From 0e9e487930b3172bcf21580fedb2adc1232eac56 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 28 Nov 2017 17:32:11 +0100 Subject: [PATCH 0001/1150] First implementation of wipe tower rotation --- xs/src/libslic3r/GCode/WipeTower.hpp | 10 ++++ xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 52 +++++++++++++++------ 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTower.hpp b/xs/src/libslic3r/GCode/WipeTower.hpp index c5fa27392c..329d92b22b 100644 --- a/xs/src/libslic3r/GCode/WipeTower.hpp +++ b/xs/src/libslic3r/GCode/WipeTower.hpp @@ -23,6 +23,16 @@ public: xy& operator-=(const xy &rhs) { x -= rhs.x; y -= rhs.y; return *this; } bool operator==(const xy &rhs) { return x == rhs.x && y == rhs.y; } bool operator!=(const xy &rhs) { return x != rhs.x || y != rhs.y; } + + // Rotate the point around given point about given angle (in degrees) + xy rotate(const xy& origin, float angle) const { + xy out(0,0); + angle *= M_PI/180.; + out.x=(x-origin.x) * cos(angle) - (y-origin.y) * sin(angle); + out.y=(x-origin.x) * sin(angle) + (y-origin.y) * cos(angle); + return out+origin; + } + float x; float y; }; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 951d71075e..5a7ee00024 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -14,6 +14,9 @@ #define strcasecmp _stricmp #endif +#define ROTATION_ANGLE 30 + + namespace Slic3r { @@ -47,6 +50,9 @@ public: Writer& set_extrusion_flow(float flow) { m_extrusion_flow = flow; return *this; } + + Writer& set_rotation(WipeTower::xy pos,float angle) + { m_wipe_tower_pos = pos; m_angle_deg = angle; return (*this); } // Suppress / resume G-code preview in Slic3r. Slic3r will have difficulty to differentiate the various // filament loading and cooling moves from normal extrusion moves. Therefore the writer @@ -67,6 +73,7 @@ public: float y() const { return m_current_pos.y; } const WipeTower::xy& start_pos() const { return m_start_pos; } const WipeTower::xy& pos() const { return m_current_pos; } + const WipeTower::xy printer_pos() const { return m_current_pos.rotate(m_wipe_tower_pos,m_angle_deg); } float elapsed_time() const { return m_elapsed_time; } // Extrude with an explicitely provided amount of extrusion. @@ -79,29 +86,43 @@ public: float dx = x - m_current_pos.x; float dy = y - m_current_pos.y; double len = sqrt(dx*dx+dy*dy); + + // For rotated wipe tower, transform position to printer coordinates + //Q zavadet nove promenne? rotace o zaporny uhel? + WipeTower::xy rotated_current_pos( m_current_pos.rotate(m_wipe_tower_pos,m_angle_deg) ); + WipeTower::xy rot( WipeTower::xy(x,y).rotate(m_wipe_tower_pos,m_angle_deg ) ); + + if (! m_preview_suppressed && e > 0.f && len > 0.) { // Width of a squished extrusion, corrected for the roundings of the squished extrusions. // This is left zero if it is a travel move. float width = float(double(e) * m_filament_area / (len * m_layer_height)); // Correct for the roundings of a squished extrusion. width += float(m_layer_height * (1. - M_PI / 4.)); - if (m_extrusions.empty() || m_extrusions.back().pos != m_current_pos) - m_extrusions.emplace_back(WipeTower::Extrusion(m_current_pos, 0, m_current_tool)); - m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(x, y), width, m_current_tool)); + if (m_extrusions.empty() || m_extrusions.back().pos != rotated_current_pos) + m_extrusions.emplace_back(WipeTower::Extrusion(rotated_current_pos, 0, m_current_tool)); + m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(rot.x, rot.y), width, m_current_tool)); } m_gcode += "G1"; - if (x != m_current_pos.x) - m_gcode += set_format_X(x); - if (y != m_current_pos.y) - m_gcode += set_format_Y(y); + if (rot.x != rotated_current_pos.x) + m_gcode += set_format_X(rot.x); + if (rot.y != rotated_current_pos.y) + m_gcode += set_format_Y(rot.y); + + // Transform current position back to wipe tower coordinates (was updated by set_format_X) + m_current_pos.x = x; + m_current_pos.y = y; if (e != 0.f) m_gcode += set_format_E(e); if (f != 0.f && f != m_current_feedrate) m_gcode += set_format_F(f); - + + + + // Update the elapsed time with a rough estimate. m_elapsed_time += ((len == 0) ? std::abs(e) : len) / m_current_feedrate * 60.f; m_gcode += "\n"; @@ -278,6 +299,8 @@ private: std::vector m_extrusions; float m_elapsed_time; const double m_filament_area = 0.25*M_PI*1.75*1.75; + float m_angle_deg = 0; + WipeTower::xy m_wipe_tower_pos; std::string set_format_X(float x) { char buf[64]; @@ -338,7 +361,7 @@ public: }; */ -} // namespace PrusaMultiMaterial +}; // namespace PrusaMultiMaterial WipeTowerPrusaMM::material_type WipeTowerPrusaMM::parse_material(const char *name) { @@ -470,7 +493,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( result.elapsed_time = writer.elapsed_time(); result.extrusions = writer.extrusions(); result.start_pos = writer.start_pos(); - result.end_pos = writer.pos(); + result.end_pos = writer.printer_pos(); return result; } @@ -525,6 +548,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) + .set_rotation(this->m_wipe_tower_pos,ROTATION_ANGLE) .append(";--------------------\n" "; CP TOOLCHANGE START\n") .comment_with_value(" toolchange #", m_num_tool_changes) @@ -605,7 +629,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo result.elapsed_time = writer.elapsed_time(); result.extrusions = writer.extrusions(); result.start_pos = writer.start_pos(); - result.end_pos = writer.pos(); + result.end_pos = writer.printer_pos(); return result; } @@ -622,6 +646,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) + .set_rotation(this->m_wipe_tower_pos,ROTATION_ANGLE) .append( ";-------------------------------------\n" "; CP WIPE TOWER FIRST LAYER BRIM START\n"); @@ -705,7 +730,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b result.elapsed_time = writer.elapsed_time(); result.extrusions = writer.extrusions(); result.start_pos = writer.start_pos(); - result.end_pos = writer.pos(); + result.end_pos = writer.printer_pos(); return result; } @@ -910,6 +935,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) + .set_rotation(this->m_wipe_tower_pos,ROTATION_ANGLE) .append(";--------------------\n" "; CP EMPTY GRID START\n") // m_num_layer_changes is incremented by set_z, so it is 1 based. @@ -1025,7 +1051,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) result.elapsed_time = writer.elapsed_time(); result.extrusions = writer.extrusions(); result.start_pos = writer.start_pos(); - result.end_pos = writer.pos(); + result.end_pos = writer.printer_pos(); return result; } From 2921302fe9602dae3974cb8bbdaea8dcb17677c4 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 30 Nov 2017 12:08:22 +0100 Subject: [PATCH 0002/1150] GUI integration of rotation angle setting --- lib/Slic3r/GUI/Plater.pm | 2 +- lib/Slic3r/GUI/Tab.pm | 3 ++- xs/src/libslic3r/GCode/WipeTower.hpp | 2 +- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 7 +++---- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 8 +++++++- xs/src/libslic3r/Print.cpp | 3 ++- xs/src/libslic3r/PrintConfig.cpp | 7 +++++++ xs/src/libslic3r/PrintConfig.hpp | 2 ++ xs/src/slic3r/GUI/Preset.cpp | 2 +- 9 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a6915bb7c2..cdb03e791b 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -52,7 +52,7 @@ sub new { bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width variable_layer_height serial_port serial_speed octoprint_host octoprint_apikey nozzle_diameter single_extruder_multi_material - wipe_tower wipe_tower_x wipe_tower_y wipe_tower_width wipe_tower_per_color_wipe extruder_colour filament_colour + wipe_tower wipe_tower_x wipe_tower_y wipe_tower_width wipe_tower_per_color_wipe wipe_tower_rotation_angle extruder_colour filament_colour )]); # C++ Slic3r::Model with Perl extensions in Slic3r/Model.pm $self->{model} = Slic3r::Model->new; diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 907be7872b..d43c33ff18 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -725,6 +725,7 @@ sub build { $optgroup->append_single_option_line('wipe_tower_y'); $optgroup->append_single_option_line('wipe_tower_width'); $optgroup->append_single_option_line('wipe_tower_per_color_wipe'); + $optgroup->append_single_option_line('wipe_tower_rotation_angle'); } { my $optgroup = $page->new_optgroup('Advanced'); @@ -1032,7 +1033,7 @@ sub _update { my $have_wipe_tower = $config->wipe_tower; $self->get_field($_)->toggle($have_wipe_tower) - for qw(wipe_tower_x wipe_tower_y wipe_tower_width wipe_tower_per_color_wipe); + for qw(wipe_tower_x wipe_tower_y wipe_tower_width wipe_tower_per_color_wipe wipe_tower_rotation_angle); $self->Thaw; } diff --git a/xs/src/libslic3r/GCode/WipeTower.hpp b/xs/src/libslic3r/GCode/WipeTower.hpp index f55fd5c2f7..8a97333de1 100644 --- a/xs/src/libslic3r/GCode/WipeTower.hpp +++ b/xs/src/libslic3r/GCode/WipeTower.hpp @@ -32,7 +32,7 @@ public: out.y=(x-origin.x) * sin(angle) + (y-origin.y) * cos(angle); return out+origin; } - + float x; float y; }; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 5a7ee00024..3df1e9d4a6 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -14,7 +14,6 @@ #define strcasecmp _stricmp #endif -#define ROTATION_ANGLE 30 namespace Slic3r @@ -548,7 +547,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) - .set_rotation(this->m_wipe_tower_pos,ROTATION_ANGLE) + .set_rotation(this->m_wipe_tower_pos,m_wipe_tower_rotation_angle) .append(";--------------------\n" "; CP TOOLCHANGE START\n") .comment_with_value(" toolchange #", m_num_tool_changes) @@ -646,7 +645,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) - .set_rotation(this->m_wipe_tower_pos,ROTATION_ANGLE) + .set_rotation(this->m_wipe_tower_pos,m_wipe_tower_rotation_angle) .append( ";-------------------------------------\n" "; CP WIPE TOWER FIRST LAYER BRIM START\n"); @@ -935,7 +934,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) - .set_rotation(this->m_wipe_tower_pos,ROTATION_ANGLE) + .set_rotation(this->m_wipe_tower_pos,m_wipe_tower_rotation_angle) .append(";--------------------\n" "; CP EMPTY GRID START\n") // m_num_layer_changes is incremented by set_z, so it is 1 based. diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 15a96d3672..fd9c55cb7a 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -8,6 +8,8 @@ #include "WipeTower.hpp" + + namespace Slic3r { @@ -39,10 +41,11 @@ public: // y -- y coordinates of wipe tower in mm ( left bottom corner ) // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm - WipeTowerPrusaMM(float x, float y, float width, float wipe_area, unsigned int initial_tool) : + WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, unsigned int initial_tool) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), m_wipe_area(wipe_area), + m_wipe_tower_rotation_angle(rotation_angle), m_z_pos(0.f), m_current_tool(initial_tool) { @@ -96,6 +99,7 @@ public: // Extrusion rate for an extrusion aka perimeter width 0.35mm. // Clamp the extrusion height to a 0.2mm layer height, independent of the nozzle diameter. // m_extrusion_flow = std::min(0.2f, layer_height) * 0.145f; + // Use a strictly m_extrusion_flow = layer_height * 0.145f; } @@ -149,6 +153,8 @@ private: float m_wipe_tower_width; // Per color Y span. float m_wipe_area; + // Wipe tower rotation angle in degrees (with respect to x axis + float m_wipe_tower_rotation_angle; // Current Z position. float m_z_pos = 0.f; // Current layer height. diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 78ebf9294f..3bd07d3eb7 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -191,6 +191,7 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_x.value), float(this->config.wipe_tower_y.value), float(this->config.wipe_tower_width.value), float(this->config.wipe_tower_per_color_wipe.value), - initial_extruder_id); + float(this->config.wipe_tower_rotation_angle.value), initial_extruder_id); //wipe_tower.set_retract(); //wipe_tower.set_zhop(); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 217f9bdef0..65ae569611 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1708,6 +1708,13 @@ PrintConfigDef::PrintConfigDef() def->cli = "wipe-tower-per-color-wipe=f"; def->default_value = new ConfigOptionFloat(15.); + def = this->add("wipe_tower_rotation_angle", coFloat); + def->label = "Wipe tower rotation angle"; + def->tooltip = "Wipe tower rotation angle with respect to x-asis "; + def->sidetext = "degrees"; + def->cli = "wipe-tower-rotation-angle=f"; + def->default_value = new ConfigOptionFloat(0.); + def = this->add("xy_size_compensation", coFloat); def->label = "XY Size Compensation"; def->category = "Advanced"; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index ab58aa3566..ea4e07dd92 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -607,6 +607,7 @@ public: ConfigOptionFloat wipe_tower_y; ConfigOptionFloat wipe_tower_width; ConfigOptionFloat wipe_tower_per_color_wipe; + ConfigOptionFloat wipe_tower_rotation_angle; ConfigOptionFloat z_offset; protected: @@ -671,6 +672,7 @@ protected: OPT_PTR(wipe_tower_y); OPT_PTR(wipe_tower_width); OPT_PTR(wipe_tower_per_color_wipe); + OPT_PTR(wipe_tower_rotation_angle); OPT_PTR(z_offset); } }; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index e4b0448cf2..2d6ff59b09 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -178,7 +178,7 @@ const std::vector& Preset::print_options() "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", - "wipe_tower_width", "wipe_tower_per_color_wipe", + "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "compatible_printers" }; return s_opts; From a733df8f375901ed3fbd0a1f0721ce5bb4c33407 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 30 Nov 2017 14:43:47 +0100 Subject: [PATCH 0003/1150] Wipe tower rotation - preview box --- lib/Slic3r/GUI/Plater/3D.pm | 2 +- xs/src/slic3r/GUI/3DScene.cpp | 10 ++++++---- xs/src/slic3r/GUI/3DScene.hpp | 4 ++-- xs/xsp/GUI_3DScene.xsp | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index 503a3d1592..2bc7dd90f9 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -198,7 +198,7 @@ sub reload_scene { $self->volumes->load_wipe_tower_preview(1000, $self->{config}->wipe_tower_x, $self->{config}->wipe_tower_y, $self->{config}->wipe_tower_width, $self->{config}->wipe_tower_per_color_wipe * ($extruders_count - 1), - $self->{model}->bounding_box->z_max, $self->UseVBOs); + $self->{model}->bounding_box->z_max, $self->{config}->wipe_tower_rotation_angle, $self->UseVBOs); } } } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 81dbcdaccc..6679b55159 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -301,17 +301,19 @@ std::vector GLVolumeCollection::load_object( int GLVolumeCollection::load_wipe_tower_preview( - int obj_idx, float pos_x, float pos_y, float width, float depth, float height, bool use_VBOs) + int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs) { float color[4] = { 1.0f, 1.0f, 0.0f, 0.5f }; this->volumes.emplace_back(new GLVolume(color)); GLVolume &v = *this->volumes.back(); auto mesh = make_cube(width, depth, height); - v.indexed_vertex_array.load_mesh_flat_shading(mesh); - v.origin = Pointf3(pos_x, pos_y, 0.); + v.origin = Pointf3(pos_x, pos_y, 0.); + Point origin = Point(pos_x,pos_y); + mesh.rotate(rotation_angle,&origin); + v.indexed_vertex_array.load_mesh_flat_shading(mesh); // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry(). v.bounding_box = v.indexed_vertex_array.bounding_box(); - v.indexed_vertex_array.finalize_geometry(use_VBOs); + v.indexed_vertex_array.finalize_geometry(use_VBOs); v.composite_id = obj_idx * 1000000; v.select_group_id = obj_idx * 1000000; v.drag_group_id = obj_idx * 1000; diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 27eeb7ca83..3649db779d 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -226,7 +226,7 @@ public: const std::string &drag_by); int load_wipe_tower_preview( - int obj_idx, float pos_x, float pos_y, float width, float depth, float height, bool use_VBOs); + int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs); // Bounding box of this volume, in unscaled coordinates. BoundingBoxf3 bounding_box; @@ -315,7 +315,7 @@ public: bool use_VBOs); int load_wipe_tower_preview( - int obj_idx, float pos_x, float pos_y, float width, float depth, float height, bool use_VBOs); + int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs); // Render the volumes by OpenGL. void render_VBOs() const; diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 13f0d42f2c..d19744f259 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -76,7 +76,7 @@ std::vector load_object(ModelObject *object, int obj_idx, std::vector 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, 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(); %}; From 55570119f7f8fe9d218d2d895e44f487b764df0a Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 30 Nov 2017 16:11:20 +0100 Subject: [PATCH 0004/1150] Correction of previous commit --- xs/src/slic3r/GUI/3DScene.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 6679b55159..bb4183bdf0 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -307,10 +307,9 @@ int GLVolumeCollection::load_wipe_tower_preview( this->volumes.emplace_back(new GLVolume(color)); GLVolume &v = *this->volumes.back(); auto mesh = make_cube(width, depth, height); - v.origin = Pointf3(pos_x, pos_y, 0.); - Point origin = Point(pos_x,pos_y); - mesh.rotate(rotation_angle,&origin); + mesh.rotate_z(rotation_angle*M_PI/180.); v.indexed_vertex_array.load_mesh_flat_shading(mesh); + v.origin = Pointf3(pos_x, pos_y, 0.); // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry(). v.bounding_box = v.indexed_vertex_array.bounding_box(); v.indexed_vertex_array.finalize_geometry(use_VBOs); From cb84a6cfceb8151ddd0d8ec647ffd87cf4c9d060 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 1 Dec 2017 11:10:01 +0100 Subject: [PATCH 0005/1150] Wipe tower rotation - bug fix (now returning start_pos correctly) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 3df1e9d4a6..cec3e0cf9c 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -70,9 +70,9 @@ public: const std::vector& extrusions() const { return m_extrusions; } float x() const { return m_current_pos.x; } float y() const { return m_current_pos.y; } - const WipeTower::xy& start_pos() const { return m_start_pos; } const WipeTower::xy& pos() const { return m_current_pos; } - const WipeTower::xy printer_pos() const { return m_current_pos.rotate(m_wipe_tower_pos,m_angle_deg); } + const WipeTower::xy start_pos_rotated() const { return m_start_pos.rotate(m_wipe_tower_pos,m_angle_deg); } + const WipeTower::xy pos_rotated() const { return m_current_pos.rotate(m_wipe_tower_pos,m_angle_deg); } float elapsed_time() const { return m_elapsed_time; } // Extrude with an explicitely provided amount of extrusion. @@ -87,7 +87,6 @@ public: double len = sqrt(dx*dx+dy*dy); // For rotated wipe tower, transform position to printer coordinates - //Q zavadet nove promenne? rotace o zaporny uhel? WipeTower::xy rotated_current_pos( m_current_pos.rotate(m_wipe_tower_pos,m_angle_deg) ); WipeTower::xy rot( WipeTower::xy(x,y).rotate(m_wipe_tower_pos,m_angle_deg ) ); @@ -491,8 +490,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( result.gcode = writer.gcode(); result.elapsed_time = writer.elapsed_time(); result.extrusions = writer.extrusions(); - result.start_pos = writer.start_pos(); - result.end_pos = writer.printer_pos(); + result.start_pos = writer.start_pos_rotated(); + result.end_pos = writer.pos_rotated(); return result; } @@ -627,8 +626,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo result.gcode = writer.gcode(); result.elapsed_time = writer.elapsed_time(); result.extrusions = writer.extrusions(); - result.start_pos = writer.start_pos(); - result.end_pos = writer.printer_pos(); + result.start_pos = writer.start_pos_rotated(); + result.end_pos = writer.pos_rotated(); return result; } @@ -728,8 +727,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b result.gcode = writer.gcode(); result.elapsed_time = writer.elapsed_time(); result.extrusions = writer.extrusions(); - result.start_pos = writer.start_pos(); - result.end_pos = writer.printer_pos(); + result.start_pos = writer.start_pos_rotated(); + result.end_pos = writer.pos_rotated(); return result; } @@ -1049,8 +1048,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) result.gcode = writer.gcode(); result.elapsed_time = writer.elapsed_time(); result.extrusions = writer.extrusions(); - result.start_pos = writer.start_pos(); - result.end_pos = writer.printer_pos(); + result.start_pos = writer.start_pos_rotated(); + result.end_pos = writer.pos_rotated(); return result; } From c34fd10e23eef14c083fcd14f55e36acda2afa84 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 5 Dec 2017 11:25:38 +0100 Subject: [PATCH 0006/1150] Wipe tower rotation around center point --- xs/src/libslic3r/GCode/WipeTower.hpp | 11 ++-- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 65 +++++++++++---------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 7 ++- xs/src/libslic3r/PrintConfig.cpp | 2 +- xs/src/slic3r/GUI/3DScene.cpp | 7 ++- 5 files changed, 52 insertions(+), 40 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTower.hpp b/xs/src/libslic3r/GCode/WipeTower.hpp index 8a97333de1..c5ce9b7278 100644 --- a/xs/src/libslic3r/GCode/WipeTower.hpp +++ b/xs/src/libslic3r/GCode/WipeTower.hpp @@ -25,12 +25,15 @@ public: bool operator!=(const xy &rhs) const { return x != rhs.x || y != rhs.y; } // Rotate the point around given point about given angle (in degrees) - xy rotate(const xy& origin, float angle) const { + // shifts the result so that point of rotation is in the middle of the tower + xy rotate(const xy& origin, float width, float depth, float angle) const { xy out(0,0); + float temp_x = x - width / 2.f; + float temp_y = y - depth / 2.f; angle *= M_PI/180.; - out.x=(x-origin.x) * cos(angle) - (y-origin.y) * sin(angle); - out.y=(x-origin.x) * sin(angle) + (y-origin.y) * cos(angle); - return out+origin; + out.x += (temp_x - origin.x) * cos(angle) - (temp_y - origin.y) * sin(angle); + out.y += (temp_x - origin.x) * sin(angle) + (temp_y - origin.y) * cos(angle); + return out + origin; } float x; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index cec3e0cf9c..de772060db 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -15,7 +15,6 @@ #endif - namespace Slic3r { @@ -50,8 +49,8 @@ public: Writer& set_extrusion_flow(float flow) { m_extrusion_flow = flow; return *this; } - Writer& set_rotation(WipeTower::xy pos,float angle) - { m_wipe_tower_pos = pos; m_angle_deg = angle; return (*this); } + Writer& set_rotation(WipeTower::xy pos,float width,float depth,float angle) + { m_wipe_tower_pos = pos; m_wipe_tower_depth = depth; m_wipe_tower_width = width; m_angle_deg = angle; return (*this); } // Suppress / resume G-code preview in Slic3r. Slic3r will have difficulty to differentiate the various // filament loading and cooling moves from normal extrusion moves. Therefore the writer @@ -71,8 +70,8 @@ public: float x() const { return m_current_pos.x; } float y() const { return m_current_pos.y; } const WipeTower::xy& pos() const { return m_current_pos; } - const WipeTower::xy start_pos_rotated() const { return m_start_pos.rotate(m_wipe_tower_pos,m_angle_deg); } - const WipeTower::xy pos_rotated() const { return m_current_pos.rotate(m_wipe_tower_pos,m_angle_deg); } + const WipeTower::xy start_pos_rotated() const { return m_start_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } + const WipeTower::xy pos_rotated() const { return m_current_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } float elapsed_time() const { return m_elapsed_time; } // Extrude with an explicitely provided amount of extrusion. @@ -87,10 +86,9 @@ public: double len = sqrt(dx*dx+dy*dy); // For rotated wipe tower, transform position to printer coordinates - WipeTower::xy rotated_current_pos( m_current_pos.rotate(m_wipe_tower_pos,m_angle_deg) ); - WipeTower::xy rot( WipeTower::xy(x,y).rotate(m_wipe_tower_pos,m_angle_deg ) ); - - + WipeTower::xy rotated_current_pos(m_current_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); + WipeTower::xy rot(WipeTower::xy(x, y).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); + if (! m_preview_suppressed && e > 0.f && len > 0.) { // Width of a squished extrusion, corrected for the roundings of the squished extrusions. // This is left zero if it is a travel move. @@ -160,7 +158,7 @@ public: m_gcode += "\n"; return *this; } - + // Derectract while moving in the X direction. // If |x| > 0, the feed rate relates to the x distance, // otherwise the feed rate relates to the e distance. @@ -299,6 +297,8 @@ private: const double m_filament_area = 0.25*M_PI*1.75*1.75; float m_angle_deg = 0; WipeTower::xy m_wipe_tower_pos; + float m_wipe_tower_width; + float m_wipe_tower_depth; std::string set_format_X(float x) { char buf[64]; @@ -543,18 +543,18 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow) - .set_z(m_z_pos) - .set_layer_height(m_layer_height) - .set_initial_tool(m_current_tool) - .set_rotation(this->m_wipe_tower_pos,m_wipe_tower_rotation_angle) - .append(";--------------------\n" - "; CP TOOLCHANGE START\n") - .comment_with_value(" toolchange #", m_num_tool_changes) - .comment_material(m_material[m_current_tool]) - .append(";--------------------\n") - .speed_override(100); + .set_z(m_z_pos) + .set_layer_height(m_layer_height) + .set_initial_tool(m_current_tool) + .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) + .append(";--------------------\n" + "; CP TOOLCHANGE START\n") + .comment_with_value(" toolchange #", m_num_tool_changes) + .comment_material(m_material[m_current_tool]) + .append(";--------------------\n") + .speed_override(100); - xy initial_position = ((m_current_shape == SHAPE_NORMAL) ? cleaning_box.ld : cleaning_box.lu) + + xy initial_position = ((m_current_shape == SHAPE_NORMAL) ? cleaning_box.ld : cleaning_box.lu) + xy(m_perimeter_width, ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width); if (purpose == PURPOSE_MOVE_TO_TOWER || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { @@ -640,11 +640,12 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow * 1.1f) - // Let the writer know the current Z position as a base for Z-hop. + // Let the writer know the current Z position as a base for Z-hop. .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) - .set_rotation(this->m_wipe_tower_pos,m_wipe_tower_rotation_angle) + .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) + //.set_offset(xy(-)) .append( ";-------------------------------------\n" "; CP WIPE TOWER FIRST LAYER BRIM START\n"); @@ -866,7 +867,7 @@ void WipeTowerPrusaMM::toolchange_Load( writer.extrude(xr, writer.y(), 1600); bool colorInit = false; size_t pass = colorInit ? 1 : 2; - float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width * 0.85f; + float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width * 0.85f; for (int i = 0; i < pass; ++ i) { writer.travel (xr, writer.y() + dy, 7200); writer.extrude(xl, writer.y(), 2200); @@ -930,14 +931,14 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow) - .set_z(m_z_pos) - .set_layer_height(m_layer_height) - .set_initial_tool(m_current_tool) - .set_rotation(this->m_wipe_tower_pos,m_wipe_tower_rotation_angle) - .append(";--------------------\n" - "; CP EMPTY GRID START\n") - // m_num_layer_changes is incremented by set_z, so it is 1 based. - .comment_with_value(" layer #", m_num_layer_changes - 1); + .set_z(m_z_pos) + .set_layer_height(m_layer_height) + .set_initial_tool(m_current_tool) + .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) + .append(";--------------------\n" + "; CP EMPTY GRID START\n") + // m_num_layer_changes is incremented by set_z, so it is 1 based. + .comment_with_value(" layer #", m_num_layer_changes - 1); // Slow down on the 1st layer. float speed_factor = m_is_first_layer ? 0.5f : 1.f; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index fd9c55cb7a..8f3e7ccaf4 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -9,7 +9,6 @@ #include "WipeTower.hpp" - namespace Slic3r { @@ -86,6 +85,9 @@ public: // Is this the last layer of the waste tower? bool is_last_layer) { + if (is_first_layer) + m_wipe_tower_depth = m_wipe_area * max_tool_changes; // tower depth (y-range) of the bottom + m_z_pos = print_z; m_layer_height = layer_height; m_max_color_changes = max_tool_changes; @@ -151,6 +153,8 @@ private: xy m_wipe_tower_pos; // Width of the wipe tower. float m_wipe_tower_width; + // Depth of the wipe tower (wipe_area * max_color_changes at the base) + float m_wipe_tower_depth; // Per color Y span. float m_wipe_area; // Wipe tower rotation angle in degrees (with respect to x axis @@ -171,6 +175,7 @@ private: float m_retract = 4.f; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_perimeter_width = 0.5f; + // Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. float m_extrusion_flow = 0.029f; diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 65ae569611..b561388fdd 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1710,7 +1710,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("wipe_tower_rotation_angle", coFloat); def->label = "Wipe tower rotation angle"; - def->tooltip = "Wipe tower rotation angle with respect to x-asis "; + def->tooltip = "Wipe tower rotation angle with respect to x-axis "; def->sidetext = "degrees"; def->cli = "wipe-tower-rotation-angle=f"; def->default_value = new ConfigOptionFloat(0.); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index bb4183bdf0..83432446a9 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -306,8 +306,11 @@ int GLVolumeCollection::load_wipe_tower_preview( float color[4] = { 1.0f, 1.0f, 0.0f, 0.5f }; this->volumes.emplace_back(new GLVolume(color)); GLVolume &v = *this->volumes.back(); - auto mesh = make_cube(width, depth, height); - mesh.rotate_z(rotation_angle*M_PI/180.); + auto mesh = make_cube(width, depth, height); + mesh.translate(-width/2.f,-depth/2.f,0.f); + Point origin_of_rotation(0.f,0.f); + mesh.rotate(rotation_angle,&origin_of_rotation); + v.indexed_vertex_array.load_mesh_flat_shading(mesh); v.origin = Pointf3(pos_x, pos_y, 0.); // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry(). From 87c67636dfecc8612dcc4825708560fc1fa57b62 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 7 Dec 2017 11:59:14 +0100 Subject: [PATCH 0007/1150] Extrusion flow calculation based on nozzle diameter etc --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 11 +++++----- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 23 +++++++++++++++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index de772060db..03a5f0b154 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -406,7 +406,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( float e_length = this->tool_change(0, false, PURPOSE_EXTRUDE).total_extrusion_length_in_plane(); // Shrink wipe_area by the amount of extrusion extruded by the finish_layer(). // Y stepping of the wipe extrusions. - float dy = m_perimeter_width * 0.8f; + float dy = m_line_width; // Number of whole wipe lines, that would be extruded to wipe as much material as the finish_layer(). // Minimum wipe area is 5mm wide. //FIXME calculate the purge_lines_width precisely. @@ -453,7 +453,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( if (last_wipe_inside_wipe_tower) { // Shrink the last wipe area to the area of the other purge areas, // remember the last initial wipe width to be purged into the 1st layer of the wipe tower. - this->m_initial_extra_wipe = std::max(0.f, wipe_area - (y_end + 0.5f * 0.85f * m_perimeter_width - cleaning_box.ld.y)); + this->m_initial_extra_wipe = std::max(0.f, wipe_area - (y_end + 0.5f * m_line_width - cleaning_box.ld.y)); cleaning_box.lu.y -= this->m_initial_extra_wipe; cleaning_box.ru.y -= this->m_initial_extra_wipe; } @@ -524,7 +524,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo } // Shrink wipe_area by the amount of extrusion extruded by the finish_layer(). // Y stepping of the wipe extrusions. - float dy = m_perimeter_width * 0.8f; + float dy = m_line_width; // Number of whole wipe lines, that would be extruded to wipe as much material as the finish_layer(). float num_lines_extruded = floor(e_length / m_wipe_tower_width); // Minimum wipe area is 5mm wide. @@ -645,7 +645,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - //.set_offset(xy(-)) .append( ";-------------------------------------\n" "; CP WIPE TOWER FIRST LAYER BRIM START\n"); @@ -867,7 +866,7 @@ void WipeTowerPrusaMM::toolchange_Load( writer.extrude(xr, writer.y(), 1600); bool colorInit = false; size_t pass = colorInit ? 1 : 2; - float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width * 0.85f; + float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_line_width; for (int i = 0; i < pass; ++ i) { writer.travel (xr, writer.y() + dy, 7200); writer.extrude(xl, writer.y(), 2200); @@ -896,7 +895,7 @@ void WipeTowerPrusaMM::toolchange_Wipe( float wipe_speed_inc = 50.f; float wipe_speed_max = 4800.f; // Y increment per wipe line. - float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width * 0.8f; + float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_line_width; for (bool p = true; // Next wipe line fits the cleaning box. ((m_current_shape == SHAPE_NORMAL) ? diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 8f3e7ccaf4..80ccb7ee9b 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -8,6 +8,18 @@ #include "WipeTower.hpp" +// Following is used to calculate extrusion flow - should be taken from config in future +constexpr float Filament_Diameter = 1.75f; // filament diameter in mm +constexpr float Nozzle_Diameter = 0.4f; // nozzle diameter in mm +// desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust +constexpr float Width_To_Nozzle_Ratio = 1.f; +// m_perimeter_width was hardcoded until now as 0.5 (for 0.4 nozzle and 0.2 layer height) +// Konst = 1.25 implies same result +constexpr float Konst = 1.25f; +constexpr float m_perimeter_width = Nozzle_Diameter * Width_To_Nozzle_Ratio * Konst; + + + namespace Slic3r { @@ -63,7 +75,7 @@ public: // _zHop - z hop value in mm void set_zhop(float zhop) { m_zhop = zhop; } - + // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp) { @@ -101,9 +113,12 @@ public: // Extrusion rate for an extrusion aka perimeter width 0.35mm. // Clamp the extrusion height to a 0.2mm layer height, independent of the nozzle diameter. // m_extrusion_flow = std::min(0.2f, layer_height) * 0.145f; - // Use a strictly - m_extrusion_flow = layer_height * 0.145f; + //m_extrusion_flow = layer_height * 0.145f; + + // Calculates extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height + m_extrusion_flow = 4.f * layer_height * ( Width_To_Nozzle_Ratio * Nozzle_Diameter - layer_height * (1-M_PI/4.f)) / + (M_PI * pow(Filament_Diameter,2.f)); } // Return the wipe tower position. @@ -174,7 +189,7 @@ private: float m_zhop = 0.5f; float m_retract = 4.f; // Width of an extrusion line, also a perimeter spacing for 100% infill. - float m_perimeter_width = 0.5f; + float m_line_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. float m_extrusion_flow = 0.029f; From b7a326a550131ba91e4b9651e45d12808d52425e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 21 Dec 2017 13:28:26 +0100 Subject: [PATCH 0008/1150] First attempts of variable wipe implementation, sparse infill modified to sawtooth --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 248 ++++++++++++++++---- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 109 +++++++-- xs/src/libslic3r/Print.cpp | 28 ++- 3 files changed, 310 insertions(+), 75 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 03a5f0b154..3890a3626e 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -49,8 +49,8 @@ public: Writer& set_extrusion_flow(float flow) { m_extrusion_flow = flow; return *this; } - Writer& set_rotation(WipeTower::xy pos,float width,float depth,float angle) - { m_wipe_tower_pos = pos; m_wipe_tower_depth = depth; m_wipe_tower_width = width; m_angle_deg = angle; return (*this); } + Writer& set_rotation(WipeTower::xy& pos, float width, float depth, float angle) + { m_wipe_tower_pos = pos; m_wipe_tower_width = width; m_wipe_tower_depth=depth; m_angle_deg = angle; return (*this); } // Suppress / resume G-code preview in Slic3r. Slic3r will have difficulty to differentiate the various // filament loading and cooling moves from normal extrusion moves. Therefore the writer @@ -87,17 +87,17 @@ public: // For rotated wipe tower, transform position to printer coordinates WipeTower::xy rotated_current_pos(m_current_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); - WipeTower::xy rot(WipeTower::xy(x, y).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); + WipeTower::xy rot(WipeTower::xy(x,y).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); if (! m_preview_suppressed && e > 0.f && len > 0.) { // Width of a squished extrusion, corrected for the roundings of the squished extrusions. // This is left zero if it is a travel move. float width = float(double(e) * m_filament_area / (len * m_layer_height)); // Correct for the roundings of a squished extrusion. - width += float(m_layer_height * (1. - M_PI / 4.)); + width += m_layer_height * float(1. - M_PI / 4.); if (m_extrusions.empty() || m_extrusions.back().pos != rotated_current_pos) m_extrusions.emplace_back(WipeTower::Extrusion(rotated_current_pos, 0, m_current_tool)); - m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(rot.x, rot.y), width, m_current_tool)); + m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(rot.x, rot.y), width, m_current_tool)); } m_gcode += "G1"; @@ -401,7 +401,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( float wipe_area = m_wipe_area; // Calculate the amount of wipe over the wipe tower brim following the prime, decrease wipe_area // with the amount of material extruded over the brim. - { + // DOESN'T MAKE SENSE NOW, wipe tower dimensions are still unknown at this point + /*{ // Simulate the brim extrusions, summ the length of the extrusion. float e_length = this->tool_change(0, false, PURPOSE_EXTRUDE).total_extrusion_length_in_plane(); // Shrink wipe_area by the amount of extrusion extruded by the finish_layer(). @@ -414,7 +415,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( wipe_area = std::max(5.f, m_wipe_area - float(floor(e_length / m_wipe_tower_width)) * dy - purge_lines_width); } - this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false); + this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false);*/ this->m_num_layer_changes = 0; this->m_current_tool = tools.front(); @@ -422,7 +423,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( // Due to the XYZ calibration, this working space may shrink slightly from all directions, // therefore the homing position is shifted inside the bed by 0.2 in the firmware to [0.2, -2.0]. // box_coordinates cleaning_box(xy(0.5f, - 1.5f), m_wipe_tower_width, wipe_area); - box_coordinates cleaning_box(xy(5.f, 0.f), m_wipe_tower_width, wipe_area); + //FIXME: set the width properly + constexpr float prime_section_width = 60.f; + box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, wipe_area); PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow) @@ -465,7 +468,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( toolchange_Unload(writer, cleaning_box, m_material[m_current_tool], m_first_layer_temperature[tools[idx_tool+1]]); // Save the y end of the non-last priming area. y_end = writer.y(); - cleaning_box.translate(m_wipe_tower_width, 0.f); + cleaning_box.translate(prime_section_width, 0.f); writer.travel(cleaning_box.ld, 7200); } ++ m_num_tool_changes; @@ -482,7 +485,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( "\n\n"); // Force m_idx_tool_change_in_layer to -1, so that tool_change() will know to extrude the wipe tower brim. - m_idx_tool_change_in_layer = (unsigned int)(-1); + ///m_idx_tool_change_in_layer = (unsigned int)(-1); + m_print_brim = true; ToolChangeResult result; result.print_z = this->m_z_pos; @@ -501,13 +505,14 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo // or there must be a nonzero wipe tower partitions available. // assert(tool < 0 || it_layer_tools->wipe_tower_partitions > 0); - if (m_idx_tool_change_in_layer == (unsigned int)(-1)) { + if ( m_print_brim ) { + ///if (m_idx_tool_change_in_layer == (unsigned int)(-1)) { // First layer, prime the extruder. return toolchange_Brim(purpose); } - - float wipe_area = m_wipe_area; - if (++ m_idx_tool_change_in_layer < (unsigned int)m_max_color_changes && last_in_layer) { + + float wipe_area = 0.f; + /*if (++ m_idx_tool_change_in_layer < (unsigned int)m_max_color_changes && last_in_layer) { // This tool_change() call will be followed by a finish_layer() call. // Try to shrink the wipe_area to save material, as less than usual wipe is required // if this step is foolowed by finish_layer() extrusions wiping the same extruder. @@ -534,11 +539,20 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo break; } } - } + }*/ + if (tool != (unsigned int)(-1)) { + for (const auto &b : m_layer_info->tool_changes) + if ( b.new_tool == tool ) + wipe_area = b.required_depth; + } + else { + // Otherwise we are going to Unload only. And m_layer_info would be invalid. + } + box_coordinates cleaning_box( m_wipe_tower_pos + xy(0.f, m_current_wipe_start_y + 0.5f * m_perimeter_width), - m_wipe_tower_width, + m_wipe_tower_width, wipe_area - m_perimeter_width); PrusaMultiMaterial::Writer writer; @@ -546,7 +560,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) - .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) + .set_rotation(m_wipe_tower_pos,m_wipe_tower_width,m_wipe_tower_depth,m_wipe_tower_rotation_angle) .append(";--------------------\n" "; CP TOOLCHANGE START\n") .comment_with_value(" toolchange #", m_num_tool_changes) @@ -636,16 +650,16 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b const box_coordinates wipeTower_box( m_wipe_tower_pos, m_wipe_tower_width, - m_wipe_area * float(m_max_color_changes) - m_perimeter_width / 2); + m_wipe_tower_depth - m_perimeter_width / 2); PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow * 1.1f) // Let the writer know the current Z position as a base for Z-hop. - .set_z(m_z_pos) - .set_layer_height(m_layer_height) - .set_initial_tool(m_current_tool) - .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - .append( + .set_z(m_z_pos) + .set_layer_height(m_layer_height) + .set_initial_tool(m_current_tool) + .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) + .append( ";-------------------------------------\n" "; CP WIPE TOWER FIRST LAYER BRIM START\n"); @@ -718,7 +732,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b ";-----------------------------------\n"); // Mark the brim as extruded. - m_idx_tool_change_in_layer = 0; + ///m_idx_tool_change_in_layer = 0; + m_print_brim = false; } ToolChangeResult result; @@ -896,11 +911,12 @@ void WipeTowerPrusaMM::toolchange_Wipe( float wipe_speed_max = 4800.f; // Y increment per wipe line. float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_line_width; + for (bool p = true; - // Next wipe line fits the cleaning box. + // Next wipe line fits the cleaning box (and not forgetting about border) ((m_current_shape == SHAPE_NORMAL) ? - (writer.y() <= cleaning_box.lu.y - m_perimeter_width) : - (writer.y() >= cleaning_box.ld.y + m_perimeter_width)); + (writer.y() <= cleaning_box.lu.y - 1.5f * m_perimeter_width) : + (writer.y() >= cleaning_box.ld.y + 1.5f * m_perimeter_width)); p = ! p) { wipe_speed = std::min(wipe_speed_max, wipe_speed + wipe_speed_inc); @@ -922,6 +938,9 @@ void WipeTowerPrusaMM::toolchange_Wipe( writer.set_extrusion_flow(m_extrusion_flow); } + + + WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) { // This should only be called if the layer is not finished yet. @@ -942,17 +961,20 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) // Slow down on the 1st layer. float speed_factor = m_is_first_layer ? 0.5f : 1.f; + float current_depth = m_wipe_tower_depth; + if (m_is_first_layer) + current_depth = m_wipe_tower_depth; + else + current_depth = m_layer_info->depth; + + box_coordinates fill_box(m_wipe_tower_pos + xy(0.f, m_current_wipe_start_y), - m_wipe_tower_width, float(m_max_color_changes) * m_wipe_area - m_current_wipe_start_y); + m_wipe_tower_width, current_depth - m_current_wipe_start_y); fill_box.expand(0.f, - 0.5f * m_perimeter_width); - { - float firstLayerOffset = 0.f; - fill_box.ld.y += firstLayerOffset; - fill_box.rd.y += firstLayerOffset; - } + if (purpose == PURPOSE_MOVE_TO_TOWER || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - if (m_idx_tool_change_in_layer == 0) { + if ( m_layer_info->tool_changes.size() == 0) { // There were no tool changes at all in this layer. writer.retract(m_retract * 1.5f, 3600) // Jump with retract to fill_box.ld + a random shift in +x. @@ -992,12 +1014,14 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) box.rd.y = box.ld.y; int nsteps = int(floor((box.lu.y - box.ld.y) / (2. * (1.0 * m_perimeter_width)))); float step = (box.lu.y - box.ld.y) / nsteps; - for (size_t i = 0; i < nsteps; ++ i) { - writer.extrude(box.ld.x, writer.y() + 0.5f * step); - writer.extrude(box.rd.x, writer.y()); - writer.extrude(box.rd.x, writer.y() + 0.5f * step); - writer.extrude(box.ld.x, writer.y()); - } + //FIXME: + if (nsteps >= 0) + for (size_t i = 0; i < nsteps; ++i) { + writer.extrude(box.ld.x, writer.y() + 0.5f * step); + writer.extrude(box.rd.x, writer.y()); + writer.extrude(box.rd.x, writer.y() + 0.5f * step); + writer.extrude(box.ld.x, writer.y()); + } } else { // Extrude a sparse infill to support the material to be printed above. @@ -1008,10 +1032,11 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) .extrude(fill_box.lu + xy(m_perimeter_width * 6, - m_perimeter_width)) .extrude(fill_box.ld + xy(m_perimeter_width * 6, m_perimeter_width)); - if (fill_box.lu.y - fill_box.ld.y > 4.f) { - // Extrude three zig-zags. - float step = (m_wipe_tower_width - m_perimeter_width * 12.f) / 12.f; - for (size_t i = 0; i < 3; ++ i) { + /*if (fill_box.lu.y - fill_box.ld.y > 4.f) { + const float max_bridge_distance = 10.f; // in mm + size_t zig_zags_num = int((m_wipe_tower_width - m_perimeter_width * 12.f) / ( max_bridge_distance * 2.f ) ) + 1 ; + float step = (m_wipe_tower_width - m_perimeter_width * 12.f) / (zig_zags_num * 4); + for (size_t i = 0; i < zig_zags_num; ++ i) { writer.extrude(writer.x() + step, fill_box.ld.y + m_perimeter_width * 8, 3200 * speed_factor); writer.extrude(writer.x() , fill_box.lu.y - m_perimeter_width * 8); writer.extrude(writer.x() + step, fill_box.lu.y - m_perimeter_width ); @@ -1020,12 +1045,42 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) writer.extrude(writer.x() + step, fill_box.ld.y + m_perimeter_width ); } } + // Extrude an inverse U at the left of the region. + writer.extrude(fill_box.ru + xy(-m_perimeter_width * 6, -m_perimeter_width), 2900 * speed_factor) + .extrude(fill_box.ru + xy(-m_perimeter_width * 3, -m_perimeter_width)) + .extrude(fill_box.rd + xy(-m_perimeter_width * 3, m_perimeter_width)) + .extrude(fill_box.rd + xy(-m_perimeter_width, m_perimeter_width));*/ + + const float dy = (fill_box.lu.y - fill_box.ld.y - 2.f * m_perimeter_width); + if (dy > m_perimeter_width) + { + const float max_bridge_distance = 10.f; // in mm + const size_t zig_zags_num = (fill_box.rd.x - fill_box.ld.x - m_perimeter_width * 12.f) / max_bridge_distance; + const float step = (fill_box.rd.x - fill_box.ld.x - m_perimeter_width * 12.f) / (float)zig_zags_num; + + float offsety = std::max(0.f, dy - m_last_infill_tan * (step - m_perimeter_width)); + if (offsety < m_last_infill_tan * m_perimeter_width + WT_EPSILON || offsety > dy / 2.f) + offsety = 0.f; + float offsetx = ( offsety != 0 ? 0 : std::max(0.f, dy / m_last_infill_tan > step / 2.f ? step - dy / m_last_infill_tan : 0.f ) ); + + for (size_t i = 0; i < zig_zags_num; ++i) + { + writer.extrude(writer.x() + offsetx, writer.y(), 3200 * speed_factor); + if ( offsety != 0 ) { + writer.extrude(writer.x() + m_perimeter_width, writer.y()); + writer.extrude(writer.x(), writer.y() + offsety); + } + writer.extrude(writer.x() + step - offsetx - (offsety==0 ? 0 : m_perimeter_width), fill_box.lu.y - m_perimeter_width); + writer.extrude(writer.x() , fill_box.ld.y + m_perimeter_width); + } + m_last_infill_tan = (dy - offsety) / (step - offsetx - (offsety==0 ? 0 : m_perimeter_width)); + } // Extrude an inverse U at the left of the region. - writer.extrude(fill_box.ru + xy(- m_perimeter_width * 6, - m_perimeter_width), 2900 * speed_factor) - .extrude(fill_box.ru + xy(- m_perimeter_width * 3, - m_perimeter_width)) - .extrude(fill_box.rd + xy(- m_perimeter_width * 3, m_perimeter_width)) - .extrude(fill_box.rd + xy(- m_perimeter_width, m_perimeter_width)); + writer.extrude(fill_box.rd + xy(-m_perimeter_width * 6, m_perimeter_width), 2900 * speed_factor) + .extrude(fill_box.rd + xy(-m_perimeter_width * 3, m_perimeter_width)) + .extrude(fill_box.ru + xy(-m_perimeter_width * 3, -m_perimeter_width)) + .extrude(fill_box.ru + xy(-m_perimeter_width, -m_perimeter_width)); } if (purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) @@ -1039,7 +1094,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) ";------------------\n\n\n\n\n\n\n"); // Indicate that this wipe tower layer is fully covered. - m_idx_tool_change_in_layer = (unsigned int)m_max_color_changes; + m_current_wipe_start_y = m_wipe_tower_depth; + ///m_idx_tool_change_in_layer = (unsigned int)m_max_color_changes; + } ToolChangeResult result; @@ -1053,4 +1110,97 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) return result; } +// Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box + +void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool) +{ + assert(m_plan.back().z <= z_par); // refuse to add a layer below the last one + + // volumes in mm^3 required for ramming + // hardcoded so far, in future should be calculated by integrating the speed/time curve + const std::vector ram_volumes = {22,22,22,22}; + + // volumes in mm^3 required for wipe: {{from 0 to ...},{from 1 to ...},{from 2 to ...},{from 3 to ...}}, usage [from][to] + const std::vector> wipe_volumes = {{ 0, 40, 60, 80}, + {100, 0,120,100}, + { 80,107, 0,110}, + { 60, 40, 60, 0}}; + + float depth = (wipe_volumes[old_tool][new_tool]) / (m_extrusion_flow * Filament_Area); // length of extrusion + depth = floor(depth / m_wipe_tower_width + 1); // number of lines to extrude + depth += 6; // reserved for ramming + depth += 2; // reserved for loading + depth -= 2; // we will also print borders + depth *= m_perimeter_width; // conversion to distance + + if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan along with the first toolchange + m_plan.push_back(WipeTowerInfo(z_par, layer_height_par)); + + if ( old_tool != new_tool ) { + if (!m_plan_brim_finished) { // this toolchange prints brim, we need it in m_plan, but not to count its depth + m_plan_brim_finished = true; + depth = 0.f; + } + m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth)); + } + + + + // Calculate m_wipe_tower (maximum depth for all the layers) and propagate depths downwards + // Could be only called when a layer is changed, but do not forget about the last one + float this_layer_depth = m_plan.back().toolchanges_depth(); + m_plan.back().depth = this_layer_depth; + + if (this_layer_depth > m_wipe_tower_depth) + m_wipe_tower_depth = this_layer_depth; + for (int i = m_plan.size() - 2; i >= 0 && m_plan[i].depth < this_layer_depth; i-- ) { + if ( this_layer_depth - m_plan[i].depth < min_layer_difference && !m_plan[i].tool_changes.empty()) + m_plan[i].tool_changes.back().required_depth += this_layer_depth - m_plan[i].depth; + m_plan[i].depth = this_layer_depth; + } +} + + +// Processes vector m_plan and calls respective function to generate G-code for the wipe tower +// Resulting ToolChangeResults are appended into container passed by "result" reference +void WipeTowerPrusaMM::generate(std::vector> &result) +{ + std::vector layer_result; + + for (auto layer : m_plan) + { + + set_layer(layer.z,layer.height,0,layer.z == m_plan.front().z,layer.z == m_plan.back().z); + + for (const auto &toolchange : layer.tool_changes) + layer_result.emplace_back(tool_change(toolchange.new_tool, false, WipeTower::PURPOSE_EXTRUDE)); + + if (! layer_finished()) { + layer_result.emplace_back(finish_layer(WipeTower::PURPOSE_EXTRUDE)); + if (layer_result.size() > 1) { + // Merge the two last tool changes into one. + WipeTower::ToolChangeResult &tc1 = layer_result[layer_result.size() - 2]; + WipeTower::ToolChangeResult &tc2 = layer_result.back(); + if (tc1.end_pos != tc2.start_pos) { + // Add a travel move from tc1.end_pos to tc2.start_pos. + char buf[2048]; + sprintf(buf, "G1 X%.3f Y%.3f F7200\n", tc2.start_pos.x, tc2.start_pos.y); + tc1.gcode += buf; + } + tc1.gcode += tc2.gcode; + tc1.extrusions.insert(tc1.extrusions.end(), tc2.extrusions.begin(), tc2.extrusions.end()); + tc1.end_pos = tc2.end_pos; + layer_result.pop_back(); + } + } + else + m_last_infill_tan = 1000.f; //if the layer was dense, no worries about infill continuity on the next + + result.emplace_back(std::move(layer_result)); + m_is_first_layer = false; + } +} + + + }; // namespace Slic3r diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 80ccb7ee9b..275b2f2374 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -9,15 +9,19 @@ #include "WipeTower.hpp" // Following is used to calculate extrusion flow - should be taken from config in future -constexpr float Filament_Diameter = 1.75f; // filament diameter in mm +constexpr float Filament_Area = M_PI * 1.75f * 1.75f / 4.f; // filament diameter in mm constexpr float Nozzle_Diameter = 0.4f; // nozzle diameter in mm // desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust constexpr float Width_To_Nozzle_Ratio = 1.f; // m_perimeter_width was hardcoded until now as 0.5 (for 0.4 nozzle and 0.2 layer height) // Konst = 1.25 implies same result constexpr float Konst = 1.25f; + +// m_perimeter_width is used in plan_toolchange - take care of proper initialization value when changing to variable constexpr float m_perimeter_width = Nozzle_Diameter * Width_To_Nozzle_Ratio * Konst; +constexpr float WT_EPSILON = 1e-3f; +constexpr float min_layer_difference = 2.f; @@ -75,7 +79,8 @@ public: // _zHop - z hop value in mm void set_zhop(float zhop) { m_zhop = zhop; } - + + // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp) { @@ -84,32 +89,39 @@ public: m_first_layer_temperature[idx] = first_layer_temp; } + + // Setter for internal structure m_plan containing info about the future wipe tower + // to be used before building begins. The entries must be added ordered in z. + void plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool); + + void generate(std::vector> &result); + // Switch to a next layer. virtual void set_layer( // Print height of this layer. - float print_z, - // Layer height, used to calculate extrusion the rate. - float layer_height, + float print_z, + // Layer height, used to calculate extrusion the rate. + float layer_height, // Maximum number of tool changes on this layer or the layers below. - size_t max_tool_changes, + size_t max_tool_changes, // Is this the first layer of the print? In that case print the brim first. - bool is_first_layer, + bool is_first_layer, // Is this the last layer of the waste tower? - bool is_last_layer) + bool is_last_layer) { - if (is_first_layer) - m_wipe_tower_depth = m_wipe_area * max_tool_changes; // tower depth (y-range) of the bottom - m_z_pos = print_z; m_layer_height = layer_height; - m_max_color_changes = max_tool_changes; m_is_first_layer = is_first_layer; - m_is_last_layer = is_last_layer; // Start counting the color changes from zero. Special case: -1 - extrude a brim first. - m_idx_tool_change_in_layer = is_first_layer ? (unsigned int)(-1) : 0; + ///m_idx_tool_change_in_layer = is_first_layer ? (unsigned int)(-1) : 0; + m_print_brim = is_first_layer; m_current_wipe_start_y = 0.f; m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL; ++ m_num_layer_changes; + + + ///m_max_color_changes = max_tool_changes; + ///m_is_last_layer = is_last_layer; // Extrusion rate for an extrusion aka perimeter width 0.35mm. // Clamp the extrusion height to a 0.2mm layer height, independent of the nozzle diameter. // m_extrusion_flow = std::min(0.2f, layer_height) * 0.145f; @@ -117,8 +129,14 @@ public: //m_extrusion_flow = layer_height * 0.145f; // Calculates extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height - m_extrusion_flow = 4.f * layer_height * ( Width_To_Nozzle_Ratio * Nozzle_Diameter - layer_height * (1-M_PI/4.f)) / - (M_PI * pow(Filament_Diameter,2.f)); + m_extrusion_flow = extrusion_flow(layer_height); + + m_layer_info = nullptr; + for (auto &a : m_plan) + if ( a.z > print_z - WT_EPSILON && a.z < print_z + WT_EPSILON ) { + m_layer_info = &a; + break; + } } // Return the wipe tower position. @@ -151,8 +169,15 @@ public: // Is the current layer finished? A layer is finished if either the wipe tower is finished, or // the wipe tower has been completely covered by the tool change extrusions, // or the rest of the tower has been filled by a sparse infill with the finish_layer() method. - virtual bool layer_finished() const - { return m_idx_tool_change_in_layer == m_max_color_changes; } + virtual bool layer_finished() const { + + if (m_is_first_layer) { + return (m_wipe_tower_depth - WT_EPSILON < m_current_wipe_start_y); + } + else + return (m_layer_info->depth - WT_EPSILON < m_current_wipe_start_y); + } + private: WipeTowerPrusaMM(); @@ -169,7 +194,7 @@ private: // Width of the wipe tower. float m_wipe_tower_width; // Depth of the wipe tower (wipe_area * max_color_changes at the base) - float m_wipe_tower_depth; + float m_wipe_tower_depth = 0.f; // Per color Y span. float m_wipe_area; // Wipe tower rotation angle in degrees (with respect to x axis @@ -205,7 +230,8 @@ private: // Tool change change counter for the output statistics. unsigned int m_num_tool_changes = 0; // Layer change counter in this layer. Counting up to m_max_color_changes. - unsigned int m_idx_tool_change_in_layer = 0; + ///unsigned int m_idx_tool_change_in_layer = 0; + bool m_print_brim = true; // A fill-in direction (positive Y, negative Y) alternates with each layer. wipe_shape m_current_shape = SHAPE_NORMAL; unsigned int m_current_tool = 0; @@ -214,7 +240,18 @@ private: // How much to wipe the 1st extruder over the wipe tower at the 1st layer // after the wipe tower brim has been extruded? float m_initial_extra_wipe = 0.f; + float m_last_infill_tan = 1000.f; // impossibly high value + bool m_plan_brim_finished = false; + float + extrusion_flow(float layer_height = -1.f) + { + if ( layer_height < 0 ) + return m_extrusion_flow; + return layer_height * ( Width_To_Nozzle_Ratio * Nozzle_Diameter - layer_height * (1-M_PI/4.f)) / (Filament_Area); + } + + struct box_coordinates { box_coordinates(float left, float bottom, float width, float height) : @@ -246,8 +283,34 @@ private: xy rd; // right lower }; + + // to store information about tool changes for a given layer + struct WipeTowerInfo{ + struct ToolChange { + unsigned int old_tool; + unsigned int new_tool; + float required_depth; + ToolChange(unsigned int old,unsigned int newtool,float depth) : old_tool{old}, new_tool{newtool}, required_depth{depth} {} + }; + float z; // z position of the layer + float height; // layer height + float depth; // depth of the layer based on all layers above + float toolchanges_depth() const { float sum = 0.f; for (const auto &a : tool_changes) sum += a.required_depth; return sum; } + + std::vector tool_changes; + + WipeTowerInfo(float z_par, float layer_height_par) + : z{z_par}, height{layer_height_par} { } + }; + + // Stores information about all layers and toolchanges for the future wipe tower (filled by plan_toolchange(...)) + std::vector m_plan; + + WipeTowerInfo* m_layer_info; + + // Returns gcode for wipe tower brim - // sideOnly -- set to false -- experimental, draw brim on sides of wipe tower + // sideOnly -- set to false -- experimental, draw brim on sides of wipe tower // offset -- set to 0 -- experimental, offset to replace brim in front / rear of wipe tower ToolChangeResult toolchange_Brim(Purpose purpose, bool sideOnly = false, float y_offset = 0.f); @@ -269,9 +332,7 @@ private: void toolchange_Wipe( PrusaMultiMaterial::Writer &writer, const box_coordinates &cleaning_box, - bool skip_initial_y_move); - - void toolchange_Perimeter(); + bool skip_initial_y_move); }; }; // namespace Slic3r diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 3bd07d3eb7..cfc26eeac6 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -1005,9 +1005,33 @@ void Print::_make_wipe_tower() m_wipe_tower_priming = Slic3r::make_unique( wipe_tower.prime(this->skirt_first_layer_height(), m_tool_ordering.all_extruders(), ! last_priming_wipe_full, WipeTower::PURPOSE_EXTRUDE)); + + // Lets go through the wipe tower layers and determine pairs of extruder changes for each + // to pass to wipe_tower (so that it can use it for planning the layout of the tower) + { + unsigned int current_extruder_id = initial_extruder_id; + for (const auto &layer_tools : m_tool_ordering.layer_tools()) { // for all layers + if (!layer_tools.has_wipe_tower) continue; + bool first_layer = &layer_tools == &m_tool_ordering.front(); + wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, current_extruder_id); + for (const auto extruder_id : layer_tools.extruders) { + if ((first_layer && extruder_id == initial_extruder_id) || extruder_id != current_extruder_id) { + wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, extruder_id); + current_extruder_id = extruder_id; + } + } + if (&layer_tools == &m_tool_ordering.back() || (&layer_tools + 1)->wipe_tower_partitions == 0) + break; + } + } + + + // Generate the wipe tower layers. m_wipe_tower_tool_changes.reserve(m_tool_ordering.layer_tools().size()); - unsigned int current_extruder_id = initial_extruder_id; + wipe_tower.generate(m_wipe_tower_tool_changes); + + /*unsigned int current_extruder_id = initial_extruder_id; for (const ToolOrdering::LayerTools &layer_tools : m_tool_ordering.layer_tools()) { if (! layer_tools.has_wipe_tower) // This is a support only layer, or the wipe tower does not reach to this height. @@ -1047,7 +1071,7 @@ void Print::_make_wipe_tower() m_wipe_tower_tool_changes.emplace_back(std::move(tool_changes)); if (last_layer) break; - } + }*/ // Unload the current filament over the purge tower. coordf_t layer_height = this->objects.front()->config.layer_height.value; From c6718c94bf4cca861fd22fdf854e2103a5779324 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 21 Dec 2017 14:24:47 +0100 Subject: [PATCH 0009/1150] Merge fix --- xs/src/libslic3r/Print.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 3cb2e481b2..8b7f9805c9 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -1044,14 +1044,15 @@ void Print::_make_wipe_tower() // Lets go through the wipe tower layers and determine pairs of extruder changes for each // to pass to wipe_tower (so that it can use it for planning the layout of the tower) + { - unsigned int current_extruder_id = initial_extruder_id; + unsigned int current_extruder_id = m_tool_ordering.all_extruders().back(); for (const auto &layer_tools : m_tool_ordering.layer_tools()) { // for all layers if (!layer_tools.has_wipe_tower) continue; bool first_layer = &layer_tools == &m_tool_ordering.front(); wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, current_extruder_id); for (const auto extruder_id : layer_tools.extruders) { - if ((first_layer && extruder_id == initial_extruder_id) || extruder_id != current_extruder_id) { + if ((first_layer && extruder_id == m_tool_ordering.all_extruders().back()) || extruder_id != current_extruder_id) { wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, extruder_id); current_extruder_id = extruder_id; } @@ -1069,7 +1070,7 @@ void Print::_make_wipe_tower() wipe_tower.generate(m_wipe_tower_tool_changes); // Set current_extruder_id to the last extruder primed. - unsigned int current_extruder_id = m_tool_ordering.all_extruders().back(); + /*unsigned int current_extruder_id = m_tool_ordering.all_extruders().back(); for (const ToolOrdering::LayerTools &layer_tools : m_tool_ordering.layer_tools()) { if (! layer_tools.has_wipe_tower) From 180967484e15d529a132a59f2ac760354cf87298 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 22 Dec 2017 11:26:43 +0100 Subject: [PATCH 0010/1150] Correction of wipe tower brim generation --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 42 +++++++++++++++------ xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 14 ++----- xs/src/libslic3r/Print.cpp | 7 ++-- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 0b3a023a41..e51b434301 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -92,7 +92,7 @@ public: if (! m_preview_suppressed && e > 0.f && len > 0.) { // Width of a squished extrusion, corrected for the roundings of the squished extrusions. // This is left zero if it is a travel move. - float width = float(double(e) * m_filament_area / (len * m_layer_height)); + float width = float(double(e) * Filament_Area / (len * m_layer_height)); // Correct for the roundings of a squished extrusion. width += m_layer_height * float(1. - M_PI / 4.); if (m_extrusions.empty() || m_extrusions.back().pos != rotated_current_pos) @@ -258,6 +258,25 @@ public: return *this; }; + + Writer& set_fan(unsigned int speed) + { + if (speed == m_last_fan_speed) + return *this; + + if (speed == 0) + m_gcode += "M107\n"; + else + { + m_gcode += "M106 S"; + char buf[128]; + sprintf(buf,"%u\n",(unsigned int)(255.0 * speed / 100.0)); + m_gcode += buf; + } + m_last_fan_speed = speed; + return *this; + } + Writer& comment_material(WipeTowerPrusaMM::material_type material) { m_gcode += "; material : "; @@ -294,13 +313,15 @@ private: std::string m_gcode; std::vector m_extrusions; float m_elapsed_time; - const double m_filament_area = 0.25*M_PI*1.75*1.75; float m_angle_deg = 0; WipeTower::xy m_wipe_tower_pos; float m_wipe_tower_width; float m_wipe_tower_depth; + float m_last_fan_speed = 0.f; - std::string set_format_X(float x) { + std::string + set_format_X(float x) + { char buf[64]; sprintf(buf, " X%.3f", x); m_current_pos.x = x; @@ -1116,7 +1137,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) // Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box -void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool) +void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool,bool brim) { assert(m_plan.back().z <= z_par); // refuse to add a layer below the last one @@ -1131,20 +1152,18 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi { 60, 40, 60, 0}}; float depth = (wipe_volumes[old_tool][new_tool]) / (m_extrusion_flow * Filament_Area); // length of extrusion + depth += 6 * 59; // reserved for ramming + depth += 2 * 59; // reserved for loading + depth -= 2 * 59; // we will also print borders depth = floor(depth / m_wipe_tower_width + 1); // number of lines to extrude - depth += 6; // reserved for ramming - depth += 2; // reserved for loading - depth -= 2; // we will also print borders depth *= m_perimeter_width; // conversion to distance if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan along with the first toolchange m_plan.push_back(WipeTowerInfo(z_par, layer_height_par)); - if ( old_tool != new_tool ) { - if (!m_plan_brim_finished) { // this toolchange prints brim, we need it in m_plan, but not to count its depth - m_plan_brim_finished = true; + if ( brim || old_tool != new_tool ) { + if (brim) // this toolchange prints brim, we need it in m_plan, but not to count its depth depth = 0.f; - } m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth)); } @@ -1173,7 +1192,6 @@ void WipeTowerPrusaMM::generate(std::vector> &result); @@ -131,6 +131,7 @@ public: // Calculates extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height m_extrusion_flow = extrusion_flow(layer_height); + // FIXME - ideally get rid of set_layer altogether and iterate through m_plan in generate(...) m_layer_info = nullptr; for (auto &a : m_plan) if ( a.z > print_z - WT_EPSILON && a.z < print_z + WT_EPSILON ) { @@ -170,12 +171,7 @@ public: // the wipe tower has been completely covered by the tool change extrusions, // or the rest of the tower has been filled by a sparse infill with the finish_layer() method. virtual bool layer_finished() const { - - if (m_is_first_layer) { - return (m_wipe_tower_depth - WT_EPSILON < m_current_wipe_start_y); - } - else - return (m_layer_info->depth - WT_EPSILON < m_current_wipe_start_y); + return ( (m_is_first_layer ? m_wipe_tower_depth : m_layer_info->depth) - WT_EPSILON < m_current_wipe_start_y); } @@ -241,10 +237,8 @@ private: // after the wipe tower brim has been extruded? float m_initial_extra_wipe = 0.f; float m_last_infill_tan = 1000.f; // impossibly high value - bool m_plan_brim_finished = false; - float - extrusion_flow(float layer_height = -1.f) + float extrusion_flow(float layer_height = -1.f) const { if ( layer_height < 0 ) return m_extrusion_flow; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 8b7f9805c9..64f4d60462 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -1050,10 +1050,10 @@ void Print::_make_wipe_tower() for (const auto &layer_tools : m_tool_ordering.layer_tools()) { // for all layers if (!layer_tools.has_wipe_tower) continue; bool first_layer = &layer_tools == &m_tool_ordering.front(); - wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, current_extruder_id); + wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, current_extruder_id,false); for (const auto extruder_id : layer_tools.extruders) { - if ((first_layer && extruder_id == m_tool_ordering.all_extruders().back()) || extruder_id != current_extruder_id) { - wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, extruder_id); + if ((first_layer && extruder_id == m_tool_ordering.all_extruders().back()) || extruder_id != current_extruder_id) { + wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, extruder_id, first_layer && extruder_id == m_tool_ordering.all_extruders().back()); current_extruder_id = extruder_id; } } @@ -1066,7 +1066,6 @@ void Print::_make_wipe_tower() // Generate the wipe tower layers. m_wipe_tower_tool_changes.reserve(m_tool_ordering.layer_tools().size()); - wipe_tower.generate(m_wipe_tower_tool_changes); // Set current_extruder_id to the last extruder primed. From 37bbeeb9d0db258dd0d4a7cf95dd723579e12a3f Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 4 Jan 2018 12:03:06 +0100 Subject: [PATCH 0011/1150] Parametrization of ramming and loading sequence - first steps --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 190 +++++++++++++++----- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 1 + 2 files changed, 142 insertions(+), 49 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index e51b434301..ce9b8883aa 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -15,6 +15,14 @@ #endif +// experimental: ramming speed (mm^3/s) sampled in 0.25s intervals (one filament so far) +const std::vector ramming_speed = {7.6, 7.6, 7.6, 7.6, 9.0, 9.0, 9.0, 10.7, 10.7, 10.7}; +// experimental: time requested for cooling in seconds (common for all materials so far) +const float cooling_time = 14; // PVA: 20; SCAFF: 17 +const float loading_volume = 20; + + + namespace Slic3r { @@ -562,6 +570,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo } }*/ + // Finds this toolchange info if (tool != (unsigned int)(-1)) { for (const auto &b : m_layer_info->tool_changes) if ( b.new_tool == tool ) @@ -779,15 +788,51 @@ void WipeTowerPrusaMM::toolchange_Unload( { float xl = cleaning_box.ld.x + 0.5f * m_perimeter_width; float xr = cleaning_box.rd.x - 0.5f * m_perimeter_width; - float y_step = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width; - + writer.append("; CP TOOLCHANGE UNLOAD\n"); - + // Ram the hot material out of the extruder melt zone. // Current extruder position is on the left, one perimeter inside the cleaning box in both X and Y. - float e0 = m_perimeter_width * m_extrusion_flow; - float e = (xr - xl) * m_extrusion_flow; - switch (current_material) + //float e0 = m_perimeter_width * m_extrusion_flow; + //float e = (xr - xl) * m_extrusion_flow; + //float y_step = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width * ramming_step_multiplicator; + + constexpr float ramming_step_multiplicator = 1.f; // extra spacing needed for some materials + const float line_width = m_line_width * 1.5f; // desired ramming line thickness + + float y_step = (m_current_shape == SHAPE_NORMAL ? 1.f : -1.f) * // spacing between lines in mm + line_width * ramming_step_multiplicator; + + + int i = 0; // iterates through ramming_speed + m_left_to_right = true; // current direction of ramming + float remaining = xr - xl - 2 * m_perimeter_width; // keeps track of distance to the next turnaround + float e_done = 0; // measures E move done from each segment + + writer.travel(xl + m_perimeter_width, writer.y() + y_step * 0.2); // move to starting position + + while (i < ramming_speed.size()) { + const float x = (ramming_speed[i] * 0.25f) / // extrusion length to get desired line_width + (m_layer_height * (line_width - m_layer_height * (1. - M_PI / 4.))); + const float e = ramming_speed[i] * 0.25f / Filament_Area; // transform volume per sec to E move; + const float dist = std::min(x - e_done, remaining); // distance to travel for the next 0.25s + writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), std::hypot(dist, e * (dist / x)) / (0.25 / 60.)); + remaining -= dist; + + if ( remaining < WT_EPSILON ) { // we reached a turning point + writer.travel(writer.x(), writer.y() + y_step); + m_left_to_right = !m_left_to_right; + remaining = xr - xl - 2 * m_perimeter_width; + } + e_done += dist; // subtract what was actually transversed + if (e_done > x - WT_EPSILON) { // current segment finished + ++i; + e_done = 0; + } + } + + + /*switch (current_material) { case ABS: // ramming start end y increment amount feedrate @@ -803,7 +848,7 @@ void WipeTowerPrusaMM::toolchange_Unload( .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 1.5f, 0, 1.75f * e, 4800) .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 1.5f, 0, 1.75f * e, 5000); break; - case SCAFF: + case PET: //!!! SCAFF (PET only used for testing): writer.ram(xl + m_perimeter_width * 2, xr - m_perimeter_width, y_step * 2.f, 0, 1.75f * e, 4000) .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 3.f, 0, 2.34f * e, 4600) .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 3.f, 0, 2.63f * e, 5200); @@ -814,7 +859,7 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.ram(xl + m_perimeter_width * 2, xr - m_perimeter_width, y_step * 0.2f, 0, 1.60f * e, 4000) .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 1.2f, e0, 1.65f * e, 4600) .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 1.2f, e0, 1.74f * e, 5200); - } + }*/ // Pull the filament end into a cooling tube. writer.retract(15, 5000).retract(50, 5400).retract(15, 3000).retract(12, 2000); @@ -827,9 +872,45 @@ void WipeTowerPrusaMM::toolchange_Unload( if (std::abs(writer.x() - xl) < std::abs(writer.x() - xr)) std::swap(xl, xr); // Horizontal cooling moves will be performed at the following Y coordinate: - writer.travel(xr, writer.y() + y_step * 0.8f, 7200) + /*writer.travel(xr, writer.y() + y_step * 0.8f, 7200) + .suppress_preview();*/ + + /*constexpr float min_cool_speed = 1600; + constexpr float max_cool_speed = 2400; + + const int num_of_intervals = 4; + + writer.travel(writer.x(), writer.y() + y_step) + .retract(-3,min_cool_speed) .suppress_preview(); - switch (current_material) + + int filament_direction = -1; // retract first + float cool_speed = min_cool_speed; + // Numbers 12 (24) below fix velocity in E to 12 times less than in X (total move in X assumed to be >> move in E) + + for (int counter=0 ; counter < num_of_intervals ; ++counter) { + float needed_e_move = cool_speed * (cooling_time / num_of_intervals) / 12.f; // distance yet to move in E axis + do { + remaining = ( left_to_right ? xr-m_perimeter_width-writer.x() : -xl-m_perimeter_width+writer.x()); // distance to the turning point + float xmove = std::min( std::fabs(needed_e_move) * 12.f, remaining * 2.f); // distance to travel + printf("posun z %f na %f",writer.x(),writer.x()+xmove / 2.f * (left_to_right ? 1 : -1)); + writer.cool(writer.x() + xmove / 2.f * (left_to_right ? 1 : -1), writer.x(), filament_direction * xmove / 24.f, filament_direction * xmove / 24.f, cool_speed); + printf(", E %f, rychlost %f\n\n",filament_direction * xmove /12.f,cool_speed); + needed_e_move -= xmove/12.f; + if (needed_e_move > WT_EPSILON) + filament_direction *= -1; + else + left_to_right = !left_to_right; + + } while (needed_e_move > WT_EPSILON); + if (filament_direction==-1) + cool_speed += (max_cool_speed - min_cool_speed) / num_of_intervals; + } + + writer.retract(3, max_cool_speed);*/ + + + /*switch (current_material) { case PVA: writer.cool(xl, xr, 3, -5, 1600) @@ -851,7 +932,7 @@ void WipeTowerPrusaMM::toolchange_Unload( .cool(xl, xr, 5, -5, 2000) .cool(xl, xr, 5, -5, 2400) .cool(xl, xr, 5, -3, 2400); - } + }*/ writer.resume_preview() .flush_planner_queue(); @@ -881,13 +962,13 @@ void WipeTowerPrusaMM::toolchange_Load( PrusaMultiMaterial::Writer &writer, const box_coordinates &cleaning_box) { - float xl = cleaning_box.ld.x + m_perimeter_width; - float xr = cleaning_box.rd.x - m_perimeter_width; + float xl = cleaning_box.ld.x + m_perimeter_width * 0.75f; + float xr = cleaning_box.rd.x - m_perimeter_width * 0.75f; //FIXME flipping left / right side, so that the following toolchange_Wipe will start // where toolchange_Load ends. - std::swap(xl, xr); + //std::swap(xl, xr); - writer.append("; CP TOOLCHANGE LOAD\n") + /*writer.append("; CP TOOLCHANGE LOAD\n") // Load the filament while moving left / right, // so the excess material will not create a blob at a single position. .suppress_preview() @@ -899,9 +980,9 @@ void WipeTowerPrusaMM::toolchange_Load( .load_move_x(xr, 20, 1600) .load_move_x(xl, 10, 1000) .resume_preview(); - +*/ // Extrude first five lines (just three lines if colorInit is set). - writer.extrude(xr, writer.y(), 1600); + /*writer.extrude(xr, writer.y(), 1600); bool colorInit = false; size_t pass = colorInit ? 1 : 2; float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_line_width; @@ -910,12 +991,31 @@ void WipeTowerPrusaMM::toolchange_Load( writer.extrude(xl, writer.y(), 2200); writer.travel (xl, writer.y() + dy, 7200); writer.extrude(xr, writer.y(), 2200); + }*/ + + float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_line_width; + float x = (loading_volume) / (Filament_Area * m_extrusion_flow); // extrusion length to extrude desired volume + while (x > WT_EPSILON) { + float remaining = (m_left_to_right ? xr - writer.x() : writer.x() - xl ); + float dist = std::min(x, remaining); + writer.extrude(writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, writer.y(), 2200); + x -= dist; + + if (x > WT_EPSILON) { // don't switch it for the last (unfinished) line + m_left_to_right = !m_left_to_right; + writer.travel(writer.x(), writer.y() + dy, 7200); + } + else // advance just a fraction for debugging (to see where the load ends) (FIXME - HAS to be deleted, can pass the edge) + writer.travel(writer.x()+(m_left_to_right ? 0.1f : -0.1f),writer.y()); } // Reset the extruder current to the normal value. writer.set_extruder_trimpot(550); } + + + // Wipe the newly loaded filament until the end of the assigned wipe area. void WipeTowerPrusaMM::toolchange_Wipe( PrusaMultiMaterial::Writer &writer, @@ -926,8 +1026,8 @@ void WipeTowerPrusaMM::toolchange_Wipe( writer.set_extrusion_flow(m_extrusion_flow * (m_is_first_layer ? 1.18f : 1.f)) .append("; CP TOOLCHANGE WIPE\n"); float wipe_coeff = m_is_first_layer ? 0.5f : 1.f; - float xl = cleaning_box.ld.x + 2.f * m_perimeter_width; - float xr = cleaning_box.rd.x - 2.f * m_perimeter_width; + const float& xl = cleaning_box.ld.x; // + 2.f * m_perimeter_width; + const float& xr = cleaning_box.rd.x; // - 2.f * m_perimeter_width; // Wipe speed will increase up to 4800. float wipe_speed = 4200.f; float wipe_speed_inc = 50.f; @@ -935,27 +1035,22 @@ void WipeTowerPrusaMM::toolchange_Wipe( // Y increment per wipe line. float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_line_width; - for (bool p = true; - // Next wipe line fits the cleaning box (and not forgetting about border) - ((m_current_shape == SHAPE_NORMAL) ? - (writer.y() <= cleaning_box.lu.y - 1.5f * m_perimeter_width) : - (writer.y() >= cleaning_box.ld.y + 1.5f * m_perimeter_width)); - p = ! p) + for ( int i = 0 ; true ; ++i ) { wipe_speed = std::min(wipe_speed_max, wipe_speed + wipe_speed_inc); - if (skip_initial_y_move) - skip_initial_y_move = false; + if (m_left_to_right) + writer.extrude(xr - (i % 4 == 0 ? 0 : m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); else - writer.extrude(xl - (p ? m_perimeter_width / 2 : m_perimeter_width), writer.y() + dy, wipe_speed * wipe_coeff); - writer.extrude(xr + (p ? m_perimeter_width : m_perimeter_width * 2), writer.y(), wipe_speed * wipe_coeff); - // Next wipe line fits the cleaning box. - if ((m_current_shape == SHAPE_NORMAL) ? - (writer.y() > cleaning_box.lu.y - m_perimeter_width) : - (writer.y() < cleaning_box.ld.y + m_perimeter_width)) + writer.extrude(xl + (i % 4 == 1 ? 0 : m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); + + if ((m_current_shape == SHAPE_NORMAL) ? // in case next line would not fit + (writer.y() > cleaning_box.lu.y - m_perimeter_width * 1.5f) : + (writer.y() < cleaning_box.ld.y + m_perimeter_width * 1.5f)) break; - wipe_speed = std::min(wipe_speed_max, wipe_speed + wipe_speed_inc); - writer.extrude(xr + m_perimeter_width, writer.y() + dy, wipe_speed * wipe_coeff); - writer.extrude(xl - m_perimeter_width, writer.y()); + + // stepping to the next line: + writer.extrude(writer.x() + (i % 4 == 0 ? -1.f : (i % 4 == 1 ? 1.f : 0.f)) * m_perimeter_width, writer.y() + dy); + m_left_to_right = !m_left_to_right; } // Reset the extrusion flow. writer.set_extrusion_flow(m_extrusion_flow); @@ -1081,10 +1176,11 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) const size_t zig_zags_num = (fill_box.rd.x - fill_box.ld.x - m_perimeter_width * 12.f) / max_bridge_distance; const float step = (fill_box.rd.x - fill_box.ld.x - m_perimeter_width * 12.f) / (float)zig_zags_num; - float offsety = std::max(0.f, dy - m_last_infill_tan * (step - m_perimeter_width)); + float offsetx = std::max(0.f, dy / m_last_infill_tan > step / 2.f ? step - dy / m_last_infill_tan : 0.f); + float offsety = ( offsetx != 0 ? 0 : std::max(0.f, dy - m_last_infill_tan * (step - m_perimeter_width)) ); if (offsety < m_last_infill_tan * m_perimeter_width + WT_EPSILON || offsety > dy / 2.f) offsety = 0.f; - float offsetx = ( offsety != 0 ? 0 : std::max(0.f, dy / m_last_infill_tan > step / 2.f ? step - dy / m_last_infill_tan : 0.f ) ); + for (size_t i = 0; i < zig_zags_num; ++i) { @@ -1140,23 +1236,19 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool,bool brim) { assert(m_plan.back().z <= z_par); // refuse to add a layer below the last one - - // volumes in mm^3 required for ramming - // hardcoded so far, in future should be calculated by integrating the speed/time curve - const std::vector ram_volumes = {22,22,22,22}; - + // volumes in mm^3 required for wipe: {{from 0 to ...},{from 1 to ...},{from 2 to ...},{from 3 to ...}}, usage [from][to] - const std::vector> wipe_volumes = {{ 0, 40, 60, 80}, - {100, 0,120,100}, - { 80,107, 0,110}, - { 60, 40, 60, 0}}; + const std::vector> wipe_volumes = {{ 0, 40, 60,100}, + {100, 0,130,100}, + { 80, 90, 0,110}, + { 50, 40, 60, 0}}; - float depth = (wipe_volumes[old_tool][new_tool]) / (m_extrusion_flow * Filament_Area); // length of extrusion + float depth = (wipe_volumes[old_tool][new_tool]) / (extrusion_flow(layer_height_par) * Filament_Area); // length of extrusion depth += 6 * 59; // reserved for ramming depth += 2 * 59; // reserved for loading depth -= 2 * 59; // we will also print borders depth = floor(depth / m_wipe_tower_width + 1); // number of lines to extrude - depth *= m_perimeter_width; // conversion to distance + depth *= m_line_width; // conversion to distance if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan along with the first toolchange m_plan.push_back(WipeTowerInfo(z_par, layer_height_par)); diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 04e0b004a7..6ca807528c 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -237,6 +237,7 @@ private: // after the wipe tower brim has been extruded? float m_initial_extra_wipe = 0.f; float m_last_infill_tan = 1000.f; // impossibly high value + bool m_left_to_right = true; float extrusion_flow(float layer_height = -1.f) const { From 5ca0a2f37dc69aed796d84db6a82f99bdbc50d8c Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 21 Feb 2018 13:07:32 +0100 Subject: [PATCH 0012/1150] Parametrized toolchanges, experiments with sparse wipe tower, etc --- xs/src/libslic3r/GCode/WipeTower.hpp | 1 + xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 792 ++++++++++---------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 105 ++- 3 files changed, 441 insertions(+), 457 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTower.hpp b/xs/src/libslic3r/GCode/WipeTower.hpp index 28549ae640..289e8e1225 100644 --- a/xs/src/libslic3r/GCode/WipeTower.hpp +++ b/xs/src/libslic3r/GCode/WipeTower.hpp @@ -17,6 +17,7 @@ public: struct xy { xy(float x = 0.f, float y = 0.f) : x(x), y(y) {} + xy(xy& pos,float xp,float yp) : x(pos.x+xp), y(pos.y+yp) {} xy operator+(const xy &rhs) const { xy out(*this); out.x += rhs.x; out.y += rhs.y; return out; } xy operator-(const xy &rhs) const { xy out(*this); out.x -= rhs.x; out.y -= rhs.y; return out; } xy& operator+=(const xy &rhs) { x += rhs.x; y += rhs.y; return *this; } diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index ce9b8883aa..c409b5f20d 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -1,3 +1,18 @@ +/* + +TODO LIST +--------- + +1. cooling moves - DONE +2. priming extrusions - DONE (fixed wiping volume so far) +3. account for perimeter and finish_layer extrusions and subtract it from last wipe +4. Peter's wipe tower - layer's are not exactly square +5. Peter's wipe tower - variable width for higher levels +6. Peter's wipe tower - make sure it is not too sparse (apply max_bridge_distance and make last wipe longer) +7. Peter's wipe tower - enable enhanced first layer adhesion + +*/ + #include "WipeTowerPrusaMM.hpp" #include @@ -14,14 +29,35 @@ #define strcasecmp _stricmp #endif - +constexpr bool peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet +constexpr float min_layer_difference = 2*m_perimeter_width; +constexpr float max_bridge_distance = 10.f; // in mm +constexpr bool improve_first_layer_adhesion = true; // experimental: ramming speed (mm^3/s) sampled in 0.25s intervals (one filament so far) const std::vector ramming_speed = {7.6, 7.6, 7.6, 7.6, 9.0, 9.0, 9.0, 10.7, 10.7, 10.7}; +constexpr float ramming_step_multiplicator = 1.2f; // extra spacing may be needed for some materials +constexpr float ramming_line_width_multiplicator = 1.5f; + // experimental: time requested for cooling in seconds (common for all materials so far) -const float cooling_time = 14; // PVA: 20; SCAFF: 17 -const float loading_volume = 20; +constexpr float cooling_time = 14; // PVA: 20; SCAFF: 17; PLA+others: 14 +// volumes in mm^3 required for wipe: {{from 0 to ...},{from 1 to ...},{from 2 to ...},{from 3 to ...}}, usage [from][to] +const std::vector> wipe_volumes = {{ 0,120, 10, 50}, + { 20, 0, 30, 40}, + { 90, 20, 0, 85}, + {100,140, 30, 0}}; + +/*const std::vector> wipe_volumes = {{0, 67, 67, 67}, + {67, 0, 67, 67}, + {67, 67, 0, 67}, + {67, 67, 67, 0}}; +*/ +/*const std::vector> wipe_volumes = {{0, 10, 10, 10}, + {10, 0, 10, 10}, + {10, 10, 0, 10}, + {10, 10, 10, 0}}; +*/ namespace Slic3r { @@ -35,8 +71,8 @@ public: m_current_pos(std::numeric_limits::max(), std::numeric_limits::max()), m_current_z(0.f), m_current_feedrate(0.f), - m_extrusion_flow(0.f), m_layer_height(0.f), + m_extrusion_flow(0.f), m_preview_suppressed(false), m_elapsed_time(0.f) {} @@ -60,6 +96,9 @@ public: Writer& set_rotation(WipeTower::xy& pos, float width, float depth, float angle) { m_wipe_tower_pos = pos; m_wipe_tower_width = width; m_wipe_tower_depth=depth; m_angle_deg = angle; return (*this); } + Writer& set_y_shift(float shift) + { m_y_shift = shift; return (*this); } + // Suppress / resume G-code preview in Slic3r. Slic3r will have difficulty to differentiate the various // filament loading and cooling moves from normal extrusion moves. Therefore the writer // is asked to suppres output of some lines, which look like extrusions. @@ -79,7 +118,7 @@ public: float y() const { return m_current_pos.y; } const WipeTower::xy& pos() const { return m_current_pos; } const WipeTower::xy start_pos_rotated() const { return m_start_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } - const WipeTower::xy pos_rotated() const { return m_current_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } + const WipeTower::xy pos_rotated() const { return m_current_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } float elapsed_time() const { return m_elapsed_time; } // Extrude with an explicitely provided amount of extrusion. @@ -92,10 +131,11 @@ public: float dx = x - m_current_pos.x; float dy = y - m_current_pos.y; double len = sqrt(dx*dx+dy*dy); - + + // For rotated wipe tower, transform position to printer coordinates - WipeTower::xy rotated_current_pos(m_current_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); - WipeTower::xy rot(WipeTower::xy(x,y).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); + WipeTower::xy rotated_current_pos(WipeTower::xy(m_current_pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); + WipeTower::xy rot(WipeTower::xy(x,y+m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); if (! m_preview_suppressed && e > 0.f && len > 0.) { // Width of a squished extrusion, corrected for the roundings of the squished extrusions. @@ -321,7 +361,8 @@ private: std::string m_gcode; std::vector m_extrusions; float m_elapsed_time; - float m_angle_deg = 0; + float m_angle_deg = 0.f; + float m_y_shift = 0.f; WipeTower::xy m_wipe_tower_pos; float m_wipe_tower_width; float m_wipe_tower_depth; @@ -427,7 +468,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( { this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false); - float wipe_area = m_wipe_area; // Calculate the amount of wipe over the wipe tower brim following the prime, decrease wipe_area // with the amount of material extruded over the brim. // DOESN'T MAKE SENSE NOW, wipe tower dimensions are still unknown at this point @@ -454,7 +494,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( // box_coordinates cleaning_box(xy(0.5f, - 1.5f), m_wipe_tower_width, wipe_area); //FIXME: set the width properly constexpr float prime_section_width = 60.f; - box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, wipe_area); + box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, 15.f); PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow) @@ -466,37 +506,26 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( .append(";--------------------\n") .speed_override(100); - // Always move to the starting position. - writer.set_initial_position(xy(0.f, 0.f)) - .travel(cleaning_box.ld, 7200) - // Increase the extruder driver current to allow fast ramming. - .set_extruder_trimpot(750); + writer.set_initial_position(xy(0.f, 0.f)) // Always move to the starting position + .travel(cleaning_box.ld, 7200) + .set_extruder_trimpot(750); // Increase the extruder driver current to allow fast ramming. if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - float y_end = 0.f; for (size_t idx_tool = 0; idx_tool < tools.size(); ++ idx_tool) { unsigned int tool = tools[idx_tool]; - // Select the tool, set a speed override for soluble and flex materials. - toolchange_Change(writer, tool, m_material[tool]); - // Prime the tool. - toolchange_Load(writer, cleaning_box); + m_left_to_right = true; + toolchange_Change(writer, tool, m_material[tool]); // Select the tool, set a speed override for soluble and flex materials. + toolchange_Load(writer, cleaning_box); // Prime the tool. if (idx_tool + 1 == tools.size()) { // Last tool should not be unloaded, but it should be wiped enough to become of a pure color. - if (last_wipe_inside_wipe_tower) { - // Shrink the last wipe area to the area of the other purge areas, - // remember the last initial wipe width to be purged into the 1st layer of the wipe tower. - this->m_initial_extra_wipe = std::max(0.f, wipe_area - (y_end + 0.5f * m_line_width - cleaning_box.ld.y)); - cleaning_box.lu.y -= this->m_initial_extra_wipe; - cleaning_box.ru.y -= this->m_initial_extra_wipe; - } - toolchange_Wipe(writer, cleaning_box, false); + toolchange_Wipe(writer, cleaning_box, 20.f); } else { // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. - writer.travel(writer.x(), writer.y() + m_perimeter_width, 7200); - // Change the extruder temperature to the temperature of the next filament before starting the cooling moves. - toolchange_Unload(writer, cleaning_box, m_material[m_current_tool], m_first_layer_temperature[tools[idx_tool+1]]); - // Save the y end of the non-last priming area. - y_end = writer.y(); + //writer.travel(writer.x(), writer.y() + m_perimeter_width, 7200); + toolchange_Wipe(writer, cleaning_box , 5.f); + box_coordinates box = cleaning_box; + box.translate(0.f, writer.y() - cleaning_box.ld.y + m_perimeter_width); + toolchange_Unload(writer, box , m_material[m_current_tool], m_first_layer_temperature[tools[idx_tool + 1]]); cleaning_box.translate(prime_section_width, 0.f); writer.travel(cleaning_box.ld, 7200); } @@ -541,7 +570,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo } float wipe_area = 0.f; - /*if (++ m_idx_tool_change_in_layer < (unsigned int)m_max_color_changes && last_in_layer) { + {/*if (++ m_idx_tool_change_in_layer < (unsigned int)m_max_color_changes && last_in_layer) { // This tool_change() call will be followed by a finish_layer() call. // Try to shrink the wipe_area to save material, as less than usual wipe is required // if this step is foolowed by finish_layer() extrusions wiping the same extruder. @@ -568,29 +597,39 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo break; } } - }*/ + }*/} + bool last_change_in_layer = false; + float wipe_volume = 0.f; + // Finds this toolchange info - if (tool != (unsigned int)(-1)) { + if (tool != (unsigned int)(-1)) + { for (const auto &b : m_layer_info->tool_changes) - if ( b.new_tool == tool ) - wipe_area = b.required_depth; + if ( b.new_tool == tool ) { + wipe_volume = wipe_volumes[b.old_tool][b.new_tool]; + if (tool == m_layer_info->tool_changes.back().new_tool) + last_change_in_layer = true; + wipe_area = b.required_depth * m_layer_info->extra_spacing; + break; + } } else { // Otherwise we are going to Unload only. And m_layer_info would be invalid. } - + box_coordinates cleaning_box( - m_wipe_tower_pos + xy(0.f, m_current_wipe_start_y + 0.5f * m_perimeter_width), - m_wipe_tower_width, - wipe_area - m_perimeter_width); + m_wipe_tower_pos + xy(m_perimeter_width / 2.f, m_perimeter_width / 2.f), + m_wipe_tower_width - m_perimeter_width, + (tool != (unsigned int)(-1) ? m_layer_info->depth : m_wipe_tower_depth-m_perimeter_width)); PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow) .set_z(m_z_pos) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) - .set_rotation(m_wipe_tower_pos,m_wipe_tower_width,m_wipe_tower_depth,m_wipe_tower_rotation_angle) + .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) + .set_y_shift(m_y_shift) .append(";--------------------\n" "; CP TOOLCHANGE START\n") .comment_with_value(" toolchange #", m_num_tool_changes) @@ -598,8 +637,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .append(";--------------------\n") .speed_override(100); - xy initial_position = ((m_current_shape == SHAPE_NORMAL) ? cleaning_box.ld : cleaning_box.lu) + - xy(m_perimeter_width, ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width); + xy initial_position = cleaning_box.ld + WipeTower::xy(0.f,m_depth_traversed); if (purpose == PURPOSE_MOVE_TO_TOWER || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { // Scaffold leaks terribly, reduce leaking by a full retract when going to the wipe tower. @@ -623,35 +661,29 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { // Increase the extruder driver current to allow fast ramming. writer.set_extruder_trimpot(750); + // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. - - if (tool != (unsigned int)-1) { + if (tool != (unsigned int)-1){ // This is not the last change. toolchange_Unload(writer, cleaning_box, m_material[m_current_tool], - m_is_first_layer ? m_first_layer_temperature[tool] : m_temperature[tool]); - // This is not the last change. - // Change the tool, set a speed override for soluble and flex materials. - toolchange_Change(writer, tool, m_material[tool]); - toolchange_Load(writer, cleaning_box); - // Wipe the newly loaded filament until the end of the assigned wipe area. - toolchange_Wipe(writer, cleaning_box, false); - // Draw a perimeter around cleaning_box and wipe. - box_coordinates box = cleaning_box; - if (m_current_shape == SHAPE_REVERSED) { - std::swap(box.lu, box.ld); - std::swap(box.ru, box.rd); - } - // Draw a perimeter around cleaning_box. - writer.travel(box.lu, 7000) - .extrude(box.ld, 3200).extrude(box.rd) - .extrude(box.ru).extrude(box.lu); - // Wipe the nozzle. - //if (purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) + m_is_first_layer ? m_first_layer_temperature[tool] : m_temperature[tool]); + toolchange_Change(writer, tool, m_material[tool]); // Change the tool, set a speed override for soluble and flex materials. + toolchange_Load(writer, cleaning_box); + toolchange_Wipe(writer, cleaning_box, wipe_volume); // Wipe the newly loaded filament until the end of the assigned wipe area. + // Always wipe the nozzle with a long wipe to reduce stringing when moving away from the wipe tower. - writer.travel(box.ru, 7200) - .travel(box.lu); + /*box_coordinates box = cleaning_box; + writer.travel(box.ru, 7200) + .travel(box.lu);*/ } else toolchange_Unload(writer, cleaning_box, m_material[m_current_tool], m_temperature[m_current_tool]); + if (last_change_in_layer) // draw perimeter line + writer.travel(m_wipe_tower_pos, 7000) + .extrude(m_wipe_tower_pos + xy(0, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width), 3200) + .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width)) + .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, 0)) + .extrude(m_wipe_tower_pos); + // Reset the extruder current to a normal value. writer.set_extruder_trimpot(550) .feedrate(6000) @@ -662,7 +694,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo "\n\n"); ++ m_num_tool_changes; - m_current_wipe_start_y += wipe_area; + //m_current_wipe_start_y += wipe_area; + m_depth_traversed += wipe_area; } ToolChangeResult result; @@ -681,18 +714,16 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b const box_coordinates wipeTower_box( m_wipe_tower_pos, m_wipe_tower_width, - m_wipe_tower_depth - m_perimeter_width / 2); + m_wipe_tower_depth); PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow * 1.1f) - // Let the writer know the current Z position as a base for Z-hop. - .set_z(m_z_pos) - .set_layer_height(m_layer_height) - .set_initial_tool(m_current_tool) - .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - .append( - ";-------------------------------------\n" - "; CP WIPE TOWER FIRST LAYER BRIM START\n"); + .set_z(m_z_pos) // Let the writer know the current Z position as a base for Z-hop. + .set_layer_height(m_layer_height) + .set_initial_tool(m_current_tool) + .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) + .append(";-------------------------------------\n" + "; CP WIPE TOWER FIRST LAYER BRIM START\n"); xy initial_position = wipeTower_box.lu - xy(m_perimeter_width * 6.f, 0); @@ -705,66 +736,29 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b writer.set_initial_position(initial_position); if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - // Prime the extruder 10*m_perimeter_width left along the vertical edge of the wipe tower. - writer.extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), - 1.5f * m_extrusion_flow * (wipeTower_box.lu.y - wipeTower_box.ld.y), 2400); + + writer.extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), // Prime the extruder left of the wipe tower. + 1.5f * m_extrusion_flow * (wipeTower_box.lu.y - wipeTower_box.ld.y), 2400); // The tool is supposed to be active and primed at the time when the wipe tower brim is extruded. // toolchange_Change(writer, int(tool), m_material[tool]); + + // Extrude 4 rounds of a brim around the future wipe tower. + box_coordinates box(wipeTower_box); + box.expand(m_perimeter_width); + for (size_t i = 0; i < 4; ++ i) { + writer.travel (box.ld, 7000) + .extrude(box.lu, 2100).extrude(box.ru) + .extrude(box.rd ).extrude(box.ld); + box.expand(m_perimeter_width); + } - if (sideOnly) { - float x_offset = m_perimeter_width; - for (size_t i = 0; i < 4; ++ i, x_offset += m_perimeter_width) - writer.travel (wipeTower_box.ld + xy(- x_offset, y_offset), 7000) - .extrude(wipeTower_box.lu + xy(- x_offset, - y_offset), 2100); - writer.travel(wipeTower_box.rd + xy(x_offset, y_offset), 7000); - x_offset = m_perimeter_width; - for (size_t i = 0; i < 4; ++ i, x_offset += m_perimeter_width) - writer.travel (wipeTower_box.rd + xy(x_offset, y_offset), 7000) - .extrude(wipeTower_box.ru + xy(x_offset, - y_offset), 2100); - } else { - // Extrude 4 rounds of a brim around the future wipe tower. - box_coordinates box(wipeTower_box); - //FIXME why is the box shifted in +Y by 0.5f * m_perimeter_width? - box.translate(0.f, 0.5f * m_perimeter_width); - box.expand(0.5f * m_perimeter_width); - for (size_t i = 0; i < 4; ++ i) { - writer.travel (box.ld, 7000) - .extrude(box.lu, 2100).extrude(box.ru) - .extrude(box.rd ).extrude(box.ld); - box.expand(m_perimeter_width); - } - } - - if (m_initial_extra_wipe > m_perimeter_width * 1.9f) { - box_coordinates cleaning_box( - m_wipe_tower_pos + xy(0.f, 0.5f * m_perimeter_width), - m_wipe_tower_width, - m_initial_extra_wipe - m_perimeter_width); - writer.travel(cleaning_box.ld + xy(m_perimeter_width, 0.5f * m_perimeter_width), 6000); - // Wipe the newly loaded filament until the end of the assigned wipe area. - toolchange_Wipe(writer, cleaning_box, true); - // Draw a perimeter around cleaning_box. - writer.travel(cleaning_box.lu, 7000) - .extrude(cleaning_box.ld, 3200).extrude(cleaning_box.rd) - .extrude(cleaning_box.ru).extrude(cleaning_box.lu); - m_current_wipe_start_y = m_initial_extra_wipe; - } - - // Move to the front left corner. - writer.travel(wipeTower_box.ld, 7000); - - //if (purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) - // Wipe along the front edge. - // Always wipe the nozzle with a long wipe to reduce stringing when moving away from the wipe tower. - writer.travel(wipeTower_box.rd) - .travel(wipeTower_box.ld); - - writer.append("; CP WIPE TOWER FIRST LAYER BRIM END\n" + writer.travel(wipeTower_box.ld, 7000); // Move to the front left corner. + writer.travel(wipeTower_box.rd) // Always wipe the nozzle with a long wipe to reduce stringing when moving away from the wipe tower. + .travel(wipeTower_box.ld); + writer.append("; CP WIPE TOWER FIRST LAYER BRIM END\n" ";-----------------------------------\n"); - // Mark the brim as extruded. - ///m_idx_tool_change_in_layer = 0; m_print_brim = false; } @@ -779,6 +773,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b return result; } + + // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. void WipeTowerPrusaMM::toolchange_Unload( PrusaMultiMaterial::Writer &writer, @@ -786,53 +782,46 @@ void WipeTowerPrusaMM::toolchange_Unload( const material_type current_material, const int new_temperature) { - float xl = cleaning_box.ld.x + 0.5f * m_perimeter_width; - float xr = cleaning_box.rd.x - 0.5f * m_perimeter_width; + float xl = cleaning_box.ld.x + 1.f * m_perimeter_width; + float xr = cleaning_box.rd.x - 1.f * m_perimeter_width; writer.append("; CP TOOLCHANGE UNLOAD\n"); - // Ram the hot material out of the extruder melt zone. - // Current extruder position is on the left, one perimeter inside the cleaning box in both X and Y. - //float e0 = m_perimeter_width * m_extrusion_flow; - //float e = (xr - xl) * m_extrusion_flow; - //float y_step = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_perimeter_width * ramming_step_multiplicator; + const float line_width = m_line_width * ramming_line_width_multiplicator; // desired ramming line thickness + const float y_step = line_width * ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm - constexpr float ramming_step_multiplicator = 1.f; // extra spacing needed for some materials - const float line_width = m_line_width * 1.5f; // desired ramming line thickness - - float y_step = (m_current_shape == SHAPE_NORMAL ? 1.f : -1.f) * // spacing between lines in mm - line_width * ramming_step_multiplicator; - - - int i = 0; // iterates through ramming_speed + unsigned i = 0; // iterates through ramming_speed m_left_to_right = true; // current direction of ramming - float remaining = xr - xl - 2 * m_perimeter_width; // keeps track of distance to the next turnaround + float remaining = xr - xl ; // keeps track of distance to the next turnaround float e_done = 0; // measures E move done from each segment + + writer.travel(xl, cleaning_box.ld.y + m_depth_traversed + y_step/2.f ); // move to starting position - writer.travel(xl + m_perimeter_width, writer.y() + y_step * 0.2); // move to starting position - - while (i < ramming_speed.size()) { - const float x = (ramming_speed[i] * 0.25f) / // extrusion length to get desired line_width - (m_layer_height * (line_width - m_layer_height * (1. - M_PI / 4.))); - const float e = ramming_speed[i] * 0.25f / Filament_Area; // transform volume per sec to E move; - const float dist = std::min(x - e_done, remaining); // distance to travel for the next 0.25s - writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), std::hypot(dist, e * (dist / x)) / (0.25 / 60.)); + while (i < ramming_speed.size()) + { + const float x = volume_to_length(ramming_speed[i] * 0.25f, line_width, m_layer_height); + const float e = ramming_speed[i] * 0.25f / Filament_Area; // transform volume per sec to E move; + const float dist = std::min(x - e_done, remaining); // distance to travel for either the next 0.25s, or to the next turnaround + const float actual_time = dist/x * 0.25; + writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), std::hypot(dist, e * (dist / x)) / (actual_time / 60.)); remaining -= dist; - if ( remaining < WT_EPSILON ) { // we reached a turning point - writer.travel(writer.x(), writer.y() + y_step); + if (remaining < WT_EPSILON) { // we reached a turning point + writer.travel(writer.x(), writer.y() + y_step, 7200); m_left_to_right = !m_left_to_right; - remaining = xr - xl - 2 * m_perimeter_width; + remaining = xr - xl; } - e_done += dist; // subtract what was actually transversed - if (e_done > x - WT_EPSILON) { // current segment finished + e_done += dist; // subtract what was actually done + if (e_done > x - WT_EPSILON) { // current segment finished ++i; e_done = 0; } } + WipeTower::xy end_of_ramming(writer.x(),writer.y()); - - /*switch (current_material) +// Alex's old ramming: +{ + /*switch (current_material) { case ABS: // ramming start end y increment amount feedrate @@ -848,7 +837,7 @@ void WipeTowerPrusaMM::toolchange_Unload( .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 1.5f, 0, 1.75f * e, 4800) .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 1.5f, 0, 1.75f * e, 5000); break; - case PET: //!!! SCAFF (PET only used for testing): + case SCAFF: writer.ram(xl + m_perimeter_width * 2, xr - m_perimeter_width, y_step * 2.f, 0, 1.75f * e, 4000) .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 3.f, 0, 2.34f * e, 4600) .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 3.f, 0, 2.63f * e, 5200); @@ -860,85 +849,83 @@ void WipeTowerPrusaMM::toolchange_Unload( .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 1.2f, e0, 1.65f * e, 4600) .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 1.2f, e0, 1.74f * e, 5200); }*/ - +} // Pull the filament end into a cooling tube. writer.retract(15, 5000).retract(50, 5400).retract(15, 3000).retract(12, 2000); - if (new_temperature != 0) - // Set the extruder temperature, but don't wait. + if (new_temperature != 0) // Set the extruder temperature, but don't wait. writer.set_extruder_temp(new_temperature, false); - // In case the current print head position is closer to the left edge, reverse the direction. - if (std::abs(writer.x() - xl) < std::abs(writer.x() - xr)) - std::swap(xl, xr); - // Horizontal cooling moves will be performed at the following Y coordinate: - /*writer.travel(xr, writer.y() + y_step * 0.8f, 7200) - .suppress_preview();*/ - - /*constexpr float min_cool_speed = 1600; - constexpr float max_cool_speed = 2400; - - const int num_of_intervals = 4; - - writer.travel(writer.x(), writer.y() + y_step) - .retract(-3,min_cool_speed) - .suppress_preview(); - - int filament_direction = -1; // retract first - float cool_speed = min_cool_speed; - // Numbers 12 (24) below fix velocity in E to 12 times less than in X (total move in X assumed to be >> move in E) +// cooling: + writer.retract(2, 2000); + writer.suppress_preview(); + writer.travel(writer.x(), writer.y() + y_step); + const float start_x = writer.x(); + const float turning_point = ( xr-start_x > start_x-xl ? xr : xl ); + const float max_x_dist = 2*std::abs(start_x-turning_point); + const int N = 4 + (cooling_time-14)/3; + float time = cooling_time / N; - for (int counter=0 ; counter < num_of_intervals ; ++counter) { - float needed_e_move = cool_speed * (cooling_time / num_of_intervals) / 12.f; // distance yet to move in E axis - do { - remaining = ( left_to_right ? xr-m_perimeter_width-writer.x() : -xl-m_perimeter_width+writer.x()); // distance to the turning point - float xmove = std::min( std::fabs(needed_e_move) * 12.f, remaining * 2.f); // distance to travel - printf("posun z %f na %f",writer.x(),writer.x()+xmove / 2.f * (left_to_right ? 1 : -1)); - writer.cool(writer.x() + xmove / 2.f * (left_to_right ? 1 : -1), writer.x(), filament_direction * xmove / 24.f, filament_direction * xmove / 24.f, cool_speed); - printf(", E %f, rychlost %f\n\n",filament_direction * xmove /12.f,cool_speed); - needed_e_move -= xmove/12.f; - if (needed_e_move > WT_EPSILON) - filament_direction *= -1; - else - left_to_right = !left_to_right; - - } while (needed_e_move > WT_EPSILON); - if (filament_direction==-1) - cool_speed += (max_cool_speed - min_cool_speed) / num_of_intervals; + i = 0; + while (i WT_EPSILON) { - float remaining = (m_left_to_right ? xr - writer.x() : writer.x() - xl ); - float dist = std::min(x, remaining); - writer.extrude(writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, writer.y(), 2200); - x -= dist; - - if (x > WT_EPSILON) { // don't switch it for the last (unfinished) line - m_left_to_right = !m_left_to_right; - writer.travel(writer.x(), writer.y() + dy, 7200); - } - else // advance just a fraction for debugging (to see where the load ends) (FIXME - HAS to be deleted, can pass the edge) - writer.travel(writer.x()+(m_left_to_right ? 0.1f : -0.1f),writer.y()); - } - + }*/ +} // Reset the extruder current to the normal value. writer.set_extruder_trimpot(550); } @@ -1020,40 +995,55 @@ void WipeTowerPrusaMM::toolchange_Load( void WipeTowerPrusaMM::toolchange_Wipe( PrusaMultiMaterial::Writer &writer, const box_coordinates &cleaning_box, - bool skip_initial_y_move) + float wipe_volume) { // Increase flow on first layer, slow down print. writer.set_extrusion_flow(m_extrusion_flow * (m_is_first_layer ? 1.18f : 1.f)) .append("; CP TOOLCHANGE WIPE\n"); float wipe_coeff = m_is_first_layer ? 0.5f : 1.f; - const float& xl = cleaning_box.ld.x; // + 2.f * m_perimeter_width; - const float& xr = cleaning_box.rd.x; // - 2.f * m_perimeter_width; - // Wipe speed will increase up to 4800. - float wipe_speed = 4200.f; - float wipe_speed_inc = 50.f; - float wipe_speed_max = 4800.f; - // Y increment per wipe line. - float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_line_width; + const float& xl = cleaning_box.ld.x; + const float& xr = cleaning_box.rd.x; + + // DEBUGGING: The function makes sure it always wipes at least the ordered volume, even if it means violating + // the perimeter. This can later be removed and simply wipe until the end of the assigned area. + // (Variables x_to_wipe and traversed_x) - for ( int i = 0 ; true ; ++i ) - { - wipe_speed = std::min(wipe_speed_max, wipe_speed + wipe_speed_inc); - if (m_left_to_right) - writer.extrude(xr - (i % 4 == 0 ? 0 : m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); - else - writer.extrude(xl + (i % 4 == 1 ? 0 : m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); + float x_to_wipe = volume_to_length(wipe_volume, m_line_width, m_layer_height); + float dy = m_extra_spacing*m_line_width; + float wipe_speed = 1600.f; + + for (int i = 0; true; ++i) { + if (i!=0) { + if (wipe_speed < 1610.f) wipe_speed = 1800.f; + else if (wipe_speed < 1810.f) wipe_speed = 2200.f; + else if (wipe_speed < 2210.f) wipe_speed = 4200.f; + else wipe_speed = std::min(4800.f, wipe_speed + 50.f); + } - if ((m_current_shape == SHAPE_NORMAL) ? // in case next line would not fit + float traversed_x = writer.x(); + if (m_left_to_right) + writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); + else + writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); + + /*if ((m_current_shape == SHAPE_NORMAL) ? // in case next line would not fit (writer.y() > cleaning_box.lu.y - m_perimeter_width * 1.5f) : (writer.y() < cleaning_box.ld.y + m_perimeter_width * 1.5f)) + break;*/ + traversed_x -= writer.x(); + x_to_wipe -= fabs(traversed_x); + if (x_to_wipe < WT_EPSILON) { + writer.travel(m_left_to_right ? xl + 1.5*m_perimeter_width : xr - 1.5*m_perimeter_width, writer.y(), 7200); break; - + } // stepping to the next line: - writer.extrude(writer.x() + (i % 4 == 0 ? -1.f : (i % 4 == 1 ? 1.f : 0.f)) * m_perimeter_width, writer.y() + dy); + writer.extrude(writer.x() + (i % 4 == 0 ? -1.f : (i % 4 == 1 ? 1.f : 0.f)) * 1.5*m_perimeter_width, writer.y() + dy); m_left_to_right = !m_left_to_right; } - // Reset the extrusion flow. - writer.set_extrusion_flow(m_extrusion_flow); + writer.set_extrusion_flow(m_extrusion_flow); // Reset the extrusion flow. + + // Wipe the nozzle + } @@ -1071,6 +1061,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) + .set_y_shift(m_y_shift) .append(";--------------------\n" "; CP EMPTY GRID START\n") // m_num_layer_changes is incremented by set_z, so it is 1 based. @@ -1078,18 +1069,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) // Slow down on the 1st layer. float speed_factor = m_is_first_layer ? 0.5f : 1.f; - - float current_depth = m_wipe_tower_depth; - if (m_is_first_layer) - current_depth = m_wipe_tower_depth; - else - current_depth = m_layer_info->depth; - - - box_coordinates fill_box(m_wipe_tower_pos + xy(0.f, m_current_wipe_start_y), - m_wipe_tower_width, current_depth - m_current_wipe_start_y); - fill_box.expand(0.f, - 0.5f * m_perimeter_width); - + float current_depth = m_layer_info->depth - m_layer_info->toolchanges_depth(); + box_coordinates fill_box(m_wipe_tower_pos + xy(m_perimeter_width, m_depth_traversed + m_perimeter_width), + m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width); if (purpose == PURPOSE_MOVE_TO_TOWER || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { if ( m_layer_info->tool_changes.size() == 0) { @@ -1106,102 +1088,62 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) } } else { // The print head is inside the wipe tower. Rather move to the start of the following extrusion. - // writer.set_initial_position(fill_box.ld); writer.set_initial_position(fill_box.ld); } if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - // Extrude the first perimeter. box_coordinates box = fill_box; - writer.extrude(box.lu, 2400 * speed_factor) - .extrude(box.ru) - .extrude(box.rd) - .extrude(box.ld + xy(m_perimeter_width / 2, 0)); + for (int i=0;i<2;++i) { + if (m_layer_info->toolchanges_depth() < WT_EPSILON) { // there were no toolchanges on this layer + if (i==0) box.expand(m_perimeter_width); + else box.expand(-m_perimeter_width); + } + else i=2; // only draw the inner perimeter - // Extrude second perimeter. - box.expand(- m_perimeter_width / 2); - writer.extrude(box.lu, 3200 * speed_factor) - .extrude(box.ru) - .extrude(box.rd) - .extrude(box.ld + xy(m_perimeter_width / 2, 0)); + writer.travel(box.ld,7200) + .extrude(box.lu, 2400 * speed_factor) + .extrude(box.ru) + .extrude(box.rd) + .extrude(box.ld); + } - if (m_is_first_layer) { + if (m_is_first_layer && improve_first_layer_adhesion) { // Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower. - box.expand(- m_perimeter_width / 2); - box.ld.y -= 0.5f * m_perimeter_width; - box.rd.y = box.ld.y; - int nsteps = int(floor((box.lu.y - box.ld.y) / (2. * (1.0 * m_perimeter_width)))); + box.expand(-m_perimeter_width/2.f); + unsigned nsteps = int(floor((box.lu.y - box.ld.y) / (2*m_perimeter_width))); float step = (box.lu.y - box.ld.y) / nsteps; - //FIXME: + writer.travel(box.ld-xy(m_perimeter_width/2.f,m_perimeter_width/2.f)); if (nsteps >= 0) for (size_t i = 0; i < nsteps; ++i) { - writer.extrude(box.ld.x, writer.y() + 0.5f * step); - writer.extrude(box.rd.x, writer.y()); - writer.extrude(box.rd.x, writer.y() + 0.5f * step); - writer.extrude(box.ld.x, writer.y()); + writer.extrude(box.ld.x+m_perimeter_width/2.f, writer.y() + 0.5f * step); + writer.extrude(box.rd.x - m_perimeter_width / 2.f, writer.y()); + writer.extrude(box.rd.x - m_perimeter_width / 2.f, writer.y() + 0.5f * step); + writer.extrude(box.ld.x + m_perimeter_width / 2.f, writer.y()); } + writer.travel(box.rd.x-m_perimeter_width/2.f,writer.y()); // wipe the nozzle } else { // Extrude a sparse infill to support the material to be printed above. - // Extrude an inverse U at the left of the region. - writer.extrude(box.ld + xy(m_perimeter_width / 2, m_perimeter_width / 2)) - .extrude(fill_box.ld + xy(m_perimeter_width * 3, m_perimeter_width), 2900 * speed_factor) - .extrude(fill_box.lu + xy(m_perimeter_width * 3, - m_perimeter_width)) - .extrude(fill_box.lu + xy(m_perimeter_width * 6, - m_perimeter_width)) - .extrude(fill_box.ld + xy(m_perimeter_width * 6, m_perimeter_width)); - - /*if (fill_box.lu.y - fill_box.ld.y > 4.f) { - const float max_bridge_distance = 10.f; // in mm - size_t zig_zags_num = int((m_wipe_tower_width - m_perimeter_width * 12.f) / ( max_bridge_distance * 2.f ) ) + 1 ; - float step = (m_wipe_tower_width - m_perimeter_width * 12.f) / (zig_zags_num * 4); - for (size_t i = 0; i < zig_zags_num; ++ i) { - writer.extrude(writer.x() + step, fill_box.ld.y + m_perimeter_width * 8, 3200 * speed_factor); - writer.extrude(writer.x() , fill_box.lu.y - m_perimeter_width * 8); - writer.extrude(writer.x() + step, fill_box.lu.y - m_perimeter_width ); - writer.extrude(writer.x() + step, fill_box.lu.y - m_perimeter_width * 8); - writer.extrude(writer.x() , fill_box.ld.y + m_perimeter_width * 8); - writer.extrude(writer.x() + step, fill_box.ld.y + m_perimeter_width ); - } - } - // Extrude an inverse U at the left of the region. - writer.extrude(fill_box.ru + xy(-m_perimeter_width * 6, -m_perimeter_width), 2900 * speed_factor) - .extrude(fill_box.ru + xy(-m_perimeter_width * 3, -m_perimeter_width)) - .extrude(fill_box.rd + xy(-m_perimeter_width * 3, m_perimeter_width)) - .extrude(fill_box.rd + xy(-m_perimeter_width, m_perimeter_width));*/ - - const float dy = (fill_box.lu.y - fill_box.ld.y - 2.f * m_perimeter_width); + const float dy = (fill_box.lu.y - fill_box.ld.y - m_perimeter_width); if (dy > m_perimeter_width) - { - const float max_bridge_distance = 10.f; // in mm - const size_t zig_zags_num = (fill_box.rd.x - fill_box.ld.x - m_perimeter_width * 12.f) / max_bridge_distance; - const float step = (fill_box.rd.x - fill_box.ld.x - m_perimeter_width * 12.f) / (float)zig_zags_num; + { + // Extrude an inverse U at the left of the region. + writer.travel(fill_box.ld + xy(m_perimeter_width * 2, 0.f)) + .extrude(fill_box.lu + xy(m_perimeter_width * 2, 0.f), 2900 * speed_factor); - float offsetx = std::max(0.f, dy / m_last_infill_tan > step / 2.f ? step - dy / m_last_infill_tan : 0.f); - float offsety = ( offsetx != 0 ? 0 : std::max(0.f, dy - m_last_infill_tan * (step - m_perimeter_width)) ); - if (offsety < m_last_infill_tan * m_perimeter_width + WT_EPSILON || offsety > dy / 2.f) - offsety = 0.f; - - - for (size_t i = 0; i < zig_zags_num; ++i) - { - writer.extrude(writer.x() + offsetx, writer.y(), 3200 * speed_factor); - if ( offsety != 0 ) { - writer.extrude(writer.x() + m_perimeter_width, writer.y()); - writer.extrude(writer.x(), writer.y() + offsety); - } - writer.extrude(writer.x() + step - offsetx - (offsety==0 ? 0 : m_perimeter_width), fill_box.lu.y - m_perimeter_width); - writer.extrude(writer.x() , fill_box.ld.y + m_perimeter_width); + const float left = fill_box.lu.x+2*m_perimeter_width; + const float right = fill_box.ru.x - 2 * m_perimeter_width; + const int n = 1+(right-left)/max_bridge_distance; + const float dx = (right-left)/n; + for (int i=1;i<=n;++i) { + float x=left+dx*i; + writer.travel(x,writer.y()); + writer.extrude(x,i%2 ? fill_box.rd.y : fill_box.ru.y); } - m_last_infill_tan = (dy - offsety) / (step - offsetx - (offsety==0 ? 0 : m_perimeter_width)); + writer.travel(left,writer.y(),7200); // wipes the nozzle before moving away from the wipe tower } - - // Extrude an inverse U at the left of the region. - writer.extrude(fill_box.rd + xy(-m_perimeter_width * 6, m_perimeter_width), 2900 * speed_factor) - .extrude(fill_box.rd + xy(-m_perimeter_width * 3, m_perimeter_width)) - .extrude(fill_box.ru + xy(-m_perimeter_width * 3, -m_perimeter_width)) - .extrude(fill_box.ru + xy(-m_perimeter_width, -m_perimeter_width)); } - +/* // if (purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) if (true) // Wipe along the front side of the current wiping box. @@ -1210,16 +1152,14 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) .travel(fill_box.rd + xy(- m_perimeter_width, m_perimeter_width / 2)); else writer.feedrate(7200); - +*/ writer.append("; CP EMPTY GRID END\n" ";------------------\n\n\n\n\n\n\n"); // Indicate that this wipe tower layer is fully covered. - m_current_wipe_start_y = m_wipe_tower_depth; - ///m_idx_tool_change_in_layer = (unsigned int)m_max_color_changes; - + m_depth_traversed = m_wipe_tower_depth-m_perimeter_width; + ///m_idx_tool_change_in_layer = (unsigned int)m_max_color_changes; } - ToolChangeResult result; result.print_z = this->m_z_pos; result.layer_height = this->m_layer_height; @@ -1232,23 +1172,20 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) } // Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box - void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool,bool brim) -{ - assert(m_plan.back().z <= z_par); // refuse to add a layer below the last one - - // volumes in mm^3 required for wipe: {{from 0 to ...},{from 1 to ...},{from 2 to ...},{from 3 to ...}}, usage [from][to] - const std::vector> wipe_volumes = {{ 0, 40, 60,100}, - {100, 0,130,100}, - { 80, 90, 0,110}, - { 50, 40, 60, 0}}; +{ + assert(m_plan.back().z <= z_par + WT_EPSILON ); // refuses to add a layer below the last one - float depth = (wipe_volumes[old_tool][new_tool]) / (extrusion_flow(layer_height_par) * Filament_Area); // length of extrusion - depth += 6 * 59; // reserved for ramming - depth += 2 * 59; // reserved for loading - depth -= 2 * 59; // we will also print borders - depth = floor(depth / m_wipe_tower_width + 1); // number of lines to extrude - depth *= m_line_width; // conversion to distance + float width = m_wipe_tower_width - 3*m_perimeter_width; + float length_to_extrude = volume_to_length(0.25f * std::accumulate(ramming_speed.begin(), ramming_speed.end(), 0.f), + m_line_width * ramming_line_width_multiplicator, + layer_height_par); + float depth = (int(length_to_extrude / width) + 1) * (m_line_width * ramming_line_width_multiplicator * ramming_step_multiplicator); + length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; + length_to_extrude += volume_to_length(wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); + length_to_extrude = std::max(length_to_extrude,0.f); + depth += (int(length_to_extrude / width) + 1) * m_line_width; + depth *= m_extra_spacing; if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan along with the first toolchange m_plan.push_back(WipeTowerInfo(z_par, layer_height_par)); @@ -1259,33 +1196,97 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth)); } - - - // Calculate m_wipe_tower (maximum depth for all the layers) and propagate depths downwards - // Could be only called when a layer is changed, but do not forget about the last one - float this_layer_depth = m_plan.back().toolchanges_depth(); + // Calculate m_wipe_tower_depth (maximum depth for all the layers) and propagate depths downwards + /*float this_layer_depth = m_plan.back().toolchanges_depth(); m_plan.back().depth = this_layer_depth; - if (this_layer_depth > m_wipe_tower_depth) - m_wipe_tower_depth = this_layer_depth; + if (this_layer_depth > m_wipe_tower_depth - m_perimeter_width) + m_wipe_tower_depth = this_layer_depth + m_perimeter_width; for (int i = m_plan.size() - 2; i >= 0 && m_plan[i].depth < this_layer_depth; i-- ) { if ( this_layer_depth - m_plan[i].depth < min_layer_difference && !m_plan[i].tool_changes.empty()) - m_plan[i].tool_changes.back().required_depth += this_layer_depth - m_plan[i].depth; + m_plan[i].depth += this_layer_depth - m_plan[i].depth; m_plan[i].depth = this_layer_depth; + }*/ +} + + + +void WipeTowerPrusaMM::plan_tower() +{ + // Calculate m_wipe_tower_depth (maximum depth for all the layers) and propagate depths downwards + m_wipe_tower_depth = 0.f; + for (auto& layer : m_plan) + layer.depth = 0.f; + + for (int layer_index = m_plan.size() - 1; layer_index >= 0; --layer_index) + { + float this_layer_depth = std::max(m_plan[layer_index].depth, m_plan[layer_index].toolchanges_depth()); + m_plan[layer_index].depth = this_layer_depth; + + if (this_layer_depth > m_wipe_tower_depth - m_perimeter_width) + m_wipe_tower_depth = this_layer_depth + m_perimeter_width; + + for (int i = layer_index - 1; i >= 0 /*&& m_plan[i].depth < this_layer_depth*/; i--) + { + if (m_plan[i].depth - this_layer_depth < min_layer_difference ) + m_plan[i].depth = this_layer_depth; + } } } -// Processes vector m_plan and calls respective function to generate G-code for the wipe tower -// Resulting ToolChangeResults are appended into container passed by "result" reference +void WipeTowerPrusaMM::make_wipe_tower_square() +{ + const float width = m_wipe_tower_width - 3 * m_perimeter_width; + const float depth = m_wipe_tower_depth - m_perimeter_width; + // area that we actually print into is width*depth + float side = sqrt(depth * width); + + m_wipe_tower_width = side + 3 * m_perimeter_width; + m_wipe_tower_depth = side + 2 * m_perimeter_width; + // For all layers, find how depth changed and update all toolchange depths + for (auto &lay : m_plan) + { + side = sqrt(lay.depth * width); + float width_ratio = width / side; + + //lay.extra_spacing = width_ratio; + for (auto &tch : lay.tool_changes) + tch.required_depth *= width_ratio; + } + + plan_tower(); // propagates depth downwards again (width has changed) + for (auto& lay : m_plan) // depths set, now the spacing + lay.extra_spacing = lay.depth / lay.toolchanges_depth(); + +} + + +// Processes vector m_plan and calls respective functions to generate G-code for the wipe tower +// Resulting ToolChangeResults are appended into vector "result" void WipeTowerPrusaMM::generate(std::vector> &result) { + m_extra_spacing = 1.f; + + plan_tower(); + if (peters_wipe_tower) + make_wipe_tower_square(); + std::vector layer_result; - for (auto layer : m_plan) { set_layer(layer.z,layer.height,0,layer.z == m_plan.front().z,layer.z == m_plan.back().z); + + if (peters_wipe_tower) + m_wipe_tower_rotation_angle += 90.f; + else + m_wipe_tower_rotation_angle += 180.f; + if (!peters_wipe_tower && m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width) + m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f; + + + for (const auto &toolchange : layer.tool_changes) layer_result.emplace_back(tool_change(toolchange.new_tool, false, WipeTower::PURPOSE_EXTRUDE)); @@ -1307,8 +1308,6 @@ void WipeTowerPrusaMM::generate(std::vector> &result); + void plan_tower(); + + void make_wipe_tower_square(); + // Switch to a next layer. virtual void set_layer( // Print height of this layer. @@ -115,18 +118,10 @@ public: // Start counting the color changes from zero. Special case: -1 - extrude a brim first. ///m_idx_tool_change_in_layer = is_first_layer ? (unsigned int)(-1) : 0; m_print_brim = is_first_layer; - m_current_wipe_start_y = 0.f; + m_depth_traversed = 0.f; // to make room for perimeter line m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL; + ++ m_num_layer_changes; - - - ///m_max_color_changes = max_tool_changes; - ///m_is_last_layer = is_last_layer; - // Extrusion rate for an extrusion aka perimeter width 0.35mm. - // Clamp the extrusion height to a 0.2mm layer height, independent of the nozzle diameter. -// m_extrusion_flow = std::min(0.2f, layer_height) * 0.145f; - // Use a strictly - //m_extrusion_flow = layer_height * 0.145f; // Calculates extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height m_extrusion_flow = extrusion_flow(layer_height); @@ -135,6 +130,7 @@ public: m_layer_info = nullptr; for (auto &a : m_plan) if ( a.z > print_z - WT_EPSILON && a.z < print_z + WT_EPSILON ) { + m_extra_spacing = a.extra_spacing; m_layer_info = &a; break; } @@ -171,49 +167,36 @@ public: // the wipe tower has been completely covered by the tool change extrusions, // or the rest of the tower has been filled by a sparse infill with the finish_layer() method. virtual bool layer_finished() const { - return ( (m_is_first_layer ? m_wipe_tower_depth : m_layer_info->depth) - WT_EPSILON < m_current_wipe_start_y); + return ( (m_is_first_layer ? m_wipe_tower_depth - m_perimeter_width : m_layer_info->depth) - WT_EPSILON < m_depth_traversed); } private: WipeTowerPrusaMM(); - // A fill-in direction (positive Y, negative Y) alternates with each layer. - enum wipe_shape + enum wipe_shape // A fill-in direction (positive Y, negative Y) alternates with each layer. { - SHAPE_NORMAL = 1, + SHAPE_NORMAL = 1, SHAPE_REVERSED = -1 }; - // Left front corner of the wipe tower in mm. - xy m_wipe_tower_pos; - // Width of the wipe tower. - float m_wipe_tower_width; - // Depth of the wipe tower (wipe_area * max_color_changes at the base) - float m_wipe_tower_depth = 0.f; - // Per color Y span. - float m_wipe_area; - // Wipe tower rotation angle in degrees (with respect to x axis - float m_wipe_tower_rotation_angle; - // Current Z position. - float m_z_pos = 0.f; - // Current layer height. - float m_layer_height = 0.f; - // Maximum number of color changes per layer. - size_t m_max_color_changes = 0; - // Is this the 1st layer of the print? If so, print the brim around the waste tower. - bool m_is_first_layer = false; - // Is this the last layer of this waste tower? - bool m_is_last_layer = false; + xy m_wipe_tower_pos; // Left front corner of the wipe tower in mm. + float m_wipe_tower_width; // Width of the wipe tower. + float m_wipe_tower_depth = 0.f; // Depth of the wipe tower + float m_wipe_tower_rotation_angle; // Wipe tower rotation angle in degrees (with respect to x axis + float m_y_shift = 0.f; // y shift passed to writer + float m_z_pos = 0.f; // Current Z position. + float m_layer_height = 0.f; // Current layer height. + size_t m_max_color_changes = 0; // Maximum number of color changes per layer. + bool m_is_first_layer = false;// Is this the 1st layer of the print? If so, print the brim around the waste tower. + bool m_is_last_layer = false;// Is this the last layer of this waste tower? // G-code generator parameters. float m_zhop = 0.5f; float m_retract = 4.f; - // Width of an extrusion line, also a perimeter spacing for 100% infill. - float m_line_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; - // Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. - float m_extrusion_flow = 0.029f; + float m_line_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. + float m_extrusion_flow = 0.038; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. // Extruder specific parameters. material_type m_material[4]; @@ -221,23 +204,20 @@ private: int m_first_layer_temperature[4]; // State of the wiper tower generator. - // Layer change counter for the output statistics. - unsigned int m_num_layer_changes = 0; - // Tool change change counter for the output statistics. - unsigned int m_num_tool_changes = 0; - // Layer change counter in this layer. Counting up to m_max_color_changes. - ///unsigned int m_idx_tool_change_in_layer = 0; + unsigned int m_num_layer_changes = 0; // Layer change counter for the output statistics. + unsigned int m_num_tool_changes = 0; // Tool change change counter for the output statistics. + ///unsigned int m_idx_tool_change_in_layer = 0; // Layer change counter in this layer. Counting up to m_max_color_changes. bool m_print_brim = true; // A fill-in direction (positive Y, negative Y) alternates with each layer. wipe_shape m_current_shape = SHAPE_NORMAL; unsigned int m_current_tool = 0; - // Current y position at the wipe tower. - float m_current_wipe_start_y = 0.f; + + float m_depth_traversed = 0.f; // Current y position at the wipe tower. // How much to wipe the 1st extruder over the wipe tower at the 1st layer // after the wipe tower brim has been extruded? float m_initial_extra_wipe = 0.f; - float m_last_infill_tan = 1000.f; // impossibly high value bool m_left_to_right = true; + float m_extra_spacing = 1.f; float extrusion_flow(float layer_height = -1.f) const { @@ -246,7 +226,11 @@ private: return layer_height * ( Width_To_Nozzle_Ratio * Nozzle_Diameter - layer_height * (1-M_PI/4.f)) / (Filament_Area); } - + float volume_to_length(float volume, float line_width, float layer_height) const { + return volume / (layer_height * (line_width - layer_height * (1. - M_PI / 4.))); + } + + struct box_coordinates { box_coordinates(float left, float bottom, float width, float height) : @@ -274,8 +258,8 @@ private: } xy ld; // left down xy lu; // left upper - xy ru; // right upper xy rd; // right lower + xy ru; // right upper }; @@ -290,12 +274,13 @@ private: float z; // z position of the layer float height; // layer height float depth; // depth of the layer based on all layers above + float extra_spacing; float toolchanges_depth() const { float sum = 0.f; for (const auto &a : tool_changes) sum += a.required_depth; return sum; } std::vector tool_changes; WipeTowerInfo(float z_par, float layer_height_par) - : z{z_par}, height{layer_height_par} { } + : z{z_par}, height{layer_height_par}, depth{0}, extra_spacing{1.f} {} }; // Stores information about all layers and toolchanges for the future wipe tower (filled by plan_toolchange(...)) @@ -327,7 +312,7 @@ private: void toolchange_Wipe( PrusaMultiMaterial::Writer &writer, const box_coordinates &cleaning_box, - bool skip_initial_y_move); + float wipe_volume); }; }; // namespace Slic3r From 5a02bde1705bb86674e651288af3616e3f194566 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 22 Feb 2018 09:28:31 +0100 Subject: [PATCH 0013/1150] Fix of merge conflict and uninitialized variables in writer class --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 4 ++-- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 2 +- xs/src/slic3r/GUI/3DScene.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index adb19eba9f..c5b0d6044d 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -366,8 +366,8 @@ private: float m_angle_deg = 0.f; float m_y_shift = 0.f; WipeTower::xy m_wipe_tower_pos; - float m_wipe_tower_width; - float m_wipe_tower_depth; + float m_wipe_tower_width = 0.f; + float m_wipe_tower_depth = 0.f; float m_last_fan_speed = 0.f; std::string diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 9ed7ae128c..ea704694a1 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -183,7 +183,7 @@ private: xy m_wipe_tower_pos; // Left front corner of the wipe tower in mm. float m_wipe_tower_width; // Width of the wipe tower. float m_wipe_tower_depth = 0.f; // Depth of the wipe tower - float m_wipe_tower_rotation_angle; // Wipe tower rotation angle in degrees (with respect to x axis + float m_wipe_tower_rotation_angle = 0.f; // Wipe tower rotation angle in degrees (with respect to x axis float m_y_shift = 0.f; // y shift passed to writer float m_z_pos = 0.f; // Current Z position. float m_layer_height = 0.f; // Current layer height. diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index cfc0947fe9..74ec515c18 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -321,11 +321,11 @@ int GLVolumeCollection::load_wipe_tower_preview( Point origin_of_rotation(0.f,0.f); mesh.rotate(rotation_angle,&origin_of_rotation); - v.indexed_vertex_array.load_mesh_flat_shading(mesh); - v.origin = Pointf3(pos_x, pos_y, 0.); + v.indexed_vertex_array.load_mesh_flat_shading(mesh); + v.origin = Pointf3(pos_x, pos_y, 0.); // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry(). v.bounding_box = v.indexed_vertex_array.bounding_box(); - v.indexed_vertex_array.finalize_geometry(use_VBOs); + v.indexed_vertex_array.finalize_geometry(use_VBOs); v.composite_id = obj_idx * 1000000; v.select_group_id = obj_idx * 1000000; v.drag_group_id = obj_idx * 1000; @@ -2291,7 +2291,7 @@ void _3DScene::_load_shells(const Print& print, GLVolumeCollection& volumes, boo const PrintConfig& config = print.config; unsigned int extruders_count = config.nozzle_diameter.size(); if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects) - volumes.load_wipe_tower_preview(1000, config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, config.wipe_tower_per_color_wipe * (extruders_count - 1), max_z, use_VBOs); + volumes.load_wipe_tower_preview(1000, config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, config.wipe_tower_per_color_wipe * (extruders_count - 1), max_z, config.wipe_tower_rotation_angle, use_VBOs); } } From 5f5a59328b243e25439a7241ab8403e8570352f6 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 22 Feb 2018 11:03:29 +0100 Subject: [PATCH 0014/1150] Minor refactoring, actualized comments, etc. --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 35 +++++++++++++-------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 33 +++++++++---------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index c5b0d6044d..2a78ed6f1f 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -1193,26 +1193,32 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi { assert(m_plan.back().z <= z_par + WT_EPSILON ); // refuses to add a layer below the last one + if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan first + m_plan.push_back(WipeTowerInfo(z_par, layer_height_par)); + + if (brim) { // this toolchange prints brim - we must add it to m_plan, but not to count its depth + m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool)); + return; + } + + if (old_tool==new_tool) // new layer without toolchanges - we are done + return; + + // this is an actual toolchange - let's calculate depth to reserve on the wipe tower + float depth = 0.f; float width = m_wipe_tower_width - 3*m_perimeter_width; float length_to_extrude = volume_to_length(0.25f * std::accumulate(ramming_speed.begin(), ramming_speed.end(), 0.f), - m_line_width * ramming_line_width_multiplicator, - layer_height_par); - float depth = (int(length_to_extrude / width) + 1) * (m_line_width * ramming_line_width_multiplicator * ramming_step_multiplicator); + m_line_width * ramming_line_width_multiplicator, + layer_height_par); + depth = (int(length_to_extrude / width) + 1) * (m_line_width * ramming_line_width_multiplicator * ramming_step_multiplicator); length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; length_to_extrude += volume_to_length(wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); length_to_extrude = std::max(length_to_extrude,0.f); depth += (int(length_to_extrude / width) + 1) * m_line_width; - depth *= m_extra_spacing; - - if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan along with the first toolchange - m_plan.push_back(WipeTowerInfo(z_par, layer_height_par)); - - if ( brim || old_tool != new_tool ) { - if (brim) // this toolchange prints brim, we need it in m_plan, but not to count its depth - depth = 0.f; - m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth)); - } + depth *= m_extra_spacing; + m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth)); + // Calculate m_wipe_tower_depth (maximum depth for all the layers) and propagate depths downwards /*float this_layer_depth = m_plan.back().toolchanges_depth(); m_plan.back().depth = this_layer_depth; @@ -1283,6 +1289,9 @@ void WipeTowerPrusaMM::make_wipe_tower_square() // Resulting ToolChangeResults are appended into vector "result" void WipeTowerPrusaMM::generate(std::vector> &result) { + if (m_plan.empty()) return; + else m_layer_info = m_plan.begin(); + m_extra_spacing = 1.f; plan_tower(); diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index ea704694a1..f5fc2985ed 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -93,10 +93,13 @@ public: // to be used before building begins. The entries must be added ordered in z. void plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool, bool brim); + // Iterates through prepared m_plan, generates ToolChangeResults and appends them to "result" void generate(std::vector> &result); + // Calculates depth for all layers and propagates them downwards void plan_tower(); + // Goes through m_plan and recalculates depths and width of the WT to make it exactly square - experimental void make_wipe_tower_square(); // Switch to a next layer. @@ -115,7 +118,7 @@ public: m_z_pos = print_z; m_layer_height = layer_height; m_is_first_layer = is_first_layer; - // Start counting the color changes from zero. Special case: -1 - extrude a brim first. + // Start counting the color changes from zero. Special case -1: extrude a brim first. ///m_idx_tool_change_in_layer = is_first_layer ? (unsigned int)(-1) : 0; m_print_brim = is_first_layer; m_depth_traversed = 0.f; // to make room for perimeter line @@ -126,14 +129,8 @@ public: // Calculates extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height m_extrusion_flow = extrusion_flow(layer_height); - // FIXME - ideally get rid of set_layer altogether and iterate through m_plan in generate(...) - m_layer_info = nullptr; - for (auto &a : m_plan) - if ( a.z > print_z - WT_EPSILON && a.z < print_z + WT_EPSILON ) { - m_extra_spacing = a.extra_spacing; - m_layer_info = &a; - break; - } + while (!m_plan.empty() && m_layer_info->z < print_z - WT_EPSILON && m_layer_info+1!=m_plan.end()) + ++m_layer_info; } // Return the wipe tower position. @@ -159,13 +156,11 @@ public: // On the first layer, extrude a brim around the future wipe tower first. virtual ToolChangeResult tool_change(unsigned int new_tool, bool last_in_layer, Purpose purpose); - // Close the current wipe tower layer with a perimeter and possibly fill the unfilled space with a zig-zag. + // Fill the unfilled space with a zig-zag. // Call this method only if layer_finished() is false. virtual ToolChangeResult finish_layer(Purpose purpose); - // Is the current layer finished? A layer is finished if either the wipe tower is finished, or - // the wipe tower has been completely covered by the tool change extrusions, - // or the rest of the tower has been filled by a sparse infill with the finish_layer() method. + // Is the current layer finished? virtual bool layer_finished() const { return ( (m_is_first_layer ? m_wipe_tower_depth - m_perimeter_width : m_layer_info->depth) - WT_EPSILON < m_depth_traversed); } @@ -219,13 +214,15 @@ private: bool m_left_to_right = true; float m_extra_spacing = 1.f; - float extrusion_flow(float layer_height = -1.f) const + // Calculates extrusion flow needed to produce required line width for given layer height + float extrusion_flow(float layer_height = -1.f) const // negative layer_height - return current m_extrusion_flow { if ( layer_height < 0 ) return m_extrusion_flow; return layer_height * ( Width_To_Nozzle_Ratio * Nozzle_Diameter - layer_height * (1-M_PI/4.f)) / (Filament_Area); } + // Calculates length of extrusion line to extrude given volume float volume_to_length(float volume, float line_width, float layer_height) const { return volume / (layer_height * (line_width - layer_height * (1. - M_PI / 4.))); } @@ -269,7 +266,7 @@ private: unsigned int old_tool; unsigned int new_tool; float required_depth; - ToolChange(unsigned int old,unsigned int newtool,float depth) : old_tool{old}, new_tool{newtool}, required_depth{depth} {} + ToolChange(unsigned int old,unsigned int newtool,float depth=0.f) : old_tool{old}, new_tool{newtool}, required_depth{depth} {} }; float z; // z position of the layer float height; // layer height @@ -283,10 +280,8 @@ private: : z{z_par}, height{layer_height_par}, depth{0}, extra_spacing{1.f} {} }; - // Stores information about all layers and toolchanges for the future wipe tower (filled by plan_toolchange(...)) - std::vector m_plan; - - WipeTowerInfo* m_layer_info; + std::vector m_plan; // Stores information about all layers and toolchanges for the future wipe tower (filled by plan_toolchange(...)) + std::vector::iterator m_layer_info; // Returns gcode for wipe tower brim From 3099c32d0805a6fff26929e9be3dcb27e50f9bfa Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 27 Feb 2018 08:56:11 +0100 Subject: [PATCH 0015/1150] GUI - reenabling rotation angle settings for the wipe tower (was disabled by the merge with master) --- xs/src/libslic3r/PrintConfig.cpp | 6 +++--- xs/src/slic3r/GUI/Tab.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index bc5d115c35..995dcee99f 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1732,9 +1732,9 @@ PrintConfigDef::PrintConfigDef() def->default_value = new ConfigOptionFloat(15.); def = this->add("wipe_tower_rotation_angle", coFloat); - def->label = "Wipe tower rotation angle"; - def->tooltip = "Wipe tower rotation angle with respect to x-axis "; - def->sidetext = "degrees"; + def->label = _L("Wipe tower rotation angle"); + def->tooltip = _L("Wipe tower rotation angle with respect to x-axis "); + def->sidetext = _L("degrees"); def->cli = "wipe-tower-rotation-angle=f"; def->default_value = new ConfigOptionFloat(0.); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index b27e7b8387..ebfa69eb5b 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -446,6 +446,7 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_y"); optgroup->append_single_option_line("wipe_tower_width"); optgroup->append_single_option_line("wipe_tower_per_color_wipe"); + optgroup->append_single_option_line("wipe_tower_rotation_angle"); optgroup = page->new_optgroup(_L("Advanced")); optgroup->append_single_option_line("interface_shells"); @@ -762,7 +763,7 @@ void TabPrint::update() bool have_wipe_tower = m_config->opt_bool("wipe_tower"); vec_enable.resize(0); - vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe"}; + vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle"}; for (auto el : vec_enable) get_field(el)->toggle(have_wipe_tower); From a62ad3323f389e3ce93915b7fea92bd1eccf321e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 28 Feb 2018 16:04:56 +0100 Subject: [PATCH 0016/1150] First naive implementation of wipe tower settings dialog --- xs/CMakeLists.txt | 5 + xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 65 ++--- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 152 ++++++++++- xs/src/libslic3r/Print.cpp | 4 +- xs/src/libslic3r/PrintConfig.cpp | 9 +- xs/src/libslic3r/PrintConfig.hpp | 2 + xs/src/slic3r/GUI/BedShapeDialog.cpp | 2 +- xs/src/slic3r/GUI/Preset.cpp | 6 +- xs/src/slic3r/GUI/RammingChart.cpp | 273 ++++++++++++++++++++ xs/src/slic3r/GUI/RammingChart.hpp | 129 +++++++++ xs/src/slic3r/GUI/Tab.cpp | 24 ++ xs/src/slic3r/GUI/Tab.hpp | 1 + xs/src/slic3r/GUI/WipeTowerDialog.cpp | 264 +++++++++++++++++++ xs/src/slic3r/GUI/WipeTowerDialog.hpp | 115 +++++++++ 14 files changed, 996 insertions(+), 55 deletions(-) create mode 100644 xs/src/slic3r/GUI/RammingChart.cpp create mode 100644 xs/src/slic3r/GUI/RammingChart.hpp create mode 100644 xs/src/slic3r/GUI/WipeTowerDialog.cpp create mode 100644 xs/src/slic3r/GUI/WipeTowerDialog.hpp diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 41bf9de26a..4e217d1480 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -195,6 +195,11 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/2DBed.hpp ${LIBDIR}/slic3r/GUI/wxExtensions.cpp ${LIBDIR}/slic3r/GUI/wxExtensions.hpp + ${LIBDIR}/slic3r/GUI/WipeTowerDialog.cpp + ${LIBDIR}/slic3r/GUI/WipeTowerDialog.hpp + ${LIBDIR}/slic3r/GUI/RammingChart.cpp + ${LIBDIR}/slic3r/GUI/RammingChart.hpp + ) add_library(admesh STATIC diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 2a78ed6f1f..d7492fdbb0 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -33,33 +33,6 @@ TODO LIST constexpr bool peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet constexpr float min_layer_difference = 2*m_perimeter_width; -constexpr float max_bridge_distance = 10.f; // in mm -constexpr bool improve_first_layer_adhesion = true; -// experimental: ramming speed (mm^3/s) sampled in 0.25s intervals (one filament so far) -const std::vector ramming_speed = {7.6, 7.6, 7.6, 7.6, 9.0, 9.0, 9.0, 10.7, 10.7, 10.7}; -constexpr float ramming_step_multiplicator = 1.2f; // extra spacing may be needed for some materials -constexpr float ramming_line_width_multiplicator = 1.5f; - -// experimental: time requested for cooling in seconds (common for all materials so far) -constexpr float cooling_time = 14; // PVA: 20; SCAFF: 17; PLA+others: 14 - - -// volumes in mm^3 required for wipe: {{from 0 to ...},{from 1 to ...},{from 2 to ...},{from 3 to ...}}, usage [from][to] -const std::vector> wipe_volumes = {{ 0,120, 10, 50}, - { 20, 0, 30, 40}, - { 90, 20, 0, 85}, - {100,140, 30, 0}}; - -/*const std::vector> wipe_volumes = {{0, 67, 67, 67}, - {67, 0, 67, 67}, - {67, 67, 0, 67}, - {67, 67, 67, 0}}; -*/ -/*const std::vector> wipe_volumes = {{0, 10, 10, 10}, - {10, 0, 10, 10}, - {10, 10, 0, 10}, - {10, 10, 10, 0}}; -*/ namespace Slic3r { @@ -614,7 +587,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo { for (const auto &b : m_layer_info->tool_changes) if ( b.new_tool == tool ) { - wipe_volume = wipe_volumes[b.old_tool][b.new_tool]; + wipe_volume = m_par.wipe_volumes[b.old_tool][b.new_tool]; if (tool == m_layer_info->tool_changes.back().new_tool) last_change_in_layer = true; wipe_area = b.required_depth * m_layer_info->extra_spacing; @@ -804,20 +777,20 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.append("; CP TOOLCHANGE UNLOAD\n"); - const float line_width = m_line_width * ramming_line_width_multiplicator; // desired ramming line thickness - const float y_step = line_width * ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm + const float line_width = m_line_width * m_par.ramming_line_width_multiplicator[m_current_tool]; // desired ramming line thickness + const float y_step = line_width * m_par.ramming_step_multiplicator[m_current_tool] * m_extra_spacing; // spacing between lines in mm unsigned i = 0; // iterates through ramming_speed m_left_to_right = true; // current direction of ramming float remaining = xr - xl ; // keeps track of distance to the next turnaround float e_done = 0; // measures E move done from each segment - + writer.travel(xl, cleaning_box.ld.y + m_depth_traversed + y_step/2.f ); // move to starting position - while (i < ramming_speed.size()) + while (i < m_par.ramming_speed[m_current_tool].size()) { - const float x = volume_to_length(ramming_speed[i] * 0.25f, line_width, m_layer_height); - const float e = ramming_speed[i] * 0.25f / Filament_Area; // transform volume per sec to E move; + const float x = volume_to_length(m_par.ramming_speed[m_current_tool][i] * 0.25f, line_width, m_layer_height); + const float e = m_par.ramming_speed[m_current_tool][i] * 0.25f / Filament_Area; // transform volume per sec to E move; const float dist = std::min(x - e_done, remaining); // distance to travel for either the next 0.25s, or to the next turnaround const float actual_time = dist/x * 0.25; writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), std::hypot(dist, e * (dist / x)) / (actual_time / 60.)); @@ -880,21 +853,21 @@ void WipeTowerPrusaMM::toolchange_Unload( const float start_x = writer.x(); const float turning_point = ( xr-start_x > start_x-xl ? xr : xl ); const float max_x_dist = 2*std::abs(start_x-turning_point); - const int N = 4 + (cooling_time-14)/3; - float time = cooling_time / N; - + const unsigned int N = 4 + std::max(0,(m_par.cooling_time[m_current_tool]-14)/3); + float time = m_par.cooling_time[m_current_tool] / N; + i = 0; - while (i #include #include +#include #include #include "WipeTower.hpp" @@ -22,6 +23,11 @@ constexpr float m_perimeter_width = Nozzle_Diameter * Width_To_Nozzle_Ratio * Ko constexpr float WT_EPSILON = 1e-3f; + + + + + namespace Slic3r { @@ -29,6 +35,141 @@ namespace PrusaMultiMaterial { class Writer; }; + + +// Operator overload to output std::pairs +template +std::ostream& operator<<(std::ostream& stream,const std::pair& pair) { + return stream << pair.first << " " << pair.second; +} + +// Operator overload to output elements of a vector to std::ofstream easily: +template +std::ostream& operator<<(std::ostream& stream,const std::vector& vect) { + for (const auto& element : vect) + stream << element << " "; + return stream; +} + +// Operator overload to input elements of a vector from std::ifstream easily (reads until a fail) +template +std::istream& operator>>(std::istream& stream, std::vector& vect) { + vect.clear(); + T value{}; + bool we_read_something = false; + while (stream >> value) { + vect.push_back(value); + we_read_something = true; + } + if (!stream.eof() && we_read_something) { // if this is not eof, we might be at separator - let's get rid of it + stream.clear(); // if we failed on very first line or reached eof, return stream in !good() state + stream.get(); // get() whatever we are stuck at + } + return stream; +} + + +// This struct is used to store parameters and to pass it to wipe tower generator +struct WipeTowerParameters { + WipeTowerParameters() { } // create new empty object + WipeTowerParameters(const std::string& init_data) { // create object and initialize from std::string + std::istringstream in(init_data); // validation of input is left to the caller + in >> bridging >> adhesion >> sampling; + for (std::vector vect{} ; in >> vect ;) { // until we get to fail state ("**")... + if (vect.size()>=3) { + cooling_time.push_back(vect[0]); + ramming_line_width_multiplicator.push_back(vect[1]); + ramming_step_multiplicator.push_back(vect[2]); + vect.erase(vect.begin(),vect.begin()+3); + } + else vect.clear(); // something's not right, we will restore defaults anyway + ramming_speed.push_back(vect); + + if (in.good()) { + in >> vect; + std::vector> pairs; + for (unsigned int i=0;i vect{} ; in >> vect ;) { // let's keep reading + wipe_volumes.push_back(vect); + } + in.clear(); + in.get(); + + std::vector vect{}; + in >> vect; + for (unsigned int i=0;i{7.6, 7.6, 7.6, 7.6, 9.0, 9.0, 9.0, 10.7, 10.7, 10.7}); + ramming_buttons.push_back(std::vector>{{0.05, 6.6},{0.45, 6.8},{0.95, 7.8},{1.45, 8.3},{1.95, 9.7},{2.45,10},{2.95, 7.6},{3.45, 7.6},{3.95, 7.6},{4.45, 7.6},{4.95, 7.6}}); + } + wipe_volumes = {{ 0, 60, 60, 60}, + { 60, 0, 60, 60}, + { 60, 60, 0, 60}, + { 60, 60, 60, 0}}; + filament_wipe_volumes = {{30,30},{30,30},{30,30},{30,30}}; + } + + int bridging = 0.f; + bool adhesion = false; + float sampling = 0.25f; // this does not quite work yet, keep it fixed to 0.25f + std::vector cooling_time; + std::vector ramming_line_width_multiplicator; + std::vector ramming_step_multiplicator; + std::vector> ramming_speed; + std::vector>> ramming_buttons; + std::vector> wipe_volumes; + std::vector> filament_wipe_volumes; +}; + + class WipeTowerPrusaMM : public WipeTower { public: @@ -53,15 +194,16 @@ public: // y -- y coordinates of wipe tower in mm ( left bottom corner ) // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm - WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, unsigned int initial_tool) : + WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, unsigned int initial_tool,std::string& parameters) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), m_wipe_tower_rotation_angle(rotation_angle), m_y_shift(0.f), m_z_pos(0.f), m_is_first_layer(false), - m_is_last_layer(false), - m_current_tool(initial_tool) + m_is_last_layer(false), + m_current_tool(initial_tool), + m_par(parameters) { for (size_t i = 0; i < 4; ++ i) { // Extruder specific parameters. @@ -206,6 +348,7 @@ private: // A fill-in direction (positive Y, negative Y) alternates with each layer. wipe_shape m_current_shape = SHAPE_NORMAL; unsigned int m_current_tool = 0; + WipeTowerParameters m_par; float m_depth_traversed = 0.f; // Current y position at the wipe tower. // How much to wipe the 1st extruder over the wipe tower at the 1st layer @@ -310,6 +453,9 @@ private: float wipe_volume); }; + + + }; // namespace Slic3r #endif /* WipeTowerPrusaMM_hpp_ */ diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 1c63dbf607..fe98612cfe 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -187,6 +187,7 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_x.value), float(this->config.wipe_tower_y.value), float(this->config.wipe_tower_width.value), float(this->config.wipe_tower_per_color_wipe.value), - float(this->config.wipe_tower_rotation_angle.value), m_tool_ordering.first_extruder()); + float(this->config.wipe_tower_rotation_angle.value), m_tool_ordering.first_extruder(), + this->config.wipe_tower_advanced.value); //wipe_tower.set_retract(); //wipe_tower.set_zhop(); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 995dcee99f..7a48b3a32e 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1701,6 +1701,13 @@ PrintConfigDef::PrintConfigDef() def->cli = "wipe-tower!"; def->default_value = new ConfigOptionBool(false); + def = this->add("wipe_tower_advanced", coString); + def->label = _L("Advanced string"); + def->tooltip = _L("Advanced tooltip "); + def->sidetext = _L("advanced sidetext"); + def->cli = "wipe-tower-advanced=s"; + def->default_value = new ConfigOptionString(""); + def = this->add("wipe_tower_x", coFloat); def->label = _L("Position X"); def->tooltip = _L("X coordinate of the left front corner of a wipe tower"); @@ -1723,7 +1730,7 @@ PrintConfigDef::PrintConfigDef() def->default_value = new ConfigOptionFloat(60.); def = this->add("wipe_tower_per_color_wipe", coFloat); - def->label = _L("Per color change depth"); + def->label = "(Unused and will be likely removed)";//_L("Per color change depth"); def->tooltip = _L("Depth of a wipe color per color change. For N colors, there will be " "maximum (N-1) tool switches performed, therefore the total depth " "of the wipe tower will be (N-1) times this value."); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 7c2d404589..d55aafed6b 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -605,6 +605,7 @@ public: ConfigOptionInt threads; ConfigOptionBools wipe; ConfigOptionBool wipe_tower; + ConfigOptionString wipe_tower_advanced; ConfigOptionFloat wipe_tower_x; ConfigOptionFloat wipe_tower_y; ConfigOptionFloat wipe_tower_width; @@ -670,6 +671,7 @@ protected: OPT_PTR(threads); OPT_PTR(wipe); OPT_PTR(wipe_tower); + OPT_PTR(wipe_tower_advanced); OPT_PTR(wipe_tower_x); OPT_PTR(wipe_tower_y); OPT_PTR(wipe_tower_width); diff --git a/xs/src/slic3r/GUI/BedShapeDialog.cpp b/xs/src/slic3r/GUI/BedShapeDialog.cpp index 5ee0c1f8ba..8e7f572410 100644 --- a/xs/src/slic3r/GUI/BedShapeDialog.cpp +++ b/xs/src/slic3r/GUI/BedShapeDialog.cpp @@ -34,7 +34,7 @@ void BedShapeDialog::build_dialog(ConfigOptionPoints* default_pt) void BedShapePanel::build_panel(ConfigOptionPoints* default_pt) { -// on_change(nullptr); +// on_change(nullptr); auto box = new wxStaticBox(this, wxID_ANY, _L("Shape")); auto sbsizer = new wxStaticBoxSizer(box, wxVERTICAL); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 4d55f347ae..be31c1bd1c 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -198,9 +198,9 @@ const std::vector& Preset::print_options() "ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width", "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", - "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", - "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", - "compatible_printers", "compatible_printers_condition" + "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower_advanced", "wipe_tower", "wipe_tower_x", + "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "compatible_printers", + "compatible_printers_condition" }; return s_opts; diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp new file mode 100644 index 0000000000..3b5f4e41e5 --- /dev/null +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -0,0 +1,273 @@ +#include +#include "RammingChart.hpp" + + +wxDEFINE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); + + +void Chart::draw(wxDC& dc) { + dc.SetPen(*wxBLACK_PEN); + dc.SetBrush(*wxWHITE_BRUSH); + dc.DrawRectangle(m_rect); + + if (visible_area->m_width < 0.499) { + dc.DrawText("NO RAMMING AT ALL",wxPoint(m_rect.GetLeft()+m_rect.GetWidth()/2-50,m_rect.GetBottom()-m_rect.GetHeight()/2)); + return; + } + + + if (!m_line_to_draw->empty()) { + for (uint i=0;isize()-2;++i) { + int color = 510*((m_rect.GetBottom()-(*m_line_to_draw)[i])/double(m_rect.GetHeight())); + dc.SetPen( wxPen( wxColor(std::min(255,color),255-std::max(color-255,0),0), 1 ) ); + dc.DrawLine(m_rect.GetLeft()+1+i,(*m_line_to_draw)[i],m_rect.GetLeft()+1+i,m_rect.GetBottom()); + } + dc.SetPen( wxPen( wxColor(0,0,0), 1 ) ); + for (uint i=0;isize()-2;++i) { + if (splines) + dc.DrawLine(m_rect.GetLeft()+i,(*m_line_to_draw)[i],m_rect.GetLeft()+i+1,(*m_line_to_draw)[i+1]); + else { + dc.DrawLine(m_rect.GetLeft()+i,(*m_line_to_draw)[i],m_rect.GetLeft()+i+1,(*m_line_to_draw)[i]); + dc.DrawLine(m_rect.GetLeft()+i+1,(*m_line_to_draw)[i],m_rect.GetLeft()+i+1,(*m_line_to_draw)[i+1]); + } + } + } + + // draw draggable buttons + dc.SetBrush(*wxBLUE_BRUSH); + dc.SetPen( wxPen( wxColor(0,0,0), 1 ) ); + for (auto& button : m_buttons[m_current_extruder]) + //dc.DrawRectangle(math_to_screen(button.get_pos())-wxPoint(side/2.,side/2.), wxSize(side,side)); + dc.DrawCircle(math_to_screen(button.get_pos()),side/2.); + //dc.DrawRectangle(math_to_screen(button.get_pos()-wxPoint2DDouble(0.125,0))-wxPoint(0,5),wxSize(50,10)); + + // draw x-axis: + float last_mark = -10000; + for (float math_x=int(visible_area->m_x*10)/10 ; math_x <= (visible_area->m_x+visible_area->m_width) ; math_x+=0.1) { + int x = math_to_screen(wxPoint2DDouble(math_x,visible_area->m_y)).x; + int y = m_rect.GetBottom(); + if (x-last_mark < 50) continue; + dc.DrawLine(x,y+3,x,y-3); + dc.DrawText(wxString().Format(wxT("%.1f"), math_x),wxPoint(x-10,y+7)); + last_mark = x; + } + + // draw y-axis: + last_mark=10000; + for (int math_y=visible_area->m_y ; math_y <= (visible_area->m_y+visible_area->m_height) ; math_y+=1) { + int y = math_to_screen(wxPoint2DDouble(visible_area->m_x,math_y)).y; + int x = m_rect.GetLeft(); + if (last_mark-y < 50) continue; + dc.DrawLine(x-3,y,x+3,y); + dc.DrawText(wxString()<2) { + m_buttons[m_current_extruder].erase(m_buttons[m_current_extruder].begin()+button_index); + recalculate_line(); + } +} + + + +void Chart::mouse_clicked(wxMouseEvent& event) { + wxPoint point = event.GetPosition(); + int button_index = which_button_is_clicked(point); + if ( button_index != -1) { + m_dragged = &m_buttons[m_current_extruder][button_index]; + m_previous_mouse = point; + } +} + + + +void Chart::mouse_moved(wxMouseEvent& event) { + if (!event.Dragging() || !m_dragged) return; + wxPoint pos = event.GetPosition(); + wxRect rect = m_rect; + rect.Deflate(side/2.); + if (!(rect.Contains(pos))) { // the mouse left chart area + mouse_left_window(event); + return; + } + int delta_x = pos.x - m_previous_mouse.x; + int delta_y = pos.y - m_previous_mouse.y; + m_dragged->move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area->m_width,-double(delta_y)/m_rect.GetHeight() * visible_area->m_height); + m_previous_mouse = pos; + recalculate_line(); +} + + + +void Chart::mouse_double_clicked(wxMouseEvent& event) { + if (!manual_points_manipulation) + return; + wxPoint point = event.GetPosition(); + if (!m_rect.Contains(point)) // the click is outside the chart + return; + m_buttons[m_current_extruder].push_back(screen_to_math(point)); + std::sort(m_buttons[m_current_extruder].begin(),m_buttons[m_current_extruder].end()); + recalculate_line(); + return; +} + + + + +void Chart::recalculate_line() { + std::vector points; + for (auto& but : m_buttons[m_current_extruder]) { + points.push_back(wxPoint(math_to_screen(but.get_pos()))); + if (points.size()>1 && points.back().x==points[points.size()-2].x) points.pop_back(); + if (points.size()>1 && points.back().x > m_rect.GetRight()) { + points.pop_back(); + break; + } + } + std::sort(points.begin(),points.end(),[](wxPoint& a,wxPoint& b) { return a.x < b.x; }); + + m_line_to_draw->clear(); + m_total_volume = 0.f; + + + // Cubic spline interpolation: see https://en.wikiversity.org/wiki/Cubic_Spline_Interpolation#Methods + const bool boundary_first_derivative = true; // true - first derivative is 0 at the leftmost and rightmost point + // false - second ---- || ------- + const int N = points.size()-1; // last point can be accessed as N, we have N+1 total points + std::vector diag(N+1); + std::vector mu(N+1); + std::vector lambda(N+1); + std::vector h(N+1); + std::vector rhs(N+1); + + // let's fill in inner equations + for (int i=1;i<=N;++i) h[i] = points[i].x-points[i-1].x; + std::fill(diag.begin(),diag.end(),2.f); + for (int i=1;i<=N-1;++i) { + mu[i] = h[i]/(h[i]+h[i+1]); + lambda[i] = 1.f - mu[i]; + rhs[i] = 6 * ( float(points[i+1].y-points[i].y )/(h[i+1]*(points[i+1].x-points[i-1].x)) - + float(points[i].y -points[i-1].y)/(h[i] *(points[i+1].x-points[i-1].x)) ); + } + + // now fill in the first and last equations, according to boundary conditions: + if (boundary_first_derivative) { + const float endpoints_derivative = 0; + lambda[0] = 1; + mu[N] = 1; + rhs[0] = (6.f/h[1]) * (float(points[0].y-points[1].y)/(points[0].x-points[1].x) - endpoints_derivative); + rhs[N] = (6.f/h[N]) * (endpoints_derivative - float(points[N-1].y-points[N].y)/(points[N-1].x-points[N].x)); + } + else { + lambda[0] = 0; + mu[N] = 0; + rhs[0] = 0; + rhs[N] = 0; + } + + // the trilinear system is ready to be solved: + for (int i=1;i<=N;++i) { + float multiple = mu[i]/diag[i-1]; // let's subtract proper multiple of above equation + diag[i]-= multiple * lambda[i-1]; + rhs[i] -= multiple * rhs[i-1]; + } + // now the back substitution (vector mu contains invalid values from now on): + rhs[N] = rhs[N]/diag[N]; + for (int i=N-1;i>=0;--i) + rhs[i] = (rhs[i]-lambda[i]*rhs[i+1])/diag[i]; + + + + + unsigned int i=1; + float y=0.f; + for (int x=m_rect.GetLeft(); x<=m_rect.GetRight() ; ++x) { + if (splines) { + if (i x) + y = points[0].y; + else + if (points[N].x < x) + y = points[N].y; + else + y = (rhs[i-1]*pow(points[i].x-x,3)+rhs[i]*pow(x-points[i-1].x,3)) / (6*h[i]) + + (points[i-1].y-rhs[i-1]*h[i]*h[i]/6.f) * (points[i].x-x)/h[i] + + (points[i].y -rhs[i] *h[i]*h[i]/6.f) * (x-points[i-1].x)/h[i]; + m_line_to_draw->push_back(y); + } + else { + float x_math = screen_to_math(wxPoint(x,0)).m_x; + if (i+2<=points.size() && m_buttons[m_current_extruder][i+1].get_pos().m_x-0.125 < x_math) + ++i; + m_line_to_draw->push_back(math_to_screen(wxPoint2DDouble(x_math,m_buttons[m_current_extruder][i].get_pos().m_y)).y); + } + + + m_line_to_draw->back() = std::max(m_line_to_draw->back(), m_rect.GetTop()-1); + m_line_to_draw->back() = std::min(m_line_to_draw->back(), m_rect.GetBottom()-1); + m_total_volume += (m_rect.GetBottom() - m_line_to_draw->back()) * (visible_area->m_width / m_rect.GetWidth()) * (visible_area->m_height / m_rect.GetHeight()); + } + + wxPostEvent(this->GetParent(), wxCommandEvent(EVT_WIPE_TOWER_CHART_CHANGED)); + Refresh(); +} + + + +std::vector> Chart::get_ramming_speeds(float sampling) const { + std::vector> speeds_out; + for (unsigned int extruder_id = 0;extruder_id this_extruder; + const int number_of_samples = std::round( visible_areas[extruder_id].m_width / sampling); + if (number_of_samples>0) { + const int dx = (m_lines_to_draw[extruder_id].size()-1) / number_of_samples; + for (int j=0;j>> Chart::get_buttons() const { + std::vector>> buttons_out; + for (const auto& ext : m_buttons) { + std::vector> this_extruder; + for (const auto& button : ext) + this_extruder.push_back(std::make_pair(button.get_pos().m_x,button.get_pos().m_y)); + buttons_out.push_back(std::move(this_extruder)); + } + return buttons_out; +} + + + + +BEGIN_EVENT_TABLE(Chart, wxWindow) +EVT_MOTION(Chart::mouse_moved) +EVT_LEFT_DOWN(Chart::mouse_clicked) +EVT_LEFT_UP(Chart::mouse_released) +EVT_LEFT_DCLICK(Chart::mouse_double_clicked) +EVT_RIGHT_DOWN(Chart::mouse_right_button_clicked) +EVT_LEAVE_WINDOW(Chart::mouse_left_window) +EVT_PAINT(Chart::paint_event) +END_EVENT_TABLE() diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp new file mode 100644 index 0000000000..5443e957a8 --- /dev/null +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -0,0 +1,129 @@ +#ifndef RAMMING_CHART_H_ +#define RAMMING_CHART_H_ + +#include +#include +#ifndef WX_PRECOMP + #include +#endif + +wxDECLARE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); + + +class Chart : public wxWindow { + +public: + Chart(wxWindow* parent, wxRect rect,const std::vector>>& initial_buttons,std::vector> ramming_speed, float sampling) : + wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize()) + { + m_rect=wxRect(wxPoint(30,0),rect.GetSize()-wxSize(30,30)); + for (int i=0;i<4;++i) { + visible_areas.push_back(wxRect2DDouble(0.0, 0.0, sampling*ramming_speed[i].size(), 20.)); + m_buttons.push_back(std::vector()); + m_lines_to_draw.push_back(std::vector()); + if (initial_buttons.size()>0) + for (const auto& pair : initial_buttons[i]) + m_buttons.back().push_back(wxPoint2DDouble(pair.first,pair.second)); + set_extruder(i); // to calculate all interpolating splines + } + set_extruder(0); + } + void set_extruder(unsigned ext) { + if (ext>=4) return; + m_current_extruder = ext; + visible_area = &(visible_areas[ext]); + m_line_to_draw = &(m_lines_to_draw[ext]); + recalculate_line(); + } + void set_xy_range(float x,float y) { + x = int(x/0.5) * 0.5; + if (x>=0) visible_area->SetRight(x); + if (y>=0) visible_area->SetBottom(y); + recalculate_line(); + } + float get_volume() const { return m_total_volume; } + float get_time() const { return visible_area->m_width; } + std::vector> get_ramming_speeds(float sampling) const; //returns sampled ramming speed for all extruders + std::vector>> get_buttons() const; // returns buttons position for all extruders + + + void draw(wxDC& dc); + + void mouse_clicked(wxMouseEvent& event); + void mouse_right_button_clicked(wxMouseEvent& event); + void mouse_moved(wxMouseEvent& event); + void mouse_double_clicked(wxMouseEvent& event); + void mouse_left_window(wxMouseEvent&) { m_dragged = nullptr; } + void mouse_released(wxMouseEvent&) { m_dragged = nullptr; } + void paint_event(wxPaintEvent&) { wxPaintDC dc(this); draw(dc); } + DECLARE_EVENT_TABLE() + + + +private: + static const bool fixed_x = true; + static const bool splines = true; + static const bool manual_points_manipulation = false; + static const int side = 10; // side of draggable button + + class ButtonToDrag { + public: + bool operator<(ButtonToDrag& a) { return m_pos.m_x < a.m_pos.m_x; } + ButtonToDrag(wxPoint2DDouble pos) : m_pos{pos} {}; + wxPoint2DDouble get_pos() const { return m_pos; } + void move(double x,double y) { m_pos.m_x+=x; m_pos.m_y+=y; } + private: + wxPoint2DDouble m_pos; // position in math coordinates + }; + + + + wxPoint math_to_screen(const wxPoint2DDouble& math) const { + wxPoint screen; + screen.x = (math.m_x-visible_area->m_x) * (m_rect.GetWidth() / visible_area->m_width ); + screen.y = (math.m_y-visible_area->m_y) * (m_rect.GetHeight() / visible_area->m_height ); + screen.y *= -1; + screen += m_rect.GetLeftBottom(); + return screen; + } + wxPoint2DDouble screen_to_math(const wxPoint& screen) const { + wxPoint2DDouble math = screen; + math -= m_rect.GetLeftBottom(); + math.m_y *= -1; + math.m_x *= visible_area->m_width / m_rect.GetWidth(); // scales to [0;1]x[0,1] + math.m_y *= visible_area->m_height / m_rect.GetHeight(); + return (math+visible_area->GetLeftTop()); + } + + int which_button_is_clicked(const wxPoint& point) const { + if (!m_rect.Contains(point)) + return -1; + for (uint i=0;i > m_buttons; + std::vector< std::vector > m_lines_to_draw; + std::vector< wxRect2DDouble > visible_areas; + wxRect2DDouble* visible_area = nullptr; + std::vector* m_line_to_draw = nullptr; + ButtonToDrag* m_dragged = nullptr; + float m_total_volume = 0.f; + + +}; + + +#endif // RAMMING_CHART_H_ \ No newline at end of file diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ebfa69eb5b..7e1ad5dc57 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -3,6 +3,7 @@ #include "PresetBundle.hpp" #include "PresetHints.hpp" #include "../../libslic3r/Utils.hpp" +#include "WipeTowerDialog.hpp" #include #include @@ -440,6 +441,7 @@ void TabPrint::build() optgroup->append_single_option_line("ooze_prevention"); optgroup->append_single_option_line("standby_temperature_delta"); + if (true) { optgroup = page->new_optgroup(_L("Wipe tower")); optgroup->append_single_option_line("wipe_tower"); optgroup->append_single_option_line("wipe_tower_x"); @@ -447,6 +449,27 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_width"); optgroup->append_single_option_line("wipe_tower_per_color_wipe"); optgroup->append_single_option_line("wipe_tower_rotation_angle"); + Line line{ _L("Advanced"), "" }; + line.widget = [this](wxWindow* parent){ + m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _L("Advanced settings")+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); + auto sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(m_wipe_tower_btn); + m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) + { + std::string init_data = (m_config->option("wipe_tower_advanced"))->value; + std::cout << "dialog init: " << init_data << std::endl; + WipeTowerDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy + + if (dlg.ShowModal() == wxID_OK) { + load_key_value("wipe_tower_advanced", dlg.GetValue()); + std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl; + } + })); + return sizer; + }; + optgroup->append_line(line); + } + optgroup = page->new_optgroup(_L("Advanced")); optgroup->append_single_option_line("interface_shells"); @@ -766,6 +789,7 @@ void TabPrint::update() vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle"}; for (auto el : vec_enable) get_field(el)->toggle(have_wipe_tower); + m_wipe_tower_btn->Enable(have_wipe_tower); m_recommended_thin_wall_thickness_description_line->SetText( PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 4f3a157361..b6d273e382 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -90,6 +90,7 @@ protected: wxImageList* m_icons; wxCheckBox* m_compatible_printers_checkbox; wxButton* m_compatible_printers_btn; + wxButton* m_wipe_tower_btn; int m_icon_count; std::map m_icon_index; // Map from an icon file name to its index in $self->{icons}. diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp new file mode 100644 index 0000000000..5b188e6d1b --- /dev/null +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -0,0 +1,264 @@ +#include "WipeTowerDialog.hpp" + +// Human-readable output of Parameters structure +std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par) { + str << "bridging: " << par.bridging << "\n"; + str << "adhesion: " << par.adhesion << "\n"; + str << "sampling: " << par.sampling << "\n"; + + str << "cooling times: "; + for (const auto& a : par.cooling_time) str << a << " "; + + str << "line widths: "; + for (const auto& a : par.ramming_line_width_multiplicator) str << a << " "; + + str << "line spacing: "; + for (const auto& a : par.ramming_step_multiplicator) str << a << " "; + + str<<"\n\nramming_speeds:\n"; + for (const auto& a : par.ramming_speed) { + for (const auto& b : a) + str << b << " "; + str<<"\n"; + } + str<<"\n\nramming_buttons:\n"; + for (const auto& a : par.ramming_buttons) { + for (const auto& b : a) { + Slic3r::operator <<(str,b); // temporary hack (this << is in the namespace Slic3r) + str << " | "; // the function will be deleted after everything is debugged, anyway + } + str<<"\n"; + } + str<<"\n\nwipe volumes:\n"; + for (const auto& a : par.wipe_volumes) { + for (const auto& b : a) + str << b << " "; + str<<"\n"; + } + str<<"\n\nfilament wipe volumes:\n"; + for (const auto& a : par.filament_wipe_volumes) { + Slic3r::operator <<(str,a); + str << " "; + } + str<<"\n"; + + return str; +} + + + + +RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) +: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) +{ + new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT); + m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString, wxPoint(700,100), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0.,5.0,3.,0.5); + new wxStaticText(this,wxID_ANY,wxString("Total rammed volume (mm3):"), wxPoint(500,135), wxSize(200,25),wxALIGN_LEFT); + m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,130), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0,10000,0); + new wxStaticText(this,wxID_ANY,wxString("Ramming line width (%):"), wxPoint(500,205), wxSize(200,25),wxALIGN_LEFT); + m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,200), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100); + new wxStaticText(this,wxID_ANY,wxString("Ramming line spacing (%):"), wxPoint(500,235), wxSize(200,25),wxALIGN_LEFT); + m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,230), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100); + new wxStaticText(this,wxID_ANY,wxString("Extruder #:"), wxPoint(500,12), wxSize(200,25),wxALIGN_LEFT); + + wxArrayString choices; + for (unsigned int i=0;iset_extruder(0); + m_widget_time->SetValue(m_chart->get_time()); + m_widget_time->SetDigits(2); + m_widget_volume->SetValue(m_chart->get_volume()); + m_widget_volume->Disable(); + m_widget_extruder->SetSelection(0); + extruder_selection_changed(); // tell everyone to redraw + + m_widget_ramming_step_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); }); + m_widget_ramming_line_width_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); }); + m_widget_extruder->Bind(wxEVT_CHOICE,[this](wxCommandEvent&) { extruder_selection_changed(); }); + m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);}); + m_widget_time->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value + m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value + Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} ); +} + +void RammingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) +{ + if (!m_chart) return; + p.ramming_buttons = m_chart->get_buttons(); + p.ramming_speed = m_chart->get_ramming_speeds(p.sampling); + for (unsigned int i=0;iGetSelection(); + m_chart->set_extruder(m_current_extruder); // tell our chart to redraw + m_widget_ramming_line_width_multiplicator ->SetValue(m_ramming_line_width_multiplicators[m_current_extruder]); + m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicators[m_current_extruder]); +} + +void RammingPanel::line_parameters_changed() { + m_ramming_line_width_multiplicators[m_current_extruder]=m_widget_ramming_line_width_multiplicator->GetValue(); + m_ramming_step_multiplicators[m_current_extruder]=m_widget_ramming_step_multiplicator->GetValue(); +} + + + + + + +CoolingPanel::CoolingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) +: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) +{ + new wxStaticText(this,wxID_ANY,wxString("Time (in seconds) reserved for cooling after unload:"),wxPoint(220,50) ,wxSize(400,25),wxALIGN_LEFT); + for (int i=0;i<4;++i) { + new wxStaticText(this,wxID_ANY,wxString("Filament #")<=m_widget_edits.size()) + break; // so we don't initialize non-existent widget + m_widget_edits[i]->SetValue(p.cooling_time[i]); + } +} + +void CoolingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { + p.cooling_time.clear(); + for (int i=0;i<4;++i) + p.cooling_time.push_back(m_widget_edits[i]->GetValue()); +} + + + +WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) +: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) +{ + const int N = 4; // number of extruders + new wxStaticText(this,wxID_ANY,wxString("Volume to wipe when the filament is being"),wxPoint(40,55) ,wxSize(500,25)); + new wxStaticText(this,wxID_ANY,wxString("unloaded"),wxPoint(110,75) ,wxSize(500,25)); + new wxStaticText(this,wxID_ANY,wxString("loaded"),wxPoint(195,75) ,wxSize(500,25)); + m_widget_button = new wxButton(this,wxID_ANY,"-> Fill in the matrix ->",wxPoint(300,130),wxSize(175,50)); + for (int i=0;i(0)); + new wxStaticText(this,wxID_ANY,wxString("")<Disable(); + else + edit_boxes[i][j]->SetValue(wxString("")<Bind(wxEVT_BUTTON,[this](wxCommandEvent&){fill_in_matrix();}); +} + +void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { + p.wipe_volumes.clear(); + p.filament_wipe_volumes.clear(); + for (int i=0;i<4;++i) { + // first go through the full matrix: + p.wipe_volumes.push_back(std::vector()); + for (int j=0;j<4;++j) { + double val = 0.; + edit_boxes[j][i]->GetValue().ToDouble(&val); + p.wipe_volumes[i].push_back((float)val); + } + + // now the filament volumes: + p.filament_wipe_volumes.push_back(std::make_pair(m_old[i]->GetValue(),m_new[i]->GetValue())); + } +} + +void WipingPanel::fill_in_matrix() { + wxArrayString choices; + choices.Add("sum"); + choices.Add("maximum"); + wxSingleChoiceDialog dialog(this,"How shall I calculate volume for any given pair?\n\nI can either sum volumes for old and new filament, or just use the higher value.","DEBUGGING",choices); + if (dialog.ShowModal() == wxID_CANCEL) + return; + for (unsigned i=0;i<4;++i) { + for (unsigned j=0;j<4;++j) { + if (i==j) continue; + if (!dialog.GetSelection()) edit_boxes[j][i]->SetValue(wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue())); + else + edit_boxes[j][i]->SetValue(wxString("")<< (std::max(m_old[i]->GetValue(), m_new[j]->GetValue()))); + } + } +} + + + +GeneralPanel::GeneralPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) : wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) { + new wxStaticText(this,wxID_ANY,wxString("Maximum bridging over sparse infill (mm):"),wxPoint(100,105) ,wxSize(280,25),wxALIGN_LEFT); + m_widget_bridge = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxPoint(380,100),wxSize(50,25),wxALIGN_RIGHT|wxSP_ARROW_KEYS,1,50,10); + m_widget_adhesion = new wxCheckBox(this,wxID_ANY,"Increased adhesion of first layer",wxPoint(100,150),wxSize(330,25),wxALIGN_RIGHT); + m_widget_bridge->SetValue(p.bridging); + m_widget_adhesion->SetValue(p.adhesion); +} + +void GeneralPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { + p.bridging = m_widget_bridge->GetValue(); + p.adhesion = m_widget_adhesion->GetValue(); +} + + + + + +WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data) +: wxDialog(parent, -1, wxT("Wipe tower advanced settings"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +{ + this->Centre(); + + Slic3r::WipeTowerParameters parameters(init_data); + if (!parameters.validate()) { + wxMessageDialog(this,"Wipe tower parameters not parsed correctly!\nRestoring default settings.","Error",wxICON_ERROR); + parameters.set_defaults(); + } + + wxNotebook* notebook = new wxNotebook(this,wxID_ANY,wxPoint(0,0),wxSize(800,450)); + + m_panel_general = new GeneralPanel(notebook,parameters); + m_panel_ramming = new RammingPanel(notebook,parameters); + m_panel_cooling = new CoolingPanel(notebook,parameters); + m_panel_wiping = new WipingPanel(notebook,parameters); + notebook->AddPage(m_panel_general,"General"); + notebook->AddPage(m_panel_ramming,"Ramming"); + notebook->AddPage(m_panel_cooling,"Cooling"); + notebook->AddPage(m_panel_wiping,"Wiping"); + this->Show(); + + auto main_sizer = new wxBoxSizer(wxVERTICAL); + main_sizer->Add(notebook, 1, wxEXPAND); + main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); + SetSizer(main_sizer); + SetMinSize(GetSize()); + main_sizer->SetSizeHints(this); + + this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); + + this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { + m_output_data=read_dialog_values(); + EndModal(wxID_OK); + },wxID_OK); +} + diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp new file mode 100644 index 0000000000..452886bc36 --- /dev/null +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -0,0 +1,115 @@ +#ifndef _WIPE_TOWER_DIALOG_H_ +#define _WIPE_TOWER_DIALOG_H_ + +#include +#include +#include +#include +#include +#include +#include + +#include "../../libslic3r/GCode/WipeTowerPrusaMM.hpp" +#include "RammingChart.hpp" + + +// Human-readable output of Parameters structure +std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par); + + +class RammingPanel : public wxPanel { +public: + RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); + void fill_parameters(Slic3r::WipeTowerParameters& p); + +private: + Chart* m_chart = nullptr; + wxSpinCtrl* m_widget_volume = nullptr; + wxSpinCtrl* m_widget_ramming_line_width_multiplicator = nullptr; + wxSpinCtrl* m_widget_ramming_step_multiplicator = nullptr; + wxSpinCtrlDouble* m_widget_time = nullptr; + wxChoice* m_widget_extruder = nullptr; + std::vector m_ramming_step_multiplicators; + std::vector m_ramming_line_width_multiplicators; + int m_current_extruder = 0; // zero-based index + + void extruder_selection_changed(); + + void line_parameters_changed(); +}; + + + + + + +class CoolingPanel : public wxPanel { +public: + CoolingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); + void fill_parameters(Slic3r::WipeTowerParameters& p); + +private: + std::vector m_widget_edits; +}; + + + + + + +class WipingPanel : public wxPanel { +public: + WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); + void fill_parameters(Slic3r::WipeTowerParameters& p); + +private: + void fill_in_matrix(); + + std::vector m_old; + std::vector m_new; + std::vector> edit_boxes; + wxButton* m_widget_button=nullptr; +}; + + + + +class GeneralPanel : public wxPanel { +public: + GeneralPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); + void fill_parameters(Slic3r::WipeTowerParameters& p); + +private: + wxSpinCtrl* m_widget_bridge; + wxCheckBox* m_widget_adhesion; +}; + + + + +class WipeTowerDialog : public wxDialog { +public: + WipeTowerDialog(wxWindow* parent,const std::string& init_data); + + std::string GetValue() const { return m_output_data; } + + +private: + std::string m_file_name="config_wipe_tower"; + GeneralPanel* m_panel_general = nullptr; + RammingPanel* m_panel_ramming = nullptr; + CoolingPanel* m_panel_cooling = nullptr; + WipingPanel* m_panel_wiping = nullptr; + std::string m_output_data = ""; + + std::string read_dialog_values() { + Slic3r::WipeTowerParameters p; + m_panel_general->fill_parameters(p); + m_panel_ramming->fill_parameters(p); + m_panel_cooling->fill_parameters(p); + m_panel_wiping ->fill_parameters(p); + return p.to_string(); + } +}; + +#endif // _WIPE_TOWER_DIALOG_H_ \ No newline at end of file From 9ea803b000c6de4a4ccfb0d39e88ef69555cb1c1 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 28 Feb 2018 19:53:32 +0100 Subject: [PATCH 0017/1150] Attempts to fix OSX and Win builds --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 19 ++----------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 31 +++++++++------------ xs/src/slic3r/GUI/RammingChart.hpp | 2 +- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index d7492fdbb0..004aaf0de7 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -31,8 +31,7 @@ TODO LIST #define strcasecmp _stricmp #endif -constexpr bool peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet -constexpr float min_layer_difference = 2*m_perimeter_width; +const bool peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet namespace Slic3r { @@ -468,7 +467,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( // therefore the homing position is shifted inside the bed by 0.2 in the firmware to [0.2, -2.0]. // box_coordinates cleaning_box(xy(0.5f, - 1.5f), m_wipe_tower_width, wipe_area); //FIXME: set the width properly - constexpr float prime_section_width = 60.f; + const float prime_section_width = 60.f; box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, 15.f); PrusaMultiMaterial::Writer writer; @@ -1191,18 +1190,6 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi depth *= m_extra_spacing; m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth)); - - // Calculate m_wipe_tower_depth (maximum depth for all the layers) and propagate depths downwards - /*float this_layer_depth = m_plan.back().toolchanges_depth(); - m_plan.back().depth = this_layer_depth; - - if (this_layer_depth > m_wipe_tower_depth - m_perimeter_width) - m_wipe_tower_depth = this_layer_depth + m_perimeter_width; - for (int i = m_plan.size() - 2; i >= 0 && m_plan[i].depth < this_layer_depth; i-- ) { - if ( this_layer_depth - m_plan[i].depth < min_layer_difference && !m_plan[i].tool_changes.empty()) - m_plan[i].depth += this_layer_depth - m_plan[i].depth; - m_plan[i].depth = this_layer_depth; - }*/ } @@ -1224,7 +1211,7 @@ void WipeTowerPrusaMM::plan_tower() for (int i = layer_index - 1; i >= 0 /*&& m_plan[i].depth < this_layer_depth*/; i--) { - if (m_plan[i].depth - this_layer_depth < min_layer_difference ) + if (m_plan[i].depth - this_layer_depth < 2*m_perimeter_width ) m_plan[i].depth = this_layer_depth; } } diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 43163a73a5..ef58f6c568 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -10,22 +10,17 @@ #include "WipeTower.hpp" // Following is used to calculate extrusion flow - should be taken from config in future -constexpr float Filament_Area = M_PI * 1.75f * 1.75f / 4.f; // filament area in mm^3 -constexpr float Nozzle_Diameter = 0.4f; // nozzle diameter in mm +const float Filament_Area = M_PI * 1.75f * 1.75f / 4.f; // filament area in mm^3 +const float Nozzle_Diameter = 0.4f; // nozzle diameter in mm // desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust -constexpr float Width_To_Nozzle_Ratio = 1.25f; +const float Width_To_Nozzle_Ratio = 1.25f; // m_perimeter_width was hardcoded until now as 0.5 (for 0.4 nozzle and 0.2 layer height) // FIXME m_perimeter_width is used in plan_toolchange - take care of proper initialization value when changing to variable -constexpr float Konst = 1.f; -constexpr float m_perimeter_width = Nozzle_Diameter * Width_To_Nozzle_Ratio * Konst; - -constexpr float WT_EPSILON = 1e-3f; - - - - +const float Konst = 1.f; +const float m_perimeter_width = Nozzle_Diameter * Width_To_Nozzle_Ratio * Konst; +const float WT_EPSILON = 1e-3f; namespace Slic3r @@ -147,14 +142,14 @@ struct WipeTowerParameters { ramming_speed.clear(); ramming_buttons.clear(); for (unsigned int i=0;i<4;++i) { - ramming_speed.push_back(std::vector{7.6, 7.6, 7.6, 7.6, 9.0, 9.0, 9.0, 10.7, 10.7, 10.7}); - ramming_buttons.push_back(std::vector>{{0.05, 6.6},{0.45, 6.8},{0.95, 7.8},{1.45, 8.3},{1.95, 9.7},{2.45,10},{2.95, 7.6},{3.45, 7.6},{3.95, 7.6},{4.45, 7.6},{4.95, 7.6}}); + ramming_speed.push_back(std::vector{7.6f, 7.6f, 7.6f, 7.6f, 9.f, 9.f, 9.f, 10.7f, 10.7f, 10.7f}); + ramming_buttons.push_back(std::vector>{{0.05f, 6.6f},{0.45f, 6.8f},{0.95f, 7.8f},{1.45f, 8.3f},{1.95f, 9.7f},{2.45f,10.f},{2.95f, 7.6f},{3.45f, 7.6f},{3.95f, 7.6f},{4.45f, 7.6f},{4.95f, 7.6f}}); } - wipe_volumes = {{ 0, 60, 60, 60}, - { 60, 0, 60, 60}, - { 60, 60, 0, 60}, - { 60, 60, 60, 0}}; - filament_wipe_volumes = {{30,30},{30,30},{30,30},{30,30}}; + wipe_volumes = {{ 0.f, 60.f, 60.f, 60.f}, + { 60.f, 0.f, 60.f, 60.f}, + { 60.f, 60.f, 0.f, 60.f}, + { 60.f, 60.f, 60.f, 0.f}}; + filament_wipe_volumes = {{30.f,30.f},{30.f,30.f},{30.f,30.f},{30.f,30.f}}; } int bridging = 0.f; diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp index 5443e957a8..5b7f6daf8c 100644 --- a/xs/src/slic3r/GUI/RammingChart.hpp +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -68,7 +68,7 @@ private: class ButtonToDrag { public: - bool operator<(ButtonToDrag& a) { return m_pos.m_x < a.m_pos.m_x; } + bool operator<(const ButtonToDrag& a) const { return m_pos.m_x < a.m_pos.m_x; } ButtonToDrag(wxPoint2DDouble pos) : m_pos{pos} {}; wxPoint2DDouble get_pos() const { return m_pos; } void move(double x,double y) { m_pos.m_x+=x; m_pos.m_y+=y; } From b1b16359d9b54d225742233ebb45d67bb6243094 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 1 Mar 2018 08:43:43 +0100 Subject: [PATCH 0018/1150] Changes in includes in order to fix Win builds --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 2 ++ xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 004aaf0de7..fdfd8752f6 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -20,6 +20,8 @@ TODO LIST #include #include #include +#include +#include #include "Analyzer.hpp" diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index ef58f6c568..58e5c0ee6a 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -1,7 +1,6 @@ #ifndef WipeTowerPrusaMM_hpp_ #define WipeTowerPrusaMM_hpp_ -#include #include #include #include From c76c075569effe7b20f28c3217f8fd5c568b890d Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 1 Mar 2018 09:19:34 +0100 Subject: [PATCH 0019/1150] Yet another attempt to fix Win builds --- xs/src/slic3r/GUI/RammingChart.hpp | 2 +- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp index 5b7f6daf8c..e04f4b52e5 100644 --- a/xs/src/slic3r/GUI/RammingChart.hpp +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -98,7 +98,7 @@ private: int which_button_is_clicked(const wxPoint& point) const { if (!m_rect.Contains(point)) return -1; - for (uint i=0;i #include "WipeTowerDialog.hpp" // Human-readable output of Parameters structure From 1d787a15a0cc3ef798bf993b8c1202d3c747bdd1 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 1 Mar 2018 09:57:51 +0100 Subject: [PATCH 0020/1150] Fix for win builds --- xs/src/slic3r/GUI/RammingChart.cpp | 4 ++-- xs/src/slic3r/GUI/RammingChart.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp index 3b5f4e41e5..3b535aacf5 100644 --- a/xs/src/slic3r/GUI/RammingChart.cpp +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -17,13 +17,13 @@ void Chart::draw(wxDC& dc) { if (!m_line_to_draw->empty()) { - for (uint i=0;isize()-2;++i) { + for (unsigned int i=0;isize()-2;++i) { int color = 510*((m_rect.GetBottom()-(*m_line_to_draw)[i])/double(m_rect.GetHeight())); dc.SetPen( wxPen( wxColor(std::min(255,color),255-std::max(color-255,0),0), 1 ) ); dc.DrawLine(m_rect.GetLeft()+1+i,(*m_line_to_draw)[i],m_rect.GetLeft()+1+i,m_rect.GetBottom()); } dc.SetPen( wxPen( wxColor(0,0,0), 1 ) ); - for (uint i=0;isize()-2;++i) { + for (unsigned int i=0;isize()-2;++i) { if (splines) dc.DrawLine(m_rect.GetLeft()+i,(*m_line_to_draw)[i],m_rect.GetLeft()+i+1,(*m_line_to_draw)[i+1]); else { diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp index e04f4b52e5..8274b96e69 100644 --- a/xs/src/slic3r/GUI/RammingChart.hpp +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -111,7 +111,7 @@ private: void recalculate_volume(); - unsigned m_current_extruder = 0; + unsigned int m_current_extruder = 0; wxRect m_rect; // rectangle on screen the chart is mapped into (screen coordinates) wxPoint m_previous_mouse; std::vector< std::vector > m_buttons; From d2006c8d8ec32735fb8518855bc7df18cf502047 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 1 Mar 2018 16:15:00 +0100 Subject: [PATCH 0021/1150] Cooling tubes parameters added into GUI and configuration layer (not yet into wipe tower generator) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 8 ++++++- xs/src/libslic3r/Print.cpp | 8 +++++-- xs/src/libslic3r/PrintConfig.cpp | 25 +++++++++++++++++++++ xs/src/libslic3r/PrintConfig.hpp | 6 +++++ xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 3 +++ 6 files changed, 48 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 58e5c0ee6a..c05f2aebeb 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -188,7 +188,9 @@ public: // y -- y coordinates of wipe tower in mm ( left bottom corner ) // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm - WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, unsigned int initial_tool,std::string& parameters) : + WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, float cooling_tube_retraction, + float cooling_tube_length, float parking_pos_retraction, std::string& parameters, + unsigned int initial_tool) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), m_wipe_tower_rotation_angle(rotation_angle), @@ -199,6 +201,7 @@ public: m_current_tool(initial_tool), m_par(parameters) { + printf("Jsem konstruktor WT a vidim cisla %f,%f,%f\n",cooling_tube_retraction,cooling_tube_length,parking_pos_retraction); for (size_t i = 0; i < 4; ++ i) { // Extruder specific parameters. m_material[i] = PLA; @@ -325,6 +328,9 @@ private: // G-code generator parameters. float m_zhop = 0.5f; float m_retract = 4.f; + float m_cooling_tube_retraction = 0.f; + float m_cooling_tube_length = 0.f; + float m_parking_pos_retraction = 0.f; float m_line_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_extrusion_flow = 0.038; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index fe98612cfe..020af76100 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -90,6 +90,8 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_x.value), float(this->config.wipe_tower_y.value), float(this->config.wipe_tower_width.value), float(this->config.wipe_tower_per_color_wipe.value), - float(this->config.wipe_tower_rotation_angle.value), m_tool_ordering.first_extruder(), - this->config.wipe_tower_advanced.value); + float(this->config.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), + float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), + this->config.wipe_tower_advanced.value,m_tool_ordering.first_extruder()); //wipe_tower.set_retract(); //wipe_tower.set_zhop(); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 7a48b3a32e..a5fbb844b8 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -171,6 +171,22 @@ PrintConfigDef::PrintConfigDef() def->cli = "cooling!"; def->default_value = new ConfigOptionBools { true }; + def = this->add("cooling_tube_retraction", coFloat); + def->label = _L("Cooling tube position"); + def->tooltip = _L("Distance of the center-point of the cooling tube from the extruder tip "); + def->sidetext = _L("mm"); + def->cli = "cooling_tube_retraction=f"; + def->min = 0; + def->default_value = new ConfigOptionFloat(0); + + def = this->add("cooling_tube_length", coFloat); + def->label = _L("Cooling tube length"); + def->tooltip = _L("Length of the cooling tube to limit space for cooling moves inside it "); + def->sidetext = _L("mm"); + def->cli = "cooling_tube_length=f"; + def->min = 0; + def->default_value = new ConfigOptionFloat(0); + def = this->add("default_acceleration", coFloat); def->label = _L("Default"); def->tooltip = _L("This is the acceleration your printer will be reset to after " @@ -947,6 +963,15 @@ PrintConfigDef::PrintConfigDef() def->cli = "overhangs!"; def->default_value = new ConfigOptionBool(true); + def = this->add("parking_pos_retraction", coFloat); + def->label = _L("Filament parking position"); + def->tooltip = _L("Distance of the extruder tip from the position where the filament is parked" + "when unloaded. This should match the value in printer firmware. "); + def->sidetext = _L("mm"); + def->cli = "parking_pos_retraction=f"; + def->min = 0; + def->default_value = new ConfigOptionFloat(0); + def = this->add("perimeter_acceleration", coFloat); def->label = _L("Perimeters"); def->tooltip = _L("This is the acceleration your printer will use for perimeters. " diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index d55aafed6b..c556a2d69c 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -491,6 +491,9 @@ public: ConfigOptionBool use_relative_e_distances; ConfigOptionBool use_volumetric_e; ConfigOptionBool variable_layer_height; + ConfigOptionFloat cooling_tube_retraction; + ConfigOptionFloat cooling_tube_length; + ConfigOptionFloat parking_pos_retraction; std::string get_extrusion_axis() const { @@ -540,6 +543,9 @@ protected: OPT_PTR(use_relative_e_distances); OPT_PTR(use_volumetric_e); OPT_PTR(variable_layer_height); + OPT_PTR(cooling_tube_retraction); + OPT_PTR(cooling_tube_length); + OPT_PTR(parking_pos_retraction); } }; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index be31c1bd1c..c363647cb5 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -227,7 +227,7 @@ const std::vector& Preset::printer_options() "bed_shape", "z_offset", "gcode_flavor", "use_relative_e_distances", "serial_port", "serial_speed", "octoprint_host", "octoprint_apikey", "use_firmware_retraction", "use_volumetric_e", "variable_layer_height", "single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode", - "between_objects_gcode", "printer_notes" + "between_objects_gcode", "printer_notes", "cooling_tube_retraction", "cooling_tube_length", "parking_pos_retraction" }; s_opts.insert(s_opts.end(), Preset::nozzle_options().begin(), Preset::nozzle_options().end()); } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 7e1ad5dc57..790f5dc4b3 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1139,6 +1139,9 @@ void TabPrinter::build() optgroup->append_single_option_line("use_firmware_retraction"); optgroup->append_single_option_line("use_volumetric_e"); optgroup->append_single_option_line("variable_layer_height"); + optgroup->append_single_option_line("cooling_tube_retraction"); + optgroup->append_single_option_line("cooling_tube_length"); + optgroup->append_single_option_line("parking_pos_retraction"); page = add_options_page(_L("Custom G-code"), "cog.png"); optgroup = page->new_optgroup(_L("Start G-code"), 0); From e1421da5e82936bf66cdee7802c1e78481b9983e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 2 Mar 2018 13:26:16 +0100 Subject: [PATCH 0022/1150] Integrating cooling tube parameters into wipe tower generator --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 25 +++++++++++++-------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 7 +++++- xs/src/libslic3r/PrintConfig.cpp | 6 ++--- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index fdfd8752f6..2e3e7c0a7a 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -841,14 +841,17 @@ void WipeTowerPrusaMM::toolchange_Unload( .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 1.2f, e0, 1.74f * e, 5200); }*/ } - // Pull the filament end into a cooling tube. - writer.retract(15, 5000).retract(50, 5400).retract(15, 3000).retract(12, 2000); + // Pull the filament end into a cooling tube (Alex) + //writer.retract(15, 5000).retract(50, 5400).retract(15, 3000).retract(12, 2000); + + // Pull the filament end to the BEGINNING of the cooling tube + writer.retract(15, 5000).retract(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42, 5400).retract(15, 3000).retract(12, 2000); + if (new_temperature != 0) // Set the extruder temperature, but don't wait. writer.set_extruder_temp(new_temperature, false); // cooling: - writer.retract(2, 2000); writer.suppress_preview(); writer.travel(writer.x(), writer.y() + y_step); const float start_x = writer.x(); @@ -860,9 +863,10 @@ void WipeTowerPrusaMM::toolchange_Unload( i = 0; while (isidetext = _L("mm"); def->cli = "cooling_tube_retraction=f"; def->min = 0; - def->default_value = new ConfigOptionFloat(0); + def->default_value = new ConfigOptionFloat(91.5f); def = this->add("cooling_tube_length", coFloat); def->label = _L("Cooling tube length"); @@ -185,7 +185,7 @@ PrintConfigDef::PrintConfigDef() def->sidetext = _L("mm"); def->cli = "cooling_tube_length=f"; def->min = 0; - def->default_value = new ConfigOptionFloat(0); + def->default_value = new ConfigOptionFloat(5.f); def = this->add("default_acceleration", coFloat); def->label = _L("Default"); @@ -970,7 +970,7 @@ PrintConfigDef::PrintConfigDef() def->sidetext = _L("mm"); def->cli = "parking_pos_retraction=f"; def->min = 0; - def->default_value = new ConfigOptionFloat(0); + def->default_value = new ConfigOptionFloat(92.f); def = this->add("perimeter_acceleration", coFloat); def->label = _L("Perimeters"); From b3e9b82280557c9803c270854edb4935287a840e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 2 Mar 2018 15:52:16 +0100 Subject: [PATCH 0023/1150] (Un)loading speed and time delay parameters introduced into GUI and conf. layer (not yet into wipe tower generator) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 21 ++++++++-------- xs/src/libslic3r/PrintConfig.cpp | 27 +++++++++++++++++++++ xs/src/libslic3r/PrintConfig.hpp | 6 +++++ xs/src/slic3r/GUI/Preset.cpp | 9 +++---- xs/src/slic3r/GUI/Tab.cpp | 12 +++++---- 5 files changed, 55 insertions(+), 20 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 2e3e7c0a7a..c146f6030f 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -845,7 +845,11 @@ void WipeTowerPrusaMM::toolchange_Unload( //writer.retract(15, 5000).retract(50, 5400).retract(15, 3000).retract(12, 2000); // Pull the filament end to the BEGINNING of the cooling tube - writer.retract(15, 5000).retract(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42, 5400).retract(15, 3000).retract(12, 2000); + float unloading_feedrate = 5400.f; // Alex's original feedrate was 5400 + writer.retract(15, 5000) // just after ramming - fixed speed + .retract(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42, unloading_feedrate) + .retract(15, unloading_feedrate*0.55f) + .retract(12, unloading_feedrate*0.35f); if (new_temperature != 0) // Set the extruder temperature, but don't wait. @@ -953,17 +957,14 @@ void WipeTowerPrusaMM::toolchange_Load( float oldx = writer.x(); // the nozzle is in place to do the first wiping moves, we will remember the position float oldy = writer.y(); - writer.append("; CP TOOLCHANGE LOAD\n") - // Load the filament while moving left / right, + // Load the filament while moving left / right, // so the excess material will not create a blob at a single position. + float loading_feedrate = 3000.f; + writer.append("; CP TOOLCHANGE LOAD\n") .suppress_preview() - // Accelerate the filament loading - .load_move_x(xr, 20, 1400) - // Fast loading phase - //.load_move_x(xl, 40, 3000) - Alex - .load_move_x(xl,m_parking_pos_retraction-50-2,3000) // loading is 2mm shorter that previous retraction - // Slowing down - .load_move_x(xr, 20, 1600) + .load_move_x(xr, 20, 1400) // Accelerate the filament loading + .load_move_x(xl,m_parking_pos_retraction-50-2,3000) // Fast phase - loading is 2mm shorter that previous retraction + .load_move_x(xr, 20, 1600) // Slowing down .load_move_x(xl, 10, 1000) .travel(oldx,oldy) .resume_preview(); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 1886d52b88..cebb0832b2 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -448,6 +448,33 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloats { 0. }; + def = this->add("filament_loading_speed", coFloats); + def->label = _L("Loading speed"); + def->tooltip = _L("Speed used for loading the filament on the wipe tower. "); + def->sidetext = _L("mm\u00B3/s"); + def->cli = "filament-loading-speed=f@"; + def->min = 0; + def->default_value = new ConfigOptionFloats { 0. }; + + def = this->add("filament_unloading_speed", coFloats); + def->label = _L("Unloading speed"); + def->tooltip = _L("Speed used for unloading the filament on the wipe tower (does not affect " + " initial part of unloading just after ramming). "); + def->sidetext = _L("mm\u00B3/s"); + def->cli = "filament-unloading-speed=f@"; + def->min = 0; + def->default_value = new ConfigOptionFloats { 0. }; + + def = this->add("filament_toolchange_delay", coFloats); + def->label = _L("Delay after unloading"); + def->tooltip = _L("Time to wait after the filament is unloaded. " + "May help to get reliable toolchanges with flexible materials " + "that may need more time to shrink to original dimensions. "); + def->sidetext = _L("s"); + def->cli = "filament-toolchange-delay=f@"; + def->min = 0; + def->default_value = new ConfigOptionFloats { 0. }; + def = this->add("filament_diameter", coFloats); def->label = _L("Diameter"); def->tooltip = _L("Enter your filament diameter here. Good precision is required, so use a caliper " diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index c556a2d69c..4078324192 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -466,6 +466,9 @@ public: ConfigOptionBools filament_soluble; ConfigOptionFloats filament_cost; ConfigOptionFloats filament_max_volumetric_speed; + ConfigOptionFloats filament_loading_speed; + ConfigOptionFloats filament_unloading_speed; + ConfigOptionFloats filament_toolchange_delay; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; ConfigOptionString layer_gcode; @@ -518,6 +521,9 @@ protected: OPT_PTR(filament_soluble); OPT_PTR(filament_cost); OPT_PTR(filament_max_volumetric_speed); + OPT_PTR(filament_loading_speed); + OPT_PTR(filament_unloading_speed); + OPT_PTR(filament_toolchange_delay); OPT_PTR(gcode_comments); OPT_PTR(gcode_flavor); OPT_PTR(layer_gcode); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index c363647cb5..1cfd73bab9 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -210,11 +210,10 @@ const std::vector& Preset::filament_options() { static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", - "extrusion_multiplier", "filament_density", "filament_cost", "temperature", "first_layer_temperature", "bed_temperature", - "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", - "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", - "end_filament_gcode", - "compatible_printers", "compatible_printers_condition" + "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay", + "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", + "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", + "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers", "compatible_printers_condition" }; return s_opts; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 790f5dc4b3..92504f7149 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -441,7 +441,6 @@ void TabPrint::build() optgroup->append_single_option_line("ooze_prevention"); optgroup->append_single_option_line("standby_temperature_delta"); - if (true) { optgroup = page->new_optgroup(_L("Wipe tower")); optgroup->append_single_option_line("wipe_tower"); optgroup->append_single_option_line("wipe_tower_x"); @@ -449,8 +448,8 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_width"); optgroup->append_single_option_line("wipe_tower_per_color_wipe"); optgroup->append_single_option_line("wipe_tower_rotation_angle"); - Line line{ _L("Advanced"), "" }; - line.widget = [this](wxWindow* parent){ + line = { _L("Advanced"), "" }; + line.widget = [this](wxWindow* parent){ m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _L("Advanced settings")+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_wipe_tower_btn); @@ -468,8 +467,6 @@ void TabPrint::build() return sizer; }; optgroup->append_line(line); - } - optgroup = page->new_optgroup(_L("Advanced")); optgroup->append_single_option_line("interface_shells"); @@ -867,6 +864,11 @@ void TabFilament::build() }; optgroup->append_line(line); + optgroup = page->new_optgroup(_L("Toolchange behaviour")); + optgroup->append_single_option_line("filament_loading_speed"); + optgroup->append_single_option_line("filament_unloading_speed"); + optgroup->append_single_option_line("filament_toolchange_delay"); + page = add_options_page(_L("Custom G-code"), "cog.png"); optgroup = page->new_optgroup(_L("Start G-code"), 0); Option option = optgroup->get_option("start_filament_gcode"); From 5aca3045b9619903ade59fa0da22435ee21ea4e6 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 5 Mar 2018 10:45:35 +0100 Subject: [PATCH 0024/1150] (Un)loading speed and delay introduced into wipe tower generator --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 50 ++++++++++++++------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 35 ++++++++++----- xs/src/libslic3r/Print.cpp | 8 +++- xs/src/libslic3r/PrintConfig.cpp | 8 ++-- 4 files changed, 68 insertions(+), 33 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index c146f6030f..bc93a938e6 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -243,6 +243,17 @@ public: return *this; }; + // Wait for a period of time (seconds). + Writer& wait(float time) + { + if (time==0) + return *this; + char buf[128]; + sprintf(buf, "G4 S%.3f\n", time); + m_gcode += buf; + return *this; + }; + // Set speed factor override percentage. Writer& speed_override(int speed) { @@ -495,7 +506,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( for (size_t idx_tool = 0; idx_tool < tools.size(); ++ idx_tool) { unsigned int tool = tools[idx_tool]; m_left_to_right = true; - toolchange_Change(writer, tool, m_material[tool]); // Select the tool, set a speed override for soluble and flex materials. + toolchange_Change(writer, tool, m_filpar[tool].material); // Select the tool, set a speed override for soluble and flex materials. toolchange_Load(writer, cleaning_box); // Prime the tool. if (idx_tool + 1 == tools.size()) { // Last tool should not be unloaded, but it should be wiped enough to become of a pure color. @@ -506,7 +517,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( toolchange_Wipe(writer, cleaning_box , 5.f); box_coordinates box = cleaning_box; box.translate(0.f, writer.y() - cleaning_box.ld.y + m_perimeter_width); - toolchange_Unload(writer, box , m_material[m_current_tool], m_first_layer_temperature[tools[idx_tool + 1]]); + toolchange_Unload(writer, box , m_filpar[m_current_tool].material, m_filpar[tools[idx_tool + 1]].first_layer_temperature); cleaning_box.translate(prime_section_width, 0.f); writer.travel(cleaning_box.ld, 7200); } @@ -614,7 +625,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .append(";--------------------\n" "; CP TOOLCHANGE START\n") .comment_with_value(" toolchange #", m_num_tool_changes) - .comment_material(m_material[m_current_tool]) + .comment_material(m_filpar[m_current_tool].material) .append(";--------------------\n") .speed_override(100); @@ -622,7 +633,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo if (purpose == PURPOSE_MOVE_TO_TOWER || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { // Scaffold leaks terribly, reduce leaking by a full retract when going to the wipe tower. - float initial_retract = ((m_material[m_current_tool] == SCAFF) ? 1.f : 0.5f) * m_retract; + float initial_retract = ((m_filpar[m_current_tool].material == SCAFF) ? 1.f : 0.5f) * m_retract; writer // Lift for a Z hop. .z_hop(m_zhop, 7200) // Additional retract on move to tower. @@ -650,9 +661,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. if (tool != (unsigned int)-1){ // This is not the last change. - toolchange_Unload(writer, cleaning_box, m_material[m_current_tool], - m_is_first_layer ? m_first_layer_temperature[tool] : m_temperature[tool]); - toolchange_Change(writer, tool, m_material[tool]); // Change the tool, set a speed override for soluble and flex materials. + toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, + m_is_first_layer ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature); + toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials. toolchange_Load(writer, cleaning_box); toolchange_Wipe(writer, cleaning_box, wipe_volume); // Wipe the newly loaded filament until the end of the assigned wipe area. @@ -661,7 +672,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo writer.travel(box.ru, 7200) .travel(box.lu);*/ } else - toolchange_Unload(writer, cleaning_box, m_material[m_current_tool], m_temperature[m_current_tool]); + toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature); if (last_change_in_layer) // draw perimeter line writer.travel(m_wipe_tower_pos, 7000) @@ -845,8 +856,8 @@ void WipeTowerPrusaMM::toolchange_Unload( //writer.retract(15, 5000).retract(50, 5400).retract(15, 3000).retract(12, 2000); // Pull the filament end to the BEGINNING of the cooling tube - float unloading_feedrate = 5400.f; // Alex's original feedrate was 5400 - writer.retract(15, 5000) // just after ramming - fixed speed + float unloading_feedrate = 60.f * m_filpar[m_current_tool].unloading_speed; + writer.retract(15, 5000) // just after ramming - always the same speed .retract(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42, unloading_feedrate) .retract(15, unloading_feedrate*0.55f) .retract(12, unloading_feedrate*0.35f); @@ -882,6 +893,9 @@ void WipeTowerPrusaMM::toolchange_Unload( const float feedrate = std::hypot(e_dist, x_dist) / ((e_dist / speed) / 60.f); writer.cool(start_x+x_dist/2.f,start_x,e_dist/2.f,-e_dist/2.f, feedrate); } + + // let's wait is necessary + writer.wait(m_filpar[m_current_tool].delay); // we should be at the beginning of the cooling tube again - let's move to parking position: writer.retract(-m_cooling_tube_length/2.f+m_parking_pos_retraction-m_cooling_tube_retraction, 2000); @@ -957,15 +971,17 @@ void WipeTowerPrusaMM::toolchange_Load( float oldx = writer.x(); // the nozzle is in place to do the first wiping moves, we will remember the position float oldy = writer.y(); - // Load the filament while moving left / right, - // so the excess material will not create a blob at a single position. - float loading_feedrate = 3000.f; + // Load the filament while moving left / right, so the excess material will not create a blob at a single position. + float loading_speed = m_filpar[m_current_tool].loading_speed; // mm/s in e axis + float turning_point = ( oldx-xl < xr-oldx ? xr : xl ); + float dist = std::abs(oldx-turning_point); + float edist = m_parking_pos_retraction-50-2; // loading is 2mm shorter that previous retraction, 50mm reserved for acceleration/deceleration writer.append("; CP TOOLCHANGE LOAD\n") .suppress_preview() - .load_move_x(xr, 20, 1400) // Accelerate the filament loading - .load_move_x(xl,m_parking_pos_retraction-50-2,3000) // Fast phase - loading is 2mm shorter that previous retraction - .load_move_x(xr, 20, 1600) // Slowing down - .load_move_x(xl, 10, 1000) + .load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Acceleration + .load_move_x(oldx,edist,60*std::hypot(dist,edist)/edist * loading_speed) // Fast phase + .load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Slowing down + .load_move_x(oldx, 10, 60*std::hypot(dist,10.f)/10.f * loading_speed*0.1f) // Super slow .travel(oldx,oldy) .resume_preview(); diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 7f4cc8a302..893e4a125f 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -209,9 +209,9 @@ public: { for (size_t i = 0; i < 4; ++ i) { // Extruder specific parameters. - m_material[i] = PLA; - m_temperature[i] = 0; - m_first_layer_temperature[i] = 0; + m_filpar[i].material = PLA; + m_filpar[i].temperature = 0; + m_filpar[i].first_layer_temperature = 0; } } @@ -225,11 +225,15 @@ public: // Set the extruder properties. - void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp) + void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, + float unloading_speed, float delay) { - m_material[idx] = material; - m_temperature[idx] = temp; - m_first_layer_temperature[idx] = first_layer_temp; + m_filpar[idx].material = material; + m_filpar[idx].temperature = temp; + m_filpar[idx].first_layer_temperature = first_layer_temp; + m_filpar[idx].loading_speed = loading_speed; + m_filpar[idx].unloading_speed = unloading_speed; + m_filpar[idx].delay = delay; } @@ -336,14 +340,23 @@ private: float m_cooling_tube_retraction = 0.f; float m_cooling_tube_length = 0.f; float m_parking_pos_retraction = 0.f; - + float m_line_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_extrusion_flow = 0.038; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. + + struct FilamentParameters { + material_type material; + int temperature; + int first_layer_temperature; + float loading_speed; + float unloading_speed; + float delay; + }; + // Extruder specific parameters. - material_type m_material[4]; - int m_temperature[4]; - int m_first_layer_temperature[4]; + FilamentParameters m_filpar[4]; + // State of the wiper tower generator. unsigned int m_num_layer_changes = 0; // Layer change counter for the output statistics. diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 020af76100..447aec7509 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -185,6 +185,9 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.filament_type.get_at(i).c_str()), this->config.temperature.get_at(i), - this->config.first_layer_temperature.get_at(i)); + this->config.first_layer_temperature.get_at(i), + this->config.filament_loading_speed.get_at(i), + this->config.filament_unloading_speed.get_at(i), + this->config.filament_toolchange_delay.get_at(i)); // When printing the first layer's wipe tower, the first extruder is expected to be active and primed. // Therefore the number of wipe sections at the wipe tower will be (m_tool_ordering.front().extruders-1) at the 1st layer. diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index cebb0832b2..40b348fb82 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -451,19 +451,19 @@ PrintConfigDef::PrintConfigDef() def = this->add("filament_loading_speed", coFloats); def->label = _L("Loading speed"); def->tooltip = _L("Speed used for loading the filament on the wipe tower. "); - def->sidetext = _L("mm\u00B3/s"); + def->sidetext = _L("mm/s"); def->cli = "filament-loading-speed=f@"; def->min = 0; - def->default_value = new ConfigOptionFloats { 0. }; + def->default_value = new ConfigOptionFloats { 28. }; def = this->add("filament_unloading_speed", coFloats); def->label = _L("Unloading speed"); def->tooltip = _L("Speed used for unloading the filament on the wipe tower (does not affect " " initial part of unloading just after ramming). "); - def->sidetext = _L("mm\u00B3/s"); + def->sidetext = _L("mm/s"); def->cli = "filament-unloading-speed=f@"; def->min = 0; - def->default_value = new ConfigOptionFloats { 0. }; + def->default_value = new ConfigOptionFloats { 90. }; def = this->add("filament_toolchange_delay", coFloats); def->label = _L("Delay after unloading"); From 4058f002751477b677d4f547eed1af459d7ea7ee Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 5 Mar 2018 13:53:49 +0100 Subject: [PATCH 0025/1150] Added print head moves after ramming and removed one unnecessary diagonal move --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 25 ++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index bc93a938e6..f87db98a77 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -675,11 +675,11 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature); if (last_change_in_layer) // draw perimeter line - writer.travel(m_wipe_tower_pos, 7000) - .extrude(m_wipe_tower_pos + xy(0, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width), 3200) - .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width)) - .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, 0)) - .extrude(m_wipe_tower_pos); + writer.travel(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width), 7000) + .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, 0), 3200) + .extrude(m_wipe_tower_pos) + .extrude(m_wipe_tower_pos + xy(0, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width)) + .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width)); // Reset the extruder current to a normal value. writer.set_extruder_trimpot(550) @@ -856,12 +856,21 @@ void WipeTowerPrusaMM::toolchange_Unload( //writer.retract(15, 5000).retract(50, 5400).retract(15, 3000).retract(12, 2000); // Pull the filament end to the BEGINNING of the cooling tube - float unloading_feedrate = 60.f * m_filpar[m_current_tool].unloading_speed; + /*float unloading_feedrate = 60.f * m_filpar[m_current_tool].unloading_speed; writer.retract(15, 5000) // just after ramming - always the same speed .retract(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42, unloading_feedrate) .retract(15, unloading_feedrate*0.55f) - .retract(12, unloading_feedrate*0.35f); + .retract(12, unloading_feedrate*0.35f);*/ + // Pull the filament end to the BEGINNING of the cooling tube while still moving the print head + float oldx = writer.x(); + float turning_point = (!m_left_to_right ? std::max(xl,oldx-15.f) : std::min(xr,oldx+15.f) ); // so it's not too far + float xdist = std::abs(oldx-turning_point); + float edist = -(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42); + writer.load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ) // fixed speed after ramming + .load_move_x(oldx ,edist , 60.f * std::hypot(xdist,edist)/edist * m_filpar[m_current_tool].unloading_speed ) + .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * m_filpar[m_current_tool].unloading_speed*0.55f ) + .load_move_x(oldx ,-12 , 60.f * std::hypot(xdist,12)/12 * m_filpar[m_current_tool].unloading_speed*0.35f ); if (new_temperature != 0) // Set the extruder temperature, but don't wait. writer.set_extruder_temp(new_temperature, false); @@ -870,7 +879,7 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.suppress_preview(); writer.travel(writer.x(), writer.y() + y_step); const float start_x = writer.x(); - const float turning_point = ( xr-start_x > start_x-xl ? xr : xl ); + turning_point = ( xr-start_x > start_x-xl ? xr : xl ); const float max_x_dist = 2*std::abs(start_x-turning_point); const unsigned int N = 4 + std::max(0,(m_par.cooling_time[m_current_tool]-14)/3); float time = m_par.cooling_time[m_current_tool] / N; From 6c223c2f8464f92462bdaadc70dbee822b69560f Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 5 Mar 2018 16:51:31 +0100 Subject: [PATCH 0026/1150] Fixed cooling time calculation, removed unnecessary diagonal moves, fixed 'stringing' on start and end of narrower wipe tower layers --- xs/src/libslic3r/GCode/WipeTower.hpp | 2 +- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTower.hpp b/xs/src/libslic3r/GCode/WipeTower.hpp index 289e8e1225..e193fd9725 100644 --- a/xs/src/libslic3r/GCode/WipeTower.hpp +++ b/xs/src/libslic3r/GCode/WipeTower.hpp @@ -17,7 +17,7 @@ public: struct xy { xy(float x = 0.f, float y = 0.f) : x(x), y(y) {} - xy(xy& pos,float xp,float yp) : x(pos.x+xp), y(pos.y+yp) {} + xy(const xy& pos,float xp,float yp) : x(pos.x+xp), y(pos.y+yp) {} xy operator+(const xy &rhs) const { xy out(*this); out.x += rhs.x; out.y += rhs.y; return out; } xy operator-(const xy &rhs) const { xy out(*this); out.x -= rhs.x; out.y -= rhs.y; return out; } xy& operator+=(const xy &rhs) { x += rhs.x; y += rhs.y; return *this; } diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index f87db98a77..8e548a4a49 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -93,8 +93,8 @@ public: float x() const { return m_current_pos.x; } float y() const { return m_current_pos.y; } const WipeTower::xy& pos() const { return m_current_pos; } - const WipeTower::xy start_pos_rotated() const { return m_start_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } - const WipeTower::xy pos_rotated() const { return m_current_pos.rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } + const WipeTower::xy start_pos_rotated() const { return WipeTower::xy(m_start_pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } + const WipeTower::xy pos_rotated() const { return WipeTower::xy(m_current_pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } float elapsed_time() const { return m_elapsed_time; } // Extrude with an explicitely provided amount of extrusion. @@ -882,7 +882,7 @@ void WipeTowerPrusaMM::toolchange_Unload( turning_point = ( xr-start_x > start_x-xl ? xr : xl ); const float max_x_dist = 2*std::abs(start_x-turning_point); const unsigned int N = 4 + std::max(0,(m_par.cooling_time[m_current_tool]-14)/3); - float time = m_par.cooling_time[m_current_tool] / N; + float time = m_par.cooling_time[m_current_tool] / float(N); i = 0; while (i Date: Tue, 6 Mar 2018 12:12:00 +0100 Subject: [PATCH 0027/1150] GCode Preview - Fixed values in range labels of legend texture --- xs/src/libslic3r/GCode/Analyzer.cpp | 12 +++++++ xs/src/libslic3r/GCode/PreviewData.cpp | 47 +++++++++++++++++++++----- xs/src/libslic3r/GCode/PreviewData.hpp | 16 +++++---- 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/xs/src/libslic3r/GCode/Analyzer.cpp b/xs/src/libslic3r/GCode/Analyzer.cpp index 6530806c40..d4041ac192 100644 --- a/xs/src/libslic3r/GCode/Analyzer.cpp +++ b/xs/src/libslic3r/GCode/Analyzer.cpp @@ -717,6 +717,10 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data) float feedrate = FLT_MAX; unsigned int extruder_id = -1; + GCodePreviewData::Range height_range; + GCodePreviewData::Range width_range; + GCodePreviewData::Range feedrate_range; + // constructs the polylines while traversing the moves for (const GCodeMove& move : travel_moves->second) { @@ -745,11 +749,19 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data) type = move_type; feedrate = move.data.feedrate; extruder_id = move.data.extruder_id; + height_range.update_from(move.data.height); + width_range.update_from(move.data.width); + feedrate_range.update_from(move.data.feedrate); } // store last polyline polyline.remove_duplicate_points(); Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, preview_data); + + // updates preview ranges data + preview_data.travel.ranges.height.set_from(height_range); + preview_data.travel.ranges.width.set_from(width_range); + preview_data.travel.ranges.feedrate.set_from(feedrate_range); } void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_data) diff --git a/xs/src/libslic3r/GCode/PreviewData.cpp b/xs/src/libslic3r/GCode/PreviewData.cpp index 1923505e4c..73ec30eef1 100644 --- a/xs/src/libslic3r/GCode/PreviewData.cpp +++ b/xs/src/libslic3r/GCode/PreviewData.cpp @@ -85,6 +85,12 @@ void GCodePreviewData::Range::update_from(float value) max = std::max(max, value); } +void GCodePreviewData::Range::update_from(const Range& other) +{ + min = std::min(min, other.min); + max = std::max(max, other.max); +} + void GCodePreviewData::Range::set_from(const Range& other) { min = other.min; @@ -198,6 +204,11 @@ void GCodePreviewData::Travel::set_default() width = Default_Width; height = Default_Height; ::memcpy((void*)type_colors, (const void*)Default_Type_Colors, Num_Types * sizeof(Color)); + + ::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); + ::memcpy((void*)ranges.width.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); + ::memcpy((void*)ranges.feedrate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); + is_visible = false; } @@ -345,15 +356,26 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: { struct Helper { - static void FillListFromRange(LegendItemsList& list, const Range& range, unsigned int decimals, float scale_factor) + static void FillListFromRange(LegendItemsList& list, const std::vector& ranges, unsigned int decimals, float scale_factor) { + if (ranges.empty()) + return; + list.reserve(Range::Colors_Count); - float step = range.step_size(); + + Range total_range; + for (const Range* range : ranges) + { + if (range != nullptr) + total_range.update_from(*range); + } + + float step = total_range.step_size(); for (unsigned int i = 0; i < Range::Colors_Count; ++i) { - char buf[32]; - sprintf(buf, "%.*f/%.*f", decimals, scale_factor * (range.min + (float)i * step), decimals, scale_factor * (range.min + (float)(i + 1) * step)); - list.emplace_back(buf, range.colors[i]); + char buf[1024]; + sprintf(buf, "%.*f/%.*f", decimals, scale_factor * (total_range.min + (float)i * step), decimals, scale_factor * (total_range.min + (float)(i + 1) * step)); + list.emplace_back(buf, ranges[0]->colors[i]); } } }; @@ -377,17 +399,26 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: } case Extrusion::Height: { - Helper::FillListFromRange(items, extrusion.ranges.height, 3, 1.0f); + std::vector ranges; + ranges.push_back(&extrusion.ranges.height); + ranges.push_back(&travel.ranges.height); + Helper::FillListFromRange(items, ranges, 3, 1.0f); break; } case Extrusion::Width: { - Helper::FillListFromRange(items, extrusion.ranges.width, 3, 1.0f); + std::vector ranges; + ranges.push_back(&extrusion.ranges.width); + ranges.push_back(&travel.ranges.width); + Helper::FillListFromRange(items, ranges, 3, 1.0f); break; } case Extrusion::Feedrate: { - Helper::FillListFromRange(items, extrusion.ranges.feedrate, 0, 1.0f); + std::vector ranges; + ranges.push_back(&extrusion.ranges.feedrate); + ranges.push_back(&travel.ranges.feedrate); + Helper::FillListFromRange(items, ranges, 0, 1.0f); break; } case Extrusion::Tool: diff --git a/xs/src/libslic3r/GCode/PreviewData.hpp b/xs/src/libslic3r/GCode/PreviewData.hpp index 9fb2dc4645..9579bf9004 100644 --- a/xs/src/libslic3r/GCode/PreviewData.hpp +++ b/xs/src/libslic3r/GCode/PreviewData.hpp @@ -37,6 +37,7 @@ public: void reset(); bool empty() const; void update_from(float value); + void update_from(const Range& other); void set_from(const Range& other); float step_size() const; @@ -44,6 +45,13 @@ public: const Color& get_color_at_max() const; }; + struct Ranges + { + Range height; + Range width; + Range feedrate; + }; + struct LegendItem { std::string text; @@ -71,13 +79,6 @@ public: static const std::string Default_Extrusion_Role_Names[Num_Extrusion_Roles]; static const EViewType Default_View_Type; - struct Ranges - { - Range height; - Range width; - Range feedrate; - }; - struct Layer { float z; @@ -140,6 +141,7 @@ public: float height; Color type_colors[Num_Types]; bool is_visible; + Ranges ranges; void set_default(); }; From af281e13dbf6a1a295246adae5aed633097a69db Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 6 Mar 2018 19:14:12 +0100 Subject: [PATCH 0028/1150] Last wipe on layer accounts of border and sparse infill (ugly, yet working) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 105 +++++++++++++------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 8 +- 2 files changed, 76 insertions(+), 37 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 8e548a4a49..d6e3013e2b 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -613,7 +613,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo box_coordinates cleaning_box( m_wipe_tower_pos + xy(m_perimeter_width / 2.f, m_perimeter_width / 2.f), m_wipe_tower_width - m_perimeter_width, - (tool != (unsigned int)(-1) ? m_layer_info->depth : m_wipe_tower_depth-m_perimeter_width)); + (tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5*m_perimeter_width + : m_wipe_tower_depth-m_perimeter_width)); PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow) @@ -1049,11 +1050,10 @@ void WipeTowerPrusaMM::toolchange_Wipe( writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); else writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); - - /*if ((m_current_shape == SHAPE_NORMAL) ? // in case next line would not fit - (writer.y() > cleaning_box.lu.y - m_perimeter_width * 1.5f) : - (writer.y() < cleaning_box.ld.y + m_perimeter_width * 1.5f)) - break;*/ + + if (writer.y()+EPSILON > cleaning_box.lu.y-0.5f*m_perimeter_width) + break; // in case next line would not fit + traversed_x -= writer.x(); x_to_wipe -= fabs(traversed_x); if (x_to_wipe < WT_EPSILON) { @@ -1218,13 +1218,16 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi m_line_width * m_par.ramming_line_width_multiplicator[old_tool], layer_height_par); depth = (int(length_to_extrude / width) + 1) * (m_line_width * m_par.ramming_line_width_multiplicator[old_tool] * m_par.ramming_step_multiplicator[old_tool]); - length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; - length_to_extrude += volume_to_length(m_par.wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); - length_to_extrude = std::max(length_to_extrude,0.f); - depth += (int(length_to_extrude / width) + 1) * m_line_width; - depth *= m_extra_spacing; + float ramming_depth = depth; + length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; + float first_wipe_line = -length_to_extrude; + length_to_extrude += volume_to_length(m_par.wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); + length_to_extrude = std::max(length_to_extrude,0.f); - m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth)); + depth += (int(length_to_extrude / width) + 1) * m_line_width; + depth *= m_extra_spacing; + + m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth, ramming_depth,first_wipe_line)); } @@ -1252,31 +1255,27 @@ void WipeTowerPrusaMM::plan_tower() } } - -void WipeTowerPrusaMM::make_wipe_tower_square() +void WipeTowerPrusaMM::save_on_last_wipe() { - const float width = m_wipe_tower_width - 3 * m_perimeter_width; - const float depth = m_wipe_tower_depth - m_perimeter_width; - // area that we actually print into is width*depth - float side = sqrt(depth * width); + for (m_layer_info=m_plan.begin();m_layer_infoz, m_layer_info->height, 0, m_layer_info->z == m_plan.front().z, m_layer_info->z == m_plan.back().z); + if (m_layer_info->tool_changes.size()==0) // we have no way to save anything on an empty layer + continue; - m_wipe_tower_width = side + 3 * m_perimeter_width; - m_wipe_tower_depth = side + 2 * m_perimeter_width; - // For all layers, find how depth changed and update all toolchange depths - for (auto &lay : m_plan) - { - side = sqrt(lay.depth * width); - float width_ratio = width / side; + for (const auto &toolchange : m_layer_info->tool_changes) + tool_change(toolchange.new_tool, false, PURPOSE_EXTRUDE); - //lay.extra_spacing = width_ratio; - for (auto &tch : lay.tool_changes) - tch.required_depth *= width_ratio; - } + float width = m_wipe_tower_width - 3*m_perimeter_width; // width we draw into + float length_to_save = 2*(m_wipe_tower_width+m_wipe_tower_depth) + (!layer_finished() ? finish_layer(PURPOSE_EXTRUDE).total_extrusion_length_in_plane() : 0.f); + float length_to_wipe = volume_to_length(m_par.wipe_volumes[m_layer_info->tool_changes.back().old_tool][m_layer_info->tool_changes.back().new_tool], + m_line_width,m_layer_info->height) - m_layer_info->tool_changes.back().first_wipe_line - length_to_save; - plan_tower(); // propagates depth downwards again (width has changed) - for (auto& lay : m_plan) // depths set, now the spacing - lay.extra_spacing = lay.depth / lay.toolchanges_depth(); + length_to_wipe = std::max(length_to_wipe,0.f); + float depth_to_wipe = m_line_width * (std::floor(length_to_wipe/width) + ( length_to_wipe > 0.f ? 1.f : 0.f ) ) * m_extra_spacing; + //depth += (int(length_to_extrude / width) + 1) * m_line_width; + m_layer_info->tool_changes.back().required_depth = m_layer_info->tool_changes.back().ramming_depth + depth_to_wipe; + } } @@ -1285,14 +1284,20 @@ void WipeTowerPrusaMM::make_wipe_tower_square() void WipeTowerPrusaMM::generate(std::vector> &result) { if (m_plan.empty()) return; - else m_layer_info = m_plan.begin(); - m_extra_spacing = 1.f; + m_extra_spacing = 1.f; plan_tower(); + for (int i=0;i<5;++i) { + save_on_last_wipe(); + plan_tower(); + } + if (peters_wipe_tower) make_wipe_tower_square(); + m_layer_info = m_plan.begin(); + std::vector layer_result; for (auto layer : m_plan) { @@ -1306,8 +1311,6 @@ void WipeTowerPrusaMM::generate(std::vectordepth < m_wipe_tower_depth - m_perimeter_width) m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f; - - for (const auto &toolchange : layer.tool_changes) layer_result.emplace_back(tool_change(toolchange.new_tool, false, WipeTower::PURPOSE_EXTRUDE)); @@ -1336,4 +1339,34 @@ void WipeTowerPrusaMM::generate(std::vector Date: Wed, 7 Mar 2018 08:55:53 +0100 Subject: [PATCH 0029/1150] Supressed preview on unloadingmoves --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index d6e3013e2b..57135475aa 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -868,10 +868,12 @@ void WipeTowerPrusaMM::toolchange_Unload( float turning_point = (!m_left_to_right ? std::max(xl,oldx-15.f) : std::min(xr,oldx+15.f) ); // so it's not too far float xdist = std::abs(oldx-turning_point); float edist = -(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42); - writer.load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ) // fixed speed after ramming + writer.suppress_preview() + .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ) // fixed speed after ramming .load_move_x(oldx ,edist , 60.f * std::hypot(xdist,edist)/edist * m_filpar[m_current_tool].unloading_speed ) .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * m_filpar[m_current_tool].unloading_speed*0.55f ) - .load_move_x(oldx ,-12 , 60.f * std::hypot(xdist,12)/12 * m_filpar[m_current_tool].unloading_speed*0.35f ); + .load_move_x(oldx ,-12 , 60.f * std::hypot(xdist,12)/12 * m_filpar[m_current_tool].unloading_speed*0.35f ) + .resume_preview(); if (new_temperature != 0) // Set the extruder temperature, but don't wait. writer.set_extruder_temp(new_temperature, false); From fe59958ea84539c2252bc1a009247f997f4686b6 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 7 Mar 2018 09:17:59 +0100 Subject: [PATCH 0030/1150] GCode Preview - Unified preview data ranges to ensure proper paths colors --- xs/src/libslic3r/GCode/Analyzer.cpp | 12 +++--- xs/src/libslic3r/GCode/PreviewData.cpp | 59 +++++++++----------------- xs/src/libslic3r/GCode/PreviewData.hpp | 9 ++-- xs/src/slic3r/GUI/3DScene.cpp | 8 ++-- 4 files changed, 34 insertions(+), 54 deletions(-) diff --git a/xs/src/libslic3r/GCode/Analyzer.cpp b/xs/src/libslic3r/GCode/Analyzer.cpp index d4041ac192..ee1e55bebc 100644 --- a/xs/src/libslic3r/GCode/Analyzer.cpp +++ b/xs/src/libslic3r/GCode/Analyzer.cpp @@ -688,9 +688,9 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ Helper::store_polyline(polyline, data, z, preview_data); // updates preview ranges data - preview_data.extrusion.ranges.height.set_from(height_range); - preview_data.extrusion.ranges.width.set_from(width_range); - preview_data.extrusion.ranges.feedrate.set_from(feedrate_range); + preview_data.ranges.height.set_from(height_range); + preview_data.ranges.width.set_from(width_range); + preview_data.ranges.feedrate.set_from(feedrate_range); } void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data) @@ -759,9 +759,9 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data) Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, preview_data); // updates preview ranges data - preview_data.travel.ranges.height.set_from(height_range); - preview_data.travel.ranges.width.set_from(width_range); - preview_data.travel.ranges.feedrate.set_from(feedrate_range); + preview_data.ranges.height.set_from(height_range); + preview_data.ranges.width.set_from(width_range); + preview_data.ranges.feedrate.set_from(feedrate_range); } void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_data) diff --git a/xs/src/libslic3r/GCode/PreviewData.cpp b/xs/src/libslic3r/GCode/PreviewData.cpp index 73ec30eef1..b9be6643b1 100644 --- a/xs/src/libslic3r/GCode/PreviewData.cpp +++ b/xs/src/libslic3r/GCode/PreviewData.cpp @@ -164,9 +164,6 @@ void GCodePreviewData::Extrusion::set_default() view_type = Default_View_Type; ::memcpy((void*)role_colors, (const void*)Default_Extrusion_Role_Colors, Num_Extrusion_Roles * sizeof(Color)); - ::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); - ::memcpy((void*)ranges.width.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); - ::memcpy((void*)ranges.feedrate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); for (unsigned int i = 0; i < Num_Extrusion_Roles; ++i) { @@ -205,10 +202,6 @@ void GCodePreviewData::Travel::set_default() height = Default_Height; ::memcpy((void*)type_colors, (const void*)Default_Type_Colors, Num_Types * sizeof(Color)); - ::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); - ::memcpy((void*)ranges.width.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); - ::memcpy((void*)ranges.feedrate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); - is_visible = false; } @@ -239,6 +232,10 @@ GCodePreviewData::GCodePreviewData() void GCodePreviewData::set_default() { + ::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); + ::memcpy((void*)ranges.width.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); + ::memcpy((void*)ranges.feedrate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); + extrusion.set_default(); travel.set_default(); retraction.set_default(); @@ -248,6 +245,9 @@ void GCodePreviewData::set_default() void GCodePreviewData::reset() { + ranges.width.reset(); + ranges.height.reset(); + ranges.feedrate.reset(); extrusion.layers.clear(); travel.polylines.clear(); retraction.positions.clear(); @@ -264,19 +264,19 @@ const GCodePreviewData::Color& GCodePreviewData::get_extrusion_role_color(Extrus return extrusion.role_colors[role]; } -const GCodePreviewData::Color& GCodePreviewData::get_extrusion_height_color(float height) const +const GCodePreviewData::Color& GCodePreviewData::get_height_color(float height) const { - return extrusion.ranges.height.get_color_at(height); + return ranges.height.get_color_at(height); } -const GCodePreviewData::Color& GCodePreviewData::get_extrusion_width_color(float width) const +const GCodePreviewData::Color& GCodePreviewData::get_width_color(float width) const { - return extrusion.ranges.width.get_color_at(width); + return ranges.width.get_color_at(width); } -const GCodePreviewData::Color& GCodePreviewData::get_extrusion_feedrate_color(float feedrate) const +const GCodePreviewData::Color& GCodePreviewData::get_feedrate_color(float feedrate) const { - return extrusion.ranges.feedrate.get_color_at(feedrate); + return ranges.feedrate.get_color_at(feedrate); } void GCodePreviewData::set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha) @@ -356,26 +356,16 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: { struct Helper { - static void FillListFromRange(LegendItemsList& list, const std::vector& ranges, unsigned int decimals, float scale_factor) + static void FillListFromRange(LegendItemsList& list, const Range& range, unsigned int decimals, float scale_factor) { - if (ranges.empty()) - return; - list.reserve(Range::Colors_Count); - Range total_range; - for (const Range* range : ranges) - { - if (range != nullptr) - total_range.update_from(*range); - } - - float step = total_range.step_size(); + float step = range.step_size(); for (unsigned int i = 0; i < Range::Colors_Count; ++i) { char buf[1024]; - sprintf(buf, "%.*f/%.*f", decimals, scale_factor * (total_range.min + (float)i * step), decimals, scale_factor * (total_range.min + (float)(i + 1) * step)); - list.emplace_back(buf, ranges[0]->colors[i]); + sprintf(buf, "%.*f/%.*f", decimals, scale_factor * (range.min + (float)i * step), decimals, scale_factor * (range.min + (float)(i + 1) * step)); + list.emplace_back(buf, range.colors[i]); } } }; @@ -399,26 +389,17 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: } case Extrusion::Height: { - std::vector ranges; - ranges.push_back(&extrusion.ranges.height); - ranges.push_back(&travel.ranges.height); - Helper::FillListFromRange(items, ranges, 3, 1.0f); + Helper::FillListFromRange(items, ranges.height, 3, 1.0f); break; } case Extrusion::Width: { - std::vector ranges; - ranges.push_back(&extrusion.ranges.width); - ranges.push_back(&travel.ranges.width); - Helper::FillListFromRange(items, ranges, 3, 1.0f); + Helper::FillListFromRange(items, ranges.width, 3, 1.0f); break; } case Extrusion::Feedrate: { - std::vector ranges; - ranges.push_back(&extrusion.ranges.feedrate); - ranges.push_back(&travel.ranges.feedrate); - Helper::FillListFromRange(items, ranges, 0, 1.0f); + Helper::FillListFromRange(items, ranges.feedrate, 0, 1.0f); break; } case Extrusion::Tool: diff --git a/xs/src/libslic3r/GCode/PreviewData.hpp b/xs/src/libslic3r/GCode/PreviewData.hpp index 9579bf9004..6375af5f05 100644 --- a/xs/src/libslic3r/GCode/PreviewData.hpp +++ b/xs/src/libslic3r/GCode/PreviewData.hpp @@ -92,7 +92,6 @@ public: EViewType view_type; Color role_colors[Num_Extrusion_Roles]; std::string role_names[Num_Extrusion_Roles]; - Ranges ranges; LayersList layers; unsigned int role_flags; @@ -141,7 +140,6 @@ public: float height; Color type_colors[Num_Types]; bool is_visible; - Ranges ranges; void set_default(); }; @@ -180,6 +178,7 @@ public: Retraction retraction; Retraction unretraction; Shell shell; + Ranges ranges; GCodePreviewData(); @@ -188,9 +187,9 @@ public: bool empty() const; const Color& get_extrusion_role_color(ExtrusionRole role) const; - const Color& get_extrusion_height_color(float height) const; - const Color& get_extrusion_width_color(float width) const; - const Color& get_extrusion_feedrate_color(float feedrate) const; + const Color& get_height_color(float height) const; + const Color& get_width_color(float width) const; + const Color& get_feedrate_color(float feedrate) const; void set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha); void set_extrusion_paths_colors(const std::vector& colors); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 04e7f7dc6b..8a1b19c517 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1777,11 +1777,11 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, case GCodePreviewData::Extrusion::FeatureType: return data.get_extrusion_role_color((ExtrusionRole)(int)value); case GCodePreviewData::Extrusion::Height: - return data.get_extrusion_height_color(value); + return data.get_height_color(value); case GCodePreviewData::Extrusion::Width: - return data.get_extrusion_width_color(value); + return data.get_width_color(value); case GCodePreviewData::Extrusion::Feedrate: - return data.get_extrusion_feedrate_color(value); + return data.get_feedrate_color(value); case GCodePreviewData::Extrusion::Tool: { static GCodePreviewData::Color color; @@ -2061,7 +2061,7 @@ bool _3DScene::_travel_paths_by_feedrate(const GCodePreviewData& preview_data, G // creates a new volume for each feedrate for (Feedrate& feedrate : feedrates) { - GLVolume* volume = new GLVolume(preview_data.get_extrusion_feedrate_color(feedrate.value).rgba); + GLVolume* volume = new GLVolume(preview_data.get_feedrate_color(feedrate.value).rgba); if (volume == nullptr) return false; else From 76aa134f662ba760d01105d4dc15dbf097cf259a Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 7 Mar 2018 11:44:47 +0100 Subject: [PATCH 0031/1150] Ramming lines that would end unsupported are made longer to reach to the edge --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 79 ++++++++++++++++----- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 2 +- 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 57135475aa..250bad1d2f 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -790,8 +790,8 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.append("; CP TOOLCHANGE UNLOAD\n"); - const float line_width = m_line_width * m_par.ramming_line_width_multiplicator[m_current_tool]; // desired ramming line thickness - const float y_step = line_width * m_par.ramming_step_multiplicator[m_current_tool] * m_extra_spacing; // spacing between lines in mm + const float line_width = m_line_width * m_par.ramming_line_width_multiplicator[m_current_tool]; // desired ramming line thickness + const float y_step = line_width * m_par.ramming_step_multiplicator[m_current_tool] * m_extra_spacing; // spacing between lines in mm unsigned i = 0; // iterates through ramming_speed m_left_to_right = true; // current direction of ramming @@ -800,14 +800,54 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.travel(xl, cleaning_box.ld.y + m_depth_traversed + y_step/2.f ); // move to starting position - while (i < m_par.ramming_speed[m_current_tool].size()) - { - const float x = volume_to_length(m_par.ramming_speed[m_current_tool][i] * 0.25f, line_width, m_layer_height); - const float e = m_par.ramming_speed[m_current_tool][i] * 0.25f / Filament_Area; // transform volume per sec to E move; - const float dist = std::min(x - e_done, remaining); // distance to travel for either the next 0.25s, or to the next turnaround - const float actual_time = dist/x * 0.25; - writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), std::hypot(dist, e * (dist / x)) / (actual_time / 60.)); - remaining -= dist; + // if the ending point of the ram would end up in mid air, align it with the end of the wipe tower: + if (m_layer_info > m_plan.begin() && m_layer_info < m_plan.end()) { + + // this is y of the center of first supported line + float sparse_beginning_y = m_wipe_tower_pos.y + + ((m_layer_info-1)->depth - (m_layer_info-1)->toolchanges_depth()); + + //debugging: + /* float oldx = writer.x(); + float oldy = writer.y(); + writer.travel(xr,sparse_beginning_y); + writer.extrude(xr+5,writer.y()); + writer.travel(oldx,oldy);*/ + + float sum_of_depths = 0.f; + for (const auto& tch : m_layer_info->tool_changes) { // let's find this toolchange + if (tch.old_tool == m_current_tool) { + sum_of_depths += tch.ramming_depth; + float ramming_end_y = m_wipe_tower_pos.y + sum_of_depths; + ramming_end_y -= (y_step/m_extra_spacing-m_line_width) / 2.f; // center of final ramming line + + // debugging: + /*float oldx = writer.x(); + float oldy = writer.y(); + writer.travel(xl,ramming_end_y); + writer.extrude(xl-15,writer.y()); + writer.travel(oldx,oldy);*/ + + if (ramming_end_y < sparse_beginning_y) { + writer.extrude(xl + tch.first_wipe_line-1.f*m_perimeter_width-0.1f,writer.y()); + writer.travel(xl + tch.first_wipe_line-1.f*m_perimeter_width,writer.y()); + remaining -= tch.first_wipe_line-1.f*m_perimeter_width; + } + break; + } + sum_of_depths += tch.required_depth; + } + } + + // now the ramming itself: + while (i < m_par.ramming_speed[m_current_tool].size()) + { + const float x = volume_to_length(m_par.ramming_speed[m_current_tool][i] * 0.25f, line_width, m_layer_height); + const float e = m_par.ramming_speed[m_current_tool][i] * 0.25f / Filament_Area; // transform volume per sec to E move; + const float dist = std::min(x - e_done, remaining); // distance to travel for either the next 0.25s, or to the next turnaround + const float actual_time = dist/x * 0.25; + writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), std::hypot(dist, e * (dist / x)) / (actual_time / 60.)); + remaining -= dist; if (remaining < WT_EPSILON) { // we reached a turning point writer.travel(writer.x(), writer.y() + y_step, 7200); @@ -1030,15 +1070,23 @@ void WipeTowerPrusaMM::toolchange_Wipe( float wipe_coeff = m_is_first_layer ? 0.5f : 1.f; const float& xl = cleaning_box.ld.x; const float& xr = cleaning_box.rd.x; - - // DEBUGGING: The function makes sure it always wipes at least the ordered volume, even if it means violating - // the perimeter. This can later be removed and simply wipe until the end of the assigned area. - // (Variables x_to_wipe and traversed_x) + + + // Variables x_to_wipe and traversed_x are here to be able to make sure it always wipes at least + // the ordered volume, even if it means violating the box. This can later be removed and simply + // wipe until the end of the assigned area. float x_to_wipe = volume_to_length(wipe_volume, m_line_width, m_layer_height); float dy = m_extra_spacing*m_line_width; float wipe_speed = 1600.f; + // if there is less than 2.5*m_perimeter_width to the edge, advance straightaway (there is likely a blob anyway) + if ((m_left_to_right ? xr-writer.x() : writer.x()-xl) < 2.5f*m_perimeter_width) { + writer.travel((m_left_to_right ? xr-m_perimeter_width : xl+m_perimeter_width),writer.y()+dy); + m_left_to_right = !m_left_to_right; + } + + // now the wiping itself: for (int i = 0; true; ++i) { if (i!=0) { if (wipe_speed < 1610.f) wipe_speed = 1800.f; @@ -1067,9 +1115,6 @@ void WipeTowerPrusaMM::toolchange_Wipe( m_left_to_right = !m_left_to_right; } writer.set_extrusion_flow(m_extrusion_flow); // Reset the extrusion flow. - - // Wipe the nozzle - } diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 16baa2b371..1b6b943089 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -448,7 +448,7 @@ private: }; std::vector m_plan; // Stores information about all layers and toolchanges for the future wipe tower (filled by plan_toolchange(...)) - std::vector::iterator m_layer_info; + std::vector::iterator m_layer_info = m_plan.end(); // Returns gcode for wipe tower brim From f5cf181372116857524511ec22b8d770cbf45e50 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 7 Mar 2018 15:34:12 +0100 Subject: [PATCH 0032/1150] Sparse infill repositioned always to the same side --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 33 +++++++++++++-------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 1 + 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 250bad1d2f..fcb651423e 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -622,7 +622,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - .set_y_shift(m_y_shift) + .set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_layer_parity && !peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) .append(";--------------------\n" "; CP TOOLCHANGE START\n") .comment_with_value(" toolchange #", m_num_tool_changes) @@ -676,7 +676,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature); if (last_change_in_layer) // draw perimeter line - writer.travel(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width), 7000) + writer.set_y_shift(m_y_shift) + .travel(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width), 7000) .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, 0), 3200) .extrude(m_wipe_tower_pos) .extrude(m_wipe_tower_pos + xy(0, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width)) @@ -801,11 +802,15 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.travel(xl, cleaning_box.ld.y + m_depth_traversed + y_step/2.f ); // move to starting position // if the ending point of the ram would end up in mid air, align it with the end of the wipe tower: - if (m_layer_info > m_plan.begin() && m_layer_info < m_plan.end()) { + if (m_layer_info > m_plan.begin() && m_layer_info < m_plan.end() && (m_layer_info-1!=m_plan.begin() || !m_par.adhesion )) { - // this is y of the center of first supported line - float sparse_beginning_y = m_wipe_tower_pos.y - + ((m_layer_info-1)->depth - (m_layer_info-1)->toolchanges_depth()); + // this is y of the center of previous sparse infill border + float sparse_beginning_y = m_wipe_tower_pos.y; + if (m_layer_parity) + sparse_beginning_y += ((m_layer_info-1)->depth - (m_layer_info-1)->toolchanges_depth()) + - ((m_layer_info)->depth-(m_layer_info)->toolchanges_depth()) ; + else + sparse_beginning_y += (m_layer_info-1)->toolchanges_depth() + m_perimeter_width; //debugging: /* float oldx = writer.x(); @@ -828,9 +833,10 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.extrude(xl-15,writer.y()); writer.travel(oldx,oldy);*/ - if (ramming_end_y < sparse_beginning_y) { - writer.extrude(xl + tch.first_wipe_line-1.f*m_perimeter_width-0.1f,writer.y()); - writer.travel(xl + tch.first_wipe_line-1.f*m_perimeter_width,writer.y()); + if ( (m_layer_parity && ramming_end_y < sparse_beginning_y - 0.5f*m_perimeter_width ) || + (!m_layer_parity && ramming_end_y > sparse_beginning_y + 0.5f*m_perimeter_width ) ) + { + writer.extrude(xl + tch.first_wipe_line-1.f*m_perimeter_width,writer.y()); remaining -= tch.first_wipe_line-1.f*m_perimeter_width; } break; @@ -1132,7 +1138,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - .set_y_shift(m_y_shift) + .set_y_shift(m_y_shift - (m_layer_parity && !peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) .append(";--------------------\n" "; CP EMPTY GRID START\n") // m_num_layer_changes is incremented by set_z, so it is 1 based. @@ -1353,8 +1359,11 @@ void WipeTowerPrusaMM::generate(std::vectordepth < m_wipe_tower_depth - m_perimeter_width) m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 1b6b943089..0906d334e7 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -336,6 +336,7 @@ private: size_t m_max_color_changes = 0; // Maximum number of color changes per layer. bool m_is_first_layer = false;// Is this the 1st layer of the print? If so, print the brim around the waste tower. bool m_is_last_layer = false;// Is this the last layer of this waste tower? + bool m_layer_parity = false; // G-code generator parameters. float m_zhop = 0.5f; From 8340a71f885eba943b45a0e08ba5182061353ed6 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 8 Mar 2018 16:44:52 +0100 Subject: [PATCH 0033/1150] Lots of unnecessary code removed, minor refactoring changes --- xs/src/libslic3r/GCode/WipeTower.hpp | 8 +- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 533 +++++++------------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 12 +- xs/src/libslic3r/Print.cpp | 4 +- 4 files changed, 180 insertions(+), 377 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTower.hpp b/xs/src/libslic3r/GCode/WipeTower.hpp index e193fd9725..36cebeb847 100644 --- a/xs/src/libslic3r/GCode/WipeTower.hpp +++ b/xs/src/libslic3r/GCode/WipeTower.hpp @@ -126,17 +126,15 @@ public: const std::vector &tools, // If true, the last priming are will be the same as the other priming areas, and the rest of the wipe will be performed inside the wipe tower. // If false, the last priming are will be large enough to wipe the last extruder sufficiently. - bool last_wipe_inside_wipe_tower, - // May be used by a stand alone post processor. - Purpose purpose = PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) = 0; + bool last_wipe_inside_wipe_tower) = 0; // Returns gcode for toolchange and the end position. // if new_tool == -1, just unload the current filament over the wipe tower. - virtual ToolChangeResult tool_change(unsigned int new_tool, bool last_in_layer, Purpose purpose = PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) = 0; + virtual ToolChangeResult tool_change(unsigned int new_tool, bool last_in_layer) = 0; // Close the current wipe tower layer with a perimeter and possibly fill the unfilled space with a zig-zag. // Call this method only if layer_finished() is false. - virtual ToolChangeResult finish_layer(Purpose purpose = PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) = 0; + virtual ToolChangeResult finish_layer() = 0; // Is the current layer finished? A layer is finished if either the wipe tower is finished, or // the wipe tower has been completely covered by the tool change extrusions, diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index fcb651423e..39ccc71555 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -4,8 +4,8 @@ TODO LIST --------- 1. cooling moves - DONE -2. priming extrusions - DONE (fixed wiping volume so far) -3. account for perimeter and finish_layer extrusions and subtract it from last wipe +2. account for perimeter and finish_layer extrusions and subtract it from last wipe - DONE +3. priming extrusions (last wipe must clear the color) 4. Peter's wipe tower - layer's are not exactly square 5. Peter's wipe tower - variable width for higher levels 6. Peter's wipe tower - make sure it is not too sparse (apply max_bridge_distance and make last wipe longer) @@ -53,7 +53,7 @@ public: m_elapsed_time(0.f) {} Writer& set_initial_position(const WipeTower::xy &pos) { - m_start_pos = pos; + m_start_pos = WipeTower::xy(pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); m_current_pos = pos; return *this; } @@ -93,7 +93,7 @@ public: float x() const { return m_current_pos.x; } float y() const { return m_current_pos.y; } const WipeTower::xy& pos() const { return m_current_pos; } - const WipeTower::xy start_pos_rotated() const { return WipeTower::xy(m_start_pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } + const WipeTower::xy start_pos_rotated() const { return m_start_pos; } const WipeTower::xy pos_rotated() const { return WipeTower::xy(m_current_pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); } float elapsed_time() const { return m_elapsed_time; } @@ -169,6 +169,27 @@ public: Writer& extrude(const WipeTower::xy &dest, const float f = 0.f) { return extrude(dest.x, dest.y, f); } + + Writer& rectangle(const WipeTower::xy& ld,float width,float height,const float f = 0.f) + { + WipeTower::xy corners[4]; + corners[0] = ld; + corners[1] = WipeTower::xy(ld,width,0.f); + corners[2] = WipeTower::xy(ld,width,height); + corners[3] = WipeTower::xy(ld,0.f,height); + int index_of_closest = (x()-ld.x < ld.x+width-x() ? 0 : 1); + if (y()-ld.y > ld.y+height-x()) // closer to the top + index_of_closest += (index_of_closest==0 ? 3 : 1); + travel(corners[index_of_closest].x,y(),f); // travel to the closest corner + travel(x(),corners[index_of_closest].y,f); + int i = index_of_closest; + do { + ++i; + if (i==4) i=0; + this->extrude(corners[i]); + } while (i != index_of_closest); + return (*this); + } Writer& load(float e, float f = 0.f) { @@ -449,29 +470,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( const std::vector &tools, // If true, the last priming are will be the same as the other priming areas, and the rest of the wipe will be performed inside the wipe tower. // If false, the last priming are will be large enough to wipe the last extruder sufficiently. - bool last_wipe_inside_wipe_tower, - // May be used by a stand alone post processor. - Purpose purpose) + bool last_wipe_inside_wipe_tower) { this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false); - - // Calculate the amount of wipe over the wipe tower brim following the prime, decrease wipe_area - // with the amount of material extruded over the brim. - // DOESN'T MAKE SENSE NOW, wipe tower dimensions are still unknown at this point - /*{ - // Simulate the brim extrusions, summ the length of the extrusion. - float e_length = this->tool_change(0, false, PURPOSE_EXTRUDE).total_extrusion_length_in_plane(); - // Shrink wipe_area by the amount of extrusion extruded by the finish_layer(). - // Y stepping of the wipe extrusions. - float dy = m_line_width; - // Number of whole wipe lines, that would be extruded to wipe as much material as the finish_layer(). - // Minimum wipe area is 5mm wide. - //FIXME calculate the purge_lines_width precisely. - float purge_lines_width = 1.3f; - wipe_area = std::max(5.f, m_wipe_area - float(floor(e_length / m_wipe_tower_width)) * dy - purge_lines_width); - } - - this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false);*/ this->m_num_layer_changes = 0; this->m_current_tool = tools.front(); @@ -502,28 +503,26 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); writer.append(buf); - if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - for (size_t idx_tool = 0; idx_tool < tools.size(); ++ idx_tool) { - unsigned int tool = tools[idx_tool]; - m_left_to_right = true; - toolchange_Change(writer, tool, m_filpar[tool].material); // Select the tool, set a speed override for soluble and flex materials. - toolchange_Load(writer, cleaning_box); // Prime the tool. - if (idx_tool + 1 == tools.size()) { - // Last tool should not be unloaded, but it should be wiped enough to become of a pure color. - toolchange_Wipe(writer, cleaning_box, 20.f); - } else { - // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. - //writer.travel(writer.x(), writer.y() + m_perimeter_width, 7200); - toolchange_Wipe(writer, cleaning_box , 5.f); - box_coordinates box = cleaning_box; - box.translate(0.f, writer.y() - cleaning_box.ld.y + m_perimeter_width); - toolchange_Unload(writer, box , m_filpar[m_current_tool].material, m_filpar[tools[idx_tool + 1]].first_layer_temperature); - cleaning_box.translate(prime_section_width, 0.f); - writer.travel(cleaning_box.ld, 7200); - } - ++ m_num_tool_changes; - } - } + for (size_t idx_tool = 0; idx_tool < tools.size(); ++ idx_tool) { + unsigned int tool = tools[idx_tool]; + m_left_to_right = true; + toolchange_Change(writer, tool, m_filpar[tool].material); // Select the tool, set a speed override for soluble and flex materials. + toolchange_Load(writer, cleaning_box); // Prime the tool. + if (idx_tool + 1 == tools.size()) { + // Last tool should not be unloaded, but it should be wiped enough to become of a pure color. + toolchange_Wipe(writer, cleaning_box, 20.f); + } else { + // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. + //writer.travel(writer.x(), writer.y() + m_perimeter_width, 7200); + toolchange_Wipe(writer, cleaning_box , 5.f); + box_coordinates box = cleaning_box; + box.translate(0.f, writer.y() - cleaning_box.ld.y + m_perimeter_width); + toolchange_Unload(writer, box , m_filpar[m_current_tool].material, m_filpar[tools[idx_tool + 1]].first_layer_temperature); + cleaning_box.translate(prime_section_width, 0.f); + writer.travel(cleaning_box.ld, 7200); + } + ++ m_num_tool_changes; + } // Reset the extruder current to a normal value. writer.set_extruder_trimpot(550) @@ -534,8 +533,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( ";------------------\n" "\n\n"); - // Force m_idx_tool_change_in_layer to -1, so that tool_change() will know to extrude the wipe tower brim. - ///m_idx_tool_change_in_layer = (unsigned int)(-1); + // so that tool_change() will know to extrude the wipe tower brim: m_print_brim = true; ToolChangeResult result; @@ -549,48 +547,13 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( return result; } -WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, bool last_in_layer, Purpose purpose) +WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, bool last_in_layer) { - // Either it is the last tool unload, - // or there must be a nonzero wipe tower partitions available. -// assert(tool < 0 || it_layer_tools->wipe_tower_partitions > 0); + if ( m_print_brim ) + return toolchange_Brim(); - if ( m_print_brim ) { - ///if (m_idx_tool_change_in_layer == (unsigned int)(-1)) { - // First layer, prime the extruder. - return toolchange_Brim(purpose); - } float wipe_area = 0.f; - {/*if (++ m_idx_tool_change_in_layer < (unsigned int)m_max_color_changes && last_in_layer) { - // This tool_change() call will be followed by a finish_layer() call. - // Try to shrink the wipe_area to save material, as less than usual wipe is required - // if this step is foolowed by finish_layer() extrusions wiping the same extruder. - for (size_t iter = 0; iter < 3; ++ iter) { - // Simulate the finish_layer() extrusions, summ the length of the extrusion. - float e_length = 0.f; - { - unsigned int old_idx_tool_change = m_idx_tool_change_in_layer; - float old_wipe_start_y = m_current_wipe_start_y; - m_current_wipe_start_y += wipe_area; - e_length = this->finish_layer(PURPOSE_EXTRUDE).total_extrusion_length_in_plane(); - m_idx_tool_change_in_layer = old_idx_tool_change; - m_current_wipe_start_y = old_wipe_start_y; - } - // Shrink wipe_area by the amount of extrusion extruded by the finish_layer(). - // Y stepping of the wipe extrusions. - float dy = m_line_width; - // Number of whole wipe lines, that would be extruded to wipe as much material as the finish_layer(). - float num_lines_extruded = floor(e_length / m_wipe_tower_width); - // Minimum wipe area is 5mm wide. - wipe_area = m_wipe_area - num_lines_extruded * dy; - if (wipe_area < 5.) { - wipe_area = 5.; - break; - } - } - }*/} - bool last_change_in_layer = false; float wipe_volume = 0.f; @@ -622,7 +585,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - .set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_layer_parity && !peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) + .set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) .append(";--------------------\n" "; CP TOOLCHANGE START\n") .comment_with_value(" toolchange #", m_num_tool_changes) @@ -631,71 +594,46 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .speed_override(100); xy initial_position = cleaning_box.ld + WipeTower::xy(0.f,m_depth_traversed); + writer.set_initial_position(initial_position); - if (purpose == PURPOSE_MOVE_TO_TOWER || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - // Scaffold leaks terribly, reduce leaking by a full retract when going to the wipe tower. - float initial_retract = ((m_filpar[m_current_tool].material == SCAFF) ? 1.f : 0.5f) * m_retract; - writer // Lift for a Z hop. - .z_hop(m_zhop, 7200) - // Additional retract on move to tower. - .retract(initial_retract, 3600) - // Move to a starting position, one perimeter width inside the cleaning box. - .travel(initial_position, 7200) - // Unlift for a Z hop. - .z_hop_reset(7200) - // Additional retract on move to tower. - .load(initial_retract, 3600) - .load(m_retract, 1500); - } else { - // Already at the initial position. - writer.set_initial_position(initial_position); - } // adds tag for analyzer char buf[32]; sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); writer.append(buf); - if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - // Increase the extruder driver current to allow fast ramming. - writer.set_extruder_trimpot(750); - - // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. - if (tool != (unsigned int)-1){ // This is not the last change. - toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, - m_is_first_layer ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature); - toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials. - toolchange_Load(writer, cleaning_box); - toolchange_Wipe(writer, cleaning_box, wipe_volume); // Wipe the newly loaded filament until the end of the assigned wipe area. + // Increase the extruder driver current to allow fast ramming. + writer.set_extruder_trimpot(750); - // Always wipe the nozzle with a long wipe to reduce stringing when moving away from the wipe tower. - /*box_coordinates box = cleaning_box; - writer.travel(box.ru, 7200) - .travel(box.lu);*/ - } else - toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature); + // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. + if (tool != (unsigned int)-1){ // This is not the last change. + toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, + m_is_first_layer ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature); + toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials. + toolchange_Load(writer, cleaning_box); + toolchange_Wipe(writer, cleaning_box, wipe_volume); // Wipe the newly loaded filament until the end of the assigned wipe area. + } else + toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature); - if (last_change_in_layer) // draw perimeter line - writer.set_y_shift(m_y_shift) - .travel(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width), 7000) - .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, 0), 3200) - .extrude(m_wipe_tower_pos) - .extrude(m_wipe_tower_pos + xy(0, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width)) - .extrude(m_wipe_tower_pos + xy(peters_wipe_tower ? m_layer_info->depth + 3*m_perimeter_width : m_wipe_tower_width, peters_wipe_tower ? m_wipe_tower_depth : m_layer_info->depth + m_perimeter_width)); + if (last_change_in_layer) {// draw perimeter line + writer.set_y_shift(m_y_shift); + if (peters_wipe_tower) + writer.rectangle(m_wipe_tower_pos,m_layer_info->depth + 3*m_perimeter_width,m_wipe_tower_depth); + else + writer.rectangle(m_wipe_tower_pos,m_wipe_tower_width, m_layer_info->depth + m_perimeter_width); + } - // Reset the extruder current to a normal value. - writer.set_extruder_trimpot(550) - .feedrate(6000) - .flush_planner_queue() - .reset_extruder() - .append("; CP TOOLCHANGE END\n" - ";------------------\n" - "\n\n"); + // Reset the extruder current to a normal value. + writer.set_extruder_trimpot(550) + .feedrate(6000) + .flush_planner_queue() + .reset_extruder() + .append("; CP TOOLCHANGE END\n" + ";------------------\n" + "\n\n"); - ++ m_num_tool_changes; - //m_current_wipe_start_y += wipe_area; - m_depth_traversed += wipe_area; - } + ++ m_num_tool_changes; + m_depth_traversed += wipe_area; ToolChangeResult result; result.print_z = this->m_z_pos; @@ -708,7 +646,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo return result; } -WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, bool sideOnly, float y_offset) +WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(bool sideOnly, float y_offset) { const box_coordinates wipeTower_box( m_wipe_tower_pos, @@ -725,46 +663,33 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b "; CP WIPE TOWER FIRST LAYER BRIM START\n"); xy initial_position = wipeTower_box.lu - xy(m_perimeter_width * 6.f, 0); - - if (purpose == PURPOSE_MOVE_TO_TOWER || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) - // Move with Z hop. - writer.z_hop(m_zhop, 7200) - .travel(initial_position, 6000) - .z_hop_reset(7200); - else - writer.set_initial_position(initial_position); + writer.set_initial_position(initial_position); // adds tag for analyzer char buf[32]; sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); - writer.append(buf); + writer.append(buf) + .extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), // Prime the extruder left of the wipe tower. + 1.5f * m_extrusion_flow * (wipeTower_box.lu.y - wipeTower_box.ld.y), 2400); - if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { + // The tool is supposed to be active and primed at the time when the wipe tower brim is extruded. + // Extrude 4 rounds of a brim around the future wipe tower. + box_coordinates box(wipeTower_box); + box.expand(m_perimeter_width); + for (size_t i = 0; i < 4; ++ i) { + writer.travel (box.ld, 7000) + .extrude(box.lu, 2100).extrude(box.ru) + .extrude(box.rd ).extrude(box.ld); + box.expand(m_perimeter_width); + } - writer.extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), // Prime the extruder left of the wipe tower. - 1.5f * m_extrusion_flow * (wipeTower_box.lu.y - wipeTower_box.ld.y), 2400); + writer.travel(wipeTower_box.ld, 7000); // Move to the front left corner. + writer.travel(wipeTower_box.rd) // Always wipe the nozzle with a long wipe to reduce stringing when moving away from the wipe tower. + .travel(wipeTower_box.ld); + writer.append("; CP WIPE TOWER FIRST LAYER BRIM END\n" + ";-----------------------------------\n"); - // The tool is supposed to be active and primed at the time when the wipe tower brim is extruded. - // toolchange_Change(writer, int(tool), m_material[tool]); - - // Extrude 4 rounds of a brim around the future wipe tower. - box_coordinates box(wipeTower_box); - box.expand(m_perimeter_width); - for (size_t i = 0; i < 4; ++ i) { - writer.travel (box.ld, 7000) - .extrude(box.lu, 2100).extrude(box.ru) - .extrude(box.rd ).extrude(box.ld); - box.expand(m_perimeter_width); - } - - writer.travel(wipeTower_box.ld, 7000); // Move to the front left corner. - writer.travel(wipeTower_box.rd) // Always wipe the nozzle with a long wipe to reduce stringing when moving away from the wipe tower. - .travel(wipeTower_box.ld); - writer.append("; CP WIPE TOWER FIRST LAYER BRIM END\n" - ";-----------------------------------\n"); - // Mark the brim as extruded. - m_print_brim = false; - } + m_print_brim = false; // Mark the brim as extruded ToolChangeResult result; result.print_z = this->m_z_pos; @@ -806,7 +731,7 @@ void WipeTowerPrusaMM::toolchange_Unload( // this is y of the center of previous sparse infill border float sparse_beginning_y = m_wipe_tower_pos.y; - if (m_layer_parity) + if (m_current_shape == SHAPE_REVERSED) sparse_beginning_y += ((m_layer_info-1)->depth - (m_layer_info-1)->toolchanges_depth()) - ((m_layer_info)->depth-(m_layer_info)->toolchanges_depth()) ; else @@ -833,8 +758,8 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.extrude(xl-15,writer.y()); writer.travel(oldx,oldy);*/ - if ( (m_layer_parity && ramming_end_y < sparse_beginning_y - 0.5f*m_perimeter_width ) || - (!m_layer_parity && ramming_end_y > sparse_beginning_y + 0.5f*m_perimeter_width ) ) + if ( (m_current_shape == SHAPE_REVERSED && ramming_end_y < sparse_beginning_y - 0.5f*m_perimeter_width ) || + (m_current_shape == SHAPE_NORMAL && ramming_end_y > sparse_beginning_y + 0.5f*m_perimeter_width ) ) { writer.extrude(xl + tch.first_wipe_line-1.f*m_perimeter_width,writer.y()); remaining -= tch.first_wipe_line-1.f*m_perimeter_width; @@ -868,47 +793,6 @@ void WipeTowerPrusaMM::toolchange_Unload( } WipeTower::xy end_of_ramming(writer.x(),writer.y()); -// Alex's old ramming: -{ - /*switch (current_material) - { - case ABS: - // ramming start end y increment amount feedrate - writer.ram(xl + m_perimeter_width * 2, xr - m_perimeter_width, y_step * 0.2f, 0, 1.2f * e, 4000) - .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 1.2f, e0, 1.6f * e, 4600) - .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 1.2f, e0, 1.8f * e, 5000) - .ram(xr - m_perimeter_width * 2, xl + m_perimeter_width * 2, y_step * 1.2f, e0, 1.8f * e, 5000); - break; - case PVA: - // Used for the PrimaSelect PVA - writer.ram(xl + m_perimeter_width * 2, xr - m_perimeter_width, y_step * 0.2f, 0, 1.75f * e, 4000) - .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 1.5f, 0, 1.75f * e, 4500) - .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 1.5f, 0, 1.75f * e, 4800) - .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 1.5f, 0, 1.75f * e, 5000); - break; - case SCAFF: - writer.ram(xl + m_perimeter_width * 2, xr - m_perimeter_width, y_step * 2.f, 0, 1.75f * e, 4000) - .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 3.f, 0, 2.34f * e, 4600) - .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 3.f, 0, 2.63f * e, 5200); - break; - default: - // PLA, PLA/PHA and others - // Used for the Verbatim BVOH, PET, NGEN, co-polyesters - writer.ram(xl + m_perimeter_width * 2, xr - m_perimeter_width, y_step * 0.2f, 0, 1.60f * e, 4000) - .ram(xr - m_perimeter_width, xl + m_perimeter_width, y_step * 1.2f, e0, 1.65f * e, 4600) - .ram(xl + m_perimeter_width * 2, xr - m_perimeter_width * 2, y_step * 1.2f, e0, 1.74f * e, 5200); - }*/ -} - // Pull the filament end into a cooling tube (Alex) - //writer.retract(15, 5000).retract(50, 5400).retract(15, 3000).retract(12, 2000); - - // Pull the filament end to the BEGINNING of the cooling tube - /*float unloading_feedrate = 60.f * m_filpar[m_current_tool].unloading_speed; - writer.retract(15, 5000) // just after ramming - always the same speed - .retract(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42, unloading_feedrate) - .retract(15, unloading_feedrate*0.55f) - .retract(12, unloading_feedrate*0.35f);*/ - // Pull the filament end to the BEGINNING of the cooling tube while still moving the print head float oldx = writer.x(); float turning_point = (!m_left_to_right ? std::max(xl,oldx-15.f) : std::min(xr,oldx+15.f) ); // so it's not too far @@ -957,42 +841,8 @@ void WipeTowerPrusaMM::toolchange_Unload( // we should be at the beginning of the cooling tube again - let's move to parking position: writer.retract(-m_cooling_tube_length/2.f+m_parking_pos_retraction-m_cooling_tube_retraction, 2000); - writer.travel(writer.x(), writer.y() - y_step,2400); - - // Alex's old cooling: - { - // In case the current print head position is closer to the left edge, reverse the direction. - /*if (std::abs(writer.x() - xl) < std::abs(writer.x() - xr)) - std::swap(xl, xr); - // Horizontal cooling moves will be performed at the following Y coordinate: - writer.travel(xr, writer.y() + y_step * 0.8f, 7200) - .suppress_preview(); - switch (current_material) - { - case PVA: - writer.cool(xl, xr, 3, -5, 1600) - .cool(xl, xr, 5, -5, 2000) - .cool(xl, xr, 5, -5, 2200) - .cool(xl, xr, 5, -5, 2400) - .cool(xl, xr, 5, -5, 2400) - .cool(xl, xr, 5, -3, 2400); - break; - case SCAFF: - writer.cool(xl, xr, 3, -5, 1600) - .cool(xl, xr, 5, -5, 2000) - .cool(xl, xr, 5, -5, 2200) - .cool(xl, xr, 5, -5, 2200) - .cool(xl, xr, 5, -3, 2400); - break; - default: - writer.cool(xl, xr, 3, -5, 1600) - .cool(xl, xr, 5, -5, 2000) - .cool(xl, xr, 5, -5, 2400) - .cool(xl, xr, 5, -3, 2400); - }*/ -} // this is to align ramming and future loading extrusions, so the future y-steps can be uniform from the start: - writer.travel(end_of_ramming.x, end_of_ramming.y + (y_step/m_extra_spacing-m_line_width) / 2.f, 2400.f); + writer.travel(end_of_ramming.x, end_of_ramming.y + (y_step/m_extra_spacing-m_line_width) / 2.f + m_perimeter_width, 2400.f); writer.resume_preview() .flush_planner_queue(); @@ -1036,6 +886,7 @@ void WipeTowerPrusaMM::toolchange_Load( float edist = m_parking_pos_retraction-50-2; // loading is 2mm shorter that previous retraction, 50mm reserved for acceleration/deceleration writer.append("; CP TOOLCHANGE LOAD\n") .suppress_preview() + .travel(writer.x(),writer.y() + m_perimeter_width) // So that we move in free space .load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Acceleration .load_move_x(oldx,edist,60*std::hypot(dist,edist)/edist * loading_speed) // Fast phase .load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Slowing down @@ -1043,20 +894,6 @@ void WipeTowerPrusaMM::toolchange_Load( .travel(oldx,oldy) .resume_preview(); -// Alex's old loading extrusions - this has been moved to toolchange_Wipe(...) -{ - // Extrude first five lines (just three lines if colorInit is set). - /*writer.extrude(xr, writer.y(), 1600); - bool colorInit = false; - size_t pass = colorInit ? 1 : 2; - float dy = ((m_current_shape == SHAPE_NORMAL) ? 1.f : -1.f) * m_line_width; - for (int i = 0; i < pass; ++ i) { - writer.travel (xr, writer.y() + dy, 7200); - writer.extrude(xl, writer.y(), 2200); - writer.travel (xl, writer.y() + dy, 7200); - writer.extrude(xr, writer.y(), 2200); - }*/ -} // Reset the extruder current to the normal value. writer.set_extruder_trimpot(550); } @@ -1091,6 +928,8 @@ void WipeTowerPrusaMM::toolchange_Wipe( writer.travel((m_left_to_right ? xr-m_perimeter_width : xl+m_perimeter_width),writer.y()+dy); m_left_to_right = !m_left_to_right; } + + writer.travel(writer.x(),writer.y()-m_perimeter_width); // cooling & loading was done a fraction down the road // now the wiping itself: for (int i = 0; true; ++i) { @@ -1126,7 +965,7 @@ void WipeTowerPrusaMM::toolchange_Wipe( -WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) +WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() { // This should only be called if the layer is not finished yet. // Otherwise the caller would likely travel to the wipe tower in vain. @@ -1138,7 +977,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - .set_y_shift(m_y_shift - (m_layer_parity && !peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) + .set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) .append(";--------------------\n" "; CP EMPTY GRID START\n") // m_num_layer_changes is incremented by set_z, so it is 1 based. @@ -1150,93 +989,65 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose) box_coordinates fill_box(m_wipe_tower_pos + xy(m_perimeter_width, m_depth_traversed + m_perimeter_width), m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width); - if (purpose == PURPOSE_MOVE_TO_TOWER || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - if ( m_layer_info->tool_changes.size() == 0) { - // There were no tool changes at all in this layer. - writer.retract(m_retract * 1.5f, 3600) - // Jump with retract to fill_box.ld + a random shift in +x. - .z_hop(m_zhop, 7200) - .travel(fill_box.ld + xy(5.f + 15.f * float(rand()) / RAND_MAX, 0.f), 7000) - .z_hop_reset(7200) - // Prime the extruder. - .load_move_x(fill_box.ld.x, m_retract * 1.5f, 3600); - } else { - // Otherwise the extruder is already over the wipe tower. - } - } else { - // The print head is inside the wipe tower. Rather move to the start of the following extrusion. - writer.set_initial_position(fill_box.lu); - } + // The print head is inside the wipe tower. Rather move to the start of the following extrusion. + writer.set_initial_position(fill_box.lu); - if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) { - box_coordinates box = fill_box; - for (int i=0;i<2;++i) { - if (m_layer_info->toolchanges_depth() < WT_EPSILON) { // there were no toolchanges on this layer - if (i==0) box.expand(m_perimeter_width); - else box.expand(-m_perimeter_width); - } - else i=2; // only draw the inner perimeter - - writer.travel(box.lu,7200) - .extrude(box.ru, 2400 * speed_factor) - .extrude(box.rd) - .extrude(box.ld) - .extrude(box.lu); - } - - if (m_is_first_layer && m_par.adhesion) { - // Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower. - box.expand(-m_perimeter_width/2.f); - unsigned nsteps = int(floor((box.lu.y - box.ld.y) / (2*m_perimeter_width))); - float step = (box.lu.y - box.ld.y) / nsteps; - writer.travel(box.ld-xy(m_perimeter_width/2.f,m_perimeter_width/2.f)); - if (nsteps >= 0) - for (size_t i = 0; i < nsteps; ++i) { - writer.extrude(box.ld.x+m_perimeter_width/2.f, writer.y() + 0.5f * step); - writer.extrude(box.rd.x - m_perimeter_width / 2.f, writer.y()); - writer.extrude(box.rd.x - m_perimeter_width / 2.f, writer.y() + 0.5f * step); - writer.extrude(box.ld.x + m_perimeter_width / 2.f, writer.y()); - } - writer.travel(box.rd.x-m_perimeter_width/2.f,writer.y()); // wipe the nozzle - } else { - // Extrude a sparse infill to support the material to be printed above. - - const float dy = (fill_box.lu.y - fill_box.ld.y - m_perimeter_width); - if (dy > m_perimeter_width) - { - // Extrude an inverse U at the left of the region. - writer.travel(fill_box.ld + xy(m_perimeter_width * 2, 0.f)) - .extrude(fill_box.lu + xy(m_perimeter_width * 2, 0.f), 2900 * speed_factor); - - const float left = fill_box.lu.x+2*m_perimeter_width; - const float right = fill_box.ru.x - 2 * m_perimeter_width; - const int n = 1+(right-left)/(m_par.bridging); - const float dx = (right-left)/n; - for (int i=1;i<=n;++i) { - float x=left+dx*i; - writer.travel(x,writer.y()); - writer.extrude(x,i%2 ? fill_box.rd.y : fill_box.ru.y); - } - writer.travel(left,writer.y(),7200); // wipes the nozzle before moving away from the wipe tower - } - } + box_coordinates box = fill_box; + for (int i=0;i<2;++i) { + if (m_layer_info->toolchanges_depth() < WT_EPSILON) { // there were no toolchanges on this layer + if (i==0) box.expand(m_perimeter_width); + else box.expand(-m_perimeter_width); + } + else i=2; // only draw the inner perimeter, outer has been already drawn by tool_change(...) + writer.rectangle(box.ld,box.rd.x-box.ld.x,box.ru.y-box.rd.y); /* - // if (purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) - if (true) - // Wipe along the front side of the current wiping box. - // Always wipe the nozzle with a long wipe to reduce stringing when moving away from the wipe tower. - writer.travel(fill_box.ld + xy( m_perimeter_width, m_perimeter_width / 2), 7200) - .travel(fill_box.rd + xy(- m_perimeter_width, m_perimeter_width / 2)); - else - writer.feedrate(7200); -*/ - writer.append("; CP EMPTY GRID END\n" - ";------------------\n\n\n\n\n\n\n"); + writer.travel(box.lu,7200) + .extrude(box.ru, 2400 * speed_factor) + .extrude(box.rd) + .extrude(box.ld) + .extrude(box.lu);*/ + } + + if (m_is_first_layer && m_par.adhesion) { + // Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower. + box.expand(-m_perimeter_width/2.f); + unsigned nsteps = int(floor((box.lu.y - box.ld.y) / (2*m_perimeter_width))); + float step = (box.lu.y - box.ld.y) / nsteps; + writer.travel(box.ld-xy(m_perimeter_width/2.f,m_perimeter_width/2.f)); + if (nsteps >= 0) + for (size_t i = 0; i < nsteps; ++i) { + writer.extrude(box.ld.x+m_perimeter_width/2.f, writer.y() + 0.5f * step); + writer.extrude(box.rd.x - m_perimeter_width / 2.f, writer.y()); + writer.extrude(box.rd.x - m_perimeter_width / 2.f, writer.y() + 0.5f * step); + writer.extrude(box.ld.x + m_perimeter_width / 2.f, writer.y()); + } + writer.travel(box.rd.x-m_perimeter_width/2.f,writer.y()); // wipe the nozzle + } + else { // Extrude a sparse infill to support the material to be printed above. + const float dy = (fill_box.lu.y - fill_box.ld.y - m_perimeter_width); + if (dy > m_perimeter_width) + { + // Extrude an inverse U at the left of the region. + writer.travel(fill_box.ld + xy(m_perimeter_width * 2, 0.f)) + .extrude(fill_box.lu + xy(m_perimeter_width * 2, 0.f), 2900 * speed_factor); + + const float left = fill_box.lu.x+2*m_perimeter_width; + const float right = fill_box.ru.x - 2 * m_perimeter_width; + const int n = 1+(right-left)/(m_par.bridging); + const float dx = (right-left)/n; + for (int i=1;i<=n;++i) { + float x=left+dx*i; + writer.travel(x,writer.y()); + writer.extrude(x,i%2 ? fill_box.rd.y : fill_box.ru.y); + } + writer.travel(left,writer.y(),7200); // wipes the nozzle before moving away from the wipe tower + } + } + writer.append("; CP EMPTY GRID END\n" + ";------------------\n\n\n\n\n\n\n"); + + m_depth_traversed = m_wipe_tower_depth-m_perimeter_width; - // Indicate that this wipe tower layer is fully covered. - m_depth_traversed = m_wipe_tower_depth-m_perimeter_width; - ///m_idx_tool_change_in_layer = (unsigned int)m_max_color_changes; - } ToolChangeResult result; result.print_z = this->m_z_pos; result.layer_height = this->m_layer_height; @@ -1316,10 +1127,10 @@ void WipeTowerPrusaMM::save_on_last_wipe() continue; for (const auto &toolchange : m_layer_info->tool_changes) - tool_change(toolchange.new_tool, false, PURPOSE_EXTRUDE); + tool_change(toolchange.new_tool, false); float width = m_wipe_tower_width - 3*m_perimeter_width; // width we draw into - float length_to_save = 2*(m_wipe_tower_width+m_wipe_tower_depth) + (!layer_finished() ? finish_layer(PURPOSE_EXTRUDE).total_extrusion_length_in_plane() : 0.f); + float length_to_save = 2*(m_wipe_tower_width+m_wipe_tower_depth) + (!layer_finished() ? finish_layer().total_extrusion_length_in_plane() : 0.f); float length_to_wipe = volume_to_length(m_par.wipe_volumes[m_layer_info->tool_changes.back().old_tool][m_layer_info->tool_changes.back().new_tool], m_line_width,m_layer_info->height) - m_layer_info->tool_changes.back().first_wipe_line - length_to_save; @@ -1359,19 +1170,17 @@ void WipeTowerPrusaMM::generate(std::vectordepth < m_wipe_tower_depth - m_perimeter_width) m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f; for (const auto &toolchange : layer.tool_changes) - layer_result.emplace_back(tool_change(toolchange.new_tool, false, WipeTower::PURPOSE_EXTRUDE)); + layer_result.emplace_back(tool_change(toolchange.new_tool, false)); if (! layer_finished()) { - layer_result.emplace_back(finish_layer(WipeTower::PURPOSE_EXTRUDE)); + layer_result.emplace_back(finish_layer()); if (layer_result.size() > 1) { // Merge the two last tool changes into one. WipeTower::ToolChangeResult &tc1 = layer_result[layer_result.size() - 2]; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 0906d334e7..3a1b332fd6 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -269,8 +269,6 @@ public: m_z_pos = print_z; m_layer_height = layer_height; m_is_first_layer = is_first_layer; - // Start counting the color changes from zero. Special case -1: extrude a brim first. - ///m_idx_tool_change_in_layer = is_first_layer ? (unsigned int)(-1) : 0; m_print_brim = is_first_layer; m_depth_traversed = 0.f; // to make room for perimeter line m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL; @@ -299,17 +297,15 @@ public: const std::vector &tools, // If true, the last priming are will be the same as the other priming areas, and the rest of the wipe will be performed inside the wipe tower. // If false, the last priming are will be large enough to wipe the last extruder sufficiently. - bool last_wipe_inside_wipe_tower, - // May be used by a stand alone post processor. - Purpose purpose = PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE); + bool last_wipe_inside_wipe_tower); // Returns gcode for a toolchange and a final print head position. // On the first layer, extrude a brim around the future wipe tower first. - virtual ToolChangeResult tool_change(unsigned int new_tool, bool last_in_layer, Purpose purpose); + virtual ToolChangeResult tool_change(unsigned int new_tool, bool last_in_layer); // Fill the unfilled space with a zig-zag. // Call this method only if layer_finished() is false. - virtual ToolChangeResult finish_layer(Purpose purpose); + virtual ToolChangeResult finish_layer(); // Is the current layer finished? virtual bool layer_finished() const { @@ -455,7 +451,7 @@ private: // Returns gcode for wipe tower brim // sideOnly -- set to false -- experimental, draw brim on sides of wipe tower // offset -- set to 0 -- experimental, offset to replace brim in front / rear of wipe tower - ToolChangeResult toolchange_Brim(Purpose purpose, bool sideOnly = false, float y_offset = 0.f); + ToolChangeResult toolchange_Brim(bool sideOnly = false, float y_offset = 0.f); void toolchange_Unload( PrusaMultiMaterial::Writer &writer, diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 447aec7509..5affad2973 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -1052,7 +1052,7 @@ void Print::_make_wipe_tower() bool last_priming_wipe_full = m_tool_ordering.front().extruders.size() > m_tool_ordering.front().wipe_tower_partitions; m_wipe_tower_priming = Slic3r::make_unique( - wipe_tower.prime(this->skirt_first_layer_height(), m_tool_ordering.all_extruders(), ! last_priming_wipe_full, WipeTower::PURPOSE_EXTRUDE)); + wipe_tower.prime(this->skirt_first_layer_height(), m_tool_ordering.all_extruders(), ! last_priming_wipe_full)); // Lets go through the wipe tower layers and determine pairs of extruder changes for each @@ -1146,7 +1146,7 @@ void Print::_make_wipe_tower() wipe_tower.set_layer(float(m_tool_ordering.back().print_z), float(layer_height), 0, false, true); } m_wipe_tower_final_purge = Slic3r::make_unique( - wipe_tower.tool_change((unsigned int)-1, false, WipeTower::PURPOSE_EXTRUDE)); + wipe_tower.tool_change((unsigned int)-1, false)); } std::string Print::output_filename() From 6e39f61198e237a85a43b08df6c3aaa6e7fa775e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 9 Mar 2018 12:40:39 +0100 Subject: [PATCH 0034/1150] Priming extrusions, nozzle-wipes when leaving tower, removed few unnecessary moves --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 71 +++++++++++++-------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 2 +- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 39ccc71555..671819286f 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -72,8 +72,11 @@ public: Writer& set_rotation(WipeTower::xy& pos, float width, float depth, float angle) { m_wipe_tower_pos = pos; m_wipe_tower_width = width; m_wipe_tower_depth=depth; m_angle_deg = angle; return (*this); } - Writer& set_y_shift(float shift) - { m_y_shift = shift; return (*this); } + Writer& set_y_shift(float shift) { + m_current_pos.y += shift-m_y_shift; + m_y_shift = shift; + return (*this); + } // Suppress / resume G-code preview in Slic3r. Slic3r will have difficulty to differentiate the various // filament loading and cooling moves from normal extrusion moves. Therefore the writer @@ -481,8 +484,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( // therefore the homing position is shifted inside the bed by 0.2 in the firmware to [0.2, -2.0]. // box_coordinates cleaning_box(xy(0.5f, - 1.5f), m_wipe_tower_width, wipe_area); //FIXME: set the width properly - const float prime_section_width = 60.f; - box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, 15.f); + const float prime_section_width = 55.f; + box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, 100.f); PrusaMultiMaterial::Writer writer; writer.set_extrusion_flow(m_extrusion_flow) @@ -510,11 +513,11 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( toolchange_Load(writer, cleaning_box); // Prime the tool. if (idx_tool + 1 == tools.size()) { // Last tool should not be unloaded, but it should be wiped enough to become of a pure color. - toolchange_Wipe(writer, cleaning_box, 20.f); + toolchange_Wipe(writer, cleaning_box, m_par.wipe_volumes[tools[idx_tool-1]][tool]); } else { // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. //writer.travel(writer.x(), writer.y() + m_perimeter_width, 7200); - toolchange_Wipe(writer, cleaning_box , 5.f); + toolchange_Wipe(writer, cleaning_box , 20.f); box_coordinates box = cleaning_box; box.translate(0.f, writer.y() - cleaning_box.ld.y + m_perimeter_width); toolchange_Unload(writer, box , m_filpar[m_current_tool].material, m_filpar[tools[idx_tool + 1]].first_layer_temperature); @@ -611,20 +614,28 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo m_is_first_layer ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature); toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials. toolchange_Load(writer, cleaning_box); - toolchange_Wipe(writer, cleaning_box, wipe_volume); // Wipe the newly loaded filament until the end of the assigned wipe area. + writer.travel(writer.x(),writer.y()-m_perimeter_width); // cooling and loading were done a bit down the road + toolchange_Wipe(writer, cleaning_box, wipe_volume); // Wipe the newly loaded filament until the end of the assigned wipe area. } else toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature); + ++ m_num_tool_changes; + m_depth_traversed += wipe_area; + if (last_change_in_layer) {// draw perimeter line writer.set_y_shift(m_y_shift); if (peters_wipe_tower) writer.rectangle(m_wipe_tower_pos,m_layer_info->depth + 3*m_perimeter_width,m_wipe_tower_depth); - else + else { + writer.wait(2.f); writer.rectangle(m_wipe_tower_pos,m_wipe_tower_width, m_layer_info->depth + m_perimeter_width); + if (layer_finished()) { // no finish_layer will be called, we must wipe the nozzle + writer.travel(m_wipe_tower_pos.x + (writer.x()>m_wipe_tower_pos.x + EPSILON ? 0.f : m_wipe_tower_width), writer.y()); + } + } } - // Reset the extruder current to a normal value. - writer.set_extruder_trimpot(550) + writer.set_extruder_trimpot(550) // Reset the extruder current to a normal value. .feedrate(6000) .flush_planner_queue() .reset_extruder() @@ -632,9 +643,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo ";------------------\n" "\n\n"); - ++ m_num_tool_changes; - m_depth_traversed += wipe_area; - ToolChangeResult result; result.print_z = this->m_z_pos; result.layer_height = this->m_layer_height; @@ -841,7 +849,8 @@ void WipeTowerPrusaMM::toolchange_Unload( // we should be at the beginning of the cooling tube again - let's move to parking position: writer.retract(-m_cooling_tube_length/2.f+m_parking_pos_retraction-m_cooling_tube_retraction, 2000); - // this is to align ramming and future loading extrusions, so the future y-steps can be uniform from the start: + // this is to align ramming and future wiping extrusions, so the future y-steps can be uniform from the start: + // the perimeter_width will later be subtracted, it is there to not load while moving over just extruded material writer.travel(end_of_ramming.x, end_of_ramming.y + (y_step/m_extra_spacing-m_line_width) / 2.f + m_perimeter_width, 2400.f); writer.resume_preview() @@ -877,7 +886,6 @@ void WipeTowerPrusaMM::toolchange_Load( float xl = cleaning_box.ld.x + m_perimeter_width * 0.75f; float xr = cleaning_box.rd.x - m_perimeter_width * 0.75f; float oldx = writer.x(); // the nozzle is in place to do the first wiping moves, we will remember the position - float oldy = writer.y(); // Load the filament while moving left / right, so the excess material will not create a blob at a single position. float loading_speed = m_filpar[m_current_tool].loading_speed; // mm/s in e axis @@ -886,12 +894,10 @@ void WipeTowerPrusaMM::toolchange_Load( float edist = m_parking_pos_retraction-50-2; // loading is 2mm shorter that previous retraction, 50mm reserved for acceleration/deceleration writer.append("; CP TOOLCHANGE LOAD\n") .suppress_preview() - .travel(writer.x(),writer.y() + m_perimeter_width) // So that we move in free space .load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Acceleration .load_move_x(oldx,edist,60*std::hypot(dist,edist)/edist * loading_speed) // Fast phase .load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Slowing down .load_move_x(oldx, 10, 60*std::hypot(dist,10.f)/10.f * loading_speed*0.1f) // Super slow - .travel(oldx,oldy) .resume_preview(); // Reset the extruder current to the normal value. @@ -929,7 +935,6 @@ void WipeTowerPrusaMM::toolchange_Wipe( m_left_to_right = !m_left_to_right; } - writer.travel(writer.x(),writer.y()-m_perimeter_width); // cooling & loading was done a fraction down the road // now the wiping itself: for (int i = 0; true; ++i) { @@ -959,6 +964,14 @@ void WipeTowerPrusaMM::toolchange_Wipe( writer.extrude(writer.x() + (i % 4 == 0 ? -1.f : (i % 4 == 1 ? 1.f : 0.f)) * 1.5*m_perimeter_width, writer.y() + dy); m_left_to_right = !m_left_to_right; } + + // this is neither priming nor not the last toolchange on this layer - we are going back to the model - wipe the nozzle + if (m_layer_info != m_plan.end() && m_current_tool != m_layer_info->tool_changes.back().new_tool) { + m_left_to_right = !m_left_to_right; + writer.travel(writer.x(), writer.y() - dy) + .travel(m_wipe_tower_pos.x + (m_left_to_right ? m_wipe_tower_width : 0.f), writer.y()); + } + writer.set_extrusion_flow(m_extrusion_flow); // Reset the extrusion flow. } @@ -989,8 +1002,10 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() box_coordinates fill_box(m_wipe_tower_pos + xy(m_perimeter_width, m_depth_traversed + m_perimeter_width), m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width); - // The print head is inside the wipe tower. Rather move to the start of the following extrusion. - writer.set_initial_position(fill_box.lu); + if (m_left_to_right) // so there is never a diagonal travel + writer.set_initial_position(fill_box.ru); + else + writer.set_initial_position(fill_box.lu); box_coordinates box = fill_box; for (int i=0;i<2;++i) { @@ -1000,14 +1015,12 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() } else i=2; // only draw the inner perimeter, outer has been already drawn by tool_change(...) writer.rectangle(box.ld,box.rd.x-box.ld.x,box.ru.y-box.rd.y); -/* - writer.travel(box.lu,7200) - .extrude(box.ru, 2400 * speed_factor) - .extrude(box.rd) - .extrude(box.ld) - .extrude(box.lu);*/ } + // we are in one of the corners, travel to ld along the perimeter: + if (writer.x() > fill_box.ld.x+EPSILON) writer.travel(fill_box.ld.x,writer.y()); + if (writer.y() > fill_box.ld.y+EPSILON) writer.travel(writer.x(),fill_box.ld.y); + if (m_is_first_layer && m_par.adhesion) { // Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower. box.expand(-m_perimeter_width/2.f); @@ -1025,14 +1038,14 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() } else { // Extrude a sparse infill to support the material to be printed above. const float dy = (fill_box.lu.y - fill_box.ld.y - m_perimeter_width); + const float left = fill_box.lu.x+2*m_perimeter_width; + const float right = fill_box.ru.x - 2 * m_perimeter_width; if (dy > m_perimeter_width) { // Extrude an inverse U at the left of the region. writer.travel(fill_box.ld + xy(m_perimeter_width * 2, 0.f)) .extrude(fill_box.lu + xy(m_perimeter_width * 2, 0.f), 2900 * speed_factor); - const float left = fill_box.lu.x+2*m_perimeter_width; - const float right = fill_box.ru.x - 2 * m_perimeter_width; const int n = 1+(right-left)/(m_par.bridging); const float dx = (right-left)/n; for (int i=1;i<=n;++i) { @@ -1042,6 +1055,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() } writer.travel(left,writer.y(),7200); // wipes the nozzle before moving away from the wipe tower } + else + writer.travel(right,writer.y(),7200); // wipes the nozzle before moving away from the wipe tower } writer.append("; CP EMPTY GRID END\n" ";------------------\n\n\n\n\n\n\n"); diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 3a1b332fd6..3182c8b8e3 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -471,7 +471,7 @@ private: void toolchange_Wipe( PrusaMultiMaterial::Writer &writer, const box_coordinates &cleaning_box, - float wipe_volume); + float wipe_volume); }; From d68804772aaa20e7b4e37c3a880896ed3782d238 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 9 Mar 2018 15:27:38 +0100 Subject: [PATCH 0035/1150] GCode Preview - Added handling of G10 and G11 commands --- xs/src/libslic3r/GCode/Analyzer.cpp | 22 ++++++++++++++++++++++ xs/src/libslic3r/GCode/Analyzer.hpp | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/xs/src/libslic3r/GCode/Analyzer.cpp b/xs/src/libslic3r/GCode/Analyzer.cpp index ee1e55bebc..15b99b2fbc 100644 --- a/xs/src/libslic3r/GCode/Analyzer.cpp +++ b/xs/src/libslic3r/GCode/Analyzer.cpp @@ -177,6 +177,16 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi _processG1(line); break; } + case 10: // Retract + { + _processG10(line); + break; + } + case 11: // Unretract + { + _processG11(line); + break; + } case 22: // Firmware controlled Retract { _processG22(line); @@ -305,6 +315,18 @@ void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line) _store_move(type); } +void GCodeAnalyzer::_processG10(const GCodeReader::GCodeLine& line) +{ + // stores retract move + _store_move(GCodeMove::Retract); +} + +void GCodeAnalyzer::_processG11(const GCodeReader::GCodeLine& line) +{ + // stores unretract move + _store_move(GCodeMove::Unretract); +} + void GCodeAnalyzer::_processG22(const GCodeReader::GCodeLine& line) { // stores retract move diff --git a/xs/src/libslic3r/GCode/Analyzer.hpp b/xs/src/libslic3r/GCode/Analyzer.hpp index 7939d432d4..e2f38292e1 100644 --- a/xs/src/libslic3r/GCode/Analyzer.hpp +++ b/xs/src/libslic3r/GCode/Analyzer.hpp @@ -127,6 +127,12 @@ private: // Move void _processG1(const GCodeReader::GCodeLine& line); + // Retract + void _processG10(const GCodeReader::GCodeLine& line); + + // Unretract + void _processG11(const GCodeReader::GCodeLine& line); + // Firmware controlled Retract void _processG22(const GCodeReader::GCodeLine& line); From f55becd43c164aac7528ce3732f599f24173c496 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 9 Mar 2018 16:37:33 +0100 Subject: [PATCH 0036/1150] Introduced the system profiles. The Config Wizard now just copies the Vendor's Config Bundle into user_dir/vendor/ directory and Slic3r uses the configs from the bundles found in user_dir/vendor directly. --- lib/Slic3r/GUI.pm | 3 +- lib/Slic3r/GUI/MainFrame.pm | 4 +- .../Original Prusa i3 MK2 and MK2S.ini | 3376 ---------------- ...inal Prusa i3 MK2, MK2S, MK2MM and MK3.ini | 995 ----- .../profiles/Original Prusa i3 MK2MM.ini | 3419 ----------------- resources/profiles/Original Prusa i3 MK3.ini | 3295 ---------------- xs/src/libslic3r/Config.cpp | 10 +- xs/src/libslic3r/Config.hpp | 15 +- xs/src/libslic3r/PrintConfig.cpp | 34 + xs/src/slic3r/GUI/Preset.cpp | 15 +- xs/src/slic3r/GUI/Preset.hpp | 49 +- xs/src/slic3r/GUI/PresetBundle.cpp | 183 +- xs/src/slic3r/GUI/PresetBundle.hpp | 29 +- xs/src/slic3r/GUI/Tab.cpp | 15 +- xs/xsp/GUI_Preset.xsp | 14 +- 15 files changed, 318 insertions(+), 11138 deletions(-) delete mode 100644 resources/profiles/Original Prusa i3 MK2 and MK2S.ini delete mode 100644 resources/profiles/Original Prusa i3 MK2, MK2S, MK2MM and MK3.ini delete mode 100644 resources/profiles/Original Prusa i3 MK2MM.ini delete mode 100644 resources/profiles/Original Prusa i3 MK3.ini diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 7a3b30a6b0..7097ab5212 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -110,12 +110,11 @@ sub OnInit { # Suppress the '- default -' presets. $self->{preset_bundle}->set_default_suppressed($self->{app_config}->get('no_defaults') ? 1 : 0); - eval { $self->{preset_bundle}->load_presets }; + eval { $self->{preset_bundle}->load_presets($self->{app_config}); }; if ($@) { warn $@ . "\n"; show_error(undef, $@); } - eval { $self->{preset_bundle}->load_selections($self->{app_config}) }; $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only; # application frame diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 442d0abc95..9e7bfacd80 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -722,7 +722,9 @@ sub config_wizard { wxTheApp->{preset_bundle}->load_config('My Settings', $result->{config}); } else { # Wizard returned a name of a preset bundle bundled with the installation. Unpack it. - wxTheApp->{preset_bundle}->load_configbundle($directory . '/' . $result->{preset_name} . '.ini'); + wxTheApp->{preset_bundle}->install_vendor_configbundle($directory . '/' . $result->{preset_name} . '.ini'); + # Reload all presets after the vendor config bundle has been installed. + wxTheApp->{preset_bundle}->load_presets(wxTheApp->{app_config}); } }; Slic3r::GUI::catch_error($self) and return; diff --git a/resources/profiles/Original Prusa i3 MK2 and MK2S.ini b/resources/profiles/Original Prusa i3 MK2 and MK2S.ini deleted file mode 100644 index a186c37759..0000000000 --- a/resources/profiles/Original Prusa i3 MK2 and MK2S.ini +++ /dev/null @@ -1,3376 +0,0 @@ -# generated by Slic3r Prusa Edition 1.39.0 on 2018-01-06 at 15:10:57 - -[print:0.05mm DETAIL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 25% -fill_pattern = cubic -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.5 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 30 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 80 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 30 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 15 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 30 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.3 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1.5 -support_material_speed = 30 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 180 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.05mm DETAIL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 and num_extruders==1 -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.28 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.3 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 20 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0 -perimeter_speed = 20 -perimeters = 4 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0 -solid_infill_speed = 20 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.18 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 20 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 200 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.05mm DETAIL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 25% -fill_pattern = grid -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 30 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 80 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 30 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 15 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 30 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.3 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1.5 -support_material_speed = 30 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 180 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 40 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 600 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.25 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.25 -fill_angle = 45 -fill_density = 15% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.25 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1600 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.25 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 40 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 600 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.25 -perimeter_speed = 25 -perimeters = 4 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.25 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.18 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.25 -top_solid_infill_speed = 30 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 3500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 200 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 250 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 200 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 5 -travel_speed = 250 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm 100mms Linear Advance] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 50 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 100 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 150 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 60 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 30 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 100 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 60 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 70 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 40 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 600 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.25 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.25 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.25 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1600 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.25 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 40 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 600 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.25 -perimeter_speed = 25 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.25 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.2 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 35 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.25 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 40 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 3500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 200 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 250 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 200 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 5 -travel_speed = 250 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL SOLUBLE FULL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 25 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 1 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL SOLUBLE INTERFACE] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 25 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm 100mms Linear Advance] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 50 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 100 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 150 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 60 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 30 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 100 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 60 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 70 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm FAST MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 3500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 200 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 250 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 200 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 5 -travel_speed = 250 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 40 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 40 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL SOLUBLE FULL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 1 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 30 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL SOLUBLE INTERFACE] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 30 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.7 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.43 -perimeter_speed = 50 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.7 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.43 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 50 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST sol full 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.55 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.57 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST sol int 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.55 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.57 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[filament:ColorFabb Brass Bronze] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.3 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 210 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 210 - -[filament:ColorFabb HT] -bed_temperature = 105 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 105 -first_layer_temperature = 270 -max_fan_speed = 20 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 270 - -[filament:ColorFabb PLA-PHA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:ColorFabb Woodfil] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 200 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 200 - -[filament:ColorFabb XT] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 270 - -[filament:ColorFabb XT-CF20] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 1 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 260 - -[filament:ColorFabb nGen] -bed_temperature = 85 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = NGEN -first_layer_bed_temperature = 85 -first_layer_temperature = 240 -max_fan_speed = 35 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:ColorFabb nGen flex] -bed_temperature = 85 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 5 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = FLEX -first_layer_bed_temperature = 85 -first_layer_temperature = 260 -max_fan_speed = 35 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 260 - -[filament:E3D Edge] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:E3D PC-ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 270 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 270 - -[filament:Fillamentum ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 240 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 240 - -[filament:Fillamentum ASA] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 265 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 265 - -[filament:Fillamentum CPE HG100 HM100] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "CPE HG100 , CPE HM100" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -max_fan_speed = 80 -min_fan_speed = 80 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 260 - -[filament:Fillamentum Timberfil] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 190 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 190 - -[filament:Generic ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 255 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 255 - -[filament:Generic PET] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:Generic PLA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:Polymaker PC-Max] -bed_temperature = 120 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 120 -first_layer_temperature = 270 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 270 - -[filament:Primavalue PVA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 1 -filament_type = PVA -first_layer_bed_temperature = 60 -first_layer_temperature = 195 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 195 - -[filament:Prusa ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 255 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 255 - -[filament:Prusa HIPS] -bed_temperature = 100 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 0.9 -fan_always_on = 1 -fan_below_layer_time = 10 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 1 -filament_type = HIPS -first_layer_bed_temperature = 100 -first_layer_temperature = 220 -max_fan_speed = 20 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 220 - -[filament:Prusa PET] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:Prusa PLA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:SemiFlex or Flexfill 98A] -bed_temperature = 50 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1 -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #00CA0A -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 2.5 -filament_notes = "List of materials tested with FLEX print settings & FLEX material settings for MK2:\n\nFillamentum Flex 98A\nFillamentum Flex 92A\nPlasty MladeÄ PP\nPlasty MladeÄ TPE32 \nPlasty MladeÄ TPE88" -filament_settings_id = -filament_soluble = 0 -filament_type = FLEX -first_layer_bed_temperature = 50 -first_layer_temperature = 220 -max_fan_speed = 90 -min_fan_speed = 70 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 230 - -[filament:Taulman Bridge] -bed_temperature = 50 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #DEE0E6 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 90 -first_layer_temperature = 240 -max_fan_speed = 5 -min_fan_speed = 0 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 250 - -[filament:Taulman T-Glase] -bed_temperature = 90 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 240 -max_fan_speed = 5 -min_fan_speed = 0 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 240 - -[filament:Verbatim BVOH] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 1 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 210 - -[filament:Verbatim PP] -bed_temperature = 100 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 2 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #DEE0E6 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 5 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 220 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 220 - -[printer:Original Prusa i3 MK2] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 0 -end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -extruder_colour = #FFFF00 -extruder_offset = 0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.25 -min_layer_height = 0.07 -nozzle_diameter = 0.4 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n -printer_settings_id = -retract_before_travel = 1 -retract_before_wipe = 0% -retract_layer_change = 1 -retract_length = 0.8 -retract_length_toolchange = 3 -retract_lift = 0.6 -retract_lift_above = 0 -retract_lift_below = 199 -retract_restart_extra = 0 -retract_restart_extra_toolchange = 0 -retract_speed = 35 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 0 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0 -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 1 -wipe = 1 -z_offset = 0 - -[printer:Original Prusa i3 MK2 0.25 nozzle] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 0 -end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -extruder_colour = #FFFF00 -extruder_offset = 0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.1 -min_layer_height = 0.05 -nozzle_diameter = 0.25 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n -printer_settings_id = -retract_before_travel = 1 -retract_before_wipe = 0% -retract_layer_change = 1 -retract_length = 1 -retract_length_toolchange = 3 -retract_lift = 0.6 -retract_lift_above = 0 -retract_lift_below = 199 -retract_restart_extra = 0 -retract_restart_extra_toolchange = 0 -retract_speed = 50 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 0 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0 -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 0 -wipe = 1 -z_offset = 0 - -[printer:Original Prusa i3 MK2 0.6 nozzle] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 0 -end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -extruder_colour = #FFFF00 -extruder_offset = 0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.35 -min_layer_height = 0.1 -nozzle_diameter = 0.6 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n -printer_settings_id = -retract_before_travel = 1 -retract_before_wipe = 0% -retract_layer_change = 1 -retract_length = 0.8 -retract_length_toolchange = 3 -retract_lift = 0.6 -retract_lift_above = 0 -retract_lift_below = 199 -retract_restart_extra = 0 -retract_restart_extra_toolchange = 0 -retract_speed = 35 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 0 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0 -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 1 -wipe = 1 -z_offset = 0 - -[presets] -print = 0.15mm OPTIMAL -printer = Original Prusa i3 MK2 -filament = Prusa PLA diff --git a/resources/profiles/Original Prusa i3 MK2, MK2S, MK2MM and MK3.ini b/resources/profiles/Original Prusa i3 MK2, MK2S, MK2MM and MK3.ini deleted file mode 100644 index 0b4dddb55d..0000000000 --- a/resources/profiles/Original Prusa i3 MK2, MK2S, MK2MM and MK3.ini +++ /dev/null @@ -1,995 +0,0 @@ -# generated by Slic3r Prusa Edition 1.39.0.29-prusa3d-win64 on 2018-01-22 at 14:53:14 - -# All presets starting with asterisk, for example *common*, are intermediate and they will -# not make it into the user interface. - -# Common print preset, mostly derived from MK2 single material with a 0.4mm nozzle. -# All other print presets will derive from the *common* print preset. -[print:*common*] -avoid_crossing_perimeters = 0 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeters_first = 0 -external_perimeter_extrusion_width = 0.45 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -interface_shells = 0 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -overhangs = 0 -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirts = 1 -skirt_distance = 2 -skirt_height = 3 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_extruder = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_enforce_layers = 0 -support_material_interface_contact_loops = 0 -support_material_interface_layers = 2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 40 -travel_speed = 180 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -# Print parameters common to a 0.25mm diameter nozzle. -[print:*0.25nozzle*] -external_perimeter_extrusion_width = 0.25 -extrusion_width = 0.25 -first_layer_extrusion_width = 0.25 -infill_extrusion_width = 0.25 -perimeter_extrusion_width = 0.25 -solid_infill_extrusion_width = 0.25 -top_infill_extrusion_width = 0.25 -support_material_extrusion_width = 0.18 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_spacing = 1 -support_material_xy_spacing = 150% - -# Print parameters common to a 0.6mm diameter nozzle. -[print:*0.6nozzle*] -external_perimeter_extrusion_width = 0.61 -extrusion_width = 0.67 -first_layer_extrusion_width = 0.65 -infill_extrusion_width = 0.75 -perimeter_extrusion_width = 0.65 -solid_infill_extrusion_width = 0.65 -top_infill_extrusion_width = 0.6 - -[print:*0.05mm*] -inherits = *common* -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_flow_ratio = 0.7 -default_acceleration = 500 -external_perimeter_speed = 20 -fill_density = 25% -first_layer_acceleration = 500 -gap_fill_speed = 20 -infill_acceleration = 800 -infill_speed = 30 -max_print_speed = 80 -small_perimeter_speed = 15 -solid_infill_speed = 30 -support_material_extrusion_width = 0.3 -support_material_interface_spacing = 0.2 -support_material_spacing = 1.5 -layer_height = 0.05 -perimeter_acceleration = 300 -perimeter_speed = 30 -perimeters = 3 -support_material_contact_distance = 0.15 -support_material_speed = 30 -top_solid_infill_speed = 20 -top_solid_layers = 15 - -[print:0.05mm DETAIL] -inherits = *0.05mm* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -infill_extrusion_width = 0.5 - -[print:0.05mm DETAIL MK3] -inherits = *0.05mm* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -fill_pattern = grid -top_infill_extrusion_width = 0.4 - -[print:0.05mm DETAIL 0.25 nozzle] -inherits = *0.05mm*; *0.25nozzle* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 and num_extruders==1 -external_perimeter_extrusion_width = 0 -extrusion_width = 0.28 -fill_density = 20% -first_layer_extrusion_width = 0.3 -infill_extrusion_width = 0 -infill_speed = 20 -max_print_speed = 100 -perimeter_extrusion_width = 0 -perimeter_speed = 20 -perimeters = 4 -small_perimeter_speed = 10 -solid_infill_extrusion_width = 0 -solid_infill_speed = 20 -support_material_speed = 20 -top_infill_extrusion_width = 0 - -[print:*0.10mm*] -inherits = *common* -bottom_solid_layers = 7 -bridge_flow_ratio = 0.7 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -layer_height = 0.1 -perimeter_acceleration = 800 -support_material_contact_distance = 0.15 -support_material_interface_spacing = 0.2 -support_material_spacing = 2 -top_solid_layers = 9 - -[print:0.10mm DETAIL] -inherits = *0.10mm* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -external_perimeter_speed = 40 -infill_acceleration = 2000 -infill_speed = 60 -perimeter_speed = 50 -perimeters = 3 -solid_infill_speed = 50 - -[print:0.10mm DETAIL MK3] -inherits = *0.10mm* -bridge_flow_ratio = 0.8 -bridge_speed = 30 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -external_perimeter_speed = 35 -fill_pattern = grid -infill_acceleration = 1500 -infill_speed = 170 -max_print_speed = 170 -perimeter_speed = 45 -perimeters = 2 -solid_infill_speed = 170 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 - -[print:0.10mm DETAIL 0.25 nozzle] -inherits = *0.10mm*; *0.25nozzle* -bridge_acceleration = 600 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 -external_perimeter_speed = 20 -fill_density = 15% -infill_acceleration = 1600 -infill_speed = 40 -perimeter_acceleration = 600 -perimeter_speed = 25 -perimeters = 4 -small_perimeter_speed = 10 -solid_infill_speed = 40 -top_solid_infill_speed = 30 - -[print:*0.15mm*] -inherits = *common* -bottom_solid_layers = 5 -external_perimeter_speed = 40 -infill_acceleration = 2000 -infill_speed = 60 -layer_height = 0.15 -perimeter_acceleration = 800 -perimeter_speed = 50 -perimeters = 3 -solid_infill_speed = 50 -support_material_contact_distance = 0.15 -support_material_interface_spacing = 0.2 -support_material_spacing = 2 -top_infill_extrusion_width = 0.4 -top_solid_layers = 7 - -[print:0.15mm 100mms Linear Advance] -inherits = *0.15mm* -bottom_solid_layers = 4 -bridge_flow_ratio = 0.95 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -external_perimeter_speed = 50 -infill_speed = 100 -max_print_speed = 150 -perimeter_speed = 60 -perimeters = 2 -small_perimeter_speed = 30 -solid_infill_speed = 100 -support_material_speed = 60 -top_solid_infill_speed = 70 -top_solid_layers = 5 - -[print:0.15mm OPTIMAL] -inherits = *0.15mm* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -top_infill_extrusion_width = 0.45 - -[print:0.15mm OPTIMAL 0.25 nozzle] -inherits = *0.15mm*; *0.25nozzle* -bridge_acceleration = 600 -bridge_flow_ratio = 0.7 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 -external_perimeter_speed = 20 -infill_acceleration = 1600 -infill_speed = 40 -perimeter_acceleration = 600 -perimeter_speed = 25 -perimeters = 2 -small_perimeter_speed = 10 -solid_infill_speed = 40 -support_material_extrusion_width = 0.2 -support_material_threshold = 35 -top_solid_infill_speed = 30 - -[print:0.15mm OPTIMAL 0.6 nozzle] -inherits = *0.15mm*; *0.6nozzle* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -wipe_tower = 1 - -[print:0.15mm OPTIMAL MK3] -inherits = *0.15mm* -bridge_speed = 30 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -external_perimeter_speed = 35 -fill_pattern = grid -infill_acceleration = 1500 -infill_speed = 170 -max_print_speed = 170 -perimeter_speed = 45 -perimeters = 2 -solid_infill_speed = 170 -top_solid_infill_speed = 50 -wipe_tower = 1 - -[print:0.15mm OPTIMAL SOLUBLE FULL] -inherits = *0.15mm* -bottom_solid_layers = 5 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -external_perimeter_speed = 25 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder -overhangs = 1 -perimeter_speed = 40 -skirts = 0 -solid_infill_speed = 40 -support_material = 1 -support_material_contact_distance = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.45 -support_material_interface_extruder = 4 -support_material_interface_spacing = 0.1 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 1 -support_material_xy_spacing = 60% -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 30 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 - -[print:0.15mm OPTIMAL SOLUBLE INTERFACE] -inherits = 0.15mm OPTIMAL SOLUBLE FULL -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -support_material_extruder = 0 -support_material_interface_layers = 3 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% - -[print:*0.20mm*] -inherits = *common* -bottom_solid_layers = 4 -bridge_flow_ratio = 0.95 -external_perimeter_speed = 40 -infill_acceleration = 2000 -infill_speed = 60 -layer_height = 0.2 -perimeter_acceleration = 800 -perimeter_speed = 50 -perimeters = 2 -solid_infill_speed = 50 -support_material_contact_distance = 0.15 -support_material_interface_spacing = 0.2 -support_material_spacing = 2 -top_infill_extrusion_width = 0.4 -top_solid_layers = 5 -wipe_tower = 1 - -[print:0.20mm 100mms Linear Advance] -inherits = *0.20mm* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -external_perimeter_speed = 50 -infill_speed = 100 -max_print_speed = 150 -perimeter_speed = 60 -small_perimeter_speed = 30 -solid_infill_speed = 100 -support_material_speed = 60 -top_solid_infill_speed = 70 - -[print:0.20mm FAST MK3] -inherits = *0.20mm* -bridge_speed = 30 -bridge_flow_ratio = 0.8 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -external_perimeter_speed = 35 -fill_pattern = grid -infill_acceleration = 1500 -infill_speed = 170 -max_print_speed = 170 -perimeter_speed = 45 -solid_infill_speed = 170 -top_solid_infill_speed = 50 - -[print:0.20mm NORMAL] -inherits = *0.20mm* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 - -[print:0.20mm NORMAL 0.6 nozzle] -inherits = *0.20mm*; *0.6nozzle* -bridge_flow_ratio = 0.8 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -perimeters = 3 - -[print:0.20mm NORMAL SOLUBLE FULL] -inherits = *0.20mm* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -external_perimeter_speed = 30 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder -overhangs = 1 -perimeter_speed = 40 -skirts = 0 -solid_infill_speed = 40 -support_material = 1 -support_material_contact_distance = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.45 -support_material_interface_extruder = 4 -support_material_interface_spacing = 0.1 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 1 -support_material_xy_spacing = 120% -top_solid_infill_speed = 30 -wipe_tower_per_color_wipe = 20 - -[print:0.20mm NORMAL SOLUBLE INTERFACE] -inherits = 0.20mm NORMAL SOLUBLE FULL -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -support_material_extruder = 0 -support_material_interface_layers = 3 -support_material_with_sheath = 0 - -[print:*0.35mm*] -inherits = *common* -bottom_solid_layers = 3 -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 40 -first_layer_extrusion_width = 0.75 -infill_acceleration = 2000 -infill_extrusion_width = 0.75 -infill_speed = 60 -layer_height = 0.35 -perimeter_acceleration = 800 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 2 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -support_material_contact_distance = 0.15 -support_material_interface_spacing = 0.2 -support_material_spacing = 2 -top_solid_infill_speed = 50 -top_solid_layers = 4 -wipe_tower = 1 - -[print:0.35mm FAST] -inherits = *0.35mm* -bridge_flow_ratio = 0.95 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -first_layer_extrusion_width = 0.42 -infill_extrusion_width = 0.7 -perimeter_extrusion_width = 0.43 -solid_infill_extrusion_width = 0.7 -top_infill_extrusion_width = 0.43 - -[print:0.35mm FAST 0.6 nozzle] -inherits = *0.35mm*; *0.6nozzle* -bottom_solid_layers = 7 -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -perimeters = 3 -top_solid_layers = 9 - -[print:0.35mm FAST sol full 0.6 nozzle] -inherits = *0.35mm*; *0.6nozzle* -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1 -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 30 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -overhangs = 1 -perimeter_speed = 40 -skirts = 0 -support_material = 1 -support_material_contact_distance = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.55 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_xy_spacing = 120% -top_infill_extrusion_width = 0.57 -wipe_tower_per_color_wipe = 20 - -[print:0.35mm FAST sol int 0.6 nozzle] -inherits = 0.35mm FAST sol full 0.6 nozzle -support_material_extruder = 0 -support_material_interface_layers = 2 -support_material_xy_spacing = 150% - -[filament:*common*] -cooling = 1 -compatible_printers = -compatible_printers_condition = -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_settings_id = -filament_soluble = 0 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" - -[filament:*PLA*] -inherits = *common* -bed_temperature = 60 -bridge_fan_speed = 100 -disable_fan_first_layers = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_max_volumetric_speed = 15 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -temperature = 210 - -[filament:*PET*] -inherits = *common* -bed_temperature = 90 -bridge_fan_speed = 50 -disable_fan_first_layers = 3 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_max_volumetric_speed = 10 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:*ABS*] -inherits = *common* -bed_temperature = 100 -bridge_fan_speed = 30 -cooling = 0 -disable_fan_first_layers = 3 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_max_volumetric_speed = 13 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 255 -max_fan_speed = 30 -min_fan_speed = 10 -temperature = 255 - -[filament:*FLEX*] -inherits = *common* -bridge_fan_speed = 100 -compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1 -cooling = 0 -disable_fan_first_layers = 1 -extrusion_multiplier = 1.2 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_max_volumetric_speed = 1.5 -filament_type = FLEX -first_layer_bed_temperature = 50 -first_layer_temperature = 240 -max_fan_speed = 90 -min_fan_speed = 70 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 240 - -[filament:ColorFabb Brass Bronze] -inherits = *PLA* -compatible_printers_condition = nozzle_diameter[0]>0.35 -extrusion_multiplier = 1.3 -filament_colour = #804040 -filament_max_volumetric_speed = 10 -min_print_speed = 5 - -[filament:ColorFabb HT] -bed_temperature = 105 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 105 -first_layer_temperature = 270 -max_fan_speed = 20 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 270 - -[filament:ColorFabb PLA-PHA] -inherits = *PLA* -filament_colour = #FF3232 - -[filament:ColorFabb Woodfil] -inherits = *PLA* -compatible_printers_condition = nozzle_diameter[0]>0.35 -extrusion_multiplier = 1.2 -filament_colour = #804040 -filament_max_volumetric_speed = 10 -first_layer_temperature = 200 -min_print_speed = 5 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 200 - -[filament:ColorFabb XT] -inherits = *PET* -filament_colour = #FF8000 -filament_type = PLA -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -temperature = 270 - -[filament:ColorFabb XT-CF20] -inherits = *PET* -extrusion_multiplier = 1.2 -filament_colour = #804040 -filament_max_volumetric_speed = 1 -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 260 - -[filament:ColorFabb nGen] -inherits = *PET* -bridge_fan_speed = 40 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_type = NGEN -first_layer_temperature = 240 -max_fan_speed = 35 -min_fan_speed = 20 - -[filament:ColorFabb nGen flex] -inherits = *flex* -bed_temperature = 85 -bridge_fan_speed = 40 -cooling = 1 -disable_fan_first_layers = 3 -extrusion_multiplier = 1 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_max_volumetric_speed = 5 -first_layer_bed_temperature = 85 -first_layer_temperature = 260 -max_fan_speed = 35 -min_fan_speed = 20 -temperature = 260 - -[filament:E3D Edge] -inherits = *PET* -filament_colour = #FF8000 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" - -[filament:E3D PC-ABS] -inherits = *ABS* -filament_colour = #3A80CA -first_layer_temperature = 270 -temperature = 270 - -[filament:Fillamentum ABS] -inherits = *ABS* -filament_colour = #3A80CA -first_layer_temperature = 240 -temperature = 240 - -[filament:Fillamentum ASA] -fan_always_on = 1 -filament_colour = #3A80CA -first_layer_temperature = 265 -temperature = 265 - -[filament:Fillamentum CPE HG100 HM100] -inherits = *PET* -disable_fan_first_layers = 1 -filament_colour = #FF8000 -filament_notes = "CPE HG100 , CPE HM100" -first_layer_bed_temperature = 90 -first_layer_temperature = 275 -max_fan_speed = 50 -min_fan_speed = 50 -temperature = 275 - -[filament:Fillamentum Timberfil] -inherits = *PLA* -compatible_printers_condition = nozzle_diameter[0]>0.35 -extrusion_multiplier = 1.2 -filament_colour = #804040 -filament_max_volumetric_speed = 10 -first_layer_temperature = 190 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 190 - -[filament:Generic ABS] -inherits = *ABS* -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" - -[filament:Generic PET] -inherits = *PET* -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" - -[filament:Generic PLA] -inherits = *PLA* -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" - -[filament:Polymaker PC-Max] -inherits = *ABS* -bed_temperature = 120 -filament_colour = #3A80CA -first_layer_bed_temperature = 120 -first_layer_temperature = 270 -temperature = 270 - -[filament:Primavalue PVA] -inherits = *PLA* -cooling = 0 -fan_always_on = 0 -filament_colour = #FFFFD7 -filament_max_volumetric_speed = 10 -filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH" -filament_soluble = 1 -filament_type = PVA -first_layer_temperature = 195 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 195 - -[filament:Prusa ABS] -inherits = *ABS* -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" - -[filament:Prusa HIPS] -inherits = *ABS* -bridge_fan_speed = 50 -cooling = 1 -extrusion_multiplier = 0.9 -fan_always_on = 1 -fan_below_layer_time = 10 -filament_colour = #FFFFD7 -filament_soluble = 1 -filament_type = HIPS -first_layer_temperature = 220 -max_fan_speed = 20 -min_fan_speed = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 220 - -[filament:Prusa PET] -inherits = *PET* -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" - -[filament:Prusa PLA] -inherits = *PLA* -filament_colour = #FF3232 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" - -[filament:SemiFlex or Flexfill 98A] -inherits = *flex* - -[filament:Taulman Bridge] -bed_temperature = 50 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #DEE0E6 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 90 -first_layer_temperature = 240 -max_fan_speed = 5 -min_fan_speed = 0 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 250 - -[filament:Taulman T-Glase] -inherits = *PET* -bridge_fan_speed = 40 -cooling = 0 -fan_always_on = 0 -filament_colour = #FF8000 -first_layer_bed_temperature = 90 -first_layer_temperature = 240 -max_fan_speed = 5 -min_fan_speed = 0 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" - -[filament:Verbatim BVOH] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 1 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 210 - -[filament:Verbatim PP] -bed_temperature = 100 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 2 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #DEE0E6 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 5 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 220 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 220 - -[printer:*common*] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 0 -end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -extruder_colour = #FFFF00 -extruder_offset = 0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.25 -min_layer_height = 0.07 -nozzle_diameter = 0.4 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n -printer_settings_id = -retract_before_travel = 1 -retract_before_wipe = 0% -retract_layer_change = 1 -retract_length = 0.8 -retract_length_toolchange = 3 -retract_lift = 0.6 -retract_lift_above = 0 -retract_lift_below = 199 -retract_restart_extra = 0 -retract_restart_extra_toolchange = 0 -retract_speed = 35 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 0 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0 -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 1 -wipe = 1 -z_offset = 0 - -[printer:*multimaterial*] -inherits = *common* -deretract_speed = 50 -retract_before_travel = 3 -retract_before_wipe = 60% -retract_layer_change = 0 -retract_length = 4 -retract_length_toolchange = 4 -retract_lift = 0.6 -retract_lift_above = 0 -retract_lift_below = 199 -retract_restart_extra = 0 -retract_restart_extra_toolchange = 0 -retract_speed = 80 -single_extruder_multi_material = 1 - -[printer:*mm-single*] -inherits = *multimaterial* -end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 - -[printer:*mm-multi*] -inherits = *multimaterial* -end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors -extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259 -nozzle_diameter = 0.4,0.4,0.4,0.4 -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 -variable_layer_height = 0 - -[printer:Original Prusa i3 MK2] -inherits = *common* - -[printer:Original Prusa i3 MK2 0.25 nozzle] -inherits = *common* -max_layer_height = 0.1 -min_layer_height = 0.05 -nozzle_diameter = 0.25 -retract_length = 1 -retract_speed = 50 -variable_layer_height = 0 - -[printer:Original Prusa i3 MK2 0.6 nozzle] -inherits = *common* -max_layer_height = 0.35 -min_layer_height = 0.1 -nozzle_diameter = 0.6 - -[printer:Original Prusa i3 MK2 MM Single Mode] -inherits = *mm-single* - -[printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle] -inherits = *mm-single* -nozzle_diameter = 0.6 - -[printer:Original Prusa i3 MK2 MultiMaterial] -inherits = *mm-multi* -nozzle_diameter = 0.4,0.4,0.4,0.4 - -[printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle] -inherits = *mm-multi* -nozzle_diameter = 0.6,0.6,0.6,0.6 - -[printer:Original Prusa i3 MK3] -inherits = *common* -end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n -retract_lift_below = 209 -start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} - -[presets] -print = 0.15mm OPTIMAL MK3 -printer = Original Prusa i3 MK3 -filament = Prusa PLA diff --git a/resources/profiles/Original Prusa i3 MK2MM.ini b/resources/profiles/Original Prusa i3 MK2MM.ini deleted file mode 100644 index 035d15515e..0000000000 --- a/resources/profiles/Original Prusa i3 MK2MM.ini +++ /dev/null @@ -1,3419 +0,0 @@ -# generated by Slic3r Prusa Edition 1.39.0 on 2018-01-06 at 15:12:06 - -[print:0.05mm DETAIL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 25% -fill_pattern = cubic -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.5 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 30 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 80 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 30 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 15 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 30 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.3 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1.5 -support_material_speed = 30 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 180 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.05mm DETAIL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 and num_extruders==1 -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.28 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.3 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 20 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0 -perimeter_speed = 20 -perimeters = 4 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0 -solid_infill_speed = 20 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.18 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 20 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 200 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.05mm DETAIL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 25% -fill_pattern = grid -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 30 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 80 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 30 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 15 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 30 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.3 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1.5 -support_material_speed = 30 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 180 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 40 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 600 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.25 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.25 -fill_angle = 45 -fill_density = 15% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.25 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1600 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.25 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 40 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 600 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.25 -perimeter_speed = 25 -perimeters = 4 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.25 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.18 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.25 -top_solid_infill_speed = 30 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 3500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 200 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 250 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 200 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 5 -travel_speed = 250 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm 100mms Linear Advance] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 50 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 100 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 150 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 60 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 30 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 100 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 60 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 70 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 40 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 600 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.25 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.25 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.25 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1600 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.25 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 40 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 600 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.25 -perimeter_speed = 25 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.25 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.2 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 35 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.25 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 40 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 3500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 200 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 250 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 200 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 5 -travel_speed = 250 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL SOLUBLE FULL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 25 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 1 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL SOLUBLE INTERFACE] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 25 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm 100mms Linear Advance] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 50 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 100 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 150 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 60 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 30 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 100 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 60 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 70 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm FAST MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 3500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 200 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 250 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 200 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 5 -travel_speed = 250 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 40 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 40 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL SOLUBLE FULL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 1 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 30 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL SOLUBLE INTERFACE] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 30 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.7 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.43 -perimeter_speed = 50 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.7 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.43 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 50 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST sol full 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.55 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.57 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST sol int 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.55 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.57 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[filament:ColorFabb Brass Bronze] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.3 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 210 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 210 - -[filament:ColorFabb HT] -bed_temperature = 105 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 105 -first_layer_temperature = 270 -max_fan_speed = 20 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 270 - -[filament:ColorFabb PLA-PHA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:ColorFabb Woodfil] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 200 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 200 - -[filament:ColorFabb XT] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 270 - -[filament:ColorFabb XT-CF20] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 1 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 260 - -[filament:ColorFabb nGen] -bed_temperature = 85 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = NGEN -first_layer_bed_temperature = 85 -first_layer_temperature = 240 -max_fan_speed = 35 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:ColorFabb nGen flex] -bed_temperature = 85 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 5 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = FLEX -first_layer_bed_temperature = 85 -first_layer_temperature = 260 -max_fan_speed = 35 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 260 - -[filament:E3D Edge] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:E3D PC-ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 270 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 270 - -[filament:Fillamentum ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 240 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 240 - -[filament:Fillamentum ASA] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 265 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 265 - -[filament:Fillamentum CPE HG100 HM100] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "CPE HG100 , CPE HM100" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -max_fan_speed = 80 -min_fan_speed = 80 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 260 - -[filament:Fillamentum Timberfil] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 190 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 190 - -[filament:Generic ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 255 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 255 - -[filament:Generic PET] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:Generic PLA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:Polymaker PC-Max] -bed_temperature = 120 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 120 -first_layer_temperature = 270 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 270 - -[filament:Primavalue PVA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 1 -filament_type = PVA -first_layer_bed_temperature = 60 -first_layer_temperature = 195 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 195 - -[filament:Prusa ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 255 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 255 - -[filament:Prusa HIPS] -bed_temperature = 100 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 0.9 -fan_always_on = 1 -fan_below_layer_time = 10 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 1 -filament_type = HIPS -first_layer_bed_temperature = 100 -first_layer_temperature = 220 -max_fan_speed = 20 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 220 - -[filament:Prusa PET] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:Prusa PLA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:SemiFlex or Flexfill 98A] -bed_temperature = 50 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1 -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #00CA0A -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 2.5 -filament_notes = "List of materials tested with FLEX print settings & FLEX material settings for MK2:\n\nFillamentum Flex 98A\nFillamentum Flex 92A\nPlasty MladeÄ PP\nPlasty MladeÄ TPE32 \nPlasty MladeÄ TPE88" -filament_settings_id = -filament_soluble = 0 -filament_type = FLEX -first_layer_bed_temperature = 50 -first_layer_temperature = 220 -max_fan_speed = 90 -min_fan_speed = 70 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 230 - -[filament:Taulman Bridge] -bed_temperature = 50 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #DEE0E6 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 90 -first_layer_temperature = 240 -max_fan_speed = 5 -min_fan_speed = 0 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 250 - -[filament:Taulman T-Glase] -bed_temperature = 90 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 240 -max_fan_speed = 5 -min_fan_speed = 0 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 240 - -[filament:Verbatim BVOH] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 1 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 210 - -[filament:Verbatim PP] -bed_temperature = 100 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 2 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #DEE0E6 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 5 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 220 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 220 - -[printer:Original Prusa i3 MK2 MM Single Mode] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 50 -end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n -extruder_colour = #FFAA55 -extruder_offset = 0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.25 -min_layer_height = 0.07 -nozzle_diameter = 0.4 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN -printer_settings_id = -retract_before_travel = 3 -retract_before_wipe = 60% -retract_layer_change = 0 -retract_length = 4 -retract_length_toolchange = 6 -retract_lift = 0.6 -retract_lift_above = 0 -retract_lift_below = 199 -retract_restart_extra = 0 -retract_restart_extra_toolchange = 0 -retract_speed = 80 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 1 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 1 -wipe = 1 -z_offset = 0 - -[printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 50 -end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n -extruder_colour = #FFAA55 -extruder_offset = 0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.25 -min_layer_height = 0.07 -nozzle_diameter = 0.6 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN -printer_settings_id = -retract_before_travel = 3 -retract_before_wipe = 60% -retract_layer_change = 0 -retract_length = 4 -retract_length_toolchange = 6 -retract_lift = 0.6 -retract_lift_above = 0 -retract_lift_below = 199 -retract_restart_extra = 0 -retract_restart_extra_toolchange = 0 -retract_speed = 80 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 1 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 1 -wipe = 1 -z_offset = 0 - -[printer:Original Prusa i3 MK2 MultiMaterial] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 50,50,50,50 -end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors -extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259 -extruder_offset = 0x0,0x0,0x0,0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.25,0.25,0.25,0.25 -min_layer_height = 0.07,0.07,0.07,0.07 -nozzle_diameter = 0.4,0.4,0.4,0.4 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN -printer_settings_id = -retract_before_travel = 3,3,3,3 -retract_before_wipe = 60%,60%,60%,60% -retract_layer_change = 0,0,0,0 -retract_length = 4,4,4,4 -retract_length_toolchange = 4,4,4,4 -retract_lift = 0.6,0.6,0.6,0.6 -retract_lift_above = 0,0,0,0 -retract_lift_below = 199,199,199,199 -retract_restart_extra = 0,0,0,0 -retract_restart_extra_toolchange = 0,0,0,0 -retract_speed = 80,80,80,80 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 1 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 0 -wipe = 1,1,1,1 -z_offset = 0 - -[printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 50,50,50,50 -end_gcode = {if not has_wipe_tower}\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n -extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259 -extruder_offset = 0x0,0x0,0x0,0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.25,0.25,0.25,0.25 -min_layer_height = 0.07,0.07,0.07,0.07 -nozzle_diameter = 0.6,0.6,0.6,0.6 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN -printer_settings_id = -retract_before_travel = 3,3,3,3 -retract_before_wipe = 60%,60%,60%,60% -retract_layer_change = 0,0,0,0 -retract_length = 4,4,4,4 -retract_length_toolchange = 4,4,4,4 -retract_lift = 0.6,0.6,0.6,0.6 -retract_lift_above = 0,0,0,0 -retract_lift_below = 199,199,199,199 -retract_restart_extra = 0,0,0,0 -retract_restart_extra_toolchange = 0,0,0,0 -retract_speed = 80,80,80,80 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 1 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 0 -wipe = 1,1,1,1 -z_offset = 0 - -[presets] -print = 0.15mm OPTIMAL -printer = Original Prusa i3 MK2 MultiMaterial -filament = Prusa PLA -filament_1 = Prusa PLA -filament_2 = Prusa PLA -filament_3 = Prusa PLA diff --git a/resources/profiles/Original Prusa i3 MK3.ini b/resources/profiles/Original Prusa i3 MK3.ini deleted file mode 100644 index b53006b0fb..0000000000 --- a/resources/profiles/Original Prusa i3 MK3.ini +++ /dev/null @@ -1,3295 +0,0 @@ -# generated by Slic3r Prusa Edition 1.39.0 on 2018-02-02 at 10:48:46 - -[print:0.05mm DETAIL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 25% -fill_pattern = cubic -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.5 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 30 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 80 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 30 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 15 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 30 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.3 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1.5 -support_material_speed = 30 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 180 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.05mm DETAIL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 and num_extruders==1 -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.28 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.3 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 20 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0 -perimeter_speed = 20 -perimeters = 4 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0 -solid_infill_speed = 20 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.18 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 20 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 200 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.05mm DETAIL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 10 -bridge_acceleration = 300 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 500 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 25% -fill_pattern = grid -first_layer_acceleration = 500 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 20 -gcode_comments = 0 -infill_acceleration = 800 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 30 -interface_shells = 0 -layer_height = 0.05 -max_print_speed = 80 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 300 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 30 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 15 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 30 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.3 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1.5 -support_material_speed = 30 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 20 -top_solid_layers = 15 -travel_speed = 180 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 40 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 600 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.25 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.25 -fill_angle = 45 -fill_density = 15% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.25 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1600 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.25 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 40 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 600 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.25 -perimeter_speed = 25 -perimeters = 4 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.25 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.18 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.25 -top_solid_infill_speed = 30 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.10mm DETAIL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 170 -interface_shells = 0 -layer_height = 0.1 -max_print_speed = 170 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 170 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 9 -travel_speed = 170 -wipe_tower = 0 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm 100mms Linear Advance] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 50 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 100 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 150 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 60 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 30 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 100 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 60 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 70 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 40 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL 0.25 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 600 -bridge_angle = 0 -bridge_flow_ratio = 0.7 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.25 -external_perimeter_speed = 20 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.25 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.25 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1600 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.25 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 40 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 600 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.25 -perimeter_speed = 25 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 10 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.25 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.2 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 0 -support_material_interface_spacing = 0.15 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 1 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 35 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.25 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 40 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 170 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 170 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 170 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 7 -travel_speed = 170 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL SOLUBLE FULL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 25 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 1 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.15mm OPTIMAL SOLUBLE INTERFACE] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 5 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 25 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.15 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.45 -top_solid_infill_speed = 30 -top_solid_layers = 7 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm 100mms Linear Advance] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 50 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 100 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 150 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 60 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 30 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 100 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 60 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 70 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm FAST MK3] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 30 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 35 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = grid -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 1500 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 170 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 170 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 45 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 170 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 50 -top_solid_layers = 5 -travel_speed = 170 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 50 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 0 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 40 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 50 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 40 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL SOLUBLE FULL] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 1 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 30 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.20mm NORMAL SOLUBLE INTERFACE] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 4 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.45 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.45 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.2 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.45 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.45 -solid_infill_speed = 40 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.45 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.1 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.4 -top_solid_infill_speed = 30 -top_solid_layers = 5 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.95 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.45 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.7 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.43 -perimeter_speed = 50 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.7 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 1 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.43 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 7 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.61 -external_perimeter_speed = 40 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 0 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 50 -perimeters = 3 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 1 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 0 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0.15 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.35 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 1 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 0 -support_material_threshold = 45 -support_material_with_sheath = 0 -support_material_xy_spacing = 60% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.6 -top_solid_infill_speed = 50 -top_solid_layers = 9 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 15 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST sol full 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 4 -support_material_extrusion_width = 0.55 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 3 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 120% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.57 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[print:0.35mm FAST sol int 0.6 nozzle] -avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 -bridge_acceleration = 1000 -bridge_angle = 0 -bridge_flow_ratio = 0.8 -bridge_speed = 20 -brim_width = 0 -clip_multipart_objects = 1 -compatible_printers = -compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1 -complete_objects = 0 -default_acceleration = 1000 -dont_support_bridges = 1 -elefant_foot_compensation = 0 -ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear -external_perimeter_extrusion_width = 0.6 -external_perimeter_speed = 30 -external_perimeters_first = 0 -extra_perimeters = 0 -extruder_clearance_height = 20 -extruder_clearance_radius = 20 -extrusion_width = 0.67 -fill_angle = 45 -fill_density = 20% -fill_pattern = cubic -first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.65 -first_layer_height = 0.2 -first_layer_speed = 30 -gap_fill_speed = 40 -gcode_comments = 0 -infill_acceleration = 2000 -infill_every_layers = 1 -infill_extruder = 1 -infill_extrusion_width = 0.75 -infill_first = 0 -infill_only_where_needed = 0 -infill_overlap = 25% -infill_speed = 60 -interface_shells = 0 -layer_height = 0.35 -max_print_speed = 100 -max_volumetric_extrusion_rate_slope_negative = 0 -max_volumetric_extrusion_rate_slope_positive = 0 -max_volumetric_speed = 0 -min_skirt_length = 4 -notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder -only_retract_when_crossing_perimeters = 0 -ooze_prevention = 0 -output_filename_format = [input_filename_base].gcode -overhangs = 1 -perimeter_acceleration = 800 -perimeter_extruder = 1 -perimeter_extrusion_width = 0.65 -perimeter_speed = 40 -perimeters = 2 -post_process = -print_settings_id = -raft_layers = 0 -resolution = 0 -seam_position = nearest -skirt_distance = 2 -skirt_height = 3 -skirts = 0 -small_perimeter_speed = 20 -solid_infill_below_area = 0 -solid_infill_every_layers = 0 -solid_infill_extruder = 1 -solid_infill_extrusion_width = 0.65 -solid_infill_speed = 60 -spiral_vase = 0 -standby_temperature_delta = -5 -support_material = 1 -support_material_angle = 0 -support_material_buildplate_only = 0 -support_material_contact_distance = 0 -support_material_enforce_layers = 0 -support_material_extruder = 0 -support_material_extrusion_width = 0.55 -support_material_interface_contact_loops = 0 -support_material_interface_extruder = 4 -support_material_interface_layers = 2 -support_material_interface_spacing = 0.2 -support_material_interface_speed = 100% -support_material_pattern = rectilinear -support_material_spacing = 2 -support_material_speed = 50 -support_material_synchronize_layers = 1 -support_material_threshold = 80 -support_material_with_sheath = 0 -support_material_xy_spacing = 150% -thin_walls = 0 -threads = 4 -top_infill_extrusion_width = 0.57 -top_solid_infill_speed = 50 -top_solid_layers = 4 -travel_speed = 120 -wipe_tower = 1 -wipe_tower_per_color_wipe = 20 -wipe_tower_width = 60 -wipe_tower_x = 180 -wipe_tower_y = 140 -xy_size_compensation = 0 - -[filament:ColorFabb Brass Bronze] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.3 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 210 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 210 - -[filament:ColorFabb HT] -bed_temperature = 105 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 105 -first_layer_temperature = 270 -max_fan_speed = 20 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 270 - -[filament:ColorFabb PLA-PHA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:ColorFabb Woodfil] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 200 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 200 - -[filament:ColorFabb XT] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 270 - -[filament:ColorFabb XT-CF20] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 1 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 260 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 260 - -[filament:ColorFabb nGen] -bed_temperature = 85 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = NGEN -first_layer_bed_temperature = 85 -first_layer_temperature = 240 -max_fan_speed = 35 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:ColorFabb nGen flex] -bed_temperature = 85 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 10 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 5 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = FLEX -first_layer_bed_temperature = 85 -first_layer_temperature = 260 -max_fan_speed = 35 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 260 - -[filament:E3D Edge] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:E3D PC-ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 270 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 270 - -[filament:Fillamentum ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 240 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 240 - -[filament:Fillamentum ASA] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 265 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 265 - -[filament:Fillamentum CPE HG100 HM100] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "CPE HG100 , CPE HM100" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 275 -max_fan_speed = 50 -min_fan_speed = 50 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 275 - -[filament:Fillamentum Timberfil] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #804040 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 190 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 190 - -[filament:Generic ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 255 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 255 - -[filament:Generic PET] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:Generic PLA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:Polymaker PC-Max] -bed_temperature = 120 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 120 -first_layer_temperature = 270 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 270 - -[filament:Primavalue PVA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 1 -filament_type = PVA -first_layer_bed_temperature = 60 -first_layer_temperature = 195 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 195 - -[filament:Prusa ABS] -bed_temperature = 100 -bridge_fan_speed = 30 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #3A80CA -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -filament_settings_id = -filament_soluble = 0 -filament_type = ABS -first_layer_bed_temperature = 100 -first_layer_temperature = 255 -max_fan_speed = 30 -min_fan_speed = 10 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 255 - -[filament:Prusa HIPS] -bed_temperature = 100 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 0.9 -fan_always_on = 1 -fan_below_layer_time = 10 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 13 -filament_notes = "" -filament_settings_id = -filament_soluble = 1 -filament_type = HIPS -first_layer_bed_temperature = 100 -first_layer_temperature = 220 -max_fan_speed = 20 -min_fan_speed = 20 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 220 - -[filament:Prusa PET] -bed_temperature = 90 -bridge_fan_speed = 50 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 85 -first_layer_temperature = 230 -max_fan_speed = 50 -min_fan_speed = 30 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" -temperature = 240 - -[filament:Prusa PLA] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #FF3232 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 15 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 210 - -[filament:SemiFlex or Flexfill 98A] -bed_temperature = 50 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1 -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1.2 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #00CA0A -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 1.5 -filament_notes = "List of materials tested with FLEX print settings & FLEX material settings for MK2:\n\nFillamentum Flex 98A\nFillamentum Flex 92A\nPlasty MladeÄ PP\nPlasty MladeÄ TPE32 \nPlasty MladeÄ TPE88" -filament_settings_id = -filament_soluble = 0 -filament_type = FLEX -first_layer_bed_temperature = 50 -first_layer_temperature = 240 -max_fan_speed = 90 -min_fan_speed = 70 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 240 - -[filament:Taulman Bridge] -bed_temperature = 50 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #DEE0E6 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 90 -first_layer_temperature = 240 -max_fan_speed = 5 -min_fan_speed = 0 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 250 - -[filament:Taulman T-Glase] -bed_temperature = 90 -bridge_fan_speed = 40 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 20 -filament_colour = #FF8000 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "" -filament_settings_id = -filament_soluble = 0 -filament_type = PET -first_layer_bed_temperature = 90 -first_layer_temperature = 240 -max_fan_speed = 5 -min_fan_speed = 0 -min_print_speed = 5 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" -temperature = 240 - -[filament:Verbatim BVOH] -bed_temperature = 60 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 0 -disable_fan_first_layers = 1 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 100 -filament_colour = #FFFFD7 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 10 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" -filament_settings_id = -filament_soluble = 1 -filament_type = PLA -first_layer_bed_temperature = 60 -first_layer_temperature = 215 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 210 - -[filament:Verbatim PP] -bed_temperature = 100 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 2 -end_filament_gcode = "; Filament-specific end gcode" -extrusion_multiplier = 1 -fan_always_on = 1 -fan_below_layer_time = 100 -filament_colour = #DEE0E6 -filament_cost = 0 -filament_density = 0 -filament_diameter = 1.75 -filament_max_volumetric_speed = 5 -filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA" -filament_settings_id = -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 100 -first_layer_temperature = 220 -max_fan_speed = 100 -min_fan_speed = 100 -min_print_speed = 15 -slowdown_below_layer_time = 20 -start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" -temperature = 220 - -[printer:Original Prusa i3 MK3] -bed_shape = 0x0,250x0,250x210,0x210 -before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n -between_objects_gcode = -deretract_speed = 0 -end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -extruder_colour = #FFFF00 -extruder_offset = 0x0 -gcode_flavor = marlin -layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] -max_layer_height = 0.25 -min_layer_height = 0.07 -nozzle_diameter = 0.4 -octoprint_apikey = -octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n -retract_before_travel = 1 -retract_before_wipe = 0% -retract_layer_change = 1 -retract_length = 0.8 -retract_length_toolchange = 3 -retract_lift = 0.6 -retract_lift_above = 0 -retract_lift_below = 209 -retract_restart_extra = 0 -retract_restart_extra_toolchange = 0 -retract_speed = 35 -serial_port = -serial_speed = 250000 -single_extruder_multi_material = 0 -start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} -toolchange_gcode = -use_firmware_retraction = 0 -use_relative_e_distances = 1 -use_volumetric_e = 0 -variable_layer_height = 1 -wipe = 1 -z_offset = 0 - -[presets] -print = 0.15mm OPTIMAL MK3 -printer = Original Prusa i3 MK3 -filament = Prusa PLA diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index 1a0b8fb4a3..0a531849da 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -185,7 +185,7 @@ void ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys // This is only possible if other is of DynamicConfig type. if (ignore_nonexistent) continue; - throw UnknownOptionException(); + throw UnknownOptionException(opt_key); } const ConfigOption *other_opt = other.option(opt_key); if (other_opt != nullptr) @@ -232,7 +232,7 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con // Try to deserialize the option by its name. const ConfigDef *def = this->def(); if (def == nullptr) - throw NoDefinitionException(); + throw NoDefinitionException(opt_key); const ConfigOptionDef *optdef = def->get(opt_key); if (optdef == nullptr) { // If we didn't find an option, look for any other option having this as an alias. @@ -248,7 +248,7 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con break; } if (optdef == nullptr) - throw UnknownOptionException(); + throw UnknownOptionException(opt_key); } if (! optdef->shortcut.empty()) { @@ -278,7 +278,7 @@ double ConfigBase::get_abs_value(const t_config_option_key &opt_key) const // Get option definition. const ConfigDef *def = this->def(); if (def == nullptr) - throw NoDefinitionException(); + throw NoDefinitionException(opt_key); const ConfigOptionDef *opt_def = def->get(opt_key); assert(opt_def != nullptr); // Compute absolute value over the absolute value of the base option. @@ -468,7 +468,7 @@ ConfigOption* DynamicConfig::optptr(const t_config_option_key &opt_key, bool cre // Try to create a new ConfigOption. const ConfigDef *def = this->def(); if (def == nullptr) - throw NoDefinitionException(); + throw NoDefinitionException(opt_key); const ConfigOptionDef *optdef = def->get(opt_key); if (optdef == nullptr) // throw std::runtime_error(std::string("Invalid option name: ") + opt_key); diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 3dccedbf0a..1f4e85a349 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -1232,17 +1232,22 @@ protected: }; /// Specialization of std::exception to indicate that an unknown config option has been encountered. -class UnknownOptionException : public std::exception -{ +class UnknownOptionException : public std::runtime_error { public: - const char* what() const noexcept override { return "Unknown config option"; } + UnknownOptionException() : + std::runtime_error("Unknown option exception") {} + UnknownOptionException(const std::string &opt_key) : + std::runtime_error(std::string("Unknown option exception: ") + opt_key) {} }; /// Indicate that the ConfigBase derived class does not provide config definition (the method def() returns null). -class NoDefinitionException : public std::exception +class NoDefinitionException : public std::runtime_error { public: - const char* what() const noexcept override { return "No config definition"; } + NoDefinitionException() : + std::runtime_error("No definition exception") {} + NoDefinitionException(const std::string &opt_key) : + std::runtime_error(std::string("No definition exception: ") + opt_key) {} }; } diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 2b95ffa842..f66a4c7fba 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -176,6 +176,18 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(0); + def = this->add("default_filament_profile", coStrings); + def->label = L("Default filament profile"); + def->tooltip = L("Default filament profile associated with the current printer profile. " + "On selection of the current printer profile, this filament profile will be activated."); + def->default_value = new ConfigOptionStrings(); + + def = this->add("default_print_profile", coString); + def->label = L("Default print profile"); + def->tooltip = L("Default print profile associated with the current printer profile. " + "On selection of the current printer profile, this print profile will be activated."); + def->default_value = new ConfigOptionString(); + def = this->add("disable_fan_first_layers", coInts); def->label = L("Disable fan for the first"); def->tooltip = L("You can set this to a positive value to disable fan at all " @@ -753,6 +765,13 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(80); + def = this->add("inherits", coString); + def->label = L("Inherits profile"); + def->tooltip = L("Name of the profile, from which this profile inherits."); + def->full_width = true; + def->height = 50; + def->default_value = new ConfigOptionString(""); + def = this->add("interface_shells", coBool); def->label = L("Interface shells"); def->tooltip = L("Force the generation of solid shells between adjacent materials/volumes. " @@ -1017,6 +1036,11 @@ PrintConfigDef::PrintConfigDef() def->height = 60; def->default_value = new ConfigOptionStrings{ "" }; + def = this->add("printer_model", coString); + def->label = L("Printer type"); + def->tooltip = L("Type of the printer."); + def->default_value = new ConfigOptionString(); + def = this->add("printer_notes", coString); def->label = L("Printer notes"); def->tooltip = L("You can put your notes regarding the printer here."); @@ -1026,6 +1050,16 @@ PrintConfigDef::PrintConfigDef() def->height = 130; def->default_value = new ConfigOptionString(""); + def = this->add("printer_vendor", coString); + def->label = L("Printer vendor"); + def->tooltip = L("Name of the printer vendor."); + def->default_value = new ConfigOptionString(); + + def = this->add("printer_variant", coString); + def->label = L("Printer variant"); + def->tooltip = L("Name of the printer variant. For example, the printer variants may be differentiated by a nozzle diameter."); + def->default_value = new ConfigOptionString(); + def = this->add("print_settings_id", coString); def->default_value = new ConfigOptionString(""); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 52717e1fc4..d3d569cae9 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -200,7 +200,7 @@ const std::vector& Preset::print_options() "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", - "compatible_printers", "compatible_printers_condition" + "compatible_printers", "compatible_printers_condition", "inherits" }; return s_opts; } @@ -213,7 +213,7 @@ const std::vector& Preset::filament_options() "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode", - "compatible_printers", "compatible_printers_condition" + "compatible_printers", "compatible_printers_condition", "inherits" }; return s_opts; } @@ -226,7 +226,7 @@ const std::vector& Preset::printer_options() "bed_shape", "z_offset", "gcode_flavor", "use_relative_e_distances", "serial_port", "serial_speed", "octoprint_host", "octoprint_apikey", "octoprint_cafile", "use_firmware_retraction", "use_volumetric_e", "variable_layer_height", "single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode", - "between_objects_gcode", "printer_notes" + "between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "default_print_profile", "default_filament_profile", "inherits", }; s_opts.insert(s_opts.end(), Preset::nozzle_options().begin(), Preset::nozzle_options().end()); } @@ -269,7 +269,7 @@ void PresetCollection::reset(bool delete_files) if (delete_files) { // Erase the preset files. for (Preset &preset : m_presets) - if (! preset.is_default && ! preset.is_external) + if (! preset.is_default && ! preset.is_external && ! preset.is_system) boost::nowide::remove(preset.file.c_str()); } // Don't use m_presets.resize() here as it requires a default constructor for Preset. @@ -284,7 +284,6 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri { boost::filesystem::path dir = boost::filesystem::canonical(boost::filesystem::path(dir_path) / subdir).make_preferred(); m_dir_path = dir.string(); - m_presets.erase(m_presets.begin()+1, m_presets.end()); t_config_option_keys keys = this->default_preset().config.keys(); std::string errors_cummulative; for (auto &dir_entry : boost::filesystem::directory_iterator(dir)) @@ -292,6 +291,10 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri std::string name = dir_entry.path().filename().string(); // Remove the .ini suffix. name.erase(name.size() - 4); + if (this->find_preset(name, false)) { + errors_cummulative += "The user preset \"" + name + "\" cannot be loaded. A system preset of the same name has already been loaded."; + continue; + } try { Preset preset(m_type, name, false); preset.file = dir_entry.path().string(); @@ -364,7 +367,7 @@ void PresetCollection::delete_current_preset() const Preset &selected = this->get_selected_preset(); if (selected.is_default) return; - if (! selected.is_external) { + if (! selected.is_external && ! selected.is_system) { // Erase the preset file. boost::nowide::remove(selected.file.c_str()); } diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index c1d85833bf..c56b91bcfe 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -23,6 +23,46 @@ enum ConfigFileType extern ConfigFileType guess_config_file_type(const boost::property_tree::ptree &tree); +class VendorProfile +{ +public: + std::string name; + std::string id; + std::string config_version; + std::string config_update_url; + + struct PrinterVariant { + PrinterVariant() {} + PrinterVariant(const std::string &name) : name(name) {} + std::string name; + bool enabled = true; + }; + + struct PrinterModel { + PrinterModel() {} + PrinterModel(const std::string &name) : name(name) {} + std::string name; + bool enabled = true; + std::vector variants; + PrinterVariant* variant(const std::string &name) { + for (auto &v : this->variants) + if (v.name == name) + return &v; + return nullptr; + } + const PrinterVariant* variant(const std::string &name) const { return const_cast(this)->variant(name); } + + bool operator< (const PrinterModel &rhs) const { return this->name < rhs.name; } + bool operator==(const PrinterModel &rhs) const { return this->name == rhs.name; } + }; + std::set models; + + size_t num_variants() const { size_t n = 0; for (auto &model : models) n += model.variants.size(); return n; } + + bool operator< (const VendorProfile &rhs) const { return this->id < rhs.id; } + bool operator==(const VendorProfile &rhs) const { return this->id == rhs.id; } +}; + class Preset { public: @@ -44,6 +84,8 @@ public: // External preset points to a configuration, which has been loaded but not imported // into the Slic3r default configuration location. bool is_external = false; + // System preset is read-only. + bool is_system = false; // Preset is visible, if it is compatible with the active Printer. // Also the "default" preset is only visible, if it is the only preset in the list. bool is_visible = true; @@ -55,9 +97,14 @@ public: // Name of the preset, usually derived form the file name. std::string name; // File name of the preset. This could be a Print / Filament / Printer preset, - // or a Configuration file bundling the Print + Filament + Printer presets (in that case is_external will be true), + // or a Configuration file bundling the Print + Filament + Printer presets (in that case is_external and possibly is_system will be true), // or it could be a G-code (again, is_external will be true). std::string file; + // A user profile may inherit its settings either from a system profile, or from a user profile. + // A system profile shall never derive from any other profile, as the system profile hierarchy is being flattened during loading. + std::string inherits; + // If this is a system profile, then there should be a vendor data available to display at the UI. + const VendorProfile *vendor = nullptr; // Has this profile been loaded? bool loaded = false; diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index bf79c6562e..77eb5c0814 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -51,6 +51,14 @@ PresetBundle::PresetBundle() : this->filaments.preset(0).config.optptr("compatible_printers_condition", true); this->prints.preset(0).config.optptr("compatible_printers", true); this->prints.preset(0).config.optptr("compatible_printers_condition", true); + // Create the "inherits" keys. + this->prints.preset(0).config.optptr("inherits", true); + this->filaments.preset(0).config.optptr("inherits", true); + this->printers.preset(0).config.optptr("inherits", true); + // Create the "printer_vendor", "printer_model" and "printer_variant" keys. + this->printers.preset(0).config.optptr("printer_vendor", true); + this->printers.preset(0).config.optptr("printer_model", true); + this->printers.preset(0).config.optptr("printer_variant", true); this->prints .load_bitmap_default("cog.png"); this->filaments.load_bitmap_default("spool.png"); @@ -84,7 +92,8 @@ void PresetBundle::setup_directories() { boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); std::initializer_list paths = { - data_dir, + data_dir, + data_dir / "vendor", #ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR // Store the print/filament/printer presets into a "presets" directory. data_dir / "presets", @@ -107,10 +116,12 @@ void PresetBundle::setup_directories() } } -void PresetBundle::load_presets() +void PresetBundle::load_presets(const AppConfig &config) { - std::string errors_cummulative; - const std::string dir_path = data_dir() + // First load the vendor specific system presets. + std::string errors_cummulative = this->load_system_presets(); + + const std::string dir_user_presets = data_dir() #ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR // Store the print/filament/printer presets into a "presets" directory. + "/presets" @@ -119,17 +130,17 @@ void PresetBundle::load_presets() #endif ; try { - this->prints.load_presets(dir_path, "print"); + this->prints.load_presets(dir_user_presets, "print"); } catch (const std::runtime_error &err) { errors_cummulative += err.what(); } try { - this->filaments.load_presets(dir_path, "filament"); + this->filaments.load_presets(dir_user_presets, "filament"); } catch (const std::runtime_error &err) { errors_cummulative += err.what(); } try { - this->printers.load_presets(dir_path, "printer"); + this->printers.load_presets(dir_user_presets, "printer"); } catch (const std::runtime_error &err) { errors_cummulative += err.what(); } @@ -137,6 +148,31 @@ void PresetBundle::load_presets() this->update_compatible_with_printer(false); if (! errors_cummulative.empty()) throw std::runtime_error(errors_cummulative); + + this->load_selections(config); +} + +// Load system presets into this PresetBundle. +// For each vendor, there will be a single PresetBundle loaded. +std::string PresetBundle::load_system_presets() +{ + // Here the vendor specific read only Config Bundles are stored. + boost::filesystem::path dir = (boost::filesystem::path(data_dir()) / "vendor").make_preferred(); + std::string errors_cummulative; + for (auto &dir_entry : boost::filesystem::directory_iterator(dir)) + if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini")) { + std::string name = dir_entry.path().filename().string(); + // Remove the .ini suffix. + name.erase(name.size() - 4); + try { + // Load the config bundle, flatten it. + this->load_configbundle(dir_entry.path().string(), LOAD_CFGBNDLE_SYSTEM); + } catch (const std::runtime_error &err) { + errors_cummulative += err.what(); + errors_cummulative += "\n"; + } + } + return errors_cummulative; } static inline std::string remove_ini_suffix(const std::string &name) @@ -147,6 +183,14 @@ static inline std::string remove_ini_suffix(const std::string &name) return out; } +// Set the "enabled" flag for printer vendors, printer models and printer variants +// based on the user configuration. +// If the "vendor" section is missing, enable all models and variants of the particular vendor. +void PresetBundle::load_installed_printers(const AppConfig &config) +{ + // m_storage +} + // Load selections (current print, current filaments, current printer) from config.ini // This is done just once on application start up. void PresetBundle::load_selections(const AppConfig &config) @@ -594,11 +638,54 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree) flatten_configbundle_hierarchy(tree, "printer"); } +static void load_vendor_profile(const boost::property_tree::ptree &tree, VendorProfile &vendor_profile) +{ + const std::string printer_model_key = "printer_model:"; + for (auto §ion : tree) + if (section.first == "vendor") { + // Load the names of the active presets. + for (auto &kvp : section.second) { + if (kvp.first == "name") + vendor_profile.name = kvp.second.data(); + else if (kvp.first == "id") + vendor_profile.id = kvp.second.data(); + else if (kvp.first == "config_version") + vendor_profile.config_version = kvp.second.data(); + else if (kvp.first == "config_update_url") + vendor_profile.config_update_url = kvp.second.data(); + } + } else if (boost::starts_with(section.first, printer_model_key)) { + VendorProfile::PrinterModel model; + model.name = section.first.substr(printer_model_key.size()); + section.second.get("variants", ""); + std::vector variants; + if (Slic3r::unescape_strings_cstyle(section.second.get("variants", ""), variants)) { + for (const std::string &variant_name : variants) { + if (model.variant(variant_name) == nullptr) + model.variants.emplace_back(VendorProfile::PrinterVariant(variant_name)); + } + } else { + // Log error? + } + if (! model.name.empty() && ! model.variants.empty()) + vendor_profile.models.insert(model); + } +} + +// Load a config bundle file, into presets and store the loaded presets into separate files +// of the local configuration directory. +void PresetBundle::install_vendor_configbundle(const std::string &src_path0) +{ + boost::filesystem::path src_path(src_path0); + boost::filesystem::copy_file(src_path, (boost::filesystem::path(data_dir()) / "vendor" / src_path.filename()).make_preferred(), boost::filesystem::copy_option::overwrite_if_exists); +} + // Load a config bundle file, into presets and store the loaded presets into separate files // of the local configuration directory. size_t PresetBundle::load_configbundle(const std::string &path, unsigned int flags) { - if (flags & LOAD_CFGBNDLE_RESET_USER_PROFILE) + if (flags & (LOAD_CFGBNDLE_RESET_USER_PROFILE | LOAD_CFGBNDLE_SYSTEM)) + // Reset this bundle, delete user profile files if LOAD_CFGBNDLE_SAVE. this->reset(flags & LOAD_CFGBNDLE_SAVE); // 1) Read the complete config file into a boost::property_tree. @@ -609,6 +696,17 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla // Flatten the config bundle by applying the inheritance rules. Internal profiles (with names starting with '*') are removed. flatten_configbundle_hierarchy(tree); + const VendorProfile *vendor_profile = nullptr; + if (flags & LOAD_CFGBNDLE_SYSTEM) { + VendorProfile vp; + load_vendor_profile(tree, vp); + if (vp.name.empty()) + throw std::runtime_error(std::string("Vendor Config Bundle is not valid: Missing vendor name key.")); + if (vp.num_variants() == 0) + return 0; + vendor_profile = &(*this->vendors.insert(vp).first); + } + // 2) Parse the property_tree, extract the active preset names and the profiles, save them into local config files. std::vector loaded_prints; std::vector loaded_filaments; @@ -622,15 +720,15 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla std::vector *loaded = nullptr; std::string preset_name; if (boost::starts_with(section.first, "print:")) { - presets = &prints; + presets = &this->prints; loaded = &loaded_prints; preset_name = section.first.substr(6); } else if (boost::starts_with(section.first, "filament:")) { - presets = &filaments; + presets = &this->filaments; loaded = &loaded_filaments; preset_name = section.first.substr(9); } else if (boost::starts_with(section.first, "printer:")) { - presets = &printers; + presets = &this->printers; loaded = &loaded_printers; preset_name = section.first.substr(8); } else if (section.first == "presets") { @@ -664,6 +762,40 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla for (auto &kvp : section.second) config.set_deserialize(kvp.first, kvp.second.data()); Preset::normalize(config); + if ((flags & LOAD_CFGBNDLE_SYSTEM) && presets == &printers) { + // Filter out printer presets, which are not mentioned in the vendor profile. + // These presets are considered not installed. + auto printer_model = config.opt_string("printer_model"); + if (printer_model.empty()) { + BOOST_LOG_TRIVIAL(error) << "Error in a Vendor Config Bundle \"" << path << "\": The printer preset \"" << + section.first << "\" defines no printer model, it will be ignored."; + continue; + } + auto printer_variant = config.opt_string("printer_variant"); + if (printer_variant.empty()) { + BOOST_LOG_TRIVIAL(error) << "Error in a Vendor Config Bundle \"" << path << "\": The printer preset \"" << + section.first << "\" defines no printer variant, it will be ignored."; + continue; + } + auto it_model = vendor_profile->models.find(VendorProfile::PrinterModel(printer_model)); + if (it_model == vendor_profile->models.end()) { + BOOST_LOG_TRIVIAL(error) << "Error in a Vendor Config Bundle \"" << path << "\": The printer preset \"" << + section.first << "\" defines invalid printer model \"" << printer_model << "\", it will be ignored."; + continue; + } + auto it_variant = it_model->variant(printer_variant); + if (it_variant == nullptr) { + BOOST_LOG_TRIVIAL(error) << "Error in a Vendor Config Bundle \"" << path << "\": The printer preset \"" << + section.first << "\" defines invalid printer variant \"" << printer_variant << "\", it will be ignored."; + continue; + } + const Preset *preset_existing = presets->find_preset(section.first, false); + if (preset_existing != nullptr) { + BOOST_LOG_TRIVIAL(error) << "Error in a Vendor Config Bundle \"" << path << "\": The printer preset \"" << + section.first << "\" has already been loaded from another Confing Bundle."; + continue; + } + } // Decide a full path to this .ini file. auto file_name = boost::algorithm::iends_with(preset_name, ".ini") ? preset_name : preset_name + ".ini"; auto file_path = (boost::filesystem::path(data_dir()) @@ -678,24 +810,29 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla Preset &loaded = presets->load_preset(file_path.string(), preset_name, std::move(config), false); if (flags & LOAD_CFGBNDLE_SAVE) loaded.save(); + if (flags & LOAD_CFGBNDLE_SYSTEM) { + loaded.is_system = true; + loaded.vendor = vendor_profile; + } ++ presets_loaded; } } // 3) Activate the presets. - if (! active_print.empty()) - prints.select_preset_by_name(active_print, true); - if (! active_printer.empty()) - printers.select_preset_by_name(active_printer, true); - // Activate the first filament preset. - if (! active_filaments.empty() && ! active_filaments.front().empty()) - filaments.select_preset_by_name(active_filaments.front(), true); + if ((flags & LOAD_CFGBNDLE_SYSTEM) == 0) { + if (! active_print.empty()) + prints.select_preset_by_name(active_print, true); + if (! active_printer.empty()) + printers.select_preset_by_name(active_printer, true); + // Activate the first filament preset. + if (! active_filaments.empty() && ! active_filaments.front().empty()) + filaments.select_preset_by_name(active_filaments.front(), true); + this->update_multi_material_filament_presets(); + for (size_t i = 0; i < std::min(this->filament_presets.size(), active_filaments.size()); ++ i) + this->filament_presets[i] = filaments.find_preset(active_filaments[i], true)->name; + this->update_compatible_with_printer(false); + } - this->update_multi_material_filament_presets(); - for (size_t i = 0; i < std::min(this->filament_presets.size(), active_filaments.size()); ++ i) - this->filament_presets[i] = filaments.find_preset(active_filaments[i], true)->name; - - this->update_compatible_with_printer(false); return presets_loaded; } diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index e6aea206d1..aaa66265aa 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -4,6 +4,8 @@ #include "AppConfig.hpp" #include "Preset.hpp" +#include + namespace Slic3r { class PlaceholderParser; @@ -22,11 +24,10 @@ public: void setup_directories(); // Load ini files of all types (print, filament, printer) from Slic3r::data_dir() / presets. - void load_presets(); - // Load selections (current print, current filaments, current printer) from config.ini // This is done just once on application start up. - void load_selections(const AppConfig &config); + void load_presets(const AppConfig &config); + // Export selections (current print, current filaments, current printer) into config.ini void export_selections(AppConfig &config); // Export selections (current print, current filaments, current printer) into a placeholder parser. @@ -39,6 +40,10 @@ public: // extruders.size() should be the same as printers.get_edited_preset().config.nozzle_diameter.size() std::vector filament_presets; + // There will be an entry for each system profile loaded, + // and the system profiles will point to the VendorProfile instances owned by PresetBundle::vendors. + std::set vendors; + bool has_defauls_only() const { return prints.size() <= 1 && filaments.size() <= 1 && printers.size() <= 1; } @@ -69,11 +74,16 @@ public: // Save the profiles, which have been loaded. LOAD_CFGBNDLE_SAVE = 1, // Delete all old config profiles before loading. - LOAD_CFGBNDLE_RESET_USER_PROFILE = 2 + LOAD_CFGBNDLE_RESET_USER_PROFILE = 2, + // Load a system config bundle. + LOAD_CFGBNDLE_SYSTEM = 4, }; // Load the config bundle, store it to the user profile directory by default. size_t load_configbundle(const std::string &path, unsigned int flags = LOAD_CFGBNDLE_SAVE); + // Install the Vendor specific config bundle into user's directory. + void install_vendor_configbundle(const std::string &src_path); + // Export a config bundle file containing all the presets and the names of the active presets. void export_configbundle(const std::string &path); // , const DynamicPrintConfig &settings); @@ -99,6 +109,17 @@ public: void update_compatible_with_printer(bool select_other_if_incompatible); private: + std::string load_system_presets(); + + // Set the "enabled" flag for printer vendors, printer models and printer variants + // based on the user configuration. + // If the "vendor" section is missing, enable all models and variants of the particular vendor. + void load_installed_printers(const AppConfig &config); + + // Load selections (current print, current filaments, current printer) from config.ini + // This is done just once on application start up. + void load_selections(const AppConfig &config); + // Load print, filament & printer presets from a config. If it is an external config, then the name is extracted from the external path. // and the external config is just referenced, not stored into user profile directory. // If it is not an external config, then the config will be stored into the user profile directory. diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 7ce6790a12..7c29a3beaf 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1352,7 +1352,7 @@ void Tab::load_current_preset() auto preset = m_presets->get_edited_preset(); // try{ // local $SIG{ __WARN__ } = Slic3r::GUI::warning_catcher($self); - preset.is_default ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true); + (preset.is_default || preset.is_system) ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true); update(); // For the printer profile, generate the extruder pages. on_preset_loaded(); @@ -1557,7 +1557,7 @@ void Tab::save_preset(std::string name /*= ""*/) std::vector values; for (size_t i = 0; i < m_presets->size(); ++i) { const Preset &preset = m_presets->preset(i); - if (preset.is_default || preset.is_external) + if (preset.is_default || preset.is_system || preset.is_external) continue; values.push_back(preset.name); } @@ -1571,6 +1571,15 @@ void Tab::save_preset(std::string name /*= ""*/) show_error(this, _(L("The supplied name is empty. It can't be saved."))); return; } + const Preset *existing = m_presets->find_preset(name, false); + if (existing && (existing->is_default || existing->is_system)) { + show_error(this, _(L("Cannot overwrite a system profile."))); + return; + } + if (existing && (existing->is_external)) { + show_error(this, _(L("Cannot overwrite an external."))); + return; + } } // Save the preset into Slic3r::data_dir / presets / section_name / preset_name.ini @@ -1670,7 +1679,7 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox for (size_t idx = 0; idx < printers->size(); ++idx) { Preset& preset = printers->preset(idx); - if (!preset.is_default && !preset.is_external) + if (!preset.is_default && !preset.is_external && !preset.is_system) presets.Add(preset.name); } diff --git a/xs/xsp/GUI_Preset.xsp b/xs/xsp/GUI_Preset.xsp index 0033ebd0e2..84efdde53f 100644 --- a/xs/xsp/GUI_Preset.xsp +++ b/xs/xsp/GUI_Preset.xsp @@ -12,6 +12,7 @@ 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; %}; @@ -110,10 +111,10 @@ PresetCollection::arrayref() croak("Cannot create configuration directories:\n%s\n", e.what()); } %}; - void load_presets() + void load_presets(AppConfig *config) %code%{ try { - THIS->load_presets(); + 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()); @@ -143,6 +144,14 @@ PresetCollection::arrayref() croak("Loading of a config bundle %s failed:\n%s\n", path, e.what()); } %}; + void install_vendor_configbundle(const char *path) + %code%{ + try { + THIS->install_vendor_configbundle(path); + } catch (std::exception& e) { + croak("Installing a vendor config bundle %s failed:\n%s\n", path, e.what()); + } + %}; void export_configbundle(char *path) %code%{ try { @@ -154,7 +163,6 @@ PresetCollection::arrayref() 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); %}; From b5fd4ddb8c50908e5754df8f49d698eb16f0fd2f Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 12 Mar 2018 08:35:35 +0100 Subject: [PATCH 0037/1150] Removed an unnecessary wait --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 671819286f..624b489038 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -627,7 +627,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo if (peters_wipe_tower) writer.rectangle(m_wipe_tower_pos,m_layer_info->depth + 3*m_perimeter_width,m_wipe_tower_depth); else { - writer.wait(2.f); writer.rectangle(m_wipe_tower_pos,m_wipe_tower_width, m_layer_info->depth + m_perimeter_width); if (layer_finished()) { // no finish_layer will be called, we must wipe the nozzle writer.travel(m_wipe_tower_pos.x + (writer.x()>m_wipe_tower_pos.x + EPSILON ? 0.f : m_wipe_tower_width), writer.y()); From 27ab8ff4e1fc9efdc5ca61ff1ae70cdfde16b4e8 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 12 Mar 2018 15:41:25 +0100 Subject: [PATCH 0038/1150] Configuration layer changes (cooling_time, bridging, adhesion moved from dedicated dialog to filament/print settings) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 12 ++--- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 42 ++++++++--------- xs/src/libslic3r/Print.cpp | 5 ++ xs/src/libslic3r/PrintConfig.cpp | 23 ++++++++++ xs/src/libslic3r/PrintConfig.hpp | 6 +++ xs/src/slic3r/GUI/Preset.cpp | 6 +-- xs/src/slic3r/GUI/Tab.cpp | 23 ++++++++++ xs/src/slic3r/GUI/WipeTowerDialog.cpp | 51 ++------------------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 33 ------------- 9 files changed, 91 insertions(+), 110 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 624b489038..b94950af10 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -734,7 +734,7 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.travel(xl, cleaning_box.ld.y + m_depth_traversed + y_step/2.f ); // move to starting position // if the ending point of the ram would end up in mid air, align it with the end of the wipe tower: - if (m_layer_info > m_plan.begin() && m_layer_info < m_plan.end() && (m_layer_info-1!=m_plan.begin() || !m_par.adhesion )) { + if (m_layer_info > m_plan.begin() && m_layer_info < m_plan.end() && (m_layer_info-1!=m_plan.begin() || !m_adhesion )) { // this is y of the center of previous sparse infill border float sparse_beginning_y = m_wipe_tower_pos.y; @@ -821,8 +821,8 @@ void WipeTowerPrusaMM::toolchange_Unload( const float start_x = writer.x(); turning_point = ( xr-start_x > start_x-xl ? xr : xl ); const float max_x_dist = 2*std::abs(start_x-turning_point); - const unsigned int N = 4 + std::max(0,(m_par.cooling_time[m_current_tool]-14)/3); - float time = m_par.cooling_time[m_current_tool] / float(N); + const unsigned int N = 4 + std::max(0,(m_filpar[m_current_tool].cooling_time-14)/3); + float time = m_filpar[m_current_tool].cooling_time / float(N); i = 0; while (i fill_box.ld.x+EPSILON) writer.travel(fill_box.ld.x,writer.y()); if (writer.y() > fill_box.ld.y+EPSILON) writer.travel(writer.x(),fill_box.ld.y); - if (m_is_first_layer && m_par.adhesion) { + if (m_is_first_layer && m_adhesion) { // Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower. box.expand(-m_perimeter_width/2.f); unsigned nsteps = int(floor((box.lu.y - box.ld.y) / (2*m_perimeter_width))); @@ -1045,7 +1045,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() writer.travel(fill_box.ld + xy(m_perimeter_width * 2, 0.f)) .extrude(fill_box.lu + xy(m_perimeter_width * 2, 0.f), 2900 * speed_factor); - const int n = 1+(right-left)/(m_par.bridging); + const int n = 1+(right-left)/(m_bridging); const float dx = (right-left)/n; for (int i=1;i<=n;++i) { float x=left+dx*i; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 3182c8b8e3..3c2f82ffdd 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -68,13 +68,12 @@ struct WipeTowerParameters { WipeTowerParameters() { } // create new empty object WipeTowerParameters(const std::string& init_data) { // create object and initialize from std::string std::istringstream in(init_data); // validation of input is left to the caller - in >> bridging >> adhesion >> sampling; + in >> sampling; for (std::vector vect{} ; in >> vect ;) { // until we get to fail state ("**")... - if (vect.size()>=3) { - cooling_time.push_back(vect[0]); - ramming_line_width_multiplicator.push_back(vect[1]); - ramming_step_multiplicator.push_back(vect[2]); - vect.erase(vect.begin(),vect.begin()+3); + if (vect.size()>=2) { + ramming_line_width_multiplicator.push_back(vect[0]); + ramming_step_multiplicator.push_back(vect[1]); + vect.erase(vect.begin(),vect.begin()+2); } else vect.clear(); // something's not right, we will restore defaults anyway ramming_speed.push_back(vect); @@ -102,16 +101,16 @@ struct WipeTowerParameters { for (unsigned int i=0;i cooling_time; std::vector ramming_line_width_multiplicator; std::vector ramming_step_multiplicator; std::vector> ramming_speed; @@ -192,7 +185,7 @@ public: // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, float cooling_tube_retraction, - float cooling_tube_length, float parking_pos_retraction, std::string& parameters, + float cooling_tube_length, float parking_pos_retraction, float bridging, bool adhesion, std::string& parameters, unsigned int initial_tool) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), @@ -205,8 +198,11 @@ public: m_cooling_tube_length(cooling_tube_length), m_parking_pos_retraction(parking_pos_retraction), m_current_tool(initial_tool), - m_par(parameters) + m_par(parameters) { + m_bridging = bridging; + m_adhesion = adhesion; + for (size_t i = 0; i < 4; ++ i) { // Extruder specific parameters. m_filpar[i].material = PLA; @@ -226,7 +222,7 @@ public: // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, - float unloading_speed, float delay) + float unloading_speed, float delay, int cooling_time) { m_filpar[idx].material = material; m_filpar[idx].temperature = temp; @@ -234,6 +230,7 @@ public: m_filpar[idx].loading_speed = loading_speed; m_filpar[idx].unloading_speed = unloading_speed; m_filpar[idx].delay = delay; + m_filpar[idx].cooling_time = cooling_time; } @@ -340,6 +337,8 @@ private: float m_cooling_tube_retraction = 0.f; float m_cooling_tube_length = 0.f; float m_parking_pos_retraction = 0.f; + float m_bridging = 0.f; + bool m_adhesion = true; float m_line_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_extrusion_flow = 0.038; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. @@ -352,6 +351,7 @@ private: float loading_speed; float unloading_speed; float delay; + int cooling_time; }; // Extruder specific parameters. diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 5affad2973..95c57339a5 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -188,6 +188,7 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_width.value), float(this->config.wipe_tower_per_color_wipe.value), float(this->config.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), + float(this->config.wipe_tower_bridging), bool(this->config.wipe_tower_adhesion), this->config.wipe_tower_advanced.value,m_tool_ordering.first_extruder()); //wipe_tower.set_retract(); @@ -1044,6 +1048,7 @@ void Print::_make_wipe_tower() this->config.first_layer_temperature.get_at(i), this->config.filament_loading_speed.get_at(i), this->config.filament_unloading_speed.get_at(i), + this->config.filament_toolchange_delay.get_at(i), this->config.filament_toolchange_delay.get_at(i)); // When printing the first layer's wipe tower, the first extruder is expected to be active and primed. diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index f31e5de3be..b0b1c4e993 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -469,6 +469,15 @@ PrintConfigDef::PrintConfigDef() def->cli = "filament-toolchange-delay=f@"; def->min = 0; def->default_value = new ConfigOptionFloats { 0. }; + + def = this->add("filament_cooling_time", coInts); + def->label = L("Cooling time"); + def->tooltip = L("The filament is slowly moved back and forth after retraction into the cooling tube " + "for this amount of time."); + def->cli = "filament_cooling_time=i@"; + def->sidetext = L("s"); + def->min = 0; + def->default_value = new ConfigOptionInts { 14 }; def = this->add("filament_diameter", coFloats); def->label = L("Diameter"); @@ -1800,6 +1809,20 @@ PrintConfigDef::PrintConfigDef() def->sidetext = L("degrees"); def->cli = "wipe-tower-rotation-angle=f"; def->default_value = new ConfigOptionFloat(0.); + + def = this->add("wipe_tower_bridging", coFloat); + def->label = L("Maximal bridging distance"); + def->tooltip = L("Maximal distance between supports on sparse infill sections. "); + def->sidetext = L("mm"); + def->cli = "wipe-tower-bridging=f"; + def->default_value = new ConfigOptionFloat(10.); + + def = this->add("wipe_tower_adhesion", coBool); + def->label = L("Increase first layer adhesion"); + def->tooltip = L("This prevents using sparse infill on the first layer, if it would be " + "normally applied. Dense infill is used instead. "); + def->cli = "wipe-tower_adhesion!"; + def->default_value = new ConfigOptionBool(true); def = this->add("xy_size_compensation", coFloat); def->label = L("XY Size Compensation"); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 06aa343b8c..501a8ac367 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -470,6 +470,7 @@ public: ConfigOptionFloats filament_loading_speed; ConfigOptionFloats filament_unloading_speed; ConfigOptionFloats filament_toolchange_delay; + ConfigOptionInts filament_cooling_time; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; ConfigOptionString layer_gcode; @@ -525,6 +526,7 @@ protected: OPT_PTR(filament_loading_speed); OPT_PTR(filament_unloading_speed); OPT_PTR(filament_toolchange_delay); + OPT_PTR(filament_cooling_time); OPT_PTR(gcode_comments); OPT_PTR(gcode_flavor); OPT_PTR(layer_gcode); @@ -624,6 +626,8 @@ public: ConfigOptionFloat wipe_tower_width; ConfigOptionFloat wipe_tower_per_color_wipe; ConfigOptionFloat wipe_tower_rotation_angle; + ConfigOptionFloat wipe_tower_bridging; + ConfigOptionBool wipe_tower_adhesion; ConfigOptionFloat z_offset; protected: @@ -690,6 +694,8 @@ protected: OPT_PTR(wipe_tower_width); OPT_PTR(wipe_tower_per_color_wipe); OPT_PTR(wipe_tower_rotation_angle); + OPT_PTR(wipe_tower_bridging); + OPT_PTR(wipe_tower_adhesion); OPT_PTR(z_offset); } }; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index a8b6a514c5..92bfef4165 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -199,8 +199,8 @@ const std::vector& Preset::print_options() "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower_advanced", "wipe_tower", "wipe_tower_x", - "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "compatible_printers", - "compatible_printers_condition" + "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_adhesion", "wipe_tower_bridging", + "compatible_printers", "compatible_printers_condition" }; return s_opts; @@ -211,7 +211,7 @@ const std::vector& Preset::filament_options() static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay", - "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", + "filament_cooling_time", "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers", "compatible_printers_condition" }; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 177fccc599..ea80e2ecec 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -458,6 +458,8 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_width"); optgroup->append_single_option_line("wipe_tower_per_color_wipe"); optgroup->append_single_option_line("wipe_tower_rotation_angle"); + optgroup->append_single_option_line("wipe_tower_bridging"); + optgroup->append_single_option_line("wipe_tower_adhesion"); line = { _(L("Advanced")), "" }; line.widget = [this](wxWindow* parent){ m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); @@ -880,6 +882,27 @@ void TabFilament::build() optgroup->append_single_option_line("filament_loading_speed"); optgroup->append_single_option_line("filament_unloading_speed"); optgroup->append_single_option_line("filament_toolchange_delay"); + optgroup->append_single_option_line("filament_cooling_time"); + line = { _(L("Ramming")), "" }; + line.widget = [this](wxWindow* parent){ + auto ramming_dialog = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); + auto sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(ramming_dialog); + /*m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) + { + std::string init_data = (m_config->option("wipe_tower_advanced"))->value; + std::cout << "dialog init: " << init_data << std::endl; + WipeTowerDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy + + if (dlg.ShowModal() == wxID_OK) { + load_key_value("wipe_tower_advanced", dlg.GetValue()); + std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl; + } + }));*/ + return sizer; + }; + optgroup->append_line(line); + page = add_options_page(_(L("Custom G-code")), "cog.png"); optgroup = page->new_optgroup(_(L("Start G-code")), 0); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 323749b0a9..1891a401c4 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -3,13 +3,8 @@ // Human-readable output of Parameters structure std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par) { - str << "bridging: " << par.bridging << "\n"; - str << "adhesion: " << par.adhesion << "\n"; str << "sampling: " << par.sampling << "\n"; - str << "cooling times: "; - for (const auto& a : par.cooling_time) str << a << " "; - str << "line widths: "; for (const auto& a : par.ramming_line_width_multiplicator) str << a << " "; @@ -116,30 +111,6 @@ void RammingPanel::line_parameters_changed() { - -CoolingPanel::CoolingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) -: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) -{ - new wxStaticText(this,wxID_ANY,wxString("Time (in seconds) reserved for cooling after unload:"),wxPoint(220,50) ,wxSize(400,25),wxALIGN_LEFT); - for (int i=0;i<4;++i) { - new wxStaticText(this,wxID_ANY,wxString("Filament #")<=m_widget_edits.size()) - break; // so we don't initialize non-existent widget - m_widget_edits[i]->SetValue(p.cooling_time[i]); - } -} - -void CoolingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { - p.cooling_time.clear(); - for (int i=0;i<4;++i) - p.cooling_time.push_back(m_widget_edits[i]->GetValue()); -} - - - WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) : wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) { @@ -208,20 +179,6 @@ void WipingPanel::fill_in_matrix() { -GeneralPanel::GeneralPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) : wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) { - new wxStaticText(this,wxID_ANY,wxString("Maximum bridging over sparse infill (mm):"),wxPoint(100,105) ,wxSize(280,25),wxALIGN_LEFT); - m_widget_bridge = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxPoint(380,100),wxSize(50,25),wxALIGN_RIGHT|wxSP_ARROW_KEYS,1,50,10); - m_widget_adhesion = new wxCheckBox(this,wxID_ANY,"Increased adhesion of first layer",wxPoint(100,150),wxSize(330,25),wxALIGN_RIGHT); - m_widget_bridge->SetValue(p.bridging); - m_widget_adhesion->SetValue(p.adhesion); -} - -void GeneralPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { - p.bridging = m_widget_bridge->GetValue(); - p.adhesion = m_widget_adhesion->GetValue(); -} - - @@ -238,13 +195,13 @@ WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data) wxNotebook* notebook = new wxNotebook(this,wxID_ANY,wxPoint(0,0),wxSize(800,450)); - m_panel_general = new GeneralPanel(notebook,parameters); + //m_panel_general = new GeneralPanel(notebook,parameters); m_panel_ramming = new RammingPanel(notebook,parameters); - m_panel_cooling = new CoolingPanel(notebook,parameters); + //m_panel_cooling = new CoolingPanel(notebook,parameters); m_panel_wiping = new WipingPanel(notebook,parameters); - notebook->AddPage(m_panel_general,"General"); + //notebook->AddPage(m_panel_general,"General"); notebook->AddPage(m_panel_ramming,"Ramming"); - notebook->AddPage(m_panel_cooling,"Cooling"); + //notebook->AddPage(m_panel_cooling,"Cooling"); notebook->AddPage(m_panel_wiping,"Wiping"); this->Show(); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index 452886bc36..8a1c88be81 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -40,23 +40,6 @@ private: - - - -class CoolingPanel : public wxPanel { -public: - CoolingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); - void fill_parameters(Slic3r::WipeTowerParameters& p); - -private: - std::vector m_widget_edits; -}; - - - - - - class WipingPanel : public wxPanel { public: WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); @@ -74,18 +57,6 @@ private: -class GeneralPanel : public wxPanel { -public: - GeneralPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); - void fill_parameters(Slic3r::WipeTowerParameters& p); - -private: - wxSpinCtrl* m_widget_bridge; - wxCheckBox* m_widget_adhesion; -}; - - - class WipeTowerDialog : public wxDialog { public: @@ -96,17 +67,13 @@ public: private: std::string m_file_name="config_wipe_tower"; - GeneralPanel* m_panel_general = nullptr; RammingPanel* m_panel_ramming = nullptr; - CoolingPanel* m_panel_cooling = nullptr; WipingPanel* m_panel_wiping = nullptr; std::string m_output_data = ""; std::string read_dialog_values() { Slic3r::WipeTowerParameters p; - m_panel_general->fill_parameters(p); m_panel_ramming->fill_parameters(p); - m_panel_cooling->fill_parameters(p); m_panel_wiping ->fill_parameters(p); return p.to_string(); } From 30c859ac7f8568ce6e102f7d511d6ec49898c5b7 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 12 Mar 2018 16:04:32 +0100 Subject: [PATCH 0039/1150] Added a lock icon to the list of filaments, added some helper methods to PresetBundle. --- xs/CMakeLists.txt | 2 + xs/src/slic3r/GUI/BitmapCache.cpp | 120 +++++++++++++++++++++++++++++ xs/src/slic3r/GUI/BitmapCache.hpp | 43 +++++++++++ xs/src/slic3r/GUI/Field.hpp | 4 +- xs/src/slic3r/GUI/Preset.cpp | 53 ++++++++++--- xs/src/slic3r/GUI/Preset.hpp | 19 ++++- xs/src/slic3r/GUI/PresetBundle.cpp | 83 ++++++++++---------- xs/src/slic3r/GUI/PresetBundle.hpp | 12 ++- 8 files changed, 277 insertions(+), 59 deletions(-) create mode 100644 xs/src/slic3r/GUI/BitmapCache.cpp create mode 100644 xs/src/slic3r/GUI/BitmapCache.hpp diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 590b5d24fa..d834b46082 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -171,6 +171,8 @@ add_library(libslic3r STATIC add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/AppConfig.cpp ${LIBDIR}/slic3r/GUI/AppConfig.hpp + ${LIBDIR}/slic3r/GUI/BitmapCache.cpp + ${LIBDIR}/slic3r/GUI/BitmapCache.hpp ${LIBDIR}/slic3r/GUI/3DScene.cpp ${LIBDIR}/slic3r/GUI/3DScene.hpp ${LIBDIR}/slic3r/GUI/GLShader.cpp diff --git a/xs/src/slic3r/GUI/BitmapCache.cpp b/xs/src/slic3r/GUI/BitmapCache.cpp new file mode 100644 index 0000000000..f92369650c --- /dev/null +++ b/xs/src/slic3r/GUI/BitmapCache.cpp @@ -0,0 +1,120 @@ +#include "BitmapCache.hpp" + +namespace Slic3r { namespace GUI { + +void BitmapCache::clear() +{ + for (std::pair &bitmap : m_map) + delete bitmap.second; +} + +wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height) +{ + wxBitmap *bitmap = nullptr; + auto it = m_map.find(bitmap_key); + if (it == m_map.end()) { + bitmap = new wxBitmap(width, height); + m_map[bitmap_key] = bitmap; + } else { + bitmap = it->second; + if (bitmap->GetWidth() != width || bitmap->GetHeight() != height) + bitmap->Create(width, height); + } +#if defined(__APPLE__) || defined(_MSC_VER) + bitmap->UseAlpha(); +#endif + return bitmap; +} + +wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp) +{ + wxBitmap *bitmap = this->insert(bitmap_key, bmp.GetWidth(), bmp.GetHeight()); + + wxMemoryDC memDC; + memDC.SelectObject(*bitmap); + memDC.SetBackground(*wxTRANSPARENT_BRUSH); + memDC.Clear(); + memDC.DrawBitmap(bmp, 0, 0, true); + memDC.SelectObject(wxNullBitmap); + + return bitmap; +} + +wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2) +{ + wxBitmap *bitmap = this->insert(bitmap_key, bmp.GetWidth() + bmp2.GetWidth(), std::max(bmp.GetHeight(), bmp2.GetHeight())); + + wxMemoryDC memDC; + memDC.SelectObject(*bitmap); + memDC.SetBackground(*wxTRANSPARENT_BRUSH); + memDC.Clear(); + if (bmp.GetWidth() > 0) + memDC.DrawBitmap(bmp, 0, 0, true); + if (bmp2.GetWidth() > 0) + memDC.DrawBitmap(bmp2, bmp.GetWidth(), 0, true); + memDC.SelectObject(wxNullBitmap); + + return bitmap; +} + +wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3) +{ + wxBitmap *bitmap = this->insert(bitmap_key, bmp.GetWidth() + bmp2.GetWidth() + bmp3.GetWidth(), std::max(std::max(bmp.GetHeight(), bmp2.GetHeight()), bmp3.GetHeight())); + + wxMemoryDC memDC; + memDC.SelectObject(*bitmap); + memDC.SetBackground(*wxTRANSPARENT_BRUSH); + memDC.Clear(); + if (bmp.GetWidth() > 0) + memDC.DrawBitmap(bmp, 0, 0, true); + if (bmp2.GetWidth() > 0) + memDC.DrawBitmap(bmp2, bmp.GetWidth(), 0, true); + if (bmp3.GetWidth() > 0) + memDC.DrawBitmap(bmp3, bmp.GetWidth() + bmp2.GetWidth(), 0, true); + memDC.SelectObject(wxNullBitmap); + + return bitmap; +} + +wxBitmap* BitmapCache::insert(const std::string &bitmap_key, std::vector &bmps) +{ + size_t width = 0; + size_t height = 0; + for (wxBitmap &bmp : bmps) { + width += bmp.GetWidth(); + height = std::max(height, bmp.GetHeight()); + } + wxBitmap *bitmap = this->insert(bitmap_key, width, height); + + wxMemoryDC memDC; + memDC.SelectObject(*bitmap); + memDC.SetBackground(*wxTRANSPARENT_BRUSH); + memDC.Clear(); + size_t x = 0; + for (wxBitmap &bmp : bmps) { + if (bmp.GetWidth() > 0) + memDC.DrawBitmap(bmp, x, 0, true); + x += bmp.GetWidth(); + } + memDC.SelectObject(wxNullBitmap); + + return bitmap; +} + +wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency) +{ + wxImage image(width, height); + image.InitAlpha(); + unsigned char* imgdata = image.GetData(); + unsigned char* imgalpha = image.GetAlpha(); + for (size_t i = 0; i < width * height; ++ i) { + *imgdata ++ = r; + *imgdata ++ = g; + *imgdata ++ = b; + *imgalpha ++ = transparency; + } + return wxBitmap(std::move(image)); +} + +} // namespace GUI +} // namespace Slic3r diff --git a/xs/src/slic3r/GUI/BitmapCache.hpp b/xs/src/slic3r/GUI/BitmapCache.hpp new file mode 100644 index 0000000000..0cf9d8acf0 --- /dev/null +++ b/xs/src/slic3r/GUI/BitmapCache.hpp @@ -0,0 +1,43 @@ +#ifndef SLIC3R_GUI_BITMAP_CACHE_HPP +#define SLIC3R_GUI_BITMAP_CACHE_HPP + +#include +#ifndef WX_PRECOMP + #include +#endif + +#include "../../libslic3r/libslic3r.h" +#include "../../libslic3r/Config.hpp" + +#include "GUI.hpp" + +namespace Slic3r { namespace GUI { + +class BitmapCache +{ +public: + BitmapCache() {} + ~BitmapCache() { clear(); } + void clear(); + + wxBitmap* find(const std::string &name) { auto it = m_map.find(name); return (it == m_map.end()) ? nullptr : it->second; } + const wxBitmap* find(const std::string &name) const { return const_cast(this)->find(name); } + + wxBitmap* insert(const std::string &name, size_t width, size_t height); + wxBitmap* insert(const std::string &name, const wxBitmap &bmp); + wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2); + wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3); + wxBitmap* insert(const std::string &name, std::vector &bmps); + + static wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency); + static wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3]) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE); } + static wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT); } + +private: + std::map m_map; +}; + +} // GUI +} // Slic3r + +#endif /* SLIC3R_GUI_BITMAP_CACHE_HPP */ diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 492629b411..9d4febe2e6 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -264,9 +264,7 @@ public: wxSizer* getSizer() override { return sizer; } }; - -#endif } // GUI } // Slic3r - +#endif /* SLIC3R_GUI_FIELD_HPP */ diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index d3d569cae9..a1706ba475 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -345,16 +345,33 @@ void PresetCollection::save_current_preset(const std::string &new_name) if (it != m_presets.end() && it->name == new_name) { // Preset with the same name found. Preset &preset = *it; - if (preset.is_default) + if (preset.is_default || preset.is_external || preset.is_system) // Cannot overwrite the default preset. return; // Overwriting an existing preset. preset.config = std::move(m_edited_preset.config); } else { // Creating a new preset. - Preset &preset = *m_presets.insert(it, m_edited_preset); + Preset &preset = *m_presets.insert(it, m_edited_preset); + std::string &inherits = preset.config.opt_string("inherits", true); + std::string old_name = preset.name; preset.name = new_name; preset.file = this->path_from_name(new_name); + preset.vendor = nullptr; + if (preset.is_system) { + // Inheriting from a system preset. + inherits = /* preset.vendor->name + "/" + */ old_name; + } else if (inherits.empty()) { + // Inheriting from a user preset. Link the new preset to the old preset. + inherits = old_name; + } else { + // Inherited from a user preset. Just maintain the "inherited" flag, + // meaning it will inherit from either the system preset, or the inherited user preset. + } + preset.inherits = inherits; + preset.is_default = false; + preset.is_system = false; + preset.is_external = false; } // 2) Activate the saved preset. this->select_preset_by_name(new_name, true); @@ -387,6 +404,15 @@ bool PresetCollection::load_bitmap_default(const std::string &file_name) return m_bitmap_main_frame->LoadFile(wxString::FromUTF8(Slic3r::var(file_name).c_str()), wxBITMAP_TYPE_PNG); } +const Preset* PresetCollection::get_selected_preset_parent() const +{ + auto *inherits = dynamic_cast(this->get_edited_preset().config.option("inherits")); + if (inherits == nullptr || inherits->value.empty()) + return nullptr; + const Preset* preset = this->find_preset(inherits->value, false); + return (preset == nullptr || preset->is_default || preset->is_external) ? nullptr : preset; +} + // Return a preset by its name. If the preset is active, a temporary copy is returned. // If a preset is not found by its name, null is returned. Preset* PresetCollection::find_preset(const std::string &name, bool first_visible_if_not_found) @@ -530,16 +556,19 @@ bool PresetCollection::update_dirty_ui(wxBitmapComboBox *ui) return was_dirty != is_dirty; } -std::vector PresetCollection::current_dirty_options() const -{ - std::vector changed = this->get_selected_preset().config.diff(this->get_edited_preset().config); - // The "compatible_printers" option key is handled differently from the others: - // It is not mandatory. If the key is missing, it means it is compatible with any printer. - // If the key exists and it is empty, it means it is compatible with no printer. - std::initializer_list optional_keys { "compatible_printers", "compatible_printers_condition" }; - for (auto &opt_key : optional_keys) { - if (this->get_selected_preset().config.has(opt_key) != this->get_edited_preset().config.has(opt_key)) - changed.emplace_back(opt_key); +std::vector PresetCollection::dirty_options(const Preset *edited, const Preset *reference) +{ + std::vector changed; + if (edited != nullptr && reference != nullptr) { + changed = reference->config.diff(edited->config); + // The "compatible_printers" option key is handled differently from the others: + // It is not mandatory. If the key is missing, it means it is compatible with any printer. + // If the key exists and it is empty, it means it is compatible with no printer. + std::initializer_list optional_keys { "compatible_printers", "compatible_printers_condition" }; + for (auto &opt_key : optional_keys) { + if (reference->config.has(opt_key) != edited->config.has(opt_key)) + changed.emplace_back(opt_key); + } } return changed; } diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index c56b91bcfe..a6ce77dfe0 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -191,6 +191,8 @@ public: // Compatible & incompatible marks, to be placed at the wxBitmapComboBox items. void set_bitmap_compatible (const wxBitmap *bmp) { m_bitmap_compatible = bmp; } void set_bitmap_incompatible(const wxBitmap *bmp) { m_bitmap_incompatible = bmp; } + void set_bitmap_lock (const wxBitmap *bmp) { m_bitmap_lock = bmp; } + void set_bitmap_lock_open (const wxBitmap *bmp) { m_bitmap_lock_open = bmp; } // Enable / disable the "- default -" preset. void set_default_suppressed(bool default_suppressed); @@ -202,6 +204,11 @@ public: Preset& get_selected_preset() { return m_presets[m_idx_selected]; } const Preset& get_selected_preset() const { return m_presets[m_idx_selected]; } int get_selected_idx() const { return m_idx_selected; } + // For the current edited preset, return the parent preset if there is one. + // If there is no parent preset, nullptr is returned. + // The parent preset may be a system preset or a user preset, which will be + // reflected by the UI. + const Preset* get_selected_preset_parent() const; // Return the selected preset including the user modifications. Preset& get_edited_preset() { return m_edited_preset; } const Preset& get_edited_preset() const { return m_edited_preset; } @@ -238,7 +245,11 @@ public: // Compare the content of get_selected_preset() with get_edited_preset() configs, return true if they differ. bool current_is_dirty() const { return ! this->current_dirty_options().empty(); } // Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ. - std::vector current_dirty_options() const; + std::vector current_dirty_options() const + { return dirty_options(&this->get_edited_preset(), &this->get_selected_preset()); } + // Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ. + std::vector current_different_from_parent_options() const + { return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent()); } // Update the choice UI from the list of presets. // If show_incompatible, all presets are shown, otherwise only the compatible presets are shown. @@ -278,6 +289,8 @@ private: std::deque::const_iterator find_preset_internal(const std::string &name) const { return const_cast(this)->find_preset_internal(name); } + static std::vector dirty_options(const Preset *edited, const Preset *reference); + // Type of this PresetCollection: TYPE_PRINT, TYPE_FILAMENT or TYPE_PRINTER. Preset::Type m_type; // List of presets, starting with the "- default -" preset. @@ -292,8 +305,10 @@ private: bool m_default_suppressed = true; // Compatible & incompatible marks, to be placed at the wxBitmapComboBox items of a Platter. // These bitmaps are not owned by PresetCollection, but by a PresetBundle. - const wxBitmap *m_bitmap_compatible = nullptr; + const wxBitmap *m_bitmap_compatible = nullptr; const wxBitmap *m_bitmap_incompatible = nullptr; + const wxBitmap *m_bitmap_lock = nullptr; + const wxBitmap *m_bitmap_lock_open = nullptr; // Marks placed at the wxBitmapComboBox of a MainFrame. // These bitmaps are owned by PresetCollection. wxBitmap *m_bitmap_main_frame; diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 77eb5c0814..453208fde4 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -2,6 +2,7 @@ #include #include "PresetBundle.hpp" +#include "BitmapCache.hpp" #include #include @@ -37,7 +38,10 @@ PresetBundle::PresetBundle() : filaments(Preset::TYPE_FILAMENT, Preset::filament_options()), printers(Preset::TYPE_PRINTER, Preset::printer_options()), m_bitmapCompatible(new wxBitmap), - m_bitmapIncompatible(new wxBitmap) + m_bitmapIncompatible(new wxBitmap), + m_bitmapLock(new wxBitmap), + m_bitmapLockOpen(new wxBitmap), + m_bitmapCache(new GUI::BitmapCache) { if (wxImage::FindHandler(wxBITMAP_TYPE_PNG) == nullptr) wxImage::AddHandler(new wxPNGHandler); @@ -70,12 +74,18 @@ PresetBundle::~PresetBundle() { assert(m_bitmapCompatible != nullptr); assert(m_bitmapIncompatible != nullptr); + assert(m_bitmapLock != nullptr); + assert(m_bitmapLockOpen != nullptr); delete m_bitmapCompatible; m_bitmapCompatible = nullptr; delete m_bitmapIncompatible; m_bitmapIncompatible = nullptr; - for (std::pair &bitmap : m_mapColorToBitmap) - delete bitmap.second; + delete m_bitmapLock; + m_bitmapLock = nullptr; + delete m_bitmapLockOpen; + m_bitmapLockOpen = nullptr; + delete m_bitmapCache; + m_bitmapCache = nullptr; } void PresetBundle::reset(bool delete_files) @@ -244,10 +254,16 @@ bool PresetBundle::load_compatible_bitmaps() { const std::string path_bitmap_compatible = "flag-green-icon.png"; const std::string path_bitmap_incompatible = "flag-red-icon.png"; + const std::string path_bitmap_lock = "lock.png"; + const std::string path_bitmap_lock_open = "lock_open.png"; bool loaded_compatible = m_bitmapCompatible ->LoadFile( wxString::FromUTF8(Slic3r::var(path_bitmap_compatible).c_str()), wxBITMAP_TYPE_PNG); bool loaded_incompatible = m_bitmapIncompatible->LoadFile( wxString::FromUTF8(Slic3r::var(path_bitmap_incompatible).c_str()), wxBITMAP_TYPE_PNG); + bool loaded_lock = m_bitmapLock->LoadFile( + wxString::FromUTF8(Slic3r::var(path_bitmap_lock).c_str()), wxBITMAP_TYPE_PNG); + bool loaded_lock_open = m_bitmapLockOpen->LoadFile( + wxString::FromUTF8(Slic3r::var(path_bitmap_lock_open).c_str()), wxBITMAP_TYPE_PNG); if (loaded_compatible) { prints .set_bitmap_compatible(m_bitmapCompatible); filaments.set_bitmap_compatible(m_bitmapCompatible); @@ -258,7 +274,17 @@ bool PresetBundle::load_compatible_bitmaps() filaments.set_bitmap_incompatible(m_bitmapIncompatible); // printers .set_bitmap_incompatible(m_bitmapIncompatible); } - return loaded_compatible && loaded_incompatible; + if (loaded_lock) { + prints .set_bitmap_lock(m_bitmapLock); + filaments.set_bitmap_lock(m_bitmapLock); + printers .set_bitmap_lock(m_bitmapLock); + } + if (loaded_lock_open) { + prints .set_bitmap_lock_open(m_bitmapLock); + filaments.set_bitmap_lock_open(m_bitmapLock); + printers .set_bitmap_lock_open(m_bitmapLock); + } + return loaded_compatible && loaded_incompatible && loaded_lock && loaded_lock_open; } DynamicPrintConfig PresetBundle::full_config() const @@ -973,49 +999,26 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma // If the filament preset is not compatible and there is a "red flag" icon loaded, show it left // to the filament color image. if (wide_icons) - bitmap_key += preset.is_compatible ? "comp" : "notcomp"; - auto it = m_mapColorToBitmap.find(bitmap_key); - wxBitmap *bitmap = (it == m_mapColorToBitmap.end()) ? nullptr : it->second; + bitmap_key += preset.is_compatible ? ",cmpt" : ",ncmpt"; + bitmap_key += (preset.is_system || preset.is_default) ? ",syst" : ",nsyst"; + wxBitmap *bitmap = m_bitmapCache->find(bitmap_key); if (bitmap == nullptr) { // Create the bitmap with color bars. - bitmap = new wxBitmap((wide_icons ? 16 : 0) + 24, 16); -#if defined(__APPLE__) || defined(_MSC_VER) - bitmap->UseAlpha(); -#endif - wxMemoryDC memDC; - memDC.SelectObject(*bitmap); - memDC.SetBackground(*wxTRANSPARENT_BRUSH); - memDC.Clear(); - if (wide_icons && ! preset.is_compatible) - // Paint the red flag. - memDC.DrawBitmap(*m_bitmapIncompatible, 0, 0, true); + std::vector bmps; + if (wide_icons) + // Paint a red flag for incompatible presets. + bmps.emplace_back(preset.is_compatible ? m_bitmapCache->mkclear(16, 16) : *m_bitmapIncompatible); // Paint the color bars. parse_color(filament_rgb, rgb); - wxImage image(24, 16); - image.InitAlpha(); - unsigned char* imgdata = image.GetData(); - unsigned char* imgalpha = image.GetAlpha(); - for (size_t i = 0; i < image.GetWidth() * image.GetHeight(); ++ i) { - *imgdata ++ = rgb[0]; - *imgdata ++ = rgb[1]; - *imgdata ++ = rgb[2]; - *imgalpha ++ = wxALPHA_OPAQUE; - } + bmps.emplace_back(m_bitmapCache->mksolid(single_bar ? 24 : 16, 16, rgb)); if (! single_bar) { parse_color(extruder_rgb, rgb); - imgdata = image.GetData(); - for (size_t r = 0; r < 16; ++ r) { - imgdata = image.GetData() + r * image.GetWidth() * 3; - for (size_t c = 0; c < 16; ++ c) { - *imgdata ++ = rgb[0]; - *imgdata ++ = rgb[1]; - *imgdata ++ = rgb[2]; - } - } + bmps.emplace_back(m_bitmapCache->mksolid(8, 16, rgb)); } - memDC.DrawBitmap(wxBitmap(image), wide_icons ? 16 : 0, 0, true); - memDC.SelectObject(wxNullBitmap); - m_mapColorToBitmap[bitmap_key] = bitmap; + // Paint a lock at the system presets. + bmps.emplace_back(m_bitmapCache->mkclear(4, 16)); + bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmapLock : m_bitmapCache->mkclear(16, 16)); + bitmap = m_bitmapCache->insert(bitmap_key, bmps); } ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), (bitmap == 0) ? wxNullBitmap : *bitmap); if (selected) diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index aaa66265aa..f481ba374f 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -8,6 +8,10 @@ namespace Slic3r { +namespace GUI { + class BitmapCache; +}; + class PlaceholderParser; // Bundle of Print + Filament + Printer presets. @@ -131,8 +135,12 @@ private: wxBitmap *m_bitmapCompatible; // Indicator, that the preset is NOT compatible with the selected printer. wxBitmap *m_bitmapIncompatible; - // Caching color bitmaps for the - std::map m_mapColorToBitmap; + // Indicator, that the preset is system and not modified. + wxBitmap *m_bitmapLock; + // Indicator, that the preset is system and user modified. + wxBitmap *m_bitmapLockOpen; + // Caching color bitmaps for the filament combo box. + GUI::BitmapCache *m_bitmapCache; }; } // namespace Slic3r From 729d879b0e80c0e0f2927b31aa308db83cdc4c91 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 13 Mar 2018 09:45:04 +0100 Subject: [PATCH 0040/1150] Added the Prusa's vendor specific Config Bundle. Added the "unlocked lock" icon when the system profile gets modified. --- resources/profiles/PrusaResearch.ini | 1026 ++++++++++++++++++++++++++ xs/src/slic3r/GUI/Preset.cpp | 9 +- xs/src/slic3r/GUI/PresetBundle.cpp | 5 +- 3 files changed, 1036 insertions(+), 4 deletions(-) create mode 100644 resources/profiles/PrusaResearch.ini diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini new file mode 100644 index 0000000000..444203e2eb --- /dev/null +++ b/resources/profiles/PrusaResearch.ini @@ -0,0 +1,1026 @@ +# Print profiles for the Prusa Research printers. + +[vendor] +# Vendor name will be shown by the Config Wizard. +name = Prusa Research +# Configuration version of this file. Config file will only be installed, if the config_version differs. +# This means, the server may force the Slic3r configuration to be downgraded. +config_version = 0.1 +# Where to get the updates from? +config_update_url = https://raw.githubusercontent.com/prusa3d/Slic3r-settings/master/live/PrusaResearch.ini + +# The printer models will be shown by the Configuration Wizard in this order, +# also the first model installed & the first nozzle installed will be activated after install. +#TODO: One day we may differentiate variants of the nozzles / hot ends, +#for example by the melt zone size, or whether the nozzle is hardened. +[printer_model:MK3] +variants = 0.4; 0.25; 0.6 + +[printer_model:MK2S] +variants = 0.4; 0.25; 0.6 + +[printer_model:MK2SMM] +# Printer model name will be shown by the installation wizard. +name = MK2S Multi Material +variants = 0.4; 0.6 + +# All presets starting with asterisk, for example *common*, are intermediate and they will +# not make it into the user interface. + +# Common print preset, mostly derived from MK2 single material with a 0.4mm nozzle. +# All other print presets will derive from the *common* print preset. +[print:*common*] +avoid_crossing_perimeters = 0 +bridge_acceleration = 1000 +bridge_angle = 0 +bridge_flow_ratio = 0.8 +bridge_speed = 20 +brim_width = 0 +clip_multipart_objects = 1 +compatible_printers = +complete_objects = 0 +default_acceleration = 1000 +dont_support_bridges = 1 +elefant_foot_compensation = 0 +ensure_vertical_shell_thickness = 1 +external_fill_pattern = rectilinear +external_perimeters_first = 0 +external_perimeter_extrusion_width = 0.45 +extra_perimeters = 0 +extruder_clearance_height = 20 +extruder_clearance_radius = 20 +extrusion_width = 0.45 +fill_angle = 45 +fill_density = 20% +fill_pattern = cubic +first_layer_acceleration = 1000 +first_layer_extrusion_width = 0.42 +first_layer_height = 0.2 +first_layer_speed = 30 +gap_fill_speed = 40 +gcode_comments = 0 +infill_every_layers = 1 +infill_extruder = 1 +infill_extrusion_width = 0.45 +infill_first = 0 +infill_only_where_needed = 0 +infill_overlap = 25% +interface_shells = 0 +max_print_speed = 100 +max_volumetric_extrusion_rate_slope_negative = 0 +max_volumetric_extrusion_rate_slope_positive = 0 +max_volumetric_speed = 0 +min_skirt_length = 4 +notes = +overhangs = 0 +only_retract_when_crossing_perimeters = 0 +ooze_prevention = 0 +output_filename_format = [input_filename_base].gcode +perimeter_extruder = 1 +perimeter_extrusion_width = 0.45 +post_process = +print_settings_id = +raft_layers = 0 +resolution = 0 +seam_position = nearest +skirts = 1 +skirt_distance = 2 +skirt_height = 3 +small_perimeter_speed = 20 +solid_infill_below_area = 0 +solid_infill_every_layers = 0 +solid_infill_extruder = 1 +solid_infill_extrusion_width = 0.45 +spiral_vase = 0 +standby_temperature_delta = -5 +support_material = 0 +support_material_extruder = 0 +support_material_extrusion_width = 0.35 +support_material_interface_extruder = 0 +support_material_angle = 0 +support_material_buildplate_only = 0 +support_material_enforce_layers = 0 +support_material_interface_contact_loops = 0 +support_material_interface_layers = 2 +support_material_interface_speed = 100% +support_material_pattern = rectilinear +support_material_speed = 50 +support_material_synchronize_layers = 0 +support_material_threshold = 45 +support_material_with_sheath = 0 +support_material_xy_spacing = 60% +thin_walls = 0 +top_infill_extrusion_width = 0.45 +top_solid_infill_speed = 40 +travel_speed = 180 +wipe_tower = 0 +wipe_tower_per_color_wipe = 15 +wipe_tower_width = 60 +wipe_tower_x = 180 +wipe_tower_y = 140 +xy_size_compensation = 0 + +# Print parameters common to a 0.25mm diameter nozzle. +[print:*0.25nozzle*] +external_perimeter_extrusion_width = 0.25 +extrusion_width = 0.25 +first_layer_extrusion_width = 0.25 +infill_extrusion_width = 0.25 +perimeter_extrusion_width = 0.25 +solid_infill_extrusion_width = 0.25 +top_infill_extrusion_width = 0.25 +support_material_extrusion_width = 0.18 +support_material_interface_layers = 0 +support_material_interface_spacing = 0.15 +support_material_spacing = 1 +support_material_xy_spacing = 150% + +# Print parameters common to a 0.6mm diameter nozzle. +[print:*0.6nozzle*] +external_perimeter_extrusion_width = 0.61 +extrusion_width = 0.67 +first_layer_extrusion_width = 0.65 +infill_extrusion_width = 0.75 +perimeter_extrusion_width = 0.65 +solid_infill_extrusion_width = 0.65 +top_infill_extrusion_width = 0.6 + +[print:*0.05mm*] +inherits = *common* +bottom_solid_layers = 10 +bridge_acceleration = 300 +bridge_flow_ratio = 0.7 +default_acceleration = 500 +external_perimeter_speed = 20 +fill_density = 25% +first_layer_acceleration = 500 +gap_fill_speed = 20 +infill_acceleration = 800 +infill_speed = 30 +max_print_speed = 80 +small_perimeter_speed = 15 +solid_infill_speed = 30 +support_material_extrusion_width = 0.3 +support_material_interface_spacing = 0.2 +support_material_spacing = 1.5 +layer_height = 0.05 +perimeter_acceleration = 300 +perimeter_speed = 30 +perimeters = 3 +support_material_contact_distance = 0.15 +support_material_speed = 30 +top_solid_infill_speed = 20 +top_solid_layers = 15 + +[print:0.05mm DETAIL] +inherits = *0.05mm* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 +infill_extrusion_width = 0.5 + +[print:0.05mm DETAIL MK3] +inherits = *0.05mm* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ +fill_pattern = grid +top_infill_extrusion_width = 0.4 + +[print:0.05mm DETAIL 0.25 nozzle] +inherits = *0.05mm*; *0.25nozzle* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 and num_extruders==1 +external_perimeter_extrusion_width = 0 +extrusion_width = 0.28 +fill_density = 20% +first_layer_extrusion_width = 0.3 +infill_extrusion_width = 0 +infill_speed = 20 +max_print_speed = 100 +perimeter_extrusion_width = 0 +perimeter_speed = 20 +perimeters = 4 +small_perimeter_speed = 10 +solid_infill_extrusion_width = 0 +solid_infill_speed = 20 +support_material_speed = 20 +top_infill_extrusion_width = 0 + +[print:*0.10mm*] +inherits = *common* +bottom_solid_layers = 7 +bridge_flow_ratio = 0.7 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 +layer_height = 0.1 +perimeter_acceleration = 800 +support_material_contact_distance = 0.15 +support_material_interface_spacing = 0.2 +support_material_spacing = 2 +top_solid_layers = 9 + +[print:0.10mm DETAIL] +inherits = *0.10mm* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1 +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +perimeter_speed = 50 +perimeters = 3 +solid_infill_speed = 50 + +[print:0.10mm DETAIL MK3] +inherits = *0.10mm* +bridge_flow_ratio = 0.8 +bridge_speed = 30 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +perimeters = 2 +solid_infill_speed = 170 +top_infill_extrusion_width = 0.4 +top_solid_infill_speed = 50 + +[print:0.10mm DETAIL 0.25 nozzle] +inherits = *0.10mm*; *0.25nozzle* +bridge_acceleration = 600 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 +external_perimeter_speed = 20 +fill_density = 15% +infill_acceleration = 1600 +infill_speed = 40 +perimeter_acceleration = 600 +perimeter_speed = 25 +perimeters = 4 +small_perimeter_speed = 10 +solid_infill_speed = 40 +top_solid_infill_speed = 30 + +[print:*0.15mm*] +inherits = *common* +bottom_solid_layers = 5 +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +layer_height = 0.15 +perimeter_acceleration = 800 +perimeter_speed = 50 +perimeters = 3 +solid_infill_speed = 50 +support_material_contact_distance = 0.15 +support_material_interface_spacing = 0.2 +support_material_spacing = 2 +top_infill_extrusion_width = 0.4 +top_solid_layers = 7 + +[print:0.15mm 100mms Linear Advance] +inherits = *0.15mm* +bottom_solid_layers = 4 +bridge_flow_ratio = 0.95 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 +external_perimeter_speed = 50 +infill_speed = 100 +max_print_speed = 150 +perimeter_speed = 60 +perimeters = 2 +small_perimeter_speed = 30 +solid_infill_speed = 100 +support_material_speed = 60 +top_solid_infill_speed = 70 +top_solid_layers = 5 + +[print:0.15mm OPTIMAL] +inherits = *0.15mm* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 +top_infill_extrusion_width = 0.45 + +[print:0.15mm OPTIMAL 0.25 nozzle] +inherits = *0.15mm*; *0.25nozzle* +bridge_acceleration = 600 +bridge_flow_ratio = 0.7 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 +external_perimeter_speed = 20 +infill_acceleration = 1600 +infill_speed = 40 +perimeter_acceleration = 600 +perimeter_speed = 25 +perimeters = 2 +small_perimeter_speed = 10 +solid_infill_speed = 40 +support_material_extrusion_width = 0.2 +support_material_threshold = 35 +top_solid_infill_speed = 30 + +[print:0.15mm OPTIMAL 0.6 nozzle] +inherits = *0.15mm*; *0.6nozzle* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 +wipe_tower = 1 + +[print:0.15mm OPTIMAL MK3] +inherits = *0.15mm* +bridge_speed = 30 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +perimeters = 2 +solid_infill_speed = 170 +top_solid_infill_speed = 50 +wipe_tower = 1 + +[print:0.15mm OPTIMAL SOLUBLE FULL] +inherits = *0.15mm* +bottom_solid_layers = 5 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 +external_perimeter_speed = 25 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder +overhangs = 1 +perimeter_speed = 40 +skirts = 0 +solid_infill_speed = 40 +support_material = 1 +support_material_contact_distance = 0 +support_material_extruder = 4 +support_material_extrusion_width = 0.45 +support_material_interface_extruder = 4 +support_material_interface_spacing = 0.1 +support_material_synchronize_layers = 1 +support_material_threshold = 80 +support_material_with_sheath = 1 +support_material_xy_spacing = 60% +top_infill_extrusion_width = 0.45 +top_solid_infill_speed = 30 +wipe_tower = 1 +wipe_tower_per_color_wipe = 20 + +[print:0.15mm OPTIMAL SOLUBLE INTERFACE] +inherits = 0.15mm OPTIMAL SOLUBLE FULL +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +support_material_extruder = 0 +support_material_interface_layers = 3 +support_material_with_sheath = 0 +support_material_xy_spacing = 120% + +[print:*0.20mm*] +inherits = *common* +bottom_solid_layers = 4 +bridge_flow_ratio = 0.95 +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +layer_height = 0.2 +perimeter_acceleration = 800 +perimeter_speed = 50 +perimeters = 2 +solid_infill_speed = 50 +support_material_contact_distance = 0.15 +support_material_interface_spacing = 0.2 +support_material_spacing = 2 +top_infill_extrusion_width = 0.4 +top_solid_layers = 5 +wipe_tower = 1 + +[print:0.20mm 100mms Linear Advance] +inherits = *0.20mm* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 +external_perimeter_speed = 50 +infill_speed = 100 +max_print_speed = 150 +perimeter_speed = 60 +small_perimeter_speed = 30 +solid_infill_speed = 100 +support_material_speed = 60 +top_solid_infill_speed = 70 + +[print:0.20mm FAST MK3] +inherits = *0.20mm* +bridge_speed = 30 +bridge_flow_ratio = 0.8 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:0.20mm NORMAL] +inherits = *0.20mm* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 + +[print:0.20mm NORMAL 0.6 nozzle] +inherits = *0.20mm*; *0.6nozzle* +bridge_flow_ratio = 0.8 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 +perimeters = 3 + +[print:0.20mm NORMAL SOLUBLE FULL] +inherits = *0.20mm* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1 +external_perimeter_speed = 30 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder +overhangs = 1 +perimeter_speed = 40 +skirts = 0 +solid_infill_speed = 40 +support_material = 1 +support_material_contact_distance = 0 +support_material_extruder = 4 +support_material_extrusion_width = 0.45 +support_material_interface_extruder = 4 +support_material_interface_spacing = 0.1 +support_material_synchronize_layers = 1 +support_material_threshold = 80 +support_material_with_sheath = 1 +support_material_xy_spacing = 120% +top_solid_infill_speed = 30 +wipe_tower_per_color_wipe = 20 + +[print:0.20mm NORMAL SOLUBLE INTERFACE] +inherits = 0.20mm NORMAL SOLUBLE FULL +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +support_material_extruder = 0 +support_material_interface_layers = 3 +support_material_with_sheath = 0 + +[print:*0.35mm*] +inherits = *common* +bottom_solid_layers = 3 +external_perimeter_extrusion_width = 0.6 +external_perimeter_speed = 40 +first_layer_extrusion_width = 0.75 +infill_acceleration = 2000 +infill_extrusion_width = 0.75 +infill_speed = 60 +layer_height = 0.35 +perimeter_acceleration = 800 +perimeter_extrusion_width = 0.65 +perimeter_speed = 50 +perimeters = 2 +solid_infill_extrusion_width = 0.65 +solid_infill_speed = 60 +support_material_contact_distance = 0.15 +support_material_interface_spacing = 0.2 +support_material_spacing = 2 +top_solid_infill_speed = 50 +top_solid_layers = 4 +wipe_tower = 1 + +[print:0.35mm FAST] +inherits = *0.35mm* +bridge_flow_ratio = 0.95 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 +first_layer_extrusion_width = 0.42 +infill_extrusion_width = 0.7 +perimeter_extrusion_width = 0.43 +solid_infill_extrusion_width = 0.7 +top_infill_extrusion_width = 0.43 + +[print:0.35mm FAST 0.6 nozzle] +inherits = *0.35mm*; *0.6nozzle* +bottom_solid_layers = 7 +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 +perimeters = 3 +top_solid_layers = 9 + +[print:0.35mm FAST sol full 0.6 nozzle] +inherits = *0.35mm*; *0.6nozzle* +compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1 +external_perimeter_extrusion_width = 0.6 +external_perimeter_speed = 30 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +overhangs = 1 +perimeter_speed = 40 +skirts = 0 +support_material = 1 +support_material_contact_distance = 0 +support_material_extruder = 4 +support_material_extrusion_width = 0.55 +support_material_interface_extruder = 4 +support_material_interface_layers = 3 +support_material_synchronize_layers = 1 +support_material_threshold = 80 +support_material_xy_spacing = 120% +top_infill_extrusion_width = 0.57 +wipe_tower_per_color_wipe = 20 + +[print:0.35mm FAST sol int 0.6 nozzle] +inherits = 0.35mm FAST sol full 0.6 nozzle +support_material_extruder = 0 +support_material_interface_layers = 2 +support_material_xy_spacing = 150% + +[filament:*common*] +cooling = 1 +compatible_printers = +compatible_printers_condition = +end_filament_gcode = "; Filament-specific end gcode" +extrusion_multiplier = 1 +filament_cost = 0 +filament_density = 0 +filament_diameter = 1.75 +filament_settings_id = +filament_soluble = 0 +min_print_speed = 5 +slowdown_below_layer_time = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" + +[filament:*PLA*] +inherits = *common* +bed_temperature = 60 +bridge_fan_speed = 100 +disable_fan_first_layers = 1 +fan_always_on = 1 +fan_below_layer_time = 100 +filament_colour = #FF3232 +filament_max_volumetric_speed = 15 +filament_type = PLA +first_layer_bed_temperature = 60 +first_layer_temperature = 215 +max_fan_speed = 100 +min_fan_speed = 100 +temperature = 210 + +[filament:*PET*] +inherits = *common* +bed_temperature = 90 +bridge_fan_speed = 50 +disable_fan_first_layers = 3 +fan_always_on = 1 +fan_below_layer_time = 20 +filament_colour = #FF8000 +filament_max_volumetric_speed = 10 +filament_type = PET +first_layer_bed_temperature = 85 +first_layer_temperature = 230 +max_fan_speed = 50 +min_fan_speed = 30 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" +temperature = 240 + +[filament:*ABS*] +inherits = *common* +bed_temperature = 100 +bridge_fan_speed = 30 +cooling = 0 +disable_fan_first_layers = 3 +fan_always_on = 0 +fan_below_layer_time = 20 +filament_colour = #3A80CA +filament_max_volumetric_speed = 13 +filament_type = ABS +first_layer_bed_temperature = 100 +first_layer_temperature = 255 +max_fan_speed = 30 +min_fan_speed = 10 +temperature = 255 + +[filament:*FLEX*] +inherits = *common* +bridge_fan_speed = 100 +compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1 +cooling = 0 +disable_fan_first_layers = 1 +extrusion_multiplier = 1.2 +fan_always_on = 0 +fan_below_layer_time = 100 +filament_max_volumetric_speed = 1.5 +filament_type = FLEX +first_layer_bed_temperature = 50 +first_layer_temperature = 240 +max_fan_speed = 90 +min_fan_speed = 70 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 240 + +[filament:ColorFabb Brass Bronze] +inherits = *PLA* +compatible_printers_condition = nozzle_diameter[0]>0.35 +extrusion_multiplier = 1.3 +filament_colour = #804040 +filament_max_volumetric_speed = 10 +min_print_speed = 5 + +[filament:ColorFabb HT] +bed_temperature = 105 +bridge_fan_speed = 30 +compatible_printers = +compatible_printers_condition = +cooling = 1 +disable_fan_first_layers = 3 +end_filament_gcode = "; Filament-specific end gcode" +extrusion_multiplier = 1 +fan_always_on = 0 +fan_below_layer_time = 10 +filament_colour = #FF8000 +filament_cost = 0 +filament_density = 0 +filament_diameter = 1.75 +filament_max_volumetric_speed = 10 +filament_notes = "" +filament_settings_id = +filament_soluble = 0 +filament_type = PLA +first_layer_bed_temperature = 105 +first_layer_temperature = 270 +max_fan_speed = 20 +min_fan_speed = 10 +min_print_speed = 5 +slowdown_below_layer_time = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" +temperature = 270 + +[filament:ColorFabb PLA-PHA] +inherits = *PLA* +filament_colour = #FF3232 + +[filament:ColorFabb Woodfil] +inherits = *PLA* +compatible_printers_condition = nozzle_diameter[0]>0.35 +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 10 +first_layer_temperature = 200 +min_print_speed = 5 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 200 + +[filament:ColorFabb XT] +inherits = *PET* +filament_colour = #FF8000 +filament_type = PLA +first_layer_bed_temperature = 90 +first_layer_temperature = 260 +temperature = 270 + +[filament:ColorFabb XT-CF20] +inherits = *PET* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 1 +first_layer_bed_temperature = 90 +first_layer_temperature = 260 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" +temperature = 260 + +[filament:ColorFabb nGen] +inherits = *PET* +bridge_fan_speed = 40 +fan_always_on = 0 +fan_below_layer_time = 10 +filament_colour = #FF8000 +filament_type = NGEN +first_layer_temperature = 240 +max_fan_speed = 35 +min_fan_speed = 20 + +[filament:ColorFabb nGen flex] +inherits = *flex* +bed_temperature = 85 +bridge_fan_speed = 40 +cooling = 1 +disable_fan_first_layers = 3 +extrusion_multiplier = 1 +fan_below_layer_time = 10 +filament_colour = #FF8000 +filament_max_volumetric_speed = 5 +first_layer_bed_temperature = 85 +first_layer_temperature = 260 +max_fan_speed = 35 +min_fan_speed = 20 +temperature = 260 + +[filament:E3D Edge] +inherits = *PET* +filament_colour = #FF8000 +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:E3D PC-ABS] +inherits = *ABS* +filament_colour = #3A80CA +first_layer_temperature = 270 +temperature = 270 + +[filament:Fillamentum ABS] +inherits = *ABS* +filament_colour = #3A80CA +first_layer_temperature = 240 +temperature = 240 + +[filament:Fillamentum ASA] +fan_always_on = 1 +filament_colour = #3A80CA +first_layer_temperature = 265 +temperature = 265 + +[filament:Fillamentum CPE HG100 HM100] +inherits = *PET* +disable_fan_first_layers = 1 +filament_colour = #FF8000 +filament_notes = "CPE HG100 , CPE HM100" +first_layer_bed_temperature = 90 +first_layer_temperature = 275 +max_fan_speed = 50 +min_fan_speed = 50 +temperature = 275 + +[filament:Fillamentum Timberfil] +inherits = *PLA* +compatible_printers_condition = nozzle_diameter[0]>0.35 +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 10 +first_layer_temperature = 190 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 190 + +[filament:Generic ABS] +inherits = *ABS* +filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" + +[filament:Generic PET] +inherits = *PET* +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:Generic PLA] +inherits = *PLA* +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" + +[filament:Polymaker PC-Max] +inherits = *ABS* +bed_temperature = 120 +filament_colour = #3A80CA +first_layer_bed_temperature = 120 +first_layer_temperature = 270 +temperature = 270 + +[filament:Primavalue PVA] +inherits = *PLA* +cooling = 0 +fan_always_on = 0 +filament_colour = #FFFFD7 +filament_max_volumetric_speed = 10 +filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH" +filament_soluble = 1 +filament_type = PVA +first_layer_temperature = 195 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 195 + +[filament:Prusa ABS] +inherits = *ABS* +filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" + +[filament:Prusa HIPS] +inherits = *ABS* +bridge_fan_speed = 50 +cooling = 1 +extrusion_multiplier = 0.9 +fan_always_on = 1 +fan_below_layer_time = 10 +filament_colour = #FFFFD7 +filament_soluble = 1 +filament_type = HIPS +first_layer_temperature = 220 +max_fan_speed = 20 +min_fan_speed = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 220 + +[filament:Prusa PET] +inherits = *PET* +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:Prusa PLA] +inherits = *PLA* +filament_colour = #FF3232 +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" + +[filament:SemiFlex or Flexfill 98A] +inherits = *flex* + +[filament:Taulman Bridge] +bed_temperature = 50 +bridge_fan_speed = 40 +compatible_printers = +compatible_printers_condition = +cooling = 0 +disable_fan_first_layers = 3 +end_filament_gcode = "; Filament-specific end gcode" +extrusion_multiplier = 1 +fan_always_on = 0 +fan_below_layer_time = 20 +filament_colour = #DEE0E6 +filament_cost = 0 +filament_density = 0 +filament_diameter = 1.75 +filament_max_volumetric_speed = 10 +filament_notes = "" +filament_settings_id = +filament_soluble = 0 +filament_type = PLA +first_layer_bed_temperature = 90 +first_layer_temperature = 240 +max_fan_speed = 5 +min_fan_speed = 0 +min_print_speed = 5 +slowdown_below_layer_time = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 250 + +[filament:Taulman T-Glase] +inherits = *PET* +bridge_fan_speed = 40 +cooling = 0 +fan_always_on = 0 +filament_colour = #FF8000 +first_layer_bed_temperature = 90 +first_layer_temperature = 240 +max_fan_speed = 5 +min_fan_speed = 0 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" + +[filament:Verbatim BVOH] +bed_temperature = 60 +bridge_fan_speed = 100 +compatible_printers = +compatible_printers_condition = +cooling = 0 +disable_fan_first_layers = 1 +end_filament_gcode = "; Filament-specific end gcode" +extrusion_multiplier = 1 +fan_always_on = 0 +fan_below_layer_time = 100 +filament_colour = #FFFFD7 +filament_cost = 0 +filament_density = 0 +filament_diameter = 1.75 +filament_max_volumetric_speed = 10 +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" +filament_settings_id = +filament_soluble = 1 +filament_type = PLA +first_layer_bed_temperature = 60 +first_layer_temperature = 215 +max_fan_speed = 100 +min_fan_speed = 100 +min_print_speed = 15 +slowdown_below_layer_time = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 210 + +[filament:Verbatim PP] +bed_temperature = 100 +bridge_fan_speed = 100 +compatible_printers = +compatible_printers_condition = +cooling = 1 +disable_fan_first_layers = 2 +end_filament_gcode = "; Filament-specific end gcode" +extrusion_multiplier = 1 +fan_always_on = 1 +fan_below_layer_time = 100 +filament_colour = #DEE0E6 +filament_cost = 0 +filament_density = 0 +filament_diameter = 1.75 +filament_max_volumetric_speed = 5 +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA" +filament_settings_id = +filament_soluble = 0 +filament_type = PLA +first_layer_bed_temperature = 100 +first_layer_temperature = 220 +max_fan_speed = 100 +min_fan_speed = 100 +min_print_speed = 15 +slowdown_below_layer_time = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 220 + +[printer:*common*] +bed_shape = 0x0,250x0,250x210,0x210 +before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n +between_objects_gcode = +deretract_speed = 0 +end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +extruder_colour = #FFFF00 +extruder_offset = 0x0 +gcode_flavor = marlin +layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] +max_layer_height = 0.25 +min_layer_height = 0.07 +nozzle_diameter = 0.4 +octoprint_apikey = +octoprint_host = +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n +printer_settings_id = +retract_before_travel = 1 +retract_before_wipe = 0% +retract_layer_change = 1 +retract_length = 0.8 +retract_length_toolchange = 3 +retract_lift = 0.6 +retract_lift_above = 0 +retract_lift_below = 199 +retract_restart_extra = 0 +retract_restart_extra_toolchange = 0 +retract_speed = 35 +serial_port = +serial_speed = 250000 +single_extruder_multi_material = 0 +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0 +toolchange_gcode = +use_firmware_retraction = 0 +use_relative_e_distances = 1 +use_volumetric_e = 0 +variable_layer_height = 1 +wipe = 1 +z_offset = 0 +printer_model = MK2S +printer_variant = 0.4 +default_print_profile = 0.15mm OPTIMAL +default_filament_profile = Prusa PLA + +[printer:*multimaterial*] +inherits = *common* +deretract_speed = 50 +retract_before_travel = 3 +retract_before_wipe = 60% +retract_layer_change = 0 +retract_length = 4 +retract_length_toolchange = 4 +retract_lift = 0.6 +retract_lift_above = 0 +retract_lift_below = 199 +retract_restart_extra = 0 +retract_restart_extra_toolchange = 0 +retract_speed = 80 +single_extruder_multi_material = 1 +printer_model = MK2SMM + +[printer:*mm-single*] +inherits = *multimaterial* +end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 + +[printer:*mm-multi*] +inherits = *multimaterial* +end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors +extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259 +nozzle_diameter = 0.4,0.4,0.4,0.4 +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 +variable_layer_height = 0 + +[printer:Original Prusa i3 MK2] +inherits = *common* + +[printer:Original Prusa i3 MK2 0.25 nozzle] +inherits = *common* +max_layer_height = 0.1 +min_layer_height = 0.05 +nozzle_diameter = 0.25 +retract_length = 1 +retract_speed = 50 +variable_layer_height = 0 +printer_variant = 0.25 +default_print_profile = 0.10mm DETAIL 0.25 nozzle + +[printer:Original Prusa i3 MK2 0.6 nozzle] +inherits = *common* +max_layer_height = 0.35 +min_layer_height = 0.1 +nozzle_diameter = 0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK2 MM Single Mode] +inherits = *mm-single* + +[printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle] +inherits = *mm-single* +nozzle_diameter = 0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK2 MultiMaterial] +inherits = *mm-multi* +nozzle_diameter = 0.4,0.4,0.4,0.4 + +[printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle] +inherits = *mm-multi* +nozzle_diameter = 0.6,0.6,0.6,0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK3] +inherits = *common* +end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +retract_lift_below = 209 +start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} +printer_model = MK3 +default_print_profile = 0.15mm OPTIMAL MK3 diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index a1706ba475..0796a0f4ae 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -226,13 +226,15 @@ const std::vector& Preset::printer_options() "bed_shape", "z_offset", "gcode_flavor", "use_relative_e_distances", "serial_port", "serial_speed", "octoprint_host", "octoprint_apikey", "octoprint_cafile", "use_firmware_retraction", "use_volumetric_e", "variable_layer_height", "single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode", - "between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "default_print_profile", "default_filament_profile", "inherits", + "between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "default_print_profile", "inherits", }; s_opts.insert(s_opts.end(), Preset::nozzle_options().begin(), Preset::nozzle_options().end()); } return s_opts; } +// The following nozzle options of a printer profile will be adjusted to match the size +// of the nozzle_diameter vector. const std::vector& Preset::nozzle_options() { // ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings @@ -240,7 +242,8 @@ const std::vector& Preset::nozzle_options() "nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset", "retract_length", "retract_lift", "retract_lift_above", "retract_lift_below", "retract_speed", "deretract_speed", "retract_before_wipe", "retract_restart_extra", "retract_before_travel", "wipe", - "retract_layer_change", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour" + "retract_layer_change", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", + "default_filament_profile" }; return s_opts; } @@ -363,7 +366,7 @@ void PresetCollection::save_current_preset(const std::string &new_name) inherits = /* preset.vendor->name + "/" + */ old_name; } else if (inherits.empty()) { // Inheriting from a user preset. Link the new preset to the old preset. - inherits = old_name; + // inherits = old_name; } else { // Inherited from a user preset. Just maintain the "inherited" flag, // meaning it will inherit from either the system preset, or the inherited user preset. diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 453208fde4..7131bf7716 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -1001,6 +1001,8 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma if (wide_icons) bitmap_key += preset.is_compatible ? ",cmpt" : ",ncmpt"; bitmap_key += (preset.is_system || preset.is_default) ? ",syst" : ",nsyst"; + if (preset.is_dirty) + bitmap_key += ",drty"; wxBitmap *bitmap = m_bitmapCache->find(bitmap_key); if (bitmap == nullptr) { // Create the bitmap with color bars. @@ -1017,7 +1019,8 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma } // Paint a lock at the system presets. bmps.emplace_back(m_bitmapCache->mkclear(4, 16)); - bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmapLock : m_bitmapCache->mkclear(16, 16)); + bmps.emplace_back((preset.is_system || preset.is_default) ? + (preset.is_dirty ? *m_bitmapLockOpen : *m_bitmapLock) : m_bitmapCache->mkclear(16, 16)); bitmap = m_bitmapCache->insert(bitmap_key, bmps); } ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), (bitmap == 0) ? wxNullBitmap : *bitmap); From 7f31f7a3ab2afc7c0f507a90a2b7485837b3ec64 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 13 Mar 2018 13:39:46 +0100 Subject: [PATCH 0041/1150] Added lock and lock_open icons. --- resources/icons/lock.png | Bin 0 -> 749 bytes resources/icons/lock_open.png | Bin 0 -> 727 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 resources/icons/lock.png create mode 100644 resources/icons/lock_open.png diff --git a/resources/icons/lock.png b/resources/icons/lock.png new file mode 100644 index 0000000000000000000000000000000000000000..2ebc4f6f9663e32cad77d67ef93ab8843dfea3c0 GIT binary patch literal 749 zcmVe|tv9>?g+k#9o0pTxd@;_sq{kwlU;^VvV*?BV8P@}BoaZTQUROpWV6|-M`|^n&)=+8tHo3*<<$NU zU`%V~ZF;?hBSYsjJ6%JzV}E(D{pOLqQklliUf9um_tGl-wty`y*p?eYNW56P>X@1s zZs7KrRZKtmV7Lqj^5Fgr7_`LjhdJK@ltF&O`j7?*NUM$KvmNGz)3WjM?V$vHlPT0AFyF?kLE<#HZabCSW3-oa*6;Z zrXD`Ulwd<^2glP%1Y1Kc1Ij%DU^=ME(jKf6APNlA$Uu;J4bVilQHSWX5uJ$9Zsp4M z0%!@LvyTxz=Z6stxlichODIY+yNGt%RM;m`>H4LOKLFs9Y%b5aUN|2|{0Zw|<_~i} fmXz*V19AKYarLKlJyH=-*k3W|aiVYC~e{STzB+=%NyKm^5w z3m4+bm8cXnzG}0Gw2c^Ol0K$0_ity0#@^}dhsl97GUJu9lkxh`Okt_0|=(|h`!tol*)tahk*i! zgS8GLCq{|Gd7N1T=a4u`0gM4BU}M^~w|L$b3WtyL{rO$Q?PPfL6z$J7;&2In&vryC zqT@6`g9u_Zg@Xt1vO7RIY-D-g8eo{1!oIz%ujUZ52IBq#JOI%e5ertc^kIf}?KOA? zx9*6-2qdQcN5WDRs@&WP6I?Nxm{No*quRTbIBKa{opLb zA%3`w)e+)sGB0CNfH Date: Tue, 13 Mar 2018 15:54:29 +0100 Subject: [PATCH 0042/1150] Started to move ramming dialog into filament settings --- xs/src/slic3r/GUI/RammingChart.cpp | 98 ++++++++++++--------------- xs/src/slic3r/GUI/RammingChart.hpp | 61 +++++++---------- xs/src/slic3r/GUI/Tab.cpp | 24 +++---- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 88 ++++++++++++------------ xs/src/slic3r/GUI/WipeTowerDialog.hpp | 23 ++++--- 5 files changed, 135 insertions(+), 159 deletions(-) diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp index 3b535aacf5..e07b958392 100644 --- a/xs/src/slic3r/GUI/RammingChart.cpp +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -10,41 +10,41 @@ void Chart::draw(wxDC& dc) { dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(m_rect); - if (visible_area->m_width < 0.499) { + if (visible_area.m_width < 0.499) { dc.DrawText("NO RAMMING AT ALL",wxPoint(m_rect.GetLeft()+m_rect.GetWidth()/2-50,m_rect.GetBottom()-m_rect.GetHeight()/2)); return; } - if (!m_line_to_draw->empty()) { - for (unsigned int i=0;isize()-2;++i) { - int color = 510*((m_rect.GetBottom()-(*m_line_to_draw)[i])/double(m_rect.GetHeight())); + if (!m_line_to_draw.empty()) { + for (unsigned int i=0;isize()-2;++i) { + for (unsigned int i=0;im_x*10)/10 ; math_x <= (visible_area->m_x+visible_area->m_width) ; math_x+=0.1) { - int x = math_to_screen(wxPoint2DDouble(math_x,visible_area->m_y)).x; + for (float math_x=int(visible_area.m_x*10)/10 ; math_x <= (visible_area.m_x+visible_area.m_width) ; math_x+=0.1) { + int x = math_to_screen(wxPoint2DDouble(math_x,visible_area.m_y)).x; int y = m_rect.GetBottom(); if (x-last_mark < 50) continue; dc.DrawLine(x,y+3,x,y-3); @@ -54,8 +54,8 @@ void Chart::draw(wxDC& dc) { // draw y-axis: last_mark=10000; - for (int math_y=visible_area->m_y ; math_y <= (visible_area->m_y+visible_area->m_height) ; math_y+=1) { - int y = math_to_screen(wxPoint2DDouble(visible_area->m_x,math_y)).y; + for (int math_y=visible_area.m_y ; math_y <= (visible_area.m_y+visible_area.m_height) ; math_y+=1) { + int y = math_to_screen(wxPoint2DDouble(visible_area.m_x,math_y)).y; int x = m_rect.GetLeft(); if (last_mark-y < 50) continue; dc.DrawLine(x-3,y,x+3,y); @@ -72,8 +72,8 @@ void Chart::mouse_right_button_clicked(wxMouseEvent& event) { return; wxPoint point = event.GetPosition(); int button_index = which_button_is_clicked(point); - if (button_index != -1 && m_buttons[m_current_extruder].size()>2) { - m_buttons[m_current_extruder].erase(m_buttons[m_current_extruder].begin()+button_index); + if (button_index != -1 && m_buttons.size()>2) { + m_buttons.erase(m_buttons.begin()+button_index); recalculate_line(); } } @@ -84,7 +84,7 @@ void Chart::mouse_clicked(wxMouseEvent& event) { wxPoint point = event.GetPosition(); int button_index = which_button_is_clicked(point); if ( button_index != -1) { - m_dragged = &m_buttons[m_current_extruder][button_index]; + m_dragged = &m_buttons[button_index]; m_previous_mouse = point; } } @@ -102,7 +102,7 @@ void Chart::mouse_moved(wxMouseEvent& event) { } int delta_x = pos.x - m_previous_mouse.x; int delta_y = pos.y - m_previous_mouse.y; - m_dragged->move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area->m_width,-double(delta_y)/m_rect.GetHeight() * visible_area->m_height); + m_dragged->move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area.m_width,-double(delta_y)/m_rect.GetHeight() * visible_area.m_height); m_previous_mouse = pos; recalculate_line(); } @@ -115,8 +115,8 @@ void Chart::mouse_double_clicked(wxMouseEvent& event) { wxPoint point = event.GetPosition(); if (!m_rect.Contains(point)) // the click is outside the chart return; - m_buttons[m_current_extruder].push_back(screen_to_math(point)); - std::sort(m_buttons[m_current_extruder].begin(),m_buttons[m_current_extruder].end()); + m_buttons.push_back(screen_to_math(point)); + std::sort(m_buttons.begin(),m_buttons.end()); recalculate_line(); return; } @@ -126,7 +126,7 @@ void Chart::mouse_double_clicked(wxMouseEvent& event) { void Chart::recalculate_line() { std::vector points; - for (auto& but : m_buttons[m_current_extruder]) { + for (auto& but : m_buttons) { points.push_back(wxPoint(math_to_screen(but.get_pos()))); if (points.size()>1 && points.back().x==points[points.size()-2].x) points.pop_back(); if (points.size()>1 && points.back().x > m_rect.GetRight()) { @@ -136,7 +136,7 @@ void Chart::recalculate_line() { } std::sort(points.begin(),points.end(),[](wxPoint& a,wxPoint& b) { return a.x < b.x; }); - m_line_to_draw->clear(); + m_line_to_draw.clear(); m_total_volume = 0.f; @@ -205,19 +205,19 @@ void Chart::recalculate_line() { y = (rhs[i-1]*pow(points[i].x-x,3)+rhs[i]*pow(x-points[i-1].x,3)) / (6*h[i]) + (points[i-1].y-rhs[i-1]*h[i]*h[i]/6.f) * (points[i].x-x)/h[i] + (points[i].y -rhs[i] *h[i]*h[i]/6.f) * (x-points[i-1].x)/h[i]; - m_line_to_draw->push_back(y); + m_line_to_draw.push_back(y); } else { float x_math = screen_to_math(wxPoint(x,0)).m_x; - if (i+2<=points.size() && m_buttons[m_current_extruder][i+1].get_pos().m_x-0.125 < x_math) + if (i+2<=points.size() && m_buttons[i+1].get_pos().m_x-0.125 < x_math) ++i; - m_line_to_draw->push_back(math_to_screen(wxPoint2DDouble(x_math,m_buttons[m_current_extruder][i].get_pos().m_y)).y); + m_line_to_draw.push_back(math_to_screen(wxPoint2DDouble(x_math,m_buttons[i].get_pos().m_y)).y); } - m_line_to_draw->back() = std::max(m_line_to_draw->back(), m_rect.GetTop()-1); - m_line_to_draw->back() = std::min(m_line_to_draw->back(), m_rect.GetBottom()-1); - m_total_volume += (m_rect.GetBottom() - m_line_to_draw->back()) * (visible_area->m_width / m_rect.GetWidth()) * (visible_area->m_height / m_rect.GetHeight()); + m_line_to_draw.back() = std::max(m_line_to_draw.back(), m_rect.GetTop()-1); + m_line_to_draw.back() = std::min(m_line_to_draw.back(), m_rect.GetBottom()-1); + m_total_volume += (m_rect.GetBottom() - m_line_to_draw.back()) * (visible_area.m_width / m_rect.GetWidth()) * (visible_area.m_height / m_rect.GetHeight()); } wxPostEvent(this->GetParent(), wxCommandEvent(EVT_WIPE_TOWER_CHART_CHANGED)); @@ -226,36 +226,26 @@ void Chart::recalculate_line() { -std::vector> Chart::get_ramming_speeds(float sampling) const { - std::vector> speeds_out; - for (unsigned int extruder_id = 0;extruder_id this_extruder; - const int number_of_samples = std::round( visible_areas[extruder_id].m_width / sampling); - if (number_of_samples>0) { - const int dx = (m_lines_to_draw[extruder_id].size()-1) / number_of_samples; - for (int j=0;j Chart::get_ramming_speed(float sampling) const { + std::vector speeds_out; + const int number_of_samples = std::round( visible_area.m_width / sampling); + if (number_of_samples>0) { + const int dx = (m_line_to_draw.size()-1) / number_of_samples; + for (int j=0;j>> Chart::get_buttons() const { - std::vector>> buttons_out; - for (const auto& ext : m_buttons) { - std::vector> this_extruder; - for (const auto& button : ext) - this_extruder.push_back(std::make_pair(button.get_pos().m_x,button.get_pos().m_y)); - buttons_out.push_back(std::move(this_extruder)); - } +std::vector> Chart::get_buttons() const { + std::vector> buttons_out; + for (const auto& button : m_buttons) + buttons_out.push_back(std::make_pair(button.get_pos().m_x,button.get_pos().m_y)); return buttons_out; } diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp index 8274b96e69..520b5808e0 100644 --- a/xs/src/slic3r/GUI/RammingChart.hpp +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -13,39 +13,28 @@ wxDECLARE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); class Chart : public wxWindow { public: - Chart(wxWindow* parent, wxRect rect,const std::vector>>& initial_buttons,std::vector> ramming_speed, float sampling) : + Chart(wxWindow* parent, wxRect rect,const std::vector>& initial_buttons,std::vector ramming_speed, float sampling) : wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize()) { m_rect=wxRect(wxPoint(30,0),rect.GetSize()-wxSize(30,30)); - for (int i=0;i<4;++i) { - visible_areas.push_back(wxRect2DDouble(0.0, 0.0, sampling*ramming_speed[i].size(), 20.)); - m_buttons.push_back(std::vector()); - m_lines_to_draw.push_back(std::vector()); - if (initial_buttons.size()>0) - for (const auto& pair : initial_buttons[i]) - m_buttons.back().push_back(wxPoint2DDouble(pair.first,pair.second)); - set_extruder(i); // to calculate all interpolating splines - } - set_extruder(0); - } - void set_extruder(unsigned ext) { - if (ext>=4) return; - m_current_extruder = ext; - visible_area = &(visible_areas[ext]); - m_line_to_draw = &(m_lines_to_draw[ext]); + visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed.size(), 20.); + m_buttons.clear(); + if (initial_buttons.size()>0) + for (const auto& pair : initial_buttons) + m_buttons.push_back(wxPoint2DDouble(pair.first,pair.second)); recalculate_line(); } void set_xy_range(float x,float y) { x = int(x/0.5) * 0.5; - if (x>=0) visible_area->SetRight(x); - if (y>=0) visible_area->SetBottom(y); + if (x>=0) visible_area.SetRight(x); + if (y>=0) visible_area.SetBottom(y); recalculate_line(); } float get_volume() const { return m_total_volume; } - float get_time() const { return visible_area->m_width; } - std::vector> get_ramming_speeds(float sampling) const; //returns sampled ramming speed for all extruders - std::vector>> get_buttons() const; // returns buttons position for all extruders - + float get_time() const { return visible_area.m_width; } + + std::vector get_ramming_speed(float sampling) const; //returns sampled ramming speed + std::vector> get_buttons() const; // returns buttons position void draw(wxDC& dc); @@ -80,8 +69,8 @@ private: wxPoint math_to_screen(const wxPoint2DDouble& math) const { wxPoint screen; - screen.x = (math.m_x-visible_area->m_x) * (m_rect.GetWidth() / visible_area->m_width ); - screen.y = (math.m_y-visible_area->m_y) * (m_rect.GetHeight() / visible_area->m_height ); + screen.x = (math.m_x-visible_area.m_x) * (m_rect.GetWidth() / visible_area.m_width ); + screen.y = (math.m_y-visible_area.m_y) * (m_rect.GetHeight() / visible_area.m_height ); screen.y *= -1; screen += m_rect.GetLeftBottom(); return screen; @@ -90,16 +79,16 @@ private: wxPoint2DDouble math = screen; math -= m_rect.GetLeftBottom(); math.m_y *= -1; - math.m_x *= visible_area->m_width / m_rect.GetWidth(); // scales to [0;1]x[0,1] - math.m_y *= visible_area->m_height / m_rect.GetHeight(); - return (math+visible_area->GetLeftTop()); + math.m_x *= visible_area.m_width / m_rect.GetWidth(); // scales to [0;1]x[0,1] + math.m_y *= visible_area.m_height / m_rect.GetHeight(); + return (math+visible_area.GetLeftTop()); } int which_button_is_clicked(const wxPoint& point) const { if (!m_rect.Contains(point)) return -1; - for (unsigned int i=0;i > m_buttons; - std::vector< std::vector > m_lines_to_draw; - std::vector< wxRect2DDouble > visible_areas; - wxRect2DDouble* visible_area = nullptr; - std::vector* m_line_to_draw = nullptr; + std::vector m_buttons; + std::vector m_line_to_draw; + wxRect2DDouble visible_area; ButtonToDrag* m_dragged = nullptr; - float m_total_volume = 0.f; - + float m_total_volume = 0.f; }; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ea80e2ecec..58d714fc77 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -796,7 +796,7 @@ void TabPrint::update() bool have_wipe_tower = m_config->opt_bool("wipe_tower"); vec_enable.resize(0); - vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle"}; + vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_bridging"}; for (auto el : vec_enable) get_field(el)->toggle(have_wipe_tower); m_wipe_tower_btn->Enable(have_wipe_tower); @@ -885,20 +885,18 @@ void TabFilament::build() optgroup->append_single_option_line("filament_cooling_time"); line = { _(L("Ramming")), "" }; line.widget = [this](wxWindow* parent){ - auto ramming_dialog = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); - auto sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(ramming_dialog); - /*m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) + auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); + auto sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(ramming_dialog_btn); + + ramming_dialog_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { - std::string init_data = (m_config->option("wipe_tower_advanced"))->value; - std::cout << "dialog init: " << init_data << std::endl; - WipeTowerDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy - - if (dlg.ShowModal() == wxID_OK) { - load_key_value("wipe_tower_advanced", dlg.GetValue()); - std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl; + //std::string init_data = (m_config->option("wipe_tower_advanced"))->value; + RammingDialog dlg(this,std::string()); + if (dlg.ShowModal() == wxID_OK) { + //load_key_value("wipe_tower_advanced", dlg.GetValue()); } - }));*/ + })); return sizer; }; optgroup->append_line(line); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 1891a401c4..8bf51e4e50 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -40,12 +40,37 @@ std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par) { return str; } + + +RammingDialog::RammingDialog(wxWindow* parent,const std::string& init_data) +: wxDialog(parent, -1, wxT("Ramming customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +{ + this->Centre(); + m_panel_ramming = new RammingPanel(this,Slic3r::WipeTowerParameters(std::string())); + m_panel_ramming->Show(true); + this->Show(); + + auto main_sizer = new wxBoxSizer(wxVERTICAL); + main_sizer->Add(m_panel_ramming, 1, wxEXPAND); + main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); + SetSizer(main_sizer); + SetMinSize(GetSize()); + main_sizer->SetSizeHints(this); + + this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); + this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { + // m_output_data=read_dialog_values(); + EndModal(wxID_OK); + },wxID_OK); +} + + RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) -: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) +: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) { new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT); m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString, wxPoint(700,100), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0.,5.0,3.,0.5); @@ -55,56 +80,40 @@ RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,200), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100); new wxStaticText(this,wxID_ANY,wxString("Ramming line spacing (%):"), wxPoint(500,235), wxSize(200,25),wxALIGN_LEFT); m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,230), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100); - new wxStaticText(this,wxID_ANY,wxString("Extruder #:"), wxPoint(500,12), wxSize(200,25),wxALIGN_LEFT); - wxArrayString choices; - for (unsigned int i=0;iset_extruder(0); m_widget_time->SetValue(m_chart->get_time()); m_widget_time->SetDigits(2); m_widget_volume->SetValue(m_chart->get_volume()); m_widget_volume->Disable(); - m_widget_extruder->SetSelection(0); - extruder_selection_changed(); // tell everyone to redraw + m_widget_ramming_line_width_multiplicator->SetValue(m_ramming_line_width_multiplicator); + m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator); m_widget_ramming_step_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); }); m_widget_ramming_line_width_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); }); - m_widget_extruder->Bind(wxEVT_CHOICE,[this](wxCommandEvent&) { extruder_selection_changed(); }); m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);}); m_widget_time->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value - Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} ); + Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} ); + Refresh(this); } + void RammingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { if (!m_chart) return; - p.ramming_buttons = m_chart->get_buttons(); - p.ramming_speed = m_chart->get_ramming_speeds(p.sampling); - for (unsigned int i=0;iGetSelection(); - m_chart->set_extruder(m_current_extruder); // tell our chart to redraw - m_widget_ramming_line_width_multiplicator ->SetValue(m_ramming_line_width_multiplicators[m_current_extruder]); - m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicators[m_current_extruder]); + p.ramming_buttons[0] = m_chart->get_buttons(); + p.ramming_speed[0] = m_chart->get_ramming_speed(p.sampling); + p.ramming_line_width_multiplicator.push_back(m_ramming_line_width_multiplicator/100.f); + p.ramming_step_multiplicator.push_back(m_ramming_step_multiplicator/100.f); } + void RammingPanel::line_parameters_changed() { - m_ramming_line_width_multiplicators[m_current_extruder]=m_widget_ramming_line_width_multiplicator->GetValue(); - m_ramming_step_multiplicators[m_current_extruder]=m_widget_ramming_step_multiplicator->GetValue(); + m_ramming_line_width_multiplicator = m_widget_ramming_line_width_multiplicator->GetValue(); + m_ramming_step_multiplicator = m_widget_ramming_step_multiplicator->GetValue(); } @@ -112,7 +121,7 @@ void RammingPanel::line_parameters_changed() { WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) -: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) +: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) { const int N = 4; // number of extruders new wxStaticText(this,wxID_ANY,wxString("Volume to wipe when the filament is being"),wxPoint(40,55) ,wxSize(500,25)); @@ -141,6 +150,7 @@ WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) } m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){fill_in_matrix();}); + Refresh(this); } void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { @@ -183,7 +193,7 @@ void WipingPanel::fill_in_matrix() { WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data) -: wxDialog(parent, -1, wxT("Wipe tower advanced settings"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +: wxDialog(parent, -1, wxT("Wiping customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { this->Centre(); @@ -192,21 +202,11 @@ WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data) wxMessageDialog(this,"Wipe tower parameters not parsed correctly!\nRestoring default settings.","Error",wxICON_ERROR); parameters.set_defaults(); } - - wxNotebook* notebook = new wxNotebook(this,wxID_ANY,wxPoint(0,0),wxSize(800,450)); - - //m_panel_general = new GeneralPanel(notebook,parameters); - m_panel_ramming = new RammingPanel(notebook,parameters); - //m_panel_cooling = new CoolingPanel(notebook,parameters); - m_panel_wiping = new WipingPanel(notebook,parameters); - //notebook->AddPage(m_panel_general,"General"); - notebook->AddPage(m_panel_ramming,"Ramming"); - //notebook->AddPage(m_panel_cooling,"Cooling"); - notebook->AddPage(m_panel_wiping,"Wiping"); + m_panel_wiping = new WipingPanel(this,parameters); this->Show(); auto main_sizer = new wxBoxSizer(wxVERTICAL); - main_sizer->Add(notebook, 1, wxEXPAND); + main_sizer->Add(m_panel_wiping, 1, wxEXPAND); main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); SetSizer(main_sizer); SetMinSize(GetSize()); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index 8a1c88be81..f9a9f95248 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -15,10 +15,10 @@ // Human-readable output of Parameters structure std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par); - class RammingPanel : public wxPanel { public: + RammingPanel(wxWindow* parent); RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); void fill_parameters(Slic3r::WipeTowerParameters& p); @@ -28,17 +28,22 @@ private: wxSpinCtrl* m_widget_ramming_line_width_multiplicator = nullptr; wxSpinCtrl* m_widget_ramming_step_multiplicator = nullptr; wxSpinCtrlDouble* m_widget_time = nullptr; - wxChoice* m_widget_extruder = nullptr; - std::vector m_ramming_step_multiplicators; - std::vector m_ramming_line_width_multiplicators; - int m_current_extruder = 0; // zero-based index - - void extruder_selection_changed(); - + int m_ramming_step_multiplicator; + int m_ramming_line_width_multiplicator; + void line_parameters_changed(); }; +class RammingDialog : public wxDialog { +public: + RammingDialog(wxWindow* parent,const std::string& init_data); +private: + RammingPanel* m_panel_ramming = nullptr; +}; + + + class WipingPanel : public wxPanel { public: @@ -67,13 +72,11 @@ public: private: std::string m_file_name="config_wipe_tower"; - RammingPanel* m_panel_ramming = nullptr; WipingPanel* m_panel_wiping = nullptr; std::string m_output_data = ""; std::string read_dialog_values() { Slic3r::WipeTowerParameters p; - m_panel_ramming->fill_parameters(p); m_panel_wiping ->fill_parameters(p); return p.to_string(); } From 5f28b89ae02a873080a229f76debd2e5f406ef0e Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 14 Mar 2018 11:54:11 +0100 Subject: [PATCH 0043/1150] Added a project specific config to the PresetBundle class. This project specific config will be stored into the config.ini, into .3mf and .amf and .gcode, and recover it from the same files. --- xs/src/slic3r/GUI/PresetBundle.cpp | 9 +++++++++ xs/src/slic3r/GUI/PresetBundle.hpp | 5 +++++ xs/xsp/GUI_Preset.xsp | 2 ++ 3 files changed, 16 insertions(+) diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index bf79c6562e..7d2501a655 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -32,6 +32,9 @@ namespace Slic3r { +static std::vector s_project_options { +}; + PresetBundle::PresetBundle() : prints(Preset::TYPE_PRINT, Preset::print_options()), filaments(Preset::TYPE_FILAMENT, Preset::filament_options()), @@ -56,6 +59,8 @@ PresetBundle::PresetBundle() : this->filaments.load_bitmap_default("spool.png"); this->printers .load_bitmap_default("printer_empty.png"); this->load_compatible_bitmaps(); + + this->project_config.apply_only(FullPrintConfig::defaults(), s_project_options); } PresetBundle::~PresetBundle() @@ -223,6 +228,7 @@ DynamicPrintConfig PresetBundle::full_config() const out.apply(FullPrintConfig()); out.apply(this->prints.get_edited_preset().config); out.apply(this->printers.get_edited_preset().config); + out.apply(this->project_config); auto *nozzle_diameter = dynamic_cast(out.option("nozzle_diameter")); size_t num_extruders = nozzle_diameter->values.size(); @@ -412,6 +418,9 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool } } + // 4) Load the project config values (the per extruder wipe matrix etc). + this->project_config.apply_only(config, s_project_options); + this->update_compatible_with_printer(false); } diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index e6aea206d1..6840df75e2 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -39,6 +39,11 @@ public: // extruders.size() should be the same as printers.get_edited_preset().config.nozzle_diameter.size() std::vector filament_presets; + // The project configuration values are kept separated from the print/filament/printer preset, + // they are being serialized / deserialized from / to the .amf, .3mf, .config, .gcode, + // and they are being used by slicing core. + DynamicPrintConfig project_config; + bool has_defauls_only() const { return prints.size() <= 1 && filaments.size() <= 1 && printers.size() <= 1; } diff --git a/xs/xsp/GUI_Preset.xsp b/xs/xsp/GUI_Preset.xsp index 0033ebd0e2..dc8ebf41cb 100644 --- a/xs/xsp/GUI_Preset.xsp +++ b/xs/xsp/GUI_Preset.xsp @@ -161,6 +161,8 @@ PresetCollection::arrayref() Ref print() %code%{ RETVAL = &THIS->prints; %}; Ref filament() %code%{ RETVAL = &THIS->filaments; %}; Ref printer() %code%{ RETVAL = &THIS->printers; %}; + Ref project_config() %code%{ RETVAL = &THIS->project_config; %}; + bool has_defauls_only(); std::vector filament_presets() %code%{ RETVAL = THIS->filament_presets; %}; From 317f651b786f05a8f3be8f3f36df9fbaf9de10b2 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 14 Mar 2018 12:44:53 +0100 Subject: [PATCH 0044/1150] Fixed a crash at the start of the application when the datadir is missing, due to the option "default_filament_profile" not being part of the FullPrinterConfig. --- My Settings | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 My Settings diff --git a/My Settings b/My Settings new file mode 100644 index 0000000000..f896db7679 --- /dev/null +++ b/My Settings @@ -0,0 +1,27 @@ +# generated by Slic3r Prusa Edition 1.38.4 on 2017-12-20 at 11:02:03 +bed_temperature = 0 +bridge_fan_speed = 100 +compatible_printers = +compatible_printers_condition = +cooling = 1 +disable_fan_first_layers = 3 +end_filament_gcode = "; Filament-specific end gcode \n;END gcode for filament\n" +extrusion_multiplier = 1 +fan_always_on = 0 +fan_below_layer_time = 60 +filament_colour = #29b2b2 +filament_cost = 0 +filament_density = 0 +filament_diameter = 3 +filament_max_volumetric_speed = 0 +filament_notes = "" +filament_soluble = 0 +filament_type = PLA +first_layer_bed_temperature = 0 +first_layer_temperature = 205 +max_fan_speed = 100 +min_fan_speed = 35 +min_print_speed = 10 +slowdown_below_layer_time = 5 +start_filament_gcode = "; Filament gcode\n" +temperature = 200 From 1969a8b2c1c0b39ccb6fb800ee09ff9d03637c8a Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 14 Mar 2018 13:12:17 +0100 Subject: [PATCH 0045/1150] Fixed crash on start of the application in case there is no profile available. --- xs/src/slic3r/GUI/Preset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 0796a0f4ae..661b11ee0d 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -80,7 +80,7 @@ void Preset::set_num_extruders(DynamicPrintConfig &config, unsigned int num_extr auto *opt = config.option(key, false); assert(opt != nullptr); assert(opt->is_vector()); - if (opt != nullptr && opt->is_vector()) + if (opt != nullptr && opt->is_vector() && key != "default_filament_profile") static_cast(opt)->resize(num_extruders, defaults.option(key)); } } From e680658cf562dc0d4f21a0da1c851d01f1759335 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 14 Mar 2018 13:29:50 +0100 Subject: [PATCH 0046/1150] Fixed selection of sensible active print / filament / printer profile after the initial wizard run. --- lib/Slic3r/GUI/MainFrame.pm | 4 ++++ xs/src/slic3r/GUI/AppConfig.cpp | 11 +++++++++++ xs/src/slic3r/GUI/AppConfig.hpp | 5 +++++ xs/xsp/GUI_AppConfig.xsp | 2 ++ 4 files changed, 22 insertions(+) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 9e7bfacd80..d1f3a9d4c5 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -723,6 +723,10 @@ sub config_wizard { } else { # Wizard returned a name of a preset bundle bundled with the installation. Unpack it. wxTheApp->{preset_bundle}->install_vendor_configbundle($directory . '/' . $result->{preset_name} . '.ini'); + # Reset the print / filament / printer selections, so that following line will select some sensible defaults. + if ($fresh_start) { + wxTheApp->{app_config}->reset_selections; + } # Reload all presets after the vendor config bundle has been installed. wxTheApp->{preset_bundle}->load_presets(wxTheApp->{app_config}); } diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 99339e2f35..e32b645b47 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -145,6 +145,17 @@ void AppConfig::update_last_output_dir(const std::string &dir) this->set("", "last_output_path", dir); } +void AppConfig::reset_selections() +{ + auto it = m_storage.find("presets"); + if (it != m_storage.end()) { + it->second.erase("print"); + it->second.erase("filament"); + it->second.erase("printer"); + m_dirty = true; + } +} + std::string AppConfig::config_path() { return (boost::filesystem::path(Slic3r::data_dir()) / "slic3r.ini").make_preferred().string(); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index c6d7766a41..9b1d5a7128 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -73,6 +73,11 @@ public: std::string get_last_output_dir(const std::string &alt) const; void update_last_output_dir(const std::string &dir); + // reset the current print / filament / printer selections, so that + // the PresetBundle::load_selections(const AppConfig &config) call will select + // the first non-default preset when called. + void reset_selections(); + // Get the default config path from Slic3r::data_dir(). static std::string config_path(); diff --git a/xs/xsp/GUI_AppConfig.xsp b/xs/xsp/GUI_AppConfig.xsp index 8162b9a5e0..08a88883db 100644 --- a/xs/xsp/GUI_AppConfig.xsp +++ b/xs/xsp/GUI_AppConfig.xsp @@ -41,4 +41,6 @@ void update_skein_dir(char *dir); std::string get_last_output_dir(const char *alt = ""); void update_last_output_dir(char *dir); + + void reset_selections(); }; From 9f18b639a84e43f4f0f783b6023a4fd896269973 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 14 Mar 2018 15:48:37 +0100 Subject: [PATCH 0047/1150] Added filament_ramming_parameters and filament_ramming_buttons into configuration layer --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 2 +- xs/src/libslic3r/PrintConfig.cpp | 12 ++++++++++++ xs/src/libslic3r/PrintConfig.hpp | 4 ++++ xs/src/slic3r/GUI/Preset.cpp | 7 ++++--- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 3c2f82ffdd..160848a479 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -56,7 +56,7 @@ std::istream& operator>>(std::istream& stream, std::vector& vect) { we_read_something = true; } if (!stream.eof() && we_read_something) { // if this is not eof, we might be at separator - let's get rid of it - stream.clear(); // if we failed on very first line or reached eof, return stream in !good() state + stream.clear(); // if we failed on very first line or reached eof, return stream in good() state stream.get(); // get() whatever we are stuck at } return stream; diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index b0b1c4e993..198d78ad32 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -479,6 +479,18 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionInts { 14 }; + def = this->add("filament_ramming_parameters", coStrings); + def->label = L("Ramming parameters"); + def->tooltip = L("This string is edited by RammingDialog and contains ramming specific parameters "); + def->cli = "filament-ramming-parameters=s@"; + def->default_value = new ConfigOptionStrings { "120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0" }; + + def = this->add("filament_ramming_buttons", coStrings); + def->label = L("Draggable button in RammingDialog"); + def->tooltip = L("This string is edited by RammingDialog and contains position of draggable buttons "); + def->cli = "filament-ramming-buttons=s@"; + def->default_value = new ConfigOptionStrings { "0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" }; + def = this->add("filament_diameter", coFloats); def->label = L("Diameter"); def->tooltip = L("Enter your filament diameter here. Good precision is required, so use a caliper " diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 501a8ac367..c6d7ce2775 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -471,6 +471,8 @@ public: ConfigOptionFloats filament_unloading_speed; ConfigOptionFloats filament_toolchange_delay; ConfigOptionInts filament_cooling_time; + ConfigOptionStrings filament_ramming_parameters; + ConfigOptionStrings filament_ramming_buttons; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; ConfigOptionString layer_gcode; @@ -527,6 +529,8 @@ protected: OPT_PTR(filament_unloading_speed); OPT_PTR(filament_toolchange_delay); OPT_PTR(filament_cooling_time); + OPT_PTR(filament_ramming_parameters); + OPT_PTR(filament_ramming_buttons); OPT_PTR(gcode_comments); OPT_PTR(gcode_flavor); OPT_PTR(layer_gcode); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 92bfef4165..c3a988e65d 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -211,9 +211,10 @@ const std::vector& Preset::filament_options() static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay", - "filament_cooling_time", "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", - "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", - "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers", "compatible_printers_condition" + "filament_cooling_time", "filament_ramming_buttons", "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature", + "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", + "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers", + "compatible_printers_condition" }; return s_opts; } From c3ec40c3ccb712fdb11b52ce2cb52f11402cee00 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 15 Mar 2018 09:55:31 +0100 Subject: [PATCH 0048/1150] Added prototype of an "Undo to system" button --- lib/Slic3r/GUI/Plater.pm | 4 ++-- xs/src/slic3r/GUI/Field.cpp | 11 ++++++++--- xs/src/slic3r/GUI/Field.hpp | 1 + xs/src/slic3r/GUI/OptionsGroup.cpp | 8 +++++++- xs/src/slic3r/GUI/Tab.cpp | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a99bbddefe..71da1a26d9 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -483,8 +483,8 @@ sub new { $right_sizer->Add($print_info_sizer, 0, wxEXPAND, 0); # Callback for showing / hiding the print info box. $self->{"print_info_box_show"} = sub { - if ($right_sizer->IsShown(4) != $_[0]) { - $right_sizer->Show(4, $_[0]); + if ($right_sizer->IsShown(5) != $_[0]) { + $right_sizer->Show(5, $_[0]); $self->Layout } }; diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index aed7ba12f6..984aa05ae2 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -19,12 +19,17 @@ namespace Slic3r { namespace GUI { } void Field::PostInitialize(){ - m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); - // use bouth of temporary_icons till don't have "undo_icon" auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - if (wxMSW) m_Undo_btn->SetBackgroundColour(color); + m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + if (wxMSW) { + m_Undo_btn->SetBackgroundColour(color); + m_Undo_to_sys_btn->SetBackgroundColour(color); + } m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); + m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); + m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ /*on_back_to_initial_value()*/; })); BUILD(); } diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index e72316fc1a..b5a4c66faf 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -89,6 +89,7 @@ public: wxStaticText* m_Label = nullptr; wxButton* m_Undo_btn = nullptr; + wxButton* m_Undo_to_sys_btn = nullptr; /// Fires the enable or disable function, based on the input. inline void toggle(bool en) { en ? enable() : disable(); } diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 0be24824c4..d672d4b479 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -82,7 +82,10 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co if (!this->m_disabled) this->back_to_initial_value(opt_id); }; - if (!m_is_tab_opt) field->m_Undo_btn->Hide(); + if (!m_is_tab_opt) { + field->m_Undo_btn->Hide(); + field->m_Undo_to_sys_btn->Hide(); + } // assign function objects for callbacks, etc. return field; @@ -112,6 +115,7 @@ void OptionsGroup::append_line(const Line& line) { const auto& option = option_set.front(); const auto& field = build_field(option); + sizer->Add(field->m_Undo_to_sys_btn); sizer->Add(field->m_Undo_btn); if (is_window_field(field)) sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); @@ -149,6 +153,7 @@ void OptionsGroup::append_line(const Line& line) { const auto& option = option_set.front(); const auto& field = build_field(option, label); + sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL); if (is_window_field(field)) sizer->Add(field->getWindow(), 0, (option.opt.full_width ? wxEXPAND : 0) | @@ -177,6 +182,7 @@ void OptionsGroup::append_line(const Line& line) { // add field const Option& opt_ref = opt; auto& field = build_field(opt_ref, label); + sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL, 0); is_sizer_field(field) ? sizer->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) : diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index a875072e58..ec5d2a55b7 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -191,6 +191,7 @@ void Tab::update_changed_ui() field->m_Label->SetForegroundColour(*get_modified_label_clr()); field->m_Label->Refresh(true); } + // use bouth of temporary_icons till don't have "undo_icon" field->m_Undo_btn->SetBitmap(wxBitmap(from_u8(wxMSW ? var("action_undo.png") : var("arrow_undo.png")), wxBITMAP_TYPE_PNG)); field->m_is_modified_value = true; From 67009d80fd83d5bb3951e9e4b4cc73824e0cad6f Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 15 Mar 2018 14:04:12 +0100 Subject: [PATCH 0049/1150] Ramming parameters reduced to one and connected to the wipe tower generator again --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 19 +- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 106 +++-------- xs/src/libslic3r/Print.cpp | 4 +- xs/src/libslic3r/PrintConfig.cpp | 9 +- xs/src/libslic3r/PrintConfig.hpp | 2 - xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/RammingChart.hpp | 4 +- xs/src/slic3r/GUI/Tab.cpp | 8 +- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 187 +++++++++----------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 15 +- 10 files changed, 139 insertions(+), 217 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index b94950af10..ab54296154 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -465,6 +465,7 @@ WipeTowerPrusaMM::material_type WipeTowerPrusaMM::parse_material(const char *nam return INVALID; } + // Returns gcode to prime the nozzles at the front edge of the print bed. WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( // print_z of the first layer. @@ -478,7 +479,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false); this->m_num_layer_changes = 0; this->m_current_tool = tools.front(); - + // The Prusa i3 MK2 has a working space of [0, -2.2] to [250, 210]. // Due to the XYZ calibration, this working space may shrink slightly from all directions, // therefore the homing position is shifted inside the bed by 0.2 in the firmware to [0.2, -2.0]. @@ -723,8 +724,8 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.append("; CP TOOLCHANGE UNLOAD\n"); - const float line_width = m_line_width * m_par.ramming_line_width_multiplicator[m_current_tool]; // desired ramming line thickness - const float y_step = line_width * m_par.ramming_step_multiplicator[m_current_tool] * m_extra_spacing; // spacing between lines in mm + const float line_width = m_line_width * m_filpar[m_current_tool].ramming_line_width_multiplicator; // desired ramming line thickness + const float y_step = line_width * m_filpar[m_current_tool].ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm unsigned i = 0; // iterates through ramming_speed m_left_to_right = true; // current direction of ramming @@ -778,10 +779,10 @@ void WipeTowerPrusaMM::toolchange_Unload( } // now the ramming itself: - while (i < m_par.ramming_speed[m_current_tool].size()) + while (i < m_filpar[m_current_tool].ramming_speed.size()) { - const float x = volume_to_length(m_par.ramming_speed[m_current_tool][i] * 0.25f, line_width, m_layer_height); - const float e = m_par.ramming_speed[m_current_tool][i] * 0.25f / Filament_Area; // transform volume per sec to E move; + const float x = volume_to_length(m_filpar[m_current_tool].ramming_speed[i] * 0.25f, line_width, m_layer_height); + const float e = m_filpar[m_current_tool].ramming_speed[i] * 0.25f / Filament_Area; // transform volume per sec to E move; const float dist = std::min(x - e_done, remaining); // distance to travel for either the next 0.25s, or to the next turnaround const float actual_time = dist/x * 0.25; writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), std::hypot(dist, e * (dist / x)) / (actual_time / 60.)); @@ -1092,10 +1093,10 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi // this is an actual toolchange - let's calculate depth to reserve on the wipe tower float depth = 0.f; float width = m_wipe_tower_width - 3*m_perimeter_width; - float length_to_extrude = volume_to_length(0.25f * std::accumulate(m_par.ramming_speed[old_tool].begin(), m_par.ramming_speed[old_tool].end(), 0.f), - m_line_width * m_par.ramming_line_width_multiplicator[old_tool], + float length_to_extrude = volume_to_length(0.25f * std::accumulate(m_filpar[old_tool].ramming_speed.begin(), m_filpar[old_tool].ramming_speed.end(), 0.f), + m_line_width * m_filpar[old_tool].ramming_line_width_multiplicator, layer_height_par); - depth = (int(length_to_extrude / width) + 1) * (m_line_width * m_par.ramming_line_width_multiplicator[old_tool] * m_par.ramming_step_multiplicator[old_tool]); + depth = (int(length_to_extrude / width) + 1) * (m_line_width * m_filpar[old_tool].ramming_line_width_multiplicator * m_filpar[old_tool].ramming_step_multiplicator); float ramming_depth = depth; length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; float first_wipe_line = -length_to_extrude; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 160848a479..4ecdb5f42e 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -67,82 +67,11 @@ std::istream& operator>>(std::istream& stream, std::vector& vect) { struct WipeTowerParameters { WipeTowerParameters() { } // create new empty object WipeTowerParameters(const std::string& init_data) { // create object and initialize from std::string - std::istringstream in(init_data); // validation of input is left to the caller - in >> sampling; - for (std::vector vect{} ; in >> vect ;) { // until we get to fail state ("**")... - if (vect.size()>=2) { - ramming_line_width_multiplicator.push_back(vect[0]); - ramming_step_multiplicator.push_back(vect[1]); - vect.erase(vect.begin(),vect.begin()+2); - } - else vect.clear(); // something's not right, we will restore defaults anyway - ramming_speed.push_back(vect); - - if (in.good()) { - in >> vect; - std::vector> pairs; - for (unsigned int i=0;i vect{} ; in >> vect ;) { // let's keep reading - wipe_volumes.push_back(vect); - } - in.clear(); - in.get(); - - std::vector vect{}; - in >> vect; - for (unsigned int i=0;i{7.6f, 7.6f, 7.6f, 7.6f, 9.f, 9.f, 9.f, 10.7f, 10.7f, 10.7f}); - ramming_buttons.push_back(std::vector>{{0.05f, 6.6f},{0.45f, 6.8f},{0.95f, 7.8f},{1.45f, 8.3f},{1.95f, 9.7f},{2.45f,10.f},{2.95f, 7.6f},{3.45f, 7.6f},{3.95f, 7.6f},{4.45f, 7.6f},{4.95f, 7.6f}}); - } wipe_volumes = {{ 0.f, 60.f, 60.f, 60.f}, { 60.f, 0.f, 60.f, 60.f}, { 60.f, 60.f, 0.f, 60.f}, @@ -151,10 +80,6 @@ struct WipeTowerParameters { } float sampling = 0.25f; // this does not quite work yet, keep it fixed to 0.25f - std::vector ramming_line_width_multiplicator; - std::vector ramming_step_multiplicator; - std::vector> ramming_speed; - std::vector>> ramming_buttons; std::vector> wipe_volumes; std::vector> filament_wipe_volumes; }; @@ -222,7 +147,7 @@ public: // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, - float unloading_speed, float delay, int cooling_time) + float unloading_speed, float delay, int cooling_time, std::string ramming_parameters) { m_filpar[idx].material = material; m_filpar[idx].temperature = temp; @@ -231,6 +156,14 @@ public: m_filpar[idx].unloading_speed = unloading_speed; m_filpar[idx].delay = delay; m_filpar[idx].cooling_time = cooling_time; + + std::stringstream stream{ramming_parameters}; + float speed = 0.f; + stream >> m_filpar[idx].ramming_line_width_multiplicator >> m_filpar[idx].ramming_step_multiplicator; + m_filpar[idx].ramming_line_width_multiplicator /= 100; + m_filpar[idx].ramming_step_multiplicator /= 100; + while (stream >> speed) + m_filpar[idx].ramming_speed.push_back(speed); } @@ -345,13 +278,16 @@ private: struct FilamentParameters { - material_type material; - int temperature; - int first_layer_temperature; - float loading_speed; - float unloading_speed; - float delay; - int cooling_time; + material_type material; + int temperature; + int first_layer_temperature; + float loading_speed; + float unloading_speed; + float delay; + int cooling_time; + float ramming_line_width_multiplicator; + float ramming_step_multiplicator; + std::vector ramming_speed; }; // Extruder specific parameters. diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 95c57339a5..ae34b47d86 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -189,6 +189,7 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.filament_loading_speed.get_at(i), this->config.filament_unloading_speed.get_at(i), this->config.filament_toolchange_delay.get_at(i), - this->config.filament_toolchange_delay.get_at(i)); + this->config.filament_cooling_time.get_at(i), + this->config.filament_ramming_parameters.get_at(i)); // When printing the first layer's wipe tower, the first extruder is expected to be active and primed. // Therefore the number of wipe sections at the wipe tower will be (m_tool_ordering.front().extruders-1) at the 1st layer. diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 198d78ad32..081c05b2d4 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -483,13 +483,8 @@ PrintConfigDef::PrintConfigDef() def->label = L("Ramming parameters"); def->tooltip = L("This string is edited by RammingDialog and contains ramming specific parameters "); def->cli = "filament-ramming-parameters=s@"; - def->default_value = new ConfigOptionStrings { "120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0" }; - - def = this->add("filament_ramming_buttons", coStrings); - def->label = L("Draggable button in RammingDialog"); - def->tooltip = L("This string is edited by RammingDialog and contains position of draggable buttons "); - def->cli = "filament-ramming-buttons=s@"; - def->default_value = new ConfigOptionStrings { "0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" }; + def->default_value = new ConfigOptionStrings { "120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0|" + " 0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" }; def = this->add("filament_diameter", coFloats); def->label = L("Diameter"); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index c6d7ce2775..ecec43ae15 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -472,7 +472,6 @@ public: ConfigOptionFloats filament_toolchange_delay; ConfigOptionInts filament_cooling_time; ConfigOptionStrings filament_ramming_parameters; - ConfigOptionStrings filament_ramming_buttons; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; ConfigOptionString layer_gcode; @@ -530,7 +529,6 @@ protected: OPT_PTR(filament_toolchange_delay); OPT_PTR(filament_cooling_time); OPT_PTR(filament_ramming_parameters); - OPT_PTR(filament_ramming_buttons); OPT_PTR(gcode_comments); OPT_PTR(gcode_flavor); OPT_PTR(layer_gcode); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index c3a988e65d..5049c9cf61 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -211,7 +211,7 @@ const std::vector& Preset::filament_options() static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay", - "filament_cooling_time", "filament_ramming_buttons", "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature", + "filament_cooling_time", "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers", "compatible_printers_condition" diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp index 520b5808e0..5ec8b33eea 100644 --- a/xs/src/slic3r/GUI/RammingChart.hpp +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -13,11 +13,11 @@ wxDECLARE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); class Chart : public wxWindow { public: - Chart(wxWindow* parent, wxRect rect,const std::vector>& initial_buttons,std::vector ramming_speed, float sampling) : + Chart(wxWindow* parent, wxRect rect,const std::vector>& initial_buttons,int ramming_speed_size, float sampling) : wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize()) { m_rect=wxRect(wxPoint(30,0),rect.GetSize()-wxSize(30,30)); - visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed.size(), 20.); + visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed_size, 20.); m_buttons.clear(); if (initial_buttons.size()>0) for (const auto& pair : initial_buttons) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 58d714fc77..ef95da90b4 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -469,7 +469,7 @@ void TabPrint::build() { std::string init_data = (m_config->option("wipe_tower_advanced"))->value; std::cout << "dialog init: " << init_data << std::endl; - WipeTowerDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy + WipingDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy if (dlg.ShowModal() == wxID_OK) { load_key_value("wipe_tower_advanced", dlg.GetValue()); @@ -891,10 +891,10 @@ void TabFilament::build() ramming_dialog_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { - //std::string init_data = (m_config->option("wipe_tower_advanced"))->value; - RammingDialog dlg(this,std::string()); + RammingDialog dlg(this,(m_config->option("filament_ramming_parameters"))->get_at(0)); if (dlg.ShowModal() == wxID_OK) { - //load_key_value("wipe_tower_advanced", dlg.GetValue()); + wxMessageBox("DIALOG OK:\n"+dlg.get_parameters()); + //load_key_value("wipe_tower_advanced", dlg.get_parameters()); } })); return sizer; diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 8bf51e4e50..8e2746329a 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -1,52 +1,13 @@ #include +#include #include "WipeTowerDialog.hpp" -// Human-readable output of Parameters structure -std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par) { - str << "sampling: " << par.sampling << "\n"; - - str << "line widths: "; - for (const auto& a : par.ramming_line_width_multiplicator) str << a << " "; - - str << "line spacing: "; - for (const auto& a : par.ramming_step_multiplicator) str << a << " "; - - str<<"\n\nramming_speeds:\n"; - for (const auto& a : par.ramming_speed) { - for (const auto& b : a) - str << b << " "; - str<<"\n"; - } - str<<"\n\nramming_buttons:\n"; - for (const auto& a : par.ramming_buttons) { - for (const auto& b : a) { - Slic3r::operator <<(str,b); // temporary hack (this << is in the namespace Slic3r) - str << " | "; // the function will be deleted after everything is debugged, anyway - } - str<<"\n"; - } - str<<"\n\nwipe volumes:\n"; - for (const auto& a : par.wipe_volumes) { - for (const auto& b : a) - str << b << " "; - str<<"\n"; - } - str<<"\n\nfilament wipe volumes:\n"; - for (const auto& a : par.filament_wipe_volumes) { - Slic3r::operator <<(str,a); - str << " "; - } - str<<"\n"; - - return str; -} - -RammingDialog::RammingDialog(wxWindow* parent,const std::string& init_data) +RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) : wxDialog(parent, -1, wxT("Ramming customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { this->Centre(); - m_panel_ramming = new RammingPanel(this,Slic3r::WipeTowerParameters(std::string())); + m_panel_ramming = new RammingPanel(this,parameters); m_panel_ramming->Show(true); this->Show(); @@ -60,7 +21,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& init_data) this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { - // m_output_data=read_dialog_values(); + m_output_data = m_panel_ramming->get_parameters(); EndModal(wxID_OK); },wxID_OK); } @@ -69,7 +30,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& init_data) -RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) +RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) : wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) { new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT); @@ -81,8 +42,22 @@ RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p new wxStaticText(this,wxID_ANY,wxString("Ramming line spacing (%):"), wxPoint(500,235), wxSize(200,25),wxALIGN_LEFT); m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,230), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100); + std::stringstream stream{parameters}; + stream >> m_ramming_line_width_multiplicator >> m_ramming_step_multiplicator; + int ramming_speed_size = 0; + float dummy = 0.f; + while (stream >> dummy) + ++ramming_speed_size; + stream.clear(); + stream.get(); - m_chart = new Chart(this,wxRect(10,10,480,360),p.ramming_buttons[0],p.ramming_speed[0],p.sampling); + std::vector> buttons; + float x = 0.f; + float y = 0.f; + while (stream >> x >> y) + buttons.push_back(std::make_pair(x,y)); + + m_chart = new Chart(this,wxRect(10,10,480,360),buttons,ramming_speed_size,0.25f); m_widget_time->SetValue(m_chart->get_time()); m_widget_time->SetDigits(2); @@ -100,26 +75,83 @@ RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p Refresh(this); } - -void RammingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) -{ - if (!m_chart) return; - p.ramming_buttons[0] = m_chart->get_buttons(); - p.ramming_speed[0] = m_chart->get_ramming_speed(p.sampling); - p.ramming_line_width_multiplicator.push_back(m_ramming_line_width_multiplicator/100.f); - p.ramming_step_multiplicator.push_back(m_ramming_step_multiplicator/100.f); -} - - void RammingPanel::line_parameters_changed() { m_ramming_line_width_multiplicator = m_widget_ramming_line_width_multiplicator->GetValue(); m_ramming_step_multiplicator = m_widget_ramming_step_multiplicator->GetValue(); } +std::string RammingPanel::get_parameters() +{ + std::vector speeds = m_chart->get_ramming_speed(0.25f); + std::vector> buttons = m_chart->get_buttons(); + std::stringstream stream; + stream << m_ramming_line_width_multiplicator << " " << m_ramming_step_multiplicator; + for (const float& speed_value : speeds) + stream << " " << speed_value; + stream << "|"; + for (const auto& button : buttons) + stream << " " << button.first << " " << button.second; + return stream.str(); +} + + + + +/* +void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { + p.wipe_volumes.clear(); + p.filament_wipe_volumes.clear(); + for (int i=0;i<4;++i) { + // first go through the full matrix: + p.wipe_volumes.push_back(std::vector()); + for (int j=0;j<4;++j) { + double val = 0.; + edit_boxes[j][i]->GetValue().ToDouble(&val); + p.wipe_volumes[i].push_back((float)val); + } + + // now the filament volumes: + p.filament_wipe_volumes.push_back(std::make_pair(m_old[i]->GetValue(),m_new[i]->GetValue())); + } +} +*/ + + + +WipingDialog::WipingDialog(wxWindow* parent,const std::string& init_data) +: wxDialog(parent, -1, wxT("Wiping customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +{ + this->Centre(); + + Slic3r::WipeTowerParameters parameters(init_data); + /*if (!parameters.validate()) { + wxMessageDialog(this,"Wipe tower parameters not parsed correctly!\nRestoring default settings.","Error",wxICON_ERROR); + parameters.set_defaults(); + }*/ + m_panel_wiping = new WipingPanel(this,parameters); + this->Show(); + + auto main_sizer = new wxBoxSizer(wxVERTICAL); + main_sizer->Add(m_panel_wiping, 1, wxEXPAND); + main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); + SetSizer(main_sizer); + SetMinSize(GetSize()); + main_sizer->SetSizeHints(this); + + this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); + + this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { + m_output_data=read_dialog_values(); + EndModal(wxID_OK); + },wxID_OK); +} + + + WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) : wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) { @@ -153,23 +185,6 @@ WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) Refresh(this); } -void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { - p.wipe_volumes.clear(); - p.filament_wipe_volumes.clear(); - for (int i=0;i<4;++i) { - // first go through the full matrix: - p.wipe_volumes.push_back(std::vector()); - for (int j=0;j<4;++j) { - double val = 0.; - edit_boxes[j][i]->GetValue().ToDouble(&val); - p.wipe_volumes[i].push_back((float)val); - } - - // now the filament volumes: - p.filament_wipe_volumes.push_back(std::make_pair(m_old[i]->GetValue(),m_new[i]->GetValue())); - } -} - void WipingPanel::fill_in_matrix() { wxArrayString choices; choices.Add("sum"); @@ -192,31 +207,5 @@ void WipingPanel::fill_in_matrix() { -WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data) -: wxDialog(parent, -1, wxT("Wiping customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) -{ - this->Centre(); - - Slic3r::WipeTowerParameters parameters(init_data); - if (!parameters.validate()) { - wxMessageDialog(this,"Wipe tower parameters not parsed correctly!\nRestoring default settings.","Error",wxICON_ERROR); - parameters.set_defaults(); - } - m_panel_wiping = new WipingPanel(this,parameters); - this->Show(); - auto main_sizer = new wxBoxSizer(wxVERTICAL); - main_sizer->Add(m_panel_wiping, 1, wxEXPAND); - main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); - SetSizer(main_sizer); - SetMinSize(GetSize()); - main_sizer->SetSizeHints(this); - - this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); - - this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { - m_output_data=read_dialog_values(); - EndModal(wxID_OK); - },wxID_OK); -} diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index f9a9f95248..92624037bd 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -13,14 +13,13 @@ #include "RammingChart.hpp" -// Human-readable output of Parameters structure std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par); class RammingPanel : public wxPanel { public: RammingPanel(wxWindow* parent); - RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); - void fill_parameters(Slic3r::WipeTowerParameters& p); + RammingPanel(wxWindow* parent,const std::string& data); + std::string get_parameters(); private: Chart* m_chart = nullptr; @@ -37,9 +36,11 @@ private: class RammingDialog : public wxDialog { public: - RammingDialog(wxWindow* parent,const std::string& init_data); + RammingDialog(wxWindow* parent,const std::string& parameters); + std::string get_parameters() { return m_output_data; } private: RammingPanel* m_panel_ramming = nullptr; + std::string m_output_data; }; @@ -63,9 +64,9 @@ private: -class WipeTowerDialog : public wxDialog { +class WipingDialog : public wxDialog { public: - WipeTowerDialog(wxWindow* parent,const std::string& init_data); + WipingDialog(wxWindow* parent,const std::string& init_data); std::string GetValue() const { return m_output_data; } @@ -78,7 +79,7 @@ private: std::string read_dialog_values() { Slic3r::WipeTowerParameters p; m_panel_wiping ->fill_parameters(p); - return p.to_string(); + //return p.to_string(); } }; From 7f5bfe3ddc11be07f6dad9a2fdf92182a20bf324 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 16 Mar 2018 12:56:03 +0100 Subject: [PATCH 0050/1150] First visualization of system value changes --- lib/Slic3r/GUI/Plater.pm | 3 +- xs/src/libslic3r/Config.cpp | 12 +++++ xs/src/libslic3r/Config.hpp | 1 + xs/src/slic3r/GUI/Field.cpp | 7 ++- xs/src/slic3r/GUI/Field.hpp | 5 +- xs/src/slic3r/GUI/GUI.cpp | 7 ++- xs/src/slic3r/GUI/GUI.hpp | 1 + xs/src/slic3r/GUI/OptionsGroup.cpp | 8 +++- xs/src/slic3r/GUI/OptionsGroup.hpp | 2 + xs/src/slic3r/GUI/Preset.cpp | 24 +++++++++- xs/src/slic3r/GUI/Preset.hpp | 2 + xs/src/slic3r/GUI/Tab.cpp | 75 ++++++++++++++++++++++++++---- xs/src/slic3r/GUI/Tab.hpp | 3 ++ 13 files changed, 131 insertions(+), 19 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 747567fe5c..2fd4d67983 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1941,7 +1941,8 @@ sub selection_changed { $self->{object_info_manifold}->SetToolTipString($message); $self->{object_info_manifold_warning_icon}->SetToolTipString($message); } else { - $self->{object_info_manifold}->SetLabel(L("Yes")); + $self->{object_info_manifold}->SetLabel(L("Yes")); + $self->{object_info_manifold_warning_icon}->Hide; } } else { $self->{object_info_facets}->SetLabel($object->facets); diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index 0a531849da..a4eaf3072a 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -206,6 +206,18 @@ t_config_option_keys ConfigBase::diff(const ConfigBase &other) const return diff; } +t_config_option_keys ConfigBase::equal(const ConfigBase &other) const +{ + t_config_option_keys equal; + for (const t_config_option_key &opt_key : this->keys()) { + const ConfigOption *this_opt = this->option(opt_key); + const ConfigOption *other_opt = other.option(opt_key); + if (this_opt != nullptr && other_opt != nullptr && *this_opt == *other_opt) + equal.emplace_back(opt_key); + } + return equal; +} + std::string ConfigBase::serialize(const t_config_option_key &opt_key) const { const ConfigOption* opt = this->option(opt_key); diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 1f4e85a349..6eb307c5ce 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -1046,6 +1046,7 @@ public: void apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false); bool equals(const ConfigBase &other) const { return this->diff(other).empty(); } t_config_option_keys diff(const ConfigBase &other) const; + t_config_option_keys equal(const ConfigBase &other) const; std::string serialize(const t_config_option_key &opt_key) const; // Set a configuration value from a string, it will call an overridable handle_legacy() // to resolve renamed and removed configuration keys. diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 984aa05ae2..1d5a25e065 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -28,12 +28,15 @@ namespace Slic3r { namespace GUI { } m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); - m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); - m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ /*on_back_to_initial_value()*/; })); + m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ /*on_back_to_sys_value()*/; })); BUILD(); } + void Field::set_nonsys_btn_icon(const std::string& icon){ + m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(icon)), wxBITMAP_TYPE_PNG)); + } + void Field::on_kill_focus(wxEvent& event) { // Without this, there will be nasty focus bugs on Windows. // Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index b5a4c66faf..2a1f707a7c 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -68,8 +68,8 @@ public: // This is used to avoid recursive invocation of the field change/update by wxWidgets. bool m_disable_change_event {false}; - // This is used to avoid recursive invocation of the field change/update by wxWidgets. bool m_is_modified_value {false}; + bool m_is_nonsys_value; /// Copy of ConfigOption for deduction purposes const ConfigOptionDef m_opt {ConfigOptionDef()}; @@ -96,6 +96,9 @@ public: virtual wxString get_tooltip_text(const wxString& default_string); + // set icon to "UndoToSystemValue" button according to an inheritance of preset + void set_nonsys_btn_icon(const std::string& icon); + Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {}; Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {}; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 262d41a799..fdb97ef72e 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -518,11 +518,14 @@ wxApp* get_app(){ return g_wxApp; } -wxColour* get_modified_label_clr() -{ +wxColour* get_modified_label_clr(){ return new wxColour(253, 88, 0); } +wxColour* get_sys_label_clr(){ + return new wxColour(26, 132, 57); +} + void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string items, bool initial_value) { if (comboCtrl == nullptr) diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 2baa10cb95..75b54652ba 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -79,6 +79,7 @@ void set_preset_bundle(PresetBundle *preset_bundle); AppConfig* get_app_config(); wxApp* get_app(); wxColour* get_modified_label_clr(); +wxColour* get_sys_label_clr(); void add_debug_menu(wxMenuBar *menu, int event_language_change); diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index d672d4b479..7faf9baefc 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -86,6 +86,8 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co field->m_Undo_btn->Hide(); field->m_Undo_to_sys_btn->Hide(); } + if (nonsys_btn_icon != "") + field->set_nonsys_btn_icon(nonsys_btn_icon); // assign function objects for callbacks, etc. return field; @@ -115,8 +117,10 @@ void OptionsGroup::append_line(const Line& line) { const auto& option = option_set.front(); const auto& field = build_field(option); - sizer->Add(field->m_Undo_to_sys_btn); - sizer->Add(field->m_Undo_btn); + auto btn_sizer = new wxBoxSizer(wxHORIZONTAL); + btn_sizer->Add(field->m_Undo_to_sys_btn); + btn_sizer->Add(field->m_Undo_btn); + sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0); if (is_window_field(field)) sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); if (is_sizer_field(field)) diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 42db222254..0fe162b7a0 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -83,6 +83,8 @@ public: wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; + std::string nonsys_btn_icon = ""; + /// Returns a copy of the pointer of the parent wxWindow. /// Accessor function is because users are not allowed to change the parent /// but defining it as const means a lot of const_casts to deal with wx functions. diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 661b11ee0d..a5ab65c9fe 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -226,7 +226,8 @@ const std::vector& Preset::printer_options() "bed_shape", "z_offset", "gcode_flavor", "use_relative_e_distances", "serial_port", "serial_speed", "octoprint_host", "octoprint_apikey", "octoprint_cafile", "use_firmware_retraction", "use_volumetric_e", "variable_layer_height", "single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode", - "between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "default_print_profile", "inherits", + "between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "max_print_height", + "default_print_profile", "inherits", }; s_opts.insert(s_opts.end(), Preset::nozzle_options().begin(), Preset::nozzle_options().end()); } @@ -411,7 +412,7 @@ const Preset* PresetCollection::get_selected_preset_parent() const { auto *inherits = dynamic_cast(this->get_edited_preset().config.option("inherits")); if (inherits == nullptr || inherits->value.empty()) - return nullptr; + return this->get_selected_preset().is_system ? &this->get_selected_preset() : nullptr; // nullptr; const Preset* preset = this->find_preset(inherits->value, false); return (preset == nullptr || preset->is_default || preset->is_external) ? nullptr : preset; } @@ -576,6 +577,25 @@ std::vector PresetCollection::dirty_options(const Preset *edited, c return changed; } +std::vector PresetCollection::system_equal_options() const +{ + const Preset *edited = &this->get_edited_preset(); + const Preset *reference = this->get_selected_preset_parent(); + std::vector equal; + if (edited != nullptr && reference != nullptr) { + equal = reference->config.equal(edited->config); + // The "compatible_printers" option key is handled differently from the others: + // It is not mandatory. If the key is missing, it means it is compatible with any printer. + // If the key exists and it is empty, it means it is compatible with no printer. + std::initializer_list optional_keys{ "compatible_printers", "compatible_printers_condition" }; + for (auto &opt_key : optional_keys) { + if (reference->config.has(opt_key) == edited->config.has(opt_key)) + equal.emplace_back(opt_key); + } + } + return equal; +} + // Select a new preset. This resets all the edits done to the currently selected preset. // If the preset with index idx does not exist, a first visible preset is selected. Preset& PresetCollection::select_preset(size_t idx) diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index a6ce77dfe0..3634c5dd94 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -250,6 +250,8 @@ public: // Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ. std::vector current_different_from_parent_options() const { return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent()); } + // Compare the content of get_selected_preset() with get_selected_preset_parent() configs, return the list of keys where they equal. + std::vector system_equal_options() const; // Update the choice UI from the list of presets. // If show_incompatible, all presets are shown, otherwise only the compatible presets are shown. diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 4a4ba1d73c..894e593c61 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -113,6 +113,14 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) update(); } +void Tab::load_initial_data() +{ + m_config = &m_presets->get_edited_preset().config; + m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ? + "bullet_white.png" : + wxMSW ? "sys_unlock.png" : "lock_open.png"; +} + PageShp Tab::add_options_page(wxString title, std::string icon, bool is_extruder_pages/* = false*/) { // Index of icon in an icon list $self->{icons}. @@ -186,17 +194,19 @@ void Tab::update_changed_ui() // Add new dirty options to m_dirty_options for (auto opt_key : dirty_options){ Field* field = get_field(opt_key); - if (field != nullptr && find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()){ - if (field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(*get_modified_label_clr()); - field->m_Label->Refresh(true); - } + if (field != nullptr && + find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()){ // use bouth of temporary_icons till don't have "undo_icon" field->m_Undo_btn->SetBitmap(wxBitmap(from_u8(wxMSW ? var("action_undo.png") : var("arrow_undo.png")), wxBITMAP_TYPE_PNG)); field->m_is_modified_value = true; m_dirty_options.push_back(opt_key); } + + if (field != nullptr && field->m_Label != nullptr){ + field->m_Label->SetForegroundColour(*get_modified_label_clr()); + field->m_Label->Refresh(true); + } } // Delete clear options from m_dirty_options @@ -219,6 +229,47 @@ void Tab::update_changed_ui() } } } + + + //update system options (colored in green) + auto sys_options = m_presets->system_equal_options(); + // Add new system equal options to m_sys_options + for (auto opt_key : sys_options){ + Field* field = get_field(opt_key); + if (field != nullptr && find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()){ + field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(wxMSW ? var("sys_lock.png") : var("lock.png")), wxBITMAP_TYPE_PNG)); + field->m_is_nonsys_value = false; + + m_sys_options.push_back(opt_key); + } + if (field != nullptr && field->m_Label != nullptr){ + field->m_Label->SetForegroundColour(*get_sys_label_clr()); + field->m_Label->Refresh(true); + } + } + // Delete clear options from m_dirty_options + for (auto i = 0; i < m_sys_options.size(); ++i) + { + const std::string &opt_key = m_sys_options[i]; + Field* field = get_field(opt_key); + if (field != nullptr && find(sys_options.begin(), sys_options.end(), opt_key) == sys_options.end()) + { + // use bouth of temporary_icons till don't have "unlock_icon" + field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); + if (field->m_Label != nullptr && + find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()){ + field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); + field->m_Label->Refresh(true); + } + field->m_is_nonsys_value = true; + std::vector::iterator itr = find(m_sys_options.begin(), m_sys_options.end(), opt_key); + if (itr != m_sys_options.end()){ + m_sys_options.erase(itr); + --i; + } + } + } + } // Update the combo box label of the selected preset based on its "dirty" state, @@ -376,7 +427,7 @@ void Tab::reload_compatible_printers_widget() void TabPrint::build() { m_presets = &m_preset_bundle->prints; - m_config = &m_presets->get_edited_preset().config; + load_initial_data(); auto page = add_options_page(_(L("Layers and perimeters")), "layers.png"); auto optgroup = page->new_optgroup(_(L("Layer height"))); @@ -853,7 +904,7 @@ void TabPrint::OnActivate() void TabFilament::build() { m_presets = &m_preset_bundle->filaments; - m_config = &m_preset_bundle->filaments.get_edited_preset().config; + load_initial_data(); auto page = add_options_page(_(L("Filament")), "spool.png"); auto optgroup = page->new_optgroup(_(L("Filament"))); @@ -1000,8 +1051,7 @@ bool Tab::current_preset_is_dirty() void TabPrinter::build() { m_presets = &m_preset_bundle->printers; - m_config = &m_preset_bundle->printers.get_edited_preset().config; - auto default_config = m_preset_bundle->full_config(); + load_initial_data(); auto *nozzle_diameter = dynamic_cast(m_config->option("nozzle_diameter")); m_initial_extruders_count = m_extruders_count = nozzle_diameter->values.size(); @@ -1414,6 +1464,9 @@ void TabPrinter::update(){ void Tab::load_current_preset() { auto preset = m_presets->get_edited_preset(); + m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ? + "bullet_white.png" : + wxMSW ? "sys_unlock.png" : "lock_open.png"; preset.is_default ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true); update(); // For the printer profile, generate the extruder pages. @@ -1658,6 +1711,8 @@ void Tab::save_preset(std::string name /*= ""*/) update_tab_ui(); // Update the selection boxes at the platter. on_presets_changed(); + + update_changed_ui(); } // Called for a currently selected preset. @@ -1833,6 +1888,8 @@ ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_wid return config; }; + optgroup->nonsys_btn_icon = static_cast(GetParent())->m_nonsys_btn_icon; + vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10); m_optgroups.push_back(optgroup); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index e2dc51ee4e..d3be0e8bc5 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -100,6 +100,7 @@ protected: std::vector m_reload_dependent_tabs = {}; std::vector m_dirty_options = {}; + std::vector m_sys_options = {}; // The two following two event IDs are generated at Plater.pm by calling Wx::NewEventType. wxEventType m_event_value_change = 0; @@ -110,6 +111,7 @@ public: bool m_show_btn_incompatible_presets = false; PresetCollection* m_presets; DynamicPrintConfig* m_config; + std::string m_nonsys_btn_icon; public: Tab() {} @@ -154,6 +156,7 @@ public: virtual void on_preset_loaded(){} virtual void build() = 0; virtual void update() = 0; + void load_initial_data(); void update_dirty(); void update_tab_ui(); void load_config(DynamicPrintConfig config); From b556cec42d25291fa167da745c9b985490b0a8ac Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 16 Mar 2018 13:58:58 +0100 Subject: [PATCH 0051/1150] Got rid of wipe_tower_advanced option --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 2 +- xs/src/libslic3r/Print.cpp | 3 +-- xs/src/libslic3r/PrintConfig.cpp | 24 +++++++++++++++------ xs/src/libslic3r/PrintConfig.hpp | 6 +++--- xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 9 ++++---- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 21 +++++++----------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 10 ++++----- 8 files changed, 40 insertions(+), 37 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 4ecdb5f42e..d5dc4f9629 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -110,7 +110,7 @@ public: // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, float cooling_tube_retraction, - float cooling_tube_length, float parking_pos_retraction, float bridging, bool adhesion, std::string& parameters, + float cooling_tube_length, float parking_pos_retraction, float bridging, bool adhesion, const std::string& parameters, unsigned int initial_tool) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index ae34b47d86..6a804c10d6 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -195,7 +195,6 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), float(this->config.wipe_tower_bridging), bool(this->config.wipe_tower_adhesion), - this->config.wipe_tower_advanced.value,m_tool_ordering.first_extruder()); + /*this->config.wipe_tower_advanced.value*/std::string(""),m_tool_ordering.first_extruder()); //wipe_tower.set_retract(); //wipe_tower.set_zhop(); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 081c05b2d4..6d40b85824 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1773,12 +1773,24 @@ PrintConfigDef::PrintConfigDef() def->cli = "wipe-tower!"; def->default_value = new ConfigOptionBool(false); - def = this->add("wipe_tower_advanced", coString); - def->label = L("Advanced string"); - def->tooltip = L("Advanced tooltip "); - def->sidetext = L("advanced sidetext"); - def->cli = "wipe-tower-advanced=s"; - def->default_value = new ConfigOptionString(""); + def = this->add("wiping_volumes_extruders", coFloats); + def->label = L("Extrusion multiplier"); + def->tooltip = L("This vector saves required volumes to change from/to each tool used on the " + "wipe tower. These values are used to simplify creation of the full purging " + "volumes below. "); + def->cli = "wiping-volumes-extruders=f@"; + def->default_value = new ConfigOptionFloats { 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f }; + + def = this->add("wiping_volumes_matrix", coFloats); + def->label = L("Extrusion multiplier"); + def->tooltip = L("This matrix describes volumes (in cubic milimetres) required to purge the" + " new filament on the wipe tower for any given pair of tools. "); + def->cli = "wiping-volumes-matrix=f@"; + def->default_value = new ConfigOptionFloats { 0.f, 100.f, 100.f, 100.f, 100.f, + 100.f, 0.f, 100.f, 100.f, 100.f, + 100.f, 100.f, 0.f, 100.f, 100.f, + 100.f, 100.f, 100.f, 0.f, 100.f, + 100.f, 100.f, 100.f, 100.f, 0.f }; def = this->add("wipe_tower_x", coFloat); def->label = L("Position X"); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index ecec43ae15..af0c814e12 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -500,7 +500,8 @@ public: ConfigOptionFloat cooling_tube_retraction; ConfigOptionFloat cooling_tube_length; ConfigOptionFloat parking_pos_retraction; - + + std::string get_extrusion_axis() const { return @@ -622,7 +623,6 @@ public: ConfigOptionInt threads; ConfigOptionBools wipe; ConfigOptionBool wipe_tower; - ConfigOptionString wipe_tower_advanced; ConfigOptionFloat wipe_tower_x; ConfigOptionFloat wipe_tower_y; ConfigOptionFloat wipe_tower_width; @@ -690,7 +690,6 @@ protected: OPT_PTR(threads); OPT_PTR(wipe); OPT_PTR(wipe_tower); - OPT_PTR(wipe_tower_advanced); OPT_PTR(wipe_tower_x); OPT_PTR(wipe_tower_y); OPT_PTR(wipe_tower_width); @@ -736,6 +735,7 @@ class FullPrintConfig : public: // Validate the FullPrintConfig. Returns an empty string on success, otherwise an error message is returned. std::string validate(); + protected: // Protected constructor to be called to initialize ConfigCache::m_default. FullPrintConfig(int) : PrintObjectConfig(0), PrintRegionConfig(0), PrintConfig(0), HostConfig(0) {} diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 5049c9cf61..e2706c5dba 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -198,7 +198,7 @@ const std::vector& Preset::print_options() "ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width", "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", - "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower_advanced", "wipe_tower", "wipe_tower_x", + "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_adhesion", "wipe_tower_bridging", "compatible_printers", "compatible_printers_condition" diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ef95da90b4..473e0b13c8 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -467,13 +467,12 @@ void TabPrint::build() sizer->Add(m_wipe_tower_btn); m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { - std::string init_data = (m_config->option("wipe_tower_advanced"))->value; - std::cout << "dialog init: " << init_data << std::endl; - WipingDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy + //auto init_data = (m_config->option("wiping_volumes_matrix"))->values; + //WipingDialog dlg(this,std::vector(init_data.begin(), init_data.end())); // dlg lives on stack, no need to call Destroy if (dlg.ShowModal() == wxID_OK) { - load_key_value("wipe_tower_advanced", dlg.GetValue()); - std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl; + //load_key_value("wipe_tower_advanced", dlg.GetValue()); + //std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl; } })); return sizer; diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 8e2746329a..1c69285b7b 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -122,17 +122,12 @@ void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { -WipingDialog::WipingDialog(wxWindow* parent,const std::string& init_data) +WipingDialog::WipingDialog(wxWindow* parent,const std::vector& init_data) : wxDialog(parent, -1, wxT("Wiping customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { this->Centre(); - - Slic3r::WipeTowerParameters parameters(init_data); - /*if (!parameters.validate()) { - wxMessageDialog(this,"Wipe tower parameters not parsed correctly!\nRestoring default settings.","Error",wxICON_ERROR); - parameters.set_defaults(); - }*/ - m_panel_wiping = new WipingPanel(this,parameters); + + m_panel_wiping = new WipingPanel(this,init_data); this->Show(); auto main_sizer = new wxBoxSizer(wxVERTICAL); @@ -145,14 +140,14 @@ WipingDialog::WipingDialog(wxWindow* parent,const std::string& init_data) this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { - m_output_data=read_dialog_values(); + //m_output_data=read_dialog_values(); EndModal(wxID_OK); },wxID_OK); } -WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) +WipingPanel::WipingPanel(wxWindow* parent,const std::vector& data) : wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) { const int N = 4; // number of extruders @@ -162,8 +157,8 @@ WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) m_widget_button = new wxButton(this,wxID_ANY,"-> Fill in the matrix ->",wxPoint(300,130),wxSize(175,50)); for (int i=0;iDisable(); else - edit_boxes[i][j]->SetValue(wxString("")<SetValue(wxString("")<& data); void fill_parameters(Slic3r::WipeTowerParameters& p); private: @@ -66,15 +66,13 @@ private: class WipingDialog : public wxDialog { public: - WipingDialog(wxWindow* parent,const std::string& init_data); - - std::string GetValue() const { return m_output_data; } + WipingDialog(wxWindow* parent,const std::vector& init_data); + std::vector get_value() const { return m_output_data; } private: - std::string m_file_name="config_wipe_tower"; WipingPanel* m_panel_wiping = nullptr; - std::string m_output_data = ""; + std::vector m_output_data; std::string read_dialog_values() { Slic3r::WipeTowerParameters p; From 7e6887cca82e5c43279c55de64972b695d524d61 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 16 Mar 2018 17:25:11 +0100 Subject: [PATCH 0052/1150] Completed UI for system value changes --- xs/src/slic3r/GUI/Field.cpp | 10 +++++--- xs/src/slic3r/GUI/Field.hpp | 7 ++++-- xs/src/slic3r/GUI/OptionsGroup.cpp | 21 +++++++++++++++-- xs/src/slic3r/GUI/OptionsGroup.hpp | 7 +++++- xs/src/slic3r/GUI/Tab.cpp | 38 +++++++++++++++++++++++++----- 5 files changed, 69 insertions(+), 14 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 1d5a25e065..3247bc8b84 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -28,7 +28,7 @@ namespace Slic3r { namespace GUI { } m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); - m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ /*on_back_to_sys_value()*/; })); + m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); BUILD(); } @@ -53,12 +53,16 @@ namespace Slic3r { namespace GUI { m_on_change(m_opt_id, get_value()); } - void Field::on_back_to_initial_value() - { + void Field::on_back_to_initial_value(){ if (m_back_to_initial_value != nullptr && m_is_modified_value) m_back_to_initial_value(m_opt_id); } + void Field::on_back_to_sys_value(){ + if (m_back_to_sys_value != nullptr && m_is_nonsys_value) + m_back_to_sys_value(m_opt_id); + } + wxString Field::get_tooltip_text(const wxString& default_string) { wxString tooltip_text(""); diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 2a1f707a7c..cb1df9d81c 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -52,6 +52,8 @@ protected: void on_change_field(); /// Call the attached m_back_to_initial_value method. void on_back_to_initial_value(); + /// Call the attached m_back_to_sys_value method. + void on_back_to_sys_value(); public: /// parent wx item, opportunity to refactor (probably not necessary - data duplication) @@ -63,13 +65,14 @@ public: /// Function object to store callback passed in from owning object. t_change m_on_change {nullptr}; - /// Function object to store callback passed in from owning object. + /// Function object to store callback passed in from owning object. t_back_to_init m_back_to_initial_value{ nullptr }; + t_back_to_init m_back_to_sys_value{ nullptr }; // This is used to avoid recursive invocation of the field change/update by wxWidgets. bool m_disable_change_event {false}; bool m_is_modified_value {false}; - bool m_is_nonsys_value; + bool m_is_nonsys_value {true}; /// Copy of ConfigOption for deduction purposes const ConfigOptionDef m_opt {ConfigOptionDef()}; diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 7faf9baefc..37f3fea68d 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -82,6 +82,10 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co if (!this->m_disabled) this->back_to_initial_value(opt_id); }; + field->m_back_to_sys_value = [this](std::string opt_id){ + if (!this->m_disabled) + this->back_to_sys_value(opt_id); + }; if (!m_is_tab_opt) { field->m_Undo_btn->Hide(); field->m_Undo_to_sys_btn->Hide(); @@ -297,7 +301,20 @@ void ConfigOptionsGroup::back_to_initial_value(const std::string opt_key) { if (m_get_initial_config == nullptr) return; - DynamicPrintConfig config = m_get_initial_config(); + back_to_config_value(m_get_initial_config(), opt_key); +} + +void ConfigOptionsGroup::back_to_sys_value(const std::string opt_key) +{ + if (m_get_sys_config == nullptr) + return; + if (!have_sys_config()) + return; + back_to_config_value(m_get_sys_config(), opt_key); +} + +void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, const std::string opt_key) +{ boost::any value; if (opt_key == "extruders_count"){ auto *nozzle_diameter = dynamic_cast(config.option("nozzle_diameter")); @@ -345,7 +362,7 @@ boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index, } } -boost::any ConfigOptionsGroup::get_config_value(DynamicPrintConfig& config, std::string opt_key, int opt_index/* = -1*/) +boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config, std::string opt_key, int opt_index /*= -1*/) { size_t idx = opt_index == -1 ? 0 : opt_index; diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 0fe162b7a0..3efa427304 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -79,6 +79,8 @@ public: column_t extra_column {nullptr}; t_change m_on_change {nullptr}; std::function m_get_initial_config{ nullptr }; + std::function m_get_sys_config{ nullptr }; + std::function have_sys_config{ nullptr }; wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; @@ -151,6 +153,7 @@ protected: virtual void on_kill_focus (){}; virtual void on_change_OG(t_config_option_key opt_id, boost::any value); virtual void back_to_initial_value(const std::string opt_key){}; + virtual void back_to_sys_value(const std::string opt_key){}; }; class ConfigOptionsGroup: public OptionsGroup { @@ -179,11 +182,13 @@ public: void on_change_OG(t_config_option_key opt_id, boost::any value) override; void back_to_initial_value(const std::string opt_key) override; + void back_to_sys_value(const std::string opt_key) override; + void back_to_config_value(const DynamicPrintConfig& config, const std::string opt_key); void on_kill_focus() override{ reload_config();} void reload_config(); boost::any config_value(std::string opt_key, int opt_index, bool deserialize); // return option value from config - boost::any get_config_value(DynamicPrintConfig& config, std::string opt_key, int opt_index = -1); + boost::any get_config_value(const DynamicPrintConfig& config, std::string opt_key, int opt_index = -1); Field* get_fieldc(t_config_option_key opt_key, int opt_index); }; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 894e593c61..c101f1bd32 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -97,7 +97,6 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) if (selected_item >= 0){ std::string selected_string = m_presets_choice->GetString(selected_item).ToUTF8().data(); select_preset(selected_string); - update_changed_ui(); } })); @@ -247,6 +246,20 @@ void Tab::update_changed_ui() field->m_Label->Refresh(true); } } + if (sys_options.empty() && !m_sys_options.empty()){ + for (auto opt_key : m_config->keys()){ + Field* field = get_field(opt_key); + if (field != nullptr){ + field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); + field->m_is_nonsys_value = false; + if (field->m_Label != nullptr){ + field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); + field->m_Label->Refresh(true); + } + } + } + m_sys_options.resize(0); + } // Delete clear options from m_dirty_options for (auto i = 0; i < m_sys_options.size(); ++i) { @@ -646,9 +659,11 @@ void TabPrint::update() { Freeze(); + double fill_density = m_config->option("fill_density")->value; + if (m_config->opt_bool("spiral_vase") && !(m_config->opt_int("perimeters") == 1 && m_config->opt_int("top_solid_layers") == 0 && - m_config->option("fill_density")->value == 0)) { + fill_density == 0)) { wxString msg_text = _(L("The Spiral Vase mode requires:\n" "- one perimeter\n" "- no top solid layers\n" @@ -665,11 +680,13 @@ void TabPrint::update() new_conf.set_key_value("support_material", new ConfigOptionBool(false)); new_conf.set_key_value("support_material_enforce_layers", new ConfigOptionInt(0)); new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(false)); + fill_density = 0; } else { new_conf.set_key_value("spiral_vase", new ConfigOptionBool(false)); } load_config(new_conf); + on_value_change("fill_density", fill_density); } auto first_layer_height = m_config->option("first_layer_height")->value; @@ -783,7 +800,6 @@ void TabPrint::update() "\nShall I switch to rectilinear fill pattern?")); auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Infill")), wxICON_WARNING | wxYES | wxNO); DynamicPrintConfig new_conf = *m_config; - double fill_density; if (dialog->ShowModal() == wxID_YES) { new_conf.set_key_value("fill_pattern", new ConfigOptionEnum(ipRectilinear)); fill_density = 100; @@ -1464,15 +1480,16 @@ void TabPrinter::update(){ void Tab::load_current_preset() { auto preset = m_presets->get_edited_preset(); - m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ? - "bullet_white.png" : - wxMSW ? "sys_unlock.png" : "lock_open.png"; + preset.is_default ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true); update(); // For the printer profile, generate the extruder pages. on_preset_loaded(); // Reload preset pages with the new configuration values. reload_config(); + m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ? + "bullet_white.png" : + wxMSW ? "sys_unlock.png" : "lock_open.png"; // use CallAfter because some field triggers schedule on_change calls using CallAfter, // and we don't want them to be called after this update_dirty() as they would mark the @@ -1888,6 +1905,15 @@ ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_wid return config; }; + optgroup->m_get_sys_config = [this](){ + DynamicPrintConfig config = static_cast(GetParent())->m_presets->get_selected_preset_parent()->config; + return config; + }; + + optgroup->have_sys_config = [this](){ + return static_cast(GetParent())->m_presets->get_selected_preset_parent() != nullptr; + }; + optgroup->nonsys_btn_icon = static_cast(GetParent())->m_nonsys_btn_icon; vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10); From e41eff91868063326fc4e163c33a6201d0fe8149 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 19 Mar 2018 15:30:54 +0100 Subject: [PATCH 0053/1150] Wiping volumes options temporarily added to Print Settings --- xs/src/libslic3r/PrintConfig.hpp | 4 ++++ xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/PresetBundle.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 7 ++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 3488b5c4f0..b35cf9cf1c 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -630,6 +630,8 @@ public: ConfigOptionFloat wipe_tower_rotation_angle; ConfigOptionFloat wipe_tower_bridging; ConfigOptionBool wipe_tower_adhesion; + ConfigOptionFloats wiping_volumes_matrix; + ConfigOptionFloats wiping_volumes_extruders; ConfigOptionFloat z_offset; protected: @@ -698,6 +700,8 @@ protected: OPT_PTR(wipe_tower_rotation_angle); OPT_PTR(wipe_tower_bridging); OPT_PTR(wipe_tower_adhesion); + OPT_PTR(wiping_volumes_matrix); + OPT_PTR(wiping_volumes_extruders); OPT_PTR(z_offset); } }; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 57fa977749..847c7e523b 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -200,7 +200,7 @@ const std::vector& Preset::print_options() "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_adhesion", "wipe_tower_bridging", - "compatible_printers", "compatible_printers_condition" + "wiping_volumes_matrix", "wiping_volumes_extruders", "compatible_printers", "compatible_printers_condition" }; return s_opts; diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 7d2501a655..668b9ee125 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -32,7 +32,7 @@ namespace Slic3r { -static std::vector s_project_options { +static std::vector s_project_options { }; PresetBundle::PresetBundle() : diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 8cec658b32..6e978f0837 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -528,11 +528,12 @@ void TabPrint::build() sizer->Add(m_wipe_tower_btn); m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { - //auto init_data = (m_config->option("wiping_volumes_matrix"))->values; - //WipingDialog dlg(this,std::vector(init_data.begin(), init_data.end())); // dlg lives on stack, no need to call Destroy + std::vector init_data = (m_config->option("wiping_volumes_matrix"))->values; + load_key_value("wiping_volumes_matrix", a); + WipingDialog dlg(this,std::vector(init_data.begin(), init_data.end())); // dlg lives on stack, no need to call Destroy if (dlg.ShowModal() == wxID_OK) { - //load_key_value("wipe_tower_advanced", dlg.GetValue()); + //load_key_value("wiping_volumes_matrix", dlg.GetValue()); //std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl; } })); From 349a8a88aec920c0970fe384f6ee94cab5e8a9a9 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 19 Mar 2018 15:35:31 +0100 Subject: [PATCH 0054/1150] Bug fix: speed for finish_layer was not properly set --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index ab54296154..59fa7dceda 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -1014,7 +1014,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() else box.expand(-m_perimeter_width); } else i=2; // only draw the inner perimeter, outer has been already drawn by tool_change(...) - writer.rectangle(box.ld,box.rd.x-box.ld.x,box.ru.y-box.rd.y); + writer.rectangle(box.ld,box.rd.x-box.ld.x,box.ru.y-box.rd.y,2900*speed_factor); } // we are in one of the corners, travel to ld along the perimeter: diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 6e978f0837..d220130fdb 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -529,7 +529,6 @@ void TabPrint::build() m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { std::vector init_data = (m_config->option("wiping_volumes_matrix"))->values; - load_key_value("wiping_volumes_matrix", a); WipingDialog dlg(this,std::vector(init_data.begin(), init_data.end())); // dlg lives on stack, no need to call Destroy if (dlg.ShowModal() == wxID_OK) { From 76b280c64caab570c5b3e3fb6704cfa9a767797d Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 19 Mar 2018 15:53:49 +0100 Subject: [PATCH 0055/1150] Removed parameter 'wipe_tower_adhesion', it will always be true --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 3 +-- xs/src/libslic3r/Print.cpp | 3 +-- xs/src/libslic3r/PrintConfig.cpp | 7 ------- xs/src/libslic3r/PrintConfig.hpp | 2 -- xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 1 - 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index d5dc4f9629..8cfc5872c4 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -110,7 +110,7 @@ public: // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, float cooling_tube_retraction, - float cooling_tube_length, float parking_pos_retraction, float bridging, bool adhesion, const std::string& parameters, + float cooling_tube_length, float parking_pos_retraction, float bridging, const std::string& parameters, unsigned int initial_tool) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), @@ -126,7 +126,6 @@ public: m_par(parameters) { m_bridging = bridging; - m_adhesion = adhesion; for (size_t i = 0; i < 4; ++ i) { // Extruder specific parameters. diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index a126d84b7b..0167b8ba75 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -202,7 +202,6 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_width.value), float(this->config.wipe_tower_per_color_wipe.value), float(this->config.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), - float(this->config.wipe_tower_bridging), bool(this->config.wipe_tower_adhesion), + float(this->config.wipe_tower_bridging), /*this->config.wipe_tower_advanced.value*/std::string(""),m_tool_ordering.first_extruder()); //wipe_tower.set_retract(); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index a09b896c96..ff426c9a25 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1840,13 +1840,6 @@ PrintConfigDef::PrintConfigDef() def->sidetext = L("mm"); def->cli = "wipe-tower-bridging=f"; def->default_value = new ConfigOptionFloat(10.); - - def = this->add("wipe_tower_adhesion", coBool); - def->label = L("Increase first layer adhesion"); - def->tooltip = L("This prevents using sparse infill on the first layer, if it would be " - "normally applied. Dense infill is used instead. "); - def->cli = "wipe-tower_adhesion!"; - def->default_value = new ConfigOptionBool(true); def = this->add("xy_size_compensation", coFloat); def->label = L("XY Size Compensation"); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index b35cf9cf1c..d184a21611 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -629,7 +629,6 @@ public: ConfigOptionFloat wipe_tower_per_color_wipe; ConfigOptionFloat wipe_tower_rotation_angle; ConfigOptionFloat wipe_tower_bridging; - ConfigOptionBool wipe_tower_adhesion; ConfigOptionFloats wiping_volumes_matrix; ConfigOptionFloats wiping_volumes_extruders; ConfigOptionFloat z_offset; @@ -699,7 +698,6 @@ protected: OPT_PTR(wipe_tower_per_color_wipe); OPT_PTR(wipe_tower_rotation_angle); OPT_PTR(wipe_tower_bridging); - OPT_PTR(wipe_tower_adhesion); OPT_PTR(wiping_volumes_matrix); OPT_PTR(wiping_volumes_extruders); OPT_PTR(z_offset); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 847c7e523b..99d003f7a9 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -199,7 +199,7 @@ const std::vector& Preset::print_options() "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", - "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_adhesion", "wipe_tower_bridging", + "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_bridging", "wiping_volumes_matrix", "wiping_volumes_extruders", "compatible_printers", "compatible_printers_condition" }; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index d220130fdb..e3e773f7d0 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -520,7 +520,6 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_per_color_wipe"); optgroup->append_single_option_line("wipe_tower_rotation_angle"); optgroup->append_single_option_line("wipe_tower_bridging"); - optgroup->append_single_option_line("wipe_tower_adhesion"); line = { _(L("Advanced")), "" }; line.widget = [this](wxWindow* parent){ m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); From f72bb895219f50164892ab3413ea57abced3fdc0 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 19 Mar 2018 17:21:37 +0100 Subject: [PATCH 0056/1150] Reset to system value works for Extruders too --- xs/src/slic3r/GUI/Tab.cpp | 86 ++++++++++++++++++++++++++++++--------- xs/src/slic3r/GUI/Tab.hpp | 1 + 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index c101f1bd32..464734f9c9 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -160,34 +160,78 @@ void add_correct_opts_to_dirty_options(const std::string &opt_key, std::vector +void add_correct_opts_to_sys_options(const std::string &opt_key, std::vector *vec, TabPrinter *tab) +{ + const Preset* sys_preset = tab->m_presets->get_selected_preset_parent(); + if (sys_preset == nullptr) + return; + T *opt_cur = static_cast(tab->m_config->option(opt_key)); + const T *opt_sys = static_cast(sys_preset->config.option(opt_key)); + int opt_max_id = opt_sys->values.size()-1; + for (int i = 0; i < opt_cur->values.size(); i++) + { + int init_id = i <= opt_max_id ? i : 0; + if (opt_cur->values[i] == opt_sys->values[init_id]) + vec->emplace_back(opt_key + "#" + std::to_string(i)); + } +} + // Update UI according to changes void Tab::update_changed_ui() { auto dirty_options = m_presets->current_dirty_options(); + auto sys_options = m_presets->system_equal_options(); + if (name() == "printer"){ // Update dirty_options in case changes of Extruder's options TabPrinter* tab = static_cast(this); - std::vector new_dirty; + std::vector new_options; for (auto opt_key : dirty_options) { switch (m_config->option(opt_key)->type()) { - case coInts: add_correct_opts_to_dirty_options(opt_key, &new_dirty, tab); break; - case coBools: add_correct_opts_to_dirty_options(opt_key, &new_dirty, tab); break; - case coFloats: add_correct_opts_to_dirty_options(opt_key, &new_dirty, tab); break; - case coStrings: add_correct_opts_to_dirty_options(opt_key, &new_dirty, tab); break; - case coPercents:add_correct_opts_to_dirty_options(opt_key, &new_dirty, tab); break; - case coPoints: add_correct_opts_to_dirty_options(opt_key, &new_dirty, tab); break; - default: new_dirty.emplace_back(opt_key); break; + case coInts: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; + case coBools: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; + case coFloats: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; + case coStrings: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; + case coPercents:add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; + case coPoints: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; + default: new_options.emplace_back(opt_key); break; } } dirty_options.resize(0); - dirty_options = new_dirty; - if (tab->m_initial_extruders_count != tab->m_extruders_count){ + dirty_options = new_options; + if (tab->m_initial_extruders_count != tab->m_extruders_count) dirty_options.emplace_back("extruders_count"); + + new_options.resize(0); + std::initializer_list optional_keys{"bed_shape", "compatible_printers", "compatible_printers_condition" }; + for (auto &opt_key : optional_keys) { + if (find(sys_options.begin(), sys_options.end(),opt_key) != sys_options.end()) + new_options.emplace_back(opt_key); } + for (auto opt_key : m_config->keys()) + { + if (opt_key == "bed_shape") continue; + switch (m_config->option(opt_key)->type()) + { + case coInts: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; + case coBools: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; + case coFloats: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; + case coStrings: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; + case coPercents:add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; + case coPoints: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; + default: new_options.emplace_back(opt_key); break; + } + } + + sys_options.resize(0); + sys_options = new_options; + if (tab->m_sys_extruders_count == tab->m_extruders_count) + sys_options.emplace_back("extruders_count"); } // Add new dirty options to m_dirty_options @@ -231,7 +275,6 @@ void Tab::update_changed_ui() //update system options (colored in green) - auto sys_options = m_presets->system_equal_options(); // Add new system equal options to m_sys_options for (auto opt_key : sys_options){ Field* field = get_field(opt_key); @@ -265,16 +308,18 @@ void Tab::update_changed_ui() { const std::string &opt_key = m_sys_options[i]; Field* field = get_field(opt_key); - if (field != nullptr && find(sys_options.begin(), sys_options.end(), opt_key) == sys_options.end()) + if (find(sys_options.begin(), sys_options.end(), opt_key) == sys_options.end()) { - // use bouth of temporary_icons till don't have "unlock_icon" - field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); - if (field->m_Label != nullptr && - find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()){ - field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); - field->m_Label->Refresh(true); + if (field != nullptr){ + // use bouth of temporary_icons till don't have "unlock_icon" + field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); + if (field->m_Label != nullptr && + find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()){ + field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); + field->m_Label->Refresh(true); + } + field->m_is_nonsys_value = true; } - field->m_is_nonsys_value = true; std::vector::iterator itr = find(m_sys_options.begin(), m_sys_options.end(), opt_key); if (itr != m_sys_options.end()){ m_sys_options.erase(itr); @@ -1071,6 +1116,7 @@ void TabPrinter::build() auto *nozzle_diameter = dynamic_cast(m_config->option("nozzle_diameter")); m_initial_extruders_count = m_extruders_count = nozzle_diameter->values.size(); + m_sys_extruders_count = static_cast(m_presets->get_selected_preset_parent()->config.option("nozzle_diameter"))->values.size(); auto page = add_options_page(_(L("General")), "printer_empty.png"); auto optgroup = page->new_optgroup(_(L("Size and coordinates"))); @@ -1729,6 +1775,8 @@ void Tab::save_preset(std::string name /*= ""*/) // Update the selection boxes at the platter. on_presets_changed(); + if (m_name == "printer") + static_cast(this)->m_initial_extruders_count = static_cast(this)->m_extruders_count; update_changed_ui(); } diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index d3be0e8bc5..a2cf648e96 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -228,6 +228,7 @@ public: size_t m_extruders_count; size_t m_initial_extruders_count; + size_t m_sys_extruders_count; std::vector m_extruder_pages; TabPrinter() {} From 1f3f109263af5a7dccde6371bc7e75da335ea79f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 20 Mar 2018 09:31:42 +0100 Subject: [PATCH 0057/1150] Out of bed detection - Fixed false detection due to float precision --- xs/src/libslic3r/Model.cpp | 4 ++++ xs/src/slic3r/GUI/3DScene.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 6f1ce1ce5c..ad2ce54cd2 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -450,6 +450,8 @@ bool Model::fits_print_volume(const DynamicPrintConfig* config) const BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config->opt_float("max_print_height"))); + // Allow the objects to protrude below the print bed + print_volume.min.z = -1e10; return print_volume.contains(transformed_bounding_box()); } @@ -459,6 +461,8 @@ bool Model::fits_print_volume(const FullPrintConfig &config) const return true; BoundingBox bed_box_2D = get_extents(Polygon::new_scale(config.bed_shape.values)); BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config.max_print_height)); + // Allow the objects to protrude below the print bed + print_volume.min.z = -1e10; return print_volume.contains(transformed_bounding_box()); } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index f6be96a783..cb5d580c11 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -627,6 +627,8 @@ void GLVolumeCollection::update_outside_state(const DynamicPrintConfig* config, BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config->opt_float("max_print_height"))); + // Allow the objects to protrude below the print bed + print_volume.min.z = -1e10; for (GLVolume* volume : this->volumes) { From 6298a2849484def97e5af36943647c84497812ab Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 20 Mar 2018 11:59:33 +0100 Subject: [PATCH 0058/1150] Disabled back face culling to show broken geometry --- lib/Slic3r/GUI/3DScene.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 75a154281f..b4f1849e87 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1316,12 +1316,18 @@ sub Render { $self->mark_volumes_for_layer_height; $self->volumes->set_print_box($self->bed_bounding_box->x_min, $self->bed_bounding_box->y_min, 0.0, $self->bed_bounding_box->x_max, $self->bed_bounding_box->y_max, $self->{config}->get('max_print_height')); $self->volumes->update_outside_state($self->{config}, 0); + # do not cull backfaces to show broken geometry, if any + glDisable(GL_CULL_FACE); } $self->{plain_shader}->enable if $self->{plain_shader}; $self->volumes->render_VBOs; $self->{plain_shader}->disable; + glEnable(GL_CULL_FACE) if ($self->enable_picking); } else { + # do not cull backfaces to show broken geometry, if any + glDisable(GL_CULL_FACE) if ($self->enable_picking); $self->volumes->render_legacy; + glEnable(GL_CULL_FACE) if ($self->enable_picking); } # draw cutting plane @@ -1358,6 +1364,9 @@ sub draw_volumes { # $fakecolor is a boolean indicating, that the objects shall be rendered in a color coding the object index for picking. my ($self, $fakecolor) = @_; + # do not cull backfaces to show broken geometry, if any + glDisable(GL_CULL_FACE); + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1385,6 +1394,8 @@ sub draw_volumes { } glDisableClientState(GL_NORMAL_ARRAY); glDisable(GL_BLEND); + + glEnable(GL_CULL_FACE); if (defined $self->cutting_plane_z) { glLineWidth(2); From f99aaa1191245a61ded3e8c70ffdd6548612a8dd Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 20 Mar 2018 13:01:50 +0100 Subject: [PATCH 0059/1150] Out of bed detection - New colors for out of bed state --- lib/Slic3r/GUI/3DScene.pm | 11 +++++------ xs/src/slic3r/GUI/3DScene.cpp | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index b4f1849e87..420ea493ae 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1823,6 +1823,7 @@ sub _fragment_shader_Gouraud { return <<'FRAGMENT'; #version 110 +const vec4 OUTSIDE_COLOR = vec4(0.24, 0.42, 0.62, 1.0); const vec3 ZERO = vec3(0.0, 0.0, 0.0); // x = tainted, y = specular; @@ -1835,13 +1836,11 @@ uniform vec4 uniform_color; void main() { - gl_FragColor = vec4(intensity.y, intensity.y, intensity.y, 0.0) + uniform_color * intensity.x; + // if the fragment is outside the print volume use predefined color + vec4 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? OUTSIDE_COLOR : uniform_color; - // if the fragment is outside the print volume darken it and set it as transparent - if (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) - gl_FragColor = vec4(mix(gl_FragColor.xyz, ZERO, 0.5), 0.5 * uniform_color.a); - else - gl_FragColor.a = uniform_color.a; + gl_FragColor = vec4(intensity.y, intensity.y, intensity.y, 0.0) + color * intensity.x; + gl_FragColor.a = color.a; } FRAGMENT diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index cb5d580c11..0bd7008d25 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -194,8 +194,8 @@ void GLIndexedVertexArray::render( const float GLVolume::SELECTED_COLOR[4] = { 0.0f, 1.0f, 0.0f, 1.0f }; const float GLVolume::HOVER_COLOR[4] = { 0.4f, 0.9f, 0.1f, 1.0f }; -const float GLVolume::OUTSIDE_COLOR[4] = { 0.75f, 0.0f, 0.75f, 1.0f }; -const float GLVolume::SELECTED_OUTSIDE_COLOR[4] = { 1.0f, 0.0f, 1.0f, 1.0f }; +const float GLVolume::OUTSIDE_COLOR[4] = { 0.0f, 0.38f, 0.8f, 1.0f }; +const float GLVolume::SELECTED_OUTSIDE_COLOR[4] = { 0.19f, 0.58f, 1.0f, 1.0f }; void GLVolume::set_render_color(float r, float g, float b, float a) { From a923062167ed8f0632eda1eeca304e4aecaeec71 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 20 Mar 2018 13:50:51 +0100 Subject: [PATCH 0060/1150] Purging volume dialog improved and connected to configuration layer --- xs/src/slic3r/GUI/Tab.cpp | 12 +- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 175 +++++++++++++++++--------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 34 ++--- 3 files changed, 141 insertions(+), 80 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index e3e773f7d0..146696d1ea 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -527,12 +527,16 @@ void TabPrint::build() sizer->Add(m_wipe_tower_btn); m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { - std::vector init_data = (m_config->option("wiping_volumes_matrix"))->values; - WipingDialog dlg(this,std::vector(init_data.begin(), init_data.end())); // dlg lives on stack, no need to call Destroy + std::vector init_matrix = (m_config->option("wiping_volumes_matrix"))->values; + std::vector init_extruders = (m_config->option("wiping_volumes_extruders"))->values; + + WipingDialog dlg(this,std::vector(init_matrix.begin(),init_matrix.end()),std::vector(init_extruders.begin(),init_extruders.end())); if (dlg.ShowModal() == wxID_OK) { - //load_key_value("wiping_volumes_matrix", dlg.GetValue()); - //std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl; + std::vector matrix = dlg.get_matrix(); + std::vector extruders = dlg.get_extruders(); + (m_config->option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(),matrix.end()); + (m_config->option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(),extruders.end()); } })); return sizer; diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 1c69285b7b..fc3d30a5d4 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -2,6 +2,11 @@ #include #include "WipeTowerDialog.hpp" +//! macro used to mark string used at localization, +//! return same string +#define L(s) s + + RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) : wxDialog(parent, -1, wxT("Ramming customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) @@ -97,37 +102,12 @@ std::string RammingPanel::get_parameters() - - - - -/* -void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { - p.wipe_volumes.clear(); - p.filament_wipe_volumes.clear(); - for (int i=0;i<4;++i) { - // first go through the full matrix: - p.wipe_volumes.push_back(std::vector()); - for (int j=0;j<4;++j) { - double val = 0.; - edit_boxes[j][i]->GetValue().ToDouble(&val); - p.wipe_volumes[i].push_back((float)val); - } - - // now the filament volumes: - p.filament_wipe_volumes.push_back(std::make_pair(m_old[i]->GetValue(),m_new[i]->GetValue())); - } -} -*/ - - - -WipingDialog::WipingDialog(wxWindow* parent,const std::vector& init_data) -: wxDialog(parent, -1, wxT("Wiping customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +WipingDialog::WipingDialog(wxWindow* parent,const std::vector& matrix, const std::vector& extruders) +: wxDialog(parent, -1, wxT(L("Wipe tower - Purging volume adjustment")), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { this->Centre(); - m_panel_wiping = new WipingPanel(this,init_data); + m_panel_wiping = new WipingPanel(this,matrix,extruders); this->Show(); auto main_sizer = new wxBoxSizer(wxVERTICAL); @@ -140,59 +120,85 @@ WipingDialog::WipingDialog(wxWindow* parent,const std::vector& init_data) this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { - //m_output_data=read_dialog_values(); + m_output_matrix = m_panel_wiping->read_matrix_values(); + m_output_extruders = m_panel_wiping->read_extruders_values(); EndModal(wxID_OK); },wxID_OK); } -WipingPanel::WipingPanel(wxWindow* parent,const std::vector& data) -: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) + +WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders) +: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(500,350),wxBORDER_RAISED) { - const int N = 4; // number of extruders - new wxStaticText(this,wxID_ANY,wxString("Volume to wipe when the filament is being"),wxPoint(40,55) ,wxSize(500,25)); - new wxStaticText(this,wxID_ANY,wxString("unloaded"),wxPoint(110,75) ,wxSize(500,25)); - new wxStaticText(this,wxID_ANY,wxString("loaded"),wxPoint(195,75) ,wxSize(500,25)); - m_widget_button = new wxButton(this,wxID_ANY,"-> Fill in the matrix ->",wxPoint(300,130),wxSize(175,50)); - for (int i=0;i(0)); - new wxStaticText(this,wxID_ANY,wxString("")<Disable(); else - edit_boxes[i][j]->SetValue(wxString("")<SetValue(wxString("")<Bind(wxEVT_BUTTON,[this](wxCommandEvent&){fill_in_matrix();}); - Refresh(this); + + m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){toggle_advanced(true);}); + toggle_advanced(); } + + + + +std::vector WipingPanel::read_matrix_values() { + if (!m_advanced) + fill_in_matrix(); + std::vector output; + for (unsigned int i=0;iGetValue().ToDouble(&val); + output.push_back((float)val); + } + } + return output; +} + + +std::vector WipingPanel::read_extruders_values() { + std::vector output; + for (unsigned int i=0;iGetValue()); + output.push_back(m_new[i]->GetValue()); + } + return output; +} + + void WipingPanel::fill_in_matrix() { - wxArrayString choices; - choices.Add("sum"); - choices.Add("maximum"); - wxSingleChoiceDialog dialog(this,"How shall I calculate volume for any given pair?\n\nI can either sum volumes for old and new filament, or just use the higher value.","DEBUGGING",choices); - if (dialog.ShowModal() == wxID_CANCEL) - return; - for (unsigned i=0;i<4;++i) { - for (unsigned j=0;j<4;++j) { + for (unsigned i=0;iSetValue(wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue())); - else - edit_boxes[j][i]->SetValue(wxString("")<< (std::max(m_old[i]->GetValue(), m_new[j]->GetValue()))); + edit_boxes[j][i]->SetValue(wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue())); } } } @@ -200,7 +206,52 @@ void WipingPanel::fill_in_matrix() { +bool WipingPanel::advanced_matches_simple() { + for (unsigned i=0;iGetValue() != (wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue()))) + return false; + } + } + return true; +} +void WipingPanel::toggle_advanced(bool user_button) { + if (m_advanced && !advanced_matches_simple() && user_button) { + if (wxMessageDialog(this,wxString(L("Switching to simple settings will discard changes done in the advanced mode!\n\nDo you want to proceed?")), + wxString(L("Warning")),wxYES_NO|wxICON_EXCLAMATION).ShowModal() != wxID_YES) + return; + } + m_advanced = !m_advanced; + + if (!user_button) { // we were called from constructor + if (advanced_matches_simple()) // advanced and simple match - let's show simple version + m_advanced = false; + else + m_advanced = true; + } + + for (unsigned i=0;iShow(m_advanced); + m_old[i]->Show(!m_advanced); + m_new[i]->Show(!m_advanced); + } + for (const auto& widget : m_advanced_widgets) // shows/hides other widgets + widget->Show(m_advanced); + for (const auto& widget : m_notadvanced_widgets) + widget->Show(!m_advanced); + + if (m_advanced) { + if (user_button) fill_in_matrix(); // otherwise keep values loaded from config + m_widget_button->SetLabel(L("Show simplified settings")); + } + else + m_widget_button->SetLabel(L("Show advanced settings")); + + this->Refresh(); +} \ No newline at end of file diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index 8e84f3dc16..0adefe5f27 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -46,18 +46,28 @@ private: + + + class WipingPanel : public wxPanel { public: - WipingPanel(wxWindow* parent,const std::vector& data); - void fill_parameters(Slic3r::WipeTowerParameters& p); + WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders); + std::vector read_matrix_values(); + std::vector read_extruders_values(); private: void fill_in_matrix(); + void toggle_advanced(bool user_button = false); + bool advanced_matches_simple(); std::vector m_old; std::vector m_new; + std::vector m_advanced_widgets; + std::vector m_notadvanced_widgets; std::vector> edit_boxes; - wxButton* m_widget_button=nullptr; + wxButton* m_widget_button = nullptr; + unsigned int m_number_of_extruders = 0; + bool m_advanced = false; }; @@ -66,19 +76,15 @@ private: class WipingDialog : public wxDialog { public: - WipingDialog(wxWindow* parent,const std::vector& init_data); - std::vector get_value() const { return m_output_data; } - - + WipingDialog(wxWindow* parent,const std::vector& matrix, const std::vector& extruders); + std::vector get_matrix() const { return m_output_matrix; } + std::vector get_extruders() const { return m_output_extruders; } + + private: WipingPanel* m_panel_wiping = nullptr; - std::vector m_output_data; - - std::string read_dialog_values() { - Slic3r::WipeTowerParameters p; - m_panel_wiping ->fill_parameters(p); - //return p.to_string(); - } + std::vector m_output_matrix; + std::vector m_output_extruders; }; #endif // _WIPE_TOWER_DIALOG_H_ \ No newline at end of file From a782424d5f4ab4e34e4291af8cee965b2ad23848 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 20 Mar 2018 15:07:18 +0100 Subject: [PATCH 0061/1150] Wipe tower generator connected to purging volumes from the configuration layer --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 8 +-- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 63 ++------------------- xs/src/libslic3r/Print.cpp | 4 +- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 5 -- 4 files changed, 13 insertions(+), 67 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 59fa7dceda..2010b7ae7a 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -514,7 +514,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( toolchange_Load(writer, cleaning_box); // Prime the tool. if (idx_tool + 1 == tools.size()) { // Last tool should not be unloaded, but it should be wiped enough to become of a pure color. - toolchange_Wipe(writer, cleaning_box, m_par.wipe_volumes[tools[idx_tool-1]][tool]); + toolchange_Wipe(writer, cleaning_box, wipe_volumes[tools[idx_tool-1]][tool]); } else { // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool. //writer.travel(writer.x(), writer.y() + m_perimeter_width, 7200); @@ -566,7 +566,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo { for (const auto &b : m_layer_info->tool_changes) if ( b.new_tool == tool ) { - wipe_volume = m_par.wipe_volumes[b.old_tool][b.new_tool]; + wipe_volume = wipe_volumes[b.old_tool][b.new_tool]; if (tool == m_layer_info->tool_changes.back().new_tool) last_change_in_layer = true; wipe_area = b.required_depth * m_layer_info->extra_spacing; @@ -1100,7 +1100,7 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi float ramming_depth = depth; length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; float first_wipe_line = -length_to_extrude; - length_to_extrude += volume_to_length(m_par.wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); + length_to_extrude += volume_to_length(wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); length_to_extrude = std::max(length_to_extrude,0.f); depth += (int(length_to_extrude / width) + 1) * m_line_width; @@ -1146,7 +1146,7 @@ void WipeTowerPrusaMM::save_on_last_wipe() float width = m_wipe_tower_width - 3*m_perimeter_width; // width we draw into float length_to_save = 2*(m_wipe_tower_width+m_wipe_tower_depth) + (!layer_finished() ? finish_layer().total_extrusion_length_in_plane() : 0.f); - float length_to_wipe = volume_to_length(m_par.wipe_volumes[m_layer_info->tool_changes.back().old_tool][m_layer_info->tool_changes.back().new_tool], + float length_to_wipe = volume_to_length(wipe_volumes[m_layer_info->tool_changes.back().old_tool][m_layer_info->tool_changes.back().new_tool], m_line_width,m_layer_info->height) - m_layer_info->tool_changes.back().first_wipe_line - length_to_save; length_to_wipe = std::max(length_to_wipe,0.f); diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 8cfc5872c4..acdcef8f2f 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -31,59 +31,6 @@ namespace PrusaMultiMaterial { -// Operator overload to output std::pairs -template -std::ostream& operator<<(std::ostream& stream,const std::pair& pair) { - return stream << pair.first << " " << pair.second; -} - -// Operator overload to output elements of a vector to std::ofstream easily: -template -std::ostream& operator<<(std::ostream& stream,const std::vector& vect) { - for (const auto& element : vect) - stream << element << " "; - return stream; -} - -// Operator overload to input elements of a vector from std::ifstream easily (reads until a fail) -template -std::istream& operator>>(std::istream& stream, std::vector& vect) { - vect.clear(); - T value{}; - bool we_read_something = false; - while (stream >> value) { - vect.push_back(value); - we_read_something = true; - } - if (!stream.eof() && we_read_something) { // if this is not eof, we might be at separator - let's get rid of it - stream.clear(); // if we failed on very first line or reached eof, return stream in good() state - stream.get(); // get() whatever we are stuck at - } - return stream; -} - - -// This struct is used to store parameters and to pass it to wipe tower generator -struct WipeTowerParameters { - WipeTowerParameters() { } // create new empty object - WipeTowerParameters(const std::string& init_data) { // create object and initialize from std::string - set_defaults(); - } - - void set_defaults() { - sampling = 0.25f; - wipe_volumes = {{ 0.f, 60.f, 60.f, 60.f}, - { 60.f, 0.f, 60.f, 60.f}, - { 60.f, 60.f, 0.f, 60.f}, - { 60.f, 60.f, 60.f, 0.f}}; - filament_wipe_volumes = {{30.f,30.f},{30.f,30.f},{30.f,30.f},{30.f,30.f}}; - } - - float sampling = 0.25f; // this does not quite work yet, keep it fixed to 0.25f - std::vector> wipe_volumes; - std::vector> filament_wipe_volumes; -}; - class WipeTowerPrusaMM : public WipeTower { @@ -110,7 +57,7 @@ public: // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, float cooling_tube_retraction, - float cooling_tube_length, float parking_pos_retraction, float bridging, const std::string& parameters, + float cooling_tube_length, float parking_pos_retraction, float bridging, const std::vector& wiping_matrix, unsigned int initial_tool) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), @@ -123,9 +70,11 @@ public: m_cooling_tube_length(cooling_tube_length), m_parking_pos_retraction(parking_pos_retraction), m_current_tool(initial_tool), - m_par(parameters) + m_bridging(bridging) { - m_bridging = bridging; + const unsigned int number_of_extruders = int(sqrt(wiping_matrix.size())+WT_EPSILON); + for (unsigned int i = 0; i(wiping_matrix.begin()+i*number_of_extruders,wiping_matrix.begin()+(i+1)*number_of_extruders)); for (size_t i = 0; i < 4; ++ i) { // Extruder specific parameters. @@ -301,7 +250,7 @@ private: // A fill-in direction (positive Y, negative Y) alternates with each layer. wipe_shape m_current_shape = SHAPE_NORMAL; unsigned int m_current_tool = 0; - WipeTowerParameters m_par; + std::vector> wipe_volumes; float m_depth_traversed = 0.f; // Current y position at the wipe tower. // How much to wipe the 1st extruder over the wipe tower at the 1st layer diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 0167b8ba75..acff4492a7 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -202,6 +202,7 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), float(this->config.wipe_tower_bridging), - /*this->config.wipe_tower_advanced.value*/std::string(""),m_tool_ordering.first_extruder()); + std::vector((this->config.wiping_volumes_matrix.values).begin(),(this->config.wiping_volumes_matrix.values).end()), + m_tool_ordering.first_extruder()); //wipe_tower.set_retract(); //wipe_tower.set_zhop(); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index 0adefe5f27..54ae9596d8 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -5,16 +5,11 @@ #include #include #include -#include -#include #include -#include "../../libslic3r/GCode/WipeTowerPrusaMM.hpp" #include "RammingChart.hpp" -std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par); - class RammingPanel : public wxPanel { public: RammingPanel(wxWindow* parent); From 0fc2da5a325d07252d57a6bb1a88ad1e27824df3 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 20 Mar 2018 15:45:11 +0100 Subject: [PATCH 0062/1150] Wipe tower generator should now work for more than 4 extruders (actual number extracted from wiping_volumes_matrix) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 32 +++++++++++---------- xs/src/libslic3r/Print.cpp | 11 +++---- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index acdcef8f2f..90317673e4 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -69,19 +69,19 @@ public: m_cooling_tube_retraction(cooling_tube_retraction), m_cooling_tube_length(cooling_tube_length), m_parking_pos_retraction(parking_pos_retraction), - m_current_tool(initial_tool), - m_bridging(bridging) + m_bridging(bridging), + m_current_tool(initial_tool) { const unsigned int number_of_extruders = int(sqrt(wiping_matrix.size())+WT_EPSILON); for (unsigned int i = 0; i(wiping_matrix.begin()+i*number_of_extruders,wiping_matrix.begin()+(i+1)*number_of_extruders)); - for (size_t i = 0; i < 4; ++ i) { + /*for (size_t i = 0; i < number_of_extruders; ++ i) { // Extruder specific parameters. - m_filpar[i].material = PLA; + m_filpar[i].material = PLA; m_filpar[i].temperature = 0; m_filpar[i].first_layer_temperature = 0; - } + }*/ } virtual ~WipeTowerPrusaMM() {} @@ -97,6 +97,8 @@ public: void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, float unloading_speed, float delay, int cooling_time, std::string ramming_parameters) { + while (m_filpar.size() < idx+1) // makes sure the required element is in the vector + m_filpar.push_back(FilamentParameters()); m_filpar[idx].material = material; m_filpar[idx].temperature = temp; m_filpar[idx].first_layer_temperature = first_layer_temp; @@ -226,20 +228,20 @@ private: struct FilamentParameters { - material_type material; - int temperature; - int first_layer_temperature; - float loading_speed; - float unloading_speed; - float delay; - int cooling_time; - float ramming_line_width_multiplicator; - float ramming_step_multiplicator; + material_type material = PLA; + int temperature = 0; + int first_layer_temperature = 0; + float loading_speed = 0.f; + float unloading_speed = 0.f; + float delay = 0.f ; + int cooling_time = 0; + float ramming_line_width_multiplicator = 0.f; + float ramming_step_multiplicator = 0.f; std::vector ramming_speed; }; // Extruder specific parameters. - FilamentParameters m_filpar[4]; + std::vector m_filpar; // State of the wiper tower generator. diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index acff4492a7..cd227ed1c0 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -1037,21 +1037,22 @@ void Print::_make_wipe_tower() } } + // Get wiping matrix to get number of extruders and convert vector to vector: + std::vector wiping_volumes((this->config.wiping_volumes_matrix.values).begin(),(this->config.wiping_volumes_matrix.values).end()); + // Initialize the wipe tower. WipeTowerPrusaMM wipe_tower( float(this->config.wipe_tower_x.value), float(this->config.wipe_tower_y.value), float(this->config.wipe_tower_width.value), float(this->config.wipe_tower_per_color_wipe.value), float(this->config.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), - float(this->config.wipe_tower_bridging), - std::vector((this->config.wiping_volumes_matrix.values).begin(),(this->config.wiping_volumes_matrix.values).end()), - m_tool_ordering.first_extruder()); - + float(this->config.wipe_tower_bridging), wiping_volumes, m_tool_ordering.first_extruder()); + //wipe_tower.set_retract(); //wipe_tower.set_zhop(); // Set the extruder & material properties at the wipe tower object. - for (size_t i = 0; i < 4; ++ i) + for (size_t i = 0; i < (int)(sqrt(wiping_volumes.size())+EPSILON); ++ i) wipe_tower.set_extruder( i, WipeTowerPrusaMM::parse_material(this->config.filament_type.get_at(i).c_str()), From a32281c2684535b1f4de15fbcb353a773b713c66 Mon Sep 17 00:00:00 2001 From: Chow Loong Jin Date: Wed, 21 Mar 2018 15:38:33 +0800 Subject: [PATCH 0063/1150] Fix format-security violations (#802) croak() expects printf-style format strings. Calling croak(e.what()) directly causes compilations to fail with -Werror=format-security --- xs/xsp/GCode.xsp | 2 +- xs/xsp/PlaceholderParser.xsp | 4 ++-- xs/xsp/Print.xsp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xs/xsp/GCode.xsp b/xs/xsp/GCode.xsp index b4cb7c0e92..36b43271c9 100644 --- a/xs/xsp/GCode.xsp +++ b/xs/xsp/GCode.xsp @@ -23,7 +23,7 @@ try { THIS->do_export(print, path); } catch (std::exception& e) { - croak(e.what()); + croak("%s\n", e.what()); } %}; void do_export_w_preview(Print *print, const char *path, GCodePreviewData *preview_data) diff --git a/xs/xsp/PlaceholderParser.xsp b/xs/xsp/PlaceholderParser.xsp index 244f89cf88..5fa4e33aa1 100644 --- a/xs/xsp/PlaceholderParser.xsp +++ b/xs/xsp/PlaceholderParser.xsp @@ -18,7 +18,7 @@ try { RETVAL = THIS->process(str, 0); } catch (std::exception& e) { - croak(e.what()); + croak("%s\n", e.what()); } %}; @@ -27,7 +27,7 @@ try { RETVAL = THIS->evaluate_boolean_expression(str, THIS->config()); } catch (std::exception& e) { - croak(e.what()); + croak("%s\n", e.what()); } %}; }; diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index cbc04a804f..ef9c5345f4 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -212,7 +212,7 @@ _constant() try { RETVAL = THIS->output_filepath(path); } catch (std::exception& e) { - croak(e.what()); + croak("%s\n", e.what()); } %}; From ac9db81820af7b531ea548cc8f8f2b149a87db08 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 21 Mar 2018 09:36:27 +0100 Subject: [PATCH 0064/1150] Normalization of purging volume parameters when number of extruders is changed --- xs/src/slic3r/GUI/PresetBundle.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 668b9ee125..d26a007bb9 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -719,6 +719,35 @@ void PresetBundle::update_multi_material_filament_presets() // Append the rest of filament presets. // if (this->filament_presets.size() < num_extruders) this->filament_presets.resize(num_extruders, this->filament_presets.empty() ? this->filaments.first_visible().name : this->filament_presets.back()); + + + + // Now verify if wiping_volumes_matrix has proper size (it is used to deduce number of extruders in wipe tower generator): + std::vector old_matrix = (prints.get_edited_preset().config.option("wiping_volumes_matrix"))->values; + size_t old_number_of_extruders = int(sqrt(old_matrix.size())+EPSILON); + // First do it for the extruders presets (in-place): + std::vector& extruders = (prints.get_edited_preset().config.option("wiping_volumes_extruders"))->values; + while (extruders.size() < 2*num_extruders) { + extruders.push_back(extruders[0]); // copy the values from the first extruder + extruders.push_back(extruders[1]); + } + while (extruders.size() > 2*num_extruders) { + extruders.pop_back(); + extruders.pop_back(); + } + // Now update the purging volume matrix: + if (num_extruders != old_number_of_extruders) { + std::vector new_matrix; + for (unsigned int i=0;i("wiping_volumes_matrix"))->values = new_matrix; + } } void PresetBundle::update_compatible_with_printer(bool select_other_if_incompatible) From 4a179c81d29eaad4dc3b4a107a31809b68615076 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 21 Mar 2018 10:03:10 +0100 Subject: [PATCH 0065/1150] GCode Preview - Added visualization of volumetric flow rate --- lib/Slic3r/GUI/Plater/3DPreview.pm | 1 + xs/src/libslic3r/GCode/Analyzer.cpp | 7 ++++++- xs/src/libslic3r/GCode/PreviewData.cpp | 14 ++++++++++++++ xs/src/libslic3r/GCode/PreviewData.hpp | 3 +++ xs/src/slic3r/GUI/3DScene.cpp | 4 ++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index 8f3fa49f59..537cb0c8f2 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -69,6 +69,7 @@ sub new { $choice_view_type->Append(L("Height")); $choice_view_type->Append(L("Width")); $choice_view_type->Append(L("Speed")); + $choice_view_type->Append(L("Volumetric flow rate")); $choice_view_type->Append(L("Tool")); $choice_view_type->SetSelection(0); diff --git a/xs/src/libslic3r/GCode/Analyzer.cpp b/xs/src/libslic3r/GCode/Analyzer.cpp index 15b99b2fbc..e20f6589fd 100644 --- a/xs/src/libslic3r/GCode/Analyzer.cpp +++ b/xs/src/libslic3r/GCode/Analyzer.cpp @@ -670,14 +670,16 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ float z = FLT_MAX; Polyline polyline; Pointf3 position(FLT_MAX, FLT_MAX, FLT_MAX); + float volumetric_rate = FLT_MAX; GCodePreviewData::Range height_range; GCodePreviewData::Range width_range; GCodePreviewData::Range feedrate_range; + GCodePreviewData::Range volumetric_rate_range; // constructs the polylines while traversing the moves for (const GCodeMove& move : extrude_moves->second) { - if ((data != move.data) || (data.feedrate != move.data.feedrate) || (z != move.start_position.z) || (position != move.start_position)) + if ((data != move.data) || (z != move.start_position.z) || (position != move.start_position) || (volumetric_rate != move.data.feedrate * (float)move.data.mm3_per_mm)) { // store current polyline polyline.remove_duplicate_points(); @@ -693,9 +695,11 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ // update current values data = move.data; z = move.start_position.z; + volumetric_rate = move.data.feedrate * (float)move.data.mm3_per_mm; height_range.update_from(move.data.height); width_range.update_from(move.data.width); feedrate_range.update_from(move.data.feedrate); + volumetric_rate_range.update_from(volumetric_rate); } else // append end vertex of the move to current polyline @@ -713,6 +717,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ preview_data.ranges.height.set_from(height_range); preview_data.ranges.width.set_from(width_range); preview_data.ranges.feedrate.set_from(feedrate_range); + preview_data.ranges.volumetric_rate.set_from(volumetric_rate_range); } void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data) diff --git a/xs/src/libslic3r/GCode/PreviewData.cpp b/xs/src/libslic3r/GCode/PreviewData.cpp index b9be6643b1..69fd3524da 100644 --- a/xs/src/libslic3r/GCode/PreviewData.cpp +++ b/xs/src/libslic3r/GCode/PreviewData.cpp @@ -235,6 +235,7 @@ void GCodePreviewData::set_default() ::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); ::memcpy((void*)ranges.width.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); ::memcpy((void*)ranges.feedrate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); + ::memcpy((void*)ranges.volumetric_rate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color)); extrusion.set_default(); travel.set_default(); @@ -248,6 +249,7 @@ void GCodePreviewData::reset() ranges.width.reset(); ranges.height.reset(); ranges.feedrate.reset(); + ranges.volumetric_rate.reset(); extrusion.layers.clear(); travel.polylines.clear(); retraction.positions.clear(); @@ -279,6 +281,11 @@ const GCodePreviewData::Color& GCodePreviewData::get_feedrate_color(float feedra return ranges.feedrate.get_color_at(feedrate); } +const GCodePreviewData::Color& GCodePreviewData::get_volumetric_rate_color(float rate) const +{ + return ranges.volumetric_rate.get_color_at(rate); +} + void GCodePreviewData::set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha) { for (unsigned int i = 0; i < Extrusion::Num_Extrusion_Roles; ++i) @@ -345,6 +352,8 @@ std::string GCodePreviewData::get_legend_title() const return L("Width (mm)"); case Extrusion::Feedrate: return L("Speed (mm/s)"); + case Extrusion::VolumetricRate: + return L("Volumetric flow rate (mm3/s)"); case Extrusion::Tool: return L("Tool"); } @@ -402,6 +411,11 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: Helper::FillListFromRange(items, ranges.feedrate, 0, 1.0f); break; } + case Extrusion::VolumetricRate: + { + Helper::FillListFromRange(items, ranges.volumetric_rate, 3, 1.0f); + break; + } case Extrusion::Tool: { unsigned int tools_colors_count = tool_colors.size() / 4; diff --git a/xs/src/libslic3r/GCode/PreviewData.hpp b/xs/src/libslic3r/GCode/PreviewData.hpp index 6375af5f05..e9c5f75154 100644 --- a/xs/src/libslic3r/GCode/PreviewData.hpp +++ b/xs/src/libslic3r/GCode/PreviewData.hpp @@ -50,6 +50,7 @@ public: Range height; Range width; Range feedrate; + Range volumetric_rate; }; struct LegendItem @@ -70,6 +71,7 @@ public: Height, Width, Feedrate, + VolumetricRate, Tool, Num_View_Types }; @@ -190,6 +192,7 @@ public: const Color& get_height_color(float height) const; const Color& get_width_color(float width) const; const Color& get_feedrate_color(float feedrate) const; + const Color& get_volumetric_rate_color(float rate) const; void set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha); void set_extrusion_paths_colors(const std::vector& colors); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 4762fa54c2..eafca6cd11 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -2039,6 +2039,8 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, return path.width; case GCodePreviewData::Extrusion::Feedrate: return path.feedrate; + case GCodePreviewData::Extrusion::VolumetricRate: + return path.feedrate * (float)path.mm3_per_mm; case GCodePreviewData::Extrusion::Tool: return (float)path.extruder_id; } @@ -2058,6 +2060,8 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, return data.get_width_color(value); case GCodePreviewData::Extrusion::Feedrate: return data.get_feedrate_color(value); + case GCodePreviewData::Extrusion::VolumetricRate: + return data.get_volumetric_rate_color(value); case GCodePreviewData::Extrusion::Tool: { static GCodePreviewData::Color color; From 1a1be94c99f99a63aab45a13f83711e8a007e8c2 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 21 Mar 2018 10:20:36 +0100 Subject: [PATCH 0066/1150] Purging volume parameters normalization - minor changes --- xs/src/slic3r/GUI/PresetBundle.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index d26a007bb9..1d47958326 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -721,22 +721,21 @@ void PresetBundle::update_multi_material_filament_presets() this->filament_presets.resize(num_extruders, this->filament_presets.empty() ? this->filaments.first_visible().name : this->filament_presets.back()); - // Now verify if wiping_volumes_matrix has proper size (it is used to deduce number of extruders in wipe tower generator): std::vector old_matrix = (prints.get_edited_preset().config.option("wiping_volumes_matrix"))->values; size_t old_number_of_extruders = int(sqrt(old_matrix.size())+EPSILON); - // First do it for the extruders presets (in-place): + if (num_extruders != old_number_of_extruders) { + // First verify if purging volumes presets for each extruder matches number of extruders std::vector& extruders = (prints.get_edited_preset().config.option("wiping_volumes_extruders"))->values; while (extruders.size() < 2*num_extruders) { - extruders.push_back(extruders[0]); // copy the values from the first extruder - extruders.push_back(extruders[1]); + extruders.push_back(extruders.size()>1 ? extruders[0] : 50.); // copy the values from the first extruder + extruders.push_back(extruders.size()>1 ? extruders[1] : 50.); } while (extruders.size() > 2*num_extruders) { extruders.pop_back(); extruders.pop_back(); } - // Now update the purging volume matrix: - if (num_extruders != old_number_of_extruders) { + std::vector new_matrix; for (unsigned int i=0;i Date: Wed, 21 Mar 2018 14:00:06 +0100 Subject: [PATCH 0067/1150] Added Italian and updated German to localization --- lib/Slic3r/GUI.pm | 7 + resources/localization/de_DE/Slic3rPE.mo | Bin 42270 -> 109309 bytes resources/localization/de_DE/Slic3rPE_de.po | 7798 ++++++++----------- resources/localization/it/Slic3rPE.mo | Bin 0 -> 106597 bytes resources/localization/it/Slic3rPE_it.po | 3515 +++++++++ 5 files changed, 6842 insertions(+), 4478 deletions(-) create mode 100644 resources/localization/it/Slic3rPE.mo create mode 100644 resources/localization/it/Slic3rPE_it.po diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 663c538923..74456ca2f9 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -174,6 +174,13 @@ sub recreate_GUI{ $topwindow->Destroy; } + EVT_IDLE($self->{mainframe}, sub { + while (my $cb = shift @cb) { + $cb->(); + } + $self->{app_config}->save if $self->{app_config}->dirty; + }); + my $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only; if ($run_wizard) { # On OSX the UI was not initialized correctly if the wizard was called diff --git a/resources/localization/de_DE/Slic3rPE.mo b/resources/localization/de_DE/Slic3rPE.mo index a64dc1ca7067a22af25c8e4817d1af1831a3f749..d4d03fb2e9b2d4c0779104688195a645e6452a28 100644 GIT binary patch literal 109309 zcmeFad7NBD)&GA-_8_3hqO6xCVFH=S#u`M(3Xz0_Odt@J&@^f_XO_(cLRR{ z?gDNwJxR_1cL%otuLrjU?*!+A4}zP5yUrkfupQh8oCK0wvOlPJ4hA;^mx5#^=>?16 z8$rGIQ&92z8dUs$0AB-+nd#y81lw>Q0=^tP6xyPZvaJacYwEnUjz028S|XZF9FBkz6?}*e-PXeycwJV-Ul8E{vDhMzLw5287zaF zf>(p8-y6V#^YfQ&9EtCvZdX1&}NzFI(XL3&1UK9~<1g;8wVogNo-3pz?nXcsKZVP~~|2LVv#- zRJtWl`D=iB?|kqO@M7@g;Qiodz(+xayYy&p&uhUN?$3j-1g9+Wc9;b!-7au3cp@nJ z_#~+Mx)Zz-d;}Do4R_JUz>7iUZ(CkE3+w<@&o_evP3{E`((_}S{uY4Z3q?@$bq1*V zdJm|2zZ%>NycOI7d=$J3{0F!vc;~TR{wF}?>(`*#WwRyTUnhYRaW4c_A7_J8zraP#AmgsM&U2Y(B`1$-a4;&`W*S1$GN+XtKsD&8YOYbS7f+~?R_Qrtk4tNtd7XN#} zt-)V_s>i>9D(_ZgPVbKgmHu>4?R+A*Iama@1WyAM?rd-?@Cxu_;77nSz++B!dUy!b z^T$EG_Zv{{{kP!%ie=uODJc5i3lu$007Xv+1@}x)5b?_tL&fT8xuYgMbo1p0U2cX8qAAtvfe+HHB$vw~-cqpiHt^h?x zXMuNv=YuNG>|W@(ElHMvXW@QJ(c|5?&-1$l$Y1gr{wcp_gOG0WPEh&yHK_jcC-95l zF8$OE_yl+@__+b%1ecYld+=#cbbG+5Nm2!G1c@d=lJ` ze4bmOzQE7%vf_Dg$mwI=X`b&BLDfeOD7rZVR5{-cs(!Br)n9H3&+iJ)zZv|W4*q`z zcOl#+HShQ1zzuNE0#%c0{2&7kPy5>Rw-6{z<<32qDC9`IYB z^7j-dy8R`naK8`uJecBct9!rN9TeRh0&W5>2Gt%Xf+}}EsCgcGr`+Iy??-n*XJVe9^6Gx;r2W|@D)(uri1c75mdYdQ2FQwmEQ`u z2Y4nZy895Q_mNnQv35}XRQLrkv(PXt9D74T^AEb!IfgP{8FuRw+SQ@~B% z;QVk0Q0X29?f@q@2TK^7F0UPd))sOU=`=iAS^L?2RH>BbA{*Y5K!%K z9H@3X1KbRJKe#=3J*f2V0oCqb2UX68LDBcGz;WOoLG_EB-s|ahfTGiB;I`m=Q046j z&(8uC{_Wtw;8o!7z(>F#@aykOl9}MaS2{mD3sm`U01p6f2378#f!Bb~fv*AI{eJJ4 z9|x80^Wcu)E3R_6Z30MBB)zs~G3|Iiat@pu?f(KkrIaFToJlwDR2xS4^ z1B%`bAkdLu0aST!2I(Tn55cp+>W#=k;O{`Pmb~F6bOCVJkHJI1bHTm9yTQ5O&%k5A zi8oVr@H~(vPQC@s081bD{{1m<58RJ|dheeguO@Rpfy_*P{{;R9_gg>d`tpif;la2& zZlg`Xr@=Ra4}OYzCj8=0yT13v&$wOaG4LJu_kI=|8{wYgxFPQAK=s=j!41H> z!A-$0f}-cI2Yd|N9`|p+jlm5ca=P0bRJ-p6z8stjZUG((ZUy!RY=C^<3oddRm@}CM0fOA3h>s!J7zz4x?z)c?aezy~-_~(Io{sgFY*^WW# zL~sXiDmVg80dE4&0DlDj6FlKZ&Yw>BvFo?Ppz8e-;4<*5pz3X}CwyF;1nz`;7N~kE zfNI|osC*8AJAfC1uL5rb_57ZIUk><95VA|Y1FAgV2NmD1LB0QbaA$DKpLjb>05`)u z8B}}+2mcwteK@Fm9u;s2sCqsnJYNoq-fE!IISUlMoDYg_-wTRPZUjYVcYw|9c0V45s)W2&(;$2lf8x;3nW( z0$v1eiu-bKGWdbuelXyppy=+WpxXIwpxS4nU($x)_TXON>7br}5LCO|81QCLbaM-+ zcK-&r8TfthyWkU`o`3pRp095Qd>GtY&%tZK&42Com0Q58a9{WvkEi_^r;90|`sb10 zhF}3yef9->W59QVixSx zmE%!R?eRyj1ANVI{rTab^4ANh{Hs9G_qpI!;ANoN`#SI=;2og)S@-X}Ud{$Z{}+Ih zz-z#bz=uG!$HSoF{}s3;m^|y@w*plU?cgiGLqXBwLQvsrAWe{55Z%vt{apZ#!T%kg z=<^Ct`MC}}09*|o4*m_C2G0Dw>pf?J3V$~^0sK0seEu0!eZK&TZnyn|k5>nS>JLYO zD&MJ~@^uapS*px2cN*b8>oD}?9cvuM{o<=dxC2BDWK9@0ID921=XIHf}aMj z0Tph^Up$@$cm?ivfNGa%c#NyX!ezZw`1YcnWwGsB!xr;E!>? z`ekiapML?z;r?g9aT~N*`_BheFK2?U0?!AF;FaL*U>lhgoqsOiH$b)fq|7oDwdljhu`WA3o@G?;E-vmAe-U+@Be9xx--V~HwmG59s;pPSRiNQSx zD*iWuivKO(tHF1I%EwK?|I48A`yiAwq9{;mNvj(iRjy*~-6|89&h|2y#I z;K|?%;1|IYxA5n?Z0Ys4C#Zfn72Fw|1}gpIK+*R*!9&5TK-Jq1LGj^dz@LDB2Gt)P z*{aR#3V#5vzsCb?R7lF@$s?S+lx7j@2$)M`zHgI3?3m{!F`6HU|NYd>scW{t_rU8UmG{m0&w~J*f8|2+yAm_*+nX;xC}u`{ld) z``dxa|E{3uWe-qvH$7kx+!gm*LArGEQBdJ;*~7zs3asJ(5GXpBJ+{rpt7V|_cP6NK z&j%-i*9H7Rz|F>axPw8}-z-q=u@JllJO&iM{4=QX@32=}@&#}oP~m<9?g%~$?gDOs z(k%Z8pyHbhs$U-hs{Ln!YL_Ko30w(23;q;54E)~sHq-C7+q=!?bC-ci_bO2J`f>0b z;FrO1VAnq0uB$-R?*#$h52_#E0xG?SLDj?ap!nRYCwRX10uRAG6Fdxj6R38)7u5T| z235XSb+jdI)bm7eEbhsj-i}K^)pG$H=g44vOOsO4p8+z3sgTp1ysFU462-0gQBzRg8z-d{|->; ze*rui{0`U$jzu|BKHd(hJnsp33%C#N`#`nVA3^oct@ibFUjwQgjsW$3KWK6esD64O zsB(TBoCw|vjt8Fu6@I7vyk7SL)sAyP<-ZS9dk%uCk2ioS_m$vr;H}_taC4Zd+F=CL zduM|x-}%A)K2Y&q1FHS*0Yz6&fUgCg0bd91eSp(>37m)fhJb$vIQ>8`*F~WE`}Lss z%zdEBaX)w@_%NvY*z+K7x0#^$_+oHxunMaF-Ulk5*MiE&XTd4pAHe;@r zGr_lm%HOv^wcAfYrT?l!oX*CBs@DSp9s{06|F3}+@Tu1!?}1&1wIwUSJEpfKKLRJs zY)ifkZZ*3txdVJ+PFu1ReBTkYBlyR;lpFlV>%ILa&+~db6g0jIiY|@;)$To@=&cN@ z9Or_{*PWo+;bBnx;Lo7Sx5<3RJwWlhLqXNsNuc`YIiTWu8z{Q}FsO7M0QLUEp!oD3 zK=rqckMjI&3o4y)pz^mr_-=3(cmenbsQ%Wy!0Gr?pwj&YxF`55sCM0Mp{KtGD7rcr z6y47OmHtTqSAwFO%fj=AK&AgnQ1ZZELG|M;kM{WY0>ww>f$EPZfwREVKv;hA8Sp~f zPcA}U0SCLBj=l|A{eiE?f0M@}@OQY616PA{ zmw5l*;RQtU@JpUZ1`neZW zyZi`D!Dql8;@|QFf4_F3m+NX!_5Wq?6X36d|CJ}TB^Tqq7yKBw=w$CF{{&TUdo1(( z9RO~Qdj@zrcoe97ZE}j!={BI~<~87R;O^iLz-K_=kwp%X7dYu7ed## zp8)Cl$wqJY_q*QFX6p)XxrlNTPyfYjw*KuC;BC~~7MHXo4e*QaL@(mK{V#KRzU=b0 zp=0hyFvAfM}z;9p!nbOpx&E&h4+IQ zV2b-_a4c8@H6C37?gick?hQT$UJq{k-nOI+-VAEI-{F0Z`vyD;RQdy;#)I=f<^M`h z`MVZWzU~V6B~bn1o5B4EsBz~f;BDYWR}v5PatBD)Pab%`>r>;e_I}y>0oU)g`5^s| z=Qo3A@ZJ}%@%+B-Lq6{R3{-#o4JbbF7f|)E&4(Swg5rn!gMHuvP~koUNm@ zTBncQ!Rv4@0rmU^kY-E{yw3UD!Jz2qTJQky5%5azmDfAn+zhHeedPx4$G-!W-u@q9 zoCFtvk^{a3im!YN+#P%pRDEvrQO7Mo)z|i*_}#&v`0??e^OYeB_78&vuWf_qtTmq3ME2`Zm& z21U0Y1XaGzf-3(vK*<$92bIs~L7LTc=G*c3t~_%;(ZuI)|4D(uk5`h%xb_WUpW(j7 zvk|U)Vj!>`|DCvC2}v6Kmxp&CtK<`0y zo!rX(Q}}CKR3F#))y*}A>y5aVfTMpJo5Vj}%k?;6?!+y+JqEYvNWWil-GuuqTy&FU zfN=VKn=9pB^uHJQO|D5iXJ}4N$L}26f9D#{y?8hzmz>LW6ZbcAJ;1a06Ac`Ldl#;& zxn38Z-3TJW*>4l>Hw*W_3V1VqPjdey@TcG@pnm@V{|UaG>$CFUr*@7%$*Ag2pCsH< zyayXhw0A_mXYpIW^)aq%aUTN4-xJ~feDH;Ee-Q8P!?j&-{}^1xwKIPDZ3+G|Ji9IU z$$t^o2e`h-wR!M=5BE24y`J!MxR&6*Wq23w#o_}|a9Fg(-vsJlmY95=>;3rO8~lIH{h?gqar$ZOJ&tP%SNv%l_(yQe!GAxl5A*)Z zXumrCXL5gfF8tyU_OBpp+T?~WhV=H#g+nwjounIFPT04EFnWC}{Jw#Eg&h25AXW&Qi+k&eH_YZKlacK;0!|x&Pzsvnw zx%4|0w|-yen#=Pc@JX)6xMuV0z4&!#P4jbCvaD}e!zYFeV=dxTuZr*!+-nm;6U6*a*v2& zYqQP)^^-g@hI`3PKQJH0d)$a>$%8z58Tc-)cXR3Y>VUfcCf7G|?k^Dj3@-it8SuwE z|1Q@*Lbwg^e?9lN1UEx_(#LfI{;%b|Yryfi5xMNQKW_e#eS=$`9eBKk>uL*u{>ign zaDNKd*7zf)*gWjv+~0xUd0bPt-i7;BTp#249=QL=^*`MI3Dj?Y?&I%!gwyZK_ziNu zIoFT4KM8ymJQrNerQb1JXL0{Nt}pQHWUf8!2{r-zdbr-orQajqGvG>d`M+lcfk1W- z{tprE`&^q6SNvVW&2C%=;;-K?!n5e35r>zk)DFaP7){DfquP;70gg!2OrO z$9eunu10tk;cGnGgX=J!eHG75K>d!#Zx+`I+&h8Kfu99`34WC8r-b=7ZvDO!uoHj% zPR6|>_nQX)6Y={w?#;k$LYTdIR#sqs4+KBmqe_@edKu3j=Ki<%y&=SNML>lc=Ki-_ z*Kuu4xOw2IT({^Uzjty!#Pulmec&*7GuKzS|106Y#q}}Vl6!8#Pjb%-_+7=N--h@- z4Ne31;nHso*JpYDrV!>g_`jd)EA|w=ivKIPK8N3jxE6Em6`tLL|2(e01ou0+|1kGQ za6L!33%TNNSMC=D_d|Goj z08Y$>Kap^~T+b6`d+;Ql4REjDdvLGDT>;18mP{wPdPm%chB!{e{b}yc2<}O^ujToh zxgO;HGr@lh?jr6FfcjN~|0lsKa8JU&9G?BiLioR(gWtQs`@=hb<-WxAYutBo4Rig9 z;OBDvKD_&G@C5v;g!>Kmhk{?jeJz)McjEqPxPJ}!dHhy!6}f*i*Gitp-#Oe|A00XT zVt9WnVSmE?Z9Ka<_}v%Y-yKYY-&x>$!o8x|foC&u*T7$KE#m%fT=#K3!Sxod{BJIf zZ{$4o=J_SKJ3_d3a^Dl~?e#W!EgHyo6@n6Pu1NW~BVV~yyNv_Xx{f=jIxjxSQ<=`K{>4f_>_xk-E z+=c7Q++V=6N4P%#+y?jW6oB6h{N91zN>IAY9pI8e9)((CI_YU0a_b50O{61F~ z&wkDILGJUviwN^K{O{s=3lClf>UR|W6>wj!4|4xQF8z+?`IX^*HutaO`U~#;^)UFi zZQ$#0wi!;Qq55{N5VE9n1aOxPK$q%e9m+UjrpvJj3-t zF8#g^UL5Y_elyp{dGABu1pJTYejn~H))nGjh5yyuZ^-o(?mrCv5iD@&w}9(-u9;jP z;n`E*FTyi!lN0oBEx(C`c>({=aMeTjpX9=g4flU0&V}4hC(I!Dd+;!>0{6S|?BMY3 zC%{X?{YQCr6xX&~ClcmJ{I}wMkoy_n1aQ9)7H2Y<`|a^Nlj~^QQ*j@_{iWRR$n{U| z^&1QRlxIKWx}N*HxW0w|t8u@a>kHg(f!|WF27Z$(|N9AH-o&Nf^zdvb;2z-r=-HSt zvr6@zLajIL87Nfxi}kcn;l5gFlq$nT94ki(D-R`@yi1LApioa61I4tjS}s>dN|pX} zxKb~yC}!_ZBkXzwD%I0UwLwyYLxo1EyIf31N{xYZs8*^pinTGxm|4Tz_FHOIlB}iW z!pdT;J|XQZRMKS3+`hC}ZD!bUToJy>v!$ZB~ zm1?JM8;zl96DRgl4a41?RLsPo+Hk!vwRd8@T+E({hc6yCBwc53I8zI1SKV!bobGul-F`&1=0QdgY~7EUh> zmR3>NBrR14R8DCZYO$iHYN`705M?C*`5&p)mMfvjlO~O&x++w`%FZ!kx(2AfbZ%Ow zDSHMKuvYA${!5i&p{A6xNDob@bkDlun8aGTP7!<5qV7wu5h$)c+|yI6*ZYRmI;xCf zFC{U0DWof^W$L=2%C^E_h>Zol_qK`kWNdHR&Q%{Mmdo|=a`qPciuetpZB^azi-+8Y>Z*Qwdt+)cp41V2(p5-I-sJh3f1XTg`Y3bO`DP^^T zyu5s)idGsF8LDvOrgv8%-Y#qSWZcXuP0~M1mZ8x!88`cM1x(#LoiSYLEf=3W`}$E2 z@Y!r;qgLK$b~0`b&7O=qqF5eE#?7l1de`!9&O3W^ouvvYFiB#~~dc-nBOR_q<$nRKS>#q1_i4meFRWmYnkzxi{#&lIiBi$?#+zWd#K zOWM;j5^hG4>1lVhO45~-a8R~oXV`d%_$3@Q*MP<<>S?u)Vx$Fn2<#&;KCr4T+L^-O z8Uqv{7hh2?8oQutHEP4f2_7W8qvDcKz0_Nzz-zEp!YU?;N0*_4u&|tdsLUG2fy@W1wIc0UE)^IioU0eg^{V^#miqciJ;UXO zvm15RPRoeBl_gzIM+V^F71%jdBhFh`Q7!d~$M+Y8>hL@mOLa)@5tvxLGxWW5d9lc2 zy1X7Wqnp6M2WRsE)+>!T$NR?mP?GQ z&ToxL#!S?QYhplDL^bUnF4PK)ibabYT5pu-lFrfaqPxLf>S=qUI|uInsbqSewT8$%4E*Wg9X-|FVlus4=BiTG<5Gr%y1i!Z<43udHr)&l8lb(0 zq^DN9jS`1zHO3%H&p2D5_Q=N25NyH8hfdN5nL;@A7JnO=yVc(HMnTLlnNI7ktPWFm z;bw%&P`&WP2q~9S_sC_{J#u-iQI-9a6I`kGD&rh3^cPdH6&HW#KeTOM38q3NSBJ~J z$USrbqe(HJIs+x8VR$55wX$0>eYjEW=)pxT43TS!B%fMws36{B15mM6tJWBR^aQCz zO{luDAmRgEi{}}mu>d}B=ew4uHSMWY;VdnLn9N|j>Gxv72Q*F+AelkMait8&Lq)r* zXLpU_AcS0KP@ncB=eC~VWRn(*NL1*)QVo_`t-zHeXc$|f{#O-iu%T+&TdJ#PA|}zP zn{j6x0#RlV`O!L=qGMzm8g6uwHvN#^vKBI&Ve;Big1F>WwPB|osdVk$X}kJ$9fq%V zp@$exr8dSVGpt(#NNpf;ua=&Y%&3)+0s>?LQmGn!yr%|NJ)%jZ)?)6X27;;>a4o*f znZlcDq~OfGTKepwPlxZ5$jH2J_ujAD9ZEoraODlr#L!AgFE_79<}w=s~+EDRO8k?R^I zdhblr9MXK}o)1u&lW+I=rF|Sk+GZ{xT42ry5Dl+Oa8czFa zaJY8*%ftmUUO$ncYa)a6#D$BF>6$)%+M4g1!1yo2L)|GgVWWmphM%r8g;GroQcGr* zOGD`(V^66=y*>?8n#`=0t30g^b~D~Z_AVK5S9ud%0QCm{s4gRGMm6Ikiqcs{ zBpfLu@LE>{H0DCrNOTa+z%YE^585=qdF#!r&bX{ zUE`zzh>6xg@(M5EaPHWsHpq2vOkO#)3^b}EBp#y-wvyAmnzeClMW<{DqAB}sxP!lod&GzCEcACL^>XUW6Jgb(NITa zWK=81pjx0RDVsJIe+hrb-kCe)t3j@b=&6r5K8iwIkf#+mT zB@zr*qAX~dyjmpk6zlwy(chn#5*f5lzYaP=oiU*-3C$G+hB$RdN++3FdFzp0k<A zSHyv_TELtJykZrAoFI%8Ybt~1T=pgPa6L82Cq9ufnGu1h6AFUQilP}d2AX}aczTaD z9?#)YBx{^&FQZS_g&1Gd%-DJ)bRvpYS2Zb|p}d>ouB0d{N_APs)Wm_CX6C5Ku}1sX zmzNlf6uXZE?RE6$wFz!s7gkVz$2b(@ph;W2W|8zG@)bnqgH|mV!zAVwdIyT)C%Jst zxa{vXGaHyS^b;5_HD0ZuO+iLJl3P937$H#I5s4UZFwR8k6ax%`Nml+$qS2cYi8=}{ z)u(-Ep3)LRqC;k+AcxkoqB==QWa{BCuR^~R3(^YGrFvyDyIdSXqM;{NgMAV%Xbe7? zT@eiiu#{C88_xWZNrELQ71FG{XGN=|nIPl4F)uP-S|14(DXY*Bm+>E3#Oq%@MhZr6 ztVRhb6JT7h(;^gYy0y4*xq#4N<6i-GSMRBnhRndwfYq2)LAsP@%^Iw07QLnB{L=JX z@i=-u(q<^nfH6{^}tjMKO9FeWlRJg2{j}k$rjS4SyZ(U*G z=w^X}e`4UP4-O)M=2BZfnK%DRjd99G8Ke6A6YTWV=h$`SBnCB#rnzAE5OEK}lnt-T z`%{s3V4$$WY6bqH+D1lez(UNXfF#1`>EcW%M{9h+*!xoBN~c4M8Y~!`;A&>pFam?K zEU!Q~^!-Y|O9olq#lZr5wzf0FQzXa`p8nx_3R0CbCXYN*n(R#v667h0jnG*g?uTEO z>hzZ$Eb|q_L~plIq!sOpCXm6IC=h8Q+Q1^oe=lY#DF{O} z-5{1pxRVlt=bKT*cwcBMlUQU|vjNHS&By|i!qzZb#smK!%q$Z5GTY=DPcnO6crr2| zWome+jOkZz21ef$_8CD*Yg+2zcLTG@6(ewaiIFRreYy)e2)$?;uoh_&65(V7N9`u^ z*p)NpW_+f*sAtjgj;xDJSPKd%I;&<}DCb&YC$ELxQxV}^Ay;CO52ST6h&ng-M^TE? z05P8GcqUh)z3OZ83z8Y3YlVz=RHD^TZ{VNB zis`8@*naKNFr=5=q+@%V_pZ9@b%jZLFzKVvFg~@z+MB_ueSNfe)15bai9p?AW@11# z=0>w6`MO40IPGGy)jYQ-SOB_AjW)efv&#RD>8ND(;k6+yND8$7%GDs^% z#sSR|iU+xXfKhUojA#zjMs~jq!>K#Mglmh#c&jtbGRoITM;w6NX3)82VC*Fm!z@4u zDsrZtkcVTqby+;MwBbOq`j z6P0PE7V0Z2JqQ35o9@nH3GB%`Lw+*58G2NlQZ!LzBw3=!`%u!F*F%+m3Ag!q9(B1| zv7dpnu6YHGim1ASbbrYVjDr*y!d6VwPmk1G>50KiM&(b^@ zAy;){fua+D>@0inu3%x7}SkQgy!bUAUBh_Th z;E);I`)Wl*p-MLY#55cd8|K`@3q#6OIXT>x2Sh|qtyCFfm}1KsrfJM}#o4TnnJg%J zfFa6^GO8I1gD?nFsz}HsbmS)$DRkK|WQgoXwaFk#p4JgaOhoPs6Xho1m>mQXlo}Y@ zurri`+>e&W*8Rk2p_TBOB@M#_N}!8*F4ft@$^;QKN~Bd1q=<2ZSZdT8$^_Oqx722& zA-UQ63nmJMa%)9v95RX+r=+}*_MMaQHWFSWUDRWfI?Zw)trF@F-l21S453k?zxCR5 z2rC4|tu~xJ$5t3FG23S{PG@oiLkKk2-Slgj-cmnSUA2t$j3M4WkidUBKX!yOOa~W0 z!o7OC8F`An*nnJ8s=&HhOg%6YNvLMV6j@3`3HBklJJXw`A_Xq=V>FP#xrPvc7=8q1 zzg2WzwVkb-$@{oHlPnn7$}D7-!YF)OeUhOt%Wp&(cx$NSe1#D)=~9z(7bbI24(qak zn&H6vkPL^)ceBU0Coi(}>&4c2WvjQm#ck}#48P3M!s0X|@1<$!@hlq?V-`DB=T(Q* zLK8Fcv=1;SL0JfEw%E$5!A*@ei|x^RzQ*=y5f-LAl^|<5B=17ExF}uK+ljVRz|hlk z@e*ThGC>WiHt_Oj5lTDEv3TL397^W(;+cxZujW!cuL)yeP1aH`!Y*6Z=26nfA*4o27HO@A zOu;u(ml=PDs@VH9oGN1(f8^~rVPG-*=b6mccWb7sUZnJ6(12(qVaWy%7jEHY1rL)7 z)Rj4#+;Bpi=&@Qh)23PjP8yk6ZtaX`LzC_v#w!0sBScT_2x|nI5mK>LNE#}n+E(rb znafDv93_)(w8qodSDM`$qCpc@Rr`>=K1pNNut_QCLp|Qs00fIn6}~L~Q)FFQ;47Mr zl}-U)iY;2IV5m2#!JBZ6qRMdJ+WoNah?i(eoEa5SE_Ah=IiR>EMT;1H!5B9pvPd@8 zt~N~`$C-umrcXd#s|`kv=`*^l+_I?l8JTntnlwRO{rmv_c z2jwo4O`NyIkXf@z;PRDk>z#9^kOD*V#AMiJ>_=et1zVPSCW2>7dTD2RJdLKw*v2q) zYK@i8B?Ih`EhV!A)*SVme%0{*s&3bv!^lT%R0>MM`sc9BVqYT{OThS2iy+g?VYFIA zzM(n^oi~W<(U{s}v+RrwnsJ~3&16@`vMgd{$jNeto;!e8X4dE~)<0p_gFxi7QNDdCXah4>3~-wJAp}ajP52Gp|lKdkeB!q1KORUSSely@jAFtuYI> z%Gh3w^X+E2ixgN_Pewm83u=*>IrJMdvd77etk%o`mX}O}N{4uCk!PfvH$U4F zH&;@dSyw?slp_&&=y3!lo zt!$AO^T2R;o-tn;yL)riPAd&nWs#rOhr3PprzuP&P-Mp)5BHAKd@k@n?zw6SW^>uk zHE1)s%y!`i!tvGd>Q!(7V)G?VuxUb36T@ilET0z(nJ?jyj9XQkR?wsb8)VfY66j*@}A4}@csN=$8_OwpsVEwk(?e!&1 z+9pS`nAPSe3uWeEGzXMqOSR^iI6K>i5xg~n83vW$@{y*+!K@>Ur0#wZtXC~;)~LmW zkV{`{)?zY`$zJ>CIh<$nKgm3?J6%_hu}vy4cXM%^tsBruST=gD*t`n@){z&avJ zjN%PX++U3nBV8l?uxcP^veI{@7AfJ*WPYiltF>ahB2fyE+t^=IG_3|h7ptX>Q&*XH zwUryrq?!_)4enOEBIMyAE0-4T$*Bd!%BSgQ@?ay4L`F8pFgKPSf&9Z#+n5$h_+>5O=w)wXksBC~CS*fgo ztWk}Tm_gg8ELCgv0H&#hBW`wYN=ZDo$vy|K2v%v?t{B$>LWs3J%1tZ!s_69#>kFpW zFRZVnCM+9elKEBE-)o^XcdVV5uR*+N=E-VV@@+K0;)z@cEe#FV&@v;R6*GcLS<4l6 zqIIUT-5hD<)PfoeaM8Hv!=Xl+<{~btT*>E`Vu}*2=KPT+VMCN5 z3&8}JB^t`pIc9ECS&3q&=#u;}uShOO#f%8<%gE=NSx{2y7{ZEx;AIHK+9+krjGl_f zLtNxE7)^qSIE&L(kR3WEISTV(a#S^)QLUV+p|#i7d)bZ|`4iuYQgyhFSZ*s|t)DZM z%%(NHr^TTBXNefFY8C0RS;1F`9hI$G$Tg0edtwbF%`kA6mH|+uL78KoBr`&*oxC)0 zP0?tJAlb?ibz5q*u9>mQEES3+_8n_Q>r_5&#F=O`3`A-fPTMiZxvMY~j?c3e zg?WnlFw2xt2(*@;wU4m85KCOcr!{3>Rib-#lajnqlXV5Tf_~SW1%u9PK?>VADdA`y z<1z%pZL+`?wI;TG!vBZWIUHw-3_5_-3%`+blo2!< z*I5NjrAlZ*a-eoBwyYmLuDLBZYp!FGqgnOB-tn|uy`5YIk$*f7 zvR%a1Z@Z-YkDIRjh|amEm$j#uVA(F|MHps=>&YVZaQ%yYdJ#)_68&>Ua}je5T1qQr zFt9|1d0#cJ0YB`f6bG?EJgi&L?rrVYMT1~SO_fyP*qX+=_aAwf`yP`nw4T@IDMmeC=5&6Sxv=Qgvs#0!-v z3~Md)L|BX+Y}JLmY1J6<(BPTs$E{hS(lE^)j5|^hvPZ=3Rqy;V`b$a(Z*!XlYs4Bp zY5QWt0e^LT{)H}6>K)Mmn zgIda_(zx-uX`d9)j$+BMiQyp_ax*$=%ogI<|IjD2=$JY(NPTlVJ3W?bZ(*yiCjX1I zj-Js^!@N`s+(MM0mtj0zd(1BycwGsu<0XirQ0p#Hb*TM5x`tA%_X~06Iw;Wp?(0FP z{&!ywYW5<|D4E$}{z_sWlZ{ryV~fm^u44~Rj7j=`c1Bu9OxtZu2G)BYbDCD!)HftM zFJvbG_qG+|ZHNC@nRu43U$%Q45_JZGIA2$n}M}$$bm~`oXFiHf++S&n86gHP> zzP1q1UtM=-Jqb;;UO|snjWQCgPvFpY>k~AzQwS;p*Q!u#@xZQPVKCUxVKDA8xur!y zS?7Z&jC7d+DAhS2VIO6>xX|qb;bPtvOHOshhc79LgMBm5)GUyTam^=_fJ1sDgjS~JYPF-$AzFy3j zN(0C0s>OfOH9C2T0h)-z8|Kysnx6{dvGUQ>dVTG?RxNj}xpy4DY^=%OyTFA{BWGyv z9a-M+P3r-t0dY`}tp;)vJvlJTt}INh+?fPz_6%EHWA={L4dP)q)C9BEd5n4ijYo=< z%2jE#<{(@vMEl$dsup7$LGS z!HU^MjfDt|)P*$LB3r5AU%a~NJYQF3nX*THj9N*~0!J-I(UvmbVjrdHQB{}CW0|&v znS-?Q^G=*3GiAT@^fl@=PJijO^{$t63MVH0FIG!#9Z+XBX-$s3Cqaiu3`}?TnOf>i z?&ncSk{G?yZ+#m-ojfJKSZIx=&t)nI*H(XOV{+t;73s$F+FWNes`35{loQBZ1$NV2 zW-9xCk$w(((VA^lD*oe6m8%+=Ae$AVd{I0@kEq(W#loSRkUMd}wXqbf*8+##+yz z*N2$@wSjjHljMJgYyRK%Ux`c2tzRsW!>|<9LNoE(FeGD~N~_S(LmImDeqWNQV<>w3 zJR1eF`4+4pE(O|%Q|K#lbfT|oX8<&F4^c>{&|v6GVH8q_K-i{JUr50-U*h94>0#}j zY$9&A)MSK`WH}pxQR^@%e?&0f@k=arMoTtXXXOjkkGNQqRi+_v*UiB`8IDqU!;OvE$K2HR&ze$@lBHf z*^(!uh2qVVwS=xj7GH#ye(*A_R{-?IiCfw^ioh1>RVNFrcZpO_wbts9>B|fJW z-M$MtJXC}Gd}Us{v+3GQwTn|qw#lLHbMUI5Lg*dgfJ4X(1Eo}Q^)!}Uvock^LyZKD z*dd&@Qsh5PFFU@HWaci^7D1?6OI56?vusnt-YK)hO?(kwshdH?hhtl29@l}=-OSft zq2=8C15xO-7}tNTC~JSj5(Qb<3pBA#?(~=KRktU)WNAhwd(NKy5RyP$$BsLkj^p+S z%uou^3s+!yobIK7Gecb5EpyR!oFvJ@?C4|Njwt|NI*$_O>3N@un+SXcxJx_bauX~` zS8j7%i^JC;kMas6-|Cx9)WMC4h49R>Kz)S$ZE+RI8XjW#HmwtuR~zp(LXtv}-y28U zR9X9S_{8~k*rGII^nY<>^PBVIq|sxb(LbeI}1mQrOFnuJG<(&pU%b<N$ws<}}$5Sf|ERe`1ECP-TY+J1c>1^9`X$$Ow za!-Ojhnfv%mYT26)b2U2t++EQXdr=r;C>3YW*nns96M`8qlX#&?LP+*6oz}pt1IVD zKC+1pkwPpr%qJX$6yDahF17@DRK|X!F{$XbBh(Kk^+odVFQ!damHJn4ZjH^;cc!+W z(}r8w2X|Rqa zrl27?o3_0Kp_l%v@>=fK*ey9~h1L2iSNn~&7Br8Nv^=jt*l`H4<)azlt}Rzh*6mr!i8Fyz-xwIl!8z6{^;W+S^2umiP>;lgy>=;y53NZTge%)-lbWR@4V?07I* zdbIABonOQ_3=L#lk`u}hse-l#7j*;0e@-W!oqvZ)S|$+NPaPhFhhnF*FYNy1`cMthIdMBzG6xMATZ0qtl*s zh$!vKu>m#>n6@9J(@qb`IFTJ^*WBmR&u}W0iC(YMDA%FXxaO8=C01ufig|uwiMEH+ ze#ls~%;&-&)$1f|+egY+ZCuA0o<=Z36NDqf!kaLX}bjSIHTuSLYgU39Xry>r@_ zj&zpg-&wkNO>-D&ep4VE0Yv4fU4yn}17@hH`k|Hy6R3A*9Z%%N9qH~8V0c9oIb>`d zueAoCYOF~YYLrPQrgNeuH!(FYF$0^)qOP?Lk^vNsghVE(%uex>Qz8&cKtrOS?x>`@hfV9Y7(&YjRXR6P$S{MNjONN(bhIM`AT9XdVB35~ zO@cI~dog>Flf}Gl|8k5GX@;$kabuF`Qgh}RE#j^)uE-9a8>R4_G*;S@&K9-PQa#-0 z?(4pU-~g~?Q5afg!q76t9A9+wuc#gB%$8+(_epd4Khz48J18Zb0Y!zxE@I=UO19<{ zOggD^%HSZ6to5VW#(3AH&dK`?GPzhK%vA3Fjcls9nmJpaoO%OSI!38b>UHInW1O+D z!b44O8in@vhE<~R?5m92B2NvQPsL(57eVW3d?iokn08xY8meho>{H9K7$h{W@zkUX z@zG|uxXA(Hhv8V2jnADWvvwx7mS$aNeFYUScA#u^nRT(|@xgQA$&AfqKStiUyhJIV zk$){2SW5)nYFU*)4x099AFkL66Elz_K58p!PqU|IoLVgv9_wQqE^Pa7s!?0VqUTOW zHBm0eM=?b>n?C4c0v_ZPdsz0E4v%+qs_vCPs~95@HM>W-J|VMy@Ag)itT>g}PAbZh zpcN*sPh5F%Z@t2g8n$yIcKhUgCZv;M;Y22DP&);0uGwx9xekFf$u*t&%j2lbrc#rev<=rv9@a&nq&Xo`av5advRE=r zHc+t1Slped)v@x`*;I@^%4jq@9`rg#2fY^U)NHSdFa*b3@O6ce%EXtLm-e_J5RtP~ zu@3@GXzr#xM0=>sGqy^$J0%S9Qoc|)iXCh*7v&<9Li3nku{(&)N98f>ytkSWb7<~; z(MC=w;Y|*P(ZvnDE=jjY(S9nUHuxzKXRTpPA$wg|Kc%tGtlK(djtb8fZ4Iar^|2nk znCTIO*2)hvxoXfyV8;Z;SqCo~uC5aV&{yD5r%HtppXYeU)aW?|pwFimDh55C zUDx8nrrdNF?Jx#Si)FbnmSqbsHPHL+$%(OUM&&QYsuOVkWyGenn(%<06e7wrYAuLT zgJLN%8?8?jSY2j}g}#LtS!=EUU6(GLy)jrtt%8=Aj%r;uq#lrq$W0PdA!HWYD$80k z9J^xIp?!}|(VH8FWk=lGMhRlqSzAnN&84=pcEG+IQyd-KguytLg$i3+7!#}yw$9(w zDHy|bGP~A?X^^qFeBbOe%UqPUL`|(zU7=Ce+BLGl-4rihh8=7Jlf2*9H;54OwaF;W zTSk2t&L2!_DP+~GCUI^TGGN?E#ir);6&_iXeG46|Eo%23R+=q(YOn~dxm=B7aI+5| zG{-`vuY+QkfMQ(pGqP1zrWS?BWYrrfSpP7q^ue$kJK0ED-2BOt_MM>r2kHO5lVr)A zKlz|ZR^xG#rSoZ(!B2uvQCd&5v9{s6NBMk2BY3CQ%S&y+bR1P;4dAf+o}yH8Q>^?{ zXGCs>Uyv#MT}OaG+ZHD<^R?|Ku|V##Z1OKg&6 zaavl2jQU9@KDxLp$;fE?4804hsh66W)EIDBkS^a`Khkg9jgzSLTOui>K4K32bV#eh=JmkC1Y*>W>Nn;g>mjG>xXv6A&-=!6-k-bXsAAD zhZ|VAe4wP_ol3Go*&eWh(T1KEmTgnsGgId8X;@HtdA(%Pb=DU#uUi- z@X3=SUpD4wG#EIfAFPu*P^T%kG(|*{!7>?9&4+1JBlY}3jrp|~E2d?{`xA z)JPV`NobT4f%cluO5$`Dqnb>CY_Wnp0t;;YE6L1liBL!nHiAyP(~$x;)hwk zu&=51HST(4hm|ZbcKBSqia{>yI%x@$$^4|^!}3dQ4Qwgenj95W#U6HY(MOO2^pOHn z>rA#ni0;hRG>32Y!a*^emo)-o_M#&U>4XkN5VP6nzr5fv6WqFcjL^ zjMH1Q(Dsd9IIAX-u{q1S>1EEJsKM+{VL63_kA+OD8` zLSMWj?|j(}9qSk^^>WVU0(BHXCv_fVFYD8)(lb;AB#M5nyJ-0e?9y^01uGus6bUsW z@K}wxo-v#CqkL^Ms~9%=nb1tZidr_MRVCqobmcfq0b4}b%ujqd9RE!?Z6l{X=s)?- zv8fR~c2>1oPq9%{wgo2@>1dRKgQl{NeVOPa30z98nfGgUe6wnyX(%?vul0hqTC~SB zT}lwAKAJhQ5lL`gZJcJKSwnaOf;F%u8Z~Vbg zV74JZQ|^PBK_X8a_|ROa7`Zyf7TMQ_*03k!E0l7=RIIwHXkRU7iCEiMwZ)bGKD@-r zuxyy^0x?-<5&9|kv4&B?6mPUKpr2^bP_%vIxtV{a*~{)mBFSB1ZO%@oiTqBGG-(qNq29&5Y`uS6sB;Z~wW{&66xC~({II}Sf zDZtKAbozfO2il0pl?z)jv3`fxSnIILs6R{x2L2c6l1}Tql%pzO{iYkb4Lz(83SC&8 z89p0bd4hD}%PLT7$zqLpvepaft$8bnbZjXL_y+BbvhjVkmRF5-wGM}T#mT6^8=^oW z7LvEd5-#gf-DQroV!TEES{`{0HjI!t5v@*PVGPMWwia~V%rfB>&FTGO*sN9^YQAej zXZ~x=O%6w?Ea#ZUT>Tfz$UgnRR~m~Q@I^P{>qNxtgU`lOd`PfdwPz-BmetVkWz0`q zkbhiU6^B?$#rttSI*GgVZ{LnWI-Dy85P*eBQ zF2>IBEm5h6`q-wi2s^1EKVF4d1d0(;Xr5))!}kJ2wQF6SXahzZE%GsTqJj8vf4Q|9 zt+TGAcEEmPqtwapQwE*1ABwHT%d|AN zA%9_nr?8$<2rE6ljvocaw*XIhJH zOuZLX!QReUI3peL$wd|kK{b(*sVP4uPHJ&HgGthdRx^b41>ySvz7nXls$CLsSD4GW7IMRh;S)y)!aqgwe*_faf&{7c>4gK6OYrfFC6mL(F zuTk6gz^G%3iWf9K+F+>#pRp?r2EoneNikbjrf%HisTtKU**n+>aq^fFJto??r1Rq(QJ%C!L`G<7|mmJFTSi0Vbn zKKL61Afl&DM(>BVV|&y1u^)sP%?P8%wJdcdTQ9QEHC8UN13E+eDmlGb`OTHc6|0!Z z7hM2r!~go1E0;((7%}Y5dhH?U{+%+M#l1>4WBUJ65xvFYVpgP8wtv`1yrE91ubdAC zoA9Nap$mvIawRq?hL(qObn6S?er8$`Ej#LP#;4pa5oRg9zxdLL?gFQ@7nlL}$!4Ds z?dQ|NFHQ&9Hy|eO=ih*U$n(uFK{?B%bC>3Dl~Jx2KL}*bq{Bk5b`{e;gex-g4>dby zwDt7z#H7QL(up>_kz0ty_G!91mAb5|Q^iEB+t!Mhjnj1|vVS)Qf-dS~%8q;gb0-l1L#@?HikwE*IZ7i`fks9j}h=8QWIV7@WF9(KssfbVR!~aj{9U%sW}E)wZ`Gw z5A3(Z^s={rFC2;UXK}xvVs>+4GvvAmDw`_)|A`1e^CeC_yB*KE7TwA}DcFwW+&puC zd=M#vnR}^BCgJnil1#i?`KgvJ)X+}$F_6eH=)n0EQ{5a(x)kZJw=NS{v>Q!xdD%Y( zWb3+J>k7e4<S6@!CV}IOyMIUN(tETgARhGDq&yg^q|>! z8mwkt%;Nk)Z#`l#%!{}YV_5@&ZLlm(qQj&*SUBcijw#fa!zC8zoKpr`E$}CfD0!18 zLyONAH1`5D#q#Fyeb_h|fWjna)$BCbrjo_Y1$J>m#Nz4@-a~$}nr`yT|LjT5;7e(; z-AS^Zv9mE85xUrp2T!z{EF3|^*cmpDnQ!h8JZqgeJ~V@MCdcSN``Tc6r8Za|!#D5H zDV%ZQ(vHvGbfz{;6ziFLq1kJ2%h(c^kv3m6|1yW&_hetQVL|{t6TW?8&vPGjh>LDK zLTlzAAk%8z@(?y({=^XG19-~}laW~{85)NCy@%_asXSHBoo6M5|@^#WKtVXrB zu=3FK$#XwMAWX>Nn;AZ7??EJXMR7nwHnrsDJp@QTU=^5$Kd?_h&@Hh#@WeD!Uwu7T zsPQQdSGB}S7`NkbTvmx9H>9)BHl7!AXm}sBg&|n0l}B|<*KyFG)h+C#5s86Q?Q@$w zd}7<;50bNeZpYsjFQ6b=e-{>ty5P`0MbflpLnA*`BPXutkt0v{V`EKLwlP}I(8r9S z>dRGOp20+76uZT$!k8Af!@hHbxWc|r2)xEIqOuOuhMBk4G8ANEcx8|Z!}KO*Jf9SX z5NxTNXw6d1I%D%}ilAo{W&7(KRWr6eA6>yWsJf*pOhEWdw`(O#^3vR`#H>%E`b=ED zl;Zn*PNF6gd^CAk+cYp@`&XN#F|n{s>Per@$jj|pay4Qd8$Ky<>nHh$M^*?$w08Y? zvhB4LH5ysQS>${%LxnVXshMV3p=2M#LT)CvDAwY~YFuqlV0lN}f1Q(puVlN>sDxT!B#SOvKLiP3{?Xz|y%?Jm=4o7G9eMq~&Q|2- z-mzP(4JJiQiZpCJT{=jnuR7BR(ty7SqjSXrdRne8HL#W0G+>M-u8MLnTkHK+V# zS#my=Uq*zNrPE?t4#t^0t43t0j)baK^|w}cQ!=AXI#iF zCkVv!5|UIJxlN}&eq{Ax^}D`_I#0?~7l*X!dvtE1AW!x^aQp9HJM~)_RDsg5k+Y#Q zq6rp11?{&vU!OOQwW#q?dxE-0oj`A=63V=bNUalY#YY%JO@?UJl^ zqNDL9cm{Ks%;?czluZX41GLX&x^(kW!@syGNc=P|C=kQ5s?3JdoJml85GomEgQU7y zWYU@BzYezk)p0yh>hVFx*NQ0H=16xk>yr*N;FLL?Y92aigY>;uWU3PltyT%vU0O?v zis@!*L+sJ{$Sq!rj$Wy68^?yv7_yRI&v%0KV>xcV;#>kIO}0jVSkY+Gzg}rG+df+w zSHGwbxrs&DVpK8$!Ope5OcmiGQ#LSSfvV^7i#%ZG^1)}$;vt5 zARS^rH^{F7R%N+=slw@@^6{05x`WCjHtW_-s$WL3nDhrNSgX&nZsu`VNL7z8Y*xA;3gKh&r|Lb1_YFhHwic%pR)oG0Gr8y}bnSH@t@!0u?S-X) z*4B_CV>|YJ%rVw-G@4!%nfKG!8XLc2v-Za(+3;v|AFn6<6MN8c61QO| z7OtKQ4)T|_$Hf6*3VXafNp);QomY)o$`&_eMm3TJX?+w*pr;cR`$Qyuk4I~8@$i4F z$kn|q%uOJz;>wB3`;*LCT~B=BP|~8KN3I>`jItFMNn^A+Z_`^=$Knr(%Nzc2JuDDf zY-69D_6KTsR$bDnv|DF#?=5^ck3;`CNNpPPhhyf?oj<$dSSRUetO=epW+r_B*3`j_ zC_%)~Cer&#m4iivbmzt)$1I-HabPnXQg59-*d4PunM@pOT6!Rdp^sTu=G?+^2VHis zJ}s>bnX`V#l!LL8>d7JPm2|g5(#hiw9&=nrc1pvvbYWFri_zz5JNF;6uvR@48MoYvjdApr4I9`)~2Nk%Eje%6i}u( z=OVM9omQ4t)7P%#;}MnRg~R#>`D{WbocVQQVik2PW<3|NCu7E}K3B$uVayh+VCD0W z67Ja(BXyQ_l6?hiJe5NUCm&OgOIkNlCb+&tqxb6UAxG23m5XZ{ue`+I`noBf!=v>E z`2xnUEf!?aCEw#+9(3VinH(=!eXa6DZ)Ut%eHW{}l=UuV@d;Y2Oh}KVm66S~`ZXCd z2eDA+{3DLnP^22t4@1~qrLn3=iv6|KpIQ9@eRsUjO{A47Gp=?v|3IPK&AQ%7dL|vX ztGHY{`cT=W+cFxW-6{|BR^Md;rSe`x`NN{9UG=buY^AAc7KISq#3D!!=hF)VBRUJD zf4MTS3eic;<^-;)HcBrShG~q>WXw@k4Q@ars&onUjrWlxC+i#2pL#v|a~{JiNIiINA!#wvTjpfoM9ru6EV6C`CwrKQxW*s)XfDG=u>ok=RH z*XNcMfpR@-xYje!S01j{5i9grC}@OJ;Nz-~L2`(!W8?`UK?j19$#@@^nfAC;X!iEXUWP8D@8sTLtj{< z;H?!g#&cd6uJ;#5pw%)I*BXK-Muv$Cl2lKk79kgs(YzcZQLg6PN>#Bf397ARY?80A z1gdQ3N{@uM4c7)#z+z>*ynBoE3g|)|Go4djeXSa80%VmQi84mLEU!Y5{d#V`F^Cjc zn4Z4pOW4epIl@)L{Y5IXf7BCI(DLFyhz9!NOBbuJ#qdUJc~Z*GJSOytm1+9$OIgh= zzt&12OZn=+7NKR@M(5*8ywwe*} z(9hbNos2W;OU4~hD)$wWar2O9Tf-`LkKUqOGeDZfHjnqK%Q?G*?bGn?WZVMI16kfk z#w~<1Atj8PQ8W&kATz8|d(bs1kQsN9lcW>zO}BA1ZB?##2D=9Mo-5z!88^KG*Xk#Z zIqZ&s?vwU$i;Cm@wNn*c2%ofvPyCHf#)p1E6B-ZeOfYLTS%Olfw~4tO!AF%O_4yc} zKG-};F^s47l~;}!Alurs&){l3PtB)~Dv|vGY#zkFUPH^|$d8jLvy!R&&7Tw4K-Prx zYG&Tj#6EeF_8+sV?ze-wn+*@_#=Ilu0uPuzTsOu(!FaRs-_qQ5dNDmhj0quex$LQx zING>ihqSI?5JuhLyXwV?u}|g)vY5r5kTC~zsJq1`&8WuQi;oDLxkuCt@GvF|+8n*I z;ccx6!>M5cMfz!HGJV~Z5YE|5yi+VqW~kuhB0JmrA^iGsSOKdvk)O3}uVFm5rq6J} z7vO+4R#GXdfV9hX>~?eTZ&k63uZ_KmX1F#!o9I}*VR~kS7ViAXZz5@s$uF9=EKT&#=bDT7HmP2Mgjuiovs>=Tt`LEWwM*GU`DaG zQ0s&F@;yE*dJB2S_VjrAEFc`@+!i*R(2NiQS*)$TR)s`Nu(6iN$-`igrBwRtxf{KW zk74g*|4>J!f9=%>rYq|*ORuBTUEdlk~3 zQ?!lMk^{Sjm>V2u^3fSZShhGk_J7nPBUiN|CkNw=6~!e`By1KpQbHPqGVPWuW-T5S z9u|H;-K+?wf75eRUcAu`G+j$yHA!Gj5dy5~3sv|kRLi?cQJ;+QaZaz(Q%!VqiL@z@ zuE{%&tQChP-ib`%s7f&FSIH5k)%BxB^orCdD7jCJk!UGVxWoR}a30%y3 z`k}4Ft@bX?Wz^^6g0h6BCsGej=;$tt+NdUu3`2mRP2M{S%YW95W)%BWWky|HjpDGW zLRQEb29RwsKOO7Smv1BV&5ExCfMR7eTB~b?T4{MwB>)J%y*a`r#0CQnm8Kbfb>Y zkzcT!nw(POdZM^pVFnG*(H8N|UHv`O)m&#gv1`Xni?ZWSYyp!~%?iGF_2;8AdNGc! zTW*GDJ^GsG)dQ5jiZIJIri*4qw@|i8EONB|+o?y#(goo$xD{0mmP>Lh$EIv71RYK* zUoznKVrFnwP?fzWF#Jp8Q4Cdk@XqZ&$`vPC4TM$a*&OfRJB8EhZ zzL<)sVxn84nP$YnF^Y>l|7RD69}n5cO#=iy5z}vE|ZQWIhQ;3jYlG#rd1P zP=hpy;Y*xqf9yvai)pgfM4@siJ=^#eUIjBrHbVd*9BoR_4RxyTE!?nMpMCzt1iAxjclsbm9SH^%Ir(KvF#1AfGTNB5j)HpUys z?(R_mcrd!7!%!~2L3$iTHhs3ay^EcMKLwK6dt|1s{_?_seSMJsr_LAld6|=#k0VN1 zpvm1iXidn4cr^Ttd^&eoPifu5J>*K;$aI#JA4Xy8{iFttU;X*jpAO_ml#0dT@65rg zfja>zy^Lq8-|+O%uoLv}0w+!G2Q&=WrQ~K(uW28q?bGIc*{=}d6l}@c`H~_Ln`28F z?y2#Pt?2_+!1514qylUqnJwMCo|E28I1SB%0&4msuhslTkX=Vn)6eS-4zY0$h+br? z!&{x>)={lQ%syKX!;_xC)i$UF@Za;$z@6ATXJYTpk$0|yb|eH|dm$cwepo>i*c zw_R)wX?a6my!^=lHaL;9&lz^aF%-A~@!~E_CCPT?g;J6$k;?tV-$Ih2r?vr+v)cG% z^Ue*KdVsz2{WQVK^nCNeq%}^lH&dV}ut-F{KPRfEpjv}a-@I-J_&CRCML$vxH$9H+ zNGM53d=B#q7Xj&kj&M%md6O@WDOld$Eh7R|*i+9U;#%iY%4%1LB4*HX;W09<9Uh7m z->@E2X~6-*(&}H}mB%p?T0_2wrG5!7@Q1v6Oq+QCH=5^}rnETEh;I23m+b;jPZ_%B zantduzvyPX|GTgL0*mF4@TOvzllybRDftw647>3-5>3Rzlip_&uDN^48s1Z>5df)- z?7~SwSlV366u&sdvPti4+`f7HM!==`SC1T8y_9}q+DN)YhXYna`dam#ydgl|rXArf zsP7OEMO0b?lBDxDMK2!{9v>QsX)$7W6e?}}L%QQ&;Yf-Epq7cS7+y+a(xKXEEAH};+2W%6{_!_JmZwyi>OEo2 zrAv6c+$l9MU^QUvz#!VyA{$sk+@N^(+h7J=%7e5_i>chLAQ?KAm7Px?Q1_uVbATM! zsAH`#eW)xv`~c}{0-_TfnucZb(<($n6%fIB;x{Uzztn!|WsVxsEhb3Rf}~6JRB@+Iw9B1<66sL#cw7w3pG@ zJYi^2UQ`PgfV0ic57Dn)fHts_Sgej}j88Cjti9G#9-ImbbsN8s;^oEA27vrJv{}WEfG_tLK9+=l5t^?Mv@Ax3#N!JaHkXDaFB|y11j5p>QW}U>!b}e$yHGHb zwf6iJ3jsN6;V3_1Yo8P2LZ%AU2+l`j?Ff(_a8e}Y7b<_S?kTTz^M)0w;uvxZ0FlQx z);#VFLME;GU^L9lr%uajO4o4BC69&l8#-7%XUPBpFelejW53?KEyBqo(J1H;B%asH z1v;ds1AUgl6tOInIfd2Zt*`!M4UB39$_X@QF@1*XgJJ@kXv?$ug7Dtn^2stc;*JH5 z!*gYOlzogyM(w&7uC|d$R1lrY03vE)S!4t77stT*TDlxlRX~JA?_s+zQ((HM0(uCs zW1SvWnYZ~7F6@?Io|0%u!RNX7oxC&^fA@%Wlv%WaT5W`%6ZB!WDqWbB0aTy2;S)92_|mmR^2hh+hZ4 zaW{UsP2?C5N>2ix5R2EmXXME^Zvuzqs8`>y?s{15jjqp-|FUVUdj*6lLP~sxu*=}(osX#$ z&?CInALqjGwv|d2sUA@cVjy;Z4Th zheq>ZjSE0n1;wtt!IyN?gw(|H7CxC%W`Qe|zX;zk&f$OqR7*M!m`?YdBeU(p^!i@+ zIdHkUW?HT`M|a)mF8VY|@#?A`4Bwn+1ODZS_8d1YN-tj^X9F#(f`~-W@zwX`eBq`n z#Ox|bogV>7z4}2eJMNmGX2|iQxr6RC0bmoeI+uWmNo5f#?Gr)np{DGmc8Hb?^JQ~O z|Bv@O=dB05ZEm9*pQqS{cl??|i!t^ABM;hNfK_n(QTKPaJ>3@ta%1svju-uiqW>AQ z>L|}fulK`9Sxz3|rvt$(&%S@z|ICB&*yVgo%Ef3O5RBfV>t{R%oNfxaFtY7Zd>Q^k zO0+Ye_cf)0lYq=47OU!s{8HN6#>|Cf+%Ai)V63Z^Q8v301MxYWuJ{}^M*YuWchKDX z3=_YhC5RP+1NrVn#ymi{t<^il{eiy9#js(_dM0L^{v!bg{*i0c7R2;ss@gt z*No&_oF`wCMsE5#3gqe*ri*MLD>DAB`sCkI3ydyXNI+*Xt^TZQ>mC#z{TF=k z93&Ei3MCdnC?w@t{s42;YviOo4`iFWRGiRZK17S?4uB%j@lm>P5cif>k-j=xc-WLT zEx@0w>>sJY-aKte*d|k#jWkriDknX9(lk;`sok$!QFv5)M&iFS#Miu^p>{>wp#kRQ zYE>~(=5zDcUL~K>Vq;I3&_M{a-Q{|&w9Ea6U;OL&45|JG^ZnV`>GaO;*m=-LF1ZojX*&04X!!s%d@RD;7Xk2-BXqRz&9x2 zgXv&hHy_P-y#uBF18OaKlboBZUkgSMssqB7oS@J)LA(_RWaXz8Dwv~2(@0tvoGSSZ z66h;UWkLS=!l*?GtQKchX$+!IF1(4}rE-|4L;!NAgZA1I$-q&~pM~y8OLvdb8!d{N zl7=W2x>VhASP8fTatal|k`%D1n-dWX1*9h(qgHILp_5(vhd<7se7nZxOZ-gSSNQ;Sd=QmQx~Pbg<_eb3uf+UrR_ zJaq|)bC=_1Nc|CUsBfMT6ZpcnH#6tadqUV}i-e=-WPUO!m^WBNL`rAn;S85g_cKxQ zRYT1ni98_wI94A%b^|UdNh+60i!Sv|p5mOF>#BLY;WXCp&uRdONs6?ERxPX>NrSV!8F6r^LopF~ zT6t<=!VnS`1{L zSyl_lxWE<0Vtzyh;s?6Zg468-(Y=eoV~ zIM+~6!spTt;6ZcCYt{+Ns~9;TtuR80nnj>{9m0@iP4AEq?%Y)AHz|1s7C6&yJ1b=wj_}2` z5YILroa1XU3WfUKqb5OWMvT|bvf~Ec%%;?rN;1S7#V4ldnh9u0mEm^*f~*AZQc*yM z@z?yqxIoeLIeyxS*=YSlGb16>4HM3*DwH6j{V^!hGv`t=1~$qcvmO@t#I<%rcjud_ zBuj8{3lyTA9=ycULIg_zlaiLBcoXF-GU_SL#4#il{Fsrt)%xr?2^CgyizG+XeCdWt z57p!Aojh)Sd~kR|lP;Dw-rY)~r06^;mh^O=O@g?H;@aWM&;(UDm-%$pfOxP{Xkj>t zZHic-6~q;>5T=PWw|K-zLa&j%~6lzmNIV`0M!O{w%YTM1YZ z^$mdw+v|2qbxOw$6I=Q3Mes;PkG;;U8LXOI{FKBB>zkr!{(UQu#7OMX(3Qflef@MY zc^nm{7p!>?#6gArWov@knkP@E|KpBbn;$i&yZ2G|B%6@!FAX)() z?$9&78mbNFM||;WvXUq%AMiMLUdDxA9G@NlSvZV|#Mu47)~4}RWkQ)#FoCx#%7wcD zN}#BHdU7}^RU{5+|oJec;%Ytm2Y-jaAVLEWHe zw2fl;u2H~eA?`)dU3mc74M$d6?OZyDR!So#MS5IQyz=4cAvumzwN7k~E)-7W_D`E; zlS2JA*UyKXoC`pCh^zUSZf@a_&ca^_G$ThTV(uU8;vexg{r{>3X}`|TXl=kS<=^py zpbf_NJICVo)>>$HuNOzi5O7)AVA&|ef3T(u8`o*unQa9t6k99#%|5TLd1?4uQC1+D zy0icYX?Yb!YHP5i zi7y?MYKaE>nJ}0+D^ZkzbzXf<0d9Z^7|(Vi99P*dc4E{5nG`Z1amCw$SVubp7@=_e zqOGtY5prsvHDC~d2AWERK1a$mcl+TR7`D9f*RBQzBe=P(j3WW*RnP0+@zopO!8VBD zJMQCM!2xGzWEBx%jM2`ISh|V9Ye4I$K-sKCtBjDF`#HH>HVrF$pe5_qrMqr)Gk`uN zMV2p7Pj(aRIyefl!>CBBN^@1Q4U|8vcSpQD&I4^t0uFE>o9-hiEtNznL~&V`XTp@4 zPo;FCE1|i@6D<6C&lLgiq@&H|juzsOu)lOH9@ECeEesa=WhhRdBLv8ydeTEFaGX4^VLH(c;&?n0!J4aN@2QJ12{Op<@tO4d5rf zcWit2Z({#bRoY7dBkyVn;x}*kXAE1HA%4Jd=Jq1v_K75MZfCkY4EMD z#|ATol>{x35Q7W)dB>n}y5;0G1h{8a*jqi|Q$mNZd|wFfWV%eMPy5#$i5`@9r<8K% z{^`l9KmB_0EVg`;OQu$DqC=xORs$ zS&HyHS^<#;{fyA!g;SN!eEoL(73z$pTluShbI|XpN?FDpnx*yLzsB}ZrY)5amIa-x zUHvk1a!fvv0(DViF9K^%~Wk?oCZFrRv^(Fs|VQjJ6-3 z=62OP;m0m~I^SJtz?WW^T9_G}oNnHwgz{v+jaI7RxMzCcD=4jfBxT~ob8?qtl+;uR zPQ>R>P^fjN;6V<=u^cr&DFM`FZ!1QAx}pX3lz!VCAc6$9n?Hl07oFOrlnD z@>zaKD-$h6I9+9J%jvo?`Q2t+IQgpkSl{`jq`6Peyj-lbRy(!J7A^zTC>_#G>i!#H zcpAO&1@sF`GWe@0k(-m9IqVGhgS6E?wHBM9l31_a70(>rQ|l4CNt+_@bzjm_Qene{ z59yrreUs@%WZ=<%HLUysn*e2l>gO4vTM~sGWliNfc{uMrkxaJ_cBvF$>JvWs=p~RJ)<19!j#cWl%DKduejXJ zn|2T@bhA{wRzm5Z5Tn53k@-Yh&wjy%WH;U!Z!!&~{mZ+;Rh2~Hx}Fwia@OLL-@bE> z4RIK#{v}~6zL@-$v;;^Dnc7q?%u!ld-5B2aZFh_Pwu%ok_1Ye@eWdP9q0G^Jc2_2! z&-M<^m;8fD(SLf{1K*QnL#r4Z@{;CP_o};@ZMeI>i0W12@zk-3**r9TmvyhlM;3=} zT+cn^$s0fMgX#1WF|rgcjJ&UgI7EQr8LA%>hY*!QZTWrd<;-1iR0(@|ovU`5j>jCz zOC{FAh^TBWi%`_XwHX+bA?F?wtnQN4{c0?LaJ z`zVw|lO5D@*2Zex6y8|eK77jXuj$4p{H5MI-npVEcy0WY`8G3}?S_CJaBRE0GU6W& z{1SkBZ6}p~;pz$Sf;42LC)s2d53SqrUur~R1!uc@e30vdlIzS74=>d& zwV-#Y-B$3t;L=WvrOnQ$MkS@pBDkv=yK}yHA!a3FWw0#r@W=a-t@CwP07{3uhEJA{ zY@k8k)@Es#TsOZ_v9vs@_S!eOIVz=K&Nse&4p%9`M%BqKlLf~L|0IaVD-g1o^2>kfx+msiGed$1v`=l{+d$j*)vXM0<^*`H;URLef!jsxl=a$rUG1AS z=msag!7X3q8lu2o|E`8YzWyx@hV0$)yzQm!-rb0Xhk+aW;;ek=zRx-IO4VPE)RCxW81%oT7Ok&mS=i2M*dD9pVM@8z9GD24WDvH~;(X?@rr=zJc zQk+DsbDP#Bt04*!bi1X~<_g(hN8yEPF%nJLl6%-dOF){H2(5hYiiP{*^v=yY@4lxf zBp%qtwVvGcf&Mv?Thww~9+FLf5H4>=ZN>Oig|j!4s9SK@O?C(ybQ~WXIc|AE802OV zKh?5bP31f9{!FQix0#|TU<51e;NAIh3&Cip&-~XAC9oAK$B9snwl1Z2W zy`%qBpOdpmnNl0pfTWNPj#LzDvvCgqG}{BACNIv>TFQkP%_ysa7*Q50@leJk-zr?% zMUzD0jg9}$DzVp8UO(66?WF4e0{LO*>`-A|&1Q;lQ)R$6ZXh(M2Z7b33!GSYu@)GU z8(OO+c8|f7D|CveP|0`|;kk%+)^>Y)+p03;eTM9+m z2DwcLXx6eJ%pVdPvJLh4)VR9>5G8GU_4>F~RVaZZ+jEuY9mS5_o*r*v$Vk|rmD4K$ zez565&>Fi&-PK!=FF<1y&=PFi>w?pkzX<2mmhEGTI(*&_x1n=>MdbFs}mW<4tzi0$?2ERt;=tDHK*7vF!xflR|z!ow0u=+?bb>le2@ z{+@41qN|LQ!0W^6bo0pI=3H+=;|XEl>PTvqASF7i!oyj`~~oQbL| z+&fiM(Z0yqiTXQ|F7=lSp%P-LS~Wzp+w8Ah{!Uh9T>{0qq;S+4gT0#;7*6j{oyn2P z_<(dk1FChQChyo=j7)ES81n4k`GGdoD)FfeKx#5c)=`JiD(L4U2RQ!(gX+$F@up)9 z;G@qrw@E=TNXt;0;^s#d_KR-hZ6Fb^bMO6O;x~1tLEqTY6Y$3PvW9GuUIrI*&zvOo z(z(`4zGmB51FV6zrP4h8@I9zCGq#Zhz3@WRH}461%`rU>=sKIEgdkWtai%9o`rSAO`AOrWNr@w76N z=sQzGWR4FJY>4y%3tN>r>%I#+mwQJt8?98HZ%vnlS9Q*T)GiuedjHm===Hf1y_MWp zaEbi1zK30tBXnhyiCOAH&%+yv9>aRm1DH1;c1K&hlYcZjC=S(O^Q?)qG3CqJ;9~!v zE9;br>u}4SR>y00UBV!|yvu{`Ns}>TCHJqXHnoS=T+@_a*!F364hv=`L#kc&hH>X4 zN!^kTiZM;Yhuww>6=(Y*Ys^&T+2|qvI_xK%c$Qe06=P6w2G31fM!kp4rP+wo3ok~r z!jvbHoGRKu+^7@rZiALOr5bYVO2`d@gL-LbOg-&hwqW1Hac%kJBw*(mLpBl;+k!!| zN3I%CxW((5R}4MgeEejjUB-V;H>io+lM_QN(Bqw3;H}P?vqK-3r3xk(e3FpT6tNwR zGSqm)l&fyvI$!zL^2Ye5Z6|jJFoWh~iZe`H{Iq?Sn=Qs9Tnn#HH^TW6 z$LwBwx23@kTht13SG`yraC6w@3{=(3EZ4utqv@8Sbz(N-LymqmQ}1-kZ1Gqa`~ME!9- zyW%OBhD1e^U#uvDKxilJHG7W9P?5FV0$q!yEDW{L(#9_A8yvy!L-tyIHthA3a{_ci zrmBpPBHO>v9@6vOR;E(PY`gh!C>2}Bp02lI+VLuy%sKMTeW@hbYcp(V9kOTx*@esM zyj7L?$dy%%mx$YCsvNko!gj;i1 zF>8a|PagX$?C@(RbkyXf@++xoR9}b-JZ{ObqGtBbs@n4JP*xabpJyBV2R8(}`f)0l zuJYZ<noxfXa@H zrG_64A_s^>BO!ac+F>wycW%=F2U&{{L{K201Onik1z1oJ3Jugw4=%L57h2-H#rDe$ zH9J!=a?6nRE`$DZ`_YsI4@j+^PO`K^033#pxD&groOBdCZt~7k_B^0Gr zSQhZ$rStZ`o?Js1Y^|quIgkYnhd*za6xFlmWE1lpo$UJg`jJ z6mMl;p*$Ua12U0mzGjUF8X9$X!Q9y297~V~95^&TL>Wej%TP#D&si)gF*%_pL z=Lxu+NgjCEs2GATV;5E0slN4=TgLCVuZPPly-K1U&!^o~lA2#&f|j&W{@SkWH?yO! z-HhPtGdS#!UIfdlBn*})iL$*GC$7#0yI%Cx8P=Nj=cbSb$0-))sMT0NE3fXjP3am@ zpitY^_>5K3oTj(8-aS4ZTo3})CrGomx3})RcN}o;?X6$(@keInO7_!;4YkrMWBx1V zrO~eeA((Gzh9z$d;bs?Iwnp!ia+nfvhJC00&R+O$Pq$1mR z&#OxakvKdJ>#kg)Z2*pgyNhd|aWg}BI0m%Bm%mZRn={2#mAt|*Z%o(Nsbm--JWu!* z)vHYaDfv=Tg`h~ct3L`CS!+NP9eL7QdC_@B5fvaw9OHuDA~qgBVZ7M9q_m6unEore z9kR8WDXzI&t6N7_u&k9ylb%iPc1~68kb}!Wn8GpH_BNC>Ibuz$P`4{8;Qb7}x-rgh z;uDPWEwPnlsKr+dCUxt@BqA%8fFw!mz(mh*E?yFJ&1JbaD>kixgM}TGN09e*RAQby zJc^Lo`(&W*5DWDPZTsUf)Wfvv4}=@|V0B!*=MSC|%N0|F=zf%)475t$Pg?b0`)jQJ z5*v5^6RlT882e+%Icub~(bc=26IIvPaXI_4>#SSxDo3M*v1;*H>>p&za_feqxqMOs zhw!Fvb=<~m?dkn*pOg(iEOzN}yY2R<+;YgivmiMM;=tdxiw=Pj28wzd?FK~x*r==S zJKT~_%AmDgvT=wvk;~h+mLxlC%JNH>=+gU!rQ_%NwG5L>SzDt2d`yb%(RzdZEvF*bID=W5eax zigg}>^ymEx+Ik(SHM3MWSFX-Lv^3JZ-D|?xd@|uN?m~wVM^cGdY>s2{BS@n~QkJQZ zLv{I_9K}MzlC);G!sRh=%kVpbY^+c>u;c<(8bg@cb02sF53}s6tPZu( zc*ET3*&8{F8E1Q%TaRYEM(4#451q|lNO<9~H-FXM%v;{UW%ROmhYEmt&xN)lOrt}C zxuFY9)b;}j<7l3+kV9>EYRN3x5`MmW_JLmuEfOtW$yFqyN&H3v2kASjv=!*3 zzyw|`@WEO~zSwOKP9L8~~#S}YL_@O)O1QX=WQCRww?^P@Yre|2-pf8W=Ce|0-d z{G&VX-?ngQu4*7KIu@9Tc>WkCfXGfeKuWr%!aEC^V6@- zfRhCI5flF5+GfxcnPbAaZH{EL6PVMN8kS9Fy~8ptPFSVRkU6qFYMSQS(%CTrlaHg+ zQc0=tXhEvxSoYUuiA}MF5yv$7YK*;z!(7>i#=*NkDQStPpy2O=T#NJLKX^p>_r)KY zd^FO(DOo)HB#KNj3=YM$&ABH13|5JzSI$Z|@%afE=g)n)%1 zER)6L_b*T9-yWQtFIyO!YqpsG@vQgViqPcB>DWthmKQXdS9dg>EzC6JS;+a{j`aH; zHvS-2sBM$-MOjJGvG-3p&(%S9Mk2CRr$LbJZjrc-BrB~ z8b{|{SJTA)rP8d(p_ET;Ci$!MS}hIL2)I^iF)KSGH>4tJIYpVij<~s*ffX-B1n`ty z<-o)C=^4eN!o14ezO(g@^y~kR|8Z;iAO9VQMdg>L)PV7>s-9qZ`<7w ztzQX}>fRg&Iou3jtM`2Zk6*e`2Mw6tz3syT9J{=?^{X7&bfaDH4|M@0e8l+Jl;!l@ zY3sZ1KJyg*2n>;5Mh(gpbX0RhyE?7*@#;>FwM$WSi@rp~PAId^-+tZK7h-V#&TVVj z`*-f3{+vOSk+k`Tt1=eBmK|f|C7O7U;o4dZ=m&J1g|H#Rax*nV9UQCd<)axDZi~$? zF(Pz>;fwxYUx!S}l_?mU-s^SEbvXL*`R>8tF^#KWR0!Z)ISCJ%s=_o3mX~)wa!SZk zLD+IG3x@J+Dx~W5f^%bq^ff8cSip=WU6QmU6Z4%<|Nhatw{K7HV(gD_n-^za?;Y?j zqxt&wAEr-k|9yG>xL~Je)nXc^&fS469Pc$FW!T262jH03NW^D)<%RMPKZbADO@jN= zW2p3m70O#J5KG=u0F2+KWk!~y!Z3oTLyLVzBNKFs2SxKrEnb} z+=(qthOTECbTsqnw zttoX(u#jbhW~TBso>?HVpFPmY9Cf(w(z}{kX5^edKwWFsRDaJ@6b>Cmi=S4f;=P9^ zc(o1|O4vsZ%_ngWiB>S%|vvZy5iH75it zOO?a*)twEPTgTjnRJiD#N>Wbc%1JV!&b`Fj)K*awhX9h^h7RnRB#%bCAoIfA_G4Dk zpn7&Mqn=V!pez)DdHMp8;V2+N+bIlBf_`zTPfVvqYi%0Gkp$N^?w3IkoD`dx5@%*= z5)e%2bMT_bp1QDGsOYLQeYB94ZX?wy822%f#V2@AJPK|5Um# zT&3PQELz=Qy|X49aA0>>P9v=-SyeOQp+Tc5o3hA8_U(fRnu}v6qFd|=QOjT?L47KU zdhUt$-9v?h`G_}0{#9Kn0z&+@C5kzduFr8!N#P_Zjo;v7))~fpSP5SA| zE=?hG%1aDJwRTKc|9_pXy49VRwz{i2ta8a`Q}!tUgYO?4#+)QbR$C(lYNfJXx1zbb z1Cc1`dG%*nyUTND!Ne+i%A|%C^f|VHV#1e?6>SJm%I)o;a+<>_zd{P3k6Wx$SXKre zw|hY}S?a;EX~HZ!oql+N$rX3$MdEztwUfDJ6#FCc~G44 zisI13LG4t|zF=#`1-npqq#W6mCsW%x&;gv|8OF$|l}h)zZ8TDCY_$11dWSW<$tuo# z79&cLG!LwOCp7JhLRz8G=z<$D@NK%*0p({(@REAdtH&kA7!9I)54kp->nhdxmZQ=; zjG7h8|AfO6OZeF+_>iZy1MQ2`F0rcOH2XZmxiiDwUI>#k)|+_g%H_S1jJ@ZqA6zi^ z%1WflVTKuZhN2&FWIALBszYsg4^$JX$EITog=O#GCMv_}Q;c2iYx>6f=lF`$%#&OL zTgnpbTaEhIl&Zm-V-@Z0d;oayo)C;*zBhFj zn$SDS(r6)YLZ}~OHdd{&{>2;No_IaDP$5Y@y-Q%}2?c=<@3WudJRXWdiZC9hO;LLo z|8$9`cX>cVFzsw9DUZ-@wA$e^d z>xo{Z?be&oYNjaO%%aD*rGq6yJByj42A5T937*?GZ@&jJ<;UN?d54c>0-N<5hBRyc76^TDH(exSBnFA}2_N_oqxiWcH=oOeoOFjxc zqslZRFvpMro3!w!Vr1l)`T7mQkw$}tbc!Zhf$xzkPxF;xiSv^r5)BAK-N(t{1Ox>7aW-~w4dRv6h#PJJFLCmmpp^TUdD z(4e-_k}U|_;k(=&=D&ZKqF1_Hjdl&WH10 zl6yX4KpvC}g6KP*4`xKOZk~4 z>(5Q29%d)e_H#54mCUroFlVevasi_~P5QCDJ;@QcCEU zNK!4Fr~l=jr~h!%x^`paLhPKp&=zjG!ipR}CmKTZ%ZV7J46E*XQM1o!tXLsFeYpu- zEc?=TMrpjXJ|r{(CG>%41cy(Buy4Vtoc6&7kozyY{I zRPam6wX=#1;Y%9Q9|i7$*wp6Cux7SnKg#NN-ea5E6`VfySW@FLvjG7@MvA%ZsSU-L zv3CCW19#8Z5Xri<3&O;K2Q%YUu`>|;Z-h>pNg^c0GULRk|9i9D=qMqb=-P0kg2X-= zVRl}?XK7+Cnh6y*1VWXKO2mO6WBd9#o)`?f`FkU|&+XNT3~1k-OwK@yMdpjwJC63D z(w{wj;Log=1_waQq?M%26Fi~;^|^K1(l&7iJ@_(S@LJYyt<%5n6)y?$>6S~o9)4N-0$lA zy_viyK>-&hxI$ah8_R{VL#|2mPd(=y)a=j+mPlc?zbrhwS0P?`lMfssP(5BK2?4Up6U@NY^Qx=EEkL~~)h1my1TP_kX(LZ_lP9pp zUp#Nk$!}6O!O6XesK`M|h#J}_Xztk_JBZ_7W})Dj*Lh!tJ)qJh%GL3fh(P;ZF4qsT zd8~u`V9F>!UPhpOI?7;Irlesi^Rw^J4z}b9prjpofj=B4e=f2@AFB`Wt=yW7-$ks$ z#Jyo+(zlTHWfqiCYfI=lA#Wk?!+9|kFHb(jg}^dpTCg^E$Jh03K?_{&yiOFHM*4_> zk@$)Oj_w^C$$(GPzvHp0K2&@3C7vQnhQF=vH(O&5J+!Og?VN

cI`fLG*@jiZr`t zs9Dcb2p{umj%P9ykAy77yMr}Z@S&3xJ~te- z!xl6x4j;wO+uCP}Vb8A55yeYx#oS#Lp~iH`PS%$+ED(^ku^5z2+#>-Y*HIEmt8aXe z=1ozd62KeVN05ux8YZlpr&)z>)*yt6{AF`I{MFsy#+QAx1~2QM>B~mi0kz_2*R#I6 zwy}Rh16=pZ@#VizuXbaC!_Qc$R)cpSL6-X}eR8GZ@qTOX_Q3J;#P_ld zMGo7ZY{cKeLw(Xn^h^_cydKgbB)4Xck_O+Z1IOzzRiz|%av|&vdQLY`yK_ZL5XaPp z8vPXf4MZtDMA66AXsB>3_HFOG)sK4Z1=C7MzwK(Ya#=Ihm!DZ~>LDYpUYVp~w7L$A zt=@P-+i_v_1IEM!l9030le3FVbLw0uqUWM4yhAg{YTCr*y-Y^Gu*Rhn1F`$o2FS*t zJzpFL-J?vWPoWaeP`nJOz>X+gkVSrSLhTu<*J?As4XSLlU2dw7ovBz%!&51YI70Za z|AKBY%jslE60s9#kT`(AJfkmd+Xtr-+;IaQ>3;%cH)w#1HL=W#u8>3Vp} zTYVi19P91sOnVB^APUWjWG^J*+nKu`$k;6;8%JyqUf)94;Td(Y}kJ2ZnjJ#?nUZl=v6uf5{F zSkwR*l$Eu)tXH(4sF3A>gA}m`6iSyb9R;nZ0&y&6HnRwro^eP4mYENGP9Is4mpGQ# zR?Bgp;(}YI!~@-Vam#4Dp;utHzigd4;U}v#AI7H22dM@cLkI_$QdPy7)ReF*-|<0h znFEm9e{uGQn^SE?IQklIm-BbOXGa!i7THCrb+>!}dvF9$;o0#^-SIuUCG_txvC0d5 z*qeQ?e_ouN$M*-ke6DYn^KVWTd-{ZtR;Z(o2kZ(w`|tRqa+C2e_}1BUUFmyzj>26Sy*dQog}2J)Ud%35l^2*{5l5Vh)1z)O zI{UWMzWiHh23A=sD6_}`?rdh@gEWP6^l>8&Hk_~vS9Dd5P-D4ZsB}tVPdw_S z%N02Ds}$5k-0kg@Byr~OItw=m4_s$s|MB2h{u7!wd7oVY5PCT&KW-u?NAdS$Mk`Zz za?HioTcz@4*OW(0Ov@95(P=@rdjHlp#JZD6VNV{n?~jis;AGkeYp8MRRT#0D&e(Dgg-u-!3O&K4Re)Q!n^{>CR@w45Z#JXf zJ7Le_*5SS)`L5)dS>J01#PULwx;IR#nF>hJL!MYx#g^^YOAxU^8LC%vIDdT6cr b^}XxYIUDy}HK_5ML8(wYI0gUl-zNVH&RGsu literal 42270 zcmd6w37lnjRp&3r8jw{2$aaZ_R7+QNbrwiE1nEv!x#KJ%mdz#@%aqLlQ~}W;4Hi9ep&X%kI>aD`^aOnj7!;X z2lz+8hj9LJ;1hv=72pHDCd(em`BQ<91Wo|I7I-;O&(8rL1iTr@BiVd7KLdO;=Pw58 zzSo8GHv%8X`MZJq%iha>dhSEOCjtL3oPQ4Z7|tK^xGZ}B@JT?mlLOxmoB%!^_!r^& z7l2oB{-E=HeEWfY&QAk1j^6=lexC$texC)t68K;mQ9G~Yzn22v0i^5f!Y5?e6~H|} zn$8A5&GS2e8t-=lF9N;;_;tYF0NxG!pTP5gKTao40p0~X0{jEu{{UVD^4<)5Jd?cz z_*1}j;Ggz=s208sKYyJ2`(7Z~*)jp!&P=X}%5zfWqS`;4xqu_%7fFfnN<= z&V60Z05y+GpPpsUfZh%RU&{IL0>|Iq0~a~}zrY)T3m{M9xf}RLz+VO40lfX|v+PyC zYc9;PR|9_oco*=*Gx!boNRTi1lfd)oXKuprc*{=Xa zkADNa75Jdtj*r`bqK~sc{r(D|o_h=MI^a8j!rR{g9|-(Mp!&@&&ayuNJOcO#;Aemu z?>_;1z=tqN(eqg#m$JVHvgFysr9QqRK&{I>Q1ap|P|trK@Na>)1Fr^t&t*RT-v_Gy zF94qnd;mz*bI$?30eB-2Qp^4Z_&nfaxk>Xn4ph4@1U?Gb0YYNgOMtrnoj|qo>%hkW zKMjP`vM&HN|B1_?G2j6BcHkYrCh*`D&bL1X{0!%(_GH~-dx0N6v`Ny;D zNBRBc6Iu5Czz5&pdg2Fx8uz15`g*Mj{q+LPTrVh{{n0PA0l{@kMCBX z&Tj+mWuEK62XlV+%?>{Vd;;gc4ty-|Q$R#^_J4pH@8ju2*C&9w?>Rs{e*!4_y#**b zTL{?nz^4P>4%Gd>3>2My7^rst7WlQm2i)TAJPr70&MyP%{sTa@GYkA> z;0-{v|Ku0={4N7Ni}U9Ib-e_x0bc`rGVlSXoo}8FR6mnI;rAf$@xVU=z8?6$ff~=Z zz0mRb7NDO02vG9lv%nnq4?ywp6B}8!8+Z%wJ;2ui9|nBRe3l^svxC6Bz%}5Nz`KCA z1OFb#5@&B*a6bPm@JXD%9434s@U6h70Pg~7-hTj8yMGQ8o<9S8Gw}WeI0pUzQ1?A; z(dFhufR_h&5U6#$5vX=rK+R_u&c6k?lk?XAUj@7iD0%q2CCBGs;6Qb-?!m z{}QNn-ni^~@om7TbAF%&t=x}(fFw#+ToxleJe;g>jyAvom@L{0V?YDqhufGQV9q^${ zTEG7@P`}@AfK3WMo&prT-7v&v1$Kd2m)8Q%0Dlm82k>#6><9il@Ot3C0QUf|hp1ly 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 diff --git a/resources/localization/de_DE/Slic3rPE_de.po b/resources/localization/de_DE/Slic3rPE_de.po index 96e9b7b76c..8665d2d3c0 100644 --- a/resources/localization/de_DE/Slic3rPE_de.po +++ b/resources/localization/de_DE/Slic3rPE_de.po @@ -1,56 +1,1622 @@ -# Nathan Hellweg , 2017. msgid "" msgstr "" -"Project-Id-Version: Slic3rPE\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-02-28 13:53+0100\n" -"PO-Revision-Date: 2018-02-28 14:16+0100\n" -"Last-Translator: Oleksandra Iushchenko \n" -"Language-Team: ok\n" +"Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 2.0.6\n" -"X-Poedit-Basepath: ..\n" -"X-Poedit-SourceCharset: UTF-8\n" -"X-Poedit-KeywordsList: L\n" -"X-Poedit-SearchPath-0: xs/src/libslic3r\n" -"X-Poedit-SearchPath-1: xs/xrc/slic3r/GUI\n" -"X-Poedit-SearchPath-2: xs/xrc/slic3r\n" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: Oleksandra Iushchenko \n" +"Language-Team: \n" -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:39 -msgid "Shape" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:46 -msgid "Rectangular" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:50 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1191 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:408 -msgid "Size" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:51 -msgid "Size in X and Y of the rectangular plate." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:57 -msgid "Origin" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:58 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 msgid "" -"Distance of the 0,0 G-code coordinate from the front left corner of the " -"rectangle." +"\n" +"\n" +"and it has the following unsaved changes:" msgstr "" +"\n" +"\n" +"und hat die folgenden ungesicherten Änderungen:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1491 +msgid "" +"\n" +"\n" +"Discard changes and continue anyway?" +msgstr "" +"\n" +"\n" +"Änderungen verwerfen und fortfahren?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1489 +msgid "" +"\n" +"\n" +"has the following unsaved changes:" +msgstr "" +"\n" +"\n" +"hat die folgenden ungesicherten Änderungen:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 +msgid "" +"\n" +"\n" +"is not compatible with printer\n" +msgstr "" +"\n" +"\n" +"ist mit dem Drucker nicht kompatibel\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:34 +msgid "" +"\n" +"During the other layers, fan " +msgstr "" +"\n" +"Während der übrigen Schichten, Ventilator " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:30 +#, c-format +msgid "" +"\n" +"If estimated layer time is greater, but still below ~%ds, fan will run at a proportionally decreasing speed between %d%% and %d%%." +msgstr "" +"\n" +"Falls die erwartete Schichtdruckzeit größer, aber noch unterhalb von ~%d Sekunden ist, wird der Lüfter mit einer sich proportional verringernden Geschwindigkeit zwischen %d%% und %d%% laufen." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:927 +msgid "" +"\n" +"Non-positive value." +msgstr "" +"\n" +"Nicht positiver Wert." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:928 +msgid "" +"\n" +"Not a numeric value." +msgstr "" +"\n" +"Kein numerischer Wert." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 +msgid " - Remember to check for updates at http://github.com/prusa3d/slic3r/releases" +msgstr " - Denken Sie an die Überprüfung von Updates auf http://github.com/prusa3d/slic3r/releases" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 +msgid " as:" +msgstr " als:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:226 +#, c-format +msgid " at filament speed %3.2f mm/s." +msgstr " mit einer Filamentgeschwindigkeit von %3.2f mm³/s." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1035 +msgid " Browse " +msgstr " Suchen " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 +msgid " file as:" +msgstr " Datei als:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:215 +msgid " flow rate is maximized " +msgstr " die Durchflussmenge ist am Maximum " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 +#, no-c-format +msgid "" +" infill pattern is not supposed to work at 100% density.\n" +"\n" +"Shall I switch to rectilinear fill pattern?" +msgstr "" +" Infillmuster ist nicht empfohlen für 100% Füllvolumen.\n" +"\n" +"Soll auf das rechtlineare Füllmuster umgestellt werden?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1470 +msgid " preset\n" +msgstr " Voreinstellung\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 +msgid " preset" +msgstr " Voreinstellung" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1583 +msgid " Preset" +msgstr " Voreinstellung" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:942 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1637 +msgid " Set " +msgstr " Setzen " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 +msgid " the selected preset?" +msgstr " die ausgewählte Voreinstellung?" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:548 +msgid " was successfully sliced." +msgstr " wurde erfolgreich gesliced." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:220 +msgid " with a volumetric rate " +msgstr " mit einer Volumenrate von " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:99 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:504 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:789 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:850 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1060 +msgid "%" +msgstr "%" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:224 +#, c-format +msgid "%3.2f mm³/s" +msgstr "%3.2f mm³/s" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1958 +#, perl-format +msgid "%d (%d shells)" +msgstr "%d (%d Konturhüllen)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1965 +#, perl-format +msgid "%d degenerate facets, %d edges fixed, %d facets removed, %d facets added, %d facets reversed, %d backwards edges" +msgstr "%d degenerierte Flächen, %d Kanten korrigiert, %d Flächen entfernt, %d Flächen hinzugefügt, %d Flächen umgekehrt, %d rückwärtige Kanten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:269 +#, c-format +msgid "%d lines: %.2lf mm" +msgstr "%d Linien: %.2lf mm" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:687 +#, perl-format +msgid "%d presets successfully imported." +msgstr "%d Voreinstellungen erfolgreich importiert." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 +msgid "&About Slic3r" +msgstr "&Über Slic3r" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 +msgid "&Configuration " +msgstr "&Konfiguration " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 +msgid "&Export Config Bundle…" +msgstr "Konfigurationssamlung &exportieren…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 +msgid "&Export Config…\tCtrl+E" +msgstr "&Exportiere Konfiguration…\tCtrl+E" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:418 +msgid "&File" +msgstr "&Datei" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:426 +msgid "&Help" +msgstr "&Hilfe" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 +msgid "&Load Config Bundle…" +msgstr "&Lade Konfigurationssammlung …" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 +msgid "&Load Config…\tCtrl+L" +msgstr "&Lade Konfiguration …\tCtrl+L" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:339 +msgid "&Localization" +msgstr "&Lokalisation" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:420 +msgid "&Object" +msgstr "&Objekt" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:419 +msgid "&Plater" +msgstr "&Platte" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 +msgid "&Quit" +msgstr "&Beenden" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 +msgid "&Repeat Last Quick Slice\tCtrl+Shift+U" +msgstr "letzten schnellen Slice wiede&rholen\tCtrl+Shift+U" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:422 +msgid "&View" +msgstr "&Anzeige" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:421 +msgid "&Window" +msgstr "&Fenster" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 +msgid "(&Re)Slice Now\tCtrl+S" +msgstr "(&Re)Slice jetzt\tCtrl+S" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:994 +msgid "(minimum)" +msgstr "(Minimum)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 +msgid ") not found." +msgstr ") nicht gefunden." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:215 +msgid "). Check hostname and OctoPrint version (at least 1.1.0 is required)." +msgstr "). Überprüfen Sie den Hostnamen und die OctoPrint Version (mindestens 1.1.0 ist erforderlich)." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 +msgid ". Discard changes and continue anyway?" +msgstr ". Änderungen verwerfen und fortfahren?" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:63 +msgid "1 Layer" +msgstr "1 Schicht" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:138 +msgid "2D" +msgstr "2D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:104 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2124 +msgid "3D" +msgstr "3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1608 +msgid "3MF file exported to " +msgstr "3MF Datei exportiert nach " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:185 +msgid "45° ccw" +msgstr "45° gUzs" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:186 +msgid "45° cw" +msgstr "45° mUzs" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:148 +msgid "A boolean expression using the configuration values of an active printer profile. If this expression evaluates to true, this profile is considered compatible with the active printer profile." +msgstr "Ein boolescher Ausdruck, der die Konfigurationswerte eines aktiven Druckerprofils verwendet. Wenn dieser Ausdruck als wahr bewertet wird, wird dieses Profil als kompatibel mit dem aktiven Druckerprofil angesehen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1099 +msgid "Above Z" +msgstr "Über Z" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:417 +msgid "Acceleration control (advanced)" +msgstr "Beschleunigungskontrolle (fortgeschritten)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1566 +msgid "Add a sheath (a single perimeter line) around the base support. This makes the support more reliable, but also more difficult to remove." +msgstr "Fügen Sie eine Sheath (eine einzelne Druckkontur) um die Basisschicht herum hinzu. Das macht das Stützmaterial zuverlässiger, aber auch schwieriger zu entfernen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:299 +#, no-c-format +msgid "Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r keeps adding perimeters, until more than 70% of the loop immediately above is supported." +msgstr "Fügen Sie bei Bedarf weitere Perimeter hinzu, um Spalten in schrägen Wänden zu vermeiden. Slic3r fügt immer wieder Perimeter hinzu, bis mehr als 70% der unmittelbar darüber liegenden Schleife unterstützt werden." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:240 +msgid "Add solid infill near sloping surfaces to guarantee the vertical shell thickness (top+bottom solid layers)." +msgstr "Fügen Sie stabiles Infill in der Nähe von schrägen Flächen hinzu, um die vertikale Schalenstärke zu gewährleisten (obere und untere massive Schichten)." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:177 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:195 +msgid "Add…" +msgstr "Import…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:342 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:356 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:449 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:452 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:831 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1113 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:107 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:208 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:736 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1733 +msgid "Advanced" +msgstr "Erweiterte Einstellungen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1138 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:766 +msgid "After layer change G-code" +msgstr "G-Code am Schichtende" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1636 +msgid "All" +msgstr "Alle" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 +msgid "Along X axis…" +msgstr "Entlang der X Achse…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 +msgid "Along Y axis…" +msgstr "Entlang der Y Achse…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 +msgid "Along Z axis…" +msgstr "Entlang der Z Achse…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1592 +msgid "AMF file exported to " +msgstr "AMF Datei exportiert nach " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 +msgid "Another export job is currently running." +msgstr "Ein anderer Exportjob läuft zur Zeit." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:901 +msgid "API Key" +msgstr "API Key" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 +msgid "Application preferences" +msgstr "Anwendungseinstellungen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 +msgid "Application will be restarted" +msgstr "Anwendung wird neu gestartet" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:397 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1242 +msgid "approximate seconds" +msgstr "ungefähre Sekunden" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 +msgid "Are you sure you want to " +msgstr "Wollen Sie wirklich " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 +msgid "Around X axis…" +msgstr "Entlang der X Achse…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 +msgid "Around Y axis…" +msgstr "Entlang der Y Achse…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 +msgid "Around Z axis…" +msgstr "Entlang der Z Achse…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:180 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:198 +msgid "Arrange" +msgstr "Anordnen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:224 +msgid "Array of language names and identifiers should have the same size." +msgstr "Felder mit Sprachnamen und Bezeichnern sollten die gleiche Größe haben." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 +msgid "Attention!" +msgstr "Achtung!" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:35 +msgid "Auto-center parts" +msgstr "Teile automatisch zentrieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1960 +#, perl-format +msgid "Auto-repaired (%d errors)" +msgstr "Auto-Reparatur (%d Fehler)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 +msgid "Automatically repair an STL file" +msgstr "Repariere automatisch die STL Datei" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:424 +msgid "Autospeed (advanced)" +msgstr "Automatische Geschindigkeit (fortgeschritten)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:26 +msgid "Avoid crossing perimeters" +msgstr "Kreuzen der Kontur vermeiden" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:43 +msgid "Background processing" +msgstr "Hintergrundberechnung" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:800 +msgid "Bed" +msgstr "Druckbett" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:940 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:34 +msgid "Bed shape" +msgstr "Druckbettkontur" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp:42 +msgid "Bed Shape" +msgstr "Druckbrettprofil" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:42 +msgid "Bed temperature" +msgstr "Druckbetttemperatur" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:39 +msgid "Bed temperature for layers after the first one. Set this to zero to disable bed temperature control commands in the output." +msgstr "Druckbett-Temperatur für Schichten nach der ersten Schicht. Setzen Sie diesen Wert auf Null, um die Befehle zur Steuerung der Betttemperatur im Output zu deaktivieren." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1132 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:48 +msgid "Before layer change G-code" +msgstr "G-Code vor dem Schichtwechsel" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1108 +msgid "Below Z" +msgstr "Unter Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:59 +msgid "Between objects G-code" +msgstr "G-Code zwischen Objekten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1150 +msgid "Between objects G-code (for sequential printing)" +msgstr "G-Code zwischen Objekten (Sequentielles Drucken)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:68 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 +msgid "Bottom" +msgstr "Unten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:72 +msgid "Bottom solid layers" +msgstr "Dichte Basisschichten" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 +msgid "Bottom View" +msgstr "Ansicht von Unten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:77 +msgid "Bridge" +msgstr "Überbrückung" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:106 +msgid "Bridge flow ratio" +msgstr "Brückenflussverhältnis" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:144 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:86 +msgid "Bridge infill" +msgstr "Überbrückungs-Infill" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:117 +msgid "Bridges" +msgstr "Überbrückungen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:97 +msgid "Bridges fan speed" +msgstr "Brückenventilatorgeschwindigkeit" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:86 +msgid "Bridging angle" +msgstr "Überbrückungswinkel" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:88 +msgid "Bridging angle override. If left to zero, the bridging angle will be calculated automatically. Otherwise the provided angle will be used for all bridges. Use 180° for zero angle." +msgstr "Überbrückungswinkel Übersteuerung. Wird der Wert auf Null gesetzt, wird der Überbrückungswinkel automatisch berechnet. Andernfalls wird der angegebene Winkel für alle Brücken verwendet. Verwenden Sie 180° für den Nullwinkel." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "Bridging volumetric" +msgstr "Überbrückungvolumen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:371 +msgid "Brim" +msgstr "Rand" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:127 +msgid "Brim width" +msgstr "Randbreite" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:218 +msgid "by the print profile maximum" +msgstr "mit dem Maximum des Druckerprofils" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:962 +msgid "Capabilities" +msgstr "Fähigkeiten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:325 +msgid "Change Application Language" +msgstr "Wechsel der Anwendungssprache" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 +msgid "Change the number of copies of the selected object" +msgstr "Ändere die Anzahl der Kopien der ausgewählten Objekte" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:298 +msgid "Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Wählen Sie eine Datei als Druckbettkontur aus (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:457 +msgid "Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Wählen Sie eine Datei zum Slicen (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\lib\Slic3r\GUI.pm:286 +msgid "Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Wählen Sie eine oder mehrere Dateien (STL/OBJ/AMF/3MF/PRUSA):" #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:62 msgid "Circular" -msgstr "" +msgstr "Kreisförmig" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:135 +msgid "Clip multi-part objects" +msgstr "Beschneiden von Objekten aus mehreren Teilen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:405 +msgid "Color" +msgstr "Farbe" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:690 +msgid "Combine infill every" +msgstr "Infill kombinieren alle" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:696 +msgid "Combine infill every n layers" +msgstr "Kombiniere das Infill all n Schichten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:509 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:869 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1668 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:143 +msgid "Compatible printers" +msgstr "Kompatible Drucker" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:147 +msgid "Compatible printers condition" +msgstr "Kompatible Druckerbedingung" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:154 +msgid "Complete individual objects" +msgstr "Kompatible Einzelobjekte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:884 +msgid "Configuration notes" +msgstr "Konfigurationsnotizen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1020 +msgid "Connection failed." +msgstr "Verbindung ist fehlgeschlagen." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:211 +msgid "Connection to OctoPrint works correctly." +msgstr "Verbindung zu Octoprint funktioniert einwandfrei." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 +msgid "Connection to printer works correctly." +msgstr "Verbindung zum Drucker funktioniert einwandfrei." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1416 +msgid "Contact Z distance" +msgstr "Kontakt Z-Abstand" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:120 +msgid "Controller" +msgstr "Controller" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:805 +msgid "Cooling" +msgstr "Kühlung" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:826 +msgid "Cooling thresholds" +msgstr "Kühlungsschwellwerte" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:221 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 +msgid "Copies" +msgstr "Kopien" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:476 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:450 +msgid "Cost" +msgstr "Preis" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1465 +msgid "Cover the top contact layer of the supports with loops. Disabled by default." +msgstr "Decken Sie die obere Kontaktschicht der Stützen mit Schleifen ab. Standardmäßig deaktiviert." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:71 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:150 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:92 +msgid "Custom" +msgstr "Benutzerdefiniert" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:846 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119 +msgid "Custom G-code" +msgstr "Benutzerdefinierter G-Code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:189 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:205 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 +msgid "Cut…" +msgstr "Schnitt…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 +msgid "Decrease copies" +msgstr "Verringere Anzahl" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:300 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:170 +msgid "Default" +msgstr "Standard" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp:42 +msgid "default" +msgstr "Standard" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 +msgid "Default " +msgstr "Standard " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:489 +msgid "Default base angle for infill orientation. Cross-hatching will be applied to this. Bridges will be infilled using the best direction Slic3r can detect, so this setting does not affect them." +msgstr "Standard-Grundwinkel für die Ausrichtung der Füllung. Hierfür werden Kreuzschraffuren verwendet. Brücken werden mit der besten Richtung gefüllt, die Slic3r erkennen kann, so dass diese Einstellung sie nicht beeinflusst." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:376 +msgid "Default extrusion width" +msgstr "Standardextrusionsbreite" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:178 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:196 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 +msgid "Delete" +msgstr "Löschen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 +msgid "delete" +msgstr "löschen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:179 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:197 +msgid "Delete All" +msgstr "Alle löschen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:51 +msgid "Delete this preset" +msgstr "Lösche diese Voreinstellung" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:440 +msgid "Density" +msgstr "Dichte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:503 +#, no-c-format +msgid "Density of internal infill, expressed in the range 0% - 100%." +msgstr "Infilldichte. Als Prozentwert von 0% - 100% ausgedrückt." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:507 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:867 +msgid "Dependencies" +msgstr "Abhängigkeiten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1724 +msgid "Depth of a wipe color per color change. For N colors, there will be maximum (N-1) tool switches performed, therefore the total depth of the wipe tower will be (N-1) times this value." +msgstr "Tiefe einer Reinigungsfarbe pro Farbänderung. Für N Farben werden maximal (N-1) Werkzeugwechsel durchgeführt, daher ist die Gesamttiefe des Reinigungsturms (N-1) mal diesem Wert." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1142 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1143 +msgid "Deretraction Speed" +msgstr "Wiedereinzugsgeschwindigkeit" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:940 +msgid "Detect bridging perimeters" +msgstr "Umfangbrücken entdecken" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1584 +msgid "Detect single-width walls (parts where two extrusions don't fit and we need to collapse them into a single trace)." +msgstr "Erkennen von Wänden mit einfacher Breite (Teile, bei denen zwei Extrusionen nicht passen und wir sie in eine einzige Druckspur zusammenfassen müssen)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1582 +msgid "Detect thin walls" +msgstr "Dünne Wände erkennen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 +msgid "Device Browser" +msgstr "Geräte Browser" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:66 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:431 +msgid "Diameter" +msgstr "Durchmesser" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:67 +msgid "Diameter of the print bed. It is assumed that origin (0,0) is located in the center." +msgstr "Durchmesser des Druckbettes. Es wird angenommen, dass der Ursprung (0,0) sich im Mittelpunkt befindet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1169 +msgid "Direction" +msgstr "Richtung" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:53 +msgid "Disable communication with the printer over a serial / USB cable. This simplifies the user interface in case the printer is never attached to the computer." +msgstr "Deaktivieren Sie die Kommunikation mit dem Drucker über ein serielles / USB-Kabel. Dies ist eine Vereinfachung der Benutzeroberfläche für den Fall, dass der Drucker nicht an den Computer angeschlossen ist." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:180 +msgid "Disable fan for the first" +msgstr "Ventilator für die Ersten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:51 +msgid "Disable USB/serial connection" +msgstr "USB/Serielle Verbindung ausschalten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:916 +msgid "Disables retraction when the travel path does not exceed the upper layer's perimeters (and thus any ooze will be probably invisible)." +msgstr "Deaktiviert den Einzug, wenn der Verfahrweg die Perimeter der oberen Schicht nicht überschreitet (und somit ist der Auslauf wahrscheinlich unsichtbar)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:198 +msgid "Distance between copies" +msgstr "Abstand zwischen Kopien" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1213 +msgid "Distance between skirt and object(s). Set this to zero to attach the skirt to the object(s) and get a brim for better adhesion." +msgstr "Distanz zwischen Schürze und Objekt. Auf Null stellen um die Schürze an das Objekt zu verbinden und einen Rand für bessere Haftung zu generieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1212 +msgid "Distance from object" +msgstr "Abstand vom Objekt" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:58 +msgid "Distance of the 0,0 G-code coordinate from the front left corner of the rectangle." +msgstr "Abstand der 0,0 G-Code-Koordinate von der linken vorderen Ecke des Rechtecks." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:199 +msgid "Distance used for the auto-arrange feature of the plater." +msgstr "Abstand für die automatische Plattenbelegung." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:190 +msgid "Don't support bridges" +msgstr "Brücken nicht unterstützen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:132 +msgid "Drag your objects here" +msgstr "Ziehen Sie Ihr Objekte hier hin" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:207 +msgid "Elephant foot compensation" +msgstr "Elefantenfuss Kompensation" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:806 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:922 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1695 +msgid "Enable" +msgstr "Aktivieren" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:163 +msgid "Enable auto cooling" +msgstr "Automatische Kühlung aktivieren" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:394 +msgid "Enable fan if layer print time is below" +msgstr "Ventilator anschalten wenn die Schichtdruckzeit geringer ist als" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1381 +msgid "Enable support material generation." +msgstr "Aktiviert Generierung von Stützstrukturen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:645 +msgid "Enable this to get a commented G-code file, with each line explained by a descriptive text. If you print from SD card, the additional weight of the file could make your firmware slow down." +msgstr "Aktivieren Sie diese Option, um eine kommentierte G-Code-Datei zu erhalten, wobei jede Zeile durch einen beschreibenden Text erklärt wird. Wenn Sie von einer SD-Karte drucken, kann die zusätzliche Dateigröße dazu führen, dass Ihre Firmware langsamer wird." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1681 +msgid "Enable variable layer height feature" +msgstr "Variable Schichthöhen aktivieren" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:853 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1126 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:217 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:227 +msgid "End G-code" +msgstr "G-Code am Ende" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1431 +msgid "Enforce support for the first" +msgstr "Erzwinge Stützstrukturen bei den ersten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1439 +msgid "Enforce support for the first n layers" +msgstr "Erzwinge Stützmaterial bei den ersten n Schichten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:238 +msgid "Ensure vertical shell thickness" +msgstr "Stelle die vertikale Hüllenstärke sicher" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +msgid "Enter the new max size for the selected object:" +msgstr "Geben Sie die neue maximale Größe für das ausgewählte Objekt ein:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1030 +#, perl-format +msgid "Enter the new size for the selected object (print bed: %smm):" +msgstr "Geben Sie die neue Größe für das ausgewählte Objekt (Druckbett: %s mm)ein:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 +msgid "Enter the number of copies of the selected object:" +msgstr "Geben Sie die Anzahl der Kopien der ausgewählten Objekte ein:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Enter the rotation angle:" +msgstr "Geben Sie den Rotationswinkel ein:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +#, no-perl-format +msgid "Enter the scale % for the selected object:" +msgstr "Geben Sie den Skalierungsfaktor in % für das ausgewählte Objekt ein:" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:477 +msgid "Enter your filament cost per kg here. This is only for statistical information." +msgstr "Geben Sie hier Ihre Filamentkosten pro kg ein. Dies dient ausschließlich statistischen Zwecken." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:441 +msgid "Enter your filament density here. This is only for statistical information. A decent way is to weigh a known length of filament and compute the ratio of the length to volume. Better is to calculate the volume directly through displacement." +msgstr "Geben Sie hier Ihre Filamentdichte ein. Dies dient ausschließlich statistischen Zwecken. Ein vernünftiger Weg ist es, eine bekannte Filamentlänge zu wiegen und das Verhältnis von Länge zu Volumen zu berechnen. Besser ist es, das Volumen direkt durch Verdrängung zu berechnen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:432 +msgid "Enter your filament diameter here. Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average." +msgstr "Geben Sie hier Ihren Filamentdurchmesser ein. Eine hohe Genauigkeit ist erforderlich, also verwenden Sie einen Messschieber und führen Sie mehrere Messungen entlang des Filaments durch, um dann den Mittelwert zu berechnen." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:488 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:470 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 +msgid "Error" +msgstr "Fehler" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1612 +msgid "Error exporting 3MF file " +msgstr "Fehler beim Exportieren der 3MF Datei " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1596 +msgid "Error exporting AMF file " +msgstr "Fehler beim Exportieren der AMF Datei " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1526 +msgid "Error while uploading to the OctoPrint server: " +msgstr "Fehler beim Hochladen auf den OctoPrint Server: " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:315 +msgid "Error! " +msgstr "Fehler! " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:451 +msgid "Estimated printing time" +msgstr "Erwartete Druckzeit" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:44 +#, c-format +msgid "except for the first %d layers" +msgstr "außer für die ersten %d Schichten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:48 +msgid "except for the first layer" +msgstr "außer für die erste Schicht" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:192 +msgid "Experimental option for preventing support material from being generated under bridged areas." +msgstr "Experimentelle Option zur Verhinderung der Bildung von Trägermaterial unter Überbrückungsflächen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:942 +msgid "Experimental option to adjust flow for overhangs (bridge flow will be used), to apply bridge speed to them and enable fan." +msgstr "Experimentelle Option zur Anpassung des Durchflusses für Überhänge (Brückenvolumenfluss wird verwendet), zur Anwendung der Brückengeschwindigkeit und zur Aktivierung des Lüfters." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 +msgid "Export all presets to file" +msgstr "Exportiere alle Voreinstellungen in eine Datei" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 +msgid "Export current configuration to file" +msgstr "Exportiere die aktuelle Konfiguration in eine Datei" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 +msgid "Export current plate as 3MF" +msgstr "Exportiere die aktuelle Plattenbelegung als 3MF" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 +msgid "Export current plate as AMF" +msgstr "Exportiere die aktuelle Plattenbelegung als AMF" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 +msgid "Export current plate as G-code" +msgstr "Exportiere die aktuelle Plattenbelegung als G-Code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 +msgid "Export current plate as STL" +msgstr "Exportiere die aktuelle Plattenbelegung als STL" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1454 +msgid "Export failed" +msgstr "Export ist fehlgeschlagen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 +msgid "Export G-code..." +msgstr "Export G-Code..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:236 +msgid "Export G-code…" +msgstr "Export G-Code…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 +msgid "Export object as STL…" +msgstr "Exportiere das Objekt als STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 +msgid "Export plate as 3MF..." +msgstr "Exportiere die Plattenbelegung als 3MF..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 +msgid "Export plate as AMF..." +msgstr "Exportiere die Plattenbelegung als AMF..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 +msgid "Export plate as STL..." +msgstr "Exportiere die Plattenbelegung als STL..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:240 +msgid "Export STL…" +msgstr "Exportiere STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 +msgid "Export this single object as STL file" +msgstr "Exportiere dieses einzelne Objekt als STL Datei" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:139 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:81 +msgid "External perimeter" +msgstr "Außenschicht" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:267 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:277 +msgid "External perimeters" +msgstr "Außenschichten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:151 +msgid "external perimeters" +msgstr "Außenschichten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:289 +msgid "External perimeters first" +msgstr "Außenkonturen zuerst drucken" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1118 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1126 +msgid "Extra length on restart" +msgstr "Extra Länge bei Neustart" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:297 +msgid "Extra perimeters if needed" +msgstr "Extra Konturen wenn notwendig" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:795 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1234 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:307 +msgid "Extruder" +msgstr "Extruder" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1187 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:400 +#, c-format +msgid "Extruder %d" +msgstr "Extruder %d" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:479 +msgid "Extruder clearance (mm)" +msgstr "Extruder Abstand (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:342 +msgid "Extruder Color" +msgstr "Extruder Farbe" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:350 +msgid "Extruder offset" +msgstr "Extruder Offset" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:626 +msgid "Extruder temperature for first layer. If you want to control temperature manually during print, set this to zero to disable temperature control commands in the output file." +msgstr "Extrudertemperatur für die erste Schicht. Wenn Sie die Temperatur während des Druckvorgangs manuell regeln möchten, setzen Sie diesen Wert auf Null, um die Temperatursteuerbefehle in der Ausgabedatei zu deaktivieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1573 +msgid "Extruder temperature for layers after the first one. Set this to zero to disable temperature control commands in the output." +msgstr "Extrudertemperatur für Schichten nach der ersten Schicht. Setzen Sie diesen Wert auf Null, um die Temperaturregelbefehle im Ausgabedatei zu deaktivieren." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:431 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:966 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:308 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:702 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:958 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1272 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1445 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1471 +msgid "Extruders" +msgstr "Extruder" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:360 +msgid "Extrusion axis" +msgstr "Extrusionsachse" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:367 +msgid "Extrusion multiplier" +msgstr "Extrusionsfaktor" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:268 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:377 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:592 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:710 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:967 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1292 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1454 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1614 +msgid "Extrusion Width" +msgstr "Extrusionsbreite" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:453 +msgid "Extrusion width" +msgstr "Extrusionbreite" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:410 +msgid "Facets" +msgstr "Flächen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:36 +msgid "Fan " +msgstr "Ventilator " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:817 +msgid "Fan settings" +msgstr "Ventilator Einstellungen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:818 +msgid "Fan speed" +msgstr "Ventilatorgeschwindigkeit" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:330 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:68 +msgid "Feature type" +msgstr "Merkmalstyp" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:78 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:79 +msgid "Feature types" +msgstr "Merkmalstypen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:183 +msgid "Fewer" +msgstr "Weniger" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:786 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:787 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:368 +msgid "Filament" +msgstr "Filament" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:412 +msgid "Filament notes" +msgstr "Filament Bemerkungen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:832 +msgid "Filament properties" +msgstr "Filament Eigenschaften" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:202 +msgid "Filament Settings" +msgstr "Filamenteinstellungen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:450 +msgid "Filament type" +msgstr "Filament Typ" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1445 +msgid "File added to print queue" +msgstr "Datei zur Druckwarteschlange hinzugefügt" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:475 +msgid "File Not Found" +msgstr "Datei nicht gefunden" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:487 +msgid "Fill angle" +msgstr "Füllwinkel" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:501 +msgid "Fill density" +msgstr "Fülldichte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:539 +msgid "Fill pattern" +msgstr "Füllmuster" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:541 +msgid "Fill pattern for general low-density infill." +msgstr "Füllmuster für allgemeines Infill mit niedriger Dichte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:248 +msgid "Fill pattern for top/bottom infill. This only affects the external visible layer, and not its adjacent solid shells." +msgstr "Füllmuster für die obere und untere Füllung. Dies wirkt sich nur auf die äußere sichtbare Schicht aus, nicht aber auf die angrenzenden soliden Konturen." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1110 +msgid "Firmware" +msgstr "Firmware" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1314 +msgid "Firmware Retraction" +msgstr "Firmware Einzug" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:573 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:582 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:591 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:625 +msgid "First layer" +msgstr "Erste Schicht" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:603 +msgid "First layer height" +msgstr "Höhe der ersten Schicht" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:615 +msgid "First layer speed" +msgstr "Druckgeschwindigkeit der ersten Schicht" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "First layer volumetric" +msgstr "Volumenparameter der ersten Schicht" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:466 +msgid "Flow" +msgstr "Fluss" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:599 +msgid "" +"For the Wipe Tower to work with the soluble supports, the support layers\n" +"need to be synchronized with the object layers.\n" +"\n" +"Shall I synchronize support layers in order to enable the Wipe Tower?" +msgstr "Damit der Reinigungsturm mit den löslichen Trägermaterialien arbeiten kann, müssen die Stützschichten mit den Objektschichten synchronisiert werden. Soll ich Unterstützungsschichten synchronisieren, um den Reinigungsturm zu aktivieren?" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1264 +msgid "Force solid infill for regions having a smaller area than the specified threshold." +msgstr "Feste Füllung für Bereiche, die eine kleinere Fläche als die angegebene Schwelle aufweisen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:758 +msgid "Force the generation of solid shells between adjacent materials/volumes. Useful for multi-extruder prints with translucent materials or manual soluble support material." +msgstr "Erzwingt die Erzeugung von festen Schalen zwischen benachbarten Materialien/Volumina. Geeignet für Multiextruderdrucke mit transluzenten Materialien oder manuell löslichen Trägermaterialien." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 +msgid "Front" +msgstr "Front" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 +msgid "Front View" +msgstr "Frontalansicht" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +msgid "G-code" +msgstr "G-Code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1451 +msgid "G-code file exported to " +msgstr "G-Code Datei exportiert nach " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1524 +msgid "G-code file successfully uploaded to the OctoPrint server" +msgstr "G-Code Datei erfolgreich zum OctoPrint Server hochgeladen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:652 +msgid "G-code flavor" +msgstr "G-Code Typ" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:444 +msgid "g/cm³" +msgstr "g/cm³" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:634 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:145 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:87 +msgid "Gap fill" +msgstr "Lückenfüllung" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:937 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:11 +msgid "General" +msgstr "Allgemein" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:875 +msgid "Generate no less than the number of skirt loops required to consume the specified amount of filament on the bottom layer. For multi-extruder machines, this minimum applies to each extruder." +msgstr "Erzeugt nicht weniger als die Anzahl der Schürzenschleifen, die benötigt wird, um die angegebene Menge an Filament auf der unteren Schicht zu verbrauchen. Bei Multiextruder-Maschinen gilt dieses Minimum für jeden Extruder." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1379 +msgid "Generate support material" +msgstr "Generiere Stützstrukturen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1433 +msgid "Generate support material for the specified number of layers counting from bottom, regardless of whether normal support material is enabled or not and regardless of any angle threshold. This is useful for getting more adhesion of objects having a very thin or poor footprint on the build plate." +msgstr "Generiere Stützmaterial für die angegebene Anzahl von Schichten, die von unten gezählt werden, unabhängig davon, ob normales Stützmaterial aktiviert ist oder nicht und unabhängig von einer Winkelschwelle. Dies ist nützlich, um die Haftung von Objekten mit einem sehr dünnen oder schlechten Standfuß auf der Bauplatte zu erhöhen." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:498 +msgid "GLUquadricObjPtr | Attempt to free unreferenced scalar" +msgstr "GLUquadricObjPtr | Versuch, unreferenzierte Skalare freizugeben" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:583 +msgid "Heated build plate temperature for the first layer. Set this to zero to disable bed temperature control commands in the output." +msgstr "Druckbetttemperatur für die erste Schicht. Setzen Sie diesen Wert auf Null, um die Befehle zur Steuerung der Betttemperatur im Ausgang zu deaktivieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:320 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:69 +msgid "Height" +msgstr "Höhe" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:332 +msgid "Height (mm)" +msgstr "Höhe (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1222 +msgid "Height of skirt expressed in layers. Set this to a tall value to use skirt as a shield against drafts." +msgstr "Höhe der Schürze in Schichten. Eine hohe Schürze kann gegen Zugluft schützen." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:329 +msgid "Horizontal shells" +msgstr "Horizontale Konturhüllen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:128 +msgid "Horizontal width of the brim that will be printed around each object on the first layer." +msgstr "Horizontalbreite des Randes, der um jedes Objekt auf der Bodenschicht gedruckt wird." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:908 +msgid "Host or IP" +msgstr "Host oder IP" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:214 +msgid "I wasn't able to connect to OctoPrint (" +msgstr "Ich konnte keine Verbindung zu OctoPrint herstellen(" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:26 +#, c-format +msgid "If estimated layer time is below ~%ds, fan will run at %d%% and print speed will be reduced so that no less than %ds are spent on that layer (however, speed will never be reduced below %dmm/s)." +msgstr "Wenn die geschätzte Schichtzeit unter ~%ds liegt, läuft der Lüfter mit %d%% und die Druckgeschwindigkeit wird reduziert, so dass nicht weniger als %ds für diese Schicht verwendet werden (die Geschwindigkeit wird jedoch nie unter %dmm/s reduziert)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:616 +msgid "If expressed as absolute value in mm/s, this speed will be applied to all the print moves of the first layer, regardless of their type. If expressed as a percentage (for example: 40%) it will scale the default speeds." +msgstr "Wird diese Geschwindigkeit als Absolutwert in mm/s angegeben, so wird sie auf alle Druckbewegungen der ersten Lage angewendet, unabhängig von ihrem Typ. In Prozent ausgedrückt (z.B. 40%) skaliert es die voreingestellten Geschwindigkeiten." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:395 +msgid "If layer print time is estimated below this number of seconds, fan will be enabled and its speed will be calculated by interpolating the minimum and maximum speeds." +msgstr "Wenn die Druckzeit der Ebenen unter dieser Anzahl von Sekunden liegt, wird der Lüfter aktiviert und seine Geschwindigkeit durch Interpolation der minimalen und maximalen Geschwindigkeiten berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1240 +msgid "If layer print time is estimated below this number of seconds, print moves speed will be scaled down to extend duration to this value." +msgstr "Wenn die Druckzeit der Ebene unter dieser Anzahl von Sekunden liegt, wird die Geschwindigkeit des Druckvorgangs verringert, um die Zeitdauer auf diesen Wert zu verlängern." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:388 +msgid "If this is enabled, fan will never be disabled and will be kept running at least at its minimum speed. Useful for PLA, harmful for ABS." +msgstr "Wenn diese Option aktiviert ist, wird der Lüfter niemals deaktiviert und läuft mindestens mit seiner Minimaldrehzahl weiter. Sinnvoll für PLA, ungeignet für ABS." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:37 +msgid "If this is enabled, Slic3r will auto-center objects around the print bed center." +msgstr "Wenn diese Option aktiviert ist, zentriert Slic3r Objekte automatisch um die Mitte des Druckbettes." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:45 +msgid "If this is enabled, Slic3r will pre-process objects as soon as they're loaded in order to save time when exporting G-code." +msgstr "Wenn diese Option aktiviert ist, wird Slic3r Objekte vorverarbeiten, sobald sie geladen werden, um Zeit beim Export von G-Code zu sparen." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:29 +msgid "If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files." +msgstr "Wenn diese Option aktiviert ist, öffnet Slic3r das letzte Ausgabeverzeichnis anstelle des Verzeichnisses, in dem sich die Eingabedateien befinden." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:77 +msgid "If you have rendering issues caused by a buggy OpenGL 2.0 driver, you may try to check this checkbox. This will disable the layer height editing and anti aliasing, so it is likely better to upgrade your graphics driver." +msgstr "Wenn Sie Rendering-Probleme haben, die durch einen fehlerhaften OpenGL 2.0-Treiber verursacht wurden, können Sie versuchen, dieses Kontrollkästchen zu aktivieren. Dies deaktiviert die Bearbeitung der Ebenenhöhe und das Anti-Aliasing, so dass es wahrscheinlich sinnvoller ist, den Grafiktreiber zu aktualisieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1091 +msgid "If you set this to a positive value, Z is quickly raised every time a retraction is triggered. When using multiple extruders, only the setting for the first extruder will be considered." +msgstr "Wenn Sie diesen Wert auf einen positiven Wert setzen, wird Z bei jedem Auslösen eines Einzugs schnell angehoben. Bei Verwendung mehrerer Extruder wird nur die Einstellung für den ersten Extruder berücksichtigt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1101 +msgid "If you set this to a positive value, Z lift will only take place above the specified absolute Z. You can tune this setting for skipping lift on the first layers." +msgstr "Wenn Sie diesen Wert auf einen positiven Wert setzen, erfolgt der Z-Hub nur oberhalb des angegebenen absoluten Z-Wertes. Sie können diese Einstellung für das Auslassen von Z-Hüben auf den ersten Ebenen einstellen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1110 +msgid "If you set this to a positive value, Z lift will only take place below the specified absolute Z. You can tune this setting for limiting lift to the first layers." +msgstr "Wenn Sie diesen Wert auf einen positiven Wert setzen, erfolgt der Z-Hub nur unterhalb des angegebenen absoluten Z-Wertes. Sie können diese Einstellung so einstellen, dass der Z-Hub auf die ersten Lagen begrenzt wird." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:451 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1002 +msgid "If you want to process the output G-code through custom scripts, just list their absolute paths here. Separate multiple scripts with a semicolon. Scripts will be passed the absolute path to the G-code file as the first argument, and they can access the Slic3r config settings by reading environment variables." +msgstr "Wenn Sie den Ausgabe-G-Code durch eigene Skripte verarbeiten wollen, geben Sie hier einfach die absoluten Pfade an. Trennen Sie mehrere Skripte durch ein Semikolon. Skripten werden als erstes Argument die absoluten Pfad zur G-Code-Datei übergeben, und sie können auf die Slic3r-Konfigurationseinstellungen zugreifen, indem sie Umgebungsvariablen lesen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:351 +msgid "If your firmware doesn't handle the extruder displacement you need the G-code to take it into account. This option lets you specify the displacement of each extruder with respect to the first one. It expects positive coordinates (they will be subtracted from the XY coordinate)." +msgstr "Wenn Ihre Firmware die Verschiebung des Extruders nicht beherrscht, benötigen Sie den G-Code, um sie zu berücksichtigen. Mit dieser Option können Sie die Verschiebung jedes Extruders in Bezug auf den ersten Extruder festlegen. Es erwartet positive Koordinaten (sie werden von der XY-Koordinate subtrahiert)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1664 +msgid "If your firmware requires relative E values, check this, otherwise leave it unchecked. Most firmwares use absolute values." +msgstr "Wenn Ihre Firmware relative E-Werte benötigt, diese Option aktivieren, ansonsten lassen Sie sie unmarkiert. Die meisten Firmwares verwenden absolute Werte." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 +msgid "Increase copies" +msgstr "Erhöhe Anzahl" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:346 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:347 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:664 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:87 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:247 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:488 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:502 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:540 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:681 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:691 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:709 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:727 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:746 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1263 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1280 +msgid "Infill" +msgstr "Infill" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:169 +msgid "infill" +msgstr "Infill" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:720 +msgid "Infill before perimeters" +msgstr "Infill vor Kontur" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:701 +msgid "Infill extruder" +msgstr "Infill Extruder" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:735 +msgid "Infill/perimeters overlap" +msgstr "Infill/Kontur Überlappung" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:398 +msgid "Info" +msgstr "Info" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1479 +msgid "Interface layers" +msgstr "Schnittstellen Schichten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1463 +msgid "Interface loops" +msgstr "Kontaktschleifen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1488 +msgid "Interface pattern spacing" +msgstr "Schnittstellenmuster Abstand" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:757 +msgid "Interface shells" +msgstr "Schnittstellenshells" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:141 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:83 +msgid "Internal infill" +msgstr "Internes Infill" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Invalid rotation angle entered" +msgstr "Ungültiger Rotationswinkel wurde eingegeben" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +msgid "Invalid scaling value entered" +msgstr "Ungültiger Skalierungsfaktor wurde eingegeben" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 +msgid "Iso" +msgstr "Iso" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 +msgid "Iso View" +msgstr "Iso Ansicht" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1180 +msgid "Jitter" +msgstr "Jitter" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:387 +msgid "Keep fan always on" +msgstr "Ventilator ständig laufen lassen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 +msgid "Language" +msgstr "Spache" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:192 +msgid "Layer Editing" +msgstr "Schichthöhen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:207 +msgid "Layer editing" +msgstr "Schichthöhen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:314 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:777 +msgid "Layer height" +msgstr "Schichthöhe" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1194 +msgid "Layer height limits" +msgstr "Schichthöhen Grenzen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:183 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:694 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1033 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1224 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1285 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1437 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1482 +msgid "layers" +msgstr "Schichten" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:157 +msgid "Layers" +msgstr "Schichten" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:69 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:239 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:290 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:298 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:604 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:762 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:778 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:941 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:989 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1152 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1583 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1639 +msgid "Layers and Perimeters" +msgstr "Schichten und Konturen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:313 +msgid "Layers and perimeters" +msgstr "Schichten und Umfänge" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 +msgid "Left" +msgstr "Links" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 +msgid "Left View" +msgstr "Anicht von Links" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1071 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1080 +msgid "Length" +msgstr "Länge" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1090 +msgid "Lift Z" +msgstr "Z Hebung" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 +msgid "Load exported configuration file" +msgstr "Laden einer exportierten Konfigurationsdatei" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 +msgid "Load presets from a bundle" +msgstr "Lade Voreinstellungen aus einer Sammlung" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:75 +msgid "Load shape from STL..." +msgstr "Lade Umriß von STL..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:692 +msgid "Loaded " +msgstr "Geladen " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 +msgid "Loading…" +msgstr "Laden…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1229 +msgid "Loops (minimum)" +msgstr "Schleifen (minimal)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:412 +msgid "Manifold" +msgstr "Hülle ok" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:411 +msgid "Materials" +msgstr "Material" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:787 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:796 +msgid "Max" +msgstr "Max" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:807 +msgid "Max print speed" +msgstr "Maximale Druckgeschwindigkeit" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:837 +msgid "Max volumetric slope negative" +msgstr "Max. volumetrische Steigung negativ" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:826 +msgid "Max volumetric slope positive" +msgstr "Max. volumetrische Steigung positiv" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:421 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:817 +msgid "Max volumetric speed" +msgstr "Maximale Volumengeschwindigkeit" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:422 +msgid "Maximum volumetric speed allowed for this filament. Limits the maximum volumetric speed of a print to the minimum of print and filament volumetric speed. Set to zero for no limit." +msgstr "Maximale volumetrische Geschwindigkeit, die für dieses Filament zulässig ist. Begrenzt die maximale volumetrische Geschwindigkeit eines Drucks auf das Minimum von Druck- und Filament-Volumengeschwindigkeit. Wird auf Null gesetzt, wenn es keine Begrenzung gibt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:848 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:857 +msgid "Min" +msgstr "Min" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:866 +msgid "Min print speed" +msgstr "Minimale Druckgeschwindigkeit" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1040 +msgid "Minimum detail resolution, used to simplify the input file for speeding up the slicing job and reducing memory usage. High-resolution models often carry more detail than printers can render. Set to zero to disable any simplification and use full resolution from input." +msgstr "Minimale Detailauflösung, die verwendet wird, um die Eingabedatei zu vereinfachen, um den Slicingjob zu beschleunigen und den Speicherverbrauch zu reduzieren. Hochauflösende Modelle weisen oft mehr Details auf, als der Drucker wiedergeben kann. Setzen Sie den Wert auf Null, um die Vereinfachung zu deaktivieren und die volle Auflösung des Eingangsdatei zu verwenden." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:874 +msgid "Minimum extrusion length" +msgstr "Minimale Extrusionslänge" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1050 +msgid "Minimum travel after retraction" +msgstr "Minimalbewegung nach Einziehen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 +msgid "Mirror" +msgstr "Spiegeln" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 +msgid "Mirror the selected object" +msgstr "Ausgewähltes Objekt spiegeln" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 +msgid "Mirror the selected object along the X axis" +msgstr "Ausgewähltes Objekt entlang der X-Achse spiegeln" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 +msgid "Mirror the selected object along the Y axis" +msgstr "Ausgewähltes Objekt entlang der Y-Achse spiegeln" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 +msgid "Mirror the selected object along the Z axis" +msgstr "Ausgewähltes Objekt entlang der Z-Achse spiegeln" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:151 +msgid "Mixed" +msgstr "Gemischt" #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:65 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:129 @@ -83,187 +1649,1141 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1737 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1747 msgid "mm" -msgstr "" +msgstr "mm" -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:66 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:431 -msgid "Diameter" -msgstr "Durchmesser" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1075 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1085 +msgid "mm (zero to disable)" +msgstr "mm (Null eingeben zum deaktivieren)" -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:67 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:609 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:740 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1390 +msgid "mm or %" +msgstr "mm oder %" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:382 +msgid "mm or % (leave 0 for auto)" +msgstr "mm oder % (für automatischen Wert auf Null belassen)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:272 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:597 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:715 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:972 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1296 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1458 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1619 +msgid "mm or % (leave 0 for default)" +msgstr "mm oder % (für Standardwert auf Null belassen)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:120 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:638 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:749 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:811 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:868 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:981 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1137 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1146 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1536 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1649 +msgid "mm/s" +msgstr "mm/s" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:282 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:619 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1255 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1306 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1501 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1631 +msgid "mm/s or %" +msgstr "mm/s oder %" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:80 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:174 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:576 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:684 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:952 +msgid "mm/s²" +msgstr "mm/s²" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1265 +msgid "mm²" +msgstr "mm²" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:425 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:820 +msgid "mm³/s" +msgstr "mm³/s" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:831 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:842 +msgid "mm³/s²" +msgstr "mm³/s²" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:414 +msgid "Modifiers" +msgstr "Veränderer" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:478 +msgid "money/kg" +msgstr "Kosten/kg" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:182 +msgid "More" +msgstr "Mehr" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1696 +msgid "Multi material printers may need to prime or purge extruders on tool changes. Extrude the excess material into the wipe tower." +msgstr "Multi-Material-Drucker müssen eventuell Extruder bei Werkzeugwechseln vor- oder nachspülen. Extrudieren Sie das überschüssige Material in den Reinigungsturm." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:666 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:683 +msgid "Multi-part object detected" +msgstr "Objekt mit mehreren Teilen erkannt" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:430 +msgid "Multiple Extruders" +msgstr "Mehrere Extruder" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:680 msgid "" -"Diameter of the print bed. It is assumed that origin (0,0) is located in the " -"center." +"Multiple objects were loaded for a multi-material printer.\n" +"Instead of considering them as multiple objects, should I consider\n" +"these files to represent a single object having multiple parts?\n" msgstr "" +"Für einen Multimaterialdrucker wurden mehrere Objekte geladen.\n" +"Soll ich, anstatt sie als mehrere Objekte zu betrachten, \n" +"diese Dateien als ein einzelnes Objekt mit mehreren Teilen behandeln?\n" -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:71 -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:150 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:92 -msgid "Custom" -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:220 +msgid "Name" +msgstr "Name" -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:75 -msgid "Load shape from STL..." -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 +msgid "No Bonjour device found" +msgstr "Kein Bonjourgerät gefunden" -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:120 -msgid "Settings" -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:469 +msgid "No previously sliced file." +msgstr "Keine vorher gesclicete Datei." -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:298 -msgid "Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):" -msgstr "" +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:137 +msgid "None" +msgstr "Kein" -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:315 -msgid "Error! " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:324 -msgid "The selected file contains no geometry." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:328 -msgid "" -"The selected file contains several disjoint areas. This is not supported." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp:42 -msgid "Bed Shape" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:224 -msgid "Array of language names and identifiers should have the same size." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 -msgid "Select the language" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 -msgid "Language" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:300 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:170 -msgid "Default" -msgstr "Standard" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:325 -msgid "Change Application Language" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 -msgid "Application will be restarted" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 -msgid "Attention!" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:339 -msgid "&Localization" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:488 -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:470 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 -msgid "Error" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:500 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:501 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:859 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:860 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1156 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1157 +msgid "Notes" +msgstr "Anmerkungen" #: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:493 msgid "Notice" -msgstr "" +msgstr "Hinweis" -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:498 -msgid "GLUquadricObjPtr | Attempt to free unreferenced scalar" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:894 +msgid "Nozzle diameter" +msgstr "Düsendurchmesser" -#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:500 -msgid "Warning" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:967 +msgid "Number of extruders of the printer." +msgstr "Anzahl der Extruder des Druckers." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1481 +msgid "Number of interface layers to insert between the object(s) and support material." +msgstr "Anzahl der Schnittstellenschichten, die zwischen Objekt(en) und Trägermaterial eingefügt werden sollen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1231 +msgid "Number of loops for the skirt. If the Minimum Extrusion Length option is set, the number of loops might be greater than the one configured here. Set this to zero to disable skirt completely." +msgstr "Anzahl der Schleifen für die Schürze. Wenn die Option Minimale Extrusionslänge gesetzt ist, kann die Anzahl der Schleifen größer sein als die hier konfigurierte. Setzen Sie diesen Wert auf Null, um die Schürze komplett zu deaktivieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:70 +msgid "Number of solid layers to generate on bottom surfaces." +msgstr "Anzahl der zu erzeugenden festen Schichten auf der Bodenfläche." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1315 +msgid "Number of solid layers to generate on top and bottom surfaces." +msgstr "Anzahl der zu erzeugenden festen Schichten auf der Ober- und Unterseite." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1640 +msgid "Number of solid layers to generate on top surfaces." +msgstr "Anzahl der zu erzeugenden festen Schichten auf der Oberseite." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:745 +msgid "Object too large?" +msgstr "Objekt zu groß?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1032 +msgid "OctoPrint upload" +msgstr "Zu OctoPrint hochladen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1410 +msgid "Only create support if it lies on a build plate. Don't create support on a print." +msgstr "Nur dann Stützen schaffen, wenn sie auf der Druckplattform aufbauen. Erstellt keine Stützstrukturen, die auf dem Ausdruck gründen würden." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:726 +msgid "Only infill where needed" +msgstr "Infill nur wo es notwendig ist drucken" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1205 +msgid "Only lift Z" +msgstr "Nur Z anheben" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1100 +msgid "Only lift Z above" +msgstr "Z nur Anheben über" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1109 +msgid "Only lift Z below" +msgstr "Z anheben nur unter" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:915 +msgid "Only retract when crossing perimeters" +msgstr "Nur bei Umfangsüberquerungen einziehen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:438 +msgid "Ooze prevention" +msgstr "Vermeidung von Nachsickern (Ooze)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 +msgid "Open a model" +msgstr "Modell öffnen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 +msgid "Open STL/OBJ/AMF…\tCtrl+O" +msgstr "STL/OBJ/AMF öffnen…\tCtrl+O" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 +msgid "Open the 3D cutting tool" +msgstr "3D-Schneidewerkzeug öffnen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 +msgid "Open the object editor dialog" +msgstr "Objekteditor-Dialog öffnen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 +msgid "Open the Prusa Edition releases page in your browser" +msgstr "Seite mit den Prusa Edition-Releases in Ihrem Browser öffnen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 +msgid "Open the Prusa3D drivers download page in your browser" +msgstr "Download-Seite für die Prusa3D-Treiber in Ihrem Browser öffnen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 +msgid "Open the Slic3r manual in your browser" +msgstr "Slic3r-Handbuch in Ihrem Browser öffnen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 +msgid "Open the Slic3r website in your browser" +msgstr "Slic3r-Website in Ihrem Browser öffnen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:27 +msgid "Optimize travel moves in order to minimize the crossing of perimeters. This is mostly useful with Bowden extruders which suffer from oozing. This feature slows down both the print and the G-code generation." +msgstr "Optimieren Sie die Verfahrbewegungen, um das Überschreiten von Konturen zu minimieren. Dies ist vor allem bei Bowdenextrudern nützlich, die unter sickerndem Material leiden. Diese Funktion verlangsamt sowohl den Druck als auch die Generierung des G-Codes." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:384 +msgid "Options for support material and raft" +msgstr "Optionen für Stützmaterial und Raft" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:57 +msgid "Origin" +msgstr "Nullpunkt" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:469 +msgid "Other" +msgstr "Sonstige" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:38 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1572 +msgid "Other layers" +msgstr "Andere Schichten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:488 +msgid "Output file" +msgstr "Ausgabedatei" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:930 +msgid "Output filename format" +msgstr "Ausgabe Dateinamen Format" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:476 +msgid "Output options" +msgstr "Ausgabeoptionen" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:140 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:82 +msgid "Overhang perimeter" +msgstr "Überhängende Aussenschicht" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1550 +msgid "Overhang threshold" +msgstr "Überhangsschwellwert" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:463 +msgid "Overlap" +msgstr "Überlappung" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1508 +msgid "Pattern" +msgstr "Muster" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1398 +msgid "Pattern angle" +msgstr "Muster Winkel" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1524 +msgid "Pattern spacing" +msgstr "Muster Abstand" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1510 +msgid "Pattern used to generate support material." +msgstr "Unterstützungsmaterialmuster." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1723 +msgid "Per color change depth" +msgstr "Länge bei jedem Farbwechsel" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:138 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:80 +msgid "Perimeter" +msgstr "Aussenschicht" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:957 +msgid "Perimeter extruder" +msgstr "Umfang Extruder" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:948 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:966 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:978 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:988 +msgid "Perimeters" +msgstr "Konturen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:160 +msgid "perimeters" +msgstr "Aussenschichten" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 +msgid "Place one more copy of the selected object" +msgstr "Eine weitere Kopie des ausgewählten Objekts positionieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:118 +msgid "Plater" +msgstr "Platte" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1199 +msgid "Position (for multi-extruder printers)" +msgstr "Position (für Multi-Extruder-Drucker)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1153 +msgid "Position of perimeters starting points." +msgstr "Position des Startpunktes des Umfangs." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1702 +msgid "Position X" +msgstr "X-Position" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1709 +msgid "Position Y" +msgstr "Y-Position" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:494 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1001 +msgid "Post-processing scripts" +msgstr "Nachbearbeitungs Script" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp:17 +msgid "Preferences" +msgstr "Einstellungen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 +msgid "Preferences…\tCtrl+," +msgstr "Einstellungen…\tCtrl+," + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1171 +msgid "Preferred direction of the seam" +msgstr "Bevorzugte Richtung für die Naht" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1183 +msgid "Preferred direction of the seam - jitter" +msgstr "Bevorzugte Zitterrichtung für die Naht" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1222 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:150 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2125 +msgid "Preview" +msgstr "Vorschau" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 +msgid "Previously sliced file (" +msgstr "Vorher geslicete Datei (" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:291 +msgid "Print contour perimeters from the outermost one to the innermost one instead of the default inverse order." +msgstr "Drucken Sie Konturumfänge von der äußersten zur innersten Kontur anstatt der standardmäßigen umgekehrten Reihenfolge." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:182 +msgid "Print Settings" +msgstr "Druckeinstellung" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:367 +msgid "Print settings" +msgstr "Druckeinstellung" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:836 +msgid "Print speed override" +msgstr "Korrektur der Druckgeschwindigkeit" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:369 +msgid "Printer" +msgstr "Drucker" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1014 +msgid "Printer notes" +msgstr "Drucker Anmerkungen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:228 +msgid "Printer Settings" +msgstr "Druckereinstellung" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:238 +msgid "Print…" +msgstr "Drucken…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 +msgid "Processing " +msgstr "Berechnung " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:643 +msgid "Processing input file\n" +msgstr "Eingabe Datei wird verarbeitet\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:508 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:868 +msgid "Profile dependencies" +msgstr "Profil Abhängigkeiten" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 +msgid "Prusa 3D Drivers" +msgstr "Prusa 3D Treiber" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 +msgid "Prusa Edition Releases" +msgstr "Prusa Edition Release" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 +msgid "Q&uick Slice…\tCtrl+U" +msgstr "Q&uick Slice…\tCtrl+U" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:335 +msgid "Quality (slower slicing)" +msgstr "Qualtät (langsamer Slicen)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 +msgid "Quick Slice and Save &As…\tCtrl+Alt+U" +msgstr "&Quick Slice und Speichern unter…\tCtrl+Alt+U" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 +msgid "Quit Slic3r" +msgstr "Slic3r beenden" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:331 +msgid "Radius" +msgstr "Radius" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:380 +msgid "Raft" +msgstr "Raft" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1029 +msgid "Raft layers" +msgstr "Raft Schichten" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 +msgid "Rear" +msgstr "Hinten" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 +msgid "Rear View" +msgstr "Ansicht von Hinten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:262 +#, c-format +msgid "Recommended object thin wall thickness for layer height %.2f and " +msgstr "Empfohlene Stärke der dünnen Wände des Objekts für die Schichthöhe %.2f und " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:245 +msgid "Recommended object thin wall thickness: Not available due to invalid layer height." +msgstr "Empfohlene Stärke der dünnen Wände des Objekts: Nicht verfügbar wegen unzulässiger Schichthöhe." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:46 +msgid "Rectangular" +msgstr "Rechteckig" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:352 +msgid "Reducing printing time" +msgstr "Druckzeit wird verkürzt" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 +msgid "Reload from Disk" +msgstr "Von Festplatte neu laden" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 +msgid "Reload the selected file from Disk" +msgstr "Ausgewählte Datei von Festplatte neu laden" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:27 +msgid "Remember output directory" +msgstr "Ausgabeverzeichnis merken" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 +msgid "Remove" +msgstr "Entfernen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 +msgid "remove" +msgstr "Entfernen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 +msgid "Remove one copy of the selected object" +msgstr "Eine Kopie des ausgewählten Objekts entfernen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 +msgid "Remove the selected object" +msgstr "Ausgewähltes Objekt entfernen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 +msgid "Repair" +msgstr "Reparieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 +msgid "Repair STL file…" +msgstr "STL-Datei reparieren…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 +msgid "Repeat last quick slice" +msgstr "Letzten schnellen Slice wiederholen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 +msgid "Report an Issue" +msgstr "Einen Fehler melden" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 +msgid "Report an issue on the Slic3r Prusa Edition" +msgstr "Einen Fehler in der Slic3r Prusa Edition melden" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:995 +msgid "Rescan serial ports" +msgstr "Serielle Schnittstellen nochmals abfragen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1039 +msgid "Resolution" +msgstr "Auflösung" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1057 +msgid "Retract amount before wipe" +msgstr "Einzugslänge vor einer Reinigung" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1065 +msgid "Retract on layer change" +msgstr "Bei Schichtwechsel Einziehen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1202 +msgid "Retraction" +msgstr "Einzug" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1051 +msgid "Retraction is not triggered when travel moves are shorter than this length." +msgstr "Der Einzug wird nicht ausgelöst, wenn die Fahrbewegungen kürzer als diese Länge sind." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1072 +msgid "Retraction Length" +msgstr "Einzugslänge" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1081 +msgid "Retraction Length (Toolchange)" +msgstr "Einzugslänge (Werkzeugwechsel)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1134 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1135 +msgid "Retraction Speed" +msgstr "Einzugsgeschwindigkeit" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1218 +msgid "Retraction when tool is disabled (advanced settings for multi-extruder setups)" +msgstr "Einzug, wenn das Werkzeug deaktiviert ist (weiterführende Einstellungen für Multi-Extruder-Einrichtungen)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:96 +msgid "Retractions" +msgstr "Einzüge" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 +msgid "Right" +msgstr "Rechts" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 +msgid "Right View" +msgstr "Ansicht von rechts" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 +msgid "Rotate" +msgstr "Drehen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 +msgid "Rotate 45° clockwise" +msgstr "45° im Uhrzeigersinn drehen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 +msgid "Rotate 45° counter-clockwise" +msgstr "45° im Gegenuhrzeigersinn drehen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Rotate around " +msgstr "Rotieren um " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 +msgid "Rotate the selected object by 45° clockwise" +msgstr "Drehen Sie das ausgewählte Objekt um 45° mit dem Uhrzeiger" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 +msgid "Rotate the selected object by 45° counter-clockwise" +msgstr "Drehen Sie das ausgewählte Objekt um 45° gegen den Uhrzeiger" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 +msgid "Rotate the selected object by an arbitrary angle" +msgstr "Drehen Sie das ausgewählte Objekt um einen beliebigen Winkel" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 +msgid "Rotate the selected object by an arbitrary angle around X axis" +msgstr "Drehen Sie das ausgewählte Objekt um einen beliebigen Winkel um die X-Achse" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 +msgid "Rotate the selected object by an arbitrary angle around Y axis" +msgstr "Drehen Sie das ausgewählte Objekt um einen beliebigen Winkel um die Y-Achse" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 +msgid "Rotate the selected object by an arbitrary angle around Z axis" +msgstr "Drehen Sie das ausgewählte Objekt um einen beliebigen Winkel um die Z-Achse" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 +msgid "Run Configuration " +msgstr "Konfiguration benutzen " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 +msgid "Save " +msgstr "Speichern " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:605 +msgid "Save configuration as:" +msgstr "Konfiguration speichern unter:" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:50 msgid "Save current " -msgstr "" +msgstr "Aktuell sichern " -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:51 -msgid "Delete this preset" -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:580 +msgid "Save OBJ file (less prone to coordinate errors than STL) as:" +msgstr "Speichern als OBJ-Datei (weniger anfällig für Koordinatenfehler als STL):" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:313 -msgid "Layers and perimeters" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:248 +msgid "Save preset" +msgstr "Sichern der Voreinstellung" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:314 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:777 -msgid "Layer height" -msgstr "Schichtdicke" +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:646 +msgid "Save presets bundle as:" +msgstr "Sichern der Voreinstellungssammlung unter:" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:318 -msgid "Vertical shells" -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:222 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 +msgid "Scale" +msgstr "Skalieren" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:329 -msgid "Horizontal shells" -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +msgid "Scale along " +msgstr "Skalieren entlang " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 +msgid "Scale the selected object along a single axis" +msgstr "Ausgewähltes Objekt entlang einer einzelnen Achse skalieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 +msgid "Scale the selected object along the X axis" +msgstr "Ausgewähltes Objekt entlang der X-Achse skalieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 +msgid "Scale the selected object along the XYZ axes" +msgstr "Ausgewähltes Objekt entlang der XYZ-Achsen skalieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 +msgid "Scale the selected object along the Y axis" +msgstr "Ausgewähltes Objekt entlang der Y-Achse skalieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 +msgid "Scale the selected object along the Z axis" +msgstr "Ausgewähltes Objekt entlang der Z-Achse skalieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 +msgid "Scale to size" +msgstr "Auf Größe skalieren" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:187 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:203 +msgid "Scale…" +msgstr "Skalieren…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1151 +msgid "Seam position" +msgstr "Nahtposition" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1172 +msgid "Seam preferred direction" +msgstr "Bevorzugte Richtung für Nähte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1182 +msgid "Seam preferred direction jitter" +msgstr "Bevorzugte Zitterrichtung für Nähte" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 +msgid "Select &Controller Tab\tCtrl+T" +msgstr "Reiter \"&Controller\" auswählen\tCtrl+T" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 +msgid "Select &Filament Settings Tab\tCtrl+3" +msgstr "Reiter \"&Filamenteinstellungen\" auswählen\tCtrl+3" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 +msgid "Select &Plater Tab\tCtrl+1" +msgstr "Reiter \"&Plater\" auswählen\tCtrl+1" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:623 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:667 +msgid "Select configuration to load:" +msgstr "Konfiguration zum Laden auswählen:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 +msgid "Select P&rint Settings Tab\tCtrl+2" +msgstr "Reiter \"D&ruckeinstellungen\" auswählen\tCtrl+2" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 +msgid "Select Print&er Settings Tab\tCtrl+4" +msgstr "Reiter \"Druck&ereinstellungen\" auswählen\tCtrl+4" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 +msgid "Select the language" +msgstr "Wählen Sie die Sprache aus" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1667 +msgid "Select the printers this profile is compatible with." +msgstr "Wählen Sie die Drucker aus, die mit diesem Profil kompatibel sind." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:566 +msgid "Select the STL file to repair:" +msgstr "Geben Sie die STL-Datei an, die repariert werden soll:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:239 +msgid "Send to printer" +msgstr "Zum Drucker senden" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1448 +msgid "Sending G-code file to the OctoPrint server..." +msgstr "Datei mit G-Code zum OctoPrint-Server senden…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:477 +msgid "Sequential printing" +msgstr "Sequentielles Drucken" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:990 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1193 +msgid "Serial port" +msgstr "Serieller Port" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1202 +msgid "Serial port speed" +msgstr "Serielle Portgeschwindigkeit" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 +msgid "Set number of copies…" +msgstr "Anzahl der Kopien angeben…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:378 +msgid "Set this to a non-zero value to allow a manual extrusion width. If left to zero, Slic3r derives extrusion widths from the nozzle diameter (see the tooltips for perimeter extrusion width, infill extrusion width etc). If expressed as percentage (for example: 230%), it will be computed over layer height." +msgstr "Setzen Sie dies auf einen Nicht-Nullwert, um eine manuelle Extrusionsbreite zuzulassen. Falls auf Null belassen, wird Slic3r die Extrusionsbreiten vom Durchmesser der Druckdüse ableiten (siehe die Hilfstexte für die Extrusionsbreite für Aussenschichten, Infill usw.). Falls als Prozentwert (z.B. 230%) angegeben, wird dieser ausgehend von der Schichthöhe berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:269 +msgid "Set this to a non-zero value to set a manual extrusion width for external perimeters. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 200%), it will be computed over layer height." +msgstr "Setzen Sie dies auf einen Nicht-Nullwert, um eine manuelle Extrusionsbreite für externe Aussenschichten anzugeben. Falls auf Null belassen, wird die Standard-Extrusionsbreite verwendet (falls angeben), ansonsten wird der Durchmesser der Druckdüse x 1,125 verwendet. Falls als Prozentwert (z.B. 200%) angegeben, wird dieser ausgehend von der Schichthöhe berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:593 +msgid "Set this to a non-zero value to set a manual extrusion width for first layer. You can use this to force fatter extrudates for better adhesion. If expressed as percentage (for example 120%) it will be computed over first layer height. If set to zero, it will use the default extrusion width." +msgstr "Setzen Sie dies auf einen Nicht-Nullwert, um eine manuelle Extrusionsbreite für die erste Druckschicht anzugeben. Sie können damit eine dickere Extrusion für bessere Haftung erzwingen. Falls auf Null belassen, wird die Standard-Extrusionsbreite verwendet. Falls als Prozentwert (z.B. 120%) angegeben, wird dieser ausgehend von der Schichthöhe berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1293 +msgid "Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Setzen Sie dies auf einen Nicht-Nullwert, um eine manuelle Extrusionsbreite für den Infill bei stabilen Flächen anzugeben. Falls auf Null belassen, wird die Standard-Extrusionsbreite verwendet (falls angeben), ansonsten wird der Durchmesser der Druckdüse x 1,125 verwendet. Falls als Prozentwert (z.B. 90%) angegeben, wird dieser ausgehend von der Schichthöhe berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1615 +msgid "Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. You may want to use thinner extrudates to fill all narrow regions and get a smoother finish. If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Setzen Sie dies auf einen Nicht-Nullwert, um eine manuelle Extrusionsbreite für die oberen Aussenflächen anzugeben. Dünnere Extrusionsbreiten sind vorteilhaft, um Engstellen auszufüllen und um eine schönere Oberfläche zu erhalten. Falls auf Null belassen, wird die Standard-Extrusionsbreite verwendet (falls angeben), ansonsten wird der Durchmesser der Druckdüse verwendet. Falls als Prozentwert (z.B. 90%) angegeben, wird dieser ausgehend von der Schichthöhe berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:711 +msgid "Set this to a non-zero value to set a manual extrusion width for infill. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. You may want to use fatter extrudates to speed up the infill and make your parts stronger. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Setzen Sie dies auf einen Nicht-Nullwert, um eine manuelle Extrusionsbreite für den Infill anzugeben. Falls auf Null belassen, wird die Standard-Extrusionsbreite verwendet (falls angeben), ansonsten wird der Durchmesser der Druckdüse x 1,125 verwendet. Dickere Extrusionsbreiten sind vorteilhaft, um den Infill zu beschleunigen und um die Teile stärker zu machen. Falls als Prozentwert (z.B. 90%) angegeben, wird dieser ausgehend von der Schichthöhe berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:968 +msgid "Set this to a non-zero value to set a manual extrusion width for perimeters. You may want to use thinner extrudates to get more accurate surfaces. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 200%) it will be computed over layer height." +msgstr "Setzen Sie dies auf einen Nicht-Nullwert, um eine manuelle Extrusionsbreite für Aussenschichten anzugeben. Dünnere Extrusionsbreiten sind vorteilhaft, um genauere Oberflächen zu erhalten. Falls auf Null belassen, wird die Standard-Extrusionsbreite verwendet (falls angeben), ansonsten wird der Durchmesser der Druckdüse x 1,125 verwendet. Falls als Prozentwert (z.B. 200%) angegeben, wird dieser ausgehend von der Schichthöhe berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1455 +msgid "Set this to a non-zero value to set a manual extrusion width for support material. If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Setzen Sie dies auf einen Nicht-Nullwert, um eine manuelle Extrusionsbreite für das Stützmaterial anzugeben. Falls auf Null belassen, wird die Standard-Extrusionsbreite verwendet (falls angeben), ansonsten wird der Durchmesser der Druckdüse verwendet. Als Prozentwert (z.B. 90%) angegeben, wird dieser ausgehend von der Schichthöhe berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:332 +msgid "Set this to the clearance radius around your extruder. If the extruder is not centered, choose the largest value for safety. This setting is used to check for collisions and to display the graphical preview in the plater." +msgstr "Stellen Sie dies auf den Freiraumradius um Ihren Extruder ein. Wenn der Extruder nicht zentriert ist, wählen Sie zur Sicherheit den größten Wert. Diese Einstellung wird verwendet, um Kollisionen zu prüfen und die grafische Vorschau auf der Platte anzuzeigen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:321 +msgid "Set this to the vertical distance between your nozzle tip and (usually) the X carriage rods. In other words, this is the height of the clearance cylinder around your extruder, and it represents the maximum depth the extruder can peek before colliding with other printed objects." +msgstr "Stellen Sie dies auf den vertikalen Abstand zwischen Ihrer Düsenspitze und (in der Regel) den X-Wagenstangen ein. Mit anderen Worten, das ist die Höhe des Abstandszylinders um Ihren Extruder herum und stellt die maximale Tiefe dar, die der Extruder vor der Kollision mit anderen Druckobjekten sehen kann." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:120 +msgid "Settings" +msgstr "Einstellungen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:191 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:206 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 +msgid "Settings…" +msgstr "Einstellungen…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:39 +msgid "Shape" +msgstr "Form" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:98 +msgid "Shells" +msgstr "Konturhüllen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:75 +msgid "Show" +msgstr "Anzeigen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 +msgid "Show about dialog" +msgstr "\"Über\"-Dialog anzeigen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:67 +msgid "Show incompatible print and filament presets" +msgstr "Inkompatible Druck- und Filamenteinstellungen anzeigen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 +msgid "Show system information" +msgstr "Systeminformationen anzeigen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 +msgid "Show the filament settings" +msgstr "Filamenteinstellungen anzeigen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 +msgid "Show the plater" +msgstr "Platte anzeigen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 +msgid "Show the print settings" +msgstr "Druckeinstellungen anzeigen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 +msgid "Show the printer controller" +msgstr "Drucker-Controller anzeigen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 +msgid "Show the printer settings" +msgstr "Druckereinstellungen anzeigen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1373 +msgid "Single Extruder Multi Material" +msgstr "Einzelner Extruder mit Multi-Material" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:50 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1191 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:408 +msgid "Size" +msgstr "Grösse" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:938 +msgid "Size and coordinates" +msgstr "Grösse und Koordinaten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:51 +msgid "Size in X and Y of the rectangular plate." +msgstr "Grösse der rechteckigen Platte in X und Y." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:365 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:146 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:88 +msgid "Skirt" +msgstr "Schürze" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:364 +msgid "Skirt and brim" +msgstr "Schürze und Rand" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1221 +msgid "Skirt height" +msgstr "Schürzenhöhe" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1230 +msgid "Skirt Loops" +msgstr "Schleifen für die Schürze" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 +msgid "Slic3r &Manual" +msgstr "Slic3r &Handbuch" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 +msgid "Slic3r &Website" +msgstr "Slic3r &Website" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:902 +msgid "Slic3r can upload G-code files to OctoPrint. This field should contain the API Key required for authentication." +msgstr "Slic3r kann G-Code Dateien zu OctoPrint hochladen. Dieses Feld sollte den API-Schlüssel enthalten, der für die Authentifizierung erforderlich ist." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:909 +msgid "Slic3r can upload G-code files to OctoPrint. This field should contain the hostname or IP address of the OctoPrint instance." +msgstr "Slic3r kann G-Code Dateien zu OctoPrint hochladen. Dieses Feld sollte den Hostnamen oder die IP-Adresse der OctoPrint-Instanz enthalten." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:929 +msgid "Slic3r Error" +msgstr "Slic3r Fehler" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:867 +msgid "Slic3r will not scale speed down below this speed." +msgstr "Slic3r wird die Geschwindigkeit nicht unterhalb dieser Geschwindigkeit skalieren." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 +msgid "Slice a file into a G-code" +msgstr "Datei zu G-Code slicen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 +msgid "Slice a file into a G-code, save as" +msgstr "Datei zu G-Code slicen, speichern als" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 +msgid "Slice file to a multi-layer SVG" +msgstr "Datei zu einem Mehrebenen-SVG slicen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:237 +msgid "Slice now" +msgstr "Jetzt slicen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 +msgid "Slice to SV&G…\tCtrl+G" +msgstr "Slice zu SV&G…\tCtrl+G" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:438 +msgid "Sliced Info" +msgstr "Slice-Info" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1286 +msgid "Slicing cancelled" +msgstr "Der Slice wurde abgebrochen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:550 +msgid "Slicing Done!" +msgstr "Der Slice ist beendet!" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 +msgid "Slicing…" +msgstr "Der Slice wird berechnet…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1239 +msgid "Slow down if layer print time is below" +msgstr "Langsamer drucken wenn die Schichtdruckzeit geringer ist als" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1250 +msgid "Small perimeters" +msgstr "Dünne Aussenschichten" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:179 +msgid "solid infill" +msgstr "Stabiles Infill" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1291 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1301 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:142 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:84 +msgid "Solid infill" +msgstr "Stabiles Infill" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1279 +msgid "Solid infill every" +msgstr "Massives Infill alle" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1271 +msgid "Solid infill extruder" +msgstr "Massives Infill Extruder" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1262 +msgid "Solid infill threshold area" +msgstr "Massives Infill Flächen Schwellwert" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:330 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1314 msgid "Solid layers" msgstr "Dichte Schichten" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:335 -msgid "Quality (slower slicing)" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:470 +msgid "Soluble material" +msgstr "Lösliches Material" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:342 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:356 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:449 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:452 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:831 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1113 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:107 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:208 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:736 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1733 -msgid "Advanced" -msgstr "Erweiterte Einstellungen" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:471 +msgid "Soluble material is most likely used for a soluble support." +msgstr "Lösliches Material wird meistens für lösliche Stützen verwendet." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:346 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:347 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:664 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:87 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:247 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:488 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:502 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:540 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:681 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:691 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:709 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:727 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:746 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1263 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1280 -msgid "Infill" -msgstr "Infill" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:653 +msgid "Some G/M-code commands, including temperature control and others, are not universal. Set this option to your printer's firmware to get a compatible output. The \"No extrusion\" flavor prevents Slic3r from exporting any extrusion value at all." +msgstr "Einige G/M-Code-Befehle, einschließlich Temperatursteuerung und andere, sind nicht universell. Stellen Sie diese Option auf die Firmware Ihres Druckers ein, um eine kompatible Ausgabe zu erhalten. Die Eigenschaft \"Keine Extrusion\" verhindert, dass Slic3r überhaupt einen Extrusionswert exportiert." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:352 -msgid "Reducing printing time" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1682 +msgid "Some printers or printer setups may have difficulties printing with a variable layer height. Enabled by default." +msgstr "Mit einigen Druckern oder Druckerkonfigurationen ist es schwierig, mit einer variablen Schichthöhe zu drucken. Standardmässig aktiviert." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:364 -msgid "Skirt and brim" -msgstr "Zarge und Krempel" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1490 +msgid "Spacing between interface lines. Set zero to get a solid interface." +msgstr "Abstand zwischen den Schnittstellenlinien. Auf Null stellen, um ein solides Interface zu erhalten." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:365 -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:146 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:88 -msgid "Skirt" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1526 +msgid "Spacing between support material lines." +msgstr "Abstand zwischen Stützmateriallinien." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:371 -msgid "Brim" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:398 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:118 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:278 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:635 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:747 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:979 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1201 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1251 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1302 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1625 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:71 +msgid "Speed" +msgstr "Geschwindigkeit" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1203 +msgid "Speed (baud) of USB/serial port for printer connection." +msgstr "Geschwindigkeit (baud) des USB/seriellen Ports für den Drucker Anschluß." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:336 +msgid "Speed (mm/s)" +msgstr "Geschwindigkeit (mm/s)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:636 +msgid "Speed for filling small gaps using short zigzag moves. Keep this reasonably low to avoid too much shaking and resonance issues. Set zero to disable gaps filling." +msgstr "Geschwindigkeit, mit der kleine Lücken mit kurzen Zickzackbewegungen gefüllt werden. Beschränken Sie diese auf einen mässigen Wert, um übermässiges Rütteln und Resonanzprobleme zu vermeiden. Auf Null gesetzt, wird das Füllen kleiner Lücken deaktiviert." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:411 +msgid "Speed for non-print moves" +msgstr "Geschwindigkeit für Bewegungen zwischen den Druckvorgängen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:980 +msgid "Speed for perimeters (contours, aka vertical shells). Set to zero for auto." +msgstr "Geschwindigkeit für Aussenschichten (Konturen, bzw. vertikale Hüllen). Für Automatik auf Null setzen." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:399 +msgid "Speed for print moves" +msgstr "Geschwindigkeit für Druckbewegungen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:119 +msgid "Speed for printing bridges." +msgstr "Brückendruckgeschwindigkeit." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1303 +msgid "Speed for printing solid regions (top/bottom/internal horizontal shells). This can be expressed as a percentage (for example: 80%) over the default infill speed above. Set to zero for auto." +msgstr "Druckgeschwindigkeit für stabile Bereiche (obere/untere/innenliegende waagrechte Hüllen). Sie kann als Prozentwert (z.B. 80%) der oben eingegebenen standardmässigen Infill-Geschwindigkeit angegeben werden. Für Automatik auf Null setzen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1499 +msgid "Speed for printing support material interface layers. If expressed as percentage (for example 50%) it will be calculated over support material speed." +msgstr "Geschwindigkeit für den Druck von Trägermaterial-Schnittstellenschichten. Wenn es als Prozentsatz (z.B. 50%) ausgedrückt wird, wird es über die Geschwindigkeit des Trägermaterials berechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1535 +msgid "Speed for printing support material." +msgstr "Druckgeschwindigkeit des Stützmaterials." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:748 +msgid "Speed for printing the internal fill. Set to zero for auto." +msgstr "Druckgeschwindigkeit für den Infill. Für Automatik auf Null setzen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1626 +msgid "Speed for printing top solid layers (it only applies to the uppermost external layers and not to their internal solid layers). You may want to slow down this to get a nicer surface finish. This can be expressed as a percentage (for example: 80%) over the solid infill speed above. Set to zero for auto." +msgstr "Druckgeschwindigkeit für die oberen stabilen Schichten (betrifft nur die obersten Aussenschichten und nicht deren innenliegende stabilen Schichten). Wir empfehlen, diesen Wert zu reduzieren, um eine schönere Oberfläche zu erhalten. Dies kann als Prozentwert (z.B. 80%) der oben eingegebenen Geschwindigkeit für stabiles Infill angegeben werden. Für Automatik auf Null setzen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1648 +msgid "Speed for travel moves (jumps between distant extrusion points)." +msgstr "Bewegungsgeschwindigkeit (zwischen weit entfernten Extrusionsorten)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1322 +msgid "Spiral vase" +msgstr "Spiralvasenmodus" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:540 +msgid "Spiral Vase" +msgstr "Spiralvase" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:188 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:204 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 +msgid "Split" +msgstr "Trennen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 +msgid "Split the selected object into individual parts" +msgstr "Ausgewähltes Objekt in Einzelteile trennen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:847 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1120 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1342 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1357 +msgid "Start G-code" +msgstr "Start G-Code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 +msgid "Start new slicing process" +msgstr "Neuen Slicing-Prozess starten" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1539 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1581 +msgid "STL file exported to " +msgstr "Die STL-Datei wurde exportiert zu " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 +msgid "Success!" +msgstr "Erfolg!" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:198 +msgid "support" +msgstr "Stützen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:620 +msgid "Support Generator" +msgstr "Generator für die Stützen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:208 +msgid "support interface" +msgstr "Schnittstelle zu den Stützen" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:374 #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:375 @@ -290,137 +2810,154 @@ msgstr "" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:147 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:89 msgid "Support material" -msgstr "Unterstützungsmaterial" +msgstr "Stützmaterial" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:380 -msgid "Raft" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1497 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:148 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:90 +msgid "Support material interface" +msgstr "Schnittstelle zum Stützmaterial" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1552 +msgid "Support material will not be generated for overhangs whose slope angle (90° = vertical) is above the given threshold. In other words, this value represent the most horizontal slope (measured from the horizontal plane) that you can print without support material. Set to zero for automatic detection (recommended)." +msgstr "Für Überhänge, deren Neigungswinkel (90° = vertikal) oberhalb der vorgegebenen Schwelle liegt, wird kein Stützmaterial erzeugt. Mit anderen Worten, dieser Wert stellt die größte horizontale Steigung (gemessen von der horizontalen Ebene) dar, die Sie ohne Trägermaterial drucken können. Für die automatische Erkennung auf Null setzen (empfohlen)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1470 +msgid "Support material/raft interface extruder" +msgstr "Stützmaterial/Raft Schnittstellen Extruder" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1444 +msgid "Support material/raft/skirt extruder" +msgstr "Stützmaterial/Raft/Schürzen Extruder" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1408 +msgid "Support on build plate only" +msgstr "Stützmaterial nur auf dem Druckbrett" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:617 +msgid "" +"Supports work better, if the following feature is enabled:\n" +"- Detect bridging perimeters\n" +"\n" +"Shall I adjust those settings for supports?" msgstr "" +"Stützen funktionieren besser, falls die folgende Option aktiviert ist:\n" +"- Aussenschichten von Überbrückungen erkennen\n" +"\n" +"Soll ich diese Einstellung für die Stützen anpassen?" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:384 -msgid "Options for support material and raft" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:59 +msgid "Suppress \" - default - \" presets" +msgstr "\"Standard\"-Einstellungen unterdrücken" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:398 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:118 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:278 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:635 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:747 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:979 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1201 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1251 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1302 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1625 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:71 -msgid "Speed" -msgstr "Geschwindigkeit" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:61 +msgid "Suppress \" - default - \" presets in the Print / Filament / Printer selections once there are any other valid presets available." +msgstr "\"Standard\"-Einstellungen in den Auswahlen für Druck / Filament / Drucker unterdrücken, falls andere gültige Voreinstellungen vorhanden sind." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:399 -msgid "Speed for print moves" -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +msgid "SVG" +msgstr "SVG" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:411 -msgid "Speed for non-print moves" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1544 +msgid "Synchronize support layers with the object print layers. This is useful with multi-material printers, where the extruder switch is expensive." +msgstr "Stützschichten mit den Druckschichten des Objekts synchronisieren. Dies ist nützlich bei Multi-Material-Druckern, bei denen der Wechsel des Extruders kostenaufwendig ist." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:414 -msgid "Modifiers" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1542 +msgid "Synchronize with object layers" +msgstr "Mit Objektschichten synchronisieren" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:417 -msgid "Acceleration control (advanced)" -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 +msgid "System Info" +msgstr "Systeminformationen" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:424 -msgid "Autospeed (advanced)" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:794 +msgid "Temperature " +msgstr "Temperatur " -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:430 -msgid "Multiple Extruders" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1576 +msgid "Temperature" +msgstr "Temperatur" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:431 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:966 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:308 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:702 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:958 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1272 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1445 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1471 -msgid "Extruders" -msgstr "Extruder" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1333 +msgid "Temperature difference to be applied when an extruder is not active. Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped." +msgstr "Der anzuwendende Temperaturunterschied, wenn kein Extruder aktiv ist. Dies aktiviert eine \"Wegwerf-\"Schürze über die ganze Druckhöhe, auf der die Düsen periodisch gereinigt werden." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:438 -msgid "Ooze prevention" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1332 +msgid "Temperature variation" +msgstr "Temperaturen" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:442 -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:149 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:91 -msgid "Wipe tower" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1004 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1072 +msgid "Test" +msgstr "Test" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:453 -msgid "Extrusion width" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 +msgid "The " +msgstr "Der/Die " -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:463 -msgid "Overlap" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:309 +msgid "The extruder to use (unless more specific extruder settings are specified). This value overrides perimeter and infill extruders, but not the support extruders." +msgstr "Der Extruder, der verwendet werden soll, falls keine sonstigen Extrudereinstellungen angegeben wurden. Dies übersteuert die Angaben für die Aussenschicht- und Infill-Extruder, aber nicht die Angabe des Extruders für die Stützen." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:466 -msgid "Flow" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:703 +msgid "The extruder to use when printing infill." +msgstr "Extruder der beim Infill benutzt wird." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:469 -msgid "Other" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:959 +msgid "The extruder to use when printing perimeters and brim. First extruder is 1." +msgstr "Extruder der beim Umfang und Rand Drucken benutzt werden soll. Der erste Extruder ist 1." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:476 -msgid "Output options" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1273 +msgid "The extruder to use when printing solid infill." +msgstr "Der Extruder der beim Drucken von solidem Infill benutzt werden soll." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:477 -msgid "Sequential printing" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1472 +msgid "The extruder to use when printing support material interface (1+, 0 to use the current extruder to minimize tool changes). This affects raft too." +msgstr "Der Extruder, der für den Druck von Schnittstellen zum Stützmaterial verwendet wird (1+, oder Null um den aktuellen Extruder für die Minimierung von Werkzeugwechseln zu verwenden). Dies betrifft auch den Raft." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:479 -msgid "Extruder clearance (mm)" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1446 +msgid "The extruder to use when printing support material, raft and skirt (1+, 0 to use the current extruder to minimize tool changes)." +msgstr "Der Extruder, der für den Druck von Stützmaterial, Raft und Schürze verwendet wird (1+, oder Null um den aktuellen Extruder für die Minimierung von Werkzeugwechseln zu verwenden)." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:488 -msgid "Output file" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:209 +msgid "The first layer will be shrunk in the XY plane by the configured value to compensate for the 1st layer squish aka an Elephant Foot effect." +msgstr "Die erste Schicht wird in der XY-Ebene um den vorgegebenen Wert verkleinert, um das Ausquetschen in der ersten Schicht (\"Elephant Foot\"-Effekt) zu kompensieren." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:494 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1001 -msgid "Post-processing scripts" -msgstr "Nacharbeitungsprogramm" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1734 +msgid "The object will be grown/shrunk in the XY plane by the configured value (negative = inwards, positive = outwards). This might be useful for fine-tuning hole sizes." +msgstr "Das Objekt wird in der XY-Ebene um den konfigurierten Wert (negativ = einwärts, positiv = auswärts) vergrößert/verkleinert. Dies kann bei der Feinabstimmung von Lochgrößen hilfreich sein." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:500 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:501 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:859 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:860 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1156 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1157 -msgid "Notes" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1031 +msgid "The object will be raised by this number of layers, and support material will be generated under it." +msgstr "Das Objekt wird um diese Anzahl von Schichten angehoben, und darunter wird Trägermaterial erzeugt." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:507 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:867 -msgid "Dependencies" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1374 +msgid "The printer multiplexes filaments into a single hot end." +msgstr "Der Drucker multiplext mehrere Filamente in einem Hotend." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:508 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:868 -msgid "Profile dependencies" -msgstr "" +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:324 +msgid "The selected file contains no geometry." +msgstr "Die ausgewählte Datei enthält keine Geometrie." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:509 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:869 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1668 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:143 -msgid "Compatible printers" -msgstr "Kompatibele Drucker" +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:328 +msgid "The selected file contains several disjoint areas. This is not supported." +msgstr "Die ausgewählte Datei enthält mehrere nicht zusammenhängende Bereiche. Dies wird nicht unterstützt." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1112 +msgid "The selected object can't be split because it contains more than one volume/material." +msgstr "Das ausgewählte Objekt konnte nicht getrennt werden, weil es aus mehr als einem Volumen/Material besteht." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1121 +msgid "The selected object couldn't be split because it contains only one part." +msgstr "Das ausgewählte Objekt konnte nicht getrennt werden, da es nur aus einem Teil besteht." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1144 +msgid "The speed for loading of a filament into extruder after retraction (it only applies to the extruder motor). If left to zero, the retraction speed is used." +msgstr "Die Geschwindigkeit, mit der ein Filament nach dem Einzug wieder in den Extruder vorgeschoben wird. Falls Null, wird die Einzugsgeschwindigkeit verwendet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1136 +msgid "The speed for retractions (it only applies to the extruder motor)." +msgstr "Die Einzugsgeschwindigkeit (sie betrifft nur den Extruderantrieb)." #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:533 #, no-c-format @@ -434,10 +2971,40 @@ msgid "" "\n" "Shall I adjust those settings in order to enable Spiral Vase?" msgstr "" +"Der Spiralvasen-Modus erfordert:\n" +"- eine Aussenschicht\n" +"- keine stabilen Schichten oben\n" +"- 0% Füllungsdichte\n" +"- keine Stützen\n" +"- kein ensure_vertical_shell_thickness\n" +"\n" +"Soll ich diese Einstellungen anpassen, um den Spiralvasen-Modus zu aktivieren?" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:540 -msgid "Spiral Vase" +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1560 +msgid "The supplied name is empty. It can't be saved." +msgstr "Der angegebene Name ist leer. Die Speicherung kann nicht erfolgen." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1788 +msgid "The supplied name is not available." +msgstr "Der angegebene Name ist nicht verfügbar." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1785 +msgid "The supplied name is not valid; the following characters are not allowed:" +msgstr "Der angegebene Name ist ungültig; die folgenden Zeichen sind nicht erlaubt:" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1418 +msgid "The vertical distance between object and support material interface. Setting this to 0 will also prevent Slic3r from using bridge flow and speed for the first object layer." +msgstr "Der vertikale Abstand zwischen Objekt und Trägermaterialschnittstelle. Wenn Sie diesen Wert auf 0 setzen, wird Slic3r auch verhindern, dass Bridge-Flow und -Geschwindigkeit für die erste Objektschicht verwendet werden." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1312 +msgid "" +"The Wipe option is not available when using the Firmware Retraction mode.\n" +"\n" +"Shall I disable it in order to enable Firmware Retraction?" msgstr "" +"Die Reinigungsoption ist nicht verfügbar, wenn der Firmware-Einzug verwendet wird.\n" +"\n" +"Soll ich sie ausschalten, um den Firmware-Einzug zu aktivieren?" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:560 msgid "" @@ -447,701 +3014,490 @@ msgid "" "\n" "Shall I adjust those settings in order to enable the Wipe Tower?" msgstr "" +"Die Reinigungssäule unterstützt zur Zeit nur:\n" +"- Höhe der ersten Schicht 0.2mm\n" +"- Höhe der anderen Schichten zwischen 0.15mm und 0.35mm\n" +"\n" +"Soll ich diese Einstellungen ändern, um die Reinigungssäule zu aktivieren?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:581 +msgid "" +"The Wipe Tower currently supports the non-soluble supports only\n" +"if they are printed with the current extruder without triggering a tool change.\n" +"(both support_material_extruder and support_material_interface_extruder need to be set to 0).\n" +"\n" +"Shall I adjust those settings in order to enable the Wipe Tower?" +msgstr "" +"Die Reinigungssäule unterstützt zur Zeit nichtlösliche Stützen nur, falls sie mit dem aktuellen Extruder ohne einen Werkzeugwechsel gedruckt werden (sowohl support_material_extruder wie auch support_material_interface_extruder müssen auf Null gesetzt werden).\n" +"\n" +"Soll ich diese Einstellungen anpassen, um die Reinigungssäule zu aktivieren?" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:60 +msgid "This code is inserted between objects when using sequential printing. By default extruder and bed temperature are reset using non-wait command; however if M104, M109, M140 or M190 are detected in this custom code, Slic3r will not add temperature commands. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want." +msgstr "Dieser Code wird beim sequentiellen Drucken zwischen Objekten eingefügt. Standardmäßig werden Extruder- und Betttemperatur mit dem Befehl, der nicht auf die Änderung wartet, zurückgesetzt. Wenn jedoch M104, M109, M140 oder M190 in diesem benutzerdefinierten Code erkannt werden, fügt Slic3r keine Temperaturbefehle hinzu. Beachten Sie, dass Sie Platzhaltervariablen für alle Slic3r-Einstellungen verwenden können, so dass Sie einen \"M109 S[first_layer_temperature]\"-Befehl an beliebiger Stelle platzieren können." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:767 +msgid "This custom code is inserted at every layer change, right after the Z move and before the extruder moves to the first layer point. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z]." +msgstr "Dieser benutzerdefinierte Code wird bei jedem Schichtwechsel eingefügt, direkt nach der Z-Bewegung und bevor der Extruder zum ersten Lagenpunkt fährt. Beachten Sie, dass Sie Platzhaltervariablen für alle Slic3r-Einstellungen sowie [layer_num] und [layer_z] verwenden können." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:49 +msgid "This custom code is inserted at every layer change, right before the Z move. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z]." +msgstr "Dieser benutzerdefinierte Code wird bei jedem Lagenwechsel, unmittelbar vor der Z Bewegung, eingefügt. Beachten Sie, dass Sie Platzhaltervariablen für alle Slic3r-Einstellungen sowie [layer_num] und [layer_z] verwenden können." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1603 +msgid "This custom code is inserted right before every extruder change. Note that you can use placeholder variables for all Slic3r settings as well as [previous_extruder] and [next_extruder]." +msgstr "Dieser Code wird unmittelbar vor jedem Extruderwechsel eingefügt. Beachten Sie, dass Sie Platzhaltervariablen für alle Slic3r-Einstellungen sowie für [previous_extruder] und [next_extruder] verwenden können." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:228 +msgid "This end procedure is inserted at the end of the output file, before the printer end gcode. Note that you can use placeholder variables for all Slic3r settings. If you have multiple extruders, the gcode is processed in extruder order." +msgstr "Diese Endprozedur wird am Ende der Ausgabedatei vor dem DruckerEnde G-Code eingefügt. Beachten Sie, dass Sie Platzhaltervariablen für alle Slic3r-Einstellungen verwenden können. Wenn Sie über mehrere Extruder verfügen, wird der G-Code in der Extruderreihenfolge verarbeitet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:218 +msgid "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings." +msgstr "Dieser G-Code wird am Ende der Ausgabedatei angehängt. Sie können Platzhaltervariablen für alle Slic3r-Einstellungen verwenden." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:827 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:838 +msgid "This experimental setting is used to limit the speed of change in extrusion rate. A value of 1.8 mm³/s² ensures, that a change from the extrusion rate of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds." +msgstr "Diese experimentelle Einstellung beschränkt die Änderungsgeschwindigkeit der Extrusionsmenge. Ein Wert von 1.8 mm³/s² gewährleistet, dass eine Änderung der Extrusionsmenge von 1.8 mm³/s (0.45mm Extrusionsbreite, 0.2mm Extrusionshöhe, Vorschub 20 mm/s) zu 5.4 mm³/s (Vorschub 60 mm/s) mindestens 2 Sekunden dauern wird." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:818 +msgid "This experimental setting is used to set the maximum volumetric speed your extruder supports." +msgstr "Diese experimentelle Einstellung gibt die maximale volumetrische Geschwindigkeit an, die von Ihrem Extruder unterstützt wird." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1657 +msgid "This experimental setting uses G10 and G11 commands to have the firmware handle the retraction. This is only supported in recent Marlin." +msgstr "Diese experimentelle Einstellung benutzt G10 und G11 Befehle, damit die Druckerfirmware den Einzug übernimmt. Dies wird nur von neueren Marlin-Versionen unterstützt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1671 +msgid "This experimental setting uses outputs the E values in cubic millimeters instead of linear millimeters. If your firmware doesn't already know filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] T0' in your start G-code in order to turn volumetric mode on and use the filament diameter associated to the filament selected in Slic3r. This is only supported in recent Marlin." +msgstr "Diese experimentelle Einstellung generiert E-Koordinaten in Kubikmillimetern stat in linearen Millimetern. Wenn die Firmware den Filamentdurchmesser noch nicht kennt, können Sie Befehle wie 'M200 D[filament_diameter_0] T0' in den Start-G-Code eingeben, um den volumetrischen Modus zu aktivieren und den in Slic3r angegebenen Filamentdurchmesser zu benutzen. Dies wird nur von neueren Marlin-Versionen unterstützt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:108 +msgid "This factor affects the amount of plastic for bridging. You can decrease it slightly to pull the extrudates and prevent sagging, although default settings are usually good and you should experiment with cooling (use a fan) before tweaking this." +msgstr "Diese Einstellung beeinflusst den Materialausstoss bei Brücken. Sie können den Wert leicht verringern, um die Extrusionsfäden zu strecken und ein Durchhängen zu vermeiden. Die Standardwerte sind aber normalerweise ausreichend und Sie sollten zuerst mit der Lüftergeschwindigkeit experimentieren, bevor Sie diesen Wert verändern." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:368 +msgid "This factor changes the amount of flow proportionally. You may need to tweak this setting to get nice surface finish and correct single wall widths. Usual values are between 0.9 and 1.1. If you think you need to change this more, check filament diameter and your firmware E steps." +msgstr "Dieser Faktor ändert die Extrusionsmenge proportional. Sie müssen diese Einstellung möglicherweise anpassen, um schöne Oberflächen und korrekte Hüllendicken zu erhalten. Die üblichen Werte bewegen sich zwischen 0,9 und 1,1. Falls Sie grössere Anpassungen eingeben müssen, kontrollieren Sie auch den Filamentdurchmesser und die E-Schritte in Ihrer Firmware." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:98 +msgid "This fan speed is enforced during all bridges and overhangs." +msgstr "Die Lüftergeschwindigkeit, die für Überbrückungen und Überhänge benutzt wird." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:692 +msgid "This feature allows to combine infill and speed up your print by extruding thicker infill layers while preserving thin perimeters, thus accuracy." +msgstr "Diese Einstellung erlaubt es, Infill zu kombinieren und die Druckdauer zu verringern, indem dickere Infill-Schichten gedruckt werden, während gleichzeitig dünne Aussenschichten und damit die Genauigkeit erhalten bleiben." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1281 +msgid "This feature allows to force a solid layer every given number of layers. Zero to disable. You can set this to any value (for example 9999); Slic3r will automatically choose the maximum possible number of layers to combine according to nozzle diameter and layer height." +msgstr "Diese Einstellung erzwingt eine stabile Schicht nach einer vorgegebenen Anzahl von Schichten. Null deaktiviert diese Einstellung. Sie können jeden Wert eingeben (z.B. 9999); Slic3r wird automatisch die grösstmögliche Anzahl von Schichten wählen, die in Abhängigkeit von Düsendurchmesser und Schichthöhe kombiniert werden können." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1323 +msgid "This feature will raise Z gradually while printing a single-walled object in order to remove any visible seam. This option requires a single perimeter, no infill, no top solid layers and no support material. You can still set any number of bottom solid layers as well as skirt/brim loops. It won't work when printing more than an object." +msgstr "Dieses Verfahren erhöht die Z-Position allmählich, während eine einfache Hülle gedruckt wird, um jeglichen sichtbaren Saum zu vermeiden. Diese Option setzt eine einzige Aussenschicht, keinen Infill, keine stabilen Deckenschichten und keine Stützen voraus. Sie können immer noch eine beliebige Anzahl von Bodenschichten sowie Schleifen für Schürzen und Rand einstellen. Die Methode funktioniert nicht, wenn mehr als ein Objekt gedruckt wird." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:663 +msgid "" +"This file contains several objects positioned at multiple heights. Instead of considering them as multiple objects, should I consider\n" +"this file as a single object having multiple parts?\n" +msgstr "Diese Datei enthält mehrere Objekte, die in verschiedenen Höhen positioniert sind. Anstatt sie als mehrere Objekte zu betrachten, soll ich diese Datei als ein einzelnes Objekt mit mehreren Teilen betrachten?\n" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:164 +msgid "This flag enables the automatic cooling logic that adjusts print speed and fan speed according to layer printing time." +msgstr "Diese Einstellung aktiviert the Logik, die die Druckgeschwindigkeit und Lüftergeschwindigkeit automatisch gemäß der Schichtdruckdauer regelt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1066 +msgid "This flag enforces a retraction whenever a Z move is done." +msgstr "Diese Stellung erzwingt einen Einzug bei jeder Z-Bewegung." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1689 +msgid "This flag will move the nozzle while retracting to minimize the possible blob on leaky extruders." +msgstr "Diese Einstellung wird die Düse während dem Einzug bewegen, um mögliche Tropfen bei einem undichten Extruder zu minimieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:343 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:406 +msgid "This is only used in the Slic3r interface as a visual help." +msgstr "Dies wird nur als visuelles Hilfsmittel in der Slic3r-Benutzeroberfläche verwendet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:171 +msgid "This is the acceleration your printer will be reset to after the role-specific acceleration values are used (perimeter/infill). Set zero to prevent resetting acceleration at all." +msgstr "Dies ist der Beschleunigungswert, auf den Ihr Drucker zurückgesetzt wird, nachdem aufgabenspezifische Beschleunigungswerte (Aussenschichten/Infill) verwendet wurden. Setzen Sie dies auf Null, um ein Zurückstellen der Beschleunigungswerte zu deaktivieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:78 +msgid "This is the acceleration your printer will use for bridges. Set zero to disable acceleration control for bridges." +msgstr "Die Beschleunigung, die Ihr Drucker für Brücken verwendet. Setzen Sie dies auf Null, um die Beschleunigungskontrolle bei Brücken zu deaktivieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:574 +msgid "This is the acceleration your printer will use for first layer. Set zero to disable acceleration control for first layer." +msgstr "Die Beschleunigung, die Ihr Drucker für die erste Schicht verwendet. Setzen Sie dies auf Null, um die Beschleunigungskontrolle bei der ersten Schicht zu deaktivieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:682 +msgid "This is the acceleration your printer will use for infill. Set zero to disable acceleration control for infill." +msgstr "Diese Stellung bestimmt die Beschleunigung des Druckers für Infill. Setzen Sie dies auf Null, um die Beschleunigungskontrolle für Infill zu deaktivieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:949 +msgid "This is the acceleration your printer will use for perimeters. A high value like 9000 usually gives good results if your hardware is up to the job. Set zero to disable acceleration control for perimeters." +msgstr "Dies ist die Beschleunigung, die der Drucker für Aussenschichten benutzen wird. Ein hoher Wert wie 9000 ergibt üblicherweise gute Resultate falls Ihre Hardware mithalten kann. Setzen Sie dies auf Null, um die Beschleunigungskontrolle bei Aussenschichten zu deaktivieren." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:895 +msgid "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)" +msgstr "Durchmesser der Extruderdüse (z.B.: 0.5, 0.35 usw.)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:797 +#, no-c-format +msgid "This is the highest printable layer height for this extruder, used to cap the variable layer height and support layer height. Maximum recommended layer height is 75% of the extrusion width to achieve reasonable inter-layer adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter." +msgstr "Dies ist die höchste druckbare Schichthöhe für diesen Extruder, mit der die variable Schichthöhe und Stützschichthöhe abgedeckt wird. Die maximale empfohlene Schichthöhe beträgt 75% der Extrusionsbreite, um eine angemessene Zwischenlagenhaftung zu erreichen. Bei Einstellung auf 0 ist die Lagenhöhe auf 75% des Düsendurchmessers begrenzt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:858 +msgid "This is the lowest printable layer height for this extruder and limits the resolution for variable layer height. Typical values are between 0.05 mm and 0.1 mm." +msgstr "Dies ist die niedrigste druckbare Schichthöhe für diesen Extruder und begrenzt die Auflösung bei variabler Schichthöhe. Typische Werte liegen zwischen 0,05 mm und 0,1 mm." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:990 +msgid "This option sets the number of perimeters to generate for each layer. Note that Slic3r may increase this number automatically when it detects sloping surfaces which benefit from a higher number of perimeters if the Extra Perimeters option is enabled." +msgstr "Diese Stellung bestimmt die Anzahl der Aussenschichten, die für jede Schicht erzeugt werden. Slic3r kann diese Zahl automatisch vergrössern, wenn es schräge Oberflächen erkennt, die sich mit einer höheren Zahl von Aussenschichten besser drucken lassen, wenn die \"Zusätzliche Aussenschichten falls notwendig\" Option aktiviert ist." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:923 +msgid "This option will drop the temperature of the inactive extruders to prevent oozing. It will enable a tall skirt automatically and move extruders outside such skirt when changing temperatures." +msgstr "Mit dieser Option wird die Temperatur der inaktiven Extruder gesenkt, um ein Materialnachsickern zu verhindern. Es aktiviert automatisch eine hohe Schürze und bewegt die Extruder bei Temperaturänderungen ausserhalb dieser Schürze." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:728 +msgid "This option will limit infill to the areas actually needed for supporting ceilings (it will act as internal support material). If enabled, slows down the G-code generation due to the multiple checks involved." +msgstr "Diese Einstellung beschränkt den Infill auf die Bereiche, die tatsächlich für das Stützen von Decken benötigt werden (der Infill dient hier als internes Stützmaterial). Falls aktiviert, kann dies die Erstellung des G-Codes wegen zusätzlichen Kontrollschritten verlangsamen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:721 +msgid "This option will switch the print order of perimeters and infill, making the latter first." +msgstr "Diese Einstellungen kehrt die Druckreihenfolge von Aussenschichten und Infill um, sodass der Infill zuerst gedruckt wird." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:279 +msgid "This separate setting will affect the speed of external perimeters (the visible ones). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above. Set to zero for auto." +msgstr "Diese separate Einstellung wirkt sich auf die Geschwindigkeit der äusseren (sichtbaren) Aussenschichten aus. Als Prozentwert eingegeben (z.B. 80%), wird sie ausgehend von der obigen Geschwindigkeitseinstellung für Aussenschichten berechnet. Für die automatische Berechnung auf Null setzen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1252 +msgid "This separate setting will affect the speed of perimeters having radius <= 6.5mm (usually holes). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above. Set to zero for auto." +msgstr "Diese separate Einstellung wirkt sich auf die Geschwindigkeit von Aussenschichten mit einem Radius <= 6,5 mm (üblicherweise Bohrungen) aus. Als Prozentwert eingegeben (z.B. 80%), wird sie ausgehend von der obigen Geschwindigkeitseinstellung für Aussenschichten berechnet. Für eine automatische Berechnung setzen Sie dies auf Null." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:737 +msgid "This setting applies an additional overlap between infill and perimeters for better bonding. Theoretically this shouldn't be needed, but backlash might cause gaps. If expressed as percentage (example: 15%) it is calculated over perimeter extrusion width." +msgstr "Diese Einstellung fügt eine zusätzliche Überlappung zwischen Aussenschichten und Infill ein, um die Haftung zu verbessern. Theoretisch sollte dies nicht notwendig sein, doch vorhandenes Getriebespiel könnte Lücken erzeugen. Als Prozentwert eingegeben (z.B. 15%) wird sie ausgehend von der Extrusionsbreite für die Aussenschicht ausgerechnet." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:779 +msgid "This setting controls the height (and thus the total number) of the slices/layers. Thinner layers give better accuracy but take more time to print." +msgstr "Diese Einstellung bestimmt die Höhe (und damit die Gesamtanzahl) der Scheiben/Schichten. Dünnere Schichten ergeben eine bessere Genauigkeit, benötigen aber mehr Zeit zum drucken." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:788 +msgid "This setting represents the maximum speed of your fan." +msgstr "Diese Einstellung bestimmt die maximale Geschwindigkeit Ihres Lüfters." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:849 +msgid "This setting represents the minimum PWM your fan needs to work." +msgstr "Diese Einstellung gibt den minimalen PWM-Wert an, den Ihr Lüfter für den Betrieb benötigt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1358 +msgid "This start procedure is inserted at the beginning, after any printer start gcode. This is used to override settings for a specific filament. If Slic3r detects M104, M109, M140 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want. If you have multiple extruders, the gcode is processed in extruder order." +msgstr "Dieser Startvorgang wird am Anfang nach dem G-Code für den Druckerstart eingefügt. Damit können Einstellungen für ein bestimmtes Filament übersteuert werden. Falls Slic3r M104, M109, M140 oder M190 in Ihren benutzerdefinierten Codes erkennt, werden solche Befehle nicht automatisch vorangestellt, sodass Sie die Reihenfolge der Heizbefehle und anderer benutzerdefinierter Aktionen anpassen können. Beachten Sie, dass Sie Platzhaltervariablen für alle Slic3r-Einstellungen verwenden können, sodass Sie einen \"M109 S[first_layer_temperature]\"-Befehl an beliebiger Stelle platzieren können. Falls Sie mehrere Extruder haben, wird der G-Code in der Reihenfolge der Extruder ausgeführt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1343 +msgid "This start procedure is inserted at the beginning, after bed has reached the target temperature and extruder just started heating, and before extruder has finished heating. If Slic3r detects M104 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want." +msgstr "Dieser Startvorgang wird am Anfang eingefügt, nachdem das Heizbett die Zieltemperatur erreicht hat und der Extruder gerade erst mit dem Aufheizen begonnen hat, und bevor der Extruder fertig aufgeheizt ist. Falls Slic3r M104 oder M190 in Ihren benutzerdefinierten Codes erkennt, werden solche Befehle nicht automatisch vorangestellt, sodass Sie die Reihenfolge der Heizbefehle und anderer benutzerdefinierter Aktionen anpassen können. Beachten Sie, dass Sie Platzhaltervariablen für alle Slic3r-Einstellungen verwenden können, sodass Sie einen \"M109 S[first_layer_temperature]\"-Befehl an beliebiger Stelle platzieren können." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1743 +msgid "This value will be added (or subtracted) from all the Z coordinates in the output G-code. It is used to compensate for bad Z endstop position: for example, if your endstop zero actually leaves the nozzle 0.3mm far from the print bed, set this to -0.3 (or fix your endstop)." +msgstr "Dieser Wert wird zu allen Z-Koordinaten im ausgegebenen G-Code hinzuaddiert oder davon abgezogen. Damit kann eine fehlerhafte Z-Endanschlagsposition kompensiert werden: wenn z.B. bei Ihrem Nullwert die Druckdüse sich beim Endanschlag 0.3mm über der Druckplatte befindet, setzen Sie diesen Wert auf -0.3 (oder stellen Sie Ihren Endanschlag neu ein)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1590 +msgid "Threads" +msgstr "Threads" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1591 +msgid "Threads are used to parallelize long-running tasks. Optimal threads number is slightly above the number of available cores/processors." +msgstr "Threads werden benutzt, um mehrere zeitaufwendige Berechnungen gleichzeitig auszuführen. Die optimale Anzahl beträgt etwas mehr als die Anzahl der verfügbaren Kerne/Prozessoren." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:338 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:72 +msgid "Tool" +msgstr "Werkzeug" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1144 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1602 +msgid "Tool change G-code" +msgstr "G-Code für Werkzeugwechsel" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1638 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 +msgid "Top" +msgstr "Decke" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:187 +msgid "top solid infill" +msgstr "Oberes stabiles Infill" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1613 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1624 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:143 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:85 +msgid "Top solid infill" +msgstr "Oberes stabiles Infill" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1642 +msgid "Top solid layers" +msgstr "Obere stabile Schichten" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 +msgid "Top View" +msgstr "Ansicht von oben" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:246 +msgid "Top/bottom fill pattern" +msgstr "Boden- und Deckenfüllmuster" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1647 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:95 +msgid "Travel" +msgstr "Eilgang" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 +msgid "Uniformly…" +msgstr "Gleichmässig…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:97 +msgid "Unretractions" +msgstr "Wiedereinzüge" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1492 +msgid "Unsaved Changes" +msgstr "Nicht abgespeicherte Änderungen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:750 +msgid "Unsaved Presets" +msgstr "Nicht abgespeicherte Voreinstellungen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:989 +msgid "USB/Serial connection" +msgstr "USB/Serielle Verbindung" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1194 +msgid "USB/serial port for printer connection." +msgstr "USB-/serielle Schnittstelle für den Druckeranschluss." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1656 +msgid "Use firmware retraction" +msgstr "Firmware-Einzug aktivieren" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:75 +msgid "Use legacy OpenGL 1.1 rendering" +msgstr "Älteres OpenGL 1.1-Rendering verwenden" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1663 +msgid "Use relative E distances" +msgstr "Relative Abstände für Extrusion benutzen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:361 +msgid "Use this option to set the axis letter associated to your printer's extruder (usually E but some printers use A)." +msgstr "Verwenden Sie diese Einstellung, um den Buchstaben der Achse anzugeben, die mit Ihrem Extruder verknüpft ist (normalerweise E, aber bei manchen Druckern ist dies A)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1400 +msgid "Use this setting to rotate the support material pattern on the horizontal plane." +msgstr "Verwenden Sie diese Einstellung, um das Muster für das Stützmaterial auf der horizontalen Ebene zu drehen." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1670 +msgid "Use volumetric E" +msgstr "Volumetrisches E benutzen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:449 +msgid "Used Filament (g)" +msgstr "Verbrauchtes Filament (g)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:447 +msgid "Used Filament (m)" +msgstr "Verbrauchtes Filament (m)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:448 +msgid "Used Filament (mm³)" +msgstr "Verbrauchtes Filament (mm³)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:644 +msgid "Verbose G-code" +msgstr "Ausführlicher G-Code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 +msgid "Version " +msgstr "Version " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:318 +msgid "Vertical shells" +msgstr "Vertikale Konturhüllen" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:65 +msgid "View" +msgstr "Ansicht" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:409 +msgid "Volume" +msgstr "Volumen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "Volumetric" +msgstr "Volumetrisch" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:500 +msgid "Warning" +msgstr "Warnung" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:131 +msgid "What do you want to print today? ™" +msgstr "Was möchten Sie heute drucken? ™" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:69 +msgid "When checked, the print and filament presets are shown in the preset editor even if they are marked as incompatible with the active printer" +msgstr "Falls angekreuzt, werden Voreinstellungen für Druck und Filament im Voreinstellungseditor auch dann angezeigt, wenn sie als inkompatibel zum aktiven Drucker gekennzeichnet wurden" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:219 +msgid "when printing " +msgstr "während dem Druck " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:136 +msgid "When printing multi-material objects, this settings will make slic3r to clip the overlapping object parts one by the other (2nd part will be clipped by the 1st, 3rd part will be clipped by the 1st and 2nd etc)." +msgstr "Wenn Multi-Material-Objekte gedruckt werden, wird Slic3r mit diesen Einstellungen einen überlappenden Teil des Objekts durch den anderen einschränken (zweiter Teil wird durch den ersten Teil eingeschränkt, dritter Teil wird durch den ersten und zweiten eingeschränkt usw.)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:155 +msgid "When printing multiple objects or copies, this feature will complete each object before moving onto next one (and starting it from its bottom layer). This feature is useful to avoid the risk of ruined prints. Slic3r should warn and prevent you from extruder collisions, but beware." +msgstr "Wenn mehrere Objekte oder Kopien gedruckt werden, wird bei dieser Einstellung jedes Objekt vollständig gedruckt, bevor das nächste (angefangen mit der Bodenschicht) begonnen wird. Diese Einstellung ist nützlich, um Fehldrucke zu vermeiden. Slic3r sollte vor Extruderkollisionen warnen und diese verhindern, aber seien Sie trotzdem aufmerksam." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:605 +msgid "When printing with very low layer heights, you might still want to print a thicker bottom layer to improve adhesion and tolerance for non perfect build plates. This can be expressed as an absolute value or as a percentage (for example: 150%) over the default layer height." +msgstr "Wenn mit sehr kleinen Schichthöhen gedruckt wird, möchten Sie vielleicht trotzdem eine dickere Bodenschicht drucken, um die Haftung sowie die Toleranz bei nicht perfekt ebenen Druckplatten zu verbessern. Dieser Wert kann als Absolutwert oder als Prozentwert (z.B. 150%) der Standardschichthöhe angegeben werden." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1082 +msgid "When retraction is triggered before changing tool, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder)." +msgstr "Wenn der Einzug vor dem Werkzeugwechsel ausgelöst wird, wird das Filament um diese Länge eingezogen. (Die Länge wird am unverarbeiteten Filament vor dem Extruder gemessen)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1073 +msgid "When retraction is triggered, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder)." +msgstr "Wenn der Einzug ausgelöst wird, wird das Filament um diese Länge eingezogen. (Die Länge wird am unverarbeiteten Filament vor dem Extruder gemessen)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:808 +msgid "When setting other speed settings to 0 Slic3r will autocalculate the optimal speed in order to keep constant extruder pressure. This experimental setting is used to set the highest print speed you want to allow." +msgstr "Wenn andere Geschwindigkeitseinstellungen auf Null gesetzt wurden, wird Slic3r die optimale Geschwindigkeit automatisch berechnen, um den Extruderdruck konstant zu halten. Diese experimentelle Einstellung erlaubt Ihnen, die höchste zulässige Druckgeschwindigkeit anzugeben." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1127 +msgid "When the retraction is compensated after changing tool, the extruder will push this additional amount of filament." +msgstr "Wenn der Einzug nach dem Werkzeugwechsel kompensiert wurde, wird der Extruder diese zusätzliche Menge an Filament ausgeben." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1119 +msgid "When the retraction is compensated after the travel move, the extruder will push this additional amount of filament. This setting is rarely needed." +msgstr "Wenn der Einzug nach der Zwischenbewegung kompensiert wurde, wird der Extruder diese zusätzliche Menge an Filament ausgeben. Diese Einstellung wird selten benötigt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1716 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:70 +msgid "Width" +msgstr "Breite" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:334 +msgid "Width (mm)" +msgstr "Breite (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1717 +msgid "Width of a wipe tower" +msgstr "Breite der Reinigungssäule" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:41 +#, c-format +msgid "will always run at %d%% " +msgstr "wird immer mit %d%% laufen " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:50 +msgid "will be turned off." +msgstr "wird abgeschaltet." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:442 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:149 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:91 +msgid "Wipe tower" +msgstr "Reinigungssäule" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:564 #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:585 #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:602 msgid "Wipe Tower" -msgstr "" +msgstr "Reinigungssäule" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:581 -msgid "" -"The Wipe Tower currently supports the non-soluble supports only\n" -"if they are printed with the current extruder without triggering a tool " -"change.\n" -"(both support_material_extruder and support_material_interface_extruder need " -"to be set to 0).\n" -"\n" -"Shall I adjust those settings in order to enable the Wipe Tower?" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1688 +msgid "Wipe while retracting" +msgstr "Während Einzug reinigen" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:599 -msgid "" -"For the Wipe Tower to work with the soluble supports, the support layers\n" -"need to be synchronized with the object layers.\n" -"\n" -"Shall I synchronize support layers in order to enable the Wipe Tower?" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1058 +msgid "With bowden extruders, it may be wise to do some amount of quick retract before doing the wipe movement." +msgstr "Bei Bowden-Extrudern kann es ratsam sein, vor der Reinigungsbewegung einen kurzen Einzug auszuführen." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:617 -msgid "" -"Supports work better, if the following feature is enabled:\n" -"- Detect bridging perimeters\n" -"\n" -"Shall I adjust those settings for supports?" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1564 +msgid "With sheath around the support" +msgstr "Mit Umhüllung der Stützen" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:620 -msgid "Support Generator" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1703 +msgid "X coordinate of the left front corner of a wipe tower" +msgstr "X-Koordinate der linken vorderen Ecke der Reinigungssäule" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 -msgid "The " -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1386 +msgid "XY separation between an object and its support" +msgstr "XY-Abstand zwischen einem Objekt und seinen Stützen" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 -#, no-c-format -msgid "" -" infill pattern is not supposed to work at 100% density.\n" -"\n" -"Shall I switch to rectilinear fill pattern?" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1388 +msgid "XY separation between an object and its support. If expressed as percentage (for example 50%), it will be calculated over external perimeter width." +msgstr "XY-Abstand zwischen einem Objekt und seinen Stützen. Falls in Prozenten angegeben (z.B. 50%), wird der Abstand von der Breite der Aussenschicht ausgehend berechnet." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:786 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:787 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:368 -msgid "Filament" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1732 +msgid "XY Size Compensation" +msgstr "XY-Grössenausgleich" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:794 -msgid "Temperature " -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1710 +msgid "Y coordinate of the left front corner of a wipe tower" +msgstr "Y-Koordinate der linken vorderen Ecke der Reinigungssäule" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:795 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1234 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:307 -msgid "Extruder" -msgstr "Extruder" +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1970 +msgid "Yes" +msgstr "Ja" -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:800 -msgid "Bed" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:885 +msgid "You can put here your personal notes. This text will be added to the G-code header comments." +msgstr "Sie können hier Ihre persönlichen Notizen eingeben. Der Text wird dem Header vom G-Code hinzugefügt." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:805 -msgid "Cooling" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:413 +msgid "You can put your notes regarding the filament here." +msgstr "Sie können Ihre Notizen zum Filament hier eingeben." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:806 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:922 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1695 -msgid "Enable" -msgstr "Aktivieren" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1015 +msgid "You can put your notes regarding the printer here." +msgstr "Sie können Ihre Bemerkungen zum Drucker hier eingeben." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:817 -msgid "Fan settings" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:181 +msgid "You can set this to a positive value to disable fan at all during the first layers, so that it does not make adhesion worse." +msgstr "Sie können einen positiven Wert eingeben, um den Lüfter vollständig für die ersten Schichten auszuschalten, damit er die Haftung nicht beeinträchtigt." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:818 -msgid "Fan speed" -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:931 +msgid "You can use all configuration options as variables inside this template. For example: [layer_height], [fill_density] etc. You can also use [timestamp], [year], [month], [day], [hour], [minute], [second], [version], [input_filename], [input_filename_base]." +msgstr "Sie können alle Konfigurationsoptionen als Variablen in dieser Vorlage benutzen. Zum Beispiel: [layer_height], [fill_density] usw. Sie können auch [timestamp], [year], [month], [day], [hour], [minute], [second], [version], [input_filename], und [input_filename_base] benutzen." -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:826 -msgid "Cooling thresholds" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:832 -msgid "Filament properties" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:836 -msgid "Print speed override" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:846 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119 -msgid "Custom G-code" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:847 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1120 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1342 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1357 -msgid "Start G-code" -msgstr "Start G-code" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:853 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1126 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:217 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:227 -msgid "End G-code" -msgstr "Ende G-code" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:937 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:11 -msgid "General" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:938 -msgid "Size and coordinates" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:940 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:34 -msgid "Bed shape" -msgstr "Druckbrettprofil" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:942 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1637 -msgid " Set " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:962 -msgid "Capabilities" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:967 -msgid "Number of extruders of the printer." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:989 -msgid "USB/Serial connection" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:990 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1193 -msgid "Serial port" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:995 -msgid "Rescan serial ports" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1004 -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1072 -msgid "Test" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 -msgid "Connection to printer works correctly." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 -msgid "Success!" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1020 -msgid "Connection failed." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1032 -msgid "OctoPrint upload" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1035 -msgid " Browse " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1110 -msgid "Firmware" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1132 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:48 -msgid "Before layer change G-code" -msgstr "Vorschichtwechsel G-Code" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1138 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:766 -msgid "After layer change G-code" -msgstr "Schicht ende G-Code" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1144 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1602 -msgid "Tool change G-code" -msgstr "Werkzeugwechsel G-code" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1150 -msgid "Between objects G-code (for sequential printing)" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1187 -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:400 -#, c-format -msgid "Extruder %d" -msgstr "Extruder %d" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1194 -msgid "Layer height limits" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1199 -msgid "Position (for multi-extruder printers)" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1202 -msgid "Retraction" -msgstr "Einziehen" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1205 -msgid "Only lift Z" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1218 -msgid "" -"Retraction when tool is disabled (advanced settings for multi-extruder " -"setups)" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1222 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:150 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2125 -msgid "Preview" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1312 -msgid "" -"The Wipe option is not available when using the Firmware Retraction mode.\n" -"\n" -"Shall I disable it in order to enable Firmware Retraction?" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1314 -msgid "Firmware Retraction" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 -msgid "Default " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 -msgid " preset" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1470 -msgid " preset\n" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 -msgid "" -"\n" -"\n" -"is not compatible with printer\n" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 -msgid "" -"\n" -"\n" -"and it has the following unsaved changes:" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1489 -msgid "" -"\n" -"\n" -"has the following unsaved changes:" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1491 -msgid "" -"\n" -"\n" -"Discard changes and continue anyway?" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1492 -msgid "Unsaved Changes" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1560 -msgid "The supplied name is empty. It can't be saved." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 -msgid "remove" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 -msgid "delete" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 -msgid "Are you sure you want to " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 -msgid " the selected preset?" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 -msgid "Remove" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:178 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:196 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 -msgid "Delete" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1583 -msgid " Preset" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1636 -msgid "All" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1667 -msgid "Select the printers this profile is compatible with." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 -msgid "Save " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 -msgid " as:" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1785 -msgid "" -"The supplied name is not valid; the following characters are not allowed:" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1788 -msgid "The supplied name is not available." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:182 -msgid "Print Settings" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:202 -msgid "Filament Settings" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:228 -msgid "Printer Settings" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:248 -msgid "Save preset" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp:42 -msgid "default" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:26 -#, c-format -msgid "" -"If estimated layer time is below ~%ds, fan will run at %d%% and print speed " -"will be reduced so that no less than %ds are spent on that layer (however, " -"speed will never be reduced below %dmm/s)." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:30 -#, c-format -msgid "" -"\n" -"If estimated layer time is greater, but still below ~%ds, fan will run at a " -"proportionally decreasing speed between %d%% and %d%%." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:34 -msgid "" -"\n" -"During the other layers, fan " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:36 -msgid "Fan " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:41 -#, c-format -msgid "will always run at %d%% " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:44 -#, c-format -msgid "except for the first %d layers" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:48 -msgid "except for the first layer" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:50 -msgid "will be turned off." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:151 -msgid "external perimeters" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:160 -msgid "perimeters" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:169 -msgid "infill" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:179 -msgid "solid infill" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:187 -msgid "top solid infill" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:198 -msgid "support" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:208 -msgid "support interface" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 -msgid "First layer volumetric" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 -msgid "Bridging volumetric" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 -msgid "Volumetric" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:215 -msgid " flow rate is maximized " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:218 -msgid "by the print profile maximum" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:219 -msgid "when printing " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:220 -msgid " with a volumetric rate " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:224 -#, c-format -msgid "%3.2f mm³/s" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:226 -#, c-format -msgid " at filament speed %3.2f mm/s." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:245 -msgid "" -"Recommended object thin wall thickness: Not available due to invalid layer " -"height." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:262 -#, c-format -msgid "Recommended object thin wall thickness for layer height %.2f and " -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:269 -#, c-format -msgid "%d lines: %.2lf mm" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp:17 -msgid "Preferences" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:27 -msgid "Remember output directory" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:29 -msgid "" -"If this is enabled, Slic3r will prompt the last output directory instead of " -"the one containing the input files." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:35 -msgid "Auto-center parts" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:37 -msgid "" -"If this is enabled, Slic3r will auto-center objects around the print bed " -"center." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:43 -msgid "Background processing" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:45 -msgid "" -"If this is enabled, Slic3r will pre-process objects as soon as they're " -"loaded in order to save time when exporting G-code." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:51 -msgid "Disable USB/serial connection" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:53 -msgid "" -"Disable communication with the printer over a serial / USB cable. This " -"simplifies the user interface in case the printer is never attached to the " -"computer." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:59 -msgid "Suppress \" - default - \" presets" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:61 -msgid "" -"Suppress \" - default - \" presets in the Print / Filament / Printer " -"selections once there are any other valid presets available." -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:67 -msgid "Show incompatible print and filament presets" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:69 -msgid "" -"When checked, the print and filament presets are shown in the preset editor " -"even if they are marked as incompatible with the active printer" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:75 -msgid "Use legacy OpenGL 1.1 rendering" -msgstr "" - -#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:77 -msgid "" -"If you have rendering issues caused by a buggy OpenGL 2.0 driver, you may " -"try to check this checkbox. This will disable the layer height editing and " -"anti aliasing, so it is likely better to upgrade your graphics driver." -msgstr "" +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 +msgid "You have unsaved changes " +msgstr "Sie haben nicht gespeicherte Änderungen " #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:101 msgid "You need to restart Slic3r to make the changes effective." -msgstr "" +msgstr "Sie müssen Slic3r neu starten, damit die Änderungen wirksam werden." -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:26 -msgid "Avoid crossing perimeters" -msgstr "Vermeide Umfangüberquerungen" +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 +msgid "Your file was repaired." +msgstr "Ihre Datei wurde repariert." -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:27 -msgid "" -"Optimize travel moves in order to minimize the crossing of perimeters. This " -"is mostly useful with Bowden extruders which suffer from oozing. This " -"feature slows down both the print and the G-code generation." -msgstr "" -"Optimire bewegungen um Umfangüberquerungen zu vermeiden. Das ist " -"hauptsächlich nützlich mit sickernden Bowden Extrudern. Dass verlangsamt " -"das Drucken und auch die G-Codegenerierung." +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:744 +msgid "Your object appears to be too large, so it was automatically scaled down to fit your print bed." +msgstr "Ihr Objekt scheint zu gross zu sein. Es wurde deshalb automatisch verkleinert, um auf Ihre Druckplatte zu passen." -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:38 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1572 -msgid "Other layers" -msgstr "Andere Schichten" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:39 -msgid "" -"Bed temperature for layers after the first one. Set this to zero to disable " -"bed temperature control commands in the output." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:42 -msgid "Bed temperature" -msgstr "Druckbrettemperatur" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:49 -msgid "" -"This custom code is inserted at every layer change, right before the Z move. " -"Note that you can use placeholder variables for all Slic3r settings as well " -"as [layer_num] and [layer_z]." -msgstr "" -"Dieser G-Code wird bei jedem Schichtwechsel gerade vor der Z Bewegung " -"eingefügt. Man kann Platzhalter für alle Slic3r Einstellugnen, sowie auch " -"[layer_num] und [layer_z] benutzen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:59 -msgid "Between objects G-code" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:60 -msgid "" -"This code is inserted between objects when using sequential printing. By " -"default extruder and bed temperature are reset using non-wait command; " -"however if M104, M109, M140 or M190 are detected in this custom code, Slic3r " -"will not add temperature commands. Note that you can use placeholder " -"variables for all Slic3r settings, so you can put a \"M109 " -"S[first_layer_temperature]\" command wherever you want." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:68 -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 -msgid "Bottom" -msgstr "Boden" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:69 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:239 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:290 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:298 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:604 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:762 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:778 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:941 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:989 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1152 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1583 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1639 -msgid "Layers and Perimeters" -msgstr "Schichten und Umfänge" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:70 -msgid "Number of solid layers to generate on bottom surfaces." -msgstr "Zahl der dichten Schichten die an den Unterseiten zu generieren ist." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:72 -msgid "Bottom solid layers" -msgstr "Dichte Bodenschichten" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:77 -msgid "Bridge" -msgstr "Brücke" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:78 -msgid "" -"This is the acceleration your printer will use for bridges. Set zero to " -"disable acceleration control for bridges." -msgstr "" -"Dies ist die Beschleunigung die der Drucker bei Brücken einsätzen wird. Auf " -"Null stellen um Brückenbeschleunigungskontrolle zu deaktivieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:80 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:174 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:576 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:684 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:952 -msgid "mm/s²" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:86 -msgid "Bridging angle" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:88 -msgid "" -"Bridging angle override. If left to zero, the bridging angle will be " -"calculated automatically. Otherwise the provided angle will be used for all " -"bridges. Use 180° for zero angle." -msgstr "" +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1742 +msgid "Z offset" +msgstr "Z-Abstand" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:91 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:492 @@ -1150,3518 +3506,4 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1401 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1557 msgid "°" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:97 -msgid "Bridges fan speed" -msgstr "Brückenventilatorgeschwindigkeit" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:98 -msgid "This fan speed is enforced during all bridges and overhangs." -msgstr "" -"Diese Ventilatorgeschwindigkeit wird bei Brückungen und Überhängen benutzt." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:99 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:504 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:789 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:850 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1060 -msgid "%" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:106 -msgid "Bridge flow ratio" -msgstr "Brückenflussverhältnis" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:108 -msgid "" -"This factor affects the amount of plastic for bridging. You can decrease it " -"slightly to pull the extrudates and prevent sagging, although default " -"settings are usually good and you should experiment with cooling (use a fan) " -"before tweaking this." -msgstr "" -"Dieser faktor ändert die Plastikmenge bei Brücken. Man kann ihn verringern " -"um die Extrudate ein Bisschen zu ziehen um Senkung zu vermeiden, obwohl die " -"standard Einstellungen normalerweise gut sind, und man vor Änderung dieser " -"stellung mit Kühlung (d. h. Ventilator) experimentieren sollte." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:117 -msgid "Bridges" -msgstr "Brücken" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:119 -msgid "Speed for printing bridges." -msgstr "Brückendruckgeschwindigkeit" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:120 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:638 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:749 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:811 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:868 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:981 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1137 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1146 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1536 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1649 -msgid "mm/s" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:127 -msgid "Brim width" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:128 -msgid "" -"Horizontal width of the brim that will be printed around each object on the " -"first layer." -msgstr "" -"Horizontalbreite der krempe die um jedes Objekt bei der Bodenschicht " -"gedruckt wird." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:135 -msgid "Clip multi-part objects" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:136 -msgid "" -"When printing multi-material objects, this settings will make slic3r to clip " -"the overlapping object parts one by the other (2nd part will be clipped by " -"the 1st, 3rd part will be clipped by the 1st and 2nd etc)." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:147 -msgid "Compatible printers condition" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:148 -msgid "" -"A boolean expression using the configuration values of an active printer " -"profile. If this expression evaluates to true, this profile is considered " -"compatible with the active printer profile." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:154 -msgid "Complete individual objects" -msgstr "Kompatibele Einzelobjekte." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:155 -msgid "" -"When printing multiple objects or copies, this feature will complete each " -"object before moving onto next one (and starting it from its bottom layer). " -"This feature is useful to avoid the risk of ruined prints. Slic3r should " -"warn and prevent you from extruder collisions, but beware." -msgstr "" -"Wenn mehrere Objekte oder Kopien gedruckt werden wird bei dieser Stellung " -"jedes einzelne Objekt komplett gedruckt vorde, das drucken des Nächsten (von " -"der Bodenschicht) angefängt.\n" -" Diese stellung kann das Risko von völlig ruinierten Druckversuchen " -"verringern. Slic3r sollte von Extruder aufprall vorwarnen und vermeiden, " -"aber man sollte Acht nehmen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:163 -msgid "Enable auto cooling" -msgstr "Automatische Kühlung Aktivieren" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:164 -msgid "" -"This flag enables the automatic cooling logic that adjusts print speed and " -"fan speed according to layer printing time." -msgstr "" -"Diese Einstellung aktiviert the Logik die die Druckgeschwindigkeit und " -"Ventilatorgeschwindigkeit automatisch gemäß der Schichtdruckzeit regelt." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:171 -msgid "" -"This is the acceleration your printer will be reset to after the role-" -"specific acceleration values are used (perimeter/infill). Set zero to " -"prevent resetting acceleration at all." -msgstr "" -"Nach der Zwecksbeschleunigung für Rand oder Infill wird der Drucker auf " -"diese Beschleunigung zurückgestelt. Auf Null stellen um the " -"Beschleunigungszurückstellung auszuschalten." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:180 -msgid "Disable fan for the first" -msgstr "Ventilator für die Ersten" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:181 -msgid "" -"You can set this to a positive value to disable fan at all during the first " -"layers, so that it does not make adhesion worse." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:183 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:694 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1033 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1224 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1285 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1437 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1482 -msgid "layers" -msgstr "Schichten ausschalten" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:190 -msgid "Don't support bridges" -msgstr "Brücken nicht unterstützen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:192 -msgid "" -"Experimental option for preventing support material from being generated " -"under bridged areas." -msgstr "" -"Experimentalstellung dass kein Unterstützungsmaterial unter Brücken " -"generiert wird." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:198 -msgid "Distance between copies" -msgstr "Distanz Zwischen Kopien" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:199 -msgid "Distance used for the auto-arrange feature of the plater." -msgstr "Distanz für die auto-arrange Funktion des Platers." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:207 -msgid "Elephant foot compensation" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:209 -msgid "" -"The first layer will be shrunk in the XY plane by the configured value to " -"compensate for the 1st layer squish aka an Elephant Foot effect." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:218 -msgid "" -"This end procedure is inserted at the end of the output file. Note that you " -"can use placeholder variables for all Slic3r settings." -msgstr "" -"Dieser G-code wird dem Ende der Outputdatei angehängt. Man kann in diesem " -"Code Platzhalter anwenden." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:228 -msgid "" -"This end procedure is inserted at the end of the output file, before the " -"printer end gcode. Note that you can use placeholder variables for all " -"Slic3r settings. If you have multiple extruders, the gcode is processed in " -"extruder order." -msgstr "" -"Dieser G-code wird dem Ende der Outputdatei angehängt. Man kann in diesem " -"Code Platzhalter anwenden. Bei mehrfachen Extrudern wird der Code in " -"Extruderreinfolge angehängt." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:238 -msgid "Ensure vertical shell thickness" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:240 -msgid "" -"Add solid infill near sloping surfaces to guarantee the vertical shell " -"thickness (top+bottom solid layers)." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:246 -msgid "Top/bottom fill pattern" -msgstr "Boden- und Deckenfüllmuster" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:248 -msgid "" -"Fill pattern for top/bottom infill. This only affects the external visible " -"layer, and not its adjacent solid shells." -msgstr "" -"Füllmuster für die Boden- und Deckenschicht. Diese Einstellung betrifft nur " -"the sichtbaren Schichten, und nicht den Rände nebenan." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:267 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:277 -msgid "External perimeters" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:268 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:377 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:592 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:710 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:967 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1292 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1454 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1614 -msgid "Extrusion Width" -msgstr "Extrusionbreite" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:269 -msgid "" -"Set this to a non-zero value to set a manual extrusion width for external " -"perimeters. If left zero, default extrusion width will be used if set, " -"otherwise 1.125 x nozzle diameter will be used. If expressed as percentage " -"(for example 200%), it will be computed over layer height." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:272 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:597 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:715 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:972 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1296 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1458 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1619 -msgid "mm or % (leave 0 for default)" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:279 -msgid "" -"This separate setting will affect the speed of external perimeters (the " -"visible ones). If expressed as percentage (for example: 80%) it will be " -"calculated on the perimeters speed setting above. Set to zero for auto." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:282 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:619 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1255 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1306 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1501 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1631 -msgid "mm/s or %" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:289 -msgid "External perimeters first" -msgstr "Außenumfänge erst Drucken" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:291 -msgid "" -"Print contour perimeters from the outermost one to the innermost one instead " -"of the default inverse order." -msgstr "" -"Drucke die Umfänge von Außen nach innen, stat der umgekehrten Standardfolge." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:297 -msgid "Extra perimeters if needed" -msgstr "Extra Umfänge wenn Notwendig" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:299 -#, no-c-format -msgid "" -"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r " -"keeps adding perimeters, until more than 70% of the loop immediately above " -"is supported." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:309 -msgid "" -"The extruder to use (unless more specific extruder settings are specified). " -"This value overrides perimeter and infill extruders, but not the support " -"extruders." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:320 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:69 -msgid "Height" -msgstr "Höhe" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:321 -#, fuzzy -msgid "" -"Set this to the vertical distance between your nozzle tip and (usually) the " -"X carriage rods. In other words, this is the height of the clearance " -"cylinder around your extruder, and it represents the maximum depth the " -"extruder can peek before colliding with other printed objects." -msgstr "" -"#-#-#-#-# Slic3rPE_de_DE.po #-#-#-#-#\n" -"#-#-#-#-# de_DE.po (Slic3r) #-#-#-#-#\n" -"Stelle diese zahl auf the Vertikaldistanz zwischen der Düsenspitze und " -"(typischerweise) den X-Schlittenstangen. In anderen Worten, die Höhe des " -"Umfangszylinders um den Extruder, und sie repräsentiert die maximaltiefe die " -"der Extruder ergründen kann ohne auf gedruckte Objecte aufzuprallen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:331 -msgid "Radius" -msgstr "Radius" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:332 -msgid "" -"Set this to the clearance radius around your extruder. If the extruder is " -"not centered, choose the largest value for safety. This setting is used to " -"check for collisions and to display the graphical preview in the plater." -msgstr "" -"Stelle diese Zahl auf den Umfangsradius um den Extruder. Wenn der Extruder " -"nicht Zentriet ist, stelle die Zahl auf den Maximalradius. Diese stellung " -"wird benutzt um nach Aufprall zu prüfen, und wenn der Gravphical Preview im " -"Plater gezeigt wird." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:342 -msgid "Extruder Color" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:343 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:406 -msgid "This is only used in the Slic3r interface as a visual help." -msgstr "Nur im Slic3r Interface benutzt." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:350 -msgid "Extruder offset" -msgstr "Extruder Verschiebung" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:351 -msgid "" -"If your firmware doesn't handle the extruder displacement you need the G-" -"code to take it into account. This option lets you specify the displacement " -"of each extruder with respect to the first one. It expects positive " -"coordinates (they will be subtracted from the XY coordinate)." -msgstr "" -"Wenn die Firmware die Extruderverschiebung nicht ausgleicht muss das im G-" -"code passieren. Diese stellung berschreibt die Verschiebung der Extruder " -"relativ dem Ersten. Sie wird im G-code von den XY-Koordinaten abegzogen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:360 -msgid "Extrusion axis" -msgstr "Extrusionsachse" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:361 -msgid "" -"Use this option to set the axis letter associated to your printer's extruder " -"(usually E but some printers use A)." -msgstr "" -"Diese stellung ist der Buchstabe die bei dem Drucker die Extrusionsachse " -"ist. (Typisch E doch bei manchen Drukern A.)" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:367 -msgid "Extrusion multiplier" -msgstr "Extrusionfaktor" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:368 -msgid "" -"This factor changes the amount of flow proportionally. You may need to tweak " -"this setting to get nice surface finish and correct single wall widths. " -"Usual values are between 0.9 and 1.1. If you think you need to change this " -"more, check filament diameter and your firmware E steps." -msgstr "" -"Dieser faktor ändert proportional die Extrusionsmenge. Es kann notwending " -"sein diese Stellung zu optimieren um gute Obeflächen zu drucken order " -"Wandbreiten zu korigieren. Typische stellungen sind zwischen 0,9 und 1,1. " -"Wenn grösere oder kleinere werte notwendig scheinen, erst den " -"Fialmentdurchmesser und the Extrusionsschritte in der firmware nachchecken." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:376 -msgid "Default extrusion width" -msgstr "Standardextrusionsbreite" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:378 -msgid "" -"Set this to a non-zero value to allow a manual extrusion width. If left to " -"zero, Slic3r derives extrusion widths from the nozzle diameter (see the " -"tooltips for perimeter extrusion width, infill extrusion width etc). If " -"expressed as percentage (for example: 230%), it will be computed over layer " -"height." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:382 -msgid "mm or % (leave 0 for auto)" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:387 -msgid "Keep fan always on" -msgstr "Ventilator ständig laufen lassen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:388 -msgid "" -"If this is enabled, fan will never be disabled and will be kept running at " -"least at its minimum speed. Useful for PLA, harmful for ABS." -msgstr "" -"Wenn diese Stellung Aktiviert ist, wird der Ventilator nicht ausgeschaltet, " -"und wird mindestens bei seiner Mindestgeschwindigkeit laufen. Nützlich für " -"PLA, shädlich für ABS." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:394 -msgid "Enable fan if layer print time is below" -msgstr "Ventilator anschalten wenn die Schichtdruckzeit weniger als ___ ist" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:395 -msgid "" -"If layer print time is estimated below this number of seconds, fan will be " -"enabled and its speed will be calculated by interpolating the minimum and " -"maximum speeds." -msgstr "" -"Wenn die Schichtendruckzeit kürzer als diese Zahl von Sekunden eingeschätzt " -"ist wird der Vetilator angschaltet und the Ventilatorgeschwindigkeit wird " -"durch Interpolierung der Maximal- und Minmalventilatorgeschwindigkeiten " -"ausgerechnet." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:397 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1242 -msgid "approximate seconds" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:405 -msgid "Color" -msgstr "Farbe" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:412 -msgid "Filament notes" -msgstr "Filament Notizen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:413 -msgid "You can put your notes regarding the filament here." -msgstr "Man kann Filament Notizen hier eingeben" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:421 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:817 -msgid "Max volumetric speed" -msgstr "Maximale Volumgeschwindigkeit" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:422 -msgid "" -"Maximum volumetric speed allowed for this filament. Limits the maximum " -"volumetric speed of a print to the minimum of print and filament volumetric " -"speed. Set to zero for no limit." -msgstr "" -"Maximalvolumgeschwindigkeit die mit diesem Filament erlaubt ist. Scränkt " -"die Maximalvolumgeschwindigkeit auf das Minimum von Druck- und " -"Filamentmaximalvolumgeschwindigkeit ein. Auf Null stellen um " -"Volumgeschwindigkeit nicht einzuschränken." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:425 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:820 -msgid "mm³/s" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:432 -msgid "" -"Enter your filament diameter here. Good precision is required, so use a " -"caliper and do multiple measurements along the filament, then compute the " -"average." -msgstr "" -"Filamentdurchmesser hier eingeben. Präzision is wichtig also eine " -"Messschieber benutzen, mehrmals an verscheiden Orten messen, und den " -"Durchschnitt ausrechnen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:440 -msgid "Density" -msgstr "Dichte" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:441 -msgid "" -"Enter your filament density here. This is only for statistical information. " -"A decent way is to weigh a known length of filament and compute the ratio of " -"the length to volume. Better is to calculate the volume directly through " -"displacement." -msgstr "Filamentdichte hier eingeben. Nur für Statistik benutzt. " - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:444 -msgid "g/cm³" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:450 -msgid "Filament type" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:451 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1002 -msgid "" -"If you want to process the output G-code through custom scripts, just list " -"their absolute paths here. Separate multiple scripts with a semicolon. " -"Scripts will be passed the absolute path to the G-code file as the first " -"argument, and they can access the Slic3r config settings by reading " -"environment variables." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:470 -msgid "Soluble material" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:471 -msgid "Soluble material is most likely used for a soluble support." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:476 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:450 -msgid "Cost" -msgstr "Preis" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:477 -msgid "" -"Enter your filament cost per kg here. This is only for statistical " -"information." -msgstr "Filamentpreis pro kg hier eingeben. Nur für Statistik benutzt. " - -# Set this to be the local currency symbol. -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:478 -msgid "money/kg" -msgstr "Geld/kg" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:487 -msgid "Fill angle" -msgstr "Füllwinkel" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:489 -msgid "" -"Default base angle for infill orientation. Cross-hatching will be applied to " -"this. Bridges will be infilled using the best direction Slic3r can detect, " -"so this setting does not affect them." -msgstr "" -"Standardwinkel für Infill Richtung. Kreuzschraffur wird daran bezogen. " -"Brücken werden mit der besten Richtung die Slic3r finden kann Ingefillt, " -"also sind sie von dieser Einstellung unabhängig." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:501 -msgid "Fill density" -msgstr "Filldichte" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:503 -#, no-c-format -msgid "Density of internal infill, expressed in the range 0% - 100%." -msgstr "Infilldichte. Als Prozentwert 0% - 100% ausgedrückt." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:539 -msgid "Fill pattern" -msgstr "Füllmuster" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:541 -msgid "Fill pattern for general low-density infill." -msgstr "Füllmuster für Infill von geringer Dichte." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:573 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:582 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:591 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:625 -msgid "First layer" -msgstr "Erste Schicht" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:574 -msgid "" -"This is the acceleration your printer will use for first layer. Set zero to " -"disable acceleration control for first layer." -msgstr "" -"Die Beschleunigung die ihr Drucker bei der ersten Schicht benutzt. Auf Null " -"stellen um Beschleunigungskontrolle bei der ersten Schicht einzustellen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:583 -msgid "" -"Heated build plate temperature for the first layer. Set this to zero to " -"disable bed temperature control commands in the output." -msgstr "" -"Druckbretttemperatur für die erste Schicht. Auf Null stellen um " -"Temperaturkontrollkode im Output zu deaktivieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:593 -msgid "" -"Set this to a non-zero value to set a manual extrusion width for first " -"layer. You can use this to force fatter extrudates for better adhesion. If " -"expressed as percentage (for example 120%) it will be computed over first " -"layer height. If set to zero, it will use the default extrusion width." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:603 -msgid "First layer height" -msgstr "Höhe der ersten Schicht" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:605 -msgid "" -"When printing with very low layer heights, you might still want to print a " -"thicker bottom layer to improve adhesion and tolerance for non perfect build " -"plates. This can be expressed as an absolute value or as a percentage (for " -"example: 150%) over the default layer height." -msgstr "" -"Wenn man with kleinen Schichtdicken druckt möchte mann trotzdem manchmal " -"eine dickere Bodenschicht drucken um bessere Klebfestigkeit und Toleranz für " -"Druckplatten zu haben. Das kann als Absolutwert oder als Prozent (z.b.: " -"150%) der Standardschichtdicke eigegeben werden." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:609 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:740 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1390 -msgid "mm or %" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:615 -msgid "First layer speed" -msgstr "Druckgeschwindigkeit der ersten Schicht" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:616 -msgid "" -"If expressed as absolute value in mm/s, this speed will be applied to all " -"the print moves of the first layer, regardless of their type. If expressed " -"as a percentage (for example: 40%) it will scale the default speeds." -msgstr "" -"Als Absolutwert in mm/s, bestimmt diese Stellung die Druckgeschwindigkeit " -"der ersten Schicht. Als Prozent eigegeben (z.b.: 40%) wird sie relativ der " -"Standardschichtdicke ausgerechnet." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:626 -msgid "" -"Extruder temperature for first layer. If you want to control temperature " -"manually during print, set this to zero to disable temperature control " -"commands in the output file." -msgstr "" -"Extrudertemperatur für die erste Schicht. Für Temperaturhandkontrolle auf " -"Null stellen, dann wird die Outputdatei ohne Temparaturkontrolcode generiert." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:634 -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:145 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:87 -msgid "Gap fill" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:636 -msgid "" -"Speed for filling small gaps using short zigzag moves. Keep this reasonably " -"low to avoid too much shaking and resonance issues. Set zero to disable gaps " -"filling." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:644 -msgid "Verbose G-code" -msgstr "Ausführlicher G-code" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:645 -msgid "" -"Enable this to get a commented G-code file, with each line explained by a " -"descriptive text. If you print from SD card, the additional weight of the " -"file could make your firmware slow down." -msgstr "" -"Diese Stellung aktiviert Anmerkungen die jede Zeile der G-code Datei " -"beschreiben. Wenn sie von einder SD-karte drucken, könnte das die Firmware " -"des Druckers verlangsamen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:652 -msgid "G-code flavor" -msgstr "G-code Typ" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:653 -msgid "" -"Some G/M-code commands, including temperature control and others, are not " -"universal. Set this option to your printer's firmware to get a compatible " -"output. The \"No extrusion\" flavor prevents Slic3r from exporting any " -"extrusion value at all." -msgstr "" -"Einige G/M-code Befehle, zum Beispiel Temperaturkontrolle sind nicht " -"universal. Diese stellung soll der Druckerfirmware angepasst sein um " -"kompatiblen Output zu generieren. Der \"No extrusion\" Typ generiert G-code " -"ohne Extrusion." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:682 -msgid "" -"This is the acceleration your printer will use for infill. Set zero to " -"disable acceleration control for infill." -msgstr "" -"Diese Stellung bestimmt die Beschleunigung des Druckers für Infill. Auf " -"Null stellen um Beschleunigungskontrolle für Infill zu deaktivieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:690 -msgid "Combine infill every" -msgstr "Jede __ Schichten Infill combinieren" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:692 -#, fuzzy -msgid "" -"This feature allows to combine infill and speed up your print by extruding " -"thicker infill layers while preserving thin perimeters, thus accuracy." -msgstr "" -"#-#-#-#-# Slic3rPE_de_DE.po #-#-#-#-#\n" -"#-#-#-#-# de_DE.po (Slic3r) #-#-#-#-#\n" -"Wenn diese Stellung aktiviert ist dan wird Infill in dicken Schichten " -"gedruckt während die Umfänge in dünnen Schichten gedruckt werden. So kann " -"man schneller doch trotzdem präzise drucken." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:696 -msgid "Combine infill every n layers" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:701 -msgid "Infill extruder" -msgstr "Infill Extruder" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:703 -msgid "The extruder to use when printing infill." -msgstr "Extruder der bei Infill zu benutzen ist." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:711 -msgid "" -"Set this to a non-zero value to set a manual extrusion width for infill. If " -"left zero, default extrusion width will be used if set, otherwise 1.125 x " -"nozzle diameter will be used. You may want to use fatter extrudates to speed " -"up the infill and make your parts stronger. If expressed as percentage (for " -"example 90%) it will be computed over layer height." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:720 -msgid "Infill before perimeters" -msgstr "Infill vor Umfang" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:721 -msgid "" -"This option will switch the print order of perimeters and infill, making the " -"latter first." -msgstr "" -"Diese stellung wendet die druckfolge von Umfang und Infill, so das Infill " -"erst gedruckt wird." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:726 -msgid "Only infill where needed" -msgstr "Infill nur wo Notwendig drucken" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:728 -msgid "" -"This option will limit infill to the areas actually needed for supporting " -"ceilings (it will act as internal support material). If enabled, slows down " -"the G-code generation due to the multiple checks involved." -msgstr "" -"Diese stellung wird Infill in die Volumen wo er notwendig ist um Decken zu " -"unterstützen. (Der Infill wird as internes Unterstützungsmaterial wirken.) " -"Wenn aktiviert, verlangsamt sie die G-code generierung." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:735 -msgid "Infill/perimeters overlap" -msgstr "Infill/Umfang Überlappung" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:737 -msgid "" -"This setting applies an additional overlap between infill and perimeters for " -"better bonding. Theoretically this shouldn't be needed, but backlash might " -"cause gaps. If expressed as percentage (example: 15%) it is calculated over " -"perimeter extrusion width." -msgstr "" -"Diese stellung setzt eine Überlappung zwischen Umfang und Infill ein um eine " -"bessere Verbindung zu formen. Theoretisch sollte das nicht notwendig sein, " -"doch Getriebespiel könnte Spalten zeugen. Als Prozent eingegeben (z.B: 15%) " -"wird sie relativ der Umfangsextrusionsbreite ausgerechnet." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:748 -msgid "Speed for printing the internal fill. Set to zero for auto." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:757 -msgid "Interface shells" -msgstr "Verbindungschichten" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:758 -msgid "" -"Force the generation of solid shells between adjacent materials/volumes. " -"Useful for multi-extruder prints with translucent materials or manual " -"soluble support material." -msgstr "" -"Generiert dichte Schichten zwischen angrenzenden Materiellen/Volumen. " -"Nützlich bei multi-Extruder druken mit durchsichtigem Material, oder " -"lösbarem Unterstützungsmaterial." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:767 -msgid "" -"This custom code is inserted at every layer change, right after the Z move " -"and before the extruder moves to the first layer point. Note that you can " -"use placeholder variables for all Slic3r settings as well as [layer_num] and " -"[layer_z]." -msgstr "" -"Dieser Code wird am ende jeder Schicht (nach der Z Bewegung und vor der " -"Bewegum zum ersten punkt der nächsten Schicht) dem G-code beigetragen. " -"Platzhalter für alle Slic3r Einstellung sowie [layer_num] und [layer_z] " -"können hier benutzt werden." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:779 -msgid "" -"This setting controls the height (and thus the total number) of the slices/" -"layers. Thinner layers give better accuracy but take more time to print." -msgstr "" -"Diese Stellung bestimmt die Dicke (und dadurch auch die Zahl) der Scheiben/" -"Schichten. Dünnere Schichten drucken präziser doch langsamer." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:787 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:796 -msgid "Max" -msgstr "Max" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:788 -msgid "This setting represents the maximum speed of your fan." -msgstr "Diese Stellung Bestimmt die Maximalgeschwindigkeit des Ventilators." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:797 -#, no-c-format -msgid "" -"This is the highest printable layer height for this extruder, used to cap " -"the variable layer height and support layer height. Maximum recommended " -"layer height is 75% of the extrusion width to achieve reasonable inter-layer " -"adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:807 -msgid "Max print speed" -msgstr "Maximaldruckgeschwindigkeit" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:808 -#, fuzzy -msgid "" -"When setting other speed settings to 0 Slic3r will autocalculate the optimal " -"speed in order to keep constant extruder pressure. This experimental setting " -"is used to set the highest print speed you want to allow." -msgstr "" -"#-#-#-#-# Slic3rPE_de_DE.po #-#-#-#-#\n" -"#-#-#-#-# de_DE.po (Slic3r) #-#-#-#-#\n" -"Wenn andere Geschwindigkeitstellungen 0 sind wird Slic3r automatisch die " -"Optimalgeschwindigikeit ausrechnen um Düsendruck gleichmäßig zu halten. " -"Diese Experimentalstellung bestimmt die maximal erlaubte " -"Druckgeschwindigkeit." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:818 -msgid "" -"This experimental setting is used to set the maximum volumetric speed your " -"extruder supports." -msgstr "" -"Diese Experimentalstellung beschreibt die Maximalvolumgeschwindigkeit des " -"Extruders." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:826 -msgid "Max volumetric slope positive" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:827 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:838 -msgid "" -"This experimental setting is used to limit the speed of change in extrusion " -"rate. A value of 1.8 mm³/s² ensures, that a change from the extrusion rate " -"of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/" -"s) to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:831 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:842 -msgid "mm³/s²" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:837 -msgid "Max volumetric slope negative" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:848 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:857 -msgid "Min" -msgstr "Min" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:849 -msgid "This setting represents the minimum PWM your fan needs to work." -msgstr "Diese stellung ist die minimale PWM für den Ventilator." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:858 -msgid "" -"This is the lowest printable layer height for this extruder and limits the " -"resolution for variable layer height. Typical values are between 0.05 mm and " -"0.1 mm." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:866 -msgid "Min print speed" -msgstr "Minimaldruckgeschwindigkeit" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:867 -msgid "Slic3r will not scale speed down below this speed." -msgstr "Slic3r nicht unter diese Geschwindigkeit skalieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:874 -msgid "Minimum extrusion length" -msgstr "Minimalextrusionslänge" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:875 -msgid "" -"Generate no less than the number of skirt loops required to consume the " -"specified amount of filament on the bottom layer. For multi-extruder " -"machines, this minimum applies to each extruder." -msgstr "" -"Mindestzahl der Schaufen notwendig um die angegebene Menge Filament am Boden " -"zu verbrauchen. Bei Multi-extruder Druckern gilt diese Mindestzahl für alle " -"Extruder." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:884 -msgid "Configuration notes" -msgstr "Konfigurationsnotizen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:885 -msgid "" -"You can put here your personal notes. This text will be added to the G-code " -"header comments." -msgstr "" -"Man kann Notizen hier eingeben. Der Text wird dem G-code Header beigetragen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:894 -msgid "Nozzle diameter" -msgstr "Düsenduchmesser" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:895 -msgid "" -"This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)" -msgstr "Durchmesser der Extruderdüse (z.B.: 0.5, 0.35 usw.)" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:901 -msgid "API Key" -msgstr "API Key" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:902 -msgid "" -"Slic3r can upload G-code files to OctoPrint. This field should contain the " -"API Key required for authentication." -msgstr "" -"Slic3r kann G-code Dateien bei OctoPrint Hochladen. Diese stellung ist der " -"API Key für Authentifikation." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:908 -msgid "Host or IP" -msgstr "Host or IP" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:909 -msgid "" -"Slic3r can upload G-code files to OctoPrint. This field should contain the " -"hostname or IP address of the OctoPrint instance." -msgstr "" -"Slic3r kann G-code Dateien bei OctoPrint Hochladen. Diese Stellung ist der " -"Hostname oder die IP address von OctoPrint." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:915 -msgid "Only retract when crossing perimeters" -msgstr "Nur bei Umfangsüberquerungen einziehen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:916 -msgid "" -"Disables retraction when the travel path does not exceed the upper layer's " -"perimeters (and thus any ooze will be probably invisible)." -msgstr "" -"Deaktiviert einziehen wenn der Extruderweg nicht die Umgfänge der " -"Oberschicht überschreitet (so das jegliches Sickern warscheinlich unsichtbar " -"ist.)" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:923 -msgid "" -"This option will drop the temperature of the inactive extruders to prevent " -"oozing. It will enable a tall skirt automatically and move extruders outside " -"such skirt when changing temperatures." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:930 -msgid "Output filename format" -msgstr "Output Dateinamen Format" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:931 -msgid "" -"You can use all configuration options as variables inside this template. For " -"example: [layer_height], [fill_density] etc. You can also use [timestamp], " -"[year], [month], [day], [hour], [minute], [second], [version], " -"[input_filename], [input_filename_base]." -msgstr "" -"Man kann alle Konfigurationsoptionen als Variable in dieser Vorlage " -"benutzen. Zum Beispiel: [layer_height], [fill_density] usw. Man kann auch " -"[timestamp], [year], [month], [day], [hour], [minute], [second], [version], " -"[input_filename], und [input_filename_base] benutzen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:940 -msgid "Detect bridging perimeters" -msgstr "Umfangbrücken entdecken" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:942 -msgid "" -"Experimental option to adjust flow for overhangs (bridge flow will be used), " -"to apply bridge speed to them and enable fan." -msgstr "" -"Experimentalstellung die Plastikfluss bei Überhang druken ändert, indem die " -"Brücken stellungen angewendet und der Ventilator eingeschaltet werden." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:948 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:966 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:978 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:988 -msgid "Perimeters" -msgstr "Umfänge" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:949 -msgid "" -"This is the acceleration your printer will use for perimeters. A high value " -"like 9000 usually gives good results if your hardware is up to the job. Set " -"zero to disable acceleration control for perimeters." -msgstr "" -"Die Beschleunigung die der Drucker bei Umfängen benutzt. Eine große stelling " -"wie 9000 funktioniert norwalerwise gut. Auf Null stellen um " -"Beschleunigungskontrolle bei Umfängen auszuschalten." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:957 -msgid "Perimeter extruder" -msgstr "Umfangsextruder" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:959 -msgid "" -"The extruder to use when printing perimeters and brim. First extruder is 1." -msgstr "" -"Extruder der bei Umfang und Krempe drucken benutzt werden soll. Der erste " -"extruder ist 1." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:968 -msgid "" -"Set this to a non-zero value to set a manual extrusion width for perimeters. " -"You may want to use thinner extrudates to get more accurate surfaces. If " -"left zero, default extrusion width will be used if set, otherwise 1.125 x " -"nozzle diameter will be used. If expressed as percentage (for example 200%) " -"it will be computed over layer height." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:980 -msgid "" -"Speed for perimeters (contours, aka vertical shells). Set to zero for auto." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:990 -msgid "" -"This option sets the number of perimeters to generate for each layer. Note " -"that Slic3r may increase this number automatically when it detects sloping " -"surfaces which benefit from a higher number of perimeters if the Extra " -"Perimeters option is enabled." -msgstr "" -"Diese Stellung bestimmt die Zahl der Umfänge die für jede Schicht generiert " -"werden. Slic3r kann diese Zahl automatisch vergrößern wenn es schräge " -"Oberflächen erkent die mit mehr Umfängen besser drucken wenn die \"Extra " -"Umfänge wenn Notwendig\" Option aktiviert ist." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:994 -msgid "(minimum)" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1014 -msgid "Printer notes" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1015 -msgid "You can put your notes regarding the printer here." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1029 -msgid "Raft layers" -msgstr "Gründungsfloßschichten" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1031 -msgid "" -"The object will be raised by this number of layers, and support material " -"will be generated under it." -msgstr "" -"Das Objekt wird diese Zhal von Schichten gehoben, und Understützungsmaterial " -"wird darunter generiert." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1039 -msgid "Resolution" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1040 -msgid "" -"Minimum detail resolution, used to simplify the input file for speeding up " -"the slicing job and reducing memory usage. High-resolution models often " -"carry more detail than printers can render. Set to zero to disable any " -"simplification and use full resolution from input." -msgstr "" -"Diese Minimaldetailauflösung ist benutzt um Inputdateien zu vereinfachen, " -"das Slicing zu beschleunigen, und Speicher zu schonen. Modele mit " -"Hochauflösung haben oft Details die der Drucker nicht Vollziehen kann. Auf " -"Null stellen um vereinfachen zu deaktivieren und die volle Auflösung des " -"Inputs zu benutzen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1050 -msgid "Minimum travel after retraction" -msgstr "Minimalbewegung nach Einziehen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1051 -msgid "" -"Retraction is not triggered when travel moves are shorter than this length." -msgstr "" -"Einziehen wird bei Bewegung dieser Distanz oder kürzer nicht ausgelöst." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1057 -msgid "Retract amount before wipe" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1058 -msgid "" -"With bowden extruders, it may be wise to do some amount of quick retract " -"before doing the wipe movement." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1065 -msgid "Retract on layer change" -msgstr "Bei Schichtenwechsel Einziehen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1066 -msgid "This flag enforces a retraction whenever a Z move is done." -msgstr "Diese Stellung zwingt Einziehen bei jeder Z bewegung." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1071 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1080 -msgid "Length" -msgstr "Länge" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1072 -msgid "Retraction Length" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1073 -msgid "" -"When retraction is triggered, filament is pulled back by the specified " -"amount (the length is measured on raw filament, before it enters the " -"extruder)." -msgstr "" -"Wenn Einziehen ausgelöst wird, wird das Filament diese Länge zurückgezogen. " -"(Die Länge ist am Rohfilament gemessen vordem es im Extruder ist.)" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1075 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1085 -msgid "mm (zero to disable)" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1081 -msgid "Retraction Length (Toolchange)" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1082 -msgid "" -"When retraction is triggered before changing tool, filament is pulled back " -"by the specified amount (the length is measured on raw filament, before it " -"enters the extruder)." -msgstr "" -"Wenn Einziehen ausgelöst wird, wird das Filament diese Länge zurückgezogen. " -"(Die Länge ist am Rohfilament gemessen vordem es im Extruder ist.)" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1090 -msgid "Lift Z" -msgstr "Z Heben" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1091 -msgid "" -"If you set this to a positive value, Z is quickly raised every time a " -"retraction is triggered. When using multiple extruders, only the setting for " -"the first extruder will be considered." -msgstr "" -"Wenn diese Stellung positiv ist wird die Z Achse schnell gehoben jedesmal " -"wenn Einziehen ausgelöst wird. Bei mehrfachen Extrudern gilt nur die " -"Stellung vom Ersten Extruder." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1099 -msgid "Above Z" -msgstr "Über Z" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1100 -msgid "Only lift Z above" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1101 -msgid "" -"If you set this to a positive value, Z lift will only take place above the " -"specified absolute Z. You can tune this setting for skipping lift on the " -"first layers." -msgstr "" -"Wenn diese stellung Positiv ist, dann findet Z Heben nur über dieser " -"absoluten Z-position statt." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1108 -msgid "Below Z" -msgstr "Unter Z" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1109 -msgid "Only lift Z below" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1110 -msgid "" -"If you set this to a positive value, Z lift will only take place below the " -"specified absolute Z. You can tune this setting for limiting lift to the " -"first layers." -msgstr "" -"Wenn diese stellung Positiv ist, dann findet Z Heben nur unter dieser " -"absoluten Z-position statt." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1118 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1126 -msgid "Extra length on restart" -msgstr "Extra Länge bei Neustart" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1119 -msgid "" -"When the retraction is compensated after the travel move, the extruder will " -"push this additional amount of filament. This setting is rarely needed." -msgstr "" -"Wenn nach der Bewegung das Einziehen ausgegleicht wird, wird der Extruder " -"diese Extramenge Filament schieben. Diese stellung ist nur selten notwendig." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1127 -msgid "" -"When the retraction is compensated after changing tool, the extruder will " -"push this additional amount of filament." -msgstr "" -"Wenn nach der Bewegung das Einziehen ausgegleicht wird, wird der Extruder " -"diese Extramenge Filament schieben." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1134 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1135 -msgid "Retraction Speed" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1136 -msgid "The speed for retractions (it only applies to the extruder motor)." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1142 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1143 -msgid "Deretraction Speed" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1144 -msgid "" -"The speed for loading of a filament into extruder after retraction (it only " -"applies to the extruder motor). If left to zero, the retraction speed is " -"used." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1151 -msgid "Seam position" -msgstr "Saumposition" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1153 -msgid "Position of perimeters starting points." -msgstr "Position des Umfanganfangs" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1169 -msgid "Direction" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1171 -msgid "Preferred direction of the seam" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1172 -msgid "Seam preferred direction" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1180 -msgid "Jitter" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1182 -msgid "Seam preferred direction jitter" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1183 -msgid "Preferred direction of the seam - jitter" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1194 -msgid "USB/serial port for printer connection." -msgstr "USB/serial port für Drucker Anschluß." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1202 -msgid "Serial port speed" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1203 -msgid "Speed (baud) of USB/serial port for printer connection." -msgstr "Geschwindigkeit (baud) des USB/serial port für Drucker Anschluß." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1212 -msgid "Distance from object" -msgstr "Distance vom Objekt" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1213 -msgid "" -"Distance between skirt and object(s). Set this to zero to attach the skirt " -"to the object(s) and get a brim for better adhesion." -msgstr "" -"Distanz zwischen Zarge und Objekt. Auf Null stellen um die Zarge an das " -"Objekt zu verbinden und eine Krempe für bessere Haftung zu generieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1221 -msgid "Skirt height" -msgstr "Zargengröße" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1222 -msgid "" -"Height of skirt expressed in layers. Set this to a tall value to use skirt " -"as a shield against drafts." -msgstr "" -"Größe der Zarge in Schichten. Eine große Zarge kann gegen Züge schützen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1229 -msgid "Loops (minimum)" -msgstr "Schalaufen (minimal)" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1230 -msgid "Skirt Loops" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1231 -msgid "" -"Number of loops for the skirt. If the Minimum Extrusion Length option is " -"set, the number of loops might be greater than the one configured here. Set " -"this to zero to disable skirt completely." -msgstr "" -"Zahl der Schlaufen in der Zarge. Wenn Minimalextrusionslänge kann die Zahl " -"von Schlaufen in der Zarge größer sein. Auf Null stellen um Zargen zu " -"deaktivieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1239 -msgid "Slow down if layer print time is below" -msgstr "Langsamer drucken wenn die Schichtendruckzeit weniger als ___ ist" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1240 -msgid "" -"If layer print time is estimated below this number of seconds, print moves " -"speed will be scaled down to extend duration to this value." -msgstr "" -"Wenn die Schichtendruckzeitseinschätzung weniger als diese Zahl von Sekunden " -"ist dann wird die Druckgeschwindigkeit langsamer skaliert um die " -"Schichtdruckzeit auf die vorgeschriebene Zeit zu verlängern." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1250 -msgid "Small perimeters" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1252 -msgid "" -"This separate setting will affect the speed of perimeters having radius <= " -"6.5mm (usually holes). If expressed as percentage (for example: 80%) it will " -"be calculated on the perimeters speed setting above. Set to zero for auto." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1262 -msgid "Solid infill threshold area" -msgstr "Massivinfillflächeninhaltschwellwert " - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1264 -msgid "" -"Force solid infill for regions having a smaller area than the specified " -"threshold." -msgstr "" -"Zwinge Massivinfill in Regionen deren Flächeninhalt kleiner als diese " -"Schwellwert ist." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1265 -msgid "mm²" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1271 -msgid "Solid infill extruder" -msgstr "Massivinfillextruder" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1273 -msgid "The extruder to use when printing solid infill." -msgstr "Der Extruder der beim Drucken von Massivinfill benutzt werden soll." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1279 -msgid "Solid infill every" -msgstr "Massivinfill jede" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1281 -msgid "" -"This feature allows to force a solid layer every given number of layers. " -"Zero to disable. You can set this to any value (for example 9999); Slic3r " -"will automatically choose the maximum possible number of layers to combine " -"according to nozzle diameter and layer height." -msgstr "" -"Diese Einstellung Generiert eine dichte Schicht je der eingegeben Zahl von " -"Schichten. Auf Null stellen um zu deaktivieren. Man kann diese Stellung " -"auf eine beliebige Zahl stellen (z. B. 9999), und Slic3r wird automatisch " -"die maximal verienbaren Schichten duch Düsenduchmesser und Schichtdicke " -"ausrechnen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1291 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1301 -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:142 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:84 -msgid "Solid infill" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1293 -msgid "" -"Set this to a non-zero value to set a manual extrusion width for infill for " -"solid surfaces. If left zero, default extrusion width will be used if set, " -"otherwise 1.125 x nozzle diameter will be used. If expressed as percentage " -"(for example 90%) it will be computed over layer height." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1303 -msgid "" -"Speed for printing solid regions (top/bottom/internal horizontal shells). " -"This can be expressed as a percentage (for example: 80%) over the default " -"infill speed above. Set to zero for auto." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1315 -msgid "Number of solid layers to generate on top and bottom surfaces." -msgstr "" -"Zahl der dichten Schichten die am Boden und an der Decke generiert werden " -"sollen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1322 -msgid "Spiral vase" -msgstr "Spiralvase" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1323 -msgid "" -"This feature will raise Z gradually while printing a single-walled object in " -"order to remove any visible seam. This option requires a single perimeter, " -"no infill, no top solid layers and no support material. You can still set " -"any number of bottom solid layers as well as skirt/brim loops. It won't work " -"when printing more than an object." -msgstr "" -"Dieses Druckmethode erhöht die Z Position allmählich, während eine einfache " -"Hülle gedruckt wird um jeglichen sichtbaren Saum zu vermeiden. Diese Option " -"erfordert stellungen auf einen einzigen Umfang, kein Infill, keine dichten " -"Deckenschichten und kein Unterstützungsmaterial. Man kann noch eine " -"beliebige zahl der dichten Bodenschichten, und auch Zarg- oder " -"Krempenschlaufen drucken. Die Methode funktioniert auch nicht wenn man mehr " -"als ein Objekt druckt." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1332 -msgid "Temperature variation" -msgstr "Temperaturunterschied" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1333 -msgid "" -"Temperature difference to be applied when an extruder is not active. Enables " -"a full-height \"sacrificial\" skirt on which the nozzles are periodically " -"wiped." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1343 -msgid "" -"This start procedure is inserted at the beginning, after bed has reached the " -"target temperature and extruder just started heating, and before extruder " -"has finished heating. If Slic3r detects M104 or M190 in your custom codes, " -"such commands will not be prepended automatically so you're free to " -"customize the order of heating commands and other custom actions. Note that " -"you can use placeholder variables for all Slic3r settings, so you can put a " -"\"M109 S[first_layer_temperature]\" command wherever you want." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1358 -msgid "" -"This start procedure is inserted at the beginning, after any printer start " -"gcode. This is used to override settings for a specific filament. If Slic3r " -"detects M104, M109, M140 or M190 in your custom codes, such commands will " -"not be prepended automatically so you're free to customize the order of " -"heating commands and other custom actions. Note that you can use placeholder " -"variables for all Slic3r settings, so you can put a \"M109 " -"S[first_layer_temperature]\" command wherever you want. If you have multiple " -"extruders, the gcode is processed in extruder order." -msgstr "" -"Diese Routine wird am anfang des G-codes eingefügt, nachdem das Druckbrett " -"aufgeheizt ist und die Extruder heizung grade angeschaltet ist, und vordem " -"der Extruder seine Zieltemperatur erreicht hat. Wenn Slic3r M104, M109, " -"M140, oder M190 in dieser Routine erkennt dann werden solche Codes nicht " -"automatisch generiert so dass man die reinfolge der Heizungsbefehle frei " -"anpassen kann. Man kann in diesm Code Platzhalter anwenden, zum Beispiel, " -"könnte irgendwo in der Routine der \"M109 S[first_layer_temperature]\" " -"Befehl stehen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1373 -msgid "Single Extruder Multi Material" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1374 -msgid "The printer multiplexes filaments into a single hot end." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1379 -msgid "Generate support material" -msgstr "Generiere Unterstützungsmaterial" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1381 -msgid "Enable support material generation." -msgstr "Aktiviert generierung von Unterstützungsmaterial" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1386 -msgid "XY separation between an object and its support" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1388 -msgid "" -"XY separation between an object and its support. If expressed as percentage " -"(for example 50%), it will be calculated over external perimeter width." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1398 -msgid "Pattern angle" -msgstr "Muster Winkel" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1400 -msgid "" -"Use this setting to rotate the support material pattern on the horizontal " -"plane." -msgstr "" -"Diese stellung dreht das Unterstützungsmaterialsmuster in der Horizontalebene" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1408 -msgid "Support on build plate only" -msgstr "Unterstützungsmaterial nur auf dem Druckbrett" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1410 -msgid "" -"Only create support if it lies on a build plate. Don't create support on a " -"print." -msgstr "" -"Unterstützungsmaterial nur generieren wenn es auf dem Druckbrett ist. " -"Unterstützungsmaterial nicht auf Objekten generieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1416 -msgid "Contact Z distance" -msgstr "Kontakt Z-distanz" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1418 -msgid "" -"The vertical distance between object and support material interface. Setting " -"this to 0 will also prevent Slic3r from using bridge flow and speed for the " -"first object layer." -msgstr "" -"Die vertikale distanz zwischen Objekt und Unterstützungsmaterial. Wenn " -"diese stellung 0 ist wird Slic3r die Brücken Fluss und " -"Brückengeschwindigkeits stellungen bei der ersten Objektschicht ignoriert." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1431 -msgid "Enforce support for the first" -msgstr "Zwinge Unterstützungsmaterial bei den ersten " - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1433 -msgid "" -"Generate support material for the specified number of layers counting from " -"bottom, regardless of whether normal support material is enabled or not and " -"regardless of any angle threshold. This is useful for getting more adhesion " -"of objects having a very thin or poor footprint on the build plate." -msgstr "" -"Generiere Unterstützungsmaterial für die eingegebe Zahl von Schichten vom " -"Boden. Generiert Material unabhängig von der aktivierung von normalem " -"Unterstützungsmaterial oder jeglichem Winkelschwellwert. Nützlich um " -"Haftung für Objekte die dunne oder schwache Grundlagen am Druckbrett haben." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1439 -msgid "Enforce support for the first n layers" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1444 -msgid "Support material/raft/skirt extruder" -msgstr "Unterstützungsmaterial Gründungsfloß und Zargen Extruder" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1446 -msgid "" -"The extruder to use when printing support material, raft and skirt (1+, 0 to " -"use the current extruder to minimize tool changes)." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1455 -msgid "" -"Set this to a non-zero value to set a manual extrusion width for support " -"material. If left zero, default extrusion width will be used if set, " -"otherwise nozzle diameter will be used. If expressed as percentage (for " -"example 90%) it will be computed over layer height." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1463 -msgid "Interface loops" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1465 -msgid "" -"Cover the top contact layer of the supports with loops. Disabled by default." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1470 -msgid "Support material/raft interface extruder" -msgstr "Unterstützungsmaterial und Gründungsfloß Schnittstellen Extruder" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1472 -msgid "" -"The extruder to use when printing support material interface (1+, 0 to use " -"the current extruder to minimize tool changes). This affects raft too." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1479 -msgid "Interface layers" -msgstr "Schnittstellen Schichten" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1481 -msgid "" -"Number of interface layers to insert between the object(s) and support " -"material." -msgstr "" -"Zahl der Schichten von Schnittstellenmaterial die zwischen Objekt und " -"Unterstützungsmaterial generiert werden sollen." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1488 -msgid "Interface pattern spacing" -msgstr "Schnistellenmuster Abstand" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1490 -msgid "Spacing between interface lines. Set zero to get a solid interface." -msgstr "" -"Abstand zwischen Schnittstellenmateriallinien. Auf Null stellen um dichtes " -"Schnittstellenmaterial zu generieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1497 -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:148 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:90 -msgid "Support material interface" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1499 -msgid "" -"Speed for printing support material interface layers. If expressed as " -"percentage (for example 50%) it will be calculated over support material " -"speed." -msgstr "" -"Druckgeschwindigkeitsstellung für Unterstützungsmaterialschnittstellen. Als " -"Prozent eingegeben (z.B 50%) wird sie relativ der " -"Unterstützungsmaterialdruckgeschwindigkeit ausgerechnet." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1508 -msgid "Pattern" -msgstr "Muster" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1510 -msgid "Pattern used to generate support material." -msgstr "Unterstützungsmaterialmuster." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1524 -msgid "Pattern spacing" -msgstr "Muster Abstand" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1526 -msgid "Spacing between support material lines." -msgstr "Abstand zwischen Unterstützungsmateriallinien." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1535 -msgid "Speed for printing support material." -msgstr "Understützungsmaterialdruckgeschwindigkeit." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1542 -msgid "Synchronize with object layers" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1544 -msgid "" -"Synchronize support layers with the object print layers. This is useful with " -"multi-material printers, where the extruder switch is expensive." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1550 -msgid "Overhang threshold" -msgstr "Überhangschwellwert" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1552 -msgid "" -"Support material will not be generated for overhangs whose slope angle (90° " -"= vertical) is above the given threshold. In other words, this value " -"represent the most horizontal slope (measured from the horizontal plane) " -"that you can print without support material. Set to zero for automatic " -"detection (recommended)." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1564 -msgid "With sheath around the support" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1566 -msgid "" -"Add a sheath (a single perimeter line) around the base support. This makes " -"the support more reliable, but also more difficult to remove." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1573 -msgid "" -"Extruder temperature for layers after the first one. Set this to zero to " -"disable temperature control commands in the output." -msgstr "" -"Extrudertemperatur für Schichten nach der ersten. Auf Null stellen um " -"Temparaturkontrolcode in der Outputdatei zu deaktivieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1576 -msgid "Temperature" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1582 -msgid "Detect thin walls" -msgstr "Dünne Wände Identifizieren" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1584 -msgid "" -"Detect single-width walls (parts where two extrusions don't fit and we need " -"to collapse them into a single trace)." -msgstr "" -"Identifiziere einbreitige Wände. (Wo zwei Extrudate nicht passen, und in " -"ein eiziges zusammengefügt werden müssen.)" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1590 -msgid "Threads" -msgstr "Threads" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1591 -msgid "" -"Threads are used to parallelize long-running tasks. Optimal threads number " -"is slightly above the number of available cores/processors." -msgstr "" -"Threads sind bei Parallelrechnung benutzt. Die optimale Zahl ist ein " -"bisschen größer als die zahl von verfügbarern Cores/Prozessoren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1603 -msgid "" -"This custom code is inserted right before every extruder change. Note that " -"you can use placeholder variables for all Slic3r settings as well as " -"[previous_extruder] and [next_extruder]." -msgstr "" -"Dieser G-Code wird vor jedem Extruderwechsel eingefügt. Mann kann in diesem " -"Code Platzhalter für alle Slic3r Einstellung und auch [previous_extruder] " -"und [next_extruder] anwenden." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1613 -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1624 -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:143 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:85 -msgid "Top solid infill" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1615 -msgid "" -"Set this to a non-zero value to set a manual extrusion width for infill for " -"top surfaces. You may want to use thinner extrudates to fill all narrow " -"regions and get a smoother finish. If left zero, default extrusion width " -"will be used if set, otherwise nozzle diameter will be used. If expressed as " -"percentage (for example 90%) it will be computed over layer height." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1626 -msgid "" -"Speed for printing top solid layers (it only applies to the uppermost " -"external layers and not to their internal solid layers). You may want to " -"slow down this to get a nicer surface finish. This can be expressed as a " -"percentage (for example: 80%) over the solid infill speed above. Set to zero " -"for auto." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1638 -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 -msgid "Top" -msgstr "Decke" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1640 -msgid "Number of solid layers to generate on top surfaces." -msgstr "Zahl der dichten Schichten die als Decke generiert werden." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1642 -msgid "Top solid layers" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1647 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:95 -msgid "Travel" -msgstr "Eilgang" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1648 -msgid "Speed for travel moves (jumps between distant extrusion points)." -msgstr "Eilganggeschwindigkeit (zwischen entfernten Extrudionsplätzen)." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1656 -msgid "Use firmware retraction" -msgstr "Firmware Zurückziehen aktivieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1657 -msgid "" -"This experimental setting uses G10 and G11 commands to have the firmware " -"handle the retraction. This is only supported in recent Marlin." -msgstr "" -"Experimentalstellung die G10 und G11 G-Code benutzt so dass die " -"Druckerfirmware das Zurückziehen übernimmt. Nur mit neuen Marlin Versionen " -"möglich." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1663 -msgid "Use relative E distances" -msgstr "Relitive Extrusiondistanz Benutzen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1664 -msgid "" -"If your firmware requires relative E values, check this, otherwise leave it " -"unchecked. Most firmwares use absolute values." -msgstr "" -"Wenn die Druckerfirmware relative E-Koordinate benötigt, aktiviere diese " -"stellung. Sonst deaktiviert lassen. Typische Drucker benutzen absolute " -"Koordinaten." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1670 -msgid "Use volumetric E" -msgstr "Volumetrische E Benutzen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1671 -msgid "" -"This experimental setting uses outputs the E values in cubic millimeters " -"instead of linear millimeters. If your firmware doesn't already know " -"filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] " -"T0' in your start G-code in order to turn volumetric mode on and use the " -"filament diameter associated to the filament selected in Slic3r. This is " -"only supported in recent Marlin." -msgstr "" -"Diese Experimentalstellung generiert E-Koordinaten in Kubikmillimeter stat " -"in linearen Millimetern. Wenn die Firmware den Filamentdurchmesser noch " -"nicht weiss, kann Man befehle wie 'M200 D[filament_diameter_0] T0' in den " -"start G-Code eingeben um Volumenmodus zu aktivieren und den " -"Fialmentdurchmesser in der Slic3reinstellun zu benutzen. Nur mit neuen " -"Marlin Versionen möglich." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1681 -msgid "Enable variable layer height feature" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1682 -msgid "" -"Some printers or printer setups may have difficulties printing with a " -"variable layer height. Enabled by default." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1688 -msgid "Wipe while retracting" -msgstr "Während Zurückziehen wischen" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1689 -msgid "" -"This flag will move the nozzle while retracting to minimize the possible " -"blob on leaky extruders." -msgstr "" -"Diese Stellung wird die Düse während dem Zurückziehen um Tropfen am Extruder " -"zu minimieren." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1696 -msgid "" -"Multi material printers may need to prime or purge extruders on tool " -"changes. Extrude the excess material into the wipe tower." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1702 -msgid "Position X" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1703 -msgid "X coordinate of the left front corner of a wipe tower" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1709 -msgid "Position Y" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1710 -msgid "Y coordinate of the left front corner of a wipe tower" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1716 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:70 -msgid "Width" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1717 -msgid "Width of a wipe tower" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1723 -msgid "Per color change depth" -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1724 -msgid "" -"Depth of a wipe color per color change. For N colors, there will be maximum " -"(N-1) tool switches performed, therefore the total depth of the wipe tower " -"will be (N-1) times this value." -msgstr "" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1732 -msgid "XY Size Compensation" -msgstr "XY Gößenausgleich" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1734 -msgid "" -"The object will be grown/shrunk in the XY plane by the configured value " -"(negative = inwards, positive = outwards). This might be useful for fine-" -"tuning hole sizes." -msgstr "" -"Das Objekt wird in der XY-Ebene vergrößert oder gerschrumpft " -"(negativ=einwärts, positiv = auswärts). Dass könnte für fein-kontrolle von " -"Lochgrößen nützlich sein." - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1742 -msgid "Z offset" -msgstr "Z Abstand" - -#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1743 -msgid "" -"This value will be added (or subtracted) from all the Z coordinates in the " -"output G-code. It is used to compensate for bad Z endstop position: for " -"example, if your endstop zero actually leaves the nozzle 0.3mm far from the " -"print bed, set this to -0.3 (or fix your endstop)." -msgstr "" -"Diese stellung wird allen Z-Koordinaten in dem G-Code zugesätzt (oder " -"abgezogen). Sie ist zum ausgleich einer schlechten Z-Endanschlagsposition " -"geeignet: Zum Beispiel, wenn der Endanschlagnull die Düse 0.3mm vom " -"Druckbrett lässt, kann man hier -0.3 eingeben." - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:137 -msgid "None" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:138 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:80 -msgid "Perimeter" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:139 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:81 -msgid "External perimeter" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:140 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:82 -msgid "Overhang perimeter" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:141 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:83 -msgid "Internal infill" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:144 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:86 -msgid "Bridge infill" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:151 -msgid "Mixed" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:330 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:68 -msgid "Feature type" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:332 -msgid "Height (mm)" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:334 -msgid "Width (mm)" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:336 -msgid "Speed (mm/s)" -msgstr "" - -#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:338 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:72 -msgid "Tool" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI.pm:286 -msgid "Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 -msgid "Version " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 -msgid "" -" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:118 -msgid "Plater" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:120 -msgid "Controller" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 -msgid "No Bonjour device found" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 -msgid "Device Browser" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:211 -msgid "Connection to OctoPrint works correctly." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:214 -msgid "I wasn't able to connect to OctoPrint (" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:215 -msgid "). Check hostname and OctoPrint version (at least 1.1.0 is required)." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 -msgid "Open STL/OBJ/AMF…\tCtrl+O" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 -msgid "Open a model" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 -msgid "&Load Config…\tCtrl+L" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 -msgid "Load exported configuration file" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 -msgid "&Export Config…\tCtrl+E" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 -msgid "Export current configuration to file" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 -msgid "&Load Config Bundle…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 -msgid "Load presets from a bundle" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 -msgid "&Export Config Bundle…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 -msgid "Export all presets to file" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 -msgid "Q&uick Slice…\tCtrl+U" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 -msgid "Slice a file into a G-code" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 -msgid "Quick Slice and Save &As…\tCtrl+Alt+U" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 -msgid "Slice a file into a G-code, save as" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 -msgid "&Repeat Last Quick Slice\tCtrl+Shift+U" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 -msgid "Repeat last quick slice" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 -msgid "Slice to SV&G…\tCtrl+G" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 -msgid "Slice file to a multi-layer SVG" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 -msgid "(&Re)Slice Now\tCtrl+S" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 -msgid "Start new slicing process" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 -msgid "Repair STL file…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 -msgid "Automatically repair an STL file" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 -msgid "Preferences…\tCtrl+," -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 -msgid "Application preferences" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 -msgid "&Quit" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 -msgid "Quit Slic3r" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 -msgid "Export G-code..." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 -msgid "Export current plate as G-code" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 -msgid "Export plate as STL..." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 -msgid "Export current plate as STL" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 -msgid "Export plate as AMF..." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 -msgid "Export current plate as AMF" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 -msgid "Export plate as 3MF..." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 -msgid "Export current plate as 3MF" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 -msgid "Select &Plater Tab\tCtrl+1" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 -msgid "Show the plater" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 -msgid "Select &Controller Tab\tCtrl+T" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 -msgid "Show the printer controller" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 -msgid "Select P&rint Settings Tab\tCtrl+2" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 -msgid "Show the print settings" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 -msgid "Select &Filament Settings Tab\tCtrl+3" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 -msgid "Show the filament settings" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 -msgid "Select Print&er Settings Tab\tCtrl+4" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 -msgid "Show the printer settings" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 -msgid "Iso" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 -msgid "Iso View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 -msgid "Top View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 -msgid "Bottom View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 -msgid "Front" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 -msgid "Front View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 -msgid "Rear" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 -msgid "Rear View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 -msgid "Left" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 -msgid "Left View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 -msgid "Right" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 -msgid "Right View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 -msgid "&Configuration " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 -msgid "Run Configuration " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 -msgid "Prusa 3D Drivers" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 -msgid "Open the Prusa3D drivers download page in your browser" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 -msgid "Prusa Edition Releases" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 -msgid "Open the Prusa Edition releases page in your browser" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 -msgid "Slic3r &Website" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 -msgid "Open the Slic3r website in your browser" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 -msgid "Slic3r &Manual" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 -msgid "Open the Slic3r manual in your browser" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 -msgid "System Info" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 -msgid "Show system information" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 -msgid "Report an Issue" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 -msgid "Report an issue on the Slic3r Prusa Edition" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 -msgid "&About Slic3r" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 -msgid "Show about dialog" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:418 -msgid "&File" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:419 -msgid "&Plater" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:420 -msgid "&Object" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:421 -msgid "&Window" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:422 -msgid "&View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:426 -msgid "&Help" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:457 -msgid "Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:469 -msgid "No previously sliced file." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 -msgid "Previously sliced file (" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 -msgid ") not found." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:475 -msgid "File Not Found" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 -msgid "SVG" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 -msgid "G-code" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 -msgid " file as:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 -msgid "Slicing…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 -msgid "Processing " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:548 -msgid " was successfully sliced." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:550 -msgid "Slicing Done!" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:566 -msgid "Select the STL file to repair:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:580 -msgid "Save OBJ file (less prone to coordinate errors than STL) as:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 -msgid "Your file was repaired." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 -msgid "Repair" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:605 -msgid "Save configuration as:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:623 -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:667 -msgid "Select configuration to load:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:646 -msgid "Save presets bundle as:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:687 -#, perl-format -msgid "%d presets successfully imported." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 -msgid "You have unsaved changes " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 -msgid ". Discard changes and continue anyway?" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:750 -msgid "Unsaved Presets" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:104 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2124 -msgid "3D" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:138 -msgid "2D" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:157 -msgid "Layers" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:177 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:195 -msgid "Add…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:179 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:197 -msgid "Delete All" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:180 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:198 -msgid "Arrange" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:182 -msgid "More" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:183 -msgid "Fewer" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:185 -msgid "45° ccw" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:186 -msgid "45° cw" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:187 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:203 -msgid "Scale…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:188 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:204 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 -msgid "Split" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:189 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:205 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 -msgid "Cut…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:191 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:206 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 -msgid "Settings…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:192 -msgid "Layer Editing" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:207 -msgid "Layer editing" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:220 -msgid "Name" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:221 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 -msgid "Copies" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:222 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 -msgid "Scale" -msgstr "Skalieren" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:236 -msgid "Export G-code…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:237 -msgid "Slice now" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:238 -msgid "Print…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:239 -msgid "Send to printer" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:240 -msgid "Export STL…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:367 -msgid "Print settings" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:369 -msgid "Printer" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:398 -msgid "Info" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:409 -msgid "Volume" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:410 -msgid "Facets" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:411 -msgid "Materials" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:412 -msgid "Manifold" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:438 -msgid "Sliced Info" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:447 -msgid "Used Filament (m)" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:448 -msgid "Used Filament (mm³)" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:449 -msgid "Used Filament (g)" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:451 -msgid "Estimated printing time" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 -msgid "Loading…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:643 -msgid "Processing input file\n" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:663 -msgid "" -"This file contains several objects positioned at multiple heights. Instead " -"of considering them as multiple objects, should I consider\n" -"this file as a single object having multiple parts?\n" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:666 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:683 -msgid "Multi-part object detected" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:680 -msgid "" -"Multiple objects were loaded for a multi-material printer.\n" -"Instead of considering them as multiple objects, should I consider\n" -"these files to represent a single object having multiple parts?\n" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:692 -msgid "Loaded " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:744 -msgid "" -"Your object appears to be too large, so it was automatically scaled down to " -"fit your print bed." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:745 -msgid "Object too large?" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 -msgid "Enter the number of copies of the selected object:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:927 -msgid "" -"\n" -"Non-positive value." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:928 -msgid "" -"\n" -"Not a numeric value." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:929 -msgid "Slic3r Error" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 -msgid "Enter the rotation angle:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 -msgid "Rotate around " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 -msgid "Invalid rotation angle entered" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1030 -#, perl-format -msgid "Enter the new size for the selected object (print bed: %smm):" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 -msgid "Scale along " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 -msgid "Invalid scaling value entered" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 -#, no-perl-format -msgid "Enter the scale % for the selected object:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 -msgid "Enter the new max size for the selected object:" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1112 -msgid "" -"The selected object can't be split because it contains more than one volume/" -"material." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1121 -msgid "" -"The selected object couldn't be split because it contains only one part." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1286 -msgid "Slicing cancelled" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 -msgid "Another export job is currently running." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1445 -msgid "File added to print queue" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1448 -msgid "Sending G-code file to the OctoPrint server..." -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1451 -msgid "G-code file exported to " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1454 -msgid "Export failed" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1524 -msgid "G-code file successfully uploaded to the OctoPrint server" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1526 -msgid "Error while uploading to the OctoPrint server: " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1539 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1581 -msgid "STL file exported to " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1592 -msgid "AMF file exported to " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1596 -msgid "Error exporting AMF file " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1608 -msgid "3MF file exported to " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1612 -msgid "Error exporting 3MF file " -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1958 -#, perl-format -msgid "%d (%d shells)" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1960 -#, perl-format -msgid "Auto-repaired (%d errors)" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1965 -#, perl-format -msgid "" -"%d degenerate facets, %d edges fixed, %d facets removed, %d facets added, %d " -"facets reversed, %d backwards edges" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1970 -msgid "Yes" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 -msgid "Remove the selected object" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 -msgid "Increase copies" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 -msgid "Place one more copy of the selected object" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 -msgid "Decrease copies" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 -msgid "Remove one copy of the selected object" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 -msgid "Set number of copies…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 -msgid "Change the number of copies of the selected object" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 -msgid "Rotate 45° clockwise" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 -msgid "Rotate the selected object by 45° clockwise" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 -msgid "Rotate 45° counter-clockwise" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 -msgid "Rotate the selected object by 45° counter-clockwise" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 -msgid "Rotate" -msgstr "Drehen" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 -msgid "Rotate the selected object by an arbitrary angle" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 -msgid "Around X axis…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 -msgid "Rotate the selected object by an arbitrary angle around X axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 -msgid "Around Y axis…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 -msgid "Rotate the selected object by an arbitrary angle around Y axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 -msgid "Around Z axis…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 -msgid "Rotate the selected object by an arbitrary angle around Z axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 -msgid "Mirror" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 -msgid "Mirror the selected object" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 -msgid "Along X axis…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 -msgid "Mirror the selected object along the X axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 -msgid "Along Y axis…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 -msgid "Mirror the selected object along the Y axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 -msgid "Along Z axis…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 -msgid "Mirror the selected object along the Z axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 -msgid "Scale the selected object along a single axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 -msgid "Uniformly…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 -msgid "Scale the selected object along the XYZ axes" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 -msgid "Scale the selected object along the X axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 -msgid "Scale the selected object along the Y axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 -msgid "Scale the selected object along the Z axis" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 -msgid "Scale to size" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 -msgid "Split the selected object into individual parts" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 -msgid "Open the 3D cutting tool" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 -msgid "Open the object editor dialog" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 -msgid "Reload from Disk" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 -msgid "Reload the selected file from Disk" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 -msgid "Export object as STL…" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 -msgid "Export this single object as STL file" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:131 -msgid "What do you want to print today? ™" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:132 -msgid "Drag your objects here" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:63 -msgid "1 Layer" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:65 -msgid "View" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:75 -msgid "Show" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:78 -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:79 -msgid "Feature types" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:96 -msgid "Retractions" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:97 -msgid "Unretractions" -msgstr "" - -#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:98 -msgid "Shells" -msgstr "" - -#~ msgid "Rectilinear" -#~ msgstr "Rechtwinkelig" - -#~ msgid "Concentric" -#~ msgstr "Konzentrisch" - -#~ msgid "Hilbert Curve" -#~ msgstr "Hilbert Kurve" - -#~ msgid "Archimedean Chords" -#~ msgstr "Archimedische Sehnen" - -#~ msgid "Octagram Spiral" -#~ msgstr "Octagramspirale\t" - -#~ msgid "Has heated bed" -#~ msgstr "Hat Druckbrettheizung" - -#~ msgid "" -#~ "Unselecting this will suppress automatic generation of bed heating gcode." -#~ msgstr "" -#~ "Deaktivirung schaltet Generierung von druckbrett heizungs G-Code aus." - -#~ msgid "Bed temperature for layers after the first one." -#~ msgstr "Druckbrettemperatur für Schichten nach der Ersten." - -#~ msgid "Bottom infill pattern" -#~ msgstr "Boden Infill Muster" - -#~ msgid "" -#~ "Infill pattern for bottom layers. This only affects the external visible " -#~ "layer, and not its adjacent solid shells." -#~ msgstr "" -#~ "Infill Muster für die Bodenschichten. Diese Einstellung betrifft nur die " -#~ "äusere sichtbare Schicht, und nicht den Rand nebenan." - -#~ msgid "Speed > Acceleration" -#~ msgstr "Geschwindigkeit > Beschleunigung" - -#~ msgid "Brim connections width" -#~ msgstr "Krempenanschlussbreite" - -#~ msgid "" -#~ "If set to a positive value, straight connections will be built on the " -#~ "first layer between adjacent objects." -#~ msgstr "" -#~ "Wenn diese Stellung positiv ist dann werden gerade Anschlüsse zwischen " -#~ "anliegenden Gengeständen genderiert." - -#~ msgid "Exterior brim width" -#~ msgstr "Ausenkrempelbreite" - -#~ msgid "" -#~ "This disables the fan completely for the first N layers to aid in the " -#~ "adhesion of media to the bed. (default 3)" -#~ msgstr "" -#~ "Schaltet den Ventilator für die ersten N Schichten aus um der Befestigung " -#~ "an das Druckbrett zu helfen. (Standardeinstellung 3)" - -#~ msgid "↳ external" -#~ msgstr "↳ Außen- " - -#~ msgid "External perimeters extrusion width" -#~ msgstr "Außenumfangsextrusionsbreite" - -#~ msgid "" -#~ "Set this to a non-zero value to set a manual extrusion width for external " -#~ "perimeters. If auto is chosen, a value will be used that maximizes " -#~ "accuracy of the external visible surfaces. If expressed as percentage " -#~ "(for example 200%) it will be computed over layer height." -#~ msgstr "" -#~ "Wenn diese Stellung nicht Null ist dann bestimmt sie die Extrusionsbreite " -#~ "der äuseren Umfänge. Wenn die Stellung \"auto\" ist, dan wird ein Wert " -#~ "benutzt der die Präzision der sichtbaren Oberflächen optimiert. Also " -#~ "Prozent eingegeben (z. B. 200%) wird sie relativ der Schichtendicke " -#~ "ausgerechnet. " - -#~ msgid "External perimeters speed" -#~ msgstr "Außenumfangsgeschwindigkeit" - -#~ msgid "" -#~ "This separate setting will affect the speed of external perimeters (the " -#~ "visible ones). If expressed as percentage (for example: 80%) it will be " -#~ "calculated on the perimeters speed setting above." -#~ msgstr "" -#~ "Diese getrennte Stellung wird bestimmt die Geschwindigkeit des Druckens " -#~ "der (sichtbaren) Ausenumfänge. Als Prozent eingegeben (z. B. 80%) wird " -#~ "sie relativ der Außenumfangsgeschwindigkeitstellung oben ausgerechnet." - -#~ msgid "Add more perimeters when needed for avoiding gaps in sloping walls." -#~ msgstr "" -#~ "Meh Umfänge druken wenn es notwendig ist um Spalten in schrägen " -#~ "Oberflächen zu vermeiden." - -#~ msgid "" -#~ "The extruder to use (unless more specific extruder settings are " -#~ "specified)." -#~ msgstr "" -#~ "Extruder der zu benutzen ist (es sei denn es spezifischere " -#~ "Extruderstellungen gibt)." - -#~ msgid "" -#~ "Set this to a non-zero value to set a manual extrusion width. If " -#~ "expressed as percentage (for example: 230%) it will be computed over " -#~ "layer height." -#~ msgstr "" -#~ "Wenn diese stellung nicht Null ist dann bestimmt sie die " -#~ "Extrusionsbreite. Als Prozent eingegeben (z. B. 230%) wird sie relativ " -#~ "der Schichtdicke ausgerechnet." - -#~ msgid "Fill gaps" -#~ msgstr "Spalten Füllen" - -#~ msgid "" -#~ "If this is enabled, gaps will be filled with single passes. Enable this " -#~ "for better quality, disable it for shorter printing times." -#~ msgstr "" -#~ "Wenn diese Stellung Aktiviert ist wereden Spalten mit einer Durchfahrt " -#~ "gefüllt. Für bessere Qualität anschalten, für schnelleres Drucken " -#~ "ausschalten." - -#~ msgid "" -#~ "Set this to a non-zero value to set a manual extrusion width for first " -#~ "layer. You can use this to force fatter extrudates for better adhesion. " -#~ "If expressed as percentage (for example 120%) it will be computed over " -#~ "first layer height." -#~ msgstr "" -#~ "Auf nicht-null stellen um manuell Extrusionsbreite bei der ersten Schicht " -#~ "zu stellen. Man kann diese stellung benutzen um fettere Extrudate zu " -#~ "zwingen und Adhäsion zu bessern. Als prozent ausgedrückt (z.b. 120%) " -#~ "wird is relativ der ersten Schicht höhe ausgerechnet." - -#~ msgid "↳ gaps" -#~ msgstr "↳ spalten" - -#~ msgid "" -#~ "Speed for filling gaps. Since these are usually single lines you might " -#~ "want to use a low speed for better sticking. If expressed as percentage " -#~ "(for example: 80%) it will be calculated on the infill speed setting " -#~ "above." -#~ msgstr "" -#~ "Geschwindigkeit für Spaltenfüllung. Da diese typisch einzelne Faden sind " -#~ "könnte langsameres Drucken für bessere Haftung angewiesen sein. Als " -#~ "Prozent eigegeben (z.b.: 80%) wird sie relativ der " -#~ "Infillgeschwindingkeitsstellung ausgerechnet." - -#~ msgid "Use native G-code arcs" -#~ msgstr "Eingebaute G-code Kurven Benutzen" - -#~ msgid "" -#~ "This experimental feature tries to detect arcs from segments and " -#~ "generates G2/G3 arc commands instead of multiple straight G1 commands." -#~ msgstr "" -#~ "Diese Experimentalstellung versucht Kurven anzuerkennen und G2/G3 " -#~ "Kurvenbefehle stat mehreren G1 Befehlen in dem Output zu Generieren." - -#~ msgid "" -#~ "Set this to a non-zero value to set a manual extrusion width for infill. " -#~ "You may want to use fatter extrudates to speed up the infill and make " -#~ "your parts stronger. If expressed as percentage (for example 90%) it will " -#~ "be computed over layer height." -#~ msgstr "" -#~ "Wenn diese Stellung nicht Null ist dan bestimmt sie die Extrudsionsbreite " -#~ "des Infills. Fettere Extrudate beim Infill drucken schneller und können " -#~ "fester sein. Als Prozent eingegeben (z.B.: 90%) wird es relativ der " -#~ "Shichtendicke ausgerechnet." - -#~ msgid "Speed for printing the internal fill." -#~ msgstr "Internfilldruckgeschwindigkeit" - -#~ msgid "Interior brim width" -#~ msgstr "Internkrempenbreite" - -#~ msgid "" -#~ "Horizontal width of the brim that will be printed inside object holes on " -#~ "the first layer." -#~ msgstr "" -#~ "Horizontalbreite der Krempe die in Löchern in der ersten Schicht gedruckt " -#~ "wird." - -#~ msgid "" -#~ "During multi-extruder prints, this option will drop the temperature of " -#~ "the inactive extruders to prevent oozing. It will enable a tall skirt " -#~ "automatically and move extruders outside such skirt when changing " -#~ "temperatures." -#~ msgstr "" -#~ "Bei multi-Extruder Drucken wird diese Stelling die Teperatur der nicht " -#~ "aktiven Extruder fallen lassen um Sickern zu vermeiden. Sie aktiviert " -#~ "automatisch eine große Zarge und hält die extruder bei Temperaturwechel " -#~ "auserhalb dieser Zarge." - -#~ msgid "Overridable options" -#~ msgstr "Überbrückbare Einstellungen" - -#~ msgid "" -#~ "Set this to a non-zero value to set a manual extrusion width for " -#~ "perimeters. You may want to use thinner extrudates to get more accurate " -#~ "surfaces. If expressed as percentage (for example 200%) it will be " -#~ "computed over layer height." -#~ msgstr "" -#~ "Wenn diese stellung nicht Null ist dan bestimmt sie the Extrusionsbreite " -#~ "von Umfgängen. Mann will eventuel dunnere Extrudate benutzen um genauere " -#~ "Oberflächen zu drucken. Als Prozent eigegeben (z.B.: 200%) wird sie " -#~ "relativ der Schichtdicke ausgerechnet." - -#~ msgid "Speed for perimeters (contours, aka vertical shells)." -#~ msgstr "Geschwindigkeit für Umfänge." - -#~ msgid "" -#~ "If you want to process the output G-code through custom scripts, just " -#~ "list their absolute paths here. Separate multiple scripts on individual " -#~ "lines. Scripts will be passed the absolute path to the G-code file as the " -#~ "first argument, and they can access the Slic3r config settings by reading " -#~ "environment variables." -#~ msgstr "" -#~ "Wenn man Programme den G-code automatisch nacharbeiten lassen will, kann " -#~ "man hier deren absolute Pfade eingeben. Jedes program auf seine einge " -#~ "zeile eingeben. Der Pfad zum G-code wird als erstes " -#~ "Kommandozeilenargument ans Programm gegeben, und die programme können " -#~ "Slic3r Einstellungen as Umgebungsvariable abrufen." - -#~ msgid "Pressure advance" -#~ msgstr "Düsendruckkontrolle" - -#~ msgid "" -#~ "When set to a non-zero value, this experimental option enables pressure " -#~ "regulation. It's the K constant for the advance algorithm that pushes " -#~ "more or less filament upon speed changes. It's useful for Bowden-tube " -#~ "extruders. Reasonable values are in range 0-10." -#~ msgstr "" -#~ "Wenn diese Experimentalstellung nicht Null ist dann ist " -#~ "Düsendruckkontrolle aktiviert. Die Stellung ist die K Konstante die der " -#~ "Vorrücksalogrithmus der mehr oder weniger Filament bei " -#~ "Geschwindigkeitsänderungen schiebt. Nützlich bei Bowden-tube Extrudern. " -#~ "0-10 sind zumutbare Stellungen." - -#~ msgid "Raft offset" -#~ msgstr "Gründungsfloßversatz" - -#~ msgid "Horizontal margin between object base layer and raft contour." -#~ msgstr "" -#~ "Horizontalspielraum zwischen Objectbasisschicht und Gründungsfloßkontur" - -#~ msgid "Resolution (deprecated)" -#~ msgstr "Auflösung (veraltet)" - -#~ msgid "" -#~ "The speed for retractions (it only applies to the extruder motor). If you " -#~ "use the Firmware Retraction option, please note this value still affects " -#~ "the auto-speed pressure regulator." -#~ msgstr "" -#~ "Einziehungsgeschwindigkeit (betrifft nur den Extrudermotor.) Man sei " -#~ "angewiesen dass wenn die Firmwareeinziehungsstellung benutzt wird, diese " -#~ "stellung trotzdem den \"auto-speed pressure regulator\" betrifft." - -#~ msgid "↳ small" -#~ msgstr "↳ klein" - -#~ msgid "" -#~ "This separate setting will affect the speed of perimeters having radius " -#~ "<= 6.5mm (usually holes). If expressed as percentage (for example: 80%) " -#~ "it will be calculated on the perimeters speed setting above." -#~ msgstr "" -#~ "Diese getrennte stelling betrifft the Druckgeschwindigkeit von Umfängen " -#~ "mit Radius <= 6.5mm (normalerweise in Löchern). Als Prozent eigegeben (z. " -#~ "B.: 80%) wird sie relativ der Umfangsgeschwindigkeit oben ausgerechnet." - -#~ msgid "↳ solid" -#~ msgstr "↳ massiv" - -#~ msgid "" -#~ "Set this to a non-zero value to set a manual extrusion width for infill " -#~ "for solid surfaces. If expressed as percentage (for example 90%) it will " -#~ "be computed over layer height." -#~ msgstr "" -#~ "Wenn diese Einstellung nicht Null ist dann bestimmt sie die " -#~ "Extrusionsbreite von festeb Oberflächen. Als Prozent eingegeben (z. B. " -#~ "90%) wird sie relativ der Schichtdicke ausgerechnet." - -#~ msgid "" -#~ "Speed for printing solid regions (top/bottom/internal horizontal shells). " -#~ "This can be expressed as a percentage (for example: 80%) over the default " -#~ "infill speed above." -#~ msgstr "" -#~ "Druckgeschwindigkeit für dichte zonen (Boden/Decke/internen horizontalen " -#~ "Hüllen). Als Prozent eingegeben (z. B.: 80%) wirds sie relativ der " -#~ "Standardinfillgetschwindigkeit ausgerechnet." - -#~ msgid "" -#~ "Temperature difference to be applied when an extruder is not active. " -#~ "Enables a full-height \"sacrificial\" skirt on which the nozzles are " -#~ "periodically wiped." -#~ msgstr "" -#~ "Temperaturunterschied der den nicht aktiven Extrudern bezogen wird. " -#~ "Aktiviert eine große Opferzarge an der die Düsen abgewischt werden." - -#~ msgid "" -#~ "This start procedure is inserted at the beginning, after bed has reached " -#~ "the target temperature and extruder just started heating, and before " -#~ "extruder has finished heating. If Slic3r detects M104, M109, M140 or M190 " -#~ "in your custom codes, such commands will not be prepended automatically " -#~ "so you're free to customize the order of heating commands and other " -#~ "custom actions. Note that you can use placeholder variables for all " -#~ "Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" " -#~ "command wherever you want." -#~ msgstr "" -#~ "Diese Routine wird am anfang des G-codes eingefügt, nachdem das " -#~ "Druckbrett aufgeheizt ist und die Extruder heizung grade angeschaltet " -#~ "ist, und vordem der Extruder seine Zieltemperatur erreicht hat. Wenn " -#~ "Slic3r M104, M109, M140, oder M190 in dieser Routine erkennt dann werden " -#~ "solche Codes nicht automatisch generiert so dass man die reinfolge der " -#~ "Heizungsbefehle frei anpassen kann. Man kann in diesm Code Platzhalter " -#~ "anwenden, zum Beispiel, könnte irgendwo in der Routine der \"M109 " -#~ "S[first_layer_temperature]\" Befehl stehen." - -#~ msgid "The extruder to use when printing support material, raft and skirt." -#~ msgstr "" -#~ "Der Extruder der bei Unterstützungsmaterial Gründungsfloß und Zargen zu " -#~ "benutzen ist." - -#~ msgid "" -#~ "Set this to a non-zero value to set a manual extrusion width for support " -#~ "material. If expressed as percentage (for example 90%) it will be " -#~ "computed over layer height." -#~ msgstr "" -#~ "Wenn diese stellung nicht Null ist dan bestimmt sie die Extrusionsbreite " -#~ "des Unterstützungsmaterial. Als Prozent eingegeben (z. B. 90%) wird sie " -#~ "relativ der Schichtendicke ausgerechnet." - -#~ msgid "" -#~ "The extruder to use when printing support material interface. This " -#~ "affects raft too." -#~ msgstr "" -#~ "Extruder der beim drucken der Schnittstelle zwischen " -#~ "Unterstützungsmaterial und Objekt, und zu benutzen ist. Betrifft auch " -#~ "die Schnittstelle zwischen dem Gründungsfloß und dem Objekt." - -#~ msgid "↳ interface" -#~ msgstr "↳ Schnitstellen" - -#~ msgid "Interface Speed" -#~ msgstr "Schnittstellendruckgeschwindigkeit" - -#~ msgid "Support material interface speed" -#~ msgstr "Unterstützungsmaterialschnittstellendruckgeschwindigkeit" - -#~ msgid "" -#~ "Support material will not be generated for overhangs whose slope angle " -#~ "(90° = vertical) is above the given threshold. In other words, this value " -#~ "represent the most horizontal slope (measured from the horizontal plane) " -#~ "that you can print without support material. Set to a percentage to " -#~ "automatically detect based on some % of overhanging perimeter width " -#~ "instead (recommended)." -#~ msgstr "" -#~ "Understützungsmaterial wird nicht generiert wenn der Winkel eines " -#~ "Überhangs größer ist als diese stellung (90° = vertikal). Anders " -#~ "gesagt: Diese stellung ist der flachste Winke (von Horizontal gemessen) " -#~ "den man ohne Understützungsmaterial drucken kann. Als Prozent eingeben " -#~ "um statdessen automatisch als % von überhängenden Umfang anzuerkennen " -#~ "(empfohlen)." - -#, fuzzy -#~ msgid "↳ top solid" -#~ msgstr "↳ Dichte Decke" - -#~ msgid "" -#~ "Set this to a non-zero value to set a manual extrusion width for infill " -#~ "for top surfaces. You may want to use thinner extrudates to fill all " -#~ "narrow regions and get a smoother finish. If expressed as percentage (for " -#~ "example 90%) it will be computed over layer height." -#~ msgstr "" -#~ "Wenn nicht null bestimmt diese Stellung the Extrusionsbreite für " -#~ "Deckenoberflächen. Mann will vielleicht dünnere Extrudate um schmale " -#~ "Zonen zu füllen und eine glatte Oberfläche zue ducken. Als Prozent " -#~ "eingegeben (z. B. 90%) wird sie relativ der Schichtdicke ausgerechnet." - -#~ msgid "" -#~ "Infill pattern for top layers. This only affects the external visible " -#~ "layer, and not its adjacent solid shells." -#~ msgstr "" -#~ "Infillmuster für Deckenschichten. Diese Stellung betrifft nur die " -#~ "äusere sichtbare Schicht und nicht dem dichten Rand nebenan." - -#~ msgid "" -#~ "Speed for printing top solid layers (it only applies to the uppermost " -#~ "external layers and not to their internal solid layers). You may want to " -#~ "slow down this to get a nicer surface finish. This can be expressed as a " -#~ "percentage (for example: 80%) over the solid infill speed above." -#~ msgstr "" -#~ "Druckgeschwindigkeit für Oberschichten (betrifft nur die äusere sichtbare " -#~ "Schicht und nicht dem dichten Rand nebenan). Mann will eventuel " -#~ "langsamer drucken um eine bessere Oberflächenqualität zu erhalten. Als " -#~ "Prozent eingegeben (z. B. 80%) wird diese Stellung relativ der " -#~ "Infillgeschwindingkeitsstellung ausgerechnet." - -#~ msgid "Vibration limit (deprecated)" -#~ msgstr "Vibrirgrenze (veraltet)" - -#~ msgid "" -#~ "This experimental option will slow down those moves hitting the " -#~ "configured frequency limit. The purpose of limiting vibrations is to " -#~ "avoid mechanical resonance. Set zero to disable." -#~ msgstr "" -#~ "Diese Experimentalstellung werden Bewegungen die die Eingestellte " -#~ "Frequenz treffen verlangsamt. Das Ziel des Einschränken der Vibrationen " -#~ "ist mechanische Resonanz zu vermeiden. Zu deaktivieren auf Null stellen." - -#~ msgid "Z full steps/mm" -#~ msgstr "Z Vollschritte/mm" - -#~ msgid "" -#~ "Set this to the number of *full* steps (not microsteps) needed for moving " -#~ "the Z axis by 1mm; you can calculate this by dividing the number of " -#~ "microsteps configured in your firmware by the microstepping amount (8, " -#~ "16, 32). Slic3r will round your configured layer height to the nearest " -#~ "multiple of that value in order to ensure the best accuracy. This is most " -#~ "useful for machines with imperial leadscrews or belt-driven Z or for " -#~ "unusual layer heights with metric leadscrews. Set to zero to disable this " -#~ "experimental feature." -#~ msgstr "" -#~ "Die Zahl der *Voll*schritte (nicht Microschritte) die die Z-achse 1mm " -#~ "bewegen. Mann kann diese Zahl ausrechnen wenn man die Zahl von " -#~ "Micrschritten in der Firmware durch die Microschrittmenge (8, 16, 32) " -#~ "teilt. Slicer wird die Schichtdicke auf das nähste Vielfache davon " -#~ "abrunden um für die beste Genauigkeit zu sorgen. Nützlich wenn der " -#~ "Drucker Imperialeinheitenleitspindel oder ungewöhnliche Z-Schritte " -#~ "macht. Zum deaktivieren auf Null stellen." - -#~ msgid "Cut" -#~ msgstr "Schnitt" - -#~ msgid "Cut model at the given Z." -#~ msgstr "Model an dem eingegeben Z-Wert Abschneiden" - -#~ msgid "Cut model in the XY plane into tiles of the specified max size." -#~ msgstr "" -#~ "Model in der XY-Ebene in Kacheln der eingegeben Maximalgöße aufteilen." - -#~ msgid "Cut model at the given X." -#~ msgstr "Model an dem eingegeben X-Wert Abschneiden" - -#~ msgid "Cut model at the given Y." -#~ msgstr "Model an dem eingegeben X-Wert Abschneiden" - -#~ msgid "Export SVG" -#~ msgstr "SVG Datei Export" - -#~ msgid "Export the model as OBJ." -#~ msgstr "Datei als OBJ Exportieren" - -#~ msgid "Export POV" -#~ msgstr "POV Datei Export" - -#~ msgid "Export the model as POV-Ray definition." -#~ msgstr "Model als POV-Ray definition exportieren." - -#~ msgid "Slice the model and export slices as SVG." -#~ msgstr "Model aufschneiden und the Scheiben als SVG exportieren." - -#~ msgid "Output Model Info" -#~ msgstr "Modelinfo Ausgeben" - -#~ msgid "Write information about the model to the console." -#~ msgstr "Information über das Model an die Konsole schreiben." - -#~ msgid "Load config file" -#~ msgstr "Config Datei Laden" - -#~ msgid "" -#~ "Load configuration from the specified file. It can be used more than once " -#~ "to load options from multiple files." -#~ msgstr "" -#~ "Konfiguration von der eingegebenen Datei laden. Kann mehrmals benutzt um " -#~ "Optionen von mehreren Dateien zu laden." - -#~ msgid "Output File" -#~ msgstr "Outputdatei" - -#~ msgid "" -#~ "The file where the output will be written (if not specified, it will be " -#~ "based on the input file)." -#~ msgstr "" -#~ "Die Datei wo der Output gespeichert wird. (Wenn kein name eingegeben ist " -#~ "bestimmt die Inputdatei die Outputdatei.)" - -#~ msgid "Rotation angle around the Z axis in degrees (0-360, default: 0)." -#~ msgstr "Drehwinkel um die Z-Achse in Grad (0-360, Standard: 0)." - -#~ msgid "Rotate around X" -#~ msgstr "Um X Drehen" - -#~ msgid "Rotation angle around the X axis in degrees (0-360, default: 0)." -#~ msgstr "Drehwinkel um die X-Achse in Grad (0-360, Standard: 0)." - -#~ msgid "Rotate around Y" -#~ msgstr "Um X Drehen" - -#~ msgid "Rotation angle around the Y axis in degrees (0-360, default: 0)." -#~ msgstr "Drehwinkel um die Y-Achse in Grad (0-360, Standard: 0)." - -#~ msgid "Save config file" -#~ msgstr "Konfiguration speichern" - -#~ msgid "Save configuration to the specified file." -#~ msgstr "Konfiguration in der eingegeben Datei speichern" - -#~ msgid "Scaling factor (default: 1)." -#~ msgstr "Skalierfaktor (Standard: 1)." - -#~ msgid "Scale to Fit" -#~ msgstr "Anpassend skalieren" - -#~ msgid "Scale to fit the given volume." -#~ msgstr "Dem eingegebenen Volum anpassend skalieren." +msgstr "°" diff --git a/resources/localization/it/Slic3rPE.mo b/resources/localization/it/Slic3rPE.mo new file mode 100644 index 0000000000000000000000000000000000000000..a6cb61ead50f1d1d2f59c78fc26018d4772d2bf0 GIT binary patch literal 106597 zcmeF4cbr^R`Ty?%QdW^73Q{j6$p*5!DbxgnR0yOj+0a6Xv%8bsA+s~f%xsznsDK4g zP(%>L1{Sa&*pMQEilCxc5i5$QfCcO#`g?z#=bSrtHVFpx_5FVT_|0qYe(pK<+*6

4cq_O!_z<`! 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\n" +"Language-Team: \n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 +msgid "" +"\n" +"\n" +"and it has the following unsaved changes:" +msgstr "" +"\n" +"\n" +"e sono presenti le seguenti modifiche non salvate:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1491 +msgid "" +"\n" +"\n" +"Discard changes and continue anyway?" +msgstr "" +"\n" +"\n" +"Eliminare le modifiche e continuare comunque?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1489 +msgid "" +"\n" +"\n" +"has the following unsaved changes:" +msgstr "" +"\n" +"\n" +"ha le seguenti modifiche non salvate:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 +msgid "" +"\n" +"\n" +"is not compatible with printer\n" +msgstr "" +"\n" +"\n" +"non è compatibile con la stampante\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:34 +msgid "" +"\n" +"During the other layers, fan " +msgstr "" +"\n" +"Durante gli altri layer, la ventola " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:30 +#, c-format +msgid "" +"\n" +"If estimated layer time is greater, but still below ~%ds, fan will run at a proportionally decreasing speed between %d%% and %d%%." +msgstr "" +"\n" +"Se il tempo di stampa previsto per il layer è più lungo, ma comunque inferiore a ~%ds, la ventola girerà ad una velocità proporzionalmente decrescente compresa tra %d%% e %d%%." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:927 +msgid "" +"\n" +"Non-positive value." +msgstr "" +"\n" +"Valore non positivo." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:928 +msgid "" +"\n" +"Not a numeric value." +msgstr "" +"\n" +"Valore non numerico." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 +msgid " - Remember to check for updates at http://github.com/prusa3d/slic3r/releases" +msgstr " - Ricorda di controllare gli aggiornamenti su http://github.com/prusa3d/slic3r/releases" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 +msgid " as:" +msgstr " come:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:226 +#, c-format +msgid " at filament speed %3.2f mm/s." +msgstr " alla velocità del filamento di %3.2f mm/s." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1035 +msgid " Browse " +msgstr " Naviga " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 +msgid " file as:" +msgstr " file come:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:215 +msgid " flow rate is maximized " +msgstr " Il flusso viene massimizzato " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 +#, no-c-format +msgid "" +" infill pattern is not supposed to work at 100% density.\n" +"\n" +"Shall I switch to rectilinear fill pattern?" +msgstr "" +" il pattern di riempimento non dovrebbe funzionare con densità 100%.\n" +"\n" +"Posso cambiarlo in pattern di riempimento rettilineo?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1470 +msgid " preset\n" +msgstr " preset\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 +msgid " preset" +msgstr " preset" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1583 +msgid " Preset" +msgstr " Preset" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:942 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1637 +msgid " Set " +msgstr " Imposta " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 +msgid " the selected preset?" +msgstr " il preset selezionato?" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:548 +msgid " was successfully sliced." +msgstr " generato con successo." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:220 +msgid " with a volumetric rate " +msgstr " con una portata volumetrica " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:99 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:504 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:789 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:850 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1060 +msgid "%" +msgstr "%" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:224 +#, c-format +msgid "%3.2f mm³/s" +msgstr "%3.2f mm³/s" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1958 +#, perl-format +msgid "%d (%d shells)" +msgstr "%d (%d di perimetri)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1965 +#, perl-format +msgid "%d degenerate facets, %d edges fixed, %d facets removed, %d facets added, %d facets reversed, %d backwards edges" +msgstr "%d facce degenerate, %d spigoli riparati, %d facce rimosse, %d faccee aggiunte, %d facce invertite, %d spigoli inversi" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:269 +#, c-format +msgid "%d lines: %.2lf mm" +msgstr "%d linee: %.2lf mm" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:687 +#, perl-format +msgid "%d presets successfully imported." +msgstr "%d preset importati correttamente." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 +msgid "&About Slic3r" +msgstr "&Su Slic3r" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 +msgid "&Configuration " +msgstr "&Configurazione " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 +msgid "&Export Config Bundle…" +msgstr "&Esporta Gruppo di Configurazioni…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 +msgid "&Export Config…\tCtrl+E" +msgstr "&Esporta Configurazione… \tCtrl+E" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:418 +msgid "&File" +msgstr "&File" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:426 +msgid "&Help" +msgstr "&Aiuto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 +msgid "&Load Config Bundle…" +msgstr "&Carica Gruppo di Configurazioni…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 +msgid "&Load Config…\tCtrl+L" +msgstr "Carica Configurazione…\tCtrl+&L" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:339 +msgid "&Localization" +msgstr "&Localizazione" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:420 +msgid "&Object" +msgstr "&Oggetto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:419 +msgid "&Plater" +msgstr "&Piano" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 +msgid "&Quit" +msgstr "&Chiudi" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 +msgid "&Repeat Last Quick Slice\tCtrl+Shift+U" +msgstr "&Ripeti l'ultimo Slice Rapido\tCtrl+Shift+U" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:422 +msgid "&View" +msgstr "&Vista" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:421 +msgid "&Window" +msgstr "&Finestra" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 +msgid "(&Re)Slice Now\tCtrl+S" +msgstr "(&Re)Slice Ora\tCtrl+S" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:994 +msgid "(minimum)" +msgstr "(minimo)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 +msgid ") not found." +msgstr ") non trovato." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:215 +msgid "). Check hostname and OctoPrint version (at least 1.1.0 is required)." +msgstr "). Verifica l'hostname e la versione di OctoPrint ( ver. 1.1.0 o successive)." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 +msgid ". Discard changes and continue anyway?" +msgstr ". Scartare le modifiche e continuare comunque?" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:63 +msgid "1 Layer" +msgstr "1 Layer" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:138 +msgid "2D" +msgstr "2D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:104 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2124 +msgid "3D" +msgstr "3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1608 +msgid "3MF file exported to " +msgstr "File 3MF esportato a " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:185 +msgid "45° ccw" +msgstr "45° antiorario" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:186 +msgid "45° cw" +msgstr "45° senso orario" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:148 +msgid "A boolean expression using the configuration values of an active printer profile. If this expression evaluates to true, this profile is considered compatible with the active printer profile." +msgstr "Un'espressione booleana che usa i valori di configurazione di un profilo stampante attivo. Se questa espressione produce un risultato vero, questo profilo si considera compatibile con il profilo stampante attivo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1099 +msgid "Above Z" +msgstr "Sopra Z" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:417 +msgid "Acceleration control (advanced)" +msgstr "Controllo Accelerazione (avanzato)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1566 +msgid "Add a sheath (a single perimeter line) around the base support. This makes the support more reliable, but also more difficult to remove." +msgstr "Aggiunge un contorno (una singola linea di perimetro) attorno alla base del supporto. Questo rende il supporto più affidabile, ma anche più difficile da rimuovere." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:299 +#, no-c-format +msgid "Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r keeps adding perimeters, until more than 70% of the loop immediately above is supported." +msgstr "Aggiunge più perimetri quando necessario per evitare spazi tra i perimetri inclinati. Slic3r continua ad aggiungere perimetri fino a quando almeno il 70% del giro immediatamente sopra sarà supportato." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:240 +msgid "Add solid infill near sloping surfaces to guarantee the vertical shell thickness (top+bottom solid layers)." +msgstr "Aggiunge un riempimento solido vicino le superfici inclinate per garantire lo spessore verticale (layer solidi superiore + inferiore)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:177 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:195 +msgid "Add…" +msgstr "Aggiungi…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:342 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:356 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:449 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:452 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:831 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1113 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:107 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:208 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:736 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1733 +msgid "Advanced" +msgstr "Avanzate" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1138 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:766 +msgid "After layer change G-code" +msgstr "Dopo il G-code di cambio di strato" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1636 +msgid "All" +msgstr "Tutto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 +msgid "Along X axis…" +msgstr "Lungo l'asse X…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 +msgid "Along Y axis…" +msgstr "Lungo l'asse Y…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 +msgid "Along Z axis…" +msgstr "Lungo l'asse Z…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1592 +msgid "AMF file exported to " +msgstr "File AMF esportato a " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 +msgid "Another export job is currently running." +msgstr "Un altro processo di esportazione è in corso." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:901 +msgid "API Key" +msgstr "API Key" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 +msgid "Application preferences" +msgstr "Preferenze applicazione" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 +msgid "Application will be restarted" +msgstr "L'applicazione verrà riavviata" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:397 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1242 +msgid "approximate seconds" +msgstr "secondi approssimativi" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 +msgid "Are you sure you want to " +msgstr "Sei sicuro di voler " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 +msgid "Around X axis…" +msgstr "Attorno l'asse X…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 +msgid "Around Y axis…" +msgstr "Attorno l'asse Y…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 +msgid "Around Z axis…" +msgstr "Attorno l'asse Z…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:180 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:198 +msgid "Arrange" +msgstr "Organizza" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:224 +msgid "Array of language names and identifiers should have the same size." +msgstr "Gli array dei nomi di lingua e gli identificatori dovrebbero avere la stessa dimensione." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 +msgid "Attention!" +msgstr "Attenzione!" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:35 +msgid "Auto-center parts" +msgstr "Auto-centra le parti" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1960 +#, perl-format +msgid "Auto-repaired (%d errors)" +msgstr "Auto-riparati (%d errori)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 +msgid "Automatically repair an STL file" +msgstr "Ripara automaticamente un file STL" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:424 +msgid "Autospeed (advanced)" +msgstr "Autovelocità (avanzato)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:26 +msgid "Avoid crossing perimeters" +msgstr "Evita incrocio perimetri" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:43 +msgid "Background processing" +msgstr "Lavorazione in background" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:800 +msgid "Bed" +msgstr "Letto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp:42 +msgid "Bed Shape" +msgstr "Forma Letto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:940 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:34 +msgid "Bed shape" +msgstr "Forma letto" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:42 +msgid "Bed temperature" +msgstr "Temperatura letto" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:39 +msgid "Bed temperature for layers after the first one. Set this to zero to disable bed temperature control commands in the output." +msgstr "Temperatura per i layer dopo il primo. Imposta questo a zero per disattivare i comandi di controllo della temperatura del letto in output." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1132 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:48 +msgid "Before layer change G-code" +msgstr "Prima del G-code di cambio di strato" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1108 +msgid "Below Z" +msgstr "Sotto Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:59 +msgid "Between objects G-code" +msgstr "G-code tra gli oggetti" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1150 +msgid "Between objects G-code (for sequential printing)" +msgstr "G-code tra gli oggetti (per stampa sequenziale)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:68 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 +msgid "Bottom" +msgstr "Inferiore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:72 +msgid "Bottom solid layers" +msgstr "Layer solidi sul fondo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 +msgid "Bottom View" +msgstr "Vista inferiore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:77 +msgid "Bridge" +msgstr "Bridge" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:106 +msgid "Bridge flow ratio" +msgstr "Rapporto flusso Bridge" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:144 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:86 +msgid "Bridge infill" +msgstr "Riempimento Bridge" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:117 +msgid "Bridges" +msgstr "Bridge" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:97 +msgid "Bridges fan speed" +msgstr "Velocità ventola Bridge" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:86 +msgid "Bridging angle" +msgstr "Angolo Ponteggio" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:88 +msgid "Bridging angle override. If left to zero, the bridging angle will be calculated automatically. Otherwise the provided angle will be used for all bridges. Use 180° for zero angle." +msgstr "Ignora angolo Bridging. Se lasciato a zero, l'angolo di bridging verrà calcolato automaticamente. Altrimenti l'angolo fornito sarà utilizzato per tutti i bridge. Usa 180° per l'angolo zero." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "Bridging volumetric" +msgstr "Ponteggio volumetrico" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:371 +msgid "Brim" +msgstr "Brim" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:127 +msgid "Brim width" +msgstr "Larghezza brim" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:218 +msgid "by the print profile maximum" +msgstr "secondo il massimo del profilo di stampa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:962 +msgid "Capabilities" +msgstr "Capacità" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:325 +msgid "Change Application Language" +msgstr "Cambia Lingua Applicazione" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 +msgid "Change the number of copies of the selected object" +msgstr "Cambia il numero di copie dell'oggetto selezionato" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:298 +msgid "Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Scegli un file per importare la forma del piano da (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:457 +msgid "Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Scegli un file da processare (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\lib\Slic3r\GUI.pm:286 +msgid "Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Scegli uno o più file (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:62 +msgid "Circular" +msgstr "Circolare" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:135 +msgid "Clip multi-part objects" +msgstr "Collega oggetti multi-part" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:405 +msgid "Color" +msgstr "Colore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:690 +msgid "Combine infill every" +msgstr "Combina riempimento ogni" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:696 +msgid "Combine infill every n layers" +msgstr "Combina riempimento ogni n layer" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:509 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:869 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1668 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:143 +msgid "Compatible printers" +msgstr "Stampanti compatibili" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:147 +msgid "Compatible printers condition" +msgstr "Condizioni di stampante compatibile" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:154 +msgid "Complete individual objects" +msgstr "Completa oggetti individuali" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:884 +msgid "Configuration notes" +msgstr "Note di configurazione" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1020 +msgid "Connection failed." +msgstr "Connessione fallita." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:211 +msgid "Connection to OctoPrint works correctly." +msgstr "Connessione con OctoPrint funzionante." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 +msgid "Connection to printer works correctly." +msgstr "Connessione con la stampante funzionante." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1416 +msgid "Contact Z distance" +msgstr "Distanza di contatto Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:120 +msgid "Controller" +msgstr "Controller" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:805 +msgid "Cooling" +msgstr "Raffreddamento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:826 +msgid "Cooling thresholds" +msgstr "Soglia di raffreddamento" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:221 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 +msgid "Copies" +msgstr "Copie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:476 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:450 +msgid "Cost" +msgstr "Costo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1465 +msgid "Cover the top contact layer of the supports with loops. Disabled by default." +msgstr "Copri lo strato di contatto superiore del supporto con anelli. Disattivato per impostazione predefinita." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:71 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:150 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:92 +msgid "Custom" +msgstr "Personalizzato" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:846 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119 +msgid "Custom G-code" +msgstr "G-code personalizzato" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:189 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:205 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 +msgid "Cut…" +msgstr "Taglia…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 +msgid "Decrease copies" +msgstr "Diminuisci le copie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:300 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:170 +msgid "Default" +msgstr "Predefinito" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp:42 +msgid "default" +msgstr "predefinito" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 +msgid "Default " +msgstr "Predefinito " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:489 +msgid "Default base angle for infill orientation. Cross-hatching will be applied to this. Bridges will be infilled using the best direction Slic3r can detect, so this setting does not affect them." +msgstr "Angolo base predefinito per l'orientamento del riempimento. Su questo verrà applicato il tratteggio. I bridge saranno riempiti utilizzando la migliore direzione che Slic3r può determinare, quindi questa impostazione non influisce sui bridge." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:376 +msgid "Default extrusion width" +msgstr "Larghezza estrusione predefinita" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:178 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:196 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 +msgid "Delete" +msgstr "Cancella" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 +msgid "delete" +msgstr "cancella" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:179 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:197 +msgid "Delete All" +msgstr "Cancella tutto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:51 +msgid "Delete this preset" +msgstr "Cancella questo preset" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:440 +msgid "Density" +msgstr "Densità" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:503 +#, no-c-format +msgid "Density of internal infill, expressed in the range 0% - 100%." +msgstr "Densità del riempimento interno, espresso nell'intervallo 0% - 100%." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:507 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:867 +msgid "Dependencies" +msgstr "Dipendenze" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1724 +msgid "Depth of a wipe color per color change. For N colors, there will be maximum (N-1) tool switches performed, therefore the total depth of the wipe tower will be (N-1) times this value." +msgstr "Profondità di spurgo colore per ogni cambio colore. Per N colori, avverranno massimo (N-1) cambi di arnese, quindi la profondità totale della torre di spurgo sarà (N-1) volte questo valore." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1142 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1143 +msgid "Deretraction Speed" +msgstr "Velocità di deretrazione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:940 +msgid "Detect bridging perimeters" +msgstr "Rileva perimetri ponte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1584 +msgid "Detect single-width walls (parts where two extrusions don't fit and we need to collapse them into a single trace)." +msgstr "Rileva pareti a spessore singolo (parti in cui non entrano due estrusioni ed è necessario comprimerle in una singola traccia)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1582 +msgid "Detect thin walls" +msgstr "Rileva perimetri sottili" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 +msgid "Device Browser" +msgstr "Browser dispositivi" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:66 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:431 +msgid "Diameter" +msgstr "Diametro" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:67 +msgid "Diameter of the print bed. It is assumed that origin (0,0) is located in the center." +msgstr "Diametro del piano di stampa. Si presume che l'origine (0,0) si trovi al centro." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1169 +msgid "Direction" +msgstr "Direzione" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:53 +msgid "Disable communication with the printer over a serial / USB cable. This simplifies the user interface in case the printer is never attached to the computer." +msgstr "Disabilita la comunicazione con la stampante tramite cavo seriale / USB. Questo semplifica l'interfaccia utente nel caso in cui la stampante non sia mai connessa al computer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:180 +msgid "Disable fan for the first" +msgstr "Disattiva ventola per i primi" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:51 +msgid "Disable USB/serial connection" +msgstr "Disattiva connessione USB/seriale" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:916 +msgid "Disables retraction when the travel path does not exceed the upper layer's perimeters (and thus any ooze will be probably invisible)." +msgstr "Disabilita la retrazione quando la traiettoria del movimento non oltrepassa i perimetri del layer superiore (pertanto qualunque scolatura sarà probabilmente invisibile)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:198 +msgid "Distance between copies" +msgstr "Distanza tra le copie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1213 +msgid "Distance between skirt and object(s). Set this to zero to attach the skirt to the object(s) and get a brim for better adhesion." +msgstr "La distanza tra skirt e oggetto(i). Imposta questo valore a zero per unire lo skirt all'oggetto(i) e ottenere un brim per una migliore adesione." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1212 +msgid "Distance from object" +msgstr "Distanza dall'oggetto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:58 +msgid "Distance of the 0,0 G-code coordinate from the front left corner of the rectangle." +msgstr "Distanza della coordinata 0,0 del G-code dall'angolo frontale sinistro del rettangolo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:199 +msgid "Distance used for the auto-arrange feature of the plater." +msgstr "Distanza usata per la funzione disposizione automatica del piatto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:190 +msgid "Don't support bridges" +msgstr "Non supportare i bridge" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:132 +msgid "Drag your objects here" +msgstr "Trascina qui i tuoi oggetti" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:207 +msgid "Elephant foot compensation" +msgstr "Compensazione zampa d'elefante" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:806 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:922 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1695 +msgid "Enable" +msgstr "Abilita" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:163 +msgid "Enable auto cooling" +msgstr "Abilita auto raffreddamento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:394 +msgid "Enable fan if layer print time is below" +msgstr "Abilita ventola se il tempo di stampa del layer è inferiore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1381 +msgid "Enable support material generation." +msgstr "Abilita la creazione di materiale di supporto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:645 +msgid "Enable this to get a commented G-code file, with each line explained by a descriptive text. If you print from SD card, the additional weight of the file could make your firmware slow down." +msgstr "Abilita per ottenere un file G-code commentato, con un testo descrittivo per ciascuna linea. Se stampi da memoria SD, il peso aggiuntivo del file potrebbe rallentare il tuo firmware." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1681 +msgid "Enable variable layer height feature" +msgstr "Abilita la funzione Layer ad altezza variabile" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:853 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1126 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:217 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:227 +msgid "End G-code" +msgstr "Fine G-code" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1431 +msgid "Enforce support for the first" +msgstr "Applica il supporto per i primi" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1439 +msgid "Enforce support for the first n layers" +msgstr "Applica il supporto per i primi n layer" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:238 +msgid "Ensure vertical shell thickness" +msgstr "Mantieni spessore guscio verticale" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +msgid "Enter the new max size for the selected object:" +msgstr "Inserisci la nuova dimensione massima per l'oggetto selezionato:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1030 +#, perl-format +msgid "Enter the new size for the selected object (print bed: %smm):" +msgstr "Inserisci la nuova dimensione massima per l'oggetto selezionato (piano di stampa: %smm):" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 +msgid "Enter the number of copies of the selected object:" +msgstr "Inserisci il numero di copie dell'oggetto selezionato:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Enter the rotation angle:" +msgstr "Inserisci l'angolo di rotazione:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +#, no-perl-format +msgid "Enter the scale % for the selected object:" +msgstr "Inserisci il fattore di scala % per l'oggetto selezionato:" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:477 +msgid "Enter your filament cost per kg here. This is only for statistical information." +msgstr "Inserisci qui il costo del filamento per kg. E' solo un'informazione statistica." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:441 +msgid "Enter your filament density here. This is only for statistical information. A decent way is to weigh a known length of filament and compute the ratio of the length to volume. Better is to calculate the volume directly through displacement." +msgstr "Inserisci qui la densità del filamento. E' solo un'informazione statistica. Un metodo approssimativo consiste nel pesare un pezzo di filamento di lunghezza nota, e calcolare il rapporto tra lunghezza e volume. E' meglio calcolare il volume direttamente attraverso il dislocamento." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:432 +msgid "Enter your filament diameter here. Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average." +msgstr "Inserisci qui il diametro del filamento. E' richiesta una buona precisione, pertanto usa un calibro ed esegui misurazioni multiple lungo il filamento, per poi ricavare una media." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:488 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:470 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 +msgid "Error" +msgstr "Errore" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1612 +msgid "Error exporting 3MF file " +msgstr "Errore nell'esportazione del file 3MF " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1596 +msgid "Error exporting AMF file " +msgstr "Errore nell'esportazione del file AMF " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1526 +msgid "Error while uploading to the OctoPrint server: " +msgstr "Errore nel caricamento sul server OctoPrint: " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:315 +msgid "Error! " +msgstr "Errore! " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:451 +msgid "Estimated printing time" +msgstr "Tempo di stampa stimato" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:44 +#, c-format +msgid "except for the first %d layers" +msgstr "ad eccezione dei primi %d layers" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:48 +msgid "except for the first layer" +msgstr "ad eccezione del primo layer" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:192 +msgid "Experimental option for preventing support material from being generated under bridged areas." +msgstr "Opzione sperimentale per prevenire la formazione di supporti sotto i bridge." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:942 +msgid "Experimental option to adjust flow for overhangs (bridge flow will be used), to apply bridge speed to them and enable fan." +msgstr "Opzione sperimentale per regolare il flusso delle sporgenze (sarà utilizzato il flusso dei bridge), applicare la velocità del bridge e attivare la ventola." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 +msgid "Export all presets to file" +msgstr "Esporta tutti i preset su file" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 +msgid "Export current configuration to file" +msgstr "Esporta la configurazione corrente su file" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 +msgid "Export current plate as 3MF" +msgstr "Esporta il piano corrente come 3MF" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 +msgid "Export current plate as AMF" +msgstr "Esporta il piano corrente come AMF" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 +msgid "Export current plate as G-code" +msgstr "Esporta il piano corrente come G-code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 +msgid "Export current plate as STL" +msgstr "Esporta il piano corrente come STL" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1454 +msgid "Export failed" +msgstr "Esportazione fallita" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 +msgid "Export G-code..." +msgstr "Esporta G-code..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:236 +msgid "Export G-code…" +msgstr "Esporta G-code…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 +msgid "Export object as STL…" +msgstr "Esporta oggetto come STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 +msgid "Export plate as 3MF..." +msgstr "Esporta piano come 3MF..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 +msgid "Export plate as AMF..." +msgstr "Esporta piano come AMF..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 +msgid "Export plate as STL..." +msgstr "Esporta piano come STL..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:240 +msgid "Export STL…" +msgstr "Esporta STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 +msgid "Export this single object as STL file" +msgstr "Esporta questo singolo oggetto come file STL" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:139 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:81 +msgid "External perimeter" +msgstr "Perimetro esterno" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:267 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:277 +msgid "External perimeters" +msgstr "Perimetri esterni" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:151 +msgid "external perimeters" +msgstr "perimetri esterni" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:289 +msgid "External perimeters first" +msgstr "Perimetri esterni per primi" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1118 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1126 +msgid "Extra length on restart" +msgstr "Lunghezza extra in ripresa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:297 +msgid "Extra perimeters if needed" +msgstr "Perimetro aggiuntivo se necessario" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:795 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1234 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:307 +msgid "Extruder" +msgstr "Estrusore" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1187 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:400 +#, c-format +msgid "Extruder %d" +msgstr "Estrusore %d" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:479 +msgid "Extruder clearance (mm)" +msgstr "Spazio libero per l'estrusore (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:342 +msgid "Extruder Color" +msgstr "Colore estrusore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:350 +msgid "Extruder offset" +msgstr "Offset estrusore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:626 +msgid "Extruder temperature for first layer. If you want to control temperature manually during print, set this to zero to disable temperature control commands in the output file." +msgstr "Temperatura estrusore per il primo layer. Se vuoi controllare manualmente la temperatura durante la stampa, imposta questo a zero per disattivare i comandi di controllo temperatura nel file di output." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1573 +msgid "Extruder temperature for layers after the first one. Set this to zero to disable temperature control commands in the output." +msgstr "Temperatura estrusore per i layer successivi al primo. Imposta questo a zero per disattivare i comandi di controllo temperatura nell'output." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:431 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:966 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:308 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:702 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:958 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1272 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1445 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1471 +msgid "Extruders" +msgstr "Estrusori" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:360 +msgid "Extrusion axis" +msgstr "Asse estrusore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:367 +msgid "Extrusion multiplier" +msgstr "Moltiplicatore estrusione" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:453 +msgid "Extrusion width" +msgstr "Larghezza estrusione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:268 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:377 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:592 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:710 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:967 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1292 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1454 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1614 +msgid "Extrusion Width" +msgstr "Larghezza Estrusione" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:410 +msgid "Facets" +msgstr "Facce" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:36 +msgid "Fan " +msgstr "Ventola " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:817 +msgid "Fan settings" +msgstr "Impostazioni ventola" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:818 +msgid "Fan speed" +msgstr "Velocità ventola" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:330 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:68 +msgid "Feature type" +msgstr "Tipo di caratteristica" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:78 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:79 +msgid "Feature types" +msgstr "Tipi di caratteristica" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:183 +msgid "Fewer" +msgstr "Meno" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:786 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:787 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:368 +msgid "Filament" +msgstr "Filamento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:412 +msgid "Filament notes" +msgstr "Note filamento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:832 +msgid "Filament properties" +msgstr "Proprietà filamento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:202 +msgid "Filament Settings" +msgstr "Impostazioni Filamento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:450 +msgid "Filament type" +msgstr "Tipo filamento" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1445 +msgid "File added to print queue" +msgstr "File aggiunto alla coda di stampa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:475 +msgid "File Not Found" +msgstr "File non trovato" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:487 +msgid "Fill angle" +msgstr "Angolo riempimento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:501 +msgid "Fill density" +msgstr "Densità riempimento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:539 +msgid "Fill pattern" +msgstr "Schema riempimento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:541 +msgid "Fill pattern for general low-density infill." +msgstr "Schema per riempimento comune a bassa densità." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:248 +msgid "Fill pattern for top/bottom infill. This only affects the external visible layer, and not its adjacent solid shells." +msgstr "Pattern di riempimento per il fondo o la cima. Questo influenza solo lo strato visibile esterno e non i perimetri adiacenti." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1110 +msgid "Firmware" +msgstr "Firmware" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1314 +msgid "Firmware Retraction" +msgstr "Retrazione Firmware" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:573 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:582 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:591 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:625 +msgid "First layer" +msgstr "Primo strato" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:603 +msgid "First layer height" +msgstr "Altezza del primo strato" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:615 +msgid "First layer speed" +msgstr "Velocità del primo strato" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "First layer volumetric" +msgstr "Volumetrica primo strato" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:466 +msgid "Flow" +msgstr "Flusso" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:599 +msgid "" +"For the Wipe Tower to work with the soluble supports, the support layers\n" +"need to be synchronized with the object layers.\n" +"\n" +"Shall I synchronize support layers in order to enable the Wipe Tower?" +msgstr "" +"Perché la Wipe Tower possa funzionare con i supporti solubili, gli strati dei supporti devono essere sincronizzati con quelli del modello.\n" +"\n" +"Sincronizzare i supporti per abilitare la Wipe Tower?" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1264 +msgid "Force solid infill for regions having a smaller area than the specified threshold." +msgstr "Forza riempimento solido per le regioni con un'area inferiore al limite specificato." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:758 +msgid "Force the generation of solid shells between adjacent materials/volumes. Useful for multi-extruder prints with translucent materials or manual soluble support material." +msgstr "Forza la generazione di perimetri solidi tra volumi o materiali adiacenti. Utile per stampe multi estrusore con materiali traslucidi o supporti solubili manuali." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 +msgid "Front" +msgstr "Frontale" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 +msgid "Front View" +msgstr "Vista anteriore" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +msgid "G-code" +msgstr "G-code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1451 +msgid "G-code file exported to " +msgstr "G-code esportato a " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1524 +msgid "G-code file successfully uploaded to the OctoPrint server" +msgstr "G-code caricato correttamente sul server OctoPrint" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:652 +msgid "G-code flavor" +msgstr "Tipologia di G-code" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:444 +msgid "g/cm³" +msgstr "g/cm³" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:634 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:145 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:87 +msgid "Gap fill" +msgstr "Riempimento spazi" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:937 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:11 +msgid "General" +msgstr "Generale" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:875 +msgid "Generate no less than the number of skirt loops required to consume the specified amount of filament on the bottom layer. For multi-extruder machines, this minimum applies to each extruder." +msgstr "Genera almeno il numero di skirt necessari per consumare la quantità di filamento specificata per il primo strato. Per le macchine multi estrusore, questo minimo riguarda ciascun estrusore." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1379 +msgid "Generate support material" +msgstr "Genera materiale di supporto" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1433 +msgid "Generate support material for the specified number of layers counting from bottom, regardless of whether normal support material is enabled or not and regardless of any angle threshold. This is useful for getting more adhesion of objects having a very thin or poor footprint on the build plate." +msgstr "Genera materiale di supporto per il numero di layer specificati partendo dal basso, a prescindere che sia abilitato il materiale di supporto normale o meno, e indipendentemente dall'angolo limite. Questo è utile per ottenere più adesione negli oggetti con un appoggio sul piano molto sottile o fragile." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:498 +msgid "GLUquadricObjPtr | Attempt to free unreferenced scalar" +msgstr "GLUquadricObjPtr | Tentativo di liberare lo scalare senza riferimenti" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:583 +msgid "Heated build plate temperature for the first layer. Set this to zero to disable bed temperature control commands in the output." +msgstr "Temperatura piano riscaldato per il primo layer. Imposta a zero per disattivare i comandi di controllo temperatura nell'output." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:320 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:69 +msgid "Height" +msgstr "Altezza" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:332 +msgid "Height (mm)" +msgstr "Altezza (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1222 +msgid "Height of skirt expressed in layers. Set this to a tall value to use skirt as a shield against drafts." +msgstr "Altezza dello skirt espresso in layer. Imposta un valore alto per utilizzare lo skirt come scudo contro le scolature." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:329 +msgid "Horizontal shells" +msgstr "Gusci orizzontali" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:128 +msgid "Horizontal width of the brim that will be printed around each object on the first layer." +msgstr "Larghezza orizzontale del brim che sarà stampata attorno ad ogni oggetto nel primo layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:908 +msgid "Host or IP" +msgstr "Host o IP" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:214 +msgid "I wasn't able to connect to OctoPrint (" +msgstr "Non posso connettermi ad OctoPrint (" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:26 +#, c-format +msgid "If estimated layer time is below ~%ds, fan will run at %d%% and print speed will be reduced so that no less than %ds are spent on that layer (however, speed will never be reduced below %dmm/s)." +msgstr "Se il tempo previsto per il layer è inferiore a ~%ds, la ventola girerà al %d%% e la velocità di stampa sarà ridotta così da impiegare non meno di %ds su quel layer (in ogni caso, la velocità non sarà mai ridotta sotto %dmm/s)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:616 +msgid "If expressed as absolute value in mm/s, this speed will be applied to all the print moves of the first layer, regardless of their type. If expressed as a percentage (for example: 40%) it will scale the default speeds." +msgstr "Se espresso come valore assoluto in mm/s, questa velocità sarà applicata a tutti i movimenti di stampa del primo layer, a prescindere dal tipo di movimento. Se espresso come percentuale (per esempio: 40%) verranno scalate le velocità predefinite." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:395 +msgid "If layer print time is estimated below this number of seconds, fan will be enabled and its speed will be calculated by interpolating the minimum and maximum speeds." +msgstr "Se il tempo stimato di stampa del layer è al di sotto di questo numero di secondi, la ventola sarà attivata e la sua velocità sarà calcolata interpolando la velocità minima e massima." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1240 +msgid "If layer print time is estimated below this number of seconds, print moves speed will be scaled down to extend duration to this value." +msgstr "Se il tempo stimato di stampa del layer è al di sotto di questo numero di secondi, la velocità dei movimenti di stampa sarà ridotta per estendere la durata di questo valore." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:388 +msgid "If this is enabled, fan will never be disabled and will be kept running at least at its minimum speed. Useful for PLA, harmful for ABS." +msgstr "Se questo è attivo, la ventola non verrà mai disattiva e verrà mantenuta attiva almeno alla velocità minima. Utile per il PLA, dannosa per l'ABS." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:37 +msgid "If this is enabled, Slic3r will auto-center objects around the print bed center." +msgstr "Se attivo, Slic3r posizionerà automaticamente gli oggetti al centro del piano di stampa." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:45 +msgid "If this is enabled, Slic3r will pre-process objects as soon as they're loaded in order to save time when exporting G-code." +msgstr "Se attivo, Slic3r processerà in anticipo gli oggetti non appena saranno caricati, così da risparmiare tempo durante l'esportazione del G-code." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:29 +msgid "If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files." +msgstr "Se attivo, Slic3r suggerirà l'ultima cartella di destinazione invece della cartella contenente il file di ricezione." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:77 +msgid "If you have rendering issues caused by a buggy OpenGL 2.0 driver, you may try to check this checkbox. This will disable the layer height editing and anti aliasing, so it is likely better to upgrade your graphics driver." +msgstr "Se hai problemi nel rendering causati da bug nel driver OpenGL 2.0, puoi provare ad attivare questa opzione. Si disattiverà la modifica altezza layer e l'anti-aliasing, quindi è meglio aggiornare i driver grafici." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1091 +msgid "If you set this to a positive value, Z is quickly raised every time a retraction is triggered. When using multiple extruders, only the setting for the first extruder will be considered." +msgstr "Se inserisci un valore positivo, Z verrà alzato velocemente ogni volta che si innesca una retrazione. Quando si utilizzano diversi estrusori, verrà considerato solamente l'impostazione del primo estrusore." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1101 +msgid "If you set this to a positive value, Z lift will only take place above the specified absolute Z. You can tune this setting for skipping lift on the first layers." +msgstr "Se inserisci un valore positivo, il sollevamento Z avverrà solamente sopra un certo specifico valore assoluto Z. Puoi regolare questa impostazione per evitare il sollevamento nei primi layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1110 +msgid "If you set this to a positive value, Z lift will only take place below the specified absolute Z. You can tune this setting for limiting lift to the first layers." +msgstr "Se inserisci un valore positivo, il sollevamento Z avverrà solamente sotto un certo specifico valore assoluto Z. Puoi regolare questa impostazione per limitare il sollevamento ai primi layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:451 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1002 +msgid "If you want to process the output G-code through custom scripts, just list their absolute paths here. Separate multiple scripts with a semicolon. Scripts will be passed the absolute path to the G-code file as the first argument, and they can access the Slic3r config settings by reading environment variables." +msgstr "Se vuoi processare il G-code in uscita con script personalizzati, basta elencare qui il loro percorso assoluto. Separa i diversi script con un punto e virgola. Gli script passeranno il percorso assoluto nel G-code come primo argomento, e potranno accedere alle impostazioni di configurazione di Slic3r leggendo le variabili di ambiente." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:351 +msgid "If your firmware doesn't handle the extruder displacement you need the G-code to take it into account. This option lets you specify the displacement of each extruder with respect to the first one. It expects positive coordinates (they will be subtracted from the XY coordinate)." +msgstr "Se il firmware non gestisce lo spostamento dell'estrusore, è necessario che il G-code ne tenga conto. Questa opzione permette di specificare lo spostamento di ciascun estrusore rispetto al primo. Si aspetta delle coordinate positive (che saranno sottratte dalle coordinate XY)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1664 +msgid "If your firmware requires relative E values, check this, otherwise leave it unchecked. Most firmwares use absolute values." +msgstr "Se il firmware richiede valori E relativi, selezionalo, altrimenti lascialo non selezionato. Molti firmware utilizzano valori assoluti." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 +msgid "Increase copies" +msgstr "Aumenta copie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:346 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:347 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:664 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:87 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:247 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:488 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:502 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:540 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:681 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:691 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:709 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:727 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:746 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1263 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1280 +msgid "Infill" +msgstr "Riempimento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:169 +msgid "infill" +msgstr "riempimento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:720 +msgid "Infill before perimeters" +msgstr "Riempimento prima dei perimetri" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:701 +msgid "Infill extruder" +msgstr "Estrusore riempimento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:735 +msgid "Infill/perimeters overlap" +msgstr "Sovrapposizione riempimento/perimetri" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:398 +msgid "Info" +msgstr "Info" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1479 +msgid "Interface layers" +msgstr "Layer interfaccia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1463 +msgid "Interface loops" +msgstr "Giri interfaccia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1488 +msgid "Interface pattern spacing" +msgstr "Spaziatura trama interfaccia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:757 +msgid "Interface shells" +msgstr "Gusci interfaccia" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:141 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:83 +msgid "Internal infill" +msgstr "Riempimento interno" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Invalid rotation angle entered" +msgstr "Inserito angolo di rotazione non valido" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +msgid "Invalid scaling value entered" +msgstr "Inserito valore scala non valido" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 +msgid "Iso" +msgstr "Iso" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 +msgid "Iso View" +msgstr "Vista isometrica" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1180 +msgid "Jitter" +msgstr "Jitter" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:387 +msgid "Keep fan always on" +msgstr "Mantieni la ventola sempre accesa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 +msgid "Language" +msgstr "Lingua" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:192 +msgid "Layer Editing" +msgstr "Editing degli strati" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:207 +msgid "Layer editing" +msgstr "Editing degli strati" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:314 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:777 +msgid "Layer height" +msgstr "Altezza layer" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1194 +msgid "Layer height limits" +msgstr "Limiti altezza layer" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:183 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:694 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1033 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1224 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1285 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1437 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1482 +msgid "layers" +msgstr "layer" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:157 +msgid "Layers" +msgstr "Layer" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:69 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:239 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:290 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:298 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:604 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:762 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:778 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:941 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:989 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1152 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1583 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1639 +msgid "Layers and Perimeters" +msgstr "Layer e Perimetri" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:313 +msgid "Layers and perimeters" +msgstr "Layer e perimetri" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 +msgid "Left" +msgstr "Sinistra" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 +msgid "Left View" +msgstr "Vista sinistra" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1071 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1080 +msgid "Length" +msgstr "Lunghezza" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1090 +msgid "Lift Z" +msgstr "Solleva Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 +msgid "Load exported configuration file" +msgstr "Carica un file di configurazione esportato" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 +msgid "Load presets from a bundle" +msgstr "Carica i preset da un gruppo" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:75 +msgid "Load shape from STL..." +msgstr "Carica forma da STL..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:692 +msgid "Loaded " +msgstr "Caricato " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 +msgid "Loading…" +msgstr "Caricando…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1229 +msgid "Loops (minimum)" +msgstr "Giri (minimo)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:412 +msgid "Manifold" +msgstr "Manifold" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:411 +msgid "Materials" +msgstr "Materiali" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:787 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:796 +msgid "Max" +msgstr "Massimo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:807 +msgid "Max print speed" +msgstr "Massima velocità di stampa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:837 +msgid "Max volumetric slope negative" +msgstr "Massima pendenza volumetrica negativa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:826 +msgid "Max volumetric slope positive" +msgstr "Massima pendenza volumetrica positiva" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:421 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:817 +msgid "Max volumetric speed" +msgstr "Massima velocità volumetrica" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:422 +msgid "Maximum volumetric speed allowed for this filament. Limits the maximum volumetric speed of a print to the minimum of print and filament volumetric speed. Set to zero for no limit." +msgstr "Massima velocità volumetrica consentita per questo filamento. Limita la velocità volumetrica massima di una stampa alla velocità volumetrica minima del filamento e di stampa. Imposta a zero per non avere limite." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:848 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:857 +msgid "Min" +msgstr "Minimo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:866 +msgid "Min print speed" +msgstr "Velocità minima di stampa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1040 +msgid "Minimum detail resolution, used to simplify the input file for speeding up the slicing job and reducing memory usage. High-resolution models often carry more detail than printers can render. Set to zero to disable any simplification and use full resolution from input." +msgstr "Risoluzione minima dettaglio, utilizzato per semplificare il file input accelerando lo slicing e riducendo l'utilizzo di memoria. I file ad alta risoluzione spesso hanno più dettaglio di quanto la stampante possa generare. Impostate a zero per disabilitare la semplificazione e utilizzare la risoluzione completa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:874 +msgid "Minimum extrusion length" +msgstr "Lunghezza minima dell'estrusione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1050 +msgid "Minimum travel after retraction" +msgstr "Spostamento minimo dopo una ritrazione" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 +msgid "Mirror" +msgstr "Specchia" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 +msgid "Mirror the selected object" +msgstr "Specchia l'oggetto selezionato" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 +msgid "Mirror the selected object along the X axis" +msgstr "Specchia l'oggetto selezionato sull'asse X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 +msgid "Mirror the selected object along the Y axis" +msgstr "Specchia l'oggetto selezionato sull'asse y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 +msgid "Mirror the selected object along the Z axis" +msgstr "Specchia l'oggetto selezionato sull'asse Z" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:151 +msgid "Mixed" +msgstr "Mischiate" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:65 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:129 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:200 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:211 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:325 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:336 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:355 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:434 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:781 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:801 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:860 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:878 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:896 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1044 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1052 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1094 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1103 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1113 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1121 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1129 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1215 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1421 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1491 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1527 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1704 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1711 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1718 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1727 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1737 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1747 +msgid "mm" +msgstr "mm" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1075 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1085 +msgid "mm (zero to disable)" +msgstr "mm (imposta a zero per disabilitare)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:609 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:740 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1390 +msgid "mm or %" +msgstr "mm o %" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:382 +msgid "mm or % (leave 0 for auto)" +msgstr "mm o % (lasciate 0 per l'automatico)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:272 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:597 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:715 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:972 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1296 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1458 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1619 +msgid "mm or % (leave 0 for default)" +msgstr "mm o % (lasciate 0 per il default)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:120 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:638 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:749 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:811 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:868 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:981 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1137 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1146 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1536 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1649 +msgid "mm/s" +msgstr "mm/s" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:282 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:619 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1255 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1306 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1501 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1631 +msgid "mm/s or %" +msgstr "mm/s o %" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:80 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:174 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:576 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:684 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:952 +msgid "mm/s²" +msgstr "mm/s²" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1265 +msgid "mm²" +msgstr "mm²" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:425 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:820 +msgid "mm³/s" +msgstr "mm³/s" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:831 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:842 +msgid "mm³/s²" +msgstr "mm³/s²" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:414 +msgid "Modifiers" +msgstr "Modificatori" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:478 +msgid "money/kg" +msgstr "soldi/kg" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:182 +msgid "More" +msgstr "Altro" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1696 +msgid "Multi material printers may need to prime or purge extruders on tool changes. Extrude the excess material into the wipe tower." +msgstr "Le stampanti multi-material potrebbero necessitare di caricare o spurgare l'estrusore al cambio di strumento. Estrude il materiale in eccesso in una torre di spurgo." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:666 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:683 +msgid "Multi-part object detected" +msgstr "Rilevato oggetto in parti multiple" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:430 +msgid "Multiple Extruders" +msgstr "Estrusori multipli" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:680 +msgid "" +"Multiple objects were loaded for a multi-material printer.\n" +"Instead of considering them as multiple objects, should I consider\n" +"these files to represent a single object having multiple parts?\n" +msgstr "" +"Sono stati caricati oggetti multipli per stampante multi-material.\n" +"Invece di considerarli come oggetti multipli, devo considerarli come parte di un singolo oggetto avente parti multiple?\n" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:220 +msgid "Name" +msgstr "Nome" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 +msgid "No Bonjour device found" +msgstr "Dispositivo Bonjour non trovato" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:469 +msgid "No previously sliced file." +msgstr "File non processato precedentemente." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:137 +msgid "None" +msgstr "Nessuno" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:500 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:501 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:859 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:860 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1156 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1157 +msgid "Notes" +msgstr "Note" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:493 +msgid "Notice" +msgstr "Avvertenza" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:894 +msgid "Nozzle diameter" +msgstr "Diametro ugello" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:967 +msgid "Number of extruders of the printer." +msgstr "Numero estrusori della stampante." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1481 +msgid "Number of interface layers to insert between the object(s) and support material." +msgstr "Numero di layer interfaccia da inserire tra l'oggetto(i) e il materiale di supporto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1231 +msgid "Number of loops for the skirt. If the Minimum Extrusion Length option is set, the number of loops might be greater than the one configured here. Set this to zero to disable skirt completely." +msgstr "Numero di giri per lo skirt. Se è impostata l'opzione per la lunghezza minima di estrusione, il numero dei giri potrebbe essere più grande di quello configurato qui. Imposta questo valore a zero per disattivare completamente lo skirt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:70 +msgid "Number of solid layers to generate on bottom surfaces." +msgstr "Numero di layer solidi da generare sulle superfici inferiori." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1315 +msgid "Number of solid layers to generate on top and bottom surfaces." +msgstr "Numero di layer solidi da generare sulle superfici superiori e inferiori." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1640 +msgid "Number of solid layers to generate on top surfaces." +msgstr "Numero di layer solidi da generare sulle superfici superiori." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:745 +msgid "Object too large?" +msgstr "Oggetto troppo grande?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1032 +msgid "OctoPrint upload" +msgstr "Carica su OctoPrint" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1410 +msgid "Only create support if it lies on a build plate. Don't create support on a print." +msgstr "Crea supporti solo se poggiano sulla superficie di stampa. Non creare supporti sulla stampa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:726 +msgid "Only infill where needed" +msgstr "Riempimento solo quando necessario" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1205 +msgid "Only lift Z" +msgstr "Eleva solo Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1100 +msgid "Only lift Z above" +msgstr "Eleva solo Z al di sopra" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1109 +msgid "Only lift Z below" +msgstr "Eleva solo Z al di sotto" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:915 +msgid "Only retract when crossing perimeters" +msgstr "Ritrai solo se si attraversa un perimetro" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:438 +msgid "Ooze prevention" +msgstr "Prevenzione delle fuoriuscite" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 +msgid "Open a model" +msgstr "Aprire un modello" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 +msgid "Open STL/OBJ/AMF…\tCtrl+O" +msgstr "Aprire un STL/OBJ/AMF… Ctrl+O" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 +msgid "Open the 3D cutting tool" +msgstr "Aprire lo strumento di taglio 3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 +msgid "Open the object editor dialog" +msgstr "Apri la finestra di dialogo di modifica oggetto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 +msgid "Open the Prusa Edition releases page in your browser" +msgstr "Apri la pagina delle versioni Prusa Edition sul tuo browser" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 +msgid "Open the Prusa3D drivers download page in your browser" +msgstr "Apri la pagina di download dei driver Prusa3D sul tuo browser" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 +msgid "Open the Slic3r manual in your browser" +msgstr "Apri il manuale di Slic3r sul tuo browser" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 +msgid "Open the Slic3r website in your browser" +msgstr "Apri la pagina di Slic3r sul tuo browser" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:27 +msgid "Optimize travel moves in order to minimize the crossing of perimeters. This is mostly useful with Bowden extruders which suffer from oozing. This feature slows down both the print and the G-code generation." +msgstr "Ottimizza il movimenti di spostamento per minimizzare l'incrocio di perimetri. E' comunemente usato con estrusori Bowden che soffrono di oozing. Questa caratteristica rallenta sia la stampa che la generazione del G-code." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:384 +msgid "Options for support material and raft" +msgstr "Opzioni per materiale di supporto e raft" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:57 +msgid "Origin" +msgstr "Origine" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:469 +msgid "Other" +msgstr "Altro" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:38 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1572 +msgid "Other layers" +msgstr "Altri layer" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:488 +msgid "Output file" +msgstr "File di Output" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:930 +msgid "Output filename format" +msgstr "Formato del file di Output" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:476 +msgid "Output options" +msgstr "Opzioni Output" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:140 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:82 +msgid "Overhang perimeter" +msgstr "Perimetro sporgente" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1550 +msgid "Overhang threshold" +msgstr "Soglia sporgenza" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:463 +msgid "Overlap" +msgstr "Sovrapposizione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1508 +msgid "Pattern" +msgstr "Trama" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1398 +msgid "Pattern angle" +msgstr "Angolo trama" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1524 +msgid "Pattern spacing" +msgstr "Spaziatura trama" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1510 +msgid "Pattern used to generate support material." +msgstr "Trama usata per generare il materiale di supporto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1723 +msgid "Per color change depth" +msgstr "Profondità per ogni cambio colore" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:138 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:80 +msgid "Perimeter" +msgstr "Perimetro" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:957 +msgid "Perimeter extruder" +msgstr "Estrusore perimetro" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:948 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:966 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:978 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:988 +msgid "Perimeters" +msgstr "Perimetri" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:160 +msgid "perimeters" +msgstr "perimetri" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 +msgid "Place one more copy of the selected object" +msgstr "Posiziona una o più copie dell'oggetto selezionato" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:118 +msgid "Plater" +msgstr "Piano" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1199 +msgid "Position (for multi-extruder printers)" +msgstr "Posizione (per stampanti multi-estrusore)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1153 +msgid "Position of perimeters starting points." +msgstr "Posizione dei punti iniziali dei perimetri." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1702 +msgid "Position X" +msgstr "Posizione X" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1709 +msgid "Position Y" +msgstr "Posizione Y" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:494 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1001 +msgid "Post-processing scripts" +msgstr "Script di post produzione" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp:17 +msgid "Preferences" +msgstr "Preferenze" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 +msgid "Preferences…\tCtrl+," +msgstr "Preferenze…Ctrl+," + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1171 +msgid "Preferred direction of the seam" +msgstr "Direzione preferita della giunzione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1183 +msgid "Preferred direction of the seam - jitter" +msgstr "Direzione preferita della giunzione - jitter" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1222 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:150 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2125 +msgid "Preview" +msgstr "Anteprima" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 +msgid "Previously sliced file (" +msgstr "File precedentemente processato (" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:291 +msgid "Print contour perimeters from the outermost one to the innermost one instead of the default inverse order." +msgstr "Stampa i perimetri di contorno dal più esterno al più interno invece dell'ordine predefinito inverso." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:182 +msgid "Print Settings" +msgstr "Impostazioni Stampa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:367 +msgid "Print settings" +msgstr "Impostazioni di stampa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:836 +msgid "Print speed override" +msgstr "Scavalca velocità di stampa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:369 +msgid "Printer" +msgstr "Stampante" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1014 +msgid "Printer notes" +msgstr "Note stampante" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:228 +msgid "Printer Settings" +msgstr "Impostazioni stampante" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:238 +msgid "Print…" +msgstr "Stampa…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 +msgid "Processing " +msgstr "Elaborando " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:643 +msgid "Processing input file\n" +msgstr "Elaborando il file di input\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:508 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:868 +msgid "Profile dependencies" +msgstr "Dipendenze profilo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 +msgid "Prusa 3D Drivers" +msgstr "Driver Prusa 3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 +msgid "Prusa Edition Releases" +msgstr "Versioni Prusa Edition" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 +msgid "Q&uick Slice…\tCtrl+U" +msgstr "Slice Rapido… \tCtrl+&U" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:335 +msgid "Quality (slower slicing)" +msgstr "Qualità (slicing più lento)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 +msgid "Quick Slice and Save &As…\tCtrl+Alt+U" +msgstr "Slice veloce e S&alva come… \tCtrl+Alt+U" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 +msgid "Quit Slic3r" +msgstr "Chiudi Slic3r" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:331 +msgid "Radius" +msgstr "Raggio" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:380 +msgid "Raft" +msgstr "Raft" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1029 +msgid "Raft layers" +msgstr "Layer raft" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 +msgid "Rear" +msgstr "Posteriore" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 +msgid "Rear View" +msgstr "Vista posteriore" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:262 +#, c-format +msgid "Recommended object thin wall thickness for layer height %.2f and " +msgstr "Spessore raccomandato per oggetto con parete sottile per altezza layer %.2f e " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:245 +msgid "Recommended object thin wall thickness: Not available due to invalid layer height." +msgstr "Spessore raccomandato per oggetto con parete sottile: Non disponibile a causa di un'altezza layer non valida." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:46 +msgid "Rectangular" +msgstr "Rettangolare" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:352 +msgid "Reducing printing time" +msgstr "Ridurre tempo di stampa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 +msgid "Reload from Disk" +msgstr "Ricarica da Disco" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 +msgid "Reload the selected file from Disk" +msgstr "Ricarica il file selezionato dal Disco" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:27 +msgid "Remember output directory" +msgstr "Ricorda la directory di output" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 +msgid "Remove" +msgstr "Rimuovi" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 +msgid "remove" +msgstr "rimuovi" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 +msgid "Remove one copy of the selected object" +msgstr "Rimuovi una copia dell'oggetto selezionato" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 +msgid "Remove the selected object" +msgstr "Rimuovi l'oggetto selezionato" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 +msgid "Repair" +msgstr "Ripara" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 +msgid "Repair STL file…" +msgstr "Ripara file STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 +msgid "Repeat last quick slice" +msgstr "Ripeti l'ultimo slice veloce" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 +msgid "Report an Issue" +msgstr "Segnala un problema" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 +msgid "Report an issue on the Slic3r Prusa Edition" +msgstr "Segnala un problema su Slic3r Prusa Edition" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:995 +msgid "Rescan serial ports" +msgstr "Scansiona nuovamente porte seriali" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1039 +msgid "Resolution" +msgstr "Risoluzione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1057 +msgid "Retract amount before wipe" +msgstr "Retrai la quantità prima di pulire" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1065 +msgid "Retract on layer change" +msgstr "Ritrai al cambio layer" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1202 +msgid "Retraction" +msgstr "Retrazione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1051 +msgid "Retraction is not triggered when travel moves are shorter than this length." +msgstr "La retrazione non è attivata quando i movimenti di spostamento sono più brevi di questa lunghezza." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1072 +msgid "Retraction Length" +msgstr "Lunghezza Retrazione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1081 +msgid "Retraction Length (Toolchange)" +msgstr "Lunghezza Retrazione (cambio tool)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1134 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1135 +msgid "Retraction Speed" +msgstr "Velocità di retrazione" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1218 +msgid "Retraction when tool is disabled (advanced settings for multi-extruder setups)" +msgstr "Retrai quando l'attrezzo è disabilitato (impostazioni avanzate per setup multi-estrusore)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:96 +msgid "Retractions" +msgstr "Retrazioni" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 +msgid "Right" +msgstr "Destra" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 +msgid "Right View" +msgstr "Vista destra" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 +msgid "Rotate" +msgstr "Ruota" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 +msgid "Rotate 45° clockwise" +msgstr "Ruota 45° senso orario" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 +msgid "Rotate 45° counter-clockwise" +msgstr "Ruota 45° antiorario" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Rotate around " +msgstr "Ruota attorno " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 +msgid "Rotate the selected object by 45° clockwise" +msgstr "Ruota l'oggetto selezionato di 45° in senso orario" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 +msgid "Rotate the selected object by 45° counter-clockwise" +msgstr "Ruota l'oggetto selezionato di 45° in senso antiorario" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 +msgid "Rotate the selected object by an arbitrary angle" +msgstr "Ruota l'oggetto selezionato di un angolo arbitrario" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 +msgid "Rotate the selected object by an arbitrary angle around X axis" +msgstr "Ruota l'oggetto selezionato di un angolo arbitrario attorno l'asse X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 +msgid "Rotate the selected object by an arbitrary angle around Y axis" +msgstr "Ruota l'oggetto selezionato di un angolo arbitrario attorno l'asse Y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 +msgid "Rotate the selected object by an arbitrary angle around Z axis" +msgstr "Ruota l'oggetto selezionato di un angolo arbitrario attorno l'asse Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 +msgid "Run Configuration " +msgstr "Esegui Configurazione " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 +msgid "Save " +msgstr "Salva " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:605 +msgid "Save configuration as:" +msgstr "Salva configurazione come:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:50 +msgid "Save current " +msgstr "Salva attuale " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:580 +msgid "Save OBJ file (less prone to coordinate errors than STL) as:" +msgstr "Salva il file OBJ (meno soggetto a errori di coordinate dell'STL) come:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:248 +msgid "Save preset" +msgstr "Salva preset" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:646 +msgid "Save presets bundle as:" +msgstr "Salva il gruppo di preset come:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:222 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 +msgid "Scale" +msgstr "Scala" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +msgid "Scale along " +msgstr "Scala lungo " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 +msgid "Scale the selected object along a single axis" +msgstr "Scala l'oggetto selezionato lungo un singolo asse" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 +msgid "Scale the selected object along the X axis" +msgstr "Scala l'oggetto selezionato lungo l'asse X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 +msgid "Scale the selected object along the XYZ axes" +msgstr "Scala l'oggetto selezionato lungo gli assi XYZ" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 +msgid "Scale the selected object along the Y axis" +msgstr "Scala l'oggetto selezionato lungo l'asse Y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 +msgid "Scale the selected object along the Z axis" +msgstr "Scala l'oggetto selezionato lungo l'asse Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 +msgid "Scale to size" +msgstr "Scala alla dimensione" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:187 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:203 +msgid "Scale…" +msgstr "Scala…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1151 +msgid "Seam position" +msgstr "Posizione giunzione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1172 +msgid "Seam preferred direction" +msgstr "Direzione preferita giunzione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1182 +msgid "Seam preferred direction jitter" +msgstr "Direzione preferita giunzione jitter" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 +msgid "Select &Controller Tab\tCtrl+T" +msgstr "Seleziona Scheda &Controller\tCtrl+T" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 +msgid "Select &Filament Settings Tab\tCtrl+3" +msgstr "Seleziona Scheda Impostazioni &Filamento\tCtrl+3" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 +msgid "Select &Plater Tab\tCtrl+1" +msgstr "Seleziona Scheda &Piano\tCtrl+1" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:623 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:667 +msgid "Select configuration to load:" +msgstr "Seleziona configurazione da caricare:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 +msgid "Select P&rint Settings Tab\tCtrl+2" +msgstr "Seleziona Scheda impostazioni di &Stampa\tCtrl+2" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 +msgid "Select Print&er Settings Tab\tCtrl+4" +msgstr "Seleziona Scheda Impostazioni Stampant&e\tCtrl+4" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 +msgid "Select the language" +msgstr "Seleziona la lingua" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1667 +msgid "Select the printers this profile is compatible with." +msgstr "Seleziona le stampanti compatibili con questo profilo." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:566 +msgid "Select the STL file to repair:" +msgstr "Seleziona il file STL da riparare:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:239 +msgid "Send to printer" +msgstr "Manda alla stampante" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1448 +msgid "Sending G-code file to the OctoPrint server..." +msgstr "Mandando il file G-code al server OctoPrint..." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:477 +msgid "Sequential printing" +msgstr "Stampa sequenziale" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:990 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1193 +msgid "Serial port" +msgstr "Porta seriale" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1202 +msgid "Serial port speed" +msgstr "Velocità porta seriale" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 +msgid "Set number of copies…" +msgstr "Imposta numero delle copie…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:378 +msgid "Set this to a non-zero value to allow a manual extrusion width. If left to zero, Slic3r derives extrusion widths from the nozzle diameter (see the tooltips for perimeter extrusion width, infill extrusion width etc). If expressed as percentage (for example: 230%), it will be computed over layer height." +msgstr "Imposta questo valore diverso da zero per permettere la larghezza estrusione manuale. Se lasciato a zero, Slic3r ricava la larghezza d'estrusione dal diametro dell'ugello (vedi il suggerimento per la larghezza di estrusione perimetro,larghezza estrusione riempimento ecc.). Se espresso come percentuale (ad esempio 230%), sarà calcolato sull'altezza del layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:269 +msgid "Set this to a non-zero value to set a manual extrusion width for external perimeters. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 200%), it will be computed over layer height." +msgstr "Imposta questo valore diverso da zero per impostare una larghezza d'estrusione manuale per i perimetri esterni. Se lasciato a zero, verrà utilizzata la larghezza predefinita se impostata; diversamente verrà utilizzato il valore 1.125 x il diametro dell'ugello. Se espresso in percentuale (per esempio 200%), sarà calcolato sull'altezza del layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:593 +msgid "Set this to a non-zero value to set a manual extrusion width for first layer. You can use this to force fatter extrudates for better adhesion. If expressed as percentage (for example 120%) it will be computed over first layer height. If set to zero, it will use the default extrusion width." +msgstr "Imposta questo valore diverso da zero per impostare la larghezza di estrusione manuale per il primo layer. Puoi usarlo per forzare un'estrusione più grossa per avere un'adesione migliore. Se espresso in percentuale (per esempio 120%) sarà calcolato sull'altezza del primo layer. Se impostato a zero, sarà utilizzata la larghezza di estrusione predefinita." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1293 +msgid "Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Imposta questo valore diverso da zero per impostare una larghezza d'estrusione manuale per il riempimento delle superfici solide. Se lasciato a zero, verrà usata la larghezza d'estrusione predefinita, altrimenti verrà utilizzato il valore 1.125 x il diametro dell'ugello. Se espresso in percentuale (per esempio 90%) verrà calcolato sull'altezza del layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1615 +msgid "Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. You may want to use thinner extrudates to fill all narrow regions and get a smoother finish. If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Imposta questo valore diverso da zero per impostare una larghezza d'estrusione manuale per il riempimento delle superfici superiori. Dovresti scegliere un'estrusione più sottile per riempire gli spazi stretti ed ottenere una finitura più liscia. Se lasciato a zero, verrà usata la larghezza d'estrusione predefinita, altrimenti verrà utilizzato il valore 1.125 x il diametro dell'ugello. Se espresso in percentuale (per esempio 90%) verrà calcolato sull'altezza del layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:711 +msgid "Set this to a non-zero value to set a manual extrusion width for infill. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. You may want to use fatter extrudates to speed up the infill and make your parts stronger. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Imposta questo valore diverso da zero per impostare una larghezza d'estrusione manuale per il riempimento. Se lasciato a zero, verrà usata la larghezza d'estrusione predefinita, altrimenti verrà utilizzato il valore 1.125 x il diametro dell'ugello. Dovresti usare un estrusione più grossa per velocizzare la stampa del riempimento e rendere le tue parti più robuste. Se espresso in percentuale (per esempio 90%) verrà calcolato sull'altezza del layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:968 +msgid "Set this to a non-zero value to set a manual extrusion width for perimeters. You may want to use thinner extrudates to get more accurate surfaces. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 200%) it will be computed over layer height." +msgstr "Imposta questo valore diverso da zero per impostare una larghezza d'estrusione manuale per i perimetri. Dovresti scegliere un'estrusione più sottile per ottenere superfici più precise. Se lasciato a zero, verrà usata la larghezza d'estrusione predefinita, altrimenti verrà utilizzato il valore 1.125 x il diametro dell'ugello. Se espresso in percentuale (per esempio 200%) verrà calcolato sull'altezza del layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1455 +msgid "Set this to a non-zero value to set a manual extrusion width for support material. If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Imposta questo valore diverso da zero per impostare una larghezza d'estrusione manuale per il supporto. Se lasciato a zero, verrà usata la larghezza d'estrusione predefinita., altrimenti verrà utilizzato il valore del diametro dell'ugello. Se espresso in percentuale (per esempio 90%) verrà calcolato sull'altezza del layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:332 +msgid "Set this to the clearance radius around your extruder. If the extruder is not centered, choose the largest value for safety. This setting is used to check for collisions and to display the graphical preview in the plater." +msgstr "Imposta il raggio di spazio attorno all'estrusore. Se l'estrusore non è centrato, scegli il valore più grande per sicurezza. Questa impostazione è usata per controllare le collisioni e per mostrare l'anteprima grafica nel piano." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:321 +msgid "Set this to the vertical distance between your nozzle tip and (usually) the X carriage rods. In other words, this is the height of the clearance cylinder around your extruder, and it represents the maximum depth the extruder can peek before colliding with other printed objects." +msgstr "Imposta la distanza verticale tra la punta dell'ugello e (solitamente) le barre del carrello X. In altre parole, questa è l'altezza dello spazio cilindrico attorno l'estrusore, e indica la profondità massima che l'estrusore può affacciarsi prima di sbattere con altri oggetti stampati." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:120 +msgid "Settings" +msgstr "Impostazioni" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:191 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:206 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 +msgid "Settings…" +msgstr "Impostazioni…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:39 +msgid "Shape" +msgstr "Forma" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:98 +msgid "Shells" +msgstr "Gusci" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:75 +msgid "Show" +msgstr "Mostra" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 +msgid "Show about dialog" +msgstr "Mostra la finestra di dialogo al riguardo di" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:67 +msgid "Show incompatible print and filament presets" +msgstr "Mostra preset di stampa e di filamento incompatibili" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 +msgid "Show system information" +msgstr "Mostra informazioni di sistema" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 +msgid "Show the filament settings" +msgstr "Mostra impostazioni filamento" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 +msgid "Show the plater" +msgstr "Mostra il piano" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 +msgid "Show the print settings" +msgstr "Mostra impostazioni di stampa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 +msgid "Show the printer controller" +msgstr "Mostra controller stampante" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 +msgid "Show the printer settings" +msgstr "Mostra impostazioni della stampante" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1373 +msgid "Single Extruder Multi Material" +msgstr "Multi Material a Estrusore Singolo" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:50 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1191 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:408 +msgid "Size" +msgstr "Dimensione" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:938 +msgid "Size and coordinates" +msgstr "Dimensione e coordinate" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:51 +msgid "Size in X and Y of the rectangular plate." +msgstr "Dimensioni su X e Y del piano rettangolare." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:365 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:146 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:88 +msgid "Skirt" +msgstr "Skirt" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:364 +msgid "Skirt and brim" +msgstr "Skirt e brim" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1221 +msgid "Skirt height" +msgstr "Altezza skirt" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1230 +msgid "Skirt Loops" +msgstr "Giri skirt" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 +msgid "Slic3r &Manual" +msgstr "&Manuale Slic3r" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 +msgid "Slic3r &Website" +msgstr "Sito &web Slic3r" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:902 +msgid "Slic3r can upload G-code files to OctoPrint. This field should contain the API Key required for authentication." +msgstr "Slic3r può caricare i file G-code su OctoPrint. Questo campo dovrebbe contenere la chiave API richiesta per l'autenticazione." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:909 +msgid "Slic3r can upload G-code files to OctoPrint. This field should contain the hostname or IP address of the OctoPrint instance." +msgstr "Slic3r può caricare i file G-code su OctoPrint. Questo campo dovrebbe contenere l'hostname o l'indirizzo IP dell'istanza OctoPrint." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:929 +msgid "Slic3r Error" +msgstr "Errore Slic3r" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:867 +msgid "Slic3r will not scale speed down below this speed." +msgstr "Slic3r non rallenterà la velocità al di sotto di questa." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 +msgid "Slice a file into a G-code" +msgstr "Processa un file in G-code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 +msgid "Slice a file into a G-code, save as" +msgstr "Processa un file in G-code, salva come" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 +msgid "Slice file to a multi-layer SVG" +msgstr "Processa il file in un SVG multi-layer" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:237 +msgid "Slice now" +msgstr "Processa ora" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 +msgid "Slice to SV&G…\tCtrl+G" +msgstr "Processa a SV&G…\tCtrl+G" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:438 +msgid "Sliced Info" +msgstr "Informazioni processo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1286 +msgid "Slicing cancelled" +msgstr "Slicing cancellato" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:550 +msgid "Slicing Done!" +msgstr "Slicing Completato!" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 +msgid "Slicing…" +msgstr "Slicing…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1239 +msgid "Slow down if layer print time is below" +msgstr "Rallenta se il tempo di stampa del layer è inferiore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1250 +msgid "Small perimeters" +msgstr "Perimetri piccoli" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:179 +msgid "solid infill" +msgstr "riempimento solido" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1291 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1301 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:142 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:84 +msgid "Solid infill" +msgstr "Riempimento solido" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1279 +msgid "Solid infill every" +msgstr "Riempimento solido ogni" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1271 +msgid "Solid infill extruder" +msgstr "Estrusore riempimento solido" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1262 +msgid "Solid infill threshold area" +msgstr "Area inizio riempimento solido" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:330 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1314 +msgid "Solid layers" +msgstr "Layer solidi" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:470 +msgid "Soluble material" +msgstr "Materiale solubile" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:471 +msgid "Soluble material is most likely used for a soluble support." +msgstr "Il materiale solubile è comunemente usato per un supporto solubile." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:653 +msgid "Some G/M-code commands, including temperature control and others, are not universal. Set this option to your printer's firmware to get a compatible output. The \"No extrusion\" flavor prevents Slic3r from exporting any extrusion value at all." +msgstr "Alcuni comandi G/M-code, incluso il controllo temperatura ed altri, non sono universali. Attiva questa impostazione sul firmware della tua stampante per ottenere un output compatibile. Il tipo \"No estrusione\" impedisce che Slic3r esporti qualunque valore di estrusione." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1682 +msgid "Some printers or printer setups may have difficulties printing with a variable layer height. Enabled by default." +msgstr "Alcune stampanti o setup di stampanti possono riscontrare difficoltà a stampare con l'altezza layer variabile. Attivato come predefinito." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1490 +msgid "Spacing between interface lines. Set zero to get a solid interface." +msgstr "Spaziatura tra le linee di interfaccia. Imposta a zero per ottenere un'interfaccia solida." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1526 +msgid "Spacing between support material lines." +msgstr "Spaziatura tra le linee del materiale di supporto." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:398 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:118 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:278 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:635 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:747 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:979 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1201 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1251 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1302 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1625 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:71 +msgid "Speed" +msgstr "Velocità" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1203 +msgid "Speed (baud) of USB/serial port for printer connection." +msgstr "Velocità (baud) USB/Seriale per la connessione stampante." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:336 +msgid "Speed (mm/s)" +msgstr "Velocità (mm/s)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:636 +msgid "Speed for filling small gaps using short zigzag moves. Keep this reasonably low to avoid too much shaking and resonance issues. Set zero to disable gaps filling." +msgstr "Velocità per il riempimento degli spazi stretti utilizzando brevi movimenti a zig-zag. Mantieni questa velocità ragionevolmente bassa per evitare problemi di oscillazione e risonanza. Imposta a zero per disabilitare il riempimento degli spazi." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:411 +msgid "Speed for non-print moves" +msgstr "Velocità per i movimenti non di stampa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:980 +msgid "Speed for perimeters (contours, aka vertical shells). Set to zero for auto." +msgstr "Velocità per i perimetri (contorni, conosciuti anche come gusci verticali). Imposta a zero per automatizzare." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:399 +msgid "Speed for print moves" +msgstr "Velocità per i movimenti di stampa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:119 +msgid "Speed for printing bridges." +msgstr "Velocità di stampa Bridge." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1303 +msgid "Speed for printing solid regions (top/bottom/internal horizontal shells). This can be expressed as a percentage (for example: 80%) over the default infill speed above. Set to zero for auto." +msgstr "La velocità per le regioni di stampa solide (superiore/inferiore/gusci interni orizzontali). Questo valore può essere espresso come percentuale (per esempio: 80%) sulla velocità del riempimento predefinita qui sopra. Imposta a zero per automatizzare." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1499 +msgid "Speed for printing support material interface layers. If expressed as percentage (for example 50%) it will be calculated over support material speed." +msgstr "Velocità per la stampa dei layer di interfaccia del materiale di supporto. Se espresso come percentuale (per esempio 50%) sarà calcolato sulla velocità del materiale di supporto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1535 +msgid "Speed for printing support material." +msgstr "Velocità per la stampa del materiale di supporto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:748 +msgid "Speed for printing the internal fill. Set to zero for auto." +msgstr "Velocità per la stampa del riempimento interno. Imposta a zero per auto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1626 +msgid "Speed for printing top solid layers (it only applies to the uppermost external layers and not to their internal solid layers). You may want to slow down this to get a nicer surface finish. This can be expressed as a percentage (for example: 80%) over the solid infill speed above. Set to zero for auto." +msgstr "Velocità di stampa dei layer solidi superiori (si applica solamente al layer solido esterno più in alto e non ai layer solidi interni). Rallenta questa impostazione per ottenere una superficie più rifinita. Questo valore può essere espresso come percentuale (per esempio: 80%) della velocità del riempimento solido qui sopra. Imposta a zero per auto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1648 +msgid "Speed for travel moves (jumps between distant extrusion points)." +msgstr "Velocità per movimenti di spostamento (salti tra punti di estrusione distanti)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1322 +msgid "Spiral vase" +msgstr "Vaso a spirale" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:540 +msgid "Spiral Vase" +msgstr "Vaso a Spirale" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:188 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:204 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 +msgid "Split" +msgstr "Dividi" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 +msgid "Split the selected object into individual parts" +msgstr "Divide l'oggetto selezionato in parti individuali" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:847 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1120 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1342 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1357 +msgid "Start G-code" +msgstr "Inizia G-code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 +msgid "Start new slicing process" +msgstr "Inizia un nuovo processo di slicing" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1539 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1581 +msgid "STL file exported to " +msgstr "File STL esportato a " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 +msgid "Success!" +msgstr "Successo!" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:198 +msgid "support" +msgstr "supporto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:620 +msgid "Support Generator" +msgstr "Generatore Supporto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:208 +msgid "support interface" +msgstr "interfaccia supporto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:374 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:375 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:191 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1030 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1380 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1387 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1399 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1409 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1417 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1432 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1453 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1464 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1480 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1489 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1498 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1509 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1525 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1533 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1534 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1543 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1551 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1565 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:147 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:89 +msgid "Support material" +msgstr "Materiale supporto" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1497 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:148 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:90 +msgid "Support material interface" +msgstr "Interfaccia materiale supporto" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1552 +msgid "Support material will not be generated for overhangs whose slope angle (90° = vertical) is above the given threshold. In other words, this value represent the most horizontal slope (measured from the horizontal plane) that you can print without support material. Set to zero for automatic detection (recommended)." +msgstr "Il materiale di supporto non sarà generato per sporgenze con angolo di inclinazione (90°=verticale) superiore al limite impostato. In altre parole, questo valore rappresenta l'inclinazione orizzontale massima (misurata dal piano orizzontale) che puoi stampare senza materiale di supporto. Imposta a zero per un rilevamento automatico (raccomandato)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1470 +msgid "Support material/raft interface extruder" +msgstr "Estrusore materiale di supporto/intefaccia raft" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1444 +msgid "Support material/raft/skirt extruder" +msgstr "Estrusore materiale di supporto/raft/skirt" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1408 +msgid "Support on build plate only" +msgstr "Supporti solo dal piano di stampa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:617 +msgid "" +"Supports work better, if the following feature is enabled:\n" +"- Detect bridging perimeters\n" +"\n" +"Shall I adjust those settings for supports?" +msgstr "" +"I supporti hanno più successo se l'opzione seguente è attivata:\n" +"-Rileva i perimetri in bridging\n" +"\n" +"Adattare questa opzione ai supporti?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:59 +msgid "Suppress \" - default - \" presets" +msgstr "Sopprimi preset \" - default - \"" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:61 +msgid "Suppress \" - default - \" presets in the Print / Filament / Printer selections once there are any other valid presets available." +msgstr "Sopprimi i preset \" - default - \" nelle selezioni Stampa / Filamento / Stampante non appena sono disponibili altri preset validi." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +msgid "SVG" +msgstr "SVG" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1544 +msgid "Synchronize support layers with the object print layers. This is useful with multi-material printers, where the extruder switch is expensive." +msgstr "Sincronizza i layer di supporto con i layer dell'oggetto stampato. E' utile con le stampanti multi-material, dove il cambio estrusore è costoso." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1542 +msgid "Synchronize with object layers" +msgstr "Sincronizza con i layer dell'oggetto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 +msgid "System Info" +msgstr "Informazioni di sistema" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1576 +msgid "Temperature" +msgstr "Temperatura" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:794 +msgid "Temperature " +msgstr "Temperatura " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1333 +msgid "Temperature difference to be applied when an extruder is not active. Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped." +msgstr "La differenza di temperatura da applicare quando un estrusore non è attivo. Abilita uno skirt \"sacrificale\" a piena altezza su cui l'ugello verrà pulito periodicamente." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1332 +msgid "Temperature variation" +msgstr "Variazione di temperatura" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1004 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1072 +msgid "Test" +msgstr "Test" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 +msgid "The " +msgstr "Il " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:309 +msgid "The extruder to use (unless more specific extruder settings are specified). This value overrides perimeter and infill extruders, but not the support extruders." +msgstr "Estrusore da utilizzare (a meno che non siano specificate impostazioni d'estrusore più specifiche). Questo valore scavalca l'estrusore dei perimetri e di riempimento, ma non l'estrusore dei supporti." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:703 +msgid "The extruder to use when printing infill." +msgstr "L'estrusore da utilizzare per la stampa del riempimento." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:959 +msgid "The extruder to use when printing perimeters and brim. First extruder is 1." +msgstr "L'estrusore da utilizzare per la stampa dei perimetri e del brim. Il primo estrusore è 1." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1273 +msgid "The extruder to use when printing solid infill." +msgstr "L'estrusore da utilizzare per la stampa del riempimento solido." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1472 +msgid "The extruder to use when printing support material interface (1+, 0 to use the current extruder to minimize tool changes). This affects raft too." +msgstr "L'estrusore da utilizzare per la stampa dell'interfaccia del materiale di supporto (1+, 0 per usare l'estrusore attuale per minimizzare il cambio di strumento). Questo influenza anche il raft." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1446 +msgid "The extruder to use when printing support material, raft and skirt (1+, 0 to use the current extruder to minimize tool changes)." +msgstr "L'estrusore da utilizzare per la stampa del materiale di supporto, raft e skirt (1+, 0 per utilizzare l'estrusore attuale per minimizzare i cambi di strumento)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:209 +msgid "The first layer will be shrunk in the XY plane by the configured value to compensate for the 1st layer squish aka an Elephant Foot effect." +msgstr "Il primo layer verrà ristretto sul piano XY dal valore configurato, così da compensare per lo schiacciamento del 1° layer, anche noto come effetto Zampa d'elefante." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1734 +msgid "The object will be grown/shrunk in the XY plane by the configured value (negative = inwards, positive = outwards). This might be useful for fine-tuning hole sizes." +msgstr "L'oggetto verrà allargato/ristretto sul piano XY dal valore configurato (negativo = verso l'interno, positivo = verso l'esterno). Questo può essere utile per regolare la grandezza dei fori." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1031 +msgid "The object will be raised by this number of layers, and support material will be generated under it." +msgstr "L'oggetto verrà sollevato da questo numero di layer, e verrà generato il materiale di supporto al di sotto di questo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1374 +msgid "The printer multiplexes filaments into a single hot end." +msgstr "La stampante processa diversi filamenti in un singolo hotend." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:324 +msgid "The selected file contains no geometry." +msgstr "Il file selezionato non contiene geometrie." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:328 +msgid "The selected file contains several disjoint areas. This is not supported." +msgstr "Il file selezionato contiene molteplici aree disgiunte. Non è supportato." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1112 +msgid "The selected object can't be split because it contains more than one volume/material." +msgstr "L'oggetto selezionato non può essere diviso perché contiene più di un volume/materiale." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1121 +msgid "The selected object couldn't be split because it contains only one part." +msgstr "L'oggetto selezionato non può essere diviso perché contiene solo una parte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1144 +msgid "The speed for loading of a filament into extruder after retraction (it only applies to the extruder motor). If left to zero, the retraction speed is used." +msgstr "La velocità di caricamento di un filamento nell'estrusore dopo la retrazione (si applica solamente al motore dell'estrusore). Se lasciato a zero, verrà utilizzata la velocità di retrazione." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1136 +msgid "The speed for retractions (it only applies to the extruder motor)." +msgstr "Velocità delle retrazioni (si applica solamente al motore dell'estrusore)." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:533 +#, no-c-format +msgid "" +"The Spiral Vase mode requires:\n" +"- one perimeter\n" +"- no top solid layers\n" +"- 0% fill density\n" +"- no support material\n" +"- no ensure_vertical_shell_thickness\n" +"\n" +"Shall I adjust those settings in order to enable Spiral Vase?" +msgstr "" +"La modalità Vaso a Spirale richiede:\n" +"- un perimetro\n" +"- assenza di layer solidi superiori\n" +"- densità riempimento 0%\n" +"- assenza di materiale di supporto\n" +"- assicura_spessore_ guscio_ verticale disattivato\n" +"\n" +"Posso regolare queste impostazioni così da attivare il Vaso a Spirale?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1560 +msgid "The supplied name is empty. It can't be saved." +msgstr "Il nome fornito è vuoto. Non può essere salvato." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1788 +msgid "The supplied name is not available." +msgstr "Il nome fornito non è disponibile." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1785 +msgid "The supplied name is not valid; the following characters are not allowed:" +msgstr "Il nome fornito non è valido; i seguenti caratteri non sono permessi:" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1418 +msgid "The vertical distance between object and support material interface. Setting this to 0 will also prevent Slic3r from using bridge flow and speed for the first object layer." +msgstr "Distanza verticale tra oggetto e interfaccia del materiale di supporto. Impostando questo valore a 0 eviterà che Slic3r utilizzi il flusso e velocità bridge per il primo layer dell'oggetto." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1312 +msgid "" +"The Wipe option is not available when using the Firmware Retraction mode.\n" +"\n" +"Shall I disable it in order to enable Firmware Retraction?" +msgstr "" +"La funzione Wipe non è disponibile quando si usa la modalità Retrazione Firmware.\n" +"\n" +"Devo disattivarla per poter abilitare la Retrazione Firmware?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:560 +msgid "" +"The Wipe Tower currently supports only:\n" +"- first layer height 0.2mm\n" +"- layer height from 0.15mm to 0.35mm\n" +"\n" +"Shall I adjust those settings in order to enable the Wipe Tower?" +msgstr "" +"La Torre di Spurgo al momento supporta solo:\n" +"- altezza primo layer 0.2mm\n" +"- altezza layer da 0.15mm a 0.35mm\n" +"\n" +"Devo regolare queste impostazioni per abilitare la Torre di Spurgo?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:581 +msgid "" +"The Wipe Tower currently supports the non-soluble supports only\n" +"if they are printed with the current extruder without triggering a tool change.\n" +"(both support_material_extruder and support_material_interface_extruder need to be set to 0).\n" +"\n" +"Shall I adjust those settings in order to enable the Wipe Tower?" +msgstr "" +"La Torre di Spurgo attualmente supporta solamente supporti non solubili\n" +"se questi sono stampati con l'attuale estrusore senza attivare un cambio d'attrezzo.\n" +"(entrambi support_material_extruder e support_material_interface_extruder devono essere impostati a 0).\n" +"\n" +"Devo regolare queste impostazioni per abilitare la Torre di Spurgo?" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:60 +msgid "This code is inserted between objects when using sequential printing. By default extruder and bed temperature are reset using non-wait command; however if M104, M109, M140 or M190 are detected in this custom code, Slic3r will not add temperature commands. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want." +msgstr "Questo codice è inserito tra gli oggetti quando si utilizza una stampa sequenziale. Come predefinito, la temperatura di estrusione e del piano sono resettate con il comando non-attesa; in ogni caso se nel codice personalizzato vengono rilevati i comandi M104,M109,M140 o M190, Slic3r non aggiungerà i comandi di temperatura. Si fa presente che puoi usare variabili sostitutive per tutte le impostazioni di Slic3r, quindi puoi inserire un comando \"M109 S[first_layer_temperature]\" quando preferisci." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:767 +msgid "This custom code is inserted at every layer change, right after the Z move and before the extruder moves to the first layer point. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z]." +msgstr "Questo codice personalizzato è inserito ad ogni cambio layer, subito dopo il movimento Z e prima che l'estrusore si sposti al punto del primo layer. Si fa presente che puoi usare variabili sostitutive per tutte le impostazioni di Slic3r sia per [layer_num] che per [layer_z]." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:49 +msgid "This custom code is inserted at every layer change, right before the Z move. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z]." +msgstr "Questo codice personalizzato è inserito ad ogni cambio layer, subito prima del movimento Z. Si fa presente che puoi usare variabili sostitutive per tutte le impostazioni di Slic3r sia per [layer_num] che per [layer_z]." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1603 +msgid "This custom code is inserted right before every extruder change. Note that you can use placeholder variables for all Slic3r settings as well as [previous_extruder] and [next_extruder]." +msgstr "Questo codice personalizzato è inserito ad ogni cambio estrusore, subito prima del movimento Z. Si fa presente che puoi usare variabili sostitutive per tutte le impostazioni di Slic3r sia per [previous_extruder] che per [next_extruder]." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:228 +msgid "This end procedure is inserted at the end of the output file, before the printer end gcode. Note that you can use placeholder variables for all Slic3r settings. If you have multiple extruders, the gcode is processed in extruder order." +msgstr "Questa procedura finale è inserita alla fine del file di output, prima del termine del gcode della stampante. Si fa presente che puoi usare variabili sostitutive per tutte le impostazioni di Slic3r. Se hai estrusori multipli, il gcode è processato nell'ordine dell'estrusore." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:218 +msgid "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings." +msgstr "Questa procedura finale è inserita alla fine del file di output. Si fa presente che puoi usare variabili sostitutive per tutte le impostazioni di Slic3r." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:827 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:838 +msgid "This experimental setting is used to limit the speed of change in extrusion rate. A value of 1.8 mm³/s² ensures, that a change from the extrusion rate of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds." +msgstr "Questa impostazione sperimentale è utilizzata per limitare la velocità del cambio nel fattore di estrusione. Un valore di 1.8 mm³/s² assicura che un cambio dal fattore di estrusione di 1.8 mm³/s (larghezza estrusione 0.45mm, altezza estrusione di 0.2mm, avanzamento 20 mm/s) a 5.4 mm³/s (avanzamento a 60 mm/s) impiegherà almeno 2 secondi." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:818 +msgid "This experimental setting is used to set the maximum volumetric speed your extruder supports." +msgstr "Questa impostazione sperimentale è utilizzata per impostare la massima velocità volumetrica supportata dal tuo estrusore." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1657 +msgid "This experimental setting uses G10 and G11 commands to have the firmware handle the retraction. This is only supported in recent Marlin." +msgstr "Questa funziona sperimentale utilizza i comandi G10 e G11 per permettere al firmware la gestione della retrazione. E' supportata solo nel Marlin recenti." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1671 +msgid "This experimental setting uses outputs the E values in cubic millimeters instead of linear millimeters. If your firmware doesn't already know filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] T0' in your start G-code in order to turn volumetric mode on and use the filament diameter associated to the filament selected in Slic3r. This is only supported in recent Marlin." +msgstr "Questa impostazione sperimentale produce un valore di E in uscita in millimetri cubici anziché in millimetri lienari. Se il tuo firmware non sa ancora qual'è il diametro del filamento, puoi inserire un comando tipo 'M200 D[filament_diameter_0] T0' nel tuo G-code iniziale in modo da attivare la funzione volumetrica e usare il diametro associato al filamento selezionato su Slic3r. Questa funziona è supportata solo nel Marlin più recente." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:108 +msgid "This factor affects the amount of plastic for bridging. You can decrease it slightly to pull the extrudates and prevent sagging, although default settings are usually good and you should experiment with cooling (use a fan) before tweaking this." +msgstr "Questo fattore influenza la quantità di plastica per il bridging. Puoi diminuirlo leggermente per tendere il materiale estruso ed evitare che si afflosci, sebbene le impostazioni predefinite sono generalmente buone ed è consigliabile sperimentare con il raffreddamento (usare la ventola) prima di modificare questo valore." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:368 +msgid "This factor changes the amount of flow proportionally. You may need to tweak this setting to get nice surface finish and correct single wall widths. Usual values are between 0.9 and 1.1. If you think you need to change this more, check filament diameter and your firmware E steps." +msgstr "Questo fattore modifica proporzionalmente il valore del flusso. Dovrai modificare questa impostazione per ottenere una buona finitura superficiale e correggere la larghezza delle pareti singole. Normalmente i valori sono tra 0.9 e 1.1. Se ritieni di dover modificare questo valore ulteriormente, controlla il diametro del filamento e i passi E del tuo firmware." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:98 +msgid "This fan speed is enforced during all bridges and overhangs." +msgstr "Questa velocità della ventola verrà forzata durante tutti i bridge e overhang." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:692 +msgid "This feature allows to combine infill and speed up your print by extruding thicker infill layers while preserving thin perimeters, thus accuracy." +msgstr "Questa funzione permette di combinare il riempimento e velocizza il tempo di stampa estrudendo layer di infill più spessi conservando tuttavia i perimetri sottili, e quindi l'accuratezza." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1281 +msgid "This feature allows to force a solid layer every given number of layers. Zero to disable. You can set this to any value (for example 9999); Slic3r will automatically choose the maximum possible number of layers to combine according to nozzle diameter and layer height." +msgstr "Questa funzione permette di forzare un layer solido ogni tot layer. Zero per disabilitare. E' possibile impostare qualunque valore (per esempio 9999); Slic3r sceglierà automaticamente il maggior numero possibile di layer da combinare secondo il diametro dell'ugello e l'altezza layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1323 +msgid "This feature will raise Z gradually while printing a single-walled object in order to remove any visible seam. This option requires a single perimeter, no infill, no top solid layers and no support material. You can still set any number of bottom solid layers as well as skirt/brim loops. It won't work when printing more than an object." +msgstr "Questa funzione solleverà Z gradualmente durante la stampa di un oggetto a parete singola allo scopo di rimuovere qualunque giunzione. Questa opzione richiede un singolo perimetro, nessun riempimento, nessun layer solido superiore e nessun materiale di supporto. E' possibile comunque impostare qualunque numero di layer solidi inferiori così come per i giri di skirt/brim. Non funzionerà stampando più di un oggetto." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:663 +msgid "" +"This file contains several objects positioned at multiple heights. Instead of considering them as multiple objects, should I consider\n" +"this file as a single object having multiple parts?\n" +msgstr "" +"Questo file contiene numerosi oggetti posizionati ad altezze multiple. Invece di considerarli come oggetti multipli, devo considerare \n" +"questo file come un oggetto singolo con parti multiple?\n" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:164 +msgid "This flag enables the automatic cooling logic that adjusts print speed and fan speed according to layer printing time." +msgstr "Questo contrassegno abilita la logica del raffreddamento automatico in modo da regolare la velocità di stampa e la velocità della ventola in base al tempo di stampa del layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1066 +msgid "This flag enforces a retraction whenever a Z move is done." +msgstr "Questo contrassegno forza una retrazione ogni volta che viene effettuato un movimento di Z." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1689 +msgid "This flag will move the nozzle while retracting to minimize the possible blob on leaky extruders." +msgstr "Questo contrassegno farà spostare l'ugello durante la retrazione in modo da minimizzare il possibile grumo su estrusori che perdono." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:343 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:406 +msgid "This is only used in the Slic3r interface as a visual help." +msgstr "Utilizzato solo nell'interfaccia di Slic3r come aiuto visivo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:171 +msgid "This is the acceleration your printer will be reset to after the role-specific acceleration values are used (perimeter/infill). Set zero to prevent resetting acceleration at all." +msgstr "Questa è l'accelerazione a cui la stampante sarà reimpostata dopo aver utilizzato un valore di accelerazione per un ruolo specifico (perimetro/riempimento). Imposta a zero per evitare del tutto la reimpostazione dell'accelerazione." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:78 +msgid "This is the acceleration your printer will use for bridges. Set zero to disable acceleration control for bridges." +msgstr "Questa è l'accelerazione che la tua stampante utilizzerà per i bridge. Impostala a zero per disattivare il controllo dell'accelerazione per i bridge." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:574 +msgid "This is the acceleration your printer will use for first layer. Set zero to disable acceleration control for first layer." +msgstr "Questa è l'accelerazione che la stampante utilizzerà per il primo layer. Imposta a zero per disattivare il controllo dell'accelerazione per il primo layer." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:682 +msgid "This is the acceleration your printer will use for infill. Set zero to disable acceleration control for infill." +msgstr "Questa è l'accelerazione che la stampante utilizzerà per il riempimento. Imposta a zero per disattivare il controllo dell'accelerazione per il riempimento." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:949 +msgid "This is the acceleration your printer will use for perimeters. A high value like 9000 usually gives good results if your hardware is up to the job. Set zero to disable acceleration control for perimeters." +msgstr "Questa è l'accelerazione che la stampante utilizzerà per i perimetri. Un valore alto come 9000 solitamente produce dei buoni risultati se l'hardware è all'altezza. Imposta a zero per disattivare il controllo dell'accelerazione per i perimetri." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:895 +msgid "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)" +msgstr "Questo è il diametro dell'ugello dell'estrusore (per esempio: 0.5, 0.35 ecc.)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:797 +#, no-c-format +msgid "This is the highest printable layer height for this extruder, used to cap the variable layer height and support layer height. Maximum recommended layer height is 75% of the extrusion width to achieve reasonable inter-layer adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter." +msgstr "Questa è la massima altezza layer stampabile per questo estrusore, usata come limite per l'altezza variabile dei layer e l'altezza dei layer di supporto. L'altezza layer massima raccomandata è il 75% della larghezza di estrusione, in modo da ottenere una buona adesione tra i layer. Se impostato a 0, l'altezza layer è limitata al 75% del diametro dell'ugello." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:858 +msgid "This is the lowest printable layer height for this extruder and limits the resolution for variable layer height. Typical values are between 0.05 mm and 0.1 mm." +msgstr "Questa è l'altezza minima stampabile per questo estrusore e limita la risoluzione per l'altezza variabile di layer. Valori tipici sono compresi tra 0.05 mm e 0.1 mm." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:990 +msgid "This option sets the number of perimeters to generate for each layer. Note that Slic3r may increase this number automatically when it detects sloping surfaces which benefit from a higher number of perimeters if the Extra Perimeters option is enabled." +msgstr "Questa opzione imposta il numero di perimetri da generare per ogni layer. Da notare che Slic3r aumenta questo numero automaticamente quando rileva superfici inclinate che potrebbero beneficiare di un aumento del numero dei perimetri se l'opzione Perimetri aggiuntivi è attiva." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:923 +msgid "This option will drop the temperature of the inactive extruders to prevent oozing. It will enable a tall skirt automatically and move extruders outside such skirt when changing temperatures." +msgstr "Questa opzione abbasserà la temperatura degli estrusori inattivi per prevenire oozing. Attiverà automaticamente uno skirt alto e muoverà l'estrusore al di fuori di questo skirt al cambiamento di temperature." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:728 +msgid "This option will limit infill to the areas actually needed for supporting ceilings (it will act as internal support material). If enabled, slows down the G-code generation due to the multiple checks involved." +msgstr "Questa opzione limiterà il riempimento alle aree che effettivamente hanno bisogno di un supporto per i soffitti (si comporterà come un materiale di supporto interno). Se attivato, rallenterà la generazione del G-code a causa dei molteplici controlli necessari." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:721 +msgid "This option will switch the print order of perimeters and infill, making the latter first." +msgstr "Questa opzione sostituirà l'ordine di stampa dei perimetri e del riempimento, realizzando per primo il secondo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:279 +msgid "This separate setting will affect the speed of external perimeters (the visible ones). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above. Set to zero for auto." +msgstr "Questa impostazione separata avrà effetto sulla velocità dei perimetri esterni (quelli visibili). Se espresso come percentuale (per esempio: 80%) verrà calcolato sull'impostazione della velocità dei perimetri qui sopra. Imposta a zero per automatico." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1252 +msgid "This separate setting will affect the speed of perimeters having radius <= 6.5mm (usually holes). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above. Set to zero for auto." +msgstr "Questa impostazione separata influenzerà la velocità dei perimetri con raggio <=6.5mm (solitamente i buchi). Se espresso come percentuale (per esempio: 80%) sarà calcolato sulla velocità dei perimetri qui sopra. Imposta a zero per automatico." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:737 +msgid "This setting applies an additional overlap between infill and perimeters for better bonding. Theoretically this shouldn't be needed, but backlash might cause gaps. If expressed as percentage (example: 15%) it is calculated over perimeter extrusion width." +msgstr "Questa impostazione applica una sovrapposizione aggiuntiva tra perimetri e riempimento per una migliore unione. Teoricamente non sarebbe necessario, ma i contraccolpi possono causare spazi vuoi. Se espresso in percentuale (per esempio: 15%) viene calcolato sulla larghezza d'estrusione del perimetro." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:779 +msgid "This setting controls the height (and thus the total number) of the slices/layers. Thinner layers give better accuracy but take more time to print." +msgstr "Questa impostazione controlla l'altezza (e quindi il numero totale) delle fette/layer. Un layer più sottile sarà più preciso ma sarà necessario più tempo per stampare." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:788 +msgid "This setting represents the maximum speed of your fan." +msgstr "Questa impostazione rappresenta la velocità massima della ventola." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:849 +msgid "This setting represents the minimum PWM your fan needs to work." +msgstr "Questa impostazione rappresenta la PWM minima (modulazione di larghezza di impulso) che la ventola necessita per lavorare." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1358 +msgid "This start procedure is inserted at the beginning, after any printer start gcode. This is used to override settings for a specific filament. If Slic3r detects M104, M109, M140 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want. If you have multiple extruders, the gcode is processed in extruder order." +msgstr "Questa procedura iniziale è inserita all'inizio, dopo qualunque gcode iniziale della stampante. Questo viene usato per scavalcare le impostazioni per un filamento specifico. Se Slic3r rileva M104, M109, M140 o M190 nel tuo codice personalizzato, questi comandi non verranno inseriti automaticamente così che sarà possibile personalizzare l'ordine dei comandi di riscaldamento e altre azioni personalizzate. Da notare che è possibile utilizzare variabili sostitutive per tutte le impostazioni di Slic3r, così che sia possibile inserire un comando \"M109S [first_layer_temperature]\" ovunque si voglia. Se si hanno estrusori multipli, il gcode è processato nell'ordine degli estrusori." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1343 +msgid "This start procedure is inserted at the beginning, after bed has reached the target temperature and extruder just started heating, and before extruder has finished heating. If Slic3r detects M104 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want." +msgstr "La procedura iniziale è inserita all'inizio, dopo che il piano ha raggiunto la temperatura impostata e l'estrusore ha appena iniziato a scaldare, e prima che l'estrusore abbia completato il riscaldamento. Se Slic3r rileva M104 o M190 nei tuoi codici personalizzati, questi comandi non verranno inseriti automaticamente così sarà possibile personalizzare l'ordine dei comandi di riscaldamento e altre azioni personalizzate. Da notare che è possibile utilizzare variabili sostitutive per tutte le impostazioni di Slic3r, così sarà possibile inserire un comando \"M109 S[first_layer_temperature]\" ovunque si voglia." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1743 +msgid "This value will be added (or subtracted) from all the Z coordinates in the output G-code. It is used to compensate for bad Z endstop position: for example, if your endstop zero actually leaves the nozzle 0.3mm far from the print bed, set this to -0.3 (or fix your endstop)." +msgstr "Questo valore sarà aggiunto (o sottratto) da tutte le coordinate Z nel G-code di output. Viene utilizzato per compensare una posizione di finecorsa Z errata: per esempio, se la posizione minima del finecorsa rimane in realtà 0.3mm lontano dal piano, imposta questo valore a -0.3 (o sistema il finecorsa)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1590 +msgid "Threads" +msgstr "Thread" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1591 +msgid "Threads are used to parallelize long-running tasks. Optimal threads number is slightly above the number of available cores/processors." +msgstr "I thread sono utilizzati per parallelizzare operazioni di lunga durata. Il numero di thread ottimali è leggermente superiore al numero di core / processori disponibili." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:338 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:72 +msgid "Tool" +msgstr "Strumento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1144 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1602 +msgid "Tool change G-code" +msgstr "G-code cambio strumento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1638 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 +msgid "Top" +msgstr "Superiore" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:187 +msgid "top solid infill" +msgstr "riempimento solido superiore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1613 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1624 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:143 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:85 +msgid "Top solid infill" +msgstr "Riempimento solido superiore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1642 +msgid "Top solid layers" +msgstr "Layer solidi superiori" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 +msgid "Top View" +msgstr "Vista superiore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:246 +msgid "Top/bottom fill pattern" +msgstr "Trama riempimento superiore/inferiore" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1647 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:95 +msgid "Travel" +msgstr "Spostamento" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 +msgid "Uniformly…" +msgstr "Uniformemente…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:97 +msgid "Unretractions" +msgstr "Non retrazioni" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1492 +msgid "Unsaved Changes" +msgstr "Modifiche non salvate" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:750 +msgid "Unsaved Presets" +msgstr "Preset non salvati" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:989 +msgid "USB/Serial connection" +msgstr "Connessione USB/Seriale" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1194 +msgid "USB/serial port for printer connection." +msgstr "Porta USB/Seriale per connessione stampante." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1656 +msgid "Use firmware retraction" +msgstr "Usa retrazione firmware" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:75 +msgid "Use legacy OpenGL 1.1 rendering" +msgstr "Utilizza il rendering legacy di OpenGL 1.1" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1663 +msgid "Use relative E distances" +msgstr "Usa distanze E relative" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:361 +msgid "Use this option to set the axis letter associated to your printer's extruder (usually E but some printers use A)." +msgstr "Usa questa opzione per impostare la lettera dell'asse associato all'estrusore della tua stampante (solitamente E, ma alcune stampanti utilizzano A)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1400 +msgid "Use this setting to rotate the support material pattern on the horizontal plane." +msgstr "Usa questa impostazione per ruotare la trama del materiale di supporto sul piano orizzontale." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1670 +msgid "Use volumetric E" +msgstr "Utilizza E volumetrico" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:449 +msgid "Used Filament (g)" +msgstr "Filamento usato (g)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:447 +msgid "Used Filament (m)" +msgstr "Filamento usato (m)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:448 +msgid "Used Filament (mm³)" +msgstr "Filamento usato (mm³)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:644 +msgid "Verbose G-code" +msgstr "G-code Verbose" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 +msgid "Version " +msgstr "Versione " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:318 +msgid "Vertical shells" +msgstr "Gusci verticali" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:65 +msgid "View" +msgstr "Vista" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:409 +msgid "Volume" +msgstr "Volume" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "Volumetric" +msgstr "Volumetrico" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:500 +msgid "Warning" +msgstr "Attenzione" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:131 +msgid "What do you want to print today? â„¢" +msgstr "Cosa vuoi stampare oggi? â„¢" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:69 +msgid "When checked, the print and filament presets are shown in the preset editor even if they are marked as incompatible with the active printer" +msgstr "Quando attivato, i preset di stampa e di filamento vengono mostrati nell'editor dei preset anche se sono segnati come incompatibili con la stampante attiva" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:219 +msgid "when printing " +msgstr "durante la stampa " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:136 +msgid "When printing multi-material objects, this settings will make slic3r to clip the overlapping object parts one by the other (2nd part will be clipped by the 1st, 3rd part will be clipped by the 1st and 2nd etc)." +msgstr "Durante la stampa di oggetti multi-materiali, questa impostazione farà si che slic3r unisca le parti sovrapposte dell'oggetto (la seconda sarà collegata con la prima, la terza parte sarà collegata con la prima e la seconda ecc..)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:155 +msgid "When printing multiple objects or copies, this feature will complete each object before moving onto next one (and starting it from its bottom layer). This feature is useful to avoid the risk of ruined prints. Slic3r should warn and prevent you from extruder collisions, but beware." +msgstr "Durante la stampa di oggetti multipli o copie, questa funzione completerà ciascun oggetto prima di spostarsi al prossimo (e iniziando la stampa dal primo layer). Questa funzione è utile per evitare il rischio di stampe rovinate. Slic3r dovrebbe avvisarti e prevenire collisioni con l'estrusore, ma fai attenzione." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:605 +msgid "When printing with very low layer heights, you might still want to print a thicker bottom layer to improve adhesion and tolerance for non perfect build plates. This can be expressed as an absolute value or as a percentage (for example: 150%) over the default layer height." +msgstr "Durante la stampa di layer molto bassi, potresti comunque aver bisogno di stampare layer inferiori più spessi per migliorare l'adesione e la tolleranza per piani di stampa non perfetti. Questo può essere espresso come un valore assoluto o come una percentuale (per esempio: 150%) sull'altezza layer predefinita." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1082 +msgid "When retraction is triggered before changing tool, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder)." +msgstr "Quando viene attivata la retrazione prima del cambio strumento, il filamento è ritirato per la quantità specificata (la lunghezza è misurata sul filamento grezzo, prima che questo entri dentro l'estrusore)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1073 +msgid "When retraction is triggered, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder)." +msgstr "Quando viene attivata la retrazione, il filamento viene ritirato per la quantità specificata (la lunghezza è misurata sul filamento grezzo, prima che questo entri dentro l'estrusore)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:808 +msgid "When setting other speed settings to 0 Slic3r will autocalculate the optimal speed in order to keep constant extruder pressure. This experimental setting is used to set the highest print speed you want to allow." +msgstr "Quando viene impostata altre velocità a 0, Slic3r calcolerà automaticamente la velocità ottimale in modo da mantenere costante la pressione dell'estrusore. Questa impostazione sperimentale è utilizzata per impostare la velocità massima di stampa che vuoi permettere." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1127 +msgid "When the retraction is compensated after changing tool, the extruder will push this additional amount of filament." +msgstr "Quando la retrazione è compensata dopo un cambio di strumento, l'estrusore spingerà questa quantità addizionale di filamento." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1119 +msgid "When the retraction is compensated after the travel move, the extruder will push this additional amount of filament. This setting is rarely needed." +msgstr "Quando la retrazione è compensata dopo un movimento di spostamento, l'estrusore spingerà questa quantità addizionale di filamento. Questa impostazione è raramente necessaria." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1716 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:70 +msgid "Width" +msgstr "Larghezza" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:334 +msgid "Width (mm)" +msgstr "Larghezza (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1717 +msgid "Width of a wipe tower" +msgstr "Larghezza della torre di spurgo" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:41 +#, c-format +msgid "will always run at %d%% " +msgstr "lavorerà sempre a %d%% " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:50 +msgid "will be turned off." +msgstr "verrà spento." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:442 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:149 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:91 +msgid "Wipe tower" +msgstr "Torre di spurgo" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:564 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:585 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:602 +msgid "Wipe Tower" +msgstr "Torre di Spurgo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1688 +msgid "Wipe while retracting" +msgstr "Pulisci durante la retrazione" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1058 +msgid "With bowden extruders, it may be wise to do some amount of quick retract before doing the wipe movement." +msgstr "Con estrusori bowden, potrebbe essere saggio effettuare una certa retrazione veloce prima di effettuare un movimento di pulizia." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1564 +msgid "With sheath around the support" +msgstr "Con guaina attorno al supporto" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1703 +msgid "X coordinate of the left front corner of a wipe tower" +msgstr "Coordinata X dell'angolo frontale sinistro di una torre di spurgo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1386 +msgid "XY separation between an object and its support" +msgstr "Separazione XY tra un oggetto e il suo supporto" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1388 +msgid "XY separation between an object and its support. If expressed as percentage (for example 50%), it will be calculated over external perimeter width." +msgstr "La separazione XY tra l'oggetto e il suo supporto. Se espresso come percentuale (ad esempio 50%), verrà calcolato sulla larghezza del perimetro esterno." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1732 +msgid "XY Size Compensation" +msgstr "Compensazione dimensione XY" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1710 +msgid "Y coordinate of the left front corner of a wipe tower" +msgstr "Coordinata Y dell'angolo frontale sinistro di una torre di spurgo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1970 +msgid "Yes" +msgstr "Si" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:885 +msgid "You can put here your personal notes. This text will be added to the G-code header comments." +msgstr "E' possibile inserire qui le note personali. Questo testo verrà aggiunto nei commenti iniziali del G-code." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:413 +msgid "You can put your notes regarding the filament here." +msgstr "E' possibile inserire qui le note riguardanti il filamento." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1015 +msgid "You can put your notes regarding the printer here." +msgstr "E' possibile inserire qui le note riguardanti la stampante." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:181 +msgid "You can set this to a positive value to disable fan at all during the first layers, so that it does not make adhesion worse." +msgstr "E' possibile impostare un valore positivo per disattivare completamente la ventola durante i primi layer, così da non peggiorare l'adesione." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:931 +msgid "You can use all configuration options as variables inside this template. For example: [layer_height], [fill_density] etc. You can also use [timestamp], [year], [month], [day], [hour], [minute], [second], [version], [input_filename], [input_filename_base]." +msgstr "E' possibile utilizzare tutte le opzioni di configurazione come variabili all'interno di questo modello. Ad esempio: [layer_height], [fill_density] ecc. Puoi anche usare [timestamp], [year], [month], [day], [hour], [minute], [second], [version], [input_filename ], [nome_filename_input]." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 +msgid "You have unsaved changes " +msgstr "Sono presenti modifiche non salvate " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:101 +msgid "You need to restart Slic3r to make the changes effective." +msgstr "E' necessario riavviare Slic3r per rendere effettive le modifiche." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 +msgid "Your file was repaired." +msgstr "Il file è stato riparato." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:744 +msgid "Your object appears to be too large, so it was automatically scaled down to fit your print bed." +msgstr "L'oggetto sembra essere troppo grande, è stato quindi scalato automaticamente per entrare nel piano di stampa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1742 +msgid "Z offset" +msgstr "Offset Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:91 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:492 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1170 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1181 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1401 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1557 +msgid "°" +msgstr "°" From 5c9ba1399f184376c1b2ad19d969864e90419446 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 21 Mar 2018 14:28:51 +0100 Subject: [PATCH 0068/1150] Updated Czech to localization --- resources/localization/cs_CZ/Slic3rPE.mo | Bin 84861 -> 102179 bytes resources/localization/cs_CZ/Slic3rPE_cs.po | 635 +++++++++++--------- 2 files changed, 342 insertions(+), 293 deletions(-) diff --git a/resources/localization/cs_CZ/Slic3rPE.mo b/resources/localization/cs_CZ/Slic3rPE.mo index 7183dea318460bad33e31f1e2c014038a98bb94a..b167829156733700f786d20a00a63217894f4c76 100644 GIT binary patch delta 33225 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 delta 16571 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\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -30,17 +30,17 @@ msgstr "RozmÄ›r" #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:51 msgid "Size in X and Y of the rectangular plate." -msgstr "RozmÄ›r tiskové podložky v ose X a Y." +msgstr "RozmÄ›r obdélníkové tiskové podložky v ose X a Y." #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:57 msgid "Origin" -msgstr "Origin" +msgstr "PoÄátek" #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:58 msgid "" "Distance of the 0,0 G-code coordinate from the front left corner of the " "rectangle." -msgstr "Vzdálenost souÅ™adnice 0,0 G-kódu od pÅ™edního levého rohu obdélníku." +msgstr "Vzdálenost souÅ™adnice 0,0 G-code od pÅ™edního levého rohu obdélníku." #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:62 msgid "Circular" @@ -89,13 +89,13 @@ msgid "" "Diameter of the print bed. It is assumed that origin (0,0) is located in the " "center." msgstr "" -"PrůmÄ›r tiskové podložky.PÅ™epokládaná souÅ™adnice 0,0 je umístÄ›na uprostÅ™ed." +"PrůmÄ›r tiskové podložky. PÅ™epokládaný poÄátek (0,0) je umístÄ›n uprostÅ™ed." #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:71 #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:150 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:92 msgid "Custom" -msgstr "Upravený" +msgstr "Vlastní" #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:75 msgid "Load shape from STL..." @@ -108,6 +108,7 @@ msgstr "Nastavení" #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:298 msgid "Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):" msgstr "" +"Vyberte soubor pro import tvaru tiskové podložky z (STL/OBJ/AMF/3MF/PRUSA):" #: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:315 msgid "Error! " @@ -147,7 +148,7 @@ msgstr "Výchozí" #: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:325 msgid "Change Application Language" -msgstr "ZmÄ›nit Jazyk Aplikace" +msgstr "ZmÄ›nit jazyk aplikace" #: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 msgid "Application will be restarted" @@ -159,7 +160,7 @@ msgstr "Pozor!" #: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:339 msgid "&Localization" -msgstr "" +msgstr "&Lokalizace" #: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:488 #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:470 @@ -198,11 +199,11 @@ msgstr "Výška vrstvy" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:318 msgid "Vertical shells" -msgstr "Vertical shells" +msgstr "Svislé stÄ›ny" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:329 msgid "Horizontal shells" -msgstr "Horizontal shells" +msgstr "Vodorovné stÄ›ny" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:330 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1314 @@ -250,13 +251,13 @@ msgstr "Zkracování tiskového Äasu" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:364 msgid "Skirt and brim" -msgstr "Obrysová Äára a límec" +msgstr "Obrys a límec" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:365 #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:146 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:88 msgid "Skirt" -msgstr "Obrysová Äára" +msgstr "Obrys" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:371 msgid "Brim" @@ -295,7 +296,7 @@ msgstr "Raft" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:384 msgid "Options for support material and raft" -msgstr "Options for support material and raft" +msgstr "Volby pro podpory a raft" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:398 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:118 @@ -317,7 +318,7 @@ msgstr "Speed for print moves" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:411 msgid "Speed for non-print moves" -msgstr "Speed for non-print moves" +msgstr "Netiskové rychlosti" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:414 msgid "Modifiers" @@ -344,11 +345,11 @@ msgstr "Multiple Extruders" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1445 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1471 msgid "Extruders" -msgstr "Extrudér" +msgstr "Extruder" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:438 msgid "Ooze prevention" -msgstr "Ooze prevention" +msgstr "Prevence odkapávání" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:442 #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:149 @@ -382,7 +383,7 @@ msgstr "SekvenÄní tisk" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:479 msgid "Extruder clearance (mm)" -msgstr "Kolizní oblast extrudéru (mm)" +msgstr "Kolizní oblast extruderu (mm)" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:488 msgid "Output file" @@ -391,7 +392,7 @@ msgstr "Výstupní soubor" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:494 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1001 msgid "Post-processing scripts" -msgstr "Post-processing scripts" +msgstr "PostprodukÄní skripty" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:500 #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:501 @@ -420,7 +421,7 @@ msgid "Compatible printers" msgstr "Kompatibilní tiskárny" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:533 -#, fuzzy, no-c-format +#, no-c-format msgid "" "The Spiral Vase mode requires:\n" "- one perimeter\n" @@ -434,7 +435,7 @@ msgstr "" "Mód spirálové vázy vyžaduje:\n" "- jeden perimeter\n" "- žádné plné vrchní vrstvy\n" -"- 0% výplň\n" +"- 0% hustota výplnÄ›\n" "- žádné podpÄ›ry\n" "- nezjišťování vertikální tloušťky pláštÄ›\n" "\n" @@ -476,8 +477,8 @@ msgid "" msgstr "" "ÄŒistící věž v souÄasné dobÄ› podporuje pouze nerozpustné podpory\n" "pokud jsou vytiÅ¡tÄ›ny s aktuálním extrudérem bez spuÅ¡tÄ›ní výmÄ›ny nástroje.\n" -"(jak extruder pro tisk popor tak extruder pro tisk interface podpor je tÅ™eba " -"nastavit na 0).\n" +"(jak extruder pro tisk popor tak extruder pro tisk kontaktních podpor je " +"tÅ™eba nastavit na 0).\n" "\n" "Mám tyto nastavení upravit tak, aby bylo možné zapnout ÄŒistící věž?" @@ -514,7 +515,7 @@ msgid "The " msgstr "" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 -#, fuzzy, no-c-format +#, no-c-format msgid "" " infill pattern is not supposed to work at 100% density.\n" "\n" @@ -538,7 +539,7 @@ msgstr "Teplota " #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1234 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:307 msgid "Extruder" -msgstr "Extrudér" +msgstr "Extruder" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:800 msgid "Bed" @@ -564,7 +565,7 @@ msgstr "Rychlost ventilátoru" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:826 msgid "Cooling thresholds" -msgstr "Práh chlazení" +msgstr "Podmínky chlazení" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:832 msgid "Filament properties" @@ -577,14 +578,14 @@ msgstr "PÅ™epsání rychlosti tisku" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:846 #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119 msgid "Custom G-code" -msgstr "Upravený G-kód" +msgstr "Vlastní G-code" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:847 #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1120 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1342 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1357 msgid "Start G-code" -msgstr "ZaÄátek G-kódu" +msgstr "ZaÄátek G-code" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:853 #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1126 @@ -665,27 +666,27 @@ msgstr "Firmware" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1132 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:48 msgid "Before layer change G-code" -msgstr "Before layer change G-code" +msgstr "G-code pÅ™ed zmÄ›nou vrstvy" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1138 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:766 msgid "After layer change G-code" -msgstr "After layer change G-code" +msgstr "G-code po zmÄ›nÄ› vrstvy" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1144 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1602 msgid "Tool change G-code" -msgstr "Tool change G-code" +msgstr "G-code pro výmÄ›nu nástroje" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1150 msgid "Between objects G-code (for sequential printing)" -msgstr "Between objects G-code (for sequential printing)" +msgstr "G-code mezi objekty (pro sekvenÄní tisk)" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1187 #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:400 #, c-format msgid "Extruder %d" -msgstr "Extrudér %d" +msgstr "Extruder %d" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1194 msgid "Layer height limits" @@ -693,7 +694,7 @@ msgstr "Výskové limity vrstvy" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1199 msgid "Position (for multi-extruder printers)" -msgstr "Position (for multi-extruder printers)" +msgstr "Pozice (pro tiskárny s více extrudery)" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1202 msgid "Retraction" @@ -708,8 +709,8 @@ msgid "" "Retraction when tool is disabled (advanced settings for multi-extruder " "setups)" msgstr "" -"Retraction when tool is disabled (advanced settings for multi-extruder " -"setups)" +"Retrakce pro neaktivní extruder (pokroÄilé nastavení pro tiskárny typu " +"MultiMaterial)" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1222 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:150 @@ -723,9 +724,9 @@ msgid "" "\n" "Shall I disable it in order to enable Firmware Retraction?" msgstr "" -"The Wipe option is not available when using the Firmware Retraction mode.\n" +"Možnost OÄistit není k dispozici pÅ™i použití režimu retrací z firmwaru.\n" "\n" -"Shall I disable it in order to enable Firmware Retraction?" +"Mám ji deaktivovat, aby bylo možné povolit retrakce z firmwaru?" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1314 msgid "Firmware Retraction" @@ -789,7 +790,7 @@ msgstr "Neuložené ZmÄ›ny" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1560 msgid "The supplied name is empty. It can't be saved." -msgstr "The supplied name is empty. It can't be saved." +msgstr "Název je prázdný. Nelze uložit." #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 msgid "remove" @@ -828,7 +829,7 @@ msgstr "VÅ¡e" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1667 msgid "Select the printers this profile is compatible with." -msgstr "Select the printers this profile is compatible with." +msgstr "Vyberte tiskárny, s nimiž je tento profil kompatibilní." #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 @@ -843,12 +844,11 @@ msgstr " jako:" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1785 msgid "" "The supplied name is not valid; the following characters are not allowed:" -msgstr "" -"The supplied name is not valid; the following characters are not allowed:" +msgstr "Zadaný název je naplatný; následující znaky nejsou povoleny:" #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1788 msgid "The supplied name is not available." -msgstr "The supplied name is not available." +msgstr "Zadaný název není dostupný." #: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:182 msgid "Print Settings" @@ -877,6 +877,9 @@ msgid "" "will be reduced so that no less than %ds are spent on that layer (however, " "speed will never be reduced below %dmm/s)." msgstr "" +"Pokud je odhadovaný Äas vrstvy nižší než ~% ds, bude ventilátor pracovat na " +"%d%% a rychlost tisku bude snížena tak, aby na tuto vrstvu nebylo použito " +"ménÄ› než %ds (rychlost vÅ¡ak nikdy nebude snížena pod %dmm/s)." #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:30 #, c-format @@ -885,6 +888,9 @@ msgid "" "If estimated layer time is greater, but still below ~%ds, fan will run at a " "proportionally decreasing speed between %d%% and %d%%." msgstr "" +"\n" +"Pokud je odhadovaný Äas vrstvy delší, ale stále pod ~% ds, bude ventilátor " +"pracovat s plynule klesající rychlostí mezi %d%% a %d%%." #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:34 msgid "" @@ -901,12 +907,12 @@ msgstr "Ventilátor " #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:41 #, c-format msgid "will always run at %d%% " -msgstr "" +msgstr "bude vždy běžet na %d%% " #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:44 #, c-format msgid "except for the first %d layers" -msgstr "" +msgstr "s výjimkou prvních %d vrstev" #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:48 msgid "except for the first layer" @@ -918,7 +924,7 @@ msgstr "bude vypnut." #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:151 msgid "external perimeters" -msgstr "VnÄ›jší perimetry" +msgstr "vnÄ›jší perimetry" #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:160 msgid "perimeters" @@ -946,57 +952,59 @@ msgstr "kontaktní vrstva podpor" #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 msgid "First layer volumetric" -msgstr "" +msgstr "Volumetrická hodnota první vrstvy" #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 msgid "Bridging volumetric" -msgstr "" +msgstr "Volumetrická hodnota mostů" #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 msgid "Volumetric" -msgstr "" +msgstr "Volumetrický" #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:215 msgid " flow rate is maximized " -msgstr "" +msgstr " průtok je maximalizován " #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:218 msgid "by the print profile maximum" -msgstr "" +msgstr "maximem pro profil tisku" #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:219 msgid "when printing " -msgstr "" +msgstr "pÅ™i tisku " #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:220 msgid " with a volumetric rate " -msgstr "" +msgstr " s objemovou rychlostí " #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:224 #, c-format msgid "%3.2f mm³/s" -msgstr "" +msgstr "%3.2f mm³/s" #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:226 #, c-format msgid " at filament speed %3.2f mm/s." -msgstr "" +msgstr " pÅ™i rychlosti filamentu %3.2f mm/s." #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:245 msgid "" "Recommended object thin wall thickness: Not available due to invalid layer " "height." msgstr "" +"DoporuÄená tloušťka stÄ›ny objektu: Není k dispozici kvůli neplatné výšce " +"vrstvy." #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:262 #, c-format msgid "Recommended object thin wall thickness for layer height %.2f and " -msgstr "" +msgstr "DoporuÄená tloušťka stÄ›ny objektu pro výšku vrstvy %.2f and " #: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:269 #, c-format msgid "%d lines: %.2lf mm" -msgstr "" +msgstr "%d linie: %.2lf mm" #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp:17 msgid "Preferences" @@ -1004,13 +1012,15 @@ msgstr "Nastavení" #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:27 msgid "Remember output directory" -msgstr "Pamatovat výstupní složku" +msgstr "Pamatovat si výstupní složku" #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:29 msgid "" "If this is enabled, Slic3r will prompt the last output directory instead of " "the one containing the input files." msgstr "" +"Pokud je tato volba povolena, Slic3r vyvolá poslední výstupní adresář " +"namísto toho, který obsahuje vstupní soubory." #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:35 msgid "Auto-center parts" @@ -1021,6 +1031,8 @@ msgid "" "If this is enabled, Slic3r will auto-center objects around the print bed " "center." msgstr "" +"Pokud je tato možnost povolena, Slic3r bude automaticky centrovat objekty " +"kolem stÅ™edu tiskové plochy." #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:43 msgid "Background processing" @@ -1031,6 +1043,8 @@ msgid "" "If this is enabled, Slic3r will pre-process objects as soon as they're " "loaded in order to save time when exporting G-code." msgstr "" +"Pokud je tato možnost povolena, Slic3r pÅ™edprojektuje objekty, jakmile budou " +"naÄteny, aby Å¡etÅ™il Äas pÅ™i exportu G-code." #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:51 msgid "Disable USB/serial connection" @@ -1042,30 +1056,36 @@ msgid "" "simplifies the user interface in case the printer is never attached to the " "computer." msgstr "" +"Zakázat komunikaci s tiskárnou pÅ™es sériový / USB kabel. To zjednoduÅ¡uje " +"uživatelské rozhraní v případÄ›, že tiskárna není nikdy pÅ™ipojena k poÄítaÄi." #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:59 msgid "Suppress \" - default - \" presets" -msgstr "" +msgstr "PotlaÄit “ - výchozí - “ pÅ™ednastavení" #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:61 msgid "" "Suppress \" - default - \" presets in the Print / Filament / Printer " "selections once there are any other valid presets available." msgstr "" +"PotlaÄit “ - výchozí - “ pÅ™ednastavení v nabídkách Tisk / Filament / " +"Tiskárna, jakmile budou k dispozici další platné pÅ™edvolby." #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:67 msgid "Show incompatible print and filament presets" -msgstr "" +msgstr "Zobrazit nekompatibilní pÅ™ednastavení tisku a filamentu" #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:69 msgid "" "When checked, the print and filament presets are shown in the preset editor " "even if they are marked as incompatible with the active printer" msgstr "" +"Pokud je zaÅ¡krtnuto, pÅ™ednastavení tisku a filamentu se zobrazují v editoru " +"pÅ™ednastavení, i když jsou oznaÄeny jako nekompatibilní s aktivní tiskárnou" #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:75 msgid "Use legacy OpenGL 1.1 rendering" -msgstr "" +msgstr "Použijte historické OpenGL 1.1 vykreslování" #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:77 msgid "" @@ -1073,10 +1093,13 @@ msgid "" "try to check this checkbox. This will disable the layer height editing and " "anti aliasing, so it is likely better to upgrade your graphics driver." msgstr "" +"Pokud máte problémy s vykreslováním způsobené chybným ovladaÄem OpenGL 2.0, " +"můžete se pokusit zaÅ¡krtnout toto políÄko. Tím se vypnou úpravy výšky " +"hladiny a vyhlazení, takže je je lepší upgradovat grafický ovladaÄ." #: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:101 msgid "You need to restart Slic3r to make the changes effective." -msgstr "" +msgstr "Chcete-li provést zmÄ›ny, musíte restartovat aplikaci Slic3r." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:26 msgid "Avoid crossing perimeters" @@ -1088,9 +1111,9 @@ msgid "" "is mostly useful with Bowden extruders which suffer from oozing. This " "feature slows down both the print and the G-code generation." msgstr "" -"Optimalizovat pÅ™esuny do poÅ™adí aby se minimalizovalo pÅ™ejíždÄ›ní perimetrů. " -"Nejvíce užiteÄné u Bowdenových extruderů které trpí na vytékáné filamentu. " -"Toto nastavení zpomaluje tisk i generování G-kódu." +"Optimalizovat rychloposuny do poÅ™adí aby se minimalizovalo pÅ™ejíždÄ›ní " +"perimetrů. Nejvíce užiteÄné u Bowdenových extruderů které trpí na vytékáné " +"filamentu. Toto nastavení zpomaluje tisk i generování G-code." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:38 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1572 @@ -1115,13 +1138,13 @@ msgid "" "Note that you can use placeholder variables for all Slic3r settings as well " "as [layer_num] and [layer_z]." msgstr "" -"Tento upravený kód je vložen pro každou zmÄ›nu vrstvy, pÅ™edtím než se pohne " -"Z. Můžete pÅ™idávat zástupné promÄ›nné pro veÅ¡keré nastavení Slic3ru stejnÄ› " -"tak jako [layer_num] a [layer_z]." +"Tento vlastní kód je vložen pro každou zmÄ›nu vrstvy, pÅ™edtím než se pohne Z. " +"Můžete pÅ™idávat zástupné promÄ›nné pro veÅ¡keré nastavení Slic3ru stejnÄ› tak " +"jako [layer_num] a [layer_z]." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:59 msgid "Between objects G-code" -msgstr "G-kód mezi objekty" +msgstr "G-code mezi objekty" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:60 msgid "" @@ -1133,9 +1156,9 @@ msgid "" "S[first_layer_temperature]\" command wherever you want." msgstr "" "Tento kód je vložen mezi objekty, pokud je použit sekvenÄní tisk. Ve " -"výchozím nastavení je resetován extrudér a tisková podložka pomocí non-wait " +"výchozím nastavení je resetován extruder a tisková podložka pomocí non-wait " "(neÄekacím) příkazem; nicménÄ› pokud jsou příkazy M104, M109, 140 nebo M190 " -"detekovány v tomto upraveném kódu, Slic3r nebude pÅ™idávat teplotní příkazy. " +"detekovány v tomto vlastním kódu, Slic3r nebude pÅ™idávat teplotní příkazy. " "Můžete pÅ™idávat zástupné promÄ›nné pro veÅ¡keré nastavení Slic3ru, takže " "můžete vložit příkaz “M109 S[first_layer_temperature]†kamkoliv chcete." @@ -1284,7 +1307,7 @@ msgid "" "the overlapping object parts one by the other (2nd part will be clipped by " "the 1st, 3rd part will be clipped by the 1st and 2nd etc)." msgstr "" -"PÅ™ipnutí pÅ™ekrývajících se objektů jednek druhému pÅ™i multi-materiálovém " +"PÅ™ipnutí pÅ™ekrývajících se objektů jeden k druhému pÅ™i Multimateriálovém " "tisku. (Druhá Äást se pÅ™ipne k první, tÅ™etí Äást k první a druhé, atd)." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:147 @@ -1312,7 +1335,7 @@ msgstr "" "PÅ™i tisku více objektů nebo kopií tiskárna kompletnÄ› dokonÄí jeden objekt, " "pÅ™edtím než zaÄne tisknout druhý (zaÄíná od spodní vstvy). Tato vlastnost je " "výhodná z důvodů snížení rizika zniÄených výtisků. Slic3r by mÄ›l varovat pÅ™i " -"možné kolizi extrudéru s objektem a zabránit mu, pÅ™esto doporuÄujeme " +"možné kolizi extruderu s objektem a zabránit mu, pÅ™esto doporuÄujeme " "obezÅ™etnost." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:163 @@ -1376,17 +1399,19 @@ msgstr "Vzdálenost mezi kopiemi" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:199 msgid "Distance used for the auto-arrange feature of the plater." -msgstr "" +msgstr "Vzdálenost, použitá pro funkci automatického rozmístÄ›ní po podložce." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:207 msgid "Elephant foot compensation" -msgstr "" +msgstr "Kompenzace rozplácnutí první vrstvy" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:209 msgid "" "The first layer will be shrunk in the XY plane by the configured value to " "compensate for the 1st layer squish aka an Elephant Foot effect." msgstr "" +"První vrstva bude v rovinÄ› XY zmenÅ¡ena nakonfigurovanou hodnotou, která " +"kompenzuje rozplácnutí první vrstvy." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:218 msgid "" @@ -1404,25 +1429,25 @@ msgid "" "extruder order." msgstr "" "Tato ukonÄovací procedůra je vložena na konec výstupního souboru, pÅ™ed " -"koneÄným g-kódem tiskárny. Můžete pÅ™idávat zástupné promÄ›nné pro veÅ¡keré " -"nastavení Slic3ru. Pokud máte tiskárnu s více extrudéry, g-kód je zpracován " -"v poÅ™adí extrudérů." +"koneÄným G-code tiskárny. Můžete pÅ™idávat zástupné promÄ›nné pro veÅ¡keré " +"nastavení Slic3ru. Pokud máte tiskárnu s více extrudery, G-code je zpracován " +"v poÅ™adí extruderů." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:238 msgid "Ensure vertical shell thickness" -msgstr "Zajistit vertikální tloušťku obalu" +msgstr "Zajistit tloušťku svislých stÄ›n" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:240 msgid "" "Add solid infill near sloping surfaces to guarantee the vertical shell " "thickness (top+bottom solid layers)." msgstr "" -"PÅ™idá plnou výplň u Å¡ikmých ploch pro garanci vertikální tloušťky obalu " +"PÅ™idá plnou výplň u Å¡ikmých ploch pro garanci tloušťky svislých stÄ›n " "(vrchních a spodních plných vrstev)." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:246 msgid "Top/bottom fill pattern" -msgstr "Vzor výplnÄ› vrchních/spodních vrstev" +msgstr "Vzor výplnÄ› horních/spodních vrstev" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:248 msgid "" @@ -1507,7 +1532,7 @@ msgid "Extra perimeters if needed" msgstr "Extra perimetry pokud jsou potÅ™eba" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:299 -#, fuzzy, no-c-format +#, no-c-format msgid "" "Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r " "keeps adding perimeters, until more than 70% of the loop immediately above " @@ -1523,9 +1548,9 @@ msgid "" "This value overrides perimeter and infill extruders, but not the support " "extruders." msgstr "" -"Extrudér, který chcete použít (pokud nejsou zvoleny specifiÄtÄ›jší nastavení " +"Extruder, který chcete použít (pokud nejsou zvoleny specifiÄtÄ›jší nastavení " "extruderu). Tato hodnota pÅ™epíše nastavení perimetrového a výplňového " -"exrtuderu, ale ne nastavení extrudéru pro podpory." +"exrtuderu, ale ne nastavení extruderu pro podpory." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:320 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:69 @@ -1540,8 +1565,8 @@ msgid "" "extruder can peek before colliding with other printed objects." msgstr "" "Zadejte vertikální vzdálenost mezi tryskou a (obvykle) tyÄemi osy X. Jinými " -"slovy, je to výška kolizního prostoru okolo extrudéru a pÅ™edstavuje " -"maximální hloubku, které může extrudér dosáhnout pÅ™ed kolizí s jinými, již " +"slovy, je to výška kolizního prostoru okolo extruderu a pÅ™edstavuje " +"maximální hloubku, které může extruder dosáhnout pÅ™ed kolizí s jinými, již " "vytiÅ¡tÄ›nými, objekty." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:331 @@ -1554,13 +1579,13 @@ msgid "" "not centered, choose the largest value for safety. This setting is used to " "check for collisions and to display the graphical preview in the plater." msgstr "" -"Zadejte horizontální rádius kolizního prostoru okolo extrudéru. Pokud tryska " +"Zadejte horizontální rádius kolizního prostoru okolo extruderu. Pokud tryska " "není v centru tohoto rádiusu, zvolte nejdelší vzdálenost. Toto nastavení " -"slouží ke kontrole kolizí a zobrazení grafického náhledu v Plater." +"slouží ke kontrole kolizí a zobrazení grafického náhledu na podložce." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:342 msgid "Extruder Color" -msgstr "Barva extrudéru" +msgstr "Barva extruderu" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:343 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:406 @@ -1569,7 +1594,7 @@ msgstr "Toto je ve Slic3ru jako názorná pomoc." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:350 msgid "Extruder offset" -msgstr "Odsazení extrudéru" +msgstr "Odsazení extruderu" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:351 msgid "" @@ -1578,14 +1603,14 @@ msgid "" "of each extruder with respect to the first one. It expects positive " "coordinates (they will be subtracted from the XY coordinate)." msgstr "" -"Pokud firmware nezpracovává umístÄ›ní extrudéru správnÄ›, potÅ™ebujete aby to " -"vzal G-kód v úvahu. Toto nastavení umožňuje urÄit odsazení každého extruderu " -"vzhledem k prvnímu. OÄekávají se pozitivní souÅ™adnice (budou odeÄteny od " -"souÅ™adnice XY)." +"Pokud firmware nezpracovává umístÄ›ní extruderu správnÄ›, potÅ™ebujete aby to " +"vzal G-code v úvahu. Toto nastavení umožňuje urÄit odsazení každého " +"extruderu vzhledem k prvnímu. OÄekávají se pozitivní souÅ™adnice (budou " +"odeÄteny od souÅ™adnice XY)." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:360 msgid "Extrusion axis" -msgstr "Osa extrudéru" +msgstr "Osa extruderu" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:361 msgid "" @@ -1606,7 +1631,7 @@ msgid "" "Usual values are between 0.9 and 1.1. If you think you need to change this " "more, check filament diameter and your firmware E steps." msgstr "" -"Tento faktor mÄ›ní pomÄ›rné množství toku. Možná bude tÅ™eba toto nastavení " +"Tento faktor mÄ›ní pomÄ›rné množství průtoku. Možná bude tÅ™eba toto nastavení " "vyladit, pro dosažení hezkého povrchu a správné šířky jednotlivých stÄ›n. " "Obvyklé hodnoty jsou mezi 0,9 a 1,1. Pokud si myslíte, že hodnotu " "potÅ™ebujete zmÄ›nit více, zkontrolujte průmÄ›r filamentu a E kroky ve firmwaru." @@ -1737,9 +1762,9 @@ msgid "" "argument, and they can access the Slic3r config settings by reading " "environment variables." msgstr "" -"Pokud chcete zpracovat výstupní G-kód pomocí vlastních skriptů, staÄí zde " +"Pokud chcete zpracovat výstupní G-code pomocí vlastních skriptů, staÄí zde " "uvést jejich absolutní cesty. OddÄ›lte více skriptů stÅ™edníkem. Skripty " -"pÅ™edají absolutní cestu k souboru G-kódu jako první argument a mohou " +"pÅ™edají absolutní cestu k souboru G-code jako první argument a mohou " "pÅ™istupovat k nastavení konfigurace Slic3ru Ätením promÄ›nných prostÅ™edí." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:470 @@ -1785,7 +1810,7 @@ msgid "Fill density" msgstr "Hustota výplnÄ›" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:503 -#, fuzzy, no-c-format +#, no-c-format msgid "Density of internal infill, expressed in the range 0% - 100%." msgstr "Hustota vnitÅ™ní výplnÄ›, vyjádÅ™ená v rozmezí 0% až 100%." @@ -1876,7 +1901,7 @@ msgid "" "manually during print, set this to zero to disable temperature control " "commands in the output file." msgstr "" -"Teplota extrudéru pro první vrstvu. Chcete-li bÄ›hem tisku ruÄnÄ› ovládat " +"Teplota extruderu pro první vrstvu. Chcete-li bÄ›hem tisku ruÄnÄ› ovládat " "teplotu, nastavte tuto hodnotu na nulu, aby se ve výstupním souboru zakázaly " "příkazy pro řízení teploty." @@ -1884,7 +1909,7 @@ msgstr "" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:145 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:87 msgid "Gap fill" -msgstr "Výplň mezer" +msgstr "Výplň tenkých stÄ›n" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:636 msgid "" @@ -1898,7 +1923,7 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:644 msgid "Verbose G-code" -msgstr "Verbose G-code" +msgstr "Komentáře do G-code" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:645 msgid "" @@ -1906,13 +1931,13 @@ msgid "" "descriptive text. If you print from SD card, the additional weight of the " "file could make your firmware slow down." msgstr "" -"Aktivací získáte komentovaný soubor G-kódu, pÅ™iÄemž každý řádek je doplnÄ›n " +"Aktivací získáte komentovaný soubor G-code, pÅ™iÄemž každý řádek je doplnÄ›n " "popisným textem. Pokud tisknete z SD karty, dodateÄné informace v souboru " "můžou zpomalit firmware." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:652 msgid "G-code flavor" -msgstr "Druh G-kódu" +msgstr "Druh G-code" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:653 msgid "" @@ -1921,7 +1946,7 @@ msgid "" "output. The \"No extrusion\" flavor prevents Slic3r from exporting any " "extrusion value at all." msgstr "" -"NÄ›které příkazy G/M kódu, vÄetnÄ› řízení teploty a jiné, nejsou univerzální. " +"NÄ›které příkazy G/M code, vÄetnÄ› řízení teploty a jiné, nejsou univerzální. " "Vyberte typ firmwaru který používá vaÅ¡e tiskárna pro dosažení kompatibilního " "výstupu. Příkazy typu “No extrusion†zabraňují Slic3ru zcela exportovat " "jakoukoliv hodnotu extruze." @@ -1948,7 +1973,7 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:696 msgid "Combine infill every n layers" -msgstr "" +msgstr "Kombinovat výplň každou n vrstvu" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:701 msgid "Infill extruder" @@ -1994,7 +2019,7 @@ msgid "" msgstr "" "Tato volba omezuje výplň na plochy skuteÄnÄ› potÅ™ebné pro podporu stropů " "(bude se chovat jako vnitÅ™ní podpůrný materiál). Je-li tato volba zapnuta, " -"zpomaluje generování G-kódu kvůli nÄ›kolikanásobným kontrolám." +"zpomaluje generování G-code kvůli nÄ›kolikanásobným kontrolám." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:735 msgid "Infill/perimeters overlap" @@ -2018,7 +2043,7 @@ msgstr "Rychlost tisku vnitÅ™ní výplnÄ›. Pro automatické nastavení zadejte n #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:757 msgid "Interface shells" -msgstr "" +msgstr "Mezilehlé stÄ›ny" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:758 msgid "" @@ -2037,7 +2062,7 @@ msgid "" "use placeholder variables for all Slic3r settings as well as [layer_num] and " "[layer_z]." msgstr "" -"Tento upravený kód je vložen pÅ™i každé zmÄ›nÄ› vrstvy, hned po pohybu Z a " +"Tento vlastní kód je vložen pÅ™i každé zmÄ›nÄ› vrstvy, hned po pohybu Z a " "pÅ™edtím, než se extruder pÅ™esune na první bod vrstvy. Můžete pÅ™idávat " "zástupné promÄ›nné pro veÅ¡keré nastavení Slic3ru, stejnÄ› tak jako [layer_num] " "a [layer_z]." @@ -2053,21 +2078,21 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:787 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:796 msgid "Max" -msgstr "MaximálnÄ›" +msgstr "Maximum" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:788 msgid "This setting represents the maximum speed of your fan." msgstr "Toto nastavení vyjadÅ™uje maximální rychlost ventilátoru." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:797 -#, fuzzy, no-c-format +#, no-c-format msgid "" "This is the highest printable layer height for this extruder, used to cap " "the variable layer height and support layer height. Maximum recommended " "layer height is 75% of the extrusion width to achieve reasonable inter-layer " "adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter." msgstr "" -"Toto je nejvÄ›tší možná výška vrstvy pro tento extrudér, který se používá k " +"Toto je nejvÄ›tší možná výška vrstvy pro tento extruder, který se používá k " "zakrytí výšky promÄ›nné vrstvy a výšky podpůrné vrstvy. Maximální doporuÄená " "výška vrstvy Äiní 75% šířky vytlaÄování, aby se dosáhlo pÅ™iměřené " "pÅ™ilnavosti mezi vrstvami. Pokud je nastavena hodnota 0, je výška vrstvy " @@ -2098,7 +2123,7 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:826 msgid "Max volumetric slope positive" -msgstr "" +msgstr "Maximální pozitivní objemový sklon" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:827 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:838 @@ -2116,12 +2141,12 @@ msgstr "mm³/s²" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:837 msgid "Max volumetric slope negative" -msgstr "" +msgstr "Maximální negativní objemový sklon" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:848 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:857 msgid "Min" -msgstr "MinimálnÄ›" +msgstr "Minimum" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:849 msgid "This setting represents the minimum PWM your fan needs to work." @@ -2135,7 +2160,7 @@ msgid "" "resolution for variable layer height. Typical values are between 0.05 mm and " "0.1 mm." msgstr "" -"Nejmenší tisknutelná výška vrstvy pro tento extrudér. Omezuje rozliÅ¡ení pro " +"Nejmenší tisknutelná výška vrstvy pro tento extruder. Omezuje rozliÅ¡ení pro " "výšku promÄ›nné vrstvy. Typické hodnoty jsou mezi 0,05 mm a 0,1 mm." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:866 @@ -2156,13 +2181,13 @@ msgid "" "specified amount of filament on the bottom layer. For multi-extruder " "machines, this minimum applies to each extruder." msgstr "" -"Nevygenerovat ménÄ›, než poÄet obrysových Äar, potÅ™ebných ke spotÅ™ebování " +"Nevygenerovat ménÄ›, než poÄet obrysových smyÄek, potÅ™ebných ke spotÅ™ebování " "specifikovaného množství filamentu na spodní vrstvu. U strojů s více " -"extrudéry platí toto minimum pro každý extrudér." +"extrudery platí toto minimum pro každý extruder." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:884 msgid "Configuration notes" -msgstr "ConfiguraÄní poznámky" +msgstr "KonfiguraÄní poznámky" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:885 msgid "" @@ -2170,7 +2195,7 @@ msgid "" "header comments." msgstr "" "Zde můžete zadat své osobní poznámky. Tento text bude pÅ™idán do komentáře " -"záhlaví G kódu." +"záhlaví G code." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:894 msgid "Nozzle diameter" @@ -2179,7 +2204,7 @@ msgstr "PrůmÄ›r trysky" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:895 msgid "" "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)" -msgstr "PrůmÄ›r trysky extrudéru (například: 0.5, 0.35 atd.)" +msgstr "PrůmÄ›r trysky extruderu (například: 0.5, 0.35 atd.)" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:901 msgid "API Key" @@ -2190,7 +2215,7 @@ msgid "" "Slic3r can upload G-code files to OctoPrint. This field should contain the " "API Key required for authentication." msgstr "" -"Slic3r může nahrát soubory G kódu do OctoPrintu. Toto pole by mÄ›lo obsahovat " +"Slic3r může nahrát soubory G-code do OctoPrintu. Toto pole by mÄ›lo obsahovat " "klÃ­Ä API požadovaný pro ověření." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:908 @@ -2202,7 +2227,7 @@ msgid "" "Slic3r can upload G-code files to OctoPrint. This field should contain the " "hostname or IP address of the OctoPrint instance." msgstr "" -"Slic3r může nahrát soubory G kódu do OctoPrintu. Toto pole by mÄ›lo obsahovat " +"Slic3r může nahrát soubory G-code do OctoPrintu. Toto pole by mÄ›lo obsahovat " "název hostitele nebo IP adresu aplikace OctoPrint." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:915 @@ -2215,7 +2240,7 @@ msgid "" "perimeters (and thus any ooze will be probably invisible)." msgstr "" "Vypne retrakce, pokud dráha nepÅ™ekroÄí perimetr vrchní vrstvy (a proto bude " -"pravdÄ›podobnÄ› jakékoliv samovolné vytékání neviditelné)." +"pravdÄ›podobnÄ› jakékoliv odkapávání neviditelné)." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:923 msgid "" @@ -2228,7 +2253,7 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:930 msgid "Output filename format" -msgstr "Formát výstupního názvu" +msgstr "Formát názvu výstupního souboru" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:931 msgid "" @@ -2299,7 +2324,7 @@ msgstr "" msgid "" "Speed for perimeters (contours, aka vertical shells). Set to zero for auto." msgstr "" -"Rychlost pro perimetry (obrysy, neboli svislé schránky). Zadejte nulu pro " +"Rychlost pro perimetry (obrysy, neboli svislé stÄ›ny). Zadejte nulu pro " "automatické nastavení." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:990 @@ -2357,13 +2382,14 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1050 msgid "Minimum travel after retraction" -msgstr "Minimální pohyb po retrakci" +msgstr "Minimální rychloposun po retrakci" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1051 msgid "" "Retraction is not triggered when travel moves are shorter than this length." msgstr "" -"Retrakce není spuÅ¡tÄ›na, pokud jsou pohyby pojezdu kratší než tato délka." +"Retrakce není spuÅ¡tÄ›na, pokud jsou rychloposuny pojezdu kratší než tato " +"délka." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1057 msgid "Retract amount before wipe" @@ -2473,14 +2499,14 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1118 #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1126 msgid "Extra length on restart" -msgstr "Extra vzdálenost pÅ™i restartu" +msgstr "Extra vzdálenost pÅ™i návratu" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1119 msgid "" "When the retraction is compensated after the travel move, the extruder will " "push this additional amount of filament. This setting is rarely needed." msgstr "" -"Když je retrakce kompenzována po pohybu, extruder vytlaÄuje toto další " +"Když je retrakce kompenzována po rychloposunu, extruder vytlaÄuje toto další " "množství filamentu. Toto nastavení je zřídkakdy potÅ™eba." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1127 @@ -2536,7 +2562,7 @@ msgstr "Preferovaný smÄ›r Å¡vu" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1180 msgid "Jitter" -msgstr "" +msgstr "Rozkmit (Jitter)" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1182 msgid "Seam preferred direction jitter" @@ -2567,21 +2593,21 @@ msgid "" "Distance between skirt and object(s). Set this to zero to attach the skirt " "to the object(s) and get a brim for better adhesion." msgstr "" -"Vzdálenost mezi obrysovou Äárou a objektem (objekty). Nastavte tuto hodnotu " -"na nulu, pro slouÄení obrysové Äáry/Äar s pÅ™edmÄ›tem (pÅ™edmÄ›ty) a tvorbu " -"límce pro dosažení lepší pÅ™ilnavosti." +"Vzdálenost mezi obrysem a objektem (objekty). Nastavte tuto hodnotu na nulu, " +"pro slouÄení obrysu s pÅ™edmÄ›tem (pÅ™edmÄ›ty) a tvorbu límce pro dosažení lepší " +"pÅ™ilnavosti." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1221 msgid "Skirt height" -msgstr "Výška obrysové Äáry" +msgstr "Výška obrysu" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1222 msgid "" "Height of skirt expressed in layers. Set this to a tall value to use skirt " "as a shield against drafts." msgstr "" -"Výška obrysové Äáry vyjádÅ™ená ve vrstvách. Nastavte tuto hodnotu vysokou, " -"pro použití obrysové Äáry jako stínÄ›ní proti průvanu." +"Výška obrysu vyjádÅ™ená ve vrstvách. Nastavte tuto hodnotu vysokou, pro " +"použití obrysu jako stínÄ›ní proti průvanu." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1229 msgid "Loops (minimum)" @@ -2589,7 +2615,7 @@ msgstr "SmyÄek (minimálnÄ›)" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1230 msgid "Skirt Loops" -msgstr "PoÄet obrysových Äar" +msgstr "PoÄet obrysových smyÄek" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1231 msgid "" @@ -2597,9 +2623,9 @@ msgid "" "set, the number of loops might be greater than the one configured here. Set " "this to zero to disable skirt completely." msgstr "" -"PoÄet obrysových Äar. Je-li nastavena možnost Minimální délka extruze, poÄet " -"obrysových Äar může být vÄ›tší než poÄet zde nakonfigurovaných. Nastavte tuto " -"hodnotu na nulu, pro úplné deaktivování." +"PoÄet obrysových smyÄek. Je-li nastavena možnost Minimální délka extruze, " +"poÄet obrysových smyÄek může být vÄ›tší než poÄet zde nakonfigurovaných. " +"Nastavte tuto hodnotu na nulu, pro úplné deaktivování." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1239 msgid "Slow down if layer print time is below" @@ -2646,11 +2672,11 @@ msgstr "mm²" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1271 msgid "Solid infill extruder" -msgstr "Extrudér pro plnou výplň" +msgstr "Extruder pro plnou výplň" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1273 msgid "The extruder to use when printing solid infill." -msgstr "Extrudér který bude použit pÅ™i tisku plných výplní." +msgstr "Extruder který bude použit pÅ™i tisku plných výplní." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1279 msgid "Solid infill every" @@ -2693,9 +2719,9 @@ msgid "" "This can be expressed as a percentage (for example: 80%) over the default " "infill speed above. Set to zero for auto." msgstr "" -"Rychlost tisku plných oblastí (vrchní / spodní / vnitÅ™ní horizontální " -"pláštÄ›). Může být vyjádÅ™eno procenty (například: 80%) oproti výchozí " -"rychlosti vyplnÄ›ní. Pro automatické nastavení zadejte nulu." +"Rychlost tisku plných oblastí (vrchní / spodní / vnitÅ™ní vodorovné stÄ›ny). " +"Může být vyjádÅ™eno procenty (například: 80%) oproti výchozí rychlosti " +"vyplnÄ›ní. Pro automatické nastavení zadejte nulu." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1315 msgid "Number of solid layers to generate on top and bottom surfaces." @@ -2716,8 +2742,9 @@ msgstr "" "Tato funkce zvýší postupnÄ› Z pÅ™i tisku jednovrstvého objektu, aby se " "odstranil jakýkoli viditelný Å¡ev. Tato volba vyžaduje jediný obvod, žádnou " "výplň, žádné vrchní plné vrstvy a žádný podpůrný materiál. Můžete stále " -"nastavit libovolný poÄet spodních plných vrstev, stejnÄ› jako obrysové Äáry / " -"límec. PÅ™i tisku více než jednoho objektu nebude toto nastavení fungovat." +"nastavit libovolný poÄet spodních plných vrstev, stejnÄ› jako obrysové " +"smyÄky / límec. PÅ™i tisku více než jednoho objektu nebude toto nastavení " +"fungovat." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1332 msgid "Temperature variation" @@ -2730,7 +2757,7 @@ msgid "" "wiped." msgstr "" "Teplotní rozdíl, který se použije v případÄ›, že extruder není aktivní. " -"Umožňuje “obÄ›tní†obrysové Äáry v plné výšce objektu, na kterém jsou trysky " +"Umožňuje “obÄ›tní†obrysy v plné výšce objektu, na kterém jsou trysky " "periodicky oÄiÅ¡tÄ›ny." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1343 @@ -2744,9 +2771,9 @@ msgid "" "\"M109 S[first_layer_temperature]\" command wherever you want." msgstr "" "Tento spouÅ¡tÄ›cí postup je vložen na zaÄátku, poté, co vyhřívaná tisková " -"podložka dosáhla cílové teploty a extrudér se právÄ› zaÄal ohřívat a pÅ™edtím, " -"než dosáhl cílové teploty extrudér . Pokud Slic3r detekuje M104 nebo M190 ve " -"vaÅ¡ich upravených kódech, takové příkazy nebudou automaticky pÅ™edkládány, " +"podložka dosáhla cílové teploty a extruder se právÄ› zaÄal ohřívat a pÅ™edtím, " +"než dosáhl cílové teploty extruder . Pokud Slic3r detekuje M104 nebo M190 ve " +"vaÅ¡ich vlastních kódech, takové příkazy nebudou automaticky pÅ™edkládány, " "takže máte možnost upravit poÅ™adí příkazů pro vytápÄ›ní a další vlastní akce. " "Pro vÅ¡echny nastavení Slic3ru můžete použít zástupné promÄ›nné, takže můžete " "zadat příkaz “M109 S [first_layer_temperature]†kdekoli chcete." @@ -2762,18 +2789,18 @@ msgid "" "S[first_layer_temperature]\" command wherever you want. If you have multiple " "extruders, the gcode is processed in extruder order." msgstr "" -"Tento postup spuÅ¡tÄ›ní je vložen na zaÄátku, po každém spuÅ¡tÄ›ní G kódu " +"Tento postup spuÅ¡tÄ›ní je vložen na zaÄátku, po každém spuÅ¡tÄ›ní G-code " "tiskárny. Toto slouží k pÅ™epsání nastavení pro konkrétní filament. Pokud " -"Slic3r detekuje M104, M109, M140 nebo M190 ve vaÅ¡ich uživatelských kódech, " +"Slic3r detekuje M104, M109, M140 nebo M190 ve vaÅ¡ich vlastních kódech, " "takové příkazy nebudou automaticky pÅ™edkládány, takže máte možnost " "pÅ™izpůsobit poÅ™adí příkazů k ohÅ™evu a další vlastní akce. Pro vÅ¡echny " "nastavení Slic3ru můžete použít zástupné promÄ›nné, takže můžete zadat příkaz " "“M109 S [first_layer_temperature]†kdekoli chcete. Pokud máte více " -"extruderů, G kód se zpracovává v poÅ™adí extruderů." +"extruderů, G-code se zpracovává v poÅ™adí extruderů." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1373 msgid "Single Extruder Multi Material" -msgstr "Multi Materiálový tisk s jedním extrudérem" +msgstr "MultiMaterial tisk s jedním extrudérem" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1374 msgid "The printer multiplexes filaments into a single hot end." @@ -2823,7 +2850,7 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1416 msgid "Contact Z distance" -msgstr "Kontaktní vzdálenost Z" +msgstr "Mezera mezi podporami a objektem v ose Z" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1418 msgid "" @@ -2857,15 +2884,15 @@ msgstr "Vynucení podpor pro prvních n vrstev" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1444 msgid "Support material/raft/skirt extruder" -msgstr "Extruder pro podpory/raft/obrysové Äáry" +msgstr "Extruder pro podpory/raft/obrys" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1446 msgid "" "The extruder to use when printing support material, raft and skirt (1+, 0 to " "use the current extruder to minimize tool changes)." msgstr "" -"Extruder, který se používá pÅ™i tisku podpor, raftu a obrysových Äar (1+, 0 " -"pro použití aktuálního extrudéru pro co nejménÄ› zmÄ›n nástroje)." +"Extruder, který se používá pÅ™i tisku podpor, raftu a obrysu (1+, 0 pro " +"použití aktuálního extruderu pro co nejménÄ› zmÄ›n nástroje)." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1455 msgid "" @@ -2881,26 +2908,31 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1463 msgid "Interface loops" -msgstr "" +msgstr "Kontaktní smyÄky" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1465 msgid "" "Cover the top contact layer of the supports with loops. Disabled by default." msgstr "" +"Zakrýt smyÄkami horní kontaktní vrstvu podpor. Ve výchozím nastavení " +"zakázáno." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1470 msgid "Support material/raft interface extruder" -msgstr "Extruder pro interface podpory/rafty" +msgstr "Extruder pro kontaktní podpory/raft" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1472 msgid "" "The extruder to use when printing support material interface (1+, 0 to use " "the current extruder to minimize tool changes). This affects raft too." msgstr "" +"Extruder, který se použije pÅ™i tisku kontaktních vrstev podpor (1+, 0 pro " +"použití aktuálního extruderu, aby se minimalizovaly zmÄ›ny nástroje). To " +"ovlivňuje i raft." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1479 msgid "Interface layers" -msgstr "Interface vrstvy" +msgstr "Kontaktní vrstvy" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1481 msgid "" @@ -2910,17 +2942,19 @@ msgstr "PoÄet interface vrstev vložených mezi objekt (objekty) a podpory." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1488 msgid "Interface pattern spacing" -msgstr "" +msgstr "RozteÄ kontaktních vrstev" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1490 msgid "Spacing between interface lines. Set zero to get a solid interface." msgstr "" +"RozteÄ linií kontaktních vrstev. Nastavte nulu pro získání plných " +"kontaktních vrstev." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1497 #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:148 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:90 msgid "Support material interface" -msgstr "Support material interface" +msgstr "Kontaktní vrstvy podpor" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1499 msgid "" @@ -2941,11 +2975,11 @@ msgstr "Vzor použitý pro generování podpor." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1524 msgid "Pattern spacing" -msgstr "Vzdálenost vzoru" +msgstr "RozteÄ podpor" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1526 msgid "Spacing between support material lines." -msgstr "Vzdálenost mezi liniemi podpor." +msgstr "RozteÄ linií podpor." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1535 msgid "Speed for printing support material." @@ -2965,7 +2999,7 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1550 msgid "Overhang threshold" -msgstr "Práh pÅ™esahu" +msgstr "Mezní úhel pÅ™evisu" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1552 msgid "" @@ -2998,7 +3032,7 @@ msgid "" "Extruder temperature for layers after the first one. Set this to zero to " "disable temperature control commands in the output." msgstr "" -"Teplota extrudéru pro následující vrstvy po vrstvÄ› první. Nastavte tuto " +"Teplota extruderu pro následující vrstvy po vrstvÄ› první. Nastavte tuto " "hodnotu na nulu, abyste zakázali příkazy pro řízení teploty na výstupu." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1576 @@ -3033,7 +3067,7 @@ msgid "" "you can use placeholder variables for all Slic3r settings as well as " "[previous_extruder] and [next_extruder]." msgstr "" -"Tento upravený kód je vložen tÄ›snÄ› pÅ™ed každou zmÄ›nou extruderu. Můžete " +"Tento vlastní kód je vložen tÄ›snÄ› pÅ™ed každou zmÄ›nou extruderu. Můžete " "použít zástupné promÄ›nné pro vÅ¡echna nastavení Slic3ru, stejnÄ› jako " "[previous_extruder] a [next_extruder]." @@ -3042,7 +3076,7 @@ msgstr "" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:143 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:85 msgid "Top solid infill" -msgstr "Vrchní plná výplň" +msgstr "Výplň plných horních" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1615 msgid "" @@ -3076,7 +3110,7 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1638 #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 msgid "Top" -msgstr "Vrchních" +msgstr "Horních" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1640 msgid "Number of solid layers to generate on top surfaces." @@ -3089,15 +3123,15 @@ msgstr "Vrchních plných vrstev" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1647 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:95 msgid "Travel" -msgstr "PÅ™esun" +msgstr "Rychloposun" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1648 msgid "Speed for travel moves (jumps between distant extrusion points)." -msgstr "Rychlost pÅ™esunů (pÅ™ejezdy mezi body extruze)." +msgstr "Rychlost posunů (pÅ™ejezdy mezi body extruze)." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1656 msgid "Use firmware retraction" -msgstr "Použít retrakce z firmware" +msgstr "Použít retrakce z firmwaru" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1657 msgid "" @@ -3122,7 +3156,7 @@ msgstr "" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1670 msgid "Use volumetric E" -msgstr "Použije volumetrickou hodnotu E" +msgstr "Použít volumetrickou hodnotu E" #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1671 msgid "" @@ -3135,7 +3169,7 @@ msgid "" msgstr "" "Toto experimentální nastavení používá výstupní hodnoty E v kubických " "milimetrech místo lineárních milimetrů. Pokud firmware dosud nezná průmÄ›r " -"(průmÄ›ry) filamentu, můžete v poÄáteÄním G-kódu zadat příkazy jako “M200 D " +"(průmÄ›ry) filamentu, můžete v poÄáteÄním G-code zadat příkazy jako “M200 D " "[filament_diameter_0] T0â€, pro se zapnutí volumetrického režimu a použití " "průmÄ›ru filamentu pÅ™idruženého k vybranému filamentu ve Slic3ru. Toto je " "podporováno pouze v posledních verzích firmwaru Marlin." @@ -3169,8 +3203,8 @@ msgid "" "Multi material printers may need to prime or purge extruders on tool " "changes. Extrude the excess material into the wipe tower." msgstr "" -"Multi-materiálové tiskárny mohou potÅ™ebovat, aby pÅ™i výmÄ›nÄ› nástrojů " -"vyÄistili extrudéry. VytlaÄí pÅ™ebyteÄný materiál do Äistící věže." +"Multimateriálové tiskárny mohou potÅ™ebovat, aby pÅ™i výmÄ›nÄ› nástrojů " +"vyÄistili extrudery. VytlaÄí pÅ™ebyteÄný materiál do Äistící věže." #: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1702 msgid "Position X" @@ -3237,81 +3271,83 @@ msgid "" "print bed, set this to -0.3 (or fix your endstop)." msgstr "" "Tato hodnota bude pÅ™idána (nebo odeÄtena) ze vÅ¡ech souÅ™adnic Z ve výstupním " -"G kódu. Používá se ke kompenzování Å¡patné pozice endstopu Z. Například pokud " +"G-code. Používá se ke kompenzování Å¡patné pozice endstopu Z. Například pokud " "endstop 0 skuteÄnÄ› ponechá trysku 0,3 mm daleko od tiskové podložky, " "nastavte hodnotu -0,3 (nebo dolaÄte svůj koncový doraz)." #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:137 msgid "None" -msgstr "" +msgstr "Žádný" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:138 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:80 msgid "Perimeter" -msgstr "" +msgstr "Perimetr" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:139 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:81 msgid "External perimeter" -msgstr "" +msgstr "VnÄ›jší perimetr" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:140 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:82 msgid "Overhang perimeter" -msgstr "" +msgstr "Perimetr pÅ™evisu" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:141 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:83 msgid "Internal infill" -msgstr "" +msgstr "VnitÅ™ní výplň" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:144 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:86 msgid "Bridge infill" -msgstr "" +msgstr "Výplň mostů" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:151 msgid "Mixed" -msgstr "" +msgstr "Smíšený" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:330 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:68 msgid "Feature type" -msgstr "" +msgstr "Typ" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:332 msgid "Height (mm)" -msgstr "" +msgstr "Výška (mm)" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:334 msgid "Width (mm)" -msgstr "" +msgstr "Šířka (mm)" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:336 msgid "Speed (mm/s)" -msgstr "" +msgstr "Rychlost (mm/s)" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:338 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:72 msgid "Tool" -msgstr "" +msgstr "Nástroj" #: c:\src\Slic3r\lib\Slic3r\GUI.pm:286 msgid "Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):" -msgstr "" +msgstr "Vyberte jeden nebo více souborů (STL/OBJ/AMF/3MF/PRUSA):" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 msgid "Version " -msgstr "" +msgstr "Verze " #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 msgid "" " - Remember to check for updates at http://github.com/prusa3d/slic3r/releases" msgstr "" +" - Nezapomeňte zkontrolovat aktualizace na http://github.com/prusa3d/slic3r/" +"releases" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:118 msgid "Plater" -msgstr "" +msgstr "Podložka" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:120 msgid "Controller" @@ -3323,7 +3359,7 @@ msgstr "Nenalezena žádná Bonjour zařízení" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 msgid "Device Browser" -msgstr "" +msgstr "ProhlížeÄ zařízení" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:211 msgid "Connection to OctoPrint works correctly." @@ -3331,11 +3367,13 @@ msgstr "PÅ™ipojení k OctoPrint pracuje správnÄ›." #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:214 msgid "I wasn't able to connect to OctoPrint (" -msgstr "" +msgstr "Nelze se pÅ™ipojit k aplikaci OctoPrint (" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:215 msgid "). Check hostname and OctoPrint version (at least 1.1.0 is required)." msgstr "" +"). Zkontrolujte název hostitele a verzi OctoPrint (vyžaduje se nejménÄ› " +"1.1.0)." #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 msgid "Open STL/OBJ/AMF…\tCtrl+O" @@ -3371,7 +3409,7 @@ msgstr "NaÄíst pÅ™ednastavení z balíku" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 msgid "&Export Config Bundle…" -msgstr "" +msgstr "&Exportovat KonfiguraÄní Balík…" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 msgid "Export all presets to file" @@ -3379,43 +3417,43 @@ msgstr "Exportovat vÅ¡echna pÅ™ednastavení do souboru" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 msgid "Q&uick Slice…\tCtrl+U" -msgstr "R&ychlý Řez…\tCtrl+U" +msgstr "R&ychlé Slicování…\tCtrl+U" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 msgid "Slice a file into a G-code" -msgstr "Řez souboru do G-kódu" +msgstr "Slicovat soubor do G-code" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 msgid "Quick Slice and Save &As…\tCtrl+Alt+U" -msgstr "Rychlý Řez a Uložit &jako…\tCtrl+Alt+U" +msgstr "Rychlé Slicování a Uložit &jako…\tCtrl+Alt+U" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 msgid "Slice a file into a G-code, save as" -msgstr "Řez souboru do G-kódu, uložit jako" +msgstr "Slicovat soubor do G-code, uložit jako" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 msgid "&Repeat Last Quick Slice\tCtrl+Shift+U" -msgstr "&Opakovat Poslední Rychlý Řez\tCtrl+Shift+U" +msgstr "&Opakovat Poslední Slicování\tCtrl+Shift+U" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 msgid "Repeat last quick slice" -msgstr "Opakovat poslední rychlý Å™ez" +msgstr "Opakovat poslední rychlé slicování" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 msgid "Slice to SV&G…\tCtrl+G" -msgstr "Řez do SV&G…\tCtrl+G" +msgstr "Slicovat do SV&G…\tCtrl+G" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 msgid "Slice file to a multi-layer SVG" -msgstr "Řez souboru do více-vrstvého SVG" +msgstr "Slicovat soubor do více-vrstvého SVG" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 msgid "(&Re)Slice Now\tCtrl+S" -msgstr "" +msgstr "(&Znovu)Slicovat\tCtrl+S" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 msgid "Start new slicing process" -msgstr "" +msgstr "Zahájit nový slicovací proces" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 msgid "Repair STL file…" @@ -3447,39 +3485,39 @@ msgstr "Exportovat G-kód…" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 msgid "Export current plate as G-code" -msgstr "" +msgstr "Exportovat stávající plochu do G-code" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 msgid "Export plate as STL..." -msgstr "" +msgstr "Exportovat plochu jako STL..." #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 msgid "Export current plate as STL" -msgstr "" +msgstr "Exportovat stávající plochu jako STL" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 msgid "Export plate as AMF..." -msgstr "" +msgstr "Exportovat plochu jako AMF..." #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 msgid "Export current plate as AMF" -msgstr "" +msgstr "Exportovat stávající plochu jako AMF" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 msgid "Export plate as 3MF..." -msgstr "" +msgstr "Exportovat plochu jako 3MF..." #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 msgid "Export current plate as 3MF" -msgstr "" +msgstr "Exportovat stávající plochu jako 3MF" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 msgid "Select &Plater Tab\tCtrl+1" -msgstr "Zobrazit panel Plater\tCtrl+1" +msgstr "Zobrazit panel Podložka\tCtrl+1" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 msgid "Show the plater" -msgstr "" +msgstr "Zobrazit podložku" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 msgid "Select &Controller Tab\tCtrl+T" @@ -3487,7 +3525,7 @@ msgstr "Zobrazit panel OvladaÄ\tCtrl+T" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 msgid "Show the printer controller" -msgstr "" +msgstr "Zobrazit ovladaÄ tiskárny" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 msgid "Select P&rint Settings Tab\tCtrl+2" @@ -3495,7 +3533,7 @@ msgstr "Zobrazit panel Nastavení tisku\tCtrl+2" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 msgid "Show the print settings" -msgstr "" +msgstr "Zobrazit nastavení tisku" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 msgid "Select &Filament Settings Tab\tCtrl+3" @@ -3503,7 +3541,7 @@ msgstr "Zobrazit panel Nastavení filamentu\tCtrl+3" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 msgid "Show the filament settings" -msgstr "" +msgstr "Zobrazit nastavení filamentu" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 msgid "Select Print&er Settings Tab\tCtrl+4" @@ -3511,15 +3549,15 @@ msgstr "Zobrazit panel Nastavení tiskárny\tCtrl+4" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 msgid "Show the printer settings" -msgstr "" +msgstr "Zobrazit nastavení tiskárny" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 msgid "Iso" -msgstr "Iso" +msgstr "Izometrické" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 msgid "Iso View" -msgstr "Pohled iso" +msgstr "Izometrické zobrazení" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 msgid "Top View" @@ -3575,7 +3613,7 @@ msgstr "Prusa 3D OvladaÄe" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 msgid "Open the Prusa3D drivers download page in your browser" -msgstr "Otevřít stránku pro stahování Prusa3D ovladaÄů ve vaÅ¡em prohlížeÄi" +msgstr "Otevřít stránku pro stahování Prusa 3D ovladaÄů ve vaÅ¡em prohlížeÄi" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 msgid "Prusa Edition Releases" @@ -3631,7 +3669,7 @@ msgstr "&Soubor" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:419 msgid "&Plater" -msgstr "" +msgstr "&Podložka" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:420 msgid "&Object" @@ -3651,19 +3689,19 @@ msgstr "&Pomoc" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:457 msgid "Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):" -msgstr "Zvolit soubor k Å™ezu (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Zvolit soubor ke slicování (STL/OBJ/AMF/3MF/PRUSA):" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:469 msgid "No previously sliced file." -msgstr "" +msgstr "Žádné dříve slicované soubory." #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 msgid "Previously sliced file (" -msgstr "" +msgstr "Dříve slicovaný soubor (" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 msgid ") not found." -msgstr "" +msgstr ") nebyl nalezen." #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:475 msgid "File Not Found" @@ -3675,7 +3713,7 @@ msgstr "SVG" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 msgid "G-code" -msgstr "G-kód" +msgstr "G-code" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 @@ -3684,19 +3722,19 @@ msgstr " soubor jako:" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 msgid "Slicing…" -msgstr "" +msgstr "Slicování…" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 msgid "Processing " -msgstr "" +msgstr "Zpracovávám " #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:548 msgid " was successfully sliced." -msgstr "" +msgstr " byl úspěšnÄ› slicován." #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:550 msgid "Slicing Done!" -msgstr "" +msgstr "Slicování dokonÄeno!" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:566 msgid "Select the STL file to repair:" @@ -3791,7 +3829,7 @@ msgstr "45° doprava" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:187 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:203 msgid "Scale…" -msgstr "Å kálovat" +msgstr "Velikost…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:188 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:204 @@ -3813,11 +3851,11 @@ msgstr "Nastavení…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:192 msgid "Layer Editing" -msgstr "Editování Vrstev" +msgstr "Vyhlazení vrstev" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:207 msgid "Layer editing" -msgstr "Editování vstev" +msgstr "Vyhlazení vrstev" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:220 msgid "Name" @@ -3841,7 +3879,7 @@ msgstr "Exportovat G-kód…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:237 msgid "Slice now" -msgstr "" +msgstr "Slicovat" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:238 msgid "Print…" @@ -3873,7 +3911,7 @@ msgstr "Obsah" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:410 msgid "Facets" -msgstr "Trojúhelníků" +msgstr "Facety" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:411 msgid "Materials" @@ -3885,7 +3923,7 @@ msgstr "" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:438 msgid "Sliced Info" -msgstr "" +msgstr "Informace o slicování" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:447 msgid "Used Filament (m)" @@ -3910,7 +3948,7 @@ msgstr "NaÄítání…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:643 msgid "Processing input file\n" -msgstr "" +msgstr "Zpracovávám vstupní soubor\n" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:663 msgid "" @@ -3918,11 +3956,14 @@ msgid "" "of considering them as multiple objects, should I consider\n" "this file as a single object having multiple parts?\n" msgstr "" +"Tento soubor obsahuje nÄ›kolik objektů umístÄ›ných v různých výškách. Mají být " +"vloženy jako jeden objekt obsahující více Äástí,\n" +"namísto vložení nÄ›kolika objektů?\n" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:666 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:683 msgid "Multi-part object detected" -msgstr "" +msgstr "Detekován objekt obsahující více Äástí" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:680 msgid "" @@ -3940,6 +3981,8 @@ msgid "" "Your object appears to be too large, so it was automatically scaled down to " "fit your print bed." msgstr "" +"Váš objekt se zdá být příliÅ¡ velký, takže byl automaticky zmenÅ¡en, aby se " +"veÅ¡el na tiskovou podložku." #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:745 msgid "Object too large?" @@ -3947,23 +3990,27 @@ msgstr "Objekt moc velký?" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 msgid "Enter the number of copies of the selected object:" -msgstr "" +msgstr "Zadejte poÄet kopií pro vybraný objekt:" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:927 msgid "" "\n" "Non-positive value." msgstr "" +"\n" +"Nezáporná hodnota." #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:928 msgid "" "\n" "Not a numeric value." msgstr "" +"\n" +"NeÄíselná hodnota." #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:929 msgid "Slic3r Error" -msgstr "" +msgstr "Chyba Slic3ru" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 msgid "Enter the rotation angle:" @@ -3980,60 +4027,62 @@ msgstr "Zadán neplatný úhel otoÄení" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1030 #, perl-format msgid "Enter the new size for the selected object (print bed: %smm):" -msgstr "" +msgstr "Zadejte novou velikost vybraného objektu (tisková podložka: %smm):" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 msgid "Scale along " -msgstr "Å kálovat podél " +msgstr "Upravit rozmÄ›r podél " #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 msgid "Invalid scaling value entered" -msgstr "" +msgstr "Zadána neplatná hodnota pro úpravu rozmÄ›ru" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 #, no-perl-format msgid "Enter the scale % for the selected object:" -msgstr "" +msgstr "Zadejte rozmÄ›r % pro zvolený objekt:" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 msgid "Enter the new max size for the selected object:" -msgstr "" +msgstr "Zvolte nový maximální rozmÄ›r pro zvolný objekt:" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1112 msgid "" "The selected object can't be split because it contains more than one volume/" "material." msgstr "" +"Vybraný objekt nemůže být rozdÄ›len, protože obsahuje více nez jeden objem/" +"materiál." #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1121 msgid "" "The selected object couldn't be split because it contains only one part." -msgstr "" +msgstr "Vybraný objekt nemůže být rozdÄ›len, protože obsahuje pouze jednu Äást." #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1286 msgid "Slicing cancelled" -msgstr "" +msgstr "Slicování zruÅ¡eno" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 msgid "Another export job is currently running." -msgstr "" +msgstr "V souÄasné dobÄ› běží jiná úloha exportu." #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1445 msgid "File added to print queue" -msgstr "" +msgstr "Soubor byl pÅ™idán do tiskové fronty" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1448 msgid "Sending G-code file to the OctoPrint server..." -msgstr "" +msgstr "Odesílání souboru G-code na server OctoPrint…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1451 msgid "G-code file exported to " -msgstr "" +msgstr "Soubor G-code byl exportován do " #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1454 msgid "Export failed" @@ -4041,37 +4090,37 @@ msgstr "Exportování selhalo" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1524 msgid "G-code file successfully uploaded to the OctoPrint server" -msgstr "" +msgstr "Soubor G-code byl úspěšnÄ› odeslán na server OctoPrint" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1526 msgid "Error while uploading to the OctoPrint server: " -msgstr "" +msgstr "Chyba pÅ™i nahrávání na server OctoPrint: " #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1539 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1581 msgid "STL file exported to " -msgstr "" +msgstr "Soubor STL byl exportován do " #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1592 msgid "AMF file exported to " -msgstr "" +msgstr "Soubor AMF byl exportován do " #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1596 msgid "Error exporting AMF file " -msgstr "" +msgstr "Chyba pÅ™i exportu souboru AMF " #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1608 msgid "3MF file exported to " -msgstr "" +msgstr "Soubor 3MF byl exportován do " #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1612 msgid "Error exporting 3MF file " -msgstr "" +msgstr "Chyba pÅ™i exportu souboru 3MF " #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1958 #, perl-format msgid "%d (%d shells)" -msgstr "" +msgstr "%d (%d obalů)" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1960 #, perl-format @@ -4111,27 +4160,27 @@ msgstr "Odstaní jednu kopii vybraného objektu" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 msgid "Set number of copies…" -msgstr "Zadejte poÄet kopií…" +msgstr "Zadat poÄet kopií…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 msgid "Change the number of copies of the selected object" -msgstr "" +msgstr "Změňte poÄet kopií vybraného objektu" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 msgid "Rotate 45° clockwise" -msgstr "" +msgstr "OtoÄit o 45° ve smÄ›ru hodinových ruÄiÄek" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 msgid "Rotate the selected object by 45° clockwise" -msgstr "" +msgstr "OtoÄit vybraný objekt o 45° ve smÄ›ru hodinových ruÄiÄek" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 msgid "Rotate 45° counter-clockwise" -msgstr "" +msgstr "OtoÄit o 45° proti smÄ›ru hodinových ruÄiÄek" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 msgid "Rotate the selected object by 45° counter-clockwise" -msgstr "" +msgstr "OtoÄit vybraný objekt o 45° proti smÄ›ru hodinových ruÄiÄek" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 msgid "Rotate" @@ -4139,7 +4188,7 @@ msgstr "OtoÄit" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 msgid "Rotate the selected object by an arbitrary angle" -msgstr "" +msgstr "OtoÄit vybraným objektem o libovolný úhel" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 msgid "Around X axis…" @@ -4147,7 +4196,7 @@ msgstr "Okolo osy X…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 msgid "Rotate the selected object by an arbitrary angle around X axis" -msgstr "" +msgstr "OtoÄit vybraným objektem o libovolný úhel kolem osy X" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 msgid "Around Y axis…" @@ -4155,7 +4204,7 @@ msgstr "Okolo osy Y…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 msgid "Rotate the selected object by an arbitrary angle around Y axis" -msgstr "" +msgstr "OtoÄit vybraným objektem o libovolný úhel kolem osy Y" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 msgid "Around Z axis…" @@ -4163,7 +4212,7 @@ msgstr "Okolo osy Z…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 msgid "Rotate the selected object by an arbitrary angle around Z axis" -msgstr "" +msgstr "OtoÄit vybraným objektem o libovolný úhel kolem osy Z" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 msgid "Mirror" @@ -4181,7 +4230,7 @@ msgstr "Podél osy X…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 msgid "Mirror the selected object along the X axis" -msgstr "" +msgstr "Zrcadlit rozmÄ›r vybraného objektu podél osy X" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 @@ -4191,7 +4240,7 @@ msgstr "Podél osy Y…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 msgid "Mirror the selected object along the Y axis" -msgstr "" +msgstr "Zrcadlit rozmÄ›r vybraného objektu podél osy Y" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 @@ -4201,12 +4250,12 @@ msgstr "Podél osy Z…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 msgid "Mirror the selected object along the Z axis" -msgstr "" +msgstr "Zrcadlit rozmÄ›r vybraného objektu podél osy Z" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 msgid "Scale the selected object along a single axis" -msgstr "" +msgstr "ZmÄ›nit rozmÄ›r vybraného objektu podél jedné osy" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 @@ -4216,38 +4265,38 @@ msgstr "SoumÄ›rně…" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 msgid "Scale the selected object along the XYZ axes" -msgstr "" +msgstr "ZmÄ›nit rozmÄ›r vybraného objektu podél os XYZ" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 msgid "Scale the selected object along the X axis" -msgstr "" +msgstr "ZmÄ›nit rozmÄ›r vybraného objektu podél osy X" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 msgid "Scale the selected object along the Y axis" -msgstr "" +msgstr "ZmÄ›nit rozmÄ›r vybraného objektu podél osy Y" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 msgid "Scale the selected object along the Z axis" -msgstr "" +msgstr "ZmÄ›nit rozmÄ›r vybraného objektu podél osy Z" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 msgid "Scale to size" -msgstr "Å kálovat do rozmÄ›ru" +msgstr "Upravit do rozmÄ›ru" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 msgid "Split the selected object into individual parts" -msgstr "" +msgstr "RozdÄ›lit vybraný objekt na jednotlivé Äásti" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 msgid "Open the 3D cutting tool" -msgstr "" +msgstr "OtevÅ™ete nástroj 3D Å™ezání" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 msgid "Open the object editor dialog" -msgstr "" +msgstr "OtevÅ™e dialogové okno editoru objektů" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 msgid "Reload from Disk" @@ -4267,37 +4316,37 @@ msgstr "Exportovat tento jediný objekt jako STL soubor" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:131 msgid "What do you want to print today? â„¢" -msgstr "" +msgstr "Co chcete dnes tisknout? â„¢" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:132 msgid "Drag your objects here" -msgstr "" +msgstr "PÅ™etáhnÄ›te své objekty sem" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:63 msgid "1 Layer" -msgstr "" +msgstr "1 Vrstva" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:65 msgid "View" -msgstr "" +msgstr "Zobrazení" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:75 msgid "Show" -msgstr "" +msgstr "Zobrazit" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:78 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:79 msgid "Feature types" -msgstr "" +msgstr "Typy extruzí" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:96 msgid "Retractions" -msgstr "" +msgstr "Retrakce" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:97 msgid "Unretractions" -msgstr "" +msgstr "Deretrakce" #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:98 msgid "Shells" -msgstr "" +msgstr "Skořápky" From ebb2d457610d1dc67f17e1911198738a1bb756c7 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 21 Mar 2018 15:21:03 +0100 Subject: [PATCH 0069/1150] Out of bed detection - Disabled GUI buttons when object outside bed --- lib/Slic3r/GUI/Plater.pm | 11 +++++++++++ lib/Slic3r/GUI/Plater/3D.pm | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d3513897f3..c63f8b8b71 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -98,6 +98,16 @@ sub new { $self->update; }; + # callback to enable/disable action buttons + my $enable_action_buttons = sub { + my ($enable) = @_; + $self->{btn_export_gcode}->Enable($enable); + $self->{btn_reslice}->Enable($enable); + $self->{btn_print}->Enable($enable); + $self->{btn_send_gcode}->Enable($enable); + $self->{btn_export_stl}->Enable($enable); + }; + # Initialize 3D plater if ($Slic3r::GUI::have_OpenGL) { $self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{print}, $self->{config}); @@ -113,6 +123,7 @@ sub new { $self->{canvas3D}->set_on_decrease_objects(sub { $self->decrease() }); $self->{canvas3D}->set_on_remove_object(sub { $self->remove() }); $self->{canvas3D}->set_on_instances_moved($on_instances_moved); + $self->{canvas3D}->set_on_enable_action_buttons($enable_action_buttons); $self->{canvas3D}->use_plain_shader(1); $self->{canvas3D}->set_on_wipe_tower_moved(sub { my ($new_pos_3f) = @_; diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index 37e1321aec..09cc029302 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -12,7 +12,7 @@ use Wx::Locale gettext => 'L'; __PACKAGE__->mk_accessors(qw( on_arrange on_rotate_object_left on_rotate_object_right on_scale_object_uniformly - on_remove_object on_increase_objects on_decrease_objects)); + on_remove_object on_increase_objects on_decrease_objects on_enable_action_buttons)); sub new { my $class = shift; @@ -176,6 +176,11 @@ sub set_on_model_update { $self->on_model_update($cb); } +sub set_on_enable_action_buttons { + my ($self, $cb) = @_; + $self->on_enable_action_buttons($cb); +} + sub reload_scene { my ($self, $force) = @_; @@ -217,10 +222,12 @@ sub reload_scene { if (!$self->{model}->fits_print_volume($self->{config})) { $self->set_warning_enabled(1); Slic3r::GUI::_3DScene::generate_warning_texture(L("Detected object outside print volume")); + $self->on_enable_action_buttons->(0) if ($self->on_enable_action_buttons); } else { $self->set_warning_enabled(0); $self->volumes->update_outside_state($self->{config}, 1); Slic3r::GUI::_3DScene::reset_warning_texture(); + $self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons); } } } From 9519fae49072955eaf793195132e8f717ee16a23 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 21 Mar 2018 15:57:17 +0100 Subject: [PATCH 0070/1150] Partial refactoring of wipe tower code (got rid of global constants, etc) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 108 ++++++++------------ xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 94 +++++++---------- xs/src/libslic3r/Print.cpp | 1 - xs/src/slic3r/GUI/WipeTowerDialog.cpp | 2 +- 4 files changed, 79 insertions(+), 126 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 2010b7ae7a..7c8181ff6b 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -33,7 +33,6 @@ TODO LIST #define strcasecmp _stricmp #endif -const bool peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet namespace Slic3r { @@ -119,7 +118,7 @@ public: if (! m_preview_suppressed && e > 0.f && len > 0.) { // Width of a squished extrusion, corrected for the roundings of the squished extrusions. // This is left zero if it is a travel move. - float width = float(double(e) * Filament_Area / (len * m_layer_height)); + float width = float(double(e) * /*Filament_Area*/2.40528 / (len * m_layer_height)); // Correct for the roundings of a squished extrusion. width += m_layer_height * float(1. - M_PI / 4.); if (m_extrusions.empty() || m_extrusions.back().pos != rotated_current_pos) @@ -415,33 +414,12 @@ private: } Writer& operator=(const Writer &rhs); -}; - -/* -class Material -{ -public: - std::string name; - std::string type; - - struct RammingStep { -// float length; - float extrusion_multiplier; // sirka linky - float extrusion; - float speed; - }; - std::vector ramming_sequence; - - // Number and speed of the cooling moves. - std::vector cooling_moves; - - // Percentage of the speed overide, in pairs of - std::vector> speed_override; -}; -*/ +}; // class Writer }; // namespace PrusaMultiMaterial + + WipeTowerPrusaMM::material_type WipeTowerPrusaMM::parse_material(const char *name) { if (strcasecmp(name, "PLA") == 0) @@ -476,6 +454,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( // If false, the last priming are will be large enough to wipe the last extruder sufficiently. bool last_wipe_inside_wipe_tower) { + this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false); this->m_num_layer_changes = 0; this->m_current_tool = tools.front(); @@ -484,8 +463,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( // Due to the XYZ calibration, this working space may shrink slightly from all directions, // therefore the homing position is shifted inside the bed by 0.2 in the firmware to [0.2, -2.0]. // box_coordinates cleaning_box(xy(0.5f, - 1.5f), m_wipe_tower_width, wipe_area); - //FIXME: set the width properly - const float prime_section_width = 55.f; + + const float prime_section_width = std::min(240.f / tools.size(), 60.f); box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, 100.f); PrusaMultiMaterial::Writer writer; @@ -556,7 +535,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo if ( m_print_brim ) return toolchange_Brim(); - float wipe_area = 0.f; bool last_change_in_layer = false; float wipe_volume = 0.f; @@ -589,7 +567,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - .set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) + .set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) .append(";--------------------\n" "; CP TOOLCHANGE START\n") .comment_with_value(" toolchange #", m_num_tool_changes) @@ -625,7 +603,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo if (last_change_in_layer) {// draw perimeter line writer.set_y_shift(m_y_shift); - if (peters_wipe_tower) + if (m_peters_wipe_tower) writer.rectangle(m_wipe_tower_pos,m_layer_info->depth + 3*m_perimeter_width,m_wipe_tower_depth); else { writer.rectangle(m_wipe_tower_pos,m_wipe_tower_width, m_layer_info->depth + m_perimeter_width); @@ -724,7 +702,7 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.append("; CP TOOLCHANGE UNLOAD\n"); - const float line_width = m_line_width * m_filpar[m_current_tool].ramming_line_width_multiplicator; // desired ramming line thickness + const float line_width = m_perimeter_width * m_filpar[m_current_tool].ramming_line_width_multiplicator; // desired ramming line thickness const float y_step = line_width * m_filpar[m_current_tool].ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm unsigned i = 0; // iterates through ramming_speed @@ -757,7 +735,7 @@ void WipeTowerPrusaMM::toolchange_Unload( if (tch.old_tool == m_current_tool) { sum_of_depths += tch.ramming_depth; float ramming_end_y = m_wipe_tower_pos.y + sum_of_depths; - ramming_end_y -= (y_step/m_extra_spacing-m_line_width) / 2.f; // center of final ramming line + ramming_end_y -= (y_step/m_extra_spacing-m_perimeter_width) / 2.f; // center of final ramming line // debugging: /*float oldx = writer.x(); @@ -851,7 +829,7 @@ void WipeTowerPrusaMM::toolchange_Unload( // this is to align ramming and future wiping extrusions, so the future y-steps can be uniform from the start: // the perimeter_width will later be subtracted, it is there to not load while moving over just extruded material - writer.travel(end_of_ramming.x, end_of_ramming.y + (y_step/m_extra_spacing-m_line_width) / 2.f + m_perimeter_width, 2400.f); + writer.travel(end_of_ramming.x, end_of_ramming.y + (y_step/m_extra_spacing-m_perimeter_width) / 2.f + m_perimeter_width, 2400.f); writer.resume_preview() .flush_planner_queue(); @@ -925,8 +903,8 @@ void WipeTowerPrusaMM::toolchange_Wipe( // the ordered volume, even if it means violating the box. This can later be removed and simply // wipe until the end of the assigned area. - float x_to_wipe = volume_to_length(wipe_volume, m_line_width, m_layer_height); - float dy = m_extra_spacing*m_line_width; + float x_to_wipe = volume_to_length(wipe_volume, m_perimeter_width, m_layer_height); + float dy = m_extra_spacing*m_perimeter_width; float wipe_speed = 1600.f; // if there is less than 2.5*m_perimeter_width to the edge, advance straightaway (there is likely a blob anyway) @@ -990,7 +968,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() .set_layer_height(m_layer_height) .set_initial_tool(m_current_tool) .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) - .set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) + .set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) .append(";--------------------\n" "; CP EMPTY GRID START\n") // m_num_layer_changes is incremented by set_z, so it is 1 based. @@ -1024,11 +1002,11 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() if (m_is_first_layer && m_adhesion) { // Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower. box.expand(-m_perimeter_width/2.f); - unsigned nsteps = int(floor((box.lu.y - box.ld.y) / (2*m_perimeter_width))); + int nsteps = int(floor((box.lu.y - box.ld.y) / (2*m_perimeter_width))); float step = (box.lu.y - box.ld.y) / nsteps; writer.travel(box.ld-xy(m_perimeter_width/2.f,m_perimeter_width/2.f)); if (nsteps >= 0) - for (size_t i = 0; i < nsteps; ++i) { + for (int i = 0; i < nsteps; ++i) { writer.extrude(box.ld.x+m_perimeter_width/2.f, writer.y() + 0.5f * step); writer.extrude(box.rd.x - m_perimeter_width / 2.f, writer.y()); writer.extrude(box.rd.x - m_perimeter_width / 2.f, writer.y() + 0.5f * step); @@ -1076,7 +1054,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() // Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool,bool brim) -{ +{ assert(m_plan.back().z <= z_par + WT_EPSILON ); // refuses to add a layer below the last one if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan first @@ -1094,16 +1072,16 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi float depth = 0.f; float width = m_wipe_tower_width - 3*m_perimeter_width; float length_to_extrude = volume_to_length(0.25f * std::accumulate(m_filpar[old_tool].ramming_speed.begin(), m_filpar[old_tool].ramming_speed.end(), 0.f), - m_line_width * m_filpar[old_tool].ramming_line_width_multiplicator, + m_perimeter_width * m_filpar[old_tool].ramming_line_width_multiplicator, layer_height_par); - depth = (int(length_to_extrude / width) + 1) * (m_line_width * m_filpar[old_tool].ramming_line_width_multiplicator * m_filpar[old_tool].ramming_step_multiplicator); + depth = (int(length_to_extrude / width) + 1) * (m_perimeter_width * m_filpar[old_tool].ramming_line_width_multiplicator * m_filpar[old_tool].ramming_step_multiplicator); float ramming_depth = depth; length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; float first_wipe_line = -length_to_extrude; - length_to_extrude += volume_to_length(wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); + length_to_extrude += volume_to_length(wipe_volumes[old_tool][new_tool], m_perimeter_width, layer_height_par); length_to_extrude = std::max(length_to_extrude,0.f); - depth += (int(length_to_extrude / width) + 1) * m_line_width; + depth += (int(length_to_extrude / width) + 1) * m_perimeter_width; depth *= m_extra_spacing; m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth, ramming_depth,first_wipe_line)); @@ -1147,12 +1125,12 @@ void WipeTowerPrusaMM::save_on_last_wipe() float width = m_wipe_tower_width - 3*m_perimeter_width; // width we draw into float length_to_save = 2*(m_wipe_tower_width+m_wipe_tower_depth) + (!layer_finished() ? finish_layer().total_extrusion_length_in_plane() : 0.f); float length_to_wipe = volume_to_length(wipe_volumes[m_layer_info->tool_changes.back().old_tool][m_layer_info->tool_changes.back().new_tool], - m_line_width,m_layer_info->height) - m_layer_info->tool_changes.back().first_wipe_line - length_to_save; + m_perimeter_width,m_layer_info->height) - m_layer_info->tool_changes.back().first_wipe_line - length_to_save; length_to_wipe = std::max(length_to_wipe,0.f); - float depth_to_wipe = m_line_width * (std::floor(length_to_wipe/width) + ( length_to_wipe > 0.f ? 1.f : 0.f ) ) * m_extra_spacing; + float depth_to_wipe = m_perimeter_width * (std::floor(length_to_wipe/width) + ( length_to_wipe > 0.f ? 1.f : 0.f ) ) * m_extra_spacing; - //depth += (int(length_to_extrude / width) + 1) * m_line_width; + //depth += (int(length_to_extrude / width) + 1) * m_perimeter_width; m_layer_info->tool_changes.back().required_depth = m_layer_info->tool_changes.back().ramming_depth + depth_to_wipe; } } @@ -1172,7 +1150,7 @@ void WipeTowerPrusaMM::generate(std::vectordepth < m_wipe_tower_depth - m_perimeter_width) + if (!m_peters_wipe_tower && m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width) m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f; for (const auto &toolchange : layer.tool_changes) layer_result.emplace_back(tool_change(toolchange.new_tool, false)); if (! layer_finished()) { - layer_result.emplace_back(finish_layer()); - if (layer_result.size() > 1) { - // Merge the two last tool changes into one. - WipeTower::ToolChangeResult &tc1 = layer_result[layer_result.size() - 2]; - WipeTower::ToolChangeResult &tc2 = layer_result.back(); - if (tc1.end_pos != tc2.start_pos) { - // Add a travel move from tc1.end_pos to tc2.start_pos. - char buf[2048]; - sprintf(buf, "G1 X%.3f Y%.3f F7200\n", tc2.start_pos.x, tc2.start_pos.y); - tc1.gcode += buf; + auto finish_layer_toolchange = finish_layer(); + if (layer_result.size() > 1) { // we will merge it to the last toolchange + auto& last_toolchange = layer_result.back(); + if (last_toolchange.end_pos != finish_layer_toolchange.start_pos) { + char buf[2048]; // Add a travel move from tc1.end_pos to tc2.start_pos. + sprintf(buf, "G1 X%.3f Y%.3f F7200\n", finish_layer_toolchange.start_pos.x, finish_layer_toolchange.start_pos.y); + last_toolchange.gcode += buf; } - tc1.gcode += tc2.gcode; - tc1.extrusions.insert(tc1.extrusions.end(), tc2.extrusions.begin(), tc2.extrusions.end()); - tc1.end_pos = tc2.end_pos; - layer_result.pop_back(); - } - } + last_toolchange.gcode += finish_layer_toolchange.gcode; + last_toolchange.extrusions.insert(last_toolchange.extrusions.end(),finish_layer_toolchange.extrusions.begin(),finish_layer_toolchange.extrusions.end()); + last_toolchange.end_pos = finish_layer_toolchange.end_pos; + } + else + layer_result.emplace_back(std::move(finish_layer_toolchange)); + } result.emplace_back(std::move(layer_result)); m_is_first_layer = false; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 90317673e4..734d61dc66 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -8,19 +8,6 @@ #include "WipeTower.hpp" -// Following is used to calculate extrusion flow - should be taken from config in future -const float Filament_Area = M_PI * 1.75f * 1.75f / 4.f; // filament area in mm^3 -const float Nozzle_Diameter = 0.4f; // nozzle diameter in mm -// desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust -const float Width_To_Nozzle_Ratio = 1.25f; - -// m_perimeter_width was hardcoded until now as 0.5 (for 0.4 nozzle and 0.2 layer height) -// FIXME m_perimeter_width is used in plan_toolchange - take care of proper initialization value when changing to variable -const float Konst = 1.f; -const float m_perimeter_width = Nozzle_Diameter * Width_To_Nozzle_Ratio * Konst; - -const float WT_EPSILON = 1e-3f; - namespace Slic3r { @@ -31,7 +18,6 @@ namespace PrusaMultiMaterial { - class WipeTowerPrusaMM : public WipeTower { public: @@ -65,40 +51,27 @@ public: m_y_shift(0.f), m_z_pos(0.f), m_is_first_layer(false), - m_is_last_layer(false), m_cooling_tube_retraction(cooling_tube_retraction), m_cooling_tube_length(cooling_tube_length), m_parking_pos_retraction(parking_pos_retraction), m_bridging(bridging), m_current_tool(initial_tool) { - const unsigned int number_of_extruders = int(sqrt(wiping_matrix.size())+WT_EPSILON); + unsigned int number_of_extruders = (unsigned int)(sqrt(wiping_matrix.size())+WT_EPSILON); for (unsigned int i = 0; i(wiping_matrix.begin()+i*number_of_extruders,wiping_matrix.begin()+(i+1)*number_of_extruders)); - - /*for (size_t i = 0; i < number_of_extruders; ++ i) { - // Extruder specific parameters. - m_filpar[i].material = PLA; - m_filpar[i].temperature = 0; - m_filpar[i].first_layer_temperature = 0; - }*/ } virtual ~WipeTowerPrusaMM() {} - // _retract - retract value in mm - void set_retract(float retract) { m_retract = retract; } - - // _zHop - z hop value in mm - void set_zhop(float zhop) { m_zhop = zhop; } - // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, float unloading_speed, float delay, int cooling_time, std::string ramming_parameters) { - while (m_filpar.size() < idx+1) // makes sure the required element is in the vector - m_filpar.push_back(FilamentParameters()); + //while (m_filpar.size() < idx+1) // makes sure the required element is in the vector + m_filpar.push_back(FilamentParameters()); + m_filpar[idx].material = material; m_filpar[idx].temperature = temp; m_filpar[idx].first_layer_temperature = first_layer_temp; @@ -106,7 +79,7 @@ public: m_filpar[idx].unloading_speed = unloading_speed; m_filpar[idx].delay = delay; m_filpar[idx].cooling_time = cooling_time; - + std::stringstream stream{ramming_parameters}; float speed = 0.f; stream >> m_filpar[idx].ramming_line_width_multiplicator >> m_filpar[idx].ramming_step_multiplicator; @@ -117,21 +90,14 @@ public: } - // Setter for internal structure m_plan containing info about the future wipe tower + // Appends into internal structure m_plan containing info about the future wipe tower // to be used before building begins. The entries must be added ordered in z. void plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool, bool brim); // Iterates through prepared m_plan, generates ToolChangeResults and appends them to "result" void generate(std::vector> &result); - // Calculates depth for all layers and propagates them downwards - void plan_tower(); - // Goes through m_plan and recalculates depths and width of the WT to make it exactly square - experimental - void make_wipe_tower_square(); - - // Goes through m_plan, calculates border and finish_layer extrusions and subtracts them from last wipe - void save_on_last_wipe(); // Switch to a next layer. virtual void set_layer( @@ -150,15 +116,16 @@ public: m_layer_height = layer_height; m_is_first_layer = is_first_layer; m_print_brim = is_first_layer; - m_depth_traversed = 0.f; // to make room for perimeter line + m_depth_traversed = 0.f; m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL; ++ m_num_layer_changes; - // Calculates extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height + // Calculate extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height: m_extrusion_flow = extrusion_flow(layer_height); - while (!m_plan.empty() && m_layer_info->z < print_z - WT_EPSILON && m_layer_info+1!=m_plan.end()) + // Advance m_layer_info iterator, making sure we got it right + while (!m_plan.empty() && m_layer_info->z < print_z - WT_EPSILON && m_layer_info+1 != m_plan.end()) ++m_layer_info; } @@ -183,7 +150,7 @@ public: // On the first layer, extrude a brim around the future wipe tower first. virtual ToolChangeResult tool_change(unsigned int new_tool, bool last_in_layer); - // Fill the unfilled space with a zig-zag. + // Fill the unfilled space with a sparse infill. // Call this method only if layer_finished() is false. virtual ToolChangeResult finish_layer(); @@ -196,34 +163,38 @@ public: private: WipeTowerPrusaMM(); - enum wipe_shape // A fill-in direction (positive Y, negative Y) alternates with each layer. + enum wipe_shape // A fill-in direction { SHAPE_NORMAL = 1, SHAPE_REVERSED = -1 }; + + const bool m_peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet + const float Filament_Area = M_PI * 1.75f * 1.75f / 4.f; // filament area in mm^3 + const float Nozzle_Diameter = 0.4f; // nozzle diameter in mm + const float Width_To_Nozzle_Ratio = 1.25f; // desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust + const float WT_EPSILON = 1e-3f; + + xy m_wipe_tower_pos; // Left front corner of the wipe tower in mm. float m_wipe_tower_width; // Width of the wipe tower. float m_wipe_tower_depth = 0.f; // Depth of the wipe tower - float m_wipe_tower_rotation_angle = 0.f; // Wipe tower rotation angle in degrees (with respect to x axis + float m_wipe_tower_rotation_angle = 0.f; // Wipe tower rotation angle in degrees (with respect to x axis) float m_y_shift = 0.f; // y shift passed to writer float m_z_pos = 0.f; // Current Z position. float m_layer_height = 0.f; // Current layer height. size_t m_max_color_changes = 0; // Maximum number of color changes per layer. bool m_is_first_layer = false;// Is this the 1st layer of the print? If so, print the brim around the waste tower. - bool m_is_last_layer = false;// Is this the last layer of this waste tower? - bool m_layer_parity = false; // G-code generator parameters. - float m_zhop = 0.5f; - float m_retract = 4.f; float m_cooling_tube_retraction = 0.f; float m_cooling_tube_length = 0.f; float m_parking_pos_retraction = 0.f; float m_bridging = 0.f; bool m_adhesion = true; - float m_line_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. + float m_perimeter_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_extrusion_flow = 0.038; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. @@ -244,7 +215,7 @@ private: std::vector m_filpar; - // State of the wiper tower generator. + // State of the wipe tower generator. unsigned int m_num_layer_changes = 0; // Layer change counter for the output statistics. unsigned int m_num_tool_changes = 0; // Tool change change counter for the output statistics. ///unsigned int m_idx_tool_change_in_layer = 0; // Layer change counter in this layer. Counting up to m_max_color_changes. @@ -254,12 +225,10 @@ private: unsigned int m_current_tool = 0; std::vector> wipe_volumes; - float m_depth_traversed = 0.f; // Current y position at the wipe tower. - // How much to wipe the 1st extruder over the wipe tower at the 1st layer - // after the wipe tower brim has been extruded? - float m_initial_extra_wipe = 0.f; - bool m_left_to_right = true; - float m_extra_spacing = 1.f; + float m_depth_traversed = 0.f; // Current y position at the wipe tower. + bool m_left_to_right = true; + float m_extra_spacing = 1.f; + // Calculates extrusion flow needed to produce required line width for given layer height float extrusion_flow(float layer_height = -1.f) const // negative layer_height - return current m_extrusion_flow @@ -274,6 +243,15 @@ private: return volume / (layer_height * (line_width - layer_height * (1. - M_PI / 4.))); } + // Calculates depth for all layers and propagates them downwards + void plan_tower(); + + // Goes through m_plan and recalculates depths and width of the WT to make it exactly square - experimental + void make_wipe_tower_square(); + + // Goes through m_plan, calculates border and finish_layer extrusions and subtracts them from last wipe + void save_on_last_wipe(); + struct box_coordinates { diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index cd227ed1c0..18d2bcead0 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -1075,7 +1075,6 @@ void Print::_make_wipe_tower() // Lets go through the wipe tower layers and determine pairs of extruder changes for each // to pass to wipe_tower (so that it can use it for planning the layout of the tower) - { unsigned int current_extruder_id = m_tool_ordering.all_extruders().back(); for (const auto &layer_tools : m_tool_ordering.layer_tools()) { // for all layers diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index fc3d30a5d4..ac35756a49 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -40,7 +40,7 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) { new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT); m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString, wxPoint(700,100), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0.,5.0,3.,0.5); - new wxStaticText(this,wxID_ANY,wxString("Total rammed volume (mm3):"), wxPoint(500,135), wxSize(200,25),wxALIGN_LEFT); + new wxStaticText(this,wxID_ANY,wxString("Total rammed volume (mm\u00B3):"), wxPoint(500,135), wxSize(200,25),wxALIGN_LEFT); m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,130), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0,10000,0); new wxStaticText(this,wxID_ANY,wxString("Ramming line width (%):"), wxPoint(500,205), wxSize(200,25),wxALIGN_LEFT); m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,200), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100); From e7a5bc1afefb3d051c888830e3655e8e456b6eaa Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 21 Mar 2018 16:01:31 +0100 Subject: [PATCH 0071/1150] Added a check that no object uses extruder the printer doesn't have --- xs/src/libslic3r/Print.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 18d2bcead0..62c9c88196 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -624,7 +624,12 @@ std::string Print::validate() const for (unsigned int extruder_id : extruders) nozzle_diameters.push_back(this->config.nozzle_diameter.get_at(extruder_id)); double min_nozzle_diameter = *std::min_element(nozzle_diameters.begin(), nozzle_diameters.end()); - + + unsigned int total_extruders_count = this->config.nozzle_diameter.size(); + for (const auto& extruder_idx : extruders) + if ( extruder_idx >= total_extruders_count ) + return "One or more object have assigned an extruder that the printer does not have."; + for (PrintObject *object : this->objects) { if ((object->config.support_material_extruder == -1 || object->config.support_material_interface_extruder == -1) && (object->config.raft_layers > 0 || object->config.support_material.value)) { From 82f4e16a27f85ec3c5e277b8fb4843d006ee7680 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 21 Mar 2018 22:21:37 +0100 Subject: [PATCH 0072/1150] "Decorated" UI for options groups. * Added prototype of undo-buttons for options groups; * Fixed bugs with "decoration" updating after preset changing; * Fixed wrong Ukrainian translation. --- resources/localization/uk/Slic3rPE.mo | Bin 140066 -> 140068 bytes resources/localization/uk/Slic3rPE_uk.po | 8 +- xs/src/slic3r/GUI/OptionsGroup.cpp | 8 +- xs/src/slic3r/GUI/OptionsGroup.hpp | 5 +- xs/src/slic3r/GUI/Tab.cpp | 251 ++++++++++++++++------- xs/src/slic3r/GUI/Tab.hpp | 12 +- 6 files changed, 196 insertions(+), 88 deletions(-) diff --git a/resources/localization/uk/Slic3rPE.mo b/resources/localization/uk/Slic3rPE.mo index c980ae64db8cc2f277ea38c8f12587076ef3626a..7ced15dc8c91acee358022d27d2d1abdf88c2313 100644 GIT binary patch delta 5917 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 BiDLi& delta 5915 zcmXZgd09>s6cfpC80Bh%frh^&9rLYw$Uo!td=+Z?q3<;`i7RbFm3F zzUN+G5~}@dEQ^0)5e&I+Oazwo`VZ=3WlnTKt}zo)sT=;lWo8LR6R*M~{05b&;tv@P zERU5i7M1#**cAI?3@%4qzXzM)Vbp!z0=c{msg1yJP7Ef$YG4YM#CNa+F2y>y5nsTI zI2^10V@yX}f}QafRBhCLY)n6Fj(YGitcz<=Lwgz{dA=$6#1&P2tj!NY@Ht$FO6^{3 zi#JgZj(h4F`WF@_-i+$_H>fu~k9y!UR7VOvGiDx^!E%_1%JhB=!@{2FqD%N)gvabuY8pH6i)^y~Jn&N5V+2veu4JhxfACD27UyND-v;60CP_y7Zs(n+z)mS)c zU1^J9=pExfn2EX}9aVH|P#xHY>d<-AjRBGFfwi#$aXVCIl2Nm0DXJq|F&Z!6WPFNe zablEfKPlSRp4SZIKs}j@TERZX8n_?Tz-?5=idM8Hg-n#emBce*TpUx$)yn&o-J7n! zAb#J1O8qWWG2cP8*RF~iqSr7~^FNh?X*8UHjkzGQ8gJ}j^+MJhGoyy}?T*u^EOj&$ z&*3UmExc9Bn$`FjYWjAp?WSvA97VfJ@pBAh2kVBL>sZ4~G@dwX-sbrxq@Fdu;XM2j zN5|7ME~r@FnnhTzfi4LlxsTRP7vT&HUGe*Etb|cm0O7aq~AG)v?Z~)Q&_I=Ty`>kc#TiWmL^X zC%WS7get~lztd6cK?Z8t?Lh4rM-siRNG@|in@l))ZIAu2A%2QV{m-a1y*>HY8}`R- zq<$ePwTUlS-|jaR%Mc$yEnHWzD@Jy*rVEboyARc&P;X~fT-7m#2Q|PK`JrEutJ1C5 zgY##w0OxCVb?5700&ySI5Tv7T+M+tT4Ye*DMve6qT!9s-z?W%n4~`=CmZkNX9L&Qp zShS~003#cJ_imHk7y{&JbAB|d?SD}jW5GteBa3EIb zW6dP(|Nr7(FemO~2ki5rd$U#e3O)T5wePp<=N`BiRWsSBFPJ^3H$9H3fg7j}m3+x9 zVD(WQcnOu6H!uX}V@b{b6&&csEjR&x!g|<^JSnBKP%GhwsN&g;+7*wX8miFWjd4xX z^;7+(VghjnDign;#yoIh}y(t$mx!{MW8lWSIL@ zYJ^`CZ$;fOHpR{7IjGdGL3QW=swmH5N36sm5rw01I4(p@ugBOGhYx2R!LKj{E5GiX z@8v*m@(|ULN+VnSSP`l?cRLAyUXAEWs(zJXL z6|eW3i+ZlN?P&MF@u;IK-7*9OZZ#s4$K8hh&YQ7tqN~ogjfEuz?EUWqd5eNFq zWG8CA=lJ8lQAHTK!1cH)?jml6-(oJRn7&@-(Fp6RN{=QM=#)tcaJf2Ifn1 zLlKK!O^4nbXzZt=#xMiRo43&WOJvz62@!z;v{ zKeT2k)?I2%FFcHzMUm;u|A`#LrMnEQ!!Nn<0IIsDEVpJiZb7AZ)CxB=YjA_c7Hi>K zAG_jQm*IA~`#6v>U$l}>JMQ~ymCMAq)z0~-4y<2I(P(~t%?Z6pku`29u7-t(2ca@B z0(C@&umj`c=;s0>|a&1Kwyv7BG_xtk@2z3csB z!s}?PV^PJ`7Q?u30O}KL+(x&1Eys$)U!bb{M{I~|HnC9Ap$lJF;~{>qg+Da#5$PPt z^-Z@~lZKz5renQqYx?rL*ULc=2j{k1lfw_c?qGK#-nrA7OyUB&-1eM>Er^SLWz7ui zg3IwF&c#u?$rShHq86?Sd)$zup>OxY{+tioYfVqCdj$gnn1BD?XUz#t?E8jPV%h;~ z#^U{hR5=bi#Fr1&I>I#N4def7%{3ZIJZjAYto4I6*_@9##*pDT8moaaIX4Ckj^w}y8xi*H!p|0leB%bGWcuiUog zl;(f`JEWQuaerEK7|;G?&3#<`H~TlH6THQB>mFE>j+Gv=PUNF#@lXI`{@9vlT(>sQ zZO3b@$M^TcCe#rlu+ka5S z*)^ZX_m!K1(Zn-Q+ju5w8$N^Dbi(s{e1GSs;636EsOkJkpu4_*0gu=BUnmO-czo_b zb?7!~<%$aOn8Mf;H48doAdbUed;|4`GZRbW5^RfE`kjp2!(NzI&|{()l3o;u_JT?L z)1C7(i+Vl2|1da1W!>XMKyi=xnFeyhND=Xw5-w#oOS+WhqB0T^?(wY`4Kb3q8|wU6 z+>Re%L+nw?X^(H#z3$~;ASWh7xHmh6UlL!yK{%gDtxu{uSb+{D zmGzj#II^6__g!Esc=Q=<>f&>_4z)*|!Qz+}>4qp1)q(F&9e#w`^t=(|MQeKvtc@>W z49>-Zn1w2$9jIOFd!+Wv1&qc^s3G!1dweTjC^jYTg#|DT^`Pab_BNn~Fx$mL%x(^} z)E>l2_#>+44^c%JT+!oOf}>IA+xg>us6AmCmceYShsXVKz8H^Ts7>V7>#@tX1jp5m tYZO&CzHy!St*Mvuf\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -3330,7 +3330,7 @@ msgstr "" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:137 msgid "None" -msgstr "Жадне" +msgstr "Жодне" #: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:138 #: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:80 @@ -3718,11 +3718,11 @@ msgstr "Файл" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:419 msgid "&Plater" -msgstr "Платер" +msgstr "&Платер" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:420 msgid "&Object" -msgstr "Об'єкт" +msgstr "&Об'єкт" #: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:421 msgid "&Window" diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 37f3fea68d..3a97c98c7b 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -90,8 +90,8 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co field->m_Undo_btn->Hide(); field->m_Undo_to_sys_btn->Hide(); } - if (nonsys_btn_icon != "") - field->set_nonsys_btn_icon(nonsys_btn_icon); + if (nonsys_btn_icon != nullptr) + field->set_nonsys_btn_icon(nonsys_btn_icon()); // assign function objects for callbacks, etc. return field; @@ -335,7 +335,7 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, } void ConfigOptionsGroup::reload_config(){ - for (std::map< std::string, std::pair >::iterator it = m_opt_map.begin(); it != m_opt_map.end(); ++it) { + for (t_opt_map::iterator it = m_opt_map.begin(); it != m_opt_map.end(); ++it) { auto opt_id = it->first; std::string opt_key = m_opt_map.at(opt_id).first; int opt_index = m_opt_map.at(opt_id).second; @@ -455,7 +455,7 @@ Field* ConfigOptionsGroup::get_fieldc(t_config_option_key opt_key, int opt_index if (field != nullptr) return field; std::string opt_id = ""; - for (std::map< std::string, std::pair >::iterator it = m_opt_map.begin(); it != m_opt_map.end(); ++it) { + for (t_opt_map::iterator it = m_opt_map.begin(); it != m_opt_map.end(); ++it) { if (opt_key == m_opt_map.at(it->first).first && opt_index == m_opt_map.at(it->first).second){ opt_id = it->first; break; diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 3efa427304..7884271e1d 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -69,6 +69,7 @@ private: }; using t_optionfield_map = std::map; +using t_opt_map = std::map< std::string, std::pair >; class OptionsGroup { public: @@ -85,7 +86,7 @@ public: wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; - std::string nonsys_btn_icon = ""; + std::function nonsys_btn_icon{ nullptr }; /// Returns a copy of the pointer of the parent wxWindow. /// Accessor function is because users are not allowed to change the parent @@ -164,7 +165,7 @@ public: /// reference to libslic3r config, non-owning pointer (?). DynamicPrintConfig* m_config {nullptr}; bool m_full_labels {0}; - std::map< std::string, std::pair > m_opt_map; + t_opt_map m_opt_map; Option get_option(const std::string opt_key, int opt_index = -1); Line create_single_option_line(const std::string title, int idx = -1) /*const*/{ diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 464734f9c9..9266796645 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -55,6 +55,17 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_btn_delete_preset->SetToolTip(_(L("Delete this preset"))); m_btn_delete_preset->Disable(); + m_undo_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + m_undo_to_sys_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + if (wxMSW) { + m_undo_btn->SetBackgroundColour(color); + m_undo_to_sys_btn->SetBackgroundColour(color); + } + m_undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); + m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ })); + m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); + m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ })); + m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 0, wxBOTTOM, 3); m_hsizer->Add(m_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3); @@ -64,6 +75,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_hsizer->Add(m_btn_delete_preset, 0, wxALIGN_CENTER_VERTICAL); m_hsizer->AddSpacer(16); m_hsizer->Add(m_btn_hide_incompatible_presets, 0, wxALIGN_CENTER_VERTICAL); + m_hsizer->AddSpacer(64); + m_hsizer->Add(m_undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); + m_hsizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL); //Horizontal sizer to hold the tree and the selected page. m_hsizer = new wxBoxSizer(wxHORIZONTAL); @@ -182,8 +196,6 @@ void Tab::update_changed_ui() { auto dirty_options = m_presets->current_dirty_options(); - auto sys_options = m_presets->system_equal_options(); - if (name() == "printer"){ // Update dirty_options in case changes of Extruder's options TabPrinter* tab = static_cast(this); @@ -201,38 +213,40 @@ void Tab::update_changed_ui() default: new_options.emplace_back(opt_key); break; } } - dirty_options.resize(0); dirty_options = new_options; if (tab->m_initial_extruders_count != tab->m_extruders_count) dirty_options.emplace_back("extruders_count"); - new_options.resize(0); - std::initializer_list optional_keys{"bed_shape", "compatible_printers", "compatible_printers_condition" }; - for (auto &opt_key : optional_keys) { - if (find(sys_options.begin(), sys_options.end(),opt_key) != sys_options.end()) - new_options.emplace_back(opt_key); - } - for (auto opt_key : m_config->keys()) - { - if (opt_key == "bed_shape") continue; - switch (m_config->option(opt_key)->type()) - { - case coInts: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; - case coBools: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; - case coFloats: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; - case coStrings: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; - case coPercents:add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; - case coPoints: add_correct_opts_to_sys_options(opt_key, &new_options, tab); break; - default: new_options.emplace_back(opt_key); break; + m_sys_options.resize(0); + const auto sys_preset = m_presets->get_selected_preset_parent(); + if (sys_preset){ + std::initializer_list optional_keys{"compatible_printers", "compatible_printers_condition" }; + for (auto &opt_key : optional_keys) { + if (m_config->has(opt_key) == sys_preset->config.has(opt_key)) + m_sys_options.emplace_back(opt_key); + } + for (auto opt_key : m_config->keys()) + { + if (opt_key == "bed_shape"){ m_sys_options.emplace_back(opt_key); continue; } + switch (m_config->option(opt_key)->type()) + { + case coInts: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; + case coBools: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; + case coFloats: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; + case coStrings: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; + case coPercents:add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; + case coPoints: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; + default: m_sys_options.emplace_back(opt_key); break; + } } - } - sys_options.resize(0); - sys_options = new_options; - if (tab->m_sys_extruders_count == tab->m_extruders_count) - sys_options.emplace_back("extruders_count"); + if (tab->m_sys_extruders_count == tab->m_extruders_count) + m_sys_options.emplace_back("extruders_count"); + } } + else + m_sys_options = m_presets->system_equal_options(); // Add new dirty options to m_dirty_options for (auto opt_key : dirty_options){ @@ -272,62 +286,139 @@ void Tab::update_changed_ui() } } } - //update system options (colored in green) - // Add new system equal options to m_sys_options - for (auto opt_key : sys_options){ + for (const auto opt_key : m_full_options_list) + { Field* field = get_field(opt_key); - if (field != nullptr && find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()){ - field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(wxMSW ? var("sys_lock.png") : var("lock.png")), wxBITMAP_TYPE_PNG)); + if (field == nullptr) continue; + std::string icon = wxMSW ? "sys_lock.png" : "lock.png"; + wxColor& color = *get_sys_label_clr(); + if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) != m_sys_options.end()) { field->m_is_nonsys_value = false; - - m_sys_options.push_back(opt_key); } - if (field != nullptr && field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(*get_sys_label_clr()); + else { + field->m_is_nonsys_value = true; + icon = m_nonsys_btn_icon; + if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) + color = wxSYS_COLOUR_WINDOWTEXT; + } + field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(icon)), wxBITMAP_TYPE_PNG)); + if (field->m_Label != nullptr){ + field->m_Label->SetForegroundColour(color); field->m_Label->Refresh(true); } } - if (sys_options.empty() && !m_sys_options.empty()){ - for (auto opt_key : m_config->keys()){ - Field* field = get_field(opt_key); - if (field != nullptr){ - field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); - field->m_is_nonsys_value = false; - if (field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); - field->m_Label->Refresh(true); - } - } - } - m_sys_options.resize(0); - } - // Delete clear options from m_dirty_options - for (auto i = 0; i < m_sys_options.size(); ++i) - { - const std::string &opt_key = m_sys_options[i]; - Field* field = get_field(opt_key); - if (find(sys_options.begin(), sys_options.end(), opt_key) == sys_options.end()) - { - if (field != nullptr){ - // use bouth of temporary_icons till don't have "unlock_icon" - field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); - if (field->m_Label != nullptr && - find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()){ - field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); - field->m_Label->Refresh(true); - } - field->m_is_nonsys_value = true; - } - std::vector::iterator itr = find(m_sys_options.begin(), m_sys_options.end(), opt_key); - if (itr != m_sys_options.end()){ - m_sys_options.erase(itr); - --i; - } - } + + wxTheApp->CallAfter([this]() { + update_changed_tree_ui(); + }); +} + +template +void add_correct_opts_to_full_options_list(const std::string &opt_key, std::vector *vec, TabPrinter *tab) +{ + T *opt_cur = static_cast(tab->m_config->option(opt_key)); + for (int i = 0; i < opt_cur->values.size(); i++) + vec->emplace_back(opt_key + "#" + std::to_string(i)); +} + +void Tab::update_full_options_list() +{ + if (!m_full_options_list.empty()) + m_full_options_list.resize(0); + + if (m_name != "printer"){ + m_full_options_list = m_config->keys(); + return; } + TabPrinter* tab = static_cast(this); + for (const auto opt_key : m_config->keys()) + { + if (opt_key == "bed_shape"){ + m_full_options_list.emplace_back(opt_key); + continue; + } + switch (m_config->option(opt_key)->type()) + { + case coInts: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; + case coBools: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; + case coFloats: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; + case coStrings: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; + case coPercents:add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; + case coPoints: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; + default: m_full_options_list.emplace_back(opt_key); break; + } + } + m_full_options_list.emplace_back("extruders_count"); + + std::initializer_list optional_keys{ "compatible_printers", "compatible_printers_condition" }; + for (auto &opt_key : optional_keys) { + if (m_config->has(opt_key)) + m_full_options_list.emplace_back(opt_key); + } +} + +void Tab::update_sys_ui_after_sel_preset() +{ + for (const auto opt_key : m_full_options_list){ + Field* field = get_field(opt_key); + if (field != nullptr){ + field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); + field->m_is_nonsys_value = true; + if (field->m_Label != nullptr){ + field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); + field->m_Label->Refresh(true); + } + } + } + m_sys_options.resize(0); +} + +void Tab::update_changed_tree_ui() +{ + auto cur_item = m_treectrl->GetFirstVisibleItem(); + while (cur_item){ + auto title = m_treectrl->GetItemText(cur_item); + int i=0; + for (auto page : m_pages) + { + if (page->title() != title) + continue; + bool sys_page = true; + bool modified_page = false; + if (title == _("General")){ + if (sys_page && find(m_sys_options.begin(), m_sys_options.end(), "extruders_count") == m_sys_options.end()) + sys_page = false; + if (!modified_page && find(m_dirty_options.begin(), m_dirty_options.end(), "extruders_count") != m_dirty_options.end()) + modified_page = true; + } + for (auto group : page->m_optgroups) + { + for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { + const std::string& opt_key = it->first; + if (sys_page && find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) + sys_page = false; + if (!modified_page && find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) + modified_page = true; + } + if (!sys_page && modified_page) + break; + } + if (sys_page){ + m_treectrl->SetItemTextColour(cur_item, *get_sys_label_clr()); + } + else if (modified_page){ + m_treectrl->SetItemTextColour(cur_item, *get_modified_label_clr()); + } + else + m_treectrl->SetItemTextColour(cur_item, wxSYS_COLOUR_WINDOWTEXT); + break; + } + auto next_item = m_treectrl->GetNextVisible(cur_item); + cur_item = next_item; + } } // Update the combo box label of the selected preset based on its "dirty" state, @@ -1116,7 +1207,9 @@ void TabPrinter::build() auto *nozzle_diameter = dynamic_cast(m_config->option("nozzle_diameter")); m_initial_extruders_count = m_extruders_count = nozzle_diameter->values.size(); - m_sys_extruders_count = static_cast(m_presets->get_selected_preset_parent()->config.option("nozzle_diameter"))->values.size(); + const Preset* parent_preset = m_presets->get_selected_preset_parent(); + m_sys_extruders_count = parent_preset == nullptr ? 0 : + static_cast(parent_preset->config.option("nozzle_diameter"))->values.size(); auto page = add_options_page(_(L("General")), "printer_empty.png"); auto optgroup = page->new_optgroup(_(L("Size and coordinates"))); @@ -1550,8 +1643,14 @@ void Tab::load_current_preset() if (name() == "print") update_frequently_changed_parameters(); - if (m_name == "printer") + if (m_name == "printer"){ static_cast(this)->m_initial_extruders_count = static_cast(this)->m_extruders_count; + const Preset* parent_preset = m_presets->get_selected_preset_parent(); + static_cast(this)->m_sys_extruders_count = parent_preset == nullptr ? 0 : + static_cast(parent_preset->config.option("nozzle_diameter"))->values.size(); + } + update_sys_ui_after_sel_preset(); + update_full_options_list(); update_changed_ui(); }); } @@ -1962,7 +2061,9 @@ ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_wid return static_cast(GetParent())->m_presets->get_selected_preset_parent() != nullptr; }; - optgroup->nonsys_btn_icon = static_cast(GetParent())->m_nonsys_btn_icon; + optgroup->nonsys_btn_icon = [this](){ + return static_cast(GetParent())->m_nonsys_btn_icon; + }; vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10); m_optgroups.push_back(optgroup); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index a2cf648e96..8dd667bd1d 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -90,10 +90,12 @@ protected: wxImageList* m_icons; wxCheckBox* m_compatible_printers_checkbox; wxButton* m_compatible_printers_btn; + wxButton* m_undo_btn; + wxButton* m_undo_to_sys_btn; int m_icon_count; - std::map m_icon_index; // Map from an icon file name to its index in $self->{icons}. - std::vector m_pages; // $self->{pages} = []; + std::map m_icon_index; // Map from an icon file name to its index + std::vector m_pages; bool m_disable_tree_sel_changed_event; bool m_show_incompatible_presets; bool m_no_controller; @@ -101,6 +103,7 @@ protected: std::vector m_reload_dependent_tabs = {}; std::vector m_dirty_options = {}; std::vector m_sys_options = {}; + std::vector m_full_options_list = {}; // The two following two event IDs are generated at Plater.pm by calling Wx::NewEventType. wxEventType m_event_value_change = 0; @@ -149,7 +152,10 @@ public: void update_show_hide_incompatible_button(); void update_ui_from_settings(); void update_changed_ui(); - + void update_full_options_list(); + void update_sys_ui_after_sel_preset(); + void update_changed_tree_ui(); + PageShp add_options_page(wxString title, std::string icon, bool is_extruder_pages = false); virtual void OnActivate(){} From 78208620c0a044fb0b1d602df29846e8af3c1a93 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 22 Mar 2018 09:37:42 +0100 Subject: [PATCH 0073/1150] Correct updating of "Undo"-buttons according to the option changes --- xs/src/slic3r/GUI/Tab.cpp | 35 ++++++++++++++++++++++++++++++----- xs/src/slic3r/GUI/Tab.hpp | 7 +++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 9266796645..52b7ea94ef 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -293,7 +293,7 @@ void Tab::update_changed_ui() Field* field = get_field(opt_key); if (field == nullptr) continue; std::string icon = wxMSW ? "sys_lock.png" : "lock.png"; - wxColor& color = *get_sys_label_clr(); + wxColour& color = *get_sys_label_clr(); if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) != m_sys_options.end()) { field->m_is_nonsys_value = false; } @@ -302,6 +302,8 @@ void Tab::update_changed_ui() icon = m_nonsys_btn_icon; if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) color = wxSYS_COLOUR_WINDOWTEXT; + else + color = *get_modified_label_clr(); } field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(icon)), wxBITMAP_TYPE_PNG)); if (field->m_Label != nullptr){ @@ -379,6 +381,7 @@ void Tab::update_sys_ui_after_sel_preset() void Tab::update_changed_tree_ui() { auto cur_item = m_treectrl->GetFirstVisibleItem(); + auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); while (cur_item){ auto title = m_treectrl->GetItemText(cur_item); int i=0; @@ -406,19 +409,37 @@ void Tab::update_changed_tree_ui() if (!sys_page && modified_page) break; } - if (sys_page){ + if (sys_page) m_treectrl->SetItemTextColour(cur_item, *get_sys_label_clr()); - } - else if (modified_page){ + else if (modified_page) m_treectrl->SetItemTextColour(cur_item, *get_modified_label_clr()); - } else m_treectrl->SetItemTextColour(cur_item, wxSYS_COLOUR_WINDOWTEXT); + + page->m_is_nonsys_values = !sys_page; + page->m_is_modified_values = modified_page; + + if (selection == title){ + m_is_nonsys_values = page->m_is_nonsys_values; + m_is_modified_values = page->m_is_modified_values; + } break; } auto next_item = m_treectrl->GetNextVisible(cur_item); cur_item = next_item; } + update_undo_buttons(); +} + +void Tab::update_undo_buttons() +{ + const std::string& undo_icon = !m_is_modified_values ? "bullet_white.png" : + wxMSW ? "action_undo.png" : "arrow_undo.png"; + const std::string& undo_to_sys_icon = m_is_nonsys_values ? m_nonsys_btn_icon : + wxMSW ? "sys_lock.png" : "lock.png"; + + m_undo_btn->SetBitmap(wxBitmap(from_u8(var(undo_icon)), wxBITMAP_TYPE_PNG)); + m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(undo_to_sys_icon)), wxBITMAP_TYPE_PNG)); } // Update the combo box label of the selected preset based on its "dirty" state, @@ -1796,6 +1817,8 @@ void Tab::OnTreeSelChange(wxTreeEvent& event) if (p->title() == selection) { page = p.get(); + m_is_nonsys_values = page->m_is_nonsys_values; + m_is_modified_values = page->m_is_modified_values; break; } if (page == nullptr) return; @@ -1805,6 +1828,8 @@ void Tab::OnTreeSelChange(wxTreeEvent& event) page->Show(); m_hsizer->Layout(); Refresh(); + + update_undo_buttons(); } void Tab::OnKeyDown(wxKeyEvent& event) diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 8dd667bd1d..fbc65745c5 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -54,6 +54,9 @@ public: } ~Page(){} + bool m_is_modified_values{ false }; + bool m_is_nonsys_values{ true }; + public: std::vector m_optgroups; DynamicPrintConfig* m_config; @@ -109,6 +112,9 @@ protected: wxEventType m_event_value_change = 0; wxEventType m_event_presets_changed = 0; + bool m_is_modified_values{ false }; + bool m_is_nonsys_values{ true }; + public: PresetBundle* m_preset_bundle; bool m_show_btn_incompatible_presets = false; @@ -155,6 +161,7 @@ public: void update_full_options_list(); void update_sys_ui_after_sel_preset(); void update_changed_tree_ui(); + void update_undo_buttons(); PageShp add_options_page(wxString title, std::string icon, bool is_extruder_pages = false); From d7e23056860b7b73bd8f755702bfbc95aae48684 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 22 Mar 2018 10:56:57 +0100 Subject: [PATCH 0074/1150] "Undo"-buttons work --- xs/src/libslic3r/PrintConfig.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 49 ++++++++++++++++++++++++++++++-- xs/src/slic3r/GUI/Tab.hpp | 3 ++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 83de577aa7..a49124f879 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -418,7 +418,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("This is only used in the Slic3r interface as a visual help."); def->cli = "filament-color=s@"; def->gui_type = "color"; - def->default_value = new ConfigOptionStrings { "#29b2b2" }; + def->default_value = new ConfigOptionStrings { "#29B2B2" }; def = this->add("filament_notes", coStrings); def->label = L("Filament notes"); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 52b7ea94ef..7cb3491f6c 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -62,9 +62,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_undo_to_sys_btn->SetBackgroundColour(color); } m_undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); - m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ })); + m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); - m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ })); + m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 0, wxBOTTOM, 3); @@ -442,6 +442,51 @@ void Tab::update_undo_buttons() m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(undo_to_sys_icon)), wxBITMAP_TYPE_PNG)); } +void Tab::on_back_to_initial_value() +{ + if (!m_is_modified_values) return; + + auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); + for (auto page : m_pages) + if (page->title() == selection) { + for (auto group : page->m_optgroups){ + if (group->title == _("Capabilities")){ + if (find(m_dirty_options.begin(), m_dirty_options.end(), "extruders_count") != m_dirty_options.end()) + group->back_to_initial_value("extruders_count"); + } + for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { + const std::string& opt_key = it->first; + if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) + group->back_to_initial_value(opt_key); + } + } + break; + } + +} + +void Tab::on_back_to_sys_value() +{ + if (!m_is_nonsys_values) return; + + auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); + for (auto page : m_pages) + if (page->title() == selection) { + for (auto group : page->m_optgroups) { + if (group->title == _("Capabilities")){ + if (find(m_sys_options.begin(), m_sys_options.end(), "extruders_count") == m_sys_options.end()) + group->back_to_sys_value("extruders_count"); + } + for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { + const std::string& opt_key = it->first; + if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) + group->back_to_sys_value(opt_key); + } + } + break; + } +} + // Update the combo box label of the selected preset based on its "dirty" state, // comparing the selected preset config with $self->{config}. void Tab::update_dirty(){ diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index fbc65745c5..eaf188df4b 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -163,6 +163,9 @@ public: void update_changed_tree_ui(); void update_undo_buttons(); + void on_back_to_initial_value(); + void on_back_to_sys_value(); + PageShp add_options_page(wxString title, std::string icon, bool is_extruder_pages = false); virtual void OnActivate(){} From 44b711953f89b35cc05444df99a45695390ec942 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 22 Mar 2018 11:46:15 +0100 Subject: [PATCH 0075/1150] Added preset parent description line to Dependencies --- xs/src/slic3r/GUI/Tab.cpp | 31 ++++++++++++++++++++++++++++++- xs/src/slic3r/GUI/Tab.hpp | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 7cb3491f6c..97f496b20d 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -849,6 +849,13 @@ void TabPrint::build() option = optgroup->get_option("compatible_printers_condition"); option.opt.full_width = true; optgroup->append_single_option_line(option); + + line = Line{ "", "" }; + line.full_width = 1; + line.widget = [this](wxWindow* parent) { + return description_line_widget(parent, &m_parent_preset_description_line); + }; + optgroup->append_line(line); } // Reload current config (aka presets->edited_preset->config) into the UI fields. @@ -1216,6 +1223,13 @@ void TabFilament::build() option = optgroup->get_option("compatible_printers_condition"); option.opt.full_width = true; optgroup->append_single_option_line(option); + + line = Line{ "", "" }; + line.full_width = 1; + line.widget = [this](wxWindow* parent) { + return description_line_widget(parent, &m_parent_preset_description_line); + }; + optgroup->append_line(line); } // Reload current config (aka presets->edited_preset->config) into the UI fields. @@ -1504,6 +1518,15 @@ void TabPrinter::build() option.opt.height = 250; optgroup->append_single_option_line(option); + page = add_options_page(_(L("Dependencies")), "wrench.png"); + optgroup = page->new_optgroup(_(L("Profile dependencies"))); + line = Line{ "", "" }; + line.full_width = 1; + line.widget = [this](wxWindow* parent) { + return description_line_widget(parent, &m_parent_preset_description_line); + }; + optgroup->append_line(line); + build_extruder_pages(); if (!m_no_controller) @@ -1692,10 +1715,16 @@ void Tab::load_current_preset() on_preset_loaded(); // Reload preset pages with the new configuration values. reload_config(); - m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ? + const Preset* parent = m_presets->get_selected_preset_parent(); + m_nonsys_btn_icon = parent == nullptr ? "bullet_white.png" : wxMSW ? "sys_unlock.png" : "lock_open.png"; + wxString description_line = parent == nullptr ? + _(L("It's default preset")) : + _(L("Current preset is inherited from")) + ":\n" + parent->name; + m_parent_preset_description_line->SetText(description_line); + // use CallAfter because some field triggers schedule on_change calls using CallAfter, // and we don't want them to be called after this update_dirty() as they would mark the // preset dirty again diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index eaf188df4b..285e4f8fcc 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -121,6 +121,7 @@ public: PresetCollection* m_presets; DynamicPrintConfig* m_config; std::string m_nonsys_btn_icon; + ogStaticText* m_parent_preset_description_line; public: Tab() {} From 036e41ae6952b84c32b93b9a2ce21741542cf7ea Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 22 Mar 2018 13:07:45 +0100 Subject: [PATCH 0076/1150] Wiping dialog - first experiments with sizers --- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 138 +++++++++++++++----------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 8 +- 2 files changed, 84 insertions(+), 62 deletions(-) diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index ac35756a49..1989a82f1e 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -2,6 +2,8 @@ #include #include "WipeTowerDialog.hpp" +#include + //! macro used to mark string used at localization, //! return same string #define L(s) s @@ -22,9 +24,9 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) SetSizer(main_sizer); SetMinSize(GetSize()); main_sizer->SetSizeHints(this); - + this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); - + this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { m_output_data = m_panel_ramming->get_parameters(); EndModal(wxID_OK); @@ -101,74 +103,105 @@ std::string RammingPanel::get_parameters() - +// Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button to toggle simple/advanced mode: WipingDialog::WipingDialog(wxWindow* parent,const std::vector& matrix, const std::vector& extruders) : wxDialog(parent, -1, wxT(L("Wipe tower - Purging volume adjustment")), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { this->Centre(); - - m_panel_wiping = new WipingPanel(this,matrix,extruders); - this->Show(); + + auto widget_button = new wxButton(this,wxID_ANY,"-",wxPoint(0,0),wxDefaultSize); + m_panel_wiping = new WipingPanel(this,matrix,extruders, widget_button); auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(m_panel_wiping, 1, wxEXPAND); + + + main_sizer->Add(widget_button,0,wxALIGN_CENTER_HORIZONTAL|wxCENTER,10); main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); SetSizer(main_sizer); SetMinSize(GetSize()); main_sizer->SetSizeHints(this); - + this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); - this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { - m_output_matrix = m_panel_wiping->read_matrix_values(); - m_output_extruders = m_panel_wiping->read_extruders_values(); + this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { // if OK button is clicked.. + m_output_matrix = m_panel_wiping->read_matrix_values(); // ..query wiping panel and save returned values + m_output_extruders = m_panel_wiping->read_extruders_values(); // so they can be recovered later by calling get_...() EndModal(wxID_OK); },wxID_OK); + + this->Show(); } - -WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders) +// This panel contains all control widgets for both simple and advanced mode (these reside in separate sizers) +WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, wxButton* widget_button) : wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(500,350),wxBORDER_RAISED) { - m_number_of_extruders = (int)(sqrt(matrix.size())+0.001); // number of extruders - m_notadvanced_widgets.push_back(new wxStaticText(this,wxID_ANY,wxString(L("Total purging volume is calculated by summing two values below, depending on which tools are loaded/unloaded.")),wxPoint(40,25) ,wxSize(500,35))); - m_notadvanced_widgets.push_back(new wxStaticText(this,wxID_ANY,wxString(L("Volume to purge (mm\u00B3) when the filament is being")),wxPoint(40,85) ,wxSize(500,25))); - m_notadvanced_widgets.push_back(new wxStaticText(this,wxID_ANY,wxString(L("unloaded")),wxPoint(110,105) ,wxSize(500,25))); - m_notadvanced_widgets.push_back(new wxStaticText(this,wxID_ANY,wxString(L("loaded")),wxPoint(195,105) ,wxSize(500,25))); - m_widget_button = new wxButton(this,wxID_ANY,"-",wxPoint(0,0),wxSize(170,20)); + m_widget_button = widget_button; // pointer to the button in parent dialog + m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){ toggle_advanced(true); }); + + m_number_of_extruders = (int)(sqrt(matrix.size())+0.001); + + m_sizer_simple = new wxBoxSizer(wxVERTICAL); + m_sizer_advanced = new wxBoxSizer(wxVERTICAL); + auto gridsizer_simple = new wxGridSizer(3,10,10); + auto gridsizer_advanced = new wxGridSizer(m_number_of_extruders+1,10,10); + + + // First create controls for simple mode and assign them to m_sizer_simple: + m_sizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("Total purging volume is calculated by summing two values below, depending on which tools are loaded/unloaded.")),wxPoint(40,25), wxSize(450,35)),-1,wxEXPAND,10); + m_sizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("Volume to purge (mm\u00B3) when the filament is being")),wxPoint(40,85) ,/*wxSize(500,25)*/wxDefaultSize,wxALIGN_LEFT),-1,wxEXPAND|wxALIGN_CENTER,10); + + gridsizer_simple->Add(0,-1,wxALL,10); + gridsizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("unloaded")),wxPoint(110,105) ,/*wxSize(80,25)*/wxDefaultSize,wxALIGN_CENTER),-1,wxALIGN_CENTER,10); + gridsizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("loaded")),wxPoint(195,105) ,/*wxSize(80,25)*/wxDefaultSize,wxALIGN_CENTER),-1,wxALIGN_CENTER,10); for (unsigned int i=0;iAdd(new wxStaticText(this,wxID_ANY,wxString(L("Tool #"))<Add(m_old.back(),-1,wxALIGN_CENTER,10); + gridsizer_simple->Add(m_new.back(),-1,wxALIGN_CENTER,10); } + // Now the same for advanced mode: wxPoint origin(50,85); - m_advanced_widgets.push_back(new wxStaticText(this,wxID_ANY,wxString(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")),wxPoint(40,25) ,wxSize(500,35))); + m_sizer_advanced->Add(new wxStaticText(this,wxID_ANY,wxString(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")),wxPoint(40,25) ,/*wxSize(500,35)*/wxDefaultSize),-1,wxALL,10); + m_sizer_advanced->Add(new wxStaticText(this,wxID_ANY,wxString(L("Filament changed to")),origin+wxPoint(75,0) ,/*wxSize(500,25)*/wxDefaultSize),-1,wxALL,10); + for (unsigned int i=0;i(0)); - m_advanced_widgets.push_back(new wxStaticText(this,wxID_ANY,wxString("")<Disable(); else edit_boxes[i][j]->SetValue(wxString("")<Bind(wxEVT_BUTTON,[this](wxCommandEvent&){toggle_advanced(true);}); - toggle_advanced(); + gridsizer_advanced->Add(0,-1,wxALL,10); + for (unsigned int i=0;iAdd(new wxStaticText(this,wxID_ANY,wxString("")<Add(new wxStaticText(this,wxID_ANY,wxString("")<Add(edit_boxes[j][i],-1,wxALL,10); + } + + + m_sizer_simple->Add(gridsizer_simple,-1,wxALL,10); + m_sizer_advanced->Add(gridsizer_advanced,-1,wxALL,10); + toggle_advanced(); // to show/hide what is appropriate } - +// Reads values from the (advanced) wiping matrix: std::vector WipingPanel::read_matrix_values() { if (!m_advanced) fill_in_matrix(); @@ -183,7 +216,7 @@ std::vector WipingPanel::read_matrix_values() { return output; } - +// Reads values from simple mode to save them for next time: std::vector WipingPanel::read_extruders_values() { std::vector output; for (unsigned int i=0;i WipingPanel::read_extruders_values() { return output; } - +// This updates the "advanced" matrix based on values from "simple" mode void WipingPanel::fill_in_matrix() { for (unsigned i=0;i toggle + else { + m_advanced = !advanced_matches_simple(); // if called from constructor, show what is appropriate + (m_advanced ? m_sizer_advanced : m_sizer_simple)->SetSizeHints(this); + SetSizer(m_advanced ? m_sizer_advanced : m_sizer_simple); } - for (unsigned i=0;iShow(m_advanced); - m_old[i]->Show(!m_advanced); - m_new[i]->Show(!m_advanced); - } - for (const auto& widget : m_advanced_widgets) // shows/hides other widgets - widget->Show(m_advanced); - for (const auto& widget : m_notadvanced_widgets) - widget->Show(!m_advanced); + m_sizer_simple->Show(!m_advanced); + m_sizer_advanced->Show(m_advanced); - if (m_advanced) { - if (user_button) fill_in_matrix(); // otherwise keep values loaded from config - m_widget_button->SetLabel(L("Show simplified settings")); - } - else - m_widget_button->SetLabel(L("Show advanced settings")); + m_widget_button->SetLabel(m_advanced ? L("Show simplified settings") : L("Show advanced settings")); + if (m_advanced) + if (user_action) fill_in_matrix(); // otherwise keep values loaded from config this->Refresh(); } \ No newline at end of file diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index 54ae9596d8..c8e7bd480c 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -46,13 +46,13 @@ private: class WipingPanel : public wxPanel { public: - WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders); + WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, wxButton* widget_button); std::vector read_matrix_values(); std::vector read_extruders_values(); + void toggle_advanced(bool user_action = false); private: void fill_in_matrix(); - void toggle_advanced(bool user_button = false); bool advanced_matches_simple(); std::vector m_old; @@ -60,9 +60,11 @@ private: std::vector m_advanced_widgets; std::vector m_notadvanced_widgets; std::vector> edit_boxes; - wxButton* m_widget_button = nullptr; unsigned int m_number_of_extruders = 0; bool m_advanced = false; + wxBoxSizer*m_sizer_simple = nullptr; + wxBoxSizer*m_sizer_advanced = nullptr; + wxButton* m_widget_button = nullptr; }; From 985b414c64ba2c86be36e60b3a3134127b6146bc Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 22 Mar 2018 13:37:01 +0100 Subject: [PATCH 0077/1150] Removed parameter 'wipe_tower_per_color_wipe' from UI and configuration layer --- lib/Slic3r/GUI/Plater.pm | 3 +-- lib/Slic3r/GUI/Plater/3D.pm | 5 +++-- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 2 +- xs/src/libslic3r/Print.cpp | 3 +-- xs/src/libslic3r/PrintConfig.cpp | 9 --------- xs/src/slic3r/GUI/3DScene.cpp | 8 +++++--- xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 3 +-- 8 files changed, 13 insertions(+), 22 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index ad98fdf99b..8a49536035 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -53,8 +53,7 @@ sub new { bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width variable_layer_height serial_port serial_speed octoprint_host octoprint_apikey octoprint_cafile nozzle_diameter single_extruder_multi_material wipe_tower wipe_tower_x wipe_tower_y wipe_tower_width - wipe_tower_per_color_wipe wipe_tower_rotation_angle extruder_colour filament_colour - max_print_height + wipe_tower_rotation_angle extruder_colour filament_colour max_print_height )]); # C++ Slic3r::Model with Perl extensions in Slic3r/Model.pm $self->{model} = Slic3r::Model->new; diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index bd823c730f..00035672f2 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -205,8 +205,9 @@ sub reload_scene { if ($extruders_count > 1 && $self->{config}->single_extruder_multi_material && $self->{config}->wipe_tower && ! $self->{config}->complete_objects) { $self->volumes->load_wipe_tower_preview(1000, - $self->{config}->wipe_tower_x, $self->{config}->wipe_tower_y, - $self->{config}->wipe_tower_width, $self->{config}->wipe_tower_per_color_wipe * ($extruders_count - 1), + $self->{config}->wipe_tower_x, $self->{config}->wipe_tower_y, $self->{config}->wipe_tower_width, + #$self->{config}->wipe_tower_per_color_wipe# 15 * ($extruders_count - 1), # this is just a hack when the config parameter became obsolete + 15 * ($extruders_count - 1), $self->{model}->bounding_box->z_max, $self->{config}->wipe_tower_rotation_angle, $self->UseVBOs); } } diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 734d61dc66..4f97f700f2 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -42,7 +42,7 @@ public: // y -- y coordinates of wipe tower in mm ( left bottom corner ) // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm - WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, float cooling_tube_retraction, + WipeTowerPrusaMM(float x, float y, float width, float rotation_angle, float cooling_tube_retraction, float cooling_tube_length, float parking_pos_retraction, float bridging, const std::vector& wiping_matrix, unsigned int initial_tool) : m_wipe_tower_pos(x, y), diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 62c9c88196..cd66f6f56c 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -199,7 +199,6 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_x.value), float(this->config.wipe_tower_y.value), - float(this->config.wipe_tower_width.value), float(this->config.wipe_tower_per_color_wipe.value), + float(this->config.wipe_tower_width.value), float(this->config.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), float(this->config.wipe_tower_bridging), wiping_volumes, m_tool_ordering.first_extruder()); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index ff426c9a25..cb5bcea4a6 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1818,15 +1818,6 @@ PrintConfigDef::PrintConfigDef() def->cli = "wipe-tower-width=f"; def->default_value = new ConfigOptionFloat(60.); - def = this->add("wipe_tower_per_color_wipe", coFloat); - def->label = "(Unused and will be likely removed)";//L("Per color change depth"); - def->tooltip = L("Depth of a wipe color per color change. For N colors, there will be " - "maximum (N-1) tool switches performed, therefore the total depth " - "of the wipe tower will be (N-1) times this value."); - def->sidetext = L("mm"); - def->cli = "wipe-tower-per-color-wipe=f"; - def->default_value = new ConfigOptionFloat(15.); - def = this->add("wipe_tower_rotation_angle", coFloat); def->label = L("Wipe tower rotation angle"); def->tooltip = L("Wipe tower rotation angle with respect to x-axis "); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 994c62a83c..cbaa4ac908 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -2588,8 +2588,10 @@ void _3DScene::_load_shells(const Print& print, GLVolumeCollection& volumes, boo coordf_t max_z = print.objects[0]->model_object()->get_model()->bounding_box().max.z; const PrintConfig& config = print.config; unsigned int extruders_count = config.nozzle_diameter.size(); - if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects) - volumes.load_wipe_tower_preview(1000, config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, config.wipe_tower_per_color_wipe * (extruders_count - 1), max_z, config.wipe_tower_rotation_angle, use_VBOs); + if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects) { + const float width_per_extruder = 15.f; // a simple workaround after wipe_tower_per_color_wipe got obsolete + volumes.load_wipe_tower_preview(1000, config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, width_per_extruder * (extruders_count - 1), max_z, config.wipe_tower_rotation_angle, use_VBOs); + } } -} +} // namespace Slic3r diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 99d003f7a9..a0d4fe5ff1 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -199,7 +199,7 @@ const std::vector& Preset::print_options() "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", - "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_bridging", + "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging", "wiping_volumes_matrix", "wiping_volumes_extruders", "compatible_printers", "compatible_printers_condition" }; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 146696d1ea..9716abfb46 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -517,7 +517,6 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_x"); optgroup->append_single_option_line("wipe_tower_y"); optgroup->append_single_option_line("wipe_tower_width"); - optgroup->append_single_option_line("wipe_tower_per_color_wipe"); optgroup->append_single_option_line("wipe_tower_rotation_angle"); optgroup->append_single_option_line("wipe_tower_bridging"); line = { _(L("Advanced")), "" }; @@ -863,7 +862,7 @@ void TabPrint::update() bool have_wipe_tower = m_config->opt_bool("wipe_tower"); vec_enable.resize(0); - vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_bridging"}; + vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging"}; for (auto el : vec_enable) get_field(el)->toggle(have_wipe_tower); m_wipe_tower_btn->Enable(have_wipe_tower); From 4b8bd48663106c133914d4a89c80d89d57fe7ed7 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 22 Mar 2018 13:49:48 +0100 Subject: [PATCH 0078/1150] AMF and 3MF export - Export of print config customizable by user in the select file dialog --- lib/Slic3r/GUI/Plater.pm | 6 +++-- xs/src/libslic3r/Format/3mf.cpp | 25 ++++++++++-------- xs/src/libslic3r/Format/3mf.hpp | 2 +- xs/src/libslic3r/Format/AMF.cpp | 14 +++++----- xs/src/libslic3r/Format/AMF.hpp | 2 +- xs/src/slic3r/GUI/GUI.cpp | 45 +++++++++++++++++++++++++++++++++ xs/src/slic3r/GUI/GUI.hpp | 3 +++ xs/xsp/GUI.xsp | 7 +++++ xs/xsp/Model.xsp | 8 +++--- 9 files changed, 87 insertions(+), 25 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d3513897f3..1b26857e92 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1560,7 +1560,7 @@ sub export_amf { return if !@{$self->{objects}}; # Ask user for a file name to write into. my $output_file = $self->_get_export_file('AMF') or return; - my $res = $self->{model}->store_amf($output_file, $self->{print}); + my $res = $self->{model}->store_amf($output_file, $self->{print}, $self->{export_option}); if ($res) { $self->statusbar->SetStatusText(L("AMF file exported to ").$output_file); @@ -1576,7 +1576,7 @@ sub export_3mf { return if !@{$self->{objects}}; # Ask user for a file name to write into. my $output_file = $self->_get_export_file('3MF') or return; - my $res = $self->{model}->store_3mf($output_file, $self->{print}); + my $res = $self->{model}->store_3mf($output_file, $self->{print}, $self->{export_option}); if ($res) { $self->statusbar->SetStatusText(L("3MF file exported to ").$output_file); @@ -1618,11 +1618,13 @@ sub _get_export_file { $output_file =~ s/\.[gG][cC][oO][dD][eE]$/$suffix/; my $dlg = Wx::FileDialog->new($self, L("Save ").$format.L(" file as:"), dirname($output_file), basename($output_file), &Slic3r::GUI::FILE_WILDCARDS->{$wildcard}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + Slic3r::GUI::add_export_option($dlg, $format); if ($dlg->ShowModal != wxID_OK) { $dlg->Destroy; return undef; } $output_file = $dlg->GetPath; + $self->{export_option} = Slic3r::GUI::get_export_option($dlg); $dlg->Destroy; return $output_file; } diff --git a/xs/src/libslic3r/Format/3mf.cpp b/xs/src/libslic3r/Format/3mf.cpp index b34b8989e7..89f9b277fc 100644 --- a/xs/src/libslic3r/Format/3mf.cpp +++ b/xs/src/libslic3r/Format/3mf.cpp @@ -1443,10 +1443,10 @@ namespace Slic3r { IdToObjectDataMap m_objects_data; public: - bool save_model_to_file(const std::string& filename, Model& model, const Print& print); + bool save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config); private: - bool _save_model_to_file(const std::string& filename, Model& model, const Print& print); + bool _save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config); bool _add_content_types_file_to_archive(mz_zip_archive& archive); bool _add_relationships_file_to_archive(mz_zip_archive& archive); bool _add_model_file_to_archive(mz_zip_archive& archive, Model& model); @@ -1457,13 +1457,13 @@ namespace Slic3r { bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model); }; - bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const Print& print) + bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config) { clear_errors(); - return _save_model_to_file(filename, model, print); + return _save_model_to_file(filename, model, print, export_print_config); } - bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const Print& print) + bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config) { mz_zip_archive archive; mz_zip_zero_struct(&archive); @@ -1502,11 +1502,14 @@ namespace Slic3r { } // adds slic3r print config file - if (!_add_print_config_file_to_archive(archive, print)) + if (export_print_config) { - mz_zip_writer_end(&archive); - boost::filesystem::remove(filename); - return false; + if (!_add_print_config_file_to_archive(archive, print)) + { + mz_zip_writer_end(&archive); + boost::filesystem::remove(filename); + return false; + } } // adds slic3r model config file @@ -1863,13 +1866,13 @@ namespace Slic3r { return res; } - bool store_3mf(const char* path, Model* model, Print* print) + bool store_3mf(const char* path, Model* model, Print* print, bool export_print_config) { if ((path == nullptr) || (model == nullptr) || (print == nullptr)) return false; _3MF_Exporter exporter; - bool res = exporter.save_model_to_file(path, *model, *print); + bool res = exporter.save_model_to_file(path, *model, *print, export_print_config); if (!res) exporter.log_errors(); diff --git a/xs/src/libslic3r/Format/3mf.hpp b/xs/src/libslic3r/Format/3mf.hpp index 9b48c860b8..85bc812e38 100644 --- a/xs/src/libslic3r/Format/3mf.hpp +++ b/xs/src/libslic3r/Format/3mf.hpp @@ -12,7 +12,7 @@ namespace Slic3r { // Save the given model and the config data contained in the given Print into a 3mf file. // The model could be modified during the export process if meshes are not repaired or have no shared vertices - extern bool store_3mf(const char* path, Model* model, Print* print); + extern bool store_3mf(const char* path, Model* model, Print* print, bool export_print_config); }; // namespace Slic3r diff --git a/xs/src/libslic3r/Format/AMF.cpp b/xs/src/libslic3r/Format/AMF.cpp index a52dd532ae..8c08b46731 100644 --- a/xs/src/libslic3r/Format/AMF.cpp +++ b/xs/src/libslic3r/Format/AMF.cpp @@ -576,8 +576,7 @@ bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model) return false; } - std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf"); - if (internal_amf_filename != stat.m_filename) + if (!boost::iends_with(stat.m_filename, ".amf")) { printf("Found invalid internal filename\n"); mz_zip_reader_end(&archive); @@ -644,7 +643,7 @@ bool load_amf(const char *path, PresetBundle* bundle, Model *model) return false; } -bool store_amf(const char *path, Model *model, Print* print) +bool store_amf(const char *path, Model *model, Print* print, bool export_print_config) { if ((path == nullptr) || (model == nullptr) || (print == nullptr)) return false; @@ -661,9 +660,12 @@ bool store_amf(const char *path, Model *model, Print* print) stream << "\n"; stream << "Slic3r " << SLIC3R_VERSION << "\n"; - std::string config = "\n"; - GCode::append_full_config(*print, config); - stream << "" << config << "\n"; + if (export_print_config) + { + std::string config = "\n"; + GCode::append_full_config(*print, config); + stream << "" << config << "\n"; + } for (const auto &material : model->materials) { if (material.first.empty()) diff --git a/xs/src/libslic3r/Format/AMF.hpp b/xs/src/libslic3r/Format/AMF.hpp index 027ebdab31..4779e9a51c 100644 --- a/xs/src/libslic3r/Format/AMF.hpp +++ b/xs/src/libslic3r/Format/AMF.hpp @@ -12,7 +12,7 @@ extern bool load_amf(const char *path, PresetBundle* bundle, Model *model); // Save the given model and the config data contained in the given Print into an amf file. // The model could be modified during the export process if meshes are not repaired or have no shared vertices -extern bool store_amf(const char *path, Model *model, Print* print); +extern bool store_amf(const char *path, Model *model, Print* print, bool export_print_config); }; // namespace Slic3r diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 0410b7969c..4548526394 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -686,4 +686,49 @@ ConfigOptionsGroup* get_optgroup() return m_optgroup.get(); } +wxWindow* export_option_creator(wxWindow* parent) +{ + wxPanel* panel = new wxPanel(parent, -1); + wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + wxCheckBox* cbox = new wxCheckBox(panel, wxID_HIGHEST + 1, L("Export print config")); + sizer->AddSpacer(5); + sizer->Add(cbox, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5); + panel->SetSizer(sizer); + sizer->SetSizeHints(panel); + return panel; +} + +void add_export_option(wxFileDialog* dlg, const std::string& format) +{ + if ((dlg != nullptr) && (format == "AMF") || (format == "3MF")) + { + if (dlg->SupportsExtraControl()) + dlg->SetExtraControlCreator(export_option_creator); + } +} + +int get_export_option(wxFileDialog* dlg) +{ + if (dlg != nullptr) + { + wxWindow* wnd = dlg->GetExtraControl(); + if (wnd != nullptr) + { + wxPanel* panel = dynamic_cast(wnd); + if (panel != nullptr) + { + wxWindow* child = panel->FindWindow(wxID_HIGHEST + 1); + if (child != nullptr) + { + wxCheckBox* cbox = dynamic_cast(child); + if (cbox != nullptr) + return cbox->IsChecked() ? 1 : 0; + } + } + } + } + + return 0; +} + } } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 084b6de466..7b23702b20 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -18,6 +18,7 @@ class wxArrayLong; class wxColour; class wxBoxSizer; class wxFlexGridSizer; +class wxFileDialog; namespace Slic3r { @@ -130,6 +131,8 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl ConfigOptionsGroup* get_optgroup(); +void add_export_option(wxFileDialog* dlg, const std::string& format); +int get_export_option(wxFileDialog* dlg); } } diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index d306f12ce5..1376ff164b 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -67,3 +67,10 @@ void add_frequently_changed_parameters(SV *ui_parent, SV *ui_sizer, SV *ui_p_siz std::string fold_utf8_to_ascii(const char *src) %code%{ RETVAL = Slic3r::fold_utf8_to_ascii(src); %}; + +void add_export_option(SV *ui, std::string format) + %code%{ Slic3r::GUI::add_export_option((wxFileDialog*)wxPli_sv_2_object(aTHX_ ui, "Wx::FileDialog"), format); %}; + +int get_export_option(SV *ui) + %code%{ RETVAL = Slic3r::GUI::get_export_option((wxFileDialog*)wxPli_sv_2_object(aTHX_ ui, "Wx::FileDialog")); %}; + \ No newline at end of file diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp index 78c94661e9..7028395373 100644 --- a/xs/xsp/Model.xsp +++ b/xs/xsp/Model.xsp @@ -104,10 +104,10 @@ bool store_stl(char *path, bool binary) %code%{ TriangleMesh mesh = THIS->mesh(); RETVAL = Slic3r::store_stl(path, &mesh, binary); %}; - bool store_amf(char *path, Print* print) - %code%{ RETVAL = Slic3r::store_amf(path, THIS, print); %}; - bool store_3mf(char *path, Print* print) - %code%{ RETVAL = Slic3r::store_3mf(path, THIS, print); %}; + bool store_amf(char *path, Print* print, bool export_print_config) + %code%{ RETVAL = Slic3r::store_amf(path, THIS, print, export_print_config); %}; + bool store_3mf(char *path, Print* print, bool export_print_config) + %code%{ RETVAL = Slic3r::store_3mf(path, THIS, print, export_print_config); %}; %{ From 57b61470a3a0736d801bd49697100ea0b924e243 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 22 Mar 2018 14:12:29 +0100 Subject: [PATCH 0079/1150] "Advanced" options alignment --- xs/src/slic3r/GUI/Tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 97f496b20d..fd3e6efe25 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -784,7 +784,7 @@ void TabPrint::build() optgroup->append_single_option_line("interface_shells"); page = add_options_page(_(L("Advanced")), "wrench.png"); - optgroup = page->new_optgroup(_(L("Extrusion width")), 180); + optgroup = page->new_optgroup(_(L("Extrusion width"))); optgroup->append_single_option_line("extrusion_width"); optgroup->append_single_option_line("first_layer_extrusion_width"); optgroup->append_single_option_line("perimeter_extrusion_width"); From 1c5970d0a2ea0a4fde1af36502ea93b577208504 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 22 Mar 2018 15:16:30 +0100 Subject: [PATCH 0080/1150] Added sys_lock and sys_unlock icons. --- resources/icons/sys_lock.png | Bin 0 -> 448 bytes resources/icons/sys_unlock.png | Bin 0 -> 454 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 resources/icons/sys_lock.png create mode 100644 resources/icons/sys_unlock.png diff --git a/resources/icons/sys_lock.png b/resources/icons/sys_lock.png new file mode 100644 index 0000000000000000000000000000000000000000..0519c44a17c8f8f30b5f0a5b558e4bd71dfc13d6 GIT binary patch literal 448 zcmV;x0YCnUP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGmbN~PnbOGLGA9w%&0aZyvK~y+Tg_F<9 zfzy-m&y3pR zAJnkh?XcNwa6X@57zTR19ww7X{`E<%zqL!1Y*~qEaA95?rrWn5LOWUNoCc zoKB~FR8s;4j>jWx+s-2|_WQk*I2a6M{2}1`z9cmo4M{BPGp^p#>9iZfTc6W-&xuH$~cSDUC{LZ{QgY&Me<;R0oT3iSJZ=?{lP*+rSJ z0xV~>T1lVg@(9a(6;K|K@@Xgv0#!+^Rtt;80&yIRaqlp{5TRlGVOYCrgqMoRY${Ge qDgJShq9~G!#O>F?DV*#$4*metbIFXR3JD(o0000Px#1ZP1_K>z@;j|==^1poj532;bRa{vGmbN~PnbOGLGA9w%&0b5B#K~y+TjgzsC zgD?z+9T-3?l{!@{ofsIpl!;fU)V&Mu#KOb_@Dj{CK-nuHQ89HxLQp6dyCj$N?t1+s z%TD6_HL=U4X_`5JFvb95(==(_G!3+E3!dlE8qXe&hs;9{<2cT$Az7B8qGnMP(HR%e z@-+b@j$?Vrb=^4#0=ae^hjOs$9|8iAoagznGt>Egzn_bukZWO@K$0YM`E)wbT0Ikp zJz)mFAgSw`d>Dr01-xWwuV@1I`#`?yI`Y_!zf8cW48x$doX=;tTrS}IK5RA{{JbUY z8*HO(+pt=#o)w`0lBTJA!2fKw+tD5E4S0*l<8aV`aIiAoN{ZF}^?FSn(ca*dvMk|x zy;977kUS!UkhcQ-v!JRfiq%W1*js_)@d(@Pmg0{qz(kRJI2^#TEQ%4a|7!)J_bPqg w!!SH&L*;h6EfKE<{}`yK4#y|p3^2yv3&cNQZ!+1pRR91007*qoM6N<$f|!5CDgXcg literal 0 HcmV?d00001 From 3fdd182f0c74366f4e164d65059b516b2616dec5 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 22 Mar 2018 16:13:41 +0100 Subject: [PATCH 0081/1150] Parameters describing cooling tubes position etc moved to separate page in Printer Settings --- xs/src/slic3r/GUI/Tab.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 9716abfb46..267e579b6b 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1099,7 +1099,7 @@ void TabPrinter::build() optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value){ size_t extruders_count = boost::any_cast(optgroup->get_value("extruders_count")); wxTheApp->CallAfter([this, opt_key, value, extruders_count](){ - if (opt_key.compare("extruders_count")==0) { + if (opt_key.compare("extruders_count")==0 || opt_key.compare("single_extruder_multi_material")==0) { extruders_count_changed(extruders_count); update_dirty(); } @@ -1110,6 +1110,7 @@ void TabPrinter::build() }); }; + if (!m_no_controller) { optgroup = page->new_optgroup(_(L("USB/Serial connection"))); @@ -1249,9 +1250,6 @@ void TabPrinter::build() optgroup->append_single_option_line("use_firmware_retraction"); optgroup->append_single_option_line("use_volumetric_e"); optgroup->append_single_option_line("variable_layer_height"); - optgroup->append_single_option_line("cooling_tube_retraction"); - optgroup->append_single_option_line("cooling_tube_length"); - optgroup->append_single_option_line("parking_pos_retraction"); page = add_options_page(_(L("Custom G-code")), "cog.png"); optgroup = page->new_optgroup(_(L("Start G-code")), 0); @@ -1374,6 +1372,25 @@ void TabPrinter::build_extruder_pages(){ for (auto page_extruder : m_extruder_pages) m_pages.push_back(page_extruder); m_pages.push_back(page_note); + + { + // if we have a single extruder MM setup, add a page with configuration options: + for (int i=0;ititle().find(_(L("Single extruder MM setup"))) != std::string::npos) { + m_pages.erase(m_pages.begin()+i); + break; + } + if ( m_extruder_pages.size()>1 && m_config->opt_bool("single_extruder_multi_material")) { + // create a page, but pretend it's an extruder page, so we can add it to m_pages ourselves + auto page = add_options_page(_(L("Single extruder MM setup")), "printer_empty.png",true); + auto optgroup = page->new_optgroup(_(L("Single extruder multimaterial parameters"))); + optgroup->append_single_option_line("cooling_tube_retraction"); + optgroup->append_single_option_line("cooling_tube_length"); + optgroup->append_single_option_line("parking_pos_retraction"); + m_pages.insert(m_pages.begin()+1,page); + } + } + rebuild_page_tree(); } From 53e100b89087121565e64f3e3bd96dd935452037 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 23 Mar 2018 09:41:04 +0100 Subject: [PATCH 0082/1150] Changed PrusaResearch.ini. *(Uncommented "printer_model","printer_vendor", "printer_variant", "default_filament_profile") * Added msg "It's system preset" to Dependencies --- resources/profiles/PrusaResearch.ini | 32 ++++++++++++++-------------- xs/src/slic3r/GUI/Tab.cpp | 12 ++++++----- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 43d2ecbd15..fa4d48cdae 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -909,10 +909,10 @@ use_volumetric_e = 0 variable_layer_height = 1 wipe = 1 z_offset = 0 -#printer_model = MK2S -#printer_variant = 0.4 -#default_print_profile = 0.15mm OPTIMAL -#default_filament_profile = Prusa PLA +printer_model = MK2S +printer_variant = 0.4 +default_print_profile = 0.15mm OPTIMAL +default_filament_profile = Prusa PLA [printer:*multimaterial*] inherits = *common* @@ -928,7 +928,7 @@ retract_restart_extra = 0 retract_restart_extra_toolchange = 0 retract_speed = 80 single_extruder_multi_material = 1 -#printer_model = MK2SMM +printer_model = MK2SMM [printer:*mm-single*] inherits = *multimaterial* @@ -956,15 +956,15 @@ nozzle_diameter = 0.25 retract_length = 1 retract_speed = 50 variable_layer_height = 0 -#printer_variant = 0.25 -#default_print_profile = 0.10mm DETAIL 0.25 nozzle +printer_variant = 0.25 +default_print_profile = 0.10mm DETAIL 0.25 nozzle [printer:Original Prusa i3 MK2 0.6 nozzle] inherits = *common* max_layer_height = 0.35 min_layer_height = 0.1 nozzle_diameter = 0.6 -#printer_variant = 0.6 +printer_variant = 0.6 [printer:Original Prusa i3 MK2 MM Single Mode] inherits = *mm-single* @@ -972,7 +972,7 @@ inherits = *mm-single* [printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle] inherits = *mm-single* nozzle_diameter = 0.6 -#printer_variant = 0.6 +printer_variant = 0.6 [printer:Original Prusa i3 MK2 MultiMaterial] inherits = *mm-multi* @@ -981,7 +981,7 @@ nozzle_diameter = 0.4,0.4,0.4,0.4 [printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle] inherits = *mm-multi* nozzle_diameter = 0.6,0.6,0.6,0.6 -#printer_variant = 0.6 +printer_variant = 0.6 [printer:Original Prusa i3 MK3] inherits = *common* @@ -989,8 +989,8 @@ end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} -#printer_model = MK3 -#default_print_profile = 0.15mm OPTIMAL MK3 +printer_model = MK3 +default_print_profile = 0.15mm OPTIMAL MK3 [printer:Original Prusa i3 MK3 0.25 nozzle] inherits = *common* @@ -999,8 +999,8 @@ end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} -#printer_model = MK3 -#default_print_profile = 0.10mm DETAIL MK3 +printer_model = MK3 +default_print_profile = 0.10mm DETAIL MK3 [printer:Original Prusa i3 MK3 0.6 nozzle] inherits = *common* @@ -1009,8 +1009,8 @@ end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} -#printer_model = MK3 -#default_print_profile = 0.15mm OPTIMAL MK3 +printer_model = MK3 +default_print_profile = 0.15mm OPTIMAL MK3 [presets] print = 0.15mm OPTIMAL MK3 diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 26cf74d552..ac972f9e46 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -617,6 +617,13 @@ void Tab::on_presets_changed() event.SetString(m_name); g_wxMainFrame->ProcessWindowEvent(event); } + + const Preset* parent = m_presets->get_selected_preset_parent(); + const wxString description_line = parent == nullptr ? + _(L("It's default preset")) : parent == &m_presets->get_selected_preset() ? + _(L("It's system preset")) : + _(L("Current preset is inherited from")) + ":\n" + parent->name; + m_parent_preset_description_line->SetText(description_line); } void Tab::update_frequently_changed_parameters() @@ -1727,11 +1734,6 @@ void Tab::load_current_preset() "bullet_white.png" : wxMSW ? "sys_unlock.png" : "lock_open.png"; - wxString description_line = parent == nullptr ? - _(L("It's default preset")) : - _(L("Current preset is inherited from")) + ":\n" + parent->name; - m_parent_preset_description_line->SetText(description_line); - // use CallAfter because some field triggers schedule on_change calls using CallAfter, // and we don't want them to be called after this update_dirty() as they would mark the // preset dirty again From 77f5ed68511232b62050e4f2dc827d991a759acb Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 23 Mar 2018 12:52:37 +0100 Subject: [PATCH 0083/1150] Fixed bugs from SPE-180 --- xs/src/libslic3r/PrintConfig.cpp | 2 +- xs/src/slic3r/GUI/Field.cpp | 3 ++- xs/src/slic3r/GUI/OptionsGroup.cpp | 5 +++-- xs/src/slic3r/GUI/Preset.cpp | 8 -------- xs/src/slic3r/GUI/Tab.cpp | 19 +++++++------------ 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index a49124f879..657e5a4520 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1041,7 +1041,7 @@ PrintConfigDef::PrintConfigDef() def->multiline = true; def->full_width = true; def->height = 60; - def->default_value = new ConfigOptionStrings{ "" }; + def->default_value = new ConfigOptionStrings(); def = this->add("printer_model", coString); def->label = L("Printer type"); diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 9bb5f13e59..70a8b84cf1 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -404,6 +404,7 @@ void Choice::set_value(boost::any value, bool change_event) case coInt: case coFloat: case coPercent: + case coString: case coStrings:{ wxString text_value; if (m_opt.type == coInt) @@ -417,7 +418,6 @@ void Choice::set_value(boost::any value, bool change_event) break; ++idx; } -// if (m_opt.type == coPercent) text_value += "%"; idx == m_opt.enum_values.size() ? dynamic_cast(window)->SetValue(text_value) : dynamic_cast(window)->SetSelection(idx); @@ -446,6 +446,7 @@ void Choice::set_values(const std::vector values) auto ww = dynamic_cast(window); auto value = ww->GetValue(); ww->Clear(); + ww->Append(""); for (auto el : values) ww->Append(wxString(el)); ww->SetValue(value); diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 3a97c98c7b..2c055c9dd5 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -406,8 +406,9 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config ret = text_value; else if (opt->gui_flags.compare("serialized") == 0){ std::vector values = config.option(opt_key)->values; - for (auto el : values) - text_value += el + ";"; + if (!values.empty() && values[0].compare("") != 0) + for (auto el : values) + text_value += el + ";"; ret = text_value; } else diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index a5ab65c9fe..c437f8b414 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -584,14 +584,6 @@ std::vector PresetCollection::system_equal_options() const std::vector equal; if (edited != nullptr && reference != nullptr) { equal = reference->config.equal(edited->config); - // The "compatible_printers" option key is handled differently from the others: - // It is not mandatory. If the key is missing, it means it is compatible with any printer. - // If the key exists and it is empty, it means it is compatible with no printer. - std::initializer_list optional_keys{ "compatible_printers", "compatible_printers_condition" }; - for (auto &opt_key : optional_keys) { - if (reference->config.has(opt_key) == edited->config.has(opt_key)) - equal.emplace_back(opt_key); - } } return equal; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ac972f9e46..e15ffa8c2c 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -225,11 +225,6 @@ void Tab::update_changed_ui() m_sys_options.resize(0); const auto sys_preset = m_presets->get_selected_preset_parent(); if (sys_preset){ - std::initializer_list optional_keys{"compatible_printers", "compatible_printers_condition" }; - for (auto &opt_key : optional_keys) { - if (m_config->has(opt_key) == sys_preset->config.has(opt_key)) - m_sys_options.emplace_back(opt_key); - } for (auto opt_key : m_config->keys()) { if (opt_key == "bed_shape"){ m_sys_options.emplace_back(opt_key); continue; } @@ -241,7 +236,13 @@ void Tab::update_changed_ui() case coStrings: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; case coPercents:add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; case coPoints: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; - default: m_sys_options.emplace_back(opt_key); break; + default:{ + const ConfigOption *opt_cur = tab->m_config->option(opt_key); + const ConfigOption *opt_sys = sys_preset->config.option(opt_key); + if (opt_cur != nullptr && opt_sys != nullptr && *opt_cur == *opt_sys) + m_sys_options.emplace_back(opt_key); + break; + } } } @@ -358,12 +359,6 @@ void Tab::update_full_options_list() } } m_full_options_list.emplace_back("extruders_count"); - - std::initializer_list optional_keys{ "compatible_printers", "compatible_printers_condition" }; - for (auto &opt_key : optional_keys) { - if (m_config->has(opt_key)) - m_full_options_list.emplace_back(opt_key); - } } void Tab::update_sys_ui_after_sel_preset() From c6623bb2583a05dece819bd533d378533c51e16b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 23 Mar 2018 15:40:26 +0100 Subject: [PATCH 0084/1150] Increased camera theta max to 180 degrees. Fixes #666 --- lib/Slic3r/GUI/3DScene.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 75a154281f..c00484fde6 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -96,7 +96,7 @@ use constant MANIPULATION_IDLE => 0; use constant MANIPULATION_DRAGGING => 1; use constant MANIPULATION_LAYER_HEIGHT => 2; -use constant GIMBALL_LOCK_THETA_MAX => 170; +use constant GIMBALL_LOCK_THETA_MAX => 180; use constant VARIABLE_LAYER_THICKNESS_BAR_WIDTH => 70; use constant VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT => 22; From e7edb512b81abab0ea9188a55d44c181a42fefee Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 23 Mar 2018 17:27:43 +0100 Subject: [PATCH 0085/1150] Saved bed_shape changes. *code review --- xs/src/slic3r/GUI/BedShapeDialog.cpp | 3 +- xs/src/slic3r/GUI/GUI.cpp | 7 +- xs/src/slic3r/GUI/OptionsGroup.cpp | 10 ++- xs/src/slic3r/GUI/Tab.cpp | 124 ++++++++++++--------------- 4 files changed, 71 insertions(+), 73 deletions(-) diff --git a/xs/src/slic3r/GUI/BedShapeDialog.cpp b/xs/src/slic3r/GUI/BedShapeDialog.cpp index 51dbd6a272..24d84a7df7 100644 --- a/xs/src/slic3r/GUI/BedShapeDialog.cpp +++ b/xs/src/slic3r/GUI/BedShapeDialog.cpp @@ -183,7 +183,8 @@ void BedShapePanel::set_shape(ConfigOptionPoints* points) vertex_distances.push_back(distance); avg_dist += distance; } - + + avg_dist /= vertex_distances.size(); bool defined_value = true; for (auto el: vertex_distances) { diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 4dea4965a5..7e0296121d 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -428,8 +428,7 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b std::vector values = boost::any_cast>(value); if (values.size() == 1 && values[0] == "") break; - for (auto el : values) - config.option(opt_key)->values.push_back(el); + config.option(opt_key)->values = values; } else{ ConfigOptionStrings* vec_new = new ConfigOptionStrings{ boost::any_cast(value) }; @@ -465,6 +464,10 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b } break; case coPoints:{ + if (opt_key.compare("bed_shape") == 0){ + config.option(opt_key)->values = boost::any_cast>(value); + break; + } ConfigOptionPoints* vec_new = new ConfigOptionPoints{ boost::any_cast(value) }; config.option(opt_key)->set_at(vec_new, opt_index, 0); } diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 2c055c9dd5..24e1ddf2eb 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -327,8 +327,11 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, int opt_index = m_opt_map.at(opt_id).second; value = get_config_value(config, opt_short_key, opt_index); } - else + else{ value = get_config_value(config, opt_key); + change_opt_value(*m_config, opt_key, value); + return; + } set_value(opt_key, value); on_change_OG(opt_key, get_value(opt_key)); @@ -442,7 +445,10 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config } break; case coPoints: - ret = config.option(opt_key)->get_at(idx); + if (opt_key.compare("bed_shape") == 0) + ret = config.option(opt_key)->values; + else + ret = config.option(opt_key)->get_at(idx); break; case coNone: default: diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index e15ffa8c2c..babff7d801 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -203,31 +203,34 @@ void Tab::update_changed_ui() if (name() == "printer"){ // Update dirty_options in case changes of Extruder's options TabPrinter* tab = static_cast(this); - std::vector new_options; + m_dirty_options.resize(0); for (auto opt_key : dirty_options) { + if (opt_key == "bed_shape"){ m_dirty_options.emplace_back(opt_key); continue; } switch (m_config->option(opt_key)->type()) { - case coInts: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; - case coBools: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; - case coFloats: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; - case coStrings: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; - case coPercents:add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; - case coPoints: add_correct_opts_to_dirty_options(opt_key, &new_options, tab); break; - default: new_options.emplace_back(opt_key); break; + case coInts: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; + case coBools: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; + case coFloats: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; + case coStrings: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; + case coPercents:add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; + case coPoints: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; + default: m_dirty_options.emplace_back(opt_key); break; } } - dirty_options.resize(0); - dirty_options = new_options; if (tab->m_initial_extruders_count != tab->m_extruders_count) - dirty_options.emplace_back("extruders_count"); + m_dirty_options.emplace_back("extruders_count"); m_sys_options.resize(0); const auto sys_preset = m_presets->get_selected_preset_parent(); if (sys_preset){ for (auto opt_key : m_config->keys()) { - if (opt_key == "bed_shape"){ m_sys_options.emplace_back(opt_key); continue; } + if (opt_key == "bed_shape"){ + if (*tab->m_config->option(opt_key) == *sys_preset->config.option(opt_key)) + m_sys_options.emplace_back(opt_key); + continue; + } switch (m_config->option(opt_key)->type()) { case coInts: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; @@ -250,67 +253,38 @@ void Tab::update_changed_ui() m_sys_options.emplace_back("extruders_count"); } } - else + else{ m_sys_options = m_presets->system_equal_options(); - - // Add new dirty options to m_dirty_options - for (auto opt_key : dirty_options){ - Field* field = get_field(opt_key); - if (field != nullptr && - find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()){ - // use bouth of temporary_icons till don't have "undo_icon" - field->m_Undo_btn->SetBitmap(wxBitmap(from_u8(wxMSW ? var("action_undo.png") : var("arrow_undo.png")), wxBITMAP_TYPE_PNG)); - field->m_is_modified_value = true; - - m_dirty_options.push_back(opt_key); - } - - if (field != nullptr && field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(*get_modified_label_clr()); - field->m_Label->Refresh(true); - } + m_dirty_options = dirty_options; } - // Delete clear options from m_dirty_options - for (auto i = 0; i < m_dirty_options.size(); ++i) - { - const std::string &opt_key = m_dirty_options[i]; - Field* field = get_field(opt_key); - if (field != nullptr && find(dirty_options.begin(), dirty_options.end(), opt_key) == dirty_options.end()) - { - field->m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); - if (field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); - field->m_Label->Refresh(true); - } - field->m_is_modified_value = false; - std::vector::iterator itr = find(m_dirty_options.begin(), m_dirty_options.end(), opt_key); - if (itr != m_dirty_options.end()){ - m_dirty_options.erase(itr); - --i; - } - } - } - - //update system options (colored in green) + //update options "decoration" for (const auto opt_key : m_full_options_list) { - Field* field = get_field(opt_key); - if (field == nullptr) continue; - std::string icon = wxMSW ? "sys_lock.png" : "lock.png"; + bool is_nonsys_value = false; + bool is_modified_value = true; + std::string sys_icon = wxMSW ? "sys_lock.png" : "lock.png"; + std::string icon = wxMSW ? "action_undo.png" : "arrow_undo.png"; wxColour& color = *get_sys_label_clr(); - if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) != m_sys_options.end()) { - field->m_is_nonsys_value = false; - } - else { - field->m_is_nonsys_value = true; - icon = m_nonsys_btn_icon; + if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { + is_nonsys_value = true; + sys_icon = m_nonsys_btn_icon; if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) color = wxSYS_COLOUR_WINDOWTEXT; else color = *get_modified_label_clr(); } - field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(icon)), wxBITMAP_TYPE_PNG)); + if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) + { + is_modified_value = false; + icon = "bullet_white.png"; + } + Field* field = get_field(opt_key); + if (field == nullptr) continue; + field->m_is_nonsys_value = is_nonsys_value; + field->m_is_modified_value = is_modified_value; + field->m_Undo_btn->SetBitmap(wxBitmap(from_u8(var(icon)), wxBITMAP_TYPE_PNG)); + field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(sys_icon)), wxBITMAP_TYPE_PNG)); if (field->m_Label != nullptr){ field->m_Label->SetForegroundColour(color); field->m_Label->Refresh(true); @@ -391,10 +365,13 @@ void Tab::update_changed_tree_ui() bool sys_page = true; bool modified_page = false; if (title == _("General")){ - if (sys_page && find(m_sys_options.begin(), m_sys_options.end(), "extruders_count") == m_sys_options.end()) - sys_page = false; - if (!modified_page && find(m_dirty_options.begin(), m_dirty_options.end(), "extruders_count") != m_dirty_options.end()) - modified_page = true; + std::initializer_list optional_keys{ "extruders_count", "bed_shape" }; + for (auto &opt_key : optional_keys) { + if (sys_page && find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) + sys_page = false; + if (!modified_page && find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) + modified_page = true; + } } for (auto group : page->m_optgroups) { @@ -453,6 +430,10 @@ void Tab::on_back_to_initial_value() if (find(m_dirty_options.begin(), m_dirty_options.end(), "extruders_count") != m_dirty_options.end()) group->back_to_initial_value("extruders_count"); } + if (group->title == _("Size and coordinates")){ + if (find(m_dirty_options.begin(), m_dirty_options.end(), "bed_shape") != m_dirty_options.end()) + group->back_to_initial_value("bed_shape"); + } for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { const std::string& opt_key = it->first; if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) @@ -461,7 +442,7 @@ void Tab::on_back_to_initial_value() } break; } - + update_changed_ui(); } void Tab::on_back_to_sys_value() @@ -476,6 +457,10 @@ void Tab::on_back_to_sys_value() if (find(m_sys_options.begin(), m_sys_options.end(), "extruders_count") == m_sys_options.end()) group->back_to_sys_value("extruders_count"); } + if (group->title == _("Size and coordinates")){ + if (find(m_sys_options.begin(), m_sys_options.end(), "bed_shape") == m_sys_options.end()) + group->back_to_sys_value("bed_shape"); + } for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { const std::string& opt_key = it->first; if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) @@ -484,6 +469,7 @@ void Tab::on_back_to_sys_value() } break; } + update_changed_ui(); } // Update the combo box label of the selected preset based on its "dirty" state, @@ -1313,8 +1299,10 @@ void TabPrinter::build() { auto dlg = new BedShapeDialog(this); dlg->build_dialog(m_config->option("bed_shape")); - if (dlg->ShowModal() == wxID_OK) + if (dlg->ShowModal() == wxID_OK){ load_key_value("bed_shape", dlg->GetValue()); + update_changed_ui(); + } })); return sizer; From 903a90f37a0aea3a7e8f93835f403e236e7e38da Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 26 Mar 2018 08:58:44 +0200 Subject: [PATCH 0086/1150] AMF I/O - Forces .zip.amf extension on export --- xs/src/libslic3r/Format/AMF.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/Format/AMF.cpp b/xs/src/libslic3r/Format/AMF.cpp index 8c08b46731..98683cd8aa 100644 --- a/xs/src/libslic3r/Format/AMF.cpp +++ b/xs/src/libslic3r/Format/AMF.cpp @@ -648,10 +648,15 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c if ((path == nullptr) || (model == nullptr) || (print == nullptr)) return false; + // forces ".zip.amf" extension + std::string export_path = path; + if (!boost::iends_with(export_path, ".zip.amf")) + export_path = boost::filesystem::path(export_path).replace_extension(".zip.amf").string(); + mz_zip_archive archive; mz_zip_zero_struct(&archive); - mz_bool res = mz_zip_writer_init_file(&archive, path, 0); + mz_bool res = mz_zip_writer_init_file(&archive, export_path.c_str(), 0); if (res == 0) return false; @@ -769,20 +774,20 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c } stream << "\n"; - std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf"); + std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(export_path).filename().string(), ".zip.amf", ".amf"); std::string out = stream.str(); if (!mz_zip_writer_add_mem(&archive, internal_amf_filename.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION)) { mz_zip_writer_end(&archive); - boost::filesystem::remove(path); + boost::filesystem::remove(export_path); return false; } if (!mz_zip_writer_finalize_archive(&archive)) { mz_zip_writer_end(&archive); - boost::filesystem::remove(path); + boost::filesystem::remove(export_path); return false; } From c166af5ccec2c46ff7c030aa7bbbf7173d5e7e0f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 27 Mar 2018 11:35:48 +0200 Subject: [PATCH 0087/1150] GCode Preview - Fixed z values set on sliders --- xs/src/slic3r/GUI/3DScene.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index eafca6cd11..95a7393533 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -643,14 +643,18 @@ void GLVolumeCollection::update_outside_state(const DynamicPrintConfig* config, std::vector GLVolumeCollection::get_current_print_zs() const { std::vector print_zs; + std::vector rounded_print_zs; for (GLVolume *vol : this->volumes) { for (coordf_t z : vol->print_zs) { - double round_z = (double)round(z * 100000.0f) / 100000.0f; - if (std::find(print_zs.begin(), print_zs.end(), round_z) == print_zs.end()) - print_zs.push_back(round_z); + double round_z = ::round(z * 100000.0 + 0.5) / 100000.0; + if (std::find(rounded_print_zs.begin(), rounded_print_zs.end(), round_z) == rounded_print_zs.end()) + { + print_zs.push_back(z); + rounded_print_zs.push_back(round_z); + } } } From 7d9e892edccea9ee7fa3c94937b258e6d744f2f6 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 27 Mar 2018 13:44:18 +0200 Subject: [PATCH 0088/1150] Added a button to open purging volumes dialog directly from Plater --- xs/src/slic3r/GUI/GUI.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 0410b7969c..3c8504756c 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -1,4 +1,5 @@ #include "GUI.hpp" +#include "WipeTowerDialog.hpp" #include @@ -678,6 +679,32 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl option = Option(def, "brim"); m_optgroup->append_single_option_line(option); + + Line line = { _(L("")), "" }; + line.widget = [config](wxWindow* parent){ + auto wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT); + auto sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(wiping_dialog_button); + wiping_dialog_button->Bind(wxEVT_BUTTON, ([config, parent](wxCommandEvent& e) + { + std::vector init_matrix = (config->option("wiping_volumes_matrix"))->values; + std::vector init_extruders = (config->option("wiping_volumes_extruders"))->values; + + WipingDialog dlg(parent,std::vector(init_matrix.begin(),init_matrix.end()),std::vector(init_extruders.begin(),init_extruders.end())); + + if (dlg.ShowModal() == wxID_OK) { + std::vector matrix = dlg.get_matrix(); + std::vector extruders = dlg.get_extruders(); + (config->option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(),matrix.end()); + (config->option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(),extruders.end()); + } + })); + return sizer; + }; + m_optgroup->append_line(line); + + + sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxBottom, 1); } From 56fef5302cd8cdf7e2b3c1f9190887ac909d27c1 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 27 Mar 2018 14:42:47 +0200 Subject: [PATCH 0089/1150] Added axis-labels to RammingChart --- xs/src/slic3r/GUI/RammingChart.cpp | 23 ++++++++++++++++++----- xs/src/slic3r/GUI/RammingChart.hpp | 2 +- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp index e07b958392..79a7018475 100644 --- a/xs/src/slic3r/GUI/RammingChart.cpp +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -2,6 +2,12 @@ #include "RammingChart.hpp" +//! macro used to mark string used at localization, +//! return same string +#define L(s) s + + + wxDEFINE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); @@ -43,9 +49,9 @@ void Chart::draw(wxDC& dc) { // draw x-axis: float last_mark = -10000; - for (float math_x=int(visible_area.m_x*10)/10 ; math_x <= (visible_area.m_x+visible_area.m_width) ; math_x+=0.1) { + for (float math_x=int(visible_area.m_x*10)/10 ; math_x < (visible_area.m_x+visible_area.m_width) ; math_x+=0.1) { int x = math_to_screen(wxPoint2DDouble(math_x,visible_area.m_y)).x; - int y = m_rect.GetBottom(); + int y = m_rect.GetBottom(); if (x-last_mark < 50) continue; dc.DrawLine(x,y+3,x,y-3); dc.DrawText(wxString().Format(wxT("%.1f"), math_x),wxPoint(x-10,y+7)); @@ -54,7 +60,7 @@ void Chart::draw(wxDC& dc) { // draw y-axis: last_mark=10000; - for (int math_y=visible_area.m_y ; math_y <= (visible_area.m_y+visible_area.m_height) ; math_y+=1) { + for (int math_y=visible_area.m_y ; math_y < (visible_area.m_y+visible_area.m_height) ; math_y+=1) { int y = math_to_screen(wxPoint2DDouble(visible_area.m_x,math_y)).y; int x = m_rect.GetLeft(); if (last_mark-y < 50) continue; @@ -63,8 +69,15 @@ void Chart::draw(wxDC& dc) { last_mark = y; } - - + // axis labels: + wxString label = L("Time (s)"); + int text_width = 0; + int text_height = 0; + dc.GetTextExtent(label,&text_width,&text_height); + dc.DrawText(label,wxPoint(0.5*(m_rect.GetRight()+m_rect.GetLeft())-text_width/2.f, m_rect.GetBottom()+25)); + label = L("Volumetric speed (mm\u00B3/s)"); + dc.GetTextExtent(label,&text_width,&text_height); + dc.DrawRotatedText(label,wxPoint(0,0.5*(m_rect.GetBottom()+m_rect.GetTop())+text_width/2.f),90); } void Chart::mouse_right_button_clicked(wxMouseEvent& event) { diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp index 5ec8b33eea..aa1e7acc7a 100644 --- a/xs/src/slic3r/GUI/RammingChart.hpp +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -16,7 +16,7 @@ public: Chart(wxWindow* parent, wxRect rect,const std::vector>& initial_buttons,int ramming_speed_size, float sampling) : wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize()) { - m_rect=wxRect(wxPoint(30,0),rect.GetSize()-wxSize(30,30)); + m_rect = wxRect(wxPoint(50,0),rect.GetSize()-wxSize(50,50)); visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed_size, 20.); m_buttons.clear(); if (initial_buttons.size()>0) diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 1989a82f1e..255c0d6bde 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -38,7 +38,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) -: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) +: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,400),wxBORDER_RAISED) { new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT); m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString, wxPoint(700,100), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0.,5.0,3.,0.5); From 4da6085ef883a8139417f25c6650045379c4cc44 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 28 Mar 2018 02:17:51 +0200 Subject: [PATCH 0090/1150] Corrected UI for WipingDialog --- xs/src/slic3r/GUI/Tab.cpp | 2 +- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 135 +++++++++++++++----------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 4 + 3 files changed, 83 insertions(+), 58 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 267e579b6b..503ef54a44 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -521,7 +521,7 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_bridging"); line = { _(L("Advanced")), "" }; line.widget = [this](wxWindow* parent){ - m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); + m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_wipe_tower_btn); m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 1989a82f1e..8cd6528d9c 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -11,7 +11,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) -: wxDialog(parent, -1, wxT("Ramming customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +: wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { this->Centre(); m_panel_ramming = new RammingPanel(this,parameters); @@ -20,7 +20,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(m_panel_ramming, 1, wxEXPAND); - main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); + main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP, 10); SetSizer(main_sizer); SetMinSize(GetSize()); main_sizer->SetSizeHints(this); @@ -102,24 +102,24 @@ std::string RammingPanel::get_parameters() } - +#define ITEM_WIDTH 60 // Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button to toggle simple/advanced mode: WipingDialog::WipingDialog(wxWindow* parent,const std::vector& matrix, const std::vector& extruders) -: wxDialog(parent, -1, wxT(L("Wipe tower - Purging volume adjustment")), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +: wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - this->Centre(); - auto widget_button = new wxButton(this,wxID_ANY,"-",wxPoint(0,0),wxDefaultSize); m_panel_wiping = new WipingPanel(this,matrix,extruders, widget_button); auto main_sizer = new wxBoxSizer(wxVERTICAL); - main_sizer->Add(m_panel_wiping, 1, wxEXPAND); + // set min sizer width according to extruders count + const auto sizer_width = (int)((sqrt(matrix.size()) + 2.8)*ITEM_WIDTH); + main_sizer->SetMinSize(wxSize(sizer_width, -1)); - main_sizer->Add(widget_button,0,wxALIGN_CENTER_HORIZONTAL|wxCENTER,10); + main_sizer->Add(m_panel_wiping, 0, wxEXPAND | wxALL, 5); + main_sizer->Add(widget_button, 0, wxALIGN_CENTER_HORIZONTAL | wxCENTER | wxBOTTOM, 5); main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); SetSizer(main_sizer); - SetMinSize(GetSize()); main_sizer->SetSizeHints(this); this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); @@ -133,68 +133,91 @@ WipingDialog::WipingDialog(wxWindow* parent,const std::vector& matrix, co this->Show(); } - +// This function allows to "play" with sizers parameters (like align or border) +void WipingPanel::format_sizer(wxSizer* sizer, wxPanel* page, wxGridSizer* grid_sizer, const wxString& info, const wxString& table_title, int table_lshift/*=0*/) +{ + sizer->Add(new wxStaticText(page, wxID_ANY, info), 0, wxEXPAND | wxLEFT, 15); + auto table_sizer = new wxBoxSizer(wxVERTICAL); + sizer->Add(table_sizer, 0, wxALIGN_LEFT | wxLEFT, table_lshift); + table_sizer->Add(new wxStaticText(page, wxID_ANY, table_title), 0, wxALIGN_CENTER | wxTOP, 50); + table_sizer->Add(grid_sizer, 0, wxALIGN_CENTER | wxTOP, 10); +} // This panel contains all control widgets for both simple and advanced mode (these reside in separate sizers) WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, wxButton* widget_button) -: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(500,350),wxBORDER_RAISED) +: wxPanel(parent,wxID_ANY, wxDefaultPosition, wxDefaultSize,wxBORDER_RAISED) { m_widget_button = widget_button; // pointer to the button in parent dialog m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){ toggle_advanced(true); }); m_number_of_extruders = (int)(sqrt(matrix.size())+0.001); + // Create two switched panels with their own sizers m_sizer_simple = new wxBoxSizer(wxVERTICAL); m_sizer_advanced = new wxBoxSizer(wxVERTICAL); - auto gridsizer_simple = new wxGridSizer(3,10,10); - auto gridsizer_advanced = new wxGridSizer(m_number_of_extruders+1,10,10); + m_page_simple = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + m_page_advanced = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + m_page_simple->SetSizer(m_sizer_simple); + m_page_advanced->SetSizer(m_sizer_advanced); + auto gridsizer_simple = new wxGridSizer(3, 5, 10); + auto gridsizer_advanced = new wxGridSizer(m_number_of_extruders+1, 5, 1); - // First create controls for simple mode and assign them to m_sizer_simple: - m_sizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("Total purging volume is calculated by summing two values below, depending on which tools are loaded/unloaded.")),wxPoint(40,25), wxSize(450,35)),-1,wxEXPAND,10); - m_sizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("Volume to purge (mm\u00B3) when the filament is being")),wxPoint(40,85) ,/*wxSize(500,25)*/wxDefaultSize,wxALIGN_LEFT),-1,wxEXPAND|wxALIGN_CENTER,10); + // First create controls for advanced mode and assign them to m_page_advanced: + for (unsigned int i = 0; i < m_number_of_extruders; ++i) { + edit_boxes.push_back(std::vector(0)); - gridsizer_simple->Add(0,-1,wxALL,10); - gridsizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("unloaded")),wxPoint(110,105) ,/*wxSize(80,25)*/wxDefaultSize,wxALIGN_CENTER),-1,wxALIGN_CENTER,10); - gridsizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("loaded")),wxPoint(195,105) ,/*wxSize(80,25)*/wxDefaultSize,wxALIGN_CENTER),-1,wxALIGN_CENTER,10); + for (unsigned int j = 0; j < m_number_of_extruders; ++j) { + edit_boxes.back().push_back(new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH, -1))); + if (i == j) + edit_boxes[i][j]->Disable(); + else + edit_boxes[i][j]->SetValue(wxString("") << int(matrix[m_number_of_extruders*j + i])); + } + } + gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString(""))); + for (unsigned int i = 0; i < m_number_of_extruders; ++i) + gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + for (unsigned int i = 0; i < m_number_of_extruders; ++i) { + gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + for (unsigned int j = 0; j < m_number_of_extruders; ++j) + gridsizer_advanced->Add(edit_boxes[j][i], 0); + } - for (unsigned int i=0;iAdd(new wxStaticText(this,wxID_ANY,wxString(L("Tool #"))<Add(m_old.back(),-1,wxALIGN_CENTER,10); - gridsizer_simple->Add(m_new.back(),-1,wxALIGN_CENTER,10); - } + // collect and format sizer + format_sizer(m_sizer_advanced, m_page_advanced, gridsizer_advanced, + _(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")), + _(L("Filament changed to"))); - // Now the same for advanced mode: - wxPoint origin(50,85); - m_sizer_advanced->Add(new wxStaticText(this,wxID_ANY,wxString(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")),wxPoint(40,25) ,/*wxSize(500,35)*/wxDefaultSize),-1,wxALL,10); - m_sizer_advanced->Add(new wxStaticText(this,wxID_ANY,wxString(L("Filament changed to")),origin+wxPoint(75,0) ,/*wxSize(500,25)*/wxDefaultSize),-1,wxALL,10); + // Hide preview page before new page creating + // It allows to do that from a beginning of the main panel + m_page_advanced->Hide(); - for (unsigned int i=0;i(0)); + // Now the same for simple mode: + gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString("")), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("unloaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + gridsizer_simple->Add(new wxStaticText(m_page_simple,wxID_ANY,wxString(_(L("loaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); - for (unsigned int j=0;jDisable(); - else - edit_boxes[i][j]->SetValue(wxString("")<Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("Tool #"))) << i + 1 << ": "), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + gridsizer_simple->Add(m_old.back(),0); + gridsizer_simple->Add(m_new.back(),0); + } - gridsizer_advanced->Add(0,-1,wxALL,10); - for (unsigned int i=0;iAdd(new wxStaticText(this,wxID_ANY,wxString("")<Add(new wxStaticText(this,wxID_ANY,wxString("")<Add(edit_boxes[j][i],-1,wxALL,10); - } + // collect and format sizer + format_sizer(m_sizer_simple, m_page_simple, gridsizer_simple, + _(L("Total purging volume is calculated by summing two values below, depending on which tools are loaded/unloaded.")), + _(L("Volume to purge (mm\u00B3) when the filament is being")), 50); + m_sizer = new wxBoxSizer(wxVERTICAL); + m_sizer->Add(m_page_simple, 0, wxEXPAND | wxALL, 25); + m_sizer->Add(m_page_advanced, 0, wxEXPAND | wxALL, 25); + + m_sizer->SetSizeHints(this); + SetSizer(m_sizer); - m_sizer_simple->Add(gridsizer_simple,-1,wxALL,10); - m_sizer_advanced->Add(gridsizer_advanced,-1,wxALL,10); toggle_advanced(); // to show/hide what is appropriate } @@ -260,18 +283,16 @@ void WipingPanel::toggle_advanced(bool user_action) { } if (user_action) m_advanced = !m_advanced; // user demands a change -> toggle - else { + else m_advanced = !advanced_matches_simple(); // if called from constructor, show what is appropriate - (m_advanced ? m_sizer_advanced : m_sizer_simple)->SetSizeHints(this); - SetSizer(m_advanced ? m_sizer_advanced : m_sizer_simple); - } - m_sizer_simple->Show(!m_advanced); - m_sizer_advanced->Show(m_advanced); + (m_advanced ? m_page_advanced : m_page_simple)->Show(); + (!m_advanced ? m_page_advanced : m_page_simple)->Hide(); m_widget_button->SetLabel(m_advanced ? L("Show simplified settings") : L("Show advanced settings")); if (m_advanced) if (user_action) fill_in_matrix(); // otherwise keep values loaded from config - this->Refresh(); + m_sizer->Layout(); + Refresh(); } \ No newline at end of file diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index c8e7bd480c..7448cd1e58 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -50,6 +50,7 @@ public: std::vector read_matrix_values(); std::vector read_extruders_values(); void toggle_advanced(bool user_action = false); + void format_sizer(wxSizer* sizer, wxPanel* page, wxGridSizer* grid_sizer, const wxString& info, const wxString& table_title, int table_lshift=0); private: void fill_in_matrix(); @@ -62,6 +63,9 @@ private: std::vector> edit_boxes; unsigned int m_number_of_extruders = 0; bool m_advanced = false; + wxPanel* m_page_simple = nullptr; + wxPanel* m_page_advanced = nullptr; + wxBoxSizer* m_sizer = nullptr; wxBoxSizer*m_sizer_simple = nullptr; wxBoxSizer*m_sizer_advanced = nullptr; wxButton* m_widget_button = nullptr; From 0d2637fede41b966361fbc03876a892e1d64ad56 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 28 Mar 2018 10:16:04 +0200 Subject: [PATCH 0091/1150] t tests changed so they don't fail on the extruder number check --- t/combineinfill.t | 2 +- t/custom_gcode.t | 4 +++- t/fill.t | 4 +++- t/multi.t | 6 ++++++ t/retraction.t | 4 +++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/t/combineinfill.t b/t/combineinfill.t index e94cf9eb52..5402a84f57 100644 --- a/t/combineinfill.t +++ b/t/combineinfill.t @@ -57,7 +57,7 @@ plan tests => 8; my $config = Slic3r::Config::new_from_defaults; $config->set('layer_height', 0.2); $config->set('first_layer_height', 0.2); - $config->set('nozzle_diameter', [0.5]); + $config->set('nozzle_diameter', [0.5,0.5,0.5,0.5]); $config->set('infill_every_layers', 2); $config->set('perimeter_extruder', 1); $config->set('infill_extruder', 2); diff --git a/t/custom_gcode.t b/t/custom_gcode.t index bafcd4610d..31d1d48e0c 100644 --- a/t/custom_gcode.t +++ b/t/custom_gcode.t @@ -49,7 +49,6 @@ use Slic3r::Test; my $parser = Slic3r::GCode::PlaceholderParser->new; my $config = Slic3r::Config::new_from_defaults; $config->set('printer_notes', ' PRINTER_VENDOR_PRUSA3D PRINTER_MODEL_MK2 '); - $config->set('nozzle_diameter', [0.6, 0.6, 0.6, 0.6]); $parser->apply_config($config); $parser->set('foo' => 0); $parser->set('bar' => 2); @@ -123,6 +122,7 @@ use Slic3r::Test; { my $config = Slic3r::Config->new; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('extruder', 2); $config->set('first_layer_temperature', [200,205]); @@ -204,6 +204,7 @@ use Slic3r::Test; { my $config = Slic3r::Config->new; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6,0.6]); $config->set('start_gcode', qq! ;substitution:{if infill_extruder==1}if block {elsif infill_extruder==2}elsif block 1 @@ -228,6 +229,7 @@ use Slic3r::Test; { my $config = Slic3r::Config->new; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('start_gcode', ';substitution:{if infill_extruder==1}{if perimeter_extruder==1}block11{else}block12{endif}' . '{elsif infill_extruder==2}{if perimeter_extruder==1}block21{else}block22{endif}' . diff --git a/t/fill.t b/t/fill.t index a6fe8619cd..dd9eee4873 100644 --- a/t/fill.t +++ b/t/fill.t @@ -164,6 +164,7 @@ SKIP: for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { my $config = Slic3r::Config::new_from_defaults; + $config->set('nozzle_diameter', [0.4,0.4,0.4,0.4]); $config->set('fill_pattern', $pattern); $config->set('external_fill_pattern', $pattern); $config->set('perimeters', 1); @@ -195,6 +196,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { { my $config = Slic3r::Config::new_from_defaults; + $config->set('nozzle_diameter', [0.4,0.4,0.4,0.4]); $config->set('infill_only_where_needed', 1); $config->set('bottom_solid_layers', 0); $config->set('infill_extruder', 2); @@ -276,7 +278,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { $config->set('fill_density', 0); $config->set('layer_height', 0.2); $config->set('first_layer_height', 0.2); - $config->set('nozzle_diameter', [0.35]); + $config->set('nozzle_diameter', [0.35,0.35,0.35,0.35]); $config->set('infill_extruder', 2); $config->set('solid_infill_extruder', 2); $config->set('infill_extrusion_width', 0.52); diff --git a/t/multi.t b/t/multi.t index 49d35d9070..75ce0c286c 100644 --- a/t/multi.t +++ b/t/multi.t @@ -16,6 +16,7 @@ use Slic3r::Test; { my $config = Slic3r::Config::new_from_defaults; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('raft_layers', 2); $config->set('infill_extruder', 2); $config->set('solid_infill_extruder', 3); @@ -89,6 +90,7 @@ use Slic3r::Test; { my $config = Slic3r::Config::new_from_defaults; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('support_material_extruder', 3); my $print = Slic3r::Test::init_print('20mm_cube', config => $config); @@ -97,6 +99,7 @@ use Slic3r::Test; { my $config = Slic3r::Config->new; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('extruder', 2); my $print = Slic3r::Test::init_print('20mm_cube', config => $config); @@ -105,6 +108,7 @@ use Slic3r::Test; { my $config = Slic3r::Config->new; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('perimeter_extruder', 2); $config->set('infill_extruder', 2); $config->set('support_material_extruder', 2); @@ -126,6 +130,7 @@ use Slic3r::Test; $upper_config->set('bottom_solid_layers', 1); $upper_config->set('top_solid_layers', 0); my $config = Slic3r::Config::new_from_defaults; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('fill_density', 0); $config->set('solid_infill_speed', 99); $config->set('top_solid_infill_speed', 99); @@ -172,6 +177,7 @@ use Slic3r::Test; my $object = $model->objects->[0]; my $config = Slic3r::Config::new_from_defaults; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('layer_height', 0.4); $config->set('first_layer_height', '100%'); $config->set('skirts', 0); diff --git a/t/retraction.t b/t/retraction.t index d7f1ea1458..6e6a130ca3 100644 --- a/t/retraction.t +++ b/t/retraction.t @@ -95,6 +95,7 @@ use Slic3r::Test qw(_eq); 1; }; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('first_layer_height', $config->layer_height); $config->set('first_layer_speed', '100%'); $config->set('start_gcode', ''); # to avoid dealing with the nozzle lift in start G-code @@ -207,6 +208,7 @@ use Slic3r::Test qw(_eq); { my $config = Slic3r::Config::new_from_defaults; + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $config->set('start_gcode', ''); $config->set('retract_lift', [3, 4]); @@ -255,4 +257,4 @@ use Slic3r::Test qw(_eq); 'Z is not lifted above the configured value for 2. extruder'; } -__END__ \ No newline at end of file +__END__ From 7951349a1f64771848ca51147c7ac0474d83fb5b Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 28 Mar 2018 10:32:23 +0200 Subject: [PATCH 0092/1150] Another t-test change to avoid fails --- t/custom_gcode.t | 1 + 1 file changed, 1 insertion(+) diff --git a/t/custom_gcode.t b/t/custom_gcode.t index 31d1d48e0c..7c2a75f293 100644 --- a/t/custom_gcode.t +++ b/t/custom_gcode.t @@ -49,6 +49,7 @@ use Slic3r::Test; my $parser = Slic3r::GCode::PlaceholderParser->new; my $config = Slic3r::Config::new_from_defaults; $config->set('printer_notes', ' PRINTER_VENDOR_PRUSA3D PRINTER_MODEL_MK2 '); + $config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]); $parser->apply_config($config); $parser->set('foo' => 0); $parser->set('bar' => 2); From 1b4dc685f4430a8ff1f35aea61dd920743b71c8b Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 28 Mar 2018 15:37:10 +0200 Subject: [PATCH 0093/1150] Connected filament_ramming_parameters to respective dialog, other minor changes --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 2 +- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 4 ++-- xs/src/libslic3r/PrintConfig.cpp | 8 ++++---- xs/src/libslic3r/PrintConfig.hpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 8 +++----- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 7c8181ff6b..0c8f4fe9f1 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -800,7 +800,7 @@ void WipeTowerPrusaMM::toolchange_Unload( const float start_x = writer.x(); turning_point = ( xr-start_x > start_x-xl ? xr : xl ); const float max_x_dist = 2*std::abs(start_x-turning_point); - const unsigned int N = 4 + std::max(0,(m_filpar[m_current_tool].cooling_time-14)/3); + const unsigned int N = 4 + std::max(0.f, (m_filpar[m_current_tool].cooling_time-14)/3); float time = m_filpar[m_current_tool].cooling_time / float(N); i = 0; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 4f97f700f2..636b4b7382 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -67,7 +67,7 @@ public: // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, - float unloading_speed, float delay, int cooling_time, std::string ramming_parameters) + float unloading_speed, float delay, float cooling_time, std::string ramming_parameters) { //while (m_filpar.size() < idx+1) // makes sure the required element is in the vector m_filpar.push_back(FilamentParameters()); @@ -205,7 +205,7 @@ private: float loading_speed = 0.f; float unloading_speed = 0.f; float delay = 0.f ; - int cooling_time = 0; + float cooling_time = 0.f; float ramming_line_width_multiplicator = 0.f; float ramming_step_multiplicator = 0.f; std::vector ramming_speed; diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index cb5bcea4a6..aef9a8fa2d 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -470,14 +470,14 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloats { 0. }; - def = this->add("filament_cooling_time", coInts); + def = this->add("filament_cooling_time", coFloats); def->label = L("Cooling time"); def->tooltip = L("The filament is slowly moved back and forth after retraction into the cooling tube " "for this amount of time."); def->cli = "filament_cooling_time=i@"; def->sidetext = L("s"); def->min = 0; - def->default_value = new ConfigOptionInts { 14 }; + def->default_value = new ConfigOptionFloats { 14.f }; def = this->add("filament_ramming_parameters", coStrings); def->label = L("Ramming parameters"); @@ -1779,7 +1779,7 @@ PrintConfigDef::PrintConfigDef() def->default_value = new ConfigOptionBool(false); def = this->add("wiping_volumes_extruders", coFloats); - def->label = L("Extrusion multiplier"); + def->label = L("Purging volumes - load/unload volumes"); def->tooltip = L("This vector saves required volumes to change from/to each tool used on the " "wipe tower. These values are used to simplify creation of the full purging " "volumes below. "); @@ -1787,7 +1787,7 @@ PrintConfigDef::PrintConfigDef() def->default_value = new ConfigOptionFloats { 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f }; def = this->add("wiping_volumes_matrix", coFloats); - def->label = L("Extrusion multiplier"); + def->label = L("Purging volumes - matrix"); def->tooltip = L("This matrix describes volumes (in cubic milimetres) required to purge the" " new filament on the wipe tower for any given pair of tools. "); def->cli = "wiping-volumes-matrix=f@"; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index d184a21611..be64d35bd2 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -469,7 +469,7 @@ public: ConfigOptionFloats filament_loading_speed; ConfigOptionFloats filament_unloading_speed; ConfigOptionFloats filament_toolchange_delay; - ConfigOptionInts filament_cooling_time; + ConfigOptionFloats filament_cooling_time; ConfigOptionStrings filament_ramming_parameters; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 267e579b6b..82d4c456de 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -521,7 +521,7 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_bridging"); line = { _(L("Advanced")), "" }; line.widget = [this](wxWindow* parent){ - m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); + m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Purging volumes"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_wipe_tower_btn); m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) @@ -958,10 +958,8 @@ void TabFilament::build() ramming_dialog_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { RammingDialog dlg(this,(m_config->option("filament_ramming_parameters"))->get_at(0)); - if (dlg.ShowModal() == wxID_OK) { - wxMessageBox("DIALOG OK:\n"+dlg.get_parameters()); - //load_key_value("wipe_tower_advanced", dlg.get_parameters()); - } + if (dlg.ShowModal() == wxID_OK) + (m_config->option("filament_ramming_parameters"))->get_at(0) = dlg.get_parameters(); })); return sizer; }; From c61ffe9f6b7a776f4bc468fbcaf0f7d794197b5e Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 28 Mar 2018 20:31:36 +0200 Subject: [PATCH 0094/1150] Corrected UI for RammingDialog --- xs/src/slic3r/GUI/RammingChart.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 2 +- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 84 +++++++++++++++++---------- 3 files changed, 54 insertions(+), 34 deletions(-) diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp index e07b958392..7b6730c1b5 100644 --- a/xs/src/slic3r/GUI/RammingChart.cpp +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -59,7 +59,7 @@ void Chart::draw(wxDC& dc) { int x = m_rect.GetLeft(); if (last_mark-y < 50) continue; dc.DrawLine(x-3,y,x+3,y); - dc.DrawText(wxString()<append_single_option_line("filament_cooling_time"); line = { _(L("Ramming")), "" }; line.widget = [this](wxWindow* parent){ - auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); + auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(ramming_dialog_btn); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 8cd6528d9c..b491415dac 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -11,18 +11,16 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) -: wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +: wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - this->Centre(); m_panel_ramming = new RammingPanel(this,parameters); m_panel_ramming->Show(true); this->Show(); auto main_sizer = new wxBoxSizer(wxVERTICAL); - main_sizer->Add(m_panel_ramming, 1, wxEXPAND); - main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP, 10); + main_sizer->Add(m_panel_ramming, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5); + main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxBOTTOM, 10); SetSizer(main_sizer); - SetMinSize(GetSize()); main_sizer->SetSizeHints(this); this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); @@ -38,34 +36,48 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) -: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) +: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,/*wxPoint(50,50), wxSize(800,350),*/wxBORDER_RAISED) { - new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT); - m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString, wxPoint(700,100), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0.,5.0,3.,0.5); - new wxStaticText(this,wxID_ANY,wxString("Total rammed volume (mm\u00B3):"), wxPoint(500,135), wxSize(200,25),wxALIGN_LEFT); - m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,130), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0,10000,0); - new wxStaticText(this,wxID_ANY,wxString("Ramming line width (%):"), wxPoint(500,205), wxSize(200,25),wxALIGN_LEFT); - m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,200), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100); - new wxStaticText(this,wxID_ANY,wxString("Ramming line spacing (%):"), wxPoint(500,235), wxSize(200,25),wxALIGN_LEFT); - m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,230), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100); - - std::stringstream stream{parameters}; - stream >> m_ramming_line_width_multiplicator >> m_ramming_step_multiplicator; - int ramming_speed_size = 0; - float dummy = 0.f; - while (stream >> dummy) - ++ramming_speed_size; - stream.clear(); - stream.get(); - - std::vector> buttons; - float x = 0.f; - float y = 0.f; - while (stream >> x >> y) - buttons.push_back(std::make_pair(x,y)); - - m_chart = new Chart(this,wxRect(10,10,480,360),buttons,ramming_speed_size,0.25f); - + auto sizer_chart = new wxBoxSizer(wxVERTICAL); + auto sizer_param = new wxBoxSizer(wxVERTICAL); + + std::stringstream stream{ parameters }; + stream >> m_ramming_line_width_multiplicator >> m_ramming_step_multiplicator; + int ramming_speed_size = 0; + float dummy = 0.f; + while (stream >> dummy) + ++ramming_speed_size; + stream.clear(); + stream.get(); + + std::vector> buttons; + float x = 0.f; + float y = 0.f; + while (stream >> x >> y) + buttons.push_back(std::make_pair(x, y)); + + m_chart = new Chart(this, wxRect(10, 10, 480, 360), buttons, ramming_speed_size, 0.25f); + sizer_chart->Add(m_chart, 0, wxALL, 5); + + m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,0.,5.0,3.,0.5); + m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,0,10000,0); + m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,10,200,100); + m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,10,200,100); + + auto gsizer_param = new wxFlexGridSizer(2, 5, 15); + gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total ramming time (s):")))), 0, wxALIGN_CENTER_VERTICAL); + gsizer_param->Add(m_widget_time); + gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total rammed volume (mm"))+"\u00B3):")), 0, wxALIGN_CENTER_VERTICAL); + gsizer_param->Add(m_widget_volume); + gsizer_param->AddSpacer(20); + gsizer_param->AddSpacer(20); + gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line width (%):")))), 0, wxALIGN_CENTER_VERTICAL); + gsizer_param->Add(m_widget_ramming_line_width_multiplicator); + gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line spacing (%):")))), 0, wxALIGN_CENTER_VERTICAL); + gsizer_param->Add(m_widget_ramming_step_multiplicator); + + sizer_param->Add(gsizer_param, 0, wxTOP, 100); + m_widget_time->SetValue(m_chart->get_time()); m_widget_time->SetDigits(2); m_widget_volume->SetValue(m_chart->get_volume()); @@ -75,6 +87,14 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) m_widget_ramming_step_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); }); m_widget_ramming_line_width_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); }); + + auto sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(sizer_chart, 0, wxALL, 5); + sizer->Add(sizer_param, 0, wxALL, 10); + + sizer->SetSizeHints(this); + SetSizer(sizer); + m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);}); m_widget_time->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value From 572008546d3a6758af20963dcde20846add08445 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 29 Mar 2018 12:04:09 +0200 Subject: [PATCH 0095/1150] Vertical label in wiping matrix dialog --- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 24 +++++++++++++++++------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 2 -- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index b69d7c6f0a..05be20cd60 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -11,7 +11,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) -: wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +: wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { m_panel_ramming = new RammingPanel(this,parameters); m_panel_ramming->Show(true); @@ -36,7 +36,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) -: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,/*wxPoint(50,50), wxSize(800,350),*/wxBORDER_RAISED). +: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize/*,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED*/) { auto sizer_chart = new wxBoxSizer(wxVERTICAL); auto sizer_param = new wxBoxSizer(wxVERTICAL); @@ -125,7 +125,7 @@ std::string RammingPanel::get_parameters() #define ITEM_WIDTH 60 // Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button to toggle simple/advanced mode: WipingDialog::WipingDialog(wxWindow* parent,const std::vector& matrix, const std::vector& extruders) -: wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) +: wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { auto widget_button = new wxButton(this,wxID_ANY,"-",wxPoint(0,0),wxDefaultSize); m_panel_wiping = new WipingPanel(this,matrix,extruders, widget_button); @@ -156,16 +156,16 @@ WipingDialog::WipingDialog(wxWindow* parent,const std::vector& matrix, co // This function allows to "play" with sizers parameters (like align or border) void WipingPanel::format_sizer(wxSizer* sizer, wxPanel* page, wxGridSizer* grid_sizer, const wxString& info, const wxString& table_title, int table_lshift/*=0*/) { - sizer->Add(new wxStaticText(page, wxID_ANY, info), 0, wxEXPAND | wxLEFT, 15); + sizer->Add(new wxStaticText(page, wxID_ANY, info,wxDefaultPosition,wxSize(0,50)), 0, wxEXPAND | wxLEFT, 15); auto table_sizer = new wxBoxSizer(wxVERTICAL); - sizer->Add(table_sizer, 0, wxALIGN_LEFT | wxLEFT, table_lshift); + sizer->Add(table_sizer, 0, wxALIGN_CENTER | wxCENTER, table_lshift); table_sizer->Add(new wxStaticText(page, wxID_ANY, table_title), 0, wxALIGN_CENTER | wxTOP, 50); table_sizer->Add(grid_sizer, 0, wxALIGN_CENTER | wxTOP, 10); } // This panel contains all control widgets for both simple and advanced mode (these reside in separate sizers) WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, wxButton* widget_button) -: wxPanel(parent,wxID_ANY, wxDefaultPosition, wxDefaultSize,wxBORDER_RAISED) +: wxPanel(parent,wxID_ANY, wxDefaultPosition, wxDefaultSize/*,wxBORDER_RAISED*/) { m_widget_button = widget_button; // pointer to the button in parent dialog m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){ toggle_advanced(true); }); @@ -207,7 +207,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con // collect and format sizer format_sizer(m_sizer_advanced, m_page_advanced, gridsizer_advanced, _(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")), - _(L("Filament changed to"))); + _(L("Extruder changed to"))); // Hide preview page before new page creating // It allows to do that from a beginning of the main panel @@ -239,6 +239,16 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con SetSizer(m_sizer); toggle_advanced(); // to show/hide what is appropriate + + m_page_advanced->Bind(wxEVT_PAINT,[this](wxPaintEvent&) { + wxPaintDC dc(m_page_advanced); + int y_pos = 0.5 * (edit_boxes[0][0]->GetPosition().y + edit_boxes[0][edit_boxes.size()-1]->GetPosition().y + edit_boxes[0][edit_boxes.size()-1]->GetSize().y); + wxString label = L("From"); + int text_width = 0; + int text_height = 0; + dc.GetTextExtent(label,&text_width,&text_height); + dc.DrawRotatedText(label,5,y_pos + text_width/2.f,90); + }); } diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index 7448cd1e58..beb5c5f466 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -58,8 +58,6 @@ private: std::vector m_old; std::vector m_new; - std::vector m_advanced_widgets; - std::vector m_notadvanced_widgets; std::vector> edit_boxes; unsigned int m_number_of_extruders = 0; bool m_advanced = false; From 6fd3f38717affdd552b3b218ea69768e955a7d55 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 29 Mar 2018 14:23:45 +0200 Subject: [PATCH 0096/1150] Warning to show before ramming adjustements, vertical text in wiping dialog positioned better --- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 21 ++++++++++++++------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 5 +++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 05be20cd60..df05522994 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -29,6 +29,12 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) m_output_data = m_panel_ramming->get_parameters(); EndModal(wxID_OK); },wxID_OK); + this->Show(); + wxMessageDialog(this,L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " + "properly shape the end of the unloaded filament so it does not prevent insertion of the new filament and can itself " + "be reinserted later. This phase is important and different materials can require different extrusion speeds to get " + "the good shape. For this reason, the extrusion rates during ramming are adjustable.\n\nThis is an expert-level " + "setting, incorrect adjustment will likely lead to jams, extruder wheel grinding into filament etc."),L("Warning"),wxOK|wxICON_EXCLAMATION).ShowModal(); } @@ -181,7 +187,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con m_page_advanced->SetSizer(m_sizer_advanced); auto gridsizer_simple = new wxGridSizer(3, 5, 10); - auto gridsizer_advanced = new wxGridSizer(m_number_of_extruders+1, 5, 1); + m_gridsizer_advanced = new wxGridSizer(m_number_of_extruders+1, 5, 1); // First create controls for advanced mode and assign them to m_page_advanced: for (unsigned int i = 0; i < m_number_of_extruders; ++i) { @@ -195,17 +201,17 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con edit_boxes[i][j]->SetValue(wxString("") << int(matrix[m_number_of_extruders*j + i])); } } - gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString(""))); + m_gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString(""))); for (unsigned int i = 0; i < m_number_of_extruders; ++i) - gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + m_gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); for (unsigned int i = 0; i < m_number_of_extruders; ++i) { - gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + m_gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); for (unsigned int j = 0; j < m_number_of_extruders; ++j) - gridsizer_advanced->Add(edit_boxes[j][i], 0); + m_gridsizer_advanced->Add(edit_boxes[j][i], 0); } // collect and format sizer - format_sizer(m_sizer_advanced, m_page_advanced, gridsizer_advanced, + format_sizer(m_sizer_advanced, m_page_advanced, m_gridsizer_advanced, _(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")), _(L("Extruder changed to"))); @@ -247,7 +253,8 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con int text_width = 0; int text_height = 0; dc.GetTextExtent(label,&text_width,&text_height); - dc.DrawRotatedText(label,5,y_pos + text_width/2.f,90); + int xpos = m_gridsizer_advanced->GetPosition().x; + dc.DrawRotatedText(label,xpos-text_height,y_pos + text_width/2.f,90); }); } diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index beb5c5f466..d858062da8 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -64,8 +64,9 @@ private: wxPanel* m_page_simple = nullptr; wxPanel* m_page_advanced = nullptr; wxBoxSizer* m_sizer = nullptr; - wxBoxSizer*m_sizer_simple = nullptr; - wxBoxSizer*m_sizer_advanced = nullptr; + wxBoxSizer* m_sizer_simple = nullptr; + wxBoxSizer* m_sizer_advanced = nullptr; + wxGridSizer* m_gridsizer_advanced = nullptr; wxButton* m_widget_button = nullptr; }; From bf295b903968d75845bc9898fa880e2b91e4121d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 29 Mar 2018 14:46:11 +0200 Subject: [PATCH 0097/1150] Time Estimator and GCode Analyzer - Fixed handling of commands G90, G91, M82 and M83 - Fixes #812 --- xs/src/libslic3r/GCode/Analyzer.cpp | 38 ++++++++++++----------- xs/src/libslic3r/GCode/Analyzer.hpp | 12 ++++---- xs/src/libslic3r/GCodeTimeEstimator.cpp | 40 +++++++++++++------------ xs/src/libslic3r/GCodeTimeEstimator.hpp | 12 ++++---- 4 files changed, 54 insertions(+), 48 deletions(-) diff --git a/xs/src/libslic3r/GCode/Analyzer.cpp b/xs/src/libslic3r/GCode/Analyzer.cpp index 6530806c40..209874180b 100644 --- a/xs/src/libslic3r/GCode/Analyzer.cpp +++ b/xs/src/libslic3r/GCode/Analyzer.cpp @@ -97,8 +97,8 @@ GCodeAnalyzer::GCodeAnalyzer() void GCodeAnalyzer::reset() { _set_units(Millimeters); - _set_positioning_xyz_type(Absolute); - _set_positioning_e_type(Relative); + _set_global_positioning_type(Absolute); + _set_e_local_positioning_type(Absolute); _set_extrusion_role(erNone); _set_extruder_id(DEFAULT_EXTRUDER_ID); _set_mm3_per_mm(Default_mm3_per_mm); @@ -237,13 +237,13 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi } // Returns the new absolute position on the given axis in dependence of the given parameters -float axis_absolute_position_from_G1_line(GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeAnalyzer::EUnits units, GCodeAnalyzer::EPositioningType type, float current_absolute_position) +float axis_absolute_position_from_G1_line(GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeAnalyzer::EUnits units, bool is_relative, float current_absolute_position) { float lengthsScaleFactor = (units == GCodeAnalyzer::Inches) ? INCHES_TO_MM : 1.0f; if (lineG1.has(Slic3r::Axis(axis))) { float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor; - return (type == GCodeAnalyzer::Absolute) ? ret : current_absolute_position + ret; + return is_relative ? current_absolute_position + ret : ret; } else return current_absolute_position; @@ -256,7 +256,11 @@ void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line) float new_pos[Num_Axis]; for (unsigned char a = X; a < Num_Axis; ++a) { - new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, (a == E) ? _get_positioning_e_type() : _get_positioning_xyz_type(), _get_axis_position((EAxis)a)); + bool is_relative = (_get_global_positioning_type() == Relative); + if (a == E) + is_relative |= (_get_e_local_positioning_type() == Relative); + + new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, is_relative, _get_axis_position((EAxis)a)); } // updates feedrate from line, if present @@ -319,12 +323,12 @@ void GCodeAnalyzer::_processG23(const GCodeReader::GCodeLine& line) void GCodeAnalyzer::_processG90(const GCodeReader::GCodeLine& line) { - _set_positioning_xyz_type(Absolute); + _set_global_positioning_type(Absolute); } void GCodeAnalyzer::_processG91(const GCodeReader::GCodeLine& line) { - _set_positioning_xyz_type(Relative); + _set_global_positioning_type(Relative); } void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line) @@ -367,12 +371,12 @@ void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line) void GCodeAnalyzer::_processM82(const GCodeReader::GCodeLine& line) { - _set_positioning_e_type(Absolute); + _set_e_local_positioning_type(Absolute); } void GCodeAnalyzer::_processM83(const GCodeReader::GCodeLine& line) { - _set_positioning_e_type(Relative); + _set_e_local_positioning_type(Relative); } void GCodeAnalyzer::_processT(const GCodeReader::GCodeLine& line) @@ -466,24 +470,24 @@ GCodeAnalyzer::EUnits GCodeAnalyzer::_get_units() const return m_state.units; } -void GCodeAnalyzer::_set_positioning_xyz_type(GCodeAnalyzer::EPositioningType type) +void GCodeAnalyzer::_set_global_positioning_type(GCodeAnalyzer::EPositioningType type) { - m_state.positioning_xyz_type = type; + m_state.global_positioning_type = type; } -GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_positioning_xyz_type() const +GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_global_positioning_type() const { - return m_state.positioning_xyz_type; + return m_state.global_positioning_type; } -void GCodeAnalyzer::_set_positioning_e_type(GCodeAnalyzer::EPositioningType type) +void GCodeAnalyzer::_set_e_local_positioning_type(GCodeAnalyzer::EPositioningType type) { - m_state.positioning_e_type = type; + m_state.e_local_positioning_type = type; } -GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_positioning_e_type() const +GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_e_local_positioning_type() const { - return m_state.positioning_e_type; + return m_state.e_local_positioning_type; } void GCodeAnalyzer::_set_extrusion_role(ExtrusionRole extrusion_role) diff --git a/xs/src/libslic3r/GCode/Analyzer.hpp b/xs/src/libslic3r/GCode/Analyzer.hpp index 7939d432d4..39e67b89a3 100644 --- a/xs/src/libslic3r/GCode/Analyzer.hpp +++ b/xs/src/libslic3r/GCode/Analyzer.hpp @@ -90,8 +90,8 @@ private: struct State { EUnits units; - EPositioningType positioning_xyz_type; - EPositioningType positioning_e_type; + EPositioningType global_positioning_type; + EPositioningType e_local_positioning_type; Metadata data; Pointf3 start_position; float start_extrusion; @@ -170,11 +170,11 @@ private: void _set_units(EUnits units); EUnits _get_units() const; - void _set_positioning_xyz_type(EPositioningType type); - EPositioningType _get_positioning_xyz_type() const; + void _set_global_positioning_type(EPositioningType type); + EPositioningType _get_global_positioning_type() const; - void _set_positioning_e_type(EPositioningType type); - EPositioningType _get_positioning_e_type() const; + void _set_e_local_positioning_type(EPositioningType type); + EPositioningType _get_e_local_positioning_type() const; void _set_extrusion_role(ExtrusionRole extrusion_role); ExtrusionRole _get_extrusion_role() const; diff --git a/xs/src/libslic3r/GCodeTimeEstimator.cpp b/xs/src/libslic3r/GCodeTimeEstimator.cpp index 912799ca9b..176159ff56 100644 --- a/xs/src/libslic3r/GCodeTimeEstimator.cpp +++ b/xs/src/libslic3r/GCodeTimeEstimator.cpp @@ -369,24 +369,24 @@ namespace Slic3r { return _state.units; } - void GCodeTimeEstimator::set_positioning_xyz_type(GCodeTimeEstimator::EPositioningType type) + void GCodeTimeEstimator::set_global_positioning_type(GCodeTimeEstimator::EPositioningType type) { - _state.positioning_xyz_type = type; + _state.global_positioning_type = type; } - GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_positioning_xyz_type() const + GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_global_positioning_type() const { - return _state.positioning_xyz_type; + return _state.global_positioning_type; } - void GCodeTimeEstimator::set_positioning_e_type(GCodeTimeEstimator::EPositioningType type) + void GCodeTimeEstimator::set_e_local_positioning_type(GCodeTimeEstimator::EPositioningType type) { - _state.positioning_e_type = type; + _state.e_local_positioning_type = type; } - GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_positioning_e_type() const + GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_e_local_positioning_type() const { - return _state.positioning_e_type; + return _state.e_local_positioning_type; } void GCodeTimeEstimator::add_additional_time(float timeSec) @@ -408,8 +408,8 @@ namespace Slic3r { { set_units(Millimeters); set_dialect(gcfRepRap); - set_positioning_xyz_type(Absolute); - set_positioning_e_type(Relative); + set_global_positioning_type(Absolute); + set_e_local_positioning_type(Absolute); set_feedrate(DEFAULT_FEEDRATE); set_acceleration(DEFAULT_ACCELERATION); @@ -628,13 +628,13 @@ namespace Slic3r { } // Returns the new absolute position on the given axis in dependence of the given parameters - float axis_absolute_position_from_G1_line(GCodeTimeEstimator::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeTimeEstimator::EUnits units, GCodeTimeEstimator::EPositioningType type, float current_absolute_position) + float axis_absolute_position_from_G1_line(GCodeTimeEstimator::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeTimeEstimator::EUnits units, bool is_relative, float current_absolute_position) { float lengthsScaleFactor = (units == GCodeTimeEstimator::Inches) ? INCHES_TO_MM : 1.0f; if (lineG1.has(Slic3r::Axis(axis))) { float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor; - return (type == GCodeTimeEstimator::Absolute) ? ret : current_absolute_position + ret; + return is_relative ? current_absolute_position + ret : ret; } else return current_absolute_position; @@ -647,7 +647,11 @@ namespace Slic3r { float new_pos[Num_Axis]; for (unsigned char a = X; a < Num_Axis; ++a) { - new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, (a == E) ? get_positioning_e_type() : get_positioning_xyz_type(), get_axis_position((EAxis)a)); + bool is_relative = (get_global_positioning_type() == Relative); + if (a == E) + is_relative |= (get_e_local_positioning_type() == Relative); + + new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, is_relative, get_axis_position((EAxis)a)); } // updates feedrate from line, if present @@ -865,14 +869,12 @@ namespace Slic3r { void GCodeTimeEstimator::_processG90(const GCodeReader::GCodeLine& line) { - set_positioning_xyz_type(Absolute); + set_global_positioning_type(Absolute); } void GCodeTimeEstimator::_processG91(const GCodeReader::GCodeLine& line) { - // TODO: THERE ARE DIALECT VARIANTS - - set_positioning_xyz_type(Relative); + set_global_positioning_type(Relative); } void GCodeTimeEstimator::_processG92(const GCodeReader::GCodeLine& line) @@ -922,12 +924,12 @@ namespace Slic3r { void GCodeTimeEstimator::_processM82(const GCodeReader::GCodeLine& line) { - set_positioning_e_type(Absolute); + set_e_local_positioning_type(Absolute); } void GCodeTimeEstimator::_processM83(const GCodeReader::GCodeLine& line) { - set_positioning_e_type(Relative); + set_e_local_positioning_type(Relative); } void GCodeTimeEstimator::_processM109(const GCodeReader::GCodeLine& line) diff --git a/xs/src/libslic3r/GCodeTimeEstimator.hpp b/xs/src/libslic3r/GCodeTimeEstimator.hpp index 5ad5b8d0c7..8f948abd12 100644 --- a/xs/src/libslic3r/GCodeTimeEstimator.hpp +++ b/xs/src/libslic3r/GCodeTimeEstimator.hpp @@ -61,8 +61,8 @@ namespace Slic3r { { GCodeFlavor dialect; EUnits units; - EPositioningType positioning_xyz_type; - EPositioningType positioning_e_type; + EPositioningType global_positioning_type; + EPositioningType e_local_positioning_type; Axis axis[Num_Axis]; float feedrate; // mm/s float acceleration; // mm/s^2 @@ -257,11 +257,11 @@ namespace Slic3r { void set_units(EUnits units); EUnits get_units() const; - void set_positioning_xyz_type(EPositioningType type); - EPositioningType get_positioning_xyz_type() const; + void set_global_positioning_type(EPositioningType type); + EPositioningType get_global_positioning_type() const; - void set_positioning_e_type(EPositioningType type); - EPositioningType get_positioning_e_type() const; + void set_e_local_positioning_type(EPositioningType type); + EPositioningType get_e_local_positioning_type() const; void add_additional_time(float timeSec); void set_additional_time(float timeSec); From 281732ca388909d475abd1e504add7ce06dcc196 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 29 Mar 2018 15:32:09 +0200 Subject: [PATCH 0098/1150] Variable layer height enabled, nozzle diameters properly passed to the wipe tower generator --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 2 +- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 13 ++++++++----- xs/src/libslic3r/Print.cpp | 13 ++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 0c8f4fe9f1..889eaf2f58 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -1104,7 +1104,7 @@ void WipeTowerPrusaMM::plan_tower() if (this_layer_depth > m_wipe_tower_depth - m_perimeter_width) m_wipe_tower_depth = this_layer_depth + m_perimeter_width; - for (int i = layer_index - 1; i >= 0 /*&& m_plan[i].depth < this_layer_depth*/; i--) + for (int i = layer_index - 1; i >= 0 ; i--) { if (m_plan[i].depth - this_layer_depth < 2*m_perimeter_width ) m_plan[i].depth = this_layer_depth; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 636b4b7382..26c40fbc97 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -67,7 +67,7 @@ public: // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, - float unloading_speed, float delay, float cooling_time, std::string ramming_parameters) + float unloading_speed, float delay, float cooling_time, std::string ramming_parameters, float nozzle_diameter) { //while (m_filpar.size() < idx+1) // makes sure the required element is in the vector m_filpar.push_back(FilamentParameters()); @@ -79,6 +79,9 @@ public: m_filpar[idx].unloading_speed = unloading_speed; m_filpar[idx].delay = delay; m_filpar[idx].cooling_time = cooling_time; + m_filpar[idx].nozzle_diameter = nozzle_diameter; // to be used in future with (non-single) multiextruder MM + + m_perimeter_width = nozzle_diameter * Width_To_Nozzle_Ratio; // all extruders are now assumed to have the same diameter std::stringstream stream{ramming_parameters}; float speed = 0.f; @@ -171,8 +174,7 @@ private: const bool m_peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet - const float Filament_Area = M_PI * 1.75f * 1.75f / 4.f; // filament area in mm^3 - const float Nozzle_Diameter = 0.4f; // nozzle diameter in mm + const float Filament_Area = M_PI * 1.75f * 1.75f / 4.f; // filament area in mm^2 const float Width_To_Nozzle_Ratio = 1.25f; // desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust const float WT_EPSILON = 1e-3f; @@ -194,7 +196,7 @@ private: float m_bridging = 0.f; bool m_adhesion = true; - float m_perimeter_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. + float m_perimeter_width = 0.4 * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_extrusion_flow = 0.038; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. @@ -209,6 +211,7 @@ private: float ramming_line_width_multiplicator = 0.f; float ramming_step_multiplicator = 0.f; std::vector ramming_speed; + float nozzle_diameter; }; // Extruder specific parameters. @@ -235,7 +238,7 @@ private: { if ( layer_height < 0 ) return m_extrusion_flow; - return layer_height * ( Width_To_Nozzle_Ratio * Nozzle_Diameter - layer_height * (1-M_PI/4.f)) / (Filament_Area); + return layer_height * ( m_perimeter_width - layer_height * (1-M_PI/4.f)) / Filament_Area; } // Calculates length of extrusion line to extrude given volume diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index cd66f6f56c..168bf13026 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -581,6 +581,12 @@ std::string Print::validate() const return "The Spiral Vase option can only be used when printing single material objects."; } + if (this->config.single_extruder_multi_material) { + for (size_t i=1; iconfig.nozzle_diameter.values.size(); ++i) + if (this->config.nozzle_diameter.values[i] != this->config.nozzle_diameter.values[i-1]) + return "All extruders must have the same diameter for single extruder multimaterial printer."; + } + if (this->has_wipe_tower() && ! this->objects.empty()) { #if 0 for (auto dmr : this->config.nozzle_diameter.values) @@ -606,10 +612,10 @@ std::string Print::validate() const bool was_layer_height_profile_valid = object->layer_height_profile_valid; object->update_layer_height_profile(); object->layer_height_profile_valid = was_layer_height_profile_valid; - for (size_t i = 5; i < object->layer_height_profile.size(); i += 2) + /*for (size_t i = 5; i < object->layer_height_profile.size(); i += 2) if (object->layer_height_profile[i-1] > slicing_params.object_print_z_min + EPSILON && std::abs(object->layer_height_profile[i] - object->config.layer_height) > EPSILON) - return "The Wipe Tower is currently only supported with constant Z layer spacing. Layer editing is not allowed."; + return "The Wipe Tower is currently only supported with constant Z layer spacing. Layer editing is not allowed.";*/ } } @@ -1066,7 +1072,8 @@ void Print::_make_wipe_tower() this->config.filament_unloading_speed.get_at(i), this->config.filament_toolchange_delay.get_at(i), this->config.filament_cooling_time.get_at(i), - this->config.filament_ramming_parameters.get_at(i)); + this->config.filament_ramming_parameters.get_at(i), + this->config.nozzle_diameter.get_at(i)); // When printing the first layer's wipe tower, the first extruder is expected to be active and primed. // Therefore the number of wipe sections at the wipe tower will be (m_tool_ordering.front().extruders-1) at the 1st layer. From 89686b808d67f8d575ccd4b2f42ccc11e9846b51 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 3 Apr 2018 13:51:12 +0200 Subject: [PATCH 0099/1150] Added a check that all objects have the same layer height profile --- xs/src/libslic3r/Print.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 168bf13026..267062125e 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -612,6 +612,15 @@ std::string Print::validate() const bool was_layer_height_profile_valid = object->layer_height_profile_valid; object->update_layer_height_profile(); object->layer_height_profile_valid = was_layer_height_profile_valid; + + PrintObject* first_object = this->objects.front(); + int i = 0; + while ( i < first_object->layer_height_profile.size() && i < object->layer_height_profile.size() ) { + if (std::abs(first_object->layer_height_profile[i] - object->layer_height_profile[i]) > EPSILON ) + return "The Wipe tower is only supported if all objects have the same layer height profile"; + ++i; + } + /*for (size_t i = 5; i < object->layer_height_profile.size(); i += 2) if (object->layer_height_profile[i-1] > slicing_params.object_print_z_min + EPSILON && std::abs(object->layer_height_profile[i] - object->config.layer_height) > EPSILON) From e5f23bc11d712f8c012197b0c5c1b50bf65d9077 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 3 Apr 2018 14:35:54 +0200 Subject: [PATCH 0100/1150] Fixed bug - negative feedrate was issued during loading of a new filament --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 889eaf2f58..4dbc7440e0 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -786,7 +786,7 @@ void WipeTowerPrusaMM::toolchange_Unload( float edist = -(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42); writer.suppress_preview() .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ) // fixed speed after ramming - .load_move_x(oldx ,edist , 60.f * std::hypot(xdist,edist)/edist * m_filpar[m_current_tool].unloading_speed ) + .load_move_x(oldx ,edist , 60.f * std::hypot(xdist,edist)/std::abs(edist) * m_filpar[m_current_tool].unloading_speed ) .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * m_filpar[m_current_tool].unloading_speed*0.55f ) .load_move_x(oldx ,-12 , 60.f * std::hypot(xdist,12)/12 * m_filpar[m_current_tool].unloading_speed*0.35f ) .resume_preview(); From d54425a901a8f04d9253ea630219f537765ad4ac Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 3 Apr 2018 22:07:59 +0200 Subject: [PATCH 0101/1150] Added show/hide of "Purging volumes" button depending on a state of "wipe_tower" --- xs/src/slic3r/GUI/GUI.cpp | 11 ++++++++--- xs/src/slic3r/GUI/GUI.hpp | 2 ++ xs/src/slic3r/GUI/OptionsGroup.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 6 +++++- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 12 ++++++------ 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 3c8504756c..933a1ce0ed 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -182,6 +182,7 @@ wxLocale* g_wxLocale; std::shared_ptr m_optgroup; double m_brim_width = 0.0; +wxButton* g_wiping_dialog_button = nullptr; void set_wxapp(wxApp *app) { @@ -682,10 +683,10 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl Line line = { _(L("")), "" }; line.widget = [config](wxWindow* parent){ - auto wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT); + g_wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes")) + "\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(wiping_dialog_button); - wiping_dialog_button->Bind(wxEVT_BUTTON, ([config, parent](wxCommandEvent& e) + sizer->Add(g_wiping_dialog_button); + g_wiping_dialog_button->Bind(wxEVT_BUTTON, ([config, parent](wxCommandEvent& e) { std::vector init_matrix = (config->option("wiping_volumes_matrix"))->values; std::vector init_extruders = (config->option("wiping_volumes_extruders"))->values; @@ -713,4 +714,8 @@ ConfigOptionsGroup* get_optgroup() return m_optgroup.get(); } +wxButton* get_wiping_dialog_button(){ + return g_wiping_dialog_button; +} + } } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 084b6de466..7561d256d9 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -18,6 +18,7 @@ class wxArrayLong; class wxColour; class wxBoxSizer; class wxFlexGridSizer; +class wxButton; namespace Slic3r { @@ -129,6 +130,7 @@ wxString from_u8(const std::string &str); void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer); ConfigOptionsGroup* get_optgroup(); +wxButton* get_wiping_dialog_button(); } } diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 0be24824c4..0f165e2d31 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -137,7 +137,7 @@ void OptionsGroup::append_line(const Line& line) { // If there's a widget, build it and add the result to the sizer. if (line.widget != nullptr) { auto wgt = line.widget(parent()); - grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, wxOSX ? 0 : 5); + grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, wxOSX ? 0 : 1); return; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 50de384def..1d92439f9a 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -335,7 +335,11 @@ void Tab::on_value_change(std::string opt_key, boost::any value) bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; get_optgroup()->set_value("brim", val); } - + if (opt_key == "wipe_tower"){ + m_config->opt_bool("wipe_tower") ? + get_wiping_dialog_button()->Show() : + get_wiping_dialog_button()->Hide(); + } update(); } diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index df05522994..421ae272da 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -30,11 +30,11 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) EndModal(wxID_OK); },wxID_OK); this->Show(); - wxMessageDialog(this,L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " + wxMessageDialog(this,_(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " "properly shape the end of the unloaded filament so it does not prevent insertion of the new filament and can itself " "be reinserted later. This phase is important and different materials can require different extrusion speeds to get " "the good shape. For this reason, the extrusion rates during ramming are adjustable.\n\nThis is an expert-level " - "setting, incorrect adjustment will likely lead to jams, extruder wheel grinding into filament etc."),L("Warning"),wxOK|wxICON_EXCLAMATION).ShowModal(); + "setting, incorrect adjustment will likely lead to jams, extruder wheel grinding into filament etc.")),_(L("Warning")),wxOK|wxICON_EXCLAMATION).ShowModal(); } @@ -249,7 +249,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con m_page_advanced->Bind(wxEVT_PAINT,[this](wxPaintEvent&) { wxPaintDC dc(m_page_advanced); int y_pos = 0.5 * (edit_boxes[0][0]->GetPosition().y + edit_boxes[0][edit_boxes.size()-1]->GetPosition().y + edit_boxes[0][edit_boxes.size()-1]->GetSize().y); - wxString label = L("From"); + wxString label = _(L("From")); int text_width = 0; int text_height = 0; dc.GetTextExtent(label,&text_width,&text_height); @@ -314,8 +314,8 @@ bool WipingPanel::advanced_matches_simple() { // Switches the dialog from simple to advanced mode and vice versa void WipingPanel::toggle_advanced(bool user_action) { if (m_advanced && !advanced_matches_simple() && user_action) { - if (wxMessageDialog(this,wxString(L("Switching to simple settings will discard changes done in the advanced mode!\n\nDo you want to proceed?")), - wxString(L("Warning")),wxYES_NO|wxICON_EXCLAMATION).ShowModal() != wxID_YES) + if (wxMessageDialog(this,wxString(_(L("Switching to simple settings will discard changes done in the advanced mode!\n\nDo you want to proceed?"))), + wxString(_(L("Warning"))),wxYES_NO|wxICON_EXCLAMATION).ShowModal() != wxID_YES) return; } if (user_action) @@ -326,7 +326,7 @@ void WipingPanel::toggle_advanced(bool user_action) { (m_advanced ? m_page_advanced : m_page_simple)->Show(); (!m_advanced ? m_page_advanced : m_page_simple)->Hide(); - m_widget_button->SetLabel(m_advanced ? L("Show simplified settings") : L("Show advanced settings")); + m_widget_button->SetLabel(m_advanced ? _(L("Show simplified settings")) : _(L("Show advanced settings"))); if (m_advanced) if (user_action) fill_in_matrix(); // otherwise keep values loaded from config From 42baeee0ed4f4346ab7dc1268614c9452e7325ff Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 4 Apr 2018 09:44:05 +0200 Subject: [PATCH 0102/1150] Fixed a bug regarding the sparse infill --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 4dbc7440e0..e9523b7314 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -1174,7 +1174,7 @@ void WipeTowerPrusaMM::generate(std::vector 1) { // we will merge it to the last toolchange + if ( ! layer.tool_changes.empty() ) { // we will merge it to the last toolchange auto& last_toolchange = layer_result.back(); if (last_toolchange.end_pos != finish_layer_toolchange.start_pos) { char buf[2048]; // Add a travel move from tc1.end_pos to tc2.start_pos. From 719adfbaf3c4584da520f5bc47c302b85c301c70 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 4 Apr 2018 09:59:41 +0200 Subject: [PATCH 0103/1150] The layer height check for multiple objects is now only enabled when variable layer height is enabled --- xs/src/libslic3r/Print.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 267062125e..3ce73ab9a9 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -613,12 +613,14 @@ std::string Print::validate() const object->update_layer_height_profile(); object->layer_height_profile_valid = was_layer_height_profile_valid; - PrintObject* first_object = this->objects.front(); - int i = 0; - while ( i < first_object->layer_height_profile.size() && i < object->layer_height_profile.size() ) { - if (std::abs(first_object->layer_height_profile[i] - object->layer_height_profile[i]) > EPSILON ) - return "The Wipe tower is only supported if all objects have the same layer height profile"; - ++i; + if ( this->config.variable_layer_height ) { + PrintObject* first_object = this->objects.front(); + int i = 0; + while ( i < first_object->layer_height_profile.size() && i < object->layer_height_profile.size() ) { + if (std::abs(first_object->layer_height_profile[i] - object->layer_height_profile[i]) > EPSILON ) + return "The Wipe tower is only supported if all objects have the same layer height profile"; + ++i; + } } /*for (size_t i = 5; i < object->layer_height_profile.size(); i += 2) From be8acc5ac41e9472d45224bce19b36d9c36affb3 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 4 Apr 2018 10:18:26 +0200 Subject: [PATCH 0104/1150] Moved "wiping_volumes_extruders", "wiping_volumes_matrix" from print settings to project settings. --- xs/src/slic3r/GUI/GUI.cpp | 11 ++-- xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/PresetBundle.cpp | 10 ++-- xs/src/slic3r/GUI/Tab.cpp | 89 +++++++----------------------- xs/src/slic3r/GUI/Tab.hpp | 1 - 5 files changed, 34 insertions(+), 79 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 933a1ce0ed..ce47d527bc 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -686,18 +686,19 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl g_wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes")) + "\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(g_wiping_dialog_button); - g_wiping_dialog_button->Bind(wxEVT_BUTTON, ([config, parent](wxCommandEvent& e) + g_wiping_dialog_button->Bind(wxEVT_BUTTON, ([parent](wxCommandEvent& e) { - std::vector init_matrix = (config->option("wiping_volumes_matrix"))->values; - std::vector init_extruders = (config->option("wiping_volumes_extruders"))->values; + auto &config = g_PresetBundle->project_config; + std::vector init_matrix = (config.option("wiping_volumes_matrix"))->values; + std::vector init_extruders = (config.option("wiping_volumes_extruders"))->values; WipingDialog dlg(parent,std::vector(init_matrix.begin(),init_matrix.end()),std::vector(init_extruders.begin(),init_extruders.end())); if (dlg.ShowModal() == wxID_OK) { std::vector matrix = dlg.get_matrix(); std::vector extruders = dlg.get_extruders(); - (config->option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(),matrix.end()); - (config->option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(),extruders.end()); + (config.option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(),matrix.end()); + (config.option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(),extruders.end()); } })); return sizer; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index a0d4fe5ff1..c52df1e358 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -200,7 +200,7 @@ const std::vector& Preset::print_options() "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging", - "wiping_volumes_matrix", "wiping_volumes_extruders", "compatible_printers", "compatible_printers_condition" + "compatible_printers", "compatible_printers_condition" }; return s_opts; diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 1d47958326..0026e5ccff 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -32,7 +32,9 @@ namespace Slic3r { -static std::vector s_project_options { +static std::vector s_project_options { + "wiping_volumes_extruders", + "wiping_volumes_matrix" }; PresetBundle::PresetBundle() : @@ -722,11 +724,11 @@ void PresetBundle::update_multi_material_filament_presets() // Now verify if wiping_volumes_matrix has proper size (it is used to deduce number of extruders in wipe tower generator): - std::vector old_matrix = (prints.get_edited_preset().config.option("wiping_volumes_matrix"))->values; + std::vector old_matrix = this->project_config.option("wiping_volumes_matrix")->values; size_t old_number_of_extruders = int(sqrt(old_matrix.size())+EPSILON); if (num_extruders != old_number_of_extruders) { // First verify if purging volumes presets for each extruder matches number of extruders - std::vector& extruders = (prints.get_edited_preset().config.option("wiping_volumes_extruders"))->values; + std::vector& extruders = this->project_config.option("wiping_volumes_extruders")->values; while (extruders.size() < 2*num_extruders) { extruders.push_back(extruders.size()>1 ? extruders[0] : 50.); // copy the values from the first extruder extruders.push_back(extruders.size()>1 ? extruders[1] : 50.); @@ -745,7 +747,7 @@ void PresetBundle::update_multi_material_filament_presets() else new_matrix.push_back( i==j ? 0. : extruders[2*i]+extruders[2*j+1]); // so it matches new extruder volumes } - (prints.get_edited_preset().config.option("wiping_volumes_matrix"))->values = new_matrix; + this->project_config.option("wiping_volumes_matrix")->values = new_matrix; } } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 1d92439f9a..32a56d9b59 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -523,28 +523,6 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_width"); optgroup->append_single_option_line("wipe_tower_rotation_angle"); optgroup->append_single_option_line("wipe_tower_bridging"); - line = { _(L("Advanced")), "" }; - line.widget = [this](wxWindow* parent){ - m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Purging volumes"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); - auto sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(m_wipe_tower_btn); - m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) - { - std::vector init_matrix = (m_config->option("wiping_volumes_matrix"))->values; - std::vector init_extruders = (m_config->option("wiping_volumes_extruders"))->values; - - WipingDialog dlg(this,std::vector(init_matrix.begin(),init_matrix.end()),std::vector(init_extruders.begin(),init_extruders.end())); - - if (dlg.ShowModal() == wxID_OK) { - std::vector matrix = dlg.get_matrix(); - std::vector extruders = dlg.get_extruders(); - (m_config->option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(),matrix.end()); - (m_config->option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(),extruders.end()); - } - })); - return sizer; - }; - optgroup->append_line(line); optgroup = page->new_optgroup(_(L("Advanced"))); optgroup->append_single_option_line("interface_shells"); @@ -779,53 +757,40 @@ void TabPrint::update() } bool have_perimeters = m_config->opt_int("perimeters") > 0; - std::vector vec_enable = { "extra_perimeters", "ensure_vertical_shell_thickness", "thin_walls", "overhangs", - "seam_position", "external_perimeters_first", "external_perimeter_extrusion_width", - "perimeter_speed", "small_perimeter_speed", "external_perimeter_speed" }; - for (auto el : vec_enable) + for (auto el : {"extra_perimeters", "ensure_vertical_shell_thickness", "thin_walls", "overhangs", + "seam_position", "external_perimeters_first", "external_perimeter_extrusion_width", + "perimeter_speed", "small_perimeter_speed", "external_perimeter_speed" }) get_field(el)->toggle(have_perimeters); bool have_infill = m_config->option("fill_density")->value > 0; - vec_enable.resize(0); - vec_enable = { "fill_pattern", "infill_every_layers", "infill_only_where_needed", - "solid_infill_every_layers", "solid_infill_below_area", "infill_extruder" }; // infill_extruder uses the same logic as in Print::extruders() - for (auto el : vec_enable) + for (auto el : {"fill_pattern", "infill_every_layers", "infill_only_where_needed", + "solid_infill_every_layers", "solid_infill_below_area", "infill_extruder" }) get_field(el)->toggle(have_infill); bool have_solid_infill = m_config->opt_int("top_solid_layers") > 0 || m_config->opt_int("bottom_solid_layers") > 0; - vec_enable.resize(0); - vec_enable = { "external_fill_pattern", "infill_first", "solid_infill_extruder", - "solid_infill_extrusion_width", "solid_infill_speed" }; // solid_infill_extruder uses the same logic as in Print::extruders() - for (auto el : vec_enable) + for (auto el : {"external_fill_pattern", "infill_first", "solid_infill_extruder", + "solid_infill_extrusion_width", "solid_infill_speed" }) get_field(el)->toggle(have_solid_infill); - vec_enable.resize(0); - vec_enable = { "fill_angle", "bridge_angle", "infill_extrusion_width", - "infill_speed", "bridge_speed" }; - for (auto el : vec_enable) + for (auto el : {"fill_angle", "bridge_angle", "infill_extrusion_width", + "infill_speed", "bridge_speed" }) get_field(el)->toggle(have_infill || have_solid_infill); get_field("gap_fill_speed")->toggle(have_perimeters && have_infill); bool have_top_solid_infill = m_config->opt_int("top_solid_layers") > 0; - vec_enable.resize(0); - vec_enable = { "top_infill_extrusion_width", "top_solid_infill_speed" }; - for (auto el : vec_enable) + for (auto el : { "top_infill_extrusion_width", "top_solid_infill_speed" }) get_field(el)->toggle(have_top_solid_infill); bool have_default_acceleration = m_config->opt_float("default_acceleration") > 0; - vec_enable.resize(0); - vec_enable = { "perimeter_acceleration", "infill_acceleration", - "bridge_acceleration", "first_layer_acceleration" }; - for (auto el : vec_enable) + for (auto el : {"perimeter_acceleration", "infill_acceleration", + "bridge_acceleration", "first_layer_acceleration" }) get_field(el)->toggle(have_default_acceleration); bool have_skirt = m_config->opt_int("skirts") > 0 || m_config->opt_float("min_skirt_length") > 0; - vec_enable.resize(0); - vec_enable = { "skirt_distance", "skirt_height" }; - for (auto el : vec_enable) + for (auto el : { "skirt_distance", "skirt_height" }) get_field(el)->toggle(have_skirt); bool have_brim = m_config->opt_float("brim_width") > 0; @@ -836,18 +801,14 @@ void TabPrint::update() bool have_support_material = m_config->opt_bool("support_material") || have_raft; bool have_support_interface = m_config->opt_int("support_material_interface_layers") > 0; bool have_support_soluble = have_support_material && m_config->opt_float("support_material_contact_distance") == 0; - vec_enable.resize(0); - vec_enable = { "support_material_threshold", "support_material_pattern", "support_material_with_sheath", + for (auto el : {"support_material_threshold", "support_material_pattern", "support_material_with_sheath", "support_material_spacing", "support_material_angle", "support_material_interface_layers", "dont_support_bridges", "support_material_extrusion_width", "support_material_contact_distance", - "support_material_xy_spacing" }; - for (auto el : vec_enable) + "support_material_xy_spacing" }) get_field(el)->toggle(have_support_material); - vec_enable.resize(0); - vec_enable = { "support_material_interface_spacing", "support_material_interface_extruder", - "support_material_interface_speed", "support_material_interface_contact_loops" }; - for (auto el : vec_enable) + for (auto el : {"support_material_interface_spacing", "support_material_interface_extruder", + "support_material_interface_speed", "support_material_interface_contact_loops" }) get_field(el)->toggle(have_support_material && have_support_interface); get_field("support_material_synchronize_layers")->toggle(have_support_soluble); @@ -856,20 +817,15 @@ void TabPrint::update() get_field("support_material_speed")->toggle(have_support_material || have_brim || have_skirt); bool have_sequential_printing = m_config->opt_bool("complete_objects"); - vec_enable.resize(0); - vec_enable = { "extruder_clearance_radius", "extruder_clearance_height" }; - for (auto el : vec_enable) + for (auto el : { "extruder_clearance_radius", "extruder_clearance_height" }) get_field(el)->toggle(have_sequential_printing); bool have_ooze_prevention = m_config->opt_bool("ooze_prevention"); get_field("standby_temperature_delta")->toggle(have_ooze_prevention); bool have_wipe_tower = m_config->opt_bool("wipe_tower"); - vec_enable.resize(0); - vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging"}; - for (auto el : vec_enable) + for (auto el : { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging"}) get_field(el)->toggle(have_wipe_tower); - m_wipe_tower_btn->Enable(have_wipe_tower); m_recommended_thin_wall_thickness_description_line->SetText( from_u8(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle))); @@ -1020,13 +976,10 @@ void TabFilament::update() bool cooling = m_config->opt_bool("cooling", 0); bool fan_always_on = cooling || m_config->opt_bool("fan_always_on", 0); - std::vector vec_enable = { "max_fan_speed", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed" }; - for (auto el : vec_enable) + for (auto el : { "max_fan_speed", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed" }) get_field(el)->toggle(cooling); - vec_enable.resize(0); - vec_enable = { "min_fan_speed", "disable_fan_first_layers" }; - for (auto el : vec_enable) + for (auto el : { "min_fan_speed", "disable_fan_first_layers" }) get_field(el)->toggle(fan_always_on); } diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 234c907658..4f65f14759 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -90,7 +90,6 @@ protected: wxImageList* m_icons; wxCheckBox* m_compatible_printers_checkbox; wxButton* m_compatible_printers_btn; - wxButton* m_wipe_tower_btn; int m_icon_count; std::map m_icon_index; // Map from an icon file name to its index in $self->{icons}. From 2f6fbfb3381edcca6f81794c1fd2c76439c89a44 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 4 Apr 2018 11:00:25 +0200 Subject: [PATCH 0105/1150] Fix of SPE-183: Incorrect z values set into GCode Preview sliders. Rework to replace layer top heights with averages of EPSILON intervals. --- xs/src/slic3r/GUI/3DScene.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 95a7393533..0db81d99bb 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -642,24 +642,25 @@ void GLVolumeCollection::update_outside_state(const DynamicPrintConfig* config, std::vector GLVolumeCollection::get_current_print_zs() const { + // Collect layer top positions of all volumes. std::vector print_zs; - std::vector rounded_print_zs; - for (GLVolume *vol : this->volumes) - { - for (coordf_t z : vol->print_zs) - { - double round_z = ::round(z * 100000.0 + 0.5) / 100000.0; - if (std::find(rounded_print_zs.begin(), rounded_print_zs.end(), round_z) == rounded_print_zs.end()) - { - print_zs.push_back(z); - rounded_print_zs.push_back(round_z); - } - } - } - + append(print_zs, vol->print_zs); std::sort(print_zs.begin(), print_zs.end()); + // Replace intervals of layers with similar top positions with their average value. + int n = int(print_zs.size()); + int k = 0; + for (int i = 0; i < n;) { + int j = i + 1; + coordf_t zmax = print_zs[i] + EPSILON; + for (; j < n && print_zs[j] <= zmax; ++ j) ; + print_zs[k ++] = (j > i + 1) ? (0.5 * (print_zs[i] + print_zs[j - 1])) : print_zs[i]; + i = j; + } + if (k < n) + print_zs.erase(print_zs.begin() + k, print_zs.end()); + return print_zs; } From 1b08bc94f07930a5ebeb659f785b67a7c9eb6115 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 4 Apr 2018 11:13:28 +0200 Subject: [PATCH 0106/1150] Added g_wiping_dialog_button status update to update_frequently_changed_parameters() --- xs/src/slic3r/GUI/Tab.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 1d92439f9a..534cd3aa9d 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -372,6 +372,10 @@ void Tab::update_frequently_changed_parameters() bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; get_optgroup()->set_value("brim", val); + + m_config->opt_bool("wipe_tower") ? + get_wiping_dialog_button()->Show() : + get_wiping_dialog_button()->Hide(); } void Tab::reload_compatible_printers_widget() From b0840065ed84f4006207b38de3c9c6a5e15a7071 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 4 Apr 2018 11:18:22 +0200 Subject: [PATCH 0107/1150] Octoprint (#804) * Octoprint progress dialog * Fix curl version on Windows --- doc/How to build - Windows.md | 7 +- doc/deps-build/windows/slic3r-makedeps.ps1 | 2 +- lib/Slic3r/GUI/Plater.pm | 6 +- xs/src/slic3r/Utils/Http.cpp | 75 +++++++++++++++++++--- xs/src/slic3r/Utils/Http.hpp | 17 +++++ xs/src/slic3r/Utils/OctoPrint.cpp | 66 ++++++++++++------- xs/src/slic3r/Utils/OctoPrint.hpp | 2 +- xs/xsp/Utils_OctoPrint.xsp | 2 +- 8 files changed, 136 insertions(+), 41 deletions(-) diff --git a/doc/How to build - Windows.md b/doc/How to build - Windows.md index 104720b34e..8b7d37cdde 100644 --- a/doc/How to build - Windows.md +++ b/doc/How to build - Windows.md @@ -1,8 +1,9 @@ # Building Slic3r PE on Microsoft Windows -The currently supported way of building Slic3r PE on Windows is with MS Visual Studio 2013 +The currently supported way of building Slic3r PE on Windows is with CMake and MS Visual Studio 2013 using our Perl binary distribution (compiled from official Perl sources). You can use the free [Visual Studio 2013 Community Edition](https://www.visualstudio.com/vs/older-downloads/). +CMake installer can be downloaded from [the official website](https://cmake.org/download/). Other setups (such as mingw + Strawberry Perl) _may_ work, but we cannot guarantee this will work and cannot provide guidance. @@ -26,8 +27,8 @@ Apart from wxWidgets and Perl, you will also need additional dependencies: We have prepared a binary package of the listed libraries: - - 32 bit: [slic3r-destdir-32.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=slic3r-destdir-32.7z) - - 64 bit: [slic3r-destdir-64.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=slic3r-destdir-64.7z) + - 32 bit: [slic3r-destdir-32.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=2%2Fslic3r-destdir-32.7z) + - 64 bit: [slic3r-destdir-64.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=2%2Fslic3r-destdir-64.7z) It is recommended you unpack this package into `C:\local\` as the environment setup script expects it there. diff --git a/doc/deps-build/windows/slic3r-makedeps.ps1 b/doc/deps-build/windows/slic3r-makedeps.ps1 index 8b39cae301..e256d61e42 100644 --- a/doc/deps-build/windows/slic3r-makedeps.ps1 +++ b/doc/deps-build/windows/slic3r-makedeps.ps1 @@ -37,7 +37,7 @@ if ($destdir -eq "") { } $BOOST = 'boost_1_63_0' -$CURL = 'curl-7.28.0' +$CURL = 'curl-7.58.0' $TBB_SHA = 'a0dc9bf76d0120f917b641ed095360448cabc85b' $TBB = "tbb-$TBB_SHA" diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 0138d3f39e..14c2d66ae5 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1481,7 +1481,11 @@ sub on_export_completed { # Send $self->{send_gcode_file} to OctoPrint. if ($send_gcode) { my $op = Slic3r::OctoPrint->new($self->{config}); - $op->send_gcode($self->GetId(), $PROGRESS_BAR_EVENT, $ERROR_EVENT, $self->{send_gcode_file}); + if ($op->send_gcode($self->{send_gcode_file})) { + $self->statusbar->SetStatusText(L("OctoPrint upload finished.")); + } else { + $self->statusbar->SetStatusText(""); + } } $self->{print_file} = undef; diff --git a/xs/src/slic3r/Utils/Http.cpp b/xs/src/slic3r/Utils/Http.cpp index de28904e21..0826284d8a 100644 --- a/xs/src/slic3r/Utils/Http.cpp +++ b/xs/src/slic3r/Utils/Http.cpp @@ -36,16 +36,20 @@ struct Http::priv ::curl_slist *headerlist; std::string buffer; size_t limit; + bool cancel; std::thread io_thread; Http::CompleteFn completefn; Http::ErrorFn errorfn; + Http::ProgressFn progressfn; priv(const std::string &url); ~priv(); static bool ca_file_supported(::CURL *curl); static size_t writecb(void *data, size_t size, size_t nmemb, void *userp); + static int xfercb(void *userp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow); + static int xfercb_legacy(void *userp, double dltotal, double dlnow, double ultotal, double ulnow); std::string curl_error(CURLcode curlcode); std::string body_size_error(); void http_perform(); @@ -55,7 +59,8 @@ Http::priv::priv(const std::string &url) : curl(::curl_easy_init()), form(nullptr), form_end(nullptr), - headerlist(nullptr) + headerlist(nullptr), + cancel(false) { if (curl == nullptr) { throw std::runtime_error(std::string("Could not construct Curl object")); @@ -112,6 +117,24 @@ size_t Http::priv::writecb(void *data, size_t size, size_t nmemb, void *userp) return realsize; } +int Http::priv::xfercb(void *userp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) +{ + auto self = static_cast(userp); + bool cb_cancel = false; + + if (self->progressfn) { + Progress progress(dltotal, dlnow, ultotal, ulnow); + self->progressfn(progress, cb_cancel); + } + + return self->cancel || cb_cancel; +} + +int Http::priv::xfercb_legacy(void *userp, double dltotal, double dlnow, double ultotal, double ulnow) +{ + return xfercb(userp, dltotal, dlnow, ultotal, ulnow); +} + std::string Http::priv::curl_error(CURLcode curlcode) { return (boost::format("%1% (%2%)") @@ -132,6 +155,16 @@ void Http::priv::http_perform() ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb); ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, static_cast(this)); + ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); +#if LIBCURL_VERSION_MAJOR >= 7 && LIBCURL_VERSION_MINOR >= 32 + ::curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, xfercb); + ::curl_easy_setopt(curl, CURLOPT_XFERINFODATA, static_cast(this)); + (void)xfercb_legacy; // prevent unused function warning +#else + ::curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, xfercb); + ::curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, static_cast(this)); +#endif + #ifndef NDEBUG ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); #endif @@ -149,16 +182,16 @@ void Http::priv::http_perform() ::curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_status); if (res != CURLE_OK) { - std::string error; - if (res == CURLE_WRITE_ERROR) { - error = std::move(body_size_error()); - } else { - error = std::move(curl_error(res)); - }; - - if (errorfn) { - errorfn(std::move(buffer), std::move(error), http_status); + if (res == CURLE_ABORTED_BY_CALLBACK) { + Progress dummyprogress(0, 0, 0, 0); + bool cancel = true; + if (progressfn) { progressfn(dummyprogress, cancel); } } + else if (res == CURLE_WRITE_ERROR) { + if (errorfn) { errorfn(std::move(buffer), std::move(body_size_error()), http_status); } + } else { + if (errorfn) { errorfn(std::move(buffer), std::move(curl_error(res)), http_status); } + }; } else { if (completefn) { completefn(std::move(buffer), http_status); @@ -258,6 +291,12 @@ Http& Http::on_error(ErrorFn fn) return *this; } +Http& Http::on_progress(ProgressFn fn) +{ + if (p) { p->progressfn = std::move(fn); } + return *this; +} + Http::Ptr Http::perform() { auto self = std::make_shared(std::move(*this)); @@ -277,6 +316,11 @@ void Http::perform_sync() if (p) { p->http_perform(); } } +void Http::cancel() +{ + if (p) { p->cancel = true; } +} + Http Http::get(std::string url) { return std::move(Http{std::move(url)}); @@ -297,5 +341,16 @@ bool Http::ca_file_supported() return res; } +std::ostream& operator<<(std::ostream &os, const Http::Progress &progress) +{ + os << "Http::Progress(" + << "dltotal = " << progress.dltotal + << ", dlnow = " << progress.dlnow + << ", ultotal = " << progress.ultotal + << ", ulnow = " << progress.ulnow + << ")"; + return os; +} + } diff --git a/xs/src/slic3r/Utils/Http.hpp b/xs/src/slic3r/Utils/Http.hpp index 6ac5fcce10..7ed8196e63 100644 --- a/xs/src/slic3r/Utils/Http.hpp +++ b/xs/src/slic3r/Utils/Http.hpp @@ -14,9 +14,22 @@ class Http : public std::enable_shared_from_this { private: struct priv; public: + struct Progress + { + size_t dltotal; + size_t dlnow; + size_t ultotal; + size_t ulnow; + + Progress(size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow) : + dltotal(dltotal), dlnow(dlnow), ultotal(ultotal), ulnow(ulnow) + {} + }; + typedef std::shared_ptr Ptr; typedef std::function CompleteFn; typedef std::function ErrorFn; + typedef std::function ProgressFn; Http(Http &&other); @@ -37,9 +50,11 @@ public: Http& on_complete(CompleteFn fn); Http& on_error(ErrorFn fn); + Http& on_progress(ProgressFn fn); Ptr perform(); void perform_sync(); + void cancel(); static bool ca_file_supported(); private: @@ -48,6 +63,8 @@ private: std::unique_ptr p; }; +std::ostream& operator<<(std::ostream &, const Http::Progress &); + } diff --git a/xs/src/slic3r/Utils/OctoPrint.cpp b/xs/src/slic3r/Utils/OctoPrint.cpp index 5bf51f470a..e63a16c386 100644 --- a/xs/src/slic3r/Utils/OctoPrint.cpp +++ b/xs/src/slic3r/Utils/OctoPrint.cpp @@ -1,10 +1,11 @@ #include "OctoPrint.hpp" -#include +#include #include #include #include +#include #include "libslic3r/PrintConfig.hpp" #include "slic3r/GUI/GUI.hpp" @@ -39,36 +40,53 @@ bool OctoPrint::test(wxString &msg) const return res; } -void OctoPrint::send_gcode(int windowId, int completeEvt, int errorEvt, const std::string &filename, bool print) const +bool OctoPrint::send_gcode(const std::string &filename, bool print) const { + enum { PROGRESS_RANGE = 1000 }; + + const auto errortitle = _(L("Error while uploading to the OctoPrint server")); + + wxProgressDialog progress_dialog( + _(L("OctoPrint upload")), + _(L("Sending G-code file to the OctoPrint server...")), + PROGRESS_RANGE, nullptr, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); + progress_dialog.Pulse(); + + wxString test_msg; + if (!test(test_msg)) { + auto errormsg = wxString::Format("%s: %s", errortitle, test_msg); + GUI::show_error(&progress_dialog, std::move(errormsg)); + return false; + } + + bool res = true; + auto http = Http::post(std::move(make_url("api/files/local"))); set_auth(http); http.form_add("print", print ? "true" : "false") .form_add_file("file", filename) - .on_complete([=](std::string body, unsigned status) { - wxWindow *window = wxWindow::FindWindowById(windowId); - if (window == nullptr) { return; } - - wxCommandEvent* evt = new wxCommandEvent(completeEvt); - evt->SetString(_(L("G-code file successfully uploaded to the OctoPrint server"))); - evt->SetInt(100); - wxQueueEvent(window, evt); + .on_complete([&](std::string body, unsigned status) { + progress_dialog.Update(PROGRESS_RANGE); }) - .on_error([=](std::string body, std::string error, unsigned status) { - wxWindow *window = wxWindow::FindWindowById(windowId); - if (window == nullptr) { return; } - - wxCommandEvent* evt_complete = new wxCommandEvent(completeEvt); - evt_complete->SetInt(100); - wxQueueEvent(window, evt_complete); - - wxCommandEvent* evt_error = new wxCommandEvent(errorEvt); - evt_error->SetString(wxString::Format("%s: %s", - _(L("Error while uploading to the OctoPrint server")), - format_error(error, status))); - wxQueueEvent(window, evt_error); + .on_error([&](std::string body, std::string error, unsigned status) { + auto errormsg = wxString::Format("%s: %s", errortitle, format_error(error, status)); + GUI::show_error(&progress_dialog, std::move(errormsg)); + res = false; }) - .perform(); + .on_progress([&](Http::Progress progress, bool &cancel) { + if (cancel) { + // Upload was canceled + res = false; + } else if (progress.ultotal > 0) { + int value = PROGRESS_RANGE * progress.ulnow / progress.ultotal; + cancel = !progress_dialog.Update(std::min(value, PROGRESS_RANGE - 1)); // Cap the value to prevent premature dialog closing + } else { + cancel = !progress_dialog.Pulse(); + } + }) + .perform_sync(); + + return res; } void OctoPrint::set_auth(Http &http) const diff --git a/xs/src/slic3r/Utils/OctoPrint.hpp b/xs/src/slic3r/Utils/OctoPrint.hpp index 1f544295ce..744b4fcc11 100644 --- a/xs/src/slic3r/Utils/OctoPrint.hpp +++ b/xs/src/slic3r/Utils/OctoPrint.hpp @@ -17,7 +17,7 @@ public: OctoPrint(DynamicPrintConfig *config); bool test(wxString &curl_msg) const; - void send_gcode(int windowId, int completeEvt, int errorEvt, const std::string &filename, bool print = false) const; + bool send_gcode(const std::string &filename, bool print = false) const; private: std::string host; std::string apikey; diff --git a/xs/xsp/Utils_OctoPrint.xsp b/xs/xsp/Utils_OctoPrint.xsp index 124f66cb59..282a3055d4 100644 --- a/xs/xsp/Utils_OctoPrint.xsp +++ b/xs/xsp/Utils_OctoPrint.xsp @@ -9,5 +9,5 @@ OctoPrint(DynamicPrintConfig *config); ~OctoPrint(); - void send_gcode(int windowId, int completeEvt, int errorEvt, std::string filename, bool print = false) const; + bool send_gcode(std::string filename, bool print = false) const; }; From 597e8650a6f35b5c40b98d5512598066bde2a464 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 4 Apr 2018 12:49:16 +0200 Subject: [PATCH 0108/1150] Fixed incorrect redraw of Purging volumes button in certain cases --- xs/src/slic3r/GUI/Tab.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 32fac14239..bb0e859e6e 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -376,6 +376,7 @@ void Tab::update_frequently_changed_parameters() m_config->opt_bool("wipe_tower") ? get_wiping_dialog_button()->Show() : get_wiping_dialog_button()->Hide(); + (get_wiping_dialog_button()->GetParent())->Layout(); } void Tab::reload_compatible_printers_widget() From 290e3e66c01dbb181ab05a6fa551ec3b66dd7220 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 4 Apr 2018 14:41:23 +0200 Subject: [PATCH 0109/1150] Merge correction --- xs/src/slic3r/GUI/GUI.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 3fc3bfba2b..80a6427d5e 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -716,8 +716,10 @@ ConfigOptionsGroup* get_optgroup() } -wxButton* get_wiping_dialog_button(){ +wxButton* get_wiping_dialog_button() +{ return g_wiping_dialog_button; +} wxWindow* export_option_creator(wxWindow* parent) { @@ -762,6 +764,9 @@ int get_export_option(wxFileDialog* dlg) } return 0; + } -} } + +} // namespace GUI +} // namespace Slic3r From 706dd7020fedbd0aa8e0e90642fcf508350ec604 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 4 Apr 2018 14:59:31 +0200 Subject: [PATCH 0110/1150] New extruder temperature is only set when it differs from the old one --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index e9523b7314..682845135d 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -260,10 +260,13 @@ public: // Set extruder temperature, don't wait by default. Writer& set_extruder_temp(int temperature, bool wait = false) { - char buf[128]; - sprintf(buf, "M%d S%d\n", wait ? 109 : 104, temperature); - m_gcode += buf; - return *this; + if (temperature != current_temp) { + char buf[128]; + sprintf(buf, "M%d S%d\n", wait ? 109 : 104, temperature); + m_gcode += buf; + current_temp = temperature; + } + return *this; }; // Wait for a period of time (seconds). @@ -377,6 +380,7 @@ private: float m_wipe_tower_width = 0.f; float m_wipe_tower_depth = 0.f; float m_last_fan_speed = 0.f; + int current_temp = -1; std::string set_format_X(float x) From 2eee3a64b77c165bd6166caf3e1a24fd32b931b9 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 4 Apr 2018 20:37:37 +0200 Subject: [PATCH 0111/1150] First try to fix bug with CheckBox selection if cursor is in SpinCtrl. --- xs/src/slic3r/GUI/Field.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index e4475b3f3e..e8f055aeab 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -207,7 +207,7 @@ public: m_disable_change_event = false; } boost::any get_value() override { - return boost::any(dynamic_cast(window)->GetValue()); + return boost::any(tmp_value); } void enable() override { dynamic_cast(window)->Enable(); } From 1e185dacc466dec21fd3663999dde60be6f604ee Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 5 Apr 2018 09:02:03 +0200 Subject: [PATCH 0112/1150] Out of bed detection - GUI buttons disabled after object load if model detected as out of bed --- lib/Slic3r/GUI/Plater.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 14c2d66ae5..ecac430a44 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -105,7 +105,6 @@ sub new { $self->{btn_reslice}->Enable($enable); $self->{btn_print}->Enable($enable); $self->{btn_send_gcode}->Enable($enable); - $self->{btn_export_stl}->Enable($enable); }; # Initialize 3D plater @@ -1915,7 +1914,8 @@ sub object_list_changed { } my $export_in_progress = $self->{export_gcode_output_file} || $self->{send_gcode_file}; - my $method = ($have_objects && ! $export_in_progress) ? 'Enable' : 'Disable'; + my $model_fits = $self->{model}->fits_print_volume($self->{config}); + my $method = ($have_objects && ! $export_in_progress && $model_fits) ? 'Enable' : 'Disable'; $self->{"btn_$_"}->$method for grep $self->{"btn_$_"}, qw(reslice export_gcode print send_gcode); } From 4611b5094e87c93faf95d36a2690ec232dc5e962 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 5 Apr 2018 10:31:53 +0200 Subject: [PATCH 0113/1150] Fixed regression of the gyroid infill. --- xs/src/libslic3r/Fill/FillGyroid.cpp | 21 ++++++++++++--------- xs/src/libslic3r/Fill/FillGyroid.hpp | 4 ---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/xs/src/libslic3r/Fill/FillGyroid.cpp b/xs/src/libslic3r/Fill/FillGyroid.cpp index e63ce0bfdc..a3920caab1 100644 --- a/xs/src/libslic3r/Fill/FillGyroid.cpp +++ b/xs/src/libslic3r/Fill/FillGyroid.cpp @@ -41,7 +41,7 @@ static inline Polyline make_wave_horizontal( polyline.points.emplace_back(Point(0, coord_t(clamp(0., height, y0) * scaleFactor))); double phase_offset_sin = (z_sin < 0 ? M_PI : 0) + (flip ? 0 : M_PI); double phase_offset_cos = z_sin < 0 ? M_PI : 0.; - for (double x=0.; x < width + segmentSize; x += segmentSize) { + for (double x = 0.; x < width + segmentSize; x += segmentSize) { x = std::min(x, width); double a = cos(x + phase_offset_cos); double b = - z_sin; @@ -55,10 +55,10 @@ static inline Polyline make_wave_horizontal( return polyline; } -static Polylines make_gyroid_waves(double gridZ, double density, double layer_width, double width, double height) +static Polylines make_gyroid_waves(double gridZ, double density_adjusted, double line_spacing, double width, double height) { - double scaleFactor = scale_(layer_width) / density; - double segmentSize = 0.5 * density; + double scaleFactor = scale_(line_spacing) / density_adjusted; + double segmentSize = 0.5 * density_adjusted; //scale factor for 5% : 8 712 388 // 1z = 10^-6 mm ? double z = gridZ / scaleFactor; @@ -74,7 +74,7 @@ static Polylines make_gyroid_waves(double gridZ, double density, double layer_wi } else { // Horizontal wave bool flip = true; - for (double y0 = 0.; y0 < width; y0 += M_PI, flip = !flip) + for (double y0 = 0.; y0 < height; y0 += M_PI, flip = !flip) result.emplace_back(make_wave_horizontal(width, height, y0, segmentSize, scaleFactor, z_cos, z_sin, flip)); } return result; @@ -87,17 +87,20 @@ void FillGyroid::_fill_surface_single( ExPolygon &expolygon, Polylines &polylines_out) { - // no rotation is supported for this infill pattern + // no rotation is supported for this infill pattern (yet) BoundingBox bb = expolygon.contour.bounding_box(); - coord_t distance = coord_t(scale_(this->spacing) / (params.density*this->scaling)); + // Density adjusted to have a good %of weight. + double density_adjusted = params.density * 1.75; + // Distance between the gyroid waves in scaled coordinates. + coord_t distance = coord_t(scale_(this->spacing) / density_adjusted); // align bounding box to a multiple of our grid module - bb.merge(_align_to_grid(bb.min, Point(2*M_PI*distance, 2*M_PI*distance))); + bb.merge(_align_to_grid(bb.min, Point(2.*M_PI*distance, 2.*M_PI*distance))); // generate pattern Polylines polylines = make_gyroid_waves( scale_(this->z), - params.density*this->scaling, + density_adjusted, this->spacing, ceil(bb.size().x / distance) + 1., ceil(bb.size().y / distance) + 1.); diff --git a/xs/src/libslic3r/Fill/FillGyroid.hpp b/xs/src/libslic3r/Fill/FillGyroid.hpp index 758652a5cb..17924b5ab2 100644 --- a/xs/src/libslic3r/Fill/FillGyroid.hpp +++ b/xs/src/libslic3r/Fill/FillGyroid.hpp @@ -17,10 +17,6 @@ public: virtual bool use_bridge_flow() const { return true; } protected: - - // mult of density, to have a good %of weight for each density parameter - float scaling = 1.75; - virtual void _fill_surface_single( const FillParams ¶ms, unsigned int thickness_layers, From 6af45362ce85bf4debb3f4483d74a0e973ffb377 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 5 Apr 2018 10:44:31 +0200 Subject: [PATCH 0114/1150] Purging volumes button is only shown when the wipe tower is enabled and we have single extruder MM printer with more than one extruder --- xs/src/slic3r/GUI/Tab.cpp | 32 ++++++++++++++++++++++---------- xs/src/slic3r/GUI/Tab.hpp | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index bb0e859e6e..e05dda8c4b 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -335,15 +335,28 @@ void Tab::on_value_change(std::string opt_key, boost::any value) bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; get_optgroup()->set_value("brim", val); } - if (opt_key == "wipe_tower"){ - m_config->opt_bool("wipe_tower") ? - get_wiping_dialog_button()->Show() : - get_wiping_dialog_button()->Hide(); - } - + + if (opt_key == "wipe_tower" || opt_key == "single_extruder_multi_material" || opt_key == "extruders_count" ) + update_wiping_button_visibility(); + update(); } + +// Show/hide the 'purging volumes' button +void Tab::update_wiping_button_visibility() { + bool wipe_tower_enabled = dynamic_cast( (m_preset_bundle->prints.get_edited_preset().config ).option("wipe_tower"))->value; + bool multiple_extruders = dynamic_cast((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1; + bool single_extruder_mm = dynamic_cast( (m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value; + + if (wipe_tower_enabled && multiple_extruders && single_extruder_mm) + get_wiping_dialog_button()->Show(); + else get_wiping_dialog_button()->Hide(); + + (get_wiping_dialog_button()->GetParent())->Layout(); +} + + // Call a callback to update the selection of presets on the platter: // To update the content of the selection boxes, // to update the filament colors of the selection boxes, @@ -373,10 +386,7 @@ void Tab::update_frequently_changed_parameters() bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; get_optgroup()->set_value("brim", val); - m_config->opt_bool("wipe_tower") ? - get_wiping_dialog_button()->Show() : - get_wiping_dialog_button()->Hide(); - (get_wiping_dialog_button()->GetParent())->Layout(); + update_wiping_button_visibility(); } void Tab::reload_compatible_printers_widget() @@ -1062,6 +1072,8 @@ void TabPrinter::build() if (opt_key.compare("extruders_count")==0 || opt_key.compare("single_extruder_multi_material")==0) { extruders_count_changed(extruders_count); update_dirty(); + if (opt_key.compare("single_extruder_multi_material")==0) // the single_extruder_multimaterial was added to force pages + on_value_change(opt_key, value); // rebuild - let's make sure the on_value_change is not skipped } else { update_dirty(); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 4f65f14759..f4aafd184c 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -174,6 +174,7 @@ public: protected: void on_presets_changed(); void update_frequently_changed_parameters(); + void update_wiping_button_visibility(); }; //Slic3r::GUI::Tab::Print; From 28b6d222f2988d3cd7a4c2b2ae9d3e28eb3ee3f8 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 5 Apr 2018 12:12:35 +0200 Subject: [PATCH 0115/1150] Next try to fix bug with CheckBox selection if cursor is in SpinCtrl. --- xs/src/slic3r/GUI/Field.cpp | 4 ++-- xs/src/slic3r/GUI/Field.hpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 70a8b84cf1..36ef9098f8 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -265,8 +265,8 @@ void SpinCtrl::BUILD() { auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, 0, min_val, max_val, default_value); - temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { tmp_value = undef_spin_val; on_change_field(); }), temp->GetId()); - temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { tmp_value = undef_spin_val; on_kill_focus(e); }), temp->GetId()); +// temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { tmp_value = undef_spin_val; on_change_field(); }), temp->GetId()); +// temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { tmp_value = undef_spin_val; on_kill_focus(e); }), temp->GetId()); temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { // # On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index e8f055aeab..da3e23ccd8 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -203,7 +203,8 @@ public: } void set_value(boost::any value, bool change_event = false) { m_disable_change_event = !change_event; - dynamic_cast(window)->SetValue(boost::any_cast(value)); + tmp_value = boost::any_cast(value); + dynamic_cast(window)->SetValue(tmp_value/*boost::any_cast(value)*/); m_disable_change_event = false; } boost::any get_value() override { From 76beaa6421ca1391c1463ce68d3bc21615f68e67 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 5 Apr 2018 12:52:29 +0200 Subject: [PATCH 0116/1150] Objects colored by extruder color --- lib/Slic3r/GUI/3DScene.pm | 5 ++ lib/Slic3r/GUI/Plater/3D.pm | 2 + lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 1 + lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 1 + xs/src/slic3r/GUI/3DScene.cpp | 96 ++++++++++++++++++++++- xs/src/slic3r/GUI/3DScene.hpp | 10 +++ xs/src/slic3r/GUI/PresetBundle.cpp | 2 +- xs/src/slic3r/GUI/PresetBundle.hpp | 2 + xs/xsp/GUI_3DScene.xsp | 1 + 9 files changed, 118 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index c05de06c67..a89ed08884 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1677,6 +1677,11 @@ sub draw_warning { } } +sub update_volumes_colors_by_extruder { + my ($self, $config) = @_; + $self->volumes->update_colors_by_extruder($config); +} + sub opengl_info { my ($self, %params) = @_; diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index 09cc029302..36d55d27be 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -216,6 +216,8 @@ sub reload_scene { } } + $self->update_volumes_colors_by_extruder($self->{config}); + # checks for geometry outside the print volume to render it accordingly if (scalar @{$self->volumes} > 0) { diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 7712bd01d0..0b5312b30a 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -247,6 +247,7 @@ sub _update { $self->{cut_options}{z}, [@expolygons], ); + $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config}); $self->{canvas}->Render; } } diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 8a8e6064c8..424d88d699 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -162,6 +162,7 @@ sub new { $canvas->load_object($self->{model_object}, undef, undef, [0]); $canvas->set_auto_bed_shape; $canvas->SetSize([500,700]); + $canvas->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); $canvas->zoom_to_volumes; } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index a459b7cbf5..1ce3d76bfd 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -9,6 +9,7 @@ #include "../../libslic3r/GCode/PreviewData.hpp" #include "../../libslic3r/Print.hpp" #include "../../libslic3r/Slicing.hpp" +#include "../../slic3r/GUI/PresetBundle.hpp" #include "GCode/Analyzer.hpp" #include @@ -381,6 +382,15 @@ std::vector GLVolumeCollection::load_object( std::vector volumes_idx; for (int volume_idx = 0; volume_idx < int(model_object->volumes.size()); ++ volume_idx) { const ModelVolume *model_volume = model_object->volumes[volume_idx]; + + int extruder_id = -1; + if (!model_volume->modifier) + { + extruder_id = model_volume->config.has("extruder") ? model_volume->config.option("extruder")->getInt() : 0; + if (extruder_id == 0) + extruder_id = model_object->config.has("extruder") ? model_object->config.option("extruder")->getInt() : 0; + } + for (int instance_idx : instance_idxs) { const ModelInstance *instance = model_object->instances[instance_idx]; TriangleMesh mesh = model_volume->mesh; @@ -410,8 +420,14 @@ std::vector GLVolumeCollection::load_object( v.drag_group_id = obj_idx * 1000; else if (drag_by == "instance") v.drag_group_id = obj_idx * 1000 + instance_idx; - if (! model_volume->modifier) + + if (!model_volume->modifier) + { v.layer_height_texture = layer_height_texture; + if (extruder_id != -1) + v.extruder_id = extruder_id; + } + v.is_modifier = model_volume->modifier; } } @@ -438,6 +454,7 @@ int GLVolumeCollection::load_wipe_tower_preview( v.composite_id = obj_idx * 1000000; v.select_group_id = obj_idx * 1000000; v.drag_group_id = obj_idx * 1000; + v.is_wipe_tower = true; return int(this->volumes.size() - 1); } @@ -642,6 +659,83 @@ void GLVolumeCollection::update_outside_state(const DynamicPrintConfig* config, } } +void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* config) +{ + static const float inv_255 = 1.0f / 255.0f; + + struct Color + { + std::string text; + unsigned char rgb[3]; + + Color() + : text("") + { + rgb[0] = 255; + rgb[1] = 255; + rgb[2] = 255; + } + + void set(const std::string& text, unsigned char* rgb) + { + this->text = text; + ::memcpy((void*)this->rgb, (const void*)rgb, 3 * sizeof(unsigned char)); + } + }; + + if (config == nullptr) + return; + + const ConfigOptionStrings* extruders_opt = dynamic_cast(config->option("extruder_colour")); + if (extruders_opt == nullptr) + return; + + const ConfigOptionStrings* filamemts_opt = dynamic_cast(config->option("filament_colour")); + if (filamemts_opt == nullptr) + return; + + unsigned int colors_count = std::max((unsigned int)extruders_opt->values.size(), (unsigned int)filamemts_opt->values.size()); + if (colors_count == 0) + return; + + std::vector colors(colors_count); + + unsigned char rgb[3]; + for (unsigned int i = 0; i < colors_count; ++i) + { + const std::string& txt_color = config->opt_string("extruder_colour", i); + if (PresetBundle::parse_color(txt_color, rgb)) + { + colors[i].set(txt_color, rgb); + } + else + { + const std::string& txt_color = config->opt_string("filament_colour", i); + if (PresetBundle::parse_color(txt_color, rgb)) + colors[i].set(txt_color, rgb); + } + } + + for (GLVolume* volume : volumes) + { + if ((volume == nullptr) || volume->is_modifier || volume->is_wipe_tower) + continue; + + int extruder_id = volume->extruder_id - 1; + if ((extruder_id < 0) || ((unsigned int)colors.size() <= extruder_id)) + extruder_id = 0; + + const Color& color = colors[extruder_id]; + if (!color.text.empty()) + { + for (int i = 0; i < 3; ++i) + { + volume->color[i] = (float)color.rgb[i] * inv_255; + } + } + } +} + std::vector GLVolumeCollection::get_current_print_zs() const { // Collect layer top positions of all volumes. diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 0fd31d8d69..6486a7f0e7 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -246,12 +246,15 @@ public: composite_id(-1), select_group_id(-1), drag_group_id(-1), + extruder_id(0), selected(false), is_active(true), zoom_to_volumes(true), outside_printer_detection_enabled(true), is_outside(false), hover(false), + is_modifier(false), + is_wipe_tower(false), tverts_range(0, size_t(-1)), qverts_range(0, size_t(-1)) { @@ -287,6 +290,8 @@ public: int select_group_id; // An ID for group dragging. It may be the same for all meshes of all object instances, or for just a single object instance. int drag_group_id; + // An ID containing the extruder ID (used to select color). + int extruder_id; // Is this object selected? bool selected; // Whether or not this volume is active for rendering @@ -299,6 +304,10 @@ public: bool is_outside; // Boolean: Is mouse over this object? bool hover; + // Wheter or not this volume has been generated from a modifier + bool is_modifier; + // Wheter or not this volume has been generated from the wipe tower + bool is_wipe_tower; // Interleaved triangles & normals with indexed triangles & quads. GLIndexedVertexArray indexed_vertex_array; @@ -417,6 +426,7 @@ public: } void update_outside_state(const DynamicPrintConfig* config, bool all_inside); + void update_colors_by_extruder(const DynamicPrintConfig* config); // Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection std::vector get_current_print_zs() const; diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index bf79c6562e..ce56d4cb1f 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -788,7 +788,7 @@ static inline int hex_digit_to_int(const char c) (c >= 'a' && c <= 'f') ? int(c - 'a') + 10 : -1; } -static inline bool parse_color(const std::string &scolor, unsigned char *rgb_out) +bool PresetBundle::parse_color(const std::string &scolor, unsigned char *rgb_out) { rgb_out[0] = rgb_out[1] = rgb_out[2] = 0; if (scolor.size() != 7 || scolor.front() != '#') diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index e6aea206d1..e25647c7b1 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -98,6 +98,8 @@ public: // preset if the current print or filament preset is not compatible. void update_compatible_with_printer(bool select_other_if_incompatible); + static bool parse_color(const std::string &scolor, unsigned char *rgb_out); + private: // Load print, filament & printer presets from a config. If it is an external config, then the name is extracted from the external path. // and the external config is just referenced, not stored into user profile directory. diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 25aa6b81a7..ce773adebf 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -105,6 +105,7 @@ 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); + void update_colors_by_extruder(DynamicPrintConfig* config); bool move_volume_up(int idx) %code%{ From 6053c8f54d362c3ac276a9e088de32025a1bc198 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 5 Apr 2018 13:52:30 +0200 Subject: [PATCH 0117/1150] Try to fix bug with CheckBox selection if cursor is in TextCtrl. --- xs/src/slic3r/GUI/Field.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 36ef9098f8..fee08e27ed 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -173,7 +173,8 @@ namespace Slic3r { namespace GUI { temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e) { - on_kill_focus(e); +// on_kill_focus(e); + e.Skip(); temp->GetToolTip()->Enable(true); }), temp->GetId()); From 2b8da333efa035966afb54a120b0e9d795c219dc Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 5 Apr 2018 14:22:11 +0200 Subject: [PATCH 0118/1150] Semver: Semantic version parsing and arithmetics --- xs/CMakeLists.txt | 5 + xs/src/semver/semver.c | 617 +++++++++++++++++++++++++++++++++ xs/src/semver/semver.h | 105 ++++++ xs/src/slic3r/Utils/Semver.hpp | 90 +++++ 4 files changed, 817 insertions(+) create mode 100644 xs/src/semver/semver.c create mode 100644 xs/src/semver/semver.h create mode 100644 xs/src/slic3r/Utils/Semver.hpp diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 63b99a8351..ca398da5a2 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -299,6 +299,11 @@ add_library(Shiny STATIC ${LIBDIR}/Shiny/ShinyZone.h ) +add_library(semver STATIC + ${LIBDIR}/semver/semver.h + ${LIBDIR}/semver/semver.c +) + # Generate the Slic3r Perl module (XS) typemap file. set(MyTypemap ${CMAKE_CURRENT_BINARY_DIR}/typemap) add_custom_command( diff --git a/xs/src/semver/semver.c b/xs/src/semver/semver.c new file mode 100644 index 0000000000..29bc1868d3 --- /dev/null +++ b/xs/src/semver/semver.c @@ -0,0 +1,617 @@ +/* + * semver.c + * + * Copyright (c) 2015-2017 Tomas Aparicio + * MIT licensed + */ + +#include +#include +#include +#include "semver.h" + +#define SLICE_SIZE 50 +#define DELIMITER "." +#define PR_DELIMITER "-" +#define MT_DELIMITER "+" +#define NUMBERS "0123456789" +#define ALPHA "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +#define DELIMITERS DELIMITER PR_DELIMITER MT_DELIMITER +#define VALID_CHARS NUMBERS ALPHA DELIMITERS + +static const size_t MAX_SIZE = sizeof(char) * 255; +static const int MAX_SAFE_INT = (unsigned int) -1 >> 1; + +/** + * Define comparison operators, storing the + * ASCII code per each symbol in hexadecimal notation. + */ + +enum operators { + SYMBOL_GT = 0x3e, + SYMBOL_LT = 0x3c, + SYMBOL_EQ = 0x3d, + SYMBOL_TF = 0x7e, + SYMBOL_CF = 0x5e +}; + +/** + * Private helpers + */ + +/* + * Remove [begin:len-begin] from str by moving len data from begin+len to begin. + * If len is negative cut out to the end of the string. + */ +static int +strcut (char *str, int begin, int len) { + size_t l; + l = strlen(str); + + if((int)l < 0 || (int)l > MAX_SAFE_INT) return -1; + + if (len < 0) len = l - begin + 1; + if (begin + len > (int)l) len = l - begin; + memmove(str + begin, str + begin + len, l - len + 1 - begin); + + return len; +} + +static int +contains (const char c, const char *matrix, size_t len) { + size_t x; + for (x = 0; x < len; x++) + if ((char) matrix[x] == c) return 1; + return 0; +} + +static int +has_valid_chars (const char *str, const char *matrix) { + size_t i, len, mlen; + len = strlen(str); + mlen = strlen(matrix); + + for (i = 0; i < len; i++) + if (contains(str[i], matrix, mlen) == 0) + return 0; + + return 1; +} + +static int +binary_comparison (int x, int y) { + if (x == y) return 0; + if (x > y) return 1; + return -1; +} + +static int +parse_int (const char *s) { + int valid, num; + valid = has_valid_chars(s, NUMBERS); + if (valid == 0) return -1; + + num = strtol(s, NULL, 10); + if (num > MAX_SAFE_INT) return -1; + + return num; +} + +/* + * Return a string allocated on the heap with the content from sep to end and + * terminate buf at sep. + */ +static char * +parse_slice (char *buf, char sep) { + char *pr, *part; + int plen; + + /* Find separator in buf */ + pr = strchr(buf, sep); + if (pr == NULL) return NULL; + /* Length from separator to end of buf */ + plen = strlen(pr); + + /* Copy from buf into new string */ + part = calloc(plen + 1, sizeof(*part)); + if (part == NULL) return NULL; + memcpy(part, pr + 1, plen); + /* Null terminate new string */ + part[plen] = '\0'; + + /* Terminate buf where separator was */ + *pr = '\0'; + + return part; +} + +/** + * Parses a string as semver expression. + * + * Returns: + * + * `0` - Parsed successfully + * `-1` - In case of error + */ + +int +semver_parse (const char *str, semver_t *ver) { + int valid, res; + size_t len; + char *buf; + valid = semver_is_valid(str); + if (!valid) return -1; + + len = strlen(str); + buf = calloc(len + 1, sizeof(*buf)); + if (buf == NULL) return -1; + strcpy(buf, str); + + ver->metadata = parse_slice(buf, MT_DELIMITER[0]); + ver->prerelease = parse_slice(buf, PR_DELIMITER[0]); + + res = semver_parse_version(buf, ver); + free(buf); +#if DEBUG > 0 + printf("[debug] semver.c %s = %d.%d.%d, %s %s\n", str, ver->major, ver->minor, ver->patch, ver->prerelease, ver->metadata); +#endif + return res; +} + +/** + * Parses a given string as semver expression. + * + * Returns: + * + * `0` - Parsed successfully + * `-1` - Parse error or invalid + */ + +int +semver_parse_version (const char *str, semver_t *ver) { + size_t len; + int index, value; + char *slice, *next, *endptr; + slice = (char *) str; + index = 0; + + while (slice != NULL && index++ < 4) { + next = strchr(slice, DELIMITER[0]); + if (next == NULL) + len = strlen(slice); + else + len = next - slice; + if (len > SLICE_SIZE) return -1; + + /* Cast to integer and store */ + value = strtol(slice, &endptr, 10); + if (endptr != next && *endptr != '\0') return -1; + + switch (index) { + case 1: ver->major = value; break; + case 2: ver->minor = value; break; + case 3: ver->patch = value; break; + } + + /* Continue with the next slice */ + if (next == NULL) + slice = NULL; + else + slice = next + 1; + } + + return 0; +} + +static int +compare_prerelease (char *x, char *y) { + char *lastx, *lasty, *xptr, *yptr, *endptr; + int xlen, ylen, xisnum, yisnum, xnum, ynum; + int xn, yn, min, res; + if (x == NULL && y == NULL) return 0; + if (y == NULL && x) return -1; + if (x == NULL && y) return 1; + + lastx = x; + lasty = y; + xlen = strlen(x); + ylen = strlen(y); + + while (1) { + if ((xptr = strchr(lastx, DELIMITER[0])) == NULL) + xptr = x + xlen; + if ((yptr = strchr(lasty, DELIMITER[0])) == NULL) + yptr = y + ylen; + + xnum = strtol(lastx, &endptr, 10); + xisnum = endptr == xptr ? 1 : 0; + ynum = strtol(lasty, &endptr, 10); + yisnum = endptr == yptr ? 1 : 0; + + if (xisnum && !yisnum) return -1; + if (!xisnum && yisnum) return 1; + + if (xisnum && yisnum) { + /* Numerical comparison */ + if (xnum != ynum) return xnum < ynum ? -1 : 1; + } else { + /* String comparison */ + xn = xptr - lastx; + yn = yptr - lasty; + min = xn < yn ? xn : yn; + if ((res = strncmp(lastx, lasty, min))) return res < 0 ? -1 : 1; + if (xn != yn) return xn < yn ? -1 : 1; + } + + lastx = xptr + 1; + lasty = yptr + 1; + if (lastx == x + xlen + 1 && lasty == y + ylen + 1) break; + if (lastx == x + xlen + 1) return -1; + if (lasty == y + ylen + 1) return 1; + } + + return 0; +} + +int +semver_compare_prerelease (semver_t x, semver_t y) { + return compare_prerelease(x.prerelease, y.prerelease); +} + +/** + * Performs a major, minor and patch binary comparison (x, y). + * This function is mostly used internally + * + * Returns: + * + * `0` - If versiona are equal + * `1` - If x is higher than y + * `-1` - If x is lower than y + */ + +int +semver_compare_version (semver_t x, semver_t y) { + int res; + + if ((res = binary_comparison(x.major, y.major)) == 0) { + if ((res = binary_comparison(x.minor, y.minor)) == 0) { + return binary_comparison(x.patch, y.patch); + } + } + + return res; +} + +/** + * Compare two semantic versions (x, y). + * + * Returns: + * - `1` if x is higher than y + * - `0` if x is equal to y + * - `-1` if x is lower than y + */ + +int +semver_compare (semver_t x, semver_t y) { + int res; + + if ((res = semver_compare_version(x, y)) == 0) { + return semver_compare_prerelease(x, y); + } + + return res; +} + +/** + * Performs a `greater than` comparison + */ + +int +semver_gt (semver_t x, semver_t y) { + return semver_compare(x, y) == 1; +} + +/** + * Performs a `lower than` comparison + */ + +int +semver_lt (semver_t x, semver_t y) { + return semver_compare(x, y) == -1; +} + +/** + * Performs a `equality` comparison + */ + +int +semver_eq (semver_t x, semver_t y) { + return semver_compare(x, y) == 0; +} + +/** + * Performs a `non equal to` comparison + */ + +int +semver_neq (semver_t x, semver_t y) { + return semver_compare(x, y) != 0; +} + +/** + * Performs a `greater than or equal` comparison + */ + +int +semver_gte (semver_t x, semver_t y) { + return semver_compare(x, y) >= 0; +} + +/** + * Performs a `lower than or equal` comparison + */ + +int +semver_lte (semver_t x, semver_t y) { + return semver_compare(x, y) <= 0; +} + +/** + * Checks if version `x` can be satisfied by `y` + * performing a comparison with caret operator. + * + * See: https://docs.npmjs.com/misc/semver#caret-ranges-1-2-3-0-2-5-0-0-4 + * + * Returns: + * + * `1` - Can be satisfied + * `0` - Cannot be satisfied + */ + +int +semver_satisfies_caret (semver_t x, semver_t y) { + if (x.major == y.major) { + if (x.major == 0) { + return x.minor >= y.minor; + } + return 1; + } + return 0; +} + +/** + * Checks if version `x` can be satisfied by `y` + * performing a comparison with tilde operator. + * + * See: https://docs.npmjs.com/misc/semver#tilde-ranges-1-2-3-1-2-1 + * + * Returns: + * + * `1` - Can be satisfied + * `0` - Cannot be satisfied + */ + +int +semver_satisfies_patch (semver_t x, semver_t y) { + return x.major == y.major + && x.minor == y.minor; +} + +/** + * Checks if both versions can be satisfied + * based on the given comparison operator. + * + * Allowed operators: + * + * - `=` - Equality + * - `>=` - Higher or equal to + * - `<=` - Lower or equal to + * - `<` - Lower than + * - `>` - Higher than + * - `^` - Caret comparison (see https://docs.npmjs.com/misc/semver#caret-ranges-1-2-3-0-2-5-0-0-4) + * - `~` - Tilde comparison (see https://docs.npmjs.com/misc/semver#tilde-ranges-1-2-3-1-2-1) + * + * Returns: + * + * `1` - Can be satisfied + * `0` - Cannot be satisfied + */ + +int +semver_satisfies (semver_t x, semver_t y, const char *op) { + int first, second; + /* Extract the comparison operator */ + first = op[0]; + second = op[1]; + + /* Caret operator */ + if (first == SYMBOL_CF) + return semver_satisfies_caret(x, y); + + /* Tilde operator */ + if (first == SYMBOL_TF) + return semver_satisfies_patch(x, y); + + /* Strict equality */ + if (first == SYMBOL_EQ) + return semver_eq(x, y); + + /* Greater than or equal comparison */ + if (first == SYMBOL_GT) { + if (second == SYMBOL_EQ) { + return semver_gte(x, y); + } + return semver_gt(x, y); + } + + /* Lower than or equal comparison */ + if (first == SYMBOL_LT) { + if (second == SYMBOL_EQ) { + return semver_lte(x, y); + } + return semver_lt(x, y); + } + + return 0; +} + +/** + * Free heep allocated memory of a given semver. + * This is just a convenient function that you + * should call when you're done. + */ + +void +semver_free (semver_t *x) { + if (x->metadata) { + free(x->metadata); + x->metadata = NULL; + } + if (x->prerelease) { + free(x->prerelease); + x->prerelease = NULL; + } +} + +/** + * Renders + */ + +static void +concat_num (char * str, int x, char * sep) { + char buf[SLICE_SIZE] = {0}; + if (sep == NULL) sprintf(buf, "%d", x); + else sprintf(buf, "%s%d", sep, x); + strcat(str, buf); +} + +static void +concat_char (char * str, char * x, char * sep) { + char buf[SLICE_SIZE] = {0}; + sprintf(buf, "%s%s", sep, x); + strcat(str, buf); +} + +/** + * Render a given semver as string + */ + +void +semver_render (semver_t *x, char *dest) { + if (x->major) concat_num(dest, x->major, NULL); + if (x->minor) concat_num(dest, x->minor, DELIMITER); + if (x->patch) concat_num(dest, x->patch, DELIMITER); + if (x->prerelease) concat_char(dest, x->prerelease, PR_DELIMITER); + if (x->metadata) concat_char(dest, x->metadata, MT_DELIMITER); +} + +/** + * Version bump helpers + */ + +void +semver_bump (semver_t *x) { + x->major++; +} + +void +semver_bump_minor (semver_t *x) { + x->minor++; +} + +void +semver_bump_patch (semver_t *x) { + x->patch++; +} + +/** + * Helpers + */ + +static int +has_valid_length (const char *s) { + return strlen(s) <= MAX_SIZE; +} + +/** + * Checks if a given semver string is valid + * + * Returns: + * + * `1` - Valid expression + * `0` - Invalid + */ + +int +semver_is_valid (const char *s) { + return has_valid_length(s) + && has_valid_chars(s, VALID_CHARS); +} + +/** + * Removes non-valid characters in the given string. + * + * Returns: + * + * `0` - Valid + * `-1` - Invalid input + */ + +int +semver_clean (char *s) { + size_t i, len, mlen; + int res; + if (has_valid_length(s) == 0) return -1; + + len = strlen(s); + mlen = strlen(VALID_CHARS); + + for (i = 0; i < len; i++) { + if (contains(s[i], VALID_CHARS, mlen) == 0) { + res = strcut(s, i, 1); + if(res == -1) return -1; + --len; --i; + } + } + + return 0; +} + +static int +char_to_int (const char * str) { + int buf; + size_t i,len, mlen; + buf = 0; + len = strlen(str); + mlen = strlen(VALID_CHARS); + + for (i = 0; i < len; i++) + if (contains(str[i], VALID_CHARS, mlen)) + buf += (int) str[i]; + + return buf; +} + +/** + * Render a given semver as numeric value. + * Useful for ordering and filtering. + */ + +int +semver_numeric (semver_t *x) { + int num; + char buf[SLICE_SIZE * 3]; + memset(&buf, 0, SLICE_SIZE * 3); + + if (x->major) concat_num(buf, x->major, NULL); + if (x->minor) concat_num(buf, x->minor, NULL); + if (x->patch) concat_num(buf, x->patch, NULL); + + num = parse_int(buf); + if(num == -1) return -1; + + if (x->prerelease) num += char_to_int(x->prerelease); + if (x->metadata) num += char_to_int(x->metadata); + + return num; +} diff --git a/xs/src/semver/semver.h b/xs/src/semver/semver.h new file mode 100644 index 0000000000..1b48670ca3 --- /dev/null +++ b/xs/src/semver/semver.h @@ -0,0 +1,105 @@ +/* + * semver.h + * + * Copyright (c) 2015-2017 Tomas Aparicio + * MIT licensed + */ + +#ifndef __SEMVER_H +#define __SEMVER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SEMVER_VERSION +#define SEMVER_VERSION "0.2.0" +#endif + +/** + * semver_t struct + */ + +typedef struct semver_version_s { + int major; + int minor; + int patch; + char * metadata; + char * prerelease; +} semver_t; + +/** + * Set prototypes + */ + +int +semver_satisfies (semver_t x, semver_t y, const char *op); + +int +semver_satisfies_caret (semver_t x, semver_t y); + +int +semver_satisfies_patch (semver_t x, semver_t y); + +int +semver_compare (semver_t x, semver_t y); + +int +semver_compare_version (semver_t x, semver_t y); + +int +semver_compare_prerelease (semver_t x, semver_t y); + +int +semver_gt (semver_t x, semver_t y); + +int +semver_gte (semver_t x, semver_t y); + +int +semver_lt (semver_t x, semver_t y); + +int +semver_lte (semver_t x, semver_t y); + +int +semver_eq (semver_t x, semver_t y); + +int +semver_neq (semver_t x, semver_t y); + +int +semver_parse (const char *str, semver_t *ver); + +int +semver_parse_version (const char *str, semver_t *ver); + +void +semver_render (semver_t *x, char *dest); + +int +semver_numeric (semver_t *x); + +void +semver_bump (semver_t *x); + +void +semver_bump_minor (semver_t *x); + +void +semver_bump_patch (semver_t *x); + +void +semver_free (semver_t *x); + +int +semver_is_valid (const char *s); + +int +semver_clean (char *s); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp new file mode 100644 index 0000000000..3606e90e4c --- /dev/null +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -0,0 +1,90 @@ +#ifndef slic3r_Semver_hpp_ +#define slic3r_Semver_hpp_ + +#include +#include +#include +#include + +#include "semver/semver.h" + +namespace Slic3r { + + +class Semver +{ +public: + struct Major { const int i; Major(int i) : i(i) {} }; + struct Minor { const int i; Minor(int i) : i(i) {} }; + struct Patch { const int i; Patch(int i) : i(i) {} }; + + static boost::optional parse(const std::string &str) + { + semver_t ver; + if (::semver_parse(str.c_str(), &ver) == 0) { + return Semver(ver); + } else { + return boost::none; + } + } + + Semver(Semver &&other) { *this = std::move(other); } + Semver(const Semver &other) { *this = other; } + + Semver &operator=(Semver &&other) + { + ver = other.ver; + other.ver.major = other.ver.minor = other.ver.patch = 0; + other.ver.metadata = other.ver.prerelease = nullptr; + } + + Semver &operator=(const Semver &other) + { + ver = other.ver; + if (other.ver.metadata != nullptr) { std::strcpy(ver.metadata, other.ver.metadata); } + if (other.ver.prerelease != nullptr) { std::strcpy(ver.prerelease, other.ver.prerelease); } + } + + ~Semver() { ::semver_free(&ver); } + + // Comparison + bool operator<(const Semver &b) const { return ::semver_compare(ver, b.ver) == -1; } + bool operator<=(const Semver &b) const { return ::semver_compare(ver, b.ver) <= 0; } + bool operator==(const Semver &b) const { return ::semver_compare(ver, b.ver) == 0; } + bool operator!=(const Semver &b) const { return ::semver_compare(ver, b.ver) != 0; } + bool operator>=(const Semver &b) const { return ::semver_compare(ver, b.ver) >= 0; } + bool operator>(const Semver &b) const { return ::semver_compare(ver, b.ver) == 1; } + // We're using '&' instead of the '~' operator here as '~' is unary-only: + bool operator&(const Semver &b) const { return ::semver_satisfies_patch(ver, b.ver); } + bool operator^(const Semver &b) const { return ::semver_satisfies_caret(ver, b.ver); } + + // Conversion + std::string to_string() const { + auto res = (boost::format("%1%.%2%.%3%") % ver.major % ver.minor % ver.patch).str(); + if (ver.prerelease != nullptr) { res += '-'; res += ver.prerelease; } + if (ver.metadata != nullptr) { res += '+'; res += ver.metadata; } + return res; + } + + // Arithmetics + Semver& operator+=(const Major &b) { ver.major += b.i; return *this; } + Semver& operator+=(const Minor &b) { ver.minor += b.i; return *this; } + Semver& operator+=(const Patch &b) { ver.patch += b.i; return *this; } + Semver& operator-=(const Major &b) { ver.major -= b.i; return *this; } + Semver& operator-=(const Minor &b) { ver.minor -= b.i; return *this; } + Semver& operator-=(const Patch &b) { ver.patch -= b.i; return *this; } + Semver operator+(const Major &b) const { Semver res(*this); return res += b; } + Semver operator+(const Minor &b) const { Semver res(*this); return res += b; } + Semver operator+(const Patch &b) const { Semver res(*this); return res += b; } + Semver operator-(const Major &b) const { Semver res(*this); return res -= b; } + Semver operator-(const Minor &b) const { Semver res(*this); return res -= b; } + Semver operator-(const Patch &b) const { Semver res(*this); return res -= b; } +private: + semver_t ver; + + Semver(semver_t ver) : ver(ver) {} +}; + + +} +#endif From 3a61833d131ac3ae0181f8bc34212d63133c7270 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 5 Apr 2018 15:55:50 +0200 Subject: [PATCH 0119/1150] Update view in object's setting dialog when changing extruder --- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 424d88d699..c7b9049d87 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -88,7 +88,7 @@ sub new { $self->{btn_move_down}->SetFont($Slic3r::GUI::small_font); # part settings panel - $self->{settings_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self, on_change => sub { $self->{part_settings_changed} = 1; }); + $self->{settings_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self, on_change => sub { $self->{part_settings_changed} = 1; $self->_update_canvas; }); my $settings_sizer = Wx::StaticBoxSizer->new($self->{staticbox} = Wx::StaticBox->new($self, -1, "Part Settings"), wxVERTICAL); $settings_sizer->Add($self->{settings_panel}, 1, wxEXPAND | wxALL, 0); @@ -479,6 +479,7 @@ sub _parts_changed { $self->{canvas}->reset_objects; $self->{canvas}->load_object($self->{model_object}); $self->{canvas}->zoom_to_volumes; + $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); $self->{canvas}->Render; } } @@ -509,6 +510,25 @@ sub PartSettingsChanged { return $self->{part_settings_changed}; } +sub _update_canvas { + my ($self) = @_; + + if ($self->{canvas}) { + $self->{canvas}->reset_objects; + $self->{canvas}->load_object($self->{model_object}); + + # restore selection, if any + if (my $itemData = $self->get_selection) { + if ($itemData->{type} eq 'volume') { + $self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1); + } + } + + $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); + $self->{canvas}->Render; + } +} + sub _update { my ($self) = @_; my ($m_x, $m_y, $m_z) = ($self->{move_options}{x}, $self->{move_options}{y}, $self->{move_options}{z}); @@ -529,6 +549,7 @@ sub _update { push @objects, $self->{model_object}; $self->{canvas}->reset_objects; $self->{canvas}->load_object($_, undef, [0]) for @objects; + $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); $self->{canvas}->Render; } From cb9937cde4c4d65fc4e7f8c71cf750f3a5e63974 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 6 Apr 2018 12:02:52 +0200 Subject: [PATCH 0120/1150] Corrected wipe tower comments in GCode --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 6 ++---- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 8 ++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 682845135d..dd75e03edb 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -460,7 +460,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( { this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false); - this->m_num_layer_changes = 0; this->m_current_tool = tools.front(); // The Prusa i3 MK2 has a working space of [0, -2.2] to [250, 210]. @@ -574,7 +573,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo .set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) .append(";--------------------\n" "; CP TOOLCHANGE START\n") - .comment_with_value(" toolchange #", m_num_tool_changes) + .comment_with_value(" toolchange #", m_num_tool_changes + 1) // the number is zero-based .comment_material(m_filpar[m_current_tool].material) .append(";--------------------\n") .speed_override(100); @@ -975,8 +974,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() .set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) .append(";--------------------\n" "; CP EMPTY GRID START\n") - // m_num_layer_changes is incremented by set_z, so it is 1 based. - .comment_with_value(" layer #", m_num_layer_changes - 1); + .comment_with_value(" layer #", m_num_layer_changes + 1); // Slow down on the 1st layer. float speed_factor = m_is_first_layer ? 0.5f : 1.f; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 26c40fbc97..175de0276e 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -121,8 +121,12 @@ public: m_print_brim = is_first_layer; m_depth_traversed = 0.f; m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL; - - ++ m_num_layer_changes; + if (is_first_layer) { + this->m_num_layer_changes = 0; + this->m_num_tool_changes = 0; + } + else + ++ m_num_layer_changes; // Calculate extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height: m_extrusion_flow = extrusion_flow(layer_height); From 3fcf194e39e93d36bc164acffbf7f4ad2c67fb6f Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 13 Mar 2018 12:39:57 +0100 Subject: [PATCH 0121/1150] ConfigWizard: Basic structure / WIP --- lib/Slic3r/GUI.pm | 20 +- lib/Slic3r/GUI/MainFrame.pm | 8 +- resources/icons/printers/MK2S.png | Bin 0 -> 58794 bytes resources/icons/printers/MK2SMM.png | Bin 0 -> 57081 bytes resources/icons/printers/MK3.png | Bin 0 -> 64194 bytes resources/profiles/PrusaResearch.ini | 8 +- xs/CMakeLists.txt | 5 + xs/src/libslic3r/Utils.hpp | 2 + xs/src/slic3r/GUI/AppConfig.cpp | 2 +- xs/src/slic3r/GUI/ConfigWizard.cpp | 433 +++++++++++++++++++++ xs/src/slic3r/GUI/ConfigWizard.hpp | 38 ++ xs/src/slic3r/GUI/ConfigWizard_private.hpp | 162 ++++++++ xs/src/slic3r/GUI/GUI.cpp | 15 + xs/src/slic3r/GUI/GUI.hpp | 4 + xs/src/slic3r/GUI/Preferences.cpp | 1 + xs/src/slic3r/GUI/Preset.hpp | 9 +- xs/src/slic3r/GUI/PresetBundle.cpp | 31 +- xs/src/slic3r/GUI/PresetBundle.hpp | 1 + xs/src/slic3r/Utils/PresetUpdate.cpp | 104 +++++ xs/src/slic3r/Utils/PresetUpdate.hpp | 38 ++ xs/xsp/GUI.xsp | 3 + xs/xsp/Utils_PresetUpdate.xsp | 18 + xs/xsp/my.map | 3 + 23 files changed, 881 insertions(+), 24 deletions(-) create mode 100644 resources/icons/printers/MK2S.png create mode 100644 resources/icons/printers/MK2SMM.png create mode 100644 resources/icons/printers/MK3.png create mode 100644 xs/src/slic3r/GUI/ConfigWizard.cpp create mode 100644 xs/src/slic3r/GUI/ConfigWizard.hpp create mode 100644 xs/src/slic3r/GUI/ConfigWizard_private.hpp create mode 100644 xs/src/slic3r/Utils/PresetUpdate.cpp create mode 100644 xs/src/slic3r/Utils/PresetUpdate.hpp create mode 100644 xs/xsp/Utils_PresetUpdate.xsp diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 4ec388c147..0c5e87429d 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -101,6 +101,8 @@ sub OnInit { $self->{app_config}->set('version', $Slic3r::VERSION); $self->{app_config}->save; + my $slic3r_update_avail = $self->{app_config}->get("version_check") && $self->{app_config}->get("version_online") != $Slic3r::VERSION; + Slic3r::GUI::set_app_config($self->{app_config}); Slic3r::GUI::load_language(); @@ -111,6 +113,7 @@ sub OnInit { warn $@ . "\n"; show_error(undef, $@); } + # TODO: check previously downloaded updates $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only; Slic3r::GUI::set_preset_bundle($self->{preset_bundle}); @@ -134,14 +137,19 @@ sub OnInit { $self->{app_config}->save if $self->{app_config}->dirty; }); - if ($run_wizard) { - # On OSX the UI was not initialized correctly if the wizard was called - # before the UI was up and running. - $self->CallAfter(sub { + # On OSX the UI was not initialized correctly if the wizard was called + # before the UI was up and running. + $self->CallAfter(sub { + if ($slic3r_update_avail) { + # TODO + } elsif ($run_wizard) { # Run the config wizard, don't offer the "reset user profile" checkbox. $self->{mainframe}->config_wizard(1); - }); - } + } + + # XXX: recreate_GUI ??? + Slic3r::PresetUpdater::download($self->{app_config}, $self->{preset_bundle}); + }); # The following event is emited by the C++ menu implementation of application language change. EVT_COMMAND($self, -1, $LANGUAGE_CHANGE_EVENT, sub{ diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index b2f51b9e1d..68fc963394 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -95,7 +95,7 @@ sub new { }); $self->update_ui_from_settings; - + return $self; } @@ -643,6 +643,12 @@ sub config_wizard { my ($self, $fresh_start) = @_; # Exit wizard if there are unsaved changes and the user cancels the action. return unless $self->check_unsaved_changes; + + + # TODO: Offer "reset user profile" + Slic3r::GUI::open_config_wizard(); + return; + # Enumerate the profiles bundled with the Slic3r installation under resources/profiles. my $directory = Slic3r::resources_dir() . "/profiles"; my @profiles = (); diff --git a/resources/icons/printers/MK2S.png b/resources/icons/printers/MK2S.png new file mode 100644 index 0000000000000000000000000000000000000000..925447cf201911308d2a4788e6a0f8fd6f9db2c6 GIT binary patch literal 58794 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 DH{Xdt literal 0 HcmV?d00001 diff --git a/resources/icons/printers/MK2SMM.png b/resources/icons/printers/MK2SMM.png new file mode 100644 index 0000000000000000000000000000000000000000..d6ff161259d9752504ad959c87d0e8529ad97541 GIT binary patch literal 57081 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 literal 0 HcmV?d00001 diff --git a/resources/icons/printers/MK3.png b/resources/icons/printers/MK3.png new file mode 100644 index 0000000000000000000000000000000000000000..5279ba01e060d81738565c5fd99c11e06fbef540 GIT binary patch literal 64194 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�WrFjD4RdqUre@ogt*oytQM-njETd@mVx1yo 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

H`@`RyGv2V%cRm zB3AgRoS99FaA*JaJF3;LSMN3m=6GJltr65d8uPZ+g6jrBL}C8c*uw3>bL(4p&%yn* z1L!=|>Nlac8C>4j2 zL@Kf(2V*EpivaRK4Zkrq&<;=-W7uVvy}0;-3pn(tb!=~fSG@d1Ty?`NN4)smEEyf; zU2i#x-(2~h{PLGqKJt=d=iPVZ7eD{`k!h{QOs~7?qyPTyiNC0;6h)m#Ya%7-&UW>7 zJ8nys+fpe*mSwc+O`JD4Z;7IShBz0z|5T)rGHBkp3d+;96ql*WcDD<*Q!(p&@F*O( z!RqQ8b`13V<`5Ii$>@fKi^Jyu0u(cj{&P?K?a&qLKAx=DzQbl#^&pT30Wv>8TLi

#>L=X2CcPG;rmSx$cc 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

mM0xmn2E#!U}l&p`N$PZaZ@8&36buIP20?_pDBU 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 literal 0 HcmV?d00001 diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index fa4d48cdae..0a1d26eaa0 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -7,21 +7,25 @@ name = Prusa Research # This means, the server may force the Slic3r configuration to be downgraded. config_version = 0.1 # Where to get the updates from? -config_update_url = https://raw.githubusercontent.com/prusa3d/Slic3r-settings/master/live/PrusaResearch.ini +# TODO: proper URL +# config_update_url = https://raw.githubusercontent.com/prusa3d/Slic3r-settings/master/live/PrusaResearch.ini +config_update_url = https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/e9187c3e15ceaf1a90f29b7c43cf3ccc746140f0/PrusaResearch.ini # The printer models will be shown by the Configuration Wizard in this order, # also the first model installed & the first nozzle installed will be activated after install. #TODO: One day we may differentiate variants of the nozzles / hot ends, #for example by the melt zone size, or whether the nozzle is hardened. [printer_model:MK3] +name = Original Prusa i3 MK3 variants = 0.4; 0.25; 0.6 [printer_model:MK2S] +name = Original Prusa i3 MK2S variants = 0.4; 0.25; 0.6 [printer_model:MK2SMM] # Printer model name will be shown by the installation wizard. -name = MK2S Multi Material +name = Original Prusa i3 MK2SMM variants = 0.4; 0.6 # All presets starting with asterisk, for example *common*, are intermediate and they will diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index f28db8f92b..e73c8429a5 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -205,12 +205,16 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/BonjourDialog.hpp ${LIBDIR}/slic3r/Utils/ASCIIFolding.cpp ${LIBDIR}/slic3r/Utils/ASCIIFolding.hpp + ${LIBDIR}/slic3r/GUI/ConfigWizard.cpp + ${LIBDIR}/slic3r/GUI/ConfigWizard.hpp ${LIBDIR}/slic3r/Utils/Http.cpp ${LIBDIR}/slic3r/Utils/Http.hpp ${LIBDIR}/slic3r/Utils/OctoPrint.cpp ${LIBDIR}/slic3r/Utils/OctoPrint.hpp ${LIBDIR}/slic3r/Utils/Bonjour.cpp ${LIBDIR}/slic3r/Utils/Bonjour.hpp + ${LIBDIR}/slic3r/Utils/PresetUpdate.cpp + ${LIBDIR}/slic3r/Utils/PresetUpdate.hpp ) add_library(admesh STATIC @@ -356,6 +360,7 @@ set(XS_XSP_FILES ${XSP_DIR}/SurfaceCollection.xsp ${XSP_DIR}/TriangleMesh.xsp ${XSP_DIR}/Utils_OctoPrint.xsp + ${XSP_DIR}/Utils_PresetUpdate.xsp ${XSP_DIR}/XS.xsp ) foreach (file ${XS_XSP_FILES}) diff --git a/xs/src/libslic3r/Utils.hpp b/xs/src/libslic3r/Utils.hpp index 27e7fad6b0..7e2fe31800 100644 --- a/xs/src/libslic3r/Utils.hpp +++ b/xs/src/libslic3r/Utils.hpp @@ -3,6 +3,8 @@ #include +#include "libslic3r.h" + namespace Slic3r { extern void set_logging_level(unsigned int level); diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index e32b645b47..4bdf88dda6 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -42,7 +42,7 @@ void AppConfig::set_defaults() set("no_defaults", "1"); if (get("show_incompatible_presets").empty()) set("show_incompatible_presets", "0"); - // Version check is enabled by default in the config, but it is not implemented yet. + // Version check is enabled by default in the config, but it is not implemented yet. // XXX if (get("version_check").empty()) set("version_check", "1"); // Use OpenGL 1.1 even if OpenGL 2.0 is available. This is mainly to support some buggy Intel HD Graphics drivers. diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp new file mode 100644 index 0000000000..3cad789b65 --- /dev/null +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -0,0 +1,433 @@ +#include "ConfigWizard_private.hpp" + +#include // XXX +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "libslic3r/Utils.hpp" +#include "PresetBundle.hpp" +#include "GUI.hpp" + +namespace fs = boost::filesystem; + +namespace Slic3r { +namespace GUI { + + +// Wizard page base + +ConfigWizardPage::ConfigWizardPage(ConfigWizard *parent, wxString title, wxString shortname) : + wxPanel(parent), + parent(parent), + shortname(std::move(shortname)), + p_prev(nullptr), + p_next(nullptr) +{ + auto *sizer = new wxBoxSizer(wxVERTICAL); + + auto *text = new wxStaticText(this, wxID_ANY, std::move(title), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + auto font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + font.SetWeight(wxFONTWEIGHT_BOLD); + font.SetPointSize(14); + text->SetFont(font); + sizer->Add(text, 0, wxALIGN_LEFT, 0); + sizer->AddSpacer(10); + + content = new wxBoxSizer(wxVERTICAL); + sizer->Add(content, 1); + + SetSizer(sizer); + + this->Hide(); + + Bind(wxEVT_SIZE, [this](wxSizeEvent &event) { + this->Layout(); + event.Skip(); + }); +} + +ConfigWizardPage::~ConfigWizardPage() {} + +ConfigWizardPage* ConfigWizardPage::chain(ConfigWizardPage *page) +{ + if (p_next != nullptr) { p_next->p_prev = nullptr; } + p_next = page; + if (page != nullptr) { + if (page->p_prev != nullptr) { page->p_prev->p_next = nullptr; } + page->p_prev = this; + } + + return page; +} + +void ConfigWizardPage::append_text(wxString text) +{ + auto *widget = new wxStaticText(this, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + widget->Wrap(CONTENT_WIDTH); + widget->SetMinSize(wxSize(CONTENT_WIDTH, -1)); + // content->Add(widget, 1, wxALIGN_LEFT | wxTOP | wxBOTTOM, 10); + content->Add(widget, 0, wxALIGN_LEFT | wxTOP | wxBOTTOM, 10); +} + +void ConfigWizardPage::append_widget(wxWindow *widget, int proportion) +{ + content->Add(widget, proportion, wxEXPAND | wxTOP | wxBOTTOM, 10); +} + +void ConfigWizardPage::append_spacer(int space) +{ + content->AddSpacer(space); +} + +bool ConfigWizardPage::Show(bool show) +{ + if (extra_buttons() != nullptr) { extra_buttons()->Show(show); } + return wxPanel::Show(show); +} + +void ConfigWizardPage::enable_next(bool enable) { parent->p->enable_next(enable); } + + +// Wizard pages + +PageWelcome::PageWelcome(ConfigWizard *parent, const PresetBundle &bundle) : + ConfigWizardPage(parent, _(L("Welcome to the Slic3r Configuration assistant")), _(L("Welcome"))), + others_buttons(new wxPanel(parent)), + variants_checked(0) +{ + append_text(_(L("Hello, welcome to Slic3r Prusa Edition! TODO: This text."))); + + const auto &vendors = bundle.vendors; + const auto vendor_prusa = std::find(vendors.cbegin(), vendors.cend(), VendorProfile("PrusaResearch")); + + // TODO: preload checkiness from app config + + if (vendor_prusa != vendors.cend()) { + const auto &models = vendor_prusa->models; + + auto *printer_picker = new wxPanel(this); + auto *printer_grid = new wxFlexGridSizer(models.size(), 0, 20); + printer_grid->SetFlexibleDirection(wxVERTICAL); + printer_picker->SetSizer(printer_grid); + + auto namefont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + namefont.SetWeight(wxFONTWEIGHT_BOLD); + + for (auto model = models.cbegin(); model != models.cend(); ++model) { + auto *panel = new wxPanel(printer_picker); + auto *sizer = new wxBoxSizer(wxVERTICAL); + panel->SetSizer(sizer); + + auto *title = new wxStaticText(panel, wxID_ANY, model->name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + title->SetFont(namefont); + sizer->Add(title, 0, wxBOTTOM, 3); + + auto bitmap_file = wxString::Format("printers/%s.png", model->id); + wxBitmap bitmap(GUI::from_u8(Slic3r::var(bitmap_file.ToStdString())), wxBITMAP_TYPE_PNG); + auto *bitmap_widget = new wxStaticBitmap(panel, wxID_ANY, bitmap); + sizer->Add(bitmap_widget, 0, wxBOTTOM, 3); + + sizer->AddSpacer(20); + + for (const auto &variant : model->variants) { + auto *cbox = new wxCheckBox(panel, wxID_ANY, wxString::Format("%s %s %s", variant.name, _(L("mm")), _(L("nozzle")))); + sizer->Add(cbox, 0, wxBOTTOM, 3); + cbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { + this->variants_checked += event.IsChecked() ? 1 : -1; + this->on_variant_checked(); + }); + } + + printer_grid->Add(panel); + } + + append_widget(printer_picker); + } + + { + auto *sizer = new wxBoxSizer(wxHORIZONTAL); + auto *other_vendors = new wxButton(others_buttons, wxID_ANY, _(L("Other vendors"))); + auto *custom_setup = new wxButton(others_buttons, wxID_ANY, _(L("Custom setup"))); + + sizer->Add(other_vendors); + sizer->AddSpacer(BTN_SPACING); + sizer->Add(custom_setup); + + other_vendors->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->wizard_p()->on_other_vendors(); }); + custom_setup->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->wizard_p()->on_custom_setup(); }); + + others_buttons->SetSizer(sizer); + } +} + +void PageWelcome::on_page_set() +{ + chain(wizard_p()->page_update); + on_variant_checked(); +} + +void PageWelcome::on_variant_checked() +{ + enable_next(variants_checked > 0); +} + +PageUpdate::PageUpdate(ConfigWizard *parent) : + ConfigWizardPage(parent, _(L("Automatic updates")), _(L("Updates"))) +{ + append_text(_(L("TODO: text"))); + auto *box_slic3r = new wxCheckBox(this, wxID_ANY, _(L("Check for Slic3r updates"))); + box_slic3r->SetValue(true); + append_widget(box_slic3r); + + append_text(_(L("TODO: text"))); + auto *box_presets = new wxCheckBox(this, wxID_ANY, _(L("Update built-in Presets automatically"))); + box_presets->SetValue(true); + append_widget(box_presets); +} + +void PageUpdate::presets_update_enable(bool enable) +{ + // TODO +} + +PageVendors::PageVendors(ConfigWizard *parent) : + ConfigWizardPage(parent, _(L("Other Vendors")), _(L("Other Vendors"))) +{} + +PageFirmware::PageFirmware(ConfigWizard *parent) : + ConfigWizardPage(parent, _(L("Firmware Type")), _(L("Firmware"))) +{} + +PageBedShape::PageBedShape(ConfigWizard *parent) : + ConfigWizardPage(parent, _(L("Bed Shape and Size")), _(L("Bed Shape"))) +{} + +PageDiameters::PageDiameters(ConfigWizard *parent) : + ConfigWizardPage(parent, _(L("Filament and Nozzle Diameter")), _(L("Print Diameters"))) +{} + +PageTemperatures::PageTemperatures(ConfigWizard *parent) : + ConfigWizardPage(parent, _(L("Bed and Extruder Temperature")), _(L("Temperatures"))) +{} + + +// Index + +ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent) : + wxPanel(parent), + bg(GUI::from_u8(Slic3r::var("Slic3r_192px_transparent.png")), wxBITMAP_TYPE_PNG), + bullet_black(GUI::from_u8(Slic3r::var("bullet_black.png")), wxBITMAP_TYPE_PNG), + bullet_blue(GUI::from_u8(Slic3r::var("bullet_blue.png")), wxBITMAP_TYPE_PNG), + bullet_white(GUI::from_u8(Slic3r::var("bullet_white.png")), wxBITMAP_TYPE_PNG) +{ + SetMinSize(bg.GetSize()); + Bind(wxEVT_PAINT, &ConfigWizardIndex::on_paint, this); + + wxClientDC dc(this); + text_height = dc.GetCharHeight(); +} + +void ConfigWizardIndex::load_items(ConfigWizardPage *firstpage) +{ + items.clear(); + item_active = items.cend(); + + for (auto *page = firstpage; page != nullptr; page = page->page_next()) { + items.emplace_back(page->shortname); + } + + Refresh(); +} + +void ConfigWizardIndex::set_active(ConfigWizardPage *page) +{ + item_active = std::find(items.cbegin(), items.cend(), page->shortname); + Refresh(); +} + +void ConfigWizardIndex::on_paint(wxPaintEvent & evt) +{ + enum { + MARGIN = 10, + SPACING = 5, + }; + + const auto size = GetClientSize(); + const auto h = size.GetHeight(); + const auto w = size.GetWidth(); + if (h == 0 || w == 0) { return; } + + wxPaintDC dc(this); + dc.DrawBitmap(bg, 0, h - bg.GetHeight(), false); + + const auto bullet_w = bullet_black.GetSize().GetWidth(); + const auto bullet_h = bullet_black.GetSize().GetHeight(); + const int yoff_icon = bullet_h < text_height ? (text_height - bullet_h) / 2 : 0; + const int yoff_text = bullet_h > text_height ? (bullet_h - text_height) / 2 : 0; + const int yinc = std::max(bullet_h, text_height) + SPACING; + + unsigned y = 0; + for (auto it = items.cbegin(); it != items.cend(); ++it) { + if (it < item_active) { dc.DrawBitmap(bullet_black, MARGIN, y + yoff_icon, false); } + if (it == item_active) { dc.DrawBitmap(bullet_blue, MARGIN, y + yoff_icon, false); } + if (it > item_active) { dc.DrawBitmap(bullet_white, MARGIN, y + yoff_icon, false); } + dc.DrawText(*it, MARGIN + bullet_w + SPACING, y + yoff_text); + y += yinc; + } +} + + + +// priv + +void ConfigWizard::priv::index_refresh() +{ + index->load_items(page_welcome); +} + +void ConfigWizard::priv::add_page(ConfigWizardPage *page) +{ + topsizer->Add(page, 0, wxEXPAND); + + auto *extra_buttons = page->extra_buttons(); + if (extra_buttons != nullptr) { + btnsizer->Prepend(extra_buttons, 0); + } +} + +void ConfigWizard::priv::set_page(ConfigWizardPage *page) +{ + if (page == nullptr) { return; } + if (page_current != nullptr) { page_current->Hide(); } + page_current = page; + enable_next(true); + + page->on_page_set(); + index->load_items(page_welcome); + index->set_active(page); + page->Show(); + + btn_prev->Enable(page->page_prev() != nullptr); + btn_next->Show(page->page_next() != nullptr); + btn_finish->Show(page->page_next() == nullptr); + + q->Layout(); +} + +void ConfigWizard::priv::enable_next(bool enable) +{ + btn_next->Enable(enable); + btn_finish->Enable(enable); +} + +void ConfigWizard::priv::on_other_vendors() +{ + page_welcome + ->chain(page_vendors) + ->chain(page_update); + set_page(page_vendors); +} + +void ConfigWizard::priv::on_custom_setup() +{ + page_welcome->chain(page_firmware); + page_temps->chain(page_update); + set_page(page_firmware); +} + +// Public + +ConfigWizard::ConfigWizard(wxWindow *parent, const PresetBundle &bundle) : + wxDialog(parent, wxID_ANY, _(L("Configuration Assistant")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), + p(new priv(this)) +{ + p->index = new ConfigWizardIndex(this); + + auto *vsizer = new wxBoxSizer(wxVERTICAL); + p->topsizer = new wxBoxSizer(wxHORIZONTAL); + auto *hline = new wxStaticLine(this); + p->btnsizer = new wxBoxSizer(wxHORIZONTAL); + + p->topsizer->Add(p->index, 0, wxEXPAND); + p->topsizer->AddSpacer(INDEX_MARGIN); + + // TODO: btn labels vs default w/ icons ... use arrows from resources? (no apply icon) + // Also: http://docs.wxwidgets.org/3.0/page_stockitems.html + p->btn_prev = new wxButton(this, wxID_BACKWARD, _(L("< &Back"))); + p->btn_next = new wxButton(this, wxID_FORWARD, _(L("&Next >"))); + p->btn_finish = new wxButton(this, wxID_APPLY, _(L("&Finish"))); + p->btn_cancel = new wxButton(this, wxID_CANCEL); + p->btnsizer->AddStretchSpacer(); + p->btnsizer->Add(p->btn_prev, 0, wxLEFT, BTN_SPACING); + p->btnsizer->Add(p->btn_next, 0, wxLEFT, BTN_SPACING); + p->btnsizer->Add(p->btn_finish, 0, wxLEFT, BTN_SPACING); + p->btnsizer->Add(p->btn_cancel, 0, wxLEFT, BTN_SPACING); + + p->add_page(p->page_welcome = new PageWelcome(this, bundle)); + p->add_page(p->page_update = new PageUpdate(this)); + p->add_page(p->page_vendors = new PageVendors(this)); + p->add_page(p->page_firmware = new PageFirmware(this)); + p->add_page(p->page_bed = new PageBedShape(this)); + p->add_page(p->page_diams = new PageDiameters(this)); + p->add_page(p->page_temps = new PageTemperatures(this)); + p->index_refresh(); + + p->page_welcome->chain(p->page_update); + p->page_firmware + ->chain(p->page_bed) + ->chain(p->page_diams) + ->chain(p->page_temps); + + vsizer->Add(p->topsizer, 1, wxEXPAND | wxALL, DIALOG_MARGIN); + vsizer->Add(hline, 0, wxEXPAND); + vsizer->Add(p->btnsizer, 0, wxEXPAND | wxALL, DIALOG_MARGIN); + + p->set_page(p->page_welcome); + SetSizerAndFit(vsizer); + SetMinSize(GetSize()); + + p->btn_prev->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->go_prev(); }); + p->btn_next->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->go_next(); }); +} + +ConfigWizard::~ConfigWizard() {} + +void ConfigWizard::run(wxWindow *parent) +{ + PresetBundle bundle; + + const auto profiles_dir = fs::path(resources_dir()) / "profiles"; + for (fs::directory_iterator it(profiles_dir); it != fs::directory_iterator(); ++it) { + if (it->path().extension() == ".ini") { + bundle.load_configbundle(it->path().native(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); + } + } + + // XXX + for (const auto &vendor : bundle.vendors) { + std::cerr << "vendor: " << vendor.name << std::endl; + std::cerr << " URL: " << vendor.config_update_url << std::endl; + for (const auto &model : vendor.models) { + std::cerr << "\tmodel: " << model.id << " (" << model.name << ")" << std::endl; + for (const auto &variant : model.variants) { + std::cerr << "\t\tvariant: " << variant.name << std::endl; + } + } + } + + ConfigWizard wizard(parent, bundle); + wizard.ShowModal(); +} + + +} +} diff --git a/xs/src/slic3r/GUI/ConfigWizard.hpp b/xs/src/slic3r/GUI/ConfigWizard.hpp new file mode 100644 index 0000000000..1b14e29be7 --- /dev/null +++ b/xs/src/slic3r/GUI/ConfigWizard.hpp @@ -0,0 +1,38 @@ +#ifndef slic3r_ConfigWizard_hpp_ +#define slic3r_ConfigWizard_hpp_ + +#include + +#include + +namespace Slic3r { + +class PresetBundle; + +namespace GUI { + + +class ConfigWizard: public wxDialog +{ +public: + ConfigWizard(wxWindow *parent, const PresetBundle &bundle); + ConfigWizard(ConfigWizard &&) = delete; + ConfigWizard(const ConfigWizard &) = delete; + ConfigWizard &operator=(ConfigWizard &&) = delete; + ConfigWizard &operator=(const ConfigWizard &) = delete; + ~ConfigWizard(); + + static void run(wxWindow *parent); +private: + struct priv; + std::unique_ptr p; + + friend class ConfigWizardPage; +}; + + + +} +} + +#endif diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp new file mode 100644 index 0000000000..ba028c0e87 --- /dev/null +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -0,0 +1,162 @@ +#ifndef slic3r_ConfigWizard_private_hpp_ +#define slic3r_ConfigWizard_private_hpp_ + +#include "ConfigWizard.hpp" + +#include + +#include +#include +#include + + +namespace Slic3r { +namespace GUI { + + +enum { + DIALOG_MARGIN = 15, + INDEX_MARGIN = 40, + BTN_SPACING = 10, +}; + +struct ConfigWizardPage: wxPanel +{ + enum { + CONTENT_WIDTH = 500, + }; + + ConfigWizard *parent; + const wxString shortname; + wxBoxSizer *content; + + ConfigWizardPage(ConfigWizard *parent, wxString title, wxString shortname); + + virtual ~ConfigWizardPage(); + + ConfigWizardPage *page_prev() const { return p_prev; } + ConfigWizardPage *page_next() const { return p_next; } + ConfigWizardPage* chain(ConfigWizardPage *page); + + void append_text(wxString text); + void append_widget(wxWindow *widget, int proportion = 0); + void append_spacer(int space); + + ConfigWizard::priv *wizard_p() const { return parent->p.get(); } + + virtual bool Show(bool show = true); + virtual bool Hide() { return Show(false); } + virtual wxPanel* extra_buttons() { return nullptr; } + virtual void on_page_set() {} + + void enable_next(bool enable); +private: + ConfigWizardPage *p_prev; + ConfigWizardPage *p_next; +}; + +struct PageWelcome: ConfigWizardPage +{ + wxPanel *others_buttons; + unsigned variants_checked; + + PageWelcome(ConfigWizard *parent, const PresetBundle &bundle); + + virtual wxPanel* extra_buttons() { return others_buttons; } + virtual void on_page_set(); + + void on_variant_checked(); +}; + +struct PageUpdate: ConfigWizardPage +{ + PageUpdate(ConfigWizard *parent); + + void presets_update_enable(bool enable); +}; + +struct PageVendors: ConfigWizardPage +{ + PageVendors(ConfigWizard *parent); +}; + +struct PageFirmware: ConfigWizardPage +{ + PageFirmware(ConfigWizard *parent); +}; + +struct PageBedShape: ConfigWizardPage +{ + PageBedShape(ConfigWizard *parent); +}; + +struct PageDiameters: ConfigWizardPage +{ + PageDiameters(ConfigWizard *parent); +}; + +struct PageTemperatures: ConfigWizardPage +{ + PageTemperatures(ConfigWizard *parent); +}; + + +class ConfigWizardIndex: public wxPanel +{ +public: + ConfigWizardIndex(wxWindow *parent); + + void load_items(ConfigWizardPage *firstpage); + void set_active(ConfigWizardPage *page); +private: + const wxBitmap bg; + const wxBitmap bullet_black; + const wxBitmap bullet_blue; + const wxBitmap bullet_white; + int text_height; + + std::vector items; + std::vector::const_iterator item_active; + + void on_paint(wxPaintEvent & evt); +}; + +struct ConfigWizard::priv +{ + ConfigWizard *q; + wxBoxSizer *topsizer = nullptr; + wxBoxSizer *btnsizer = nullptr; + ConfigWizardPage *page_current = nullptr; + ConfigWizardIndex *index = nullptr; + wxButton *btn_prev = nullptr; + wxButton *btn_next = nullptr; + wxButton *btn_finish = nullptr; + wxButton *btn_cancel = nullptr; + + PageWelcome *page_welcome = nullptr; + PageUpdate *page_update = nullptr; + PageVendors *page_vendors = nullptr; + PageFirmware *page_firmware = nullptr; + PageBedShape *page_bed = nullptr; + PageDiameters *page_diams = nullptr; + PageTemperatures *page_temps = nullptr; + + priv(ConfigWizard *q) : q(q) {} + + void add_page(ConfigWizardPage *page); + void index_refresh(); + void set_page(ConfigWizardPage *page); + void go_prev() { if (page_current != nullptr) { set_page(page_current->page_prev()); } } + void go_next() { if (page_current != nullptr) { set_page(page_current->page_next()); } } + void enable_next(bool enable); + + void on_other_vendors(); + void on_custom_setup(); +}; + + + +} +} + +#endif diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 3eca4e7075..53288067cf 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -44,6 +44,7 @@ #include "TabIface.hpp" #include "AppConfig.hpp" #include "Utils.hpp" +#include "ConfigWizard.hpp" #include "Preferences.hpp" #include "PresetBundle.hpp" @@ -352,6 +353,20 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change) //#endif } +void open_config_wizard() +{ + if (g_wxMainFrame == nullptr) { + throw std::runtime_error("Main frame not set"); + } + + // auto *wizard = new ConfigWizard(static_cast(g_wxMainFrame)); // FIXME: lifetime + + // wizard->run(); + ConfigWizard::run(g_wxMainFrame); + + // show_info(g_wxMainFrame, "After wizard", "After wizard"); +} + void open_preferences_dialog(int event_preferences) { auto dlg = new PreferencesDialog(g_wxMainFrame, event_preferences); diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 362b15307b..1f93e18e99 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -73,6 +73,7 @@ void break_to_debugger(); // Passing the wxWidgets GUI classes instantiated by the Perl part to C++. void set_wxapp(wxApp *app); void set_main_frame(wxFrame *main_frame); +// wxFrame* get_main_frame(); void set_tab_panel(wxNotebook *tab_panel); void set_app_config(AppConfig *app_config); void set_preset_bundle(PresetBundle *preset_bundle); @@ -84,6 +85,9 @@ wxColour* get_sys_label_clr(); void add_debug_menu(wxMenuBar *menu, int event_language_change); +// Opens the first-time configuration wizard +void open_config_wizard(); + // Create "Preferences" dialog after selecting menu "Preferences" in Perl part void open_preferences_dialog(int event_preferences); diff --git a/xs/src/slic3r/GUI/Preferences.cpp b/xs/src/slic3r/GUI/Preferences.cpp index 0009b17ecd..6731cd394d 100644 --- a/xs/src/slic3r/GUI/Preferences.cpp +++ b/xs/src/slic3r/GUI/Preferences.cpp @@ -14,6 +14,7 @@ void PreferencesDialog::build() m_values[opt_key] = boost::any_cast(value) ? "1" : "0"; }; + // TODO // $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( // opt_id = > 'version_check', // type = > 'bool', diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 3634c5dd94..78e15badae 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -40,7 +40,7 @@ public: struct PrinterModel { PrinterModel() {} - PrinterModel(const std::string &name) : name(name) {} + std::string id; std::string name; bool enabled = true; std::vector variants; @@ -51,11 +51,10 @@ public: return nullptr; } const PrinterVariant* variant(const std::string &name) const { return const_cast(this)->variant(name); } - - bool operator< (const PrinterModel &rhs) const { return this->name < rhs.name; } - bool operator==(const PrinterModel &rhs) const { return this->name == rhs.name; } }; - std::set models; + std::vector models; + + VendorProfile(std::string id) : id(std::move(id)) {} size_t num_variants() const { size_t n = 0; for (auto &model : models) n += model.variants.size(); return n; } diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 7131bf7716..241f0433ef 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -4,6 +4,7 @@ #include "PresetBundle.hpp" #include "BitmapCache.hpp" +#include #include #include #include @@ -104,6 +105,7 @@ void PresetBundle::setup_directories() std::initializer_list paths = { data_dir, data_dir / "vendor", + data_dir / "cache", #ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR // Store the print/filament/printer presets into a "presets" directory. data_dir / "presets", @@ -198,6 +200,7 @@ static inline std::string remove_ini_suffix(const std::string &name) // If the "vendor" section is missing, enable all models and variants of the particular vendor. void PresetBundle::load_installed_printers(const AppConfig &config) { + // TODO // m_storage } @@ -667,7 +670,7 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree) static void load_vendor_profile(const boost::property_tree::ptree &tree, VendorProfile &vendor_profile) { const std::string printer_model_key = "printer_model:"; - for (auto §ion : tree) + for (auto §ion : tree) { if (section.first == "vendor") { // Load the names of the active presets. for (auto &kvp : section.second) { @@ -682,7 +685,8 @@ static void load_vendor_profile(const boost::property_tree::ptree &tree, VendorP } } else if (boost::starts_with(section.first, printer_model_key)) { VendorProfile::PrinterModel model; - model.name = section.first.substr(printer_model_key.size()); + model.id = section.first.substr(printer_model_key.size()); + model.name = section.second.get("name", model.id); section.second.get("variants", ""); std::vector variants; if (Slic3r::unescape_strings_cstyle(section.second.get("variants", ""), variants)) { @@ -693,9 +697,10 @@ static void load_vendor_profile(const boost::property_tree::ptree &tree, VendorP } else { // Log error? } - if (! model.name.empty() && ! model.variants.empty()) - vendor_profile.models.insert(model); + if (! model.id.empty() && ! model.variants.empty()) + vendor_profile.models.push_back(std::move(model)); } + } } // Load a config bundle file, into presets and store the loaded presets into separate files @@ -719,12 +724,11 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla pt::ptree tree; boost::nowide::ifstream ifs(path); pt::read_ini(ifs, tree); - // Flatten the config bundle by applying the inheritance rules. Internal profiles (with names starting with '*') are removed. - flatten_configbundle_hierarchy(tree); const VendorProfile *vendor_profile = nullptr; - if (flags & LOAD_CFGBNDLE_SYSTEM) { - VendorProfile vp; + if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) { + boost::filesystem::path fspath(path); + VendorProfile vp(fspath.stem().native()); load_vendor_profile(tree, vp); if (vp.name.empty()) throw std::runtime_error(std::string("Vendor Config Bundle is not valid: Missing vendor name key.")); @@ -732,6 +736,13 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla return 0; vendor_profile = &(*this->vendors.insert(vp).first); } + + if (flags & LOAD_CFGBUNDLE_VENDOR_ONLY) { + return 0; + } + + // 1.5) Flatten the config bundle by applying the inheritance rules. Internal profiles (with names starting with '*') are removed. + flatten_configbundle_hierarchy(tree); // 2) Parse the property_tree, extract the active preset names and the profiles, save them into local config files. std::vector loaded_prints; @@ -803,7 +814,9 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla section.first << "\" defines no printer variant, it will be ignored."; continue; } - auto it_model = vendor_profile->models.find(VendorProfile::PrinterModel(printer_model)); + auto it_model = std::find_if(vendor_profile->models.cbegin(), vendor_profile->models.cend(), + [&](const VendorProfile::PrinterModel &m) { return m.id == printer_model; } + ); if (it_model == vendor_profile->models.end()) { BOOST_LOG_TRIVIAL(error) << "Error in a Vendor Config Bundle \"" << path << "\": The printer preset \"" << section.first << "\" defines invalid printer model \"" << printer_model << "\", it will be ignored."; diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index f481ba374f..4949e0e037 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -81,6 +81,7 @@ public: LOAD_CFGBNDLE_RESET_USER_PROFILE = 2, // Load a system config bundle. LOAD_CFGBNDLE_SYSTEM = 4, + LOAD_CFGBUNDLE_VENDOR_ONLY = 8, }; // Load the config bundle, store it to the user profile directory by default. size_t load_configbundle(const std::string &path, unsigned int flags = LOAD_CFGBNDLE_SAVE); diff --git a/xs/src/slic3r/Utils/PresetUpdate.cpp b/xs/src/slic3r/Utils/PresetUpdate.cpp new file mode 100644 index 0000000000..0e4c62af9a --- /dev/null +++ b/xs/src/slic3r/Utils/PresetUpdate.cpp @@ -0,0 +1,104 @@ +#include "PresetUpdate.hpp" + +#include // XXX +#include +#include +#include + +#include "libslic3r/Utils.hpp" +#include "slic3r/GUI/PresetBundle.hpp" +#include "slic3r/Utils/Http.hpp" + +namespace fs = boost::filesystem; + + +namespace Slic3r { + + +struct PresetUpdater::priv +{ + PresetBundle *bundle; + fs::path cache_path; + std::thread thread; + + priv(PresetBundle *bundle); + + void download(); +}; + + +PresetUpdater::priv::priv(PresetBundle *bundle) : + bundle(bundle), + cache_path(fs::path(Slic3r::data_dir()) / "cache") +{} + +void PresetUpdater::priv::download() +{ + std::cerr << "PresetUpdater::priv::download()" << std::endl; + + std::cerr << "Bundle vendors: " << bundle->vendors.size() << std::endl; + for (const auto &vendor : bundle->vendors) { + std::cerr << "vendor: " << vendor.name << std::endl; + std::cerr << " URL: " << vendor.config_update_url << std::endl; + + // TODO: Proper caching + + auto target_path = cache_path / vendor.id; + target_path += ".ini"; + std::cerr << "target_path: " << target_path << std::endl; + + Http::get(vendor.config_update_url) + .on_complete([&](std::string body, unsigned http_status) { + std::cerr << "Got ini: " << http_status << ", body: " << body.size() << std::endl; + fs::fstream file(target_path, std::ios::out | std::ios::binary | std::ios::trunc); + file.write(body.c_str(), body.size()); + }) + .on_error([](std::string body, std::string error, unsigned http_status) { + // TODO: what about errors? + std::cerr << "Error: " << http_status << ", " << error << std::endl; + }) + .perform_sync(); + } +} + +PresetUpdater::PresetUpdater(PresetBundle *preset_bundle) : p(new priv(preset_bundle)) {} + + +// Public + +PresetUpdater::~PresetUpdater() +{ + if (p && p->thread.joinable()) { + p->thread.detach(); + } +} + +void PresetUpdater::download(AppConfig *app_config, PresetBundle *preset_bundle) +{ + std::cerr << "PresetUpdater::download()" << std::endl; + + auto self = std::make_shared(preset_bundle); + auto thread = std::thread([self](){ + self->p->download(); + }); + self->p->thread = std::move(thread); +} + + +// TODO: remove +namespace Utils { + +void preset_update_check() +{ + std::cerr << "preset_update_check()" << std::endl; + + // TODO: + // 1. Get a version tag or the whole bundle from the web + // 2. Store into temporary location (?) + // 3. ??? + // 4. Profit! +} + +} + +} diff --git a/xs/src/slic3r/Utils/PresetUpdate.hpp b/xs/src/slic3r/Utils/PresetUpdate.hpp new file mode 100644 index 0000000000..4311340973 --- /dev/null +++ b/xs/src/slic3r/Utils/PresetUpdate.hpp @@ -0,0 +1,38 @@ +#ifndef slic3r_PresetUpdate_hpp_ +#define slic3r_PresetUpdate_hpp_ + +#include + +namespace Slic3r { + + +class AppConfig; +class PresetBundle; + +class PresetUpdater +{ +public: + PresetUpdater(PresetBundle *preset_bundle); + PresetUpdater(PresetUpdater &&) = delete; + PresetUpdater(const PresetUpdater &) = delete; + PresetUpdater &operator=(PresetUpdater &&) = delete; + PresetUpdater &operator=(const PresetUpdater &) = delete; + ~PresetUpdater(); + + static void download(AppConfig *app_config, PresetBundle *preset_bundle); +private: + struct priv; + std::unique_ptr p; +}; + + +// TODO: Remove +namespace Utils { + +void preset_update_check(); + +} + +} + +#endif diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 1376ff164b..5115eda646 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -54,6 +54,9 @@ int combochecklist_get_flags(SV *ui) void set_app_config(AppConfig *app_config) %code%{ Slic3r::GUI::set_app_config(app_config); %}; +void open_config_wizard() + %code%{ Slic3r::GUI::open_config_wizard(); %}; + void open_preferences_dialog(int preferences_event) %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %}; diff --git a/xs/xsp/Utils_PresetUpdate.xsp b/xs/xsp/Utils_PresetUpdate.xsp new file mode 100644 index 0000000000..3596b7c86b --- /dev/null +++ b/xs/xsp/Utils_PresetUpdate.xsp @@ -0,0 +1,18 @@ +%module{Slic3r::XS}; + +%{ +#include +#include "slic3r/Utils/PresetUpdate.hpp" +%} + +%name{Slic3r::PresetUpdater} class PresetUpdater { + static void download(PresetBundle *preset_bundle); +}; + + +# TODO: remove: + +%package{Slic3r::Utils}; + +void preset_update_check() + %code%{ Slic3r::Utils::preset_update_check(); %}; diff --git a/xs/xsp/my.map b/xs/xsp/my.map index 87a8d8d866..d817af0529 100644 --- a/xs/xsp/my.map +++ b/xs/xsp/my.map @@ -235,6 +235,9 @@ PresetHints* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T TabIface* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T +# TODO: remove: +# ConfigWizard* O_OBJECT_SLIC3R +# Ref O_OBJECT_SLIC3R_T OctoPrint* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T From 57e47a3296c94e9ed879e5bf281aef69f1942409 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 28 Mar 2018 11:36:36 +0200 Subject: [PATCH 0122/1150] AppConfig: Support for vendor / model / variant enable state --- lib/Slic3r/GUI.pm | 24 ++- xs/CMakeLists.txt | 6 +- xs/src/perlglue.cpp | 1 + xs/src/slic3r/GUI/AppConfig.cpp | 75 +++++++++- xs/src/slic3r/GUI/AppConfig.hpp | 16 ++ xs/src/slic3r/Utils/PresetUpdate.cpp | 104 ------------- xs/src/slic3r/Utils/PresetUpdater.cpp | 137 ++++++++++++++++++ .../{PresetUpdate.hpp => PresetUpdater.hpp} | 12 +- xs/xsp/GUI_AppConfig.xsp | 1 + xs/xsp/Utils_PresetUpdate.xsp | 18 --- xs/xsp/Utils_PresetUpdater.xsp | 11 ++ xs/xsp/my.map | 4 + 12 files changed, 267 insertions(+), 142 deletions(-) delete mode 100644 xs/src/slic3r/Utils/PresetUpdate.cpp create mode 100644 xs/src/slic3r/Utils/PresetUpdater.cpp rename xs/src/slic3r/Utils/{PresetUpdate.hpp => PresetUpdater.hpp} (71%) delete mode 100644 xs/xsp/Utils_PresetUpdate.xsp create mode 100644 xs/xsp/Utils_PresetUpdater.xsp diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 0c5e87429d..495dd9ecc7 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -70,6 +70,8 @@ our $grey = Wx::Colour->new(200,200,200); our $LANGUAGE_CHANGE_EVENT = Wx::NewEventType; # 2) To inform about a change of Preferences. our $PREFERENCES_EVENT = Wx::NewEventType; +# To inform AppConfig about Slic3r version available online +our $VERSION_ONLINE_EVENT = Wx::NewEventType; sub OnInit { my ($self) = @_; @@ -101,7 +103,9 @@ sub OnInit { $self->{app_config}->set('version', $Slic3r::VERSION); $self->{app_config}->save; - my $slic3r_update_avail = $self->{app_config}->get("version_check") && $self->{app_config}->get("version_online") != $Slic3r::VERSION; + # my $version_check = $self->{app_config}->get('version_check'); + $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT, $self->{app_config}); + my $slic3r_update = $self->{app_config}->slic3r_update_avail; Slic3r::GUI::set_app_config($self->{app_config}); Slic3r::GUI::load_language(); @@ -140,15 +144,17 @@ sub OnInit { # On OSX the UI was not initialized correctly if the wizard was called # before the UI was up and running. $self->CallAfter(sub { - if ($slic3r_update_avail) { + # XXX: recreate_GUI ??? + if ($slic3r_update) { # TODO - } elsif ($run_wizard) { + } + # XXX: ? + if ($run_wizard) { # Run the config wizard, don't offer the "reset user profile" checkbox. $self->{mainframe}->config_wizard(1); } - # XXX: recreate_GUI ??? - Slic3r::PresetUpdater::download($self->{app_config}, $self->{preset_bundle}); + $self->{preset_updater}->download($self->{preset_bundle}); }); # The following event is emited by the C++ menu implementation of application language change. @@ -161,6 +167,14 @@ sub OnInit { $self->update_ui_from_settings; }); + # The following event is emited by PresetUpdater (C++) + EVT_COMMAND($self, -1, $VERSION_ONLINE_EVENT, sub { + my ($self, $event) = @_; + my $version = $event->GetString; + $self->{app_config}->set('version_online', $version); + $self->{app_config}->save; + }); + return 1; } diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index e73c8429a5..3ce499d2b6 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -213,8 +213,8 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/Utils/OctoPrint.hpp ${LIBDIR}/slic3r/Utils/Bonjour.cpp ${LIBDIR}/slic3r/Utils/Bonjour.hpp - ${LIBDIR}/slic3r/Utils/PresetUpdate.cpp - ${LIBDIR}/slic3r/Utils/PresetUpdate.hpp + ${LIBDIR}/slic3r/Utils/PresetUpdater.cpp + ${LIBDIR}/slic3r/Utils/PresetUpdater.hpp ) add_library(admesh STATIC @@ -360,7 +360,7 @@ set(XS_XSP_FILES ${XSP_DIR}/SurfaceCollection.xsp ${XSP_DIR}/TriangleMesh.xsp ${XSP_DIR}/Utils_OctoPrint.xsp - ${XSP_DIR}/Utils_PresetUpdate.xsp + ${XSP_DIR}/Utils_PresetUpdater.xsp ${XSP_DIR}/XS.xsp ) foreach (file ${XS_XSP_FILES}) diff --git a/xs/src/perlglue.cpp b/xs/src/perlglue.cpp index d7c9a590a0..9706ced2cd 100644 --- a/xs/src/perlglue.cpp +++ b/xs/src/perlglue.cpp @@ -64,6 +64,7 @@ REGISTER_CLASS(PresetCollection, "GUI::PresetCollection"); REGISTER_CLASS(PresetBundle, "GUI::PresetBundle"); REGISTER_CLASS(PresetHints, "GUI::PresetHints"); REGISTER_CLASS(TabIface, "GUI::Tab"); +REGISTER_CLASS(PresetUpdater, "PresetUpdater"); REGISTER_CLASS(OctoPrint, "OctoPrint"); SV* ConfigBase__as_hash(ConfigBase* THIS) diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 4bdf88dda6..e951beb440 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -1,5 +1,3 @@ -#include - #include "../../libslic3r/libslic3r.h" #include "../../libslic3r/Utils.hpp" #include "AppConfig.hpp" @@ -9,15 +7,20 @@ #include #include #include +#include #include #include #include #include #include +#include namespace Slic3r { +static const std::string VENDOR_PREFIX = "vendor:"; +static const std::string MODEL_PREFIX = "model:"; + void AppConfig::reset() { m_storage.clear(); @@ -45,6 +48,8 @@ void AppConfig::set_defaults() // Version check is enabled by default in the config, but it is not implemented yet. // XXX if (get("version_check").empty()) set("version_check", "1"); + if (get("preset_update").empty()) + set("preset_update", "1"); // Use OpenGL 1.1 even if OpenGL 2.0 is available. This is mainly to support some buggy Intel HD Graphics drivers. // https://github.com/prusa3d/Slic3r/issues/233 if (get("use_legacy_opengl").empty()) @@ -67,6 +72,19 @@ void AppConfig::load() if (! data.empty()) // If there is a non-empty data, then it must be a top-level (without a section) config entry. m_storage[""][section.first] = data; + } else if (boost::starts_with(section.first, VENDOR_PREFIX)) { + // This is a vendor section listing enabled model / variants + const auto vendor_name = section.first.substr(VENDOR_PREFIX.size()); + auto &vendor = m_vendors[vendor_name]; + for (const auto &kvp : section.second) { + if (! boost::starts_with(kvp.first, MODEL_PREFIX)) { continue; } + const auto model_name = kvp.first.substr(MODEL_PREFIX.size()); + std::vector variants; + if (! unescape_strings_cstyle(kvp.second.data(), variants)) { continue; } + for (const auto &variant : variants) { + vendor[model_name].insert(variant); + } + } } else { // This must be a section name. Read the entries of a section. std::map &storage = m_storage[section.first]; @@ -96,10 +114,53 @@ void AppConfig::save() for (const std::pair &kvp : category.second) c << kvp.first << " = " << kvp.second << std::endl; } + // Write vendor sections + for (const auto &vendor : m_vendors) { + size_t size_sum = 0; + for (const auto &model : vendor.second) { size_sum += model.second.size(); } + if (size_sum == 0) { continue; } + + c << std::endl << "[" << VENDOR_PREFIX << vendor.first << "]" << std::endl; + + for (const auto &model : vendor.second) { + if (model.second.size() == 0) { continue; } + const std::vector variants(model.second.begin(), model.second.end()); + const auto escaped = escape_strings_cstyle(variants); + c << MODEL_PREFIX << model.first << " = " << escaped << std::endl; + } + } c.close(); m_dirty = false; } +bool AppConfig::get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const +{ + std::cerr << "AppConfig::get_variant(" << vendor << ", " << model << ", " << variant << ") "; + + const auto it_v = m_vendors.find(vendor); + if (it_v == m_vendors.end()) { return false; } + const auto it_m = it_v->second.find(model); + return it_m == it_v->second.end() ? false : it_m->second.find(variant) != it_m->second.end(); +} + +void AppConfig::set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable) +{ + if (enable) { + if (get_variant(vendor, model, variant)) { return; } + m_vendors[vendor][model].insert(variant); + } else { + auto it_v = m_vendors.find(vendor); + if (it_v == m_vendors.end()) { return; } + auto it_m = it_v->second.find(model); + if (it_m == it_v->second.end()) { return; } + auto it_var = it_m->second.find(variant); + if (it_var == it_m->second.end()) { return; } + it_m->second.erase(it_var); + } + // If we got here, there was an update + m_dirty = true; +} + std::string AppConfig::get_last_dir() const { const auto it = m_storage.find("recent"); @@ -156,6 +217,16 @@ void AppConfig::reset_selections() } } +bool AppConfig::version_check_enabled() const +{ + return get("version_check") == "1"; +} + +bool AppConfig::slic3r_update_avail() const +{ + return version_check_enabled() && get("version_online") != SLIC3R_VERSION; +} + std::string AppConfig::config_path() { return (boost::filesystem::path(Slic3r::data_dir()) / "slic3r.ini").make_preferred().string(); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index 9b1d5a7128..4ccd51304f 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -1,9 +1,12 @@ #ifndef slic3r_AppConfig_hpp_ #define slic3r_AppConfig_hpp_ +#include #include #include +#include "libslic3r/Config.hpp" + namespace Slic3r { class AppConfig @@ -65,6 +68,13 @@ public: void clear_section(const std::string §ion) { m_storage[section].clear(); } + // TODO: remove / upgrade + // ConfigOptionStrings get_strings(const std::string §ion, const std::string &key) const; + // void set_strings(const std::string §ion, const std::string &key, const ConfigOptionStrings &value); + // TODO: + bool get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const; + void set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable); + // return recent/skein_directory or recent/config_directory or empty string. std::string get_last_dir() const; void update_config_dir(const std::string &dir); @@ -78,6 +88,10 @@ public: // the first non-default preset when called. void reset_selections(); + // Whether the Slic3r version available online differs from this one + bool version_check_enabled() const; + bool slic3r_update_avail() const; + // Get the default config path from Slic3r::data_dir(). static std::string config_path(); @@ -87,6 +101,8 @@ public: private: // Map of section, name -> value std::map> m_storage; + // Map of enabled vendors / models / variants + std::map>> m_vendors; // Has any value been modified since the config.ini has been last saved or loaded? bool m_dirty; }; diff --git a/xs/src/slic3r/Utils/PresetUpdate.cpp b/xs/src/slic3r/Utils/PresetUpdate.cpp deleted file mode 100644 index 0e4c62af9a..0000000000 --- a/xs/src/slic3r/Utils/PresetUpdate.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "PresetUpdate.hpp" - -#include // XXX -#include -#include -#include - -#include "libslic3r/Utils.hpp" -#include "slic3r/GUI/PresetBundle.hpp" -#include "slic3r/Utils/Http.hpp" - -namespace fs = boost::filesystem; - - -namespace Slic3r { - - -struct PresetUpdater::priv -{ - PresetBundle *bundle; - fs::path cache_path; - std::thread thread; - - priv(PresetBundle *bundle); - - void download(); -}; - - -PresetUpdater::priv::priv(PresetBundle *bundle) : - bundle(bundle), - cache_path(fs::path(Slic3r::data_dir()) / "cache") -{} - -void PresetUpdater::priv::download() -{ - std::cerr << "PresetUpdater::priv::download()" << std::endl; - - std::cerr << "Bundle vendors: " << bundle->vendors.size() << std::endl; - for (const auto &vendor : bundle->vendors) { - std::cerr << "vendor: " << vendor.name << std::endl; - std::cerr << " URL: " << vendor.config_update_url << std::endl; - - // TODO: Proper caching - - auto target_path = cache_path / vendor.id; - target_path += ".ini"; - std::cerr << "target_path: " << target_path << std::endl; - - Http::get(vendor.config_update_url) - .on_complete([&](std::string body, unsigned http_status) { - std::cerr << "Got ini: " << http_status << ", body: " << body.size() << std::endl; - fs::fstream file(target_path, std::ios::out | std::ios::binary | std::ios::trunc); - file.write(body.c_str(), body.size()); - }) - .on_error([](std::string body, std::string error, unsigned http_status) { - // TODO: what about errors? - std::cerr << "Error: " << http_status << ", " << error << std::endl; - }) - .perform_sync(); - } -} - -PresetUpdater::PresetUpdater(PresetBundle *preset_bundle) : p(new priv(preset_bundle)) {} - - -// Public - -PresetUpdater::~PresetUpdater() -{ - if (p && p->thread.joinable()) { - p->thread.detach(); - } -} - -void PresetUpdater::download(AppConfig *app_config, PresetBundle *preset_bundle) -{ - std::cerr << "PresetUpdater::download()" << std::endl; - - auto self = std::make_shared(preset_bundle); - auto thread = std::thread([self](){ - self->p->download(); - }); - self->p->thread = std::move(thread); -} - - -// TODO: remove -namespace Utils { - -void preset_update_check() -{ - std::cerr << "preset_update_check()" << std::endl; - - // TODO: - // 1. Get a version tag or the whole bundle from the web - // 2. Store into temporary location (?) - // 3. ??? - // 4. Profit! -} - -} - -} diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp new file mode 100644 index 0000000000..11064d2f0b --- /dev/null +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -0,0 +1,137 @@ +#include "PresetUpdater.hpp" + +#include // XXX +#include +#include +#include +#include + +#include +#include + +#include "libslic3r/Utils.hpp" +#include "slic3r/GUI/GUI.hpp" +// #include "slic3r/GUI/AppConfig.hpp" +#include "slic3r/GUI/PresetBundle.hpp" +#include "slic3r/Utils/Http.hpp" + +namespace fs = boost::filesystem; + + +namespace Slic3r { + + +// TODO: proper URL +static const std::string SLIC3R_VERSION_URL = "https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/e9187c3e15ceaf1a90f29b7c43cf3ccc746140f0/slic3rPE.version"; +enum { + SLIC3R_VERSION_BODY_MAX = 256, +}; + +struct PresetUpdater::priv +{ + int version_online_event; + bool version_check; + bool preset_update; + + fs::path cache_path; + bool cancel; + std::thread thread; + + priv(int event); + + void download(const std::set vendors) const; +}; + +PresetUpdater::priv::priv(int event) : + version_online_event(event), + version_check(false), + preset_update(false), + cache_path(fs::path(Slic3r::data_dir()) / "cache"), + cancel(false) +{} + +void PresetUpdater::priv::download(const std::set vendors) const +{ + std::cerr << "PresetUpdater::priv::download()" << std::endl; + + if (!version_check) { return; } + + // Download current Slic3r version + Http::get(SLIC3R_VERSION_URL) + .size_limit(SLIC3R_VERSION_BODY_MAX) + .on_progress([this](Http::Progress, bool &cancel) { + cancel = this->cancel; + }) + .on_complete([&](std::string body, unsigned http_status) { + boost::trim(body); + std::cerr << "Got version: " << http_status << ", body: \"" << body << '"' << std::endl; + wxCommandEvent* evt = new wxCommandEvent(version_online_event); + evt->SetString(body); + GUI::get_app()->QueueEvent(evt); + }) + .perform_sync(); + + if (!preset_update) { return; } + + // Donwload vendor preset bundles + std::cerr << "Bundle vendors: " << vendors.size() << std::endl; + for (const auto &vendor : vendors) { + std::cerr << "vendor: " << vendor.name << std::endl; + std::cerr << " URL: " << vendor.config_update_url << std::endl; + + if (cancel) { return; } + + // TODO: Proper caching + + auto target_path = cache_path / vendor.id; + target_path += ".ini"; + std::cerr << "target_path: " << target_path << std::endl; + + Http::get(vendor.config_update_url) + .on_progress([this](Http::Progress, bool &cancel) { + cancel = this->cancel; + }) + .on_complete([&](std::string body, unsigned http_status) { + std::cerr << "Got ini: " << http_status << ", body: " << body.size() << std::endl; + fs::fstream file(target_path, std::ios::out | std::ios::binary | std::ios::trunc); + file.write(body.c_str(), body.size()); + }) + .perform_sync(); + } +} + +PresetUpdater::PresetUpdater(int version_online_event, AppConfig *app_config) : + p(new priv(version_online_event)) +{ + p->preset_update = app_config->get("preset_update") == "1"; + // preset_update implies version_check: + p->version_check = p->preset_update || app_config->get("version_check") == "1"; +} + + +// Public + +PresetUpdater::~PresetUpdater() +{ + if (p && p->thread.joinable()) { + p->cancel = true; + p->thread.join(); + } +} + +void PresetUpdater::download(PresetBundle *preset_bundle) +{ + std::cerr << "PresetUpdater::download()" << std::endl; + + // Copy the whole vendors data for use in the background thread + // Unfortunatelly as of C++11, it needs to be copied again + // into the closure (but perhaps the compiler can elide this). + std::set vendors = preset_bundle->vendors; + + p->thread = std::move(std::thread([this, vendors]() { + this->p->download(std::move(vendors)); + })); +} + + +} diff --git a/xs/src/slic3r/Utils/PresetUpdate.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp similarity index 71% rename from xs/src/slic3r/Utils/PresetUpdate.hpp rename to xs/src/slic3r/Utils/PresetUpdater.hpp index 4311340973..aafe9569b7 100644 --- a/xs/src/slic3r/Utils/PresetUpdate.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -12,27 +12,19 @@ class PresetBundle; class PresetUpdater { public: - PresetUpdater(PresetBundle *preset_bundle); + PresetUpdater(int version_online_event, AppConfig *app_config); PresetUpdater(PresetUpdater &&) = delete; PresetUpdater(const PresetUpdater &) = delete; PresetUpdater &operator=(PresetUpdater &&) = delete; PresetUpdater &operator=(const PresetUpdater &) = delete; ~PresetUpdater(); - static void download(AppConfig *app_config, PresetBundle *preset_bundle); + void download(PresetBundle *preset_bundle); private: struct priv; std::unique_ptr p; }; -// TODO: Remove -namespace Utils { - -void preset_update_check(); - } - -} - #endif diff --git a/xs/xsp/GUI_AppConfig.xsp b/xs/xsp/GUI_AppConfig.xsp index 08a88883db..de0e5a22bc 100644 --- a/xs/xsp/GUI_AppConfig.xsp +++ b/xs/xsp/GUI_AppConfig.xsp @@ -43,4 +43,5 @@ void update_last_output_dir(char *dir); void reset_selections(); + bool slic3r_update_avail() const; }; diff --git a/xs/xsp/Utils_PresetUpdate.xsp b/xs/xsp/Utils_PresetUpdate.xsp deleted file mode 100644 index 3596b7c86b..0000000000 --- a/xs/xsp/Utils_PresetUpdate.xsp +++ /dev/null @@ -1,18 +0,0 @@ -%module{Slic3r::XS}; - -%{ -#include -#include "slic3r/Utils/PresetUpdate.hpp" -%} - -%name{Slic3r::PresetUpdater} class PresetUpdater { - static void download(PresetBundle *preset_bundle); -}; - - -# TODO: remove: - -%package{Slic3r::Utils}; - -void preset_update_check() - %code%{ Slic3r::Utils::preset_update_check(); %}; diff --git a/xs/xsp/Utils_PresetUpdater.xsp b/xs/xsp/Utils_PresetUpdater.xsp new file mode 100644 index 0000000000..666379f02e --- /dev/null +++ b/xs/xsp/Utils_PresetUpdater.xsp @@ -0,0 +1,11 @@ +%module{Slic3r::XS}; + +%{ +#include +#include "slic3r/Utils/PresetUpdater.hpp" +%} + +%name{Slic3r::PresetUpdater} class PresetUpdater { + PresetUpdater(int version_online_event, AppConfig *app_config); + void download(PresetBundle* preset_bundle); +}; diff --git a/xs/xsp/my.map b/xs/xsp/my.map index d817af0529..9c0f60c1dc 100644 --- a/xs/xsp/my.map +++ b/xs/xsp/my.map @@ -239,6 +239,10 @@ Ref O_OBJECT_SLIC3R_T # ConfigWizard* O_OBJECT_SLIC3R # Ref O_OBJECT_SLIC3R_T +PresetUpdater* O_OBJECT_SLIC3R +Ref O_OBJECT_SLIC3R_T +Clone O_OBJECT_SLIC3R_T + OctoPrint* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T Clone O_OBJECT_SLIC3R_T From e53949f2c85e06adaf7be9a96873844a8862eab6 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 29 Mar 2018 17:54:43 +0200 Subject: [PATCH 0123/1150] Apply printer model / variant preferences when loading presets --- lib/Slic3r/GUI.pm | 2 +- lib/Slic3r/GUI/MainFrame.pm | 6 +- resources/profiles/PrusaResearch.ini | 2 + xs/src/slic3r/GUI/AppConfig.cpp | 8 +- xs/src/slic3r/GUI/AppConfig.hpp | 5 +- xs/src/slic3r/GUI/ConfigWizard.cpp | 154 ++++++++++++++++----- xs/src/slic3r/GUI/ConfigWizard.hpp | 5 +- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 30 +++- xs/src/slic3r/GUI/GUI.cpp | 9 +- xs/src/slic3r/GUI/GUI.hpp | 2 +- xs/src/slic3r/GUI/Preset.cpp | 11 ++ xs/src/slic3r/GUI/Preset.hpp | 18 ++- xs/src/slic3r/GUI/PresetBundle.cpp | 20 ++- xs/src/slic3r/GUI/PresetBundle.hpp | 2 + xs/src/slic3r/Utils/PresetUpdater.cpp | 2 +- xs/xsp/GUI.xsp | 4 +- xs/xsp/GUI_Preset.xsp | 2 +- 17 files changed, 218 insertions(+), 64 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 495dd9ecc7..ed2f6dfc7d 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -154,7 +154,7 @@ sub OnInit { $self->{mainframe}->config_wizard(1); } - $self->{preset_updater}->download($self->{preset_bundle}); + # $self->{preset_updater}->download($self->{preset_bundle}); }); # The following event is emited by the C++ menu implementation of application language change. diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 68fc963394..4307375c81 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -646,7 +646,11 @@ sub config_wizard { # TODO: Offer "reset user profile" - Slic3r::GUI::open_config_wizard(); + Slic3r::GUI::open_config_wizard(wxTheApp->{preset_bundle}); + # Load the currently selected preset into the GUI, update the preset selection box. + foreach my $tab (values %{$self->{options_tabs}}) { # XXX: only if not cancelled? + $tab->load_current_preset; + } return; # Enumerate the profiles bundled with the Slic3r installation under resources/profiles. diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 0a1d26eaa0..6dc29a96e9 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -999,6 +999,7 @@ default_print_profile = 0.15mm OPTIMAL MK3 [printer:Original Prusa i3 MK3 0.25 nozzle] inherits = *common* nozzle_diameter = 0.25 +printer_variant = 0.25 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 @@ -1009,6 +1010,7 @@ default_print_profile = 0.10mm DETAIL MK3 [printer:Original Prusa i3 MK3 0.6 nozzle] inherits = *common* nozzle_diameter = 0.6 +printer_variant = 0.6 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index e951beb440..10a586e27c 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -135,7 +135,7 @@ void AppConfig::save() bool AppConfig::get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const { - std::cerr << "AppConfig::get_variant(" << vendor << ", " << model << ", " << variant << ") "; + // std::cerr << "AppConfig::get_variant(" << vendor << ", " << model << ", " << variant << ") " << std::endl; const auto it_v = m_vendors.find(vendor); if (it_v == m_vendors.end()) { return false; } @@ -161,6 +161,12 @@ void AppConfig::set_variant(const std::string &vendor, const std::string &model, m_dirty = true; } +void AppConfig::set_vendors(const AppConfig &from) +{ + m_vendors = from.m_vendors; + m_dirty = true; +} + std::string AppConfig::get_last_dir() const { const auto it = m_storage.find("recent"); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index 4ccd51304f..e43ff51bf6 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -68,12 +68,9 @@ public: void clear_section(const std::string §ion) { m_storage[section].clear(); } - // TODO: remove / upgrade - // ConfigOptionStrings get_strings(const std::string §ion, const std::string &key) const; - // void set_strings(const std::string §ion, const std::string &key, const ConfigOptionStrings &value); - // TODO: bool get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const; void set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable); + void set_vendors(const AppConfig &from); // return recent/skein_directory or recent/config_directory or empty string. std::string get_last_dir() const; diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 3cad789b65..556b91a462 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -74,13 +74,17 @@ void ConfigWizardPage::append_text(wxString text) auto *widget = new wxStaticText(this, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); widget->Wrap(CONTENT_WIDTH); widget->SetMinSize(wxSize(CONTENT_WIDTH, -1)); - // content->Add(widget, 1, wxALIGN_LEFT | wxTOP | wxBOTTOM, 10); content->Add(widget, 0, wxALIGN_LEFT | wxTOP | wxBOTTOM, 10); } -void ConfigWizardPage::append_widget(wxWindow *widget, int proportion) +void ConfigWizardPage::append_widget(wxWindow *widget, int proportion, int flag, int border) { - content->Add(widget, proportion, wxEXPAND | wxTOP | wxBOTTOM, 10); + content->Add(widget, proportion, flag, border); +} + +void ConfigWizardPage::append_sizer(wxSizer *sizer, int proportion) +{ + content->Add(sizer, proportion, wxEXPAND | wxTOP | wxBOTTOM, 10); } void ConfigWizardPage::append_spacer(int space) @@ -99,17 +103,19 @@ void ConfigWizardPage::enable_next(bool enable) { parent->p->enable_next(enable) // Wizard pages -PageWelcome::PageWelcome(ConfigWizard *parent, const PresetBundle &bundle) : +// PageWelcome::PageWelcome(ConfigWizard *parent, const PresetBundle &bundle) : +PageWelcome::PageWelcome(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Welcome to the Slic3r Configuration assistant")), _(L("Welcome"))), others_buttons(new wxPanel(parent)), variants_checked(0) { append_text(_(L("Hello, welcome to Slic3r Prusa Edition! TODO: This text."))); + const PresetBundle &bundle = wizard_p()->bundle_vendors; const auto &vendors = bundle.vendors; const auto vendor_prusa = std::find(vendors.cbegin(), vendors.cend(), VendorProfile("PrusaResearch")); - // TODO: preload checkiness from app config + const AppConfig &appconfig_vendors = wizard_p()->appconfig_vendors; if (vendor_prusa != vendors.cend()) { const auto &models = vendor_prusa->models; @@ -138,12 +144,20 @@ PageWelcome::PageWelcome(ConfigWizard *parent, const PresetBundle &bundle) : sizer->AddSpacer(20); + std::string model_id = model->id; + for (const auto &variant : model->variants) { + std::string variant_name = variant.name; auto *cbox = new wxCheckBox(panel, wxID_ANY, wxString::Format("%s %s %s", variant.name, _(L("mm")), _(L("nozzle")))); + bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant_name); + variants_checked += enabled; + cbox->SetValue(enabled); sizer->Add(cbox, 0, wxBOTTOM, 3); - cbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { + cbox->Bind(wxEVT_CHECKBOX, [=](wxCommandEvent &event) { this->variants_checked += event.IsChecked() ? 1 : -1; this->on_variant_checked(); + AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors; + appconfig_vendors.set_variant("PrusaResearch", model_id, variant_name, event.IsChecked()); }); } @@ -156,6 +170,7 @@ PageWelcome::PageWelcome(ConfigWizard *parent, const PresetBundle &bundle) : { auto *sizer = new wxBoxSizer(wxHORIZONTAL); auto *other_vendors = new wxButton(others_buttons, wxID_ANY, _(L("Other vendors"))); + other_vendors->Disable(); auto *custom_setup = new wxButton(others_buttons, wxID_ANY, _(L("Custom setup"))); sizer->Add(other_vendors); @@ -181,17 +196,24 @@ void PageWelcome::on_variant_checked() } PageUpdate::PageUpdate(ConfigWizard *parent) : - ConfigWizardPage(parent, _(L("Automatic updates")), _(L("Updates"))) + ConfigWizardPage(parent, _(L("Automatic updates")), _(L("Updates"))), + version_check(true), + preset_update(true) { - append_text(_(L("TODO: text"))); - auto *box_slic3r = new wxCheckBox(this, wxID_ANY, _(L("Check for Slic3r updates"))); - box_slic3r->SetValue(true); - append_widget(box_slic3r); + const AppConfig *app_config = GUI::get_app_config(); + append_text(_(L("TODO: text"))); + auto *box_slic3r = new wxCheckBox(this, wxID_ANY, _(L("Check for Slic3r updates"))); + box_slic3r->SetValue(app_config->get("version_check") == "1"); + append_widget(box_slic3r); + append_text(_(L("TODO: text"))); auto *box_presets = new wxCheckBox(this, wxID_ANY, _(L("Update built-in Presets automatically"))); - box_presets->SetValue(true); + box_presets->SetValue(app_config->get("preset_update") == "1"); append_widget(box_presets); + + box_slic3r->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->version_check = event.IsChecked(); }); + box_presets->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->preset_update = event.IsChecked(); }); } void PageUpdate::presets_update_enable(bool enable) @@ -201,7 +223,42 @@ void PageUpdate::presets_update_enable(bool enable) PageVendors::PageVendors(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Other Vendors")), _(L("Other Vendors"))) -{} +{ + enum { + INDENT_SPACING = 30, + VERTICAL_SPACING = 10, + }; + + append_text(_(L("Other vendors! TODO: This text."))); + + const PresetBundle &bundle = wizard_p()->bundle_vendors; + auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + boldfont.SetWeight(wxFONTWEIGHT_BOLD); + + for (const auto &vendor : bundle.vendors) { + if (vendor.id == "PrusaResearch") { continue; } + + auto *label_vendor = new wxStaticText(this, wxID_ANY, vendor.name); + label_vendor->SetFont(boldfont); + append_thing(label_vendor, 0, 0, 0); + + for (const auto &model : vendor.models) { + auto *label_model = new wxStaticText(this, wxID_ANY, model.name); + label_model->SetFont(boldfont); + append_thing(label_model, 0, wxLEFT, INDENT_SPACING); + + for (const auto &variant : model.variants) { + auto *cbox = new wxCheckBox(this, wxID_ANY, variant.name); + append_thing(cbox, 0, wxEXPAND | wxLEFT, 2 * INDENT_SPACING); + cbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { + // TODO + }); + } + } + + append_spacer(VERTICAL_SPACING); + } +} PageFirmware::PageFirmware(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Firmware Type")), _(L("Firmware"))) @@ -289,6 +346,31 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt) // priv +void ConfigWizard::priv::load_vendors() +{ + const auto vendor_dir = fs::path(Slic3r::data_dir()) / "vendor"; + // const auto profiles_dir = fs::path(resources_dir()) / "profiles"; + for (fs::directory_iterator it(vendor_dir); it != fs::directory_iterator(); ++it) { + if (it->path().extension() == ".ini") { + bundle_vendors.load_configbundle(it->path().native(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); + } + } + + // XXX + // for (const auto &vendor : bundle_vendors.vendors) { + // std::cerr << "vendor: " << vendor.name << std::endl; + // std::cerr << " URL: " << vendor.config_update_url << std::endl; + // for (const auto &model : vendor.models) { + // std::cerr << "\tmodel: " << model.id << " (" << model.name << ")" << std::endl; + // for (const auto &variant : model.variants) { + // std::cerr << "\t\tvariant: " << variant.name << std::endl; + // } + // } + // } + + appconfig_vendors.set_vendors(*GUI::get_app_config()); +} + void ConfigWizard::priv::index_refresh() { index->load_items(page_welcome); @@ -344,12 +426,31 @@ void ConfigWizard::priv::on_custom_setup() set_page(page_firmware); } +void ConfigWizard::priv::on_finish() +{ + const bool is_custom_setup = page_welcome->page_next() == page_firmware; + + if (! is_custom_setup) { + AppConfig *app_config = GUI::get_app_config(); + app_config->set_vendors(appconfig_vendors); + + app_config->set("version_check", page_update->version_check ? "1" : "0"); + app_config->set("preset_update", page_update->preset_update ? "1" : "0"); + } else { + // TODO + } + + q->EndModal(wxID_OK); +} + // Public -ConfigWizard::ConfigWizard(wxWindow *parent, const PresetBundle &bundle) : +ConfigWizard::ConfigWizard(wxWindow *parent) : wxDialog(parent, wxID_ANY, _(L("Configuration Assistant")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), p(new priv(this)) { + p->load_vendors(); + p->index = new ConfigWizardIndex(this); auto *vsizer = new wxBoxSizer(wxVERTICAL); @@ -372,7 +473,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent, const PresetBundle &bundle) : p->btnsizer->Add(p->btn_finish, 0, wxLEFT, BTN_SPACING); p->btnsizer->Add(p->btn_cancel, 0, wxLEFT, BTN_SPACING); - p->add_page(p->page_welcome = new PageWelcome(this, bundle)); + p->add_page(p->page_welcome = new PageWelcome(this)); p->add_page(p->page_update = new PageUpdate(this)); p->add_page(p->page_vendors = new PageVendors(this)); p->add_page(p->page_firmware = new PageFirmware(this)); @@ -397,35 +498,24 @@ ConfigWizard::ConfigWizard(wxWindow *parent, const PresetBundle &bundle) : p->btn_prev->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->go_prev(); }); p->btn_next->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->go_next(); }); + p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->on_finish(); }); } ConfigWizard::~ConfigWizard() {} -void ConfigWizard::run(wxWindow *parent) +void ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) { - PresetBundle bundle; - const auto profiles_dir = fs::path(resources_dir()) / "profiles"; for (fs::directory_iterator it(profiles_dir); it != fs::directory_iterator(); ++it) { if (it->path().extension() == ".ini") { - bundle.load_configbundle(it->path().native(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); + PresetBundle::install_vendor_configbundle(it->path()); } } - // XXX - for (const auto &vendor : bundle.vendors) { - std::cerr << "vendor: " << vendor.name << std::endl; - std::cerr << " URL: " << vendor.config_update_url << std::endl; - for (const auto &model : vendor.models) { - std::cerr << "\tmodel: " << model.id << " (" << model.name << ")" << std::endl; - for (const auto &variant : model.variants) { - std::cerr << "\t\tvariant: " << variant.name << std::endl; - } - } + ConfigWizard wizard(parent); + if (wizard.ShowModal() == wxID_OK) { + preset_bundle->load_presets(*GUI::get_app_config()); } - - ConfigWizard wizard(parent, bundle); - wizard.ShowModal(); } diff --git a/xs/src/slic3r/GUI/ConfigWizard.hpp b/xs/src/slic3r/GUI/ConfigWizard.hpp index 1b14e29be7..a06388396c 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard.hpp @@ -15,14 +15,15 @@ namespace GUI { class ConfigWizard: public wxDialog { public: - ConfigWizard(wxWindow *parent, const PresetBundle &bundle); + // ConfigWizard(wxWindow *parent, const PresetBundle &bundle); + ConfigWizard(wxWindow *parent); ConfigWizard(ConfigWizard &&) = delete; ConfigWizard(const ConfigWizard &) = delete; ConfigWizard &operator=(ConfigWizard &&) = delete; ConfigWizard &operator=(const ConfigWizard &) = delete; ~ConfigWizard(); - static void run(wxWindow *parent); + static void run(wxWindow *parent, PresetBundle *preset_bundle); private: struct priv; std::unique_ptr p; diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index ba028c0e87..ab291d40f8 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -9,6 +9,9 @@ #include #include +#include "AppConfig.hpp" +#include "PresetBundle.hpp" + namespace Slic3r { namespace GUI { @@ -34,14 +37,23 @@ struct ConfigWizardPage: wxPanel virtual ~ConfigWizardPage(); - ConfigWizardPage *page_prev() const { return p_prev; } - ConfigWizardPage *page_next() const { return p_next; } + ConfigWizardPage* page_prev() const { return p_prev; } + ConfigWizardPage* page_next() const { return p_next; } ConfigWizardPage* chain(ConfigWizardPage *page); void append_text(wxString text); - void append_widget(wxWindow *widget, int proportion = 0); + void append_widget(wxWindow *widget, int proportion = 0, int flag = wxEXPAND|wxTOP|wxBOTTOM, int border = 10); + + template + void append_thing(T *thing, int proportion = 0, int flag = wxEXPAND|wxTOP|wxBOTTOM, int border = 10) + { + content->Add(thing, proportion, flag, border); + } + + // TODO: remove: + void append_sizer(wxSizer *sizer, int proportion = 0); void append_spacer(int space); - + ConfigWizard::priv *wizard_p() const { return parent->p.get(); } virtual bool Show(bool show = true); @@ -60,7 +72,7 @@ struct PageWelcome: ConfigWizardPage wxPanel *others_buttons; unsigned variants_checked; - PageWelcome(ConfigWizard *parent, const PresetBundle &bundle); + PageWelcome(ConfigWizard *parent); virtual wxPanel* extra_buttons() { return others_buttons; } virtual void on_page_set(); @@ -70,6 +82,9 @@ struct PageWelcome: ConfigWizardPage struct PageUpdate: ConfigWizardPage { + bool version_check; + bool preset_update; + PageUpdate(ConfigWizard *parent); void presets_update_enable(bool enable); @@ -124,6 +139,9 @@ private: struct ConfigWizard::priv { ConfigWizard *q; + AppConfig appconfig_vendors; + PresetBundle bundle_vendors; + wxBoxSizer *topsizer = nullptr; wxBoxSizer *btnsizer = nullptr; ConfigWizardPage *page_current = nullptr; @@ -143,6 +161,7 @@ struct ConfigWizard::priv priv(ConfigWizard *q) : q(q) {} + void load_vendors(); void add_page(ConfigWizardPage *page); void index_refresh(); void set_page(ConfigWizardPage *page); @@ -152,6 +171,7 @@ struct ConfigWizard::priv void on_other_vendors(); void on_custom_setup(); + void on_finish(); }; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 53288067cf..80e2322875 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -353,18 +353,13 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change) //#endif } -void open_config_wizard() +void open_config_wizard(PresetBundle *preset_bundle) { if (g_wxMainFrame == nullptr) { throw std::runtime_error("Main frame not set"); } - // auto *wizard = new ConfigWizard(static_cast(g_wxMainFrame)); // FIXME: lifetime - - // wizard->run(); - ConfigWizard::run(g_wxMainFrame); - - // show_info(g_wxMainFrame, "After wizard", "After wizard"); + ConfigWizard::run(g_wxMainFrame, preset_bundle); } void open_preferences_dialog(int event_preferences) diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 1f93e18e99..98a1240919 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -86,7 +86,7 @@ wxColour* get_sys_label_clr(); void add_debug_menu(wxMenuBar *menu, int event_language_change); // Opens the first-time configuration wizard -void open_config_wizard(); +void open_config_wizard(PresetBundle *preset_bundle); // Create "Preferences" dialog after selecting menu "Preferences" in Perl part void open_preferences_dialog(int event_preferences); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index c437f8b414..40afca144b 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -2,6 +2,7 @@ #include #include "Preset.hpp" +#include "AppConfig.hpp" #include #include @@ -175,6 +176,16 @@ bool Preset::update_compatible_with_printer(const Preset &active_printer, const return this->is_compatible = is_compatible_with_printer(active_printer, extra_config); } +void Preset::set_visible_from_appconfig(const AppConfig &app_config) +{ + if (vendor == nullptr) { return; } + const std::string &model = config.opt_string("printer_model"); + const std::string &variant = config.opt_string("printer_variant"); + if (model.empty() || variant.empty()) { return; } + is_visible = app_config.get_variant(vendor->id, model, variant); + std::cerr << vendor->id << " / " << model << " / " << variant << ": visible: " << is_visible << std::endl; +} + const std::vector& Preset::print_options() { static std::vector s_opts { diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 78e15badae..075eed9afd 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -13,6 +13,8 @@ class wxItemContainer; namespace Slic3r { +class AppConfig; + enum ConfigFileType { CONFIG_FILE_TYPE_UNKNOWN, @@ -35,14 +37,14 @@ public: PrinterVariant() {} PrinterVariant(const std::string &name) : name(name) {} std::string name; - bool enabled = true; + // bool enabled = true; // TODO: remove these? }; struct PrinterModel { PrinterModel() {} std::string id; std::string name; - bool enabled = true; + // bool enabled = true; std::vector variants; PrinterVariant* variant(const std::string &name) { for (auto &v : this->variants) @@ -85,7 +87,7 @@ public: bool is_external = false; // System preset is read-only. bool is_system = false; - // Preset is visible, if it is compatible with the active Printer. + // Preset is visible, if it is compatible with the active Printer. TODO: fix // Also the "default" preset is only visible, if it is the only preset in the list. bool is_visible = true; // Has this preset been modified? @@ -131,6 +133,9 @@ public: // Mark this preset as compatible if it is compatible with active_printer. bool update_compatible_with_printer(const Preset &active_printer, const DynamicPrintConfig *extra_config); + // Set is_visible according to application config + void set_visible_from_appconfig(const AppConfig &app_config); + // Resize the extruder specific fields, initialize them with the content of the 1st extruder. void set_num_extruders(unsigned int n) { set_num_extruders(this->config, n); } @@ -162,6 +167,13 @@ public: PresetCollection(Preset::Type type, const std::vector &keys); ~PresetCollection(); + typedef std::deque::iterator Iterator; + typedef std::deque::const_iterator ConstIterator; + Iterator begin() { return m_presets.begin() + 1; } + ConstIterator begin() const { return m_presets.begin() + 1; } + Iterator end() { return m_presets.end(); } + ConstIterator end() const { return m_presets.end(); } + void reset(bool delete_files); Preset::Type type() const { return m_type; } diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 241f0433ef..8645a4f2d3 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -4,6 +4,7 @@ #include "PresetBundle.hpp" #include "BitmapCache.hpp" +#include // XXX #include #include #include @@ -105,7 +106,7 @@ void PresetBundle::setup_directories() std::initializer_list paths = { data_dir, data_dir / "vendor", - data_dir / "cache", + data_dir / "cache", // TODO: rename as vendor-cache? (Check usage elsewhere!) #ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR // Store the print/filament/printer presets into a "presets" directory. data_dir / "presets", @@ -200,8 +201,12 @@ static inline std::string remove_ini_suffix(const std::string &name) // If the "vendor" section is missing, enable all models and variants of the particular vendor. void PresetBundle::load_installed_printers(const AppConfig &config) { - // TODO - // m_storage + std::cerr << "load_installed_printers()" << std::endl; + + for (auto &preset : printers) { + std::cerr << "preset: printer: " << preset.name << std::endl; + preset.set_visible_from_appconfig(config); + } } // Load selections (current print, current filaments, current printer) from config.ini @@ -221,6 +226,10 @@ void PresetBundle::load_selections(const AppConfig &config) break; this->set_filament_preset(i, remove_ini_suffix(config.get("presets", name))); } + + // Update visibility of presets based on application vendor / model / variant configuration. + this->load_installed_printers(config); + // Update visibility of presets based on their compatibility with the active printer. // Always try to select a compatible print and filament preset to the current printer preset, // as the application may have been closed with an active "external" preset, which does not @@ -708,6 +717,11 @@ static void load_vendor_profile(const boost::property_tree::ptree &tree, VendorP void PresetBundle::install_vendor_configbundle(const std::string &src_path0) { boost::filesystem::path src_path(src_path0); + install_vendor_configbundle(src_path); +} + +void PresetBundle::install_vendor_configbundle(const boost::filesystem::path &src_path) +{ boost::filesystem::copy_file(src_path, (boost::filesystem::path(data_dir()) / "vendor" / src_path.filename()).make_preferred(), boost::filesystem::copy_option::overwrite_if_exists); } diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index 4949e0e037..4189e6c46f 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -5,6 +5,7 @@ #include "Preset.hpp" #include +#include namespace Slic3r { @@ -88,6 +89,7 @@ public: // Install the Vendor specific config bundle into user's directory. void install_vendor_configbundle(const std::string &src_path); + static void install_vendor_configbundle(const boost::filesystem::path &src_path); // Export a config bundle file containing all the presets and the names of the active presets. void export_configbundle(const std::string &path); // , const DynamicPrintConfig &settings); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 11064d2f0b..040d326b5c 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -11,9 +11,9 @@ #include "libslic3r/Utils.hpp" #include "slic3r/GUI/GUI.hpp" -// #include "slic3r/GUI/AppConfig.hpp" #include "slic3r/GUI/PresetBundle.hpp" #include "slic3r/Utils/Http.hpp" +#include "slic3r/Utils/Semver.hpp" namespace fs = boost::filesystem; diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 5115eda646..ad7f69a2d7 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -54,8 +54,8 @@ int combochecklist_get_flags(SV *ui) void set_app_config(AppConfig *app_config) %code%{ Slic3r::GUI::set_app_config(app_config); %}; -void open_config_wizard() - %code%{ Slic3r::GUI::open_config_wizard(); %}; +void open_config_wizard(PresetBundle *preset_bundle) + %code%{ Slic3r::GUI::open_config_wizard(preset_bundle); %}; void open_preferences_dialog(int preferences_event) %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %}; diff --git a/xs/xsp/GUI_Preset.xsp b/xs/xsp/GUI_Preset.xsp index 84efdde53f..1187a1cf56 100644 --- a/xs/xsp/GUI_Preset.xsp +++ b/xs/xsp/GUI_Preset.xsp @@ -147,7 +147,7 @@ PresetCollection::arrayref() void install_vendor_configbundle(const char *path) %code%{ try { - THIS->install_vendor_configbundle(path); + THIS->install_vendor_configbundle(std::string(path)); } catch (std::exception& e) { croak("Installing a vendor config bundle %s failed:\n%s\n", path, e.what()); } From 8422cf93c0e550e75a40522c56b9570c72d32169 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 5 Apr 2018 16:10:44 +0200 Subject: [PATCH 0124/1150] ConfigWizard: Finalize custom setup --- xs/src/libslic3r/Config.hpp | 1 + xs/src/libslic3r/PrintConfig.cpp | 2 +- xs/src/slic3r/GUI/ConfigWizard.cpp | 246 +++++++++++++++------ xs/src/slic3r/GUI/ConfigWizard_private.hpp | 40 +++- 4 files changed, 212 insertions(+), 77 deletions(-) diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 6eb307c5ce..06db9efef2 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -659,6 +659,7 @@ public: ConfigOptionPoints() : ConfigOptionVector() {} explicit ConfigOptionPoints(size_t n, const Pointf &value) : ConfigOptionVector(n, value) {} explicit ConfigOptionPoints(std::initializer_list il) : ConfigOptionVector(std::move(il)) {} + explicit ConfigOptionPoints(const std::vector &values) : ConfigOptionVector(values) {} static ConfigOptionType static_type() { return coPoints; } ConfigOptionType type() const override { return static_type(); } diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 657e5a4520..5795f044bc 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1620,7 +1620,7 @@ PrintConfigDef::PrintConfigDef() "temperature control commands in the output."); def->cli = "temperature=i@"; def->full_label = L("Temperature"); - def->max = 0; + def->min = 0; def->max = max_temp; def->default_value = new ConfigOptionInts { 200 }; diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 556b91a462..edf958bd8f 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -74,17 +74,7 @@ void ConfigWizardPage::append_text(wxString text) auto *widget = new wxStaticText(this, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); widget->Wrap(CONTENT_WIDTH); widget->SetMinSize(wxSize(CONTENT_WIDTH, -1)); - content->Add(widget, 0, wxALIGN_LEFT | wxTOP | wxBOTTOM, 10); -} - -void ConfigWizardPage::append_widget(wxWindow *widget, int proportion, int flag, int border) -{ - content->Add(widget, proportion, flag, border); -} - -void ConfigWizardPage::append_sizer(wxSizer *sizer, int proportion) -{ - content->Add(sizer, proportion, wxEXPAND | wxTOP | wxBOTTOM, 10); + append(widget); } void ConfigWizardPage::append_spacer(int space) @@ -103,7 +93,6 @@ void ConfigWizardPage::enable_next(bool enable) { parent->p->enable_next(enable) // Wizard pages -// PageWelcome::PageWelcome(ConfigWizard *parent, const PresetBundle &bundle) : PageWelcome::PageWelcome(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Welcome to the Slic3r Configuration assistant")), _(L("Welcome"))), others_buttons(new wxPanel(parent)), @@ -164,13 +153,13 @@ PageWelcome::PageWelcome(ConfigWizard *parent) : printer_grid->Add(panel); } - append_widget(printer_picker); + append(printer_picker); } { auto *sizer = new wxBoxSizer(wxHORIZONTAL); auto *other_vendors = new wxButton(others_buttons, wxID_ANY, _(L("Other vendors"))); - other_vendors->Disable(); + // other_vendors->Disable(); // XXX auto *custom_setup = new wxButton(others_buttons, wxID_ANY, _(L("Custom setup"))); sizer->Add(other_vendors); @@ -201,36 +190,24 @@ PageUpdate::PageUpdate(ConfigWizard *parent) : preset_update(true) { const AppConfig *app_config = GUI::get_app_config(); - + append_text(_(L("TODO: text"))); auto *box_slic3r = new wxCheckBox(this, wxID_ANY, _(L("Check for Slic3r updates"))); box_slic3r->SetValue(app_config->get("version_check") == "1"); - append_widget(box_slic3r); + append(box_slic3r); append_text(_(L("TODO: text"))); auto *box_presets = new wxCheckBox(this, wxID_ANY, _(L("Update built-in Presets automatically"))); box_presets->SetValue(app_config->get("preset_update") == "1"); - append_widget(box_presets); + append(box_presets); box_slic3r->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->version_check = event.IsChecked(); }); box_presets->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->preset_update = event.IsChecked(); }); } -void PageUpdate::presets_update_enable(bool enable) -{ - // TODO -} - PageVendors::PageVendors(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Other Vendors")), _(L("Other Vendors"))) { - enum { - INDENT_SPACING = 30, - VERTICAL_SPACING = 10, - }; - - append_text(_(L("Other vendors! TODO: This text."))); - const PresetBundle &bundle = wizard_p()->bundle_vendors; auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); boldfont.SetWeight(wxFONTWEIGHT_BOLD); @@ -240,16 +217,16 @@ PageVendors::PageVendors(ConfigWizard *parent) : auto *label_vendor = new wxStaticText(this, wxID_ANY, vendor.name); label_vendor->SetFont(boldfont); - append_thing(label_vendor, 0, 0, 0); + append(label_vendor, 0, 0, 0); for (const auto &model : vendor.models) { auto *label_model = new wxStaticText(this, wxID_ANY, model.name); label_model->SetFont(boldfont); - append_thing(label_model, 0, wxLEFT, INDENT_SPACING); + append(label_model, 0, wxLEFT, INDENT_SPACING); for (const auto &variant : model.variants) { auto *cbox = new wxCheckBox(this, wxID_ANY, variant.name); - append_thing(cbox, 0, wxEXPAND | wxLEFT, 2 * INDENT_SPACING); + append(cbox, 0, wxEXPAND | wxLEFT, 2 * INDENT_SPACING); cbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { // TODO }); @@ -260,21 +237,169 @@ PageVendors::PageVendors(ConfigWizard *parent) : } } + PageFirmware::PageFirmware(ConfigWizard *parent) : - ConfigWizardPage(parent, _(L("Firmware Type")), _(L("Firmware"))) -{} + ConfigWizardPage(parent, _(L("Firmware Type")), _(L("Firmware"))), + gcode_opt(print_config_def.options["gcode_flavor"]), + gcode_picker(nullptr) +{ + append_text(_(L("Choose the type of firmware used by your printer."))); + append_text(gcode_opt.tooltip); + + wxArrayString choices; + choices.Alloc(gcode_opt.enum_labels.size()); + for (const auto &label : gcode_opt.enum_labels) { + choices.Add(label); + } + + gcode_picker = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices); + const auto &enum_values = gcode_opt.enum_values; + auto needle = enum_values.cend(); + if (gcode_opt.default_value != nullptr) { + needle = std::find(enum_values.cbegin(), enum_values.cend(), gcode_opt.default_value->serialize()); + } + if (needle != enum_values.cend()) { + gcode_picker->SetSelection(needle - enum_values.cbegin()); + } else { + gcode_picker->SetSelection(0); + } + + append(gcode_picker); +} + +void PageFirmware::apply_custom_config(DynamicPrintConfig &config) +{ + ConfigOptionEnum opt; + + auto sel = gcode_picker->GetSelection(); + if (sel != wxNOT_FOUND && opt.deserialize(gcode_picker->GetString(sel).ToStdString())) { + config.set_key_value("gcode_flavor", &opt); + } +} PageBedShape::PageBedShape(ConfigWizard *parent) : - ConfigWizardPage(parent, _(L("Bed Shape and Size")), _(L("Bed Shape"))) -{} + ConfigWizardPage(parent, _(L("Bed Shape and Size")), _(L("Bed Shape"))), + shape_panel(new BedShapePanel(this)) +{ + append_text(_(L("Set the shape of your printer's bed."))); + + shape_panel->build_panel(wizard_p()->custom_config.option("bed_shape")); + append(shape_panel); +} + +void PageBedShape::apply_custom_config(DynamicPrintConfig &config) +{ + const auto points(shape_panel->GetValue()); + auto *opt = new ConfigOptionPoints(points); + config.set_key_value("bed_shape", opt); +} PageDiameters::PageDiameters(ConfigWizard *parent) : - ConfigWizardPage(parent, _(L("Filament and Nozzle Diameter")), _(L("Print Diameters"))) -{} + ConfigWizardPage(parent, _(L("Filament and Nozzle Diameters")), _(L("Print Diameters"))), + spin_nozzle(new wxSpinCtrlDouble(this, wxID_ANY)), + spin_filam(new wxSpinCtrlDouble(this, wxID_ANY)) +{ + spin_nozzle->SetDigits(2); + spin_nozzle->SetIncrement(0.1); + const auto &def_nozzle = print_config_def.options["nozzle_diameter"]; + auto *default_nozzle = dynamic_cast(def_nozzle.default_value); + spin_nozzle->SetValue(default_nozzle != nullptr && default_nozzle->size() > 0 ? default_nozzle->get_at(0) : 0.5); + + spin_filam->SetDigits(2); + spin_filam->SetIncrement(0.25); + const auto &def_filam = print_config_def.options["filament_diameter"]; + auto *default_filam = dynamic_cast(def_filam.default_value); + spin_filam->SetValue(default_filam != nullptr && default_filam->size() > 0 ? default_filam->get_at(0) : 3.0); + + append_text(_(L("Enter the diameter of your printer's hot end nozzle."))); + + auto *sizer_nozzle = new wxFlexGridSizer(3, 5, 5); + auto *text_nozzle = new wxStaticText(this, wxID_ANY, _(L("Nozzle Diameter:"))); + auto *unit_nozzle = new wxStaticText(this, wxID_ANY, _(L("mm"))); + sizer_nozzle->AddGrowableCol(0, 1); + sizer_nozzle->Add(text_nozzle, 0, wxALIGN_CENTRE_VERTICAL); + sizer_nozzle->Add(spin_nozzle); + sizer_nozzle->Add(unit_nozzle, 0, wxALIGN_CENTRE_VERTICAL); + append(sizer_nozzle); + + append_spacer(VERTICAL_SPACING); + + append_text(_(L("Enter the diameter of your filament."))); + append_text(_(L("Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average."))); + + auto *sizer_filam = new wxFlexGridSizer(3, 5, 5); + auto *text_filam = new wxStaticText(this, wxID_ANY, _(L("Filament Diameter:"))); + auto *unit_filam = new wxStaticText(this, wxID_ANY, _(L("mm"))); + sizer_filam->AddGrowableCol(0, 1); + sizer_filam->Add(text_filam, 0, wxALIGN_CENTRE_VERTICAL); + sizer_filam->Add(spin_filam); + sizer_filam->Add(unit_filam, 0, wxALIGN_CENTRE_VERTICAL); + append(sizer_filam); +} + +void PageDiameters::apply_custom_config(DynamicPrintConfig &config) +{ + auto *opt_nozzle = new ConfigOptionFloats(1, spin_nozzle->GetValue()); + config.set_key_value("nozzle_diameter", opt_nozzle); + auto *opt_filam = new ConfigOptionFloats(1, spin_filam->GetValue()); + config.set_key_value("filament_diameter", opt_filam); +} PageTemperatures::PageTemperatures(ConfigWizard *parent) : - ConfigWizardPage(parent, _(L("Bed and Extruder Temperature")), _(L("Temperatures"))) -{} + ConfigWizardPage(parent, _(L("Extruder and Bed Temperatures")), _(L("Temperatures"))), + spin_extr(new wxSpinCtrl(this, wxID_ANY)), + spin_bed(new wxSpinCtrl(this, wxID_ANY)) +{ + spin_extr->SetIncrement(5); + const auto &def_extr = print_config_def.options["temperature"]; + spin_extr->SetRange(def_extr.min, def_extr.max); + auto *default_extr = dynamic_cast(def_extr.default_value); + spin_extr->SetValue(default_extr != nullptr && default_extr->size() > 0 ? default_extr->get_at(0) : 200); + + spin_bed->SetIncrement(5); + const auto &def_bed = print_config_def.options["bed_temperature"]; + spin_bed->SetRange(def_bed.min, def_bed.max); + auto *default_bed = dynamic_cast(def_bed.default_value); + spin_bed->SetValue(default_bed != nullptr && default_bed->size() > 0 ? default_bed->get_at(0) : 0); + + append_text(_(L("Enter the temperature needed for extruding your filament."))); + append_text(_(L("A rule of thumb is 160 to 230 °C for PLA, and 215 to 250 °C for ABS."))); + + auto *sizer_extr = new wxFlexGridSizer(3, 5, 5); + auto *text_extr = new wxStaticText(this, wxID_ANY, _(L("Extrusion Temperature:"))); + auto *unit_extr = new wxStaticText(this, wxID_ANY, _(L("°C"))); + sizer_extr->AddGrowableCol(0, 1); + sizer_extr->Add(text_extr, 0, wxALIGN_CENTRE_VERTICAL); + sizer_extr->Add(spin_extr); + sizer_extr->Add(unit_extr, 0, wxALIGN_CENTRE_VERTICAL); + append(sizer_extr); + + append_spacer(VERTICAL_SPACING); + + append_text(_(L("Enter the bed temperature needed for getting your filament to stick to your heated bed."))); + append_text(_(L("A rule of thumb is 60 °C for PLA and 110 °C for ABS. Leave zero if you have no heated bed."))); + + auto *sizer_bed = new wxFlexGridSizer(3, 5, 5); + auto *text_bed = new wxStaticText(this, wxID_ANY, _(L("Bed Temperature:"))); + auto *unit_bed = new wxStaticText(this, wxID_ANY, _(L("°C"))); + sizer_bed->AddGrowableCol(0, 1); + sizer_bed->Add(text_bed, 0, wxALIGN_CENTRE_VERTICAL); + sizer_bed->Add(spin_bed); + sizer_bed->Add(unit_bed, 0, wxALIGN_CENTRE_VERTICAL); + append(sizer_bed); +} + +void PageTemperatures::apply_custom_config(DynamicPrintConfig &config) +{ + auto *opt_extr = new ConfigOptionInts(1, spin_extr->GetValue()); + config.set_key_value("temperature", opt_extr); + auto *opt_extr1st = new ConfigOptionInts(1, spin_extr->GetValue()); + config.set_key_value("first_layer_temperature", opt_extr1st); + auto *opt_bed = new ConfigOptionInts(1, spin_bed->GetValue()); + config.set_key_value("bed_temperature", opt_bed); + auto *opt_bed1st = new ConfigOptionInts(1, spin_bed->GetValue()); + config.set_key_value("first_layer_bed_temperature", opt_bed1st); +} // Index @@ -349,25 +474,12 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt) void ConfigWizard::priv::load_vendors() { const auto vendor_dir = fs::path(Slic3r::data_dir()) / "vendor"; - // const auto profiles_dir = fs::path(resources_dir()) / "profiles"; for (fs::directory_iterator it(vendor_dir); it != fs::directory_iterator(); ++it) { if (it->path().extension() == ".ini") { bundle_vendors.load_configbundle(it->path().native(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); } } - // XXX - // for (const auto &vendor : bundle_vendors.vendors) { - // std::cerr << "vendor: " << vendor.name << std::endl; - // std::cerr << " URL: " << vendor.config_update_url << std::endl; - // for (const auto &model : vendor.models) { - // std::cerr << "\tmodel: " << model.id << " (" << model.name << ")" << std::endl; - // for (const auto &variant : model.variants) { - // std::cerr << "\t\tvariant: " << variant.name << std::endl; - // } - // } - // } - appconfig_vendors.set_vendors(*GUI::get_app_config()); } @@ -426,21 +538,22 @@ void ConfigWizard::priv::on_custom_setup() set_page(page_firmware); } -void ConfigWizard::priv::on_finish() +void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *preset_bundle) { const bool is_custom_setup = page_welcome->page_next() == page_firmware; if (! is_custom_setup) { - AppConfig *app_config = GUI::get_app_config(); app_config->set_vendors(appconfig_vendors); - app_config->set("version_check", page_update->version_check ? "1" : "0"); app_config->set("preset_update", page_update->preset_update ? "1" : "0"); + app_config->reset_selections(); // XXX: only on "fresh start"? + preset_bundle->load_presets(*app_config); } else { - // TODO + for (ConfigWizardPage *page = page_firmware; page != nullptr; page = page->page_next()) { + page->apply_custom_config(custom_config); + } + preset_bundle->load_config("My Settings", custom_config); } - - q->EndModal(wxID_OK); } // Public @@ -450,6 +563,10 @@ ConfigWizard::ConfigWizard(wxWindow *parent) : p(new priv(this)) { p->load_vendors(); + std::unique_ptr custom_config_defaults(DynamicPrintConfig::new_from_defaults_keys({ + "gcode_flavor", "bed_shape", "nozzle_diameter", "filament_diameter", "temperature", "bed_temperature", + })); + p->custom_config.apply(*custom_config_defaults); p->index = new ConfigWizardIndex(this); @@ -461,10 +578,8 @@ ConfigWizard::ConfigWizard(wxWindow *parent) : p->topsizer->Add(p->index, 0, wxEXPAND); p->topsizer->AddSpacer(INDEX_MARGIN); - // TODO: btn labels vs default w/ icons ... use arrows from resources? (no apply icon) - // Also: http://docs.wxwidgets.org/3.0/page_stockitems.html - p->btn_prev = new wxButton(this, wxID_BACKWARD, _(L("< &Back"))); - p->btn_next = new wxButton(this, wxID_FORWARD, _(L("&Next >"))); + p->btn_prev = new wxButton(this, wxID_BACKWARD); + p->btn_next = new wxButton(this, wxID_FORWARD); p->btn_finish = new wxButton(this, wxID_APPLY, _(L("&Finish"))); p->btn_cancel = new wxButton(this, wxID_CANCEL); p->btnsizer->AddStretchSpacer(); @@ -498,7 +613,8 @@ ConfigWizard::ConfigWizard(wxWindow *parent) : p->btn_prev->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->go_prev(); }); p->btn_next->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->go_next(); }); - p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->on_finish(); }); + // p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->on_finish(); }); + p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->EndModal(wxID_OK); }); } ConfigWizard::~ConfigWizard() {} @@ -514,7 +630,7 @@ void ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) ConfigWizard wizard(parent); if (wizard.ShowModal() == wxID_OK) { - preset_bundle->load_presets(*GUI::get_app_config()); + wizard.p->apply_config(GUI::get_app_config(), preset_bundle); } } diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index ab291d40f8..1d9519bc3f 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -8,9 +8,13 @@ #include #include #include +#include +#include +#include "libslic3r/PrintConfig.hpp" #include "AppConfig.hpp" #include "PresetBundle.hpp" +#include "BedShapeDialog.hpp" namespace Slic3r { @@ -21,6 +25,8 @@ enum { DIALOG_MARGIN = 15, INDEX_MARGIN = 40, BTN_SPACING = 10, + INDENT_SPACING = 30, + VERTICAL_SPACING = 10, }; struct ConfigWizardPage: wxPanel @@ -41,17 +47,13 @@ struct ConfigWizardPage: wxPanel ConfigWizardPage* page_next() const { return p_next; } ConfigWizardPage* chain(ConfigWizardPage *page); - void append_text(wxString text); - void append_widget(wxWindow *widget, int proportion = 0, int flag = wxEXPAND|wxTOP|wxBOTTOM, int border = 10); - template - void append_thing(T *thing, int proportion = 0, int flag = wxEXPAND|wxTOP|wxBOTTOM, int border = 10) + void append(T *thing, int proportion = 0, int flag = wxEXPAND|wxTOP|wxBOTTOM, int border = 10) { content->Add(thing, proportion, flag, border); } - // TODO: remove: - void append_sizer(wxSizer *sizer, int proportion = 0); + void append_text(wxString text); void append_spacer(int space); ConfigWizard::priv *wizard_p() const { return parent->p.get(); } @@ -60,6 +62,7 @@ struct ConfigWizardPage: wxPanel virtual bool Hide() { return Show(false); } virtual wxPanel* extra_buttons() { return nullptr; } virtual void on_page_set() {} + virtual void apply_custom_config(DynamicPrintConfig &config) {} void enable_next(bool enable); private: @@ -84,10 +87,8 @@ struct PageUpdate: ConfigWizardPage { bool version_check; bool preset_update; - - PageUpdate(ConfigWizard *parent); - void presets_update_enable(bool enable); + PageUpdate(ConfigWizard *parent); }; struct PageVendors: ConfigWizardPage @@ -97,22 +98,37 @@ struct PageVendors: ConfigWizardPage struct PageFirmware: ConfigWizardPage { + const ConfigOptionDef &gcode_opt; + wxChoice *gcode_picker; + PageFirmware(ConfigWizard *parent); + virtual void apply_custom_config(DynamicPrintConfig &config); }; struct PageBedShape: ConfigWizardPage { + BedShapePanel *shape_panel; + PageBedShape(ConfigWizard *parent); + virtual void apply_custom_config(DynamicPrintConfig &config); }; struct PageDiameters: ConfigWizardPage { + wxSpinCtrlDouble *spin_nozzle; + wxSpinCtrlDouble *spin_filam; + PageDiameters(ConfigWizard *parent); + virtual void apply_custom_config(DynamicPrintConfig &config); }; struct PageTemperatures: ConfigWizardPage { + wxSpinCtrl *spin_extr; + wxSpinCtrl *spin_bed; + PageTemperatures(ConfigWizard *parent); + virtual void apply_custom_config(DynamicPrintConfig &config); }; @@ -133,7 +149,7 @@ private: std::vector items; std::vector::const_iterator item_active; - void on_paint(wxPaintEvent & evt); + void on_paint(wxPaintEvent &evt); }; struct ConfigWizard::priv @@ -141,6 +157,7 @@ struct ConfigWizard::priv ConfigWizard *q; AppConfig appconfig_vendors; PresetBundle bundle_vendors; + DynamicPrintConfig custom_config; wxBoxSizer *topsizer = nullptr; wxBoxSizer *btnsizer = nullptr; @@ -171,7 +188,8 @@ struct ConfigWizard::priv void on_other_vendors(); void on_custom_setup(); - void on_finish(); + + void apply_config(AppConfig *app_config, PresetBundle *preset_bundle); }; From d1c1dcbe8f380c12120228c7318f243633b27490 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 5 Apr 2018 18:30:03 +0200 Subject: [PATCH 0125/1150] ConfigWizard: Factor out a PrinterPicker widget, finalize other vendors page --- .../{MK2S.png => PrusaResearch_MK2S.png} | Bin .../{MK2SMM.png => PrusaResearch_MK2SMM.png} | Bin .../{MK3.png => PrusaResearch_MK3.png} | Bin xs/src/slic3r/GUI/ConfigWizard.cpp | 220 ++++++++++++------ xs/src/slic3r/GUI/ConfigWizard_private.hpp | 16 +- 5 files changed, 159 insertions(+), 77 deletions(-) rename resources/icons/printers/{MK2S.png => PrusaResearch_MK2S.png} (100%) rename resources/icons/printers/{MK2SMM.png => PrusaResearch_MK2SMM.png} (100%) rename resources/icons/printers/{MK3.png => PrusaResearch_MK3.png} (100%) diff --git a/resources/icons/printers/MK2S.png b/resources/icons/printers/PrusaResearch_MK2S.png similarity index 100% rename from resources/icons/printers/MK2S.png rename to resources/icons/printers/PrusaResearch_MK2S.png diff --git a/resources/icons/printers/MK2SMM.png b/resources/icons/printers/PrusaResearch_MK2SMM.png similarity index 100% rename from resources/icons/printers/MK2SMM.png rename to resources/icons/printers/PrusaResearch_MK2SMM.png diff --git a/resources/icons/printers/MK3.png b/resources/icons/printers/PrusaResearch_MK3.png similarity index 100% rename from resources/icons/printers/MK3.png rename to resources/icons/printers/PrusaResearch_MK3.png diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index edf958bd8f..914ebb9a19 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -23,6 +23,86 @@ namespace Slic3r { namespace GUI { +// FIXME: scrolling + + +// Printer model picker GUI control + +struct PrinterPickerEvent : public wxEvent +{ + std::string vendor_id; + std::string model_id; + std::string variant_name; + bool enable; + + PrinterPickerEvent(wxEventType eventType, int winid, std::string vendor_id, std::string model_id, std::string variant_name, bool enable) : + wxEvent(winid, eventType), + vendor_id(std::move(vendor_id)), + model_id(std::move(model_id)), + variant_name(std::move(variant_name)), + enable(enable) + {} + + virtual wxEvent *Clone() const + { + return new PrinterPickerEvent(*this); + } +}; + +wxDEFINE_EVENT(EVT_PRINTER_PICK, PrinterPickerEvent); + +PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, const AppConfig &appconfig_vendors) : + wxPanel(parent), + variants_checked(0) +{ + const auto vendor_id = vendor.id; + const auto &models = vendor.models; + + auto *printer_grid = new wxFlexGridSizer(models.size(), 0, 20); + printer_grid->SetFlexibleDirection(wxVERTICAL); + SetSizer(printer_grid); + + auto namefont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + namefont.SetWeight(wxFONTWEIGHT_BOLD); + + for (auto model = models.cbegin(); model != models.cend(); ++model) { + auto *panel = new wxPanel(this); + auto *sizer = new wxBoxSizer(wxVERTICAL); + panel->SetSizer(sizer); + + auto *title = new wxStaticText(panel, wxID_ANY, model->name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + title->SetFont(namefont); + sizer->Add(title, 0, wxBOTTOM, 3); + + auto bitmap_file = wxString::Format("printers/%s_%s.png", vendor.id, model->id); + wxBitmap bitmap(GUI::from_u8(Slic3r::var(bitmap_file.ToStdString())), wxBITMAP_TYPE_PNG); + auto *bitmap_widget = new wxStaticBitmap(panel, wxID_ANY, bitmap); + sizer->Add(bitmap_widget, 0, wxBOTTOM, 3); + + sizer->AddSpacer(20); + + const auto model_id = model->id; + + for (const auto &variant : model->variants) { + const auto variant_name = variant.name; + auto *cbox = new wxCheckBox(panel, wxID_ANY, wxString::Format("%s %s %s", variant.name, _(L("mm")), _(L("nozzle")))); + bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant_name); + variants_checked += enabled; + cbox->SetValue(enabled); + sizer->Add(cbox, 0, wxBOTTOM, 3); + cbox->Bind(wxEVT_CHECKBOX, [=](wxCommandEvent &event) { + this->variants_checked += event.IsChecked() ? 1 : -1; + PrinterPickerEvent evt(EVT_PRINTER_PICK, this->GetId(), std::move(vendor_id), std::move(model_id), std::move(variant_name), event.IsChecked()); + this->AddPendingEvent(evt); + }); + } + + printer_grid->Add(panel); + } + +} + + // Wizard page base ConfigWizardPage::ConfigWizardPage(ConfigWizard *parent, wxString title, wxString shortname) : @@ -95,8 +175,8 @@ void ConfigWizardPage::enable_next(bool enable) { parent->p->enable_next(enable) PageWelcome::PageWelcome(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Welcome to the Slic3r Configuration assistant")), _(L("Welcome"))), - others_buttons(new wxPanel(parent)), - variants_checked(0) + printer_picker(nullptr), + others_buttons(new wxPanel(parent)) { append_text(_(L("Hello, welcome to Slic3r Prusa Edition! TODO: This text."))); @@ -104,73 +184,34 @@ PageWelcome::PageWelcome(ConfigWizard *parent) : const auto &vendors = bundle.vendors; const auto vendor_prusa = std::find(vendors.cbegin(), vendors.cend(), VendorProfile("PrusaResearch")); - const AppConfig &appconfig_vendors = wizard_p()->appconfig_vendors; - if (vendor_prusa != vendors.cend()) { const auto &models = vendor_prusa->models; - auto *printer_picker = new wxPanel(this); - auto *printer_grid = new wxFlexGridSizer(models.size(), 0, 20); - printer_grid->SetFlexibleDirection(wxVERTICAL); - printer_picker->SetSizer(printer_grid); + AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors; - auto namefont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - namefont.SetWeight(wxFONTWEIGHT_BOLD); - - for (auto model = models.cbegin(); model != models.cend(); ++model) { - auto *panel = new wxPanel(printer_picker); - auto *sizer = new wxBoxSizer(wxVERTICAL); - panel->SetSizer(sizer); - - auto *title = new wxStaticText(panel, wxID_ANY, model->name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); - title->SetFont(namefont); - sizer->Add(title, 0, wxBOTTOM, 3); - - auto bitmap_file = wxString::Format("printers/%s.png", model->id); - wxBitmap bitmap(GUI::from_u8(Slic3r::var(bitmap_file.ToStdString())), wxBITMAP_TYPE_PNG); - auto *bitmap_widget = new wxStaticBitmap(panel, wxID_ANY, bitmap); - sizer->Add(bitmap_widget, 0, wxBOTTOM, 3); - - sizer->AddSpacer(20); - - std::string model_id = model->id; - - for (const auto &variant : model->variants) { - std::string variant_name = variant.name; - auto *cbox = new wxCheckBox(panel, wxID_ANY, wxString::Format("%s %s %s", variant.name, _(L("mm")), _(L("nozzle")))); - bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant_name); - variants_checked += enabled; - cbox->SetValue(enabled); - sizer->Add(cbox, 0, wxBOTTOM, 3); - cbox->Bind(wxEVT_CHECKBOX, [=](wxCommandEvent &event) { - this->variants_checked += event.IsChecked() ? 1 : -1; - this->on_variant_checked(); - AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors; - appconfig_vendors.set_variant("PrusaResearch", model_id, variant_name, event.IsChecked()); - }); - } - - printer_grid->Add(panel); - } + printer_picker = new PrinterPicker(this, *vendor_prusa, appconfig_vendors); + printer_picker->Bind(EVT_PRINTER_PICK, [this, &appconfig_vendors](const PrinterPickerEvent &evt) { + appconfig_vendors.set_variant(evt.vendor_id, evt.model_id, evt.variant_name, evt.enable); + this->on_variant_checked(); + }); append(printer_picker); } - { - auto *sizer = new wxBoxSizer(wxHORIZONTAL); - auto *other_vendors = new wxButton(others_buttons, wxID_ANY, _(L("Other vendors"))); - // other_vendors->Disable(); // XXX - auto *custom_setup = new wxButton(others_buttons, wxID_ANY, _(L("Custom setup"))); + const size_t num_other_vendors = vendors.size() - (vendor_prusa != vendors.cend()); + auto *sizer = new wxBoxSizer(wxHORIZONTAL); + auto *other_vendors = new wxButton(others_buttons, wxID_ANY, _(L("Other vendors"))); + other_vendors->Enable(num_other_vendors > 0); + auto *custom_setup = new wxButton(others_buttons, wxID_ANY, _(L("Custom setup"))); - sizer->Add(other_vendors); - sizer->AddSpacer(BTN_SPACING); - sizer->Add(custom_setup); + sizer->Add(other_vendors); + sizer->AddSpacer(BTN_SPACING); + sizer->Add(custom_setup); - other_vendors->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->wizard_p()->on_other_vendors(); }); - custom_setup->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->wizard_p()->on_custom_setup(); }); + other_vendors->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->wizard_p()->on_other_vendors(); }); + custom_setup->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->wizard_p()->on_custom_setup(); }); - others_buttons->SetSizer(sizer); - } + others_buttons->SetSizer(sizer); } void PageWelcome::on_page_set() @@ -181,7 +222,7 @@ void PageWelcome::on_page_set() void PageWelcome::on_variant_checked() { - enable_next(variants_checked > 0); + enable_next(printer_picker != nullptr ? printer_picker->variants_checked > 0 : false); } PageUpdate::PageUpdate(ConfigWizard *parent) : @@ -208,35 +249,63 @@ PageUpdate::PageUpdate(ConfigWizard *parent) : PageVendors::PageVendors(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Other Vendors")), _(L("Other Vendors"))) { + append_text(_(L("Pick another vendor supported by Slic3r PE:"))); + const PresetBundle &bundle = wizard_p()->bundle_vendors; auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); boldfont.SetWeight(wxFONTWEIGHT_BOLD); + AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors; + wxArrayString choices_vendors; + for (const auto &vendor : bundle.vendors) { if (vendor.id == "PrusaResearch") { continue; } - auto *label_vendor = new wxStaticText(this, wxID_ANY, vendor.name); - label_vendor->SetFont(boldfont); - append(label_vendor, 0, 0, 0); + auto *picker = new PrinterPicker(this, vendor, appconfig_vendors); + picker->Hide(); + pickers.push_back(picker); + choices_vendors.Add(vendor.name); - for (const auto &model : vendor.models) { - auto *label_model = new wxStaticText(this, wxID_ANY, model.name); - label_model->SetFont(boldfont); - append(label_model, 0, wxLEFT, INDENT_SPACING); + picker->Bind(EVT_PRINTER_PICK, [this, &appconfig_vendors](const PrinterPickerEvent &evt) { + appconfig_vendors.set_variant(evt.vendor_id, evt.model_id, evt.variant_name, evt.enable); + this->on_variant_checked(); + }); + } - for (const auto &variant : model.variants) { - auto *cbox = new wxCheckBox(this, wxID_ANY, variant.name); - append(cbox, 0, wxEXPAND | wxLEFT, 2 * INDENT_SPACING); - cbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { - // TODO - }); - } - } + auto *vendor_picker = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices_vendors); + if (choices_vendors.GetCount() > 0) { + vendor_picker->SetSelection(0); + on_vendor_pick(0); + } - append_spacer(VERTICAL_SPACING); + vendor_picker->Bind(wxEVT_CHOICE, [this](wxCommandEvent &evt) { + this->on_vendor_pick(evt.GetInt()); + }); + + append(vendor_picker); + for (PrinterPicker *picker : pickers) { this->append(picker); } +} + +void PageVendors::on_page_set() +{ + on_variant_checked(); +} + +void PageVendors::on_vendor_pick(size_t i) +{ + for (PrinterPicker *picker : pickers) { picker->Hide(); } + if (i < pickers.size()) { + pickers[i]->Show(); + Layout(); } } +void PageVendors::on_variant_checked() +{ + size_t variants_checked = 0; + for (const PrinterPicker *picker : pickers) { variants_checked += picker->variants_checked; } + enable_next(variants_checked > 0); +} PageFirmware::PageFirmware(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Firmware Type")), _(L("Firmware"))), @@ -613,7 +682,6 @@ ConfigWizard::ConfigWizard(wxWindow *parent) : p->btn_prev->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->go_prev(); }); p->btn_next->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->go_next(); }); - // p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->p->on_finish(); }); p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &evt) { this->EndModal(wxID_OK); }); } diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index 1d9519bc3f..9f9395975b 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -29,6 +29,13 @@ enum { VERTICAL_SPACING = 10, }; +struct PrinterPicker: wxPanel +{ + unsigned variants_checked; + + PrinterPicker(wxWindow *parent, const VendorProfile &vendor, const AppConfig &appconfig_vendors); +}; + struct ConfigWizardPage: wxPanel { enum { @@ -72,8 +79,8 @@ private: struct PageWelcome: ConfigWizardPage { + PrinterPicker *printer_picker; wxPanel *others_buttons; - unsigned variants_checked; PageWelcome(ConfigWizard *parent); @@ -93,7 +100,14 @@ struct PageUpdate: ConfigWizardPage struct PageVendors: ConfigWizardPage { + std::vector pickers; + PageVendors(ConfigWizard *parent); + + virtual void on_page_set(); + + void on_vendor_pick(size_t i); + void on_variant_checked(); }; struct PageFirmware: ConfigWizardPage From 9dcec6662e788a8ae0f04043581a1a3c44d36006 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 6 Apr 2018 12:15:28 +0200 Subject: [PATCH 0126/1150] ConfigWizard: Other vendor sample data, minor fixes --- resources/icons/printers/BarBaz_M1.png | Bin 0 -> 10369 bytes resources/icons/printers/BarBaz_M2.png | Bin 0 -> 10369 bytes resources/icons/printers/BarBaz_M3.png | Bin 0 -> 10369 bytes resources/icons/printers/Foobar_M1.png | Bin 0 -> 9323 bytes resources/icons/printers/Foobar_M2.png | Bin 0 -> 9323 bytes resources/icons/printers/Foobar_M3.png | Bin 0 -> 9323 bytes resources/profiles/BarBaz.ini | 985 +++++++++++++++++++++ resources/profiles/Foobar.ini | 985 +++++++++++++++++++++ xs/src/slic3r/GUI/AppConfig.cpp | 2 - xs/src/slic3r/GUI/AppConfig.hpp | 10 +- xs/src/slic3r/GUI/ConfigWizard.cpp | 21 +- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 9 +- xs/xsp/my.map | 3 - 13 files changed, 1990 insertions(+), 25 deletions(-) create mode 100644 resources/icons/printers/BarBaz_M1.png create mode 100644 resources/icons/printers/BarBaz_M2.png create mode 100644 resources/icons/printers/BarBaz_M3.png create mode 100644 resources/icons/printers/Foobar_M1.png create mode 100644 resources/icons/printers/Foobar_M2.png create mode 100644 resources/icons/printers/Foobar_M3.png create mode 100644 resources/profiles/BarBaz.ini create mode 100644 resources/profiles/Foobar.ini diff --git a/resources/icons/printers/BarBaz_M1.png b/resources/icons/printers/BarBaz_M1.png new file mode 100644 index 0000000000000000000000000000000000000000..5924cc88b9ac373d5dc802ac06b82d1ad9d5015c GIT binary patch literal 10369 zcmZ{K1yEH{*Y>61(hVXYEz*rBpmcY4my~o#NeB|s-Iwl=j*FC(v`CkPG}8TTzxikW zciw;gJ9F=uxo4kUYwfk3=UFF0MM)YP`UDDrK(J+HB-FsQ;olb>75oa1qH==^hO>;W zD+FR7{O^m<(n{qI{v>mg)N#|Wad$8i5|VH-cXzOKbQ2O%F}1dIg>V%=wsC+qA|5@rWRa%g1 zX|oH?e|;=&|EgsaJAWbkYhyucqBFTP#qR6Z;$PK=Iv(f`cU%4NCKjfe(jA|e=;olL^n)#dQ87Iu zE$yYx{;yiD!NEbT&waESn#7U$&qCgy2PG01&Q7=+-rV~yIyQARH~&)C(a~vi-TuMx zv&!&xB3sy(A5pXWi3PNEo0BRPDuGmuB#LN+Xh&x=)%R&=Xed21A;ER5Lbu*AOYps! znw(suU9Clxf`x{m65;0~`rX z9mtFIwpenq1V@F3ho|2Es)zdFWFuCT{gvxhRMlQ97DIG&bX{(4?#cCbj`$<1_=flljpQWXxUPmNJHBG(oV z$7?;s6Bw!)Wk+dP13QJ6Xg>MFp@_dYJBe^|aEtLI^jS+BV%0TYr%Ta|s~E>JF`_z* zQTZLUfBbpTjDUn1b$965)nNSaF|>x|I}?Aw!a|LQ(aWLllXbLH{vd4Vb;k4wWP~r= zHK9I_i7Acq%UucoFRePC7x>aUc*#4)5K%Rl=&4 z@ud$No5#H3^f9TtE^=K9ujXBu<`1Y096cZ@o4Ii~p?<6lnVz1;>#D0-yS&|uBxZR* z_2F#7TRP^cu5#O~CA1Z7%_Z-bJv~1kmn8ZjNiZ|~&5uWhBr@7_8QCm64Fm?bNUi~T zjI3;0(ORS4$*zz{7j@2({{v$5?B_nazWhBMVwCbk33=K4fu7^Y$id6U-%QomV-y!ydHcF!}ql!RqM6c-|4(nLx=*(B|u1}9B1f5M}`dBlN;sbv^D^xju z;LlK8^gA6T?7G=4Ul6(3DJV37w(8p+CIz71LCouzI2parf(qen?4%3^y^l|&romxb z<^ypHi`g=TL>ZQ7lP=}${ZcxXYV+!3qcS*IEj~5%`zL%l8AU|~A)(gcbt*o)M02nV z&w#TD=_3Sdg}0uB?4;sB+d&IlBtrBmEDY7QPXg+6p5x5)va6Vxnca+m=(PNWM!dDb zD}PT29C;9iP-&3K$;tgTC{~`)&>%>v+Su6SR#Zf-ubY8*Chy_F5A5A%Rgbb%wB%?F zMw_*=v{YQ^@V%5%A77JhHZVYIheq}7B)OZU;IX>2d@sE9{eAlV#}6t2*R2t*$jLb0 zHrJijA3rPgnORva4i{Tsg@uOWw?bJ;s90q1U$y4%+ms87}G~BaXS=p9(A~!PU7M1=e)9l3dK(1>f!HT`b>gRWTo4YT4 zQP6OyGCj^`v}4gdnpO4nf%%EZXXi0u22%%)E!>i@d7w)XA9vk((t zAR;27RgbohtzlDtG|;ffzBt6>iAN1fk{r`YJ&QxedH3W}_?(D>?w#%c3 zqf1Z&pKoV>rrP%XU4^oMiB$FUhQ7zqA&D4kYOc8nRdf07;H|shB4hfN zr6R0vY$O1`njWV1rqR^Y)L|vr_wbdmC+D@n>+9=#oAs_%M@Ckb+zcut(SAj%3U}iC zCXAxOhWyy##g!xRvrc})Sume9dDXupmhx3UaLk>^wrVzJW@Zg-?I!kKWU$>KA;{s( zJ9w)udDGL!l&g;EDYc=iy3D%drc>;nN3C2->{KXuL57!*lnk|JURdL7R6%923GXrG z8yKf~Gxc4Kh~&K^%JD(JRI>2p)9&lMR{YUl=TD|vw91JUF%3sFK2vu4zjZTAvBF)F zr1B2&FB?)0HIXyh@r~J)nV-@16ERk=$ybni}3d9rfp)?-r3y^K5QGETiv`8}e9iVo! zv&rhkN^2)xGD=D~yMBsO7Ut&Wam+i<-nYo09d>_WzC@^QHQ0}-&@%RxfX_uQp=S_}-Cpx8kw9c;N?(OQG-isJyk4I$*HF1W>JQt+5OFVVp0-{U+38NMuM^k4G&MkzuoH}QVC1~}&UPjL=7@Nr7s z!mz|lVc+C2ky|WD)l?yOyKzijk(}84{Cu;VF>U*sJS1tsry~ebW@kU7-Ljgp{pzHd z7`y0!9j@AIYL1xzuu;U=x=UVSRw_>5=)4NPzrEyf-_^)eVk#@kp55DRjTzX;Yi>@Z zeC6>aEo~4co6y=YucND5>afyzuMT&B3cWG%3fj5xIdnQDuUzcP`H0V3It&owhBLqp zjW1od7D;4YyXuGF!HSBw10MW54(9uYl2~l*>}Z9BvmWkm&1-c^s;jp_1oY}Knw*+y zxxZMDl|dI8uTHwVyDI}r+b84{7(|U)7`@txl0qy&UOsThj>aj`2k3CJy}do7y6eHm zS39|mjRbRUZqCBmdc&jb<@jCQPF_1v%BH; zl(MMs&5XA3eGq@k0Z3}`XjE|M;^!jSaU4=hIhvl5e&t+X}2>T9wU{vOX0@BBB3n<19!yDI?KUvap% zgAH@uh+ae=L8}mRE~$+p6>y|)K5keJZ)$G#It8F1=H=6v6L4mtJq4edR%`#tOxAV; z7QVkb9pm_Le?Cj9sij5Lx#(S#`|7O{&MC~I5f6Q}-a31&Qf6U#^!w!Gf!qwlr)3_*Mvy1tJ6CZMudafttEp6E%1Z@*2erPyPug-w0Ev05;yy9VE+71G) z=)IoGWgf4tuAcO!{`sF)C3kl|ki6Zhb?dE;w2eQUFN4FoBI0vqgOTz)$d60mtubo& z$Glc0wbLaY_yl_Tl=>Ht46Vz{${uRp%~tV&l@H4(D|fwQVR>g~WwrGW$#<8QmeSMH zn|#%))nP@a8Ry0BT2VGMqy&b~6mlQ>aCdcb;O*_*rkp8w5(~mX@XgH)4>HYfl7FLh z<-8*bO?E79=NK5E{;aWiyU>d1c%O)vV2`Zpyx zxz6p+wa`@TUbc=neOCsJKn`JDI`GmAfJ*iP=yD3|^m(<$8c66wrg%A2{>F4zp+S@CN!lCx_a=1f>^ zjz6UgRYZeg5%sf>zg{yP{^P}2wY?= zfdn?Ab=*!=k@;ViU5wF{E`shTK2TxShzJSY#LJ4p5&?>=F0zdk8>`$QfT#&h=DOJYFzew~QDnP5U8>$UGc)r@sy>asDHpX#mi^^RjSb+{o}0ga>u_9H zI@$^Kh(5f3<#@@QpHEN$$a~6B-#}~;T}SJZBbD!d?R~j+wbqj3C536@%5MTUy>T&g z%lQV|G+f~`m1-jcomRI$=XBCBce9C!MDliayOOcx<*x*2YxN3b6e%Ud#0CatXJ+EE zvV>oNja_pJxLrW|X6os*M%s1NS2IjaEF#2aBdKcNwCFOd9uX1IG4Fmp>g2CpSyECX z%goU-tUi0c(@J9_S)2bn#lPI1KjR;g%t%d5r4V}OOR6U4*!qX@ovp2HuRXfOcbca- z(i(1VZoi`b-~bZ{`L)AfAy-#kKnjvoQgURn!HhKP-Z*jI8X?awD41~nmw$6SvB5Dd zo+5We`5~+KUhpY?Rsst5?`O=+5oc#-!_vhcX$dnkT0rm$o4rJD zFG?+}d-|h2tj4kf%gR9TMCn=?TkZas#%&4B`EWsw6OKfKyt%mR$%9idgwh+=F1Cm!#CI@(~e^<^wk9qQ>q^xW{ zGbg9328p8T+m0aZy^-6%s4_&>^xIowL!DYg^$e#4F2pYo9LNm(VRzR~af)}}Se`IT_5+$Xkl9`#C>kouaOiTdDa^0iN*4`fAGtFzi&SZ&T zajyI;WGNdv2C0&=mQa?FvqN&D0eXllg1|AVO4x*J6sn%KRFOiOn7uu#V-tm>s$S@> zvtaXPvc8HYaZdG@eS2Iq+$}Dv5wiYhirM*3c!-j!g6_LSQ^m?oN8d6+@UMQO{Y22` zs(Xy>Rp=tox=GJPLwLm6NB+x6y8{gphRe>kF9QM!a`Y7tsZP9JZ##5c`g9Nx*)y?M z#Xa12ABpyW;}Ynqf5xY{0knurkq_yr1yU32C|ZR5)o<~gkqg2f29OWgohknFT@L#-MPjR=^8NEtgu| zv7YdvD^8VERrMcuoPMW^{Sp_~{daSiV-|*M6Y>*XB!P2$7P*7k{1X>xfi^pW8YePu z$@NS4j;*Gq<=VGU0Hck3{xEQJb33;!jbsSm8ak~y1@JKLA)#Vzr&({Q0*VWivw!*t zJ9|uqV=D%T!{R+C`q)`ya}ODu5(b}Df2^a|VDr#&*q`yeMVf{jAx;Ip;tZosg1=wY zxcvx#Hp%DEocn!ibQ(RTaFLvtQId~%c*HZ*y0A#N6Cy#Y%qJhxLekavd|a z;;U#b#E8-hOCqiBrf&!lAD2^7QrZtj!JG!Dwccq(FU|B?X*%?&m!tPXD-d{^miKmqb66X&zh_i@J?JD>Fd|8 zl#(=Zt2*e$>Yk=;N1eB3TVpvK+&nyUO-|HC)w7;^l}*{v4W=n{zk`+JfH)l)sb}_8 zZ%R|M@cQS@xew{2xJ%E>?Cg=>!}T_`ZJT-D(WSno=KUogp)o*xL8RAu_cGFK?K1~| z?%u07wK~tE<)Uxjz7+y^QTcwXwMt!0ZIU8%fd<5I0h{!#I=xB{PNSS9#}%N>RtvYA zbO%#ux7D!GkT#5M*CTBN#<7VGs}1=`s+x%{X^{%L?EolyKphnkF(>T4J1t-h*rJLm za14M4GfQbLlX*W~G z03w}HIUmC3K3VmISj}>+gQ2l8Zx>_TyKxzQ{}EoT}v3LzDB}nPLGD zoSGL74)I+f37@C5mplv$fl|MEa&={XULZB2Xw-DrdsJ7?!fy~D9F*i`C;j;FJ)G*> z=aw1*egLRKBtNIig+3omiT|^5t#og|oVGBN1+v&xwpXyI=sD4zxOt(hFJKn%c!po) zWmlz%cTb%m1>#@JWi-jxTu!RlNtwi4B@-G`&3AB0%GOr`2e^8l+Eq=tANF9WKrxGQ z7uH-RsGD)=aOj@u5QQGK8bskvombm{vA?57**~mV2p%^XKg6T3r@Y+9WB~2+_OJ>J zZ6lSk!&h*#G6l=vd}?(P=nojKSNPltZ=1w5WoZHj>k`9KJB)sHiRKm|5<7n+ zY|g9SmXPdje$QzY^?v0KuOmV(X7>U|y9vn|7V#GB_$guFBRw1?DVZj06tzGaZ8{tI zf{*W{3eT!Wt%MT=yV*cOe$Xk@hHZm{GsuEGnSdzt$!eT+4&O$(c*M)!5Vx$oP!pl0 zdiYvww4$(x;ps9)L>MiP+_&d*35%U3UfT6Dm8OvN|@dGvI$f-D<4r6 zFWHUSe?7GeA#?qX&}@(>dJMrWggK|+wTsyxCD7M6{HoE9v9K7aot{m(vxNuNCa|m5 zf2Wrjp=wPlls}Oj#K>juO<_mNPUT#a&Y`Eb@RE+cDK;{ctSB}IJ5)BL#jH#EP5vfO z6u}rhFT>D90I1er;}peewB*F%6(r>%HIf7jtG-)(?TY6FUT%zuAD`6rLUJuY^aPod zzM%!Z6y9ZG!N!L{;Hu_D!$sz<+bZ`l-yrp%0co9!#2wWXwtUa%Oy+9srIIRq7Wxzo zO4PSSEG856IwlKy(do11lu**esu9-XrJxCi30gd&<0vv12!Wk6JU+q63&4jQ5(9V5 z3kvw7ybPIo6guhU3wAsip*b6x=0i2KC~_VtM5ER0t?+iTo~)tI*%mIc!0Cw! zc#PV~N}qcW5Dt)-(W@M>0=Mk480-tD9AydRK&(dS>M61HN>`fx#Px?veLPDHk21>u z2?1^0Sl!5fE|3Yg|AK`hEL9Z!+nWTde_}>S$(0l{(vSXtq`t}PE4wHfMe{(1)P`=r z=4*AH`ZK?DzNQ( z4#8SM0pGsAhM87WDehMFyJx9I)jB?d>9ZdJ)(pHe>&Q& zD6g`3dC)Wu?&r0IFEiS(gcX}=pMJm%D`(jc{^@R5@?zuJDr_6E`D<-$yD`}ax2?1j zp&M-&M{}V~EM>u#?5{oQTAb%j}QC|3a`hl$` z3_kD`A#YFdsmR^jJ^a@*j=b!b^-eKG*FFokOM5#GPR{Z)UY!0z<$-K#_Qxq*ZV?}D zm$iq6Jg`Y=y<+9Oz1IR;TQ`bs*+rLR?Sl|3gPj?V*sq?L)Nb6U|~K`J81PZEhO z_HZ^dbWnbQzqHNiyMyy7HvHyBz47ngCC`w*tzuuyn$V0W;jq(GVK+2@oi!6voHQ2? zUD^`g7Jly_Q&Q|XlMcsMAE&G_A2_<%YZXPYc;1JFS6GJiY{apjh1~V~1VZ{&8gn5( z@APaE0mT=B-M#e89*{do*n4qC7_qvH#B$M1WAb_;n0Gwr87Fbc$om-;IHbwAP?k`c z@!?DG63#}h?|TkvJ?{4`Su&VHlLt8iV*yIgn!smJCl3h8|OD8N+9g~1g^;3jH9tAb=8jXURByk~*`z*UvMCsOZX zpZX~zmknMCw~HDdqmK$c!IxGgQ%qeUWX4z9omjKqkSl6KVGDGENOQTU>|pI{YC|BX zPyW3N08fE?J0*Uef-fFsuN zgb|iVqBs>&WDBZ~cmC#W#z4fA*N-MMh9%#==+B0K>JxZ<^ZdOQOV_~niKiYRDr3;R zi|Jm}vZ_52!`YK-zsj7vL^Z&dyCb>i_iCxqtDt%&=yjnO1ya#^CC}ylf|Arr|2siG zK0X=dgWHRPTOiymQro?I=Lyjkf9FIN8t1@c7NjQjrP6kB-e7{yz?fB14mJ^X5LJ{1 z>J>lbQir~yfVWG&c>>6JDC~Pt!6qP(0$xH;RagHwyGIF%J;uVA?SUts=Yyqi3A|Dy zh=_^#80hFWsEVhUA+M>%j`#QXbwRm9mPgOM}PPO(EAaWnaxGCat62M z5Lw&O^4~N9Vq!_ai+90PIshTVtd#TQdiSMLE!DXp%y?)`+{t%Rj0_NhgdA6-pd zUAMsoUku&NaQh>!$iFIC9RDz~`uN*|=l!u6c)>vROG^bgNmDs@IG9AtU?Kt3vm&B9 zxO*~u*SD7$-h!$MZ>4U15zrMR5WvzrGDb-j;*9lX-RHpj15RJ{DE@erHf(pi(tc)C zEztkRO)3IsdVYEuCeQp%L-QQTexVT?KD)$k6v>Wp1E$y#D}3?GARS3--{ZF8`gHrz z55QRrQ1dA(1C?1ZbX}ki9RnrvuCt-xjQS19HgbhYuT+Wwj6C5`yr{5H*bfNxkMDqK z6U)lPR1=fO#=A^=!Xg(J7pdQ+|Malr93L_w^j)yr8r!IeXp@)WvX6WfAQ~w<5>>&6kt>Nma{Cn$&>{0|5xgcYQezXT=>;MT)LV z9t#dJXJ>9PPhX0ut4~#d5=3Zv5itZiuJP0?#79kM(^(KoNJy9whD)sk`UiRebD;`5CUEdh8=BeTAE6aXLEWLAAv-p?XoQcME`%yyF72Q)4NNSqoJ-e^0;*l0gD8Q;)LQ|M>4J6$UL;vh+OK!#bf zX~E(CxCeKEF}r0e{aw{HMT+b#Ltz6J1%E{bYsVKQjCseV)76i-P{k?xw~cf=Zwr|e zg2guPUWbwPnbk_z_c#|LvxV3Us#=>(7H~0zGJb%nkN>|vg-nc?Tz_su61(hVXYEz*rBpmcY4my~o#NeB|s-Iwl=j*FC(v`CkPG}8TTzxikW zciw;gJ9F=uxo4kUYwfk3=UFF0MM)YP`UDDrK(J+HB-FsQ;olb>75oa1qH==^hO>;W zD+FR7{O^m<(n{qI{v>mg)N#|Wad$8i5|VH-cXzOKbQ2O%F}1dIg>V%=wsC+qA|5@rWRa%g1 zX|oH?e|;=&|EgsaJAWbkYhyucqBFTP#qR6Z;$PK=Iv(f`cU%4NCKjfe(jA|e=;olL^n)#dQ87Iu zE$yYx{;yiD!NEbT&waESn#7U$&qCgy2PG01&Q7=+-rV~yIyQARH~&)C(a~vi-TuMx zv&!&xB3sy(A5pXWi3PNEo0BRPDuGmuB#LN+Xh&x=)%R&=Xed21A;ER5Lbu*AOYps! znw(suU9Clxf`x{m65;0~`rX z9mtFIwpenq1V@F3ho|2Es)zdFWFuCT{gvxhRMlQ97DIG&bX{(4?#cCbj`$<1_=flljpQWXxUPmNJHBG(oV z$7?;s6Bw!)Wk+dP13QJ6Xg>MFp@_dYJBe^|aEtLI^jS+BV%0TYr%Ta|s~E>JF`_z* zQTZLUfBbpTjDUn1b$965)nNSaF|>x|I}?Aw!a|LQ(aWLllXbLH{vd4Vb;k4wWP~r= zHK9I_i7Acq%UucoFRePC7x>aUc*#4)5K%Rl=&4 z@ud$No5#H3^f9TtE^=K9ujXBu<`1Y096cZ@o4Ii~p?<6lnVz1;>#D0-yS&|uBxZR* z_2F#7TRP^cu5#O~CA1Z7%_Z-bJv~1kmn8ZjNiZ|~&5uWhBr@7_8QCm64Fm?bNUi~T zjI3;0(ORS4$*zz{7j@2({{v$5?B_nazWhBMVwCbk33=K4fu7^Y$id6U-%QomV-y!ydHcF!}ql!RqM6c-|4(nLx=*(B|u1}9B1f5M}`dBlN;sbv^D^xju z;LlK8^gA6T?7G=4Ul6(3DJV37w(8p+CIz71LCouzI2parf(qen?4%3^y^l|&romxb z<^ypHi`g=TL>ZQ7lP=}${ZcxXYV+!3qcS*IEj~5%`zL%l8AU|~A)(gcbt*o)M02nV z&w#TD=_3Sdg}0uB?4;sB+d&IlBtrBmEDY7QPXg+6p5x5)va6Vxnca+m=(PNWM!dDb zD}PT29C;9iP-&3K$;tgTC{~`)&>%>v+Su6SR#Zf-ubY8*Chy_F5A5A%Rgbb%wB%?F zMw_*=v{YQ^@V%5%A77JhHZVYIheq}7B)OZU;IX>2d@sE9{eAlV#}6t2*R2t*$jLb0 zHrJijA3rPgnORva4i{Tsg@uOWw?bJ;s90q1U$y4%+ms87}G~BaXS=p9(A~!PU7M1=e)9l3dK(1>f!HT`b>gRWTo4YT4 zQP6OyGCj^`v}4gdnpO4nf%%EZXXi0u22%%)E!>i@d7w)XA9vk((t zAR;27RgbohtzlDtG|;ffzBt6>iAN1fk{r`YJ&QxedH3W}_?(D>?w#%c3 zqf1Z&pKoV>rrP%XU4^oMiB$FUhQ7zqA&D4kYOc8nRdf07;H|shB4hfN zr6R0vY$O1`njWV1rqR^Y)L|vr_wbdmC+D@n>+9=#oAs_%M@Ckb+zcut(SAj%3U}iC zCXAxOhWyy##g!xRvrc})Sume9dDXupmhx3UaLk>^wrVzJW@Zg-?I!kKWU$>KA;{s( zJ9w)udDGL!l&g;EDYc=iy3D%drc>;nN3C2->{KXuL57!*lnk|JURdL7R6%923GXrG z8yKf~Gxc4Kh~&K^%JD(JRI>2p)9&lMR{YUl=TD|vw91JUF%3sFK2vu4zjZTAvBF)F zr1B2&FB?)0HIXyh@r~J)nV-@16ERk=$ybni}3d9rfp)?-r3y^K5QGETiv`8}e9iVo! zv&rhkN^2)xGD=D~yMBsO7Ut&Wam+i<-nYo09d>_WzC@^QHQ0}-&@%RxfX_uQp=S_}-Cpx8kw9c;N?(OQG-isJyk4I$*HF1W>JQt+5OFVVp0-{U+38NMuM^k4G&MkzuoH}QVC1~}&UPjL=7@Nr7s z!mz|lVc+C2ky|WD)l?yOyKzijk(}84{Cu;VF>U*sJS1tsry~ebW@kU7-Ljgp{pzHd z7`y0!9j@AIYL1xzuu;U=x=UVSRw_>5=)4NPzrEyf-_^)eVk#@kp55DRjTzX;Yi>@Z zeC6>aEo~4co6y=YucND5>afyzuMT&B3cWG%3fj5xIdnQDuUzcP`H0V3It&owhBLqp zjW1od7D;4YyXuGF!HSBw10MW54(9uYl2~l*>}Z9BvmWkm&1-c^s;jp_1oY}Knw*+y zxxZMDl|dI8uTHwVyDI}r+b84{7(|U)7`@txl0qy&UOsThj>aj`2k3CJy}do7y6eHm zS39|mjRbRUZqCBmdc&jb<@jCQPF_1v%BH; zl(MMs&5XA3eGq@k0Z3}`XjE|M;^!jSaU4=hIhvl5e&t+X}2>T9wU{vOX0@BBB3n<19!yDI?KUvap% zgAH@uh+ae=L8}mRE~$+p6>y|)K5keJZ)$G#It8F1=H=6v6L4mtJq4edR%`#tOxAV; z7QVkb9pm_Le?Cj9sij5Lx#(S#`|7O{&MC~I5f6Q}-a31&Qf6U#^!w!Gf!qwlr)3_*Mvy1tJ6CZMudafttEp6E%1Z@*2erPyPug-w0Ev05;yy9VE+71G) z=)IoGWgf4tuAcO!{`sF)C3kl|ki6Zhb?dE;w2eQUFN4FoBI0vqgOTz)$d60mtubo& z$Glc0wbLaY_yl_Tl=>Ht46Vz{${uRp%~tV&l@H4(D|fwQVR>g~WwrGW$#<8QmeSMH zn|#%))nP@a8Ry0BT2VGMqy&b~6mlQ>aCdcb;O*_*rkp8w5(~mX@XgH)4>HYfl7FLh z<-8*bO?E79=NK5E{;aWiyU>d1c%O)vV2`Zpyx zxz6p+wa`@TUbc=neOCsJKn`JDI`GmAfJ*iP=yD3|^m(<$8c66wrg%A2{>F4zp+S@CN!lCx_a=1f>^ zjz6UgRYZeg5%sf>zg{yP{^P}2wY?= zfdn?Ab=*!=k@;ViU5wF{E`shTK2TxShzJSY#LJ4p5&?>=F0zdk8>`$QfT#&h=DOJYFzew~QDnP5U8>$UGc)r@sy>asDHpX#mi^^RjSb+{o}0ga>u_9H zI@$^Kh(5f3<#@@QpHEN$$a~6B-#}~;T}SJZBbD!d?R~j+wbqj3C536@%5MTUy>T&g z%lQV|G+f~`m1-jcomRI$=XBCBce9C!MDliayOOcx<*x*2YxN3b6e%Ud#0CatXJ+EE zvV>oNja_pJxLrW|X6os*M%s1NS2IjaEF#2aBdKcNwCFOd9uX1IG4Fmp>g2CpSyECX z%goU-tUi0c(@J9_S)2bn#lPI1KjR;g%t%d5r4V}OOR6U4*!qX@ovp2HuRXfOcbca- z(i(1VZoi`b-~bZ{`L)AfAy-#kKnjvoQgURn!HhKP-Z*jI8X?awD41~nmw$6SvB5Dd zo+5We`5~+KUhpY?Rsst5?`O=+5oc#-!_vhcX$dnkT0rm$o4rJD zFG?+}d-|h2tj4kf%gR9TMCn=?TkZas#%&4B`EWsw6OKfKyt%mR$%9idgwh+=F1Cm!#CI@(~e^<^wk9qQ>q^xW{ zGbg9328p8T+m0aZy^-6%s4_&>^xIowL!DYg^$e#4F2pYo9LNm(VRzR~af)}}Se`IT_5+$Xkl9`#C>kouaOiTdDa^0iN*4`fAGtFzi&SZ&T zajyI;WGNdv2C0&=mQa?FvqN&D0eXllg1|AVO4x*J6sn%KRFOiOn7uu#V-tm>s$S@> zvtaXPvc8HYaZdG@eS2Iq+$}Dv5wiYhirM*3c!-j!g6_LSQ^m?oN8d6+@UMQO{Y22` zs(Xy>Rp=tox=GJPLwLm6NB+x6y8{gphRe>kF9QM!a`Y7tsZP9JZ##5c`g9Nx*)y?M z#Xa12ABpyW;}Ynqf5xY{0knurkq_yr1yU32C|ZR5)o<~gkqg2f29OWgohknFT@L#-MPjR=^8NEtgu| zv7YdvD^8VERrMcuoPMW^{Sp_~{daSiV-|*M6Y>*XB!P2$7P*7k{1X>xfi^pW8YePu z$@NS4j;*Gq<=VGU0Hck3{xEQJb33;!jbsSm8ak~y1@JKLA)#Vzr&({Q0*VWivw!*t zJ9|uqV=D%T!{R+C`q)`ya}ODu5(b}Df2^a|VDr#&*q`yeMVf{jAx;Ip;tZosg1=wY zxcvx#Hp%DEocn!ibQ(RTaFLvtQId~%c*HZ*y0A#N6Cy#Y%qJhxLekavd|a z;;U#b#E8-hOCqiBrf&!lAD2^7QrZtj!JG!Dwccq(FU|B?X*%?&m!tPXD-d{^miKmqb66X&zh_i@J?JD>Fd|8 zl#(=Zt2*e$>Yk=;N1eB3TVpvK+&nyUO-|HC)w7;^l}*{v4W=n{zk`+JfH)l)sb}_8 zZ%R|M@cQS@xew{2xJ%E>?Cg=>!}T_`ZJT-D(WSno=KUogp)o*xL8RAu_cGFK?K1~| z?%u07wK~tE<)Uxjz7+y^QTcwXwMt!0ZIU8%fd<5I0h{!#I=xB{PNSS9#}%N>RtvYA zbO%#ux7D!GkT#5M*CTBN#<7VGs}1=`s+x%{X^{%L?EolyKphnkF(>T4J1t-h*rJLm za14M4GfQbLlX*W~G z03w}HIUmC3K3VmISj}>+gQ2l8Zx>_TyKxzQ{}EoT}v3LzDB}nPLGD zoSGL74)I+f37@C5mplv$fl|MEa&={XULZB2Xw-DrdsJ7?!fy~D9F*i`C;j;FJ)G*> z=aw1*egLRKBtNIig+3omiT|^5t#og|oVGBN1+v&xwpXyI=sD4zxOt(hFJKn%c!po) zWmlz%cTb%m1>#@JWi-jxTu!RlNtwi4B@-G`&3AB0%GOr`2e^8l+Eq=tANF9WKrxGQ z7uH-RsGD)=aOj@u5QQGK8bskvombm{vA?57**~mV2p%^XKg6T3r@Y+9WB~2+_OJ>J zZ6lSk!&h*#G6l=vd}?(P=nojKSNPltZ=1w5WoZHj>k`9KJB)sHiRKm|5<7n+ zY|g9SmXPdje$QzY^?v0KuOmV(X7>U|y9vn|7V#GB_$guFBRw1?DVZj06tzGaZ8{tI zf{*W{3eT!Wt%MT=yV*cOe$Xk@hHZm{GsuEGnSdzt$!eT+4&O$(c*M)!5Vx$oP!pl0 zdiYvww4$(x;ps9)L>MiP+_&d*35%U3UfT6Dm8OvN|@dGvI$f-D<4r6 zFWHUSe?7GeA#?qX&}@(>dJMrWggK|+wTsyxCD7M6{HoE9v9K7aot{m(vxNuNCa|m5 zf2Wrjp=wPlls}Oj#K>juO<_mNPUT#a&Y`Eb@RE+cDK;{ctSB}IJ5)BL#jH#EP5vfO z6u}rhFT>D90I1er;}peewB*F%6(r>%HIf7jtG-)(?TY6FUT%zuAD`6rLUJuY^aPod zzM%!Z6y9ZG!N!L{;Hu_D!$sz<+bZ`l-yrp%0co9!#2wWXwtUa%Oy+9srIIRq7Wxzo zO4PSSEG856IwlKy(do11lu**esu9-XrJxCi30gd&<0vv12!Wk6JU+q63&4jQ5(9V5 z3kvw7ybPIo6guhU3wAsip*b6x=0i2KC~_VtM5ER0t?+iTo~)tI*%mIc!0Cw! zc#PV~N}qcW5Dt)-(W@M>0=Mk480-tD9AydRK&(dS>M61HN>`fx#Px?veLPDHk21>u z2?1^0Sl!5fE|3Yg|AK`hEL9Z!+nWTde_}>S$(0l{(vSXtq`t}PE4wHfMe{(1)P`=r z=4*AH`ZK?DzNQ( z4#8SM0pGsAhM87WDehMFyJx9I)jB?d>9ZdJ)(pHe>&Q& zD6g`3dC)Wu?&r0IFEiS(gcX}=pMJm%D`(jc{^@R5@?zuJDr_6E`D<-$yD`}ax2?1j zp&M-&M{}V~EM>u#?5{oQTAb%j}QC|3a`hl$` z3_kD`A#YFdsmR^jJ^a@*j=b!b^-eKG*FFokOM5#GPR{Z)UY!0z<$-K#_Qxq*ZV?}D zm$iq6Jg`Y=y<+9Oz1IR;TQ`bs*+rLR?Sl|3gPj?V*sq?L)Nb6U|~K`J81PZEhO z_HZ^dbWnbQzqHNiyMyy7HvHyBz47ngCC`w*tzuuyn$V0W;jq(GVK+2@oi!6voHQ2? zUD^`g7Jly_Q&Q|XlMcsMAE&G_A2_<%YZXPYc;1JFS6GJiY{apjh1~V~1VZ{&8gn5( z@APaE0mT=B-M#e89*{do*n4qC7_qvH#B$M1WAb_;n0Gwr87Fbc$om-;IHbwAP?k`c z@!?DG63#}h?|TkvJ?{4`Su&VHlLt8iV*yIgn!smJCl3h8|OD8N+9g~1g^;3jH9tAb=8jXURByk~*`z*UvMCsOZX zpZX~zmknMCw~HDdqmK$c!IxGgQ%qeUWX4z9omjKqkSl6KVGDGENOQTU>|pI{YC|BX zPyW3N08fE?J0*Uef-fFsuN zgb|iVqBs>&WDBZ~cmC#W#z4fA*N-MMh9%#==+B0K>JxZ<^ZdOQOV_~niKiYRDr3;R zi|Jm}vZ_52!`YK-zsj7vL^Z&dyCb>i_iCxqtDt%&=yjnO1ya#^CC}ylf|Arr|2siG zK0X=dgWHRPTOiymQro?I=Lyjkf9FIN8t1@c7NjQjrP6kB-e7{yz?fB14mJ^X5LJ{1 z>J>lbQir~yfVWG&c>>6JDC~Pt!6qP(0$xH;RagHwyGIF%J;uVA?SUts=Yyqi3A|Dy zh=_^#80hFWsEVhUA+M>%j`#QXbwRm9mPgOM}PPO(EAaWnaxGCat62M z5Lw&O^4~N9Vq!_ai+90PIshTVtd#TQdiSMLE!DXp%y?)`+{t%Rj0_NhgdA6-pd zUAMsoUku&NaQh>!$iFIC9RDz~`uN*|=l!u6c)>vROG^bgNmDs@IG9AtU?Kt3vm&B9 zxO*~u*SD7$-h!$MZ>4U15zrMR5WvzrGDb-j;*9lX-RHpj15RJ{DE@erHf(pi(tc)C zEztkRO)3IsdVYEuCeQp%L-QQTexVT?KD)$k6v>Wp1E$y#D}3?GARS3--{ZF8`gHrz z55QRrQ1dA(1C?1ZbX}ki9RnrvuCt-xjQS19HgbhYuT+Wwj6C5`yr{5H*bfNxkMDqK z6U)lPR1=fO#=A^=!Xg(J7pdQ+|Malr93L_w^j)yr8r!IeXp@)WvX6WfAQ~w<5>>&6kt>Nma{Cn$&>{0|5xgcYQezXT=>;MT)LV z9t#dJXJ>9PPhX0ut4~#d5=3Zv5itZiuJP0?#79kM(^(KoNJy9whD)sk`UiRebD;`5CUEdh8=BeTAE6aXLEWLAAv-p?XoQcME`%yyF72Q)4NNSqoJ-e^0;*l0gD8Q;)LQ|M>4J6$UL;vh+OK!#bf zX~E(CxCeKEF}r0e{aw{HMT+b#Ltz6J1%E{bYsVKQjCseV)76i-P{k?xw~cf=Zwr|e zg2guPUWbwPnbk_z_c#|LvxV3Us#=>(7H~0zGJb%nkN>|vg-nc?Tz_su61(hVXYEz*rBpmcY4my~o#NeB|s-Iwl=j*FC(v`CkPG}8TTzxikW zciw;gJ9F=uxo4kUYwfk3=UFF0MM)YP`UDDrK(J+HB-FsQ;olb>75oa1qH==^hO>;W zD+FR7{O^m<(n{qI{v>mg)N#|Wad$8i5|VH-cXzOKbQ2O%F}1dIg>V%=wsC+qA|5@rWRa%g1 zX|oH?e|;=&|EgsaJAWbkYhyucqBFTP#qR6Z;$PK=Iv(f`cU%4NCKjfe(jA|e=;olL^n)#dQ87Iu zE$yYx{;yiD!NEbT&waESn#7U$&qCgy2PG01&Q7=+-rV~yIyQARH~&)C(a~vi-TuMx zv&!&xB3sy(A5pXWi3PNEo0BRPDuGmuB#LN+Xh&x=)%R&=Xed21A;ER5Lbu*AOYps! znw(suU9Clxf`x{m65;0~`rX z9mtFIwpenq1V@F3ho|2Es)zdFWFuCT{gvxhRMlQ97DIG&bX{(4?#cCbj`$<1_=flljpQWXxUPmNJHBG(oV z$7?;s6Bw!)Wk+dP13QJ6Xg>MFp@_dYJBe^|aEtLI^jS+BV%0TYr%Ta|s~E>JF`_z* zQTZLUfBbpTjDUn1b$965)nNSaF|>x|I}?Aw!a|LQ(aWLllXbLH{vd4Vb;k4wWP~r= zHK9I_i7Acq%UucoFRePC7x>aUc*#4)5K%Rl=&4 z@ud$No5#H3^f9TtE^=K9ujXBu<`1Y096cZ@o4Ii~p?<6lnVz1;>#D0-yS&|uBxZR* z_2F#7TRP^cu5#O~CA1Z7%_Z-bJv~1kmn8ZjNiZ|~&5uWhBr@7_8QCm64Fm?bNUi~T zjI3;0(ORS4$*zz{7j@2({{v$5?B_nazWhBMVwCbk33=K4fu7^Y$id6U-%QomV-y!ydHcF!}ql!RqM6c-|4(nLx=*(B|u1}9B1f5M}`dBlN;sbv^D^xju z;LlK8^gA6T?7G=4Ul6(3DJV37w(8p+CIz71LCouzI2parf(qen?4%3^y^l|&romxb z<^ypHi`g=TL>ZQ7lP=}${ZcxXYV+!3qcS*IEj~5%`zL%l8AU|~A)(gcbt*o)M02nV z&w#TD=_3Sdg}0uB?4;sB+d&IlBtrBmEDY7QPXg+6p5x5)va6Vxnca+m=(PNWM!dDb zD}PT29C;9iP-&3K$;tgTC{~`)&>%>v+Su6SR#Zf-ubY8*Chy_F5A5A%Rgbb%wB%?F zMw_*=v{YQ^@V%5%A77JhHZVYIheq}7B)OZU;IX>2d@sE9{eAlV#}6t2*R2t*$jLb0 zHrJijA3rPgnORva4i{Tsg@uOWw?bJ;s90q1U$y4%+ms87}G~BaXS=p9(A~!PU7M1=e)9l3dK(1>f!HT`b>gRWTo4YT4 zQP6OyGCj^`v}4gdnpO4nf%%EZXXi0u22%%)E!>i@d7w)XA9vk((t zAR;27RgbohtzlDtG|;ffzBt6>iAN1fk{r`YJ&QxedH3W}_?(D>?w#%c3 zqf1Z&pKoV>rrP%XU4^oMiB$FUhQ7zqA&D4kYOc8nRdf07;H|shB4hfN zr6R0vY$O1`njWV1rqR^Y)L|vr_wbdmC+D@n>+9=#oAs_%M@Ckb+zcut(SAj%3U}iC zCXAxOhWyy##g!xRvrc})Sume9dDXupmhx3UaLk>^wrVzJW@Zg-?I!kKWU$>KA;{s( zJ9w)udDGL!l&g;EDYc=iy3D%drc>;nN3C2->{KXuL57!*lnk|JURdL7R6%923GXrG z8yKf~Gxc4Kh~&K^%JD(JRI>2p)9&lMR{YUl=TD|vw91JUF%3sFK2vu4zjZTAvBF)F zr1B2&FB?)0HIXyh@r~J)nV-@16ERk=$ybni}3d9rfp)?-r3y^K5QGETiv`8}e9iVo! zv&rhkN^2)xGD=D~yMBsO7Ut&Wam+i<-nYo09d>_WzC@^QHQ0}-&@%RxfX_uQp=S_}-Cpx8kw9c;N?(OQG-isJyk4I$*HF1W>JQt+5OFVVp0-{U+38NMuM^k4G&MkzuoH}QVC1~}&UPjL=7@Nr7s z!mz|lVc+C2ky|WD)l?yOyKzijk(}84{Cu;VF>U*sJS1tsry~ebW@kU7-Ljgp{pzHd z7`y0!9j@AIYL1xzuu;U=x=UVSRw_>5=)4NPzrEyf-_^)eVk#@kp55DRjTzX;Yi>@Z zeC6>aEo~4co6y=YucND5>afyzuMT&B3cWG%3fj5xIdnQDuUzcP`H0V3It&owhBLqp zjW1od7D;4YyXuGF!HSBw10MW54(9uYl2~l*>}Z9BvmWkm&1-c^s;jp_1oY}Knw*+y zxxZMDl|dI8uTHwVyDI}r+b84{7(|U)7`@txl0qy&UOsThj>aj`2k3CJy}do7y6eHm zS39|mjRbRUZqCBmdc&jb<@jCQPF_1v%BH; zl(MMs&5XA3eGq@k0Z3}`XjE|M;^!jSaU4=hIhvl5e&t+X}2>T9wU{vOX0@BBB3n<19!yDI?KUvap% zgAH@uh+ae=L8}mRE~$+p6>y|)K5keJZ)$G#It8F1=H=6v6L4mtJq4edR%`#tOxAV; z7QVkb9pm_Le?Cj9sij5Lx#(S#`|7O{&MC~I5f6Q}-a31&Qf6U#^!w!Gf!qwlr)3_*Mvy1tJ6CZMudafttEp6E%1Z@*2erPyPug-w0Ev05;yy9VE+71G) z=)IoGWgf4tuAcO!{`sF)C3kl|ki6Zhb?dE;w2eQUFN4FoBI0vqgOTz)$d60mtubo& z$Glc0wbLaY_yl_Tl=>Ht46Vz{${uRp%~tV&l@H4(D|fwQVR>g~WwrGW$#<8QmeSMH zn|#%))nP@a8Ry0BT2VGMqy&b~6mlQ>aCdcb;O*_*rkp8w5(~mX@XgH)4>HYfl7FLh z<-8*bO?E79=NK5E{;aWiyU>d1c%O)vV2`Zpyx zxz6p+wa`@TUbc=neOCsJKn`JDI`GmAfJ*iP=yD3|^m(<$8c66wrg%A2{>F4zp+S@CN!lCx_a=1f>^ zjz6UgRYZeg5%sf>zg{yP{^P}2wY?= zfdn?Ab=*!=k@;ViU5wF{E`shTK2TxShzJSY#LJ4p5&?>=F0zdk8>`$QfT#&h=DOJYFzew~QDnP5U8>$UGc)r@sy>asDHpX#mi^^RjSb+{o}0ga>u_9H zI@$^Kh(5f3<#@@QpHEN$$a~6B-#}~;T}SJZBbD!d?R~j+wbqj3C536@%5MTUy>T&g z%lQV|G+f~`m1-jcomRI$=XBCBce9C!MDliayOOcx<*x*2YxN3b6e%Ud#0CatXJ+EE zvV>oNja_pJxLrW|X6os*M%s1NS2IjaEF#2aBdKcNwCFOd9uX1IG4Fmp>g2CpSyECX z%goU-tUi0c(@J9_S)2bn#lPI1KjR;g%t%d5r4V}OOR6U4*!qX@ovp2HuRXfOcbca- z(i(1VZoi`b-~bZ{`L)AfAy-#kKnjvoQgURn!HhKP-Z*jI8X?awD41~nmw$6SvB5Dd zo+5We`5~+KUhpY?Rsst5?`O=+5oc#-!_vhcX$dnkT0rm$o4rJD zFG?+}d-|h2tj4kf%gR9TMCn=?TkZas#%&4B`EWsw6OKfKyt%mR$%9idgwh+=F1Cm!#CI@(~e^<^wk9qQ>q^xW{ zGbg9328p8T+m0aZy^-6%s4_&>^xIowL!DYg^$e#4F2pYo9LNm(VRzR~af)}}Se`IT_5+$Xkl9`#C>kouaOiTdDa^0iN*4`fAGtFzi&SZ&T zajyI;WGNdv2C0&=mQa?FvqN&D0eXllg1|AVO4x*J6sn%KRFOiOn7uu#V-tm>s$S@> zvtaXPvc8HYaZdG@eS2Iq+$}Dv5wiYhirM*3c!-j!g6_LSQ^m?oN8d6+@UMQO{Y22` zs(Xy>Rp=tox=GJPLwLm6NB+x6y8{gphRe>kF9QM!a`Y7tsZP9JZ##5c`g9Nx*)y?M z#Xa12ABpyW;}Ynqf5xY{0knurkq_yr1yU32C|ZR5)o<~gkqg2f29OWgohknFT@L#-MPjR=^8NEtgu| zv7YdvD^8VERrMcuoPMW^{Sp_~{daSiV-|*M6Y>*XB!P2$7P*7k{1X>xfi^pW8YePu z$@NS4j;*Gq<=VGU0Hck3{xEQJb33;!jbsSm8ak~y1@JKLA)#Vzr&({Q0*VWivw!*t zJ9|uqV=D%T!{R+C`q)`ya}ODu5(b}Df2^a|VDr#&*q`yeMVf{jAx;Ip;tZosg1=wY zxcvx#Hp%DEocn!ibQ(RTaFLvtQId~%c*HZ*y0A#N6Cy#Y%qJhxLekavd|a z;;U#b#E8-hOCqiBrf&!lAD2^7QrZtj!JG!Dwccq(FU|B?X*%?&m!tPXD-d{^miKmqb66X&zh_i@J?JD>Fd|8 zl#(=Zt2*e$>Yk=;N1eB3TVpvK+&nyUO-|HC)w7;^l}*{v4W=n{zk`+JfH)l)sb}_8 zZ%R|M@cQS@xew{2xJ%E>?Cg=>!}T_`ZJT-D(WSno=KUogp)o*xL8RAu_cGFK?K1~| z?%u07wK~tE<)Uxjz7+y^QTcwXwMt!0ZIU8%fd<5I0h{!#I=xB{PNSS9#}%N>RtvYA zbO%#ux7D!GkT#5M*CTBN#<7VGs}1=`s+x%{X^{%L?EolyKphnkF(>T4J1t-h*rJLm za14M4GfQbLlX*W~G z03w}HIUmC3K3VmISj}>+gQ2l8Zx>_TyKxzQ{}EoT}v3LzDB}nPLGD zoSGL74)I+f37@C5mplv$fl|MEa&={XULZB2Xw-DrdsJ7?!fy~D9F*i`C;j;FJ)G*> z=aw1*egLRKBtNIig+3omiT|^5t#og|oVGBN1+v&xwpXyI=sD4zxOt(hFJKn%c!po) zWmlz%cTb%m1>#@JWi-jxTu!RlNtwi4B@-G`&3AB0%GOr`2e^8l+Eq=tANF9WKrxGQ z7uH-RsGD)=aOj@u5QQGK8bskvombm{vA?57**~mV2p%^XKg6T3r@Y+9WB~2+_OJ>J zZ6lSk!&h*#G6l=vd}?(P=nojKSNPltZ=1w5WoZHj>k`9KJB)sHiRKm|5<7n+ zY|g9SmXPdje$QzY^?v0KuOmV(X7>U|y9vn|7V#GB_$guFBRw1?DVZj06tzGaZ8{tI zf{*W{3eT!Wt%MT=yV*cOe$Xk@hHZm{GsuEGnSdzt$!eT+4&O$(c*M)!5Vx$oP!pl0 zdiYvww4$(x;ps9)L>MiP+_&d*35%U3UfT6Dm8OvN|@dGvI$f-D<4r6 zFWHUSe?7GeA#?qX&}@(>dJMrWggK|+wTsyxCD7M6{HoE9v9K7aot{m(vxNuNCa|m5 zf2Wrjp=wPlls}Oj#K>juO<_mNPUT#a&Y`Eb@RE+cDK;{ctSB}IJ5)BL#jH#EP5vfO z6u}rhFT>D90I1er;}peewB*F%6(r>%HIf7jtG-)(?TY6FUT%zuAD`6rLUJuY^aPod zzM%!Z6y9ZG!N!L{;Hu_D!$sz<+bZ`l-yrp%0co9!#2wWXwtUa%Oy+9srIIRq7Wxzo zO4PSSEG856IwlKy(do11lu**esu9-XrJxCi30gd&<0vv12!Wk6JU+q63&4jQ5(9V5 z3kvw7ybPIo6guhU3wAsip*b6x=0i2KC~_VtM5ER0t?+iTo~)tI*%mIc!0Cw! zc#PV~N}qcW5Dt)-(W@M>0=Mk480-tD9AydRK&(dS>M61HN>`fx#Px?veLPDHk21>u z2?1^0Sl!5fE|3Yg|AK`hEL9Z!+nWTde_}>S$(0l{(vSXtq`t}PE4wHfMe{(1)P`=r z=4*AH`ZK?DzNQ( z4#8SM0pGsAhM87WDehMFyJx9I)jB?d>9ZdJ)(pHe>&Q& zD6g`3dC)Wu?&r0IFEiS(gcX}=pMJm%D`(jc{^@R5@?zuJDr_6E`D<-$yD`}ax2?1j zp&M-&M{}V~EM>u#?5{oQTAb%j}QC|3a`hl$` z3_kD`A#YFdsmR^jJ^a@*j=b!b^-eKG*FFokOM5#GPR{Z)UY!0z<$-K#_Qxq*ZV?}D zm$iq6Jg`Y=y<+9Oz1IR;TQ`bs*+rLR?Sl|3gPj?V*sq?L)Nb6U|~K`J81PZEhO z_HZ^dbWnbQzqHNiyMyy7HvHyBz47ngCC`w*tzuuyn$V0W;jq(GVK+2@oi!6voHQ2? zUD^`g7Jly_Q&Q|XlMcsMAE&G_A2_<%YZXPYc;1JFS6GJiY{apjh1~V~1VZ{&8gn5( z@APaE0mT=B-M#e89*{do*n4qC7_qvH#B$M1WAb_;n0Gwr87Fbc$om-;IHbwAP?k`c z@!?DG63#}h?|TkvJ?{4`Su&VHlLt8iV*yIgn!smJCl3h8|OD8N+9g~1g^;3jH9tAb=8jXURByk~*`z*UvMCsOZX zpZX~zmknMCw~HDdqmK$c!IxGgQ%qeUWX4z9omjKqkSl6KVGDGENOQTU>|pI{YC|BX zPyW3N08fE?J0*Uef-fFsuN zgb|iVqBs>&WDBZ~cmC#W#z4fA*N-MMh9%#==+B0K>JxZ<^ZdOQOV_~niKiYRDr3;R zi|Jm}vZ_52!`YK-zsj7vL^Z&dyCb>i_iCxqtDt%&=yjnO1ya#^CC}ylf|Arr|2siG zK0X=dgWHRPTOiymQro?I=Lyjkf9FIN8t1@c7NjQjrP6kB-e7{yz?fB14mJ^X5LJ{1 z>J>lbQir~yfVWG&c>>6JDC~Pt!6qP(0$xH;RagHwyGIF%J;uVA?SUts=Yyqi3A|Dy zh=_^#80hFWsEVhUA+M>%j`#QXbwRm9mPgOM}PPO(EAaWnaxGCat62M z5Lw&O^4~N9Vq!_ai+90PIshTVtd#TQdiSMLE!DXp%y?)`+{t%Rj0_NhgdA6-pd zUAMsoUku&NaQh>!$iFIC9RDz~`uN*|=l!u6c)>vROG^bgNmDs@IG9AtU?Kt3vm&B9 zxO*~u*SD7$-h!$MZ>4U15zrMR5WvzrGDb-j;*9lX-RHpj15RJ{DE@erHf(pi(tc)C zEztkRO)3IsdVYEuCeQp%L-QQTexVT?KD)$k6v>Wp1E$y#D}3?GARS3--{ZF8`gHrz z55QRrQ1dA(1C?1ZbX}ki9RnrvuCt-xjQS19HgbhYuT+Wwj6C5`yr{5H*bfNxkMDqK z6U)lPR1=fO#=A^=!Xg(J7pdQ+|Malr93L_w^j)yr8r!IeXp@)WvX6WfAQ~w<5>>&6kt>Nma{Cn$&>{0|5xgcYQezXT=>;MT)LV z9t#dJXJ>9PPhX0ut4~#d5=3Zv5itZiuJP0?#79kM(^(KoNJy9whD)sk`UiRebD;`5CUEdh8=BeTAE6aXLEWLAAv-p?XoQcME`%yyF72Q)4NNSqoJ-e^0;*l0gD8Q;)LQ|M>4J6$UL;vh+OK!#bf zX~E(CxCeKEF}r0e{aw{HMT+b#Ltz6J1%E{bYsVKQjCseV)76i-P{k?xw~cf=Zwr|e zg2guPUWbwPnbk_z_c#|LvxV3Us#=>(7H~0zGJb%nkN>|vg-nc?Tz_suH&83yRfOL0vNeKJ(xBKkA z`|h)U%rkW+&Y5#&=FDfJ)m0U+F~~7MAP~0VYgtVot_Oh-z-TByD#V%k5{S^9U+cMn zK=0-M1q7lL87ZKU%w0~`UCYM9!3+wObu#yGuyk~XLe)*JE!{xerO$0#|BXh`0jPpP zUt8K*+qi>-1^HFKrNaOk(*M%W|Dw^cwQ#oq2?+A#BXtS zn|r2C`vf3)@n3pT0Vv#koGn4N|AyppcC?nL)m8%PwTU%dC5RWh?x3aXfsK8D% zP;KL@rR#3)o5g|GjeTgm7qv2KX zL1^z`4k%amkOanL{5K^FQ+G?KxvM1*fdIAyIUsx-+&o&`f=~!Al$V052f{bY51HZT)BMT8%33oy%f-btI}ElRLjEv0%%y}1O06W)=N)c4 z1A%Bkin3B#-dV@le(sdh4W(Ug4VN{WR%Ra7NgFL0YC_1ql2LAevtl#eP$t8+`YoF? zK3O!=Wq3FpfmA0W!y$U%8FJ|!%v-96A$TNU%8zaiAG_zsYG7+1k_*f`I=xzpU%sBo zf4}nvr7*-fC~|!JUf$->*-+m){m#SA>$ch}d%-$401U_8%2zK!fJ%CL3h?vu@3o%P zi(&MKNB5f@t#;++bxsqwNaV+IWp3> zdnx>{ij_}=mj)pm4~>qJ|8;&1;;1bW5eAz^sCE&t5oss&O%g>pKrSLye?ZhL9MVTu;TJLK=krXwlTip)CS$~{6r$- zlHnlhJWFt;aZ}NMif=R-EUXM(o|x!v>b&MK`!SdP!1$`rsp9g@PHfXfy2Ywf!QftN z!r*52v1j5NJYhprBqSu+!il;Bk*TC*ztfJ9Y>~8YX7fbEtc)-t6HF7V4)#CJYw~Dx zRwN`Ofi5>k^Hni17#NtC=iZ|3US5P)DCfQ%eEj@W{+scFPb9JZaZ`y@n|FHE*z-L3 z=IkqhRRM#(ln#r!iwYvM-VX6i#-caqpz2wJANKRLwQN<*((L;69}f=fuzJ_RaK&i} zqVo=0{kM`75}f91i`}rk4u#`IFxCgCQPwY=kY$)MY&EzV z!BK%D6J%#1=K|F+v)iy7(OMIOp~9|l7WnA2=2W>y-j8q&^!lfdJA$4Ov_PaH<}-cj zhB(NQ2qmO}DRtHq5y7j7#-Jer``K_neVe)amk{~lYt?Yipw7HID&~^~;7S(6S0Qq+ zT8*0w-ysm`HOQ@cgh^jfes%?MgIEP&8#c zpE>%8bWu2AGq$!yyS%*Y?(Pm>ScpkU{>-dK5HCOBkzJ^eNCM*JE@UkH!dnw3i+)d| zq^x}Uii2a6Sh{)DXO{|xQYaYE{cTr#oG8G+o8NPWcCQV!x3`aq=bqX?$R1G&SAEzj z7{h%wbvzOrxDldzZ z)vhjb^+SHMY5W_9bqcMZ%DEV^(!%lPfa5kN)_hQy#S!y|Vt)^tuhO^i46oLcO38rN4J?AaI45x7gW#S%g zu~JGaed~C<7-l!_T>7_JL9kALeP;IA$*|slij%~;95>7wZMn91X0egDIf0(Jru&;ye zeB4slJ3iiin|uE|+PX0k59K<3TWMrcbB%d zwlAXP8QJWL)VZaBmEhpuuwQAA-7Ou?Ik#g$4DlO!#~vMuU|7W{VEYqbqm>AM5Mu z%j0>vvRrToO?tg`@UC2&qwA~(a}(Ox(UHxZ>wl4+axt-PsrW{un2ijp3ImK-xNWLN zrX1CY6arfX!g7{a{B9QtV#vF06L?sQKoptG+yD#~jE@F}E-WlO37Y&$Y$l^%d6aZKU*;Cb+UBVVc6!GZLF>BX`rGKFCO&d|B8(b zIDYDznxciyh} z1^Mq6rx_tEKuA-dRKp7E1RigjY36dXvpZ^wineByIa_3nf0!Z1l5$b&%>WJKH#W@l z4GeJa{yqhDt%YI^7|e_cxM%mm5<^fST_akD@DJ(5?M%KSswS7hjnjzAY7arAXY$(G z+IJOtbybF){=&+s?CYVJoRUh4GBUkCYaPpVs#l&SmAU>tY^@CRDgI&f@b-SM6m3dI zb4OD_gOQCDC=t0jK9x>gK5Fa76jEaQc_=Jn57)~(X)4h_(b|6y-2>&@g2Ef{AzjYGeXUaC z#&)1xFAJA4Evf3`b2&?hRUFlKyf6=<_8Ui|Ur> zjC;gGTk{o8?r*6J3n?_C&&iH?eYOT0v>5FR^TNfBlP)GmiqsQAq(d@;A*OIp`(Ztm zOYP|K4s+N2bV`4^s~HO8Uh~<*KI#d0?EB+qd$jIGk<+4STahejbg1fM;0j*oYVwlc zYt{@uGe#vip(NT(clc&oGy@Z(m@36O15gBm2;nFO2q(UXB&a9Xjm~{5*)b&_C#5w7 zTpwIEZVCI|a|-F9>Y?ysAKD=n(E=^3*{pgrc?htg(4h|DpUX5&2uojhCv06!b{KK} z{nzV|j2d27F60c4!P59z%XqaYs(lKPaqri8Rmx-ZR;*%^rB%reTJAd*DK*3{nqG*v zq|(Ccf~u&LERzd8PumcJD~6T_#~X}pdWNL5)MTWXWs9GO9sizUm) z@y&b-T?*Y7qrzB?_snU{zwC`t>+8`1q0|Df7(c@qRt<8LbtGmts*#hO3UM70|CN~B zV<0q`2BFR62E}FYWO>Y(HA~*d2J`H}hekI_IAaD~LxDejR88!Qs9>3DKG*^O`nnzQ zF{=+#U+I@oZysm&u8Pucc$1vyHPMeT)hAr5Ulp=9rG=RTPJf^F#iWJeF5o0Qe2J$~ zuyt@wBO~Qb3pj`Cn?`6OSy!&_8YzR7RcuPK&XQv$fpb-gq?~Ytf^Wy8#!&c{3NBjr zWnj<{@#lK%?R*E5W$1m;mXv)?%_~Oc0u7_4OUiG+>Zr)RJVM4<@WG+;mYIE9_|dFD zJ+v|Ub$DJ%qwn4)(;CZGX8P>tSIAa`^YeW*f?qD1OTNurX0YHo5O&i#9vMa-IIN|| zAD1%Nne;RHi}RRhen1|O!SZ&oA!*&Dkit+PDzAd`_Q$JUUS4-%GI(>uyeyj^M4QHo0<8tPJK(dXiBTv3)y$V{l z&s>deX-fO_;@72EV`y}Y%wq6rBC61MLSwPT2TuVc&-!fOp6Y2KSY1QvTiC7|dP?4AQ5|7)1ZJx;`Z@$01`)D(k{Elc3-+6>YG4fGa!?OV_}n9{ zjijSLos)95@S!G1;`emM1~n!fJmh)f@`opjj;sp~(2Wcz7kQ|3@?#2Kyfh0q35`+= zTo=`xD&d(V;jqRg8-D1Vj4bV(2jfBTf>Pa5OU}7s zNnD;Rjumx&!@d092)k9aQMkHF&W={eS(mapLLO!Y`gpUfDNrPC9_Bx0)Vs@WE3!!? z4taGc%bU{qr2o3-f9t>{ID5qGSBJm_f7J3pojX$eRnc%LP=elf z@{N(?3%LGGI zf~J-^@Q^i}mauGs@3D2vcz9Uvc`8>^_?_R|FWzET>88*5`Iq%~rrsUw$epO(m3C8` zA!FeNQ;45|qvFHhPWaY7q#ziy)+)u&%d>&LwC%9sb z{WdV>V2|hfYKwW-NCuhye1-1QQbn|r@RZz?14PH6F{>|Akqp3YJdvb%QIPUTt|^X{ ziuzc$s+KerITufGMfT?}**fGF(JA@fur3jaEnA?+5jZHSPBkM@s+=^1vadzD ztJ!IWCWP%+86o8`UUyspcNC>8fgV*rH%)9eDW5SVKNn5l{>X=fP#T~9 zQk-s5gsBoN7XOI=x2P*h^*Yd08qT*=`LGRyeLR^ zvGML&ugdrQkZDmLwkT#sJtFN~4hF1h1EE?0Zsa?}D2cDlV6%c_GW zH_t70udlAsmOU3c-0bxQh5QgZ!3Qy+KC$e55o~QY9k# zb0FyWIQ{j-i;TAN@>pCH#Ew!DE=Nl5!%D^sUMn);?mX=sSKCYM-ew5dkugJfI%*Y9 z??+3F^#jiqp%wU=UsvZ7mtO>gyl6xStD`jd36ry#j-Ao07e!4XJS?48SAOZ*S#=`g znVC>CbX?~rW14>(RHW^|D;UmqkBZtrSX|7AdU*JJ(OF{a7XimPX!U$aUsziG{oo#+ zM9<~dv;K7CtV{HP9FtGwH+iIssSsuP*vM5Xmtkv}&1xrMVU7+OU2WZV?d|I7@0a1C z#L@8W>(+ZeU$e0JdHKC)=A1OI(Yjv@St=ZZ?1 zb)x<}+s&#(*Me-hYv`x*c;sv3<`~JX;NJ*zjH1tvs`n3JkDC%z2rQqHGk11oxI8_s zk*&s`MqHZwJHLY6Wo0ezL+3Cf83RS>AQZi?OV&e3CRc5~JJTAyH zL1<_&E@}5i&lETitAr8xa{n}2BPb6{)qDw={V;+TD#~j40!z&mURF`x_}+LZA|Ek? zHa=eE>gJ}-=aS9B(x>I`jX^p$eOilKx%Ymt;ga_z`SAE*kDQAs$6#U?&TCbYuLX|Z zKr&&;0()5@-yBWF?NG>Y`sMgWNAGrnLN3R>*dE%pCIWK$Y zT*ewd28V>;d3c<@3^(Zx6>fhxK`?N1<|Y5C_s17ioCDP~eMOiJv|R}~BqQ>Ww#IM9 z!bADpiOZWPOt_Us5EEnf*=WS`lWVBBXGO%pfiSya>&FUquI=sqt83&>1Q-~u`v(V% zFn!4qbcCmJJ=;1)zIu(; z6Y>`2<>69`D(UIrJ2t8Ekr)5?5uL$1I0_wZr#D zZ*qIP{Ymqtfra%01S>2u5?8m;{zq{!G0!d4fX*!r4{sQJ>6Mv}um$yp;)S|&-QC4K zG1EqhnqSC0n9n|(DO%DAUc9DIy(dX#YuOcveBy^9;aWk-fc0b zy$lDOSv55p2ZwAv{%n)c%<{dHlZGQP51sMIyE?d<$LEGqNX7#>x9at$DgWe9&iFx8 z6Z$hT>?e}QRmxizKMiD3V%(aJuC&k~7MWHsVfh6=I>Xk^XhHiU@6`>CNmFhz0Sc-_ z#Uy7qgep3P9!CyM3L^BH&-Ww(*Ni*t%=^m<^T*=Qz+Fi~ionaGG9;D>8=~0}&6|4u zw_V%9OI(ifQ()lrM|TA4_n?^u)1~E=hbR6tPxEthOG8c(*^2UpHn+2rFZYJa3T$c;>6vkU+;x!iVYW${)4}noyFPt#L%_lc|M`u* zB)=&v;dZ51{yf|^Ar@`S zO-G)vHt7*=b}m^1WdTt}Byown&}PSW_Kp7-8J!kA`KFrJQ_9X?8eOZH;!w|h=nHW! z-^l6V_late*p^xh>Wy^?$%bv{yW0d6?97mI0=1xE*il9}qLkSK?gU|iWFYm^4UTxZ z?Z|hQ!n$Jy-U58imF8#@6@CQ?FO^B`Xb}~5@_tK~Uo2D=!}T8?)|`)~2XkVY-+#*y z5DmxkZuR5#H!7eOjA(mS?LTy~sUsbkl6@PSm4C=SGV=QbTcKXpI?d%(FMZuhjk^Kk zoZZS)LVW{8mn*M3pGl8BNWMZ2giwQso-9&Ixfg*7ld8N}B5}ab>DYehS{q7aCCogZ z_l#Hd&D+J=Kx9NPZ&#b;S8zFQRIi7;&=NgOK&@&I^ApA$(wWWQRU=2Yg%gGWf<$5crN=ac zLQQjj-Q|4teqFw@TF+o{rmUmTJS~%p`8~A#nhETVEs5S@xwt{cui3S51qs`%q1i3UJhoA0%-|CxS5_x0=wI8hi zPsS9dmPJY=n4tc;-fYK1OOd!$S;(#k?hA!{aMwbda$?nq(x6`OZ4FV?BL7AY$UzOy zruPl~D226gM1PsTO)S0@rvhP#m-df6aG_|u7-cVeW%)$`VH^RFrtsCuZvz*C9dLVz z|9;8)PhmX*l4P+KBQ`+{K#|oGC#REVHi0gOzCi8Ejj9_1;XNfnmj-h8+~xPX1w)5S zMEq9{NTu)SuL~w$6UJP?ZzkgOxLSK`Wl9K@fQ;x>nY0%=z>9d~@Zp%}!l(Ukg8G2C zqNMMLd(q|$!itP6da8m}e^mPm2tQs>-b^IwdCPNLr%I;e9n*udU~lN(0doXajs}0E zeGh9yNht=L2X-Lrp{%j%d84Yi?Li21*imnSVNhw9P7A!WbYKk@>_P!)O8MCM?ZdE^ zS#h&zf!>Nqc?DbF6K5-80rTPs&XCuS`96_^2h>>NT@FAniDOlPb-5wv9%;SI19%C| zgxQMGSlb9=AZ!Fl&k*2=tiQS}PL%y34LeNlwT0#dbc-?+MEa&~B*zMBi{6m^MZ^K?S0CvprJBbG9 zj;qUDK*|~cHitfzvsH!;hK7dC%O`G6*VotQLu}RV2wYGH`&K{Z?_XmQPL`5kp{2!Bm7iHstwWF@croavd)Jvu@P>7lPiKW@P5_8+3NL)YNXT~i`{RM}I`k(~T9o}my;IJU8pb#}xQUp9T zqOV=)T{|{?m869cs)^=XEi3|>A5Rw9z1|z;bM#}-8wf(KTWBC1BOk`<&ihx#$Hz*) zNeZnh=6(Y3@nB`sijtZdu7iWalJ8+i7eWBeTHqs1zaFGH+Q_% z<50K5mtQ$i?)(-6Ld5#_7a)zZxT`BSBm`l}QSfqi+osh8Nj3gio3fzkavfXub&^jbeUsRM41PMLqS8s7Y>8Q8pmbmW1vKTfB(o=!NjaA z%AynitbVJmo+s`X3s@_YtD74uE9?4xX)cq5L~gc-SFQa#&wEbNb?0;d_HhLOu~$+C zfQ706(C}GZ?%%lOHm|punmuWqSB%p6c$p;=3kynKUV=LBT_UEeN~o0J0(9YdwYAAZ zLqmz}oW)!Hq{dqZ<<%v5c`&-eNm9l=Fk!T8Syh$QuVhBmugR$_Qp{vci=#2bY+B7@ zOey~?zqVsfS46W6!I9R=^s8!eoP;;&FWXrQXY;Y}CaiLabVit1QDPojYg^lVn->>n z+K0yu2LQ@b&4wbMsliIA_y?eTCJ|q-^_gtwz|tSd^9H^Pd=3F%v08Hl*Ee|4vM&MO z>9n3o+uTxcgg}avl=MIPA%)mqgeML0YveCq)q81^I4Gl{qAzSE7gJDsO!VJi>i_e9 zfnQM@_{s3U;p+blW`Bmy2r1;Gh zE1}4kz(X}F09{Z*-9L7Aii4dAetImhMD$=hN%Z*t5ug7gSp$4P0V&F<%2r96g#Hf_ CbaD>> literal 0 HcmV?d00001 diff --git a/resources/icons/printers/Foobar_M2.png b/resources/icons/printers/Foobar_M2.png new file mode 100644 index 0000000000000000000000000000000000000000..61a76a63d1d3b39f402aea981f7adc11e346b389 GIT binary patch literal 9323 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 CbaD>> literal 0 HcmV?d00001 diff --git a/resources/icons/printers/Foobar_M3.png b/resources/icons/printers/Foobar_M3.png new file mode 100644 index 0000000000000000000000000000000000000000..61a76a63d1d3b39f402aea981f7adc11e346b389 GIT binary patch literal 9323 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 CbaD>> literal 0 HcmV?d00001 diff --git a/resources/profiles/BarBaz.ini b/resources/profiles/BarBaz.ini new file mode 100644 index 0000000000..83bb156844 --- /dev/null +++ b/resources/profiles/BarBaz.ini @@ -0,0 +1,985 @@ +# Print profiles for the Prusa Research printers. + +[vendor] +# Vendor name will be shown by the Config Wizard. +name = Bar Baz +# Configuration version of this file. Config file will only be installed, if the config_version differs. +# This means, the server may force the Slic3r configuration to be downgraded. +config_version = 0.1 +# Where to get the updates from? +config_update_url = https://example.com + +# The printer models will be shown by the Configuration Wizard in this order, +# also the first model installed & the first nozzle installed will be activated after install. +#TODO: One day we may differentiate variants of the nozzles / hot ends, +#for example by the melt zone size, or whether the nozzle is hardened. +[printer_model:M1] +name = Bar Baz Model 1 +variants = 0.4; 0.25; 0.6 + +[printer_model:M2] +name = Bar Baz Model 2 +variants = 0.4; 0.25; 0.6 + +[printer_model:M3] +# Printer model name will be shown by the installation wizard. +name = Bar Baz Model 3 +variants = 0.4; 0.6 + +# All presets starting with asterisk, for example *common*, are intermediate and they will +# not make it into the user interface. + +# Common print preset, mostly derived from MK2 single material with a 0.4mm nozzle. +# All other print presets will derive from the *common* print preset. +[print:*common*] +avoid_crossing_perimeters = 0 +bridge_acceleration = 1000 +bridge_angle = 0 +bridge_flow_ratio = 0.8 +bridge_speed = 20 +brim_width = 0 +clip_multipart_objects = 1 +compatible_printers = +complete_objects = 0 +default_acceleration = 1000 +dont_support_bridges = 1 +elefant_foot_compensation = 0 +ensure_vertical_shell_thickness = 1 +external_fill_pattern = rectilinear +external_perimeters_first = 0 +external_perimeter_extrusion_width = 0.45 +extra_perimeters = 0 +extruder_clearance_height = 20 +extruder_clearance_radius = 20 +extrusion_width = 0.45 +fill_angle = 45 +fill_density = 20% +fill_pattern = cubic +first_layer_acceleration = 1000 +first_layer_extrusion_width = 0.42 +first_layer_height = 0.2 +first_layer_speed = 30 +gap_fill_speed = 40 +gcode_comments = 0 +infill_every_layers = 1 +infill_extruder = 1 +infill_extrusion_width = 0.45 +infill_first = 0 +infill_only_where_needed = 0 +infill_overlap = 25% +interface_shells = 0 +max_print_speed = 100 +max_volumetric_extrusion_rate_slope_negative = 0 +max_volumetric_extrusion_rate_slope_positive = 0 +max_volumetric_speed = 0 +min_skirt_length = 4 +notes = +overhangs = 0 +only_retract_when_crossing_perimeters = 0 +ooze_prevention = 0 +output_filename_format = [input_filename_base].gcode +perimeters = 2 +perimeter_extruder = 1 +perimeter_extrusion_width = 0.45 +post_process = +print_settings_id = +raft_layers = 0 +resolution = 0 +seam_position = nearest +skirts = 1 +skirt_distance = 2 +skirt_height = 3 +small_perimeter_speed = 20 +solid_infill_below_area = 0 +solid_infill_every_layers = 0 +solid_infill_extruder = 1 +solid_infill_extrusion_width = 0.45 +spiral_vase = 0 +standby_temperature_delta = -5 +support_material = 0 +support_material_extruder = 0 +support_material_extrusion_width = 0.35 +support_material_interface_extruder = 0 +support_material_angle = 0 +support_material_buildplate_only = 0 +support_material_enforce_layers = 0 +support_material_contact_distance = 0.15 +support_material_interface_contact_loops = 0 +support_material_interface_layers = 2 +support_material_interface_spacing = 0.2 +support_material_interface_speed = 100% +support_material_pattern = rectilinear +support_material_spacing = 2 +support_material_speed = 50 +support_material_synchronize_layers = 0 +support_material_threshold = 45 +support_material_with_sheath = 0 +support_material_xy_spacing = 60% +thin_walls = 0 +top_infill_extrusion_width = 0.45 +top_solid_infill_speed = 40 +travel_speed = 180 +wipe_tower = 0 +wipe_tower_per_color_wipe = 20 +wipe_tower_width = 60 +wipe_tower_x = 180 +wipe_tower_y = 140 +xy_size_compensation = 0 + +# Print parameters common to a 0.25mm diameter nozzle. +[print:*0.25nozzle*] +external_perimeter_extrusion_width = 0.25 +extrusion_width = 0.25 +first_layer_extrusion_width = 0.25 +infill_extrusion_width = 0.25 +perimeter_extrusion_width = 0.25 +solid_infill_extrusion_width = 0.25 +top_infill_extrusion_width = 0.25 +support_material_extrusion_width = 0.18 +support_material_interface_layers = 0 +support_material_interface_spacing = 0.15 +support_material_spacing = 1 +support_material_xy_spacing = 150% + +# Print parameters common to a 0.6mm diameter nozzle. +[print:*0.6nozzle*] +external_perimeter_extrusion_width = 0.61 +extrusion_width = 0.67 +first_layer_extrusion_width = 0.65 +infill_extrusion_width = 0.7 +perimeter_extrusion_width = 0.65 +solid_infill_extrusion_width = 0.65 +top_infill_extrusion_width = 0.6 + +[print:*soluble_support*] +overhangs = 1 +skirts = 0 +support_material = 1 +support_material_contact_distance = 0 +support_material_extruder = 4 +support_material_extrusion_width = 0.45 +support_material_interface_extruder = 4 +support_material_interface_spacing = 0.1 +support_material_synchronize_layers = 1 +support_material_threshold = 80 +support_material_with_sheath = 1 +wipe_tower = 1 + +[print:*0.05mm*] +inherits = *common* +bottom_solid_layers = 10 +bridge_acceleration = 300 +bridge_flow_ratio = 0.7 +default_acceleration = 500 +external_perimeter_speed = 20 +fill_density = 20% +first_layer_acceleration = 500 +gap_fill_speed = 20 +infill_acceleration = 800 +infill_speed = 30 +max_print_speed = 80 +small_perimeter_speed = 15 +solid_infill_speed = 30 +support_material_extrusion_width = 0.3 +support_material_spacing = 1.5 +layer_height = 0.05 +perimeter_acceleration = 300 +perimeter_speed = 30 +perimeters = 3 +support_material_speed = 30 +top_solid_infill_speed = 20 +top_solid_layers = 15 + +[print:0.05mm ULTRADETAIL] +inherits = *0.05mm* +infill_extrusion_width = 0.5 + +[print:0.05mm ULTRADETAIL MK3] +inherits = *0.05mm* +fill_pattern = grid +top_infill_extrusion_width = 0.4 + +[print:0.05mm ULTRADETAIL 0.25 nozzle] +inherits = *0.05mm* +external_perimeter_extrusion_width = 0 +extrusion_width = 0.28 +fill_density = 20% +first_layer_extrusion_width = 0.3 +infill_extrusion_width = 0 +infill_speed = 20 +max_print_speed = 100 +perimeter_extrusion_width = 0 +perimeter_speed = 20 +small_perimeter_speed = 10 +solid_infill_extrusion_width = 0 +solid_infill_speed = 20 +support_material_speed = 20 +top_infill_extrusion_width = 0 + +[print:0.05mm ULTRADETAIL 0.25 nozzle MK3] +inherits = *0.05mm*; *0.25nozzle* +fill_pattern = grid +top_infill_extrusion_width = 0.4 + +[print:*0.10mm*] +inherits = *common* +bottom_solid_layers = 7 +bridge_flow_ratio = 0.7 +layer_height = 0.1 +perimeter_acceleration = 800 +top_solid_layers = 9 + +[print:0.10mm DETAIL] +inherits = *0.10mm* +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +perimeter_speed = 50 +solid_infill_speed = 50 + +[print:0.10mm DETAIL MK3] +inherits = *0.10mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 200 +perimeter_speed = 45 +solid_infill_speed = 170 +top_infill_extrusion_width = 0.4 +top_solid_infill_speed = 50 + +[print:0.10mm DETAIL 0.25 nozzle] +inherits = *0.10mm* +bridge_acceleration = 600 +external_perimeter_speed = 20 +infill_acceleration = 1600 +infill_speed = 40 +perimeter_acceleration = 600 +perimeter_speed = 25 +small_perimeter_speed = 10 +solid_infill_speed = 40 +top_solid_infill_speed = 30 + +[print:0.10mm DETAIL 0.25 nozzle MK3] +inherits = *0.10mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 200 +perimeter_speed = 45 +solid_infill_speed = 170 +top_infill_extrusion_width = 0.4 +top_solid_infill_speed = 50 + +[print:0.10mm DETAIL 0.6 nozzle MK3] +inherits = *0.10mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 200 +perimeter_speed = 45 +solid_infill_speed = 170 +top_infill_extrusion_width = 0.4 +top_solid_infill_speed = 50 + +[print:*0.15mm*] +inherits = *common* +bottom_solid_layers = 5 +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +layer_height = 0.15 +perimeter_acceleration = 800 +perimeter_speed = 50 +solid_infill_speed = 50 +top_infill_extrusion_width = 0.4 +top_solid_layers = 7 + +[print:0.15mm 100mms Linear Advance] +inherits = *0.15mm* +bridge_flow_ratio = 0.95 +external_perimeter_speed = 50 +infill_speed = 100 +max_print_speed = 150 +perimeter_speed = 60 +small_perimeter_speed = 30 +solid_infill_speed = 100 +support_material_speed = 60 +top_solid_infill_speed = 70 + +[print:0.15mm OPTIMAL] +inherits = *0.15mm* +top_infill_extrusion_width = 0.45 + +[print:0.15mm OPTIMAL 0.25 nozzle] +inherits = *0.15mm*; *0.25nozzle* +bridge_acceleration = 600 +bridge_flow_ratio = 0.7 +external_perimeter_speed = 20 +infill_acceleration = 1600 +infill_speed = 40 +perimeter_acceleration = 600 +perimeter_speed = 25 +small_perimeter_speed = 10 +solid_infill_speed = 40 +support_material_extrusion_width = 0.2 +top_solid_infill_speed = 30 + +[print:0.15mm OPTIMAL 0.6 nozzle] +inherits = *0.15mm*; *0.6nozzle* + +[print:0.15mm OPTIMAL MK3] +inherits = *0.15mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:0.15mm OPTIMAL SOLUBLE FULL] +inherits = *0.15mm*; *soluble_support* +external_perimeter_speed = 25 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder +perimeter_speed = 40 +solid_infill_speed = 40 +top_infill_extrusion_width = 0.45 +top_solid_infill_speed = 30 +wipe_tower = 1 + +[print:0.15mm OPTIMAL SOLUBLE INTERFACE] +inherits = 0.15mm OPTIMAL SOLUBLE FULL +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +support_material_extruder = 0 +support_material_interface_layers = 3 +support_material_with_sheath = 0 +support_material_xy_spacing = 80% + +[print:0.15mm OPTIMAL 0.25 nozzle MK3] +inherits = *0.15mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 +[print:*0.20mm*] +inherits = *common* +bottom_solid_layers = 4 +bridge_flow_ratio = 0.95 +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +layer_height = 0.2 +perimeter_acceleration = 800 +perimeter_speed = 50 +solid_infill_speed = 50 +top_infill_extrusion_width = 0.4 +top_solid_layers = 5 + +[print:0.15mm OPTIMAL 0.6 nozzle MK3] +inherits = *0.15mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:0.20mm 100mms Linear Advance] +inherits = *0.20mm* +external_perimeter_speed = 50 +infill_speed = 100 +max_print_speed = 150 +perimeter_speed = 60 +small_perimeter_speed = 30 +solid_infill_speed = 100 +support_material_speed = 60 +top_solid_infill_speed = 70 + +[print:0.20mm FAST MK3] +inherits = *0.20mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:0.20mm NORMAL] +inherits = *0.20mm* + +[print:0.20mm NORMAL 0.6 nozzle] +inherits = *0.20mm*; *0.6nozzle* + +[print:0.20mm NORMAL SOLUBLE FULL] +inherits = *0.20mm*; *soluble_support* +external_perimeter_speed = 30 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder +perimeter_speed = 40 +solid_infill_speed = 40 +top_solid_infill_speed = 30 + +[print:0.20mm NORMAL SOLUBLE INTERFACE] +inherits = 0.20mm NORMAL SOLUBLE FULL +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +support_material_extruder = 0 +support_material_interface_layers = 3 +support_material_with_sheath = 0 +support_material_xy_spacing = 80% + +[print:0.20mm FAST 0.6 nozzle MK3] +inherits = *0.20mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:*0.35mm*] +inherits = *common* +bottom_solid_layers = 3 +external_perimeter_extrusion_width = 0.6 +external_perimeter_speed = 40 +first_layer_extrusion_width = 0.75 +infill_acceleration = 2000 +infill_speed = 60 +layer_height = 0.35 +perimeter_acceleration = 800 +perimeter_extrusion_width = 0.65 +perimeter_speed = 50 +solid_infill_extrusion_width = 0.65 +solid_infill_speed = 60 +top_solid_infill_speed = 50 +top_solid_layers = 4 + +[print:0.35mm FAST] +inherits = *0.35mm* +bridge_flow_ratio = 0.95 +first_layer_extrusion_width = 0.42 +perimeter_extrusion_width = 0.43 +solid_infill_extrusion_width = 0.7 +top_infill_extrusion_width = 0.43 + +[print:0.35mm FAST 0.6 nozzle] +inherits = *0.35mm*; *0.6nozzle* + +[print:0.35mm FAST sol full 0.6 nozzle] +inherits = *0.35mm*; *0.6nozzle*; *soluble_support* +external_perimeter_extrusion_width = 0.6 +external_perimeter_speed = 30 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +perimeter_speed = 40 +support_material_extrusion_width = 0.55 +support_material_interface_layers = 3 +support_material_xy_spacing = 120% +top_infill_extrusion_width = 0.57 + +[print:0.35mm FAST sol int 0.6 nozzle] +inherits = 0.35mm FAST sol full 0.6 nozzle +support_material_extruder = 0 +support_material_interface_layers = 2 +support_material_with_sheath = 0 +support_material_xy_spacing = 150% + +[filament:*common*] +cooling = 1 +compatible_printers = +end_filament_gcode = "; Filament-specific end gcode" +extrusion_multiplier = 1 +filament_cost = 0 +filament_density = 0 +filament_diameter = 1.75 +filament_notes = "" +filament_settings_id = +filament_soluble = 0 +min_print_speed = 5 +slowdown_below_layer_time = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" + +[filament:*PLA*] +inherits = *common* +bed_temperature = 60 +bridge_fan_speed = 100 +disable_fan_first_layers = 1 +fan_always_on = 1 +fan_below_layer_time = 100 +filament_colour = #FF3232 +filament_max_volumetric_speed = 15 +filament_type = PLA +first_layer_bed_temperature = 60 +first_layer_temperature = 215 +max_fan_speed = 100 +min_fan_speed = 100 +temperature = 210 + +[filament:*PET*] +inherits = *common* +bed_temperature = 90 +bridge_fan_speed = 50 +disable_fan_first_layers = 3 +fan_always_on = 1 +fan_below_layer_time = 20 +filament_colour = #FF8000 +filament_max_volumetric_speed = 8 +filament_type = PET +first_layer_bed_temperature = 85 +first_layer_temperature = 230 +max_fan_speed = 50 +min_fan_speed = 30 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" +temperature = 240 + +[filament:*ABS*] +inherits = *common* +bed_temperature = 110 +bridge_fan_speed = 30 +cooling = 0 +disable_fan_first_layers = 3 +fan_always_on = 0 +fan_below_layer_time = 20 +filament_colour = #3A80CA +filament_max_volumetric_speed = 11 +filament_type = ABS +first_layer_bed_temperature = 100 +first_layer_temperature = 255 +max_fan_speed = 30 +min_fan_speed = 20 +temperature = 255 + +[filament:*FLEX*] +inherits = *common* +bridge_fan_speed = 100 +cooling = 0 +disable_fan_first_layers = 1 +extrusion_multiplier = 1.2 +fan_always_on = 0 +fan_below_layer_time = 100 +filament_colour = #00CA0A +filament_max_volumetric_speed = 1.5 +filament_type = FLEX +first_layer_bed_temperature = 50 +first_layer_temperature = 240 +max_fan_speed = 90 +min_fan_speed = 70 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 240 + +[filament:ColorFabb Brass Bronze] +inherits = *PLA* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 10 + +[filament:ColorFabb HT] +inherits = *PET* +bed_temperature = 110 +bridge_fan_speed = 30 +cooling = 1 +disable_fan_first_layers = 3 +fan_always_on = 0 +fan_below_layer_time = 10 +first_layer_bed_temperature = 105 +first_layer_temperature = 270 +max_fan_speed = 20 +min_fan_speed = 10 +min_print_speed = 5 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" +temperature = 270 + +[filament:ColorFabb PLA-PHA] +inherits = *PLA* + +[filament:ColorFabb Woodfil] +inherits = *PLA* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 10 +first_layer_temperature = 200 +min_print_speed = 5 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 200 + +[filament:ColorFabb XT] +inherits = *PET* +filament_type = PLA +first_layer_bed_temperature = 90 +first_layer_temperature = 260 +temperature = 270 + +[filament:ColorFabb XT-CF20] +inherits = *PET* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 1 +first_layer_bed_temperature = 90 +first_layer_temperature = 260 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" +temperature = 260 + +[filament:ColorFabb nGen] +inherits = *PET* +bridge_fan_speed = 40 +fan_always_on = 0 +fan_below_layer_time = 10 +filament_type = NGEN +first_layer_temperature = 240 +max_fan_speed = 35 +min_fan_speed = 20 + +[filament:ColorFabb nGen flex] +inherits = *FLEX* +bed_temperature = 85 +bridge_fan_speed = 40 +cooling = 1 +disable_fan_first_layers = 3 +extrusion_multiplier = 1 +fan_below_layer_time = 10 +filament_max_volumetric_speed = 5 +first_layer_bed_temperature = 85 +first_layer_temperature = 260 +max_fan_speed = 35 +min_fan_speed = 20 +temperature = 260 + +[filament:E3D Edge] +inherits = *PET* +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:E3D PC-ABS] +inherits = *ABS* +first_layer_temperature = 270 +temperature = 270 + +[filament:Fillamentum ABS] +inherits = *ABS* +first_layer_temperature = 240 +temperature = 240 + +[filament:Fillamentum ASA] +inherits = *ABS* +fan_always_on = 1 +first_layer_temperature = 265 +temperature = 265 + +[filament:Fillamentum CPE HG100 HM100] +inherits = *PET* +filament_notes = "CPE HG100 , CPE HM100" +first_layer_bed_temperature = 90 +first_layer_temperature = 275 +max_fan_speed = 50 +min_fan_speed = 50 +temperature = 275 + +[filament:Fillamentum Timberfil] +inherits = *PLA* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 10 +first_layer_temperature = 190 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 190 + +[filament:Generic ABS] +inherits = *ABS* +filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" + +[filament:Generic PET] +inherits = *PET* +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:Generic PLA] +inherits = *PLA* +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" + +[filament:Polymaker PC-Max] +inherits = *ABS* +bed_temperature = 115 +filament_colour = #3A80CA +first_layer_bed_temperature = 100 +first_layer_temperature = 270 +temperature = 270 + +[filament:Primavalue PVA] +inherits = *PLA* +cooling = 0 +fan_always_on = 0 +filament_colour = #FFFFD7 +filament_max_volumetric_speed = 10 +filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH" +filament_soluble = 1 +filament_type = PVA +first_layer_temperature = 195 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 195 + +[filament:Prusa ABS] +inherits = *ABS* +filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" + +[filament:Prusa HIPS] +inherits = *ABS* +bridge_fan_speed = 50 +cooling = 1 +extrusion_multiplier = 0.9 +fan_always_on = 1 +fan_below_layer_time = 10 +filament_colour = #FFFFD7 +filament_soluble = 1 +filament_type = HIPS +first_layer_temperature = 220 +max_fan_speed = 20 +min_fan_speed = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 220 + +[filament:Prusa PET] +inherits = *PET* +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:Prusa PLA] +inherits = *PLA* +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" + +[filament:SemiFlex or Flexfill 98A] +inherits = *FLEX* + +[filament:Taulman Bridge] +inherits = *common* +bed_temperature = 90 +bridge_fan_speed = 40 +cooling = 0 +disable_fan_first_layers = 3 +fan_always_on = 0 +fan_below_layer_time = 20 +filament_colour = #DEE0E6 +filament_max_volumetric_speed = 10 +filament_soluble = 0 +filament_type = PET +first_layer_bed_temperature = 60 +first_layer_temperature = 240 +max_fan_speed = 5 +min_fan_speed = 0 +min_print_speed = 5 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 250 + +[filament:Taulman T-Glase] +inherits = *PET* +bridge_fan_speed = 40 +cooling = 0 +fan_always_on = 0 +first_layer_bed_temperature = 90 +first_layer_temperature = 240 +max_fan_speed = 5 +min_fan_speed = 0 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" + +[filament:Verbatim BVOH] +inherits = *common* +bed_temperature = 60 +bridge_fan_speed = 100 +cooling = 0 +disable_fan_first_layers = 1 +extrusion_multiplier = 1 +fan_always_on = 0 +fan_below_layer_time = 100 +filament_colour = #FFFFD7 +filament_max_volumetric_speed = 10 +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" +filament_soluble = 1 +filament_type = PLA +first_layer_bed_temperature = 60 +first_layer_temperature = 215 +max_fan_speed = 100 +min_fan_speed = 100 +min_print_speed = 15 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 210 + +[filament:Verbatim PP] +inherits = *common* +bed_temperature = 100 +bridge_fan_speed = 100 +cooling = 1 +disable_fan_first_layers = 2 +extrusion_multiplier = 1 +fan_always_on = 1 +fan_below_layer_time = 100 +filament_colour = #DEE0E6 +filament_max_volumetric_speed = 5 +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA" +filament_type = PLA +first_layer_bed_temperature = 100 +first_layer_temperature = 220 +max_fan_speed = 100 +min_fan_speed = 100 +min_print_speed = 15 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 220 + +[printer:*common*] +bed_shape = 0x0,250x0,250x210,0x210 +before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n +between_objects_gcode = +deretract_speed = 0 +end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +extruder_colour = #FFFF00 +extruder_offset = 0x0 +gcode_flavor = marlin +layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] +max_layer_height = 0.25 +min_layer_height = 0.07 +nozzle_diameter = 0.4 +octoprint_apikey = +octoprint_host = +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n +printer_settings_id = +retract_before_travel = 1 +retract_before_wipe = 0% +retract_layer_change = 1 +retract_length = 0.8 +retract_length_toolchange = 4 +retract_lift = 0.6 +retract_lift_above = 0 +retract_lift_below = 199 +retract_restart_extra = 0 +retract_restart_extra_toolchange = 0 +retract_speed = 35 +serial_port = +serial_speed = 250000 +single_extruder_multi_material = 0 +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0 +toolchange_gcode = +use_firmware_retraction = 0 +use_relative_e_distances = 1 +use_volumetric_e = 0 +variable_layer_height = 1 +wipe = 1 +z_offset = 0 +printer_model = M2 +printer_variant = 0.4 +default_print_profile = 0.15mm OPTIMAL +default_filament_profile = Prusa PLA + +[printer:*multimaterial*] +inherits = *common* +deretract_speed = 50 +retract_before_travel = 3 +retract_before_wipe = 60% +retract_layer_change = 0 +retract_length = 4 +retract_lift = 0.6 +retract_lift_above = 0 +retract_lift_below = 199 +retract_restart_extra = 0 +retract_restart_extra_toolchange = 0 +retract_speed = 80 +single_extruder_multi_material = 1 +printer_model = M3 + +[printer:*mm-single*] +inherits = *multimaterial* +end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 + +[printer:*mm-multi*] +inherits = *multimaterial* +end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors +extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259 +nozzle_diameter = 0.4,0.4,0.4,0.4 +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 +variable_layer_height = 0 + +[printer:Original Prusa i3 MK2] +inherits = *common* + +[printer:Original Prusa i3 MK2 0.25 nozzle] +inherits = *common* +max_layer_height = 0.1 +min_layer_height = 0.05 +nozzle_diameter = 0.25 +retract_length = 1 +retract_speed = 50 +variable_layer_height = 0 +printer_variant = 0.25 +default_print_profile = 0.10mm DETAIL 0.25 nozzle + +[printer:Original Prusa i3 MK2 0.6 nozzle] +inherits = *common* +max_layer_height = 0.35 +min_layer_height = 0.1 +nozzle_diameter = 0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK2 MM Single Mode] +inherits = *mm-single* + +[printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle] +inherits = *mm-single* +nozzle_diameter = 0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK2 MultiMaterial] +inherits = *mm-multi* +nozzle_diameter = 0.4,0.4,0.4,0.4 + +[printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle] +inherits = *mm-multi* +nozzle_diameter = 0.6,0.6,0.6,0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK3] +inherits = *common* +end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +retract_lift_below = 209 +start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} +printer_model = M1 +default_print_profile = 0.15mm OPTIMAL MK3 + +[printer:Original Prusa i3 MK3 0.25 nozzle] +inherits = *common* +nozzle_diameter = 0.25 +printer_variant = 0.25 +end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +retract_lift_below = 209 +start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} +printer_model = M1 +default_print_profile = 0.10mm DETAIL MK3 + +[printer:Original Prusa i3 MK3 0.6 nozzle] +inherits = *common* +nozzle_diameter = 0.6 +printer_variant = 0.6 +end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +retract_lift_below = 209 +start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} +printer_model = M1 +default_print_profile = 0.15mm OPTIMAL MK3 diff --git a/resources/profiles/Foobar.ini b/resources/profiles/Foobar.ini new file mode 100644 index 0000000000..21681398aa --- /dev/null +++ b/resources/profiles/Foobar.ini @@ -0,0 +1,985 @@ +# Print profiles for the Prusa Research printers. + +[vendor] +# Vendor name will be shown by the Config Wizard. +name = Foo Bar +# Configuration version of this file. Config file will only be installed, if the config_version differs. +# This means, the server may force the Slic3r configuration to be downgraded. +config_version = 0.1 +# Where to get the updates from? +config_update_url = https://example.com + +# The printer models will be shown by the Configuration Wizard in this order, +# also the first model installed & the first nozzle installed will be activated after install. +#TODO: One day we may differentiate variants of the nozzles / hot ends, +#for example by the melt zone size, or whether the nozzle is hardened. +[printer_model:M1] +name = Foo Bar Model 1 +variants = 0.4; 0.25; 0.6 + +[printer_model:M2] +name = Foo Bar Model 2 +variants = 0.4; 0.25; 0.6 + +[printer_model:M3] +# Printer model name will be shown by the installation wizard. +name = Foo Bar Model 3 +variants = 0.4; 0.6 + +# All presets starting with asterisk, for example *common*, are intermediate and they will +# not make it into the user interface. + +# Common print preset, mostly derived from MK2 single material with a 0.4mm nozzle. +# All other print presets will derive from the *common* print preset. +[print:*common*] +avoid_crossing_perimeters = 0 +bridge_acceleration = 1000 +bridge_angle = 0 +bridge_flow_ratio = 0.8 +bridge_speed = 20 +brim_width = 0 +clip_multipart_objects = 1 +compatible_printers = +complete_objects = 0 +default_acceleration = 1000 +dont_support_bridges = 1 +elefant_foot_compensation = 0 +ensure_vertical_shell_thickness = 1 +external_fill_pattern = rectilinear +external_perimeters_first = 0 +external_perimeter_extrusion_width = 0.45 +extra_perimeters = 0 +extruder_clearance_height = 20 +extruder_clearance_radius = 20 +extrusion_width = 0.45 +fill_angle = 45 +fill_density = 20% +fill_pattern = cubic +first_layer_acceleration = 1000 +first_layer_extrusion_width = 0.42 +first_layer_height = 0.2 +first_layer_speed = 30 +gap_fill_speed = 40 +gcode_comments = 0 +infill_every_layers = 1 +infill_extruder = 1 +infill_extrusion_width = 0.45 +infill_first = 0 +infill_only_where_needed = 0 +infill_overlap = 25% +interface_shells = 0 +max_print_speed = 100 +max_volumetric_extrusion_rate_slope_negative = 0 +max_volumetric_extrusion_rate_slope_positive = 0 +max_volumetric_speed = 0 +min_skirt_length = 4 +notes = +overhangs = 0 +only_retract_when_crossing_perimeters = 0 +ooze_prevention = 0 +output_filename_format = [input_filename_base].gcode +perimeters = 2 +perimeter_extruder = 1 +perimeter_extrusion_width = 0.45 +post_process = +print_settings_id = +raft_layers = 0 +resolution = 0 +seam_position = nearest +skirts = 1 +skirt_distance = 2 +skirt_height = 3 +small_perimeter_speed = 20 +solid_infill_below_area = 0 +solid_infill_every_layers = 0 +solid_infill_extruder = 1 +solid_infill_extrusion_width = 0.45 +spiral_vase = 0 +standby_temperature_delta = -5 +support_material = 0 +support_material_extruder = 0 +support_material_extrusion_width = 0.35 +support_material_interface_extruder = 0 +support_material_angle = 0 +support_material_buildplate_only = 0 +support_material_enforce_layers = 0 +support_material_contact_distance = 0.15 +support_material_interface_contact_loops = 0 +support_material_interface_layers = 2 +support_material_interface_spacing = 0.2 +support_material_interface_speed = 100% +support_material_pattern = rectilinear +support_material_spacing = 2 +support_material_speed = 50 +support_material_synchronize_layers = 0 +support_material_threshold = 45 +support_material_with_sheath = 0 +support_material_xy_spacing = 60% +thin_walls = 0 +top_infill_extrusion_width = 0.45 +top_solid_infill_speed = 40 +travel_speed = 180 +wipe_tower = 0 +wipe_tower_per_color_wipe = 20 +wipe_tower_width = 60 +wipe_tower_x = 180 +wipe_tower_y = 140 +xy_size_compensation = 0 + +# Print parameters common to a 0.25mm diameter nozzle. +[print:*0.25nozzle*] +external_perimeter_extrusion_width = 0.25 +extrusion_width = 0.25 +first_layer_extrusion_width = 0.25 +infill_extrusion_width = 0.25 +perimeter_extrusion_width = 0.25 +solid_infill_extrusion_width = 0.25 +top_infill_extrusion_width = 0.25 +support_material_extrusion_width = 0.18 +support_material_interface_layers = 0 +support_material_interface_spacing = 0.15 +support_material_spacing = 1 +support_material_xy_spacing = 150% + +# Print parameters common to a 0.6mm diameter nozzle. +[print:*0.6nozzle*] +external_perimeter_extrusion_width = 0.61 +extrusion_width = 0.67 +first_layer_extrusion_width = 0.65 +infill_extrusion_width = 0.7 +perimeter_extrusion_width = 0.65 +solid_infill_extrusion_width = 0.65 +top_infill_extrusion_width = 0.6 + +[print:*soluble_support*] +overhangs = 1 +skirts = 0 +support_material = 1 +support_material_contact_distance = 0 +support_material_extruder = 4 +support_material_extrusion_width = 0.45 +support_material_interface_extruder = 4 +support_material_interface_spacing = 0.1 +support_material_synchronize_layers = 1 +support_material_threshold = 80 +support_material_with_sheath = 1 +wipe_tower = 1 + +[print:*0.05mm*] +inherits = *common* +bottom_solid_layers = 10 +bridge_acceleration = 300 +bridge_flow_ratio = 0.7 +default_acceleration = 500 +external_perimeter_speed = 20 +fill_density = 20% +first_layer_acceleration = 500 +gap_fill_speed = 20 +infill_acceleration = 800 +infill_speed = 30 +max_print_speed = 80 +small_perimeter_speed = 15 +solid_infill_speed = 30 +support_material_extrusion_width = 0.3 +support_material_spacing = 1.5 +layer_height = 0.05 +perimeter_acceleration = 300 +perimeter_speed = 30 +perimeters = 3 +support_material_speed = 30 +top_solid_infill_speed = 20 +top_solid_layers = 15 + +[print:0.05mm ULTRADETAIL] +inherits = *0.05mm* +infill_extrusion_width = 0.5 + +[print:0.05mm ULTRADETAIL MK3] +inherits = *0.05mm* +fill_pattern = grid +top_infill_extrusion_width = 0.4 + +[print:0.05mm ULTRADETAIL 0.25 nozzle] +inherits = *0.05mm* +external_perimeter_extrusion_width = 0 +extrusion_width = 0.28 +fill_density = 20% +first_layer_extrusion_width = 0.3 +infill_extrusion_width = 0 +infill_speed = 20 +max_print_speed = 100 +perimeter_extrusion_width = 0 +perimeter_speed = 20 +small_perimeter_speed = 10 +solid_infill_extrusion_width = 0 +solid_infill_speed = 20 +support_material_speed = 20 +top_infill_extrusion_width = 0 + +[print:0.05mm ULTRADETAIL 0.25 nozzle MK3] +inherits = *0.05mm*; *0.25nozzle* +fill_pattern = grid +top_infill_extrusion_width = 0.4 + +[print:*0.10mm*] +inherits = *common* +bottom_solid_layers = 7 +bridge_flow_ratio = 0.7 +layer_height = 0.1 +perimeter_acceleration = 800 +top_solid_layers = 9 + +[print:0.10mm DETAIL] +inherits = *0.10mm* +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +perimeter_speed = 50 +solid_infill_speed = 50 + +[print:0.10mm DETAIL MK3] +inherits = *0.10mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 200 +perimeter_speed = 45 +solid_infill_speed = 170 +top_infill_extrusion_width = 0.4 +top_solid_infill_speed = 50 + +[print:0.10mm DETAIL 0.25 nozzle] +inherits = *0.10mm* +bridge_acceleration = 600 +external_perimeter_speed = 20 +infill_acceleration = 1600 +infill_speed = 40 +perimeter_acceleration = 600 +perimeter_speed = 25 +small_perimeter_speed = 10 +solid_infill_speed = 40 +top_solid_infill_speed = 30 + +[print:0.10mm DETAIL 0.25 nozzle MK3] +inherits = *0.10mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 200 +perimeter_speed = 45 +solid_infill_speed = 170 +top_infill_extrusion_width = 0.4 +top_solid_infill_speed = 50 + +[print:0.10mm DETAIL 0.6 nozzle MK3] +inherits = *0.10mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 200 +perimeter_speed = 45 +solid_infill_speed = 170 +top_infill_extrusion_width = 0.4 +top_solid_infill_speed = 50 + +[print:*0.15mm*] +inherits = *common* +bottom_solid_layers = 5 +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +layer_height = 0.15 +perimeter_acceleration = 800 +perimeter_speed = 50 +solid_infill_speed = 50 +top_infill_extrusion_width = 0.4 +top_solid_layers = 7 + +[print:0.15mm 100mms Linear Advance] +inherits = *0.15mm* +bridge_flow_ratio = 0.95 +external_perimeter_speed = 50 +infill_speed = 100 +max_print_speed = 150 +perimeter_speed = 60 +small_perimeter_speed = 30 +solid_infill_speed = 100 +support_material_speed = 60 +top_solid_infill_speed = 70 + +[print:0.15mm OPTIMAL] +inherits = *0.15mm* +top_infill_extrusion_width = 0.45 + +[print:0.15mm OPTIMAL 0.25 nozzle] +inherits = *0.15mm*; *0.25nozzle* +bridge_acceleration = 600 +bridge_flow_ratio = 0.7 +external_perimeter_speed = 20 +infill_acceleration = 1600 +infill_speed = 40 +perimeter_acceleration = 600 +perimeter_speed = 25 +small_perimeter_speed = 10 +solid_infill_speed = 40 +support_material_extrusion_width = 0.2 +top_solid_infill_speed = 30 + +[print:0.15mm OPTIMAL 0.6 nozzle] +inherits = *0.15mm*; *0.6nozzle* + +[print:0.15mm OPTIMAL MK3] +inherits = *0.15mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:0.15mm OPTIMAL SOLUBLE FULL] +inherits = *0.15mm*; *soluble_support* +external_perimeter_speed = 25 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder +perimeter_speed = 40 +solid_infill_speed = 40 +top_infill_extrusion_width = 0.45 +top_solid_infill_speed = 30 +wipe_tower = 1 + +[print:0.15mm OPTIMAL SOLUBLE INTERFACE] +inherits = 0.15mm OPTIMAL SOLUBLE FULL +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +support_material_extruder = 0 +support_material_interface_layers = 3 +support_material_with_sheath = 0 +support_material_xy_spacing = 80% + +[print:0.15mm OPTIMAL 0.25 nozzle MK3] +inherits = *0.15mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 +[print:*0.20mm*] +inherits = *common* +bottom_solid_layers = 4 +bridge_flow_ratio = 0.95 +external_perimeter_speed = 40 +infill_acceleration = 2000 +infill_speed = 60 +layer_height = 0.2 +perimeter_acceleration = 800 +perimeter_speed = 50 +solid_infill_speed = 50 +top_infill_extrusion_width = 0.4 +top_solid_layers = 5 + +[print:0.15mm OPTIMAL 0.6 nozzle MK3] +inherits = *0.15mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:0.20mm 100mms Linear Advance] +inherits = *0.20mm* +external_perimeter_speed = 50 +infill_speed = 100 +max_print_speed = 150 +perimeter_speed = 60 +small_perimeter_speed = 30 +solid_infill_speed = 100 +support_material_speed = 60 +top_solid_infill_speed = 70 + +[print:0.20mm FAST MK3] +inherits = *0.20mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:0.20mm NORMAL] +inherits = *0.20mm* + +[print:0.20mm NORMAL 0.6 nozzle] +inherits = *0.20mm*; *0.6nozzle* + +[print:0.20mm NORMAL SOLUBLE FULL] +inherits = *0.20mm*; *soluble_support* +external_perimeter_speed = 30 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder & Support material/raft interface extruder +perimeter_speed = 40 +solid_infill_speed = 40 +top_solid_infill_speed = 30 + +[print:0.20mm NORMAL SOLUBLE INTERFACE] +inherits = 0.20mm NORMAL SOLUBLE FULL +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +support_material_extruder = 0 +support_material_interface_layers = 3 +support_material_with_sheath = 0 +support_material_xy_spacing = 80% + +[print:0.20mm FAST 0.6 nozzle MK3] +inherits = *0.20mm* +bridge_speed = 30 +external_perimeter_speed = 35 +fill_pattern = grid +infill_acceleration = 1500 +infill_speed = 170 +max_print_speed = 170 +perimeter_speed = 45 +solid_infill_speed = 170 +top_solid_infill_speed = 50 + +[print:*0.35mm*] +inherits = *common* +bottom_solid_layers = 3 +external_perimeter_extrusion_width = 0.6 +external_perimeter_speed = 40 +first_layer_extrusion_width = 0.75 +infill_acceleration = 2000 +infill_speed = 60 +layer_height = 0.35 +perimeter_acceleration = 800 +perimeter_extrusion_width = 0.65 +perimeter_speed = 50 +solid_infill_extrusion_width = 0.65 +solid_infill_speed = 60 +top_solid_infill_speed = 50 +top_solid_layers = 4 + +[print:0.35mm FAST] +inherits = *0.35mm* +bridge_flow_ratio = 0.95 +first_layer_extrusion_width = 0.42 +perimeter_extrusion_width = 0.43 +solid_infill_extrusion_width = 0.7 +top_infill_extrusion_width = 0.43 + +[print:0.35mm FAST 0.6 nozzle] +inherits = *0.35mm*; *0.6nozzle* + +[print:0.35mm FAST sol full 0.6 nozzle] +inherits = *0.35mm*; *0.6nozzle*; *soluble_support* +external_perimeter_extrusion_width = 0.6 +external_perimeter_speed = 30 +notes = Set your solluble extruder in Multiple Extruders > Support material/raft interface extruder +perimeter_speed = 40 +support_material_extrusion_width = 0.55 +support_material_interface_layers = 3 +support_material_xy_spacing = 120% +top_infill_extrusion_width = 0.57 + +[print:0.35mm FAST sol int 0.6 nozzle] +inherits = 0.35mm FAST sol full 0.6 nozzle +support_material_extruder = 0 +support_material_interface_layers = 2 +support_material_with_sheath = 0 +support_material_xy_spacing = 150% + +[filament:*common*] +cooling = 1 +compatible_printers = +end_filament_gcode = "; Filament-specific end gcode" +extrusion_multiplier = 1 +filament_cost = 0 +filament_density = 0 +filament_diameter = 1.75 +filament_notes = "" +filament_settings_id = +filament_soluble = 0 +min_print_speed = 5 +slowdown_below_layer_time = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" + +[filament:*PLA*] +inherits = *common* +bed_temperature = 60 +bridge_fan_speed = 100 +disable_fan_first_layers = 1 +fan_always_on = 1 +fan_below_layer_time = 100 +filament_colour = #FF3232 +filament_max_volumetric_speed = 15 +filament_type = PLA +first_layer_bed_temperature = 60 +first_layer_temperature = 215 +max_fan_speed = 100 +min_fan_speed = 100 +temperature = 210 + +[filament:*PET*] +inherits = *common* +bed_temperature = 90 +bridge_fan_speed = 50 +disable_fan_first_layers = 3 +fan_always_on = 1 +fan_below_layer_time = 20 +filament_colour = #FF8000 +filament_max_volumetric_speed = 8 +filament_type = PET +first_layer_bed_temperature = 85 +first_layer_temperature = 230 +max_fan_speed = 50 +min_fan_speed = 30 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" +temperature = 240 + +[filament:*ABS*] +inherits = *common* +bed_temperature = 110 +bridge_fan_speed = 30 +cooling = 0 +disable_fan_first_layers = 3 +fan_always_on = 0 +fan_below_layer_time = 20 +filament_colour = #3A80CA +filament_max_volumetric_speed = 11 +filament_type = ABS +first_layer_bed_temperature = 100 +first_layer_temperature = 255 +max_fan_speed = 30 +min_fan_speed = 20 +temperature = 255 + +[filament:*FLEX*] +inherits = *common* +bridge_fan_speed = 100 +cooling = 0 +disable_fan_first_layers = 1 +extrusion_multiplier = 1.2 +fan_always_on = 0 +fan_below_layer_time = 100 +filament_colour = #00CA0A +filament_max_volumetric_speed = 1.5 +filament_type = FLEX +first_layer_bed_temperature = 50 +first_layer_temperature = 240 +max_fan_speed = 90 +min_fan_speed = 70 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 240 + +[filament:ColorFabb Brass Bronze] +inherits = *PLA* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 10 + +[filament:ColorFabb HT] +inherits = *PET* +bed_temperature = 110 +bridge_fan_speed = 30 +cooling = 1 +disable_fan_first_layers = 3 +fan_always_on = 0 +fan_below_layer_time = 10 +first_layer_bed_temperature = 105 +first_layer_temperature = 270 +max_fan_speed = 20 +min_fan_speed = 10 +min_print_speed = 5 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" +temperature = 270 + +[filament:ColorFabb PLA-PHA] +inherits = *PLA* + +[filament:ColorFabb Woodfil] +inherits = *PLA* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 10 +first_layer_temperature = 200 +min_print_speed = 5 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 200 + +[filament:ColorFabb XT] +inherits = *PET* +filament_type = PLA +first_layer_bed_temperature = 90 +first_layer_temperature = 260 +temperature = 270 + +[filament:ColorFabb XT-CF20] +inherits = *PET* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 1 +first_layer_bed_temperature = 90 +first_layer_temperature = 260 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" +temperature = 260 + +[filament:ColorFabb nGen] +inherits = *PET* +bridge_fan_speed = 40 +fan_always_on = 0 +fan_below_layer_time = 10 +filament_type = NGEN +first_layer_temperature = 240 +max_fan_speed = 35 +min_fan_speed = 20 + +[filament:ColorFabb nGen flex] +inherits = *FLEX* +bed_temperature = 85 +bridge_fan_speed = 40 +cooling = 1 +disable_fan_first_layers = 3 +extrusion_multiplier = 1 +fan_below_layer_time = 10 +filament_max_volumetric_speed = 5 +first_layer_bed_temperature = 85 +first_layer_temperature = 260 +max_fan_speed = 35 +min_fan_speed = 20 +temperature = 260 + +[filament:E3D Edge] +inherits = *PET* +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:E3D PC-ABS] +inherits = *ABS* +first_layer_temperature = 270 +temperature = 270 + +[filament:Fillamentum ABS] +inherits = *ABS* +first_layer_temperature = 240 +temperature = 240 + +[filament:Fillamentum ASA] +inherits = *ABS* +fan_always_on = 1 +first_layer_temperature = 265 +temperature = 265 + +[filament:Fillamentum CPE HG100 HM100] +inherits = *PET* +filament_notes = "CPE HG100 , CPE HM100" +first_layer_bed_temperature = 90 +first_layer_temperature = 275 +max_fan_speed = 50 +min_fan_speed = 50 +temperature = 275 + +[filament:Fillamentum Timberfil] +inherits = *PLA* +extrusion_multiplier = 1.2 +filament_colour = #804040 +filament_max_volumetric_speed = 10 +first_layer_temperature = 190 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 190 + +[filament:Generic ABS] +inherits = *ABS* +filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" + +[filament:Generic PET] +inherits = *PET* +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:Generic PLA] +inherits = *PLA* +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" + +[filament:Polymaker PC-Max] +inherits = *ABS* +bed_temperature = 115 +filament_colour = #3A80CA +first_layer_bed_temperature = 100 +first_layer_temperature = 270 +temperature = 270 + +[filament:Primavalue PVA] +inherits = *PLA* +cooling = 0 +fan_always_on = 0 +filament_colour = #FFFFD7 +filament_max_volumetric_speed = 10 +filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH" +filament_soluble = 1 +filament_type = PVA +first_layer_temperature = 195 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 195 + +[filament:Prusa ABS] +inherits = *ABS* +filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" + +[filament:Prusa HIPS] +inherits = *ABS* +bridge_fan_speed = 50 +cooling = 1 +extrusion_multiplier = 0.9 +fan_always_on = 1 +fan_below_layer_time = 10 +filament_colour = #FFFFD7 +filament_soluble = 1 +filament_type = HIPS +first_layer_temperature = 220 +max_fan_speed = 20 +min_fan_speed = 20 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 220 + +[filament:Prusa PET] +inherits = *PET* +filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" + +[filament:Prusa PLA] +inherits = *PLA* +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" + +[filament:SemiFlex or Flexfill 98A] +inherits = *FLEX* + +[filament:Taulman Bridge] +inherits = *common* +bed_temperature = 90 +bridge_fan_speed = 40 +cooling = 0 +disable_fan_first_layers = 3 +fan_always_on = 0 +fan_below_layer_time = 20 +filament_colour = #DEE0E6 +filament_max_volumetric_speed = 10 +filament_soluble = 0 +filament_type = PET +first_layer_bed_temperature = 60 +first_layer_temperature = 240 +max_fan_speed = 5 +min_fan_speed = 0 +min_print_speed = 5 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 250 + +[filament:Taulman T-Glase] +inherits = *PET* +bridge_fan_speed = 40 +cooling = 0 +fan_always_on = 0 +first_layer_bed_temperature = 90 +first_layer_temperature = 240 +max_fan_speed = 5 +min_fan_speed = 0 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" + +[filament:Verbatim BVOH] +inherits = *common* +bed_temperature = 60 +bridge_fan_speed = 100 +cooling = 0 +disable_fan_first_layers = 1 +extrusion_multiplier = 1 +fan_always_on = 0 +fan_below_layer_time = 100 +filament_colour = #FFFFD7 +filament_max_volumetric_speed = 10 +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" +filament_soluble = 1 +filament_type = PLA +first_layer_bed_temperature = 60 +first_layer_temperature = 215 +max_fan_speed = 100 +min_fan_speed = 100 +min_print_speed = 15 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 210 + +[filament:Verbatim PP] +inherits = *common* +bed_temperature = 100 +bridge_fan_speed = 100 +cooling = 1 +disable_fan_first_layers = 2 +extrusion_multiplier = 1 +fan_always_on = 1 +fan_below_layer_time = 100 +filament_colour = #DEE0E6 +filament_max_volumetric_speed = 5 +filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA" +filament_type = PLA +first_layer_bed_temperature = 100 +first_layer_temperature = 220 +max_fan_speed = 100 +min_fan_speed = 100 +min_print_speed = 15 +start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" +temperature = 220 + +[printer:*common*] +bed_shape = 0x0,250x0,250x210,0x210 +before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n +between_objects_gcode = +deretract_speed = 0 +end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +extruder_colour = #FFFF00 +extruder_offset = 0x0 +gcode_flavor = marlin +layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] +max_layer_height = 0.25 +min_layer_height = 0.07 +nozzle_diameter = 0.4 +octoprint_apikey = +octoprint_host = +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n +printer_settings_id = +retract_before_travel = 1 +retract_before_wipe = 0% +retract_layer_change = 1 +retract_length = 0.8 +retract_length_toolchange = 4 +retract_lift = 0.6 +retract_lift_above = 0 +retract_lift_below = 199 +retract_restart_extra = 0 +retract_restart_extra_toolchange = 0 +retract_speed = 35 +serial_port = +serial_speed = 250000 +single_extruder_multi_material = 0 +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0 +toolchange_gcode = +use_firmware_retraction = 0 +use_relative_e_distances = 1 +use_volumetric_e = 0 +variable_layer_height = 1 +wipe = 1 +z_offset = 0 +printer_model = M2 +printer_variant = 0.4 +default_print_profile = 0.15mm OPTIMAL +default_filament_profile = Prusa PLA + +[printer:*multimaterial*] +inherits = *common* +deretract_speed = 50 +retract_before_travel = 3 +retract_before_wipe = 60% +retract_layer_change = 0 +retract_length = 4 +retract_lift = 0.6 +retract_lift_above = 0 +retract_lift_below = 199 +retract_restart_extra = 0 +retract_restart_extra_toolchange = 0 +retract_speed = 80 +single_extruder_multi_material = 1 +printer_model = M3 + +[printer:*mm-single*] +inherits = *multimaterial* +end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 + +[printer:*mm-multi*] +inherits = *multimaterial* +end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors +extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259 +nozzle_diameter = 0.4,0.4,0.4,0.4 +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 +variable_layer_height = 0 + +[printer:Original Prusa i3 MK2] +inherits = *common* + +[printer:Original Prusa i3 MK2 0.25 nozzle] +inherits = *common* +max_layer_height = 0.1 +min_layer_height = 0.05 +nozzle_diameter = 0.25 +retract_length = 1 +retract_speed = 50 +variable_layer_height = 0 +printer_variant = 0.25 +default_print_profile = 0.10mm DETAIL 0.25 nozzle + +[printer:Original Prusa i3 MK2 0.6 nozzle] +inherits = *common* +max_layer_height = 0.35 +min_layer_height = 0.1 +nozzle_diameter = 0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK2 MM Single Mode] +inherits = *mm-single* + +[printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle] +inherits = *mm-single* +nozzle_diameter = 0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK2 MultiMaterial] +inherits = *mm-multi* +nozzle_diameter = 0.4,0.4,0.4,0.4 + +[printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle] +inherits = *mm-multi* +nozzle_diameter = 0.6,0.6,0.6,0.6 +printer_variant = 0.6 + +[printer:Original Prusa i3 MK3] +inherits = *common* +end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +retract_lift_below = 209 +start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} +printer_model = M1 +default_print_profile = 0.15mm OPTIMAL MK3 + +[printer:Original Prusa i3 MK3 0.25 nozzle] +inherits = *common* +nozzle_diameter = 0.25 +printer_variant = 0.25 +end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +retract_lift_below = 209 +start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} +printer_model = M1 +default_print_profile = 0.10mm DETAIL MK3 + +[printer:Original Prusa i3 MK3 0.6 nozzle] +inherits = *common* +nozzle_diameter = 0.6 +printer_variant = 0.6 +end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +retract_lift_below = 209 +start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} +printer_model = M1 +default_print_profile = 0.15mm OPTIMAL MK3 diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 10a586e27c..9e5ce5f1bc 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -135,8 +135,6 @@ void AppConfig::save() bool AppConfig::get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const { - // std::cerr << "AppConfig::get_variant(" << vendor << ", " << model << ", " << variant << ") " << std::endl; - const auto it_v = m_vendors.find(vendor); if (it_v == m_vendors.end()) { return false; } const auto it_m = it_v->second.find(model); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index e43ff51bf6..7aac95fd6b 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -68,9 +68,9 @@ public: void clear_section(const std::string §ion) { m_storage[section].clear(); } - bool get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const; - void set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable); - void set_vendors(const AppConfig &from); + bool get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const; + void set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable); + void set_vendors(const AppConfig &from); // return recent/skein_directory or recent/config_directory or empty string. std::string get_last_dir() const; @@ -86,8 +86,8 @@ public: void reset_selections(); // Whether the Slic3r version available online differs from this one - bool version_check_enabled() const; - bool slic3r_update_avail() const; + bool version_check_enabled() const; + bool slic3r_update_avail() const; // Get the default config path from Slic3r::data_dir(). static std::string config_path(); diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 914ebb9a19..ce51d76411 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -1,6 +1,5 @@ #include "ConfigWizard_private.hpp" -#include // XXX #include #include #include @@ -23,9 +22,6 @@ namespace Slic3r { namespace GUI { -// FIXME: scrolling - - // Printer model picker GUI control struct PrinterPickerEvent : public wxEvent @@ -296,7 +292,7 @@ void PageVendors::on_vendor_pick(size_t i) for (PrinterPicker *picker : pickers) { picker->Hide(); } if (i < pickers.size()) { pickers[i]->Show(); - Layout(); + wizard_p()->layout_fit(); } } @@ -352,7 +348,7 @@ PageBedShape::PageBedShape(ConfigWizard *parent) : { append_text(_(L("Set the shape of your printer's bed."))); - shape_panel->build_panel(wizard_p()->custom_config.option("bed_shape")); + shape_panel->build_panel(wizard_p()->custom_config->option("bed_shape")); append(shape_panel); } @@ -583,7 +579,13 @@ void ConfigWizard::priv::set_page(ConfigWizardPage *page) btn_next->Show(page->page_next() != nullptr); btn_finish->Show(page->page_next() == nullptr); + layout_fit(); +} + +void ConfigWizard::priv::layout_fit() +{ q->Layout(); + q->Fit(); } void ConfigWizard::priv::enable_next(bool enable) @@ -619,9 +621,9 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese preset_bundle->load_presets(*app_config); } else { for (ConfigWizardPage *page = page_firmware; page != nullptr; page = page->page_next()) { - page->apply_custom_config(custom_config); + page->apply_custom_config(*custom_config); } - preset_bundle->load_config("My Settings", custom_config); + preset_bundle->load_config("My Settings", *custom_config); } } @@ -632,10 +634,9 @@ ConfigWizard::ConfigWizard(wxWindow *parent) : p(new priv(this)) { p->load_vendors(); - std::unique_ptr custom_config_defaults(DynamicPrintConfig::new_from_defaults_keys({ + p->custom_config.reset(DynamicPrintConfig::new_from_defaults_keys({ "gcode_flavor", "bed_shape", "nozzle_diameter", "filament_diameter", "temperature", "bed_temperature", })); - p->custom_config.apply(*custom_config_defaults); p->index = new ConfigWizardIndex(this); diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index 9f9395975b..d32a609be6 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -22,6 +22,8 @@ namespace GUI { enum { + CONTENT_WIDTH = 500, + DIALOG_MARGIN = 15, INDEX_MARGIN = 40, BTN_SPACING = 10, @@ -38,10 +40,6 @@ struct PrinterPicker: wxPanel struct ConfigWizardPage: wxPanel { - enum { - CONTENT_WIDTH = 500, - }; - ConfigWizard *parent; const wxString shortname; wxBoxSizer *content; @@ -171,7 +169,7 @@ struct ConfigWizard::priv ConfigWizard *q; AppConfig appconfig_vendors; PresetBundle bundle_vendors; - DynamicPrintConfig custom_config; + std::unique_ptr custom_config; wxBoxSizer *topsizer = nullptr; wxBoxSizer *btnsizer = nullptr; @@ -196,6 +194,7 @@ struct ConfigWizard::priv void add_page(ConfigWizardPage *page); void index_refresh(); void set_page(ConfigWizardPage *page); + void layout_fit(); void go_prev() { if (page_current != nullptr) { set_page(page_current->page_prev()); } } void go_next() { if (page_current != nullptr) { set_page(page_current->page_next()); } } void enable_next(bool enable); diff --git a/xs/xsp/my.map b/xs/xsp/my.map index 9c0f60c1dc..c1ca58827b 100644 --- a/xs/xsp/my.map +++ b/xs/xsp/my.map @@ -235,9 +235,6 @@ PresetHints* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T TabIface* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T -# TODO: remove: -# ConfigWizard* O_OBJECT_SLIC3R -# Ref O_OBJECT_SLIC3R_T PresetUpdater* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T From abe94706f69a45714541330f02c8a558e3844576 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 6 Apr 2018 13:27:51 +0200 Subject: [PATCH 0127/1150] Gyroid infill bug fix: abs vs std::abs --- xs/src/libslic3r/Fill/FillGyroid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Fill/FillGyroid.cpp b/xs/src/libslic3r/Fill/FillGyroid.cpp index a3920caab1..dbe6ec8961 100644 --- a/xs/src/libslic3r/Fill/FillGyroid.cpp +++ b/xs/src/libslic3r/Fill/FillGyroid.cpp @@ -65,7 +65,7 @@ static Polylines make_gyroid_waves(double gridZ, double density_adjusted, double double z_sin = sin(z); double z_cos = cos(z); Polylines result; - if (abs(z_sin) <= abs(z_cos)) { + if (std::abs(z_sin) <= std::abs(z_cos)) { // Vertical wave double x0 = M_PI * (int)((- 0.5 * M_PI) / M_PI - 1.); bool flip = ((int)(x0 / M_PI + 1.) & 1) != 0; From e4b767e8403c1c860c36598e822b02d6c2bbfc2d Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 6 Apr 2018 13:37:00 +0200 Subject: [PATCH 0128/1150] Experiment with own ComboCtrl for preset_choice. --- xs/src/slic3r/GUI/Field.cpp | 3 +- xs/src/slic3r/GUI/Tab.cpp | 47 ++++++++++++++++++++++++++++++ xs/src/slic3r/GUI/Tab.hpp | 2 ++ xs/src/slic3r/GUI/wxExtensions.cpp | 44 ++++++++++++++++++++++++++++ xs/src/slic3r/GUI/wxExtensions.hpp | 24 +++++++++++++++ 5 files changed, 118 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index fee08e27ed..a7fd8d29eb 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -173,8 +173,7 @@ namespace Slic3r { namespace GUI { temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e) { -// on_kill_focus(e); - e.Skip(); + e.Skip();// on_kill_focus(e); temp->GetToolTip()->Enable(true); }), temp->GetId()); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index babff7d801..3935dda5aa 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -20,6 +20,7 @@ #include #include +#include "wxExtensions.hpp" namespace Slic3r { namespace GUI { @@ -38,6 +39,50 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) // preset chooser m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY); + m_cc_presets_choice = new wxComboCtrl(panel, wxID_ANY, L("Presets"), wxDefaultPosition, wxSize(270, -1), wxCB_READONLY); + wxDataViewTreeCtrlComboPopup* popup = new wxDataViewTreeCtrlComboPopup; + if (popup != nullptr) + { + // FIXME If the following line is removed, the combo box popup list will not react to mouse clicks. + // On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10. +// comboCtrl->UseAltPopupWindow(); +// comboCtrl->EnablePopupAnimation(false); + m_cc_presets_choice->SetPopupControl(popup); + popup->SetStringValue(from_u8("Text1")); + + popup->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this, popup](wxCommandEvent& evt) + { + auto selected = popup->GetItemText(popup->GetSelection()); + if (selected != _(L("System presets")) && selected != _(L("Default presets"))) + m_cc_presets_choice->SetText(selected); +// popup->OnDataViewTreeCtrlSelection(evt); + }); + popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); + popup->Bind(wxEVT_KEY_UP, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); + + auto icons = new wxImageList(16, 16, true, 1); + popup->SetImageList(icons); + icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG)); + icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG)); + + Freeze(); + + // get label of the currently selected item + auto selected = popup->GetItemText(popup->GetSelection()); + auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); + auto tree_node1 = popup->AppendItem(root_sys, _("Sys1"), 0); + auto tree_node2 = popup->AppendContainer(root_sys, _("Sys2"), 0); + auto tree_node2_1 = popup->AppendItem(tree_node2, _("Sys2_1"), 0); + + auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); + auto tree_node01 = popup->AppendContainer(root_def, _("Def1"), 0); + auto tree_node02 = popup->AppendContainer(root_def, _("Def2"), 0); + auto tree_node02_1 = popup->AppendItem(tree_node02, _("Def2_1"), 0); + + Thaw(); + } + + auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); //buttons @@ -82,6 +127,8 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_hsizer->AddSpacer(64); m_hsizer->Add(m_undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); m_hsizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL); + m_hsizer->AddSpacer(64); + m_hsizer->Add(m_cc_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3); //Horizontal sizer to hold the tree and the selected page. m_hsizer = new wxBoxSizer(wxHORIZONTAL); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index f39ff728ca..075eab2188 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -95,6 +96,7 @@ protected: wxButton* m_compatible_printers_btn; wxButton* m_undo_btn; wxButton* m_undo_to_sys_btn; + wxComboCtrl* m_cc_presets_choice; int m_icon_count; std::map m_icon_index; // Map from an icon file name to its index diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 1ebd7979e9..c4dfb7e109 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -109,3 +109,47 @@ void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt) ProcessEvent(event); } } + + +// *** wxDataViewTreeCtrlComboPopup *** + +const unsigned int wxDataViewTreeCtrlComboPopup::DefaultWidth = 270; +const unsigned int wxDataViewTreeCtrlComboPopup::DefaultHeight = 200; +const unsigned int wxDataViewTreeCtrlComboPopup::DefaultItemHeight = 22; + +bool wxDataViewTreeCtrlComboPopup::Create(wxWindow* parent) +{ + return wxDataViewTreeCtrl::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0), wxSize(270, -1)); +} + +wxSize wxDataViewTreeCtrlComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight) +{ + // matches owner wxComboCtrl's width + // and sets height dinamically in dependence of contained items count + return wxSize(DefaultWidth, DefaultHeight); +} + +void wxDataViewTreeCtrlComboPopup::OnKeyEvent(wxKeyEvent& evt) +{ + // filters out all the keys which are not working properly + if (evt.GetKeyCode() == WXK_UP) + { + return; + } + else if (evt.GetKeyCode() == WXK_DOWN) + { + return; + } + else + { + evt.Skip(); + return; + } +} + +void wxDataViewTreeCtrlComboPopup::OnDataViewTreeCtrlSelection(wxCommandEvent& evt) +{ + wxComboCtrl* cmb = GetComboCtrl(); + auto selected = GetItemText(GetSelection()); + cmb->SetText(selected); +} diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index e61c17bbc3..bba412cfd1 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -3,6 +3,7 @@ #include #include +#include class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup { @@ -25,4 +26,27 @@ public: void OnListBoxSelection(wxCommandEvent& evt); }; + +// *** wxDataViewTreeCtrlComboBox *** + +class wxDataViewTreeCtrlComboPopup: public wxDataViewTreeCtrl, public wxComboPopup +{ + static const unsigned int DefaultWidth; + static const unsigned int DefaultHeight; + static const unsigned int DefaultItemHeight; + + wxString m_text; + int m_cnt_open_items=2; + +public: + virtual bool Create(wxWindow* parent); + virtual wxWindow* GetControl() { return this; } + virtual void SetStringValue(const wxString& value) { m_text = value; } + virtual wxString GetStringValue() const { return m_text; } + virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight); + + virtual void OnKeyEvent(wxKeyEvent& evt); + void OnDataViewTreeCtrlSelection(wxCommandEvent& evt); +}; + #endif // slic3r_GUI_wxExtensions_hpp_ From 90a8ef8e9f208dce144cea4252173079fd0f830c Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 6 Apr 2018 13:18:12 +0200 Subject: [PATCH 0129/1150] Cleanup --- lib/Slic3r/GUI/MainFrame.pm | 44 +--------------------- resources/profiles/PrusaResearch.ini | 5 --- xs/src/slic3r/GUI/ConfigWizard.cpp | 15 +++++--- xs/src/slic3r/GUI/ConfigWizard.hpp | 3 +- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 4 +- xs/src/slic3r/GUI/GUI.cpp | 4 +- xs/src/slic3r/GUI/GUI.hpp | 5 +-- xs/src/slic3r/GUI/Preset.cpp | 1 - xs/src/slic3r/GUI/Preset.hpp | 5 +-- xs/src/slic3r/GUI/PresetBundle.cpp | 6 +-- xs/xsp/GUI.xsp | 4 +- 11 files changed, 23 insertions(+), 73 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 4307375c81..402cb80519 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -644,48 +644,8 @@ sub config_wizard { # Exit wizard if there are unsaved changes and the user cancels the action. return unless $self->check_unsaved_changes; - - # TODO: Offer "reset user profile" - Slic3r::GUI::open_config_wizard(wxTheApp->{preset_bundle}); - # Load the currently selected preset into the GUI, update the preset selection box. - foreach my $tab (values %{$self->{options_tabs}}) { # XXX: only if not cancelled? - $tab->load_current_preset; - } - return; - - # Enumerate the profiles bundled with the Slic3r installation under resources/profiles. - my $directory = Slic3r::resources_dir() . "/profiles"; - my @profiles = (); - if (opendir(DIR, Slic3r::encode_path($directory))) { - while (my $file = readdir(DIR)) { - if ($file =~ /\.ini$/) { - $file =~ s/\.ini$//; - push @profiles, Slic3r::decode_path($file); - } - } - closedir(DIR); - } - # Open the wizard. - if (my $result = Slic3r::GUI::ConfigWizard->new($self, \@profiles, $fresh_start)->run) { - eval { - if ($result->{reset_user_profile}) { - wxTheApp->{preset_bundle}->reset(1); - } - if (defined $result->{config}) { - # Load and save the settings into print, filament and printer presets. - wxTheApp->{preset_bundle}->load_config('My Settings', $result->{config}); - } else { - # Wizard returned a name of a preset bundle bundled with the installation. Unpack it. - wxTheApp->{preset_bundle}->install_vendor_configbundle($directory . '/' . $result->{preset_name} . '.ini'); - # Reset the print / filament / printer selections, so that following line will select some sensible defaults. - if ($fresh_start) { - wxTheApp->{app_config}->reset_selections; - } - # Reload all presets after the vendor config bundle has been installed. - wxTheApp->{preset_bundle}->load_presets(wxTheApp->{app_config}); - } - }; - Slic3r::GUI::catch_error($self) and return; + # TODO: Offer "reset user profile" ??? + if (Slic3r::GUI::open_config_wizard(wxTheApp->{preset_bundle})) { # Load the currently selected preset into the GUI, update the preset selection box. foreach my $tab (values %{$self->{options_tabs}}) { $tab->load_current_preset; diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 6dc29a96e9..b654b4039f 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -1017,8 +1017,3 @@ retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = MK3 default_print_profile = 0.15mm OPTIMAL MK3 - -[presets] -print = 0.15mm OPTIMAL MK3 -printer = Original Prusa i3 MK3 -filament = Prusa PLA diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index ce51d76411..032b5e903b 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -412,16 +412,16 @@ void PageDiameters::apply_custom_config(DynamicPrintConfig &config) PageTemperatures::PageTemperatures(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("Extruder and Bed Temperatures")), _(L("Temperatures"))), - spin_extr(new wxSpinCtrl(this, wxID_ANY)), - spin_bed(new wxSpinCtrl(this, wxID_ANY)) + spin_extr(new wxSpinCtrlDouble(this, wxID_ANY)), + spin_bed(new wxSpinCtrlDouble(this, wxID_ANY)) { - spin_extr->SetIncrement(5); + spin_extr->SetIncrement(5.0); const auto &def_extr = print_config_def.options["temperature"]; spin_extr->SetRange(def_extr.min, def_extr.max); auto *default_extr = dynamic_cast(def_extr.default_value); spin_extr->SetValue(default_extr != nullptr && default_extr->size() > 0 ? default_extr->get_at(0) : 200); - spin_bed->SetIncrement(5); + spin_bed->SetIncrement(5.0); const auto &def_bed = print_config_def.options["bed_temperature"]; spin_bed->SetRange(def_bed.min, def_bed.max); auto *default_bed = dynamic_cast(def_bed.default_value); @@ -541,7 +541,7 @@ void ConfigWizard::priv::load_vendors() const auto vendor_dir = fs::path(Slic3r::data_dir()) / "vendor"; for (fs::directory_iterator it(vendor_dir); it != fs::directory_iterator(); ++it) { if (it->path().extension() == ".ini") { - bundle_vendors.load_configbundle(it->path().native(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); + bundle_vendors.load_configbundle(it->path().string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); } } @@ -688,7 +688,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent) : ConfigWizard::~ConfigWizard() {} -void ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) +bool ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) { const auto profiles_dir = fs::path(resources_dir()) / "profiles"; for (fs::directory_iterator it(profiles_dir); it != fs::directory_iterator(); ++it) { @@ -700,6 +700,9 @@ void ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) ConfigWizard wizard(parent); if (wizard.ShowModal() == wxID_OK) { wizard.p->apply_config(GUI::get_app_config(), preset_bundle); + return true; + } else { + return false; } } diff --git a/xs/src/slic3r/GUI/ConfigWizard.hpp b/xs/src/slic3r/GUI/ConfigWizard.hpp index a06388396c..40ecf09a1e 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard.hpp @@ -15,7 +15,6 @@ namespace GUI { class ConfigWizard: public wxDialog { public: - // ConfigWizard(wxWindow *parent, const PresetBundle &bundle); ConfigWizard(wxWindow *parent); ConfigWizard(ConfigWizard &&) = delete; ConfigWizard(const ConfigWizard &) = delete; @@ -23,7 +22,7 @@ public: ConfigWizard &operator=(const ConfigWizard &) = delete; ~ConfigWizard(); - static void run(wxWindow *parent, PresetBundle *preset_bundle); + static bool run(wxWindow *parent, PresetBundle *preset_bundle); private: struct priv; std::unique_ptr p; diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index d32a609be6..652328aaad 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -136,8 +136,8 @@ struct PageDiameters: ConfigWizardPage struct PageTemperatures: ConfigWizardPage { - wxSpinCtrl *spin_extr; - wxSpinCtrl *spin_bed; + wxSpinCtrlDouble *spin_extr; + wxSpinCtrlDouble *spin_bed; PageTemperatures(ConfigWizard *parent); virtual void apply_custom_config(DynamicPrintConfig &config); diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 80e2322875..310860e536 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -353,13 +353,13 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change) //#endif } -void open_config_wizard(PresetBundle *preset_bundle) +bool open_config_wizard(PresetBundle *preset_bundle) { if (g_wxMainFrame == nullptr) { throw std::runtime_error("Main frame not set"); } - ConfigWizard::run(g_wxMainFrame, preset_bundle); + return ConfigWizard::run(g_wxMainFrame, preset_bundle); } void open_preferences_dialog(int event_preferences) diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 98a1240919..321c97d367 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -73,7 +73,6 @@ void break_to_debugger(); // Passing the wxWidgets GUI classes instantiated by the Perl part to C++. void set_wxapp(wxApp *app); void set_main_frame(wxFrame *main_frame); -// wxFrame* get_main_frame(); void set_tab_panel(wxNotebook *tab_panel); void set_app_config(AppConfig *app_config); void set_preset_bundle(PresetBundle *preset_bundle); @@ -85,8 +84,8 @@ wxColour* get_sys_label_clr(); void add_debug_menu(wxMenuBar *menu, int event_language_change); -// Opens the first-time configuration wizard -void open_config_wizard(PresetBundle *preset_bundle); +// Opens the first-time configuration wizard, returns true if wizard is finished & accepted. +bool open_config_wizard(PresetBundle *preset_bundle); // Create "Preferences" dialog after selecting menu "Preferences" in Perl part void open_preferences_dialog(int event_preferences); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 40afca144b..66836074e9 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -183,7 +183,6 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config) const std::string &variant = config.opt_string("printer_variant"); if (model.empty() || variant.empty()) { return; } is_visible = app_config.get_variant(vendor->id, model, variant); - std::cerr << vendor->id << " / " << model << " / " << variant << ": visible: " << is_visible << std::endl; } const std::vector& Preset::print_options() diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 075eed9afd..4f734b85e3 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -37,14 +37,12 @@ public: PrinterVariant() {} PrinterVariant(const std::string &name) : name(name) {} std::string name; - // bool enabled = true; // TODO: remove these? }; struct PrinterModel { PrinterModel() {} std::string id; std::string name; - // bool enabled = true; std::vector variants; PrinterVariant* variant(const std::string &name) { for (auto &v : this->variants) @@ -87,7 +85,8 @@ public: bool is_external = false; // System preset is read-only. bool is_system = false; - // Preset is visible, if it is compatible with the active Printer. TODO: fix + // Preset is visible, if it is associated with a printer model / variant that is enabled in the AppConfig + // or if it has no printer model / variant association. // Also the "default" preset is only visible, if it is the only preset in the list. bool is_visible = true; // Has this preset been modified? diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 8645a4f2d3..bd9e35ca80 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -4,7 +4,6 @@ #include "PresetBundle.hpp" #include "BitmapCache.hpp" -#include // XXX #include #include #include @@ -201,10 +200,7 @@ static inline std::string remove_ini_suffix(const std::string &name) // If the "vendor" section is missing, enable all models and variants of the particular vendor. void PresetBundle::load_installed_printers(const AppConfig &config) { - std::cerr << "load_installed_printers()" << std::endl; - for (auto &preset : printers) { - std::cerr << "preset: printer: " << preset.name << std::endl; preset.set_visible_from_appconfig(config); } } @@ -742,7 +738,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla const VendorProfile *vendor_profile = nullptr; if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) { boost::filesystem::path fspath(path); - VendorProfile vp(fspath.stem().native()); + VendorProfile vp(fspath.stem().string()); load_vendor_profile(tree, vp); if (vp.name.empty()) throw std::runtime_error(std::string("Vendor Config Bundle is not valid: Missing vendor name key.")); diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index ad7f69a2d7..fcf465a290 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -54,8 +54,8 @@ int combochecklist_get_flags(SV *ui) void set_app_config(AppConfig *app_config) %code%{ Slic3r::GUI::set_app_config(app_config); %}; -void open_config_wizard(PresetBundle *preset_bundle) - %code%{ Slic3r::GUI::open_config_wizard(preset_bundle); %}; +bool open_config_wizard(PresetBundle *preset_bundle) + %code%{ RETVAL=Slic3r::GUI::open_config_wizard(preset_bundle); %}; void open_preferences_dialog(int preferences_event) %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %}; From 004f9ba1e5457203057b8cb2dad04c089bd64acf Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 6 Apr 2018 15:42:52 +0200 Subject: [PATCH 0130/1150] Added update_tab_presets functions to m_cc_preset_choise filling --- xs/src/slic3r/GUI/Preset.cpp | 4 ++ xs/src/slic3r/GUI/Preset.hpp | 6 +++ xs/src/slic3r/GUI/Tab.cpp | 65 ++++++++++++++++++++++-------- xs/src/slic3r/GUI/Tab.hpp | 1 + xs/src/slic3r/GUI/wxExtensions.cpp | 14 ++++++- xs/src/slic3r/GUI/wxExtensions.hpp | 3 +- 6 files changed, 74 insertions(+), 19 deletions(-) diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index c437f8b414..d612896a53 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -417,6 +417,10 @@ const Preset* PresetCollection::get_selected_preset_parent() const return (preset == nullptr || preset->is_default || preset->is_external) ? nullptr : preset; } +const std::string& PresetCollection::get_suffix_modified() { + return g_suffix_modified; +} + // Return a preset by its name. If the preset is active, a temporary copy is returned. // If a preset is not found by its name, null is returned. Preset* PresetCollection::find_preset(const std::string &name, bool first_visible_if_not_found) diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 3634c5dd94..f19f511c30 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -212,6 +212,12 @@ public: // Return the selected preset including the user modifications. Preset& get_edited_preset() { return m_edited_preset; } const Preset& get_edited_preset() const { return m_edited_preset; } + + // used to update preset_choice from Tab + const std::deque& get_presets() { return m_presets; } + int get_idx_selected() { return m_idx_selected; } + const std::string& get_suffix_modified(); + // Return a preset possibly with modifications. const Preset& default_preset() const { return m_presets.front(); } // Return a preset by an index. If the preset is active, a temporary copy is returned. diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 3935dda5aa..37ed8f97f7 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -54,32 +54,21 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) { auto selected = popup->GetItemText(popup->GetSelection()); if (selected != _(L("System presets")) && selected != _(L("Default presets"))) + { m_cc_presets_choice->SetText(selected); + std::string selected_string = selected.ToUTF8().data(); +//! select_preset(selected_string); + } // popup->OnDataViewTreeCtrlSelection(evt); }); + popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); popup->Bind(wxEVT_KEY_UP, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); auto icons = new wxImageList(16, 16, true, 1); popup->SetImageList(icons); - icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG)); icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG)); - - Freeze(); - - // get label of the currently selected item - auto selected = popup->GetItemText(popup->GetSelection()); - auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); - auto tree_node1 = popup->AppendItem(root_sys, _("Sys1"), 0); - auto tree_node2 = popup->AppendContainer(root_sys, _("Sys2"), 0); - auto tree_node2_1 = popup->AppendItem(tree_node2, _("Sys2_1"), 0); - - auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); - auto tree_node01 = popup->AppendContainer(root_def, _("Def1"), 0); - auto tree_node02 = popup->AppendContainer(root_def, _("Def2"), 0); - auto tree_node02_1 = popup->AppendItem(tree_node02, _("Def2_1"), 0); - - Thaw(); + icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG)); } @@ -525,11 +514,13 @@ void Tab::update_dirty(){ m_presets->update_dirty_ui(m_presets_choice); on_presets_changed(); update_changed_ui(); +// update_dirty_presets(m_cc_presets_choice); } void Tab::update_tab_ui() { m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets); + update_tab_presets(m_cc_presets_choice, m_show_incompatible_presets); } // Load a provied DynamicConfig into the tab, modifying the active preset. @@ -2141,6 +2132,46 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox return sizer; } +void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) +{ + if (ui == nullptr) + return; + ui->Freeze(); + ui->Clear(); + auto presets = m_presets->get_presets(); + auto idx_selected = m_presets->get_idx_selected(); + auto suffix_modified = m_presets->get_suffix_modified(); + int icon_compatible = 0; + int icon_incompatible = 1; + int cnt_items = 0; + + wxDataViewTreeCtrlComboPopup* popup = wxDynamicCast(m_cc_presets_choice->GetPopupControl(), wxDataViewTreeCtrlComboPopup); + if (popup != nullptr) + { + popup->DeleteAllItems(); + auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); + auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); + + for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { + const Preset &preset = presets[i]; + if (!preset.is_visible || (!show_incompatible && !preset.is_compatible && i != idx_selected)) + continue; + + auto preset_name = wxString::FromUTF8((preset.name + (preset.is_dirty ? suffix_modified : "")).c_str()); + + auto item = popup->AppendItem(preset.is_system ? root_sys : root_def, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + cnt_items++; + if (i == idx_selected){ + popup->Select(item); + m_cc_presets_choice->SetText(preset_name); + } + } + } + popup->SetItemsCnt(cnt_items); + ui->Thaw(); +} + void Page::reload_config() { for (auto group : m_optgroups) diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 075eab2188..5e2eec80dd 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -196,6 +196,7 @@ public: protected: void on_presets_changed(); void update_frequently_changed_parameters(); + void update_tab_presets(wxComboCtrl* ui, bool show_incompatible); }; //Slic3r::GUI::Tab::Print; diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index c4dfb7e109..d9f4e520aa 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -126,7 +126,19 @@ wxSize wxDataViewTreeCtrlComboPopup::GetAdjustedSize(int minWidth, int prefHeigh { // matches owner wxComboCtrl's width // and sets height dinamically in dependence of contained items count - return wxSize(DefaultWidth, DefaultHeight); + wxComboCtrl* cmb = GetComboCtrl(); + if (cmb != nullptr) + { + wxSize size = GetComboCtrl()->GetSize(); + if (m_cnt_open_items > 0) + size.SetHeight(m_cnt_open_items * DefaultItemHeight); + else + size.SetHeight(DefaultHeight); + + return size; + } + else + return wxSize(DefaultWidth, DefaultHeight); } void wxDataViewTreeCtrlComboPopup::OnKeyEvent(wxKeyEvent& evt) diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index bba412cfd1..701b12dbae 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -36,7 +36,7 @@ class wxDataViewTreeCtrlComboPopup: public wxDataViewTreeCtrl, public wxComboPop static const unsigned int DefaultItemHeight; wxString m_text; - int m_cnt_open_items=2; + int m_cnt_open_items{0}; public: virtual bool Create(wxWindow* parent); @@ -47,6 +47,7 @@ public: virtual void OnKeyEvent(wxKeyEvent& evt); void OnDataViewTreeCtrlSelection(wxCommandEvent& evt); + void SetItemsCnt(int cnt) { m_cnt_open_items = cnt; } }; #endif // slic3r_GUI_wxExtensions_hpp_ From 670061ac333cf96007b3c599fc8981bd7f2150a6 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 6 Apr 2018 16:49:33 +0200 Subject: [PATCH 0131/1150] Initial implementation of configuration snapshotting. --- xs/CMakeLists.txt | 5 + xs/src/libslic3r/FileParserError.hpp | 48 +++++ xs/src/libslic3r/Utils.hpp | 3 - xs/src/libslic3r/utils.cpp | 28 --- xs/src/slic3r/Config/Snapshot.cpp | 308 +++++++++++++++++++++++++++ xs/src/slic3r/Config/Snapshot.hpp | 106 +++++++++ xs/src/slic3r/Config/Version.cpp | 136 ++++++++++++ xs/src/slic3r/Config/Version.hpp | 75 +++++++ xs/src/slic3r/Utils/Semver.hpp | 24 +++ xs/src/slic3r/Utils/Time.cpp | 63 ++++++ xs/src/slic3r/Utils/Time.hpp | 22 ++ 11 files changed, 787 insertions(+), 31 deletions(-) create mode 100644 xs/src/libslic3r/FileParserError.hpp create mode 100644 xs/src/slic3r/Config/Snapshot.cpp create mode 100644 xs/src/slic3r/Config/Snapshot.hpp create mode 100644 xs/src/slic3r/Config/Version.cpp create mode 100644 xs/src/slic3r/Config/Version.hpp create mode 100644 xs/src/slic3r/Utils/Time.cpp create mode 100644 xs/src/slic3r/Utils/Time.hpp diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index ca398da5a2..501c90db2b 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -54,6 +54,7 @@ add_library(libslic3r STATIC ${LIBDIR}/libslic3r/ExtrusionEntityCollection.hpp ${LIBDIR}/libslic3r/ExtrusionSimulator.cpp ${LIBDIR}/libslic3r/ExtrusionSimulator.hpp + ${LIBDIR}/libslic3r/FileParserError.hpp ${LIBDIR}/libslic3r/Fill/Fill.cpp ${LIBDIR}/libslic3r/Fill/Fill.hpp ${LIBDIR}/libslic3r/Fill/Fill3DHoneycomb.cpp @@ -201,6 +202,10 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/wxExtensions.hpp ${LIBDIR}/slic3r/GUI/BonjourDialog.cpp ${LIBDIR}/slic3r/GUI/BonjourDialog.hpp + ${LIBDIR}/slic3r/Config/Snapshot.cpp + ${LIBDIR}/slic3r/Config/Snapshot.hpp + ${LIBDIR}/slic3r/Config/Version.cpp + ${LIBDIR}/slic3r/Config/Version.hpp ${LIBDIR}/slic3r/Utils/ASCIIFolding.cpp ${LIBDIR}/slic3r/Utils/ASCIIFolding.hpp ${LIBDIR}/slic3r/Utils/Http.cpp diff --git a/xs/src/libslic3r/FileParserError.hpp b/xs/src/libslic3r/FileParserError.hpp new file mode 100644 index 0000000000..82a6b328e8 --- /dev/null +++ b/xs/src/libslic3r/FileParserError.hpp @@ -0,0 +1,48 @@ +#ifndef slic3r_FileParserError_hpp_ +#define slic3r_FileParserError_hpp_ + +#include "libslic3r.h" + +#include +#include + +namespace Slic3r { + +// Generic file parser error, mostly copied from boost::property_tree::file_parser_error +class file_parser_error: public std::runtime_error +{ +public: + file_parser_error(const std::string &msg, const std::string &file, unsigned long line = 0) : + std::runtime_error(format_what(msg, file, line)), + m_message(msg), m_filename(file), m_line(line) {} + // gcc 3.4.2 complains about lack of throw specifier on compiler + // generated dtor + ~file_parser_error() throw() {} + + // Get error message (without line and file - use what() to get full message) + std::string message() const { return m_message; } + // Get error filename + std::string filename() const { return m_filename; } + // Get error line number + unsigned long line() const { return m_line; } + +private: + std::string m_message; + std::string m_filename; + unsigned long m_line; + + // Format error message to be returned by std::runtime_error::what() + static std::string format_what(const std::string &msg, const std::string &file, unsigned long l) + { + std::stringstream stream; + stream << (file.empty() ? "" : file.c_str()); + if (l > 0) + stream << '(' << l << ')'; + stream << ": " << msg; + return stream.str(); + } +}; + +}; // Slic3r + +#endif // slic3r_FileParserError_hpp_ diff --git a/xs/src/libslic3r/Utils.hpp b/xs/src/libslic3r/Utils.hpp index 27e7fad6b0..5727d6c89f 100644 --- a/xs/src/libslic3r/Utils.hpp +++ b/xs/src/libslic3r/Utils.hpp @@ -60,9 +60,6 @@ extern std::string timestamp_str(); // to be placed at the top of Slic3r generated files. inline std::string header_slic3r_generated() { return std::string("generated by " SLIC3R_FORK_NAME " " SLIC3R_VERSION " " ) + timestamp_str(); } -// Encode a file into a multi-part HTTP response with a given boundary. -std::string octoprint_encode_file_send_request_content(const char *path, bool select, bool print, const char *boundary); - // Compute the next highest power of 2 of 32-bit v // http://graphics.stanford.edu/~seander/bithacks.html template diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp index 34b9eaa9f1..733757e25a 100644 --- a/xs/src/libslic3r/utils.cpp +++ b/xs/src/libslic3r/utils.cpp @@ -263,7 +263,6 @@ namespace PerlUtils { std::string timestamp_str() { const auto now = boost::posix_time::second_clock::local_time(); - const auto date = now.date(); char buf[2048]; sprintf(buf, "on %04d-%02d-%02d at %02d:%02d:%02d", // Local date in an ANSII format. @@ -272,31 +271,4 @@ std::string timestamp_str() return buf; } -std::string octoprint_encode_file_send_request_content(const char *cpath, bool select, bool print, const char *boundary) -{ - // Read the complete G-code string into a string buffer. - // It will throw if the file cannot be open or read. - std::stringstream str_stream; - { - boost::nowide::ifstream ifs(cpath); - str_stream << ifs.rdbuf(); - } - - boost::filesystem::path path(cpath); - std::string request = boundary + '\n'; - request += "Content-Disposition: form-data; name=\""; - request += path.stem().string() + "\"; filename=\"" + path.filename().string() + "\"\n"; - request += "Content-Type: application/octet-stream\n\n"; - request += str_stream.str(); - request += boundary + '\n'; - request += "Content-Disposition: form-data; name=\"select\"\n\n"; - request += select ? "true\n" : "false\n"; - request += boundary + '\n'; - request += "Content-Disposition: form-data; name=\"print\"\n\n"; - request += print ? "true\n" : "false\n"; - request += boundary + '\n'; - - return request; -} - }; // namespace Slic3r diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp new file mode 100644 index 0000000000..559e4c63cb --- /dev/null +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -0,0 +1,308 @@ +#include "Snapshot.hpp" +#include "../GUI/AppConfig.hpp" +#include "../Utils/Time.hpp" + +#include + +#include +#include +#include +#include +#include + +#include "../../libslic3r/libslic3r.h" +#include "../../libslic3r/Config.hpp" +#include "../../libslic3r/FileParserError.hpp" +#include "../../libslic3r/Utils.hpp" + +#define SLIC3R_SNAPSHOTS_DIR "snapshots" +#define SLIC3R_SNAPSHOT_FILE "snapshot.ini" + +namespace Slic3r { +namespace GUI { +namespace Config { + +void Snapshot::clear() +{ + this->id.clear(); + this->time_captured = 0; + this->slic3r_version_captured = Semver::invalid(); + this->comment.clear(); + this->reason = SNAPSHOT_UNKNOWN; + this->print.clear(); + this->filaments.clear(); + this->printer.clear(); +} + +void Snapshot::load_ini(const std::string &path) +{ + this->clear(); + + auto throw_on_parse_error = [&path](const std::string &msg) { + throw file_parser_error(std::string("Failed loading the snapshot file. Reason: ") + msg, path); + }; + + // Load the snapshot.ini file. + boost::property_tree::ptree tree; + try { + boost::nowide::ifstream ifs(path); + boost::property_tree::read_ini(ifs, tree); + } catch (const std::ifstream::failure &err) { + throw file_parser_error(std::string("The snapshot file cannot be loaded. Reason: ") + err.what(), path); + } catch (const std::runtime_error &err) { + throw_on_parse_error(err.what()); + } + + // Parse snapshot.ini + std::string group_name_vendor = "Vendor:"; + std::string key_filament = "filament"; + for (auto §ion : tree) { + if (section.first == "snapshot") { + // Parse the common section. + for (auto &kvp : section.second) { + if (kvp.first == "id") + this->id = kvp.second.data(); + else if (kvp.first == "time_captured") { + this->time_captured = Slic3r::Utils::parse_time_ISO8601Z(kvp.second.data()); + if (this->time_captured == (time_t)-1) + throw_on_parse_error("invalid timestamp"); + } else if (kvp.first == "slic3r_version_captured") { + auto semver = Semver::parse(kvp.second.data()); + if (! semver) + throw_on_parse_error("invalid slic3r_version_captured semver"); + this->slic3r_version_captured = *semver; + } else if (kvp.first == "comment") { + this->comment = kvp.second.data(); + } else if (kvp.first == "reason") { + std::string rsn = kvp.second.data(); + if (rsn == "upgrade") + this->reason = SNAPSHOT_UPGRADE; + else if (rsn == "downgrade") + this->reason = SNAPSHOT_DOWNGRADE; + else if (rsn == "user") + this->reason = SNAPSHOT_USER; + else + this->reason = SNAPSHOT_UNKNOWN; + } + } + } else if (section.first == "presets") { + // Load the names of the active presets. + for (auto &kvp : section.second) { + if (kvp.first == "print") { + this->print = kvp.second.data(); + } else if (boost::starts_with(kvp.first, "filament")) { + int idx = 0; + if (kvp.first == "filament" || sscanf(kvp.first.c_str(), "filament_%d", &idx) == 1) { + if (int(this->filaments.size()) <= idx) + this->filaments.resize(idx + 1, std::string()); + this->filaments[idx] = kvp.second.data(); + } + } else if (kvp.first == "printer") { + this->printer = kvp.second.data(); + } + } + } else if (boost::starts_with(section.first, group_name_vendor) && section.first.size() > group_name_vendor.size()) { + // Vendor specific section. + VendorConfig vc; + vc.name = section.first.substr(group_name_vendor.size()); + for (auto &kvp : section.second) { + if (boost::starts_with(kvp.first, "model_")) { + //model:MK2S = 0.4;xxx + //model:MK3 = 0.4;xxx + } else if (kvp.first == "version" || kvp.first == "min_slic3r_version" || kvp.first == "max_slic3r_version") { + // Version of the vendor specific config bundle bundled with this snapshot. + auto semver = Semver::parse(kvp.second.data()); + if (! semver) + throw_on_parse_error("invalid " + kvp.first + " format for " + section.first); + if (kvp.first == "version") + vc.version = *semver; + else if (kvp.first == "min_slic3r_version") + vc.min_slic3r_version = *semver; + else + vc.max_slic3r_version = *semver; + } + } + } + } +} + +void Snapshot::save_ini(const std::string &path) +{ + boost::nowide::ofstream c; + c.open(path, std::ios::out | std::ios::trunc); + c << "# " << Slic3r::header_slic3r_generated() << std::endl; + + // Export the common "snapshot". + c << std::endl << "[snapshot]" << std::endl; + c << "id = " << this->id << std::endl; + c << "time_captured = " << Slic3r::Utils::format_time_ISO8601Z(this->time_captured) << std::endl; + c << "slic3r_version_captured = " << this->slic3r_version_captured.to_string() << std::endl; + c << "comment = " << this->comment << std::endl; + c << "reason = " << this->reason << std::endl; + + // Export the active presets at the time of the snapshot. + c << std::endl << "[presets]" << std::endl; + c << "print = " << this->print << std::endl; + c << "filament = " << this->filaments.front() << std::endl; + for (size_t i = 1; i < this->filaments.size(); ++ i) + c << "filament_" << std::to_string(i) << " = " << this->filaments[i] << std::endl; + c << "printer = " << this->printer << std::endl; + + // Export the vendor configs. + for (const VendorConfig &vc : this->vendor_configs) { + c << std::endl << "[Vendor:" << vc.name << "]" << std::endl; + c << "version = " << vc.version.to_string() << std::endl; + c << "min_slic3r_version = " << vc.min_slic3r_version.to_string() << std::endl; + c << "max_slic3r_version = " << vc.max_slic3r_version.to_string() << std::endl; + } + c.close(); +} + +void Snapshot::export_selections(AppConfig &config) const +{ + assert(filaments.size() >= 1); + config.clear_section("presets"); + config.set("presets", "print", print); + config.set("presets", "filament", filaments.front()); + for (int i = 1; i < filaments.size(); ++i) { + char name[64]; + sprintf(name, "filament_%d", i); + config.set("presets", name, filaments[i]); + } + config.set("presets", "printer", printer); +} + +size_t SnapshotDB::load_db() +{ + boost::filesystem::path snapshots_dir = SnapshotDB::create_db_dir(); + + m_snapshots.clear(); + + // Walk over the snapshot directories and load their index. + std::string errors_cummulative; + for (auto &dir_entry : boost::filesystem::directory_iterator(snapshots_dir)) + if (boost::filesystem::is_directory(dir_entry.status())) { + // Try to read "snapshot.ini". + boost::filesystem::path path_ini = dir_entry.path() / SLIC3R_SNAPSHOT_FILE; + Snapshot snapshot; + try { + snapshot.load_ini(path_ini.string()); + } catch (const std::runtime_error &err) { + errors_cummulative += err.what(); + errors_cummulative += "\n"; + continue; + } + // Check that the name of the snapshot directory matches the snapshot id stored in the snapshot.ini file. + if (dir_entry.path().filename().string() != snapshot.id) { + errors_cummulative += std::string("Snapshot ID ") + snapshot.id + " does not match the snapshot directory " + dir_entry.path().filename().string() + "\n"; + continue; + } + m_snapshots.emplace_back(std::move(snapshot)); + } + + if (! errors_cummulative.empty()) + throw std::runtime_error(errors_cummulative); + return m_snapshots.size(); +} + +static void copy_config_dir_single_level(const boost::filesystem::path &path_src, const boost::filesystem::path &path_dst) +{ + if (! boost::filesystem::is_directory(path_dst) && + ! boost::filesystem::create_directory(path_dst)) + throw std::runtime_error(std::string("Slic3r was unable to create a directory at ") + path_dst.string()); + + for (auto &dir_entry : boost::filesystem::directory_iterator(path_src)) + if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini")) + boost::filesystem::copy_file(dir_entry.path(), path_dst / dir_entry.path().filename(), boost::filesystem::copy_option::overwrite_if_exists); +} + +static void delete_existing_ini_files(const boost::filesystem::path &path) +{ + if (! boost::filesystem::is_directory(path)) + return; + for (auto &dir_entry : boost::filesystem::directory_iterator(path)) + if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini")) + boost::filesystem::remove(dir_entry.path()); +} + +const Snapshot& SnapshotDB::make_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment) +{ + boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); + boost::filesystem::path snapshot_db_dir = SnapshotDB::create_db_dir(); + + // 1) Prepare the snapshot structure. + Snapshot snapshot; + // Snapshot header. + snapshot.time_captured = Slic3r::Utils::get_current_time_utc(); + snapshot.id = Slic3r::Utils::format_time_ISO8601Z(snapshot.time_captured); + snapshot.slic3r_version_captured = *Semver::parse(SLIC3R_VERSION); + snapshot.comment = comment; + snapshot.reason = reason; + // Active presets at the time of the snapshot. + snapshot.print = app_config.get("presets", "print"); + snapshot.filaments.emplace_back(app_config.get("presets", "filament")); + snapshot.printer = app_config.get("presets", "printer"); + for (unsigned int i = 1; i < 1000; ++ i) { + char name[64]; + sprintf(name, "filament_%d", i); + if (! app_config.has("presets", name)) + break; + snapshot.filaments.emplace_back(app_config.get("presets", name)); + } + // Vendor specific config bundles and installed printers. + + // Backup the presets. + boost::filesystem::path snapshot_dir = snapshot_db_dir / snapshot.id; + for (const char *subdir : { "print", "filament", "printer", "vendor" }) + copy_config_dir_single_level(data_dir / subdir, snapshot_dir / subdir); + snapshot.save_ini((snapshot_dir / "snapshot.ini").string()); + m_snapshots.emplace_back(std::move(snapshot)); + return m_snapshots.back(); +} + +void SnapshotDB::restore_snapshot(const std::string &id, AppConfig &app_config) +{ + for (const Snapshot &snapshot : m_snapshots) + if (snapshot.id == id) { + this->restore_snapshot(snapshot, app_config); + return; + } + throw std::runtime_error(std::string("Snapshot with id " + id + " was not found.")); +} + +void SnapshotDB::restore_snapshot(const Snapshot &snapshot, AppConfig &app_config) +{ + boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); + boost::filesystem::path snapshot_db_dir = SnapshotDB::create_db_dir(); + boost::filesystem::path snapshot_dir = snapshot_db_dir / snapshot.id; + + // Remove existing ini files and restore the ini files from the snapshot. + for (const char *subdir : { "print", "filament", "printer", "vendor" }) { + delete_existing_ini_files(data_dir / subdir); + copy_config_dir_single_level(snapshot_dir / subdir, data_dir / subdir); + } + + // Update app_config from the snapshot. + snapshot.export_selections(app_config); + + // Store information about the snapshot. + +} + +boost::filesystem::path SnapshotDB::create_db_dir() +{ + boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); + boost::filesystem::path snapshots_dir = data_dir / SLIC3R_SNAPSHOTS_DIR; + for (const boost::filesystem::path &path : { data_dir, snapshots_dir }) { + boost::filesystem::path subdir = path; + subdir.make_preferred(); + if (! boost::filesystem::is_directory(subdir) && + ! boost::filesystem::create_directory(subdir)) + throw std::runtime_error(std::string("Slic3r was unable to create a directory at ") + subdir.string()); + } + return snapshots_dir; +} + +} // namespace Config +} // namespace GUI +} // namespace Slic3r diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp new file mode 100644 index 0000000000..358797bf76 --- /dev/null +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -0,0 +1,106 @@ +#ifndef slic3r_GUI_Snapshot_ +#define slic3r_GUI_Snapshot_ + +#include +#include + +#include + +#include "../Utils/Semver.hpp" + +namespace Slic3r { + +class AppConfig; + +namespace GUI { +namespace Config { + +// A snapshot contains: +// Slic3r.ini +// vendor/ +// print/ +// filament/ +// printer/ +class Snapshot +{ +public: + enum Reason { + SNAPSHOT_UNKNOWN, + SNAPSHOT_UPGRADE, + SNAPSHOT_DOWNGRADE, + SNAPSHOT_USER, + }; + + Snapshot() { clear(); } + + void clear(); + void load_ini(const std::string &path); + void save_ini(const std::string &path); + + // Export the print / filament / printer selections to be activated into the AppConfig. + void export_selections(AppConfig &config) const; + + // ID of a snapshot should equal to the name of the snapshot directory. + // The ID contains the date/time, reason and comment to be human readable. + std::string id; + std::time_t time_captured; + // Which Slic3r version captured this snapshot? + Semver slic3r_version_captured = Semver::invalid(); + // Comment entered by the user at the start of the snapshot capture. + std::string comment; + Reason reason; + + // Active presets at the time of the snapshot. + std::string print; + std::vector filaments; + std::string printer; + + // Annotation of the vendor configuration stored in the snapshot. + // This information is displayed to the user and used to decide compatibility + // of the configuration stored in the snapshot with the running Slic3r version. + struct VendorConfig { + // Name of the vendor contained in this snapshot. + std::string name; + // Version of the vendor config contained in this snapshot. + Semver version = Semver::invalid(); + // Minimum Slic3r version compatible with this vendor configuration. + Semver min_slic3r_version = Semver::zero(); + // Maximum Slic3r version compatible with this vendor configuration, or empty. + Semver max_slic3r_version = Semver::inf(); + }; + // List of vendor configs contained in this snapshot. + std::vector vendor_configs; +}; + +class SnapshotDB +{ +public: + typedef std::vector::const_iterator const_iterator; + + // Load the snapshot database from the snapshots directory. + // If the snapshot directory or its parent does not exist yet, it will be created. + // Returns a number of snapshots loaded. + size_t load_db(); + + // Create a snapshot directory, copy the vendor config bundles, user print/filament/printer profiles, + // create an index. + const Snapshot& make_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment); + void restore_snapshot(const std::string &id, AppConfig &app_config); + void restore_snapshot(const Snapshot &snapshot, AppConfig &app_config); + + const_iterator begin() const { return m_snapshots.begin(); } + const_iterator end() const { return m_snapshots.end(); } + const std::vector& snapshots() const { return m_snapshots; } + +private: + // Create the snapshots directory if it does not exist yet. + static boost::filesystem::path create_db_dir(); + + std::vector m_snapshots; +}; + +} // namespace Config +} // namespace GUI +} // namespace Slic3r + +#endif /* slic3r_GUI_Snapshot_ */ diff --git a/xs/src/slic3r/Config/Version.cpp b/xs/src/slic3r/Config/Version.cpp new file mode 100644 index 0000000000..1102f31494 --- /dev/null +++ b/xs/src/slic3r/Config/Version.cpp @@ -0,0 +1,136 @@ +#include "Version.hpp" + +#include +#include +#include + +#include "../../libslic3r/libslic3r.h" +#include "../../libslic3r/Config.hpp" + +namespace Slic3r { +namespace GUI { +namespace Config { + +static boost::optional s_current_slic3r_semver = Semver::parse(SLIC3R_VERSION); + +bool Version::is_current_slic3r_supported() const +{ + return this->is_slic3r_supported(*s_current_slic3r_semver); +} + +inline char* left_trim(char *c) +{ + for (; *c == ' ' || *c == '\t'; ++ c); + return c; +} + +inline char* right_trim(char *start) +{ + char *end = start + strlen(start) - 1; + for (; end >= start && (*end == ' ' || *end == '\t'); -- end); + *(++ end) = 0; + return end; +} + +inline std::string unquote_value(char *value, char *end, const std::string &path, int idx_line) +{ + std::string svalue; + if (value == end) { + // Empty string is a valid string. + } else if (*value == '"') { + if (++ value < -- end || *end != '"') + throw file_parser_error("String not enquoted correctly", path, idx_line); + *end = 0; + if (! unescape_string_cstyle(value, svalue)) + throw file_parser_error("Invalid escape sequence inside a quoted string", path, idx_line); + } + return svalue; +} + +inline std::string unquote_version_comment(char *value, char *end, const std::string &path, int idx_line) +{ + std::string svalue; + if (value == end) { + // Empty string is a valid string. + } else if (*value == '"') { + if (++ value < -- end || *end != '"') + throw file_parser_error("Version comment not enquoted correctly", path, idx_line); + *end = 0; + if (! unescape_string_cstyle(value, svalue)) + throw file_parser_error("Invalid escape sequence inside a quoted version comment", path, idx_line); + } + return svalue; +} + +size_t Index::load(const std::string &path) +{ + m_configs.clear(); + + boost::nowide::ifstream ifs(path); + std::string line; + size_t idx_line = 0; + Version ver; + while (std::getline(ifs, line)) { + ++ idx_line; + // Skip the initial white spaces. + char *key = left_trim(const_cast(line.data())); + // Right trim the line. + char *end = right_trim(key); + // Keyword may only contain alphanumeric characters. Semantic version may in addition contain "+.-". + char *key_end = key; + bool maybe_semver = false; + for (;; ++ key) { + if (strchr("+.-", *key) != nullptr) + maybe_semver = true; + else if (! std::isalnum(*key)) + break; + } + if (*key != 0 && *key != ' ' && *key != '\t' && *key != '=') + throw file_parser_error("Invalid keyword or semantic version", path, idx_line); + *key_end = 0; + boost::optional semver; + if (maybe_semver) + semver = Semver::parse(key); + char *value = left_trim(key_end); + if (*value == '=') { + if (semver) + throw file_parser_error("Key cannot be a semantic version", path, idx_line); + // Verify validity of the key / value pair. + std::string svalue = unquote_value(left_trim(++ value), end, path, idx_line); + if (key == "min_sic3r_version" || key == "max_slic3r_version") { + if (! svalue.empty()) + semver = Semver::parse(key); + if (! semver) + throw file_parser_error(std::string(key) + " must referece a valid semantic version", path, idx_line); + if (key == "min_sic3r_version") + ver.min_slic3r_version = *semver; + else + ver.max_slic3r_version = *semver; + } else { + // Ignore unknown keys, as there may come new keys in the future. + } + } + if (! semver) + throw file_parser_error("Invalid semantic version", path, idx_line); + ver.config_version = *semver; + ver.comment = (end <= key_end) ? "" : unquote_version_comment(value, end, path, idx_line); + m_configs.emplace_back(ver); + } + + return m_configs.size(); +} + +Index::const_iterator Index::recommended() const +{ + int idx = -1; + const_iterator highest = m_configs.end(); + for (const_iterator it = this->begin(); it != this->end(); ++ it) + if (it->is_current_slic3r_supported() && + (highest == this->end() || highest->max_slic3r_version < it->max_slic3r_version)) + highest = it; + return highest; +} + +} // namespace Config +} // namespace GUI +} // namespace Slic3r diff --git a/xs/src/slic3r/Config/Version.hpp b/xs/src/slic3r/Config/Version.hpp new file mode 100644 index 0000000000..7af1d4b5b7 --- /dev/null +++ b/xs/src/slic3r/Config/Version.hpp @@ -0,0 +1,75 @@ +#ifndef slic3r_GUI_ConfigIndex_ +#define slic3r_GUI_ConfigIndex_ + +#include +#include + +#include "../../libslic3r/FileParserError.hpp" +#include "../Utils/Semver.hpp" + +namespace Slic3r { +namespace GUI { +namespace Config { + +// Configuration bundle version. +struct Version +{ + // Version of this config. + Semver config_version = Semver::invalid(); + // Minimum Slic3r version, for which this config is applicable. + Semver min_slic3r_version = Semver::zero(); + // Maximum Slic3r version, for which this config is recommended. + // Slic3r should read older configuration and upgrade to a newer format, + // but likely there has been a better configuration published, using the new features. + Semver max_slic3r_version = Semver::inf(); + // Single comment line. + std::string comment; + + bool is_slic3r_supported(const Semver &slicer_version) const { return slicer_version.in_range(min_slic3r_version, max_slic3r_version); } + bool is_current_slic3r_supported() const; +}; + +// Index of vendor specific config bundle versions and Slic3r compatibilities. +// The index is being downloaded from the internet, also an initial version of the index +// is contained in the Slic3r installation. +// +// The index has a simple format: +// +// min_sic3r_version = +// max_slic3r_version = +// config_version "comment" +// config_version "comment" +// ... +// min_slic3r_version = +// max_slic3r_version = +// config_version comment +// config_version comment +// ... +// +// The min_slic3r_version, max_slic3r_version keys are applied to the config versions below, +// empty slic3r version means an open interval. +class Index +{ +public: + typedef std::vector::const_iterator const_iterator; + // Read a config index file in the simple format described in the Index class comment. + // Throws Slic3r::file_parser_error and the standard std file access exceptions. + size_t load(const std::string &path); + + const_iterator begin() const { return m_configs.begin(); } + const_iterator end() const { return m_configs.end(); } + const std::vector& configs() const { return m_configs; } + // Finds a recommended config to be installed for the current Slic3r version. + // Returns configs().end() if such version does not exist in the index. This shall never happen + // if the index is valid. + const_iterator recommended() const; + +private: + std::vector m_configs; +}; + +} // namespace Config +} // namespace GUI +} // namespace Slic3r + +#endif /* slic3r_GUI_ConfigIndex_ */ diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index 3606e90e4c..7fc3b8033a 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -28,6 +28,24 @@ public: } } + static const Semver zero() + { + static semver_t ver = { 0, 0, 0, nullptr, nullptr }; + return Semver(ver); + } + + static const Semver inf() + { + static semver_t ver = { std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), nullptr, nullptr }; + return Semver(ver); + } + + static const Semver invalid() + { + static semver_t ver = { -1, 0, 0, nullptr, nullptr }; + return Semver(ver); + } + Semver(Semver &&other) { *this = std::move(other); } Semver(const Semver &other) { *this = other; } @@ -36,13 +54,16 @@ public: ver = other.ver; other.ver.major = other.ver.minor = other.ver.patch = 0; other.ver.metadata = other.ver.prerelease = nullptr; + return *this; } Semver &operator=(const Semver &other) { + ::semver_free(&ver); ver = other.ver; if (other.ver.metadata != nullptr) { std::strcpy(ver.metadata, other.ver.metadata); } if (other.ver.prerelease != nullptr) { std::strcpy(ver.prerelease, other.ver.prerelease); } + return *this; } ~Semver() { ::semver_free(&ver); } @@ -55,8 +76,10 @@ public: bool operator>=(const Semver &b) const { return ::semver_compare(ver, b.ver) >= 0; } bool operator>(const Semver &b) const { return ::semver_compare(ver, b.ver) == 1; } // We're using '&' instead of the '~' operator here as '~' is unary-only: + // Satisfies patch if Major and minor are equal. bool operator&(const Semver &b) const { return ::semver_satisfies_patch(ver, b.ver); } bool operator^(const Semver &b) const { return ::semver_satisfies_caret(ver, b.ver); } + bool in_range(const Semver &low, const Semver &high) const { return low <= *this && *this <= high; } // Conversion std::string to_string() const { @@ -79,6 +102,7 @@ public: Semver operator-(const Major &b) const { Semver res(*this); return res -= b; } Semver operator-(const Minor &b) const { Semver res(*this); return res -= b; } Semver operator-(const Patch &b) const { Semver res(*this); return res -= b; } + private: semver_t ver; diff --git a/xs/src/slic3r/Utils/Time.cpp b/xs/src/slic3r/Utils/Time.cpp new file mode 100644 index 0000000000..c4123c7bba --- /dev/null +++ b/xs/src/slic3r/Utils/Time.cpp @@ -0,0 +1,63 @@ +#include "Time.hpp" + +namespace Slic3r { +namespace Utils { + +time_t parse_time_ISO8601Z(const std::string &sdate) +{ + int y, M, d, h, m; + float s; + if (sscanf(sdate.c_str(), "%d-%d-%dT%d:%d:%fZ", &y, &M, &d, &h, &m, &s) != 6) + return (time_t)-1; + struct tm tms; + tms.tm_year = y - 1900; // Year since 1900 + tms.tm_mon = M - 1; // 0-11 + tms.tm_mday = d; // 1-31 + tms.tm_hour = h; // 0-23 + tms.tm_min = m; // 0-59 + tms.tm_sec = (int)s; // 0-61 (0-60 in C++11) + return mktime(&tms); +} + +std::string format_time_ISO8601Z(time_t time) +{ + struct tm tms; +#ifdef WIN32 + gmtime_s(time, &tms); +#else + gmtime_r(&tms, time); +#endif + char buf[128]; + sprintf(buf, "%d-%d-%dT%d:%d:%fZ", + tms.tm_year + 1900 + tms.tm_mon + 1 + tms.tm_mday + tms.tm_hour + tms.tm_min + tms.tm_sec); + return buf; +} + +time_t get_current_time_utc() +{ +#ifdef WIN32 + SYSTEMTIME st; + ::GetSystemTime(&st); + std::tm tm; + tm.tm_sec = st.wSecond; + tm.tm_min = st.wMinute; + tm.tm_hour = st.wHour; + tm.tm_mday = st.wDay; + tm.tm_mon = st.wMonth - 1; + tm.tm_year = st.wYear - 1900; + tm.tm_isdst = -1; + return mktime(&tm); +#else + return gmtime(); +#endif +} + +}; // namespace Utils +}; // namespace Slic3r + +#endif /* slic3r_Utils_Time_hpp_ */ diff --git a/xs/src/slic3r/Utils/Time.hpp b/xs/src/slic3r/Utils/Time.hpp new file mode 100644 index 0000000000..6b2fbf8930 --- /dev/null +++ b/xs/src/slic3r/Utils/Time.hpp @@ -0,0 +1,22 @@ +#ifndef slic3r_Utils_Time_hpp_ +#define slic3r_Utils_Time_hpp_ + +#include +#include + +namespace Slic3r { +namespace Utils { + +// Utilities to convert an UTC time_t to/from an ISO8601 time format, +// useful for putting timestamps into file and directory names. +// Returns (time_t)-1 on error. +extern time_t parse_time_ISO8601Z(const std::string &s); +extern std::string format_time_ISO8601Z(time_t time); + +// There is no gmtime() on windows. +time_t get_current_time_utc(); + +}; // namespace Utils +}; // namespace Slic3r + +#endif /* slic3r_Utils_Time_hpp_ */ From e33db203d8b1819cc452e173c39003c33cef5f75 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 9 Apr 2018 09:55:24 +0200 Subject: [PATCH 0132/1150] Next try to use wxDataViewTreeCtrlComboPopup on macOS and Linux: Added: m_cc_presets_choice->UseAltPopupWindow(); m_cc_presets_choice->EnablePopupAnimation(false); like for wxCheckListBoxComboPopup --- xs/src/slic3r/GUI/Tab.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 37ed8f97f7..ee8d1261cb 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -45,8 +45,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) { // FIXME If the following line is removed, the combo box popup list will not react to mouse clicks. // On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10. -// comboCtrl->UseAltPopupWindow(); -// comboCtrl->EnablePopupAnimation(false); + m_cc_presets_choice->UseAltPopupWindow(); + + m_cc_presets_choice->EnablePopupAnimation(false); m_cc_presets_choice->SetPopupControl(popup); popup->SetStringValue(from_u8("Text1")); @@ -57,7 +58,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) { m_cc_presets_choice->SetText(selected); std::string selected_string = selected.ToUTF8().data(); -//! select_preset(selected_string); + select_preset(selected_string); } // popup->OnDataViewTreeCtrlSelection(evt); }); @@ -2159,8 +2160,14 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) auto preset_name = wxString::FromUTF8((preset.name + (preset.is_dirty ? suffix_modified : "")).c_str()); - auto item = popup->AppendItem(preset.is_system ? root_sys : root_def, preset_name, - preset.is_compatible ? icon_compatible : icon_incompatible); + wxDataViewItem item; + if (preset.is_system || preset.is_default) + item = popup->AppendItem(preset.is_system ? root_sys : root_def, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + else { + + } + cnt_items++; if (i == idx_selected){ popup->Select(item); @@ -2168,7 +2175,7 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) } } } - popup->SetItemsCnt(cnt_items); + popup->SetItemsCnt(cnt_items+2); ui->Thaw(); } From 57f6601c9d6b506ebc3aacdb580c59d3c90633d2 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 9 Apr 2018 10:41:34 +0200 Subject: [PATCH 0133/1150] ConfigWizard: Fix logo rendering --- xs/src/slic3r/GUI/ConfigWizard.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 032b5e903b..f13448c374 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -477,10 +477,22 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent) : bullet_white(GUI::from_u8(Slic3r::var("bullet_white.png")), wxBITMAP_TYPE_PNG) { SetMinSize(bg.GetSize()); - Bind(wxEVT_PAINT, &ConfigWizardIndex::on_paint, this); wxClientDC dc(this); text_height = dc.GetCharHeight(); + + // Add logo bitmap. + // This could be done in on_paint() along with the index labels, but I've found it tricky + // to get the bitmap rendered well on all platforms with transparent background. + // In some cases it didn't work at all. And so wxStaticBitmap is used here instead, + // because it has all the platform quirks figured out. + auto *sizer = new wxBoxSizer(wxVERTICAL); + auto *logo = new wxStaticBitmap(this, wxID_ANY, bg); + sizer->AddStretchSpacer(); + sizer->Add(logo); + SetSizer(sizer); + + Bind(wxEVT_PAINT, &ConfigWizardIndex::on_paint, this); } void ConfigWizardIndex::load_items(ConfigWizardPage *firstpage) @@ -509,12 +521,9 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt) }; const auto size = GetClientSize(); - const auto h = size.GetHeight(); - const auto w = size.GetWidth(); - if (h == 0 || w == 0) { return; } + if (size.GetHeight() == 0 || size.GetWidth() == 0) { return; } wxPaintDC dc(this); - dc.DrawBitmap(bg, 0, h - bg.GetHeight(), false); const auto bullet_w = bullet_black.GetSize().GetWidth(); const auto bullet_h = bullet_black.GetSize().GetHeight(); From affaeef2ab18972374d571260cba9c34d578eee7 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 9 Apr 2018 12:41:25 +0200 Subject: [PATCH 0134/1150] Default presets are visible only if it's selected from Preferences --- xs/src/slic3r/GUI/Tab.cpp | 19 +++++++++++++------ xs/src/slic3r/GUI/wxExtensions.cpp | 4 ++-- xs/src/slic3r/GUI/wxExtensions.hpp | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ee8d1261cb..5f727830f9 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -45,9 +45,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) { // FIXME If the following line is removed, the combo box popup list will not react to mouse clicks. // On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10. - m_cc_presets_choice->UseAltPopupWindow(); +// m_cc_presets_choice->UseAltPopupWindow(); - m_cc_presets_choice->EnablePopupAnimation(false); +// m_cc_presets_choice->EnablePopupAnimation(false); m_cc_presets_choice->SetPopupControl(popup); popup->SetStringValue(from_u8("Text1")); @@ -2150,8 +2150,11 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) if (popup != nullptr) { popup->DeleteAllItems(); + auto root_1 = popup->AppendContainer(wxDataViewItem(0), _(L("Root 1"))); auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); - auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); + auto show_def = get_app_config()->get("no_defaults")[0] != '1'; + wxDataViewItem root_def; + if (show_def) root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { const Preset &preset = presets[i]; @@ -2161,11 +2164,15 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) auto preset_name = wxString::FromUTF8((preset.name + (preset.is_dirty ? suffix_modified : "")).c_str()); wxDataViewItem item; - if (preset.is_system || preset.is_default) - item = popup->AppendItem(preset.is_system ? root_sys : root_def, preset_name, + if (preset.is_system) + item = popup->AppendItem(root_sys, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + else if (show_def && preset.is_default) + item = popup->AppendItem(root_def, preset_name, preset.is_compatible ? icon_compatible : icon_incompatible); else { - + item = popup->AppendItem(root_1, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); } cnt_items++; diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index d9f4e520aa..666da7f8a9 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -121,7 +121,7 @@ bool wxDataViewTreeCtrlComboPopup::Create(wxWindow* parent) { return wxDataViewTreeCtrl::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0), wxSize(270, -1)); } - +/* wxSize wxDataViewTreeCtrlComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight) { // matches owner wxComboCtrl's width @@ -140,7 +140,7 @@ wxSize wxDataViewTreeCtrlComboPopup::GetAdjustedSize(int minWidth, int prefHeigh else return wxSize(DefaultWidth, DefaultHeight); } - +*/ void wxDataViewTreeCtrlComboPopup::OnKeyEvent(wxKeyEvent& evt) { // filters out all the keys which are not working properly diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index 701b12dbae..ed8bb9276a 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -43,7 +43,7 @@ public: virtual wxWindow* GetControl() { return this; } virtual void SetStringValue(const wxString& value) { m_text = value; } virtual wxString GetStringValue() const { return m_text; } - virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight); +// virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight); virtual void OnKeyEvent(wxKeyEvent& evt); void OnDataViewTreeCtrlSelection(wxCommandEvent& evt); From 9ebff9ce0046438ff4362e73996867714c367a0d Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 9 Apr 2018 13:35:39 +0200 Subject: [PATCH 0135/1150] Bugfix: a sign mistake was causing unnecessary travel moves --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 39 ++++++++++++--------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index dd75e03edb..ad7d91c50d 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -72,7 +72,7 @@ public: { m_wipe_tower_pos = pos; m_wipe_tower_width = width; m_wipe_tower_depth=depth; m_angle_deg = angle; return (*this); } Writer& set_y_shift(float shift) { - m_current_pos.y += shift-m_y_shift; + m_current_pos.y -= shift-m_y_shift; m_y_shift = shift; return (*this); } @@ -112,8 +112,8 @@ public: // For rotated wipe tower, transform position to printer coordinates - WipeTower::xy rotated_current_pos(WipeTower::xy(m_current_pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); - WipeTower::xy rot(WipeTower::xy(x,y+m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); + WipeTower::xy rotated_current_pos(WipeTower::xy(m_current_pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); // this is where we are + WipeTower::xy rot(WipeTower::xy(x,y+m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg)); // this is where we want to go if (! m_preview_suppressed && e > 0.f && len > 0.) { // Width of a squished extrusion, corrected for the roundings of the squished extrusions. @@ -127,14 +127,14 @@ public: } m_gcode += "G1"; - if (rot.x != rotated_current_pos.x) - m_gcode += set_format_X(rot.x); - if (rot.y != rotated_current_pos.y) + if (rot.x != rotated_current_pos.x) { + m_gcode += set_format_X(rot.x); // Transform current position back to wipe tower coordinates (was updated by set_format_X) + m_current_pos.x = x; + } + if (rot.y != rotated_current_pos.y) { m_gcode += set_format_Y(rot.y); - - // Transform current position back to wipe tower coordinates (was updated by set_format_X) - m_current_pos.x = x; - m_current_pos.y = y; + m_current_pos.y = y; + } if (e != 0.f) m_gcode += set_format_E(e); @@ -179,16 +179,20 @@ public: corners[1] = WipeTower::xy(ld,width,0.f); corners[2] = WipeTower::xy(ld,width,height); corners[3] = WipeTower::xy(ld,0.f,height); - int index_of_closest = (x()-ld.x < ld.x+width-x() ? 0 : 1); - if (y()-ld.y > ld.y+height-x()) // closer to the top - index_of_closest += (index_of_closest==0 ? 3 : 1); - travel(corners[index_of_closest].x,y(),f); // travel to the closest corner - travel(x(),corners[index_of_closest].y,f); + int index_of_closest = 0; + if (x()-ld.x > ld.x+width-x()) // closer to the right + index_of_closest = 1; + if (y()-ld.y > ld.y+height-y()) // closer to the top + index_of_closest = (index_of_closest==0 ? 3 : 2); + + travel(corners[index_of_closest].x, y()); // travel to the closest corner + travel(x(),corners[index_of_closest].y); + int i = index_of_closest; do { ++i; if (i==4) i=0; - this->extrude(corners[i]); + extrude(corners[i]); } while (i != index_of_closest); return (*this); } @@ -611,7 +615,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo else { writer.rectangle(m_wipe_tower_pos,m_wipe_tower_width, m_layer_info->depth + m_perimeter_width); if (layer_finished()) { // no finish_layer will be called, we must wipe the nozzle - writer.travel(m_wipe_tower_pos.x + (writer.x()>m_wipe_tower_pos.x + EPSILON ? 0.f : m_wipe_tower_width), writer.y()); + writer.travel(m_wipe_tower_pos.x + (writer.x()> (m_wipe_tower_pos.x + m_wipe_tower_width) / 2.f ? 0.f : m_wipe_tower_width), writer.y()); } } } @@ -987,6 +991,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() else writer.set_initial_position(fill_box.lu); + box_coordinates box = fill_box; for (int i=0;i<2;++i) { if (m_layer_info->toolchanges_depth() < WT_EPSILON) { // there were no toolchanges on this layer From 254592c849326ed552677ff8e923922f678220c9 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 9 Apr 2018 14:20:44 +0200 Subject: [PATCH 0136/1150] Delete key enabled in Object's Settings Dialog --- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index c7b9049d87..47fd8a0929 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -401,14 +401,17 @@ sub on_tree_key_down { my ($self, $event) = @_; my $keycode = $event->GetKeyCode; # Wx >= 0.9911 - if (defined(&Wx::TreeEvent::GetKeyEvent) && - ($event->GetKeyEvent->GetModifiers & wxMOD_CONTROL)) { - if ($keycode == WXK_UP) { - $event->Skip; - $self->on_btn_move_up; - } elsif ($keycode == WXK_DOWN) { - $event->Skip; - $self->on_btn_move_down; + if (defined(&Wx::TreeEvent::GetKeyEvent)) { + if ($event->GetKeyEvent->GetModifiers & wxMOD_CONTROL) { + if ($keycode == WXK_UP) { + $event->Skip; + $self->on_btn_move_up; + } elsif ($keycode == WXK_DOWN) { + $event->Skip; + $self->on_btn_move_down; + } + } elsif ($keycode == WXK_DELETE) { + $self->on_btn_delete; } } } From 388deb71ab5d03116ef5ec1266c39eea8fb51520 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 9 Apr 2018 14:41:55 +0200 Subject: [PATCH 0137/1150] Adapt settings label colors to light vs dark UI themes --- xs/src/slic3r/GUI/GUI.cpp | 38 ++++++++++++++++++++++++++++++++++---- xs/src/slic3r/GUI/GUI.hpp | 6 ++++-- xs/src/slic3r/GUI/Tab.cpp | 14 +++++++------- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 3eca4e7075..9109e8b5c6 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -1,6 +1,7 @@ #include "GUI.hpp" #include +#include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include "wxExtensions.hpp" @@ -174,6 +176,8 @@ wxFrame *g_wxMainFrame = nullptr; wxNotebook *g_wxTabPanel = nullptr; AppConfig *g_AppConfig = nullptr; PresetBundle *g_PresetBundle= nullptr; +wxColour g_color_label_modified; +wxColour g_color_label_sys; std::vector g_tabs_list; @@ -182,9 +186,22 @@ wxLocale* g_wxLocale; std::shared_ptr m_optgroup; double m_brim_width = 0.0; +static void init_label_colours() +{ + auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + if (luma >= 128) { + g_color_label_modified = wxColour(253, 88, 0); + g_color_label_sys = wxColour(26, 132, 57); + } else { + g_color_label_modified = wxColour(253, 111, 40); + g_color_label_sys = wxColour(115, 220, 103); + } +} + void set_wxapp(wxApp *app) { g_wxApp = app; + init_label_colours(); } void set_main_frame(wxFrame *main_frame) @@ -514,12 +531,25 @@ wxApp* get_app(){ return g_wxApp; } -wxColour* get_modified_label_clr(){ - return new wxColour(253, 88, 0); +const wxColour& get_modified_label_clr() { + return g_color_label_modified; } -wxColour* get_sys_label_clr(){ - return new wxColour(26, 132, 57); +const wxColour& get_sys_label_clr() { + return g_color_label_sys; +} + +unsigned get_colour_approx_luma(const wxColour &colour) +{ + double r = colour.Red(); + double g = colour.Green(); + double b = colour.Blue(); + + std::round(std::sqrt( + r * r * .241 + + g * g * .691 + + b * b * .068 + )); } void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string items, bool initial_value) diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 362b15307b..24c3ec3f40 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -79,8 +79,10 @@ void set_preset_bundle(PresetBundle *preset_bundle); AppConfig* get_app_config(); wxApp* get_app(); -wxColour* get_modified_label_clr(); -wxColour* get_sys_label_clr(); + +const wxColour& get_modified_label_clr(); +const wxColour& get_sys_label_clr(); +unsigned get_colour_approx_luma(const wxColour &colour); void add_debug_menu(wxMenuBar *menu, int event_language_change); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index babff7d801..7db35f5cff 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -265,14 +265,14 @@ void Tab::update_changed_ui() bool is_modified_value = true; std::string sys_icon = wxMSW ? "sys_lock.png" : "lock.png"; std::string icon = wxMSW ? "action_undo.png" : "arrow_undo.png"; - wxColour& color = *get_sys_label_clr(); + wxColour color = get_sys_label_clr(); if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { is_nonsys_value = true; sys_icon = m_nonsys_btn_icon; if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) - color = wxSYS_COLOUR_WINDOWTEXT; + color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); else - color = *get_modified_label_clr(); + color = get_modified_label_clr(); } if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) { @@ -343,7 +343,7 @@ void Tab::update_sys_ui_after_sel_preset() field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); field->m_is_nonsys_value = true; if (field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); + field->m_Label->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); field->m_Label->Refresh(true); } } @@ -386,11 +386,11 @@ void Tab::update_changed_tree_ui() break; } if (sys_page) - m_treectrl->SetItemTextColour(cur_item, *get_sys_label_clr()); + m_treectrl->SetItemTextColour(cur_item, get_sys_label_clr()); else if (modified_page) - m_treectrl->SetItemTextColour(cur_item, *get_modified_label_clr()); + m_treectrl->SetItemTextColour(cur_item, get_modified_label_clr()); else - m_treectrl->SetItemTextColour(cur_item, wxSYS_COLOUR_WINDOWTEXT); + m_treectrl->SetItemTextColour(cur_item, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); page->m_is_nonsys_values = !sys_page; page->m_is_modified_values = modified_page; From bbbb5c9a934e2fd1ad9a65a0af4ce186a43fe133 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 9 Apr 2018 14:49:32 +0200 Subject: [PATCH 0138/1150] Ramming chart is now drawn with double-buffering --- xs/src/slic3r/GUI/RammingChart.cpp | 5 ++++- xs/src/slic3r/GUI/RammingChart.hpp | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp index 87ac9c769c..ca76298af2 100644 --- a/xs/src/slic3r/GUI/RammingChart.cpp +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -1,4 +1,6 @@ #include +#include + #include "RammingChart.hpp" @@ -11,7 +13,8 @@ wxDEFINE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); -void Chart::draw(wxDC& dc) { +void Chart::draw() { + wxAutoBufferedPaintDC dc(this); // unbuffered DC caused flickering on win dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(m_rect); diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp index aa1e7acc7a..7d3b9a9627 100644 --- a/xs/src/slic3r/GUI/RammingChart.hpp +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -16,6 +16,7 @@ public: Chart(wxWindow* parent, wxRect rect,const std::vector>& initial_buttons,int ramming_speed_size, float sampling) : wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize()) { + SetBackgroundStyle(wxBG_STYLE_PAINT); m_rect = wxRect(wxPoint(50,0),rect.GetSize()-wxSize(50,50)); visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed_size, 20.); m_buttons.clear(); @@ -36,7 +37,7 @@ public: std::vector get_ramming_speed(float sampling) const; //returns sampled ramming speed std::vector> get_buttons() const; // returns buttons position - void draw(wxDC& dc); + void draw(); void mouse_clicked(wxMouseEvent& event); void mouse_right_button_clicked(wxMouseEvent& event); @@ -44,7 +45,7 @@ public: void mouse_double_clicked(wxMouseEvent& event); void mouse_left_window(wxMouseEvent&) { m_dragged = nullptr; } void mouse_released(wxMouseEvent&) { m_dragged = nullptr; } - void paint_event(wxPaintEvent&) { wxPaintDC dc(this); draw(dc); } + void paint_event(wxPaintEvent&) { draw(); } DECLARE_EVENT_TABLE() From a8e831e04a433ac41c95937d6e3843e9e51ee881 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 9 Apr 2018 14:52:57 +0200 Subject: [PATCH 0139/1150] rm stray file --- My Settings | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 My Settings diff --git a/My Settings b/My Settings deleted file mode 100644 index f896db7679..0000000000 --- a/My Settings +++ /dev/null @@ -1,27 +0,0 @@ -# generated by Slic3r Prusa Edition 1.38.4 on 2017-12-20 at 11:02:03 -bed_temperature = 0 -bridge_fan_speed = 100 -compatible_printers = -compatible_printers_condition = -cooling = 1 -disable_fan_first_layers = 3 -end_filament_gcode = "; Filament-specific end gcode \n;END gcode for filament\n" -extrusion_multiplier = 1 -fan_always_on = 0 -fan_below_layer_time = 60 -filament_colour = #29b2b2 -filament_cost = 0 -filament_density = 0 -filament_diameter = 3 -filament_max_volumetric_speed = 0 -filament_notes = "" -filament_soluble = 0 -filament_type = PLA -first_layer_bed_temperature = 0 -first_layer_temperature = 205 -max_fan_speed = 100 -min_fan_speed = 35 -min_print_speed = 10 -slowdown_below_layer_time = 5 -start_filament_gcode = "; Filament gcode\n" -temperature = 200 From df328179929b977398f47ee4d8d2a42958d37839 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 9 Apr 2018 14:57:23 +0200 Subject: [PATCH 0140/1150] Auto assign multi-part extruders --- xs/src/libslic3r/Model.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index ad2ce54cd2..d49594c722 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -406,9 +406,24 @@ void Model::convert_multipart_object() ModelObject* object = new ModelObject(this); object->input_file = this->objects.front()->input_file; + unsigned int auto_extruder_id = 1; + char str_extruder[64]; + for (const ModelObject* o : this->objects) for (const ModelVolume* v : o->volumes) - object->add_volume(*v)->name = o->name; + { + ModelVolume* new_v = object->add_volume(*v); + if (new_v != nullptr) + { + new_v->name = o->name; + + sprintf(str_extruder, "%ud", auto_extruder_id); + new_v->config.set_deserialize("extruder", str_extruder); + + if (++auto_extruder_id > 4) + auto_extruder_id = 1; + } + } for (const ModelInstance* i : this->objects.front()->instances) object->add_instance(*i); From b8a06d728ad523b5fa1542840c02e9dc67e0403e Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 9 Apr 2018 16:24:34 +0200 Subject: [PATCH 0141/1150] Fixes in 2DBed --- xs/src/slic3r/GUI/2DBed.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/xs/src/slic3r/GUI/2DBed.cpp b/xs/src/slic3r/GUI/2DBed.cpp index c5d68400da..6d788cf340 100644 --- a/xs/src/slic3r/GUI/2DBed.cpp +++ b/xs/src/slic3r/GUI/2DBed.cpp @@ -1,4 +1,4 @@ -#include "2DBed.hpp"; +#include "2DBed.hpp" #include #include "BoundingBox.hpp" @@ -66,7 +66,7 @@ void Bed_2D::repaint() shift.y - (cbb.max.y - GetSize().GetHeight())); // draw bed fill - dc.SetBrush(*new wxBrush(*new wxColour(255, 255, 255), wxSOLID)); + dc.SetBrush(wxBrush(wxColour(255, 255, 255), wxSOLID)); wxPointList pt_list; for (auto pt: m_bed_shape) { @@ -87,7 +87,7 @@ void Bed_2D::repaint() } polylines = intersection_pl(polylines, bed_polygon); - dc.SetPen(*new wxPen(*new wxColour(230, 230, 230), 1, wxSOLID)); + dc.SetPen(wxPen(wxColour(230, 230, 230), 1, wxSOLID)); for (auto pl : polylines) { for (size_t i = 0; i < pl.points.size()-1; i++){ @@ -98,8 +98,8 @@ void Bed_2D::repaint() } // draw bed contour - dc.SetPen(*new wxPen(*new wxColour(0, 0, 0), 1, wxSOLID)); - dc.SetBrush(*new wxBrush(*new wxColour(0, 0, 0), wxTRANSPARENT)); + dc.SetPen(wxPen(wxColour(0, 0, 0), 1, wxSOLID)); + dc.SetBrush(wxBrush(wxColour(0, 0, 0), wxTRANSPARENT)); dc.DrawPolygon(&pt_list, 0, 0); auto origin_px = to_pixels(Pointf(0, 0)); @@ -108,7 +108,7 @@ void Bed_2D::repaint() auto axes_len = 50; auto arrow_len = 6; auto arrow_angle = Geometry::deg2rad(45.0); - dc.SetPen(*new wxPen(*new wxColour(255, 0, 0), 2, wxSOLID)); // red + dc.SetPen(wxPen(wxColour(255, 0, 0), 2, wxSOLID)); // red auto x_end = Pointf(origin_px.x + axes_len, origin_px.y); dc.DrawLine(wxPoint(origin_px.x, origin_px.y), wxPoint(x_end.x, x_end.y)); for (auto angle : { -arrow_angle, arrow_angle }){ @@ -118,7 +118,7 @@ void Bed_2D::repaint() dc.DrawLine(wxPoint(x_end.x, x_end.y), wxPoint(end.x, end.y)); } - dc.SetPen(*new wxPen(*new wxColour(0, 255, 0), 2, wxSOLID)); // green + dc.SetPen(wxPen(wxColour(0, 255, 0), 2, wxSOLID)); // green auto y_end = Pointf(origin_px.x, origin_px.y - axes_len); dc.DrawLine(wxPoint(origin_px.x, origin_px.y), wxPoint(y_end.x, y_end.y)); for (auto angle : { -arrow_angle, arrow_angle }) { @@ -129,19 +129,23 @@ void Bed_2D::repaint() } // draw origin - dc.SetPen(*new wxPen(*new wxColour(0, 0, 0), 1, wxSOLID)); - dc.SetBrush(*new wxBrush(*new wxColour(0, 0, 0), wxSOLID)); + dc.SetPen(wxPen(wxColour(0, 0, 0), 1, wxSOLID)); + dc.SetBrush(wxBrush(wxColour(0, 0, 0), wxSOLID)); dc.DrawCircle(origin_px.x, origin_px.y, 3); - dc.SetTextForeground(*new wxColour(0, 0, 0)); - dc.SetFont(*new wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL)); - dc.DrawText("(0,0)", origin_px.x + 1, origin_px.y + 2); + static const auto origin_label = wxString("(0,0)"); + dc.SetTextForeground(wxColour(0, 0, 0)); + dc.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL)); + auto extent = dc.GetTextExtent(origin_label); + const auto origin_label_x = origin_px.x <= cw / 2 ? origin_px.x + 1 : origin_px.x - 1 - extent.GetWidth(); + const auto origin_label_y = origin_px.y <= ch / 2 ? origin_px.y + 1 : origin_px.y - 1 - extent.GetHeight(); + dc.DrawText(origin_label, origin_label_x, origin_label_y); // draw current position if (m_pos!= Pointf(0, 0)) { auto pos_px = to_pixels(m_pos); - dc.SetPen(*new wxPen(*new wxColour(200, 0, 0), 2, wxSOLID)); - dc.SetBrush(*new wxBrush(*new wxColour(200, 0, 0), wxTRANSPARENT)); + dc.SetPen(wxPen(wxColour(200, 0, 0), 2, wxSOLID)); + dc.SetBrush(wxBrush(wxColour(200, 0, 0), wxTRANSPARENT)); dc.DrawCircle(pos_px.x, pos_px.y, 5); dc.DrawLine(pos_px.x - 15, pos_px.y, pos_px.x + 15, pos_px.y); From 26511deec0f4b86ee1f7597281f4553fbe91bca2 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 9 Apr 2018 16:39:50 +0200 Subject: [PATCH 0142/1150] Add '-alpha' suffix to data directory for now --- xs/src/libslic3r/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp index 34b9eaa9f1..14736468aa 100644 --- a/xs/src/libslic3r/utils.cpp +++ b/xs/src/libslic3r/utils.cpp @@ -119,7 +119,7 @@ static std::string g_data_dir; void set_data_dir(const std::string &dir) { - g_data_dir = dir; + g_data_dir = dir + "-alpha"; // FIXME: Resolve backcompat problems } const std::string& data_dir() From 674ddcd73a86b93f393ff50856a5111c81438123 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 9 Apr 2018 16:50:17 +0200 Subject: [PATCH 0143/1150] Show preset_tree according to preset inheritance --- xs/src/slic3r/GUI/Preset.cpp | 10 +++++ xs/src/slic3r/GUI/Preset.hpp | 4 +- xs/src/slic3r/GUI/Tab.cpp | 64 ++++++++++++++++++++++++------ xs/src/slic3r/GUI/wxExtensions.cpp | 2 +- 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index d612896a53..845f11c961 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -417,6 +417,16 @@ const Preset* PresetCollection::get_selected_preset_parent() const return (preset == nullptr || preset->is_default || preset->is_external) ? nullptr : preset; } +const Preset* PresetCollection::get_preset_parent(const Preset& child) const +{ + auto *inherits = dynamic_cast(child.config.option("inherits")); + if (inherits == nullptr || inherits->value.empty()) +// return this->get_selected_preset().is_system ? &this->get_selected_preset() : nullptr; + return nullptr; + const Preset* preset = this->find_preset(inherits->value, false); + return (preset == nullptr/* || preset->is_default */|| preset->is_external) ? nullptr : preset; +} + const std::string& PresetCollection::get_suffix_modified() { return g_suffix_modified; } diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index f19f511c30..c038160f4e 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -209,7 +209,9 @@ public: // The parent preset may be a system preset or a user preset, which will be // reflected by the UI. const Preset* get_selected_preset_parent() const; - // Return the selected preset including the user modifications. + // get parent preset for some child preset + const Preset* get_preset_parent(const Preset& child) const; + // Return the selected preset including the user modifications. Preset& get_edited_preset() { return m_edited_preset; } const Preset& get_edited_preset() const { return m_edited_preset; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 5f727830f9..fa414563c2 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -39,7 +39,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) // preset chooser m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY); - m_cc_presets_choice = new wxComboCtrl(panel, wxID_ANY, L("Presets"), wxDefaultPosition, wxSize(270, -1), wxCB_READONLY); + m_cc_presets_choice = new wxComboCtrl(panel, wxID_ANY, L(""), wxDefaultPosition, wxDefaultSize/*wxSize(270, -1)*/, wxCB_READONLY); wxDataViewTreeCtrlComboPopup* popup = new wxDataViewTreeCtrlComboPopup; if (popup != nullptr) { @@ -63,8 +63,8 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) // popup->OnDataViewTreeCtrlSelection(evt); }); - popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); - popup->Bind(wxEVT_KEY_UP, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); +// popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); +// popup->Bind(wxEVT_KEY_UP, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); auto icons = new wxImageList(16, 16, true, 1); popup->SetImageList(icons); @@ -307,7 +307,7 @@ void Tab::update_changed_ui() is_nonsys_value = true; sys_icon = m_nonsys_btn_icon; if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) - color = wxSYS_COLOUR_WINDOWTEXT; + color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); else color = *get_modified_label_clr(); } @@ -380,7 +380,7 @@ void Tab::update_sys_ui_after_sel_preset() field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); field->m_is_nonsys_value = true; if (field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(wxSYS_COLOUR_WINDOWTEXT); + field->m_Label->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); field->m_Label->Refresh(true); } } @@ -427,7 +427,7 @@ void Tab::update_changed_tree_ui() else if (modified_page) m_treectrl->SetItemTextColour(cur_item, *get_modified_label_clr()); else - m_treectrl->SetItemTextColour(cur_item, wxSYS_COLOUR_WINDOWTEXT); + m_treectrl->SetItemTextColour(cur_item, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); page->m_is_nonsys_values = !sys_page; page->m_is_modified_values = modified_page; @@ -2150,11 +2150,16 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) if (popup != nullptr) { popup->DeleteAllItems(); - auto root_1 = popup->AppendContainer(wxDataViewItem(0), _(L("Root 1"))); + + auto root_exp1 = popup->AppendContainer(wxDataViewItem(0), "Exp_root_1"); + auto item1 = popup->AppendItem(root_exp1, "child_1_1"); + auto item2 = popup->AppendItem(root_exp1, "child_1_2"); + auto item3 = popup->AppendItem(item2, "child_2_1"); + auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); + auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); + auto show_def = get_app_config()->get("no_defaults")[0] != '1'; - wxDataViewItem root_def; - if (show_def) root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { const Preset &preset = presets[i]; @@ -2170,9 +2175,41 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) else if (show_def && preset.is_default) item = popup->AppendItem(root_def, preset_name, preset.is_compatible ? icon_compatible : icon_incompatible); - else { - item = popup->AppendItem(root_1, preset_name, - preset.is_compatible ? icon_compatible : icon_incompatible); + else + { + auto parent = m_presets->get_preset_parent(preset); + if (parent == nullptr) + item = popup->AppendItem(root_def, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + else + { + auto parent_name = parent->name; + + wxDataViewTreeStoreContainerNode *node = popup->GetStore()->FindContainerNode(root_sys); + if (node) + { + wxDataViewTreeStoreNodeList::iterator iter; + for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter++) + { + wxDataViewTreeStoreNode* child = *iter; + auto child_item = child->GetItem(); + auto item_text = popup->GetItemText(child_item); + if (item_text == parent_name) + { + auto added_child = popup->AppendItem(child->GetItem(), preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + if (!added_child){ + popup->DeleteItem(child->GetItem()); + auto new_parent = popup->AppendContainer(root_sys, parent_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + popup->AppendItem(new_parent, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + } + break; + } + } + } + } } cnt_items++; @@ -2181,8 +2218,9 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) m_cc_presets_choice->SetText(preset_name); } } + if (popup->GetStore()->GetChildCount(root_def) == 0) + popup->DeleteItem(root_def); } - popup->SetItemsCnt(cnt_items+2); ui->Thaw(); } diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 666da7f8a9..8bc282474e 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -119,7 +119,7 @@ const unsigned int wxDataViewTreeCtrlComboPopup::DefaultItemHeight = 22; bool wxDataViewTreeCtrlComboPopup::Create(wxWindow* parent) { - return wxDataViewTreeCtrl::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0), wxSize(270, -1)); + return wxDataViewTreeCtrl::Create(parent, wxID_ANY/*HIGHEST + 1*/, wxPoint(0, 0), wxDefaultSize/*wxSize(270, -1)*/, wxDV_NO_HEADER); } /* wxSize wxDataViewTreeCtrlComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight) From 32c4cddb91f91a35dd468c3f394911a0b7ad952b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 9 Apr 2018 17:03:37 +0200 Subject: [PATCH 0144/1150] Ported the AboutDialog to C++, thanks @alexrj for the work. New "configuration" menu over the snapshots, user preferences etc. --- lib/Slic3r/GUI.pm | 8 -- lib/Slic3r/GUI/AboutDialog.pm | 122 -------------------------- lib/Slic3r/GUI/MainFrame.pm | 14 +-- xs/CMakeLists.txt | 6 +- xs/lib/Slic3r/XS.pm | 2 +- xs/src/libslic3r/FileParserError.hpp | 4 + xs/src/slic3r/Config/Snapshot.cpp | 36 ++++++++ xs/src/slic3r/Config/Snapshot.hpp | 7 ++ xs/src/slic3r/Config/Version.cpp | 47 +++++++++- xs/src/slic3r/Config/Version.hpp | 12 ++- xs/src/slic3r/GUI/AboutDialog.cpp | 125 +++++++++++++++++++++++++++ xs/src/slic3r/GUI/AboutDialog.hpp | 36 ++++++++ xs/src/slic3r/GUI/GUI.cpp | 74 +++++++++++----- xs/src/slic3r/GUI/GUI.hpp | 13 +-- xs/xsp/GUI.xsp | 12 +-- 15 files changed, 336 insertions(+), 182 deletions(-) delete mode 100644 lib/Slic3r/GUI/AboutDialog.pm create mode 100644 xs/src/slic3r/GUI/AboutDialog.cpp create mode 100644 xs/src/slic3r/GUI/AboutDialog.hpp diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 4ec388c147..88e4745d1e 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -7,7 +7,6 @@ use File::Basename qw(basename); use FindBin; use List::Util qw(first); use Slic3r::GUI::2DBed; -use Slic3r::GUI::AboutDialog; use Slic3r::GUI::BedShapeDialog; use Slic3r::GUI::ConfigWizard; use Slic3r::GUI::Controller; @@ -191,13 +190,6 @@ sub recreate_GUI{ } } -sub about { - my ($self) = @_; - my $about = Slic3r::GUI::AboutDialog->new(undef); - $about->ShowModal; - $about->Destroy; -} - sub system_info { my ($self) = @_; my $slic3r_info = Slic3r::slic3r_info(format => 'html'); diff --git a/lib/Slic3r/GUI/AboutDialog.pm b/lib/Slic3r/GUI/AboutDialog.pm deleted file mode 100644 index 0879ea35b5..0000000000 --- a/lib/Slic3r/GUI/AboutDialog.pm +++ /dev/null @@ -1,122 +0,0 @@ -package Slic3r::GUI::AboutDialog; -use strict; -use warnings; -use utf8; - -use Wx qw(:font :html :misc :dialog :sizer :systemsettings :frame :id); -use Wx::Event qw(EVT_HTML_LINK_CLICKED EVT_LEFT_DOWN EVT_BUTTON); -use Wx::Print; -use Wx::Html; -use base 'Wx::Dialog'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, -1, 'About Slic3r', wxDefaultPosition, [600, 340], wxCAPTION); - - $self->SetBackgroundColour(Wx::wxWHITE); - my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); - $self->SetSizer($hsizer); - - # logo - my $logo = Slic3r::GUI::AboutDialog::Logo->new($self, -1, wxDefaultPosition, wxDefaultSize); - $logo->SetBackgroundColour(Wx::wxWHITE); - $hsizer->Add($logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 30); - - my $vsizer = Wx::BoxSizer->new(wxVERTICAL); - $hsizer->Add($vsizer, 1, wxEXPAND, 0); - - # title - my $title = Wx::StaticText->new($self, -1, $Slic3r::FORK_NAME, wxDefaultPosition, wxDefaultSize); - my $title_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - $title_font->SetWeight(wxFONTWEIGHT_BOLD); - $title_font->SetFamily(wxFONTFAMILY_ROMAN); - $title_font->SetPointSize(24); - $title->SetFont($title_font); - $vsizer->Add($title, 0, wxALIGN_LEFT | wxTOP, 30); - - # version - my $version = Wx::StaticText->new($self, -1, "Version $Slic3r::VERSION", wxDefaultPosition, wxDefaultSize); - my $version_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - $version_font->SetPointSize(&Wx::wxMSW ? 9 : 11); - $version->SetFont($version_font); - $vsizer->Add($version, 0, wxALIGN_LEFT | wxBOTTOM, 10); - - # text - my $text = - '' . - '' . - '' . - 'Copyright © 2016 Vojtech Bubnik, Prusa Research.
' . - 'Copyright © 2011-2016 Alessandro Ranellucci.
' . - 'Slic3r is licensed under the ' . - 'GNU Affero General Public License, version 3.' . - '


' . - 'Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Y. Sapir, Mike Sheldrake and numerous others. ' . - 'Manual by Gary Hodgson. Inspired by the RepRap community.
' . - 'Slic3r logo designed by Corey Daniels, Silk Icon Set designed by Mark James. ' . - '
' . - '' . - ''; - my $html = Wx::HtmlWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER); - my $font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - my $size = &Wx::wxMSW ? 8 : 10; - $html->SetFonts($font->GetFaceName, $font->GetFaceName, [$size, $size, $size, $size, $size, $size, $size]); - $html->SetBorders(2); - $html->SetPage($text); - $vsizer->Add($html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 20); - EVT_HTML_LINK_CLICKED($self, $html, \&link_clicked); - - my $buttons = $self->CreateStdDialogButtonSizer(wxOK); - $self->SetEscapeId(wxID_CLOSE); - EVT_BUTTON($self, wxID_CLOSE, sub { - $self->EndModal(wxID_CLOSE); - $self->Close; - }); - $vsizer->Add($buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3); - - EVT_LEFT_DOWN($self, sub { $self->Close }); - EVT_LEFT_DOWN($logo, sub { $self->Close }); - - return $self; -} - -sub link_clicked { - my ($self, $event) = @_; - - Wx::LaunchDefaultBrowser($event->GetLinkInfo->GetHref); - $event->Skip(0); -} - -package Slic3r::GUI::AboutDialog::Logo; -use Wx qw(:bitmap :dc); -use Wx::Event qw(EVT_PAINT); -use base 'Wx::Panel'; - -sub new { - my $class = shift; - my $self = $class->SUPER::new(@_); - - $self->{logo} = Wx::Bitmap->new(Slic3r::var("Slic3r_192px.png"), wxBITMAP_TYPE_PNG); - $self->SetMinSize(Wx::Size->new($self->{logo}->GetWidth, $self->{logo}->GetHeight)); - - EVT_PAINT($self, \&repaint); - - return $self; -} - -sub repaint { - my ($self, $event) = @_; - - my $dc = Wx::PaintDC->new($self); - $dc->SetBackgroundMode(wxTRANSPARENT); - - my $size = $self->GetSize; - my $logo_w = $self->{logo}->GetWidth; - my $logo_h = $self->{logo}->GetHeight; - $dc->DrawBitmap($self->{logo}, ($size->GetWidth - $logo_w) / 2, ($size->GetHeight - $logo_h) / 2, 1); - - $event->Skip; -} - -1; diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index b2f51b9e1d..31124e432d 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -237,12 +237,6 @@ sub _init_menubar { $self->repair_stl; }, undef, 'wrench.png'); $fileMenu->AppendSeparator(); - # Cmd+, is standard on OS X - what about other operating systems? - $self->_append_menu_item($fileMenu, L("Preferences…\tCtrl+,"), L('Application preferences'), sub { - # Opening the C++ preferences dialog. - Slic3r::GUI::open_preferences_dialog($self->{preferences_event}); - }, wxID_PREFERENCES); - $fileMenu->AppendSeparator(); $self->_append_menu_item($fileMenu, L("&Quit"), L('Quit Slic3r'), sub { $self->Close(0); }, wxID_EXIT); @@ -348,7 +342,7 @@ sub _init_menubar { Wx::LaunchDefaultBrowser('http://github.com/prusa3d/slic3r/issues/new'); }); $self->_append_menu_item($helpMenu, L("&About Slic3r"), L('Show about dialog'), sub { - wxTheApp->about; + Slic3r::GUI::about; }); } @@ -362,11 +356,9 @@ sub _init_menubar { $menubar->Append($self->{object_menu}, L("&Object")) if $self->{object_menu}; $menubar->Append($windowMenu, L("&Window")); $menubar->Append($self->{viewMenu}, L("&View")) if $self->{viewMenu}; - # Add an optional debug menu - # (Select application language from the list of installed languages) - Slic3r::GUI::add_debug_menu($menubar, $self->{lang_ch_event}); + # Add a configuration menu. + Slic3r::GUI::add_config_menu($menubar, $self->{preferences_event}, $self->{lang_ch_event}); $menubar->Append($helpMenu, L("&Help")); - # Add an optional debug menu. In production code, the add_debug_menu() call should do nothing. $self->SetMenuBar($menubar); } } diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 84f169e578..b9a6dbfee2 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -170,6 +170,8 @@ add_library(libslic3r STATIC ) add_library(libslic3r_gui STATIC + ${LIBDIR}/slic3r/GUI/AboutDialog.cpp + ${LIBDIR}/slic3r/GUI/AboutDialog.hpp ${LIBDIR}/slic3r/GUI/AppConfig.cpp ${LIBDIR}/slic3r/GUI/AppConfig.hpp ${LIBDIR}/slic3r/GUI/BitmapCache.cpp @@ -533,13 +535,13 @@ if (SLIC3R_PRUSACONTROL) set(wxWidgets_UseAlienWx 1) if (wxWidgets_UseAlienWx) set(AlienWx_DEBUG 1) - find_package(AlienWx REQUIRED COMPONENTS base core adv) + find_package(AlienWx REQUIRED COMPONENTS base core adv html) include_directories(${AlienWx_INCLUDE_DIRS}) #add_compile_options(${AlienWx_CXX_FLAGS}) add_definitions(${AlienWx_DEFINITIONS}) set(wxWidgets_LIBRARIES ${AlienWx_LIBRARIES}) else () - find_package(wxWidgets REQUIRED COMPONENTS base core adv) + find_package(wxWidgets REQUIRED COMPONENTS base core adv html) include(${wxWidgets_USE_FILE}) endif () add_definitions(-DSLIC3R_GUI -DSLIC3R_PRUS) diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index 47a584343e..06eb041dfb 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -12,7 +12,7 @@ our $VERSION = '0.01'; BEGIN { if ($^O eq 'MSWin32') { eval "use Wx"; -# eval "use Wx::Html"; + eval "use Wx::Html"; eval "use Wx::Print"; # because of some Wx bug, thread creation fails if we don't have this (looks like Wx::Printout is hard-coded in some thread cleanup code) } } diff --git a/xs/src/libslic3r/FileParserError.hpp b/xs/src/libslic3r/FileParserError.hpp index 82a6b328e8..3f560fa4f5 100644 --- a/xs/src/libslic3r/FileParserError.hpp +++ b/xs/src/libslic3r/FileParserError.hpp @@ -4,6 +4,7 @@ #include "libslic3r.h" #include +#include #include namespace Slic3r { @@ -15,6 +16,9 @@ public: file_parser_error(const std::string &msg, const std::string &file, unsigned long line = 0) : std::runtime_error(format_what(msg, file, line)), m_message(msg), m_filename(file), m_line(line) {} + file_parser_error(const std::string &msg, const boost::filesystem::path &file, unsigned long line = 0) : + std::runtime_error(format_what(msg, file.string(), line)), + m_message(msg), m_filename(file.string()), m_line(line) {} // gcc 3.4.2 complains about lack of throw specifier on compiler // generated dtor ~file_parser_error() throw() {} diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index 559e4c63cb..91f02ab257 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -205,6 +205,22 @@ size_t SnapshotDB::load_db() return m_snapshots.size(); } +void SnapshotDB::update_slic3r_versions(std::vector &index_db) +{ + for (Snapshot &snapshot : m_snapshots) { + for (Snapshot::VendorConfig &vendor_config : snapshot.vendor_configs) { + auto it = std::find_if(index_db.begin(), index_db.end(), [&vendor_config](const Index &idx) { return idx.vendor() == vendor_config.name; }); + if (it != index_db.end()) { + Index::const_iterator it_version = it->find(vendor_config.version); + if (it_version != it->end()) { + vendor_config.min_slic3r_version = it_version->min_slic3r_version; + vendor_config.max_slic3r_version = it_version->max_slic3r_version; + } + } + } + } +} + static void copy_config_dir_single_level(const boost::filesystem::path &path_src, const boost::filesystem::path &path_dst) { if (! boost::filesystem::is_directory(path_dst) && @@ -303,6 +319,26 @@ boost::filesystem::path SnapshotDB::create_db_dir() return snapshots_dir; } +SnapshotDB& SnapshotDB::singleton() +{ + static SnapshotDB instance; + bool loaded = false; + if (! loaded) { + try { + loaded = true; + // Load the snapshot database. + instance.load_db(); + // Load the vendor specific configuration indices. + std::vector index_db = Index::load_db(); + // Update the min / max slic3r versions compatible with the configurations stored inside the snapshots + // based on the min / max slic3r versions defined by the vendor specific config indices. + instance.update_slic3r_versions(index_db); + } catch (std::exception &ex) { + } + } + return instance; +} + } // namespace Config } // namespace GUI } // namespace Slic3r diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp index 358797bf76..1d02c8650b 100644 --- a/xs/src/slic3r/Config/Snapshot.hpp +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -6,6 +6,7 @@ #include +#include "Version.hpp" #include "../Utils/Semver.hpp" namespace Slic3r { @@ -15,6 +16,8 @@ class AppConfig; namespace GUI { namespace Config { +class Version; + // A snapshot contains: // Slic3r.ini // vendor/ @@ -75,12 +78,16 @@ public: class SnapshotDB { public: + // Initialize the SnapshotDB singleton instance. Load the database if it has not been loaded yet. + static SnapshotDB& singleton(); + typedef std::vector::const_iterator const_iterator; // Load the snapshot database from the snapshots directory. // If the snapshot directory or its parent does not exist yet, it will be created. // Returns a number of snapshots loaded. size_t load_db(); + void update_slic3r_versions(std::vector &index_db); // Create a snapshot directory, copy the vendor config bundles, user print/filament/printer profiles, // create an index. diff --git a/xs/src/slic3r/Config/Version.cpp b/xs/src/slic3r/Config/Version.cpp index 1102f31494..cc961829de 100644 --- a/xs/src/slic3r/Config/Version.cpp +++ b/xs/src/slic3r/Config/Version.cpp @@ -6,6 +6,8 @@ #include "../../libslic3r/libslic3r.h" #include "../../libslic3r/Config.hpp" +#include "../../libslic3r/FileParserError.hpp" +#include "../../libslic3r/Utils.hpp" namespace Slic3r { namespace GUI { @@ -62,11 +64,12 @@ inline std::string unquote_version_comment(char *value, char *end, const std::st return svalue; } -size_t Index::load(const std::string &path) +size_t Index::load(const boost::filesystem::path &path) { m_configs.clear(); + m_vendor = path.stem().string(); - boost::nowide::ifstream ifs(path); + boost::nowide::ifstream ifs(path.string()); std::string line; size_t idx_line = 0; Version ver; @@ -96,7 +99,7 @@ size_t Index::load(const std::string &path) if (semver) throw file_parser_error("Key cannot be a semantic version", path, idx_line); // Verify validity of the key / value pair. - std::string svalue = unquote_value(left_trim(++ value), end, path, idx_line); + std::string svalue = unquote_value(left_trim(++ value), end, path.string(), idx_line); if (key == "min_sic3r_version" || key == "max_slic3r_version") { if (! svalue.empty()) semver = Semver::parse(key); @@ -113,13 +116,24 @@ size_t Index::load(const std::string &path) if (! semver) throw file_parser_error("Invalid semantic version", path, idx_line); ver.config_version = *semver; - ver.comment = (end <= key_end) ? "" : unquote_version_comment(value, end, path, idx_line); + ver.comment = (end <= key_end) ? "" : unquote_version_comment(value, end, path.string(), idx_line); m_configs.emplace_back(ver); } + // Sort the configs by their version. + std::sort(m_configs.begin(), m_configs.end(), [](const Version &v1, const Version &v2) { return v1.config_version < v2.config_version; }); return m_configs.size(); } +Index::const_iterator Index::find(const Semver &ver) +{ + Version key; + key.config_version = ver; + auto it = std::lower_bound(m_configs.begin(), m_configs.end(), key, + [](const Version &v1, const Version &v2) { return v1.config_version < v2.config_version; }); + return (it == m_configs.end() || it->config_version == ver) ? it : m_configs.end(); +} + Index::const_iterator Index::recommended() const { int idx = -1; @@ -131,6 +145,31 @@ Index::const_iterator Index::recommended() const return highest; } +std::vector Index::load_db() +{ + boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); + boost::filesystem::path vendor_dir = data_dir / "vendor"; + + std::vector index_db; + std::string errors_cummulative; + for (auto &dir_entry : boost::filesystem::directory_iterator(vendor_dir)) + if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".idx")) { + Index idx; + try { + idx.load(dir_entry.path()); + } catch (const std::runtime_error &err) { + errors_cummulative += err.what(); + errors_cummulative += "\n"; + continue; + } + index_db.emplace_back(std::move(idx)); + } + + if (! errors_cummulative.empty()) + throw std::runtime_error(errors_cummulative); + return index_db; +} + } // namespace Config } // namespace GUI } // namespace Slic3r diff --git a/xs/src/slic3r/Config/Version.hpp b/xs/src/slic3r/Config/Version.hpp index 7af1d4b5b7..43512e82f5 100644 --- a/xs/src/slic3r/Config/Version.hpp +++ b/xs/src/slic3r/Config/Version.hpp @@ -4,6 +4,8 @@ #include #include +#include + #include "../../libslic3r/FileParserError.hpp" #include "../Utils/Semver.hpp" @@ -54,17 +56,25 @@ public: typedef std::vector::const_iterator const_iterator; // Read a config index file in the simple format described in the Index class comment. // Throws Slic3r::file_parser_error and the standard std file access exceptions. - size_t load(const std::string &path); + size_t load(const boost::filesystem::path &path); + + const std::string& vendor() const { return m_vendor; } const_iterator begin() const { return m_configs.begin(); } const_iterator end() const { return m_configs.end(); } + const_iterator find(const Semver &ver); const std::vector& configs() const { return m_configs; } // Finds a recommended config to be installed for the current Slic3r version. // Returns configs().end() if such version does not exist in the index. This shall never happen // if the index is valid. const_iterator recommended() const; + // Load all vendor specific indices. + // Throws Slic3r::file_parser_error and the standard std file access exceptions. + static std::vector load_db(); + private: + std::string m_vendor; std::vector m_configs; }; diff --git a/xs/src/slic3r/GUI/AboutDialog.cpp b/xs/src/slic3r/GUI/AboutDialog.cpp new file mode 100644 index 0000000000..49cfff2bdd --- /dev/null +++ b/xs/src/slic3r/GUI/AboutDialog.cpp @@ -0,0 +1,125 @@ +#include "AboutDialog.hpp" + +#include "../../libslic3r/Utils.hpp" + +namespace Slic3r { +namespace GUI { + +AboutDialogLogo::AboutDialogLogo(wxWindow* parent) + : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize) +{ + this->SetBackgroundColour(*wxWHITE); + this->logo = wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG); + this->SetMinSize(this->logo.GetSize()); + + this->Bind(wxEVT_PAINT, &AboutDialogLogo::onRepaint, this); +} + +void AboutDialogLogo::onRepaint(wxEvent &event) +{ + wxPaintDC dc(this); + dc.SetBackgroundMode(wxTRANSPARENT); + + wxSize size = this->GetSize(); + int logo_w = this->logo.GetWidth(); + int logo_h = this->logo.GetHeight(); + dc.DrawBitmap(this->logo, (size.GetWidth() - logo_w)/2, (size.GetHeight() - logo_h)/2, true); + + event.Skip(); +} + +AboutDialog::AboutDialog() + : wxDialog(NULL, wxID_ANY, _(L("About Slic3r")), wxDefaultPosition, wxSize(600, 340), wxCAPTION) +{ + this->SetBackgroundColour(*wxWHITE); + + wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL); + this->SetSizer(hsizer); + + // logo + AboutDialogLogo* logo = new AboutDialogLogo(this); + hsizer->Add(logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 30); + + wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); + hsizer->Add(vsizer, 1, wxEXPAND, 0); + + // title + { + wxStaticText* title = new wxStaticText(this, wxID_ANY, "Slic3r Prusa Edition", wxDefaultPosition, wxDefaultSize); + wxFont title_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + title_font.SetWeight(wxFONTWEIGHT_BOLD); + title_font.SetFamily(wxFONTFAMILY_ROMAN); + title_font.SetPointSize(24); + title->SetFont(title_font); + vsizer->Add(title, 0, wxALIGN_LEFT | wxTOP, 30); + } + + // version + { + std::string version_string = _(L("Version ")) + std::string(SLIC3R_VERSION); + wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize); + wxFont version_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + #ifdef __WXMSW__ + version_font.SetPointSize(9); + #else + version_font.SetPointSize(11); + #endif + version->SetFont(version_font); + vsizer->Add(version, 0, wxALIGN_LEFT | wxBOTTOM, 10); + } + + // text + wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER); + { + wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + #ifdef __WXMSW__ + int size[] = {8,8,8,8,8,8,8}; + #else + int size[] = {11,11,11,11,11,11,11}; + #endif + html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); + html->SetBorders(2); + const char* text = + "" + "" + "" + "Copyright © 2016-2018 Prusa Research.
" + "Copyright © 2011-2017 Alessandro Ranellucci.
" + "Slic3r is licensed under the " + "GNU Affero General Public License, version 3." + "


" + "Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others. " + "Manual by Gary Hodgson. Inspired by the RepRap community.
" + "Slic3r logo designed by Corey Daniels, Silk Icon Set designed by Mark James. " + "
" + "" + ""; + html->SetPage(text); + vsizer->Add(html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 20); + html->Bind(wxEVT_HTML_LINK_CLICKED, &AboutDialog::onLinkClicked, this); + } + + wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE); + this->SetEscapeId(wxID_CLOSE); + this->Bind(wxEVT_BUTTON, &AboutDialog::onCloseDialog, this, wxID_CLOSE); + vsizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3); + + this->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this); + logo->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this); + html->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this); +} + +void AboutDialog::onLinkClicked(wxHtmlLinkEvent &event) +{ + wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref()); + event.Skip(false); +} + +void AboutDialog::onCloseDialog(wxEvent &) +{ + this->EndModal(wxID_CLOSE); + this->Close(); +} + +} // namespace GUI +} // namespace Slic3r diff --git a/xs/src/slic3r/GUI/AboutDialog.hpp b/xs/src/slic3r/GUI/AboutDialog.hpp new file mode 100644 index 0000000000..01f7564c50 --- /dev/null +++ b/xs/src/slic3r/GUI/AboutDialog.hpp @@ -0,0 +1,36 @@ +#ifndef slic3r_GUI_AboutDialog_hpp_ +#define slic3r_GUI_AboutDialog_hpp_ + +#include "GUI.hpp" + +#include +#include +#include + +namespace Slic3r { +namespace GUI { + +class AboutDialogLogo : public wxPanel +{ +public: + AboutDialogLogo(wxWindow* parent); + +private: + wxBitmap logo; + void onRepaint(wxEvent &event); +}; + +class AboutDialog : public wxDialog +{ +public: + AboutDialog(); + +private: + void onLinkClicked(wxHtmlLinkEvent &event); + void onCloseDialog(wxEvent &); +}; + +} // namespace GUI +} // namespace Slic3r + +#endif diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 3eca4e7075..48d56ff119 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -42,6 +42,7 @@ #include "Tab.hpp" #include "TabIface.hpp" +#include "AboutDialog.hpp" #include "AppConfig.hpp" #include "Utils.hpp" #include "Preferences.hpp" @@ -330,32 +331,56 @@ void get_installed_languages(wxArrayString & names, } } -void add_debug_menu(wxMenuBar *menu, int event_language_change) +enum ConfigMenuIDs { + ConfigMenuWizard, + ConfigMenuSnapshots, + ConfigMenuTakeSnapshot, + ConfigMenuUpdate, + ConfigMenuPreferences, + ConfigMenuLanguage, + ConfigMenuCnt, +}; + +void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change) { -//#if 0 auto local_menu = new wxMenu(); - local_menu->Append(wxWindow::NewControlId(1), _(L("Change Application Language"))); - local_menu->Bind(wxEVT_MENU, [event_language_change](wxEvent&){ - wxArrayString names; - wxArrayLong identifiers; - get_installed_languages(names, identifiers); - if (select_language(names, identifiers)){ - save_language(); - show_info(g_wxTabPanel, _(L("Application will be restarted")), _(L("Attention!"))); - if (event_language_change > 0) { - wxCommandEvent event(event_language_change); - g_wxApp->ProcessEvent(event); + wxWindowID config_id_base = wxWindow::NewControlId((int)ConfigMenuCnt); + + // Cmd+, is standard on OS X - what about other operating systems? + local_menu->Append(config_id_base + ConfigMenuWizard, _(L("Configuration Wizard\u2026")), _(L("Run configuration wizard"))); + local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots\u2026")), _(L("Inspect / activate configuration snapshots"))); + local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration Snapshot")), _(L("Capture a configuration snapshot"))); + local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); + local_menu->AppendSeparator(); + local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences\u2026\tCtrl+,")), _(L("Application preferences"))); + local_menu->AppendSeparator(); + local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); + local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ + switch (event.GetId() - config_id_base) { + case ConfigMenuPreferences: + { + auto dlg = new PreferencesDialog(g_wxMainFrame, event_preferences_changed); + dlg->ShowModal(); + break; + } + case ConfigMenuLanguage: + { + wxArrayString names; + wxArrayLong identifiers; + get_installed_languages(names, identifiers); + if (select_language(names, identifiers)) { + save_language(); + show_info(g_wxTabPanel, _(L("Application will be restarted")), _(L("Attention!"))); + if (event_language_change > 0) { + wxCommandEvent event(event_language_change); + g_wxApp->ProcessEvent(event); + } } + break; + } } }); - menu->Append(local_menu, _(L("&Localization"))); -//#endif -} - -void open_preferences_dialog(int event_preferences) -{ - auto dlg = new PreferencesDialog(g_wxMainFrame, event_preferences); - dlg->ShowModal(); + menu->Append(local_menu, _(L("&Configuration"))); } void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) @@ -737,4 +762,11 @@ int get_export_option(wxFileDialog* dlg) return 0; } +void about() +{ + AboutDialog dlg; + dlg.ShowModal(); + dlg.Destroy(); +} + } } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 362b15307b..0cbdf8729e 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -82,10 +82,7 @@ wxApp* get_app(); wxColour* get_modified_label_clr(); wxColour* get_sys_label_clr(); -void add_debug_menu(wxMenuBar *menu, int event_language_change); - -// Create "Preferences" dialog after selecting menu "Preferences" in Perl part -void open_preferences_dialog(int event_preferences); +void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change); // Create a new preset tab (print, filament and printer), void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed); @@ -134,7 +131,11 @@ ConfigOptionsGroup* get_optgroup(); void add_export_option(wxFileDialog* dlg, const std::string& format); int get_export_option(wxFileDialog* dlg); -} -} + +// Display an About dialog +void about(); + +} // namespace GUI +} // namespace Slic3r #endif diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 1376ff164b..c8d76adbab 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -9,6 +9,9 @@ %package{Slic3r::GUI}; +void about() + %code{% Slic3r::GUI::about(); %}; + void disable_screensaver() %code{% Slic3r::GUI::disable_screensaver(); %}; @@ -32,9 +35,9 @@ void set_main_frame(SV *ui) 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, int event_language_change) - %code%{ Slic3r::GUI::add_debug_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_language_change); %}; + +void add_config_menu(SV *ui, int event_preferences_changed, int event_language_change) + %code%{ Slic3r::GUI::add_config_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_preferences_changed, event_language_change); %}; void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) %code%{ Slic3r::GUI::create_preset_tabs(no_controller, event_value_change, event_presets_changed); %}; @@ -54,9 +57,6 @@ int combochecklist_get_flags(SV *ui) void set_app_config(AppConfig *app_config) %code%{ Slic3r::GUI::set_app_config(app_config); %}; -void open_preferences_dialog(int preferences_event) - %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %}; - void set_preset_bundle(PresetBundle *preset_bundle) %code%{ Slic3r::GUI::set_preset_bundle(preset_bundle); %}; From 0cca7bb5e736c89088cc84cebb3702efbc676a1a Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 9 Apr 2018 17:09:00 +0200 Subject: [PATCH 0145/1150] Dont use select_preset from preset_tree... --- xs/src/slic3r/GUI/Tab.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index fa414563c2..a40da002ba 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -58,9 +58,8 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) { m_cc_presets_choice->SetText(selected); std::string selected_string = selected.ToUTF8().data(); - select_preset(selected_string); +// select_preset(selected_string); } -// popup->OnDataViewTreeCtrlSelection(evt); }); // popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); @@ -2151,11 +2150,6 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) { popup->DeleteAllItems(); - auto root_exp1 = popup->AppendContainer(wxDataViewItem(0), "Exp_root_1"); - auto item1 = popup->AppendItem(root_exp1, "child_1_1"); - auto item2 = popup->AppendItem(root_exp1, "child_1_2"); - auto item3 = popup->AppendItem(item2, "child_2_1"); - auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); From fa4462514bb3b5a9e79e6819d007112169c6e787 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 10 Apr 2018 10:31:58 +0200 Subject: [PATCH 0146/1150] Added preset grouping to PresetCollection::update_tab_ui --- xs/src/slic3r/GUI/2DBed.hpp | 6 ++++-- xs/src/slic3r/GUI/Preset.cpp | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/xs/src/slic3r/GUI/2DBed.hpp b/xs/src/slic3r/GUI/2DBed.hpp index 859417efb0..a170b708ad 100644 --- a/xs/src/slic3r/GUI/2DBed.hpp +++ b/xs/src/slic3r/GUI/2DBed.hpp @@ -6,7 +6,7 @@ namespace GUI { class Bed_2D : public wxPanel { - bool m_user_drawn_background = false; + bool m_user_drawn_background = true; bool m_painted = false; bool m_interactive = false; @@ -26,7 +26,9 @@ public: { Create(parent, wxID_ANY, wxDefaultPosition, wxSize(250, -1), wxTAB_TRAVERSAL); // m_user_drawn_background = $^O ne 'darwin'; - m_user_drawn_background = true; +#ifdef __APPLE__ + m_user_drawn_background = false; +#endif /*__APPLE__*/ Bind(wxEVT_PAINT, ([this](wxPaintEvent e) { repaint(); })); // EVT_ERASE_BACKGROUND($self, sub{}) if $self->{user_drawn_background}; // Bind(EVT_MOUSE_EVENTS, ([this](wxMouseEvent event){/*mouse_event()*/; })); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 845f11c961..bc34e193a9 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -531,16 +531,44 @@ void PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompatibl return; ui->Freeze(); ui->Clear(); + std::map nonsys_presets; + wxString selected = ""; for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++ i) { const Preset &preset = this->m_presets[i]; if (! preset.is_visible || (! show_incompatible && ! preset.is_compatible && i != m_idx_selected)) continue; const wxBitmap *bmp = preset.is_compatible ? m_bitmap_compatible : m_bitmap_incompatible; - ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), - (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); - if (i == m_idx_selected) - ui->SetSelection(ui->GetCount() - 1); +// ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), +// (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); +// if (i == m_idx_selected) +// ui->SetSelection(ui->GetCount() - 1); + + if (preset.is_default || preset.is_system){ + ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), + (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); + if (i == m_idx_selected) + ui->SetSelection(ui->GetCount() - 1); + } + else + { + nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), preset.is_compatible); + if (i == m_idx_selected) + selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); + } + if (preset.is_default) + ui->Append("______________________", wxNullBitmap); } + if (!nonsys_presets.empty()) + { + ui->Append("______________________", wxNullBitmap); + for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { + const wxBitmap *bmp = it->second ? m_bitmap_compatible : m_bitmap_incompatible; + ui->Append(it->first, + (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); + if (it->first == selected) + ui->SetSelection(ui->GetCount() - 1); + } + } ui->Thaw(); } From f49a7be90c93fbfa7c9d81f1560dea54b8116186 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 10 Apr 2018 10:50:18 +0200 Subject: [PATCH 0147/1150] An attempt to get RammingChart background colour consistent with its parent(s) on all platforms --- xs/src/slic3r/GUI/RammingChart.cpp | 5 +++++ xs/src/slic3r/GUI/WipeTowerDialog.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp index ca76298af2..1ef43be026 100644 --- a/xs/src/slic3r/GUI/RammingChart.cpp +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -15,6 +15,11 @@ wxDEFINE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); void Chart::draw() { wxAutoBufferedPaintDC dc(this); // unbuffered DC caused flickering on win + + dc.SetBrush(GetBackgroundColour()); + dc.SetPen(GetBackgroundColour()); + dc.DrawRectangle(GetClientRect()); // otherwise the background would end up black on windows + dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(m_rect); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 421ae272da..b34de07458 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -14,6 +14,13 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) : wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { m_panel_ramming = new RammingPanel(this,parameters); + + // Not found another way of getting the background colours of RammingDialog, RammingPanel and Chart correct than setting + // them all explicitely. Reading the parent colour yielded colour that didn't really match it, no wxSYS_COLOUR_... matched + // colour used for the dialog. Same issue (and "solution") here : https://forums.wxwidgets.org/viewtopic.php?f=1&t=39608 + // Whoever can fix this, feel free to do so. + this-> SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK)); + m_panel_ramming->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK)); m_panel_ramming->Show(true); this->Show(); @@ -63,6 +70,7 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) buttons.push_back(std::make_pair(x, y)); m_chart = new Chart(this, wxRect(10, 10, 480, 360), buttons, ramming_speed_size, 0.25f); + m_chart->SetBackgroundColour(parent->GetBackgroundColour()); // see comment in RammingDialog constructor sizer_chart->Add(m_chart, 0, wxALL, 5); m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,0.,5.0,3.,0.5); From a541f5dfe1d3b7b0dc51e38d09b3883a3a14aa12 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 10 Apr 2018 11:43:04 +0200 Subject: [PATCH 0148/1150] Fix of the fix --- xs/src/slic3r/GUI/GUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 9109e8b5c6..9450f44ae1 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -545,7 +545,7 @@ unsigned get_colour_approx_luma(const wxColour &colour) double g = colour.Green(); double b = colour.Blue(); - std::round(std::sqrt( + return std::round(std::sqrt( r * r * .241 + g * g * .691 + b * b * .068 From 9993f2215d56d7dfdf727794b590756893a2ba39 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 10 Apr 2018 12:17:55 +0200 Subject: [PATCH 0149/1150] Auto assignement of extruder, after object's splitting to parts --- xs/src/libslic3r/Model.cpp | 40 +++++++++++++++++++++++++++++--------- xs/src/libslic3r/Model.hpp | 6 ++++++ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index d49594c722..5611067132 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -16,6 +16,8 @@ namespace Slic3r { + unsigned int Model::s_auto_extruder_id = 1; + Model::Model(const Model &other) { // copy materials @@ -405,9 +407,8 @@ void Model::convert_multipart_object() ModelObject* object = new ModelObject(this); object->input_file = this->objects.front()->input_file; - - unsigned int auto_extruder_id = 1; - char str_extruder[64]; + + reset_auto_extruder_id(); for (const ModelObject* o : this->objects) for (const ModelVolume* v : o->volumes) @@ -416,12 +417,7 @@ void Model::convert_multipart_object() if (new_v != nullptr) { new_v->name = o->name; - - sprintf(str_extruder, "%ud", auto_extruder_id); - new_v->config.set_deserialize("extruder", str_extruder); - - if (++auto_extruder_id > 4) - auto_extruder_id = 1; + new_v->config.set_deserialize("extruder", get_auto_extruder_id_as_string()); } } @@ -481,6 +477,28 @@ bool Model::fits_print_volume(const FullPrintConfig &config) const return print_volume.contains(transformed_bounding_box()); } +unsigned int Model::get_auto_extruder_id() +{ + unsigned int id = s_auto_extruder_id; + + if (++s_auto_extruder_id > 4) + reset_auto_extruder_id(); + + return id; +} + +std::string Model::get_auto_extruder_id_as_string() +{ + char str_extruder[64]; + sprintf(str_extruder, "%ud", get_auto_extruder_id()); + return str_extruder; +} + +void Model::reset_auto_extruder_id() +{ + s_auto_extruder_id = 1; +} + ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volumes) : name(other.name), input_file(other.input_file), @@ -1010,6 +1028,9 @@ size_t ModelVolume::split() size_t idx = 0; size_t ivolume = std::find(this->object->volumes.begin(), this->object->volumes.end(), this) - this->object->volumes.begin(); std::string name = this->name; + + Model::reset_auto_extruder_id(); + for (TriangleMesh *mesh : meshptrs) { mesh->repair(); if (idx == 0) @@ -1019,6 +1040,7 @@ size_t ModelVolume::split() char str_idx[64]; sprintf(str_idx, "_%d", idx + 1); this->object->volumes[ivolume]->name = name + str_idx; + this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string()); delete mesh; ++ idx; } diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index bf7f60e36c..0c0ffe7769 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -230,6 +230,8 @@ private: // all objects may share mutliple materials. class Model { + static unsigned int s_auto_extruder_id; + public: // Materials are owned by a model and referenced by objects through t_model_material_id. // Single material may be shared by multiple models. @@ -288,6 +290,10 @@ public: bool fits_print_volume(const FullPrintConfig &config) const; void print_info() const { for (const ModelObject *o : this->objects) o->print_info(); } + + static unsigned int get_auto_extruder_id(); + static std::string get_auto_extruder_id_as_string(); + static void reset_auto_extruder_id(); }; } From a81f78045b209420cbc243af27890bd196cc2697 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 10 Apr 2018 12:47:09 +0200 Subject: [PATCH 0150/1150] Delete key enabled in Object's Settings Dialog also for 3D view --- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 47fd8a0929..f7e38ed873 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -9,7 +9,7 @@ use utf8; use File::Basename qw(basename); use Wx qw(:misc :sizer :treectrl :button :keycode wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG wxID_CANCEL wxMOD_CONTROL wxTheApp); -use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED EVT_TREE_KEY_DOWN); +use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED EVT_TREE_KEY_DOWN EVT_KEY_DOWN); use base 'Wx::Panel'; use constant ICON_OBJECT => 0; @@ -191,6 +191,14 @@ sub new { EVT_BUTTON($self, $self->{btn_split}, \&on_btn_split); EVT_BUTTON($self, $self->{btn_move_up}, \&on_btn_move_up); EVT_BUTTON($self, $self->{btn_move_down}, \&on_btn_move_down); + EVT_KEY_DOWN($canvas, sub { + my ($canvas, $event) = @_; + if ($event->GetKeyCode == WXK_DELETE) { + $canvas->GetParent->on_btn_delete; + } else { + $event->Skip; + } + }); $self->reload_tree; From b961711f28c90886b32ce88a2130113dac41f455 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 10 Apr 2018 13:39:10 +0200 Subject: [PATCH 0151/1150] Fixed autoscale of objects after loading --- lib/Slic3r/GUI/Plater.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index ecac430a44..c74b2d32c3 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -737,7 +737,7 @@ sub load_model_objects { { # if the object is too large (more than 5 times the bed), scale it down my $size = $o->bounding_box->size; - my $ratio = max(@$size[X,Y]) / unscale(max(@$bed_size[X,Y])); + my $ratio = max($size->x / unscale($bed_size->x), $size->y / unscale($bed_size->y)); if ($ratio > 5) { $_->set_scaling_factor(1/$ratio) for @{$o->instances}; $scaled_down = 1; From c1d25ba25926ef6aeb46edc6984926f1ff68fae2 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 10 Apr 2018 14:00:48 +0200 Subject: [PATCH 0152/1150] Experiments with wxDataViewTreeCtrl --- xs/src/slic3r/GUI/Tab.cpp | 108 ++++++++++++++++++++++++++++++++++++++ xs/src/slic3r/GUI/Tab.hpp | 3 ++ 2 files changed, 111 insertions(+) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index a40da002ba..c074a1e584 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -123,6 +123,32 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 1, wxEXPAND, 0); + + + //temporary left vertical sizer + m_left_sizer = new wxBoxSizer(wxVERTICAL); + m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3); + + // tree + m_presetctrl = new wxDataViewTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(200, -1), wxDV_NO_HEADER); + m_left_sizer->Add(m_presetctrl, 1, wxEXPAND); + m_preset_icons = new wxImageList(16, 16, true, 1); + m_presetctrl->SetImageList(m_preset_icons); + m_preset_icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG)); + m_preset_icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG)); + + m_presetctrl->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this](wxCommandEvent& evt) + { + auto selected = m_presetctrl->GetItemText(m_presetctrl->GetSelection()); + if (selected != _(L("System presets")) && selected != _(L("Default presets"))) + { + std::string selected_string = selected.ToUTF8().data(); + select_preset(selected_string); + } + }); + + + //left vertical sizer m_left_sizer = new wxBoxSizer(wxVERTICAL); m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3); @@ -521,6 +547,7 @@ void Tab::update_tab_ui() { m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets); update_tab_presets(m_cc_presets_choice, m_show_incompatible_presets); + update_presetsctrl(m_presetctrl, m_show_incompatible_presets); } // Load a provied DynamicConfig into the tab, modifying the active preset. @@ -2132,6 +2159,87 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox return sizer; } +void Tab::update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible) +{ + if (ui == nullptr) + return; + ui->Freeze(); + ui->DeleteAllItems(); + auto presets = m_presets->get_presets(); + auto idx_selected = m_presets->get_idx_selected(); + auto suffix_modified = m_presets->get_suffix_modified(); + int icon_compatible = 0; + int icon_incompatible = 1; + int cnt_items = 0; + + auto root_sys = ui->AppendContainer(wxDataViewItem(0), _(L("System presets"))); + auto root_def = ui->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); + + auto show_def = get_app_config()->get("no_defaults")[0] != '1'; + + for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { + const Preset &preset = presets[i]; + if (!preset.is_visible || (!show_incompatible && !preset.is_compatible && i != idx_selected)) + continue; + + auto preset_name = wxString::FromUTF8((preset.name + (preset.is_dirty ? suffix_modified : "")).c_str()); + + wxDataViewItem item; + if (preset.is_system) + item = ui->AppendItem(root_sys, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + else if (show_def && preset.is_default) + item = ui->AppendItem(root_def, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + else + { + auto parent = m_presets->get_preset_parent(preset); + if (parent == nullptr) + item = ui->AppendItem(root_def, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + else + { + auto parent_name = parent->name; + + wxDataViewTreeStoreContainerNode *node = ui->GetStore()->FindContainerNode(root_sys); + if (node) + { + wxDataViewTreeStoreNodeList::iterator iter; + for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter++) + { + wxDataViewTreeStoreNode* child = *iter; + auto child_item = child->GetItem(); + auto item_text = ui->GetItemText(child_item); + if (item_text == parent_name) + { + auto added_child = ui->AppendItem(child->GetItem(), preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + if (!added_child){ + ui->DeleteItem(child->GetItem()); + auto new_parent = ui->AppendContainer(root_sys, parent_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + ui->AppendItem(new_parent, preset_name, + preset.is_compatible ? icon_compatible : icon_incompatible); + } + break; + } + } + } + } + } + + cnt_items++; + if (i == idx_selected){ + ui->Select(item); + m_cc_presets_choice->SetText(preset_name); + } + } + if (ui->GetStore()->GetChildCount(root_def) == 0) + ui->DeleteItem(root_def); + + ui->Thaw(); +} + void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) { if (ui == nullptr) diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 5e2eec80dd..8a2c38e052 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -97,6 +97,8 @@ protected: wxButton* m_undo_btn; wxButton* m_undo_to_sys_btn; wxComboCtrl* m_cc_presets_choice; + wxDataViewTreeCtrl* m_presetctrl; + wxImageList* m_preset_icons; int m_icon_count; std::map m_icon_index; // Map from an icon file name to its index @@ -149,6 +151,7 @@ public: bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, std::string new_printer_name = ""); wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn); + void update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible); void load_key_value(std::string opt_key, boost::any value); void reload_compatible_printers_widget(); From d789b5c0df5042516c66729fa9f63d63907d9180 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 10 Apr 2018 14:12:16 +0200 Subject: [PATCH 0153/1150] Fixed warning texture not disappearing when deleting object out of bed --- lib/Slic3r/GUI/Plater/3D.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index 36d55d27be..e9416b3cc5 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -231,6 +231,9 @@ sub reload_scene { Slic3r::GUI::_3DScene::reset_warning_texture(); $self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons); } + } else { + $self->set_warning_enabled(0); + Slic3r::GUI::_3DScene::reset_warning_texture(); } } From e7520c3d18709337e5340dff6a2d0f995cbdc27c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 10 Apr 2018 14:52:03 +0200 Subject: [PATCH 0154/1150] Don't use select_preset on OS X --- xs/src/slic3r/GUI/Tab.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index c074a1e584..1b70dfa5ca 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -58,7 +58,10 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) { m_cc_presets_choice->SetText(selected); std::string selected_string = selected.ToUTF8().data(); -// select_preset(selected_string); +#ifdef __APPLE__ +#else + select_preset(selected_string); +#endif } }); @@ -143,7 +146,10 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) if (selected != _(L("System presets")) && selected != _(L("Default presets"))) { std::string selected_string = selected.ToUTF8().data(); +#ifdef __APPLE__ +#else select_preset(selected_string); +#endif } }); From 0694fad01626578cea4828ba19749f38e8d5e146 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 10 Apr 2018 16:27:42 +0200 Subject: [PATCH 0155/1150] Initial implementation of the config snapshot dialog. --- xs/CMakeLists.txt | 6 +- xs/src/slic3r/Config/Snapshot.cpp | 8 +- xs/src/slic3r/Config/Snapshot.hpp | 2 +- xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp | 110 +++++++++++++++++++++ xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp | 30 ++++++ xs/src/slic3r/GUI/GUI.cpp | 14 +++ xs/src/slic3r/Utils/Semver.hpp | 16 ++- xs/src/slic3r/Utils/Time.cpp | 44 ++++++--- xs/src/slic3r/Utils/Time.hpp | 5 +- 9 files changed, 213 insertions(+), 22 deletions(-) create mode 100644 xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp create mode 100644 xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index b9a6dbfee2..e01f11b263 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -176,6 +176,8 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/AppConfig.hpp ${LIBDIR}/slic3r/GUI/BitmapCache.cpp ${LIBDIR}/slic3r/GUI/BitmapCache.hpp + ${LIBDIR}/slic3r/GUI/ConfigSnapshotDialog.cpp + ${LIBDIR}/slic3r/GUI/ConfigSnapshotDialog.hpp ${LIBDIR}/slic3r/GUI/3DScene.cpp ${LIBDIR}/slic3r/GUI/3DScene.hpp ${LIBDIR}/slic3r/GUI/GLShader.cpp @@ -218,6 +220,8 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/Utils/OctoPrint.hpp ${LIBDIR}/slic3r/Utils/Bonjour.cpp ${LIBDIR}/slic3r/Utils/Bonjour.hpp + ${LIBDIR}/slic3r/Utils/Time.cpp + ${LIBDIR}/slic3r/Utils/Time.hpp ) add_library(admesh STATIC @@ -408,7 +412,7 @@ if(APPLE) # Ignore undefined symbols of the perl interpreter, they will be found in the caller image. target_link_libraries(XS "-undefined dynamic_lookup") endif() -target_link_libraries(XS libslic3r libslic3r_gui admesh miniz clipper nowide polypartition poly2tri) +target_link_libraries(XS libslic3r libslic3r_gui admesh miniz clipper nowide polypartition poly2tri semver) if(SLIC3R_PROFILE) target_link_libraries(XS Shiny) endif() diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index 91f02ab257..33c7ef82ff 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -241,7 +241,7 @@ static void delete_existing_ini_files(const boost::filesystem::path &path) boost::filesystem::remove(dir_entry.path()); } -const Snapshot& SnapshotDB::make_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment) +const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment) { boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); boost::filesystem::path snapshot_db_dir = SnapshotDB::create_db_dir(); @@ -267,8 +267,10 @@ const Snapshot& SnapshotDB::make_snapshot(const AppConfig &app_config, Snapshot: } // Vendor specific config bundles and installed printers. + boost::filesystem::path snapshot_dir = snapshot_db_dir / snapshot.id; + boost::filesystem::create_directory(snapshot_dir); + // Backup the presets. - boost::filesystem::path snapshot_dir = snapshot_db_dir / snapshot.id; for (const char *subdir : { "print", "filament", "printer", "vendor" }) copy_config_dir_single_level(data_dir / subdir, snapshot_dir / subdir); snapshot.save_ini((snapshot_dir / "snapshot.ini").string()); @@ -322,7 +324,7 @@ boost::filesystem::path SnapshotDB::create_db_dir() SnapshotDB& SnapshotDB::singleton() { static SnapshotDB instance; - bool loaded = false; + static bool loaded = false; if (! loaded) { try { loaded = true; diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp index 1d02c8650b..3c77542735 100644 --- a/xs/src/slic3r/Config/Snapshot.hpp +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -91,7 +91,7 @@ public: // Create a snapshot directory, copy the vendor config bundles, user print/filament/printer profiles, // create an index. - const Snapshot& make_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment); + const Snapshot& take_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment); void restore_snapshot(const std::string &id, AppConfig &app_config); void restore_snapshot(const Snapshot &snapshot, AppConfig &app_config); diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp new file mode 100644 index 0000000000..a4e4d846b6 --- /dev/null +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -0,0 +1,110 @@ +#include "ConfigSnapshotDialog.hpp" + +#include "../Config/Snapshot.hpp" +#include "../Utils/Time.hpp" + +#include "../../libslic3r/Utils.hpp" + +namespace Slic3r { +namespace GUI { + +static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_even) +{ + // Start by declaring a row with an alternating background color. + std::string text = ""; + text += ""; +// text += _(L("ID:")) + " " + snapshot.id + "
"; + text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "
"; + text += _(L("slic3r version:")) + " " + snapshot.slic3r_version_captured.to_string() + "
"; + if (! snapshot.comment.empty()) + text += _(L("user comment:")) + " " + snapshot.comment + "
"; +// text += "reason: " + snapshot.reason + "
"; + text += "print: " + snapshot.print + "
"; + text += "filaments: " + snapshot.filaments.front() + "
"; + text += "printer: " + snapshot.printer + "
"; + + for (const Config::Snapshot::VendorConfig &vc : snapshot.vendor_configs) { + text += "vendor: " + vc.name + ", ver: " + vc.version.to_string() + ", min slic3r ver: " + vc.min_slic3r_version.to_string() + ", max slic3r ver: " + vc.max_slic3r_version.to_string() + "
"; + } + + text += "

Activate

"; + text += ""; + text += ""; + return text; +} + +static std::string generate_html_page(const Config::SnapshotDB &snapshot_db) +{ + std::string text = + "" + "" + ""; + text += ""; + for (size_t i_row = 0; i_row < snapshot_db.snapshots().size(); ++ i_row) { + const Config::Snapshot &snapshot = snapshot_db.snapshots()[i_row]; + text += generate_html_row(snapshot, i_row & 1); + } + text += + "
" + "
" + "" + ""; + return text; +} + +ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db) + : wxDialog(NULL, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition, wxSize(600, 500), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX) +{ + this->SetBackgroundColour(*wxWHITE); + + wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); + this->SetSizer(vsizer); + + // text + wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO); + { + wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + #ifdef __WXMSW__ + int size[] = {8,8,8,8,8,8,8}; + #else + int size[] = {11,11,11,11,11,11,11}; + #endif + html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); + html->SetBorders(2); + std::string text = generate_html_page(snapshot_db); + FILE *file = ::fopen("d:\\temp\\configsnapshotdialog.html", "wt"); + fwrite(text.data(), 1, text.size(), file); + fclose(file); + html->SetPage(text.c_str()); + vsizer->Add(html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 0); + html->Bind(wxEVT_HTML_LINK_CLICKED, &ConfigSnapshotDialog::onLinkClicked, this); + } + + wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE); + this->SetEscapeId(wxID_CLOSE); + this->Bind(wxEVT_BUTTON, &ConfigSnapshotDialog::onCloseDialog, this, wxID_CLOSE); + vsizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3); + +/* + this->Bind(wxEVT_LEFT_DOWN, &ConfigSnapshotDialog::onCloseDialog, this); + logo->Bind(wxEVT_LEFT_DOWN, &ConfigSnapshotDialog::onCloseDialog, this); + html->Bind(wxEVT_LEFT_DOWN, &ConfigSnapshotDialog::onCloseDialog, this); +*/ +} + +void ConfigSnapshotDialog::onLinkClicked(wxHtmlLinkEvent &event) +{ + wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref()); + event.Skip(false); +} + +void ConfigSnapshotDialog::onCloseDialog(wxEvent &) +{ + this->EndModal(wxID_CLOSE); + this->Close(); +} + +} // namespace GUI +} // namespace Slic3r diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp new file mode 100644 index 0000000000..70187ee995 --- /dev/null +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp @@ -0,0 +1,30 @@ +#ifndef slic3r_GUI_ConfigSnapshotDialog_hpp_ +#define slic3r_GUI_ConfigSnapshotDialog_hpp_ + +#include "GUI.hpp" + +#include +#include +#include + +namespace Slic3r { +namespace GUI { + +namespace Config { + class SnapshotDB; +} + +class ConfigSnapshotDialog : public wxDialog +{ +public: + ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db); + +private: + void onLinkClicked(wxHtmlLinkEvent &event); + void onCloseDialog(wxEvent &); +}; + +} // namespace GUI +} // namespace Slic3r + +#endif /* slic3r_GUI_ConfigSnapshotDialog_hpp_ */ diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 48d56ff119..0a163bf285 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -44,10 +44,13 @@ #include "TabIface.hpp" #include "AboutDialog.hpp" #include "AppConfig.hpp" +#include "ConfigSnapshotDialog.hpp" #include "Utils.hpp" #include "Preferences.hpp" #include "PresetBundle.hpp" +#include "../Config/Snapshot.hpp" + namespace Slic3r { namespace GUI { #if __APPLE__ @@ -357,6 +360,17 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ switch (event.GetId() - config_id_base) { + case ConfigMenuTakeSnapshot: + // Take a configuration snapshot. + Slic3r::GUI::Config::SnapshotDB::singleton().take_snapshot(*g_AppConfig, Slic3r::GUI::Config::Snapshot::SNAPSHOT_USER, ""); + break; + case ConfigMenuSnapshots: + { + ConfigSnapshotDialog dlg(Slic3r::GUI::Config::SnapshotDB::singleton()); + dlg.ShowModal(); + dlg.Destroy(); + break; + } case ConfigMenuPreferences: { auto dlg = new PreferencesDialog(g_wxMainFrame, event_preferences_changed); diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index 7fc3b8033a..8aa8cc53ff 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -46,11 +46,23 @@ public: return Semver(ver); } - Semver(Semver &&other) { *this = std::move(other); } - Semver(const Semver &other) { *this = other; } + Semver(Semver &&other) : ver(other.ver) + { + other.ver.major = other.ver.minor = other.ver.patch = 0; + other.ver.metadata = other.ver.prerelease = nullptr; + } + + Semver(const Semver &other) : ver(other.ver) + { + if (other.ver.metadata != nullptr) + std::strcpy(ver.metadata, other.ver.metadata); + if (other.ver.prerelease != nullptr) + std::strcpy(ver.prerelease, other.ver.prerelease); + } Semver &operator=(Semver &&other) { + ::semver_free(&ver); ver = other.ver; other.ver.major = other.ver.minor = other.ver.patch = 0; other.ver.metadata = other.ver.prerelease = nullptr; diff --git a/xs/src/slic3r/Utils/Time.cpp b/xs/src/slic3r/Utils/Time.cpp index c4123c7bba..a2b2328af6 100644 --- a/xs/src/slic3r/Utils/Time.cpp +++ b/xs/src/slic3r/Utils/Time.cpp @@ -1,13 +1,18 @@ #include "Time.hpp" +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include + #undef WIN32_LEAN_AND_MEAN +#endif /* WIN32 */ + namespace Slic3r { namespace Utils { time_t parse_time_ISO8601Z(const std::string &sdate) { - int y, M, d, h, m; - float s; - if (sscanf(sdate.c_str(), "%d-%d-%dT%d:%d:%fZ", &y, &M, &d, &h, &m, &s) != 6) + int y, M, d, h, m, s; + if (sscanf(sdate.c_str(), "%04d%02d%02dT%02d%02d%02dZ", &y, &M, &d, &h, &m, &s) != 6) return (time_t)-1; struct tm tms; tms.tm_year = y - 1900; // Year since 1900 @@ -15,7 +20,7 @@ time_t parse_time_ISO8601Z(const std::string &sdate) tms.tm_mday = d; // 1-31 tms.tm_hour = h; // 0-23 tms.tm_min = m; // 0-59 - tms.tm_sec = (int)s; // 0-61 (0-60 in C++11) + tms.tm_sec = s; // 0-61 (0-60 in C++11) return mktime(&tms); } @@ -23,21 +28,34 @@ std::string format_time_ISO8601Z(time_t time) { struct tm tms; #ifdef WIN32 - gmtime_s(time, &tms); + gmtime_s(&tms, &time); #else - gmtime_r(&tms, time); + gmtime_r(&time, &tms); #endif char buf[128]; - sprintf(buf, "%d-%d-%dT%d:%d:%fZ", - tms.tm_year + 1900 - tms.tm_mon + 1 - tms.tm_mday - tms.tm_hour - tms.tm_min + sprintf(buf, "%04d%02d%02dT%02d%02d%02dZ", + tms.tm_year + 1900, + tms.tm_mon + 1, + tms.tm_mday, + tms.tm_hour, + tms.tm_min, tms.tm_sec); return buf; } +std::string format_local_date_time(time_t time) +{ + struct tm tms; +#ifdef WIN32 + localtime_s(&tms, &time); +#else + localtime_r(&time, &tms); +#endif + char buf[80]; + strftime(buf, 80, "%x %X", &tms); + return buf; +} + time_t get_current_time_utc() { #ifdef WIN32 @@ -59,5 +77,3 @@ time_t get_current_time_utc() }; // namespace Utils }; // namespace Slic3r - -#endif /* slic3r_Utils_Time_hpp_ */ diff --git a/xs/src/slic3r/Utils/Time.hpp b/xs/src/slic3r/Utils/Time.hpp index 6b2fbf8930..7b670bd3ee 100644 --- a/xs/src/slic3r/Utils/Time.hpp +++ b/xs/src/slic3r/Utils/Time.hpp @@ -13,8 +13,11 @@ namespace Utils { extern time_t parse_time_ISO8601Z(const std::string &s); extern std::string format_time_ISO8601Z(time_t time); +// Format the date and time from an UTC time according to the active locales and a local time zone. +extern std::string format_local_date_time(time_t time); + // There is no gmtime() on windows. -time_t get_current_time_utc(); +extern time_t get_current_time_utc(); }; // namespace Utils }; // namespace Slic3r From da2878958bfb23ae65b3ee4789844530d35260d9 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 11 Apr 2018 12:21:15 +0200 Subject: [PATCH 0156/1150] Wizard runs from the new Config menu, snapshots could be rolled back / forward. --- lib/Slic3r/GUI.pm | 5 +- lib/Slic3r/GUI/Controller.pm | 4 +- lib/Slic3r/GUI/MainFrame.pm | 47 ++---------- resources/profiles/PrusaResearch.ini | 2 +- xs/src/slic3r/Config/Snapshot.cpp | 46 ++++++++++-- xs/src/slic3r/Config/Snapshot.hpp | 6 ++ xs/src/slic3r/GUI/AppConfig.hpp | 3 + xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp | 21 ++++-- xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp | 4 ++ xs/src/slic3r/GUI/GUI.cpp | 84 ++++++++++++++++++---- xs/src/slic3r/GUI/GUI.hpp | 10 ++- xs/src/slic3r/GUI/Tab.cpp | 12 ++-- xs/xsp/GUI.xsp | 7 +- 13 files changed, 165 insertions(+), 86 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index bb56fa886d..b28b84df32 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -8,7 +8,6 @@ use FindBin; use List::Util qw(first); use Slic3r::GUI::2DBed; use Slic3r::GUI::BedShapeDialog; -use Slic3r::GUI::ConfigWizard; use Slic3r::GUI::Controller; use Slic3r::GUI::Controller::ManualControlDialog; use Slic3r::GUI::Controller::PrinterPanel; @@ -150,7 +149,7 @@ sub OnInit { # XXX: ? if ($run_wizard) { # Run the config wizard, don't offer the "reset user profile" checkbox. - $self->{mainframe}->config_wizard(1); + Slic3r::GUI::config_wizard(1); } # $self->{preset_updater}->download($self->{preset_bundle}); @@ -207,7 +206,7 @@ sub recreate_GUI{ # before the UI was up and running. $self->CallAfter(sub { # Run the config wizard, don't offer the "reset user profile" checkbox. - $self->{mainframe}->config_wizard(1); + Slic3r::GUI::config_wizard(1); }); } } diff --git a/lib/Slic3r/GUI/Controller.pm b/lib/Slic3r/GUI/Controller.pm index 6aa7b34cb8..f7d90c7962 100644 --- a/lib/Slic3r/GUI/Controller.pm +++ b/lib/Slic3r/GUI/Controller.pm @@ -7,7 +7,7 @@ use strict; use warnings; use utf8; -use Wx qw(wxTheApp :frame :id :misc :sizer :bitmap :button :icon :dialog); +use Wx qw(wxTheApp :frame :id :misc :sizer :bitmap :button :icon :dialog wxBORDER_NONE); use Wx::Event qw(EVT_CLOSE EVT_LEFT_DOWN EVT_MENU); use base qw(Wx::ScrolledWindow Class::Accessor); use List::Util qw(first); @@ -34,7 +34,7 @@ sub new { # button for adding new printer panels { my $btn = $self->{btn_add} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new(Slic3r::var("add.png"), wxBITMAP_TYPE_PNG), - wxDefaultPosition, wxDefaultSize, Wx::wxBORDER_NONE); + wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); $btn->SetToolTipString("Add printer…") if $btn->can('SetToolTipString'); diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index e5b27d1dc8..886c8f4192 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -81,7 +81,7 @@ sub new { # declare events EVT_CLOSE($self, sub { my (undef, $event) = @_; - if ($event->CanVeto && !$self->check_unsaved_changes) { + if ($event->CanVeto && !Slic3r::GUI::check_unsaved_changes) { $event->Veto; return; } @@ -313,11 +313,6 @@ sub _init_menubar { # Help menu my $helpMenu = Wx::Menu->new; { - $self->_append_menu_item($helpMenu, L("&Configuration ").$Slic3r::GUI::ConfigWizard::wizard."…", L("Run Configuration ").$Slic3r::GUI::ConfigWizard::wizard, sub { - # Run the config wizard, offer the "reset user profile" checkbox. - $self->config_wizard(0); - }); - $helpMenu->AppendSeparator(); $self->_append_menu_item($helpMenu, L("Prusa 3D Drivers"), L('Open the Prusa3D drivers download page in your browser'), sub { Wx::LaunchDefaultBrowser('http://www.prusa3d.com/drivers/'); }); @@ -554,7 +549,7 @@ sub export_config { sub load_config_file { my ($self, $file) = @_; if (!$file) { - return unless $self->check_unsaved_changes; + return unless Slic3r::GUI::check_unsaved_changes; my $dlg = Wx::FileDialog->new($self, L('Select configuration to load:'), $last_config ? dirname($last_config) : wxTheApp->{app_config}->get_last_dir, "config.ini", @@ -573,7 +568,7 @@ sub load_config_file { sub export_configbundle { my ($self) = @_; - return unless $self->check_unsaved_changes; + return unless Slic3r::GUI::check_unsaved_changes; # validate current configuration in case it's dirty eval { wxTheApp->{preset_bundle}->full_config->validate; }; Slic3r::GUI::catch_error($self) and return; @@ -597,7 +592,7 @@ sub export_configbundle { # but that behavior was not documented and likely buggy. sub load_configbundle { my ($self, $file, $reset_user_profile) = @_; - return unless $self->check_unsaved_changes; + return unless Slic3r::GUI::check_unsaved_changes; if (!$file) { my $dlg = Wx::FileDialog->new($self, L('Select configuration to load:'), $last_config ? dirname($last_config) : wxTheApp->{app_config}->get_last_dir, @@ -631,40 +626,6 @@ sub load_config { $self->{plater}->on_config_change($config) if $self->{plater}; } -sub config_wizard { - my ($self, $fresh_start) = @_; - # Exit wizard if there are unsaved changes and the user cancels the action. - return unless $self->check_unsaved_changes; - - # TODO: Offer "reset user profile" ??? - if (Slic3r::GUI::open_config_wizard(wxTheApp->{preset_bundle})) { - # Load the currently selected preset into the GUI, update the preset selection box. - foreach my $tab (values %{$self->{options_tabs}}) { - $tab->load_current_preset; - } - } -} - -# This is called when closing the application, when loading a config file or when starting the config wizard -# to notify the user whether he is aware that some preset changes will be lost. -sub check_unsaved_changes { - my $self = shift; - - my @dirty = (); - foreach my $tab (values %{$self->{options_tabs}}) { - push @dirty, $tab->title if $tab->current_preset_is_dirty; - } - - if (@dirty) { - my $titles = join ', ', @dirty; - my $confirm = Wx::MessageDialog->new($self, L("You have unsaved changes ").($titles).L(". Discard changes and continue anyway?"), - L('Unsaved Presets'), wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT); - return $confirm->ShowModal == wxID_YES; - } - - return 1; -} - sub select_tab { my ($self, $tab) = @_; $self->{tabpanel}->SetSelection($tab); diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index b654b4039f..cf82855cf4 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -5,7 +5,7 @@ name = Prusa Research # Configuration version of this file. Config file will only be installed, if the config_version differs. # This means, the server may force the Slic3r configuration to be downgraded. -config_version = 0.1 +config_version = 0.1.0 # Where to get the updates from? # TODO: proper URL # config_update_url = https://raw.githubusercontent.com/prusa3d/Slic3r-settings/master/live/PrusaResearch.ini diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index 33c7ef82ff..9fabbe0136 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -1,5 +1,6 @@ #include "Snapshot.hpp" #include "../GUI/AppConfig.hpp" +#include "../GUI/PresetBundle.hpp" #include "../Utils/Time.hpp" #include @@ -172,6 +173,14 @@ void Snapshot::export_selections(AppConfig &config) const config.set("presets", "printer", printer); } +void Snapshot::export_vendor_configs(AppConfig &config) const +{ + std::map>> vendors; + for (const VendorConfig &vc : vendor_configs) + vendors[vc.name] = vc.models_variants_installed; + config.set_vendors(std::move(vendors)); +} + size_t SnapshotDB::load_db() { boost::filesystem::path snapshots_dir = SnapshotDB::create_db_dir(); @@ -199,7 +208,8 @@ size_t SnapshotDB::load_db() } m_snapshots.emplace_back(std::move(snapshot)); } - + // Sort the snapshots by their date/time. + std::sort(m_snapshots.begin(), m_snapshots.end(), [](const Snapshot &s1, const Snapshot &s2) { return s1.time_captured < s2.time_captured; }); if (! errors_cummulative.empty()) throw std::runtime_error(errors_cummulative); return m_snapshots.size(); @@ -266,6 +276,30 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot: snapshot.filaments.emplace_back(app_config.get("presets", name)); } // Vendor specific config bundles and installed printers. + for (const std::pair>> &vendor : app_config.vendors()) { + Snapshot::VendorConfig cfg; + cfg.name = vendor.first; + cfg.models_variants_installed = vendor.second; + // Read the active config bundle, parse the config version. + PresetBundle bundle; + bundle.load_configbundle((data_dir / "vendor" / (cfg.name + ".ini")).string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); + for (const VendorProfile &vp : bundle.vendors) + if (vp.id == cfg.name) + cfg.version = *Semver::parse(vp.config_version); + // Fill-in the min/max slic3r version from the config index, if possible. + try { + // Load the config index for the vendor. + Index index; + index.load(data_dir / "vendor" / (cfg.name + ".idx")); + auto it = index.find(cfg.version); + if (it != index.end()) { + cfg.min_slic3r_version = it->min_slic3r_version; + cfg.max_slic3r_version = it->max_slic3r_version; + } + } catch (const std::runtime_error &err) { + } + snapshot.vendor_configs.emplace_back(std::move(cfg)); + } boost::filesystem::path snapshot_dir = snapshot_db_dir / snapshot.id; boost::filesystem::create_directory(snapshot_dir); @@ -274,6 +308,7 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot: for (const char *subdir : { "print", "filament", "printer", "vendor" }) copy_config_dir_single_level(data_dir / subdir, snapshot_dir / subdir); snapshot.save_ini((snapshot_dir / "snapshot.ini").string()); + assert(m_snapshots.empty() || m_snapshots.back().time_captured <= snapshot.time_captured); m_snapshots.emplace_back(std::move(snapshot)); return m_snapshots.back(); } @@ -293,18 +328,15 @@ void SnapshotDB::restore_snapshot(const Snapshot &snapshot, AppConfig &app_confi boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); boost::filesystem::path snapshot_db_dir = SnapshotDB::create_db_dir(); boost::filesystem::path snapshot_dir = snapshot_db_dir / snapshot.id; - // Remove existing ini files and restore the ini files from the snapshot. for (const char *subdir : { "print", "filament", "printer", "vendor" }) { delete_existing_ini_files(data_dir / subdir); copy_config_dir_single_level(snapshot_dir / subdir, data_dir / subdir); } - - // Update app_config from the snapshot. + // Update AppConfig with the selections of the print / filament / printer profiles + // and about the installed printer types and variants. snapshot.export_selections(app_config); - - // Store information about the snapshot. - + snapshot.export_vendor_configs(app_config); } boost::filesystem::path SnapshotDB::create_db_dir() diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp index 3c77542735..a7b8a5aa5d 100644 --- a/xs/src/slic3r/Config/Snapshot.hpp +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -1,6 +1,8 @@ #ifndef slic3r_GUI_Snapshot_ #define slic3r_GUI_Snapshot_ +#include +#include #include #include @@ -17,6 +19,7 @@ namespace GUI { namespace Config { class Version; +class Index; // A snapshot contains: // Slic3r.ini @@ -42,6 +45,7 @@ public: // Export the print / filament / printer selections to be activated into the AppConfig. void export_selections(AppConfig &config) const; + void export_vendor_configs(AppConfig &config) const; // ID of a snapshot should equal to the name of the snapshot directory. // The ID contains the date/time, reason and comment to be human readable. @@ -70,6 +74,8 @@ public: Semver min_slic3r_version = Semver::zero(); // Maximum Slic3r version compatible with this vendor configuration, or empty. Semver max_slic3r_version = Semver::inf(); + // Which printer models of this vendor were installed, and which variants of the models? + std::map> models_variants_installed; }; // List of vendor configs contained in this snapshot. std::vector vendor_configs; diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index 7aac95fd6b..40b3a12fd6 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -71,6 +71,9 @@ public: bool get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const; void set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable); void set_vendors(const AppConfig &from); + void set_vendors(const std::map>> &vendors) { m_vendors = vendors; m_dirty = true; } + void set_vendors(std::map>> &&vendors) { m_vendors = std::move(vendors); m_dirty = true; } + const std::map>> vendors() const { return m_vendors; } // return recent/skein_directory or recent/config_directory or empty string. std::string get_last_dir() const; diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp index a4e4d846b6..730b97a320 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -26,7 +26,19 @@ static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_ text += "printer: " + snapshot.printer + "
"; for (const Config::Snapshot::VendorConfig &vc : snapshot.vendor_configs) { - text += "vendor: " + vc.name + ", ver: " + vc.version.to_string() + ", min slic3r ver: " + vc.min_slic3r_version.to_string() + ", max slic3r ver: " + vc.max_slic3r_version.to_string() + "
"; + text += "vendor: " + vc.name + ", ver: " + vc.version.to_string() + ", min slic3r ver: " + vc.min_slic3r_version.to_string(); + if (vc.max_slic3r_version != Semver::inf()) + text += ", max slic3r ver: " + vc.max_slic3r_version.to_string(); + text += "
"; + for (const std::pair> &model : vc.models_variants_installed) { + text += "model: " + model.first + ", variants: "; + for (const std::string &variant : model.second) { + if (&variant != &*model.second.begin()) + text += ", "; + text += variant; + } + text += "
"; + } } text += "

Activate

"; @@ -43,7 +55,7 @@ static std::string generate_html_page(const Config::SnapshotDB &snapshot_db) ""; text += ""; for (size_t i_row = 0; i_row < snapshot_db.snapshots().size(); ++ i_row) { - const Config::Snapshot &snapshot = snapshot_db.snapshots()[i_row]; + const Config::Snapshot &snapshot = snapshot_db.snapshots()[snapshot_db.snapshots().size() - i_row - 1]; text += generate_html_row(snapshot, i_row & 1); } text += @@ -96,8 +108,9 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db void ConfigSnapshotDialog::onLinkClicked(wxHtmlLinkEvent &event) { - wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref()); - event.Skip(false); + m_snapshot_to_activate = event.GetLinkInfo().GetHref(); + this->EndModal(wxID_CLOSE); + this->Close(); } void ConfigSnapshotDialog::onCloseDialog(wxEvent &) diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp index 70187ee995..0d11096159 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp @@ -19,9 +19,13 @@ class ConfigSnapshotDialog : public wxDialog public: ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db); + const std::string& snapshot_to_activate() const { return m_snapshot_to_activate; } + private: void onLinkClicked(wxHtmlLinkEvent &event); void onCloseDialog(wxEvent &); + + std::string m_snapshot_to_activate; }; } // namespace GUI diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index dcb21f6449..cef56b8929 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -349,9 +349,17 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l { auto local_menu = new wxMenu(); wxWindowID config_id_base = wxWindow::NewControlId((int)ConfigMenuCnt); - + + // A different naming convention is used for the Wizard on Windows vs. OSX & GTK. +#if WIN32 + std::string config_wizard_menu = _(L("Configuration Wizard")); + std::string config_wizard_tooltip = _(L("Run configuration wizard")); +#else + std::string config_wizard_menu = _(L("Configuration Assistant")); + std::string config_wizard_tooltip = _(L("Run configuration Assistant")); +#endif // Cmd+, is standard on OS X - what about other operating systems? - local_menu->Append(config_id_base + ConfigMenuWizard, _(L("Configuration Wizard\u2026")), _(L("Run configuration wizard"))); + local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_menu + "\u2026", config_wizard_tooltip); local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots\u2026")), _(L("Inspect / activate configuration snapshots"))); local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration Snapshot")), _(L("Capture a configuration snapshot"))); local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); @@ -361,21 +369,35 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ switch (event.GetId() - config_id_base) { + case ConfigMenuWizard: + config_wizard(0); + break; case ConfigMenuTakeSnapshot: // Take a configuration snapshot. - Slic3r::GUI::Config::SnapshotDB::singleton().take_snapshot(*g_AppConfig, Slic3r::GUI::Config::Snapshot::SNAPSHOT_USER, ""); + if (check_unsaved_changes()) { + wxTextEntryDialog dlg(nullptr, _(L("Taking configuration snapshot")), _(L("Snapshot name"))); + if (dlg.ShowModal() == wxID_OK) + Slic3r::GUI::Config::SnapshotDB::singleton().take_snapshot( + *g_AppConfig, Slic3r::GUI::Config::Snapshot::SNAPSHOT_USER, dlg.GetValue().ToUTF8().data()); + } break; case ConfigMenuSnapshots: - { - ConfigSnapshotDialog dlg(Slic3r::GUI::Config::SnapshotDB::singleton()); - dlg.ShowModal(); - dlg.Destroy(); + if (check_unsaved_changes()) { + ConfigSnapshotDialog dlg(Slic3r::GUI::Config::SnapshotDB::singleton()); + dlg.ShowModal(); + if (! dlg.snapshot_to_activate().empty()) { + Config::SnapshotDB::singleton().restore_snapshot(dlg.snapshot_to_activate(), *g_AppConfig); + g_PresetBundle->load_presets(*g_AppConfig); + // Load the currently selected preset into the GUI, update the preset selection box. + for (Tab *tab : g_tabs_list) + tab->load_current_preset(); + } + } break; - } case ConfigMenuPreferences: { - auto dlg = new PreferencesDialog(g_wxMainFrame, event_preferences_changed); - dlg->ShowModal(); + PreferencesDialog dlg(g_wxMainFrame, event_preferences_changed); + dlg.ShowModal(); break; } case ConfigMenuLanguage: @@ -398,13 +420,45 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l menu->Append(local_menu, _(L("&Configuration"))); } -bool open_config_wizard(PresetBundle *preset_bundle) +// This is called when closing the application, when loading a config file or when starting the config wizard +// to notify the user whether he is aware that some preset changes will be lost. +bool check_unsaved_changes() { - if (g_wxMainFrame == nullptr) { - throw std::runtime_error("Main frame not set"); - } + std::string dirty; + for (Tab *tab : g_tabs_list) + if (tab->current_preset_is_dirty()) + if (dirty.empty()) + dirty = tab->name(); + else + dirty += std::string(", ") + tab->name(); + if (dirty.empty()) + // No changes, the application may close or reload presets. + return true; + // Ask the user. + auto dialog = new wxMessageDialog(g_wxMainFrame, + _(L("You have unsaved changes ")) + dirty + _(L(". Discard changes and continue anyway?")), + _(L("Unsaved Presets")), + wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT); + return dialog->ShowModal() == wxID_YES; +} - return ConfigWizard::run(g_wxMainFrame, preset_bundle); +bool config_wizard(bool fresh_start) +{ + if (g_wxMainFrame == nullptr) + throw std::runtime_error("Main frame not set"); + + // Exit wizard if there are unsaved changes and the user cancels the action. + if (! check_unsaved_changes()) + return false; + + // TODO: Offer "reset user profile" ??? + if (! ConfigWizard::run(g_wxMainFrame, g_PresetBundle)) + return false; + + // Load the currently selected preset into the GUI, update the preset selection box. + for (Tab *tab : g_tabs_list) + tab->load_current_preset(); + return true; } void open_preferences_dialog(int event_preferences) diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 938eed4988..2a3667eb3e 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -82,13 +82,17 @@ wxApp* get_app(); wxColour* get_modified_label_clr(); wxColour* get_sys_label_clr(); -void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change); +extern void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change); + +// This is called when closing the application, when loading a config file or when starting the config wizard +// to notify the user whether he is aware that some preset changes will be lost. +extern bool check_unsaved_changes(); // Opens the first-time configuration wizard, returns true if wizard is finished & accepted. -bool open_config_wizard(PresetBundle *preset_bundle); +extern bool config_wizard(bool fresh_start); // Create "Preferences" dialog after selecting menu "Preferences" in Perl part -void open_preferences_dialog(int event_preferences); +extern void open_preferences_dialog(int event_preferences); // Create a new preset tab (print, filament and printer), void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index babff7d801..940987536c 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -2061,9 +2061,9 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox presets.Add(preset.name); } - auto dlg = new wxMultiChoiceDialog(parent, - _(L("Select the printers this profile is compatible with.")), - _(L("Compatible printers")), presets); + wxMultiChoiceDialog dlg(parent, + _(L("Select the printers this profile is compatible with.")), + _(L("Compatible printers")), presets); // # Collect and set indices of printers marked as compatible. wxArrayInt selections; auto *compatible_printers = dynamic_cast(m_config->option("compatible_printers")); @@ -2075,12 +2075,12 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox selections.Add(idx); break; } - dlg->SetSelections(selections); + dlg.SetSelections(selections); std::vector value; // Show the dialog. - if (dlg->ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { selections.Clear(); - selections = dlg->GetSelections(); + selections = dlg.GetSelections(); for (auto idx : selections) value.push_back(presets[idx].ToStdString()); if (value.empty()) { diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 8dba13cafa..964f350b9e 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -57,8 +57,11 @@ int combochecklist_get_flags(SV *ui) void set_app_config(AppConfig *app_config) %code%{ Slic3r::GUI::set_app_config(app_config); %}; -bool open_config_wizard(PresetBundle *preset_bundle) - %code%{ RETVAL=Slic3r::GUI::open_config_wizard(preset_bundle); %}; +bool check_unsaved_changes() + %code%{ RETVAL=Slic3r::GUI::check_unsaved_changes(); %}; + +bool config_wizard(int fresh_start) + %code%{ RETVAL=Slic3r::GUI::config_wizard(fresh_start != 0); %}; void open_preferences_dialog(int preferences_event) %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %}; From 762306d98536522bed52d493c92684cdea7be2ea Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 11 Apr 2018 13:56:37 +0200 Subject: [PATCH 0157/1150] Added preset grouping to all presets ComboBoxes Changed icons for action_undo, sys_lock and sys_unlock. There are used same icons for all OS now. Deleted/Commented temporarily used wxDataViewTreeCtrl --- resources/icons/action_undo.png | Bin 616 -> 491 bytes resources/icons/sys_lock.png | Bin 448 -> 510 bytes resources/icons/sys_unlock.png | Bin 454 -> 419 bytes xs/src/slic3r/GUI/BitmapCache.hpp | 5 +++- xs/src/slic3r/GUI/Preset.cpp | 42 ++++++++++++++++++++++++----- xs/src/slic3r/GUI/PresetBundle.cpp | 34 ++++++++++++++++++++--- xs/src/slic3r/GUI/Tab.cpp | 33 ++++++++++++----------- 7 files changed, 87 insertions(+), 27 deletions(-) diff --git a/resources/icons/action_undo.png b/resources/icons/action_undo.png index 866ae9773bf144069986bf74e5524fe7b387ff48..877f159868640a0399143631438313a31dacf1a1 100644 GIT binary patch delta 429 zcmV;e0aE_x1nUEkNPiB)000id0mpBsWB>pGfJsC_R5(wykxNSgQ545V%^63>_gk}< zP(iE4M^Mt2kto`yMY*Xq(ym%bkF_lfw55$L>|?08G8A_%g@5;6hEPTeiGFZ6bB25V z=f(XiNjV1fb9Oe?)@kzW0w1lG;HHs`CM+;%oc=vezeoEIz4z|G=8mCVKs?tti+~F@_!Maw3s5J#gC{6K{WeeZvay zIs^LszIKFWqX7e%nJr3|$3&irMOaAnus?v^?VX7Q7{{3m%)Ed|FvR@oN)#TlIG4@N z{)t8&gTY|B0Ocy5C->H|QRvob+jMp+Mq2+ld6dWd2PWktn^i8)FO>Ised=QW2*-T^ X&Lg-nvC@Jh00000NkvXXu0mjfw4BNi delta 555 zcmV+`0@VHM1Ly>hNPiM^000tn0p4aGcmMza{YgYYR5(v{Q_oKmQ4pTpZM(a)6xy=1 zpa=*76HgY@geDgFBQ!?iRm0uNLA?`hz=@cMM?7G{j~fR64N0iwiS@KAib*XMxm-F02E z9b0U*fjrL>9vEHSy?@U2p(j{-`wr>U2vS4CVlz0_dw;3e+1iGeNGe_|)M_>H1&&a> zxPaoeOH?+CX0s`N#`pbwL~RFm(iuEk%88Hn`2}>5^+Evy5gQX@pGlSxEDR5(wKl08VnP!xsz0UbmT5k$eE zgXrMqrr6C@aB+3FlauHof*`mFD!6vYP$*5)rcK(WO;SW06-5wdad1!vrD~1eGf!#L zR&wBy_TGEWJ@3BP)d{Mq4i<~WwMwPp+O~b?IL>9MR5~^cV}F`*x8KzPiA16g@-C!T z$Pb8|^S$AJjo+uHX+~sgd(bc|iPxD-W+9bI4KaB_I6&l`?>6X>?X938=DO}DE;c>S z`?HJK48r#a+v12a-3kQu5UAl~S*CuVY1#GY^fHzSwJ^=Gr$6)f-Tx;~#w zCdYmQQiS?OK7XIzQWRyJ_U2_m8n!I!P)ra@`!CAnvLyycs*ggUu!QxuYPITx3682r zst?Y*iaYxG*KvM>_$Q=CG3}H?k8H2_=Bd10Gf{wJ2}kxv>`3!7cYc ziO>5KgGKK6CD_<5#Bp$SBB?&& q@%RASUT2~%>~#t;S&&s#o%#mod=~CNPr6V50000qL!1Y*~qEaA95?rrWn5LOWUNoCcoKB~FR8s;4j>jWx z+s-2|_WQk*I2a6M{2}1`z9cmo4M{BPGp^p#>9iZfTc6W-&xu6pBszgL^6U_z(U!E82@6X617ehT#aed!N}L)k@{uL3M*wOUD^=JE*3 zd=*e0kn(9L3IbJ0tyT+*#R730i*fHTzYw8e{9#zTYJ``H$!sc4Ln;1ok)kM)i^T2M f!6}^VI1c^*)N{#pGI7vi7R5(wilf6pBKoEfQPa;7{tRlXFjo5pYh4=*4cD{iK7FLShT_K!z=QonTo?dXlfsZ7! zGv7`&#HgyuD$CMV$@AO|f?&yUoORo_H$Bf=$+FD1FuDeRn6TBeW55uq%MbQGUvO(@# znk8BV_2?tGOp;`-$qO=_`Yiks(0B?HM8|4j8?yu_@PXh^Eo|dkFeA+Rsu#@!?7GA5 zukfZpH%-%E>RlBO?6DvRI8l)AzXhL4PPo<)49P9al-%zsd2PWM2DPB4B$xE=di^BJPU8GEvCF1unmK?l z#sFi}G-=&54YX|wp6AgT&mND5%tH_3IL@jeS(c%qW>FN;8Gjeh@-+b@j$?Vrb=^4# z0=ae^hjOs$9|8iAoagznGt>Egzn_bukZWO@K$0YM`E)wbT0IkpJz)mFAgSw`d>Dr0 z1-xWwuV@1I`#`?yI`Y_!zf8cW48x$doX=;tTrS}IK5RA{{JbUY8*HO(+pt=#o)w`0 zlBTJA!2fKw+kep=?G1Q~$m4L(fN-!f-b#wq{q=fH9?{<5m9i}1dc9K2e~>&Pgpjua z{Ij5{DvH%hs@PkB m_map; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index bc34e193a9..0afbcf8cd9 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -512,16 +512,44 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) // Otherwise fill in the list from scratch. ui->Freeze(); ui->Clear(); + std::map nonsys_presets; + wxString selected = ""; for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++ i) { const Preset &preset = this->m_presets[i]; if (! preset.is_visible || (! preset.is_compatible && i != m_idx_selected)) continue; const wxBitmap *bmp = (i == 0 || preset.is_compatible) ? m_bitmap_main_frame : m_bitmap_incompatible; - ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), - (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); - if (i == m_idx_selected) - ui->SetSelection(ui->GetCount() - 1); - } +// ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), +// (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); +// if (i == m_idx_selected) +// ui->SetSelection(ui->GetCount() - 1); + + if (preset.is_default || preset.is_system){ + ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), + (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); + if (i == m_idx_selected) + ui->SetSelection(ui->GetCount() - 1); + } + else + { + nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), preset.is_compatible); + if (i == m_idx_selected) + selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); + } + if (preset.is_default) + ui->Append("------------------------------------", wxNullBitmap); + } + if (!nonsys_presets.empty()) + { + ui->Append("------------------------------------", wxNullBitmap); + for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { + const wxBitmap *bmp = it->second ? m_bitmap_compatible : m_bitmap_incompatible; + ui->Append(it->first, + (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); + if (it->first == selected) + ui->SetSelection(ui->GetCount() - 1); + } + } ui->Thaw(); } @@ -556,11 +584,11 @@ void PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompatibl selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); } if (preset.is_default) - ui->Append("______________________", wxNullBitmap); + ui->Append("------------------------------------", wxNullBitmap); } if (!nonsys_presets.empty()) { - ui->Append("______________________", wxNullBitmap); + ui->Append("------------------------------------", wxNullBitmap); for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { const wxBitmap *bmp = it->second ? m_bitmap_compatible : m_bitmap_incompatible; ui->Append(it->first, diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 7131bf7716..dcf10198d9 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -986,6 +986,8 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma // and draw a red flag in front of the selected preset. bool wide_icons = selected_preset != nullptr && ! selected_preset->is_compatible && m_bitmapIncompatible != nullptr; assert(selected_preset != nullptr); + std::map nonsys_presets; + wxString selected_str = ""; for (int i = this->filaments().front().is_visible ? 0 : 1; i < int(this->filaments().size()); ++ i) { const Preset &preset = this->filaments.preset(i); bool selected = this->filament_presets[idx_extruder] == preset.name; @@ -1023,10 +1025,36 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma (preset.is_dirty ? *m_bitmapLockOpen : *m_bitmapLock) : m_bitmapCache->mkclear(16, 16)); bitmap = m_bitmapCache->insert(bitmap_key, bmps); } - ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), (bitmap == 0) ? wxNullBitmap : *bitmap); - if (selected) - ui->SetSelection(ui->GetCount() - 1); +// ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), (bitmap == 0) ? wxNullBitmap : *bitmap); +// if (selected) +// ui->SetSelection(ui->GetCount() - 1); + + if (preset.is_default || preset.is_system){ + ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), + (bitmap == 0) ? wxNullBitmap : *bitmap); + if (selected) + ui->SetSelection(ui->GetCount() - 1); + } + else + { + nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), + (bitmap == 0) ? wxNullBitmap : *bitmap); + if (selected) + selected_str = wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()); + } + if (preset.is_default) + ui->Append("------------------------------------", wxNullBitmap); } + + if (!nonsys_presets.empty()) + { + ui->Append("------------------------------------", wxNullBitmap); + for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { + ui->Append(it->first, it->second); + if (it->first == selected_str) + ui->SetSelection(ui->GetCount() - 1); + } + } ui->Thaw(); } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 1b70dfa5ca..0b79f8229c 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -38,8 +38,8 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) // preset chooser m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY); - - m_cc_presets_choice = new wxComboCtrl(panel, wxID_ANY, L(""), wxDefaultPosition, wxDefaultSize/*wxSize(270, -1)*/, wxCB_READONLY); + /* + m_cc_presets_choice = new wxComboCtrl(panel, wxID_ANY, L(""), wxDefaultPosition, wxDefaultSize, wxCB_READONLY); wxDataViewTreeCtrlComboPopup* popup = new wxDataViewTreeCtrlComboPopup; if (popup != nullptr) { @@ -73,8 +73,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG)); icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG)); } - - +*/ auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); //buttons @@ -119,14 +118,16 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_hsizer->AddSpacer(64); m_hsizer->Add(m_undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); m_hsizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL); - m_hsizer->AddSpacer(64); - m_hsizer->Add(m_cc_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3); +// m_hsizer->AddSpacer(64); +// m_hsizer->Add(m_cc_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3); //Horizontal sizer to hold the tree and the selected page. m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 1, wxEXPAND, 0); +/* + //temporary left vertical sizer m_left_sizer = new wxBoxSizer(wxVERTICAL); @@ -153,7 +154,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) } }); - +*/ //left vertical sizer m_left_sizer = new wxBoxSizer(wxVERTICAL); @@ -202,8 +203,8 @@ void Tab::load_initial_data() { m_config = &m_presets->get_edited_preset().config; m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ? - "bullet_white.png" : - wxMSW ? "sys_unlock.png" : "lock_open.png"; + "bullet_white.png" : "sys_unlock.png"; +// wxMSW ? "sys_unlock.png" : "lock_open.png"; } PageShp Tab::add_options_page(wxString title, std::string icon, bool is_extruder_pages/* = false*/) @@ -331,8 +332,8 @@ void Tab::update_changed_ui() { bool is_nonsys_value = false; bool is_modified_value = true; - std::string sys_icon = wxMSW ? "sys_lock.png" : "lock.png"; - std::string icon = wxMSW ? "action_undo.png" : "arrow_undo.png"; + std::string sys_icon = /*wxMSW ? */"sys_lock.png"/* : "lock.png"*/; + std::string icon = /*wxMSW ? */"action_undo.png"/* : "arrow_undo.png"*/; wxColour& color = *get_sys_label_clr(); if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { is_nonsys_value = true; @@ -478,9 +479,9 @@ void Tab::update_changed_tree_ui() void Tab::update_undo_buttons() { const std::string& undo_icon = !m_is_modified_values ? "bullet_white.png" : - wxMSW ? "action_undo.png" : "arrow_undo.png"; + /*wxMSW ? */"action_undo.png"/* : "arrow_undo.png"*/; const std::string& undo_to_sys_icon = m_is_nonsys_values ? m_nonsys_btn_icon : - wxMSW ? "sys_lock.png" : "lock.png"; + /*wxMSW ? */"sys_lock.png"/* : "lock.png"*/; m_undo_btn->SetBitmap(wxBitmap(from_u8(var(undo_icon)), wxBITMAP_TYPE_PNG)); m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(undo_to_sys_icon)), wxBITMAP_TYPE_PNG)); @@ -552,8 +553,8 @@ void Tab::update_dirty(){ void Tab::update_tab_ui() { m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets); - update_tab_presets(m_cc_presets_choice, m_show_incompatible_presets); - update_presetsctrl(m_presetctrl, m_show_incompatible_presets); +// update_tab_presets(m_cc_presets_choice, m_show_incompatible_presets); +// update_presetsctrl(m_presetctrl, m_show_incompatible_presets); } // Load a provied DynamicConfig into the tab, modifying the active preset. @@ -1786,7 +1787,7 @@ void Tab::load_current_preset() const Preset* parent = m_presets->get_selected_preset_parent(); m_nonsys_btn_icon = parent == nullptr ? "bullet_white.png" : - wxMSW ? "sys_unlock.png" : "lock_open.png"; + /*wxMSW ? */"sys_unlock.png"/* : "lock_open.png"*/; // use CallAfter because some field triggers schedule on_change calls using CallAfter, // and we don't want them to be called after this update_dirty() as they would mark the From aaa8f133c00baba3ccff4e2115436254483a1fe0 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 11 Apr 2018 15:17:41 +0200 Subject: [PATCH 0158/1150] Fixed parsing of the config index. --- resources/profiles/PrusaResearch.idx | 13 +++++++ xs/src/semver/semver.c | 2 +- xs/src/slic3r/Config/Snapshot.cpp | 24 ++++++++++--- xs/src/slic3r/Config/Version.cpp | 54 ++++++++++++++++++---------- xs/src/slic3r/Utils/Semver.hpp | 10 +++--- 5 files changed, 74 insertions(+), 29 deletions(-) create mode 100644 resources/profiles/PrusaResearch.idx diff --git a/resources/profiles/PrusaResearch.idx b/resources/profiles/PrusaResearch.idx new file mode 100644 index 0000000000..28f17f10ad --- /dev/null +++ b/resources/profiles/PrusaResearch.idx @@ -0,0 +1,13 @@ +# This is an example configuration version index. +# The index contains version numbers +min_slic3r_version =1.39.0 +0.2.0-alpha "some test comment" +max_slic3r_version= 1.39.4 +0.1.0 another test comment + +# some empty lines + +# version without a comment +min_slic3r_version = 1.0.0 +max_slic3r_version = 1.1.0 +0.0.1 diff --git a/xs/src/semver/semver.c b/xs/src/semver/semver.c index 29bc1868d3..599217f89f 100644 --- a/xs/src/semver/semver.c +++ b/xs/src/semver/semver.c @@ -200,7 +200,7 @@ semver_parse_version (const char *str, semver_t *ver) { slice = next + 1; } - return 0; + return (index == 3) ? 0 : -1; } static int diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index 9fabbe0136..eeb5b6ac58 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -57,6 +57,7 @@ void Snapshot::load_ini(const std::string &path) // Parse snapshot.ini std::string group_name_vendor = "Vendor:"; std::string key_filament = "filament"; + std::string key_prefix_model = "model_"; for (auto §ion : tree) { if (section.first == "snapshot") { // Parse the common section. @@ -107,10 +108,7 @@ void Snapshot::load_ini(const std::string &path) VendorConfig vc; vc.name = section.first.substr(group_name_vendor.size()); for (auto &kvp : section.second) { - if (boost::starts_with(kvp.first, "model_")) { - //model:MK2S = 0.4;xxx - //model:MK3 = 0.4;xxx - } else if (kvp.first == "version" || kvp.first == "min_slic3r_version" || kvp.first == "max_slic3r_version") { + if (kvp.first == "version" || kvp.first == "min_slic3r_version" || kvp.first == "max_slic3r_version") { // Version of the vendor specific config bundle bundled with this snapshot. auto semver = Semver::parse(kvp.second.data()); if (! semver) @@ -121,8 +119,16 @@ void Snapshot::load_ini(const std::string &path) vc.min_slic3r_version = *semver; else vc.max_slic3r_version = *semver; - } + } else if (boost::starts_with(kvp.first, key_prefix_model) && kvp.first.size() > key_prefix_model.size()) { + // Parse the printer variants installed for the current model. + auto &set_variants = vc.models_variants_installed[kvp.first.substr(key_prefix_model.size())]; + std::vector variants; + if (unescape_strings_cstyle(kvp.second.data(), variants)) + for (auto &variant : variants) + set_variants.insert(std::move(variant)); + } } + this->vendor_configs.emplace_back(std::move(vc)); } } } @@ -155,6 +161,14 @@ void Snapshot::save_ini(const std::string &path) c << "version = " << vc.version.to_string() << std::endl; c << "min_slic3r_version = " << vc.min_slic3r_version.to_string() << std::endl; c << "max_slic3r_version = " << vc.max_slic3r_version.to_string() << std::endl; + // Export installed printer models and their variants. + for (const auto &model : vc.models_variants_installed) { + if (model.second.size() == 0) + continue; + const std::vector variants(model.second.begin(), model.second.end()); + const auto escaped = escape_strings_cstyle(variants); + c << "model_" << model.first << " = " << escaped << std::endl; + } } c.close(); } diff --git a/xs/src/slic3r/Config/Version.cpp b/xs/src/slic3r/Config/Version.cpp index cc961829de..95b3caf1a3 100644 --- a/xs/src/slic3r/Config/Version.cpp +++ b/xs/src/slic3r/Config/Version.cpp @@ -40,12 +40,13 @@ inline std::string unquote_value(char *value, char *end, const std::string &path if (value == end) { // Empty string is a valid string. } else if (*value == '"') { - if (++ value < -- end || *end != '"') + if (++ value > -- end || *end != '"') throw file_parser_error("String not enquoted correctly", path, idx_line); *end = 0; if (! unescape_string_cstyle(value, svalue)) throw file_parser_error("Invalid escape sequence inside a quoted string", path, idx_line); - } + } else + svalue.assign(value, end); return svalue; } @@ -55,12 +56,13 @@ inline std::string unquote_version_comment(char *value, char *end, const std::st if (value == end) { // Empty string is a valid string. } else if (*value == '"') { - if (++ value < -- end || *end != '"') + if (++ value > -- end || *end != '"') throw file_parser_error("Version comment not enquoted correctly", path, idx_line); *end = 0; if (! unescape_string_cstyle(value, svalue)) throw file_parser_error("Invalid escape sequence inside a quoted version comment", path, idx_line); - } + } else + svalue.assign(value, end); return svalue; } @@ -77,41 +79,55 @@ size_t Index::load(const boost::filesystem::path &path) ++ idx_line; // Skip the initial white spaces. char *key = left_trim(const_cast(line.data())); + if (*key == '#') + // Skip a comment line. + continue; // Right trim the line. char *end = right_trim(key); + if (key == end) + // Skip an empty line. + continue; // Keyword may only contain alphanumeric characters. Semantic version may in addition contain "+.-". char *key_end = key; - bool maybe_semver = false; - for (;; ++ key) { - if (strchr("+.-", *key) != nullptr) - maybe_semver = true; - else if (! std::isalnum(*key)) - break; + bool maybe_semver = true; + for (; *key_end != 0; ++ key_end) { + if (std::isalnum(*key_end) || strchr("+.-", *key_end) != nullptr) { + // It may be a semver. + } else if (*key_end == '_') { + // Cannot be a semver, but it may be a key. + maybe_semver = false; + } else + // End of semver or keyword. + break; } - if (*key != 0 && *key != ' ' && *key != '\t' && *key != '=') + if (*key_end != 0 && *key_end != ' ' && *key_end != '\t' && *key_end != '=') throw file_parser_error("Invalid keyword or semantic version", path, idx_line); - *key_end = 0; + char *value = left_trim(key_end); + bool key_value_pair = *value == '='; + if (key_value_pair) + value = left_trim(value + 1); + *key_end = 0; boost::optional semver; if (maybe_semver) semver = Semver::parse(key); - char *value = left_trim(key_end); - if (*value == '=') { + if (key_value_pair) { if (semver) - throw file_parser_error("Key cannot be a semantic version", path, idx_line); + throw file_parser_error("Key cannot be a semantic version", path, idx_line);\ // Verify validity of the key / value pair. - std::string svalue = unquote_value(left_trim(++ value), end, path.string(), idx_line); - if (key == "min_sic3r_version" || key == "max_slic3r_version") { + std::string svalue = unquote_value(value, end, path.string(), idx_line); + if (strcmp(key, "min_slic3r_version") == 0 || strcmp(key, "max_slic3r_version") == 0) { if (! svalue.empty()) - semver = Semver::parse(key); + semver = Semver::parse(svalue); if (! semver) throw file_parser_error(std::string(key) + " must referece a valid semantic version", path, idx_line); - if (key == "min_sic3r_version") + if (strcmp(key, "min_slic3r_version") == 0) ver.min_slic3r_version = *semver; else ver.max_slic3r_version = *semver; } else { // Ignore unknown keys, as there may come new keys in the future. } + continue; } if (! semver) throw file_parser_error("Invalid semantic version", path, idx_line); diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index 8aa8cc53ff..bd8e9b7582 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -55,9 +55,9 @@ public: Semver(const Semver &other) : ver(other.ver) { if (other.ver.metadata != nullptr) - std::strcpy(ver.metadata, other.ver.metadata); + ver.metadata = strdup(other.ver.metadata); if (other.ver.prerelease != nullptr) - std::strcpy(ver.prerelease, other.ver.prerelease); + ver.prerelease = strdup(other.ver.prerelease); } Semver &operator=(Semver &&other) @@ -73,8 +73,10 @@ public: { ::semver_free(&ver); ver = other.ver; - if (other.ver.metadata != nullptr) { std::strcpy(ver.metadata, other.ver.metadata); } - if (other.ver.prerelease != nullptr) { std::strcpy(ver.prerelease, other.ver.prerelease); } + if (other.ver.metadata != nullptr) + ver.metadata = strdup(other.ver.metadata); + if (other.ver.prerelease != nullptr) + ver.prerelease = strdup(other.ver.prerelease); return *this; } From 723bd22b96ac23b1af3ee1438cc41f0dd86a70f9 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 11 Apr 2018 15:35:04 +0200 Subject: [PATCH 0159/1150] Changed icons for lock/unlock filament_presets on Plater tab Experiment with filament_presets transparency on GTK --- xs/src/slic3r/GUI/BitmapCache.cpp | 5 ++++- xs/src/slic3r/GUI/PresetBundle.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/BitmapCache.cpp b/xs/src/slic3r/GUI/BitmapCache.cpp index f92369650c..e29687ce5b 100644 --- a/xs/src/slic3r/GUI/BitmapCache.cpp +++ b/xs/src/slic3r/GUI/BitmapCache.cpp @@ -88,7 +88,10 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, std::vectorLoadFile( wxString::FromUTF8(Slic3r::var(path_bitmap_compatible).c_str()), wxBITMAP_TYPE_PNG); bool loaded_incompatible = m_bitmapIncompatible->LoadFile( From 31ea03feb0af7376a35aa3b3428684b1e59d4a15 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 11 Apr 2018 13:12:08 +0200 Subject: [PATCH 0160/1150] ConfigWizard: Make bundle installation more intelligent, fixes --- xs/src/slic3r/Config/Snapshot.cpp | 4 +- xs/src/slic3r/GUI/AppConfig.cpp | 19 +++++++ xs/src/slic3r/GUI/AppConfig.hpp | 3 ++ xs/src/slic3r/GUI/ConfigWizard.cpp | 9 ++-- xs/src/slic3r/GUI/Preset.cpp | 75 ++++++++++++++++++++++++++- xs/src/slic3r/GUI/Preset.hpp | 11 +++- xs/src/slic3r/GUI/PresetBundle.cpp | 43 +-------------- xs/src/slic3r/Utils/PresetUpdater.cpp | 32 +++++++----- xs/src/slic3r/Utils/PresetUpdater.hpp | 4 +- xs/src/slic3r/Utils/Semver.hpp | 19 ++++++- xs/xsp/GUI.xsp | 8 ++- 11 files changed, 159 insertions(+), 68 deletions(-) diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index eeb5b6ac58..b6c3565764 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -275,7 +275,7 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot: // Snapshot header. snapshot.time_captured = Slic3r::Utils::get_current_time_utc(); snapshot.id = Slic3r::Utils::format_time_ISO8601Z(snapshot.time_captured); - snapshot.slic3r_version_captured = *Semver::parse(SLIC3R_VERSION); + snapshot.slic3r_version_captured = *Semver::parse(SLIC3R_VERSION); // XXX: have Semver Slic3r version snapshot.comment = comment; snapshot.reason = reason; // Active presets at the time of the snapshot. @@ -299,7 +299,7 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot: bundle.load_configbundle((data_dir / "vendor" / (cfg.name + ".ini")).string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); for (const VendorProfile &vp : bundle.vendors) if (vp.id == cfg.name) - cfg.version = *Semver::parse(vp.config_version); + cfg.version = vp.config_version; // Fill-in the min/max slic3r version from the config index, if possible. try { // Load the config index for the vendor. diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 9e5ce5f1bc..ee77f877ae 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -228,9 +229,27 @@ bool AppConfig::version_check_enabled() const bool AppConfig::slic3r_update_avail() const { + // FIXME: Update with Semver + // TODO: probably need to move semver to libslic3r return version_check_enabled() && get("version_online") != SLIC3R_VERSION; } +Semver AppConfig::get_slic3r_version() const +{ + // TODO: move to Semver c-tor (???) + auto res = Semver::parse(get("version")); + if (! res) { + throw std::runtime_error(std::string("Could not parse Slic3r version string in application config.")); + } else { + return *res; + } +} + +void AppConfig::set_slic3r_version(const Semver &version) +{ + set("version", version.to_string()); +} + std::string AppConfig::config_path() { return (boost::filesystem::path(Slic3r::data_dir()) / "slic3r.ini").make_preferred().string(); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index 40b3a12fd6..cac2759f1a 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -6,6 +6,7 @@ #include #include "libslic3r/Config.hpp" +#include "slic3r/Utils/Semver.hpp" namespace Slic3r { @@ -91,6 +92,8 @@ public: // Whether the Slic3r version available online differs from this one bool version_check_enabled() const; bool slic3r_update_avail() const; + Semver get_slic3r_version() const; + void set_slic3r_version(const Semver &version); // Get the default config path from Slic3r::data_dir(). static std::string config_path(); diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index f13448c374..0c2a9dd596 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -15,6 +15,7 @@ #include "libslic3r/Utils.hpp" #include "PresetBundle.hpp" #include "GUI.hpp" +#include "slic3r/Utils/PresetUpdater.hpp" namespace fs = boost::filesystem; @@ -699,12 +700,8 @@ ConfigWizard::~ConfigWizard() {} bool ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) { - const auto profiles_dir = fs::path(resources_dir()) / "profiles"; - for (fs::directory_iterator it(profiles_dir); it != fs::directory_iterator(); ++it) { - if (it->path().extension() == ".ini") { - PresetBundle::install_vendor_configbundle(it->path()); - } - } + // FIXME: this should be done always at app startup + PresetUpdater::init_vendors(); ConfigWizard wizard(parent); if (wizard.ShowModal() == wxID_OK) { diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 66836074e9..39bfbd3981 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -24,14 +25,16 @@ #include "../../libslic3r/Utils.hpp" #include "../../libslic3r/PlaceholderParser.hpp" +using boost::property_tree::ptree; + namespace Slic3r { -ConfigFileType guess_config_file_type(const boost::property_tree::ptree &tree) +ConfigFileType guess_config_file_type(const ptree &tree) { size_t app_config = 0; size_t bundle = 0; size_t config = 0; - for (const boost::property_tree::ptree::value_type &v : tree) { + for (const ptree::value_type &v : tree) { if (v.second.empty()) { if (v.first == "background_processing" || v.first == "last_output_path" || @@ -59,6 +62,74 @@ ConfigFileType guess_config_file_type(const boost::property_tree::ptree &tree) (bundle > config) ? CONFIG_FILE_TYPE_CONFIG_BUNDLE : CONFIG_FILE_TYPE_CONFIG; } + +VendorProfile VendorProfile::from_ini(const boost::filesystem::path &path, bool load_all) +{ + ptree tree; + boost::filesystem::ifstream ifs(path); + boost::property_tree::read_ini(ifs, tree); + return VendorProfile::from_ini(tree, path, load_all); +} + +VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem::path &path, bool load_all) +{ + static const std::string printer_model_key = "printer_model:"; + const std::string id = path.stem().string(); + VendorProfile res(id); + + auto get_or_throw = [&](const ptree &tree, const std::string &key) -> ptree::const_assoc_iterator + { + auto res = tree.find(key); + if (res == tree.not_found()) { + throw std::runtime_error((boost::format("Vendor Config Bundle `%1%` is not valid: Missing secion or key: `%2%`.") % id % key).str()); + } + return res; + }; + + const auto &vendor_section = get_or_throw(tree, "vendor")->second; + res.name = get_or_throw(vendor_section, "name")->second.data(); + + auto config_version_str = get_or_throw(vendor_section, "config_version")->second.data(); + auto config_version = Semver::parse(config_version_str); + if (! config_version) { + throw std::runtime_error((boost::format("Vendor Config Bundle `%1%` is not valid: Cannot parse config_version: `%2%`.") % id % config_version_str).str()); + } else { + res.config_version = std::move(*config_version); + } + + auto config_update_url = vendor_section.find("config_update_url"); + if (config_update_url != vendor_section.not_found()) { + res.config_update_url = config_update_url->second.data(); + } + + if (! load_all) { + return res; + } + + for (auto §ion : tree) { + if (boost::starts_with(section.first, printer_model_key)) { + VendorProfile::PrinterModel model; + model.id = section.first.substr(printer_model_key.size()); + model.name = section.second.get("name", model.id); + section.second.get("variants", ""); + std::vector variants; + if (Slic3r::unescape_strings_cstyle(section.second.get("variants", ""), variants)) { + for (const std::string &variant_name : variants) { + if (model.variant(variant_name) == nullptr) + model.variants.emplace_back(VendorProfile::PrinterVariant(variant_name)); + } + } else { + // Log error? // XXX + } + if (! model.id.empty() && ! model.variants.empty()) + res.models.push_back(std::move(model)); + } + } + + return res; +} + + // Suffix to be added to a modified preset name in the combo box. static std::string g_suffix_modified = " (modified)"; const std::string& Preset::suffix_modified() diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 4f734b85e3..d6ccfd4505 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -3,8 +3,12 @@ #include +#include +#include + #include "../../libslic3r/libslic3r.h" #include "../../libslic3r/PrintConfig.hpp" +#include "slic3r/Utils/Semver.hpp" class wxBitmap; class wxChoice; @@ -30,7 +34,7 @@ class VendorProfile public: std::string name; std::string id; - std::string config_version; + Semver config_version; std::string config_update_url; struct PrinterVariant { @@ -54,7 +58,10 @@ public: }; std::vector models; - VendorProfile(std::string id) : id(std::move(id)) {} + VendorProfile(std::string id) : id(std::move(id)), config_version(0, 0, 0) {} + + static VendorProfile from_ini(const boost::filesystem::path &path, bool load_all=true); + static VendorProfile from_ini(const boost::property_tree::ptree &tree, const boost::filesystem::path &path, bool load_all=true); size_t num_variants() const { size_t n = 0; for (auto &model : models) n += model.variants.size(); return n; } diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index bd9e35ca80..ad27bf8c68 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -105,7 +105,7 @@ void PresetBundle::setup_directories() std::initializer_list paths = { data_dir, data_dir / "vendor", - data_dir / "cache", // TODO: rename as vendor-cache? (Check usage elsewhere!) + data_dir / "cache", #ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR // Store the print/filament/printer presets into a "presets" directory. data_dir / "presets", @@ -672,42 +672,6 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree) flatten_configbundle_hierarchy(tree, "printer"); } -static void load_vendor_profile(const boost::property_tree::ptree &tree, VendorProfile &vendor_profile) -{ - const std::string printer_model_key = "printer_model:"; - for (auto §ion : tree) { - if (section.first == "vendor") { - // Load the names of the active presets. - for (auto &kvp : section.second) { - if (kvp.first == "name") - vendor_profile.name = kvp.second.data(); - else if (kvp.first == "id") - vendor_profile.id = kvp.second.data(); - else if (kvp.first == "config_version") - vendor_profile.config_version = kvp.second.data(); - else if (kvp.first == "config_update_url") - vendor_profile.config_update_url = kvp.second.data(); - } - } else if (boost::starts_with(section.first, printer_model_key)) { - VendorProfile::PrinterModel model; - model.id = section.first.substr(printer_model_key.size()); - model.name = section.second.get("name", model.id); - section.second.get("variants", ""); - std::vector variants; - if (Slic3r::unescape_strings_cstyle(section.second.get("variants", ""), variants)) { - for (const std::string &variant_name : variants) { - if (model.variant(variant_name) == nullptr) - model.variants.emplace_back(VendorProfile::PrinterVariant(variant_name)); - } - } else { - // Log error? - } - if (! model.id.empty() && ! model.variants.empty()) - vendor_profile.models.push_back(std::move(model)); - } - } -} - // Load a config bundle file, into presets and store the loaded presets into separate files // of the local configuration directory. void PresetBundle::install_vendor_configbundle(const std::string &src_path0) @@ -738,10 +702,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla const VendorProfile *vendor_profile = nullptr; if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) { boost::filesystem::path fspath(path); - VendorProfile vp(fspath.stem().string()); - load_vendor_profile(tree, vp); - if (vp.name.empty()) - throw std::runtime_error(std::string("Vendor Config Bundle is not valid: Missing vendor name key.")); + auto vp = VendorProfile::from_ini(tree, fspath.stem().string()); if (vp.num_variants() == 0) return 0; vendor_profile = &(*this->vendors.insert(vp).first); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 040d326b5c..a16a6d8894 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -1,9 +1,8 @@ #include "PresetUpdater.hpp" -#include // XXX #include #include -#include +#include #include #include @@ -22,6 +21,7 @@ namespace Slic3r { // TODO: proper URL +// TODO: Actually, use index static const std::string SLIC3R_VERSION_URL = "https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/e9187c3e15ceaf1a90f29b7c43cf3ccc746140f0/slic3rPE.version"; enum { SLIC3R_VERSION_BODY_MAX = 256, @@ -52,8 +52,6 @@ PresetUpdater::priv::priv(int event) : void PresetUpdater::priv::download(const std::set vendors) const { - std::cerr << "PresetUpdater::priv::download()" << std::endl; - if (!version_check) { return; } // Download current Slic3r version @@ -64,7 +62,6 @@ void PresetUpdater::priv::download(const std::set vendors) const }) .on_complete([&](std::string body, unsigned http_status) { boost::trim(body); - std::cerr << "Got version: " << http_status << ", body: \"" << body << '"' << std::endl; wxCommandEvent* evt = new wxCommandEvent(version_online_event); evt->SetString(body); GUI::get_app()->QueueEvent(evt); @@ -74,25 +71,19 @@ void PresetUpdater::priv::download(const std::set vendors) const if (!preset_update) { return; } // Donwload vendor preset bundles - std::cerr << "Bundle vendors: " << vendors.size() << std::endl; for (const auto &vendor : vendors) { - std::cerr << "vendor: " << vendor.name << std::endl; - std::cerr << " URL: " << vendor.config_update_url << std::endl; - if (cancel) { return; } // TODO: Proper caching auto target_path = cache_path / vendor.id; target_path += ".ini"; - std::cerr << "target_path: " << target_path << std::endl; Http::get(vendor.config_update_url) .on_progress([this](Http::Progress, bool &cancel) { cancel = this->cancel; }) .on_complete([&](std::string body, unsigned http_status) { - std::cerr << "Got ini: " << http_status << ", body: " << body.size() << std::endl; fs::fstream file(target_path, std::ios::out | std::ios::binary | std::ios::trunc); file.write(body.c_str(), body.size()); }) @@ -121,7 +112,6 @@ PresetUpdater::~PresetUpdater() void PresetUpdater::download(PresetBundle *preset_bundle) { - std::cerr << "PresetUpdater::download()" << std::endl; // Copy the whole vendors data for use in the background thread // Unfortunatelly as of C++11, it needs to be copied again @@ -133,5 +123,23 @@ void PresetUpdater::download(PresetBundle *preset_bundle) })); } +void PresetUpdater::init_vendors() +{ + const auto vendors_rources = fs::path(resources_dir()) / "profiles"; + const auto vendors_data = fs::path(Slic3r::data_dir()) / "vendor"; + + for (fs::directory_iterator it(vendors_rources); it != fs::directory_iterator(); ++it) { + if (it->path().extension() == ".ini") { + auto vp = VendorProfile::from_ini(it->path(), false); + const auto path_in_data = vendors_data / it->path().filename(); + + if (! fs::exists(path_in_data) || VendorProfile::from_ini(path_in_data, false).config_version < vp.config_version) { + // FIXME: update vendor bundle properly when snapshotting is ready + PresetBundle::install_vendor_configbundle(it->path()); + } + } + } +} + } diff --git a/xs/src/slic3r/Utils/PresetUpdater.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp index aafe9569b7..b10c61784b 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -19,7 +19,9 @@ public: PresetUpdater &operator=(const PresetUpdater &) = delete; ~PresetUpdater(); - void download(PresetBundle *preset_bundle); + void download(PresetBundle *preset_bundle); // XXX + + static void init_vendors(); private: struct priv; std::unique_ptr p; diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index bd8e9b7582..2ac2ba7002 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -10,6 +11,7 @@ namespace Slic3r { +// FIXME:: operators=: leak, return class Semver { @@ -18,9 +20,22 @@ public: struct Minor { const int i; Minor(int i) : i(i) {} }; struct Patch { const int i; Patch(int i) : i(i) {} }; + Semver(int major, int minor, int patch, + boost::optional metadata = boost::none, + boost::optional prerelease = boost::none) + { + ver.major = major; + ver.minor = minor; + ver.patch = patch; + ver.metadata = metadata ? std::strcpy(ver.metadata, metadata->c_str()) : nullptr; + ver.prerelease = prerelease ? std::strcpy(ver.prerelease, prerelease->c_str()) : nullptr; + } + + // TODO: throwing ctor ??? + static boost::optional parse(const std::string &str) { - semver_t ver; + semver_t ver = semver_zero(); if (::semver_parse(str.c_str(), &ver) == 0) { return Semver(ver); } else { @@ -121,6 +136,8 @@ private: semver_t ver; Semver(semver_t ver) : ver(ver) {} + + static semver_t semver_zero() { return { 0, 0, 0, nullptr, nullptr }; } }; diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 964f350b9e..46e4ace83f 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -61,7 +61,13 @@ bool check_unsaved_changes() %code%{ RETVAL=Slic3r::GUI::check_unsaved_changes(); %}; bool config_wizard(int fresh_start) - %code%{ RETVAL=Slic3r::GUI::config_wizard(fresh_start != 0); %}; + %code%{ + try { + RETVAL = Slic3r::GUI::config_wizard(fresh_start != 0); + } catch (std::exception& e) { + croak("%s\n", e.what()); + } + %}; void open_preferences_dialog(int preferences_event) %code%{ Slic3r::GUI::open_preferences_dialog(preferences_event); %}; From 12b3132b1a55459b550f144b70b7ae548014c751 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 11 Apr 2018 15:20:38 +0200 Subject: [PATCH 0161/1150] Perform init_vendors at startup --- lib/Slic3r/GUI.pm | 2 ++ xs/src/slic3r/GUI/ConfigWizard.cpp | 3 --- xs/xsp/Utils_PresetUpdater.xsp | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index b28b84df32..2082728cc4 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -101,6 +101,8 @@ sub OnInit { $self->{app_config}->set('version', $Slic3r::VERSION); $self->{app_config}->save; + Slic3r::PresetUpdater::init_vendors(); + # my $version_check = $self->{app_config}->get('version_check'); $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT, $self->{app_config}); my $slic3r_update = $self->{app_config}->slic3r_update_avail; diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 0c2a9dd596..52a896704d 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -700,9 +700,6 @@ ConfigWizard::~ConfigWizard() {} bool ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) { - // FIXME: this should be done always at app startup - PresetUpdater::init_vendors(); - ConfigWizard wizard(parent); if (wizard.ShowModal() == wxID_OK) { wizard.p->apply_config(GUI::get_app_config(), preset_bundle); diff --git a/xs/xsp/Utils_PresetUpdater.xsp b/xs/xsp/Utils_PresetUpdater.xsp index 666379f02e..1cb9f1c39e 100644 --- a/xs/xsp/Utils_PresetUpdater.xsp +++ b/xs/xsp/Utils_PresetUpdater.xsp @@ -8,4 +8,5 @@ %name{Slic3r::PresetUpdater} class PresetUpdater { PresetUpdater(int version_online_event, AppConfig *app_config); void download(PresetBundle* preset_bundle); + static void init_vendors(); }; From b030791384a312d8368941fb7bc01c65e1fd6dea Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 11 Apr 2018 17:07:27 +0200 Subject: [PATCH 0162/1150] Semver fixes, misc fixes --- resources/profiles/BarBaz.ini | 2 +- resources/profiles/Foobar.ini | 2 +- xs/src/semver/semver.c | 18 ++++++++++++++++++ xs/src/semver/semver.h | 3 +++ xs/src/slic3r/GUI/AboutDialog.cpp | 2 +- xs/src/slic3r/GUI/GUI.cpp | 8 ++++---- xs/src/slic3r/Utils/Semver.hpp | 30 +++++------------------------- xs/src/slic3r/Utils/Time.cpp | 3 ++- 8 files changed, 35 insertions(+), 33 deletions(-) diff --git a/resources/profiles/BarBaz.ini b/resources/profiles/BarBaz.ini index 83bb156844..7c8cd3a6bb 100644 --- a/resources/profiles/BarBaz.ini +++ b/resources/profiles/BarBaz.ini @@ -5,7 +5,7 @@ name = Bar Baz # Configuration version of this file. Config file will only be installed, if the config_version differs. # This means, the server may force the Slic3r configuration to be downgraded. -config_version = 0.1 +config_version = 0.1.0 # Where to get the updates from? config_update_url = https://example.com diff --git a/resources/profiles/Foobar.ini b/resources/profiles/Foobar.ini index 21681398aa..571aa8bb8b 100644 --- a/resources/profiles/Foobar.ini +++ b/resources/profiles/Foobar.ini @@ -5,7 +5,7 @@ name = Foo Bar # Configuration version of this file. Config file will only be installed, if the config_version differs. # This means, the server may force the Slic3r configuration to be downgraded. -config_version = 0.1 +config_version = 0.1.0 # Where to get the updates from? config_update_url = https://example.com diff --git a/xs/src/semver/semver.c b/xs/src/semver/semver.c index 599217f89f..3e4a30e3a0 100644 --- a/xs/src/semver/semver.c +++ b/xs/src/semver/semver.c @@ -615,3 +615,21 @@ semver_numeric (semver_t *x) { return num; } + +static char *semver_strdup(const char *src) { + if (src == NULL) return NULL; + size_t len = strlen(src) + 1; + char *res = malloc(len); + return res != NULL ? (char *) memcpy(res, src, len) : NULL; +} + +semver_t +semver_copy(const semver_t *ver) { + semver_t res = *ver; + if (ver->metadata != NULL) { + res.metadata = strdup(ver->metadata); + } + if (ver->prerelease != NULL) { + res.prerelease = strdup(ver->prerelease); + } +} \ No newline at end of file diff --git a/xs/src/semver/semver.h b/xs/src/semver/semver.h index 1b48670ca3..7251f51e3a 100644 --- a/xs/src/semver/semver.h +++ b/xs/src/semver/semver.h @@ -98,6 +98,9 @@ semver_is_valid (const char *s); int semver_clean (char *s); +semver_t +semver_copy(const semver_t *ver); + #ifdef __cplusplus } #endif diff --git a/xs/src/slic3r/GUI/AboutDialog.cpp b/xs/src/slic3r/GUI/AboutDialog.cpp index 49cfff2bdd..664bbd1bbd 100644 --- a/xs/src/slic3r/GUI/AboutDialog.cpp +++ b/xs/src/slic3r/GUI/AboutDialog.cpp @@ -56,7 +56,7 @@ AboutDialog::AboutDialog() // version { - std::string version_string = _(L("Version ")) + std::string(SLIC3R_VERSION); + auto version_string = _(L("Version ")) + std::string(SLIC3R_VERSION); wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize); wxFont version_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); #ifdef __WXMSW__ diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index cef56b8929..d70b47840b 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -352,11 +352,11 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l // A different naming convention is used for the Wizard on Windows vs. OSX & GTK. #if WIN32 - std::string config_wizard_menu = _(L("Configuration Wizard")); - std::string config_wizard_tooltip = _(L("Run configuration wizard")); + auto config_wizard_menu = _(L("Configuration Wizard")); + auto config_wizard_tooltip = _(L("Run configuration wizard")); #else - std::string config_wizard_menu = _(L("Configuration Assistant")); - std::string config_wizard_tooltip = _(L("Run configuration Assistant")); + auto config_wizard_menu = _(L("Configuration Assistant")); + auto config_wizard_tooltip = _(L("Run configuration Assistant")); #endif // Cmd+, is standard on OS X - what about other operating systems? local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_menu + "\u2026", config_wizard_tooltip); diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index 2ac2ba7002..a1f4a92e86 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -43,11 +43,7 @@ public: } } - static const Semver zero() - { - static semver_t ver = { 0, 0, 0, nullptr, nullptr }; - return Semver(ver); - } + static const Semver zero() { return Semver(semver_zero()); } static const Semver inf() { @@ -61,37 +57,21 @@ public: return Semver(ver); } - Semver(Semver &&other) : ver(other.ver) - { - other.ver.major = other.ver.minor = other.ver.patch = 0; - other.ver.metadata = other.ver.prerelease = nullptr; - } - - Semver(const Semver &other) : ver(other.ver) - { - if (other.ver.metadata != nullptr) - ver.metadata = strdup(other.ver.metadata); - if (other.ver.prerelease != nullptr) - ver.prerelease = strdup(other.ver.prerelease); - } + Semver(Semver &&other) : ver(other.ver) { other.ver = semver_zero(); } + Semver(const Semver &other) : ver(::semver_copy(&other.ver)) {} Semver &operator=(Semver &&other) { ::semver_free(&ver); ver = other.ver; - other.ver.major = other.ver.minor = other.ver.patch = 0; - other.ver.metadata = other.ver.prerelease = nullptr; + other.ver = semver_zero(); return *this; } Semver &operator=(const Semver &other) { ::semver_free(&ver); - ver = other.ver; - if (other.ver.metadata != nullptr) - ver.metadata = strdup(other.ver.metadata); - if (other.ver.prerelease != nullptr) - ver.prerelease = strdup(other.ver.prerelease); + ver = ::semver_copy(&other.ver); return *this; } diff --git a/xs/src/slic3r/Utils/Time.cpp b/xs/src/slic3r/Utils/Time.cpp index a2b2328af6..f38c4b4074 100644 --- a/xs/src/slic3r/Utils/Time.cpp +++ b/xs/src/slic3r/Utils/Time.cpp @@ -71,7 +71,8 @@ time_t get_current_time_utc() tm.tm_isdst = -1; return mktime(&tm); #else - return gmtime(); + const time_t current_local = time(nullptr); + return mktime(gmtime(¤t_local)); #endif } From 1a274a253abd9860f8b5a0c956ab2511ae997fef Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 12 Apr 2018 10:10:15 +0200 Subject: [PATCH 0163/1150] Fixed object/instance transformation after import from 3mf files --- xs/src/libslic3r/Format/3mf.cpp | 39 +++++---------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/xs/src/libslic3r/Format/3mf.cpp b/xs/src/libslic3r/Format/3mf.cpp index 89f9b277fc..7b5bf7e8a6 100644 --- a/xs/src/libslic3r/Format/3mf.cpp +++ b/xs/src/libslic3r/Format/3mf.cpp @@ -388,7 +388,6 @@ namespace Slic3r { bool _create_object_instance(int object_id, const Matrix4x4& matrix, unsigned int recur_counter); - void _apply_transform(ModelObject& object, const Matrix4x4& matrix); void _apply_transform(ModelInstance& instance, const Matrix4x4& matrix); bool _handle_start_config(const char** attributes, unsigned int num_attributes); @@ -557,19 +556,6 @@ namespace Slic3r { if (!_generate_volumes(*object.second, obj_geometry->second, *volumes_ptr)) return false; - - // apply transformation if the object contains a single instance - if (object.second->instances.size() == 1) - { - for (const Instance& instance : m_instances) - { - if (object.second->instances[0] == instance.instance) - { - _apply_transform(*object.second, instance.matrix); - break; - } - } - } } // fixes the min z of the model if negative @@ -822,10 +808,9 @@ namespace Slic3r { if (instance.instance != nullptr) { ModelObject* object = instance.instance->get_object(); - if ((object != nullptr) && (object->instances.size() > 1)) + if (object != nullptr) { - // multiple instances -> apply the matrix to the instance - // (for single instance the transformation can be applied only after the volumes have been generated) + // apply the matrix to the instance _apply_transform(*instance.instance, instance.matrix); } } @@ -1120,15 +1105,6 @@ namespace Slic3r { return true; } - void _3MF_Importer::_apply_transform(ModelObject& object, const Matrix4x4& matrix) - { - float matrix3x4[12] = { matrix(0, 0), matrix(0, 1), matrix(0, 2), matrix(0, 3), - matrix(1, 0), matrix(1, 1), matrix(1, 2), matrix(1, 3), - matrix(2, 0), matrix(2, 1), matrix(2, 2), matrix(2, 3) }; - - object.transform(matrix3x4); - } - void _3MF_Importer::_apply_transform(ModelInstance& instance, const Matrix4x4& matrix) { // slic3r ModelInstance cannot be transformed using a matrix @@ -1645,9 +1621,7 @@ namespace Slic3r { } Eigen::Affine3f transform; - transform = Eigen::Translation3f((float)(instance->offset.x + object.origin_translation.x), (float)(instance->offset.y + object.origin_translation.y), (float)object.origin_translation.z) - * Eigen::AngleAxisf((float)instance->rotation, Eigen::Vector3f::UnitZ()) - * Eigen::Scaling((float)instance->scaling_factor); + transform = Eigen::Translation3f((float)instance->offset.x, (float)instance->offset.y, 0.0f) * Eigen::AngleAxisf((float)instance->rotation, Eigen::Vector3f::UnitZ()) * Eigen::Scaling((float)instance->scaling_factor); build_items.emplace_back(instance_id, transform.matrix()); stream << " \n"; @@ -1690,10 +1664,9 @@ namespace Slic3r { for (int i = 0; i < stl.stats.shared_vertices; ++i) { stream << " <" << VERTEX_TAG << " "; - // Subtract origin_translation in order to restore the original local coordinates - stream << "x=\"" << (stl.v_shared[i].x - object.origin_translation.x) << "\" "; - stream << "y=\"" << (stl.v_shared[i].y - object.origin_translation.y) << "\" "; - stream << "z=\"" << (stl.v_shared[i].z - object.origin_translation.z) << "\" />\n"; + stream << "x=\"" << stl.v_shared[i].x << "\" "; + stream << "y=\"" << stl.v_shared[i].y << "\" "; + stream << "z=\"" << stl.v_shared[i].z << "\" />\n"; } } From 9ab38f416d20d0ca8fc33c08d80e2be07fc878ff Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 12 Apr 2018 11:24:03 +0200 Subject: [PATCH 0164/1150] Improvement of the snapshot dialog, fixed storing of the snapshot "reason" field. --- xs/src/slic3r/Config/Snapshot.cpp | 22 ++++++++++++++- xs/src/slic3r/Config/Snapshot.hpp | 2 ++ xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp | 31 +++++++++++++++++----- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index eeb5b6ac58..c50021e2ee 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -133,6 +133,21 @@ void Snapshot::load_ini(const std::string &path) } } +static std::string reason_string(const Snapshot::Reason reason) +{ + switch (reason) { + case Snapshot::SNAPSHOT_UPGRADE: + return "upgrade"; + case Snapshot::SNAPSHOT_DOWNGRADE: + return "downgrade"; + case Snapshot::SNAPSHOT_USER: + return "user"; + case Snapshot::SNAPSHOT_UNKNOWN: + default: + return "unknown"; + } +} + void Snapshot::save_ini(const std::string &path) { boost::nowide::ofstream c; @@ -145,7 +160,7 @@ void Snapshot::save_ini(const std::string &path) c << "time_captured = " << Slic3r::Utils::format_time_ISO8601Z(this->time_captured) << std::endl; c << "slic3r_version_captured = " << this->slic3r_version_captured.to_string() << std::endl; c << "comment = " << this->comment << std::endl; - c << "reason = " << this->reason << std::endl; + c << "reason = " << reason_string(this->reason) << std::endl; // Export the active presets at the time of the snapshot. c << std::endl << "[presets]" << std::endl; @@ -294,6 +309,11 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot: Snapshot::VendorConfig cfg; cfg.name = vendor.first; cfg.models_variants_installed = vendor.second; + for (auto it = cfg.models_variants_installed.begin(); it != cfg.models_variants_installed.end();) + if (it->second.empty()) + cfg.models_variants_installed.erase(it ++); + else + ++ it; // Read the active config bundle, parse the config version. PresetBundle bundle; bundle.load_configbundle((data_dir / "vendor" / (cfg.name + ".ini")).string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp index a7b8a5aa5d..8f27027a4d 100644 --- a/xs/src/slic3r/Config/Snapshot.hpp +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -57,6 +57,8 @@ public: std::string comment; Reason reason; + std::string format_reason() const; + // Active presets at the time of the snapshot. std::string print; std::vector filaments; diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp index 730b97a320..5bc8b1012f 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -8,6 +8,21 @@ namespace Slic3r { namespace GUI { +static std::string format_reason(const Config::Snapshot::Reason reason) +{ + switch (reason) { + case Config::Snapshot::SNAPSHOT_UPGRADE: + return std::string(_(L("Upgrade"))); + case Config::Snapshot::SNAPSHOT_DOWNGRADE: + return std::string(_(L("Downgrade"))); + case Config::Snapshot::SNAPSHOT_USER: + return std::string(_(L("User"))); + case Config::Snapshot::SNAPSHOT_UNKNOWN: + default: + return std::string(_(L("Unknown"))); + } +} + static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_even) { // Start by declaring a row with an alternating background color. @@ -15,11 +30,15 @@ static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_ text += row_even ? "#FFFFFF" : "#C0C0C0"; text += "\">"; text += ""; text += ""; text += ""; return text; } -static std::string generate_html_page(const Config::SnapshotDB &snapshot_db) +static std::string generate_html_page(const Config::SnapshotDB &snapshot_db, const std::string &on_snapshot) { std::string text = "" @@ -75,7 +79,7 @@ static std::string generate_html_page(const Config::SnapshotDB &snapshot_db) text += "
"; -// text += _(L("ID:")) + " " + snapshot.id + "
"; - text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "
"; - text += _(L("slic3r version:")) + " " + snapshot.slic3r_version_captured.to_string() + "
"; + // Format the row header. + text += std::string("") + Utils::format_local_date_time(snapshot.time_captured) + ": " + format_reason(snapshot.reason); if (! snapshot.comment.empty()) - text += _(L("user comment:")) + " " + snapshot.comment + "
"; + text += " (" + snapshot.comment + ")"; + text += "

"; + // End of row header. +// text += _(L("ID:")) + " " + snapshot.id + "
"; + // text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "
"; + text += _(L("slic3r version:")) + " " + snapshot.slic3r_version_captured.to_string() + "
"; // text += "reason: " + snapshot.reason + "
"; text += "print: " + snapshot.print + "
"; text += "filaments: " + snapshot.filaments.front() + "
"; @@ -79,9 +98,9 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db { wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); #ifdef __WXMSW__ - int size[] = {8,8,8,8,8,8,8}; + int size[] = {8,8,8,8,11,11,11}; #else - int size[] = {11,11,11,11,11,11,11}; + int size[] = {11,11,11,11,14,14,14}; #endif html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); html->SetBorders(2); From b062cddeea4f6ef11557b6bb533a046076ba177d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 12 Apr 2018 12:56:42 +0200 Subject: [PATCH 0165/1150] Fixed object cutting --- xs/src/libslic3r/Model.cpp | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 5611067132..bda49421d0 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -863,33 +863,9 @@ void ModelObject::cut(coordf_t z, Model* model) const lower->add_volume(*volume); } else { TriangleMesh upper_mesh, lower_mesh; - // TODO: shouldn't we use object bounding box instead of per-volume bb? - coordf_t cut_z = z + volume->mesh.bounding_box().min.z; - if (false) { -// if (volume->mesh.has_multiple_patches()) { - // Cutting algorithm does not work on intersecting meshes. - // As we are not sure whether the meshes don't intersect, - // we rather split the mesh into multiple non-intersecting pieces. - TriangleMeshPtrs meshptrs = volume->mesh.split(); - for (TriangleMeshPtrs::iterator mesh = meshptrs.begin(); mesh != meshptrs.end(); ++mesh) { - printf("Cutting mesh patch %d of %d\n", int(mesh - meshptrs.begin()), int(meshptrs.size())); - (*mesh)->repair(); - TriangleMeshSlicer tms(*mesh); - if (mesh == meshptrs.begin()) { - tms.cut(cut_z, &upper_mesh, &lower_mesh); - } else { - TriangleMesh upper_mesh_this, lower_mesh_this; - tms.cut(cut_z, &upper_mesh_this, &lower_mesh_this); - upper_mesh.merge(upper_mesh_this); - lower_mesh.merge(lower_mesh_this); - } - delete *mesh; - } - } else { - printf("Cutting mesh patch\n"); - TriangleMeshSlicer tms(&volume->mesh); - tms.cut(cut_z, &upper_mesh, &lower_mesh); - } + printf("Cutting mesh patch\n"); + TriangleMeshSlicer tms(&volume->mesh); + tms.cut(z, &upper_mesh, &lower_mesh); upper_mesh.repair(); lower_mesh.repair(); From a3fc49ee76673ddcc9650baffc6a95c2f02ce144 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 12 Apr 2018 13:54:26 +0200 Subject: [PATCH 0166/1150] Fixed hovering not shown on out of print bed objects --- lib/Slic3r/GUI/3DScene.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index a89ed08884..e5990fe8d5 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1828,7 +1828,6 @@ sub _fragment_shader_Gouraud { return <<'FRAGMENT'; #version 110 -const vec4 OUTSIDE_COLOR = vec4(0.24, 0.42, 0.62, 1.0); const vec3 ZERO = vec3(0.0, 0.0, 0.0); // x = tainted, y = specular; @@ -1841,11 +1840,9 @@ uniform vec4 uniform_color; void main() { - // if the fragment is outside the print volume use predefined color - vec4 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? OUTSIDE_COLOR : uniform_color; - - gl_FragColor = vec4(intensity.y, intensity.y, intensity.y, 0.0) + color * intensity.x; - gl_FragColor.a = color.a; + // if the fragment is outside the print volume -> use darker color + vec3 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(uniform_color.rgb, ZERO, 0.3333) : uniform_color.rgb; + gl_FragColor = vec4(vec3(intensity.y, intensity.y, intensity.y) + color * intensity.x, uniform_color.a); } FRAGMENT From adbaa42b2b44c2d1bda43cd589fd83ed11476c6b Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 12 Apr 2018 15:38:05 +0200 Subject: [PATCH 0167/1150] Bugfix: cooling tubes parameters change invalidates generated wipe tower --- xs/src/libslic3r/Print.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 3ce73ab9a9..4012b91f8a 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -90,8 +90,6 @@ bool Print::invalidate_state_by_config_options(const std::vector Date: Thu, 12 Apr 2018 16:13:59 +0200 Subject: [PATCH 0168/1150] Default purging volumes set to more appropriate values --- xs/src/libslic3r/PrintConfig.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index ef54b24cf8..66576c9f1a 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1038,7 +1038,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("parking_pos_retraction", coFloat); def->label = L("Filament parking position"); - def->tooltip = L("Distance of the extruder tip from the position where the filament is parked" + def->tooltip = L("Distance of the extruder tip from the position where the filament is parked " "when unloaded. This should match the value in printer firmware. "); def->sidetext = L("mm"); def->cli = "parking_pos_retraction=f"; @@ -1818,18 +1818,18 @@ PrintConfigDef::PrintConfigDef() "wipe tower. These values are used to simplify creation of the full purging " "volumes below. "); def->cli = "wiping-volumes-extruders=f@"; - def->default_value = new ConfigOptionFloats { 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f }; + def->default_value = new ConfigOptionFloats { 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f, 70.f }; def = this->add("wiping_volumes_matrix", coFloats); def->label = L("Purging volumes - matrix"); def->tooltip = L("This matrix describes volumes (in cubic milimetres) required to purge the" " new filament on the wipe tower for any given pair of tools. "); def->cli = "wiping-volumes-matrix=f@"; - def->default_value = new ConfigOptionFloats { 0.f, 100.f, 100.f, 100.f, 100.f, - 100.f, 0.f, 100.f, 100.f, 100.f, - 100.f, 100.f, 0.f, 100.f, 100.f, - 100.f, 100.f, 100.f, 0.f, 100.f, - 100.f, 100.f, 100.f, 100.f, 0.f }; + def->default_value = new ConfigOptionFloats { 0.f, 140.f, 140.f, 140.f, 140.f, + 140.f, 0.f, 140.f, 140.f, 140.f, + 140.f, 140.f, 0.f, 140.f, 140.f, + 140.f, 140.f, 140.f, 0.f, 140.f, + 140.f, 140.f, 140.f, 140.f, 0.f }; def = this->add("wipe_tower_x", coFloat); def->label = L("Position X"); From d82505984a3f63bcf66a472c54c520495421a8c3 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 12 Apr 2018 16:46:17 +0200 Subject: [PATCH 0169/1150] Rollback changes in BitmapCache --- xs/src/slic3r/GUI/BitmapCache.cpp | 3 --- xs/src/slic3r/GUI/BitmapCache.hpp | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/xs/src/slic3r/GUI/BitmapCache.cpp b/xs/src/slic3r/GUI/BitmapCache.cpp index e29687ce5b..acbcb5c73c 100644 --- a/xs/src/slic3r/GUI/BitmapCache.cpp +++ b/xs/src/slic3r/GUI/BitmapCache.cpp @@ -88,10 +88,7 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, std::vector m_map; From acd8d2df98d5207c0fb8091c96a8d86a57980387 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 13 Apr 2018 09:01:48 +0200 Subject: [PATCH 0170/1150] Fixed layer height profile editing for multipart objects --- lib/Slic3r/GUI/3DScene.pm | 12 ++++++------ xs/src/slic3r/GUI/3DScene.cpp | 7 ++++++- xs/src/slic3r/GUI/3DScene.hpp | 5 +---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index e5990fe8d5..13460cfed2 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1527,10 +1527,13 @@ sub draw_active_object_annotations { my ($reset_left, $reset_bottom, $reset_right, $reset_top) = $self->_variable_layer_thickness_reset_rect_viewport; my $z_cursor_relative = $self->_variable_layer_thickness_bar_mouse_cursor_z_relative; + my $print_object = $self->{print}->get_object($object_idx); + my $z_max = $print_object->model_object->bounding_box->z_max; + $self->{layer_height_edit_shader}->enable; $self->{layer_height_edit_shader}->set_uniform('z_to_texture_row', $volume->layer_height_texture_z_to_row_id); $self->{layer_height_edit_shader}->set_uniform('z_texture_row_to_normalized', 1. / $volume->layer_height_texture_height); - $self->{layer_height_edit_shader}->set_uniform('z_cursor', $volume->bounding_box->z_max * $z_cursor_relative); + $self->{layer_height_edit_shader}->set_uniform('z_cursor', $z_max * $z_cursor_relative); $self->{layer_height_edit_shader}->set_uniform('z_cursor_band_width', $self->{layer_height_edit_band_width}); glBindTexture(GL_TEXTURE_2D, $self->{layer_preview_z_texture_id}); glTexImage2D_c(GL_TEXTURE_2D, 0, GL_RGBA8, $volume->layer_height_texture_width, $volume->layer_height_texture_height, @@ -1552,8 +1555,8 @@ sub draw_active_object_annotations { glBegin(GL_QUADS); glVertex3f($bar_left, $bar_bottom, 0); glVertex3f($bar_right, $bar_bottom, 0); - glVertex3f($bar_right, $bar_top, $volume->bounding_box->z_max); - glVertex3f($bar_left, $bar_top, $volume->bounding_box->z_max); + glVertex3f($bar_right, $bar_top, $z_max); + glVertex3f($bar_left, $bar_top, $z_max); glEnd(); glBindTexture(GL_TEXTURE_2D, 0); $self->{layer_height_edit_shader}->disable; @@ -1572,7 +1575,6 @@ sub draw_active_object_annotations { # Paint the graph. #FIXME show some kind of legend. - my $print_object = $self->{print}->get_object($object_idx); my $max_z = unscale($print_object->size->z); my $profile = $print_object->model_object->layer_height_profile; my $layer_height = $print_object->config->get('layer_height'); @@ -1934,8 +1936,6 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); #define INTENSITY_AMBIENT 0.3 -uniform float z_to_texture_row; - // x = tainted, y = specular; varying vec2 intensity; diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 1ce3d76bfd..a33ef4d1c6 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -305,7 +305,7 @@ void GLVolume::render_using_layer_height() const glUniform1f(z_texture_row_to_normalized_id, (GLfloat)(1.0f / layer_height_texture_height())); if (z_cursor_id >= 0) - glUniform1f(z_cursor_id, (GLfloat)(bounding_box.max.z * layer_height_texture_data.z_cursor_relative)); + glUniform1f(z_cursor_id, (GLfloat)(layer_height_texture_data.print_object->model_object()->bounding_box().max.z * layer_height_texture_data.z_cursor_relative)); if (z_cursor_band_width_id >= 0) glUniform1f(z_cursor_band_width_id, (GLfloat)layer_height_texture_data.edit_band_width); @@ -327,6 +327,11 @@ void GLVolume::render_using_layer_height() const glUseProgram(current_program_id); } +double GLVolume::layer_height_texture_z_to_row_id() const +{ + return (this->layer_height_texture.get() == nullptr) ? 0.0 : double(this->layer_height_texture->cells - 1) / (double(this->layer_height_texture->width) * this->layer_height_texture_data.print_object->model_object()->bounding_box().max.z); +} + void GLVolume::generate_layer_height_texture(PrintObject *print_object, bool force) { GLTexture *tex = this->layer_height_texture.get(); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 6486a7f0e7..380206dd97 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -361,10 +361,7 @@ public: return (layer_height_texture.get() == nullptr) ? 0 : (void*)(layer_height_texture->data.data() + layer_height_texture->width * layer_height_texture->height * 4); } - double layer_height_texture_z_to_row_id() const { - return (this->layer_height_texture.get() == nullptr) ? 0. : - double(this->layer_height_texture->cells - 1) / (double(this->layer_height_texture->width) * bounding_box.max.z); - } + double layer_height_texture_z_to_row_id() const; void generate_layer_height_texture(PrintObject *print_object, bool force); 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) From b49b59cbb25ee8903837e34af1da1f647ef62c84 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 12 Apr 2018 20:04:48 +0200 Subject: [PATCH 0171/1150] Configuration update application at startup --- lib/Slic3r/GUI.pm | 18 +- xs/src/semver/semver.c | 3 +- xs/src/slic3r/Config/Version.cpp | 7 +- xs/src/slic3r/Config/Version.hpp | 2 +- xs/src/slic3r/GUI/AppConfig.hpp | 9 +- xs/src/slic3r/GUI/ConfigWizard.cpp | 63 +++++-- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 12 +- xs/src/slic3r/GUI/Preset.cpp | 7 + xs/src/slic3r/GUI/Preset.hpp | 3 +- xs/src/slic3r/GUI/PresetBundle.cpp | 3 +- xs/src/slic3r/Utils/PresetUpdater.cpp | 208 +++++++++++++++++++-- xs/src/slic3r/Utils/PresetUpdater.hpp | 2 +- xs/src/slic3r/Utils/Semver.hpp | 3 +- xs/xsp/Utils_PresetUpdater.xsp | 2 +- 14 files changed, 288 insertions(+), 54 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 2082728cc4..b592c4289b 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -101,11 +101,14 @@ sub OnInit { $self->{app_config}->set('version', $Slic3r::VERSION); $self->{app_config}->save; - Slic3r::PresetUpdater::init_vendors(); - # my $version_check = $self->{app_config}->get('version_check'); $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT, $self->{app_config}); - my $slic3r_update = $self->{app_config}->slic3r_update_avail; + eval { $self->{preset_updater}->config_update() }; + if ($@) { + warn $@ . "\n"; + fatal_error(undef, $@); + } + # my $slic3r_update = $self->{app_config}->slic3r_update_avail; Slic3r::GUI::set_app_config($self->{app_config}); Slic3r::GUI::load_language(); @@ -123,6 +126,7 @@ sub OnInit { Slic3r::GUI::set_preset_bundle($self->{preset_bundle}); # application frame + print STDERR "Creating main frame...\n"; Wx::Image::FindHandlerType(wxBITMAP_TYPE_PNG) || Wx::Image::AddHandler(Wx::PNGHandler->new); $self->{mainframe} = my $frame = Slic3r::GUI::MainFrame->new( # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden. @@ -145,9 +149,9 @@ sub OnInit { # before the UI was up and running. $self->CallAfter(sub { # XXX: recreate_GUI ??? - if ($slic3r_update) { - # TODO - } + # if ($slic3r_update) { + # # TODO + # } # XXX: ? if ($run_wizard) { # Run the config wizard, don't offer the "reset user profile" checkbox. @@ -159,6 +163,7 @@ sub OnInit { # The following event is emited by the C++ menu implementation of application language change. EVT_COMMAND($self, -1, $LANGUAGE_CHANGE_EVENT, sub{ + print STDERR "LANGUAGE_CHANGE_EVENT\n"; $self->recreate_GUI; }); @@ -179,6 +184,7 @@ sub OnInit { } sub recreate_GUI{ + print STDERR "recreate_GUI\n"; my ($self) = @_; my $topwindow = $self->GetTopWindow(); $self->{mainframe} = my $frame = Slic3r::GUI::MainFrame->new( diff --git a/xs/src/semver/semver.c b/xs/src/semver/semver.c index 3e4a30e3a0..0285fe40ef 100644 --- a/xs/src/semver/semver.c +++ b/xs/src/semver/semver.c @@ -632,4 +632,5 @@ semver_copy(const semver_t *ver) { if (ver->prerelease != NULL) { res.prerelease = strdup(ver->prerelease); } -} \ No newline at end of file + return res; +} diff --git a/xs/src/slic3r/Config/Version.cpp b/xs/src/slic3r/Config/Version.cpp index 95b3caf1a3..5430e569c4 100644 --- a/xs/src/slic3r/Config/Version.cpp +++ b/xs/src/slic3r/Config/Version.cpp @@ -141,7 +141,7 @@ size_t Index::load(const boost::filesystem::path &path) return m_configs.size(); } -Index::const_iterator Index::find(const Semver &ver) +Index::const_iterator Index::find(const Semver &ver) const { Version key; key.config_version = ver; @@ -163,12 +163,11 @@ Index::const_iterator Index::recommended() const std::vector Index::load_db() { - boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); - boost::filesystem::path vendor_dir = data_dir / "vendor"; + boost::filesystem::path cache_dir = boost::filesystem::path(Slic3r::data_dir()) / "cache"; std::vector index_db; std::string errors_cummulative; - for (auto &dir_entry : boost::filesystem::directory_iterator(vendor_dir)) + for (auto &dir_entry : boost::filesystem::directory_iterator(cache_dir)) if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".idx")) { Index idx; try { diff --git a/xs/src/slic3r/Config/Version.hpp b/xs/src/slic3r/Config/Version.hpp index 43512e82f5..c010a1748b 100644 --- a/xs/src/slic3r/Config/Version.hpp +++ b/xs/src/slic3r/Config/Version.hpp @@ -62,7 +62,7 @@ public: const_iterator begin() const { return m_configs.begin(); } const_iterator end() const { return m_configs.end(); } - const_iterator find(const Semver &ver); + const_iterator find(const Semver &ver) const; const std::vector& configs() const { return m_configs; } // Finds a recommended config to be installed for the current Slic3r version. // Returns configs().end() if such version does not exist in the index. This shall never happen diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index cac2759f1a..ffda083ec3 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -69,12 +69,13 @@ public: void clear_section(const std::string §ion) { m_storage[section].clear(); } + typedef std::map>> VendorMap; bool get_variant(const std::string &vendor, const std::string &model, const std::string &variant) const; void set_variant(const std::string &vendor, const std::string &model, const std::string &variant, bool enable); void set_vendors(const AppConfig &from); - void set_vendors(const std::map>> &vendors) { m_vendors = vendors; m_dirty = true; } - void set_vendors(std::map>> &&vendors) { m_vendors = std::move(vendors); m_dirty = true; } - const std::map>> vendors() const { return m_vendors; } + void set_vendors(const VendorMap &vendors) { m_vendors = vendors; m_dirty = true; } + void set_vendors(VendorMap &&vendors) { m_vendors = std::move(vendors); m_dirty = true; } + const VendorMap& vendors() const { return m_vendors; } // return recent/skein_directory or recent/config_directory or empty string. std::string get_last_dir() const; @@ -105,7 +106,7 @@ private: // Map of section, name -> value std::map> m_storage; // Map of enabled vendors / models / variants - std::map>> m_vendors; + VendorMap m_vendors; // Has any value been modified since the config.ini has been last saved or loaded? bool m_dirty; }; diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 52a896704d..f353ab7f7e 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -1,8 +1,8 @@ #include "ConfigWizard_private.hpp" +#include // XXX #include #include -#include #include #include @@ -17,7 +17,6 @@ #include "GUI.hpp" #include "slic3r/Utils/PresetUpdater.hpp" -namespace fs = boost::filesystem; namespace Slic3r { namespace GUI { @@ -62,25 +61,25 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, cons auto namefont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); namefont.SetWeight(wxFONTWEIGHT_BOLD); - for (auto model = models.cbegin(); model != models.cend(); ++model) { + for (const auto &model : models) { auto *panel = new wxPanel(this); auto *sizer = new wxBoxSizer(wxVERTICAL); panel->SetSizer(sizer); - auto *title = new wxStaticText(panel, wxID_ANY, model->name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + auto *title = new wxStaticText(panel, wxID_ANY, model.name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); title->SetFont(namefont); sizer->Add(title, 0, wxBOTTOM, 3); - auto bitmap_file = wxString::Format("printers/%s_%s.png", vendor.id, model->id); + auto bitmap_file = wxString::Format("printers/%s_%s.png", vendor.id, model.id); wxBitmap bitmap(GUI::from_u8(Slic3r::var(bitmap_file.ToStdString())), wxBITMAP_TYPE_PNG); auto *bitmap_widget = new wxStaticBitmap(panel, wxID_ANY, bitmap); sizer->Add(bitmap_widget, 0, wxBOTTOM, 3); sizer->AddSpacer(20); - const auto model_id = model->id; + const auto model_id = model.id; - for (const auto &variant : model->variants) { + for (const auto &variant : model.variants) { const auto variant_name = variant.name; auto *cbox = new wxCheckBox(panel, wxID_ANY, wxString::Format("%s %s %s", variant.name, _(L("mm")), _(L("nozzle")))); bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant_name); @@ -177,16 +176,18 @@ PageWelcome::PageWelcome(ConfigWizard *parent) : { append_text(_(L("Hello, welcome to Slic3r Prusa Edition! TODO: This text."))); - const PresetBundle &bundle = wizard_p()->bundle_vendors; - const auto &vendors = bundle.vendors; - const auto vendor_prusa = std::find(vendors.cbegin(), vendors.cend(), VendorProfile("PrusaResearch")); + // const PresetBundle &bundle = wizard_p()->bundle_vendors; + // const auto &vendors = bundle.vendors; + const auto &vendors = wizard_p()->vendors; + // const auto vendor_prusa = std::find(vendors.cbegin(), vendors.cend(), VendorProfile("PrusaResearch")); + const auto vendor_prusa = vendors.find("PrusaResearch"); if (vendor_prusa != vendors.cend()) { - const auto &models = vendor_prusa->models; + const auto &models = vendor_prusa->second.models; AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors; - printer_picker = new PrinterPicker(this, *vendor_prusa, appconfig_vendors); + printer_picker = new PrinterPicker(this, vendor_prusa->second, appconfig_vendors); printer_picker->Bind(EVT_PRINTER_PICK, [this, &appconfig_vendors](const PrinterPickerEvent &evt) { appconfig_vendors.set_variant(evt.vendor_id, evt.model_id, evt.variant_name, evt.enable); this->on_variant_checked(); @@ -248,14 +249,17 @@ PageVendors::PageVendors(ConfigWizard *parent) : { append_text(_(L("Pick another vendor supported by Slic3r PE:"))); - const PresetBundle &bundle = wizard_p()->bundle_vendors; + // const PresetBundle &bundle = wizard_p()->bundle_vendors; + // const auto &vendors = wizard_p()->vendors; auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); boldfont.SetWeight(wxFONTWEIGHT_BOLD); AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors; wxArrayString choices_vendors; - for (const auto &vendor : bundle.vendors) { + // for (const auto &vendor : vendors) { + for (const auto vendor_pair : wizard_p()->vendors) { + const auto &vendor = vendor_pair.second; if (vendor.id == "PrusaResearch") { continue; } auto *picker = new PrinterPicker(this, vendor, appconfig_vendors); @@ -549,9 +553,25 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt) void ConfigWizard::priv::load_vendors() { const auto vendor_dir = fs::path(Slic3r::data_dir()) / "vendor"; + const auto rsrc_vendor_dir = fs::path(resources_dir()) / "profiles"; + + // Load vendors from the "vendors" directory in datadir for (fs::directory_iterator it(vendor_dir); it != fs::directory_iterator(); ++it) { if (it->path().extension() == ".ini") { - bundle_vendors.load_configbundle(it->path().string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); + auto vp = VendorProfile::from_ini(it->path()); + vendors[vp.id] = std::move(vp); + } + } + + // Additionally load up vendors from the application resources directory, but only those not seen in the datadir + for (fs::directory_iterator it(rsrc_vendor_dir); it != fs::directory_iterator(); ++it) { + if (it->path().extension() == ".ini") { + const auto id = it->path().stem().string(); + if (vendors.find(id) == vendors.end()) { + auto vp = VendorProfile::from_ini(it->path()); + vendors_rsrc[vp.id] = it->path(); + vendors[vp.id] = std::move(vp); + } } } @@ -624,6 +644,19 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese const bool is_custom_setup = page_welcome->page_next() == page_firmware; if (! is_custom_setup) { + const auto enabled_vendors = appconfig_vendors.vendors(); + for (const auto &vendor_rsrc : vendors_rsrc) { + const auto vendor = enabled_vendors.find(vendor_rsrc.first); + if (vendor == enabled_vendors.end()) { continue; } + + size_t size_sum = 0; + for (const auto &model : vendor->second) { size_sum += model.second.size(); } + if (size_sum == 0) { continue; } + + // This vendor needs to be installed + PresetBundle::install_vendor_configbundle(vendor_rsrc.second); + } + app_config->set_vendors(appconfig_vendors); app_config->set("version_check", page_update->version_check ? "1" : "0"); app_config->set("preset_update", page_update->preset_update ? "1" : "0"); diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index 652328aaad..137b276b85 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -4,6 +4,9 @@ #include "ConfigWizard.hpp" #include +#include +#include +#include #include #include @@ -13,13 +16,16 @@ #include "libslic3r/PrintConfig.hpp" #include "AppConfig.hpp" -#include "PresetBundle.hpp" +#include "Preset.hpp" +// #include "PresetBundle.hpp" #include "BedShapeDialog.hpp" +namespace fs = boost::filesystem; namespace Slic3r { namespace GUI { +// typedef std::unordered_map VendorMap; enum { CONTENT_WIDTH = 500, @@ -168,7 +174,9 @@ struct ConfigWizard::priv { ConfigWizard *q; AppConfig appconfig_vendors; - PresetBundle bundle_vendors; + // PresetBundle bundle_vendors; + std::unordered_map vendors; + std::unordered_map vendors_rsrc; std::unique_ptr custom_config; wxBoxSizer *topsizer = nullptr; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 39bfbd3981..26f0ff5947 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -5,6 +5,8 @@ #include "AppConfig.hpp" #include +#include +#include #include #include #include @@ -75,6 +77,11 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem { static const std::string printer_model_key = "printer_model:"; const std::string id = path.stem().string(); + + if (! boost::filesystem::exists(path)) { + throw std::runtime_error((boost::format("Cannot load Vendor Config Bundle `%1%`: File not found: `%2%`.") % id % path).str()); + } + VendorProfile res(id); auto get_or_throw = [&](const ptree &tree, const std::string &key) -> ptree::const_assoc_iterator diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index d6ccfd4505..8855bf1e78 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -58,7 +58,8 @@ public: }; std::vector models; - VendorProfile(std::string id) : id(std::move(id)), config_version(0, 0, 0) {} + VendorProfile() {} + VendorProfile(std::string id) : id(std::move(id)) {} static VendorProfile from_ini(const boost::filesystem::path &path, bool load_all=true); static VendorProfile from_ini(const boost::property_tree::ptree &tree, const boost::filesystem::path &path, bool load_all=true); diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index ad27bf8c68..d1d66df60a 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -701,8 +701,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla const VendorProfile *vendor_profile = nullptr; if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) { - boost::filesystem::path fspath(path); - auto vp = VendorProfile::from_ini(tree, fspath.stem().string()); + auto vp = VendorProfile::from_ini(tree, path); if (vp.num_variants() == 0) return 0; vendor_profile = &(*this->vendors.insert(vp).first); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index a16a6d8894..28b9773213 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -1,21 +1,32 @@ #include "PresetUpdater.hpp" +#include // XXX +#include #include +#include #include #include #include #include #include +#include #include "libslic3r/Utils.hpp" #include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/PresetBundle.hpp" #include "slic3r/Utils/Http.hpp" -#include "slic3r/Utils/Semver.hpp" +#include "slic3r/Config/Version.hpp" +#include "slic3r/Config/Snapshot.hpp" namespace fs = boost::filesystem; +using Slic3r::GUI::Config::Index; +using Slic3r::GUI::Config::Version; +using Slic3r::GUI::Config::Snapshot; +using Slic3r::GUI::Config::SnapshotDB; +// XXX: Prevent incomplete file downloads: download a tmp file, then move +// Delete incomplete ones on startup. namespace Slic3r { @@ -27,26 +38,55 @@ enum { SLIC3R_VERSION_BODY_MAX = 256, }; + +struct Update +{ + fs::path source; + fs::path target; + Version version; + + Update(const fs::path &source, fs::path &&target, const Version &version) : + source(source), + target(std::move(target)), + version(version) + {} + + std::string name() { return source.stem().string(); } +}; + +typedef std::vector Updates; + + struct PresetUpdater::priv { int version_online_event; + AppConfig *app_config; bool version_check; bool preset_update; fs::path cache_path; + fs::path rsrc_path; + fs::path vendor_path; + bool cancel; std::thread thread; - priv(int event); + priv(int event, AppConfig *app_config); void download(const std::set vendors) const; + + void check_install_indices() const; + Updates config_update() const; }; -PresetUpdater::priv::priv(int event) : +PresetUpdater::priv::priv(int event, AppConfig *app_config) : version_online_event(event), + app_config(app_config), version_check(false), preset_update(false), cache_path(fs::path(Slic3r::data_dir()) / "cache"), + rsrc_path(fs::path(resources_dir()) / "profiles"), + vendor_path(fs::path(Slic3r::data_dir()) / "vendor"), cancel(false) {} @@ -91,11 +131,119 @@ void PresetUpdater::priv::download(const std::set vendors) const } } +void PresetUpdater::priv::check_install_indices() const +{ + for (fs::directory_iterator it(rsrc_path); it != fs::directory_iterator(); ++it) { + const auto &path = it->path(); + if (path.extension() == ".idx") { + const auto path_in_cache = cache_path / path.filename(); + + // TODO: compare versions + if (! fs::exists(path_in_cache)) { + fs::copy_file(path, path_in_cache, fs::copy_option::overwrite_if_exists); + } + } + } +} + +Updates PresetUpdater::priv::config_update() const +{ + priv::check_install_indices(); + const auto index_db = Index::load_db(); // TODO: Keep in Snapshots singleton? + + Updates updates; + + for (const auto idx : index_db) { + const auto bundle_path = vendor_path / (idx.vendor() + ".ini"); + + // If the bundle doesn't exist at all, update from resources + // if (! fs::exists(bundle_path)) { + // auto path_in_rsrc = rsrc_path / (idx.vendor() + ".ini"); + + // // Otherwise load it and check for chached updates + // const auto rsrc_vp = VendorProfile::from_ini(path_in_rsrc, false); + + // const auto rsrc_ver = idx.find(rsrc_vp.config_version); + // if (rsrc_ver == idx.end()) { + // // TODO: throw + // } + + // if (fs::exists(path_in_rsrc)) { + // updates.emplace_back(bundle_path, std::move(path_in_rsrc), *rsrc_ver); + // } else { + // // XXX: ??? + // } + + // continue; + // } + + if (! fs::exists(bundle_path)) { + continue; + } + + // Perform a basic load and check the version + const auto vp = VendorProfile::from_ini(bundle_path, false); + + const auto ver_current = idx.find(vp.config_version); + if (ver_current == idx.end()) { + // TODO: throw + } + + const auto recommended = idx.recommended(); + if (recommended == idx.end()) { + // TODO: throw + } + + if (! ver_current->is_current_slic3r_supported()) { + + // TODO: Downgrade situation + + } else if (recommended->config_version > ver_current->config_version) { + // Config bundle update situation + + auto path_in_cache = cache_path / (idx.vendor() + ".ini"); + const auto cached_vp = VendorProfile::from_ini(path_in_cache, false); + if (cached_vp.config_version == recommended->config_version) { + updates.emplace_back(bundle_path, std::move(path_in_cache), *ver_current); + } else { + // XXX: ??? + } + } + } + + // Check for bundles that don't have an index + // for (fs::directory_iterator it(rsrc_path); it != fs::directory_iterator(); ++it) { + // if (it->path().extension() == ".ini") { + // const auto &path = it->path(); + // const auto vendor_id = path.stem().string(); + + // const auto needle = std::find_if(index_db.begin(), index_db.end(), [&vendor_id](const Index &idx) { + // return idx.vendor() == vendor_id; + // }); + // if (needle != index_db.end()) { + // continue; + // } + + // auto vp = VendorProfile::from_ini(path, false); + // auto path_in_data = vendor_path / path.filename(); + + // if (! fs::exists(path_in_data)) { + // Version version; + // version.config_version = vp.config_version; + // updates.emplace_back(path, std::move(path_in_data), version); + // } + // } + // } + + return updates; +} + + PresetUpdater::PresetUpdater(int version_online_event, AppConfig *app_config) : - p(new priv(version_online_event)) + p(new priv(version_online_event, app_config)) { p->preset_update = app_config->get("preset_update") == "1"; - // preset_update implies version_check: + // preset_update implies version_check: // XXX: not any more p->version_check = p->preset_update || app_config->get("version_check") == "1"; } @@ -123,19 +271,49 @@ void PresetUpdater::download(PresetBundle *preset_bundle) })); } -void PresetUpdater::init_vendors() +void PresetUpdater::config_update() { - const auto vendors_rources = fs::path(resources_dir()) / "profiles"; - const auto vendors_data = fs::path(Slic3r::data_dir()) / "vendor"; + const auto updates = p->config_update(); + if (updates.size() > 0) { + const auto msg = _(L("Configuration update is available. Would you like to install it?")); - for (fs::directory_iterator it(vendors_rources); it != fs::directory_iterator(); ++it) { - if (it->path().extension() == ".ini") { - auto vp = VendorProfile::from_ini(it->path(), false); - const auto path_in_data = vendors_data / it->path().filename(); + auto ext_msg = _(L( + "Note that a full configuration snapshot will be created first. It can then be restored at any time " + "should there be a problem with the new version.\n\n" + "Updated configuration bundles:\n" + )); - if (! fs::exists(path_in_data) || VendorProfile::from_ini(path_in_data, false).config_version < vp.config_version) { - // FIXME: update vendor bundle properly when snapshotting is ready - PresetBundle::install_vendor_configbundle(it->path()); + for (const auto &update : updates) { + ext_msg += update.target.stem().string() + " " + update.version.config_version.to_string(); + if (! update.version.comment.empty()) { + ext_msg += std::string(" (") + update.version.comment + ")"; + } + ext_msg += "\n"; + } + + wxMessageDialog dlg(NULL, msg, _(L("Configuration update")), wxYES_NO|wxCENTRE); + dlg.SetExtendedMessage(ext_msg); + const auto res = dlg.ShowModal(); + std::cerr << "After modal" << std::endl; + if (res == wxID_YES) { + // User gave clearance, updates are go + + // TODO: Comment? + SnapshotDB::singleton().take_snapshot(*p->app_config, Snapshot::SNAPSHOT_UPGRADE, ""); + + for (const auto &update : updates) { + fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); + + PresetBundle bundle; + bundle.load_configbundle(update.target.string(), PresetBundle::LOAD_CFGBNDLE_SYSTEM); + + auto preset_remover = [](const Preset &preset) { + fs::remove(preset.file); + }; + + for (const auto &preset : bundle.prints) { preset_remover(preset); } + for (const auto &preset : bundle.filaments) { preset_remover(preset); } + for (const auto &preset : bundle.printers) { preset_remover(preset); } } } } diff --git a/xs/src/slic3r/Utils/PresetUpdater.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp index b10c61784b..8fd6e45289 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -21,7 +21,7 @@ public: void download(PresetBundle *preset_bundle); // XXX - static void init_vendors(); + void config_update(); private: struct priv; std::unique_ptr p; diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index a1f4a92e86..2c27ce9826 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -11,7 +11,6 @@ namespace Slic3r { -// FIXME:: operators=: leak, return class Semver { @@ -20,6 +19,8 @@ public: struct Minor { const int i; Minor(int i) : i(i) {} }; struct Patch { const int i; Patch(int i) : i(i) {} }; + Semver() : ver(semver_zero()) {} + Semver(int major, int minor, int patch, boost::optional metadata = boost::none, boost::optional prerelease = boost::none) diff --git a/xs/xsp/Utils_PresetUpdater.xsp b/xs/xsp/Utils_PresetUpdater.xsp index 1cb9f1c39e..4c1a637e49 100644 --- a/xs/xsp/Utils_PresetUpdater.xsp +++ b/xs/xsp/Utils_PresetUpdater.xsp @@ -8,5 +8,5 @@ %name{Slic3r::PresetUpdater} class PresetUpdater { PresetUpdater(int version_online_event, AppConfig *app_config); void download(PresetBundle* preset_bundle); - static void init_vendors(); + void config_update(); }; From 7b29ecb15cf450347cedece3d3445449b2f57c1f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 13 Apr 2018 12:15:43 +0200 Subject: [PATCH 0172/1150] Fixed cutting plane z in 3D view when object is scaled --- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 0b5312b30a..7f930c1d0f 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -244,7 +244,7 @@ sub _update { $self->{canvas}->reset_objects; $self->{canvas}->load_object($_, undef, undef, [0]) for @objects; $self->{canvas}->SetCuttingPlane( - $self->{cut_options}{z}, + $self->{cut_options}{z} / $self->{model_object}->instances->[0]->scaling_factor, [@expolygons], ); $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config}); From 120c1978ae9c389393ad3332c2077d5ba255353a Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 13 Apr 2018 12:35:04 +0200 Subject: [PATCH 0173/1150] Cleaned code --- xs/src/slic3r/GUI/Field.cpp | 31 +++++------------- xs/src/slic3r/GUI/Field.hpp | 52 +++++++++++++++++------------- xs/src/slic3r/GUI/GUI.cpp | 25 ++++++++------ xs/src/slic3r/GUI/GUI.hpp | 8 ++--- xs/src/slic3r/GUI/OptionsGroup.cpp | 33 +++++++------------ xs/src/slic3r/GUI/OptionsGroup.hpp | 36 ++++++++++----------- xs/src/slic3r/GUI/Tab.cpp | 45 ++++++++++++-------------- xs/src/slic3r/GUI/Tab.hpp | 26 +++++++-------- 8 files changed, 120 insertions(+), 136 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index a7fd8d29eb..c68b2304c0 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -75,13 +75,13 @@ namespace Slic3r { namespace GUI { return tooltip_text; } - bool Field::is_matched(std::string string, std::string pattern) + bool Field::is_matched(const std::string& string, const std::string& pattern) { std::regex regex_pattern(pattern, std::regex_constants::icase); // use ::icase to make the matching case insensitive like /i in perl return std::regex_match(string, regex_pattern); } - boost::any Field::get_value_by_opt_type(wxString str) + boost::any Field::get_value_by_opt_type(wxString& str) { boost::any ret_val; switch (m_opt.type){ @@ -377,7 +377,7 @@ void Choice::set_selection() } } -void Choice::set_value(const std::string value, bool change_event) //! Redundant? +void Choice::set_value(const std::string& value, bool change_event) //! Redundant? { m_disable_change_event = !change_event; @@ -396,7 +396,7 @@ void Choice::set_value(const std::string value, bool change_event) //! Redundan m_disable_change_event = false; } -void Choice::set_value(boost::any value, bool change_event) +void Choice::set_value(const boost::any& value, bool change_event) { m_disable_change_event = !change_event; @@ -435,7 +435,7 @@ void Choice::set_value(boost::any value, bool change_event) } //! it's needed for _update_serial_ports() -void Choice::set_values(const std::vector values) +void Choice::set_values(const std::vector& values) { if (values.empty()) return; @@ -554,7 +554,7 @@ void PointCtrl::BUILD() y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y)); } -void PointCtrl::set_value(const Pointf value, bool change_event) +void PointCtrl::set_value(const Pointf& value, bool change_event) { m_disable_change_event = !change_event; @@ -566,10 +566,10 @@ void PointCtrl::set_value(const Pointf value, bool change_event) m_disable_change_event = false; } -void PointCtrl::set_value(boost::any value, bool change_event) +void PointCtrl::set_value(const boost::any& value, bool change_event) { Pointf pt; - Pointf *ptf = boost::any_cast(&value); + const Pointf *ptf = boost::any_cast(&value); if (!ptf) { ConfigOptionPoints* pts = boost::any_cast(value); @@ -577,21 +577,6 @@ void PointCtrl::set_value(boost::any value, bool change_event) } else pt = *ptf; -// try -// { -// pt = boost::any_cast(value)->values.at(0); -// } -// catch (const std::exception &e) -// { -// try{ -// pt = boost::any_cast(value); -// } -// catch (const std::exception &e) -// { -// std::cerr << "Error! Can't cast PointCtrl value" << m_opt_id << "\n"; -// return; -// } -// } set_value(pt, change_event); } diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index da3e23ccd8..cdc7c0d812 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -31,8 +31,8 @@ namespace Slic3r { namespace GUI { class Field; using t_field = std::unique_ptr; using t_kill_focus = std::function; -using t_change = std::function; -using t_back_to_init = std::function; +using t_change = std::function; +using t_back_to_init = std::function; wxString double_to_string(double const value); @@ -81,7 +81,7 @@ public: /// Sets a value for this control. /// subclasses should overload with a specific version /// Postcondition: Method does not fire the on_change event. - virtual void set_value(boost::any value, bool change_event) = 0; + virtual void set_value(const boost::any& value, bool change_event) = 0; /// Gets a boost::any representing this control. /// subclasses should overload with a specific version @@ -100,7 +100,7 @@ public: virtual wxString get_tooltip_text(const wxString& default_string); // set icon to "UndoToSystemValue" button according to an inheritance of preset - void set_nonsys_btn_icon(const std::string& icon); + void set_nonsys_btn_icon(const std::string& icon); Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {}; Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {}; @@ -109,8 +109,8 @@ public: virtual wxSizer* getSizer() { return nullptr; } virtual wxWindow* getWindow() { return nullptr; } - bool is_matched(std::string string, std::string pattern); - boost::any get_value_by_opt_type(wxString str); + bool is_matched(const std::string& string, const std::string& pattern); + boost::any get_value_by_opt_type(wxString& str); /// Factory method for generating new derived classes. template @@ -137,16 +137,17 @@ class TextCtrl : public Field { public: TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {} TextCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {} + ~TextCtrl() {} void BUILD(); wxWindow* window {nullptr}; - virtual void set_value(std::string value, bool change_event = false) { + virtual void set_value(const std::string& value, bool change_event = false) { m_disable_change_event = !change_event; dynamic_cast(window)->SetValue(wxString(value)); m_disable_change_event = false; } - virtual void set_value(boost::any value, bool change_event = false) { + virtual void set_value(const boost::any& value, bool change_event = false) { m_disable_change_event = !change_event; dynamic_cast(window)->SetValue(boost::any_cast(value)); m_disable_change_event = false; @@ -164,6 +165,7 @@ class CheckBox : public Field { public: CheckBox(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {} CheckBox(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {} + ~CheckBox() {} wxWindow* window{ nullptr }; void BUILD() override; @@ -173,7 +175,7 @@ public: dynamic_cast(window)->SetValue(value); m_disable_change_event = false; } - void set_value(boost::any value, bool change_event = false) { + void set_value(const boost::any& value, bool change_event = false) { m_disable_change_event = !change_event; dynamic_cast(window)->SetValue(boost::any_cast(value)); m_disable_change_event = false; @@ -190,21 +192,22 @@ class SpinCtrl : public Field { public: SpinCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id), tmp_value(-9999) {} SpinCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id), tmp_value(-9999) {} + ~SpinCtrl() {} int tmp_value; wxWindow* window{ nullptr }; void BUILD() override; - void set_value(const std::string value, bool change_event = false) { + void set_value(const std::string& value, bool change_event = false) { m_disable_change_event = !change_event; dynamic_cast(window)->SetValue(value); m_disable_change_event = false; } - void set_value(boost::any value, bool change_event = false) { + void set_value(const boost::any& value, bool change_event = false) { m_disable_change_event = !change_event; tmp_value = boost::any_cast(value); - dynamic_cast(window)->SetValue(tmp_value/*boost::any_cast(value)*/); + dynamic_cast(window)->SetValue(tmp_value); m_disable_change_event = false; } boost::any get_value() override { @@ -221,14 +224,15 @@ class Choice : public Field { public: Choice(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {} Choice(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {} + ~Choice() {} wxWindow* window{ nullptr }; void BUILD() override; void set_selection(); - void set_value(const std::string value, bool change_event = false); - void set_value(boost::any value, bool change_event = false); - void set_values(const std::vector values); + void set_value(const std::string& value, bool change_event = false); + void set_value(const boost::any& value, bool change_event = false); + void set_values(const std::vector &values); boost::any get_value() override; void enable() override { dynamic_cast(window)->Enable(); }; @@ -241,16 +245,17 @@ class ColourPicker : public Field { public: ColourPicker(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {} ColourPicker(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {} + ~ColourPicker() {} wxWindow* window{ nullptr }; void BUILD() override; - void set_value(const std::string value, bool change_event = false) { + void set_value(const std::string& value, bool change_event = false) { m_disable_change_event = !change_event; dynamic_cast(window)->SetColour(value); m_disable_change_event = false; } - void set_value(boost::any value, bool change_event = false) { + void set_value(const boost::any& value, bool change_event = false) { m_disable_change_event = !change_event; dynamic_cast(window)->SetColour(boost::any_cast(value)); m_disable_change_event = false; @@ -268,23 +273,24 @@ class PointCtrl : public Field { public: PointCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {} PointCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {} + ~PointCtrl() {} wxSizer* sizer{ nullptr }; - wxTextCtrl* x_textctrl; - wxTextCtrl* y_textctrl; + wxTextCtrl* x_textctrl{ nullptr }; + wxTextCtrl* y_textctrl{ nullptr }; void BUILD() override; - void set_value(const Pointf value, bool change_event = false); - void set_value(boost::any value, bool change_event = false); + void set_value(const Pointf& value, bool change_event = false); + void set_value(const boost::any& value, bool change_event = false); boost::any get_value() override; void enable() override { x_textctrl->Enable(); - y_textctrl->Enable(); }; + y_textctrl->Enable(); } void disable() override{ x_textctrl->Disable(); - y_textctrl->Disable(); }; + y_textctrl->Disable(); } wxSizer* getSizer() override { return sizer; } }; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 9450f44ae1..794e873d55 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -403,7 +403,7 @@ TabIface* get_preset_tab_iface(char *name) } // opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element) -void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index /*= 0*/) +void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index /*= 0*/) { try{ switch (config.def()->get(opt_key)->type){ @@ -439,11 +439,18 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast(value))); break; case coStrings:{ - if (opt_key.compare("compatible_printers") == 0 || - config.def()->get(opt_key)->gui_flags.compare("serialized") == 0){ - config.option(opt_key)->values.resize(0); - std::vector values = boost::any_cast>(value); - if (values.size() == 1 && values[0] == "") + if (opt_key.compare("compatible_printers") == 0) { + config.option(opt_key)->values = + boost::any_cast>(value); + } + else if (config.def()->get(opt_key)->gui_flags.compare("serialized") == 0){ + std::string str = boost::any_cast(value); + if (str.back() == ';') str.pop_back(); + // Split a string to multiple strings by a semi - colon.This is the old way of storing multi - string values. + // Currently used for the post_process config value only. + std::vector values; + boost::split(values, str, boost::is_any_of(";")); + if (values.size() == 1 && values[0] == "") break; config.option(opt_key)->values = values; } @@ -510,17 +517,17 @@ void add_created_tab(Tab* panel) g_wxTabPanel->AddPage(panel, panel->title()); } -void show_error(wxWindow* parent, wxString message){ +void show_error(wxWindow* parent, const wxString& message){ auto msg_wingow = new wxMessageDialog(parent, message, _(L("Error")), wxOK | wxICON_ERROR); msg_wingow->ShowModal(); } -void show_info(wxWindow* parent, wxString message, wxString title){ +void show_info(wxWindow* parent, const wxString& message, const wxString& title){ auto msg_wingow = new wxMessageDialog(parent, message, title.empty() ? _(L("Notice")) : title, wxOK | wxICON_INFORMATION); msg_wingow->ShowModal(); } -void warning_catcher(wxWindow* parent, wxString message){ +void warning_catcher(wxWindow* parent, const wxString& message){ if (message == _(L("GLUquadricObjPtr | Attempt to free unreferenced scalar")) ) return; auto msg = new wxMessageDialog(parent, message, _(L("Warning")), wxOK | wxICON_WARNING); diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 24c3ec3f40..d92246c500 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -96,11 +96,11 @@ TabIface* get_preset_tab_iface(char *name); // add it at the end of the tab panel. void add_created_tab(Tab* panel); // Change option value in config -void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index = 0); +void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0); -void show_error(wxWindow* parent, wxString message); -void show_info(wxWindow* parent, wxString message, wxString title); -void warning_catcher(wxWindow* parent, wxString message); +void show_error(wxWindow* parent, const wxString& message); +void show_info(wxWindow* parent, const wxString& message, const wxString& title); +void warning_catcher(wxWindow* parent, const wxString& message); // load language saved at application config bool load_language(); diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 24e1ddf2eb..8e22689652 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -227,12 +227,12 @@ Line OptionsGroup::create_single_option_line(const Option& option) const { return retval; } -void OptionsGroup::on_change_OG(t_config_option_key id, /*config_value*/boost::any value) { +void OptionsGroup::on_change_OG(const t_config_option_key& opt_id, const boost::any& value) { if (m_on_change != nullptr) - m_on_change(id, value); + m_on_change(opt_id, value); } -Option ConfigOptionsGroup::get_option(const std::string opt_key, int opt_index /*= -1*/) +Option ConfigOptionsGroup::get_option(const std::string& opt_key, int opt_index /*= -1*/) { if (!m_config->has(opt_key)) { std::cerr << "No " << opt_key << " in ConfigOptionsGroup config."; @@ -245,7 +245,7 @@ Option ConfigOptionsGroup::get_option(const std::string opt_key, int opt_index / return Option(*m_config->def()->get(opt_key), opt_id); } -void ConfigOptionsGroup::on_change_OG(t_config_option_key opt_id, boost::any value) +void ConfigOptionsGroup::on_change_OG(const t_config_option_key& opt_id, const boost::any& value) { if (!m_opt_map.empty()) { @@ -268,16 +268,7 @@ void ConfigOptionsGroup::on_change_OG(t_config_option_key opt_id, boost::any val if (opt_index != -1){ // die "Can't set serialized option indexed value" ; } - // # Split a string to multiple strings by a semi - colon.This is the old way of storing multi - string values. - // # Currently used for the post_process config value only. - // my @values = split / ; / , $field_value; - // $self->config->set($opt_key, \@values); - std::string str = boost::any_cast(value); - if (str.back() == ';') - str.pop_back(); - std::vector values; - boost::split(values, str, boost::is_any_of(";")); - change_opt_value(*m_config, opt_key, values); + change_opt_value(*m_config, opt_key, value); } else { if (opt_index == -1) { @@ -297,14 +288,14 @@ void ConfigOptionsGroup::on_change_OG(t_config_option_key opt_id, boost::any val OptionsGroup::on_change_OG(opt_id, value); //!? Why doing this } -void ConfigOptionsGroup::back_to_initial_value(const std::string opt_key) +void ConfigOptionsGroup::back_to_initial_value(const std::string& opt_key) { if (m_get_initial_config == nullptr) return; back_to_config_value(m_get_initial_config(), opt_key); } -void ConfigOptionsGroup::back_to_sys_value(const std::string opt_key) +void ConfigOptionsGroup::back_to_sys_value(const std::string& opt_key) { if (m_get_sys_config == nullptr) return; @@ -313,7 +304,7 @@ void ConfigOptionsGroup::back_to_sys_value(const std::string opt_key) back_to_config_value(m_get_sys_config(), opt_key); } -void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, const std::string opt_key) +void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, const std::string& opt_key) { boost::any value; if (opt_key == "extruders_count"){ @@ -348,7 +339,7 @@ void ConfigOptionsGroup::reload_config(){ } -boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index, bool deserialize){ +boost::any ConfigOptionsGroup::config_value(const std::string& opt_key, int opt_index, bool deserialize){ if (deserialize) { // Want to edit a vector value(currently only multi - strings) in a single edit box. @@ -365,7 +356,7 @@ boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index, } } -boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config, std::string opt_key, int opt_index /*= -1*/) +boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index /*= -1*/) { size_t idx = opt_index == -1 ? 0 : opt_index; @@ -457,7 +448,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config return ret; } -Field* ConfigOptionsGroup::get_fieldc(t_config_option_key opt_key, int opt_index){ +Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int opt_index){ Field* field = get_field(opt_key); if (field != nullptr) return field; @@ -471,7 +462,7 @@ Field* ConfigOptionsGroup::get_fieldc(t_config_option_key opt_key, int opt_index return opt_id.empty() ? nullptr : get_field(opt_id); } -void ogStaticText::SetText(wxString value) +void ogStaticText::SetText(const wxString& value) { SetLabel(value); Wrap(400); diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index e58d9c9a99..b5846f24d7 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -98,16 +98,16 @@ public: void append_single_option_line(const Option& option) { append_line(create_single_option_line(option)); } // return a non-owning pointer reference - inline Field* get_field(t_config_option_key id) const{ + inline Field* get_field(const t_config_option_key& id) const{ if (m_fields.find(id) == m_fields.end()) return nullptr; return m_fields.at(id).get(); } - bool set_value(t_config_option_key id, boost::any value, bool change_event = false) { + bool set_value(const t_config_option_key& id, const boost::any& value, bool change_event = false) { if (m_fields.find(id) == m_fields.end()) return false; m_fields.at(id)->set_value(value, change_event); return true; } - boost::any get_value(t_config_option_key id) { + boost::any get_value(const t_config_option_key& id) { boost::any out; if (m_fields.find(id) == m_fields.end()) ; else @@ -118,7 +118,7 @@ public: inline void enable() { for (auto& field : m_fields) field.second->enable(); } inline void disable() { for (auto& field : m_fields) field.second->disable(); } - OptionsGroup(wxWindow* _parent, wxString title, bool is_tab_opt=false) : + OptionsGroup(wxWindow* _parent, const wxString& title, bool is_tab_opt=false) : m_parent(_parent), title(title), m_is_tab_opt(is_tab_opt), staticbox(title!="") { sizer = (staticbox ? new wxStaticBoxSizer(new wxStaticBox(_parent, wxID_ANY, title), wxVERTICAL) : new wxBoxSizer(wxVERTICAL)); auto num_columns = 1U; @@ -152,14 +152,14 @@ protected: const t_field& build_field(const Option& opt, wxStaticText* label = nullptr); virtual void on_kill_focus (){}; - virtual void on_change_OG(t_config_option_key opt_id, boost::any value); - virtual void back_to_initial_value(const std::string opt_key){}; - virtual void back_to_sys_value(const std::string opt_key){}; + virtual void on_change_OG(const t_config_option_key& opt_id, const boost::any& value); + virtual void back_to_initial_value(const std::string& opt_key){} + virtual void back_to_sys_value(const std::string& opt_key){} }; class ConfigOptionsGroup: public OptionsGroup { public: - ConfigOptionsGroup(wxWindow* parent, wxString title, DynamicPrintConfig* _config = nullptr, bool is_tab_opt = false) : + ConfigOptionsGroup(wxWindow* parent, const wxString& title, DynamicPrintConfig* _config = nullptr, bool is_tab_opt = false) : OptionsGroup(parent, title, is_tab_opt), m_config(_config) {} /// reference to libslic3r config, non-owning pointer (?). @@ -167,8 +167,8 @@ public: bool m_full_labels {0}; t_opt_map m_opt_map; - Option get_option(const std::string opt_key, int opt_index = -1); - Line create_single_option_line(const std::string title, int idx = -1) /*const*/{ + Option get_option(const std::string& opt_key, int opt_index = -1); + Line create_single_option_line(const std::string& title, int idx = -1) /*const*/{ Option option = get_option(title, idx); return OptionsGroup::create_single_option_line(option); } @@ -181,16 +181,16 @@ public: append_single_option_line(option); } - void on_change_OG(t_config_option_key opt_id, boost::any value) override; - void back_to_initial_value(const std::string opt_key) override; - void back_to_sys_value(const std::string opt_key) override; - void back_to_config_value(const DynamicPrintConfig& config, const std::string opt_key); + void on_change_OG(const t_config_option_key& opt_id, const boost::any& value) override; + void back_to_initial_value(const std::string& opt_key) override; + void back_to_sys_value(const std::string& opt_key) override; + void back_to_config_value(const DynamicPrintConfig& config, const std::string& opt_key); void on_kill_focus() override{ reload_config();} void reload_config(); - boost::any config_value(std::string opt_key, int opt_index, bool deserialize); + boost::any config_value(const std::string& opt_key, int opt_index, bool deserialize); // return option value from config - boost::any get_config_value(const DynamicPrintConfig& config, std::string opt_key, int opt_index = -1); - Field* get_fieldc(t_config_option_key opt_key, int opt_index); + boost::any get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index = -1); + Field* get_fieldc(const t_config_option_key& opt_key, int opt_index); }; // Static text shown among the options. @@ -200,7 +200,7 @@ public: ogStaticText(wxWindow* parent, const char *text) : wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize){} ~ogStaticText(){} - void SetText(wxString value); + void SetText(const wxString& value); }; }} diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ebcd4af882..a9faf4c591 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -203,11 +203,10 @@ void Tab::load_initial_data() { m_config = &m_presets->get_edited_preset().config; m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ? - "bullet_white.png" : "sys_unlock.png"; -// wxMSW ? "sys_unlock.png" : "lock_open.png"; + "bullet_white.png" : "sys_unlock.png"; } -PageShp Tab::add_options_page(wxString title, std::string icon, bool is_extruder_pages/* = false*/) +PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages/* = false*/) { // Index of icon in an icon list $self->{icons}. auto icon_idx = 0; @@ -332,8 +331,8 @@ void Tab::update_changed_ui() { bool is_nonsys_value = false; bool is_modified_value = true; - std::string sys_icon = /*wxMSW ? */"sys_lock.png"/* : "lock.png"*/; - std::string icon = /*wxMSW ? */"action_undo.png"/* : "arrow_undo.png"*/; + std::string sys_icon = "sys_lock.png"; + std::string icon = "action_undo.png"; wxColour color = get_sys_label_clr(); if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { is_nonsys_value = true; @@ -478,10 +477,8 @@ void Tab::update_changed_tree_ui() void Tab::update_undo_buttons() { - const std::string& undo_icon = !m_is_modified_values ? "bullet_white.png" : - /*wxMSW ? */"action_undo.png"/* : "arrow_undo.png"*/; - const std::string& undo_to_sys_icon = m_is_nonsys_values ? m_nonsys_btn_icon : - /*wxMSW ? */"sys_lock.png"/* : "lock.png"*/; + const std::string& undo_icon = !m_is_modified_values ? "bullet_white.png" : "action_undo.png"; + const std::string& undo_to_sys_icon = m_is_nonsys_values ? m_nonsys_btn_icon : "sys_lock.png"; m_undo_btn->SetBitmap(wxBitmap(from_u8(var(undo_icon)), wxBITMAP_TYPE_PNG)); m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(undo_to_sys_icon)), wxBITMAP_TYPE_PNG)); @@ -559,7 +556,7 @@ void Tab::update_tab_ui() // Load a provied DynamicConfig into the tab, modifying the active preset. // This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view. -void Tab::load_config(DynamicPrintConfig config) +void Tab::load_config(const DynamicPrintConfig& config) { bool modified = 0; for(auto opt_key : m_config->diff(config)) { @@ -582,7 +579,7 @@ void Tab::reload_config(){ Thaw(); } -Field* Tab::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const +Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const { Field* field = nullptr; for (auto page : m_pages){ @@ -596,7 +593,7 @@ Field* Tab::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const // Set a key/value pair on this page. Return true if the value has been modified. // Currently used for distributing extruders_count over preset pages of Slic3r::GUI::Tab::Printer // after a preset is loaded. -bool Tab::set_value(t_config_option_key opt_key, boost::any value){ +bool Tab::set_value(const t_config_option_key& opt_key, const boost::any& value){ bool changed = false; for(auto page: m_pages) { if (page->set_value(opt_key, value)) @@ -607,7 +604,7 @@ bool Tab::set_value(t_config_option_key opt_key, boost::any value){ // To be called by custom widgets, load a value into a config, // update the preset selection boxes (the dirty flags) -void Tab::load_key_value(std::string opt_key, boost::any value) +void Tab::load_key_value(const std::string& opt_key, const boost::any& value) { change_opt_value(*m_config, opt_key, value); // Mark the print & filament enabled if they are compatible with the currently selected preset. @@ -621,7 +618,7 @@ void Tab::load_key_value(std::string opt_key, boost::any value) extern wxFrame *g_wxMainFrame; -void Tab::on_value_change(std::string opt_key, boost::any value) +void Tab::on_value_change(const std::string& opt_key, const boost::any& value) { if (m_event_value_change > 0) { wxCommandEvent event(m_event_value_change); @@ -636,8 +633,8 @@ void Tab::on_value_change(std::string opt_key, boost::any value) } if (opt_key == "fill_density") { - value = get_optgroup()->get_config_value(*m_config, opt_key); - get_optgroup()->set_value(opt_key, value); + boost::any val = get_optgroup()->get_config_value(*m_config, opt_key); + get_optgroup()->set_value(opt_key, val); } if (opt_key == "support_material" || opt_key == "support_material_buildplate_only") { @@ -1785,9 +1782,7 @@ void Tab::load_current_preset() // Reload preset pages with the new configuration values. reload_config(); const Preset* parent = m_presets->get_selected_preset_parent(); - m_nonsys_btn_icon = parent == nullptr ? - "bullet_white.png" : - /*wxMSW ? */"sys_unlock.png"/* : "lock_open.png"*/; + m_nonsys_btn_icon = parent == nullptr ? "bullet_white.png" : "sys_unlock.png"; // use CallAfter because some field triggers schedule on_change calls using CallAfter, // and we don't want them to be called after this update_dirty() as they would mark the @@ -1844,7 +1839,7 @@ void Tab::rebuild_page_tree() // Called by the UI combo box when the user switches profiles. // Select a preset by a name.If !defined(name), then the default preset is selected. // If the current profile is modified, user is asked to save the changes. -void Tab::select_preset(std::string preset_name /*= ""*/) +void Tab::select_preset(const std::string& preset_name /*= ""*/) { std::string name = preset_name; auto force = false; @@ -1911,7 +1906,7 @@ void Tab::select_preset(std::string preset_name /*= ""*/) // If the current preset is dirty, the user is asked whether the changes may be discarded. // if the current preset was not dirty, or the user agreed to discard the changes, 1 is returned. -bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr*/, std::string new_printer_name /*= ""*/) +bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr*/, const std::string& new_printer_name /*= ""*/) { if (presets == nullptr) presets = m_presets; // Display a dialog showing the dirty options in a human readable form. @@ -2339,7 +2334,7 @@ void Page::reload_config() group->reload_config(); } -Field* Page::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const +Field* Page::get_field(const t_config_option_key& opt_key, int opt_index /*= -1*/) const { Field* field = nullptr; for (auto opt : m_optgroups){ @@ -2350,7 +2345,7 @@ Field* Page::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) cons return field; } -bool Page::set_value(t_config_option_key opt_key, boost::any value){ +bool Page::set_value(const t_config_option_key& opt_key, const boost::any& value){ bool changed = false; for(auto optgroup: m_optgroups) { if (optgroup->set_value(opt_key, value)) @@ -2360,7 +2355,7 @@ bool Page::set_value(t_config_option_key opt_key, boost::any value){ } // package Slic3r::GUI::Tab::Page; -ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_width /*= -1*/) +ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_label_width /*= -1*/) { //! config_ have to be "right" ConfigOptionsGroupShp optgroup = std::make_shared(this, title, m_config, true); @@ -2401,7 +2396,7 @@ ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_wid return optgroup; } -void SavePresetWindow::build(wxString title, std::string default_name, std::vector &values) +void SavePresetWindow::build(const wxString& title, const std::string& default_name, std::vector &values) { auto text = new wxStaticText(this, wxID_ANY, _(L("Save ")) + title + _(L(" as:")), wxDefaultPosition, wxDefaultSize); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 8a2c38e052..9465f86b47 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -68,9 +68,9 @@ public: size_t iconID() const { return m_iconID; } void set_config(DynamicPrintConfig* config_in) { m_config = config_in; } void reload_config(); - Field* get_field(t_config_option_key opt_key, int opt_index = -1) const; - bool set_value(t_config_option_key opt_key, boost::any value); - ConfigOptionsGroupShp new_optgroup(wxString title, int noncommon_label_width = -1); + Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; + bool set_value(const t_config_option_key& opt_key, const boost::any& value); + ConfigOptionsGroupShp new_optgroup(const wxString& title, int noncommon_label_width = -1); }; // Slic3r::GUI::Tab; @@ -129,7 +129,7 @@ public: public: Tab() {} - Tab(wxNotebook* parent, wxString title, const char* name, bool no_controller) : + Tab(wxNotebook* parent, const wxString& title, const char* name, bool no_controller) : m_parent(parent), m_title(title), m_name(name), m_no_controller(no_controller) { Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL); get_tabs_list().push_back(this); @@ -147,12 +147,12 @@ public: void create_preset_tab(PresetBundle *preset_bundle); void load_current_preset(); void rebuild_page_tree(); - void select_preset(std::string preset_name = ""); - bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, std::string new_printer_name = ""); + void select_preset(const std::string& preset_name = ""); + bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = ""); wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn); void update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible); - void load_key_value(std::string opt_key, boost::any value); + void load_key_value(const std::string& opt_key, const boost::any& value); void reload_compatible_printers_widget(); void OnTreeSelChange(wxTreeEvent& event); @@ -172,7 +172,7 @@ public: void on_back_to_initial_value(); void on_back_to_sys_value(); - PageShp add_options_page(wxString title, std::string icon, bool is_extruder_pages = false); + PageShp add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages = false); virtual void OnActivate(){} virtual void on_preset_loaded(){} @@ -181,10 +181,10 @@ public: void load_initial_data(); void update_dirty(); void update_tab_ui(); - void load_config(DynamicPrintConfig config); + void load_config(const DynamicPrintConfig& config); virtual void reload_config(); - Field* get_field(t_config_option_key opt_key, int opt_index = -1) const; - bool set_value(t_config_option_key opt_key, boost::any value); + Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; + bool set_value(const t_config_option_key& opt_key, const boost::any& value); wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText); bool current_preset_is_dirty(); DynamicPrintConfig* get_config() { return m_config; } @@ -194,7 +194,7 @@ public: } std::vector get_dependent_tabs() { return m_reload_dependent_tabs; } - void on_value_change(std::string opt_key, boost::any value); + void on_value_change(const std::string& opt_key, const boost::any& value); protected: void on_presets_changed(); @@ -270,7 +270,7 @@ public: std::string m_chosen_name; wxComboBox* m_combo; - void build(wxString title, std::string default_name, std::vector &values); + void build(const wxString& title, const std::string& default_name, std::vector &values); void accept(); std::string get_name() { return m_chosen_name; } }; From 64976c249d854572b9227e3283f35172e9d1a4a0 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 13 Apr 2018 12:49:12 +0200 Subject: [PATCH 0174/1150] Added @bubnikv's changes to BitmapCache --- xs/src/slic3r/GUI/BitmapCache.cpp | 186 +++++++++++++++++++----------- xs/src/slic3r/GUI/BitmapCache.hpp | 3 +- 2 files changed, 121 insertions(+), 68 deletions(-) diff --git a/xs/src/slic3r/GUI/BitmapCache.cpp b/xs/src/slic3r/GUI/BitmapCache.cpp index acbcb5c73c..93853458e4 100644 --- a/xs/src/slic3r/GUI/BitmapCache.cpp +++ b/xs/src/slic3r/GUI/BitmapCache.cpp @@ -1,5 +1,14 @@ #include "BitmapCache.hpp" +#if ! defined(WIN32) && ! defined(__APPLE__) +#define BROKEN_ALPHA +#endif + +#ifdef BROKEN_ALPHA + #include + #include +#endif /* BROKEN_ALPHA */ + namespace Slic3r { namespace GUI { void BitmapCache::clear() @@ -8,19 +17,31 @@ void BitmapCache::clear() delete bitmap.second; } +static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image) +{ +#ifdef BROKEN_ALPHA + wxMemoryOutputStream stream; + image.SaveFile(stream, wxBITMAP_TYPE_PNG); + wxStreamBuffer *buf = stream.GetOutputStreamBuffer(); + return wxBitmap::NewFromPNGData(buf->GetBufferStart(), buf->GetBufferSize()); +#else + return wxBitmap(std::move(image)); +#endif +} + wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height) { - wxBitmap *bitmap = nullptr; - auto it = m_map.find(bitmap_key); - if (it == m_map.end()) { - bitmap = new wxBitmap(width, height); - m_map[bitmap_key] = bitmap; - } else { - bitmap = it->second; - if (bitmap->GetWidth() != width || bitmap->GetHeight() != height) - bitmap->Create(width, height); - } -#if defined(__APPLE__) || defined(_MSC_VER) + wxBitmap *bitmap = nullptr; + auto it = m_map.find(bitmap_key); + if (it == m_map.end()) { + bitmap = new wxBitmap(width, height); + m_map[bitmap_key] = bitmap; + } else { + bitmap = it->second; + if (bitmap->GetWidth() != width || bitmap->GetHeight() != height) + bitmap->Create(width, height); + } +#ifndef BROKEN_ALPHA bitmap->UseAlpha(); #endif return bitmap; @@ -28,77 +49,108 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp) { - wxBitmap *bitmap = this->insert(bitmap_key, bmp.GetWidth(), bmp.GetHeight()); - - wxMemoryDC memDC; - memDC.SelectObject(*bitmap); - memDC.SetBackground(*wxTRANSPARENT_BRUSH); - memDC.Clear(); - memDC.DrawBitmap(bmp, 0, 0, true); - memDC.SelectObject(wxNullBitmap); - - return bitmap; + wxBitmap *bitmap = nullptr; + auto it = m_map.find(bitmap_key); + if (it == m_map.end()) { + bitmap = new wxBitmap(bmp); + m_map[bitmap_key] = bitmap; + } else { + bitmap = it->second; + *bitmap = bmp; + } + return bitmap; } wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2) { - wxBitmap *bitmap = this->insert(bitmap_key, bmp.GetWidth() + bmp2.GetWidth(), std::max(bmp.GetHeight(), bmp2.GetHeight())); - - wxMemoryDC memDC; - memDC.SelectObject(*bitmap); - memDC.SetBackground(*wxTRANSPARENT_BRUSH); - memDC.Clear(); - if (bmp.GetWidth() > 0) - memDC.DrawBitmap(bmp, 0, 0, true); - if (bmp2.GetWidth() > 0) - memDC.DrawBitmap(bmp2, bmp.GetWidth(), 0, true); - memDC.SelectObject(wxNullBitmap); - - return bitmap; + // Copying the wxBitmaps is cheap as the bitmap's content is reference counted. + const wxBitmap bmps[2] = { bmp, bmp2 }; + return this->insert(bitmap_key, bmps, bmps + 2); } wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3) { - wxBitmap *bitmap = this->insert(bitmap_key, bmp.GetWidth() + bmp2.GetWidth() + bmp3.GetWidth(), std::max(std::max(bmp.GetHeight(), bmp2.GetHeight()), bmp3.GetHeight())); + // Copying the wxBitmaps is cheap as the bitmap's content is reference counted. + const wxBitmap bmps[3] = { bmp, bmp2, bmp3 }; + return this->insert(bitmap_key, bmps, bmps + 3); +} +wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap *begin, const wxBitmap *end) +{ + size_t width = 0; + size_t height = 0; + for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) { + width += bmp->GetWidth(); + height = std::max(height, bmp->GetHeight()); + } + +#ifdef BROKEN_ALPHA + + wxImage image(width, height); + image.InitAlpha(); + // Fill in with a white color. + memset(image.GetData(), 0x0ff, width * height * 3); + // Fill in with full transparency. + memset(image.GetAlpha(), 0, width * height); + size_t x = 0; + for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) { + if (bmp->GetWidth() > 0) { + if (bmp->GetDepth() == 32) { + wxAlphaPixelData data(*const_cast(bmp)); + data.UseAlpha(); + if (data) { + for (int r = 0; r < bmp->GetHeight(); ++ r) { + wxAlphaPixelData::Iterator src(data); + src.Offset(data, 0, r); + unsigned char *dst_pixels = image.GetData() + (x + r * width) * 3; + unsigned char *dst_alpha = image.GetAlpha() + x + r * width; + for (int c = 0; c < bmp->GetWidth(); ++ c, ++ src) { + *dst_pixels ++ = src.Red(); + *dst_pixels ++ = src.Green(); + *dst_pixels ++ = src.Blue(); + *dst_alpha ++ = src.Alpha(); + } + } + } + } else if (bmp->GetDepth() == 24) { + wxNativePixelData data(*const_cast(bmp)); + if (data) { + for (int r = 0; r < bmp->GetHeight(); ++ r) { + wxNativePixelData::Iterator src(data); + src.Offset(data, 0, r); + unsigned char *dst_pixels = image.GetData() + (x + r * width) * 3; + unsigned char *dst_alpha = image.GetAlpha() + x + r * width; + for (int c = 0; c < bmp->GetWidth(); ++ c, ++ src) { + *dst_pixels ++ = src.Red(); + *dst_pixels ++ = src.Green(); + *dst_pixels ++ = src.Blue(); + *dst_alpha ++ = wxALPHA_OPAQUE; + } + } + } + } + } + x += bmp->GetWidth(); + } + return this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image))); + +#else + + wxBitmap *bitmap = this->insert(bitmap_key, width, height); wxMemoryDC memDC; memDC.SelectObject(*bitmap); memDC.SetBackground(*wxTRANSPARENT_BRUSH); memDC.Clear(); - if (bmp.GetWidth() > 0) - memDC.DrawBitmap(bmp, 0, 0, true); - if (bmp2.GetWidth() > 0) - memDC.DrawBitmap(bmp2, bmp.GetWidth(), 0, true); - if (bmp3.GetWidth() > 0) - memDC.DrawBitmap(bmp3, bmp.GetWidth() + bmp2.GetWidth(), 0, true); - memDC.SelectObject(wxNullBitmap); - - return bitmap; -} - -wxBitmap* BitmapCache::insert(const std::string &bitmap_key, std::vector &bmps) -{ - size_t width = 0; - size_t height = 0; - for (wxBitmap &bmp : bmps) { - width += bmp.GetWidth(); - height = std::max(height, bmp.GetHeight()); - } - wxBitmap *bitmap = this->insert(bitmap_key, width, height); - - wxMemoryDC memDC; - memDC.SelectObject(*bitmap); - memDC.SetBackground(*wxTRANSPARENT_BRUSH); - memDC.Clear(); size_t x = 0; - for (wxBitmap &bmp : bmps) { - if (bmp.GetWidth() > 0) - memDC.DrawBitmap(bmp, x, 0, true); - x += bmp.GetWidth(); - } + for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) { + if (bmp->GetWidth() > 0) + memDC.DrawBitmap(*bmp, x, 0, true); + x += bmp->GetWidth(); + } memDC.SelectObject(wxNullBitmap); + return bitmap; - return bitmap; +#endif } wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency) @@ -113,7 +165,7 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi *imgdata ++ = b; *imgalpha ++ = transparency; } - return wxBitmap(std::move(image)); + return wxImage_to_wxBitmap_with_alpha(std::move(image)); } } // namespace GUI diff --git a/xs/src/slic3r/GUI/BitmapCache.hpp b/xs/src/slic3r/GUI/BitmapCache.hpp index 0cf9d8acf0..bec9a7ad25 100644 --- a/xs/src/slic3r/GUI/BitmapCache.hpp +++ b/xs/src/slic3r/GUI/BitmapCache.hpp @@ -27,7 +27,8 @@ public: wxBitmap* insert(const std::string &name, const wxBitmap &bmp); wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2); wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3); - wxBitmap* insert(const std::string &name, std::vector &bmps); + wxBitmap* insert(const std::string &name, const std::vector &bmps) { return this->insert(name, &bmps.front(), &bmps.front() + bmps.size()); } + wxBitmap* insert(const std::string &name, const wxBitmap *begin, const wxBitmap *end); static wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency); static wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3]) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE); } From abe6e8a783b62fc402aaea783906cb52a6381478 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 13 Apr 2018 13:43:53 +0200 Subject: [PATCH 0175/1150] Bugfix: legacy config options were not properly processed --- xs/src/libslic3r/Print.cpp | 2 +- xs/src/libslic3r/PrintConfig.cpp | 3 ++- xs/src/libslic3r/PrintConfig.hpp | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 4012b91f8a..dcece7a9ba 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -644,7 +644,7 @@ std::string Print::validate() const unsigned int total_extruders_count = this->config.nozzle_diameter.size(); for (const auto& extruder_idx : extruders) if ( extruder_idx >= total_extruders_count ) - return "One or more object have assigned an extruder that the printer does not have."; + return "One or more object were assigned an extruder that the printer does not have."; for (PrintObject *object : this->objects) { if ((object->config.support_material_extruder == -1 || object->config.support_material_interface_extruder == -1) && diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 66576c9f1a..1e7e0bacc6 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1944,8 +1944,9 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va "standby_temperature", "scale", "rotate", "duplicate", "duplicate_grid", "start_perimeters_at_concave_points", "start_perimeters_at_non_overhang", "randomize_start", "seal_position", "vibration_limit", "bed_size", "octoprint_host", - "print_center", "g0", "threads", "pressure_advance" + "print_center", "g0", "threads", "pressure_advance", "wipe_tower_per_color_wipe" }; + if (ignore.find(opt_key) != ignore.end()) { opt_key = ""; return; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index be64d35bd2..967a873107 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -154,6 +154,13 @@ public: // Validate the PrintConfig. Returns an empty string on success, otherwise an error message is returned. std::string validate(); + + // Verify whether the opt_key has not been obsoleted or renamed. + // Both opt_key and value may be modified by handle_legacy(). + // If the opt_key is no more valid in this version of Slic3r, opt_key is cleared by handle_legacy(). + // handle_legacy() is called internally by set_deserialize(). + void handle_legacy(t_config_option_key &opt_key, std::string &value) const override + { PrintConfigDef::handle_legacy(opt_key, value); } }; template From 68c3749696bcad48f0801129dd10a6f190a02a55 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 13 Apr 2018 13:46:31 +0200 Subject: [PATCH 0176/1150] Gyroid infill - automatic discretization steps and refactoring --- xs/src/libslic3r/Fill/FillGyroid.cpp | 162 ++++++++++++++++++--------- 1 file changed, 106 insertions(+), 56 deletions(-) diff --git a/xs/src/libslic3r/Fill/FillGyroid.cpp b/xs/src/libslic3r/Fill/FillGyroid.cpp index a3920caab1..d66e63a608 100644 --- a/xs/src/libslic3r/Fill/FillGyroid.cpp +++ b/xs/src/libslic3r/Fill/FillGyroid.cpp @@ -9,77 +9,125 @@ namespace Slic3r { -static inline Polyline make_wave_vertical( - double width, double height, double x0, - double segmentSize, double scaleFactor, - double z_cos, double z_sin, bool flip) -{ - Polyline polyline; - polyline.points.emplace_back(Point(coord_t(clamp(0., width, x0) * scaleFactor), 0)); - double phase_offset_sin = (z_cos < 0 ? M_PI : 0) + M_PI; - double phase_offset_cos = (z_cos < 0 ? M_PI : 0) + M_PI + (flip ? M_PI : 0.); - for (double y = 0.; y < height + segmentSize; y += segmentSize) { - y = std::min(y, height); - double a = sin(y + phase_offset_sin); + +static inline double f(double x, double z_sin, double z_cos, bool vertical, bool flip) { + if (vertical) { + double phase_offset = (z_cos < 0 ? M_PI : 0) + M_PI; + double a = sin(x + phase_offset); double b = - z_cos; - double res = z_sin * cos(y + phase_offset_cos); + double res = z_sin * cos(x + phase_offset + (flip ? M_PI : 0.)); double r = sqrt(sqr(a) + sqr(b)); - double x = clamp(0., width, asin(a/r) + asin(res/r) + M_PI + x0); - polyline.points.emplace_back(convert_to(Pointf(x, y) * scaleFactor)); + return asin(a/r) + asin(res/r) + M_PI; } - if (flip) - std::reverse(polyline.points.begin(), polyline.points.end()); + else { + double phase_offset = z_sin < 0 ? M_PI : 0.; + double a = cos(x + phase_offset); + double b = - z_sin; + double res = z_cos * sin(x + phase_offset + (flip ? 0 : M_PI)); + double r = sqrt(sqr(a) + sqr(b)); + return (asin(a/r) + asin(res/r) + 0.5 * M_PI); + } +} + + +static inline Polyline make_wave( + const std::vector& one_period, double width, double height, double offset, double scaleFactor, + double z_cos, double z_sin, bool vertical) +{ + std::vector points = one_period; + double period = points.back().x; + points.pop_back(); + int n = points.size(); + do { + points.emplace_back(Pointf(points[points.size()-n].x + period, points[points.size()-n].y)); + } while (points.back().x < width); + points.back().x = width; + + // and construct the final polyline to return: + Polyline polyline; + for (auto& point : points) { + point.y += offset; + point.y = clamp(0., height, double(point.y)); + if (vertical) + std::swap(point.x, point.y); + polyline.points.emplace_back(convert_to(point * scaleFactor)); + } + return polyline; } -static inline Polyline make_wave_horizontal( - double width, double height, double y0, - double segmentSize, double scaleFactor, - double z_cos, double z_sin, bool flip) -{ - Polyline polyline; - polyline.points.emplace_back(Point(0, coord_t(clamp(0., height, y0) * scaleFactor))); - double phase_offset_sin = (z_sin < 0 ? M_PI : 0) + (flip ? 0 : M_PI); - double phase_offset_cos = z_sin < 0 ? M_PI : 0.; - for (double x = 0.; x < width + segmentSize; x += segmentSize) { - x = std::min(x, width); - double a = cos(x + phase_offset_cos); - double b = - z_sin; - double res = z_cos * sin(x + phase_offset_sin); - double r = sqrt(sqr(a) + sqr(b)); - double y = clamp(0., height, asin(a/r) + asin(res/r) + 0.5 * M_PI + y0); - polyline.points.emplace_back(convert_to(Pointf(x, y) * scaleFactor)); + +static std::vector make_one_period(double width, double scaleFactor, double z_cos, double z_sin, bool vertical, bool flip) { + std::vector points; + double dx = M_PI_4; // very coarse spacing to begin with + double limit = std::min(2*M_PI, width); + for (double x = 0.; x < limit + EPSILON; x += dx) { // so the last point is there too + x = std::min(x, limit); + points.emplace_back(Pointf(x,f(x, z_sin,z_cos, vertical, flip))); } - if (flip) - std::reverse(polyline.points.begin(), polyline.points.end()); - return polyline; + + // now we will check all internal points and in case some are too far from the line connecting its neighbours, + // we will add one more point on each side: + const double tolerance = .1; + for (unsigned int i=1;i tolerance) { // if the difference from straight line is more than this + double x = 0.5f * (points[i-1].x + points[i].x); + points.emplace_back(Pointf(x, f(x, z_sin, z_cos, vertical, flip))); + x = 0.5f * (points[i+1].x + points[i].x); + points.emplace_back(Pointf(x, f(x, z_sin, z_cos, vertical, flip))); + std::sort(points.begin(), points.end()); // we added the points to the end, but need them all in order + --i; // decrement i so we also check the first newly added point + } + } + return points; } + static Polylines make_gyroid_waves(double gridZ, double density_adjusted, double line_spacing, double width, double height) { - double scaleFactor = scale_(line_spacing) / density_adjusted; - double segmentSize = 0.5 * density_adjusted; + const double scaleFactor = scale_(line_spacing) / density_adjusted; //scale factor for 5% : 8 712 388 // 1z = 10^-6 mm ? - double z = gridZ / scaleFactor; - double z_sin = sin(z); - double z_cos = cos(z); - Polylines result; - if (abs(z_sin) <= abs(z_cos)) { - // Vertical wave - double x0 = M_PI * (int)((- 0.5 * M_PI) / M_PI - 1.); - bool flip = ((int)(x0 / M_PI + 1.) & 1) != 0; - for (; x0 < width - 0.5 * M_PI; x0 += M_PI, flip = ! flip) - result.emplace_back(make_wave_vertical(width, height, x0, segmentSize, scaleFactor, z_cos, z_sin, flip)); - } else { - // Horizontal wave - bool flip = true; - for (double y0 = 0.; y0 < height; y0 += M_PI, flip = !flip) - result.emplace_back(make_wave_horizontal(width, height, y0, segmentSize, scaleFactor, z_cos, z_sin, flip)); + const double z = gridZ / scaleFactor; + const double z_sin = sin(z); + const double z_cos = cos(z); + + bool vertical = (std::abs(z_sin) <= std::abs(z_cos)); + double lower_bound = 0.; + double upper_bound = height; + bool flip = true; + if (vertical) { + flip = false; + lower_bound = -M_PI; + upper_bound = width - M_PI_2; + std::swap(width,height); } + + std::vector one_period = make_one_period(width, scaleFactor, z_cos, z_sin, vertical, flip); // creates one period of the waves, so it doesn't have to be recalculated all the time + Polylines result; + + for (double y0 = lower_bound; y0 < upper_bound+EPSILON; y0 += 2*M_PI) // creates odd polylines + result.emplace_back(make_wave(one_period, width, height, y0, scaleFactor, z_cos, z_sin, vertical)); + + flip = !flip; // even polylines are a bit shifted + one_period = make_one_period(width, scaleFactor, z_cos, z_sin, vertical, flip); // updates the one period sample + for (double y0 = lower_bound + M_PI; y0 < upper_bound+EPSILON; y0 += 2*M_PI) // creates even polylines + result.emplace_back(make_wave(one_period, width, height, y0, scaleFactor, z_cos, z_sin, vertical)); + return result; } + + + + + void FillGyroid::_fill_surface_single( const FillParams ¶ms, unsigned int thickness_layers, @@ -90,13 +138,15 @@ void FillGyroid::_fill_surface_single( // no rotation is supported for this infill pattern (yet) BoundingBox bb = expolygon.contour.bounding_box(); // Density adjusted to have a good %of weight. - double density_adjusted = params.density * 1.75; + double density_adjusted = std::max(0., params.density * 2.); + + // Distance between the gyroid waves in scaled coordinates. coord_t distance = coord_t(scale_(this->spacing) / density_adjusted); // align bounding box to a multiple of our grid module bb.merge(_align_to_grid(bb.min, Point(2.*M_PI*distance, 2.*M_PI*distance))); - + // generate pattern Polylines polylines = make_gyroid_waves( scale_(this->z), From 359e7e4d32225d485c36c4733ba9f3847d5c80b5 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 13 Apr 2018 13:59:36 +0200 Subject: [PATCH 0177/1150] Scale down meshes of too big objects after loading them --- lib/Slic3r/GUI/Plater.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index c74b2d32c3..ce37a16511 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -738,7 +738,13 @@ sub load_model_objects { # if the object is too large (more than 5 times the bed), scale it down my $size = $o->bounding_box->size; my $ratio = max($size->x / unscale($bed_size->x), $size->y / unscale($bed_size->y)); - if ($ratio > 5) { + if ($ratio > 10000) { + # the size of the object is too big -> this could lead to overflow when moving to clipper coordinates, + # so scale down the mesh + $o->scale_xyz(Slic3r::Pointf3->new(1/$ratio, 1/$ratio, 1/$ratio)); + $scaled_down = 1; + } + elsif ($ratio > 5) { $_->set_scaling_factor(1/$ratio) for @{$o->instances}; $scaled_down = 1; } From 659eb3412b132350bafad6a9c8fd74feaa5560fd Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 13 Apr 2018 14:40:42 +0200 Subject: [PATCH 0178/1150] Fixed value of z in cut dialog when object is scaled --- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 7f930c1d0f..7b5752cd2b 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -60,7 +60,7 @@ sub new { label => 'Z', default => $self->{cut_options}{z}, min => 0, - max => $self->{model_object}->bounding_box->size->z * $self->{model_object}->instances->[0]->scaling_factor, + max => $self->{model_object}->bounding_box->size->z, full_width => 1, )); { @@ -244,7 +244,7 @@ sub _update { $self->{canvas}->reset_objects; $self->{canvas}->load_object($_, undef, undef, [0]) for @objects; $self->{canvas}->SetCuttingPlane( - $self->{cut_options}{z} / $self->{model_object}->instances->[0]->scaling_factor, + $self->{cut_options}{z}, [@expolygons], ); $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config}); From 82890ec815080898c601222b8e370d4475a3af2e Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 13 Apr 2018 14:49:33 +0200 Subject: [PATCH 0179/1150] Removed some obsolete Perl binding. Added Version Index "version" method. Implemented automatic selection of default_print_profile and default_filament_profile, when the print / filament profiles are not compatible with the selected printer profile. Fixed selection of a printer profile, if the currently selected printer profile becomes invisible. --- lib/Slic3r/GUI/ConfigWizard.pm | 458 --------------------- resources/profiles/PrusaResearch.idx | 3 + xs/src/perlglue.cpp | 1 - xs/src/semver/semver.c | 7 +- xs/src/slic3r/Config/Version.cpp | 9 + xs/src/slic3r/Config/Version.hpp | 3 + xs/src/slic3r/GUI/ConfigWizard.cpp | 11 +- xs/src/slic3r/GUI/ConfigWizard.hpp | 2 +- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 2 +- xs/src/slic3r/GUI/GUI.cpp | 2 +- xs/src/slic3r/GUI/Preset.cpp | 41 +- xs/src/slic3r/GUI/Preset.hpp | 45 +- xs/src/slic3r/GUI/PresetBundle.cpp | 59 ++- xs/src/slic3r/GUI/Tab.cpp | 5 +- xs/src/slic3r/GUI/Tab.hpp | 2 +- xs/xsp/GUI_Preset.xsp | 42 -- xs/xsp/my.map | 2 - xs/xsp/typemap.xspt | 2 - 18 files changed, 146 insertions(+), 550 deletions(-) delete mode 100644 lib/Slic3r/GUI/ConfigWizard.pm diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm deleted file mode 100644 index a32d345ed0..0000000000 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ /dev/null @@ -1,458 +0,0 @@ -# The config wizard is executed when the Slic3r is first started. -# The wizard helps the user to specify the 3D printer properties. - -package Slic3r::GUI::ConfigWizard; -use strict; -use warnings; -use utf8; - -use Wx; -use base 'Wx::Wizard'; - -# adhere to various human interface guidelines -our $wizard = 'Wizard'; -$wizard = 'Assistant' if &Wx::wxMAC || &Wx::wxGTK; - -sub new { - my ($class, $parent, $presets, $fresh_start) = @_; - my $self = $class->SUPER::new($parent, -1, "Configuration $wizard"); - - # initialize an empty repository - $self->{config} = Slic3r::Config->new; - - my $welcome_page = Slic3r::GUI::ConfigWizard::Page::Welcome->new($self, $fresh_start); - $self->add_page($welcome_page); - $self->add_page(Slic3r::GUI::ConfigWizard::Page::Firmware->new($self)); - $self->add_page(Slic3r::GUI::ConfigWizard::Page::Bed->new($self)); - $self->add_page(Slic3r::GUI::ConfigWizard::Page::Nozzle->new($self)); - $self->add_page(Slic3r::GUI::ConfigWizard::Page::Filament->new($self)); - $self->add_page(Slic3r::GUI::ConfigWizard::Page::Temperature->new($self)); - $self->add_page(Slic3r::GUI::ConfigWizard::Page::BedTemperature->new($self)); - $self->add_page(Slic3r::GUI::ConfigWizard::Page::Finished->new($self)); - - $_->build_index for @{$self->{pages}}; - - $welcome_page->set_selection_presets([@{$presets}, 'Other']); - - return $self; -} - -sub add_page { - my ($self, $page) = @_; - - my $n = push @{$self->{pages}}, $page; - # add first page to the page area sizer - $self->GetPageAreaSizer->Add($page) if $n == 1; - # link pages - $self->{pages}[$n-2]->set_next_page($page) if $n >= 2; - $page->set_previous_page($self->{pages}[$n-2]) if $n >= 2; -} - -sub run { - my ($self) = @_; - my $result; - if (Wx::Wizard::RunWizard($self, $self->{pages}[0])) { - my $preset_name = $self->{pages}[0]->{preset_name}; - $result = { - preset_name => $preset_name, - reset_user_profile => $self->{pages}[0]->{reset_user_profile} - }; - if ($preset_name eq 'Other') { - # it would be cleaner to have these defined inside each page class, - # in some event getting called before leaving the page - # set first_layer_height + layer_height based on nozzle_diameter - my $nozzle = $self->{config}->nozzle_diameter; - $self->{config}->set('first_layer_height', $nozzle->[0]); - $self->{config}->set('layer_height', $nozzle->[0] - 0.1); - - # set first_layer_temperature to temperature + 5 - $self->{config}->set('first_layer_temperature', [$self->{config}->temperature->[0] + 5]); - - # set first_layer_bed_temperature to temperature + 5 - $self->{config}->set('first_layer_bed_temperature', - [ ($self->{config}->bed_temperature->[0] > 0) ? ($self->{config}->bed_temperature->[0] + 5) : 0 ]); - $result->{config} = $self->{config}; - } - } - $self->Destroy; - return $result; -} - -package Slic3r::GUI::ConfigWizard::Index; -use Wx qw(:bitmap :dc :font :misc :sizer :systemsettings :window); -use Wx::Event qw(EVT_ERASE_BACKGROUND EVT_PAINT); -use base 'Wx::Panel'; - -sub new { - my $class = shift; - my ($parent, $title) = @_; - my $self = $class->SUPER::new($parent); - - push @{$self->{titles}}, $title; - $self->{own_index} = 0; - - $self->{bullets}->{before} = Wx::Bitmap->new(Slic3r::var("bullet_black.png"), wxBITMAP_TYPE_PNG); - $self->{bullets}->{own} = Wx::Bitmap->new(Slic3r::var("bullet_blue.png"), wxBITMAP_TYPE_PNG); - $self->{bullets}->{after} = Wx::Bitmap->new(Slic3r::var("bullet_white.png"), wxBITMAP_TYPE_PNG); - - $self->{background} = Wx::Bitmap->new(Slic3r::var("Slic3r_192px_transparent.png"), wxBITMAP_TYPE_PNG); - $self->SetMinSize(Wx::Size->new($self->{background}->GetWidth, $self->{background}->GetHeight)); - - EVT_PAINT($self, \&repaint); - - return $self; -} - -sub repaint { - my ($self, $event) = @_; - my $size = $self->GetClientSize; - my $gap = 5; - - my $dc = Wx::PaintDC->new($self); - $dc->SetBackgroundMode(wxTRANSPARENT); - $dc->SetFont($self->GetFont); - $dc->SetTextForeground($self->GetForegroundColour); - - my $background_h = $self->{background}->GetHeight; - my $background_w = $self->{background}->GetWidth; - $dc->DrawBitmap($self->{background}, ($size->GetWidth - $background_w) / 2, ($size->GetHeight - $background_h) / 2, 1); - - my $label_h = $self->{bullets}->{own}->GetHeight; - $label_h = $dc->GetCharHeight if $dc->GetCharHeight > $label_h; - my $label_w = $size->GetWidth; - - my $i = 0; - foreach (@{$self->{titles}}) { - my $bullet = $self->{bullets}->{own}; - $bullet = $self->{bullets}->{before} if $i < $self->{own_index}; - $bullet = $self->{bullets}->{after} if $i > $self->{own_index}; - - $dc->SetTextForeground(Wx::Colour->new(128, 128, 128)) if $i > $self->{own_index}; - $dc->DrawLabel($_, $bullet, Wx::Rect->new(0, $i * ($label_h + $gap), $label_w, $label_h)); - # Only show the first bullet if this is the only wizard page to be displayed. - last if $i == 0 && $self->{just_welcome}; - $i++; - } - - $event->Skip; -} - -sub prepend_title { - my $self = shift; - my ($title) = @_; - - unshift @{$self->{titles}}, $title; - $self->{own_index}++; - $self->Refresh; -} - -sub append_title { - my $self = shift; - my ($title) = @_; - - push @{$self->{titles}}, $title; - $self->Refresh; -} - -package Slic3r::GUI::ConfigWizard::Page; -use Wx qw(:font :misc :sizer :staticline :systemsettings); -use base 'Wx::WizardPage'; - -sub new { - my $class = shift; - my ($parent, $title, $short_title) = @_; - my $self = $class->SUPER::new($parent); - - my $sizer = Wx::FlexGridSizer->new(0, 2, 10, 10); - $sizer->AddGrowableCol(1, 1); - $sizer->AddGrowableRow(1, 1); - $sizer->AddStretchSpacer(0); - $self->SetSizer($sizer); - - # title - my $text = Wx::StaticText->new($self, -1, $title, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); - my $bold_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - $bold_font->SetWeight(wxFONTWEIGHT_BOLD); - $bold_font->SetPointSize(14); - $text->SetFont($bold_font); - $sizer->Add($text, 0, wxALIGN_LEFT, 0); - - # index - $self->{short_title} = $short_title ? $short_title : $title; - $self->{index} = Slic3r::GUI::ConfigWizard::Index->new($self, $self->{short_title}); - $sizer->Add($self->{index}, 1, wxEXPAND | wxTOP | wxRIGHT, 10); - - # contents - $self->{width} = 430; - $self->{vsizer} = Wx::BoxSizer->new(wxVERTICAL); - $sizer->Add($self->{vsizer}, 1); - - return $self; -} - -sub append_text { - my $self = shift; - my ($text) = @_; - - my $para = Wx::StaticText->new($self, -1, $text, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); - $para->Wrap($self->{width}); - $para->SetMinSize([$self->{width}, -1]); - $self->{vsizer}->Add($para, 0, wxALIGN_LEFT | wxTOP | wxBOTTOM, 10); -} - -sub append_option { - my $self = shift; - my ($full_key) = @_; - - # populate repository with the factory default - my ($opt_key, $opt_index) = split /#/, $full_key, 2; - $self->config->apply(Slic3r::Config::new_from_defaults_keys([$opt_key])); - - # draw the control - my $optgroup = Slic3r::GUI::ConfigOptionsGroup->new( - parent => $self, - title => '', - config => $self->config, - full_labels => 1, - ); - $optgroup->append_single_option_line($opt_key, $opt_index); - $self->{vsizer}->Add($optgroup->sizer, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); -} - -sub append_panel { - my ($self, $panel) = @_; - $self->{vsizer}->Add($panel, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); -} - -sub set_previous_page { - my $self = shift; - my ($previous_page) = @_; - $self->{previous_page} = $previous_page; -} - -sub GetPrev { - my $self = shift; - return $self->{previous_page}; -} - -sub set_next_page { - my $self = shift; - my ($next_page) = @_; - $self->{next_page} = $next_page; -} - -sub GetNext { - my $self = shift; - return $self->{next_page}; -} - -sub get_short_title { - my $self = shift; - return $self->{short_title}; -} - -sub build_index { - my $self = shift; - - my $page = $self; - $self->{index}->prepend_title($page->get_short_title) while ($page = $page->GetPrev); - $page = $self; - $self->{index}->append_title($page->get_short_title) while ($page = $page->GetNext); -} - -sub config { - my ($self) = @_; - return $self->GetParent->{config}; -} - -package Slic3r::GUI::ConfigWizard::Page::Welcome; -use base 'Slic3r::GUI::ConfigWizard::Page'; -use Wx qw(:misc :sizer wxID_FORWARD); -use Wx::Event qw(EVT_ACTIVATE EVT_CHOICE EVT_CHECKBOX); - -sub new { - my ($class, $parent, $fresh_start) = @_; - my $self = $class->SUPER::new($parent, "Welcome to the Slic3r Configuration $wizard", 'Welcome'); - $self->{full_wizard_workflow} = 1; - $self->{reset_user_profile} = 0; - - # Test for the existence of the old config path. - my $message_has_legacy; - { - my $datadir = Slic3r::data_dir; - if ($datadir =~ /Slic3rPE/) { - # Check for existence of the legacy Slic3r directory. - my $datadir_legacy = substr $datadir, 0, -2; - my $dir_enc = Slic3r::encode_path($datadir_legacy); - if (-e $dir_enc && -d $dir_enc && - -e ($dir_enc . '/print') && -d ($dir_enc . '/print') && - -e ($dir_enc . '/filament') && -d ($dir_enc . '/filament') && - -e ($dir_enc . '/printer') && -d ($dir_enc . '/printer') && - -e ($dir_enc . '/slic3r.ini')) { - $message_has_legacy = "Starting with Slic3r 1.38.4, the user profile directory has been renamed to $datadir. You may consider closing Slic3r and renaming $datadir_legacy to $datadir."; - } - } - } - - $self->append_text('Hello, welcome to Slic3r Prusa Edition! This '.lc($wizard).' helps you with the initial configuration; just a few settings and you will be ready to print.'); - $self->append_text('Please select your printer vendor and printer type. If your printer is not listed, you may try your luck and select a similar one. If you select "Other", this ' . lc($wizard) . ' will let you set the basic 3D printer parameters.'); - $self->append_text($message_has_legacy) if defined $message_has_legacy; - # To import an existing configuration instead, cancel this '.lc($wizard).' and use the Open Config menu item found in the File menu.'); - $self->append_text('If you received a configuration file or a config bundle from your 3D printer vendor, cancel this '.lc($wizard).' and use the "File->Load Config" or "File->Load Config Bundle" menu.'); - - $self->{choice} = my $choice = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, []); - $self->{vsizer}->Add($choice, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); - if (! $fresh_start) { - $self->{reset_checkbox} = Wx::CheckBox->new($self, -1, "Reset user profile, install from scratch"); - $self->{vsizer}->Add($self->{reset_checkbox}, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); - } - - EVT_CHOICE($parent, $choice, sub { - my $sel = $self->{choice}->GetStringSelection; - $self->{preset_name} = $sel; - $self->set_full_wizard_workflow(($sel eq 'Other') || ($sel eq '')); - }); - - if (! $fresh_start) { - EVT_CHECKBOX($self, $self->{reset_checkbox}, sub { - $self->{reset_user_profile} = $self->{reset_checkbox}->GetValue(); - }); - } - - EVT_ACTIVATE($parent, sub { - $self->set_full_wizard_workflow($self->{preset_name} eq 'Other'); - }); - - return $self; -} - -sub set_full_wizard_workflow { - my ($self, $full_workflow) = @_; - $self->{full_wizard_workflow} = $full_workflow; - $self->{index}->{just_welcome} = !$full_workflow; - $self->{index}->Refresh; - my $next_button = $self->GetParent->FindWindow(wxID_FORWARD); - $next_button->SetLabel($full_workflow ? "&Next >" : "&Finish"); -} - -# Set the preset names, select the first item. -sub set_selection_presets { - my ($self, $names) = @_; - $self->{choice}->Append($names); - $self->{choice}->SetSelection(0); - $self->{preset_name} = $names->[0]; -} - -sub GetNext { - my $self = shift; - return $self->{full_wizard_workflow} ? $self->{next_page} : undef; -} - -package Slic3r::GUI::ConfigWizard::Page::Firmware; -use base 'Slic3r::GUI::ConfigWizard::Page'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Firmware Type'); - - $self->append_text('Choose the type of firmware used by your printer, then click Next.'); - $self->append_option('gcode_flavor'); - - return $self; -} - -package Slic3r::GUI::ConfigWizard::Page::Bed; -use base 'Slic3r::GUI::ConfigWizard::Page'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Bed Size'); - - $self->append_text('Set the shape of your printer\'s bed, then click Next.'); - - $self->config->apply(Slic3r::Config::new_from_defaults_keys(['bed_shape'])); - $self->{bed_shape_panel} = my $panel = Slic3r::GUI::BedShapePanel->new($self, $self->config->bed_shape); - $self->{bed_shape_panel}->on_change(sub { - $self->config->set('bed_shape', $self->{bed_shape_panel}->GetValue); - }); - $self->append_panel($self->{bed_shape_panel}); - return $self; -} - -package Slic3r::GUI::ConfigWizard::Page::Nozzle; -use base 'Slic3r::GUI::ConfigWizard::Page'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Nozzle Diameter'); - - $self->append_text('Enter the diameter of your printer\'s hot end nozzle, then click Next.'); - $self->append_option('nozzle_diameter#0'); - - return $self; -} - -package Slic3r::GUI::ConfigWizard::Page::Filament; -use base 'Slic3r::GUI::ConfigWizard::Page'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Filament Diameter'); - - $self->append_text('Enter the diameter of your filament, then click Next.'); - $self->append_text('Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average.'); - $self->append_option('filament_diameter#0'); - - return $self; -} - -package Slic3r::GUI::ConfigWizard::Page::Temperature; -use base 'Slic3r::GUI::ConfigWizard::Page'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Extrusion Temperature'); - - $self->append_text('Enter the temperature needed for extruding your filament, then click Next.'); - $self->append_text('A rule of thumb is 160 to 230 °C for PLA, and 215 to 250 °C for ABS.'); - $self->append_option('temperature#0'); - - return $self; -} - -package Slic3r::GUI::ConfigWizard::Page::BedTemperature; -use base 'Slic3r::GUI::ConfigWizard::Page'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Bed Temperature'); - - $self->append_text('Enter the bed temperature needed for getting your filament to stick to your heated bed, then click Next.'); - $self->append_text('A rule of thumb is 60 °C for PLA and 110 °C for ABS. Leave zero if you have no heated bed.'); - $self->append_option('bed_temperature#0'); - - return $self; -} - -package Slic3r::GUI::ConfigWizard::Page::Finished; -use base 'Slic3r::GUI::ConfigWizard::Page'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Congratulations!', 'Finish'); - - $self->append_text("You have successfully completed the Slic3r Configuration $wizard. " . - 'Slic3r is now configured for your printer and filament.'); - $self->append_text('To close this '.lc($wizard).' and apply the newly created configuration, click Finish.'); - - return $self; -} - -1; diff --git a/resources/profiles/PrusaResearch.idx b/resources/profiles/PrusaResearch.idx index 28f17f10ad..3bc2aeffdd 100644 --- a/resources/profiles/PrusaResearch.idx +++ b/resources/profiles/PrusaResearch.idx @@ -1,6 +1,9 @@ # This is an example configuration version index. # The index contains version numbers min_slic3r_version =1.39.0 +max_slic3r_version= 1.39.5 +1.1.1 +1.1.0 0.2.0-alpha "some test comment" max_slic3r_version= 1.39.4 0.1.0 another test comment diff --git a/xs/src/perlglue.cpp b/xs/src/perlglue.cpp index 9706ced2cd..205eec2188 100644 --- a/xs/src/perlglue.cpp +++ b/xs/src/perlglue.cpp @@ -62,7 +62,6 @@ REGISTER_CLASS(GLVolumeCollection, "GUI::_3DScene::GLVolume::Collection"); REGISTER_CLASS(Preset, "GUI::Preset"); REGISTER_CLASS(PresetCollection, "GUI::PresetCollection"); REGISTER_CLASS(PresetBundle, "GUI::PresetBundle"); -REGISTER_CLASS(PresetHints, "GUI::PresetHints"); REGISTER_CLASS(TabIface, "GUI::Tab"); REGISTER_CLASS(PresetUpdater, "PresetUpdater"); REGISTER_CLASS(OctoPrint, "OctoPrint"); diff --git a/xs/src/semver/semver.c b/xs/src/semver/semver.c index 3e4a30e3a0..68d18af091 100644 --- a/xs/src/semver/semver.c +++ b/xs/src/semver/semver.c @@ -175,6 +175,9 @@ semver_parse_version (const char *str, semver_t *ver) { slice = (char *) str; index = 0; + // non mandatory + ver->patch = 0; + while (slice != NULL && index++ < 4) { next = strchr(slice, DELIMITER[0]); if (next == NULL) @@ -200,7 +203,8 @@ semver_parse_version (const char *str, semver_t *ver) { slice = next + 1; } - return (index == 3) ? 0 : -1; + // Major and minor versions are mandatory, patch version is not mandatory. + return (index == 2 || index == 3) ? 0 : -1; } static int @@ -632,4 +636,5 @@ semver_copy(const semver_t *ver) { if (ver->prerelease != NULL) { res.prerelease = strdup(ver->prerelease); } + return res; } \ No newline at end of file diff --git a/xs/src/slic3r/Config/Version.cpp b/xs/src/slic3r/Config/Version.cpp index 95b3caf1a3..a80b0b6e99 100644 --- a/xs/src/slic3r/Config/Version.cpp +++ b/xs/src/slic3r/Config/Version.cpp @@ -141,6 +141,15 @@ size_t Index::load(const boost::filesystem::path &path) return m_configs.size(); } +Semver Index::version() const +{ + Semver ver = Semver::zero(); + for (const Version &cv : m_configs) + if (cv.config_version >= ver) + ver = cv.config_version; + return ver; +} + Index::const_iterator Index::find(const Semver &ver) { Version key; diff --git a/xs/src/slic3r/Config/Version.hpp b/xs/src/slic3r/Config/Version.hpp index 43512e82f5..c4243ca756 100644 --- a/xs/src/slic3r/Config/Version.hpp +++ b/xs/src/slic3r/Config/Version.hpp @@ -59,6 +59,9 @@ public: size_t load(const boost::filesystem::path &path); const std::string& vendor() const { return m_vendor; } + // Returns version of the index as the highest version of all the configs. + // If there is no config, Semver::zero() is returned. + Semver version() const; const_iterator begin() const { return m_configs.begin(); } const_iterator end() const { return m_configs.end(); } diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 52a896704d..30d1bf4e3a 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -619,7 +619,7 @@ void ConfigWizard::priv::on_custom_setup() set_page(page_firmware); } -void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *preset_bundle) +void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *preset_bundle, bool fresh_start) { const bool is_custom_setup = page_welcome->page_next() == page_firmware; @@ -627,7 +627,8 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese app_config->set_vendors(appconfig_vendors); app_config->set("version_check", page_update->version_check ? "1" : "0"); app_config->set("preset_update", page_update->preset_update ? "1" : "0"); - app_config->reset_selections(); // XXX: only on "fresh start"? + if (fresh_start) + app_config->reset_selections(); preset_bundle->load_presets(*app_config); } else { for (ConfigWizardPage *page = page_firmware; page != nullptr; page = page->page_next()) { @@ -635,6 +636,8 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese } preset_bundle->load_config("My Settings", *custom_config); } + // Update the selections from the compatibilty. + preset_bundle->export_selections(*app_config); } // Public @@ -698,11 +701,11 @@ ConfigWizard::ConfigWizard(wxWindow *parent) : ConfigWizard::~ConfigWizard() {} -bool ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) +bool ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle, bool fresh_start) { ConfigWizard wizard(parent); if (wizard.ShowModal() == wxID_OK) { - wizard.p->apply_config(GUI::get_app_config(), preset_bundle); + wizard.p->apply_config(GUI::get_app_config(), preset_bundle, fresh_start); return true; } else { return false; diff --git a/xs/src/slic3r/GUI/ConfigWizard.hpp b/xs/src/slic3r/GUI/ConfigWizard.hpp index 40ecf09a1e..4e791e2796 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard.hpp @@ -22,7 +22,7 @@ public: ConfigWizard &operator=(const ConfigWizard &) = delete; ~ConfigWizard(); - static bool run(wxWindow *parent, PresetBundle *preset_bundle); + static bool run(wxWindow *parent, PresetBundle *preset_bundle, bool fresh_start); private: struct priv; std::unique_ptr p; diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index 652328aaad..6881f6f556 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -202,7 +202,7 @@ struct ConfigWizard::priv void on_other_vendors(); void on_custom_setup(); - void apply_config(AppConfig *app_config, PresetBundle *preset_bundle); + void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, bool fresh_start); }; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index d70b47840b..036e089931 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -452,7 +452,7 @@ bool config_wizard(bool fresh_start) return false; // TODO: Offer "reset user profile" ??? - if (! ConfigWizard::run(g_wxMainFrame, g_PresetBundle)) + if (! ConfigWizard::run(g_wxMainFrame, g_PresetBundle, fresh_start)) return false; // Load the currently selected preset into the GUI, update the preset selection box. diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 39bfbd3981..853c229fff 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -521,18 +521,6 @@ size_t PresetCollection::first_visible_idx() const return idx; } -// Return index of the first compatible preset. Certainly at least the '- default -' preset shall be compatible. -size_t PresetCollection::first_compatible_idx() const -{ - size_t idx = m_default_suppressed ? 1 : 0; - for (; idx < this->m_presets.size(); ++ idx) - if (m_presets[idx].is_compatible) - break; - if (idx == this->m_presets.size()) - idx = 0; - return idx; -} - void PresetCollection::set_default_suppressed(bool default_suppressed) { if (m_default_suppressed != default_suppressed) { @@ -541,7 +529,7 @@ void PresetCollection::set_default_suppressed(bool default_suppressed) } } -void PresetCollection::update_compatible_with_printer(const Preset &active_printer, bool select_other_if_incompatible) +size_t PresetCollection::update_compatible_with_printer_internal(const Preset &active_printer, bool unselect_if_incompatible) { DynamicPrintConfig config; config.set_key_value("printer_preset", new ConfigOptionString(active_printer.name)); @@ -552,14 +540,12 @@ void PresetCollection::update_compatible_with_printer(const Preset &active_print Preset &preset_selected = m_presets[idx_preset]; Preset &preset_edited = selected ? m_edited_preset : preset_selected; if (! preset_edited.update_compatible_with_printer(active_printer, &config) && - selected && select_other_if_incompatible) + selected && unselect_if_incompatible) m_idx_selected = (size_t)-1; if (selected) preset_selected.is_compatible = preset_edited.is_compatible; } - if (m_idx_selected == (size_t)-1) - // Find some other compatible preset, or the "-- default --" preset. - this->select_preset(first_compatible_idx()); + return m_idx_selected; } // Save the preset under a new name. If the name is different from the old one, @@ -689,8 +675,8 @@ bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, b // 1) Try to find the preset by its name. auto it = this->find_preset_internal(name); size_t idx = 0; - if (it != m_presets.end() && it->name == name) - // Preset found by its name. + if (it != m_presets.end() && it->name == name && it->is_visible) + // Preset found by its name and it is visible. idx = it - m_presets.begin(); else { // Find the first visible preset. @@ -711,6 +697,23 @@ bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, b return false; } +bool PresetCollection::select_preset_by_name_strict(const std::string &name) +{ + // 1) Try to find the preset by its name. + auto it = this->find_preset_internal(name); + size_t idx = (size_t)-1; + if (it != m_presets.end() && it->name == name && it->is_visible) + // Preset found by its name. + idx = it - m_presets.begin(); + // 2) Select the new preset. + if (idx != (size_t)-1) { + this->select_preset(idx); + return true; + } + m_idx_selected = idx; + return false; +} + std::string PresetCollection::name() const { switch (this->type()) { diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index d6ccfd4505..08caf4d4ec 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -18,6 +18,7 @@ class wxItemContainer; namespace Slic3r { class AppConfig; +class PresetBundle; enum ConfigFileType { @@ -243,19 +244,49 @@ public: { return const_cast(this)->find_preset(name, first_visible_if_not_found); } size_t first_visible_idx() const; - size_t first_compatible_idx() const; + // Return index of the first compatible preset. Certainly at least the '- default -' preset shall be compatible. + // If one of the prefered_alternates is compatible, select it. + template + size_t first_compatible_idx(PreferedCondition prefered_condition) const + { + size_t i = m_default_suppressed ? 1 : 0; + size_t n = this->m_presets.size(); + size_t i_compatible = n; + for (; i < n; ++ i) + if (m_presets[i].is_compatible) { + if (prefered_condition(m_presets[i].name)) + return i; + if (i_compatible == n) + // Store the first compatible profile into i_compatible. + i_compatible = i; + } + return (i_compatible == n) ? 0 : i_compatible; + } + // Return index of the first compatible preset. Certainly at least the '- default -' preset shall be compatible. + size_t first_compatible_idx() const { return this->first_compatible_idx([](const std::string&){return true;}); } + // Return index of the first visible preset. Certainly at least the '- default -' preset shall be visible. // Return the first visible preset. Certainly at least the '- default -' preset shall be visible. Preset& first_visible() { return this->preset(this->first_visible_idx()); } const Preset& first_visible() const { return this->preset(this->first_visible_idx()); } Preset& first_compatible() { return this->preset(this->first_compatible_idx()); } + template + Preset& first_compatible(PreferedCondition prefered_condition) { return this->preset(this->first_compatible_idx(prefered_condition)); } const Preset& first_compatible() const { return this->preset(this->first_compatible_idx()); } // Return number of presets including the "- default -" preset. size_t size() const { return this->m_presets.size(); } // For Print / Filament presets, disable those, which are not compatible with the printer. - void update_compatible_with_printer(const Preset &active_printer, bool select_other_if_incompatible); + template + void update_compatible_with_printer(const Preset &active_printer, bool select_other_if_incompatible, PreferedCondition prefered_condition) + { + if (this->update_compatible_with_printer_internal(active_printer, select_other_if_incompatible) == (size_t)-1) + // Find some other compatible preset, or the "-- default --" preset. + this->select_preset(this->first_compatible_idx(prefered_condition)); + } + void update_compatible_with_printer(const Preset &active_printer, bool select_other_if_incompatible) + { this->update_compatible_with_printer(active_printer, select_other_if_incompatible, [](const std::string&){return true;}); } size_t num_visible() const { return std::count_if(m_presets.begin(), m_presets.end(), [](const Preset &preset){return preset.is_visible;}); } @@ -291,6 +322,11 @@ public: // Generate a file path from a profile name. Add the ".ini" suffix if it is missing. std::string path_from_name(const std::string &new_name) const; +protected: + // Select a preset, if it exists. If it does not exist, select an invalid (-1) index. + // This is a temporary state, which shall be fixed immediately by the following step. + bool select_preset_by_name_strict(const std::string &name); + private: PresetCollection(); PresetCollection(const PresetCollection &other); @@ -308,6 +344,8 @@ private: std::deque::const_iterator find_preset_internal(const std::string &name) const { return const_cast(this)->find_preset_internal(name); } + size_t update_compatible_with_printer_internal(const Preset &active_printer, bool unselect_if_incompatible); + static std::vector dirty_options(const Preset *edited, const Preset *reference); // Type of this PresetCollection: TYPE_PRINT, TYPE_FILAMENT or TYPE_PRINTER. @@ -333,6 +371,9 @@ private: wxBitmap *m_bitmap_main_frame; // Path to the directory to store the config files into. std::string m_dir_path; + + // to access select_preset_by_name_strict() + friend class PresetBundle; }; } // namespace Slic3r diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index ad27bf8c68..244915864b 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -209,22 +209,34 @@ void PresetBundle::load_installed_printers(const AppConfig &config) // This is done just once on application start up. void PresetBundle::load_selections(const AppConfig &config) { - prints.select_preset_by_name(remove_ini_suffix(config.get("presets", "print")), true); - filaments.select_preset_by_name(remove_ini_suffix(config.get("presets", "filament")), true); - printers.select_preset_by_name(remove_ini_suffix(config.get("presets", "printer")), true); + // Update visibility of presets based on application vendor / model / variant configuration. + this->load_installed_printers(config); + + // Parse the initial print / filament / printer profile names. + std::string initial_print_profile_name = remove_ini_suffix(config.get("presets", "print")); + std::vector initial_filament_profile_names; + std::string initial_printer_profile_name = remove_ini_suffix(config.get("presets", "printer")); + auto *nozzle_diameter = dynamic_cast(printers.get_selected_preset().config.option("nozzle_diameter")); size_t num_extruders = nozzle_diameter->values.size(); - this->set_filament_preset(0, filaments.get_selected_preset().name); + initial_filament_profile_names.emplace_back(remove_ini_suffix(config.get("presets", "filament"))); + this->set_filament_preset(0, initial_filament_profile_names.back()); for (unsigned int i = 1; i < (unsigned int)num_extruders; ++ i) { char name[64]; sprintf(name, "filament_%d", i); if (! config.has("presets", name)) break; - this->set_filament_preset(i, remove_ini_suffix(config.get("presets", name))); + initial_filament_profile_names.emplace_back(remove_ini_suffix(config.get("presets", name))); + this->set_filament_preset(i, initial_filament_profile_names.back()); } - // Update visibility of presets based on application vendor / model / variant configuration. - this->load_installed_printers(config); + // Activate print / filament / printer profiles from the config. + // If the printer profile enumerated by the config are not visible, select an alternate preset. + // Do not select alternate profiles for the print / filament profiles as those presets + // will be selected by the following call of this->update_compatible_with_printer(true). + prints.select_preset_by_name_strict(initial_print_profile_name); + filaments.select_preset_by_name_strict(initial_filament_profile_names.front()); + printers.select_preset_by_name(initial_printer_profile_name, true); // Update visibility of presets based on their compatibility with the active printer. // Always try to select a compatible print and filament preset to the current printer preset, @@ -861,14 +873,35 @@ void PresetBundle::update_multi_material_filament_presets() void PresetBundle::update_compatible_with_printer(bool select_other_if_incompatible) { - this->prints.update_compatible_with_printer(this->printers.get_edited_preset(), select_other_if_incompatible); - this->filaments.update_compatible_with_printer(this->printers.get_edited_preset(), select_other_if_incompatible); + const Preset &printer_preset = this->printers.get_edited_preset(); + const std::string &prefered_print_profile = printer_preset.config.opt_string("default_print_profile"); + const std::vector &prefered_filament_profiles = printer_preset.config.option("default_filament_profile")->values; + prefered_print_profile.empty() ? + this->prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible) : + this->prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible, + [&prefered_print_profile](const std::string& profile_name){ return profile_name == prefered_print_profile; }); + prefered_filament_profiles.empty() ? + this->filaments.update_compatible_with_printer(printer_preset, select_other_if_incompatible) : + this->filaments.update_compatible_with_printer(printer_preset, select_other_if_incompatible, + [&prefered_filament_profiles](const std::string& profile_name) + { return std::find(prefered_filament_profiles.begin(), prefered_filament_profiles.end(), profile_name) != prefered_filament_profiles.end(); }); if (select_other_if_incompatible) { // Verify validity of the current filament presets. - for (std::string &filament_name : this->filament_presets) { - Preset *preset = this->filaments.find_preset(filament_name, false); - if (preset == nullptr || ! preset->is_compatible) - filament_name = this->filaments.first_compatible().name; + this->filament_presets.front() = this->filaments.get_edited_preset().name; + for (size_t idx = 1; idx < this->filament_presets.size(); ++ idx) { + std::string &filament_name = this->filament_presets[idx]; + Preset *preset = this->filaments.find_preset(filament_name, false); + if (preset == nullptr || ! preset->is_compatible) { + // Pick a compatible profile. If there are prefered_filament_profiles, use them. + if (prefered_filament_profiles.empty()) + filament_name = this->filaments.first_compatible().name; + else { + const std::string &preferred = (idx < prefered_filament_profiles.size()) ? + prefered_filament_profiles[idx] : prefered_filament_profiles.front(); + filament_name = this->filaments.first_compatible( + [&preferred](const std::string& profile_name){ return profile_name == preferred; }).name; + } + } } } } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 940987536c..ed2b4b9514 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -540,7 +540,8 @@ void Tab::load_key_value(std::string opt_key, boost::any value) change_opt_value(*m_config, opt_key, value); // Mark the print & filament enabled if they are compatible with the currently selected preset. if (opt_key.compare("compatible_printers") == 0) { - m_preset_bundle->update_compatible_with_printer(0); + // Don't select another profile if this profile happens to become incompatible. + m_preset_bundle->update_compatible_with_printer(false); } m_presets->update_dirty_ui(m_presets_choice); on_presets_changed(); @@ -1772,7 +1773,7 @@ void Tab::rebuild_page_tree() // Called by the UI combo box when the user switches profiles. // Select a preset by a name.If !defined(name), then the default preset is selected. // If the current profile is modified, user is asked to save the changes. -void Tab::select_preset(std::string preset_name /*= ""*/) +void Tab::select_preset(const std::string &preset_name /*= ""*/) { std::string name = preset_name; auto force = false; diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index f39ff728ca..bd9672bb2d 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -143,7 +143,7 @@ public: void create_preset_tab(PresetBundle *preset_bundle); void load_current_preset(); void rebuild_page_tree(); - void select_preset(std::string preset_name = ""); + void select_preset(const std::string &preset_name = ""); bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, std::string new_printer_name = ""); wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn); diff --git a/xs/xsp/GUI_Preset.xsp b/xs/xsp/GUI_Preset.xsp index 1187a1cf56..d0d4057b22 100644 --- a/xs/xsp/GUI_Preset.xsp +++ b/xs/xsp/GUI_Preset.xsp @@ -44,9 +44,6 @@ Ref 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 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); %}; @@ -55,30 +52,6 @@ %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* @@ -173,9 +146,6 @@ PresetCollection::arrayref() std::vector 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 full_config() %code%{ RETVAL = THIS->full_config(); %}; @@ -183,15 +153,3 @@ PresetCollection::arrayref() %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); %}; - static std::string recommended_thin_wall_thickness(PresetBundle *preset) - %code%{ RETVAL = PresetHints::recommended_thin_wall_thickness(*preset); %}; -}; diff --git a/xs/xsp/my.map b/xs/xsp/my.map index c1ca58827b..79b71143bf 100644 --- a/xs/xsp/my.map +++ b/xs/xsp/my.map @@ -231,8 +231,6 @@ PresetCollection* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T PresetBundle* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T -PresetHints* O_OBJECT_SLIC3R -Ref O_OBJECT_SLIC3R_T TabIface* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T diff --git a/xs/xsp/typemap.xspt b/xs/xsp/typemap.xspt index 0214a158d6..a2bca2c7b1 100644 --- a/xs/xsp/typemap.xspt +++ b/xs/xsp/typemap.xspt @@ -208,8 +208,6 @@ %typemap{Ref}{simple}; %typemap{PresetBundle*}; %typemap{Ref}{simple}; -%typemap{PresetHints*}; -%typemap{Ref}{simple}; %typemap{TabIface*}; %typemap{Ref}{simple}; From 7dbb2ed6a3f97b585ed7341a9199bfd40627da6b Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 13 Apr 2018 15:08:58 +0200 Subject: [PATCH 0180/1150] Configuration updates downloading --- lib/Slic3r/GUI.pm | 5 +- resources/profiles/PrusaResearch.idx | 3 - resources/profiles/PrusaResearch.ini | 3 +- xs/src/libslic3r/utils.cpp | 2 +- xs/src/slic3r/Config/Version.cpp | 4 +- xs/src/slic3r/GUI/AppConfig.cpp | 6 +- xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp | 3 - xs/src/slic3r/GUI/ConfigWizard.cpp | 3 +- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 6 +- xs/src/slic3r/Utils/PresetUpdater.cpp | 224 ++++++++++++--------- xs/src/slic3r/Utils/PresetUpdater.hpp | 4 +- xs/xsp/Utils_PresetUpdater.xsp | 4 +- 12 files changed, 148 insertions(+), 119 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index b592c4289b..40cfcad896 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -103,7 +103,7 @@ sub OnInit { # my $version_check = $self->{app_config}->get('version_check'); $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT, $self->{app_config}); - eval { $self->{preset_updater}->config_update() }; + eval { $self->{preset_updater}->config_update($self->{app_config}) }; if ($@) { warn $@ . "\n"; fatal_error(undef, $@); @@ -158,7 +158,8 @@ sub OnInit { Slic3r::GUI::config_wizard(1); } - # $self->{preset_updater}->download($self->{preset_bundle}); + # TODO: call periodically? + $self->{preset_updater}->sync($self->{app_config}, $self->{preset_bundle}); }); # The following event is emited by the C++ menu implementation of application language change. diff --git a/resources/profiles/PrusaResearch.idx b/resources/profiles/PrusaResearch.idx index 28f17f10ad..837bc7bac6 100644 --- a/resources/profiles/PrusaResearch.idx +++ b/resources/profiles/PrusaResearch.idx @@ -1,8 +1,5 @@ # This is an example configuration version index. # The index contains version numbers -min_slic3r_version =1.39.0 -0.2.0-alpha "some test comment" -max_slic3r_version= 1.39.4 0.1.0 another test comment # some empty lines diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index cf82855cf4..0ca094880b 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -8,8 +8,7 @@ name = Prusa Research config_version = 0.1.0 # Where to get the updates from? # TODO: proper URL -# config_update_url = https://raw.githubusercontent.com/prusa3d/Slic3r-settings/master/live/PrusaResearch.ini -config_update_url = https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/e9187c3e15ceaf1a90f29b7c43cf3ccc746140f0/PrusaResearch.ini +config_update_url = https://raw.githubusercontent.com/vojtechkral/slic3r-settings-tmp/master/PrusaResearch # The printer models will be shown by the Configuration Wizard in this order, # also the first model installed & the first nozzle installed will be activated after install. diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp index 703d5ff660..733757e25a 100644 --- a/xs/src/libslic3r/utils.cpp +++ b/xs/src/libslic3r/utils.cpp @@ -119,7 +119,7 @@ static std::string g_data_dir; void set_data_dir(const std::string &dir) { - g_data_dir = dir + "-alpha"; // FIXME: Resolve backcompat problems + g_data_dir = dir; } const std::string& data_dir() diff --git a/xs/src/slic3r/Config/Version.cpp b/xs/src/slic3r/Config/Version.cpp index 5430e569c4..b1abc5c636 100644 --- a/xs/src/slic3r/Config/Version.cpp +++ b/xs/src/slic3r/Config/Version.cpp @@ -153,10 +153,10 @@ Index::const_iterator Index::find(const Semver &ver) const Index::const_iterator Index::recommended() const { int idx = -1; - const_iterator highest = m_configs.end(); + const_iterator highest = this->end(); for (const_iterator it = this->begin(); it != this->end(); ++ it) if (it->is_current_slic3r_supported() && - (highest == this->end() || highest->max_slic3r_version < it->max_slic3r_version)) + (highest == this->end() || highest->config_version < it->config_version)) highest = it; return highest; } diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index ee77f877ae..d0f2f1019c 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -46,11 +46,15 @@ void AppConfig::set_defaults() set("no_defaults", "1"); if (get("show_incompatible_presets").empty()) set("show_incompatible_presets", "0"); - // Version check is enabled by default in the config, but it is not implemented yet. // XXX + if (get("version_check").empty()) set("version_check", "1"); + // TODO: proper URL + if (get("version_check_url").empty()) + set("version_check_url", "https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/e9187c3e15ceaf1a90f29b7c43cf3ccc746140f0/slic3rPE.version"); if (get("preset_update").empty()) set("preset_update", "1"); + // Use OpenGL 1.1 even if OpenGL 2.0 is available. This is mainly to support some buggy Intel HD Graphics drivers. // https://github.com/prusa3d/Slic3r/issues/233 if (get("use_legacy_opengl").empty()) diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp index 730b97a320..8739b8fa25 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -86,9 +86,6 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); html->SetBorders(2); std::string text = generate_html_page(snapshot_db); - FILE *file = ::fopen("d:\\temp\\configsnapshotdialog.html", "wt"); - fwrite(text.data(), 1, text.size(), file); - fclose(file); html->SetPage(text.c_str()); vsizer->Add(html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 0); html->Bind(wxEVT_HTML_LINK_CLICKED, &ConfigSnapshotDialog::onLinkClicked, this); diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index f353ab7f7e..5b49fc0258 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -660,7 +660,8 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese app_config->set_vendors(appconfig_vendors); app_config->set("version_check", page_update->version_check ? "1" : "0"); app_config->set("preset_update", page_update->preset_update ? "1" : "0"); - app_config->reset_selections(); // XXX: only on "fresh start"? + app_config->reset_selections(); + // ^ TODO: replace with appropriate printer selection preset_bundle->load_presets(*app_config); } else { for (ConfigWizardPage *page = page_firmware; page != nullptr; page = page->page_next()) { diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index 137b276b85..c93e0a80d5 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -17,7 +17,6 @@ #include "libslic3r/PrintConfig.hpp" #include "AppConfig.hpp" #include "Preset.hpp" -// #include "PresetBundle.hpp" #include "BedShapeDialog.hpp" namespace fs = boost::filesystem; @@ -173,9 +172,8 @@ private: struct ConfigWizard::priv { ConfigWizard *q; - AppConfig appconfig_vendors; - // PresetBundle bundle_vendors; - std::unordered_map vendors; + AppConfig appconfig_vendors; // TODO: use order-preserving container + std::unordered_map vendors; // TODO: just set? std::unordered_map vendors_rsrc; std::unique_ptr custom_config; diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 28b9773213..257c7f552e 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include #include @@ -25,19 +27,17 @@ using Slic3r::GUI::Config::Version; using Slic3r::GUI::Config::Snapshot; using Slic3r::GUI::Config::SnapshotDB; -// XXX: Prevent incomplete file downloads: download a tmp file, then move -// Delete incomplete ones on startup. namespace Slic3r { -// TODO: proper URL -// TODO: Actually, use index -static const std::string SLIC3R_VERSION_URL = "https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/e9187c3e15ceaf1a90f29b7c43cf3ccc746140f0/slic3rPE.version"; enum { SLIC3R_VERSION_BODY_MAX = 256, }; +static const char *INDEX_FILENAME = "index.idx"; +static const char *TMP_EXTENSION = ".download"; + struct Update { @@ -45,7 +45,7 @@ struct Update fs::path target; Version version; - Update(const fs::path &source, fs::path &&target, const Version &version) : + Update(fs::path &&source, const fs::path &target, const Version &version) : source(source), target(std::move(target)), version(version) @@ -60,9 +60,11 @@ typedef std::vector Updates; struct PresetUpdater::priv { int version_online_event; - AppConfig *app_config; - bool version_check; - bool preset_update; + std::vector index_db; + + bool enabled_version_check; + bool enabled_config_update; + std::string version_check_url; fs::path cache_path; fs::path rsrc_path; @@ -73,7 +75,11 @@ struct PresetUpdater::priv priv(int event, AppConfig *app_config); - void download(const std::set vendors) const; + void set_download_prefs(AppConfig *app_config); + bool get_file(const std::string &url, const fs::path &target_path) const; + void prune_tmps() const; + void sync_version() const; + void sync_config(const std::set vendors) const; void check_install_indices() const; Updates config_update() const; @@ -81,21 +87,62 @@ struct PresetUpdater::priv PresetUpdater::priv::priv(int event, AppConfig *app_config) : version_online_event(event), - app_config(app_config), - version_check(false), - preset_update(false), cache_path(fs::path(Slic3r::data_dir()) / "cache"), rsrc_path(fs::path(resources_dir()) / "profiles"), vendor_path(fs::path(Slic3r::data_dir()) / "vendor"), cancel(false) -{} - -void PresetUpdater::priv::download(const std::set vendors) const { - if (!version_check) { return; } + set_download_prefs(app_config); + check_install_indices(); + index_db = std::move(Index::load_db()); +} - // Download current Slic3r version - Http::get(SLIC3R_VERSION_URL) +void PresetUpdater::priv::set_download_prefs(AppConfig *app_config) +{ + enabled_version_check = app_config->get("version_check") == "1"; + version_check_url = app_config->get("version_check_url"); + enabled_config_update = app_config->get("preset_update") == "1"; +} + +bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &target_path) const +{ + std::cerr << "get_file(): " << url << " -> " << target_path << std::endl; + + // TODO: Proper caching + + bool res = false; + fs::path tmp_path = target_path; + tmp_path += TMP_EXTENSION; + + Http::get(url) + .on_progress([this](Http::Progress, bool &cancel) { + if (cancel) { cancel = true; } + }) + .on_complete([&](std::string body, unsigned http_status) { + fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc); + file.write(body.c_str(), body.size()); + fs::rename(tmp_path, target_path); + res = true; + }) + .perform_sync(); + + return res; +} + +void PresetUpdater::priv::prune_tmps() const +{ + for (fs::directory_iterator it(cache_path); it != fs::directory_iterator(); ++it) { + if (it->path().extension() == TMP_EXTENSION) { + fs::remove(it->path()); + } + } +} + +void PresetUpdater::priv::sync_version() const +{ + if (! enabled_version_check) { return; } + + Http::get(version_check_url) .size_limit(SLIC3R_VERSION_BODY_MAX) .on_progress([this](Http::Progress, bool &cancel) { cancel = this->cancel; @@ -107,27 +154,55 @@ void PresetUpdater::priv::download(const std::set vendors) const GUI::get_app()->QueueEvent(evt); }) .perform_sync(); +} - if (!preset_update) { return; } +void PresetUpdater::priv::sync_config(const std::set vendors) const +{ + std::cerr << "sync_config()" << std::endl; + + if (!enabled_config_update) { return; } // Donwload vendor preset bundles - for (const auto &vendor : vendors) { + for (const auto &index : index_db) { if (cancel) { return; } - // TODO: Proper caching + std::cerr << "Index: " << index.vendor() << std::endl; - auto target_path = cache_path / vendor.id; - target_path += ".ini"; + const auto vendor_it = vendors.find(VendorProfile(index.vendor())); + if (vendor_it == vendors.end()) { continue; } - Http::get(vendor.config_update_url) - .on_progress([this](Http::Progress, bool &cancel) { - cancel = this->cancel; - }) - .on_complete([&](std::string body, unsigned http_status) { - fs::fstream file(target_path, std::ios::out | std::ios::binary | std::ios::trunc); - file.write(body.c_str(), body.size()); - }) - .perform_sync(); + const VendorProfile &vendor = *vendor_it; + if (vendor.config_update_url.empty()) { continue; } + + // Download a fresh index + const auto idx_url = vendor.config_update_url + "/" + INDEX_FILENAME; + const auto idx_path = cache_path / (vendor.id + ".idx"); + if (! get_file(idx_url, idx_path)) { continue; } + if (cancel) { return; } + + std::cerr << "Got a new index: " << idx_path << std::endl; + + // Load the fresh index up + Index new_index; + new_index.load(idx_path); + + // See if a there's a new version to download + const auto recommended_it = new_index.recommended(); + if (recommended_it == new_index.end()) { continue; } + const auto recommended = recommended_it->config_version; + + std::cerr << "Current vendor version: " << vendor.config_version.to_string() << std::endl; + std::cerr << "Recommended version:\t" << recommended.to_string() << std::endl; + + if (vendor.config_version >= recommended) { continue; } + + // Download a fresh bundle + const auto bundle_url = (boost::format("%1%/%2%.ini") % vendor.config_update_url % recommended.to_string()).str(); + const auto bundle_path = cache_path / (vendor.id + ".ini"); + if (! get_file(bundle_url, bundle_path)) { continue; } + if (cancel) { return; } + + std::cerr << "Got a new bundle: " << bundle_path << std::endl; } } @@ -148,35 +223,11 @@ void PresetUpdater::priv::check_install_indices() const Updates PresetUpdater::priv::config_update() const { - priv::check_install_indices(); - const auto index_db = Index::load_db(); // TODO: Keep in Snapshots singleton? - Updates updates; for (const auto idx : index_db) { const auto bundle_path = vendor_path / (idx.vendor() + ".ini"); - // If the bundle doesn't exist at all, update from resources - // if (! fs::exists(bundle_path)) { - // auto path_in_rsrc = rsrc_path / (idx.vendor() + ".ini"); - - // // Otherwise load it and check for chached updates - // const auto rsrc_vp = VendorProfile::from_ini(path_in_rsrc, false); - - // const auto rsrc_ver = idx.find(rsrc_vp.config_version); - // if (rsrc_ver == idx.end()) { - // // TODO: throw - // } - - // if (fs::exists(path_in_rsrc)) { - // updates.emplace_back(bundle_path, std::move(path_in_rsrc), *rsrc_ver); - // } else { - // // XXX: ??? - // } - - // continue; - // } - if (! fs::exists(bundle_path)) { continue; } @@ -186,12 +237,12 @@ Updates PresetUpdater::priv::config_update() const const auto ver_current = idx.find(vp.config_version); if (ver_current == idx.end()) { - // TODO: throw + // TODO: throw / ignore ? } const auto recommended = idx.recommended(); if (recommended == idx.end()) { - // TODO: throw + throw std::runtime_error((boost::format("Invalid index: `%1%`") % idx.vendor()).str()); } if (! ver_current->is_current_slic3r_supported()) { @@ -202,50 +253,26 @@ Updates PresetUpdater::priv::config_update() const // Config bundle update situation auto path_in_cache = cache_path / (idx.vendor() + ".ini"); + if (! fs::exists(path_in_cache)) { + continue; + } + const auto cached_vp = VendorProfile::from_ini(path_in_cache, false); if (cached_vp.config_version == recommended->config_version) { - updates.emplace_back(bundle_path, std::move(path_in_cache), *ver_current); + updates.emplace_back(std::move(path_in_cache), bundle_path, *recommended); } else { - // XXX: ??? + // XXX: ? } } } - // Check for bundles that don't have an index - // for (fs::directory_iterator it(rsrc_path); it != fs::directory_iterator(); ++it) { - // if (it->path().extension() == ".ini") { - // const auto &path = it->path(); - // const auto vendor_id = path.stem().string(); - - // const auto needle = std::find_if(index_db.begin(), index_db.end(), [&vendor_id](const Index &idx) { - // return idx.vendor() == vendor_id; - // }); - // if (needle != index_db.end()) { - // continue; - // } - - // auto vp = VendorProfile::from_ini(path, false); - // auto path_in_data = vendor_path / path.filename(); - - // if (! fs::exists(path_in_data)) { - // Version version; - // version.config_version = vp.config_version; - // updates.emplace_back(path, std::move(path_in_data), version); - // } - // } - // } - return updates; } PresetUpdater::PresetUpdater(int version_online_event, AppConfig *app_config) : p(new priv(version_online_event, app_config)) -{ - p->preset_update = app_config->get("preset_update") == "1"; - // preset_update implies version_check: // XXX: not any more - p->version_check = p->preset_update || app_config->get("version_check") == "1"; -} +{} // Public @@ -258,8 +285,10 @@ PresetUpdater::~PresetUpdater() } } -void PresetUpdater::download(PresetBundle *preset_bundle) +void PresetUpdater::sync(AppConfig *app_config, PresetBundle *preset_bundle) { + p->set_download_prefs(app_config); + if (!p->enabled_version_check && !p->enabled_config_update) { return; } // Copy the whole vendors data for use in the background thread // Unfortunatelly as of C++11, it needs to be copied again @@ -267,12 +296,16 @@ void PresetUpdater::download(PresetBundle *preset_bundle) std::set vendors = preset_bundle->vendors; p->thread = std::move(std::thread([this, vendors]() { - this->p->download(std::move(vendors)); + this->p->prune_tmps(); + this->p->sync_version(); + this->p->sync_config(std::move(vendors)); })); } -void PresetUpdater::config_update() +void PresetUpdater::config_update(AppConfig *app_config) { + if (! p->enabled_config_update) { return; } + const auto updates = p->config_update(); if (updates.size() > 0) { const auto msg = _(L("Configuration update is available. Would you like to install it?")); @@ -298,12 +331,11 @@ void PresetUpdater::config_update() if (res == wxID_YES) { // User gave clearance, updates are go - // TODO: Comment? - SnapshotDB::singleton().take_snapshot(*p->app_config, Snapshot::SNAPSHOT_UPGRADE, ""); + SnapshotDB::singleton().take_snapshot(*app_config, Snapshot::SNAPSHOT_UPGRADE, ""); for (const auto &update : updates) { fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); - + PresetBundle bundle; bundle.load_configbundle(update.target.string(), PresetBundle::LOAD_CFGBNDLE_SYSTEM); diff --git a/xs/src/slic3r/Utils/PresetUpdater.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp index 8fd6e45289..966dd14647 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -19,9 +19,9 @@ public: PresetUpdater &operator=(const PresetUpdater &) = delete; ~PresetUpdater(); - void download(PresetBundle *preset_bundle); // XXX + void sync(AppConfig *app_config, PresetBundle *preset_bundle); - void config_update(); + void config_update(AppConfig *app_config); private: struct priv; std::unique_ptr p; diff --git a/xs/xsp/Utils_PresetUpdater.xsp b/xs/xsp/Utils_PresetUpdater.xsp index 4c1a637e49..3a4d55a01e 100644 --- a/xs/xsp/Utils_PresetUpdater.xsp +++ b/xs/xsp/Utils_PresetUpdater.xsp @@ -7,6 +7,6 @@ %name{Slic3r::PresetUpdater} class PresetUpdater { PresetUpdater(int version_online_event, AppConfig *app_config); - void download(PresetBundle* preset_bundle); - void config_update(); + void sync(AppConfig *app_config, PresetBundle* preset_bundle); + void config_update(AppConfig *app_config); }; From 6d25ed2b00447ca3b0ed48a9d0ec288ee8b24503 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 13 Apr 2018 16:15:30 +0200 Subject: [PATCH 0181/1150] Version's compatibility with Slic3r extended with pre-release compatibility check: A release Slic3r is not compatible with alpha and beta configs, a beta Slic3r is not compatible with alpha configs, but is compatible with beta configs etc. --- xs/src/slic3r/Config/Version.cpp | 120 +++++++++++++++++++++++++++++++ xs/src/slic3r/Config/Version.hpp | 2 +- xs/src/slic3r/Utils/Semver.hpp | 7 ++ 3 files changed, 128 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/Config/Version.cpp b/xs/src/slic3r/Config/Version.cpp index a80b0b6e99..8344e2822a 100644 --- a/xs/src/slic3r/Config/Version.cpp +++ b/xs/src/slic3r/Config/Version.cpp @@ -15,11 +15,131 @@ namespace Config { static boost::optional s_current_slic3r_semver = Semver::parse(SLIC3R_VERSION); +// Optimized lexicographic compare of two pre-release versions, ignoring the numeric suffix. +static int compare_prerelease(const char *p1, const char *p2) +{ + for (;;) { + char c1 = *p1 ++; + char c2 = *p2 ++; + bool a1 = std::isalpha(c1) && c1 != 0; + bool a2 = std::isalpha(c2) && c2 != 0; + if (a1) { + if (a2) { + if (c1 != c2) + return (c1 < c2) ? -1 : 1; + } else + return 1; + } else { + if (a2) + return -1; + else + return 0; + } + } + // This shall never happen. + return 0; +} + +bool Version::is_slic3r_supported(const Semver &slic3r_version) const +{ + if (! slic3r_version.in_range(min_slic3r_version, max_slic3r_version)) + return false; + // Now verify, whether the configuration pre-release status is compatible with the Slic3r's pre-release status. + // Alpha Slic3r will happily load any configuration, while beta Slic3r will ignore alpha configurations etc. + const char *prerelease_slic3r = slic3r_version.prerelease(); + const char *prerelease_config = this->config_version.prerelease(); + if (prerelease_config == nullptr) + // Released config is always supported. + return true; + else if (prerelease_slic3r == nullptr) + // Released slic3r only supports released configs. + return false; + // Compare the pre-release status of Slic3r against the config. + // If the prerelease status of slic3r is lexicographically lower or equal + // to the prerelease status of the config, accept it. + return compare_prerelease(prerelease_slic3r, prerelease_config) != 1; +} + bool Version::is_current_slic3r_supported() const { return this->is_slic3r_supported(*s_current_slic3r_semver); } +#if 0 +//TODO: This test should be moved to a unit test, once we have C++ unit tests in place. +static int version_test() +{ + Version v; + v.config_version = *Semver::parse("1.1.2"); + v.min_slic3r_version = *Semver::parse("1.38.0"); + v.max_slic3r_version = Semver::inf(); + assert(v.is_slic3r_supported(*Semver::parse("1.38.0"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.37.0-alpha"))); + // Test the prerelease status. + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0"))); + v.config_version = *Semver::parse("1.1.2-alpha"); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0"))); + v.config_version = *Semver::parse("1.1.2-alpha1"); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0"))); + v.config_version = *Semver::parse("1.1.2-beta"); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0"))); + v.config_version = *Semver::parse("1.1.2-rc"); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0"))); + v.config_version = *Semver::parse("1.1.2-rc2"); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc"))); + assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.39.0"))); + // Test the upper boundary. + v.config_version = *Semver::parse("1.1.2"); + v.max_slic3r_version = *Semver::parse("1.39.3-beta1"); + assert(v.is_slic3r_supported(*Semver::parse("1.38.0"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha1"))); + assert(! v.is_slic3r_supported(*Semver::parse("1.37.0-alpha"))); + return 0; +} +static int version_test_run = version_test(); +#endif + inline char* left_trim(char *c) { for (; *c == ' ' || *c == '\t'; ++ c); diff --git a/xs/src/slic3r/Config/Version.hpp b/xs/src/slic3r/Config/Version.hpp index c4243ca756..fb45c17eb3 100644 --- a/xs/src/slic3r/Config/Version.hpp +++ b/xs/src/slic3r/Config/Version.hpp @@ -27,7 +27,7 @@ struct Version // Single comment line. std::string comment; - bool is_slic3r_supported(const Semver &slicer_version) const { return slicer_version.in_range(min_slic3r_version, max_slic3r_version); } + bool is_slic3r_supported(const Semver &slicer_version) const; bool is_current_slic3r_supported() const; }; diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index a1f4a92e86..538a3f1443 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -77,6 +77,13 @@ public: ~Semver() { ::semver_free(&ver); } + // const accessors + int major() const { return ver.major; } + int minor() const { return ver.minor; } + int patch() const { return ver.patch; } + const char* prerelease() const { return ver.prerelease; } + const char* metadata() const { return ver.metadata; } + // Comparison bool operator<(const Semver &b) const { return ::semver_compare(ver, b.ver) == -1; } bool operator<=(const Semver &b) const { return ::semver_compare(ver, b.ver) <= 0; } From 5d363c1bb9ac2f4a2d4fae8faea3bf473ac55f34 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 13 Apr 2018 17:25:36 +0200 Subject: [PATCH 0182/1150] Removed printf debugging output --- xs/src/libslic3r/Model.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index bda49421d0..aaea863e83 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -863,7 +863,6 @@ void ModelObject::cut(coordf_t z, Model* model) const lower->add_volume(*volume); } else { TriangleMesh upper_mesh, lower_mesh; - printf("Cutting mesh patch\n"); TriangleMeshSlicer tms(&volume->mesh); tms.cut(z, &upper_mesh, &lower_mesh); From 215c2082d3bb011f5ba95cd03b8614abafb488e8 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 13 Apr 2018 18:22:06 +0200 Subject: [PATCH 0183/1150] Decorated "bed_shape" and "compatible_printers" labels --- xs/src/slic3r/GUI/OptionsGroup.cpp | 7 +++- xs/src/slic3r/GUI/OptionsGroup.hpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 62 ++++++++++++++++++++++-------- xs/src/slic3r/GUI/Tab.hpp | 2 + 4 files changed, 56 insertions(+), 17 deletions(-) diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 8e22689652..168ffcdc93 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -97,7 +97,7 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co return field; } -void OptionsGroup::append_line(const Line& line) { +void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* = nullptr*/) { //! if (line.sizer != nullptr || (line.widget != nullptr && line.full_width > 0)){ if ( (line.sizer != nullptr || line.widget != nullptr) && line.full_width){ if (line.sizer != nullptr) { @@ -150,6 +150,7 @@ void OptionsGroup::append_line(const Line& line) { if (line.widget != nullptr) { auto wgt = line.widget(parent()); grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, wxOSX ? 0 : 5); + if (colored_Label != nullptr) *colored_Label = label; return; } @@ -396,6 +397,10 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config ret = static_cast(config.opt_string(opt_key)); break; case coStrings: + if (opt_key.compare("compatible_printers") == 0){ + ret = config.option(opt_key)->values; + break; + } if (config.option(opt_key)->values.empty()) ret = text_value; else if (opt->gui_flags.compare("serialized") == 0){ diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index b5846f24d7..dd6d48f46c 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -93,7 +93,7 @@ public: /// but defining it as const means a lot of const_casts to deal with wx functions. inline wxWindow* parent() const { return m_parent; } - void append_line(const Line& line); + void append_line(const Line& line, wxStaticText** colored_Label = nullptr); Line create_single_option_line(const Option& option) const; void append_single_option_line(const Option& option) { append_line(create_single_option_line(option)); } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index a9faf4c591..4f6580f24b 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -326,6 +326,7 @@ void Tab::update_changed_ui() m_dirty_options = dirty_options; } + Freeze(); //update options "decoration" for (const auto opt_key : m_full_options_list) { @@ -347,6 +348,14 @@ void Tab::update_changed_ui() is_modified_value = false; icon = "bullet_white.png"; } + if (opt_key == "bed_shape" || opt_key == "compatible_printers") { + if (m_colored_Label != nullptr) { + m_colored_Label->SetForegroundColour(color); + m_colored_Label->Refresh(true); + } + continue; + } + Field* field = get_field(opt_key); if (field == nullptr) continue; field->m_is_nonsys_value = is_nonsys_value; @@ -358,6 +367,7 @@ void Tab::update_changed_ui() field->m_Label->Refresh(true); } } + Thaw(); wxTheApp->CallAfter([this]() { update_changed_tree_ui(); @@ -419,13 +429,20 @@ void Tab::update_sys_ui_after_sel_preset() m_sys_options.resize(0); } +void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page) +{ + if (sys_page && find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) + sys_page = false; + if (!modified_page && find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) + modified_page = true; +} + void Tab::update_changed_tree_ui() { auto cur_item = m_treectrl->GetFirstVisibleItem(); auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); while (cur_item){ auto title = m_treectrl->GetItemText(cur_item); - int i=0; for (auto page : m_pages) { if (page->title() != title) @@ -435,23 +452,20 @@ void Tab::update_changed_tree_ui() if (title == _("General")){ std::initializer_list optional_keys{ "extruders_count", "bed_shape" }; for (auto &opt_key : optional_keys) { - if (sys_page && find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) - sys_page = false; - if (!modified_page && find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) - modified_page = true; + get_sys_and_mod_flags(opt_key, sys_page, modified_page); } } + if (title == _("Dependencies")){ + get_sys_and_mod_flags("compatible_printers", sys_page, modified_page); + } for (auto group : page->m_optgroups) { - for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { - const std::string& opt_key = it->first; - if (sys_page && find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) - sys_page = false; - if (!modified_page && find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) - modified_page = true; - } if (!sys_page && modified_page) break; + for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { + const std::string& opt_key = it->first; + get_sys_and_mod_flags(opt_key, sys_page, modified_page); + } } if (sys_page) m_treectrl->SetItemTextColour(cur_item, get_sys_label_clr()); @@ -500,6 +514,14 @@ void Tab::on_back_to_initial_value() if (find(m_dirty_options.begin(), m_dirty_options.end(), "bed_shape") != m_dirty_options.end()) group->back_to_initial_value("bed_shape"); } + if (group->title == _("Profile dependencies")){ + if (find(m_dirty_options.begin(), m_dirty_options.end(), "compatible_printers") != m_dirty_options.end()) + group->back_to_initial_value("compatible_printers"); + + bool is_empty = m_config->option("compatible_printers")->values.empty(); + m_compatible_printers_checkbox->SetValue(is_empty); + is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); + } for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { const std::string& opt_key = it->first; if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) @@ -527,6 +549,14 @@ void Tab::on_back_to_sys_value() if (find(m_sys_options.begin(), m_sys_options.end(), "bed_shape") == m_sys_options.end()) group->back_to_sys_value("bed_shape"); } + if (group->title == _("Profile dependencies")){ + if (find(m_sys_options.begin(), m_sys_options.end(), "compatible_printers") == m_sys_options.end()) + group->back_to_sys_value("compatible_printers"); + + bool is_empty = m_config->option("compatible_printers")->values.empty(); + m_compatible_printers_checkbox->SetValue(is_empty); + is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); + } for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { const std::string& opt_key = it->first; if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) @@ -905,7 +935,7 @@ void TabPrint::build() line.widget = [this](wxWindow* parent){ return compatible_printers_widget(parent, &m_compatible_printers_checkbox, &m_compatible_printers_btn); }; - optgroup->append_line(line); + optgroup->append_line(line, &m_colored_Label); option = optgroup->get_option("compatible_printers_condition"); option.opt.full_width = true; @@ -1279,7 +1309,7 @@ void TabFilament::build() line.widget = [this](wxWindow* parent){ return compatible_printers_widget(parent, &m_compatible_printers_checkbox, &m_compatible_printers_btn); }; - optgroup->append_line(line); + optgroup->append_line(line, &m_colored_Label); option = optgroup->get_option("compatible_printers_condition"); option.opt.full_width = true; @@ -1376,7 +1406,7 @@ void TabPrinter::build() return sizer; }; - optgroup->append_line(line); + optgroup->append_line(line, &m_colored_Label); optgroup->append_single_option_line("max_print_height"); optgroup->append_single_option_line("z_offset"); @@ -2114,6 +2144,7 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox if ((*checkbox)->GetValue()) load_key_value("compatible_printers", std::vector {}); get_field("compatible_printers_condition")->toggle((*checkbox)->GetValue()); + update_changed_ui(); }) ); (*btn)->Bind(wxEVT_BUTTON, ([this, parent, checkbox, btn](wxCommandEvent e) @@ -2156,6 +2187,7 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox } // All printers have been made compatible with this preset. load_key_value("compatible_printers", value); + update_changed_ui(); } })); return sizer; diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 9465f86b47..c69f4285d5 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -126,6 +126,7 @@ public: DynamicPrintConfig* m_config; std::string m_nonsys_btn_icon; ogStaticText* m_parent_preset_description_line; + wxStaticText* m_colored_Label = nullptr; public: Tab() {} @@ -166,6 +167,7 @@ public: void update_changed_ui(); void update_full_options_list(); void update_sys_ui_after_sel_preset(); + void get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page); void update_changed_tree_ui(); void update_undo_buttons(); From b881ae936f7e943b2d45353fffd1a2a1291317da Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 13 Apr 2018 18:36:52 +0200 Subject: [PATCH 0184/1150] Updated preset from Jindra. --- resources/profiles/PrusaResearch.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index fa4d48cdae..de23bf0ad3 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -597,6 +597,7 @@ temperature = 255 [filament:*FLEX*] inherits = *common* +bed_temperature = 50 bridge_fan_speed = 100 compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1 cooling = 0 @@ -947,6 +948,7 @@ variable_layer_height = 0 [printer:Original Prusa i3 MK2] inherits = *common* +default_print_profile = 0.15mm OPTIMAL [printer:Original Prusa i3 MK2 0.25 nozzle] inherits = *common* @@ -965,6 +967,7 @@ max_layer_height = 0.35 min_layer_height = 0.1 nozzle_diameter = 0.6 printer_variant = 0.6 +default_print_profile = 0.20mm NORMAL 0.6 nozzle [printer:Original Prusa i3 MK2 MM Single Mode] inherits = *mm-single* @@ -973,6 +976,7 @@ inherits = *mm-single* inherits = *mm-single* nozzle_diameter = 0.6 printer_variant = 0.6 +default_print_profile = 0.20mm NORMAL 0.6 nozzle [printer:Original Prusa i3 MK2 MultiMaterial] inherits = *mm-multi* From c18b28e27ca4acf68482f981620632d86b1ac356 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 16 Apr 2018 11:03:08 +0200 Subject: [PATCH 0185/1150] Implemented caching of often rendered bitmaps on the Tab UI. --- xs/src/slic3r/GUI/Field.cpp | 8 ++--- xs/src/slic3r/GUI/Field.hpp | 32 +++++++++++++++++-- xs/src/slic3r/GUI/OptionsGroup.cpp | 4 +-- xs/src/slic3r/GUI/OptionsGroup.hpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 50 +++++++++++++++--------------- xs/src/slic3r/GUI/Tab.hpp | 19 +++++++++--- 6 files changed, 76 insertions(+), 39 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index c68b2304c0..a32943da05 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -26,16 +26,16 @@ namespace Slic3r { namespace GUI { m_Undo_btn->SetBackgroundColour(color); m_Undo_to_sys_btn->SetBackgroundColour(color); } - m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); +// m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); BUILD(); } - void Field::set_nonsys_btn_icon(const std::string& icon){ - m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(icon)), wxBITMAP_TYPE_PNG)); - } +// void Field::set_nonsys_btn_icon(const wxBitmap& icon){ +// m_Undo_to_sys_btn->SetBitmap(icon); +// } void Field::on_kill_focus(wxEvent& event) { // Without this, there will be nasty focus bugs on Windows. diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index cdc7c0d812..2b2646b7cb 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -91,8 +91,6 @@ public: virtual void disable() = 0; wxStaticText* m_Label = nullptr; - wxButton* m_Undo_btn = nullptr; - wxButton* m_Undo_to_sys_btn = nullptr; /// Fires the enable or disable function, based on the input. inline void toggle(bool en) { en ? enable() : disable(); } @@ -100,7 +98,7 @@ public: virtual wxString get_tooltip_text(const wxString& default_string); // set icon to "UndoToSystemValue" button according to an inheritance of preset - void set_nonsys_btn_icon(const std::string& icon); +// void set_nonsys_btn_icon(const wxBitmap& icon); Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {}; Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {}; @@ -120,6 +118,34 @@ public: p->PostInitialize(); return std::move(p); //!p; } + + bool set_undo_bitmap(const wxBitmap *bmp) { + if (m_undo_bitmap != bmp) { + m_undo_bitmap = bmp; + m_Undo_btn->SetBitmap(*bmp); + return true; + } + return false; + } + + bool set_undo_to_sys_bitmap(const wxBitmap *bmp) { + if (m_undo_to_sys_bitmap != bmp) { + m_undo_to_sys_bitmap = bmp; + m_Undo_to_sys_btn->SetBitmap(*bmp); + return true; + } + return false; + } + +protected: + wxButton* m_Undo_btn = nullptr; + // Bitmap for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. + const wxBitmap* m_undo_bitmap = nullptr; + wxButton* m_Undo_to_sys_btn = nullptr; + // Bitmap for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. + const wxBitmap* m_undo_to_sys_bitmap = nullptr; + + friend class OptionsGroup; }; /// Convenience function, accepts a const reference to t_field and checks to see whether diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 168ffcdc93..c71dd5ba6b 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -90,8 +90,8 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co field->m_Undo_btn->Hide(); field->m_Undo_to_sys_btn->Hide(); } - if (nonsys_btn_icon != nullptr) - field->set_nonsys_btn_icon(nonsys_btn_icon()); +// if (nonsys_btn_icon != nullptr) +// field->set_nonsys_btn_icon(*nonsys_btn_icon); // assign function objects for callbacks, etc. return field; diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index dd6d48f46c..92ebb44881 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -86,7 +86,7 @@ public: wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; - std::function nonsys_btn_icon{ nullptr }; +// std::function nonsys_btn_icon{ nullptr }; /// Returns a copy of the pointer of the parent wxWindow. /// Accessor function is because users are not allowed to change the parent diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index cc4b18c7c6..f2511708b5 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -88,9 +88,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) if (wxMSW) m_btn_delete_preset->SetBackgroundColour(color); m_show_incompatible_presets = false; - m_bmp_show_incompatible_presets = new wxBitmap(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG); - m_bmp_hide_incompatible_presets = new wxBitmap(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG); - m_btn_hide_incompatible_presets = new wxBitmapButton(panel, wxID_ANY, *m_bmp_hide_incompatible_presets, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); + m_bmp_show_incompatible_presets.LoadFile(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG); + m_bmp_hide_incompatible_presets.LoadFile(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG); + m_btn_hide_incompatible_presets = new wxBitmapButton(panel, wxID_ANY, m_bmp_hide_incompatible_presets, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); if (wxMSW) m_btn_hide_incompatible_presets->SetBackgroundColour(color); m_btn_save_preset->SetToolTip(_(L("Save current ")) + m_title); @@ -103,9 +103,16 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_undo_btn->SetBackgroundColour(color); m_undo_to_sys_btn->SetBackgroundColour(color); } - m_undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); + // Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field. + m_bmp_value_lock .LoadFile(from_u8(var("sys_lock.png")), wxBITMAP_TYPE_PNG); + m_bmp_value_unlock .LoadFile(from_u8(var("sys_unlock.png")), wxBITMAP_TYPE_PNG); + m_bmp_non_system = &m_bmp_white_bullet; + // Bitmaps to be shown on the "Undo user changes" button next to each input field. + m_bmp_value_revert .LoadFile(from_u8(var("action_undo.png")), wxBITMAP_TYPE_PNG); + m_bmp_white_bullet .LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG); + m_undo_btn->SetBitmap(m_bmp_white_bullet); m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); - m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); + m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet); m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); m_hsizer = new wxBoxSizer(wxHORIZONTAL); @@ -204,8 +211,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) void Tab::load_initial_data() { m_config = &m_presets->get_edited_preset().config; - m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ? - "bullet_white.png" : "sys_unlock.png"; + m_bmp_non_system = m_presets->get_selected_preset_parent() ? &m_bmp_value_unlock : &m_bmp_white_bullet; } PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages/* = false*/) @@ -334,12 +340,12 @@ void Tab::update_changed_ui() { bool is_nonsys_value = false; bool is_modified_value = true; - std::string sys_icon = "sys_lock.png"; - std::string icon = "action_undo.png"; + const wxBitmap *sys_icon = &m_bmp_value_lock; + const wxBitmap *icon = &m_bmp_value_revert; wxColour color = get_sys_label_clr(); if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { is_nonsys_value = true; - sys_icon = m_nonsys_btn_icon; + sys_icon = m_bmp_non_system; if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); else @@ -348,7 +354,7 @@ void Tab::update_changed_ui() if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) { is_modified_value = false; - icon = "bullet_white.png"; + icon = &m_bmp_white_bullet; } if (opt_key == "bed_shape" || opt_key == "compatible_printers") { if (m_colored_Label != nullptr) { @@ -362,8 +368,8 @@ void Tab::update_changed_ui() if (field == nullptr) continue; field->m_is_nonsys_value = is_nonsys_value; field->m_is_modified_value = is_modified_value; - field->m_Undo_btn->SetBitmap(wxBitmap(from_u8(var(icon)), wxBITMAP_TYPE_PNG)); - field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(sys_icon)), wxBITMAP_TYPE_PNG)); + field->set_undo_bitmap(icon); + field->set_undo_to_sys_bitmap(sys_icon); if (field->m_Label != nullptr){ field->m_Label->SetForegroundColour(color); field->m_Label->Refresh(true); @@ -420,7 +426,7 @@ void Tab::update_sys_ui_after_sel_preset() for (const auto opt_key : m_full_options_list){ Field* field = get_field(opt_key); if (field != nullptr){ - field->m_Undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(m_nonsys_btn_icon)), wxBITMAP_TYPE_PNG)); + field->set_undo_to_sys_bitmap(m_bmp_non_system); field->m_is_nonsys_value = true; if (field->m_Label != nullptr){ field->m_Label->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); @@ -493,11 +499,8 @@ void Tab::update_changed_tree_ui() void Tab::update_undo_buttons() { - const std::string& undo_icon = !m_is_modified_values ? "bullet_white.png" : "action_undo.png"; - const std::string& undo_to_sys_icon = m_is_nonsys_values ? m_nonsys_btn_icon : "sys_lock.png"; - - m_undo_btn->SetBitmap(wxBitmap(from_u8(var(undo_icon)), wxBITMAP_TYPE_PNG)); - m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(undo_to_sys_icon)), wxBITMAP_TYPE_PNG)); + m_undo_btn->SetBitmap(m_is_modified_values ? m_bmp_value_revert : m_bmp_white_bullet); + m_undo_to_sys_btn->SetBitmap(m_is_nonsys_values ? *m_bmp_non_system : m_bmp_value_lock); } void Tab::on_back_to_initial_value() @@ -1853,8 +1856,7 @@ void Tab::load_current_preset() on_preset_loaded(); // Reload preset pages with the new configuration values. reload_config(); - const Preset* parent = m_presets->get_selected_preset_parent(); - m_nonsys_btn_icon = parent == nullptr ? "bullet_white.png" : "sys_unlock.png"; + m_bmp_non_system = m_presets->get_selected_preset_parent() ? &m_bmp_value_unlock : &m_bmp_white_bullet; // use CallAfter because some field triggers schedule on_change calls using CallAfter, // and we don't want them to be called after this update_dirty() as they would mark the @@ -2142,7 +2144,7 @@ void Tab::toggle_show_hide_incompatible() void Tab::update_show_hide_incompatible_button() { m_btn_hide_incompatible_presets->SetBitmap(m_show_incompatible_presets ? - *m_bmp_show_incompatible_presets : *m_bmp_hide_incompatible_presets); + m_bmp_show_incompatible_presets : m_bmp_hide_incompatible_presets); m_btn_hide_incompatible_presets->SetToolTip(m_show_incompatible_presets ? "Both compatible an incompatible presets are shown. Click to hide presets not compatible with the current printer." : "Only compatible presets are shown. Click to show both the presets compatible and not compatible with the current printer."); @@ -2460,9 +2462,7 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la return static_cast(GetParent())->m_presets->get_selected_preset_parent() != nullptr; }; - optgroup->nonsys_btn_icon = [this](){ - return static_cast(GetParent())->m_nonsys_btn_icon; - }; +// optgroup->nonsys_btn_icon = m_bmp_non_system; vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10); m_optgroups.push_back(optgroup); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index f9ee4f3639..cb622582f1 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -85,8 +85,6 @@ protected: wxBitmapComboBox* m_presets_choice; wxBitmapButton* m_btn_save_preset; wxBitmapButton* m_btn_delete_preset; - wxBitmap* m_bmp_show_incompatible_presets; - wxBitmap* m_bmp_hide_incompatible_presets; wxBitmapButton* m_btn_hide_incompatible_presets; wxBoxSizer* m_hsizer; wxBoxSizer* m_left_sizer; @@ -95,11 +93,25 @@ protected: wxCheckBox* m_compatible_printers_checkbox; wxButton* m_compatible_printers_btn; wxButton* m_undo_btn; - wxButton* m_undo_to_sys_btn; + wxButton* m_undo_to_sys_btn; wxComboCtrl* m_cc_presets_choice; wxDataViewTreeCtrl* m_presetctrl; wxImageList* m_preset_icons; + // Cached bitmaps. + // A "flag" icon to be displayned next to the preset name in the Tab's combo box. + wxBitmap m_bmp_show_incompatible_presets; + wxBitmap m_bmp_hide_incompatible_presets; + // Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field. + wxBitmap m_bmp_value_lock; + wxBitmap m_bmp_value_unlock; + wxBitmap m_bmp_white_bullet; + // The following bitmap points to either m_bmp_value_unlock or m_bmp_white_bullet, depending on whether the current preset has a parent preset. + wxBitmap *m_bmp_non_system; + // Bitmaps to be shown on the "Undo user changes" button next to each input field. + wxBitmap m_bmp_value_revert; + wxBitmap m_bmp_value_unmodified; + int m_icon_count; std::map m_icon_index; // Map from an icon file name to its index std::vector m_pages; @@ -124,7 +136,6 @@ public: bool m_show_btn_incompatible_presets = false; PresetCollection* m_presets; DynamicPrintConfig* m_config; - std::string m_nonsys_btn_icon; ogStaticText* m_parent_preset_description_line; wxStaticText* m_colored_Label = nullptr; From 2726267748b7ff23665794db121db2484fbc3060 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 16 Apr 2018 11:47:35 +0200 Subject: [PATCH 0186/1150] Bugfix: validation of equal layering rejected even some valid configurations --- xs/src/libslic3r/Print.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index dcece7a9ba..c19c97faea 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -598,6 +598,12 @@ std::string Print::validate() const if (! this->config.use_relative_e_distances) return "The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1)."; SlicingParameters slicing_params0 = this->objects.front()->slicing_parameters(); + + const PrintObject* most_layered_object = this->objects.front(); // object with highest layer_height_profile.size() encountered so far + for (const auto* object : objects) + if (object->layer_height_profile.size() > most_layered_object->layer_height_profile.size()) + most_layered_object = object; + for (PrintObject *object : this->objects) { SlicingParameters slicing_params = object->slicing_parameters(); if (std::abs(slicing_params.first_print_layer_height - slicing_params0.first_print_layer_height) > EPSILON || @@ -614,12 +620,15 @@ std::string Print::validate() const object->layer_height_profile_valid = was_layer_height_profile_valid; if ( this->config.variable_layer_height ) { - PrintObject* first_object = this->objects.front(); int i = 0; - while ( i < first_object->layer_height_profile.size() && i < object->layer_height_profile.size() ) { - if (std::abs(first_object->layer_height_profile[i] - object->layer_height_profile[i]) > EPSILON ) + while ( i < object->layer_height_profile.size() ) { + if (std::abs(most_layered_object->layer_height_profile[i] - object->layer_height_profile[i]) > EPSILON) return "The Wipe tower is only supported if all objects have the same layer height profile"; ++i; + if (i == object->layer_height_profile.size()-2) // this element contains the objects max z, if the other object is taller, + // it does not have to match - we will step over it + if (most_layered_object->layer_height_profile[i] > object->layer_height_profile[i]) + ++i; } } From 5d3912698963d30edf0beada8b5e3b6182a81d73 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 16 Apr 2018 13:43:01 +0200 Subject: [PATCH 0187/1150] Changes to performance. --- xs/src/slic3r/GUI/Tab.cpp | 45 ++++++++++++++++++++++++++++----------- xs/src/slic3r/GUI/Tab.hpp | 3 ++- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index cc4b18c7c6..7fd50d5aa7 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -268,6 +268,8 @@ void add_correct_opts_to_sys_options(const std::string &opt_key, std::vectorcurrent_dirty_options(); if (name() == "printer"){ @@ -504,6 +506,8 @@ void Tab::on_back_to_initial_value() { if (!m_is_modified_values) return; + m_postpone_update_ui = true; + auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); for (auto page : m_pages) if (page->title() == selection) { @@ -513,16 +517,21 @@ void Tab::on_back_to_initial_value() group->back_to_initial_value("extruders_count"); } if (group->title == _("Size and coordinates")){ - if (find(m_dirty_options.begin(), m_dirty_options.end(), "bed_shape") != m_dirty_options.end()) + if (find(m_dirty_options.begin(), m_dirty_options.end(), "bed_shape") != m_dirty_options.end()){ group->back_to_initial_value("bed_shape"); + load_key_value("bed_shape", true/*some value*/, true); + } + } if (group->title == _("Profile dependencies")){ - if (find(m_dirty_options.begin(), m_dirty_options.end(), "compatible_printers") != m_dirty_options.end()) + if (find(m_dirty_options.begin(), m_dirty_options.end(), "compatible_printers") != m_dirty_options.end()){ group->back_to_initial_value("compatible_printers"); + load_key_value("compatible_printers", true/*some value*/, true); - bool is_empty = m_config->option("compatible_printers")->values.empty(); - m_compatible_printers_checkbox->SetValue(is_empty); - is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); + bool is_empty = m_config->option("compatible_printers")->values.empty(); + m_compatible_printers_checkbox->SetValue(is_empty); + is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); + } } for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { const std::string& opt_key = it->first; @@ -532,6 +541,8 @@ void Tab::on_back_to_initial_value() } break; } + + m_postpone_update_ui = false; update_changed_ui(); } @@ -539,6 +550,8 @@ void Tab::on_back_to_sys_value() { if (!m_is_nonsys_values) return; + m_postpone_update_ui = true; + auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); for (auto page : m_pages) if (page->title() == selection) { @@ -548,16 +561,20 @@ void Tab::on_back_to_sys_value() group->back_to_sys_value("extruders_count"); } if (group->title == _("Size and coordinates")){ - if (find(m_sys_options.begin(), m_sys_options.end(), "bed_shape") == m_sys_options.end()) + if (find(m_sys_options.begin(), m_sys_options.end(), "bed_shape") == m_sys_options.end()){ group->back_to_sys_value("bed_shape"); + load_key_value("bed_shape", true/*some value*/, true); + } } if (group->title == _("Profile dependencies")){ - if (find(m_sys_options.begin(), m_sys_options.end(), "compatible_printers") == m_sys_options.end()) + if (find(m_sys_options.begin(), m_sys_options.end(), "compatible_printers") == m_sys_options.end()){ group->back_to_sys_value("compatible_printers"); + load_key_value("compatible_printers", true/*some value*/, true); - bool is_empty = m_config->option("compatible_printers")->values.empty(); - m_compatible_printers_checkbox->SetValue(is_empty); - is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); + bool is_empty = m_config->option("compatible_printers")->values.empty(); + m_compatible_printers_checkbox->SetValue(is_empty); + is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); + } } for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { const std::string& opt_key = it->first; @@ -567,6 +584,8 @@ void Tab::on_back_to_sys_value() } break; } + + m_postpone_update_ui = false; update_changed_ui(); } @@ -636,9 +655,11 @@ bool Tab::set_value(const t_config_option_key& opt_key, const boost::any& value) // To be called by custom widgets, load a value into a config, // update the preset selection boxes (the dirty flags) -void Tab::load_key_value(const std::string& opt_key, const boost::any& value) +// If value is saved before calling this function, put saved_value = true, +// and value can be some random value because in this case it will not been used +void Tab::load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value /*= false*/) { - change_opt_value(*m_config, opt_key, value); + if (!saved_value) change_opt_value(*m_config, opt_key, value); // Mark the print & filament enabled if they are compatible with the currently selected preset. if (opt_key.compare("compatible_printers") == 0) { m_preset_bundle->update_compatible_with_printer(0); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index f9ee4f3639..f7eba61862 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -118,6 +118,7 @@ protected: bool m_is_modified_values{ false }; bool m_is_nonsys_values{ true }; + bool m_postpone_update_ui {false}; public: PresetBundle* m_preset_bundle; @@ -153,7 +154,7 @@ public: wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn); void update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible); - void load_key_value(const std::string& opt_key, const boost::any& value); + void load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value = false); void reload_compatible_printers_widget(); void OnTreeSelChange(wxTreeEvent& event); From a154fd34eef23353ced21643b2de43a360c037e2 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 16 Apr 2018 14:26:57 +0200 Subject: [PATCH 0188/1150] Added parameter extra_loading_move, prevented high feedrate moves during loading --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 19 ++++++++++++++----- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 6 ++++-- xs/src/libslic3r/Print.cpp | 4 +++- xs/src/libslic3r/PrintConfig.cpp | 9 +++++++++ xs/src/libslic3r/PrintConfig.hpp | 2 ++ xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 1 + 7 files changed, 34 insertions(+), 9 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index ad7d91c50d..bdafdfa23b 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -792,9 +792,17 @@ void WipeTowerPrusaMM::toolchange_Unload( float xdist = std::abs(oldx-turning_point); float edist = -(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42); writer.suppress_preview() - .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ) // fixed speed after ramming - .load_move_x(oldx ,edist , 60.f * std::hypot(xdist,edist)/std::abs(edist) * m_filpar[m_current_tool].unloading_speed ) - .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * m_filpar[m_current_tool].unloading_speed*0.55f ) + .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ); // fixed speed after ramming + + // now an ugly hack: unload the filament with a check that the x speed is 50 mm/s + const float speed = m_filpar[m_current_tool].unloading_speed; + xdist = std::min(xdist, std::abs( 50 * edist / speed )); + const float feedrate = std::abs( std::hypot(edist, xdist) / ((edist / speed) / 60.f)); + writer.load_move_x(writer.x() + (m_left_to_right ? -1.f : 1.f) * xdist ,edist, feedrate ); + xdist = std::abs(oldx-turning_point); // recover old value of xdist + + + writer.load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * m_filpar[m_current_tool].unloading_speed*0.55f ) .load_move_x(oldx ,-12 , 60.f * std::hypot(xdist,12)/12 * m_filpar[m_current_tool].unloading_speed*0.35f ) .resume_preview(); @@ -876,11 +884,12 @@ void WipeTowerPrusaMM::toolchange_Load( float loading_speed = m_filpar[m_current_tool].loading_speed; // mm/s in e axis float turning_point = ( oldx-xl < xr-oldx ? xr : xl ); float dist = std::abs(oldx-turning_point); - float edist = m_parking_pos_retraction-50-2; // loading is 2mm shorter that previous retraction, 50mm reserved for acceleration/deceleration + //float edist = m_parking_pos_retraction-50-2; // loading is 2mm shorter that previous retraction, 50mm reserved for acceleration/deceleration + float edist = m_parking_pos_retraction-50+m_extra_loading_move; // 50mm reserved for acceleration/deceleration writer.append("; CP TOOLCHANGE LOAD\n") .suppress_preview() .load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Acceleration - .load_move_x(oldx,edist,60*std::hypot(dist,edist)/edist * loading_speed) // Fast phase + .load_move_x(oldx,edist,std::abs( 60*std::hypot(dist,edist)/edist * loading_speed) ) // Fast phase .load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Slowing down .load_move_x(oldx, 10, 60*std::hypot(dist,10.f)/10.f * loading_speed*0.1f) // Super slow .resume_preview(); diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 175de0276e..daaabdfc09 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -43,8 +43,8 @@ public: // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm WipeTowerPrusaMM(float x, float y, float width, float rotation_angle, float cooling_tube_retraction, - float cooling_tube_length, float parking_pos_retraction, float bridging, const std::vector& wiping_matrix, - unsigned int initial_tool) : + float cooling_tube_length, float parking_pos_retraction, float extra_loading_move, float bridging, + const std::vector& wiping_matrix, unsigned int initial_tool) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), m_wipe_tower_rotation_angle(rotation_angle), @@ -54,6 +54,7 @@ public: m_cooling_tube_retraction(cooling_tube_retraction), m_cooling_tube_length(cooling_tube_length), m_parking_pos_retraction(parking_pos_retraction), + m_extra_loading_move(extra_loading_move), m_bridging(bridging), m_current_tool(initial_tool) { @@ -197,6 +198,7 @@ private: float m_cooling_tube_retraction = 0.f; float m_cooling_tube_length = 0.f; float m_parking_pos_retraction = 0.f; + float m_extra_loading_move = 0.f; float m_bridging = 0.f; bool m_adhesion = true; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index c19c97faea..c12cb64cd1 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -202,6 +202,7 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_width.value), float(this->config.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), - float(this->config.wipe_tower_bridging), wiping_volumes, m_tool_ordering.first_extruder()); + float(this->config.extra_loading_move.value), float(this->config.wipe_tower_bridging), wiping_volumes, + m_tool_ordering.first_extruder()); //wipe_tower.set_retract(); //wipe_tower.set_zhop(); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 1e7e0bacc6..75129f4fdf 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1045,6 +1045,15 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(92.f); + def = this->add("extra_loading_move", coFloat); + def->label = L("Extra loading distance"); + def->tooltip = L("When set to zero, the distance the filament is moved from parking position during load " + "is exactly the same as it was moved back during unload. When positive, it is loaded further, " + " if negative, the loading move is shorter than unloading. "); + def->sidetext = L("mm"); + def->cli = "extra_loading_move=f"; + def->default_value = new ConfigOptionFloat(-2.f); + def = this->add("perimeter_acceleration", coFloat); def->label = L("Perimeters"); def->tooltip = L("This is the acceleration your printer will use for perimeters. " diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 967a873107..62d8c7101e 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -506,6 +506,7 @@ public: ConfigOptionFloat cooling_tube_retraction; ConfigOptionFloat cooling_tube_length; ConfigOptionFloat parking_pos_retraction; + ConfigOptionFloat extra_loading_move; std::string get_extrusion_axis() const @@ -564,6 +565,7 @@ protected: OPT_PTR(cooling_tube_retraction); OPT_PTR(cooling_tube_length); OPT_PTR(parking_pos_retraction); + OPT_PTR(extra_loading_move); } }; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index d48c9bf8f5..e4a4b20936 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -226,7 +226,7 @@ const std::vector& Preset::printer_options() "octoprint_host", "octoprint_apikey", "octoprint_cafile", "use_firmware_retraction", "use_volumetric_e", "variable_layer_height", "single_extruder_multi_material", "start_gcode", "end_gcode", "before_layer_gcode", "layer_gcode", "toolchange_gcode", "between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction", - "cooling_tube_length", "parking_pos_retraction", "max_print_height", "default_print_profile", "inherits", + "cooling_tube_length", "parking_pos_retraction", "extra_loading_move", "max_print_height", "default_print_profile", "inherits", }; s_opts.insert(s_opts.end(), Preset::nozzle_options().begin(), Preset::nozzle_options().end()); } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index cc4b18c7c6..8ffe273512 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1743,6 +1743,7 @@ void TabPrinter::build_extruder_pages(){ optgroup->append_single_option_line("cooling_tube_retraction"); optgroup->append_single_option_line("cooling_tube_length"); optgroup->append_single_option_line("parking_pos_retraction"); + optgroup->append_single_option_line("extra_loading_move"); m_pages.insert(m_pages.begin()+1,page); } } From c733e3151b2d15fdf1507c8417c2a96898d1d019 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 16 Apr 2018 16:52:11 +0200 Subject: [PATCH 0189/1150] Updating: Detect legacy datadir, remove conflicting presets --- lib/Slic3r/GUI.pm | 34 ++---- xs/src/libslic3r/libslic3r.h | 2 +- xs/src/slic3r/Config/Snapshot.hpp | 2 +- xs/src/slic3r/GUI/AppConfig.cpp | 5 +- xs/src/slic3r/GUI/AppConfig.hpp | 6 +- xs/src/slic3r/GUI/ConfigWizard.cpp | 120 +++++++++++++++------ xs/src/slic3r/GUI/ConfigWizard.hpp | 3 +- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 24 ++++- xs/src/slic3r/GUI/GUI.cpp | 48 +++++++-- xs/src/slic3r/GUI/GUI.hpp | 9 +- xs/src/slic3r/Utils/PresetUpdater.cpp | 60 +++++++---- xs/src/slic3r/Utils/PresetUpdater.hpp | 3 +- xs/src/slic3r/Utils/Semver.hpp | 2 - xs/xsp/GUI.xsp | 7 +- xs/xsp/my.map | 1 - xs/xsp/typemap.xspt | 2 + 16 files changed, 232 insertions(+), 96 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 40cfcad896..473fc6b90b 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -95,14 +95,15 @@ sub OnInit { warn $@ . "\n"; fatal_error(undef, $@); } - my $run_wizard = ! $self->{app_config}->exists; + my $app_conf_exists = $self->{app_config}->exists; # load settings - $self->{app_config}->load if ! $run_wizard; + $self->{app_config}->load if $app_conf_exists; $self->{app_config}->set('version', $Slic3r::VERSION); $self->{app_config}->save; # my $version_check = $self->{app_config}->get('version_check'); $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT, $self->{app_config}); + Slic3r::GUI::set_preset_updater($self->{preset_updater}); eval { $self->{preset_updater}->config_update($self->{app_config}) }; if ($@) { warn $@ . "\n"; @@ -120,8 +121,6 @@ sub OnInit { warn $@ . "\n"; show_error(undef, $@); } - # TODO: check previously downloaded updates - $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only; Slic3r::GUI::set_preset_bundle($self->{preset_bundle}); @@ -148,16 +147,8 @@ sub OnInit { # On OSX the UI was not initialized correctly if the wizard was called # before the UI was up and running. $self->CallAfter(sub { - # XXX: recreate_GUI ??? - # if ($slic3r_update) { - # # TODO - # } - # XXX: ? - if ($run_wizard) { - # Run the config wizard, don't offer the "reset user profile" checkbox. - Slic3r::GUI::config_wizard(1); - } - + Slic3r::GUI::config_wizard_startup($app_conf_exists); + # TODO: call periodically? $self->{preset_updater}->sync($self->{app_config}, $self->{preset_bundle}); }); @@ -209,15 +200,12 @@ sub recreate_GUI{ $self->{app_config}->save if $self->{app_config}->dirty; }); - my $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only; - if ($run_wizard) { - # On OSX the UI was not initialized correctly if the wizard was called - # before the UI was up and running. - $self->CallAfter(sub { - # Run the config wizard, don't offer the "reset user profile" checkbox. - Slic3r::GUI::config_wizard(1); - }); - } + # On OSX the UI was not initialized correctly if the wizard was called + # before the UI was up and running. + $self->CallAfter(sub { + # Run the config wizard, don't offer the "reset user profile" checkbox. + Slic3r::GUI::config_wizard_startup(1); + }); } sub system_info { diff --git a/xs/src/libslic3r/libslic3r.h b/xs/src/libslic3r/libslic3r.h index 0f192c37c6..4aef4d5c16 100644 --- a/xs/src/libslic3r/libslic3r.h +++ b/xs/src/libslic3r/libslic3r.h @@ -14,7 +14,7 @@ #include #define SLIC3R_FORK_NAME "Slic3r Prusa Edition" -#define SLIC3R_VERSION "1.39.0" +#define SLIC3R_VERSION "1.40.0" #define SLIC3R_BUILD "UNKNOWN" typedef int32_t coord_t; diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp index a7b8a5aa5d..584a374005 100644 --- a/xs/src/slic3r/Config/Snapshot.hpp +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -97,7 +97,7 @@ public: // Create a snapshot directory, copy the vendor config bundles, user print/filament/printer profiles, // create an index. - const Snapshot& take_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment); + const Snapshot& take_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment = ""); void restore_snapshot(const std::string &id, AppConfig &app_config); void restore_snapshot(const Snapshot &snapshot, AppConfig &app_config); diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index d0f2f1019c..5104078b13 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -98,6 +98,10 @@ void AppConfig::load() } } + // Figure out if datadir has legacy presets + auto ini_ver = Semver::parse(get("version")); + m_legacy_datadir = ini_ver ? *ini_ver < Semver(1, 40, 0) : true; + // Override missing or keys with their defaults. this->set_defaults(); m_dirty = false; @@ -240,7 +244,6 @@ bool AppConfig::slic3r_update_avail() const Semver AppConfig::get_slic3r_version() const { - // TODO: move to Semver c-tor (???) auto res = Semver::parse(get("version")); if (! res) { throw std::runtime_error(std::string("Could not parse Slic3r version string in application config.")); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index ffda083ec3..88ba0a6623 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -13,7 +13,7 @@ namespace Slic3r { class AppConfig { public: - AppConfig() : m_dirty(false) { this->reset(); } + AppConfig() : m_dirty(false), m_legacy_datadir(false) { this->reset(); } // Clear and reset to defaults. void reset(); @@ -98,6 +98,8 @@ public: // Get the default config path from Slic3r::data_dir(). static std::string config_path(); + + bool legacy_datadir() const { return m_legacy_datadir; } // Does the config file exist? static bool exists(); @@ -109,6 +111,8 @@ private: VendorMap m_vendors; // Has any value been modified since the config.ini has been last saved or loaded? bool m_dirty; + // Whether the existing version is before system profiles & configuration updating + bool m_legacy_datadir; }; }; // namespace Slic3r diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 5b49fc0258..a059d234b4 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -1,8 +1,8 @@ #include "ConfigWizard_private.hpp" -#include // XXX #include #include +#include #include #include @@ -17,6 +17,7 @@ #include "GUI.hpp" #include "slic3r/Utils/PresetUpdater.hpp" +// TODO: Wizard vs Assistant namespace Slic3r { namespace GUI { @@ -54,48 +55,80 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, cons const auto vendor_id = vendor.id; const auto &models = vendor.models; + auto *sizer = new wxBoxSizer(wxVERTICAL); + auto *printer_grid = new wxFlexGridSizer(models.size(), 0, 20); printer_grid->SetFlexibleDirection(wxVERTICAL); - SetSizer(printer_grid); + sizer->Add(printer_grid); auto namefont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); namefont.SetWeight(wxFONTWEIGHT_BOLD); for (const auto &model : models) { auto *panel = new wxPanel(this); - auto *sizer = new wxBoxSizer(wxVERTICAL); - panel->SetSizer(sizer); + auto *col_sizer = new wxBoxSizer(wxVERTICAL); + panel->SetSizer(col_sizer); auto *title = new wxStaticText(panel, wxID_ANY, model.name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); title->SetFont(namefont); - sizer->Add(title, 0, wxBOTTOM, 3); + col_sizer->Add(title, 0, wxBOTTOM, 3); auto bitmap_file = wxString::Format("printers/%s_%s.png", vendor.id, model.id); wxBitmap bitmap(GUI::from_u8(Slic3r::var(bitmap_file.ToStdString())), wxBITMAP_TYPE_PNG); auto *bitmap_widget = new wxStaticBitmap(panel, wxID_ANY, bitmap); - sizer->Add(bitmap_widget, 0, wxBOTTOM, 3); + col_sizer->Add(bitmap_widget, 0, wxBOTTOM, 3); - sizer->AddSpacer(20); + col_sizer->AddSpacer(20); const auto model_id = model.id; for (const auto &variant : model.variants) { - const auto variant_name = variant.name; - auto *cbox = new wxCheckBox(panel, wxID_ANY, wxString::Format("%s %s %s", variant.name, _(L("mm")), _(L("nozzle")))); - bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant_name); + const auto label = wxString::Format("%s %s %s", variant.name, _(L("mm")), _(L("nozzle"))); + auto *cbox = new Checkbox(panel, label, model_id, variant.name); + const size_t idx = cboxes.size(); + cboxes.push_back(cbox); + bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant.name); variants_checked += enabled; cbox->SetValue(enabled); - sizer->Add(cbox, 0, wxBOTTOM, 3); - cbox->Bind(wxEVT_CHECKBOX, [=](wxCommandEvent &event) { - this->variants_checked += event.IsChecked() ? 1 : -1; - PrinterPickerEvent evt(EVT_PRINTER_PICK, this->GetId(), std::move(vendor_id), std::move(model_id), std::move(variant_name), event.IsChecked()); - this->AddPendingEvent(evt); + col_sizer->Add(cbox, 0, wxBOTTOM, 3); + cbox->Bind(wxEVT_CHECKBOX, [this, idx](wxCommandEvent &event) { + if (idx >= this->cboxes.size()) { return; } + this->on_checkbox(this->cboxes[idx], event.IsChecked()); }); } printer_grid->Add(panel); } + auto *all_none_sizer = new wxBoxSizer(wxHORIZONTAL); + auto *sel_all = new wxButton(this, wxID_ANY, _(L("Select all"))); + auto *sel_none = new wxButton(this, wxID_ANY, _(L("Select none"))); + sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true); }); + sel_none->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(false); }); + all_none_sizer->AddStretchSpacer(); + all_none_sizer->Add(sel_all); + all_none_sizer->Add(sel_none); + sizer->AddStretchSpacer(); + sizer->Add(all_none_sizer, 0, wxEXPAND); + + SetSizer(sizer); +} + +void PrinterPicker::select_all(bool select) +{ + for (const auto &cb : cboxes) { + if (cb->GetValue() != select) { + cb->SetValue(select); + on_checkbox(cb, select); + } + } +} + +void PrinterPicker::on_checkbox(const Checkbox *cbox, bool checked) +{ + variants_checked += checked ? 1 : -1; + PrinterPickerEvent evt(EVT_PRINTER_PICK, GetId(), vendor_id, cbox->model, cbox->variant, checked); + AddPendingEvent(evt); } @@ -176,15 +209,10 @@ PageWelcome::PageWelcome(ConfigWizard *parent) : { append_text(_(L("Hello, welcome to Slic3r Prusa Edition! TODO: This text."))); - // const PresetBundle &bundle = wizard_p()->bundle_vendors; - // const auto &vendors = bundle.vendors; const auto &vendors = wizard_p()->vendors; - // const auto vendor_prusa = std::find(vendors.cbegin(), vendors.cend(), VendorProfile("PrusaResearch")); const auto vendor_prusa = vendors.find("PrusaResearch"); if (vendor_prusa != vendors.cend()) { - const auto &models = vendor_prusa->second.models; - AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors; printer_picker = new PrinterPicker(this, vendor_prusa->second, appconfig_vendors); @@ -550,6 +578,17 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt) // priv +static const std::unordered_map> legacy_preset_map {{ + { "Original Prusa i3 MK2.ini", std::make_pair("MK2S", "0.4") }, + { "Original Prusa i3 MK2 MM Single Mode.ini", std::make_pair("MK2S", "0.4") }, + { "Original Prusa i3 MK2 MM Single Mode 0.6 nozzle.ini", std::make_pair("MK2S", "0.6") }, + { "Original Prusa i3 MK2 MultiMaterial.ini", std::make_pair("MK2S", "0.4") }, + { "Original Prusa i3 MK2 MultiMaterial 0.6 nozzle.ini", std::make_pair("MK2S", "0.6") }, + { "Original Prusa i3 MK2 0.25 nozzle.ini", std::make_pair("MK2S", "0.25") }, + { "Original Prusa i3 MK2 0.6 nozzle.ini", std::make_pair("MK2S", "0.6") }, + { "Original Prusa i3 MK3.ini", std::make_pair("MK3", "0.4") }, +}}; + void ConfigWizard::priv::load_vendors() { const auto vendor_dir = fs::path(Slic3r::data_dir()) / "vendor"; @@ -569,13 +608,28 @@ void ConfigWizard::priv::load_vendors() const auto id = it->path().stem().string(); if (vendors.find(id) == vendors.end()) { auto vp = VendorProfile::from_ini(it->path()); - vendors_rsrc[vp.id] = it->path(); + vendors_rsrc[vp.id] = it->path().filename().string(); vendors[vp.id] = std::move(vp); } } } - appconfig_vendors.set_vendors(*GUI::get_app_config()); + // Load up the set of vendors / models / variants the user has had enabled up till now + const AppConfig *app_config = GUI::get_app_config(); + if (! app_config->legacy_datadir()) { + appconfig_vendors.set_vendors(*app_config); + } else { + // In case of legacy datadir, try to guess the preference based on the printer preset files that are present + const auto printer_dir = fs::path(Slic3r::data_dir()) / "printer"; + for (fs::directory_iterator it(printer_dir); it != fs::directory_iterator(); ++it) { + auto needle = legacy_preset_map.find(it->path().filename().string()); + if (needle == legacy_preset_map.end()) { continue; } + + const auto &model = needle->second.first; + const auto &variant = needle->second.second; + appconfig_vendors.set_variant("PrusaResearch", model, variant, true); + } + } } void ConfigWizard::priv::index_refresh() @@ -639,22 +693,28 @@ void ConfigWizard::priv::on_custom_setup() set_page(page_firmware); } -void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *preset_bundle) +void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *preset_bundle, PresetUpdater *updater) { const bool is_custom_setup = page_welcome->page_next() == page_firmware; if (! is_custom_setup) { const auto enabled_vendors = appconfig_vendors.vendors(); + + // Install bundles from resources if needed: + std::vector install_bundles; for (const auto &vendor_rsrc : vendors_rsrc) { const auto vendor = enabled_vendors.find(vendor_rsrc.first); if (vendor == enabled_vendors.end()) { continue; } - + size_t size_sum = 0; for (const auto &model : vendor->second) { size_sum += model.second.size(); } if (size_sum == 0) { continue; } // This vendor needs to be installed - PresetBundle::install_vendor_configbundle(vendor_rsrc.second); + install_bundles.emplace_back(vendor_rsrc.second); + } + if (install_bundles.size() > 0) { + updater->install_bundles_rsrc(app_config, std::move(install_bundles)); } app_config->set_vendors(appconfig_vendors); @@ -732,14 +792,10 @@ ConfigWizard::ConfigWizard(wxWindow *parent) : ConfigWizard::~ConfigWizard() {} -bool ConfigWizard::run(wxWindow *parent, PresetBundle *preset_bundle) +void ConfigWizard::run(PresetBundle *preset_bundle, PresetUpdater *updater) { - ConfigWizard wizard(parent); - if (wizard.ShowModal() == wxID_OK) { - wizard.p->apply_config(GUI::get_app_config(), preset_bundle); - return true; - } else { - return false; + if (ShowModal() == wxID_OK) { + p->apply_config(GUI::get_app_config(), preset_bundle, updater); } } diff --git a/xs/src/slic3r/GUI/ConfigWizard.hpp b/xs/src/slic3r/GUI/ConfigWizard.hpp index 40ecf09a1e..b34467011d 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard.hpp @@ -8,6 +8,7 @@ namespace Slic3r { class PresetBundle; +class PresetUpdater; namespace GUI { @@ -22,7 +23,7 @@ public: ConfigWizard &operator=(const ConfigWizard &) = delete; ~ConfigWizard(); - static bool run(wxWindow *parent, PresetBundle *preset_bundle); + void run(PresetBundle *preset_bundle, PresetUpdater *updater); private: struct priv; std::unique_ptr p; diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index c93e0a80d5..8aab1cc19b 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -15,6 +15,7 @@ #include #include "libslic3r/PrintConfig.hpp" +#include "slic3r/Utils/PresetUpdater.hpp" #include "AppConfig.hpp" #include "Preset.hpp" #include "BedShapeDialog.hpp" @@ -24,8 +25,6 @@ namespace fs = boost::filesystem; namespace Slic3r { namespace GUI { -// typedef std::unordered_map VendorMap; - enum { CONTENT_WIDTH = 500, @@ -38,9 +37,26 @@ enum { struct PrinterPicker: wxPanel { + struct Checkbox : wxCheckBox + { + Checkbox(wxWindow *parent, const wxString &label, const std::string &model, const std::string &variant) : + wxCheckBox(parent, wxID_ANY, label), + model(model), + variant(variant) + {} + + std::string model; + std::string variant; + }; + + const std::string vendor_id; + std::vector cboxes; unsigned variants_checked; PrinterPicker(wxWindow *parent, const VendorProfile &vendor, const AppConfig &appconfig_vendors); + + void select_all(bool select); + void on_checkbox(const Checkbox *cbox, bool checked); }; struct ConfigWizardPage: wxPanel @@ -174,7 +190,7 @@ struct ConfigWizard::priv ConfigWizard *q; AppConfig appconfig_vendors; // TODO: use order-preserving container std::unordered_map vendors; // TODO: just set? - std::unordered_map vendors_rsrc; + std::unordered_map vendors_rsrc; std::unique_ptr custom_config; wxBoxSizer *topsizer = nullptr; @@ -208,7 +224,7 @@ struct ConfigWizard::priv void on_other_vendors(); void on_custom_setup(); - void apply_config(AppConfig *app_config, PresetBundle *preset_bundle); + void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, PresetUpdater *updater); }; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index d70b47840b..916c407aff 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include "wxExtensions.hpp" @@ -50,6 +51,7 @@ #include "Preferences.hpp" #include "PresetBundle.hpp" +#include "../Utils/PresetUpdater.hpp" #include "../Config/Snapshot.hpp" namespace Slic3r { namespace GUI { @@ -179,6 +181,7 @@ wxFrame *g_wxMainFrame = nullptr; wxNotebook *g_wxTabPanel = nullptr; AppConfig *g_AppConfig = nullptr; PresetBundle *g_PresetBundle= nullptr; +PresetUpdater *g_PresetUpdater = nullptr; std::vector g_tabs_list; @@ -212,6 +215,11 @@ void set_preset_bundle(PresetBundle *preset_bundle) g_PresetBundle = preset_bundle; } +void set_preset_updater(PresetUpdater *updater) +{ + g_PresetUpdater = updater; +} + std::vector& get_tabs_list() { return g_tabs_list; @@ -442,23 +450,51 @@ bool check_unsaved_changes() return dialog->ShowModal() == wxID_YES; } -bool config_wizard(bool fresh_start) +void config_wizard_startup(bool app_config_exists) +{ + if (! app_config_exists || g_PresetBundle->has_defauls_only()) { + config_wizard(true); + } else if (g_AppConfig->legacy_datadir()) { + // Looks like user has legacy pre-vendorbundle data directory, + // explain what this is and run the wizard + + const auto msg = _(L("Configuration update")); + const auto ext_msg = _(L( + "Slic3r PE now uses an updated configuration structure.\n\n" + + "So called 'System presets' have been introduced, which hold the built-in default settings for various " + "printers. These System presets cannot be modified, instead, users now may create their" + "own presets inheriting settings from one of the System presets.\n" + "An inheriting preset may either inherit a particular value from its parent or override it with a customized value.\n\n" + + // TODO: Assistant vs Wizard + "Please proceed with the Configuration wizard that follows to set up the new presets " + "and to choose whether to enable automatic preset updates." + )); + wxMessageDialog dlg(NULL, msg, _(L("Configuration update")), wxOK|wxCENTRE); + dlg.SetExtendedMessage(ext_msg); + const auto res = dlg.ShowModal(); + + config_wizard(true); + } +} + +void config_wizard(bool fresh_start) // TODO: fresh_start useful ? { if (g_wxMainFrame == nullptr) throw std::runtime_error("Main frame not set"); // Exit wizard if there are unsaved changes and the user cancels the action. if (! check_unsaved_changes()) - return false; + return; - // TODO: Offer "reset user profile" ??? - if (! ConfigWizard::run(g_wxMainFrame, g_PresetBundle)) - return false; + // TODO: Offer "reset user profile" ??? + ConfigWizard wizard(g_wxMainFrame); + wizard.run(g_PresetBundle, g_PresetUpdater); // Load the currently selected preset into the GUI, update the preset selection box. for (Tab *tab : g_tabs_list) tab->load_current_preset(); - return true; } void open_preferences_dialog(int event_preferences) diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 2a3667eb3e..6a23ed4eb8 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -25,6 +25,7 @@ namespace Slic3r { class PresetBundle; class PresetCollection; class AppConfig; +class PresetUpdater; class DynamicPrintConfig; class TabIface; @@ -76,6 +77,7 @@ void set_main_frame(wxFrame *main_frame); void set_tab_panel(wxNotebook *tab_panel); void set_app_config(AppConfig *app_config); void set_preset_bundle(PresetBundle *preset_bundle); +void set_preset_updater(PresetUpdater *updater); AppConfig* get_app_config(); wxApp* get_app(); @@ -88,8 +90,11 @@ extern void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int // to notify the user whether he is aware that some preset changes will be lost. extern bool check_unsaved_changes(); -// Opens the first-time configuration wizard, returns true if wizard is finished & accepted. -extern bool config_wizard(bool fresh_start); +// Checks if configuration wizard needs to run, calls config_wizard if so +extern void config_wizard_startup(bool app_config_exists); + +// Opens the configuration wizard, returns true if wizard is finished & accepted. +extern void config_wizard(bool fresh_start); // Create "Preferences" dialog after selecting menu "Preferences" in Perl part extern void open_preferences_dialog(int event_preferences); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 257c7f552e..3291af7e03 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -51,6 +51,11 @@ struct Update version(version) {} + Update(fs::path &&source, fs::path &&target) : + source(source), + target(std::move(target)) + {} + std::string name() { return source.stem().string(); } }; @@ -83,6 +88,7 @@ struct PresetUpdater::priv void check_install_indices() const; Updates config_update() const; + void perform_updates(AppConfig *app_config, Updates &&updates) const; }; PresetUpdater::priv::priv(int event, AppConfig *app_config) : @@ -121,6 +127,7 @@ bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &targe .on_complete([&](std::string body, unsigned http_status) { fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc); file.write(body.c_str(), body.size()); + file.close(); fs::rename(tmp_path, target_path); res = true; }) @@ -269,6 +276,26 @@ Updates PresetUpdater::priv::config_update() const return updates; } +void PresetUpdater::priv::perform_updates(AppConfig *app_config, Updates &&updates) const +{ + SnapshotDB::singleton().take_snapshot(*app_config, Snapshot::SNAPSHOT_UPGRADE); + + for (const auto &update : updates) { + fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); + + PresetBundle bundle; + bundle.load_configbundle(update.target.string(), PresetBundle::LOAD_CFGBNDLE_SYSTEM); + + auto preset_remover = [](const Preset &preset) { + fs::remove(preset.file); + }; + + for (const auto &preset : bundle.prints) { preset_remover(preset); } + for (const auto &preset : bundle.filaments) { preset_remover(preset); } + for (const auto &preset : bundle.printers) { preset_remover(preset); } + } +} + PresetUpdater::PresetUpdater(int version_online_event, AppConfig *app_config) : p(new priv(version_online_event, app_config)) @@ -306,7 +333,7 @@ void PresetUpdater::config_update(AppConfig *app_config) { if (! p->enabled_config_update) { return; } - const auto updates = p->config_update(); + auto updates = p->config_update(); if (updates.size() > 0) { const auto msg = _(L("Configuration update is available. Would you like to install it?")); @@ -330,26 +357,23 @@ void PresetUpdater::config_update(AppConfig *app_config) std::cerr << "After modal" << std::endl; if (res == wxID_YES) { // User gave clearance, updates are go - - SnapshotDB::singleton().take_snapshot(*app_config, Snapshot::SNAPSHOT_UPGRADE, ""); - - for (const auto &update : updates) { - fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); - - PresetBundle bundle; - bundle.load_configbundle(update.target.string(), PresetBundle::LOAD_CFGBNDLE_SYSTEM); - - auto preset_remover = [](const Preset &preset) { - fs::remove(preset.file); - }; - - for (const auto &preset : bundle.prints) { preset_remover(preset); } - for (const auto &preset : bundle.filaments) { preset_remover(preset); } - for (const auto &preset : bundle.printers) { preset_remover(preset); } - } + p->perform_updates(app_config, std::move(updates)); } } } +void PresetUpdater::install_bundles_rsrc(AppConfig *app_config, std::vector &&bundles) +{ + Updates updates; + + for (const auto &bundle : bundles) { + auto path_in_rsrc = p->rsrc_path / bundle; + auto path_in_vendors = p->vendor_path / bundle; + updates.emplace_back(std::move(path_in_rsrc), std::move(path_in_vendors)); + } + + p->perform_updates(app_config, std::move(updates)); +} + } diff --git a/xs/src/slic3r/Utils/PresetUpdater.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp index 966dd14647..1499570db7 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -2,6 +2,7 @@ #define slic3r_PresetUpdate_hpp_ #include +#include namespace Slic3r { @@ -20,8 +21,8 @@ public: ~PresetUpdater(); void sync(AppConfig *app_config, PresetBundle *preset_bundle); - void config_update(AppConfig *app_config); + void install_bundles_rsrc(AppConfig *app_config, std::vector &&bundles); private: struct priv; std::unique_ptr p; diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index 2c27ce9826..3e9276be6a 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -32,8 +32,6 @@ public: ver.prerelease = prerelease ? std::strcpy(ver.prerelease, prerelease->c_str()) : nullptr; } - // TODO: throwing ctor ??? - static boost::optional parse(const std::string &str) { semver_t ver = semver_zero(); diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 46e4ace83f..0d9f0b62e7 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -60,10 +60,10 @@ void set_app_config(AppConfig *app_config) bool check_unsaved_changes() %code%{ RETVAL=Slic3r::GUI::check_unsaved_changes(); %}; -bool config_wizard(int fresh_start) +void config_wizard_startup(int app_config_exists) %code%{ try { - RETVAL = Slic3r::GUI::config_wizard(fresh_start != 0); + Slic3r::GUI::config_wizard_startup(app_config_exists != 0); } catch (std::exception& e) { croak("%s\n", e.what()); } @@ -75,6 +75,9 @@ void open_preferences_dialog(int preferences_event) void set_preset_bundle(PresetBundle *preset_bundle) %code%{ Slic3r::GUI::set_preset_bundle(preset_bundle); %}; +void set_preset_updater(PresetUpdater* updater) + %code%{ Slic3r::GUI::set_preset_updater(updater); %}; + void add_frequently_changed_parameters(SV *ui_parent, SV *ui_sizer, SV *ui_p_sizer) %code%{ Slic3r::GUI::add_frequently_changed_parameters((wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), (wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"), diff --git a/xs/xsp/my.map b/xs/xsp/my.map index c1ca58827b..393338f3b7 100644 --- a/xs/xsp/my.map +++ b/xs/xsp/my.map @@ -238,7 +238,6 @@ Ref O_OBJECT_SLIC3R_T PresetUpdater* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T -Clone O_OBJECT_SLIC3R_T OctoPrint* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T diff --git a/xs/xsp/typemap.xspt b/xs/xsp/typemap.xspt index 0214a158d6..2539811b3c 100644 --- a/xs/xsp/typemap.xspt +++ b/xs/xsp/typemap.xspt @@ -208,6 +208,8 @@ %typemap{Ref}{simple}; %typemap{PresetBundle*}; %typemap{Ref}{simple}; +%typemap{PresetUpdater*}; +%typemap{Ref}{simple}; %typemap{PresetHints*}; %typemap{Ref}{simple}; %typemap{TabIface*}; From d26c8e5336bbc92b79875141f43182ccb7461616 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 16 Apr 2018 17:43:23 +0200 Subject: [PATCH 0190/1150] Fix: Avoid the infamous `major` & `minor` macros on GCC --- xs/src/slic3r/Utils/Semver.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index 762f5bd70b..bf3c78964c 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -77,8 +77,8 @@ public: ~Semver() { ::semver_free(&ver); } // const accessors - int major() const { return ver.major; } - int minor() const { return ver.minor; } + int maj() const { return ver.major; } + int min() const { return ver.minor; } int patch() const { return ver.patch; } const char* prerelease() const { return ver.prerelease; } const char* metadata() const { return ver.metadata; } From 37cf839b2779bb5f14b0cdf7a408956e580e80cd Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 16 Apr 2018 18:33:33 +0200 Subject: [PATCH 0191/1150] ConfigWizard: Fix regression --- xs/src/slic3r/GUI/ConfigWizard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index cd1ed64cb7..467c13e16e 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -50,9 +50,9 @@ wxDEFINE_EVENT(EVT_PRINTER_PICK, PrinterPickerEvent); PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, const AppConfig &appconfig_vendors) : wxPanel(parent), + vendor_id(vendor.id), variants_checked(0) { - const auto vendor_id = vendor.id; const auto &models = vendor.models; auto *sizer = new wxBoxSizer(wxVERTICAL); From d7dc04eb57941d04aa8757cbcd45457f49acbcf5 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 17 Apr 2018 08:18:12 +0200 Subject: [PATCH 0192/1150] Removed parameter filament_cooling_time (fixed value of 14s for now) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 4 ++-- xs/src/libslic3r/Print.cpp | 2 -- xs/src/libslic3r/PrintConfig.cpp | 9 --------- xs/src/libslic3r/PrintConfig.hpp | 2 -- xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 1 - 6 files changed, 3 insertions(+), 17 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 175de0276e..c83c79a044 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -67,7 +67,7 @@ public: // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, - float unloading_speed, float delay, float cooling_time, std::string ramming_parameters, float nozzle_diameter) + float unloading_speed, float delay, std::string ramming_parameters, float nozzle_diameter) { //while (m_filpar.size() < idx+1) // makes sure the required element is in the vector m_filpar.push_back(FilamentParameters()); @@ -78,7 +78,7 @@ public: m_filpar[idx].loading_speed = loading_speed; m_filpar[idx].unloading_speed = unloading_speed; m_filpar[idx].delay = delay; - m_filpar[idx].cooling_time = cooling_time; + m_filpar[idx].cooling_time = 14.f; // let's fix it for now, cooling moves will be reworked for 1.41 anyway m_filpar[idx].nozzle_diameter = nozzle_diameter; // to be used in future with (non-single) multiextruder MM m_perimeter_width = nozzle_diameter * Width_To_Nozzle_Ratio; // all extruders are now assumed to have the same diameter diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index c19c97faea..e692b1e9ee 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -186,7 +186,6 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.filament_loading_speed.get_at(i), this->config.filament_unloading_speed.get_at(i), this->config.filament_toolchange_delay.get_at(i), - this->config.filament_cooling_time.get_at(i), this->config.filament_ramming_parameters.get_at(i), this->config.nozzle_diameter.get_at(i)); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 1e7e0bacc6..02995baf38 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -481,15 +481,6 @@ PrintConfigDef::PrintConfigDef() def->cli = "filament-toolchange-delay=f@"; def->min = 0; def->default_value = new ConfigOptionFloats { 0. }; - - def = this->add("filament_cooling_time", coFloats); - def->label = L("Cooling time"); - def->tooltip = L("The filament is slowly moved back and forth after retraction into the cooling tube " - "for this amount of time."); - def->cli = "filament_cooling_time=i@"; - def->sidetext = L("s"); - def->min = 0; - def->default_value = new ConfigOptionFloats { 14.f }; def = this->add("filament_ramming_parameters", coStrings); def->label = L("Ramming parameters"); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 967a873107..2e36ca665c 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -476,7 +476,6 @@ public: ConfigOptionFloats filament_loading_speed; ConfigOptionFloats filament_unloading_speed; ConfigOptionFloats filament_toolchange_delay; - ConfigOptionFloats filament_cooling_time; ConfigOptionStrings filament_ramming_parameters; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; @@ -534,7 +533,6 @@ protected: OPT_PTR(filament_loading_speed); OPT_PTR(filament_unloading_speed); OPT_PTR(filament_toolchange_delay); - OPT_PTR(filament_cooling_time); OPT_PTR(filament_ramming_parameters); OPT_PTR(gcode_comments); OPT_PTR(gcode_flavor); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index d48c9bf8f5..34b4c53264 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -209,7 +209,7 @@ const std::vector& Preset::filament_options() static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay", - "filament_cooling_time", "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature", + "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers", "compatible_printers_condition", "inherits" diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index cc4b18c7c6..3e4d8ce609 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1287,7 +1287,6 @@ void TabFilament::build() optgroup->append_single_option_line("filament_loading_speed"); optgroup->append_single_option_line("filament_unloading_speed"); optgroup->append_single_option_line("filament_toolchange_delay"); - optgroup->append_single_option_line("filament_cooling_time"); line = { _(L("Ramming")), "" }; line.widget = [this](wxWindow* parent){ auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); From d254c39a7743aaf202e8ba2bba2141c456b0e3b0 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 17 Apr 2018 10:15:48 +0200 Subject: [PATCH 0193/1150] Added "smart" setting of label color --- xs/src/slic3r/GUI/Field.cpp | 9 ++------- xs/src/slic3r/GUI/Field.hpp | 18 +++++++++++++++--- xs/src/slic3r/GUI/Tab.cpp | 27 +++++++++++++++------------ xs/src/slic3r/GUI/Tab.hpp | 5 +++++ 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index a32943da05..e959c7966c 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -20,23 +20,18 @@ namespace Slic3r { namespace GUI { void Field::PostInitialize(){ auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); - m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(16, 16), wxNO_BORDER); + m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(16, 16), wxNO_BORDER); if (wxMSW) { m_Undo_btn->SetBackgroundColour(color); m_Undo_to_sys_btn->SetBackgroundColour(color); } -// m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); BUILD(); } -// void Field::set_nonsys_btn_icon(const wxBitmap& icon){ -// m_Undo_to_sys_btn->SetBitmap(icon); -// } - void Field::on_kill_focus(wxEvent& event) { // Without this, there will be nasty focus bugs on Windows. // Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 2b2646b7cb..292bfd81f8 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -90,9 +90,7 @@ public: virtual void enable() = 0; virtual void disable() = 0; - wxStaticText* m_Label = nullptr; - - /// Fires the enable or disable function, based on the input. + /// Fires the enable or disable function, based on the input. inline void toggle(bool en) { en ? enable() : disable(); } virtual wxString get_tooltip_text(const wxString& default_string); @@ -137,6 +135,16 @@ public: return false; } + bool set_label_colour(const wxColour *clr) { + if (m_Label == nullptr) return false; + if (m_label_color != clr) { + m_label_color = clr; + m_Label->SetForegroundColour(*clr); + m_Label->Refresh(true); + } + return false; + } + protected: wxButton* m_Undo_btn = nullptr; // Bitmap for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. @@ -145,6 +153,10 @@ protected: // Bitmap for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. const wxBitmap* m_undo_to_sys_bitmap = nullptr; + wxStaticText* m_Label = nullptr; + // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. + const wxColour* m_label_color; + friend class OptionsGroup; }; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 6ed124eaa4..8252437495 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -23,6 +23,7 @@ #include #include "wxExtensions.hpp" +#include namespace Slic3r { namespace GUI { @@ -115,6 +116,11 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet); m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); + // Colors for ui "decoration" + m_sys_label_clr = get_sys_label_clr(); + m_modified_label_clr = get_modified_label_clr(); + m_default_text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 0, wxBOTTOM, 3); m_hsizer->Add(m_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3); @@ -344,14 +350,14 @@ void Tab::update_changed_ui() bool is_modified_value = true; const wxBitmap *sys_icon = &m_bmp_value_lock; const wxBitmap *icon = &m_bmp_value_revert; - wxColour color = get_sys_label_clr(); + const wxColour *color = &m_sys_label_clr; if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { is_nonsys_value = true; sys_icon = m_bmp_non_system; if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) - color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + color = &m_default_text_clr; else - color = get_modified_label_clr(); + color = &m_modified_label_clr; } if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) { @@ -360,7 +366,7 @@ void Tab::update_changed_ui() } if (opt_key == "bed_shape" || opt_key == "compatible_printers") { if (m_colored_Label != nullptr) { - m_colored_Label->SetForegroundColour(color); + m_colored_Label->SetForegroundColour(*color); m_colored_Label->Refresh(true); } continue; @@ -372,10 +378,7 @@ void Tab::update_changed_ui() field->m_is_modified_value = is_modified_value; field->set_undo_bitmap(icon); field->set_undo_to_sys_bitmap(sys_icon); - if (field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(color); - field->m_Label->Refresh(true); - } + field->set_label_colour(color); } Thaw(); @@ -425,15 +428,13 @@ void Tab::update_full_options_list() void Tab::update_sys_ui_after_sel_preset() { + const wxColour* clr = &m_default_text_clr; for (const auto opt_key : m_full_options_list){ Field* field = get_field(opt_key); if (field != nullptr){ field->set_undo_to_sys_bitmap(m_bmp_non_system); field->m_is_nonsys_value = true; - if (field->m_Label != nullptr){ - field->m_Label->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - field->m_Label->Refresh(true); - } + field->set_label_colour(clr); } } m_sys_options.resize(0); @@ -2039,6 +2040,8 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr void Tab::OnTreeSelChange(wxTreeEvent& event) { if (m_disable_tree_sel_changed_event) return; + wxWindowUpdateLocker noUpdates(this); + Page* page = nullptr; auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); for (auto p : m_pages) diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index df91ef01be..4668c1238a 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -112,6 +112,11 @@ protected: wxBitmap m_bmp_value_revert; wxBitmap m_bmp_value_unmodified; + // Colors for ui "decoration" + wxColour m_sys_label_clr; + wxColour m_modified_label_clr; + wxColour m_default_text_clr; + int m_icon_count; std::map m_icon_index; // Map from an icon file name to its index std::vector m_pages; From b506aa11fab60fa5413fc82d3615e15a7a9624ea Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 17 Apr 2018 10:28:32 +0200 Subject: [PATCH 0194/1150] PresetUpdater: Fix: Compare versions when installing indices --- xs/src/slic3r/Utils/PresetUpdater.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 3291af7e03..dc3b95d798 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -220,9 +220,16 @@ void PresetUpdater::priv::check_install_indices() const if (path.extension() == ".idx") { const auto path_in_cache = cache_path / path.filename(); - // TODO: compare versions if (! fs::exists(path_in_cache)) { fs::copy_file(path, path_in_cache, fs::copy_option::overwrite_if_exists); + } else { + Index idx_rsrc, idx_cache; + idx_rsrc.load(path); + idx_cache.load(path_in_cache); + + if (idx_cache.version() < idx_rsrc.version()) { + fs::copy_file(path, path_in_cache, fs::copy_option::overwrite_if_exists); + } } } } @@ -267,8 +274,6 @@ Updates PresetUpdater::priv::config_update() const const auto cached_vp = VendorProfile::from_ini(path_in_cache, false); if (cached_vp.config_version == recommended->config_version) { updates.emplace_back(std::move(path_in_cache), bundle_path, *recommended); - } else { - // XXX: ? } } } From a05c4402632756b8401f1fe909f043349b570f02 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 17 Apr 2018 10:55:18 +0200 Subject: [PATCH 0195/1150] Fixed potential crashes due to the Perl worker thread releasing memory allocated by the GUI thread. --- lib/Slic3r.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index e55e24a7ad..ab06a64554 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -161,7 +161,12 @@ sub thread_cleanup { *Slic3r::Print::SupportMaterial2::DESTROY = sub {}; *Slic3r::TriangleMesh::DESTROY = sub {}; *Slic3r::GUI::AppConfig::DESTROY = sub {}; + *Slic3r::GUI::GCodePreviewData::DESTROY = sub {}; + *Slic3r::GUI::OctoPrint::DESTROY = sub {}; *Slic3r::GUI::PresetBundle::DESTROY = sub {}; + *Slic3r::GUI::PresetHints::DESTROY = sub {}; + *Slic3r::GUI::PresetUpdater::DESTROY = sub {}; + *Slic3r::GUI::TabIface::DESTROY = sub {}; return undef; # this prevents a "Scalars leaked" warning } From 98785e47b18c7052245e91966915c99f984aae05 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 17 Apr 2018 10:55:58 +0200 Subject: [PATCH 0196/1150] Removed the "The Wipe Tower currently supports only:\n" "- first layer height 0.2mm\n" "- layer height from 0.15mm to 0.35mm\n" message as the new wipe tower is more generic. --- xs/src/slic3r/GUI/Tab.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 851022489b..3476a897d1 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1015,29 +1015,6 @@ void TabPrint::update() on_value_change("fill_density", fill_density); } - auto first_layer_height = m_config->option("first_layer_height")->value; - auto layer_height = m_config->opt_float("layer_height"); - if (m_config->opt_bool("wipe_tower") && - (first_layer_height != 0.2 || layer_height < 0.15 || layer_height > 0.35)) { - wxString msg_text = _(L("The Wipe Tower currently supports only:\n" - "- first layer height 0.2mm\n" - "- layer height from 0.15mm to 0.35mm\n" - "\nShall I adjust those settings in order to enable the Wipe Tower?")); - auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Wipe Tower")), wxICON_WARNING | wxYES | wxNO); - DynamicPrintConfig new_conf = *m_config; - if (dialog->ShowModal() == wxID_YES) { - const auto &val = *m_config->option("first_layer_height"); - auto percent = val.percent; - new_conf.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, percent)); - - if (m_config->opt_float("layer_height") < 0.15) new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.15)); - if (m_config->opt_float("layer_height") > 0.35) new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.35)); - } - else - new_conf.set_key_value("wipe_tower", new ConfigOptionBool(false)); - load_config(new_conf); - } - if (m_config->opt_bool("wipe_tower") && m_config->opt_bool("support_material") && m_config->opt_float("support_material_contact_distance") > 0. && (m_config->opt_int("support_material_extruder") != 0 || m_config->opt_int("support_material_interface_extruder") != 0)) { From 5e6cc5ddcbc5c937e8434edb0176aceb4d98b394 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 17 Apr 2018 11:06:15 +0200 Subject: [PATCH 0197/1150] Updated max_print_height of PrusaResearch.ini --- resources/profiles/PrusaResearch.ini | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 0da7f22d14..b487aae4c8 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -69,6 +69,7 @@ infill_first = 0 infill_only_where_needed = 0 infill_overlap = 25% interface_shells = 0 +max_print_height = 200 max_print_speed = 100 max_volumetric_extrusion_rate_slope_negative = 0 max_volumetric_extrusion_rate_slope_positive = 0 @@ -120,7 +121,7 @@ thin_walls = 0 top_infill_extrusion_width = 0.45 top_solid_infill_speed = 40 travel_speed = 180 -wipe_tower = 0 +wipe_tower = 1 wipe_tower_per_color_wipe = 20 wipe_tower_width = 60 wipe_tower_x = 180 @@ -995,6 +996,7 @@ inherits = *common* end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 +max_print_height = 210 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = MK3 default_print_profile = 0.15mm OPTIMAL MK3 @@ -1006,6 +1008,7 @@ printer_variant = 0.25 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 +max_print_height = 210 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = MK3 default_print_profile = 0.10mm DETAIL MK3 @@ -1017,6 +1020,7 @@ printer_variant = 0.6 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 +max_print_height = 210 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = MK3 default_print_profile = 0.15mm OPTIMAL MK3 From 6286c9ee7c8cd2f03b4de3a38e26d96f8c7108ec Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 17 Apr 2018 11:54:59 +0200 Subject: [PATCH 0198/1150] ConfigWizard & updating: Fixes & cleanups --- resources/profiles/PrusaResearch.idx | 1 - xs/src/slic3r/GUI/ConfigWizard.cpp | 34 ++++++++++++++++++++------- xs/src/slic3r/GUI/ConfigWizard.hpp | 2 ++ xs/src/slic3r/GUI/GUI.cpp | 11 ++------- xs/src/slic3r/Utils/PresetUpdater.cpp | 6 ++--- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/resources/profiles/PrusaResearch.idx b/resources/profiles/PrusaResearch.idx index 3bc2aeffdd..b43e266635 100644 --- a/resources/profiles/PrusaResearch.idx +++ b/resources/profiles/PrusaResearch.idx @@ -1,7 +1,6 @@ # This is an example configuration version index. # The index contains version numbers min_slic3r_version =1.39.0 -max_slic3r_version= 1.39.5 1.1.1 1.1.0 0.2.0-alpha "some test comment" diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 467c13e16e..00f8399e68 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -203,7 +203,7 @@ void ConfigWizardPage::enable_next(bool enable) { parent->p->enable_next(enable) // Wizard pages PageWelcome::PageWelcome(ConfigWizard *parent) : - ConfigWizardPage(parent, _(L("Welcome to the Slic3r Configuration assistant")), _(L("Welcome"))), + ConfigWizardPage(parent, wxString::Format(_(L("Welcome to the Slic3r %s")), ConfigWizard::name()), _(L("Welcome"))), printer_picker(nullptr), others_buttons(new wxPanel(parent)) { @@ -257,16 +257,26 @@ PageUpdate::PageUpdate(ConfigWizard *parent) : preset_update(true) { const AppConfig *app_config = GUI::get_app_config(); + auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + boldfont.SetWeight(wxFONTWEIGHT_BOLD); - append_text(_(L("TODO: text"))); - auto *box_slic3r = new wxCheckBox(this, wxID_ANY, _(L("Check for Slic3r updates"))); + auto *box_slic3r = new wxCheckBox(this, wxID_ANY, _(L("Check for application updates"))); box_slic3r->SetValue(app_config->get("version_check") == "1"); append(box_slic3r); + append_text(_(L("If enabled, Slic3r checks for new versions of Slic3r PE online. When a new version becomes available a notification is displayed at the next application startup (never during program usage). This is only a notification mechanisms, no automatic installation is done."))); + + append_spacer(VERTICAL_SPACING); - append_text(_(L("TODO: text"))); auto *box_presets = new wxCheckBox(this, wxID_ANY, _(L("Update built-in Presets automatically"))); box_presets->SetValue(app_config->get("preset_update") == "1"); append(box_presets); + append_text(_(L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded into a separate temporary location. When a new preset version becomes available it is offered at application startup."))); + const auto text_bold = _(L("Updates are never applied without user's consent and never overwrite user's customized settings.")); + auto *label_bold = new wxStaticText(this, wxID_ANY, text_bold); + label_bold->SetFont(boldfont); + label_bold->Wrap(CONTENT_WIDTH); + append(label_bold); + append_text(_(L("Additionally a backup snapshot of the whole configuration is created before an update is applied."))); box_slic3r->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->version_check = event.IsChecked(); }); box_presets->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->preset_update = event.IsChecked(); }); @@ -277,15 +287,12 @@ PageVendors::PageVendors(ConfigWizard *parent) : { append_text(_(L("Pick another vendor supported by Slic3r PE:"))); - // const PresetBundle &bundle = wizard_p()->bundle_vendors; - // const auto &vendors = wizard_p()->vendors; auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); boldfont.SetWeight(wxFONTWEIGHT_BOLD); AppConfig &appconfig_vendors = this->wizard_p()->appconfig_vendors; wxArrayString choices_vendors; - // for (const auto &vendor : vendors) { for (const auto vendor_pair : wizard_p()->vendors) { const auto &vendor = vendor_pair.second; if (vendor.id == "PrusaResearch") { continue; } @@ -737,7 +744,7 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese // Public ConfigWizard::ConfigWizard(wxWindow *parent, bool fresh_start) : - wxDialog(parent, wxID_ANY, _(L("Configuration Assistant")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), + wxDialog(parent, wxID_ANY, name(), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), p(new priv(this)) { p->fresh_start = fresh_start; @@ -804,5 +811,16 @@ void ConfigWizard::run(PresetBundle *preset_bundle, PresetUpdater *updater) } +const wxString& ConfigWizard::name() +{ + // A different naming convention is used for the Wizard on Windows vs. OSX & GTK. +#if WIN32 + static const wxString config_wizard_name = _(L("Configuration Wizard")); +#else + static const wxString config_wizard_name = _(L("Configuration Assistant")); +#endif + return config_wizard_name; +} + } } diff --git a/xs/src/slic3r/GUI/ConfigWizard.hpp b/xs/src/slic3r/GUI/ConfigWizard.hpp index d1d994ac1e..66c8b3a95a 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard.hpp @@ -24,6 +24,8 @@ public: ~ConfigWizard(); void run(PresetBundle *preset_bundle, PresetUpdater *updater); + + static const wxString& name(); private: struct priv; std::unique_ptr p; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 96d1371658..bfdd46287f 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -377,16 +377,9 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l auto local_menu = new wxMenu(); wxWindowID config_id_base = wxWindow::NewControlId((int)ConfigMenuCnt); - // A different naming convention is used for the Wizard on Windows vs. OSX & GTK. -#if WIN32 - auto config_wizard_menu = _(L("Configuration Wizard")); - auto config_wizard_tooltip = _(L("Run configuration wizard")); -#else - auto config_wizard_menu = _(L("Configuration Assistant")); - auto config_wizard_tooltip = _(L("Run configuration Assistant")); -#endif + const auto config_wizard_tooltip = wxString::Format(_(L("Run %s")), ConfigWizard::name()); // Cmd+, is standard on OS X - what about other operating systems? - local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_menu + "\u2026", config_wizard_tooltip); + local_menu->Append(config_id_base + ConfigMenuWizard, ConfigWizard::name() + "\u2026", config_wizard_tooltip); local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots\u2026")), _(L("Inspect / activate configuration snapshots"))); local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration Snapshot")), _(L("Capture a configuration snapshot"))); local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index dc3b95d798..939be863c4 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -114,8 +115,6 @@ bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &targe { std::cerr << "get_file(): " << url << " -> " << target_path << std::endl; - // TODO: Proper caching - bool res = false; fs::path tmp_path = target_path; tmp_path += TMP_EXTENSION; @@ -251,7 +250,8 @@ Updates PresetUpdater::priv::config_update() const const auto ver_current = idx.find(vp.config_version); if (ver_current == idx.end()) { - // TODO: throw / ignore ? + BOOST_LOG_TRIVIAL(warning) << boost::format("Preset bundle (`%1%`) version not found in index: %2%") % idx.vendor() % vp.config_version.to_string(); + continue; } const auto recommended = idx.recommended(); From 3bedcf441390a12e10a3d6e1c9c94421c1dbb9e7 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 17 Apr 2018 15:04:14 +0200 Subject: [PATCH 0199/1150] Tweaks in generation of rendering geometry for preview toolpaths. Fixes #240 and #348 --- xs/src/slic3r/GUI/3DScene.cpp | 178 ++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 72 deletions(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index aa86ae203f..7f5e632bba 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -788,15 +788,14 @@ static void thick_lines_to_indexed_vertex_array( #define TOP 2 #define BOTTOM 3 - Line prev_line; // right, left, top, bottom int idx_prev[4] = { -1, -1, -1, -1 }; double bottom_z_prev = 0.; Pointf b1_prev; - Pointf b2_prev; Vectorf v_prev; int idx_initial[4] = { -1, -1, -1, -1 }; double width_initial = 0.; + double bottom_z_initial = 0.0; // loop once more in case of closed loops size_t lines_end = closed ? (lines.size() + 1) : lines.size(); @@ -804,13 +803,18 @@ static void thick_lines_to_indexed_vertex_array( size_t i = (ii == lines.size()) ? 0 : ii; const Line &line = lines[i]; double len = unscale(line.length()); + double inv_len = 1.0 / len; double bottom_z = top_z - heights[i]; - double middle_z = (top_z + bottom_z) / 2.; + double middle_z = 0.5 * (top_z + bottom_z); double width = widths[i]; - + + bool is_first = (ii == 0); + bool is_last = (ii == lines_end - 1); + bool is_closing = closed && is_last; + Vectorf v = Vectorf::new_unscale(line.vector()); - v.scale(1. / len); - + v.scale(inv_len); + Pointf a = Pointf::new_unscale(line.a); Pointf b = Pointf::new_unscale(line.b); Pointf a1 = a; @@ -818,17 +822,19 @@ static void thick_lines_to_indexed_vertex_array( Pointf b1 = b; Pointf b2 = b; { - double dist = width / 2.; // scaled - a1.translate(+dist*v.y, -dist*v.x); - a2.translate(-dist*v.y, +dist*v.x); - b1.translate(+dist*v.y, -dist*v.x); - b2.translate(-dist*v.y, +dist*v.x); + double dist = 0.5 * width; // scaled + double dx = dist * v.x; + double dy = dist * v.y; + a1.translate(+dy, -dx); + a2.translate(-dy, +dx); + b1.translate(+dy, -dx); + b2.translate(-dy, +dx); } // calculate new XY normals Vector n = line.normal(); Vectorf3 xy_right_normal = Vectorf3::new_unscale(n.x, n.y, 0); - xy_right_normal.scale(1.f / len); + xy_right_normal.scale(inv_len); int idx_a[4]; int idx_b[4]; @@ -837,14 +843,21 @@ static void thick_lines_to_indexed_vertex_array( bool bottom_z_different = bottom_z_prev != bottom_z; bottom_z_prev = bottom_z; + if (!is_first && bottom_z_different) + { + // Found a change of the layer thickness -> Add a cap at the end of the previous segment. + volume.push_quad(idx_b[BOTTOM], idx_b[LEFT], idx_b[TOP], idx_b[RIGHT]); + } + // Share top / bottom vertices if possible. - if (ii == 0) { - idx_a[TOP] = idx_last ++; + if (is_first) { + idx_a[TOP] = idx_last++; volume.push_geometry(a.x, a.y, top_z , 0., 0., 1.); } else { idx_a[TOP] = idx_prev[TOP]; } - if (ii == 0 || bottom_z_different) { + + if (is_first || bottom_z_different) { // Start of the 1st line segment or a change of the layer thickness while maintaining the print_z. idx_a[BOTTOM] = idx_last ++; volume.push_geometry(a.x, a.y, bottom_z, 0., 0., -1.); @@ -852,13 +865,15 @@ static void thick_lines_to_indexed_vertex_array( volume.push_geometry(a2.x, a2.y, middle_z, -xy_right_normal.x, -xy_right_normal.y, -xy_right_normal.z); idx_a[RIGHT] = idx_last ++; volume.push_geometry(a1.x, a1.y, middle_z, xy_right_normal.x, xy_right_normal.y, xy_right_normal.z); - } else { + } + else { idx_a[BOTTOM] = idx_prev[BOTTOM]; } - if (ii == 0) { + if (is_first) { // Start of the 1st line segment. width_initial = width; + bottom_z_initial = bottom_z; memcpy(idx_initial, idx_a, sizeof(int) * 4); } else { // Continuing a previous segment. @@ -866,43 +881,54 @@ static void thick_lines_to_indexed_vertex_array( double v_dot = dot(v_prev, v); bool sharp = v_dot < 0.707; // sin(45 degrees) if (sharp) { - // Allocate new left / right points for the start of this segment as these points will receive their own normals to indicate a sharp turn. - idx_a[RIGHT] = idx_last ++; - volume.push_geometry(a1.x, a1.y, middle_z, xy_right_normal.x, xy_right_normal.y, xy_right_normal.z); - idx_a[LEFT ] = idx_last ++; - volume.push_geometry(a2.x, a2.y, middle_z, -xy_right_normal.x, -xy_right_normal.y, -xy_right_normal.z); + if (!bottom_z_different) + { + // Allocate new left / right points for the start of this segment as these points will receive their own normals to indicate a sharp turn. + idx_a[RIGHT] = idx_last++; + volume.push_geometry(a1.x, a1.y, middle_z, xy_right_normal.x, xy_right_normal.y, xy_right_normal.z); + idx_a[LEFT] = idx_last++; + volume.push_geometry(a2.x, a2.y, middle_z, -xy_right_normal.x, -xy_right_normal.y, -xy_right_normal.z); + } } if (v_dot > 0.9) { - // The two successive segments are nearly collinear. - idx_a[LEFT ] = idx_prev[LEFT]; - idx_a[RIGHT] = idx_prev[RIGHT]; - } else if (! sharp) { - // Create a sharp corner with an overshot and average the left / right normals. - // At the crease angle of 45 degrees, the overshot at the corner will be less than (1-1/cos(PI/8)) = 8.2% over an arc. - Pointf intersection; - Geometry::ray_ray_intersection(b1_prev, v_prev, a1, v, intersection); - a1 = intersection; - a2 = 2. * a - intersection; - assert(length(a1.vector_to(a)) < width); - assert(length(a2.vector_to(a)) < width); - float *n_left_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[LEFT ] * 6; - float *p_left_prev = n_left_prev + 3; - float *n_right_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6; - float *p_right_prev = n_right_prev + 3; - p_left_prev [0] = float(a2.x); - p_left_prev [1] = float(a2.y); - p_right_prev[0] = float(a1.x); - p_right_prev[1] = float(a1.y); - xy_right_normal.x += n_right_prev[0]; - xy_right_normal.y += n_right_prev[1]; - xy_right_normal.scale(1. / length(xy_right_normal)); - n_left_prev [0] = float(-xy_right_normal.x); - n_left_prev [1] = float(-xy_right_normal.y); - n_right_prev[0] = float( xy_right_normal.x); - n_right_prev[1] = float( xy_right_normal.y); - idx_a[LEFT ] = idx_prev[LEFT ]; - idx_a[RIGHT] = idx_prev[RIGHT]; - } else if (cross(v_prev, v) > 0.) { + if (!bottom_z_different) + { + // The two successive segments are nearly collinear. + idx_a[LEFT ] = idx_prev[LEFT]; + idx_a[RIGHT] = idx_prev[RIGHT]; + } + } + else if (!sharp) { + if (!bottom_z_different) + { + // Create a sharp corner with an overshot and average the left / right normals. + // At the crease angle of 45 degrees, the overshot at the corner will be less than (1-1/cos(PI/8)) = 8.2% over an arc. + Pointf intersection; + Geometry::ray_ray_intersection(b1_prev, v_prev, a1, v, intersection); + a1 = intersection; + a2 = 2. * a - intersection; + assert(length(a1.vector_to(a)) < width); + assert(length(a2.vector_to(a)) < width); + float *n_left_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[LEFT ] * 6; + float *p_left_prev = n_left_prev + 3; + float *n_right_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6; + float *p_right_prev = n_right_prev + 3; + p_left_prev [0] = float(a2.x); + p_left_prev [1] = float(a2.y); + p_right_prev[0] = float(a1.x); + p_right_prev[1] = float(a1.y); + xy_right_normal.x += n_right_prev[0]; + xy_right_normal.y += n_right_prev[1]; + xy_right_normal.scale(1. / length(xy_right_normal)); + n_left_prev [0] = float(-xy_right_normal.x); + n_left_prev [1] = float(-xy_right_normal.y); + n_right_prev[0] = float( xy_right_normal.x); + n_right_prev[1] = float( xy_right_normal.y); + idx_a[LEFT ] = idx_prev[LEFT ]; + idx_a[RIGHT] = idx_prev[RIGHT]; + } + } + else if (cross(v_prev, v) > 0.) { // Right turn. Fill in the right turn wedge. volume.push_triangle(idx_prev[RIGHT], idx_a [RIGHT], idx_prev[TOP] ); volume.push_triangle(idx_prev[RIGHT], idx_prev[BOTTOM], idx_a [RIGHT] ); @@ -911,18 +937,21 @@ static void thick_lines_to_indexed_vertex_array( volume.push_triangle(idx_prev[LEFT], idx_prev[TOP], idx_a [LEFT] ); volume.push_triangle(idx_prev[LEFT], idx_a [LEFT], idx_prev[BOTTOM]); } - if (ii == lines.size()) { - if (! sharp) { - // Closing a loop with smooth transition. Unify the closing left / right vertices. - memcpy(volume.vertices_and_normals_interleaved.data() + idx_initial[LEFT ] * 6, volume.vertices_and_normals_interleaved.data() + idx_prev[LEFT ] * 6, sizeof(float) * 6); - memcpy(volume.vertices_and_normals_interleaved.data() + idx_initial[RIGHT] * 6, volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6, sizeof(float) * 6); - volume.vertices_and_normals_interleaved.erase(volume.vertices_and_normals_interleaved.end() - 12, volume.vertices_and_normals_interleaved.end()); - // Replace the left / right vertex indices to point to the start of the loop. - for (size_t u = volume.quad_indices.size() - 16; u < volume.quad_indices.size(); ++ u) { - if (volume.quad_indices[u] == idx_prev[LEFT]) - volume.quad_indices[u] = idx_initial[LEFT]; - else if (volume.quad_indices[u] == idx_prev[RIGHT]) - volume.quad_indices[u] = idx_initial[RIGHT]; + if (is_closing) { + if (!sharp) { + if (!bottom_z_different) + { + // Closing a loop with smooth transition. Unify the closing left / right vertices. + memcpy(volume.vertices_and_normals_interleaved.data() + idx_initial[LEFT ] * 6, volume.vertices_and_normals_interleaved.data() + idx_prev[LEFT ] * 6, sizeof(float) * 6); + memcpy(volume.vertices_and_normals_interleaved.data() + idx_initial[RIGHT] * 6, volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6, sizeof(float) * 6); + volume.vertices_and_normals_interleaved.erase(volume.vertices_and_normals_interleaved.end() - 12, volume.vertices_and_normals_interleaved.end()); + // Replace the left / right vertex indices to point to the start of the loop. + for (size_t u = volume.quad_indices.size() - 16; u < volume.quad_indices.size(); ++ u) { + if (volume.quad_indices[u] == idx_prev[LEFT]) + volume.quad_indices[u] = idx_initial[LEFT]; + else if (volume.quad_indices[u] == idx_prev[RIGHT]) + volume.quad_indices[u] = idx_initial[RIGHT]; + } } } // This is the last iteration, only required to solve the transition. @@ -931,13 +960,14 @@ static void thick_lines_to_indexed_vertex_array( } // Only new allocate top / bottom vertices, if not closing a loop. - if (closed && ii + 1 == lines.size()) { + if (is_closing) { idx_b[TOP] = idx_initial[TOP]; } else { idx_b[TOP] = idx_last ++; volume.push_geometry(b.x, b.y, top_z , 0., 0., 1.); } - if (closed && ii + 1 == lines.size() && width == width_initial) { + + if (is_closing && (width == width_initial) && (bottom_z == bottom_z_initial)) { idx_b[BOTTOM] = idx_initial[BOTTOM]; } else { idx_b[BOTTOM] = idx_last ++; @@ -949,22 +979,26 @@ static void thick_lines_to_indexed_vertex_array( idx_b[RIGHT ] = idx_last ++; volume.push_geometry(b1.x, b1.y, middle_z, xy_right_normal.x, xy_right_normal.y, xy_right_normal.z); - prev_line = line; memcpy(idx_prev, idx_b, 4 * sizeof(int)); bottom_z_prev = bottom_z; b1_prev = b1; - b2_prev = b2; - v_prev = v; + v_prev = v; + + if (bottom_z_different) + { + // Found a change of the layer thickness -> Add a cap at the beginning of this segment. + volume.push_quad(idx_a[BOTTOM], idx_a[RIGHT], idx_a[TOP], idx_a[LEFT]); + } if (! closed) { // Terminate open paths with caps. - if (i == 0) + if (is_first && !bottom_z_different) volume.push_quad(idx_a[BOTTOM], idx_a[RIGHT], idx_a[TOP], idx_a[LEFT]); // We don't use 'else' because both cases are true if we have only one line. - if (i + 1 == lines.size()) + if (is_last && !bottom_z_different) volume.push_quad(idx_b[BOTTOM], idx_b[LEFT], idx_b[TOP], idx_b[RIGHT]); } - + // Add quads for a straight hollow tube-like segment. // bottom-right face volume.push_quad(idx_a[BOTTOM], idx_b[BOTTOM], idx_b[RIGHT], idx_a[RIGHT]); From 61ee633cd2136528ee4190b78004a9966171520c Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 17 Apr 2018 16:16:25 +0200 Subject: [PATCH 0200/1150] Fixed color specular component in shaders --- lib/Slic3r/GUI/3DScene.pm | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 13460cfed2..75c19d89ef 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1753,8 +1753,8 @@ sub _vertex_shader_Gouraud { // normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31) const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); #define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SPECULAR (0.25 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SHININESS 200.0 +#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) +#define LIGHT_TOP_SHININESS 20.0 // normalized values for (1./1.43, 0.2/1.43, 1./1.43) const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); @@ -1784,15 +1784,9 @@ varying vec3 delta_box_max; void main() { - vec3 eye = -normalize((gl_ModelViewMatrix * gl_Vertex).xyz); - // First transform the normal into camera space and normalize the result. vec3 normal = normalize(gl_NormalMatrix * gl_Normal); - // Now normalize the light's direction. Note that according to the OpenGL specification, the light is stored in eye space. - // Also since we're talking about a directional light, the position field is actually direction. - vec3 halfVector = normalize(LIGHT_TOP_DIR + eye); - // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); @@ -1801,7 +1795,7 @@ void main() intensity.y = 0.0; if (NdotL > 0.0) - intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, halfVector), 0.0), LIGHT_TOP_SHININESS); + intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); // Perform the same lighting calculation for the 2nd light source (no specular applied). NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); @@ -1926,8 +1920,8 @@ sub _vertex_shader_variable_layer_height { const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); #define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SPECULAR (0.25 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SHININESS 200.0 +#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) +#define LIGHT_TOP_SHININESS 20.0 const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); #define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) @@ -1943,15 +1937,9 @@ varying float object_z; void main() { - vec3 eye = -normalize((gl_ModelViewMatrix * gl_Vertex).xyz); - // First transform the normal into camera space and normalize the result. vec3 normal = normalize(gl_NormalMatrix * gl_Normal); - // Now normalize the light's direction. Note that according to the OpenGL specification, the light is stored in eye space. - // Also since we're talking about a directional light, the position field is actually direction. - vec3 halfVector = normalize(LIGHT_TOP_DIR + eye); - // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); @@ -1960,7 +1948,7 @@ void main() intensity.y = 0.0; if (NdotL > 0.0) - intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, halfVector), 0.0), LIGHT_TOP_SHININESS); + intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); // Perform the same lighting calculation for the 2nd light source (no specular) NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); From df03b8e4e891918b95d9accad90c2e071ce088dd Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 17 Apr 2018 16:59:53 +0200 Subject: [PATCH 0201/1150] PresetUpdater: Notify about Slic3r updates --- lib/Slic3r/GUI.pm | 11 ++- xs/src/slic3r/GUI/AppConfig.cpp | 29 +------ xs/src/slic3r/GUI/AppConfig.hpp | 6 -- xs/src/slic3r/GUI/ConfigWizard.cpp | 2 +- xs/src/slic3r/GUI/PresetBundle.cpp | 13 --- xs/src/slic3r/GUI/PresetBundle.hpp | 4 - xs/src/slic3r/Utils/PresetUpdater.cpp | 116 ++++++++++++++++++++++---- xs/src/slic3r/Utils/PresetUpdater.hpp | 9 +- xs/xsp/GUI_AppConfig.xsp | 1 - xs/xsp/GUI_Preset.xsp | 8 -- xs/xsp/Utils_PresetUpdater.xsp | 7 +- 11 files changed, 119 insertions(+), 87 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 473fc6b90b..5ff8fdde1e 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -87,6 +87,7 @@ sub OnInit { $self->{app_config} = Slic3r::GUI::AppConfig->new; $self->{preset_bundle} = Slic3r::GUI::PresetBundle->new; + Slic3r::GUI::set_app_config($self->{app_config}); # just checking for existence of Slic3r::data_dir is not enough: it may be an empty directory # supplied as argument to --datadir; in that case we should still run the wizard @@ -102,16 +103,18 @@ sub OnInit { $self->{app_config}->save; # my $version_check = $self->{app_config}->get('version_check'); - $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT, $self->{app_config}); + $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT); Slic3r::GUI::set_preset_updater($self->{preset_updater}); - eval { $self->{preset_updater}->config_update($self->{app_config}) }; + eval { + $self->{preset_updater}->slic3r_update_notify(); + $self->{preset_updater}->config_update(); + }; if ($@) { warn $@ . "\n"; fatal_error(undef, $@); } # my $slic3r_update = $self->{app_config}->slic3r_update_avail; - Slic3r::GUI::set_app_config($self->{app_config}); Slic3r::GUI::load_language(); # Suppress the '- default -' presets. @@ -150,7 +153,7 @@ sub OnInit { Slic3r::GUI::config_wizard_startup($app_conf_exists); # TODO: call periodically? - $self->{preset_updater}->sync($self->{app_config}, $self->{preset_bundle}); + $self->{preset_updater}->sync($self->{preset_bundle}); }); # The following event is emited by the C++ menu implementation of application language change. diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 5104078b13..100b2d69b3 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -51,7 +51,7 @@ void AppConfig::set_defaults() set("version_check", "1"); // TODO: proper URL if (get("version_check_url").empty()) - set("version_check_url", "https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/e9187c3e15ceaf1a90f29b7c43cf3ccc746140f0/slic3rPE.version"); + set("version_check_url", "https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/2f05a64db19e45a7f8fe2cedeff555d544af679b/slic3rPE.version"); if (get("preset_update").empty()) set("preset_update", "1"); @@ -230,33 +230,6 @@ void AppConfig::reset_selections() } } -bool AppConfig::version_check_enabled() const -{ - return get("version_check") == "1"; -} - -bool AppConfig::slic3r_update_avail() const -{ - // FIXME: Update with Semver - // TODO: probably need to move semver to libslic3r - return version_check_enabled() && get("version_online") != SLIC3R_VERSION; -} - -Semver AppConfig::get_slic3r_version() const -{ - auto res = Semver::parse(get("version")); - if (! res) { - throw std::runtime_error(std::string("Could not parse Slic3r version string in application config.")); - } else { - return *res; - } -} - -void AppConfig::set_slic3r_version(const Semver &version) -{ - set("version", version.to_string()); -} - std::string AppConfig::config_path() { return (boost::filesystem::path(Slic3r::data_dir()) / "slic3r.ini").make_preferred().string(); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index 88ba0a6623..6dcfec0461 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -90,12 +90,6 @@ public: // the first non-default preset when called. void reset_selections(); - // Whether the Slic3r version available online differs from this one - bool version_check_enabled() const; - bool slic3r_update_avail() const; - Semver get_slic3r_version() const; - void set_slic3r_version(const Semver &version); - // Get the default config path from Slic3r::data_dir(). static std::string config_path(); diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 00f8399e68..c4ca7a886c 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -721,7 +721,7 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese install_bundles.emplace_back(vendor_rsrc.second); } if (install_bundles.size() > 0) { - updater->install_bundles_rsrc(app_config, std::move(install_bundles)); + updater->install_bundles_rsrc(std::move(install_bundles)); } app_config->set_vendors(appconfig_vendors); diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index beec4fe075..6f0754a035 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -695,19 +695,6 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree) flatten_configbundle_hierarchy(tree, "printer"); } -// Load a config bundle file, into presets and store the loaded presets into separate files -// of the local configuration directory. -void PresetBundle::install_vendor_configbundle(const std::string &src_path0) -{ - boost::filesystem::path src_path(src_path0); - install_vendor_configbundle(src_path); -} - -void PresetBundle::install_vendor_configbundle(const boost::filesystem::path &src_path) -{ - boost::filesystem::copy_file(src_path, (boost::filesystem::path(data_dir()) / "vendor" / src_path.filename()).make_preferred(), boost::filesystem::copy_option::overwrite_if_exists); -} - // Load a config bundle file, into presets and store the loaded presets into separate files // of the local configuration directory. size_t PresetBundle::load_configbundle(const std::string &path, unsigned int flags) diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index 651b957016..27add21eec 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -92,10 +92,6 @@ public: // Load the config bundle, store it to the user profile directory by default. size_t load_configbundle(const std::string &path, unsigned int flags = LOAD_CFGBNDLE_SAVE); - // Install the Vendor specific config bundle into user's directory. - void install_vendor_configbundle(const std::string &src_path); - static void install_vendor_configbundle(const boost::filesystem::path &src_path); - // Export a config bundle file containing all the presets and the names of the active presets. void export_configbundle(const std::string &path); // , const DynamicPrintConfig &settings); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 939be863c4..439a619c6b 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -14,7 +14,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include "libslic3r/libslic3r.h" #include "libslic3r/Utils.hpp" #include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/PresetBundle.hpp" @@ -40,6 +48,63 @@ static const char *INDEX_FILENAME = "index.idx"; static const char *TMP_EXTENSION = ".download"; +struct UpdateNotification : wxDialog +{ + // If this dialog gets any more complex, it should probably be factored out... + + enum { + CONTENT_WIDTH = 400, + BORDER = 30, + SPACING = 15, + }; + + wxCheckBox *cbox; + + UpdateNotification(const Semver &ver_current, const Semver &ver_online) : wxDialog(nullptr, wxID_ANY, _(L("Update available"))) + { + auto *topsizer = new wxBoxSizer(wxHORIZONTAL); + auto *sizer = new wxBoxSizer(wxVERTICAL); + + const auto url = wxString::Format("https://github.com/prusa3d/Slic3r/releases/tag/version_%s", ver_online.to_string()); + auto *link = new wxHyperlinkCtrl(this, wxID_ANY, url, url); + + auto *text = new wxStaticText(this, wxID_ANY, + _(L("New version of Slic3r PE is available. To download, follow the link below."))); + const auto link_width = link->GetSize().GetWidth(); + text->Wrap(CONTENT_WIDTH > link_width ? CONTENT_WIDTH : link_width); + sizer->Add(text); + sizer->AddSpacer(SPACING); + + auto *versions = new wxFlexGridSizer(2, 0, SPACING); + versions->Add(new wxStaticText(this, wxID_ANY, _(L("Current version:")))); + versions->Add(new wxStaticText(this, wxID_ANY, ver_current.to_string())); + versions->Add(new wxStaticText(this, wxID_ANY, _(L("New version:")))); + versions->Add(new wxStaticText(this, wxID_ANY, ver_online.to_string())); + sizer->Add(versions); + sizer->AddSpacer(SPACING); + + sizer->Add(link); + sizer->AddSpacer(2*SPACING); + + cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new versions any more"))); + sizer->Add(cbox); + sizer->AddSpacer(SPACING); + + auto *ok = new wxButton(this, wxID_OK); + ok->SetFocus(); + sizer->Add(ok, 0, wxALIGN_CENTRE_HORIZONTAL); + + auto *logo = new wxStaticBitmap(this, wxID_ANY, wxBitmap(GUI::from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG)); + + topsizer->Add(logo, 0, wxALL, BORDER); + topsizer->Add(sizer, 0, wxALL, BORDER); + + SetSizerAndFit(topsizer); + } + + bool disable_version_check() const { return cbox->GetValue(); } +}; + struct Update { fs::path source; @@ -79,7 +144,7 @@ struct PresetUpdater::priv bool cancel; std::thread thread; - priv(int event, AppConfig *app_config); + priv(int version_online_event); void set_download_prefs(AppConfig *app_config); bool get_file(const std::string &url, const fs::path &target_path) const; @@ -89,17 +154,17 @@ struct PresetUpdater::priv void check_install_indices() const; Updates config_update() const; - void perform_updates(AppConfig *app_config, Updates &&updates) const; + void perform_updates(Updates &&updates) const; }; -PresetUpdater::priv::priv(int event, AppConfig *app_config) : - version_online_event(event), +PresetUpdater::priv::priv(int version_online_event) : + version_online_event(version_online_event), cache_path(fs::path(Slic3r::data_dir()) / "cache"), rsrc_path(fs::path(resources_dir()) / "profiles"), vendor_path(fs::path(Slic3r::data_dir()) / "vendor"), cancel(false) { - set_download_prefs(app_config); + set_download_prefs(GUI::get_app_config()); check_install_indices(); index_db = std::move(Index::load_db()); } @@ -281,9 +346,9 @@ Updates PresetUpdater::priv::config_update() const return updates; } -void PresetUpdater::priv::perform_updates(AppConfig *app_config, Updates &&updates) const +void PresetUpdater::priv::perform_updates(Updates &&updates) const { - SnapshotDB::singleton().take_snapshot(*app_config, Snapshot::SNAPSHOT_UPGRADE); + SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE); for (const auto &update : updates) { fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); @@ -302,8 +367,8 @@ void PresetUpdater::priv::perform_updates(AppConfig *app_config, Updates &&updat } -PresetUpdater::PresetUpdater(int version_online_event, AppConfig *app_config) : - p(new priv(version_online_event, app_config)) +PresetUpdater::PresetUpdater(int version_online_event) : + p(new priv(version_online_event)) {} @@ -317,9 +382,9 @@ PresetUpdater::~PresetUpdater() } } -void PresetUpdater::sync(AppConfig *app_config, PresetBundle *preset_bundle) +void PresetUpdater::sync(PresetBundle *preset_bundle) { - p->set_download_prefs(app_config); + p->set_download_prefs(GUI::get_app_config()); if (!p->enabled_version_check && !p->enabled_config_update) { return; } // Copy the whole vendors data for use in the background thread @@ -334,7 +399,28 @@ void PresetUpdater::sync(AppConfig *app_config, PresetBundle *preset_bundle) })); } -void PresetUpdater::config_update(AppConfig *app_config) +void PresetUpdater::slic3r_update_notify() +{ + if (! p->enabled_version_check) { return; } + + auto* app_config = GUI::get_app_config(); + const auto ver_slic3r = Semver::parse(SLIC3R_VERSION); + const auto ver_online = Semver::parse(app_config->get("version_online")); + if (! ver_slic3r) { + throw std::runtime_error("Could not parse Slic3r version string: " SLIC3R_VERSION); + } + + if (ver_online && *ver_online > *ver_slic3r) { + UpdateNotification notification(*ver_slic3r, *ver_online); + notification.ShowModal(); + if (notification.disable_version_check()) { + app_config->set("version_check", "0"); + p->enabled_version_check = false; + } + } +} + +void PresetUpdater::config_update() const { if (! p->enabled_config_update) { return; } @@ -362,12 +448,12 @@ void PresetUpdater::config_update(AppConfig *app_config) std::cerr << "After modal" << std::endl; if (res == wxID_YES) { // User gave clearance, updates are go - p->perform_updates(app_config, std::move(updates)); + p->perform_updates(std::move(updates)); } } } -void PresetUpdater::install_bundles_rsrc(AppConfig *app_config, std::vector &&bundles) +void PresetUpdater::install_bundles_rsrc(std::vector &&bundles) { Updates updates; @@ -377,7 +463,7 @@ void PresetUpdater::install_bundles_rsrc(AppConfig *app_config, std::vectorperform_updates(app_config, std::move(updates)); + p->perform_updates(std::move(updates)); } diff --git a/xs/src/slic3r/Utils/PresetUpdater.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp index 1499570db7..a53ed86eb6 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -13,16 +13,17 @@ class PresetBundle; class PresetUpdater { public: - PresetUpdater(int version_online_event, AppConfig *app_config); + PresetUpdater(int version_online_event); PresetUpdater(PresetUpdater &&) = delete; PresetUpdater(const PresetUpdater &) = delete; PresetUpdater &operator=(PresetUpdater &&) = delete; PresetUpdater &operator=(const PresetUpdater &) = delete; ~PresetUpdater(); - void sync(AppConfig *app_config, PresetBundle *preset_bundle); - void config_update(AppConfig *app_config); - void install_bundles_rsrc(AppConfig *app_config, std::vector &&bundles); + void sync(PresetBundle *preset_bundle); + void slic3r_update_notify(); + void config_update() const; + void install_bundles_rsrc(std::vector &&bundles); private: struct priv; std::unique_ptr p; diff --git a/xs/xsp/GUI_AppConfig.xsp b/xs/xsp/GUI_AppConfig.xsp index de0e5a22bc..08a88883db 100644 --- a/xs/xsp/GUI_AppConfig.xsp +++ b/xs/xsp/GUI_AppConfig.xsp @@ -43,5 +43,4 @@ void update_last_output_dir(char *dir); void reset_selections(); - bool slic3r_update_avail() const; }; diff --git a/xs/xsp/GUI_Preset.xsp b/xs/xsp/GUI_Preset.xsp index ecf6f5a22e..2c63db10c4 100644 --- a/xs/xsp/GUI_Preset.xsp +++ b/xs/xsp/GUI_Preset.xsp @@ -117,14 +117,6 @@ PresetCollection::arrayref() croak("Loading of a config bundle %s failed:\n%s\n", path, e.what()); } %}; - void install_vendor_configbundle(const char *path) - %code%{ - try { - THIS->install_vendor_configbundle(std::string(path)); - } catch (std::exception& e) { - croak("Installing a vendor config bundle %s failed:\n%s\n", path, e.what()); - } - %}; void export_configbundle(char *path) %code%{ try { diff --git a/xs/xsp/Utils_PresetUpdater.xsp b/xs/xsp/Utils_PresetUpdater.xsp index 3a4d55a01e..53c3aa9855 100644 --- a/xs/xsp/Utils_PresetUpdater.xsp +++ b/xs/xsp/Utils_PresetUpdater.xsp @@ -6,7 +6,8 @@ %} %name{Slic3r::PresetUpdater} class PresetUpdater { - PresetUpdater(int version_online_event, AppConfig *app_config); - void sync(AppConfig *app_config, PresetBundle* preset_bundle); - void config_update(AppConfig *app_config); + PresetUpdater(int version_online_event); + void sync(PresetBundle* preset_bundle); + void slic3r_update_notify(); + void config_update(); }; From c884f3b213981b89d7f76a6532e961477705727c Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 17 Apr 2018 17:11:56 +0200 Subject: [PATCH 0202/1150] Display app update notification with the main frame --- lib/Slic3r/GUI.pm | 11 ++--------- xs/src/slic3r/Utils/PresetUpdater.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 5ff8fdde1e..10375a9dce 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -102,18 +102,13 @@ sub OnInit { $self->{app_config}->set('version', $Slic3r::VERSION); $self->{app_config}->save; - # my $version_check = $self->{app_config}->get('version_check'); $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT); Slic3r::GUI::set_preset_updater($self->{preset_updater}); - eval { - $self->{preset_updater}->slic3r_update_notify(); - $self->{preset_updater}->config_update(); - }; + eval { $self->{preset_updater}->config_update(); }; if ($@) { warn $@ . "\n"; fatal_error(undef, $@); } - # my $slic3r_update = $self->{app_config}->slic3r_update_avail; Slic3r::GUI::load_language(); @@ -139,7 +134,6 @@ sub OnInit { ); $self->SetTopWindow($frame); - #EVT_IDLE($frame, sub { EVT_IDLE($self->{mainframe}, sub { while (my $cb = shift @cb) { $cb->(); @@ -151,8 +145,7 @@ sub OnInit { # before the UI was up and running. $self->CallAfter(sub { Slic3r::GUI::config_wizard_startup($app_conf_exists); - - # TODO: call periodically? + $self->{preset_updater}->slic3r_update_notify(); $self->{preset_updater}->sync($self->{preset_bundle}); }); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 439a619c6b..2140a2c91e 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -86,7 +86,7 @@ struct UpdateNotification : wxDialog sizer->Add(link); sizer->AddSpacer(2*SPACING); - cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new versions any more"))); + cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new releases any more"))); sizer->Add(cbox); sizer->AddSpacer(SPACING); @@ -136,6 +136,7 @@ struct PresetUpdater::priv bool enabled_version_check; bool enabled_config_update; std::string version_check_url; + bool had_config_update; fs::path cache_path; fs::path rsrc_path; @@ -159,6 +160,7 @@ struct PresetUpdater::priv PresetUpdater::priv::priv(int version_online_event) : version_online_event(version_online_event), + had_config_update(false), cache_path(fs::path(Slic3r::data_dir()) / "cache"), rsrc_path(fs::path(resources_dir()) / "profiles"), vendor_path(fs::path(Slic3r::data_dir()) / "vendor"), @@ -401,7 +403,8 @@ void PresetUpdater::sync(PresetBundle *preset_bundle) void PresetUpdater::slic3r_update_notify() { - if (! p->enabled_version_check) { return; } + if (! p->enabled_version_check || p->had_config_update) { return; } + // ^ We don't want to bother the user with updates multiple times, put off till next time. auto* app_config = GUI::get_app_config(); const auto ver_slic3r = Semver::parse(SLIC3R_VERSION); @@ -450,6 +453,8 @@ void PresetUpdater::config_update() const // User gave clearance, updates are go p->perform_updates(std::move(updates)); } + + p->had_config_update = true; } } From 2ef164eeef2d72326469c115e4135c10bd94be1e Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 18 Apr 2018 09:44:49 +0200 Subject: [PATCH 0203/1150] Fixed cut contours in cut dialog 3D view --- lib/Slic3r/GUI/3DScene.pm | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 75c19d89ef..da04747c5a 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1330,8 +1330,8 @@ sub Render { glEnable(GL_CULL_FACE) if ($self->enable_picking); } - # draw cutting plane if (defined $self->cutting_plane_z) { + # draw cutting plane my $plane_z = $self->cutting_plane_z; my $bb = $volumes_bb; glDisable(GL_CULL_FACE); @@ -1347,6 +1347,15 @@ sub Render { glEnd(); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); + + # draw cutting contours + glEnableClientState(GL_VERTEX_ARRAY); + glLineWidth(2); + glColor3f(0, 0, 0); + glVertexPointer_c(3, GL_FLOAT, 0, $self->cut_lines_vertices->ptr()); + glDrawArrays(GL_LINES, 0, $self->cut_lines_vertices->elements / 3); + glVertexPointer_c(3, GL_FLOAT, 0, 0); + glDisableClientState(GL_VERTEX_ARRAY); } # draw warning message @@ -1393,18 +1402,10 @@ sub draw_volumes { $volume->render; } glDisableClientState(GL_NORMAL_ARRAY); - glDisable(GL_BLEND); - - glEnable(GL_CULL_FACE); - - if (defined $self->cutting_plane_z) { - glLineWidth(2); - glColor3f(0, 0, 0); - glVertexPointer_c(3, GL_FLOAT, 0, $self->cut_lines_vertices->ptr()); - glDrawArrays(GL_LINES, 0, $self->cut_lines_vertices->elements / 3); - glVertexPointer_c(3, GL_FLOAT, 0, 0); - } glDisableClientState(GL_VERTEX_ARRAY); + + glDisable(GL_BLEND); + glEnable(GL_CULL_FACE); } sub mark_volumes_for_layer_height { From c9e4c831c2c4f53b0e53f97493d1d77aca592f36 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 18 Apr 2018 10:17:22 +0200 Subject: [PATCH 0204/1150] Axes with fixed size in 3D previews --- lib/Slic3r/GUI/3DScene.pm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index da04747c5a..d8af6f71cc 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1281,10 +1281,7 @@ sub Render { # disable depth testing so that axes are not covered by ground glDisable(GL_DEPTH_TEST); my $origin = $self->origin; - my $axis_len = max( - 0.3 * max(@{ $self->bed_bounding_box->size }), - 2 * max(@{ $volumes_bb->size }), - ); + my $axis_len = $self->use_plain_shader ? 0.3 * max(@{ $self->bed_bounding_box->size }) : 2 * max(@{ $volumes_bb->size }); glLineWidth(2); glBegin(GL_LINES); # draw line for x axis From 81c6ad3ab72be74752e802f83515a41112428eab Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 18 Apr 2018 11:40:43 +0200 Subject: [PATCH 0205/1150] ConfigWizard: Add reset option, fixes Fix mock vendors --- resources/profiles/BarBaz.ini | 44 +++++++++++----------- resources/profiles/Foobar.ini | 44 +++++++++++----------- xs/src/slic3r/GUI/ConfigWizard.cpp | 32 ++++++++++++---- xs/src/slic3r/GUI/ConfigWizard.hpp | 2 +- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 9 +++-- xs/src/slic3r/GUI/GUI.cpp | 33 ++++++++-------- xs/src/slic3r/GUI/GUI.hpp | 2 +- xs/src/slic3r/Utils/PresetUpdater.cpp | 12 +++--- xs/src/slic3r/Utils/PresetUpdater.hpp | 2 +- 9 files changed, 102 insertions(+), 78 deletions(-) diff --git a/resources/profiles/BarBaz.ini b/resources/profiles/BarBaz.ini index 7c8cd3a6bb..ed2686cdc4 100644 --- a/resources/profiles/BarBaz.ini +++ b/resources/profiles/BarBaz.ini @@ -1,4 +1,4 @@ -# Print profiles for the Prusa Research printers. +# Print profiles for the BarBaz Research printers. [vendor] # Vendor name will be shown by the Config Wizard. @@ -735,11 +735,11 @@ first_layer_temperature = 195 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" temperature = 195 -[filament:Prusa ABS] +[filament:BarBaz ABS] inherits = *ABS* filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -[filament:Prusa HIPS] +[filament:BarBaz HIPS] inherits = *ABS* bridge_fan_speed = 50 cooling = 1 @@ -755,11 +755,11 @@ min_fan_speed = 20 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" temperature = 220 -[filament:Prusa PET] +[filament:BarBaz PET] inherits = *PET* filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -[filament:Prusa PLA] +[filament:BarBaz PLA] inherits = *PLA* filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" @@ -855,7 +855,7 @@ min_layer_height = 0.07 nozzle_diameter = 0.4 octoprint_apikey = octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_BarBaz3D\nPRINTER_MODEL_MK2\n printer_settings_id = retract_before_travel = 1 retract_before_wipe = 0% @@ -882,7 +882,7 @@ z_offset = 0 printer_model = M2 printer_variant = 0.4 default_print_profile = 0.15mm OPTIMAL -default_filament_profile = Prusa PLA +default_filament_profile = BarBaz PLA [printer:*multimaterial*] inherits = *common* @@ -903,7 +903,7 @@ printer_model = M3 [printer:*mm-single*] inherits = *multimaterial* end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_BarBaz3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 [printer:*mm-multi*] @@ -911,14 +911,14 @@ inherits = *multimaterial* end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259 nozzle_diameter = 0.4,0.4,0.4,0.4 -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_BarBaz3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 variable_layer_height = 0 -[printer:Original Prusa i3 MK2] +[printer:BarBaz i3 MK2] inherits = *common* -[printer:Original Prusa i3 MK2 0.25 nozzle] +[printer:BarBaz i3 MK2 0.25 nozzle] inherits = *common* max_layer_height = 0.1 min_layer_height = 0.05 @@ -929,56 +929,56 @@ variable_layer_height = 0 printer_variant = 0.25 default_print_profile = 0.10mm DETAIL 0.25 nozzle -[printer:Original Prusa i3 MK2 0.6 nozzle] +[printer:BarBaz i3 MK2 0.6 nozzle] inherits = *common* max_layer_height = 0.35 min_layer_height = 0.1 nozzle_diameter = 0.6 printer_variant = 0.6 -[printer:Original Prusa i3 MK2 MM Single Mode] +[printer:BarBaz i3 MK2 MM Single Mode] inherits = *mm-single* -[printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle] +[printer:BarBaz i3 MK2 MM Single Mode 0.6 nozzle] inherits = *mm-single* nozzle_diameter = 0.6 printer_variant = 0.6 -[printer:Original Prusa i3 MK2 MultiMaterial] +[printer:BarBaz i3 MK2 MultiMaterial] inherits = *mm-multi* nozzle_diameter = 0.4,0.4,0.4,0.4 -[printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle] +[printer:BarBaz i3 MK2 MultiMaterial 0.6 nozzle] inherits = *mm-multi* nozzle_diameter = 0.6,0.6,0.6,0.6 printer_variant = 0.6 -[printer:Original Prusa i3 MK3] +[printer:BarBaz i3 MK3] inherits = *common* end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_BarBaz3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = M1 default_print_profile = 0.15mm OPTIMAL MK3 -[printer:Original Prusa i3 MK3 0.25 nozzle] +[printer:BarBaz i3 MK3 0.25 nozzle] inherits = *common* nozzle_diameter = 0.25 printer_variant = 0.25 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_BarBaz3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = M1 default_print_profile = 0.10mm DETAIL MK3 -[printer:Original Prusa i3 MK3 0.6 nozzle] +[printer:BarBaz i3 MK3 0.6 nozzle] inherits = *common* nozzle_diameter = 0.6 printer_variant = 0.6 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_BarBaz3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = M1 diff --git a/resources/profiles/Foobar.ini b/resources/profiles/Foobar.ini index 571aa8bb8b..6f31401ea7 100644 --- a/resources/profiles/Foobar.ini +++ b/resources/profiles/Foobar.ini @@ -1,4 +1,4 @@ -# Print profiles for the Prusa Research printers. +# Print profiles for the Foobar Research printers. [vendor] # Vendor name will be shown by the Config Wizard. @@ -735,11 +735,11 @@ first_layer_temperature = 195 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" temperature = 195 -[filament:Prusa ABS] +[filament:Foobar ABS] inherits = *ABS* filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty MladeÄ ABS" -[filament:Prusa HIPS] +[filament:Foobar HIPS] inherits = *ABS* bridge_fan_speed = 50 cooling = 1 @@ -755,11 +755,11 @@ min_fan_speed = 20 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" temperature = 220 -[filament:Prusa PET] +[filament:Foobar PET] inherits = *PET* filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty MladeÄ PETG" -[filament:Prusa PLA] +[filament:Foobar PLA] inherits = *PLA* filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty MladeÄ PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH" @@ -855,7 +855,7 @@ min_layer_height = 0.07 nozzle_diameter = 0.4 octoprint_apikey = octoprint_host = -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_Foobar3D\nPRINTER_MODEL_MK2\n printer_settings_id = retract_before_travel = 1 retract_before_wipe = 0% @@ -882,7 +882,7 @@ z_offset = 0 printer_model = M2 printer_variant = 0.4 default_print_profile = 0.15mm OPTIMAL -default_filament_profile = Prusa PLA +default_filament_profile = Foobar PLA [printer:*multimaterial*] inherits = *common* @@ -903,7 +903,7 @@ printer_model = M3 [printer:*mm-single*] inherits = *multimaterial* end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_Foobar3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 [printer:*mm-multi*] @@ -911,14 +911,14 @@ inherits = *multimaterial* end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259 nozzle_diameter = 0.4,0.4,0.4,0.4 -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_Foobar3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 variable_layer_height = 0 -[printer:Original Prusa i3 MK2] +[printer:Foobar i3 MK2] inherits = *common* -[printer:Original Prusa i3 MK2 0.25 nozzle] +[printer:Foobar i3 MK2 0.25 nozzle] inherits = *common* max_layer_height = 0.1 min_layer_height = 0.05 @@ -929,56 +929,56 @@ variable_layer_height = 0 printer_variant = 0.25 default_print_profile = 0.10mm DETAIL 0.25 nozzle -[printer:Original Prusa i3 MK2 0.6 nozzle] +[printer:Foobar i3 MK2 0.6 nozzle] inherits = *common* max_layer_height = 0.35 min_layer_height = 0.1 nozzle_diameter = 0.6 printer_variant = 0.6 -[printer:Original Prusa i3 MK2 MM Single Mode] +[printer:Foobar i3 MK2 MM Single Mode] inherits = *mm-single* -[printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle] +[printer:Foobar i3 MK2 MM Single Mode 0.6 nozzle] inherits = *mm-single* nozzle_diameter = 0.6 printer_variant = 0.6 -[printer:Original Prusa i3 MK2 MultiMaterial] +[printer:Foobar i3 MK2 MultiMaterial] inherits = *mm-multi* nozzle_diameter = 0.4,0.4,0.4,0.4 -[printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle] +[printer:Foobar i3 MK2 MultiMaterial 0.6 nozzle] inherits = *mm-multi* nozzle_diameter = 0.6,0.6,0.6,0.6 printer_variant = 0.6 -[printer:Original Prusa i3 MK3] +[printer:Foobar i3 MK3] inherits = *common* end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_Foobar3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = M1 default_print_profile = 0.15mm OPTIMAL MK3 -[printer:Original Prusa i3 MK3 0.25 nozzle] +[printer:Foobar i3 MK3 0.25 nozzle] inherits = *common* nozzle_diameter = 0.25 printer_variant = 0.25 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_Foobar3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = M1 default_print_profile = 0.10mm DETAIL MK3 -[printer:Original Prusa i3 MK3 0.6 nozzle] +[printer:Foobar i3 MK3 0.6 nozzle] inherits = *common* nozzle_diameter = 0.6 printer_variant = 0.6 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors -printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_Foobar3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = M1 diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index c4ca7a886c..0eee234db7 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -17,7 +17,6 @@ #include "GUI.hpp" #include "slic3r/Utils/PresetUpdater.hpp" -// TODO: Wizard vs Assistant namespace Slic3r { namespace GUI { @@ -205,9 +204,18 @@ void ConfigWizardPage::enable_next(bool enable) { parent->p->enable_next(enable) PageWelcome::PageWelcome(ConfigWizard *parent) : ConfigWizardPage(parent, wxString::Format(_(L("Welcome to the Slic3r %s")), ConfigWizard::name()), _(L("Welcome"))), printer_picker(nullptr), - others_buttons(new wxPanel(parent)) + others_buttons(new wxPanel(parent)), + cbox_reset(new wxCheckBox(this, wxID_ANY, _(L("Remove user profiles - install from scratch (a snapshot will be taken beforehand)")))) { - append_text(_(L("Hello, welcome to Slic3r Prusa Edition! TODO: This text."))); + if (wizard_p()->flag_startup && wizard_p()->flag_empty_datadir) { + wxString::Format(_(L("Run %s")), ConfigWizard::name()); + append_text(wxString::Format( + _(L("Hello, welcome to Slic3r Prusa Edition! This %s helps you with the initial configuration; just a few settings and you will be ready to print.")), + ConfigWizard::name()) + ); + } else { + append(cbox_reset); + } const auto &vendors = wizard_p()->vendors; const auto vendor_prusa = vendors.find("PrusaResearch"); @@ -720,14 +728,22 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese // This vendor needs to be installed install_bundles.emplace_back(vendor_rsrc.second); } + + // If the datadir was empty don't take a snapshot (it would just be an empty snapshot) + const bool snapshot = !flag_empty_datadir || page_welcome->reset_user_profile(); if (install_bundles.size() > 0) { - updater->install_bundles_rsrc(std::move(install_bundles)); + // Install bundles from resources. + updater->install_bundles_rsrc(std::move(install_bundles), snapshot); + } + + if (page_welcome->reset_user_profile()) { + preset_bundle->reset(true); } app_config->set_vendors(appconfig_vendors); app_config->set("version_check", page_update->version_check ? "1" : "0"); app_config->set("preset_update", page_update->preset_update ? "1" : "0"); - if (fresh_start) + if (flag_startup) app_config->reset_selections(); // ^ TODO: replace with appropriate printer selection preset_bundle->load_presets(*app_config); @@ -743,11 +759,13 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese // Public -ConfigWizard::ConfigWizard(wxWindow *parent, bool fresh_start) : +ConfigWizard::ConfigWizard(wxWindow *parent, bool startup, bool empty_datadir) : wxDialog(parent, wxID_ANY, name(), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), p(new priv(this)) { - p->fresh_start = fresh_start; + p->flag_startup = startup; + p->flag_empty_datadir = empty_datadir; + p->load_vendors(); p->custom_config.reset(DynamicPrintConfig::new_from_defaults_keys({ "gcode_flavor", "bed_shape", "nozzle_diameter", "filament_diameter", "temperature", "bed_temperature", diff --git a/xs/src/slic3r/GUI/ConfigWizard.hpp b/xs/src/slic3r/GUI/ConfigWizard.hpp index 66c8b3a95a..eeb64c57f6 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard.hpp @@ -16,7 +16,7 @@ namespace GUI { class ConfigWizard: public wxDialog { public: - ConfigWizard(wxWindow *parent, bool fresh_start); + ConfigWizard(wxWindow *parent, bool startup, bool empty_datadir); ConfigWizard(ConfigWizard &&) = delete; ConfigWizard(const ConfigWizard &) = delete; ConfigWizard &operator=(ConfigWizard &&) = delete; diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index faabca812c..8e43ac3ac7 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -100,12 +100,14 @@ struct PageWelcome: ConfigWizardPage { PrinterPicker *printer_picker; wxPanel *others_buttons; + wxCheckBox *cbox_reset; PageWelcome(ConfigWizard *parent); virtual wxPanel* extra_buttons() { return others_buttons; } virtual void on_page_set(); + bool reset_user_profile() const { return cbox_reset->GetValue(); } void on_variant_checked(); }; @@ -188,9 +190,10 @@ private: struct ConfigWizard::priv { ConfigWizard *q; - bool fresh_start; - AppConfig appconfig_vendors; // TODO: use order-preserving container - std::unordered_map vendors; // TODO: just set? + bool flag_startup; + bool flag_empty_datadir; + AppConfig appconfig_vendors; + std::unordered_map vendors; std::unordered_map vendors_rsrc; std::unique_ptr custom_config; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index bfdd46287f..7de82cb5f4 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -390,7 +390,7 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ switch (event.GetId() - config_id_base) { case ConfigMenuWizard: - config_wizard(0); + config_wizard(false, false); break; case ConfigMenuTakeSnapshot: // Take a configuration snapshot. @@ -465,33 +465,35 @@ bool check_unsaved_changes() void config_wizard_startup(bool app_config_exists) { if (! app_config_exists || g_PresetBundle->has_defauls_only()) { - config_wizard(true); + config_wizard(true, true); } else if (g_AppConfig->legacy_datadir()) { // Looks like user has legacy pre-vendorbundle data directory, // explain what this is and run the wizard const auto msg = _(L("Configuration update")); - const auto ext_msg = _(L( - "Slic3r PE now uses an updated configuration structure.\n\n" + const auto ext_msg = wxString::Format( + _(L( + "Slic3r PE now uses an updated configuration structure.\n\n" - "So called 'System presets' have been introduced, which hold the built-in default settings for various " - "printers. These System presets cannot be modified, instead, users now may create their" - "own presets inheriting settings from one of the System presets.\n" - "An inheriting preset may either inherit a particular value from its parent or override it with a customized value.\n\n" + "So called 'System presets' have been introduced, which hold the built-in default settings for various " + "printers. These System presets cannot be modified, instead, users now may create their" + "own presets inheriting settings from one of the System presets.\n" + "An inheriting preset may either inherit a particular value from its parent or override it with a customized value.\n\n" - // TODO: Assistant vs Wizard - "Please proceed with the Configuration wizard that follows to set up the new presets " - "and to choose whether to enable automatic preset updates." - )); + "Please proceed with the %s that follows to set up the new presets " + "and to choose whether to enable automatic preset updates." + )), + ConfigWizard::name() + ); wxMessageDialog dlg(NULL, msg, _(L("Configuration update")), wxOK|wxCENTRE); dlg.SetExtendedMessage(ext_msg); const auto res = dlg.ShowModal(); - config_wizard(true); + config_wizard(true, false); } } -void config_wizard(bool fresh_start) // TODO: fresh_start useful ? +void config_wizard(bool startup, bool empty_datadir) { if (g_wxMainFrame == nullptr) throw std::runtime_error("Main frame not set"); @@ -500,8 +502,7 @@ void config_wizard(bool fresh_start) // TODO: fresh_start useful ? if (! check_unsaved_changes()) return; - // TODO: Offer "reset user profile" ??? - ConfigWizard wizard(g_wxMainFrame, fresh_start); + ConfigWizard wizard(g_wxMainFrame, startup, empty_datadir); wizard.run(g_PresetBundle, g_PresetUpdater); // Load the currently selected preset into the GUI, update the preset selection box. diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 6ee9d4f54c..92a6e6ebb8 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -97,7 +97,7 @@ extern bool check_unsaved_changes(); extern void config_wizard_startup(bool app_config_exists); // Opens the configuration wizard, returns true if wizard is finished & accepted. -extern void config_wizard(bool fresh_start); +extern void config_wizard(bool startup, bool empty_datadir); // Create "Preferences" dialog after selecting menu "Preferences" in Perl part extern void open_preferences_dialog(int event_preferences); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 2140a2c91e..bf9e1eb44e 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -155,7 +155,7 @@ struct PresetUpdater::priv void check_install_indices() const; Updates config_update() const; - void perform_updates(Updates &&updates) const; + void perform_updates(Updates &&updates, bool snapshot = true) const; }; PresetUpdater::priv::priv(int version_online_event) : @@ -348,9 +348,11 @@ Updates PresetUpdater::priv::config_update() const return updates; } -void PresetUpdater::priv::perform_updates(Updates &&updates) const +void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) const { - SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE); + if (snapshot) { + SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE); + } for (const auto &update : updates) { fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); @@ -458,7 +460,7 @@ void PresetUpdater::config_update() const } } -void PresetUpdater::install_bundles_rsrc(std::vector &&bundles) +void PresetUpdater::install_bundles_rsrc(std::vector &&bundles, bool snapshot) { Updates updates; @@ -468,7 +470,7 @@ void PresetUpdater::install_bundles_rsrc(std::vector &&bundles) updates.emplace_back(std::move(path_in_rsrc), std::move(path_in_vendors)); } - p->perform_updates(std::move(updates)); + p->perform_updates(std::move(updates), snapshot); } diff --git a/xs/src/slic3r/Utils/PresetUpdater.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp index a53ed86eb6..8fe3e021d5 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -23,7 +23,7 @@ public: void sync(PresetBundle *preset_bundle); void slic3r_update_notify(); void config_update() const; - void install_bundles_rsrc(std::vector &&bundles); + void install_bundles_rsrc(std::vector &&bundles, bool snapshot = true); private: struct priv; std::unique_ptr p; From 0711f84ea0277dd503abe49cf0b58ddeb2d030f2 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 18 Apr 2018 12:33:07 +0200 Subject: [PATCH 0206/1150] Add version check & preset update options to Preferences --- xs/src/slic3r/GUI/Preferences.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Preferences.cpp b/xs/src/slic3r/GUI/Preferences.cpp index 6731cd394d..4c60577d56 100644 --- a/xs/src/slic3r/GUI/Preferences.cpp +++ b/xs/src/slic3r/GUI/Preferences.cpp @@ -9,7 +9,7 @@ void PreferencesDialog::build() { auto app_config = get_app_config(); m_optgroup = std::make_shared(this, _(L("General"))); - m_optgroup->label_width = 200; + m_optgroup->label_width = 400; m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value){ m_values[opt_key] = boost::any_cast(value) ? "1" : "0"; }; @@ -49,6 +49,22 @@ void PreferencesDialog::build() option = Option (def,"background_processing"); m_optgroup->append_single_option_line(option); + // Please keep in sync with ConfigWizard + def.label = L("Check for application updates"); + def.type = coBool; + def.tooltip = L("If enabled, Slic3r checks for new versions of Slic3r PE online. When a new version becomes available a notification is displayed at the next application startup (never during program usage). This is only a notification mechanisms, no automatic installation is done."); + def.default_value = new ConfigOptionBool(app_config->get("version_check") == "1"); + option = Option (def, "version_check"); + m_optgroup->append_single_option_line(option); + + // Please keep in sync with ConfigWizard + def.label = L("Update built-in Presets automatically"); + def.type = coBool; + def.tooltip = L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded into a separate temporary location. When a new preset version becomes available it is offered at application startup."); + def.default_value = new ConfigOptionBool(app_config->get("preset_update") == "1"); + option = Option (def, "preset_update"); + m_optgroup->append_single_option_line(option); + def.label = L("Disable USB/serial connection"); def.type = coBool; def.tooltip = L("Disable communication with the printer over a serial / USB cable. " From 3ca2dfbc1dc83d3b976573dba6aa065c6fed236c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 18 Apr 2018 13:32:21 +0200 Subject: [PATCH 0207/1150] Added some performance changes --- xs/src/libslic3r/Config.cpp | 38 +++ xs/src/libslic3r/Config.hpp | 3 + xs/src/slic3r/GUI/GUI.cpp | 6 + xs/src/slic3r/GUI/GUI.hpp | 1 + xs/src/slic3r/GUI/Preset.cpp | 8 +- xs/src/slic3r/GUI/Preset.hpp | 10 +- xs/src/slic3r/GUI/Tab.cpp | 529 ++++++++++++++++++++++++----------- xs/src/slic3r/GUI/Tab.hpp | 41 ++- 8 files changed, 455 insertions(+), 181 deletions(-) diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index a4eaf3072a..8c1349e085 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -206,6 +206,44 @@ t_config_option_keys ConfigBase::diff(const ConfigBase &other) const return diff; } +template +void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys& vec, const ConfigBase &other, const ConfigBase *this_c) +{ + const T* opt_init = static_cast(other.option(opt_key)); + const T* opt_cur = static_cast(this_c->option(opt_key)); + int opt_init_max_id = opt_init->values.size() - 1; + for (int i = 0; i < opt_cur->values.size(); i++) + { + int init_id = i <= opt_init_max_id ? i : 0; + if (opt_cur->values[i] != opt_init->values[init_id]) + vec.emplace_back(opt_key + "#" + std::to_string(i)); + } +} + +t_config_option_keys ConfigBase::deep_diff(const ConfigBase &other) const +{ + t_config_option_keys diff; + for (const t_config_option_key &opt_key : this->keys()) { + const ConfigOption *this_opt = this->option(opt_key); + const ConfigOption *other_opt = other.option(opt_key); + if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt) + { + if (opt_key == "bed_shape"){ diff.emplace_back(opt_key); continue; } + switch (other_opt->type()) + { + case coInts: add_correct_opts_to_diff(opt_key, diff, other, this); break; + case coBools: add_correct_opts_to_diff(opt_key, diff, other, this); break; + case coFloats: add_correct_opts_to_diff(opt_key, diff, other, this); break; + case coStrings: add_correct_opts_to_diff(opt_key, diff, other, this); break; + case coPercents:add_correct_opts_to_diff(opt_key, diff, other, this); break; + case coPoints: add_correct_opts_to_diff(opt_key, diff, other, this); break; + default: diff.emplace_back(opt_key); break; + } + } + } + return diff; +} + t_config_option_keys ConfigBase::equal(const ConfigBase &other) const { t_config_option_keys equal; diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 6eb307c5ce..24a8871308 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -1046,6 +1046,9 @@ public: void apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false); bool equals(const ConfigBase &other) const { return this->diff(other).empty(); } t_config_option_keys diff(const ConfigBase &other) const; + // Use deep_diff to correct return of changed options, + // considering individual options for each extruder + t_config_option_keys deep_diff(const ConfigBase &other) const; t_config_option_keys equal(const ConfigBase &other) const; std::string serialize(const t_config_option_key &opt_key) const; // Set a configuration value from a string, it will call an overridable handle_legacy() diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index cc135931aa..c4f07935c5 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -179,6 +179,7 @@ AppConfig *g_AppConfig = nullptr; PresetBundle *g_PresetBundle= nullptr; wxColour g_color_label_modified; wxColour g_color_label_sys; +wxColour g_color_label_default; std::vector g_tabs_list; @@ -198,6 +199,7 @@ static void init_label_colours() g_color_label_modified = wxColour(253, 111, 40); g_color_label_sys = wxColour(115, 220, 103); } + g_color_label_default = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); } void set_wxapp(wxApp *app) @@ -548,6 +550,10 @@ const wxColour& get_sys_label_clr() { return g_color_label_sys; } +const wxColour& get_default_label_clr() { + return g_color_label_default; +} + unsigned get_colour_approx_luma(const wxColour &colour) { double r = colour.Red(); diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 0b681f48f1..75600a57b1 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -83,6 +83,7 @@ wxApp* get_app(); const wxColour& get_modified_label_clr(); const wxColour& get_sys_label_clr(); +const wxColour& get_default_label_clr(); unsigned get_colour_approx_luma(const wxColour &colour); void add_debug_menu(wxMenuBar *menu, int event_language_change); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index d48c9bf8f5..30f49df08f 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -629,11 +629,13 @@ bool PresetCollection::update_dirty_ui(wxBitmapComboBox *ui) return was_dirty != is_dirty; } -std::vector PresetCollection::dirty_options(const Preset *edited, const Preset *reference) +std::vector PresetCollection::dirty_options(const Preset *edited, const Preset *reference, const bool is_printer_type /*= false*/) { std::vector changed; - if (edited != nullptr && reference != nullptr) { - changed = reference->config.diff(edited->config); + if (edited != nullptr && reference != nullptr) { + changed = is_printer_type ? + reference->config.deep_diff(edited->config) : + reference->config.diff(edited->config); // The "compatible_printers" option key is handled differently from the others: // It is not mandatory. If the key is missing, it means it is compatible with any printer. // If the key exists and it is empty, it means it is compatible with no printer. diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index c038160f4e..e12f18b885 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -253,11 +253,11 @@ public: // Compare the content of get_selected_preset() with get_edited_preset() configs, return true if they differ. bool current_is_dirty() const { return ! this->current_dirty_options().empty(); } // Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ. - std::vector current_dirty_options() const - { return dirty_options(&this->get_edited_preset(), &this->get_selected_preset()); } + std::vector current_dirty_options(const bool is_printer_type = false) const + { return dirty_options(&this->get_edited_preset(), &this->get_selected_preset(), is_printer_type); } // Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ. - std::vector current_different_from_parent_options() const - { return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent()); } + std::vector current_different_from_parent_options(const bool is_printer_type = false) const + { return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent(), is_printer_type); } // Compare the content of get_selected_preset() with get_selected_preset_parent() configs, return the list of keys where they equal. std::vector system_equal_options() const; @@ -299,7 +299,7 @@ private: std::deque::const_iterator find_preset_internal(const std::string &name) const { return const_cast(this)->find_preset_internal(name); } - static std::vector dirty_options(const Preset *edited, const Preset *reference); + static std::vector dirty_options(const Preset *edited, const Preset *reference, const bool is_printer_type = false); // Type of this PresetCollection: TYPE_PRINT, TYPE_FILAMENT or TYPE_PRINTER. Preset::Type m_type; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 8252437495..dcf61f5749 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -25,6 +25,8 @@ #include "wxExtensions.hpp" #include +#include + namespace Slic3r { namespace GUI { @@ -112,14 +114,14 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_bmp_value_revert .LoadFile(from_u8(var("action_undo.png")), wxBITMAP_TYPE_PNG); m_bmp_white_bullet .LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG); m_undo_btn->SetBitmap(m_bmp_white_bullet); - m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); + m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ /*on_back_to_initial_value*/on_roll_back_value(); })); m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet); - m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); + m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ /*on_back_to_sys_value*/on_roll_back_value(true); })); // Colors for ui "decoration" m_sys_label_clr = get_sys_label_clr(); m_modified_label_clr = get_modified_label_clr(); - m_default_text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + m_default_text_clr = get_default_label_clr(); m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 0, wxBOTTOM, 3); @@ -246,45 +248,108 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo return page; } -template -void add_correct_opts_to_dirty_options(const std::string &opt_key, std::vector *vec, TabPrinter *tab) -{ - auto opt_init = static_cast(tab->m_presets->get_selected_preset().config.option(opt_key)); - auto opt_cur = static_cast(tab->m_config->option(opt_key)); - int opt_init_max_id = opt_init->values.size()-1; - for (int i = 0; i < opt_cur->values.size(); i++) - { - int init_id = i <= opt_init_max_id ? i : 0; - if (opt_cur->values[i] != opt_init->values[init_id]) - vec->emplace_back(opt_key + "#" + std::to_string(i)); - } -} - -template -void add_correct_opts_to_sys_options(const std::string &opt_key, std::vector *vec, TabPrinter *tab) -{ - const Preset* sys_preset = tab->m_presets->get_selected_preset_parent(); - if (sys_preset == nullptr) - return; - T *opt_cur = static_cast(tab->m_config->option(opt_key)); - const T *opt_sys = static_cast(sys_preset->config.option(opt_key)); - int opt_max_id = opt_sys->values.size()-1; - for (int i = 0; i < opt_cur->values.size(); i++) - { - int init_id = i <= opt_max_id ? i : 0; - if (opt_cur->values[i] == opt_sys->values[init_id]) - vec->emplace_back(opt_key + "#" + std::to_string(i)); - } -} +// template +// void add_correct_opts_to_dirty_options(const std::string &opt_key, std::vector *vec, TabPrinter *tab) +// { +// auto opt_init = static_cast(tab->m_presets->get_selected_preset().config.option(opt_key)); +// auto opt_cur = static_cast(tab->m_config->option(opt_key)); +// int opt_init_max_id = opt_init->values.size()-1; +// for (int i = 0; i < opt_cur->values.size(); i++) +// { +// int init_id = i <= opt_init_max_id ? i : 0; +// if (opt_cur->values[i] != opt_init->values[init_id]) +// vec->emplace_back(opt_key + "#" + std::to_string(i)); +// } +// } +// +// template +// void add_correct_opts_to_sys_options(const std::string &opt_key, std::vector *vec, TabPrinter *tab) +// { +// const Preset* sys_preset = tab->m_presets->get_selected_preset_parent(); +// if (sys_preset == nullptr) +// return; +// T *opt_cur = static_cast(tab->m_config->option(opt_key)); +// const T *opt_sys = static_cast(sys_preset->config.option(opt_key)); +// int opt_max_id = opt_sys->values.size()-1; +// for (int i = 0; i < opt_cur->values.size(); i++) +// { +// int init_id = i <= opt_max_id ? i : 0; +// if (opt_cur->values[i] == opt_sys->values[init_id]) +// vec->emplace_back(opt_key + "#" + std::to_string(i)); +// } +// } // Update UI according to changes void Tab::update_changed_ui() { if (m_postpone_update_ui) return; - auto dirty_options = m_presets->current_dirty_options(); - if (name() == "printer"){ + const bool is_printer_type = (name() == "printer"); + auto m_dirty_options = m_presets->current_dirty_options(is_printer_type); + auto m_nonsys_options = m_presets->current_different_from_parent_options(is_printer_type); + if (is_printer_type){ + TabPrinter* tab = static_cast(this); + if (tab->m_initial_extruders_count != tab->m_extruders_count) + m_dirty_options.emplace_back("extruders_count"); + if (tab->m_sys_extruders_count != tab->m_extruders_count) + m_nonsys_options.emplace_back("extruders_count"); + } + + for (auto& it : m_options_list) + it.second = m_opt_status_value; + +// auto m_options_list = m_options_list; + for (auto opt_key : m_dirty_options) m_options_list[opt_key] &= ~osInitValue; + for (auto opt_key : m_nonsys_options) m_options_list[opt_key] &= ~osSystemValue; + + Freeze(); + //update options "decoration" + for (const auto opt : m_options_list/*m_options_list*/) + { + bool is_nonsys_value = false; + bool is_modified_value = true; + const wxBitmap *sys_icon = &m_bmp_value_lock; + const wxBitmap *icon = &m_bmp_value_revert; + const wxColour *color = &m_sys_label_clr; + + if ((opt.second & osSystemValue) == 0){ +// if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { + is_nonsys_value = true; + sys_icon = m_bmp_non_system; + if ((opt.second & osInitValue) != 0) +// if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) + color = &m_default_text_clr; + else + color = &m_modified_label_clr; + } + if ((opt.second & osInitValue) != 0) +// if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) + { + is_modified_value = false; + icon = &m_bmp_white_bullet; + } + if (opt.first == "bed_shape" || opt.first == "compatible_printers") { + if (m_colored_Label != nullptr) { + m_colored_Label->SetForegroundColour(*color); + m_colored_Label->Refresh(true); + } + continue; + } + + Field* field = get_field(opt.first); + if (field == nullptr) continue; + field->m_is_nonsys_value = is_nonsys_value; + field->m_is_modified_value = is_modified_value; + field->set_undo_bitmap(icon); + field->set_undo_to_sys_bitmap(sys_icon); + field->set_label_colour(color); + } + Thaw(); +// m_options_list = m_options_list; +/* auto dirty_options = m_presets->current_dirty_options(); + + if (){ // Update dirty_options in case changes of Extruder's options TabPrinter* tab = static_cast(this); m_dirty_options.resize(0); @@ -381,71 +446,113 @@ void Tab::update_changed_ui() field->set_label_colour(color); } Thaw(); - +*/ wxTheApp->CallAfter([this]() { update_changed_tree_ui(); }); } +void Tab::init_options_list() +{ + if (!m_options_list.empty()) + m_options_list.clear(); + + for (const auto opt_key : m_config->keys()) + m_options_list.emplace(opt_key, m_opt_status_value); +} + template -void add_correct_opts_to_full_options_list(const std::string &opt_key, std::vector *vec, TabPrinter *tab) +void add_correct_opts_to_options_list(const std::string &opt_key, std::map& map, TabPrinter *tab, const int& value) { T *opt_cur = static_cast(tab->m_config->option(opt_key)); for (int i = 0; i < opt_cur->values.size(); i++) - vec->emplace_back(opt_key + "#" + std::to_string(i)); + map.emplace(opt_key + "#" + std::to_string(i), value); } -void Tab::update_full_options_list() +void TabPrinter::init_options_list() { - if (!m_full_options_list.empty()) - m_full_options_list.resize(0); + if (!m_options_list.empty()) + m_options_list.clear(); - if (m_name != "printer"){ - m_full_options_list = m_config->keys(); - return; - } - - TabPrinter* tab = static_cast(this); for (const auto opt_key : m_config->keys()) { if (opt_key == "bed_shape"){ - m_full_options_list.emplace_back(opt_key); + m_options_list.emplace(opt_key, m_opt_status_value); continue; } switch (m_config->option(opt_key)->type()) { - case coInts: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; - case coBools: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; - case coFloats: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; - case coStrings: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; - case coPercents:add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; - case coPoints: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; - default: m_full_options_list.emplace_back(opt_key); break; + case coInts: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; + case coBools: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; + case coFloats: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; + case coStrings: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; + case coPercents:add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; + case coPoints: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; + default: m_options_list.emplace(opt_key, m_opt_status_value); break; } } - m_full_options_list.emplace_back("extruders_count"); + m_options_list.emplace("extruders_count", m_opt_status_value); } -void Tab::update_sys_ui_after_sel_preset() -{ - const wxColour* clr = &m_default_text_clr; - for (const auto opt_key : m_full_options_list){ - Field* field = get_field(opt_key); - if (field != nullptr){ - field->set_undo_to_sys_bitmap(m_bmp_non_system); - field->m_is_nonsys_value = true; - field->set_label_colour(clr); - } - } - m_sys_options.resize(0); -} + +// template +// void add_correct_opts_to_full_options_list(const std::string &opt_key, std::vector *vec, TabPrinter *tab) +// { +// T *opt_cur = static_cast(tab->m_config->option(opt_key)); +// for (int i = 0; i < opt_cur->values.size(); i++) +// vec->emplace_back(opt_key + "#" + std::to_string(i)); +// } + +// void Tab::update_full_options_list() +// { +// if (!m_full_options_list.empty()) +// m_full_options_list.resize(0); +// +// if (m_name != "printer"){ +// m_full_options_list = m_config->keys(); +// return; +// } +// +// TabPrinter* tab = static_cast(this); +// for (const auto opt_key : m_config->keys()) +// { +// if (opt_key == "bed_shape"){ +// m_full_options_list.emplace_back(opt_key); +// continue; +// } +// switch (m_config->option(opt_key)->type()) +// { +// case coInts: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; +// case coBools: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; +// case coFloats: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; +// case coStrings: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; +// case coPercents:add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; +// case coPoints: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; +// default: m_full_options_list.emplace_back(opt_key); break; +// } +// } +// m_full_options_list.emplace_back("extruders_count"); +// } + +// void Tab::update_sys_ui_after_sel_preset() +// { +// const wxColour* clr = &m_default_text_clr; +// for (const auto opt_key : m_full_options_list){ +// Field* field = get_field(opt_key); +// if (field != nullptr){ +// field->set_undo_to_sys_bitmap(m_bmp_non_system); +// field->m_is_nonsys_value = true; +// field->set_label_colour(clr); +// } +// } +// m_sys_options.resize(0); +// } void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page) { - if (sys_page && find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) - sys_page = false; - if (!modified_page && find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) - modified_page = true; + auto opt = m_options_list.find(opt_key); + if (sys_page) sys_page = (opt->second & osSystemValue) != 0; + if (!modified_page) modified_page = (opt->second & osInitValue) == 0; } void Tab::update_changed_tree_ui() @@ -466,7 +573,7 @@ void Tab::update_changed_tree_ui() get_sys_and_mod_flags(opt_key, sys_page, modified_page); } } - if (title == _("Dependencies")){ + if (title == _("Dependencies") && name() != "printer"){ get_sys_and_mod_flags("compatible_printers", sys_page, modified_page); } for (auto group : page->m_optgroups) @@ -478,12 +585,13 @@ void Tab::update_changed_tree_ui() get_sys_and_mod_flags(opt_key, sys_page, modified_page); } } - if (sys_page) - m_treectrl->SetItemTextColour(cur_item, get_sys_label_clr()); - else if (modified_page) - m_treectrl->SetItemTextColour(cur_item, get_modified_label_clr()); - else - m_treectrl->SetItemTextColour(cur_item, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); + + const wxColor *clr = sys_page ? &m_sys_label_clr : + modified_page ? &m_modified_label_clr : + &m_default_text_clr; + + if (page->set_item_colour(clr)) + m_treectrl->SetItemTextColour(cur_item, *clr); page->m_is_nonsys_values = !sys_page; page->m_is_modified_values = modified_page; @@ -506,9 +614,17 @@ void Tab::update_undo_buttons() m_undo_to_sys_btn->SetBitmap(m_is_nonsys_values ? *m_bmp_non_system : m_bmp_value_lock); } -void Tab::on_back_to_initial_value() +void Tab::on_roll_back_value(const bool to_sys /*= true*/) { - if (!m_is_modified_values) return; + int os; + if (to_sys) { + if (!m_is_nonsys_values) return; + os = osSystemValue; + } + else { + if (!m_is_modified_values) return; + os = osInitValue; + } m_postpone_update_ui = true; @@ -517,19 +633,19 @@ void Tab::on_back_to_initial_value() if (page->title() == selection) { for (auto group : page->m_optgroups){ if (group->title == _("Capabilities")){ - if (find(m_dirty_options.begin(), m_dirty_options.end(), "extruders_count") != m_dirty_options.end()) - group->back_to_initial_value("extruders_count"); + if ((m_options_list["extruders_count"] & os) == 0) + to_sys ? group->back_to_sys_value("extruders_count") : group->back_to_initial_value("extruders_count"); } if (group->title == _("Size and coordinates")){ - if (find(m_dirty_options.begin(), m_dirty_options.end(), "bed_shape") != m_dirty_options.end()){ - group->back_to_initial_value("bed_shape"); + if ((m_options_list["bed_shape"] & os) == 0){ + to_sys ? group->back_to_sys_value("bed_shape") : group->back_to_initial_value("bed_shape"); load_key_value("bed_shape", true/*some value*/, true); } } - if (group->title == _("Profile dependencies")){ - if (find(m_dirty_options.begin(), m_dirty_options.end(), "compatible_printers") != m_dirty_options.end()){ - group->back_to_initial_value("compatible_printers"); + if (group->title == _("Profile dependencies") && name() != "printer"){ + if ((m_options_list["compatible_printers"] & os) == 0){ + to_sys ? group->back_to_sys_value("compatible_printers") : group->back_to_initial_value("compatible_printers"); load_key_value("compatible_printers", true/*some value*/, true); bool is_empty = m_config->option("compatible_printers")->values.empty(); @@ -539,8 +655,8 @@ void Tab::on_back_to_initial_value() } for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { const std::string& opt_key = it->first; - if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) - group->back_to_initial_value(opt_key); + if ((m_options_list[opt_key] & os) == 0) + to_sys ? group->back_to_sys_value(opt_key) : group->back_to_initial_value(opt_key); } } break; @@ -550,48 +666,111 @@ void Tab::on_back_to_initial_value() update_changed_ui(); } -void Tab::on_back_to_sys_value() -{ - if (!m_is_nonsys_values) return; - - m_postpone_update_ui = true; - - auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); - for (auto page : m_pages) - if (page->title() == selection) { - for (auto group : page->m_optgroups) { - if (group->title == _("Capabilities")){ - if (find(m_sys_options.begin(), m_sys_options.end(), "extruders_count") == m_sys_options.end()) - group->back_to_sys_value("extruders_count"); - } - if (group->title == _("Size and coordinates")){ - if (find(m_sys_options.begin(), m_sys_options.end(), "bed_shape") == m_sys_options.end()){ - group->back_to_sys_value("bed_shape"); - load_key_value("bed_shape", true/*some value*/, true); - } - } - if (group->title == _("Profile dependencies")){ - if (find(m_sys_options.begin(), m_sys_options.end(), "compatible_printers") == m_sys_options.end()){ - group->back_to_sys_value("compatible_printers"); - load_key_value("compatible_printers", true/*some value*/, true); - - bool is_empty = m_config->option("compatible_printers")->values.empty(); - m_compatible_printers_checkbox->SetValue(is_empty); - is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); - } - } - for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { - const std::string& opt_key = it->first; - if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) - group->back_to_sys_value(opt_key); - } - } - break; - } - - m_postpone_update_ui = false; - update_changed_ui(); -} +// void Tab::on_back_to_initial_value() +// { +// if (!m_is_modified_values) return; +// std::chrono::milliseconds ms1 = std::chrono::duration_cast( +// std::chrono::system_clock::now().time_since_epoch() +// ); +// +// m_postpone_update_ui = true; +// +// auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); +// for (auto page : m_pages) +// if (page->title() == selection) { +// for (auto group : page->m_optgroups){ +// if (group->title == _("Capabilities")){ +// if (find(m_dirty_options.begin(), m_dirty_options.end(), "extruders_count") != m_dirty_options.end()) +// group->back_to_initial_value("extruders_count"); +// } +// if (group->title == _("Size and coordinates")){ +// if (find(m_dirty_options.begin(), m_dirty_options.end(), "bed_shape") != m_dirty_options.end()){ +// group->back_to_initial_value("bed_shape"); +// load_key_value("bed_shape", true/*some value*/, true); +// } +// +// } +// if (group->title == _("Profile dependencies")){ +// if (find(m_dirty_options.begin(), m_dirty_options.end(), "compatible_printers") != m_dirty_options.end()){ +// group->back_to_initial_value("compatible_printers"); +// load_key_value("compatible_printers", true/*some value*/, true); +// +// bool is_empty = m_config->option("compatible_printers")->values.empty(); +// m_compatible_printers_checkbox->SetValue(is_empty); +// is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); +// } +// } +// for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { +// const std::string& opt_key = it->first; +// if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) +// group->back_to_initial_value(opt_key); +// } +// } +// break; +// } +// +// std::chrono::milliseconds ms2 = std::chrono::duration_cast( +// std::chrono::system_clock::now().time_since_epoch() +// ); +// +// m_postpone_update_ui = false; +// update_changed_ui(); +// +// std::chrono::milliseconds ms3 = std::chrono::duration_cast( +// std::chrono::system_clock::now().time_since_epoch() +// ); +// +// auto roll_back_duration = std::chrono::microseconds(ms2 - ms1).count(); +// auto update_ui_duration = std::chrono::microseconds(ms3 - ms2).count(); +// printf("back_to init_duration duration = %lld ms \n", roll_back_duration); +// printf("update_ui_duration duration = %lld ms \n", update_ui_duration); +// +// // m_postpone_update_ui = false; +// // update_changed_ui(); +// } +// +// void Tab::on_back_to_sys_value() +// { +// if (!m_is_nonsys_values) return; +// +// m_postpone_update_ui = true; +// +// auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); +// for (auto page : m_pages) +// if (page->title() == selection) { +// for (auto group : page->m_optgroups) { +// if (group->title == _("Capabilities")){ +// if (find(m_sys_options.begin(), m_sys_options.end(), "extruders_count") == m_sys_options.end()) +// group->back_to_sys_value("extruders_count"); +// } +// if (group->title == _("Size and coordinates")){ +// if (find(m_sys_options.begin(), m_sys_options.end(), "bed_shape") == m_sys_options.end()){ +// group->back_to_sys_value("bed_shape"); +// load_key_value("bed_shape", true/*some value*/, true); +// } +// } +// if (group->title == _("Profile dependencies")){ +// if (find(m_sys_options.begin(), m_sys_options.end(), "compatible_printers") == m_sys_options.end()){ +// group->back_to_sys_value("compatible_printers"); +// load_key_value("compatible_printers", true/*some value*/, true); +// +// bool is_empty = m_config->option("compatible_printers")->values.empty(); +// m_compatible_printers_checkbox->SetValue(is_empty); +// is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); +// } +// } +// for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { +// const std::string& opt_key = it->first; +// if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) +// group->back_to_sys_value(opt_key); +// } +// } +// break; +// } +// +// m_postpone_update_ui = false; +// update_changed_ui(); +// } // Update the combo box label of the selected preset based on its "dirty" state, // comparing the selected preset config with $self->{config}. @@ -1698,12 +1877,34 @@ void TabPrinter::extruders_count_changed(size_t extruders_count){ } void TabPrinter::build_extruder_pages(){ - for (auto extruder_idx = m_extruder_pages.size(); extruder_idx < m_extruders_count; ++extruder_idx){ + if (m_extruders_count_old == m_extruders_count) + { + // if we have a single extruder MM setup, add a page with configuration options: + for (int i = 0; i < m_pages.size(); ++i) // first make sure it's not there already + if (m_pages[i]->title().find(_(L("Single extruder MM setup"))) != std::string::npos) { + m_pages.erase(m_pages.begin() + i); + break; + } + if (m_extruders_count > 1 && m_config->opt_bool("single_extruder_multi_material")) { + // create a page, but pretend it's an extruder page, so we can add it to m_pages ourselves + auto page = add_options_page(_(L("Single extruder MM setup")), "printer_empty.png", true); + auto optgroup = page->new_optgroup(_(L("Single extruder multimaterial parameters"))); + optgroup->append_single_option_line("cooling_tube_retraction"); + optgroup->append_single_option_line("cooling_tube_length"); + optgroup->append_single_option_line("parking_pos_retraction"); + m_pages.insert(m_pages.end()-2, page); + } + rebuild_page_tree(); + return; + } + + for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx){ //# build page char buf[MIN_BUF_LENGTH_FOR_L]; sprintf(buf, _CHB(L("Extruder %d")), extruder_idx + 1); auto page = add_options_page(from_u8(buf), "funnel.png", true); - m_extruder_pages.push_back(page); + m_pages.insert(m_pages.begin() + 2+extruder_idx, page); +// m_extruder_pages.push_back(page); auto optgroup = page->new_optgroup(_(L("Size"))); optgroup->append_single_option_line("nozzle_diameter", extruder_idx); @@ -1741,36 +1942,31 @@ void TabPrinter::build_extruder_pages(){ } // # remove extra pages - if (m_extruders_count <= m_extruder_pages.size()) { - m_extruder_pages.resize(m_extruders_count); - } +// if (m_extruders_count <= m_extruders_count_old) { +// m_extruder_pages.resize(m_extruders_count); +// } + + if (m_extruders_count < m_extruders_count_old) + m_pages.erase(m_pages.begin() + 2 + m_extruders_count, m_pages.begin() + 2 + m_extruders_count_old); + + m_extruders_count_old = m_extruders_count; // # rebuild page list - PageShp page_note = m_pages.back(); - m_pages.pop_back(); - while (m_pages.back()->title().find(_(L("Extruder"))) != std::string::npos) - m_pages.pop_back(); - for (auto page_extruder : m_extruder_pages) - m_pages.push_back(page_extruder); - m_pages.push_back(page_note); - - { - // if we have a single extruder MM setup, add a page with configuration options: - for (int i=0;ititle().find(_(L("Single extruder MM setup"))) != std::string::npos) { - m_pages.erase(m_pages.begin()+i); - break; - } - if ( m_extruder_pages.size()>1 && m_config->opt_bool("single_extruder_multi_material")) { - // create a page, but pretend it's an extruder page, so we can add it to m_pages ourselves - auto page = add_options_page(_(L("Single extruder MM setup")), "printer_empty.png",true); - auto optgroup = page->new_optgroup(_(L("Single extruder multimaterial parameters"))); - optgroup->append_single_option_line("cooling_tube_retraction"); - optgroup->append_single_option_line("cooling_tube_length"); - optgroup->append_single_option_line("parking_pos_retraction"); - m_pages.insert(m_pages.begin()+1,page); - } - } +// PageShp page_note = m_pages.back(); +// m_pages.pop_back(); +// PageShp page_depend = m_pages.back(); +// m_pages.pop_back(); +// auto counter = m_extruders_count_old; +// while (counter > m_extruders_count/*m_pages.back()->title().find(_(L("Extruder"))) != std::string::npos*/){ +// m_pages.pop_back(); +// --counter; +// } +// // for (auto page_extruder : m_extruder_pages) +// // m_pages.push_back(page_extruder); +// for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx) +// m_pages.push_back(m_extruder_pages[extruder_idx]); +// m_pages.push_back(page_note); +// m_pages.push_back(page_depend); rebuild_page_tree(); } @@ -1899,8 +2095,10 @@ void Tab::load_current_preset() static_cast(this)->m_sys_extruders_count = parent_preset == nullptr ? 0 : static_cast(parent_preset->config.option("nozzle_diameter"))->values.size(); } - update_sys_ui_after_sel_preset(); - update_full_options_list(); +// update_sys_ui_after_sel_preset(); +// update_full_options_list(); + m_opt_status_value = (m_presets->get_selected_preset_parent() ? osSystemValue : 0) | osInitValue; + init_options_list(); update_changed_ui(); }); } @@ -1917,6 +2115,7 @@ void Tab::rebuild_page_tree() for (auto p : m_pages) { auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID()); + m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); if (p->title() == selected) { m_disable_tree_sel_changed_event = 1; m_treectrl->SelectItem(itemId); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 4668c1238a..2ac1e969b5 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -51,6 +51,7 @@ public: { Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); m_vsizer = new wxBoxSizer(wxVERTICAL); + m_item_color = &get_default_label_clr(); SetSizer(m_vsizer); } ~Page(){} @@ -71,6 +72,22 @@ public: Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; bool set_value(const t_config_option_key& opt_key, const boost::any& value); ConfigOptionsGroupShp new_optgroup(const wxString& title, int noncommon_label_width = -1); + + bool set_item_colour(const wxColour *clr) { + if (m_item_color != clr) { + m_item_color = clr; + return true; + } + return false; + } + + const wxColour get_item_colour() { + return *m_item_color; + } + +protected: + // Color of TreeCtrlItem. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. + const wxColour* m_item_color; }; // Slic3r::GUI::Tab; @@ -125,9 +142,13 @@ protected: bool m_no_controller; std::vector m_reload_dependent_tabs = {}; - std::vector m_dirty_options = {}; - std::vector m_sys_options = {}; - std::vector m_full_options_list = {}; +// std::vector m_dirty_options = {}; +// std::vector m_nonsys_options = {}; +// std::vector m_sys_options = {}; +// std::vector m_full_options_list = {}; + enum OptStatus { osSystemValue = 1, osInitValue = 2 }; + std::map m_options_list; + int m_opt_status_value; // The two following two event IDs are generated at Plater.pm by calling Wx::NewEventType. wxEventType m_event_value_change = 0; @@ -182,14 +203,15 @@ public: void update_show_hide_incompatible_button(); void update_ui_from_settings(); void update_changed_ui(); - void update_full_options_list(); - void update_sys_ui_after_sel_preset(); +// void update_full_options_list(); +// void update_sys_ui_after_sel_preset(); void get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page); void update_changed_tree_ui(); void update_undo_buttons(); - void on_back_to_initial_value(); - void on_back_to_sys_value(); + void on_roll_back_value(const bool to_sys = false); +// void on_back_to_initial_value(); +// void on_back_to_sys_value(); PageShp add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages = false); @@ -197,6 +219,7 @@ public: virtual void on_preset_loaded(){} virtual void build() = 0; virtual void update() = 0; + virtual void init_options_list(); void load_initial_data(); void update_dirty(); void update_tab_ui(); @@ -265,9 +288,10 @@ public: wxButton* m_octoprint_host_test_btn; size_t m_extruders_count; + size_t m_extruders_count_old = 0; size_t m_initial_extruders_count; size_t m_sys_extruders_count; - std::vector m_extruder_pages; +// std::vector m_extruder_pages; TabPrinter() {} TabPrinter(wxNotebook* parent, bool no_controller) : Tab(parent, _(L("Printer Settings")), "printer", no_controller) {} @@ -279,6 +303,7 @@ public: void extruders_count_changed(size_t extruders_count); void build_extruder_pages(); void on_preset_loaded() override; + void init_options_list() override; }; class SavePresetWindow :public wxDialog From fa97a867519ef5dc91bf7fab4c7c5d3a104f0c50 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 18 Apr 2018 13:35:51 +0200 Subject: [PATCH 0208/1150] Implemented merging of system profiles from various vendors. --- xs/src/slic3r/GUI/Preset.cpp | 23 +++++++++++++++++++++ xs/src/slic3r/GUI/Preset.hpp | 3 +++ xs/src/slic3r/GUI/PresetBundle.cpp | 33 +++++++++++++++++++++++++++++- xs/src/slic3r/GUI/PresetBundle.hpp | 4 +++- 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 7fa9c998d7..15dcb2fbbc 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -790,6 +790,29 @@ bool PresetCollection::select_preset_by_name_strict(const std::string &name) return false; } +// Merge one vendor's presets with the other vendor's presets, report duplicates. +std::vector PresetCollection::merge_presets(PresetCollection &&other, const std::set &new_vendors) +{ + std::vector duplicates; + for (Preset &preset : other.m_presets) { + if (preset.is_default || preset.is_external) + continue; + Preset key(m_type, preset.name); + auto it = std::lower_bound(m_presets.begin() + 1, m_presets.end(), key); + if (it == m_presets.end() || it->name != preset.name) { + if (preset.vendor != nullptr) { + // Re-assign a pointer to the vendor structure in the new PresetBundle. + auto it = new_vendors.find(*preset.vendor); + assert(it != new_vendors.end()); + preset.vendor = &(*it); + } + this->m_presets.emplace(it, std::move(preset)); + } else + duplicates.emplace_back(std::move(preset.name)); + } + return duplicates; +} + std::string PresetCollection::name() const { switch (this->type()) { diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index 480d6b1787..e80f138ee8 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -336,6 +336,9 @@ protected: // This is a temporary state, which shall be fixed immediately by the following step. bool select_preset_by_name_strict(const std::string &name); + // Merge one vendor's presets with the other vendor's presets, report duplicates. + std::vector merge_presets(PresetCollection &&other, const std::set &new_vendors); + private: PresetCollection(); PresetCollection(const PresetCollection &other); diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 6f0754a035..717e7a6f04 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -178,6 +178,7 @@ std::string PresetBundle::load_system_presets() // Here the vendor specific read only Config Bundles are stored. boost::filesystem::path dir = (boost::filesystem::path(data_dir()) / "vendor").make_preferred(); std::string errors_cummulative; + bool first = true; for (auto &dir_entry : boost::filesystem::directory_iterator(dir)) if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini")) { std::string name = dir_entry.path().filename().string(); @@ -185,7 +186,25 @@ std::string PresetBundle::load_system_presets() name.erase(name.size() - 4); try { // Load the config bundle, flatten it. - this->load_configbundle(dir_entry.path().string(), LOAD_CFGBNDLE_SYSTEM); + if (first) { + // Reset this PresetBundle and load the first vendor config. + this->load_configbundle(dir_entry.path().string(), LOAD_CFGBNDLE_SYSTEM); + first = false; + } else { + // Load the other vendor configs, merge them with this PresetBundle. + // Report duplicate profiles. + PresetBundle other; + other.load_configbundle(dir_entry.path().string(), LOAD_CFGBNDLE_SYSTEM); + std::vector duplicates = this->merge_presets(std::move(other)); + if (! duplicates.empty()) { + errors_cummulative += "Vendor configuration file " + name + " contains the following presets with names used by other vendors: "; + for (size_t i = 0; i < duplicates.size(); ++ i) { + if (i > 0) + errors_cummulative += ", "; + errors_cummulative += duplicates[i]; + } + } + } } catch (const std::runtime_error &err) { errors_cummulative += err.what(); errors_cummulative += "\n"; @@ -194,6 +213,18 @@ std::string PresetBundle::load_system_presets() return errors_cummulative; } +// Merge one vendor's presets with the other vendor's presets, report duplicates. +std::vector PresetBundle::merge_presets(PresetBundle &&other) +{ + this->vendors.insert(other.vendors.begin(), other.vendors.end()); + std::vector duplicate_prints = this->prints .merge_presets(std::move(other.prints), this->vendors); + std::vector duplicate_filaments = this->filaments.merge_presets(std::move(other.filaments), this->vendors); + std::vector duplicate_printers = this->printers .merge_presets(std::move(other.printers), this->vendors); + append(duplicate_prints, std::move(duplicate_filaments)); + append(duplicate_prints, std::move(duplicate_printers)); + return duplicate_prints; +} + static inline std::string remove_ini_suffix(const std::string &name) { std::string out = name; diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index 27add21eec..9f2afbead2 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -116,10 +116,12 @@ public: // preset if the current print or filament preset is not compatible. void update_compatible_with_printer(bool select_other_if_incompatible); - static bool parse_color(const std::string &scolor, unsigned char *rgb_out); + static bool parse_color(const std::string &scolor, unsigned char *rgb_out); private: std::string load_system_presets(); + // Merge one vendor's presets with the other vendor's presets, report duplicates. + std::vector merge_presets(PresetBundle &&other); // Set the "enabled" flag for printer vendors, printer models and printer variants // based on the user configuration. From f38f0edaaf3dc2b7c748e3b7c642ecbeaf140113 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 18 Apr 2018 14:15:13 +0200 Subject: [PATCH 0209/1150] Cleaned code from commented code --- xs/src/slic3r/GUI/Tab.cpp | 333 +------------------------------------- xs/src/slic3r/GUI/Tab.hpp | 9 -- 2 files changed, 7 insertions(+), 335 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index dcf61f5749..2cc51e0b5f 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -248,37 +248,6 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo return page; } -// template -// void add_correct_opts_to_dirty_options(const std::string &opt_key, std::vector *vec, TabPrinter *tab) -// { -// auto opt_init = static_cast(tab->m_presets->get_selected_preset().config.option(opt_key)); -// auto opt_cur = static_cast(tab->m_config->option(opt_key)); -// int opt_init_max_id = opt_init->values.size()-1; -// for (int i = 0; i < opt_cur->values.size(); i++) -// { -// int init_id = i <= opt_init_max_id ? i : 0; -// if (opt_cur->values[i] != opt_init->values[init_id]) -// vec->emplace_back(opt_key + "#" + std::to_string(i)); -// } -// } -// -// template -// void add_correct_opts_to_sys_options(const std::string &opt_key, std::vector *vec, TabPrinter *tab) -// { -// const Preset* sys_preset = tab->m_presets->get_selected_preset_parent(); -// if (sys_preset == nullptr) -// return; -// T *opt_cur = static_cast(tab->m_config->option(opt_key)); -// const T *opt_sys = static_cast(sys_preset->config.option(opt_key)); -// int opt_max_id = opt_sys->values.size()-1; -// for (int i = 0; i < opt_cur->values.size(); i++) -// { -// int init_id = i <= opt_max_id ? i : 0; -// if (opt_cur->values[i] == opt_sys->values[init_id]) -// vec->emplace_back(opt_key + "#" + std::to_string(i)); -// } -// } - // Update UI according to changes void Tab::update_changed_ui() { @@ -286,26 +255,25 @@ void Tab::update_changed_ui() return; const bool is_printer_type = (name() == "printer"); - auto m_dirty_options = m_presets->current_dirty_options(is_printer_type); - auto m_nonsys_options = m_presets->current_different_from_parent_options(is_printer_type); + auto dirty_options = m_presets->current_dirty_options(is_printer_type); + auto nonsys_options = m_presets->current_different_from_parent_options(is_printer_type); if (is_printer_type){ TabPrinter* tab = static_cast(this); if (tab->m_initial_extruders_count != tab->m_extruders_count) - m_dirty_options.emplace_back("extruders_count"); + dirty_options.emplace_back("extruders_count"); if (tab->m_sys_extruders_count != tab->m_extruders_count) - m_nonsys_options.emplace_back("extruders_count"); + nonsys_options.emplace_back("extruders_count"); } for (auto& it : m_options_list) it.second = m_opt_status_value; -// auto m_options_list = m_options_list; - for (auto opt_key : m_dirty_options) m_options_list[opt_key] &= ~osInitValue; - for (auto opt_key : m_nonsys_options) m_options_list[opt_key] &= ~osSystemValue; + for (auto opt_key : dirty_options) m_options_list[opt_key] &= ~osInitValue; + for (auto opt_key : nonsys_options) m_options_list[opt_key] &= ~osSystemValue; Freeze(); //update options "decoration" - for (const auto opt : m_options_list/*m_options_list*/) + for (const auto opt : m_options_list) { bool is_nonsys_value = false; bool is_modified_value = true; @@ -314,17 +282,14 @@ void Tab::update_changed_ui() const wxColour *color = &m_sys_label_clr; if ((opt.second & osSystemValue) == 0){ -// if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { is_nonsys_value = true; sys_icon = m_bmp_non_system; if ((opt.second & osInitValue) != 0) -// if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) color = &m_default_text_clr; else color = &m_modified_label_clr; } if ((opt.second & osInitValue) != 0) -// if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) { is_modified_value = false; icon = &m_bmp_white_bullet; @@ -346,107 +311,7 @@ void Tab::update_changed_ui() field->set_label_colour(color); } Thaw(); -// m_options_list = m_options_list; -/* auto dirty_options = m_presets->current_dirty_options(); - if (){ - // Update dirty_options in case changes of Extruder's options - TabPrinter* tab = static_cast(this); - m_dirty_options.resize(0); - for (auto opt_key : dirty_options) - { - if (opt_key == "bed_shape"){ m_dirty_options.emplace_back(opt_key); continue; } - switch (m_config->option(opt_key)->type()) - { - case coInts: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; - case coBools: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; - case coFloats: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; - case coStrings: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; - case coPercents:add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; - case coPoints: add_correct_opts_to_dirty_options(opt_key, &m_dirty_options, tab); break; - default: m_dirty_options.emplace_back(opt_key); break; - } - } - if (tab->m_initial_extruders_count != tab->m_extruders_count) - m_dirty_options.emplace_back("extruders_count"); - - m_sys_options.resize(0); - const auto sys_preset = m_presets->get_selected_preset_parent(); - if (sys_preset){ - for (auto opt_key : m_config->keys()) - { - if (opt_key == "bed_shape"){ - if (*tab->m_config->option(opt_key) == *sys_preset->config.option(opt_key)) - m_sys_options.emplace_back(opt_key); - continue; - } - switch (m_config->option(opt_key)->type()) - { - case coInts: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; - case coBools: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; - case coFloats: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; - case coStrings: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; - case coPercents:add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; - case coPoints: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; - default:{ - const ConfigOption *opt_cur = tab->m_config->option(opt_key); - const ConfigOption *opt_sys = sys_preset->config.option(opt_key); - if (opt_cur != nullptr && opt_sys != nullptr && *opt_cur == *opt_sys) - m_sys_options.emplace_back(opt_key); - break; - } - } - } - - if (tab->m_sys_extruders_count == tab->m_extruders_count) - m_sys_options.emplace_back("extruders_count"); - } - } - else{ - m_sys_options = m_presets->system_equal_options(); - m_dirty_options = dirty_options; - } - - Freeze(); - //update options "decoration" - for (const auto opt_key : m_full_options_list) - { - bool is_nonsys_value = false; - bool is_modified_value = true; - const wxBitmap *sys_icon = &m_bmp_value_lock; - const wxBitmap *icon = &m_bmp_value_revert; - const wxColour *color = &m_sys_label_clr; - if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) { - is_nonsys_value = true; - sys_icon = m_bmp_non_system; - if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) - color = &m_default_text_clr; - else - color = &m_modified_label_clr; - } - if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end()) - { - is_modified_value = false; - icon = &m_bmp_white_bullet; - } - if (opt_key == "bed_shape" || opt_key == "compatible_printers") { - if (m_colored_Label != nullptr) { - m_colored_Label->SetForegroundColour(*color); - m_colored_Label->Refresh(true); - } - continue; - } - - Field* field = get_field(opt_key); - if (field == nullptr) continue; - field->m_is_nonsys_value = is_nonsys_value; - field->m_is_modified_value = is_modified_value; - field->set_undo_bitmap(icon); - field->set_undo_to_sys_bitmap(sys_icon); - field->set_label_colour(color); - } - Thaw(); -*/ wxTheApp->CallAfter([this]() { update_changed_tree_ui(); }); @@ -494,60 +359,6 @@ void TabPrinter::init_options_list() m_options_list.emplace("extruders_count", m_opt_status_value); } - -// template -// void add_correct_opts_to_full_options_list(const std::string &opt_key, std::vector *vec, TabPrinter *tab) -// { -// T *opt_cur = static_cast(tab->m_config->option(opt_key)); -// for (int i = 0; i < opt_cur->values.size(); i++) -// vec->emplace_back(opt_key + "#" + std::to_string(i)); -// } - -// void Tab::update_full_options_list() -// { -// if (!m_full_options_list.empty()) -// m_full_options_list.resize(0); -// -// if (m_name != "printer"){ -// m_full_options_list = m_config->keys(); -// return; -// } -// -// TabPrinter* tab = static_cast(this); -// for (const auto opt_key : m_config->keys()) -// { -// if (opt_key == "bed_shape"){ -// m_full_options_list.emplace_back(opt_key); -// continue; -// } -// switch (m_config->option(opt_key)->type()) -// { -// case coInts: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; -// case coBools: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; -// case coFloats: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; -// case coStrings: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; -// case coPercents:add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; -// case coPoints: add_correct_opts_to_full_options_list(opt_key, &m_full_options_list, tab); break; -// default: m_full_options_list.emplace_back(opt_key); break; -// } -// } -// m_full_options_list.emplace_back("extruders_count"); -// } - -// void Tab::update_sys_ui_after_sel_preset() -// { -// const wxColour* clr = &m_default_text_clr; -// for (const auto opt_key : m_full_options_list){ -// Field* field = get_field(opt_key); -// if (field != nullptr){ -// field->set_undo_to_sys_bitmap(m_bmp_non_system); -// field->m_is_nonsys_value = true; -// field->set_label_colour(clr); -// } -// } -// m_sys_options.resize(0); -// } - void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page) { auto opt = m_options_list.find(opt_key); @@ -666,112 +477,6 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/) update_changed_ui(); } -// void Tab::on_back_to_initial_value() -// { -// if (!m_is_modified_values) return; -// std::chrono::milliseconds ms1 = std::chrono::duration_cast( -// std::chrono::system_clock::now().time_since_epoch() -// ); -// -// m_postpone_update_ui = true; -// -// auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); -// for (auto page : m_pages) -// if (page->title() == selection) { -// for (auto group : page->m_optgroups){ -// if (group->title == _("Capabilities")){ -// if (find(m_dirty_options.begin(), m_dirty_options.end(), "extruders_count") != m_dirty_options.end()) -// group->back_to_initial_value("extruders_count"); -// } -// if (group->title == _("Size and coordinates")){ -// if (find(m_dirty_options.begin(), m_dirty_options.end(), "bed_shape") != m_dirty_options.end()){ -// group->back_to_initial_value("bed_shape"); -// load_key_value("bed_shape", true/*some value*/, true); -// } -// -// } -// if (group->title == _("Profile dependencies")){ -// if (find(m_dirty_options.begin(), m_dirty_options.end(), "compatible_printers") != m_dirty_options.end()){ -// group->back_to_initial_value("compatible_printers"); -// load_key_value("compatible_printers", true/*some value*/, true); -// -// bool is_empty = m_config->option("compatible_printers")->values.empty(); -// m_compatible_printers_checkbox->SetValue(is_empty); -// is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); -// } -// } -// for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { -// const std::string& opt_key = it->first; -// if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) -// group->back_to_initial_value(opt_key); -// } -// } -// break; -// } -// -// std::chrono::milliseconds ms2 = std::chrono::duration_cast( -// std::chrono::system_clock::now().time_since_epoch() -// ); -// -// m_postpone_update_ui = false; -// update_changed_ui(); -// -// std::chrono::milliseconds ms3 = std::chrono::duration_cast( -// std::chrono::system_clock::now().time_since_epoch() -// ); -// -// auto roll_back_duration = std::chrono::microseconds(ms2 - ms1).count(); -// auto update_ui_duration = std::chrono::microseconds(ms3 - ms2).count(); -// printf("back_to init_duration duration = %lld ms \n", roll_back_duration); -// printf("update_ui_duration duration = %lld ms \n", update_ui_duration); -// -// // m_postpone_update_ui = false; -// // update_changed_ui(); -// } -// -// void Tab::on_back_to_sys_value() -// { -// if (!m_is_nonsys_values) return; -// -// m_postpone_update_ui = true; -// -// auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); -// for (auto page : m_pages) -// if (page->title() == selection) { -// for (auto group : page->m_optgroups) { -// if (group->title == _("Capabilities")){ -// if (find(m_sys_options.begin(), m_sys_options.end(), "extruders_count") == m_sys_options.end()) -// group->back_to_sys_value("extruders_count"); -// } -// if (group->title == _("Size and coordinates")){ -// if (find(m_sys_options.begin(), m_sys_options.end(), "bed_shape") == m_sys_options.end()){ -// group->back_to_sys_value("bed_shape"); -// load_key_value("bed_shape", true/*some value*/, true); -// } -// } -// if (group->title == _("Profile dependencies")){ -// if (find(m_sys_options.begin(), m_sys_options.end(), "compatible_printers") == m_sys_options.end()){ -// group->back_to_sys_value("compatible_printers"); -// load_key_value("compatible_printers", true/*some value*/, true); -// -// bool is_empty = m_config->option("compatible_printers")->values.empty(); -// m_compatible_printers_checkbox->SetValue(is_empty); -// is_empty ? m_compatible_printers_btn->Disable() : m_compatible_printers_btn->Enable(); -// } -// } -// for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { -// const std::string& opt_key = it->first; -// if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) -// group->back_to_sys_value(opt_key); -// } -// } -// break; -// } -// -// m_postpone_update_ui = false; -// update_changed_ui(); -// } - // Update the combo box label of the selected preset based on its "dirty" state, // comparing the selected preset config with $self->{config}. void Tab::update_dirty(){ @@ -1904,7 +1609,6 @@ void TabPrinter::build_extruder_pages(){ sprintf(buf, _CHB(L("Extruder %d")), extruder_idx + 1); auto page = add_options_page(from_u8(buf), "funnel.png", true); m_pages.insert(m_pages.begin() + 2+extruder_idx, page); -// m_extruder_pages.push_back(page); auto optgroup = page->new_optgroup(_(L("Size"))); optgroup->append_single_option_line("nozzle_diameter", extruder_idx); @@ -1942,32 +1646,11 @@ void TabPrinter::build_extruder_pages(){ } // # remove extra pages -// if (m_extruders_count <= m_extruders_count_old) { -// m_extruder_pages.resize(m_extruders_count); -// } - if (m_extruders_count < m_extruders_count_old) m_pages.erase(m_pages.begin() + 2 + m_extruders_count, m_pages.begin() + 2 + m_extruders_count_old); m_extruders_count_old = m_extruders_count; - // # rebuild page list -// PageShp page_note = m_pages.back(); -// m_pages.pop_back(); -// PageShp page_depend = m_pages.back(); -// m_pages.pop_back(); -// auto counter = m_extruders_count_old; -// while (counter > m_extruders_count/*m_pages.back()->title().find(_(L("Extruder"))) != std::string::npos*/){ -// m_pages.pop_back(); -// --counter; -// } -// // for (auto page_extruder : m_extruder_pages) -// // m_pages.push_back(page_extruder); -// for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx) -// m_pages.push_back(m_extruder_pages[extruder_idx]); -// m_pages.push_back(page_note); -// m_pages.push_back(page_depend); - rebuild_page_tree(); } @@ -2095,8 +1778,6 @@ void Tab::load_current_preset() static_cast(this)->m_sys_extruders_count = parent_preset == nullptr ? 0 : static_cast(parent_preset->config.option("nozzle_diameter"))->values.size(); } -// update_sys_ui_after_sel_preset(); -// update_full_options_list(); m_opt_status_value = (m_presets->get_selected_preset_parent() ? osSystemValue : 0) | osInitValue; init_options_list(); update_changed_ui(); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 2ac1e969b5..2eef29500f 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -142,10 +142,6 @@ protected: bool m_no_controller; std::vector m_reload_dependent_tabs = {}; -// std::vector m_dirty_options = {}; -// std::vector m_nonsys_options = {}; -// std::vector m_sys_options = {}; -// std::vector m_full_options_list = {}; enum OptStatus { osSystemValue = 1, osInitValue = 2 }; std::map m_options_list; int m_opt_status_value; @@ -203,15 +199,11 @@ public: void update_show_hide_incompatible_button(); void update_ui_from_settings(); void update_changed_ui(); -// void update_full_options_list(); -// void update_sys_ui_after_sel_preset(); void get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page); void update_changed_tree_ui(); void update_undo_buttons(); void on_roll_back_value(const bool to_sys = false); -// void on_back_to_initial_value(); -// void on_back_to_sys_value(); PageShp add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages = false); @@ -291,7 +283,6 @@ public: size_t m_extruders_count_old = 0; size_t m_initial_extruders_count; size_t m_sys_extruders_count; -// std::vector m_extruder_pages; TabPrinter() {} TabPrinter(wxNotebook* parent, bool no_controller) : Tab(parent, _(L("Printer Settings")), "printer", no_controller) {} From 8ab62d702c4a97579a7afbb455982c4d006ac911 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 18 Apr 2018 18:06:07 +0200 Subject: [PATCH 0210/1150] Fixed memory leak of TabIface. Added documentation of the XS interface on how the Ref<> and Clone<> wrappers work. --- xs/src/xsinit.h | 26 ++++++++++++++++++++++++-- xs/xsp/GUI.xsp | 2 +- xs/xsp/typemap.xspt | 1 - 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/xs/src/xsinit.h b/xs/src/xsinit.h index 96c4b74d74..9cb60384f6 100644 --- a/xs/src/xsinit.h +++ b/xs/src/xsinit.h @@ -85,8 +85,12 @@ namespace Slic3r { template struct ClassTraits { + // Name of a Perl alias of a C++ class type, owned by Perl, reference counted. static const char* name; - static const char* name_ref; + // Name of a Perl alias of a C++ class type, owned by the C++ code. + // The references shall be enumerated at the end of XS.pm, where the desctructor is undefined with sub DESTROY {}, + // so Perl will never delete the object instance. + static const char* name_ref; }; // use this for typedefs for which the forward prototype @@ -99,11 +103,16 @@ struct ClassTraits { class cname; \ __REGISTER_CLASS(cname, perlname); +// Return Perl alias to a C++ class name. template const char* perl_class_name(const T*) { return ClassTraits::name; } +// Return Perl alias to a C++ class name, suffixed with ::Ref. +// Such a C++ class instance will not be destroyed by Perl, the instance destruction is left to the C++ code. template const char* perl_class_name_ref(const T*) { return ClassTraits::name_ref; } +// Mark the Perl SV (Scalar Value) as owning a "blessed" pointer to an object reference. +// Perl will never release the C++ instance. template SV* perl_to_SV_ref(T &t) { SV* sv = newSV(0); @@ -111,6 +120,8 @@ SV* perl_to_SV_ref(T &t) { return sv; } +// Mark the Perl SV (Scalar Value) as owning a "blessed" pointer to an object instance. +// Perl will own the C++ instance, therefore it will also release it. template SV* perl_to_SV_clone_ref(const T &t) { SV* sv = newSV(0); @@ -118,6 +129,8 @@ SV* perl_to_SV_clone_ref(const T &t) { return sv; } +// Reference wrapper to provide a C++ instance to Perl while keeping Perl from destroying the instance. +// The instance is created temporarily by XS.cpp just to provide Perl with a CLASS name and a object instance pointer. template class Ref { T* val; @@ -125,10 +138,15 @@ public: Ref() : val(NULL) {} Ref(T* t) : val(t) {} Ref(const T* t) : val(const_cast(t)) {} + // Called by XS.cpp to convert the referenced object instance to a Perl SV, before it is blessed with the name + // returned by CLASS() operator T*() const { return val; } + // Name to bless the Perl SV with. The name ends with a "::Ref" suffix to keep Perl from destroying the object instance. static const char* CLASS() { return ClassTraits::name_ref; } }; - + +// Wrapper to clone a C++ object instance before passing it to Perl for ownership. +// This wrapper instance is created temporarily by XS.cpp to provide Perl with a CLASS name and a object instance pointer. template class Clone { T* val; @@ -136,7 +154,11 @@ public: Clone() : val(NULL) {} Clone(T* t) : val(new T(*t)) {} Clone(const T& t) : val(new T(t)) {} + // Called by XS.cpp to convert the cloned object instance to a Perl SV, before it is blessed with the name + // returned by CLASS() operator T*() const { return val; } + // Name to bless the Perl SV with. If there is a destructor registered in the XSP file for this class, then Perl will + // call this destructor when the reference counter of this SV drops to zero. static const char* CLASS() { return ClassTraits::name; } }; diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 1376ff164b..406d718286 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -39,7 +39,7 @@ void add_debug_menu(SV *ui, int event_language_change) void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) %code%{ Slic3r::GUI::create_preset_tabs(no_controller, event_value_change, event_presets_changed); %}; -Ref get_preset_tab(char *name) +TabIface* get_preset_tab(char *name) %code%{ RETVAL=Slic3r::GUI::get_preset_tab_iface(name); %}; bool load_language() diff --git a/xs/xsp/typemap.xspt b/xs/xsp/typemap.xspt index 0214a158d6..797f3c19f1 100644 --- a/xs/xsp/typemap.xspt +++ b/xs/xsp/typemap.xspt @@ -211,7 +211,6 @@ %typemap{PresetHints*}; %typemap{Ref}{simple}; %typemap{TabIface*}; -%typemap{Ref}{simple}; %typemap{PrintRegionPtrs*}; %typemap{PrintObjectPtrs*}; From c3c9ebdd12616aaa79ea0e6d2a06d3db06d36f31 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 18 Apr 2018 18:48:32 +0200 Subject: [PATCH 0211/1150] Fix wxPerl warning annoyance --- lib/Slic3r.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index e55e24a7ad..19915ddd86 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -277,5 +277,6 @@ sub system_info # this package declaration prevents an ugly fatal warning to be emitted when # spawning a new thread package GLUquadricObjPtr; +package Wx::Printout; 1; From d1580f67dfd21420e2b813dba4b682602f0c8973 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 18 Apr 2018 18:57:34 +0200 Subject: [PATCH 0212/1150] Fix of the previous commit. Once the Slic3r::GUI::Tab was rewritten from Ref to TabIface*, Perl takes ownership and the Tab is being incorrectly deleted by the background threads. --- lib/Slic3r.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index e55e24a7ad..5e91f56ce6 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -162,6 +162,7 @@ sub thread_cleanup { *Slic3r::TriangleMesh::DESTROY = sub {}; *Slic3r::GUI::AppConfig::DESTROY = sub {}; *Slic3r::GUI::PresetBundle::DESTROY = sub {}; + *Slic3r::GUI::Tab::DESTROY = sub {}; return undef; # this prevents a "Scalars leaked" warning } From 7083f58326c07050349fe8c0d999a1ee49702e5c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 19 Apr 2018 12:08:59 +0200 Subject: [PATCH 0213/1150] Added lock icons to system presets in ComboBoxes. Added right event handling if informative string is selected in ComboBoxes --- xs/src/slic3r/GUI/Preset.cpp | 109 ++++++++++++++++++++--------- xs/src/slic3r/GUI/Preset.hpp | 8 ++- xs/src/slic3r/GUI/PresetBundle.cpp | 25 ++++--- xs/src/slic3r/GUI/Tab.cpp | 10 ++- xs/src/slic3r/GUI/Tab.hpp | 2 + 5 files changed, 106 insertions(+), 48 deletions(-) diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 30f49df08f..04c5865b84 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -2,6 +2,7 @@ #include #include "Preset.hpp" +#include "BitmapCache.hpp" #include #include @@ -252,7 +253,8 @@ PresetCollection::PresetCollection(Preset::Type type, const std::vectorFreeze(); ui->Clear(); - std::map nonsys_presets; + + const Preset &selected_preset = this->get_selected_preset(); + // Show wide icons if the currently selected preset is not compatible with the current printer, + // and draw a red flag in front of the selected preset. + bool wide_icons = !selected_preset.is_compatible && m_bitmap_incompatible != nullptr; + + std::map nonsys_presets; wxString selected = ""; - for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++ i) { + if (!this->m_presets.front().is_visible) + ui->Append("------- System presets -------", wxNullBitmap); + for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++i) { const Preset &preset = this->m_presets[i]; if (! preset.is_visible || (! preset.is_compatible && i != m_idx_selected)) continue; - const wxBitmap *bmp = (i == 0 || preset.is_compatible) ? m_bitmap_main_frame : m_bitmap_incompatible; -// ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), -// (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); -// if (i == m_idx_selected) -// ui->SetSelection(ui->GetCount() - 1); + std::string bitmap_key = ""; + // If the filament preset is not compatible and there is a "red flag" icon loaded, show it left + // to the filament color image. + if (wide_icons) + bitmap_key += preset.is_compatible ? ",cmpt" : ",ncmpt"; + bitmap_key += (preset.is_system || preset.is_default) ? ",syst" : ",nsyst"; + wxBitmap *bmp = m_bitmap_cache->find(bitmap_key); + if (bmp == nullptr) { + // Create the bitmap with color bars. + std::vector bmps; + if (wide_icons) + // Paint a red flag for incompatible presets. + bmps.emplace_back(preset.is_compatible ? m_bitmap_cache->mkclear(16, 16) : *m_bitmap_incompatible); + // Paint the color bars. + bmps.emplace_back(m_bitmap_cache->mkclear(4, 16)); + bmps.emplace_back(*m_bitmap_main_frame); + // Paint a lock at the system presets. + bmps.emplace_back(m_bitmap_cache->mkclear(6, 16)); + bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmap_lock : m_bitmap_cache->mkclear(16, 16)); + bmp = m_bitmap_cache->insert(bitmap_key, bmps); + } if (preset.is_default || preset.is_system){ ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), @@ -531,20 +559,18 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) } else { - nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), preset.is_compatible); + nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), bmp/*preset.is_compatible*/); if (i == m_idx_selected) selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); } if (preset.is_default) - ui->Append("------------------------------------", wxNullBitmap); + ui->Append("------- System presets -------", wxNullBitmap); } if (!nonsys_presets.empty()) { - ui->Append("------------------------------------", wxNullBitmap); - for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { - const wxBitmap *bmp = it->second ? m_bitmap_compatible : m_bitmap_incompatible; - ui->Append(it->first, - (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); + ui->Append("------- User presets -------", wxNullBitmap); + for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { + ui->Append(it->first, *it->second); if (it->first == selected) ui->SetSelection(ui->GetCount() - 1); } @@ -552,51 +578,63 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) ui->Thaw(); } -void PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompatible) +size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompatible) { if (ui == nullptr) - return; + return 0; ui->Freeze(); ui->Clear(); - std::map nonsys_presets; + size_t selected_preset_item = 0; + + std::map nonsys_presets; wxString selected = ""; - for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++ i) { + if (!this->m_presets.front().is_visible) + ui->Append("------- System presets -------", wxNullBitmap); + for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++i) { const Preset &preset = this->m_presets[i]; if (! preset.is_visible || (! show_incompatible && ! preset.is_compatible && i != m_idx_selected)) continue; - const wxBitmap *bmp = preset.is_compatible ? m_bitmap_compatible : m_bitmap_incompatible; -// ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), -// (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); -// if (i == m_idx_selected) -// ui->SetSelection(ui->GetCount() - 1); + std::string bitmap_key = "tab"; + bitmap_key += preset.is_compatible ? ",cmpt" : ",ncmpt"; + bitmap_key += (preset.is_system || preset.is_default) ? ",syst" : ",nsyst"; + wxBitmap *bmp = m_bitmap_cache->find(bitmap_key); + if (bmp == nullptr) { + // Create the bitmap with color bars. + std::vector bmps; + const wxBitmap* tmp_bmp = preset.is_compatible ? m_bitmap_compatible : m_bitmap_incompatible; + bmps.emplace_back((tmp_bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *tmp_bmp); + // Paint a lock at the system presets. + bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmap_lock : m_bitmap_cache->mkclear(16, 16)); + bmp = m_bitmap_cache->insert(bitmap_key, bmps); + } if (preset.is_default || preset.is_system){ ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); if (i == m_idx_selected) - ui->SetSelection(ui->GetCount() - 1); + selected_preset_item = ui->GetCount() - 1; } else { - nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), preset.is_compatible); + nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), bmp/*preset.is_compatible*/); if (i == m_idx_selected) selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); } if (preset.is_default) - ui->Append("------------------------------------", wxNullBitmap); + ui->Append("------- System presets -------", wxNullBitmap); } if (!nonsys_presets.empty()) { - ui->Append("------------------------------------", wxNullBitmap); - for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { - const wxBitmap *bmp = it->second ? m_bitmap_compatible : m_bitmap_incompatible; - ui->Append(it->first, - (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); + ui->Append("------- User presets -------", wxNullBitmap); + for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { + ui->Append(it->first, *it->second); if (it->first == selected) - ui->SetSelection(ui->GetCount() - 1); + selected_preset_item = ui->GetCount() - 1; } } + ui->SetSelection(selected_preset_item); ui->Thaw(); + return selected_preset_item; } // Update a dirty floag of the current preset, update the labels of the UI component accordingly. @@ -692,6 +730,11 @@ bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, b // If the first visible preset was not found, return the 0th element, which is the default preset. } + // Temporary decision + if (name_w_suffix == "------- System presets -------" || + name_w_suffix == "------- User presets -------") + return true; + // 2) Select the new preset. if (m_idx_selected != idx || force) { this->select_preset(idx); diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp index e12f18b885..cc409addc4 100644 --- a/xs/src/slic3r/GUI/Preset.hpp +++ b/xs/src/slic3r/GUI/Preset.hpp @@ -13,6 +13,10 @@ class wxItemContainer; namespace Slic3r { +namespace GUI { + class BitmapCache; +} + enum ConfigFileType { CONFIG_FILE_TYPE_UNKNOWN, @@ -264,7 +268,7 @@ public: // Update the choice UI from the list of presets. // If show_incompatible, all presets are shown, otherwise only the compatible presets are shown. // If an incompatible preset is selected, it is shown as well. - void update_tab_ui(wxBitmapComboBox *ui, bool show_incompatible); + size_t update_tab_ui(wxBitmapComboBox *ui, bool show_incompatible); // Update the choice UI from the list of presets. // Only the compatible presets are shown. // If an incompatible preset is selected, it is shown as well. @@ -324,6 +328,8 @@ private: wxBitmap *m_bitmap_main_frame; // Path to the directory to store the config files into. std::string m_dir_path; + // Caching color bitmaps for the filament combo box. + GUI::BitmapCache *m_bitmap_cache = nullptr; }; } // namespace Slic3r diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 1c3a6dcac8..d6cde84a89 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -1025,9 +1025,11 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma // and draw a red flag in front of the selected preset. bool wide_icons = selected_preset != nullptr && ! selected_preset->is_compatible && m_bitmapIncompatible != nullptr; assert(selected_preset != nullptr); - std::map nonsys_presets; + std::map nonsys_presets; wxString selected_str = ""; - for (int i = this->filaments().front().is_visible ? 0 : 1; i < int(this->filaments().size()); ++ i) { + if (!this->filaments().front().is_visible) + ui->Append("------- System presets -------", wxNullBitmap); + for (int i = this->filaments().front().is_visible ? 0 : 1; i < int(this->filaments().size()); ++i) { const Preset &preset = this->filaments.preset(i); bool selected = this->filament_presets[idx_extruder] == preset.name; if (! preset.is_visible || (! preset.is_compatible && ! selected)) @@ -1059,14 +1061,11 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma bmps.emplace_back(m_bitmapCache->mksolid(8, 16, rgb)); } // Paint a lock at the system presets. - bmps.emplace_back(m_bitmapCache->mkclear(4, 16)); - bmps.emplace_back((preset.is_system || preset.is_default) ? - (preset.is_dirty ? *m_bitmapLockOpen : *m_bitmapLock) : m_bitmapCache->mkclear(16, 16)); + bmps.emplace_back(m_bitmapCache->mkclear(2, 16)); + bmps.emplace_back((preset.is_system || preset.is_default) ? *m_bitmapLock : m_bitmapCache->mkclear(16, 16)); +// (preset.is_dirty ? *m_bitmapLockOpen : *m_bitmapLock) : m_bitmapCache->mkclear(16, 16)); bitmap = m_bitmapCache->insert(bitmap_key, bmps); } -// ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), (bitmap == 0) ? wxNullBitmap : *bitmap); -// if (selected) -// ui->SetSelection(ui->GetCount() - 1); if (preset.is_default || preset.is_system){ ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), @@ -1077,19 +1076,19 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma else { nonsys_presets.emplace(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), - (bitmap == 0) ? wxNullBitmap : *bitmap); + (bitmap == 0) ? &wxNullBitmap : bitmap); if (selected) selected_str = wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()); } if (preset.is_default) - ui->Append("------------------------------------", wxNullBitmap); + ui->Append("------- System presets -------", wxNullBitmap); } if (!nonsys_presets.empty()) { - ui->Append("------------------------------------", wxNullBitmap); - for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { - ui->Append(it->first, it->second); + ui->Append("------- User presets -------", wxNullBitmap); + for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { + ui->Append(it->first, *it->second); if (it->first == selected_str) ui->SetSelection(ui->GetCount() - 1); } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 2cc51e0b5f..810ee6e141 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -198,8 +198,16 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) //! select_preset(m_presets_choice->GetStringSelection().ToStdString()); //! we doing next: int selected_item = m_presets_choice->GetSelection(); + if (m_selected_preset_item == selected_item) + return; if (selected_item >= 0){ std::string selected_string = m_presets_choice->GetString(selected_item).ToUTF8().data(); + if (selected_string == "------- System presets -------" || + selected_string == "------- User presets -------"){ + m_presets_choice->SetSelection(m_selected_preset_item); + return; + } + m_selected_preset_item = selected_item; select_preset(selected_string); } })); @@ -488,7 +496,7 @@ void Tab::update_dirty(){ void Tab::update_tab_ui() { - m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets); + m_selected_preset_item = m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets); // update_tab_presets(m_cc_presets_choice, m_show_incompatible_presets); // update_presetsctrl(m_presetctrl, m_show_incompatible_presets); } diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 2eef29500f..d5a679564f 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -154,6 +154,8 @@ protected: bool m_is_nonsys_values{ true }; bool m_postpone_update_ui {false}; + size_t m_selected_preset_item{ 0 }; + public: PresetBundle* m_preset_bundle; bool m_show_btn_incompatible_presets = false; From ad4cd058505ae33ce7e0b23fc513384f2de44805 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 19 Apr 2018 13:31:50 +0200 Subject: [PATCH 0214/1150] Fixed hovering while panning/rotating camera --- lib/Slic3r/GUI/3DScene.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index d8af6f71cc..65abf850ec 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -70,6 +70,7 @@ __PACKAGE__->mk_accessors( qw(_quat _dirty init _legend_enabled _warning_enabled _apply_zoom_to_volumes_filter + _mouse_dragging ) ); @@ -146,6 +147,7 @@ sub new { $self->_warning_enabled(0); $self->use_plain_shader(0); $self->_apply_zoom_to_volumes_filter(0); + $self->_mouse_dragging(0); # Collection of GLVolume objects $self->volumes(Slic3r::GUI::_3DScene::GLVolume::Collection->new); @@ -381,6 +383,8 @@ sub mouse_event { my $pos = Slic3r::Pointf->new($e->GetPositionXY); my $object_idx_selected = $self->{layer_height_edit_last_object_id} = ($self->layer_editing_enabled && $self->{print}) ? $self->_first_selected_object_id_for_variable_layer_height_editing : -1; + $self->_mouse_dragging($e->Dragging); + if ($e->Entering && &Wx::wxMSW) { # wxMSW needs focus in order to catch mouse wheel events $self->SetFocus; @@ -1182,7 +1186,7 @@ sub Render { # Head light glLightfv_p(GL_LIGHT1, GL_POSITION, 1, 0, 1, 0); - if ($self->enable_picking) { + if ($self->enable_picking && !$self->_mouse_dragging) { if (my $pos = $self->_mouse_pos) { # Render the object for picking. # FIXME This cannot possibly work in a multi-sampled context as the color gets mangled by the anti-aliasing. From 88dadcec78185c00bef759643c3ccd427f9e0d06 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 19 Apr 2018 16:20:30 +0200 Subject: [PATCH 0215/1150] Added tooltips for reverse buttons * Corrected default size of undo buttons for GTK * Experiment with rich tooltips --- xs/src/slic3r/GUI/Field.cpp | 8 +++++-- xs/src/slic3r/GUI/Tab.cpp | 42 +++++++++++++++++++++++++++++++++++-- xs/src/slic3r/GUI/Tab.hpp | 16 ++++++++++++-- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index e959c7966c..ff17a2ef8f 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -20,8 +20,12 @@ namespace Slic3r { namespace GUI { void Field::PostInitialize(){ auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(16, 16), wxNO_BORDER); - m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(16, 16), wxNO_BORDER); + auto sz = 16; + #ifdef __WXGTK__ + sz = 28 + #endif // __WXGTK__ + m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); + m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); if (wxMSW) { m_Undo_btn->SetBackgroundColour(color); m_Undo_to_sys_btn->SetBackgroundColour(color); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 810ee6e141..0491965990 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -102,10 +102,42 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_undo_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); m_undo_to_sys_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + m_question_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + m_undo_btns_legent = new wxStaticText(panel, wxID_ANY, _(L("For more information about buttons hover the mouse cursor over them.")), wxDefaultPosition, wxDefaultSize); if (wxMSW) { m_undo_btn->SetBackgroundColour(color); m_undo_to_sys_btn->SetBackgroundColour(color); + m_question_btn->SetBackgroundColour(color); } + +#ifdef __WXMSW__ + m_undo_to_sys_btn->SetToolTip(_(L( "Unlocked lock icon indicates about some value changes compared with system values " + "in current option group.\n" + "Locked lock icon indicates about same values compared with system values " + "in current option group.\n" + "White bullet icon indicates about nonsystem preset.\n" + "Click the unlocked lock to revert all values in current option group to system values."))); +#else + // ToolTips to undo buttons + m_undo_btn_tip = new wxRichToolTip("Information about current button", + _(L("Unlocked lock icon indicates about some value changes compared with system values " + "in current option group.\n" + "Locked lock icon indicates about same values compared with system values " + "in current option group.\n" + "White bullet icon indicates about nonsystem preset.\n" + "Click the unlocked lock to revert all values in current option group to system values."))); + m_undo_btn_tip->SetIcon(wxICON_INFORMATION); + m_undo_btn_tip->ShowFor(m_undo_btn); +#endif //__WXMSW__ + + m_undo_btn->SetToolTip(_(L( "Back arrow icon indicates about some value changes compared with last saved preset values " + "in current option group.\n" + "White bullet icon indicates about same values compared with last saved preset values " + "in current option group.\n" + "Click the Back arrow to revert all values in current option group to last saved preset values."))); + + m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information."))); + // Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field. m_bmp_value_lock .LoadFile(from_u8(var("sys_lock.png")), wxBITMAP_TYPE_PNG); m_bmp_value_unlock .LoadFile(from_u8(var("sys_unlock.png")), wxBITMAP_TYPE_PNG); @@ -113,10 +145,13 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) // Bitmaps to be shown on the "Undo user changes" button next to each input field. m_bmp_value_revert .LoadFile(from_u8(var("action_undo.png")), wxBITMAP_TYPE_PNG); m_bmp_white_bullet .LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG); + m_bmp_question .LoadFile(from_u8(var("question_mark_01.png")), wxBITMAP_TYPE_PNG); + m_undo_btn->SetBitmap(m_bmp_white_bullet); - m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ /*on_back_to_initial_value*/on_roll_back_value(); })); + m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_roll_back_value(); })); m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet); - m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ /*on_back_to_sys_value*/on_roll_back_value(true); })); + m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_roll_back_value(true); })); + m_question_btn->SetBitmap(m_bmp_question); // Colors for ui "decoration" m_sys_label_clr = get_sys_label_clr(); @@ -135,6 +170,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_hsizer->AddSpacer(64); m_hsizer->Add(m_undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); m_hsizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL); + m_hsizer->AddSpacer(16); + m_hsizer->Add(m_question_btn, 0, wxALIGN_CENTER_VERTICAL); + m_hsizer->Add(m_undo_btns_legent, 0, wxALIGN_CENTER_VERTICAL); // m_hsizer->AddSpacer(64); // m_hsizer->Add(m_cc_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index d5a679564f..364608dc10 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -110,7 +111,11 @@ protected: wxCheckBox* m_compatible_printers_checkbox; wxButton* m_compatible_printers_btn; wxButton* m_undo_btn; - wxButton* m_undo_to_sys_btn; + wxButton* m_undo_to_sys_btn; + wxButton* m_question_btn; + wxStaticText* m_undo_btns_legent; + wxRichToolTip* m_undo_btn_tip; + wxComboCtrl* m_cc_presets_choice; wxDataViewTreeCtrl* m_presetctrl; wxImageList* m_preset_icons; @@ -128,6 +133,7 @@ protected: // Bitmaps to be shown on the "Undo user changes" button next to each input field. wxBitmap m_bmp_value_revert; wxBitmap m_bmp_value_unmodified; + wxBitmap m_bmp_question; // Colors for ui "decoration" wxColour m_sys_label_clr; @@ -171,7 +177,13 @@ public: Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL); get_tabs_list().push_back(this); } - ~Tab() { delete_tab_from_list(this); } + ~Tab(){ + delete_tab_from_list(this); + if (m_undo_btn_tip){ + delete m_undo_btn_tip; + m_undo_btn_tip = nullptr; + } + } wxWindow* parent() const { return m_parent; } wxString title() const { return m_title; } From bdaf1b01bedea5cac8b0d3d15dd48f87f531651c Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 19 Apr 2018 16:49:22 +0200 Subject: [PATCH 0216/1150] ConfigWizard: Fix reset checkbox --- xs/src/slic3r/GUI/ConfigWizard.cpp | 3 ++- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 0eee234db7..a1ee5a7485 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -205,7 +205,7 @@ PageWelcome::PageWelcome(ConfigWizard *parent) : ConfigWizardPage(parent, wxString::Format(_(L("Welcome to the Slic3r %s")), ConfigWizard::name()), _(L("Welcome"))), printer_picker(nullptr), others_buttons(new wxPanel(parent)), - cbox_reset(new wxCheckBox(this, wxID_ANY, _(L("Remove user profiles - install from scratch (a snapshot will be taken beforehand)")))) + cbox_reset(nullptr) { if (wizard_p()->flag_startup && wizard_p()->flag_empty_datadir) { wxString::Format(_(L("Run %s")), ConfigWizard::name()); @@ -214,6 +214,7 @@ PageWelcome::PageWelcome(ConfigWizard *parent) : ConfigWizard::name()) ); } else { + cbox_reset = new wxCheckBox(this, wxID_ANY, _(L("Remove user profiles - install from scratch (a snapshot will be taken beforehand)"))); append(cbox_reset); } diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index 8e43ac3ac7..cdab2eb3ca 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -107,7 +107,7 @@ struct PageWelcome: ConfigWizardPage virtual wxPanel* extra_buttons() { return others_buttons; } virtual void on_page_set(); - bool reset_user_profile() const { return cbox_reset->GetValue(); } + bool reset_user_profile() const { return cbox_reset != nullptr ? cbox_reset->GetValue() : false; } void on_variant_checked(); }; From d671e06c32c53a2e38d5dc34c1fdbee49ecbc1b8 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 19 Apr 2018 18:29:19 +0200 Subject: [PATCH 0217/1150] Fix alpha legacy dir detection, Fix SemVer value ctor --- xs/src/semver/semver.c | 2 +- xs/src/semver/semver.h | 3 +++ xs/src/slic3r/GUI/AppConfig.cpp | 8 +++++++- xs/src/slic3r/Utils/Semver.hpp | 17 +++++++++++++---- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/xs/src/semver/semver.c b/xs/src/semver/semver.c index a193544036..527738644d 100644 --- a/xs/src/semver/semver.c +++ b/xs/src/semver/semver.c @@ -620,7 +620,7 @@ semver_numeric (semver_t *x) { return num; } -static char *semver_strdup(const char *src) { +char *semver_strdup(const char *src) { if (src == NULL) return NULL; size_t len = strlen(src) + 1; char *res = malloc(len); diff --git a/xs/src/semver/semver.h b/xs/src/semver/semver.h index 7251f51e3a..01a15fc43e 100644 --- a/xs/src/semver/semver.h +++ b/xs/src/semver/semver.h @@ -98,6 +98,9 @@ semver_is_valid (const char *s); int semver_clean (char *s); +char * +semver_strdup(const char *src); + semver_t semver_copy(const semver_t *ver); diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 100b2d69b3..965e8185d4 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -100,7 +100,13 @@ void AppConfig::load() // Figure out if datadir has legacy presets auto ini_ver = Semver::parse(get("version")); - m_legacy_datadir = ini_ver ? *ini_ver < Semver(1, 40, 0) : true; + m_legacy_datadir = false; + if (ini_ver) { + // Make 1.40.0 alphas compare well + ini_ver->set_metadata(boost::none); + ini_ver->set_prerelease(boost::none); + m_legacy_datadir = ini_ver < Semver(1, 40, 0); + } // Override missing or keys with their defaults. this->set_defaults(); diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index bf3c78964c..87396d8124 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -22,14 +22,15 @@ public: Semver() : ver(semver_zero()) {} Semver(int major, int minor, int patch, - boost::optional metadata = boost::none, - boost::optional prerelease = boost::none) + boost::optional metadata = boost::none, + boost::optional prerelease = boost::none) + : ver(semver_zero()) { ver.major = major; ver.minor = minor; ver.patch = patch; - ver.metadata = metadata ? std::strcpy(ver.metadata, metadata->c_str()) : nullptr; - ver.prerelease = prerelease ? std::strcpy(ver.prerelease, prerelease->c_str()) : nullptr; + set_metadata(metadata); + set_prerelease(prerelease); } static boost::optional parse(const std::string &str) @@ -82,6 +83,13 @@ public: int patch() const { return ver.patch; } const char* prerelease() const { return ver.prerelease; } const char* metadata() const { return ver.metadata; } + + // Setters + void set_maj(int maj) { ver.major = maj; } + void set_min(int min) { ver.minor = min; } + void set_patch(int patch) { ver.patch = patch; } + void set_metadata(boost::optional meta) { meta ? strdup(*meta) : nullptr; } + void set_prerelease(boost::optional pre) { pre ? strdup(*pre) : nullptr; } // Comparison bool operator<(const Semver &b) const { return ::semver_compare(ver, b.ver) == -1; } @@ -124,6 +132,7 @@ private: Semver(semver_t ver) : ver(ver) {} static semver_t semver_zero() { return { 0, 0, 0, nullptr, nullptr }; } + static char * strdup(const std::string &str) { return ::semver_strdup(const_cast(str.c_str())); } }; From 2e61420747b6e240fff989e8851c13edc6466375 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 19 Apr 2018 18:31:14 +0200 Subject: [PATCH 0218/1150] Sync index file --- resources/profiles/PrusaResearch.idx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/profiles/PrusaResearch.idx b/resources/profiles/PrusaResearch.idx index b43e266635..5dd09868fa 100644 --- a/resources/profiles/PrusaResearch.idx +++ b/resources/profiles/PrusaResearch.idx @@ -1,6 +1,8 @@ # This is an example configuration version index. # The index contains version numbers min_slic3r_version =1.39.0 +1.1.3 +1.1.2 1.1.1 1.1.0 0.2.0-alpha "some test comment" From ab397e5ce1d27b82006516876fa84022b4b5cd92 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 20 Apr 2018 10:26:23 +0200 Subject: [PATCH 0219/1150] Added SnapshotDB::snapshot_with_vendor_preset() utility function to find out whether there has ever been a snapshot taken with a given configuration version. Implemented an "on snapshot" flag, which indicates, whether the current state equals to some snapshot. If so, a new snapshot is not taken in upgrade / downgrade case. --- xs/src/slic3r/Config/Snapshot.cpp | 124 ++++++++++++++++++++- xs/src/slic3r/Config/Snapshot.hpp | 17 ++- xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp | 38 +++---- xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp | 4 +- xs/src/slic3r/GUI/GUI.cpp | 15 ++- 5 files changed, 168 insertions(+), 30 deletions(-) diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index c82169308e..18329aa5c8 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -81,6 +82,8 @@ void Snapshot::load_ini(const std::string &path) this->reason = SNAPSHOT_UPGRADE; else if (rsn == "downgrade") this->reason = SNAPSHOT_DOWNGRADE; + else if (rsn == "before_rollback") + this->reason = SNAPSHOT_BEFORE_ROLLBACK; else if (rsn == "user") this->reason = SNAPSHOT_USER; else @@ -131,6 +134,9 @@ void Snapshot::load_ini(const std::string &path) this->vendor_configs.emplace_back(std::move(vc)); } } + // Sort the vendors lexicographically. + std::sort(this->vendor_configs.begin(), this->vendor_configs.begin(), + [](const VendorConfig &cfg1, const VendorConfig &cfg2) { return cfg1.name < cfg2.name; }); } static std::string reason_string(const Snapshot::Reason reason) @@ -140,6 +146,8 @@ static std::string reason_string(const Snapshot::Reason reason) return "upgrade"; case Snapshot::SNAPSHOT_DOWNGRADE: return "downgrade"; + case Snapshot::SNAPSHOT_BEFORE_ROLLBACK: + return "before_rollback"; case Snapshot::SNAPSHOT_USER: return "user"; case Snapshot::SNAPSHOT_UNKNOWN: @@ -210,6 +218,74 @@ void Snapshot::export_vendor_configs(AppConfig &config) const config.set_vendors(std::move(vendors)); } +// Perform a deep compare of the active print / filament / printer / vendor directories. +// Return true if the content of the current print / filament / printer / vendor directories +// matches the state stored in this snapshot. +bool Snapshot::equal_to_active(const AppConfig &app_config) const +{ + // 1) Check, whether this snapshot contains the same set of active vendors, printer models and variants + // as app_config. + { + std::set matched; + for (const VendorConfig &vc : this->vendor_configs) { + auto it_vendor_models_variants = app_config.vendors().find(vc.name); + if (it_vendor_models_variants == app_config.vendors().end() || + it_vendor_models_variants->second != vc.models_variants_installed) + // There are more vendors enabled in the snapshot than currently installed. + return false; + matched.insert(vc.name); + } + for (const std::pair>> &v : app_config.vendors()) + if (matched.find(v.first) == matched.end() && ! v.second.empty()) + // There are more vendors currently installed than enabled in the snapshot. + return false; + } + + // 2) Check, whether this snapshot references the same set of ini files as the current state. + boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); + boost::filesystem::path snapshot_dir = boost::filesystem::path(Slic3r::data_dir()) / SLIC3R_SNAPSHOTS_DIR / this->id; + for (const char *subdir : { "print", "filament", "printer", "vendor" }) { + boost::filesystem::path path1 = data_dir / subdir; + boost::filesystem::path path2 = snapshot_dir / subdir; + std::vector files1, files2; + for (auto &dir_entry : boost::filesystem::directory_iterator(path1)) + if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini")) + files1.emplace_back(dir_entry.path().filename().string()); + for (auto &dir_entry : boost::filesystem::directory_iterator(path2)) + if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini")) + files2.emplace_back(dir_entry.path().filename().string()); + std::sort(files1.begin(), files1.end()); + std::sort(files2.begin(), files2.end()); + if (files1 != files2) + return false; + for (const std::string &filename : files1) { + FILE *f1 = boost::nowide::fopen((path1 / filename).string().c_str(), "rb"); + FILE *f2 = boost::nowide::fopen((path2 / filename).string().c_str(), "rb"); + bool same = true; + if (f1 && f2) { + char buf1[4096]; + char buf2[4096]; + do { + size_t r1 = fread(buf1, 1, 4096, f1); + size_t r2 = fread(buf2, 1, 4096, f2); + if (r1 != r2 || memcmp(buf1, buf2, r1)) { + same = false; + break; + } + } while (! feof(f1) || ! feof(f2)); + } else + same = false; + if (f1) + fclose(f1); + if (f2) + fclose(f2); + if (! same) + return false; + } + } + return true; +} + size_t SnapshotDB::load_db() { boost::filesystem::path snapshots_dir = SnapshotDB::create_db_dir(); @@ -347,12 +423,12 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot: return m_snapshots.back(); } -void SnapshotDB::restore_snapshot(const std::string &id, AppConfig &app_config) +const Snapshot& SnapshotDB::restore_snapshot(const std::string &id, AppConfig &app_config) { for (const Snapshot &snapshot : m_snapshots) if (snapshot.id == id) { this->restore_snapshot(snapshot, app_config); - return; + return snapshot; } throw std::runtime_error(std::string("Snapshot with id " + id + " was not found.")); } @@ -373,6 +449,50 @@ void SnapshotDB::restore_snapshot(const Snapshot &snapshot, AppConfig &app_confi snapshot.export_vendor_configs(app_config); } +bool SnapshotDB::is_on_snapshot(AppConfig &app_config) const +{ + // Is the "on_snapshot" configuration value set? + std::string on_snapshot = app_config.get("on_snapshot"); + if (on_snapshot.empty()) + // No, we are not on a snapshot. + return false; + // Is the "on_snapshot" equal to the current configuration state? + auto it_snapshot = this->snapshot(on_snapshot); + if (it_snapshot != this->end() && it_snapshot->equal_to_active(app_config)) + // Yes, we are on the snapshot. + return true; + // No, we are no more on a snapshot. Reset the state. + app_config.set("on_snapshot", ""); + return false; +} + +SnapshotDB::const_iterator SnapshotDB::snapshot_with_vendor_preset(const std::string &vendor_name, const Semver &config_version) +{ + auto it_found = m_snapshots.end(); + Snapshot::VendorConfig key; + key.name = vendor_name; + for (auto it = m_snapshots.begin(); it != m_snapshots.end(); ++ it) { + const Snapshot &snapshot = *it; + auto it_vendor_config = std::lower_bound(snapshot.vendor_configs.begin(), snapshot.vendor_configs.end(), + key, [](const Snapshot::VendorConfig &cfg1, const Snapshot::VendorConfig &cfg2) { return cfg1.name < cfg2.name; }); + if (it_vendor_config != snapshot.vendor_configs.end() && it_vendor_config->name == vendor_name && + config_version == it_vendor_config->version) { + // Vendor config found with the correct version. + // Save it, but continue searching, as we want the newest snapshot. + it_found = it; + } + } + return it_found; +} + +SnapshotDB::const_iterator SnapshotDB::snapshot(const std::string &id) const +{ + for (const_iterator it = m_snapshots.begin(); it != m_snapshots.end(); ++ it) + if (it->id == id) + return it; + return m_snapshots.end(); +} + boost::filesystem::path SnapshotDB::create_db_dir() { boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp index a7e70bb4bb..77aee3e21a 100644 --- a/xs/src/slic3r/Config/Snapshot.hpp +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -34,6 +34,7 @@ public: SNAPSHOT_UNKNOWN, SNAPSHOT_UPGRADE, SNAPSHOT_DOWNGRADE, + SNAPSHOT_BEFORE_ROLLBACK, SNAPSHOT_USER, }; @@ -47,6 +48,11 @@ public: void export_selections(AppConfig &config) const; void export_vendor_configs(AppConfig &config) const; + // Perform a deep compare of the active print / filament / printer / vendor directories. + // Return true if the content of the current print / filament / printer / vendor directories + // matches the state stored in this snapshot. + bool equal_to_active(const AppConfig &app_config) const; + // ID of a snapshot should equal to the name of the snapshot directory. // The ID contains the date/time, reason and comment to be human readable. std::string id; @@ -79,7 +85,7 @@ public: // Which printer models of this vendor were installed, and which variants of the models? std::map> models_variants_installed; }; - // List of vendor configs contained in this snapshot. + // List of vendor configs contained in this snapshot, sorted lexicographically. std::vector vendor_configs; }; @@ -100,17 +106,24 @@ public: // Create a snapshot directory, copy the vendor config bundles, user print/filament/printer profiles, // create an index. const Snapshot& take_snapshot(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment = ""); - void restore_snapshot(const std::string &id, AppConfig &app_config); + const Snapshot& restore_snapshot(const std::string &id, AppConfig &app_config); void restore_snapshot(const Snapshot &snapshot, AppConfig &app_config); + // Test whether the AppConfig's on_snapshot variable points to an existing snapshot, and the existing snapshot + // matches the current state. If it does not match the current state, the AppConfig's "on_snapshot" ID is reset. + bool is_on_snapshot(AppConfig &app_config) const; + // Finds the newest snapshot, which contains a config bundle for vendor_name with config_version. + const_iterator snapshot_with_vendor_preset(const std::string &vendor_name, const Semver &config_version); const_iterator begin() const { return m_snapshots.begin(); } const_iterator end() const { return m_snapshots.end(); } + const_iterator snapshot(const std::string &id) const; const std::vector& snapshots() const { return m_snapshots; } private: // Create the snapshots directory if it does not exist yet. static boost::filesystem::path create_db_dir(); + // Snapshots are sorted by their date/time, oldest first. std::vector m_snapshots; }; diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp index 0e0df15f24..99af707e1c 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -15,6 +15,8 @@ static std::string format_reason(const Config::Snapshot::Reason reason) return std::string(_(L("Upgrade"))); case Config::Snapshot::SNAPSHOT_DOWNGRADE: return std::string(_(L("Downgrade"))); + case Config::Snapshot::SNAPSHOT_BEFORE_ROLLBACK: + return std::string(_(L("Before roll back"))); case Config::Snapshot::SNAPSHOT_USER: return std::string(_(L("User"))); case Config::Snapshot::SNAPSHOT_UNKNOWN: @@ -23,34 +25,35 @@ static std::string format_reason(const Config::Snapshot::Reason reason) } } -static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_even) +static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_even, bool snapshot_active) { // Start by declaring a row with an alternating background color. std::string text = "
"; // Format the row header. - text += std::string("") + Utils::format_local_date_time(snapshot.time_captured) + ": " + format_reason(snapshot.reason); + text += std::string("") + (snapshot_active ? _(L("Active: ")) : "") + + Utils::format_local_date_time(snapshot.time_captured) + ": " + format_reason(snapshot.reason); if (! snapshot.comment.empty()) text += " (" + snapshot.comment + ")"; text += "
"; // End of row header. // text += _(L("ID:")) + " " + snapshot.id + "
"; // text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "
"; - text += _(L("slic3r version:")) + " " + snapshot.slic3r_version_captured.to_string() + "
"; + text += _(L("slic3r version")) + ": " + snapshot.slic3r_version_captured.to_string() + "
"; // text += "reason: " + snapshot.reason + "
"; - text += "print: " + snapshot.print + "
"; - text += "filaments: " + snapshot.filaments.front() + "
"; - text += "printer: " + snapshot.printer + "
"; + text += _(L("print")) + ": " + snapshot.print + "
"; + text += _(L("filaments")) + ": " + snapshot.filaments.front() + "
"; + text += _(L("printer")) + ": " + snapshot.printer + "
"; for (const Config::Snapshot::VendorConfig &vc : snapshot.vendor_configs) { - text += "vendor: " + vc.name + ", ver: " + vc.version.to_string() + ", min slic3r ver: " + vc.min_slic3r_version.to_string(); + text += _(L("vendor")) + ": " + vc.name + ", ver: " + vc.version.to_string() + ", min slic3r ver: " + vc.min_slic3r_version.to_string(); if (vc.max_slic3r_version != Semver::inf()) text += ", max slic3r ver: " + vc.max_slic3r_version.to_string(); text += "
"; for (const std::pair> &model : vc.models_variants_installed) { - text += "model: " + model.first + ", variants: "; + text += _(L("model")) + ": " + model.first + ", " + _(L("variants")) + ": "; for (const std::string &variant : model.second) { if (&variant != &*model.second.begin()) text += ", "; @@ -60,13 +63,14 @@ static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_ } } - text += "

Activate

"; + if (! snapshot_active) + text += "

" + _(L("Activate")) + "

"; text += "
"; for (size_t i_row = 0; i_row < snapshot_db.snapshots().size(); ++ i_row) { const Config::Snapshot &snapshot = snapshot_db.snapshots()[snapshot_db.snapshots().size() - i_row - 1]; - text += generate_html_row(snapshot, i_row & 1); + text += generate_html_row(snapshot, i_row & 1, snapshot.id == on_snapshot); } text += "
" @@ -85,7 +89,7 @@ static std::string generate_html_page(const Config::SnapshotDB &snapshot_db) return text; } -ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db) +ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const std::string &on_snapshot) : wxDialog(NULL, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition, wxSize(600, 500), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX) { this->SetBackgroundColour(*wxWHITE); @@ -104,7 +108,7 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db #endif html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); html->SetBorders(2); - std::string text = generate_html_page(snapshot_db); + std::string text = generate_html_page(snapshot_db, on_snapshot); html->SetPage(text.c_str()); vsizer->Add(html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 0); html->Bind(wxEVT_HTML_LINK_CLICKED, &ConfigSnapshotDialog::onLinkClicked, this); @@ -114,12 +118,6 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db this->SetEscapeId(wxID_CLOSE); this->Bind(wxEVT_BUTTON, &ConfigSnapshotDialog::onCloseDialog, this, wxID_CLOSE); vsizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3); - -/* - this->Bind(wxEVT_LEFT_DOWN, &ConfigSnapshotDialog::onCloseDialog, this); - logo->Bind(wxEVT_LEFT_DOWN, &ConfigSnapshotDialog::onCloseDialog, this); - html->Bind(wxEVT_LEFT_DOWN, &ConfigSnapshotDialog::onCloseDialog, this); -*/ } void ConfigSnapshotDialog::onLinkClicked(wxHtmlLinkEvent &event) diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp index 0d11096159..943601e731 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp @@ -17,14 +17,14 @@ namespace Config { class ConfigSnapshotDialog : public wxDialog { public: - ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db); - + ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const std::string &id); const std::string& snapshot_to_activate() const { return m_snapshot_to_activate; } private: void onLinkClicked(wxHtmlLinkEvent &event); void onCloseDialog(wxEvent &); + // If set, it contains a snapshot ID to be restored after the dialog closes. std::string m_snapshot_to_activate; }; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 7de82cb5f4..88c3f421b2 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -397,16 +397,23 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l if (check_unsaved_changes()) { wxTextEntryDialog dlg(nullptr, _(L("Taking configuration snapshot")), _(L("Snapshot name"))); if (dlg.ShowModal() == wxID_OK) - Slic3r::GUI::Config::SnapshotDB::singleton().take_snapshot( - *g_AppConfig, Slic3r::GUI::Config::Snapshot::SNAPSHOT_USER, dlg.GetValue().ToUTF8().data()); + g_AppConfig->set("on_snapshot", + Slic3r::GUI::Config::SnapshotDB::singleton().take_snapshot( + *g_AppConfig, Slic3r::GUI::Config::Snapshot::SNAPSHOT_USER, dlg.GetValue().ToUTF8().data()).id); } break; case ConfigMenuSnapshots: if (check_unsaved_changes()) { - ConfigSnapshotDialog dlg(Slic3r::GUI::Config::SnapshotDB::singleton()); + std::string on_snapshot; + if (Config::SnapshotDB::singleton().is_on_snapshot(*g_AppConfig)) + on_snapshot = g_AppConfig->get("on_snapshot"); + ConfigSnapshotDialog dlg(Slic3r::GUI::Config::SnapshotDB::singleton(), on_snapshot); dlg.ShowModal(); if (! dlg.snapshot_to_activate().empty()) { - Config::SnapshotDB::singleton().restore_snapshot(dlg.snapshot_to_activate(), *g_AppConfig); + if (! Config::SnapshotDB::singleton().is_on_snapshot(*g_AppConfig)) + Config::SnapshotDB::singleton().take_snapshot(*g_AppConfig, Config::Snapshot::SNAPSHOT_BEFORE_ROLLBACK); + g_AppConfig->set("on_snapshot", + Config::SnapshotDB::singleton().restore_snapshot(dlg.snapshot_to_activate(), *g_AppConfig).id); g_PresetBundle->load_presets(*g_AppConfig); // Load the currently selected preset into the GUI, update the preset selection box. for (Tab *tab : g_tabs_list) From 9b5480b7ba13ad3448fb92299da2c4ffc59333cc Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 20 Apr 2018 11:05:00 +0200 Subject: [PATCH 0220/1150] PresetUpdater: Use PID in cache tmp filenames --- xs/src/libslic3r/Utils.hpp | 3 +++ xs/src/libslic3r/utils.cpp | 15 +++++++++++++++ xs/src/slic3r/Utils/PresetUpdater.cpp | 7 ++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/Utils.hpp b/xs/src/libslic3r/Utils.hpp index f900137d3e..0066aa5e69 100644 --- a/xs/src/libslic3r/Utils.hpp +++ b/xs/src/libslic3r/Utils.hpp @@ -62,6 +62,9 @@ extern std::string timestamp_str(); // to be placed at the top of Slic3r generated files. inline std::string header_slic3r_generated() { return std::string("generated by " SLIC3R_FORK_NAME " " SLIC3R_VERSION " " ) + timestamp_str(); } +// getpid platform wrapper +extern unsigned get_current_pid(); + // Compute the next highest power of 2 of 32-bit v // http://graphics.stanford.edu/~seander/bithacks.html template diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp index 733757e25a..f2415ac072 100644 --- a/xs/src/libslic3r/utils.cpp +++ b/xs/src/libslic3r/utils.cpp @@ -1,6 +1,12 @@ #include #include +#ifdef WIN32 +#include +#else +#include +#endif + #include #include #include @@ -271,4 +277,13 @@ std::string timestamp_str() return buf; } +unsigned get_current_pid() +{ +#ifdef WIN32 + return GetCurrentProcessId(); +#else + return ::getpid(); +#endif +} + }; // namespace Slic3r diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index bf9e1eb44e..9b271492c8 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -180,11 +180,12 @@ void PresetUpdater::priv::set_download_prefs(AppConfig *app_config) bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &target_path) const { - std::cerr << "get_file(): " << url << " -> " << target_path << std::endl; - bool res = false; fs::path tmp_path = target_path; - tmp_path += TMP_EXTENSION; + tmp_path += (boost::format(".%1%%2%") % get_current_pid() % TMP_EXTENSION).str(); + + std::cerr << "get_file(): " << url << " -> " << target_path << std::endl + << "\ttmp_path: " << tmp_path << std::endl; Http::get(url) .on_progress([this](Http::Progress, bool &cancel) { From 93a902a75771d193cc69417a133b03a58d43aafb Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 20 Apr 2018 11:06:12 +0200 Subject: [PATCH 0221/1150] PresetUpdater: Fix double free from Perl --- lib/Slic3r.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 19915ddd86..d249bd10b1 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -162,6 +162,7 @@ sub thread_cleanup { *Slic3r::TriangleMesh::DESTROY = sub {}; *Slic3r::GUI::AppConfig::DESTROY = sub {}; *Slic3r::GUI::PresetBundle::DESTROY = sub {}; + *Slic3r::PresetUpdater::DESTROY = sub {}; return undef; # this prevents a "Scalars leaked" warning } From 1e1bf03f61c5fe3aab4a9396b1fd56f4a76b6bc1 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 20 Apr 2018 12:58:07 +0200 Subject: [PATCH 0222/1150] Added reset buttons description --- resources/icons/question_mark_01.png | Bin 0 -> 523 bytes xs/src/slic3r/GUI/2DBed.hpp | 5 +++ xs/src/slic3r/GUI/BedShapeDialog.hpp | 5 +++ xs/src/slic3r/GUI/Field.cpp | 2 +- xs/src/slic3r/GUI/OptionsGroup.hpp | 5 +++ xs/src/slic3r/GUI/Preferences.hpp | 5 +++ xs/src/slic3r/GUI/Tab.cpp | 59 ++++++++++++++++----------- xs/src/slic3r/GUI/Tab.hpp | 19 +++++---- xs/src/slic3r/GUI/TabIface.hpp | 7 +++- 9 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 resources/icons/question_mark_01.png diff --git a/resources/icons/question_mark_01.png b/resources/icons/question_mark_01.png new file mode 100644 index 0000000000000000000000000000000000000000..25814a61d4e7aa408640e206b6c58b10122962d5 GIT binary patch literal 523 zcmV+m0`&cfP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0ia1lK~y+Tol(y# z1yLBilvrRR*`Z9Cd*7^3Qc6i7C589y^&>^u*|79Gmi`ADTWecUEU+ZKNNj8{b1#u! zGtM1fjqvnxYMQ#|eCIpg_pz^t7%K=esX8tBav;T?R{RYAY@o!BR$|3uQap-S0m*+t zE3X9wNBG`R5PkjZTOj$dFGag;L?sE#fKv(4c3cn}@B{o;1I5>Dio}TTS}m0&Fv@L% z_@26*-lkp8c8V5Rp_XnB%ru#6qeLr}B?zR~1cNJx3`8@wkSJz`g#dR==1&hQ)k#!> z!^y@XEU!5j;vLbTD5Yl>jn$N3i3^DSLL*!n<+()v4c+Hf#CwoPMcrXAXPc2EH}0iZ zg+v>O{`@&Rzr$je!twetlH`V+KaQ>VD|J4_`3ACGPBBUThMgPTwmv&!`%?7&diz|6 zPp8B*VxJqu*KdZMa-#A_IOP=knfluBKgBk#pLQFthk2t?{TCRCsQh3rfW_^@AjH{x zo#EX?<%eKII9TFkd;uli{2@L;RDK9?E}U={CMQU+`8X=7iTVb{J^=r2>{O*7e`o*z N002ovPDHLkV1kV- #include "Config.hpp" @@ -45,3 +48,5 @@ public: } // GUI } // Slic3r + +#endif /* slic3r_2DBed_hpp_ */ diff --git a/xs/src/slic3r/GUI/BedShapeDialog.hpp b/xs/src/slic3r/GUI/BedShapeDialog.hpp index f4614c3426..5ff4880637 100644 --- a/xs/src/slic3r/GUI/BedShapeDialog.hpp +++ b/xs/src/slic3r/GUI/BedShapeDialog.hpp @@ -1,3 +1,5 @@ +#ifndef slic3r_BedShapeDialog_hpp_ +#define slic3r_BedShapeDialog_hpp_ // The bed shape dialog. // The dialog opens from Print Settins tab->Bed Shape : Set... @@ -49,3 +51,6 @@ public: } // GUI } // Slic3r + + +#endif /* slic3r_BedShapeDialog_hpp_ */ diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index ff17a2ef8f..2527202879 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -22,7 +22,7 @@ namespace Slic3r { namespace GUI { auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); auto sz = 16; #ifdef __WXGTK__ - sz = 28 + sz = 28; #endif // __WXGTK__ m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 92ebb44881..6a00cbe0d7 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -1,3 +1,6 @@ +#ifndef slic3r_OptionsGroup_hpp_ +#define slic3r_OptionsGroup_hpp_ + #include #include #include @@ -204,3 +207,5 @@ public: }; }} + +#endif /* slic3r_OptionsGroup_hpp_ */ diff --git a/xs/src/slic3r/GUI/Preferences.hpp b/xs/src/slic3r/GUI/Preferences.hpp index c30e94d225..f94a1db69e 100644 --- a/xs/src/slic3r/GUI/Preferences.hpp +++ b/xs/src/slic3r/GUI/Preferences.hpp @@ -1,3 +1,6 @@ +#ifndef slic3r_Preferences_hpp_ +#define slic3r_Preferences_hpp_ + #include "GUI.hpp" #include @@ -25,3 +28,5 @@ public: } // GUI } // Slic3r + +#endif /* slic3r_Preferences_hpp_ */ diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 0491965990..48521461c3 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -8,6 +8,7 @@ #include "slic3r/Utils/OctoPrint.hpp" #include "BonjourDialog.hpp" #include "WipeTowerDialog.hpp" +#include "ButtonsDescription.hpp" #include #include @@ -103,38 +104,25 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_undo_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); m_undo_to_sys_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); m_question_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); - m_undo_btns_legent = new wxStaticText(panel, wxID_ANY, _(L("For more information about buttons hover the mouse cursor over them.")), wxDefaultPosition, wxDefaultSize); +// m_undo_btns_legent = new wxStaticText(panel, wxID_ANY, _(L("For more information about buttons hover the mouse cursor over them.")), wxDefaultPosition, wxDefaultSize); if (wxMSW) { m_undo_btn->SetBackgroundColour(color); m_undo_to_sys_btn->SetBackgroundColour(color); m_question_btn->SetBackgroundColour(color); } -#ifdef __WXMSW__ - m_undo_to_sys_btn->SetToolTip(_(L( "Unlocked lock icon indicates about some value changes compared with system values " + m_undo_to_sys_btn->SetToolTip(_(L( "UNLOCKED LOCK icon indicates about some value changes compared with system values " "in current option group.\n" - "Locked lock icon indicates about same values compared with system values " + "LOCKED LOCK icon indicates about same values compared with system values " "in current option group.\n" - "White bullet icon indicates about nonsystem preset.\n" - "Click the unlocked lock to revert all values in current option group to system values."))); -#else - // ToolTips to undo buttons - m_undo_btn_tip = new wxRichToolTip("Information about current button", - _(L("Unlocked lock icon indicates about some value changes compared with system values " - "in current option group.\n" - "Locked lock icon indicates about same values compared with system values " - "in current option group.\n" - "White bullet icon indicates about nonsystem preset.\n" - "Click the unlocked lock to revert all values in current option group to system values."))); - m_undo_btn_tip->SetIcon(wxICON_INFORMATION); - m_undo_btn_tip->ShowFor(m_undo_btn); -#endif //__WXMSW__ + "WHITE BULLET icon indicates about nonsystem preset.\n\n" + "Click the UNLOCKED LOCK to revert all values in current option group to system values."))); - m_undo_btn->SetToolTip(_(L( "Back arrow icon indicates about some value changes compared with last saved preset values " + m_undo_btn->SetToolTip(_(L( "BACK ARROW icon indicates about some value changes compared with last saved preset values " "in current option group.\n" - "White bullet icon indicates about same values compared with last saved preset values " - "in current option group.\n" - "Click the Back arrow to revert all values in current option group to last saved preset values."))); + "WHITE BULLET icon indicates about same values compared with last saved preset values " + "in current option group.\n\n" + "Click the BACK ARROW to revert all values in current option group to last saved preset values."))); m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information."))); @@ -147,11 +135,18 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_bmp_white_bullet .LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG); m_bmp_question .LoadFile(from_u8(var("question_mark_01.png")), wxBITMAP_TYPE_PNG); + fill_icon_descriptions(); + m_undo_btn->SetBitmap(m_bmp_white_bullet); m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_roll_back_value(); })); m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet); m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_roll_back_value(true); })); m_question_btn->SetBitmap(m_bmp_question); + m_question_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) + { + auto dlg = new ButtonsDescription(parent(), &m_icon_descriptions); + dlg->ShowModal(); + })); // Colors for ui "decoration" m_sys_label_clr = get_sys_label_clr(); @@ -170,9 +165,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_hsizer->AddSpacer(64); m_hsizer->Add(m_undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); m_hsizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL); - m_hsizer->AddSpacer(16); + m_hsizer->AddSpacer(32); m_hsizer->Add(m_question_btn, 0, wxALIGN_CENTER_VERTICAL); - m_hsizer->Add(m_undo_btns_legent, 0, wxALIGN_CENTER_VERTICAL); +// m_hsizer->Add(m_undo_btns_legent, 0, wxALIGN_CENTER_VERTICAL); // m_hsizer->AddSpacer(64); // m_hsizer->Add(m_cc_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3); @@ -2354,6 +2349,22 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) ui->Thaw(); } +void Tab::fill_icon_descriptions() +{ + m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_lock, L("LOCKED LOCK;" + "indicates about same values compared with system values in current option group"))); + + m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_unlock, L("UNLOCKED LOCK;" + "indicates about some value changes compared with system values in current option group"))); + + m_icon_descriptions.push_back(t_icon_description(&m_bmp_white_bullet, L("WHITE BULLET;" + "indicates about : \n - nonsystem preset (on left button)" + "\n - same values compared with last saved preset values in current option group(on right button)"))); + + m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_revert, L("BACK ARROW;" + "indicates about some value changes compared with last saved preset values in current option group"))); +} + void Page::reload_config() { for (auto group : m_optgroups) diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 364608dc10..ba449c8c7e 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -1,3 +1,6 @@ +#ifndef slic3r_Tab_hpp_ +#define slic3r_Tab_hpp_ + // The "Expert" tab at the right of the main tabbed window. // // This file implements following packages: @@ -22,7 +25,6 @@ #include #include #include -#include #include #include @@ -35,6 +37,9 @@ namespace Slic3r { namespace GUI { +typedef std::pair t_icon_description; +typedef std::vector> t_icon_descriptions; + // Single Tab page containing a{ vsizer } of{ optgroups } // package Slic3r::GUI::Tab::Page; using ConfigOptionsGroupShp = std::shared_ptr; @@ -113,8 +118,7 @@ protected: wxButton* m_undo_btn; wxButton* m_undo_to_sys_btn; wxButton* m_question_btn; - wxStaticText* m_undo_btns_legent; - wxRichToolTip* m_undo_btn_tip; +// wxStaticText* m_undo_btns_legent; wxComboCtrl* m_cc_presets_choice; wxDataViewTreeCtrl* m_presetctrl; @@ -152,6 +156,8 @@ protected: std::map m_options_list; int m_opt_status_value; + t_icon_descriptions m_icon_descriptions = {}; + // The two following two event IDs are generated at Plater.pm by calling Wx::NewEventType. wxEventType m_event_value_change = 0; wxEventType m_event_presets_changed = 0; @@ -179,10 +185,6 @@ public: } ~Tab(){ delete_tab_from_list(this); - if (m_undo_btn_tip){ - delete m_undo_btn_tip; - m_undo_btn_tip = nullptr; - } } wxWindow* parent() const { return m_parent; } @@ -249,6 +251,7 @@ protected: void update_frequently_changed_parameters(); void update_wiping_button_visibility(); void update_tab_presets(wxComboCtrl* ui, bool show_incompatible); + void fill_icon_descriptions(); }; //Slic3r::GUI::Tab::Print; @@ -327,3 +330,5 @@ public: } // GUI } // Slic3r + +#endif /* slic3r_Tab_hpp_ */ diff --git a/xs/src/slic3r/GUI/TabIface.hpp b/xs/src/slic3r/GUI/TabIface.hpp index 0325c855c7..5622634e8f 100644 --- a/xs/src/slic3r/GUI/TabIface.hpp +++ b/xs/src/slic3r/GUI/TabIface.hpp @@ -1,3 +1,6 @@ +#ifndef slic3r_TabIface_hpp_ +#define slic3r_TabIface_hpp_ + #include #include @@ -30,6 +33,8 @@ public: protected: GUI::Tab *m_tab; -}; +}; // namespace GUI }; // namespace Slic3r + +#endif /* slic3r_TabIface_hpp_ */ From 669b0b68ab112972d711e0b01efc9588925ece2a Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 20 Apr 2018 13:27:25 +0200 Subject: [PATCH 0223/1150] Added missed files to commit --- xs/src/slic3r/GUI/ButtonsDescription.cpp | 42 ++++++++++++++++++++++++ xs/src/slic3r/GUI/ButtonsDescription.hpp | 27 +++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 xs/src/slic3r/GUI/ButtonsDescription.cpp create mode 100644 xs/src/slic3r/GUI/ButtonsDescription.hpp diff --git a/xs/src/slic3r/GUI/ButtonsDescription.cpp b/xs/src/slic3r/GUI/ButtonsDescription.cpp new file mode 100644 index 0000000000..6831d0dddb --- /dev/null +++ b/xs/src/slic3r/GUI/ButtonsDescription.cpp @@ -0,0 +1,42 @@ +#include "ButtonsDescription.hpp" +#include +#include +#include + +#include "GUI.hpp" + +namespace Slic3r { +namespace GUI { + +ButtonsDescription::ButtonsDescription(wxWindow* parent, t_icon_descriptions* icon_descriptions) : + wxDialog(parent, wxID_ANY, "Buttons Description", wxDefaultPosition, wxDefaultSize), + m_icon_descriptions(icon_descriptions) +{ + auto grid_sizer = new wxFlexGridSizer(3, 20, 20); + + auto main_sizer = new wxBoxSizer(wxVERTICAL); + main_sizer->Add(grid_sizer, 0, wxEXPAND | wxALL, 20); + + for (auto pair : *m_icon_descriptions) + { + auto icon = new wxStaticBitmap(this, wxID_ANY, *pair.first); + grid_sizer->Add(icon, -1, wxALIGN_CENTRE_VERTICAL); + + std::istringstream f(pair.second); + std::string s; + while (getline(f, s, ';')) { + auto description = new wxStaticText(this, wxID_ANY, _(s)); + grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL); + } + } + + auto button = CreateStdDialogButtonSizer(wxOK); + main_sizer->Add(button, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); + + SetSizer(main_sizer); + main_sizer->SetSizeHints(this); +} + +} // GUI +} // Slic3r + diff --git a/xs/src/slic3r/GUI/ButtonsDescription.hpp b/xs/src/slic3r/GUI/ButtonsDescription.hpp new file mode 100644 index 0000000000..4858eaaea3 --- /dev/null +++ b/xs/src/slic3r/GUI/ButtonsDescription.hpp @@ -0,0 +1,27 @@ +#ifndef slic3r_ButtonsDescription_hpp +#define slic3r_ButtonsDescription_hpp + +#include +#include + +namespace Slic3r { +namespace GUI { + +using t_icon_descriptions = std::vector>; + +class ButtonsDescription : public wxDialog +{ + t_icon_descriptions* m_icon_descriptions; +public: + ButtonsDescription(wxWindow* parent, t_icon_descriptions* icon_descriptions); + ~ButtonsDescription(){} + + +}; + +} // GUI +} // Slic3r + + +#endif + From e0421a3ba6ca566dab584da32ecd32329ae45b1e Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 20 Apr 2018 14:53:11 +0200 Subject: [PATCH 0224/1150] PresetUpdater: Don't display new Slic3r version notifications multiple times for the same version --- xs/src/slic3r/Utils/PresetUpdater.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 9b271492c8..473fcf84f7 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -411,18 +411,24 @@ void PresetUpdater::slic3r_update_notify() auto* app_config = GUI::get_app_config(); const auto ver_slic3r = Semver::parse(SLIC3R_VERSION); - const auto ver_online = Semver::parse(app_config->get("version_online")); + const auto ver_online_str = app_config->get("version_online"); + const auto ver_online = Semver::parse(ver_online_str); + const auto ver_online_seen = Semver::parse(app_config->get("version_online_seen")); if (! ver_slic3r) { throw std::runtime_error("Could not parse Slic3r version string: " SLIC3R_VERSION); } - if (ver_online && *ver_online > *ver_slic3r) { - UpdateNotification notification(*ver_slic3r, *ver_online); - notification.ShowModal(); - if (notification.disable_version_check()) { - app_config->set("version_check", "0"); - p->enabled_version_check = false; + if (ver_online) { + // Only display the notification if the version available online is newer AND if we haven't seen it before + if (*ver_online > *ver_slic3r && (! ver_online_seen || *ver_online_seen < *ver_online)) { + UpdateNotification notification(*ver_slic3r, *ver_online); + notification.ShowModal(); + if (notification.disable_version_check()) { + app_config->set("version_check", "0"); + p->enabled_version_check = false; + } } + app_config->set("version_online_seen", ver_online_str); } } From 48bbd2d22adc14a2b373804129f78a5a58712dd0 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 20 Apr 2018 15:02:54 +0200 Subject: [PATCH 0225/1150] Added new files to MackList --- xs/CMakeLists.txt | 2 ++ xs/src/slic3r/GUI/Tab.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index abd9c3617a..c20a1102a3 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -208,6 +208,8 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/RammingChart.hpp ${LIBDIR}/slic3r/GUI/BonjourDialog.cpp ${LIBDIR}/slic3r/GUI/BonjourDialog.hpp + ${LIBDIR}/slic3r/GUI/ButtonsDescription.cpp + ${LIBDIR}/slic3r/GUI/ButtonsDescription.hpp ${LIBDIR}/slic3r/Config/Snapshot.cpp ${LIBDIR}/slic3r/Config/Snapshot.hpp ${LIBDIR}/slic3r/Config/Version.cpp diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 48521461c3..e2b07a5569 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -144,7 +144,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_question_btn->SetBitmap(m_bmp_question); m_question_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { - auto dlg = new ButtonsDescription(parent(), &m_icon_descriptions); + auto dlg = new ButtonsDescription(this, &m_icon_descriptions); dlg->ShowModal(); })); From 27f77c7680a23e6449d47b9cdb30c5c10c2e3bc2 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 20 Apr 2018 15:40:43 +0200 Subject: [PATCH 0226/1150] Added little more information to ButtonsDescription dialog --- xs/src/slic3r/GUI/Tab.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index e2b07a5569..2b82694dbc 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -2355,14 +2355,16 @@ void Tab::fill_icon_descriptions() "indicates about same values compared with system values in current option group"))); m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_unlock, L("UNLOCKED LOCK;" - "indicates about some value changes compared with system values in current option group"))); + "indicates about some value changes compared with system values in current option group.\n" + "Click the UNLOCKED LOCK to revert all values in current option group to system values."))); m_icon_descriptions.push_back(t_icon_description(&m_bmp_white_bullet, L("WHITE BULLET;" "indicates about : \n - nonsystem preset (on left button)" "\n - same values compared with last saved preset values in current option group(on right button)"))); m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_revert, L("BACK ARROW;" - "indicates about some value changes compared with last saved preset values in current option group"))); + "indicates about some value changes compared with last saved preset values in current option group.\n" + "Click the BACK ARROW to revert all values in current option group to last saved preset values."))); } void Page::reload_config() From b8cb9369732757f427c264181d49e50a0f943237 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 20 Apr 2018 17:32:08 +0200 Subject: [PATCH 0227/1150] Added effective update of ComboBoxes on Plater --- lib/Slic3r/GUI/MainFrame.pm | 1 + lib/Slic3r/GUI/Plater.pm | 25 +++++++++++++++++++++++-- xs/src/slic3r/GUI/PresetBundle.cpp | 4 ++++ xs/src/slic3r/GUI/Tab.hpp | 7 +++---- xs/src/slic3r/GUI/TabIface.cpp | 1 + xs/src/slic3r/GUI/TabIface.hpp | 1 + xs/xsp/GUI_Tab.xsp | 1 + 7 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index b2f51b9e1d..f5d4660182 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -149,6 +149,7 @@ sub _init_tabpanel { if (defined $presets){ my $reload_dependent_tabs = $tab->get_dependent_tabs; $self->{plater}->update_presets($tab_name, $reload_dependent_tabs, $presets); + $self->{plater}->{"selected_item_$tab_name"} = $tab->get_selected_preset_item; if ($tab_name eq 'printer') { # Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors. for my $tab_name_other (qw(print filament)) { diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d59865491c..023ec4ae5a 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -514,6 +514,13 @@ sub new { $self->SetSizer($sizer); } + # Last correct selected item for each preset + { + $self->{selected_item_print} = 0; + $self->{selected_item_filament} = 0; + $self->{selected_item_printer} = 0; + } + $self->update_ui_from_settings(); return $self; @@ -538,9 +545,23 @@ sub _on_select_preset { # Only update the platter UI for the 2nd and other filaments. wxTheApp->{preset_bundle}->update_platter_filament_ui($idx, $choice); } else { + my $selected_item = $choice->GetSelection(); + print ("selected_item = $selected_item\n"); + print ("selected_item_$group = ". $self->{"selected_item_$group"}. "\n"); + return if ($selected_item == $self->{"selected_item_$group"}); + + my $selected_string = $choice->GetString($selected_item); + if ($selected_string eq "------- System presets -------" || + $selected_string eq "------- User presets -------"){ + $choice->SetSelection($self->{"selected_item_$group"}); + return; + } + # call GetSelection() in scalar context as it's context-aware - $self->{on_select_preset}->($group, $choice->GetStringSelection) - if $self->{on_select_preset}; +# $self->{on_select_preset}->($group, $choice->GetStringSelection) + $self->{on_select_preset}->($group, $selected_string) + if $self->{on_select_preset}; + $self->{"selected_item_$group"} = $selected_item; } # Synchronize config.ini with the current selections. wxTheApp->{preset_bundle}->export_selections(wxTheApp->{app_config}); diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index d6cde84a89..92525fcbf9 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -977,6 +977,10 @@ void PresetBundle::export_configbundle(const std::string &path) //, const Dynami // an optional "(modified)" suffix will be removed from the filament name. void PresetBundle::set_filament_preset(size_t idx, const std::string &name) { + if (name == "------- System presets -------" || + name == "------- User presets -------") + return; + if (idx >= filament_presets.size()) filament_presets.resize(idx + 1, filaments.default_preset().name); filament_presets[idx] = Preset::remove_suffix_modified(name); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index ba449c8c7e..eda6727a85 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -237,12 +237,11 @@ public: bool set_value(const t_config_option_key& opt_key, const boost::any& value); wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText); bool current_preset_is_dirty(); + DynamicPrintConfig* get_config() { return m_config; } - PresetCollection* get_presets() - { - return m_presets; - } + PresetCollection* get_presets() { return m_presets; } std::vector get_dependent_tabs() { return m_reload_dependent_tabs; } + size_t get_selected_preset_item() { return m_selected_preset_item; } void on_value_change(const std::string& opt_key, const boost::any& value); diff --git a/xs/src/slic3r/GUI/TabIface.cpp b/xs/src/slic3r/GUI/TabIface.cpp index 4df0e72e53..29833322b8 100644 --- a/xs/src/slic3r/GUI/TabIface.cpp +++ b/xs/src/slic3r/GUI/TabIface.cpp @@ -11,6 +11,7 @@ void TabIface::load_config(DynamicPrintConfig* config) { m_tab->load_config(*con void TabIface::load_key_value(char* opt_key, char* value){ m_tab->load_key_value(opt_key, static_cast(value)); } bool TabIface::current_preset_is_dirty() { return m_tab->current_preset_is_dirty();} void TabIface::OnActivate() { return m_tab->OnActivate();} +size_t TabIface::get_selected_preset_item() { return m_tab->get_selected_preset_item(); } std::string TabIface::title() { return m_tab->title().ToUTF8().data(); } DynamicPrintConfig* TabIface::get_config() { return m_tab->get_config(); } PresetCollection* TabIface::get_presets() { return m_tab!=nullptr ? m_tab->get_presets() : nullptr; } diff --git a/xs/src/slic3r/GUI/TabIface.hpp b/xs/src/slic3r/GUI/TabIface.hpp index 5622634e8f..2f7f4e8e7f 100644 --- a/xs/src/slic3r/GUI/TabIface.hpp +++ b/xs/src/slic3r/GUI/TabIface.hpp @@ -30,6 +30,7 @@ public: DynamicPrintConfig* get_config(); PresetCollection* get_presets(); std::vector get_dependent_tabs(); + size_t get_selected_preset_item(); protected: GUI::Tab *m_tab; diff --git a/xs/xsp/GUI_Tab.xsp b/xs/xsp/GUI_Tab.xsp index 9cacac74f0..bcbdc0d9f8 100644 --- a/xs/xsp/GUI_Tab.xsp +++ b/xs/xsp/GUI_Tab.xsp @@ -16,6 +16,7 @@ bool current_preset_is_dirty(); void load_key_value(char* opt_key, char* value); void OnActivate(); + size_t get_selected_preset_item(); std::string title(); Ref get_config(); Ref get_presets(); From f8b1dc550685a8ca76c4d7a810151eabf08db2c1 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 23 Apr 2018 08:44:24 +0200 Subject: [PATCH 0228/1150] Tweaks to zooming logic --- lib/Slic3r/GUI/3DScene.pm | 124 ++++++++++++++++++++++++----- lib/Slic3r/GUI/Plater.pm | 1 + lib/Slic3r/GUI/Plater/3DPreview.pm | 21 +---- 3 files changed, 105 insertions(+), 41 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 65abf850ec..ff6d733997 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -201,6 +201,10 @@ sub new { $self->select_view('left'); } elsif ($key == ord('6')) { $self->select_view('right'); + } elsif ($key == ord('z')) { + $self->zoom_to_volumes; + } elsif ($key == ord('b')) { + $self->zoom_to_bed; } else { $event->Skip; } @@ -599,22 +603,23 @@ sub mouse_wheel_event { $zoom = $zoom_min if defined $zoom_min && $zoom < $zoom_min; $self->_zoom($zoom); - # In order to zoom around the mouse point we need to translate - # the camera target - my $size = Slic3r::Pointf->new($self->GetSizeWH); - my $pos = Slic3r::Pointf->new($e->GetX, $size->y - $e->GetY); #- - $self->_camera_target->translate( - # ($pos - $size/2) represents the vector from the viewport center - # to the mouse point. By multiplying it by $zoom we get the new, - # transformed, length of such vector. - # Since we want that point to stay fixed, we move our camera target - # in the opposite direction by the delta of the length of such vector - # ($zoom - 1). We then scale everything by 1/$self->_zoom since - # $self->_camera_target is expressed in terms of model units. - -($pos->x - $size->x/2) * ($zoom) / $self->_zoom, - -($pos->y - $size->y/2) * ($zoom) / $self->_zoom, - 0, - ) if 0; +# # In order to zoom around the mouse point we need to translate +# # the camera target +# my $size = Slic3r::Pointf->new($self->GetSizeWH); +# my $pos = Slic3r::Pointf->new($e->GetX, $size->y - $e->GetY); #- +# $self->_camera_target->translate( +# # ($pos - $size/2) represents the vector from the viewport center +# # to the mouse point. By multiplying it by $zoom we get the new, +# # transformed, length of such vector. +# # Since we want that point to stay fixed, we move our camera target +# # in the opposite direction by the delta of the length of such vector +# # ($zoom - 1). We then scale everything by 1/$self->_zoom since +# # $self->_camera_target is expressed in terms of model units. +# -($pos->x - $size->x/2) * ($zoom) / $self->_zoom, +# -($pos->y - $size->y/2) * ($zoom) / $self->_zoom, +# 0, +# ) if 0; + $self->on_viewport_changed->() if $self->on_viewport_changed; $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen; $self->Refresh; @@ -683,9 +688,82 @@ sub select_view { sub get_zoom_to_bounding_box_factor { my ($self, $bb) = @_; - return undef if ($bb->empty); - my $max_size = max(@{$bb->size}) * 2; - return ($max_size == 0) ? undef : min($self->GetSizeWH) / $max_size; + my $max_bb_size = max(@{ $bb->size }); + return undef if ($max_bb_size == 0); + + # project the bbox vertices on a plane perpendicular to the camera forward axis + # then calculates the vertices coordinate on this plane along the camera xy axes + + # we need the view matrix, we let opengl calculate it (same as done in render sub) + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + if (!TURNTABLE_MODE) { + # Shift the perspective camera. + my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); + glTranslatef(@$camera_pos); + } + + if (TURNTABLE_MODE) { + # Turntable mode is enabled by default. + glRotatef(-$self->_stheta, 1, 0, 0); # pitch + glRotatef($self->_sphi, 0, 0, 1); # yaw + } else { + # Shift the perspective camera. + my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); + glTranslatef(@$camera_pos); + my @rotmat = quat_to_rotmatrix($self->quat); + glMultMatrixd_p(@rotmat[0..15]); + } + glTranslatef(@{ $self->_camera_target->negative }); + + # get the view matrix back from opengl + my @matrix = glGetFloatv_p(GL_MODELVIEW_MATRIX); + + # camera axes + my $right = Slic3r::Pointf3->new($matrix[0], $matrix[4], $matrix[8]); + my $up = Slic3r::Pointf3->new($matrix[1], $matrix[5], $matrix[9]); + my $forward = Slic3r::Pointf3->new($matrix[2], $matrix[6], $matrix[10]); + + my $bb_min = $bb->min_point(); + my $bb_max = $bb->max_point(); + my $bb_center = $bb->center(); + + # bbox vertices in world space + my @vertices = (); + push(@vertices, $bb_min); + push(@vertices, Slic3r::Pointf3->new($bb_max->x(), $bb_min->y(), $bb_min->z())); + push(@vertices, Slic3r::Pointf3->new($bb_max->x(), $bb_max->y(), $bb_min->z())); + push(@vertices, Slic3r::Pointf3->new($bb_min->x(), $bb_max->y(), $bb_min->z())); + push(@vertices, Slic3r::Pointf3->new($bb_min->x(), $bb_min->y(), $bb_max->z())); + push(@vertices, Slic3r::Pointf3->new($bb_max->x(), $bb_min->y(), $bb_max->z())); + push(@vertices, $bb_max); + push(@vertices, Slic3r::Pointf3->new($bb_min->x(), $bb_max->y(), $bb_max->z())); + + my $max_x = 0.0; + my $max_y = 0.0; + + # margin factor to give some empty space around the bbox + my $margin_factor = 1.25; + + foreach my $v (@vertices) { + # project vertex on the plane perpendicular to camera forward axis + my $pos = Slic3r::Pointf3->new($v->x() - $bb_center->x(), $v->y() - $bb_center->y(), $v->z() - $bb_center->z()); + my $proj_on_normal = $pos->x() * $forward->x() + $pos->y() * $forward->y() + $pos->z() * $forward->z(); + my $proj_on_plane = Slic3r::Pointf3->new($pos->x() - $proj_on_normal * $forward->x(), $pos->y() - $proj_on_normal * $forward->y(), $pos->z() - $proj_on_normal * $forward->z()); + + # calculates vertex coordinate along camera xy axes + my $x_on_plane = $proj_on_plane->x() * $right->x() + $proj_on_plane->y() * $right->y() + $proj_on_plane->z() * $right->z(); + my $y_on_plane = $proj_on_plane->x() * $up->x() + $proj_on_plane->y() * $up->y() + $proj_on_plane->z() * $up->z(); + + $max_x = max($max_x, $margin_factor * 2 * abs($x_on_plane)); + $max_y = max($max_y, $margin_factor * 2 * abs($y_on_plane)); + } + + my ($cw, $ch) = $self->GetSizeWH; + my $min_ratio = min($cw / $max_x, $ch / $max_y); + + return $min_ratio; } sub zoom_to_bounding_box { @@ -697,6 +775,8 @@ sub zoom_to_bounding_box { # center view around bounding box center $self->_camera_target($bb->center); $self->on_viewport_changed->() if $self->on_viewport_changed; + $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen; + $self->Refresh; } } @@ -1031,8 +1111,8 @@ sub Resize { #FIXME setting the size of the box 10x larger than necessary # is only a workaround for an incorrectly set camera. # This workaround harms Z-buffer accuracy! -# my $depth = 1.05 * $self->max_bounding_box->radius(); - my $depth = 10.0 * $self->max_bounding_box->radius(); +# my $depth = 1.05 * $self->max_bounding_box->radius(); + my $depth = max(@{ $self->max_bounding_box->size }); glOrtho( -$x/2, $x/2, -$y/2, $y/2, -$depth, $depth, @@ -1162,7 +1242,7 @@ sub Render { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - { + if (!TURNTABLE_MODE) { # Shift the perspective camera. my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); glTranslatef(@$camera_pos); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d59865491c..5a29ab394e 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1856,6 +1856,7 @@ sub object_cut_dialog { $self->remove($obj_idx); $self->load_model_objects(grep defined($_), @new_objects); $self->arrange; + $self->{canvas3D}->zoom_to_volumes if $self->{canvas3D}; } } diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index 537cb0c8f2..bd49bedb6d 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -10,7 +10,7 @@ use base qw(Wx::Panel Class::Accessor); use Wx::Locale gettext => 'L'; -__PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer auto_zoom)); +__PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer)); sub new { my $class = shift; @@ -21,7 +21,6 @@ sub new { $self->{number_extruders} = 1; # Show by feature type by default. $self->{preferred_color_mode} = 'feature'; - $self->auto_zoom(1); # init GUI elements my $canvas = Slic3r::GUI::3DScene->new($self); @@ -207,41 +206,29 @@ sub new { my $selection = $choice_view_type->GetCurrentSelection(); $self->{preferred_color_mode} = ($selection == 4) ? 'tool' : 'feature'; $self->gcode_preview_data->set_type($selection); - $self->auto_zoom(0); $self->reload_print; - $self->auto_zoom(1); }); EVT_CHECKLISTBOX($self, $combochecklist_features, sub { my $flags = Slic3r::GUI::combochecklist_get_flags($combochecklist_features); $self->gcode_preview_data->set_extrusion_flags($flags); - $self->auto_zoom(0); $self->refresh_print; - $self->auto_zoom(1); }); EVT_CHECKBOX($self, $checkbox_travel, sub { $self->gcode_preview_data->set_travel_visible($checkbox_travel->IsChecked()); - $self->auto_zoom(0); $self->refresh_print; - $self->auto_zoom(1); }); EVT_CHECKBOX($self, $checkbox_retractions, sub { $self->gcode_preview_data->set_retractions_visible($checkbox_retractions->IsChecked()); - $self->auto_zoom(0); $self->refresh_print; - $self->auto_zoom(1); }); EVT_CHECKBOX($self, $checkbox_unretractions, sub { $self->gcode_preview_data->set_unretractions_visible($checkbox_unretractions->IsChecked()); - $self->auto_zoom(0); $self->refresh_print; - $self->auto_zoom(1); }); EVT_CHECKBOX($self, $checkbox_shells, sub { $self->gcode_preview_data->set_shells_visible($checkbox_shells->IsChecked()); - $self->auto_zoom(0); $self->refresh_print; - $self->auto_zoom(1); }); $self->SetSizer($main_sizer); @@ -374,7 +361,7 @@ sub load_print { } $self->show_hide_ui_elements('simple'); } else { - $self->{force_sliders_full_range} = (scalar(@{$self->canvas->volumes}) == 0) && $self->auto_zoom; + $self->{force_sliders_full_range} = (scalar(@{$self->canvas->volumes}) == 0); $self->canvas->load_gcode_preview($self->print, $self->gcode_preview_data, \@colors); $self->show_hide_ui_elements('full'); @@ -384,10 +371,6 @@ sub load_print { } $self->update_sliders($n_layers); - - if ($self->auto_zoom) { - $self->canvas->zoom_to_volumes; - } $self->_loaded(1); } } From 9a1dbfa6cf4fbef9c9ad92972f23aa246c9d6701 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 23 Apr 2018 10:27:42 +0200 Subject: [PATCH 0229/1150] Updated action_undo.png icon and added sys_unlock_grey.png & action_undo_grey.png for dark themes of OS --- lib/Slic3r/GUI/Plater.pm | 2 -- resources/icons/action_undo.png | Bin 491 -> 510 bytes resources/icons/action_undo_grey.png | Bin 0 -> 480 bytes resources/icons/sys_unlock_grey.png | Bin 0 -> 423 bytes xs/src/slic3r/GUI/Tab.cpp | 8 +++++--- 5 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 resources/icons/action_undo_grey.png create mode 100644 resources/icons/sys_unlock_grey.png diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 023ec4ae5a..893cc366bb 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -546,8 +546,6 @@ sub _on_select_preset { wxTheApp->{preset_bundle}->update_platter_filament_ui($idx, $choice); } else { my $selected_item = $choice->GetSelection(); - print ("selected_item = $selected_item\n"); - print ("selected_item_$group = ". $self->{"selected_item_$group"}. "\n"); return if ($selected_item == $self->{"selected_item_$group"}); my $selected_string = $choice->GetString($selected_item); diff --git a/resources/icons/action_undo.png b/resources/icons/action_undo.png index 877f159868640a0399143631438313a31dacf1a1..06bb98b22a6d98e035059205bc4cc35f5164443f 100644 GIT binary patch delta 434 zcmV;j0Zsnv1O5Y$R)3R8L_t(IPnDCqO9Md=#$)0mf`WyextrNXE|AhR0g-^EwdoXW zt!!-dK(Me7dmH}=D?7Edw6IVD#zH|%p&-5zzgcr3xyvCA40}8G&2MM+<}zUzX6yBO zF7BBW>(@xG3)E`0(YTA)klL4Z*n4qzP#jRHRK_Gp`|8ZFYJdC}kSC%UtZIA-t9V$Y+zjoifGbbX@YMRcbW>K%YmhN6?)*X4=*|x7LP<} c9)@A|2OVI(RMldGuK)l507*qoM6N<$f{oS4Pyhe` delta 415 zcmV;Q0bu_A1M35jR)2s=L_t(IPqmRtO9D|8$4AW>N5}VDvzJgotHwuA(wC7a+NVXi zsW#HCT1k(!Eey1!jV3^}LQ6#~{1jtpi0*Ctt@Vh;5+Z_{ce|vqy3h+7u`u)Ckgl3}w1DTmE zN|wh&o{B|SNcFHkfZgq#i3J$PnGDRlfJiXJ{OU>+9&CdRbMjnH~V7dV1DxW9! z*0E9O)@j>xb}B|%|2cV-$NLB6B%4((&o7ksdVT6*{}>3zeF4rRxG}NPf+PR{002ov JPDHLkV1jTT#yPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0d+}4K~y+TwNgDx z!%!5BScQVKo0EgiIye@=(M2(vu37s71Ura>Lvi;vI6664)NYm1Av9?|nl@i3hz<%; zZ5z)C7c32>3VPrY?z`und)|Ff{teY?b-C4Qol5#UG#ZVKPN#Dd1c4_U!WYmu!+7H9G2n-&QaZxM%Bnp!HA<~2>5lTu3Nm(93dADn}X0H2K(LAWTF%Xtz;gB%KA$fspl z`xyb)J*NPdR;$(4#+xzq7~%tnJTuP-KshfHh9F)iNiriP-hUkqpEv+}x|HKA@Pymg ze2*fW1UEXqF3-fBBh<-&)lD>o5E-zE!T$hPyo0N6%hP~G75P)a@`+&>dvg5OP?RtC WJ3qPv{k%&60000Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0X#`WK~y+TwNpJy z!%!5B;2?-Nb$0Rx2(FU9;nb-`aC8x;ppMxb#8q^V3>`DN1>BlIV!mU(J1H$X6l&CS z;T5C48iIJ>@E-4;d+yD>MEDmtj}M z?!a3ZjEbU|`M!V6WPIqlzJPcEGf|sQv_w zn+WaCZD3V>1S^`soV0(4hZyW@{T*)umiCD_j=vZnX=dB@CdIJY%hm?Czqzh^LNS<) z8x2sU_pO7J_i3X6ewJMXB9I36E3xVemiAW&!Uy&+mn{OD R)@T3#002ovPDHLkV1i$rw$T6p literal 0 HcmV?d00001 diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 2b82694dbc..e157673297 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -126,13 +126,15 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information."))); + // Determine the theme color of OS (dark or light) + auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); // Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field. m_bmp_value_lock .LoadFile(from_u8(var("sys_lock.png")), wxBITMAP_TYPE_PNG); - m_bmp_value_unlock .LoadFile(from_u8(var("sys_unlock.png")), wxBITMAP_TYPE_PNG); + m_bmp_value_unlock .LoadFile(from_u8(var(luma >= 128 ? "sys_unlock.png" : "sys_unlock_grey.png")), wxBITMAP_TYPE_PNG); m_bmp_non_system = &m_bmp_white_bullet; // Bitmaps to be shown on the "Undo user changes" button next to each input field. - m_bmp_value_revert .LoadFile(from_u8(var("action_undo.png")), wxBITMAP_TYPE_PNG); - m_bmp_white_bullet .LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG); + m_bmp_value_revert .LoadFile(from_u8(var(luma >= 128 ? "action_undo.png" : "action_undo_grey.png")), wxBITMAP_TYPE_PNG); + m_bmp_white_bullet .LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG); m_bmp_question .LoadFile(from_u8(var("question_mark_01.png")), wxBITMAP_TYPE_PNG); fill_icon_descriptions(); From 33c0d1dca392db9ae852123834938b700104c2a1 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 23 Apr 2018 11:16:47 +0200 Subject: [PATCH 0230/1150] PresetUpdater: Add/fix logging, comments --- xs/src/slic3r/Utils/PresetUpdater.cpp | 115 +++++++++++++++++++++----- xs/src/slic3r/Utils/PresetUpdater.hpp | 9 +- 2 files changed, 102 insertions(+), 22 deletions(-) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 473fcf84f7..a64d05eca3 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -1,9 +1,9 @@ #include "PresetUpdater.hpp" -#include // XXX #include #include #include +#include #include #include #include @@ -48,6 +48,7 @@ static const char *INDEX_FILENAME = "index.idx"; static const char *TMP_EXTENSION = ".download"; +// A confirmation dialog listing configuration updates struct UpdateNotification : wxDialog { // If this dialog gets any more complex, it should probably be factored out... @@ -123,6 +124,11 @@ struct Update {} std::string name() { return source.stem().string(); } + + friend std::ostream& operator<<(std::ostream& os , const Update &update) { + os << "Update(" << update.source.string() << " -> " << update.target.string() << ')'; + return os; + } }; typedef std::vector Updates; @@ -171,6 +177,7 @@ PresetUpdater::priv::priv(int version_online_event) : index_db = std::move(Index::load_db()); } +// Pull relevant preferences from AppConfig void PresetUpdater::priv::set_download_prefs(AppConfig *app_config) { enabled_version_check = app_config->get("version_check") == "1"; @@ -178,19 +185,29 @@ void PresetUpdater::priv::set_download_prefs(AppConfig *app_config) enabled_config_update = app_config->get("preset_update") == "1"; } +// Downloads a file (http get operation). Cancels if the Updater is being destroyed. bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &target_path) const { bool res = false; fs::path tmp_path = target_path; tmp_path += (boost::format(".%1%%2%") % get_current_pid() % TMP_EXTENSION).str(); - std::cerr << "get_file(): " << url << " -> " << target_path << std::endl - << "\ttmp_path: " << tmp_path << std::endl; + BOOST_LOG_TRIVIAL(info) << boost::format("Get: `%1%`\n\t-> `%2%`\n\tvia tmp path `%3%`") + % url + % target_path.string() + % tmp_path.string(); Http::get(url) .on_progress([this](Http::Progress, bool &cancel) { if (cancel) { cancel = true; } }) + .on_error([&](std::string body, std::string error, unsigned http_status) { + (void)body; + BOOST_LOG_TRIVIAL(error) << boost::format("Error getting: `%1%`: HTTP %2%, %3%") + % url + % http_status + % body; + }) .on_complete([&](std::string body, unsigned http_status) { fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc); file.write(body.c_str(), body.size()); @@ -203,26 +220,39 @@ bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &targe return res; } +// Remove leftover paritally downloaded files, if any. void PresetUpdater::priv::prune_tmps() const { for (fs::directory_iterator it(cache_path); it != fs::directory_iterator(); ++it) { if (it->path().extension() == TMP_EXTENSION) { + BOOST_LOG_TRIVIAL(debug) << "Cache prune: " << it->path().string(); fs::remove(it->path()); } } } +// Get Slic3rPE version available online, save in AppConfig. void PresetUpdater::priv::sync_version() const { if (! enabled_version_check) { return; } + BOOST_LOG_TRIVIAL(info) << boost::format("Downloading Slic3rPE online version from: `%1%`") % version_check_url; + Http::get(version_check_url) .size_limit(SLIC3R_VERSION_BODY_MAX) .on_progress([this](Http::Progress, bool &cancel) { cancel = this->cancel; }) + .on_error([&](std::string body, std::string error, unsigned http_status) { + (void)body; + BOOST_LOG_TRIVIAL(error) << boost::format("Error getting: `%1%`: HTTP %2%, %3%") + % version_check_url + % http_status + % body; + }) .on_complete([&](std::string body, unsigned http_status) { boost::trim(body); + BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body; wxCommandEvent* evt = new wxCommandEvent(version_online_event); evt->SetString(body); GUI::get_app()->QueueEvent(evt); @@ -230,9 +260,11 @@ void PresetUpdater::priv::sync_version() const .perform_sync(); } +// Download vendor indices. Also download new bundles if an index indicates there's a new one available. +// Both are saved in cache. void PresetUpdater::priv::sync_config(const std::set vendors) const { - std::cerr << "sync_config()" << std::endl; + BOOST_LOG_TRIVIAL(info) << "Syncing configuration cache"; if (!enabled_config_update) { return; } @@ -240,54 +272,65 @@ void PresetUpdater::priv::sync_config(const std::set vendors) con for (const auto &index : index_db) { if (cancel) { return; } - std::cerr << "Index: " << index.vendor() << std::endl; - const auto vendor_it = vendors.find(VendorProfile(index.vendor())); - if (vendor_it == vendors.end()) { continue; } + if (vendor_it == vendors.end()) { + BOOST_LOG_TRIVIAL(warning) << "No such vendor: " << index.vendor(); + continue; + } const VendorProfile &vendor = *vendor_it; - if (vendor.config_update_url.empty()) { continue; } + if (vendor.config_update_url.empty()) { + BOOST_LOG_TRIVIAL(info) << "Vendor has no config_update_url: " << vendor.name; + continue; + } // Download a fresh index + BOOST_LOG_TRIVIAL(info) << "Downloading index for vendor: " << vendor.name; const auto idx_url = vendor.config_update_url + "/" + INDEX_FILENAME; const auto idx_path = cache_path / (vendor.id + ".idx"); if (! get_file(idx_url, idx_path)) { continue; } if (cancel) { return; } - std::cerr << "Got a new index: " << idx_path << std::endl; - // Load the fresh index up Index new_index; new_index.load(idx_path); // See if a there's a new version to download const auto recommended_it = new_index.recommended(); - if (recommended_it == new_index.end()) { continue; } + if (recommended_it == new_index.end()) { + BOOST_LOG_TRIVIAL(error) << "No recommended version for vendor: " << vendor.name << ", invalid index?"; + continue; + } const auto recommended = recommended_it->config_version; - std::cerr << "Current vendor version: " << vendor.config_version.to_string() << std::endl; - std::cerr << "Recommended version:\t" << recommended.to_string() << std::endl; + BOOST_LOG_TRIVIAL(debug) << boost::format("New index for vendor: %1%: current version: %2%, recommended version: %3%") + % vendor.name + % vendor.config_version.to_string() + % recommended.to_string(); if (vendor.config_version >= recommended) { continue; } // Download a fresh bundle + BOOST_LOG_TRIVIAL(info) << "Downloading new bundle for vendor: " << vendor.name; const auto bundle_url = (boost::format("%1%/%2%.ini") % vendor.config_update_url % recommended.to_string()).str(); const auto bundle_path = cache_path / (vendor.id + ".ini"); if (! get_file(bundle_url, bundle_path)) { continue; } if (cancel) { return; } - - std::cerr << "Got a new bundle: " << bundle_path << std::endl; } } +// Install indicies from resources. Only installs those that are either missing or older than in resources. void PresetUpdater::priv::check_install_indices() const { + BOOST_LOG_TRIVIAL(info) << "Checking if indices need to be installed from resources..."; + for (fs::directory_iterator it(rsrc_path); it != fs::directory_iterator(); ++it) { const auto &path = it->path(); if (path.extension() == ".idx") { const auto path_in_cache = cache_path / path.filename(); if (! fs::exists(path_in_cache)) { + BOOST_LOG_TRIVIAL(info) << "Install index from resources: " << path.filename(); fs::copy_file(path, path_in_cache, fs::copy_option::overwrite_if_exists); } else { Index idx_rsrc, idx_cache; @@ -295,6 +338,7 @@ void PresetUpdater::priv::check_install_indices() const idx_cache.load(path_in_cache); if (idx_cache.version() < idx_rsrc.version()) { + BOOST_LOG_TRIVIAL(info) << "Update index from resources: " << path.filename(); fs::copy_file(path, path_in_cache, fs::copy_option::overwrite_if_exists); } } @@ -302,14 +346,18 @@ void PresetUpdater::priv::check_install_indices() const } } +// Generates a list of bundle updates that are to be performed Updates PresetUpdater::priv::config_update() const { Updates updates; + + BOOST_LOG_TRIVIAL(info) << "Checking for cached configuration updates..."; for (const auto idx : index_db) { const auto bundle_path = vendor_path / (idx.vendor() + ".ini"); if (! fs::exists(bundle_path)) { + BOOST_LOG_TRIVIAL(info) << "Bundle not present for index, skipping: " << idx.vendor(); continue; } @@ -318,7 +366,7 @@ Updates PresetUpdater::priv::config_update() const const auto ver_current = idx.find(vp.config_version); if (ver_current == idx.end()) { - BOOST_LOG_TRIVIAL(warning) << boost::format("Preset bundle (`%1%`) version not found in index: %2%") % idx.vendor() % vp.config_version.to_string(); + BOOST_LOG_TRIVIAL(error) << boost::format("Preset bundle (`%1%`) version not found in index: %2%") % idx.vendor() % vp.config_version.to_string(); continue; } @@ -327,7 +375,13 @@ Updates PresetUpdater::priv::config_update() const throw std::runtime_error((boost::format("Invalid index: `%1%`") % idx.vendor()).str()); } + BOOST_LOG_TRIVIAL(debug) << boost::format("Vendor: %1%, version installed: %2%, version cached: %3%") + % vp.name + % recommended->config_version.to_string() + % ver_current->config_version.to_string(); + if (! ver_current->is_current_slic3r_supported()) { + BOOST_LOG_TRIVIAL(warning) << "Current Slic3r incompatible with installed bundle: " << bundle_path.string(); // TODO: Downgrade situation @@ -336,6 +390,7 @@ Updates PresetUpdater::priv::config_update() const auto path_in_cache = cache_path / (idx.vendor() + ".ini"); if (! fs::exists(path_in_cache)) { + BOOST_LOG_TRIVIAL(warning) << "Index indicates update, but new bundle not found in cache: " << path_in_cache.string(); continue; } @@ -351,11 +406,16 @@ Updates PresetUpdater::priv::config_update() const void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) const { + BOOST_LOG_TRIVIAL(info) << boost::format("Performing %1% updates") % updates.size(); + if (snapshot) { + BOOST_LOG_TRIVIAL(info) << "Taking a snapshot..."; SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE); } for (const auto &update : updates) { + BOOST_LOG_TRIVIAL(info) << '\t' << update; + fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); PresetBundle bundle; @@ -382,6 +442,8 @@ PresetUpdater::PresetUpdater(int version_online_event) : PresetUpdater::~PresetUpdater() { if (p && p->thread.joinable()) { + // This will stop transfers being done by the thread, if any. + // Cancelling takes some time, but should complete soon enough. p->cancel = true; p->thread.join(); } @@ -406,8 +468,12 @@ void PresetUpdater::sync(PresetBundle *preset_bundle) void PresetUpdater::slic3r_update_notify() { - if (! p->enabled_version_check || p->had_config_update) { return; } - // ^ We don't want to bother the user with updates multiple times, put off till next time. + if (! p->enabled_version_check) { return; } + + if (p->had_config_update) { + BOOST_LOG_TRIVIAL(info) << "New Slic3r version available, but there was a configuration update, notification won't be displayed"; + return; + } auto* app_config = GUI::get_app_config(); const auto ver_slic3r = Semver::parse(SLIC3R_VERSION); @@ -438,6 +504,8 @@ void PresetUpdater::config_update() const auto updates = p->config_update(); if (updates.size() > 0) { + BOOST_LOG_TRIVIAL(info) << boost::format("Update of %1% bundles available. Asking for confirmation ...") % updates.size(); + const auto msg = _(L("Configuration update is available. Would you like to install it?")); auto ext_msg = _(L( @@ -457,20 +525,25 @@ void PresetUpdater::config_update() const wxMessageDialog dlg(NULL, msg, _(L("Configuration update")), wxYES_NO|wxCENTRE); dlg.SetExtendedMessage(ext_msg); const auto res = dlg.ShowModal(); - std::cerr << "After modal" << std::endl; if (res == wxID_YES) { - // User gave clearance, updates are go + BOOST_LOG_TRIVIAL(debug) << "User agreed to perform the update"; p->perform_updates(std::move(updates)); + } else { + BOOST_LOG_TRIVIAL(info) << "User refused the update"; } p->had_config_update = true; + } else { + BOOST_LOG_TRIVIAL(info) << "No configuration updates available."; } } -void PresetUpdater::install_bundles_rsrc(std::vector &&bundles, bool snapshot) +void PresetUpdater::install_bundles_rsrc(std::vector bundles, bool snapshot) { Updates updates; + BOOST_LOG_TRIVIAL(info) << boost::format("Installing %1% bundles from resources ...") % bundles.size(); + for (const auto &bundle : bundles) { auto path_in_rsrc = p->rsrc_path / bundle; auto path_in_vendors = p->vendor_path / bundle; diff --git a/xs/src/slic3r/Utils/PresetUpdater.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp index 8fe3e021d5..287f20652f 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -20,10 +20,17 @@ public: PresetUpdater &operator=(const PresetUpdater &) = delete; ~PresetUpdater(); + // If either version check or config updating is enabled, get the appropriate data in the background and cache it. void sync(PresetBundle *preset_bundle); + + // If version check is enabled, check if chaced online slic3r version is newer, notify if so. void slic3r_update_notify(); + + // If updating is enabled, check if updates are available in cache, if so, ask about installation. void config_update() const; - void install_bundles_rsrc(std::vector &&bundles, bool snapshot = true); + + // "Update" a list of bundles from resources (behaves like an online update). + void install_bundles_rsrc(std::vector bundles, bool snapshot = true); private: struct priv; std::unique_ptr p; From ec7e10e068f1b8d587ede2028aa43abd13869593 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 23 Apr 2018 11:52:03 +0200 Subject: [PATCH 0231/1150] Fixed wrong behavior of options group Tree after extruders count change --- xs/src/slic3r/GUI/Tab.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index e157673297..3ad40d9f7a 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1348,6 +1348,9 @@ void TabPrinter::build() m_presets = &m_preset_bundle->printers; load_initial_data(); + // to avoid redundant memory allocation / deallocation during extruders count changing + m_pages.reserve(30); + auto *nozzle_diameter = dynamic_cast(m_config->option("nozzle_diameter")); m_initial_extruders_count = m_extruders_count = nozzle_diameter->values.size(); const Preset* parent_preset = m_presets->get_selected_preset_parent(); @@ -1625,7 +1628,7 @@ void TabPrinter::extruders_count_changed(size_t extruders_count){ } void TabPrinter::build_extruder_pages(){ - if (m_extruders_count_old == m_extruders_count) + if (m_extruders_count_old == m_extruders_count || m_extruders_count <= 2) { // if we have a single extruder MM setup, add a page with configuration options: for (int i = 0; i < m_pages.size(); ++i) // first make sure it's not there already @@ -1642,8 +1645,6 @@ void TabPrinter::build_extruder_pages(){ optgroup->append_single_option_line("parking_pos_retraction"); m_pages.insert(m_pages.end()-2, page); } - rebuild_page_tree(); - return; } for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx){ From a7a8030feaf5d22dfa05f6427879ec3e2613b211 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 23 Apr 2018 13:58:03 +0200 Subject: [PATCH 0232/1150] PresetUpdater: Don't install updates that are already present in a snapshot --- xs/src/slic3r/Utils/PresetUpdater.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index a64d05eca3..8dd974537e 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -160,7 +160,7 @@ struct PresetUpdater::priv void sync_config(const std::set vendors) const; void check_install_indices() const; - Updates config_update() const; + Updates get_config_updates() const; void perform_updates(Updates &&updates, bool snapshot = true) const; }; @@ -347,10 +347,10 @@ void PresetUpdater::priv::check_install_indices() const } // Generates a list of bundle updates that are to be performed -Updates PresetUpdater::priv::config_update() const +Updates PresetUpdater::priv::get_config_updates() const { Updates updates; - + BOOST_LOG_TRIVIAL(info) << "Checking for cached configuration updates..."; for (const auto idx : index_db) { @@ -388,6 +388,16 @@ Updates PresetUpdater::priv::config_update() const } else if (recommended->config_version > ver_current->config_version) { // Config bundle update situation + // Check if the update is already present in a snapshot + const auto recommended_snap = SnapshotDB::singleton().snapshot_with_vendor_preset(vp.name, recommended->config_version); + if (recommended_snap != SnapshotDB::singleton().end()) { + BOOST_LOG_TRIVIAL(info) << boost::format("Bundle update %1% %2% already found in snapshot %3%, skipping...") + % vp.name + % recommended->config_version.to_string() + % recommended_snap->id; + continue; + } + auto path_in_cache = cache_path / (idx.vendor() + ".ini"); if (! fs::exists(path_in_cache)) { BOOST_LOG_TRIVIAL(warning) << "Index indicates update, but new bundle not found in cache: " << path_in_cache.string(); @@ -502,7 +512,7 @@ void PresetUpdater::config_update() const { if (! p->enabled_config_update) { return; } - auto updates = p->config_update(); + auto updates = p->get_config_updates(); if (updates.size() > 0) { BOOST_LOG_TRIVIAL(info) << boost::format("Update of %1% bundles available. Asking for confirmation ...") % updates.size(); From cd3be74e3b3336bb46bbec85f6898813181caa79 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 23 Apr 2018 15:03:38 +0200 Subject: [PATCH 0233/1150] Workaround for 3D view and GUI buttons not in synch when object's size is almost identical to print volume's size --- xs/src/libslic3r/BoundingBox.hpp | 25 +++++++++++++++++++++++++ xs/src/libslic3r/Model.cpp | 4 ++-- xs/src/libslic3r/Print.cpp | 2 +- xs/src/slic3r/GUI/3DScene.cpp | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp index 92a2bd451c..a96fd1a301 100644 --- a/xs/src/libslic3r/BoundingBox.hpp +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -147,6 +147,31 @@ public: BoundingBoxf3() : BoundingBox3Base() {}; BoundingBoxf3(const Pointf3 &pmin, const Pointf3 &pmax) : BoundingBox3Base(pmin, pmax) {}; BoundingBoxf3(const std::vector &points) : BoundingBox3Base(points) {}; + + // check if the given point is contained inside this bounding box + // all quantities are compared after being quantized to try to reduce instability due to float imprecision + bool contains_quantized(const Pointf3& point) const { + struct Helper + { + static coordf_t quantize(coordf_t value) + { + static const coordf_t INV_EPSILON = 1.0 / EPSILON; + return round(value * INV_EPSILON + 0.5) * EPSILON; + } + }; + + coordf_t x = Helper::quantize(point.x); + coordf_t y = Helper::quantize(point.y); + coordf_t z = Helper::quantize(point.z); + + return (Helper::quantize(min.x) <= x) && (x <= Helper::quantize(max.x)) + && (Helper::quantize(min.y) <= y) && (y <= Helper::quantize(max.y)) + && (Helper::quantize(min.z) <= z) && (z <= Helper::quantize(max.z)); + } + + bool contains_quantized(const BoundingBoxf3& other) const { + return contains_quantized(other.min) && contains_quantized(other.max); + } }; template diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index aaea863e83..25e2073047 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -463,7 +463,7 @@ bool Model::fits_print_volume(const DynamicPrintConfig* config) const BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config->opt_float("max_print_height"))); // Allow the objects to protrude below the print bed print_volume.min.z = -1e10; - return print_volume.contains(transformed_bounding_box()); + return print_volume.contains_quantized(transformed_bounding_box()); } bool Model::fits_print_volume(const FullPrintConfig &config) const @@ -474,7 +474,7 @@ bool Model::fits_print_volume(const FullPrintConfig &config) const BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config.max_print_height)); // Allow the objects to protrude below the print bed print_volume.min.z = -1e10; - return print_volume.contains(transformed_bounding_box()); + return print_volume.contains_quantized(transformed_bounding_box()); } unsigned int Model::get_auto_extruder_id() diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index e692b1e9ee..9de5c03794 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -522,7 +522,7 @@ std::string Print::validate() const // Allow the objects to protrude below the print bed, only the part of the object above the print bed will be sliced. print_volume.min.z = -1e10; for (PrintObject *po : this->objects) { - if (! print_volume.contains(po->model_object()->tight_bounding_box(false))) + if (!print_volume.contains_quantized(po->model_object()->tight_bounding_box(false))) return "Some objects are outside of the print volume."; } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 7f5e632bba..7d4e4d68c5 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -665,7 +665,7 @@ void GLVolumeCollection::update_outside_state(const DynamicPrintConfig* config, continue; } - volume->is_outside = !print_volume.contains(volume->transformed_bounding_box()); + volume->is_outside = !print_volume.contains_quantized(volume->transformed_bounding_box()); } } From 6432ec8a9b91939b3e433e9a44c1f437a4b35b82 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 23 Apr 2018 15:09:01 +0200 Subject: [PATCH 0234/1150] Experiment with extruders count change --- xs/src/slic3r/GUI/Tab.cpp | 86 ++++++++++++++++++++++++++++++++++----- xs/src/slic3r/GUI/Tab.hpp | 5 +++ 2 files changed, 81 insertions(+), 10 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 3ad40d9f7a..f0471cea08 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1306,6 +1306,7 @@ void TabFilament::reload_config(){ void TabFilament::update() { + Freeze(); wxString text = from_u8(PresetHints::cooling_description(m_presets->get_edited_preset())); m_cooling_description_line->SetText(text); text = from_u8(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle)); @@ -1319,6 +1320,7 @@ void TabFilament::update() for (auto el : { "min_fan_speed", "disable_fan_first_layers" }) get_field(el)->toggle(fan_always_on); + Thaw(); } void TabFilament::OnActivate() @@ -1349,7 +1351,8 @@ void TabPrinter::build() load_initial_data(); // to avoid redundant memory allocation / deallocation during extruders count changing - m_pages.reserve(30); + m_pages.reserve(30); + m_extruders_tree_items.reserve(30); auto *nozzle_diameter = dynamic_cast(m_config->option("nozzle_diameter")); m_initial_extruders_count = m_extruders_count = nozzle_diameter->values.size(); @@ -1400,8 +1403,10 @@ void TabPrinter::build() size_t extruders_count = boost::any_cast(optgroup->get_value("extruders_count")); wxTheApp->CallAfter([this, opt_key, value, extruders_count](){ if (opt_key.compare("extruders_count")==0 || opt_key.compare("single_extruder_multi_material")==0) { + m_correct_treectrl = true; extruders_count_changed(extruders_count); update_dirty(); + m_correct_treectrl = false; if (opt_key.compare("single_extruder_multi_material")==0) // the single_extruder_multimaterial was added to force pages on_value_change(opt_key, value); // rebuild - let's make sure the on_value_change is not skipped } @@ -1835,19 +1840,80 @@ void Tab::rebuild_page_tree() // get label of the currently selected item auto selected = m_treectrl->GetItemText(m_treectrl->GetSelection()); auto rootItem = m_treectrl->GetRootItem(); - m_treectrl->DeleteChildren(rootItem); + auto have_selection = 0; - for (auto p : m_pages) + if (name() == "printer") { - auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID()); - m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); - if (p->title() == selected) { - m_disable_tree_sel_changed_event = 1; - m_treectrl->SelectItem(itemId); - m_disable_tree_sel_changed_event = 0; - have_selection = 1; + TabPrinter* tab = dynamic_cast(this); + if (!tab->m_correct_treectrl){ + m_treectrl->DeleteChildren(rootItem); + tab->m_extruders_tree_items.resize(0); + tab->m_single_extruder_MM_item = nullptr; + for (auto p : m_pages) + { + auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID()); + m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); + + if (p->title().Contains(_("Extruder"))) + tab->m_extruders_tree_items.push_back(itemId); + + if (p->title() == _("Single extruder MM setup")) + tab->m_single_extruder_MM_item = itemId; + + if (p->title() == selected) { + m_disable_tree_sel_changed_event = 1; + m_treectrl->SelectItem(itemId); + m_disable_tree_sel_changed_event = 0; + have_selection = 1; + } + } + } + else + { + while (tab->m_extruders_tree_items.size() > tab->m_extruders_count){ + m_treectrl->Delete(tab->m_extruders_tree_items.back()); + tab->m_extruders_tree_items.pop_back(); + } + + size_t i = 2 + tab->m_extruders_tree_items.size(); + for (; i < 2 + tab->m_extruders_count; ++i) + { + auto p = m_pages[i]; + auto itemId = m_treectrl->InsertItem(rootItem, tab->m_extruders_tree_items.back(), p->title(), p->iconID()); + m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); + tab->m_extruders_tree_items.push_back(itemId); + } + + if (tab->m_extruders_count == 1 || !m_config->opt_bool("single_extruder_multi_material") + && tab->m_single_extruder_MM_item) + { + m_treectrl->Delete(tab->m_single_extruder_MM_item); + tab->m_single_extruder_MM_item = nullptr; + } + else if (tab->m_single_extruder_MM_item == nullptr) + { + auto p = m_pages[i]; + auto itemId = tab->m_single_extruder_MM_item = + m_treectrl->InsertItem(rootItem, tab->m_extruders_tree_items.back(), p->title(), p->iconID()); + m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); + } } } + else + { + m_treectrl->DeleteChildren(rootItem); + for (auto p : m_pages) + { + auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID()); + m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); + if (p->title() == selected) { + m_disable_tree_sel_changed_event = 1; + m_treectrl->SelectItem(itemId); + m_disable_tree_sel_changed_event = 0; + have_selection = 1; + } + } + } if (!have_selection) { // this is triggered on first load, so we don't disable the sel change event diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index eda6727a85..0961c71fb2 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -300,6 +300,11 @@ public: size_t m_initial_extruders_count; size_t m_sys_extruders_count; + std::vector m_extruders_tree_items; + wxTreeItemId m_single_extruder_MM_item = nullptr; + bool m_correct_treectrl = false; // m_correct_tree = false -> delete/create m_treectrl + // m_correct_tree = true -> just correct m_treectrl + TabPrinter() {} TabPrinter(wxNotebook* parent, bool no_controller) : Tab(parent, _(L("Printer Settings")), "printer", no_controller) {} ~TabPrinter(){} From a3c3eb5d2af4a9e6e809377f78e3d211a2f00182 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 23 Apr 2018 15:30:41 +0200 Subject: [PATCH 0235/1150] Fixed GCode Preview not invalidated when deleting an object --- lib/Slic3r/GUI/Plater.pm | 1 + lib/Slic3r/GUI/Plater/3DPreview.pm | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 5a29ab394e..ce78eab8ec 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1677,6 +1677,7 @@ sub update { $self->{canvas}->reload_scene if $self->{canvas}; $self->{canvas3D}->reload_scene if $self->{canvas3D}; + $self->{preview3D}->reset_gcode_preview_data if $self->{preview3D}; $self->{preview3D}->reload_print if $self->{preview3D}; } diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index bd49bedb6d..4834f7aed1 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -289,6 +289,12 @@ sub refresh_print { $self->load_print; } +sub reset_gcode_preview_data { + my ($self) = @_; + $self->gcode_preview_data->reset; + $self->canvas->reset_legend_texture(); +} + sub load_print { my ($self) = @_; From b0841f78f4f602858bdaf23c2d9b41fb3b4f1958 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 23 Apr 2018 15:39:55 +0200 Subject: [PATCH 0236/1150] Experiment failed --- xs/src/slic3r/GUI/Tab.cpp | 95 ++++++++------------------------------- xs/src/slic3r/GUI/Tab.hpp | 5 --- 2 files changed, 18 insertions(+), 82 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index f0471cea08..fa6ed7ca64 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1352,7 +1352,6 @@ void TabPrinter::build() // to avoid redundant memory allocation / deallocation during extruders count changing m_pages.reserve(30); - m_extruders_tree_items.reserve(30); auto *nozzle_diameter = dynamic_cast(m_config->option("nozzle_diameter")); m_initial_extruders_count = m_extruders_count = nozzle_diameter->values.size(); @@ -1403,10 +1402,8 @@ void TabPrinter::build() size_t extruders_count = boost::any_cast(optgroup->get_value("extruders_count")); wxTheApp->CallAfter([this, opt_key, value, extruders_count](){ if (opt_key.compare("extruders_count")==0 || opt_key.compare("single_extruder_multi_material")==0) { - m_correct_treectrl = true; extruders_count_changed(extruders_count); update_dirty(); - m_correct_treectrl = false; if (opt_key.compare("single_extruder_multi_material")==0) // the single_extruder_multimaterial was added to force pages on_value_change(opt_key, value); // rebuild - let's make sure the on_value_change is not skipped } @@ -1633,6 +1630,9 @@ void TabPrinter::extruders_count_changed(size_t extruders_count){ } void TabPrinter::build_extruder_pages(){ + size_t n_before_extruders = 2; // Count of pages before Extruder pages + size_t n_after_single_extruder_MM = 2; // Count of pages after single_extruder_multi_material page + if (m_extruders_count_old == m_extruders_count || m_extruders_count <= 2) { // if we have a single extruder MM setup, add a page with configuration options: @@ -1648,16 +1648,16 @@ void TabPrinter::build_extruder_pages(){ optgroup->append_single_option_line("cooling_tube_retraction"); optgroup->append_single_option_line("cooling_tube_length"); optgroup->append_single_option_line("parking_pos_retraction"); - m_pages.insert(m_pages.end()-2, page); + m_pages.insert(m_pages.end() - n_after_single_extruder_MM, page); } } - + for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx){ //# build page char buf[MIN_BUF_LENGTH_FOR_L]; sprintf(buf, _CHB(L("Extruder %d")), extruder_idx + 1); auto page = add_options_page(from_u8(buf), "funnel.png", true); - m_pages.insert(m_pages.begin() + 2+extruder_idx, page); + m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page); auto optgroup = page->new_optgroup(_(L("Size"))); optgroup->append_single_option_line("nozzle_diameter", extruder_idx); @@ -1696,7 +1696,8 @@ void TabPrinter::build_extruder_pages(){ // # remove extra pages if (m_extruders_count < m_extruders_count_old) - m_pages.erase(m_pages.begin() + 2 + m_extruders_count, m_pages.begin() + 2 + m_extruders_count_old); + m_pages.erase( m_pages.begin() + n_before_extruders + m_extruders_count, + m_pages.begin() + n_before_extruders + m_extruders_count_old); m_extruders_count_old = m_extruders_count; @@ -1842,79 +1843,19 @@ void Tab::rebuild_page_tree() auto rootItem = m_treectrl->GetRootItem(); auto have_selection = 0; - if (name() == "printer") + m_treectrl->DeleteChildren(rootItem); + for (auto p : m_pages) { - TabPrinter* tab = dynamic_cast(this); - if (!tab->m_correct_treectrl){ - m_treectrl->DeleteChildren(rootItem); - tab->m_extruders_tree_items.resize(0); - tab->m_single_extruder_MM_item = nullptr; - for (auto p : m_pages) - { - auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID()); - m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); - - if (p->title().Contains(_("Extruder"))) - tab->m_extruders_tree_items.push_back(itemId); - - if (p->title() == _("Single extruder MM setup")) - tab->m_single_extruder_MM_item = itemId; - - if (p->title() == selected) { - m_disable_tree_sel_changed_event = 1; - m_treectrl->SelectItem(itemId); - m_disable_tree_sel_changed_event = 0; - have_selection = 1; - } - } - } - else - { - while (tab->m_extruders_tree_items.size() > tab->m_extruders_count){ - m_treectrl->Delete(tab->m_extruders_tree_items.back()); - tab->m_extruders_tree_items.pop_back(); - } - - size_t i = 2 + tab->m_extruders_tree_items.size(); - for (; i < 2 + tab->m_extruders_count; ++i) - { - auto p = m_pages[i]; - auto itemId = m_treectrl->InsertItem(rootItem, tab->m_extruders_tree_items.back(), p->title(), p->iconID()); - m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); - tab->m_extruders_tree_items.push_back(itemId); - } - - if (tab->m_extruders_count == 1 || !m_config->opt_bool("single_extruder_multi_material") - && tab->m_single_extruder_MM_item) - { - m_treectrl->Delete(tab->m_single_extruder_MM_item); - tab->m_single_extruder_MM_item = nullptr; - } - else if (tab->m_single_extruder_MM_item == nullptr) - { - auto p = m_pages[i]; - auto itemId = tab->m_single_extruder_MM_item = - m_treectrl->InsertItem(rootItem, tab->m_extruders_tree_items.back(), p->title(), p->iconID()); - m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); - } + auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID()); + m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); + if (p->title() == selected) { + m_disable_tree_sel_changed_event = 1; + m_treectrl->SelectItem(itemId); + m_disable_tree_sel_changed_event = 0; + have_selection = 1; } } - else - { - m_treectrl->DeleteChildren(rootItem); - for (auto p : m_pages) - { - auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID()); - m_treectrl->SetItemTextColour(itemId, p->get_item_colour()); - if (p->title() == selected) { - m_disable_tree_sel_changed_event = 1; - m_treectrl->SelectItem(itemId); - m_disable_tree_sel_changed_event = 0; - have_selection = 1; - } - } - } - + if (!have_selection) { // this is triggered on first load, so we don't disable the sel change event m_treectrl->SelectItem(m_treectrl->GetFirstVisibleItem());//! (treectrl->GetFirstChild(rootItem)); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 0961c71fb2..eda6727a85 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -300,11 +300,6 @@ public: size_t m_initial_extruders_count; size_t m_sys_extruders_count; - std::vector m_extruders_tree_items; - wxTreeItemId m_single_extruder_MM_item = nullptr; - bool m_correct_treectrl = false; // m_correct_tree = false -> delete/create m_treectrl - // m_correct_tree = true -> just correct m_treectrl - TabPrinter() {} TabPrinter(wxNotebook* parent, bool no_controller) : Tab(parent, _(L("Printer Settings")), "printer", no_controller) {} ~TabPrinter(){} From e31f5fc4b6d69a67f755cd8570d469b50237a6bb Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 24 Apr 2018 08:49:37 +0200 Subject: [PATCH 0237/1150] Modified text for tooltips and ButtonsDescription --- xs/src/slic3r/GUI/ButtonsDescription.cpp | 10 +++--- xs/src/slic3r/GUI/Tab.cpp | 44 +++++++++++++----------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/xs/src/slic3r/GUI/ButtonsDescription.cpp b/xs/src/slic3r/GUI/ButtonsDescription.cpp index 6831d0dddb..b932985bf5 100644 --- a/xs/src/slic3r/GUI/ButtonsDescription.cpp +++ b/xs/src/slic3r/GUI/ButtonsDescription.cpp @@ -24,10 +24,12 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, t_icon_descriptions* ic std::istringstream f(pair.second); std::string s; - while (getline(f, s, ';')) { - auto description = new wxStaticText(this, wxID_ANY, _(s)); - grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL); - } + getline(f, s, ';'); + auto description = new wxStaticText(this, wxID_ANY, _(s)); + grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL); + getline(f, s, ';'); + description = new wxStaticText(this, wxID_ANY, _(s)); + grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL | wxEXPAND); } auto button = CreateStdDialogButtonSizer(wxOK); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index fa6ed7ca64..c9c7ad6325 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -111,18 +111,20 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_question_btn->SetBackgroundColour(color); } - m_undo_to_sys_btn->SetToolTip(_(L( "UNLOCKED LOCK icon indicates about some value changes compared with system values " - "in current option group.\n" - "LOCKED LOCK icon indicates about same values compared with system values " - "in current option group.\n" - "WHITE BULLET icon indicates about nonsystem preset.\n\n" - "Click the UNLOCKED LOCK to revert all values in current option group to system values."))); + m_undo_to_sys_btn->SetToolTip(_(L( "LOCKED LOCK icon indicates that the settings are the same as the system values " + "for the current option group.\n" + "UNLOCKED LOCK icon indicates that some settings were changed and are not equal " + "to the system values for the current option group.\n" + "WHITE BULLET icon indicates a nonsystem preset.\n\n" + "Click the UNLOCKED LOCK icon to reset all settings for current option group to " + "the system values."))); - m_undo_btn->SetToolTip(_(L( "BACK ARROW icon indicates about some value changes compared with last saved preset values " - "in current option group.\n" - "WHITE BULLET icon indicates about same values compared with last saved preset values " - "in current option group.\n\n" - "Click the BACK ARROW to revert all values in current option group to last saved preset values."))); + m_undo_btn->SetToolTip(_(L( "WHITE BULLET icon indicates that the settings are the same as in the last saved" + "preset for the current option group.\n" + "BACK ARROW icon indicates that the settings were changed and are not equal to " + "the last saved preset for the current option group.\n\n" + "Click the BACK ARROW icon to reset all settings for the current option group to " + "the last saved preset."))); m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information."))); @@ -2362,19 +2364,23 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible) void Tab::fill_icon_descriptions() { m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_lock, L("LOCKED LOCK;" - "indicates about same values compared with system values in current option group"))); + "indicates that the settings are the same as the system values for the current option group"))); m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_unlock, L("UNLOCKED LOCK;" - "indicates about some value changes compared with system values in current option group.\n" - "Click the UNLOCKED LOCK to revert all values in current option group to system values."))); + "indicates that some settings were changed and are not equal to the system values for " + "the current option group.\n" + "Click the UNLOCKED LOCK icon to reset all settings for current option group to " + "the system values."))); m_icon_descriptions.push_back(t_icon_description(&m_bmp_white_bullet, L("WHITE BULLET;" - "indicates about : \n - nonsystem preset (on left button)" - "\n - same values compared with last saved preset values in current option group(on right button)"))); + "for the left button: \tindicates a non-system preset,\n" + "for the right button: \tindicates that the settings hasn't been modified."))); m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_revert, L("BACK ARROW;" - "indicates about some value changes compared with last saved preset values in current option group.\n" - "Click the BACK ARROW to revert all values in current option group to last saved preset values."))); + "indicates that the settings were changed and are not equal to the last saved preset for " + "the current option group.\n" + "Click the BACK ARROW icon to reset all settings for the current option group to " + "the last saved preset."))); } void Page::reload_config() @@ -2435,8 +2441,6 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la return static_cast(GetParent())->m_presets->get_selected_preset_parent() != nullptr; }; -// optgroup->nonsys_btn_icon = m_bmp_non_system; - vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10); m_optgroups.push_back(optgroup); From 71d9500b2e7fe37ee4de8ae6d52484285ddfc7a8 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 24 Apr 2018 09:00:33 +0200 Subject: [PATCH 0238/1150] More robust fix for 3D view and GUI buttons not in synch when object's size is almost identical to print volume's size --- lib/Slic3r/GUI/3DScene.pm | 2 +- lib/Slic3r/GUI/Plater.pm | 2 +- lib/Slic3r/GUI/Plater/3D.pm | 5 +++-- xs/src/libslic3r/BoundingBox.hpp | 25 ------------------------- xs/src/libslic3r/Model.cpp | 30 ------------------------------ xs/src/libslic3r/Model.hpp | 4 ---- xs/src/libslic3r/Print.cpp | 2 +- xs/src/slic3r/GUI/3DScene.cpp | 25 ++++++++++++++++++------- xs/src/slic3r/GUI/3DScene.hpp | 4 +++- xs/xsp/GUI_3DScene.xsp | 7 ++++++- xs/xsp/Model.xsp | 3 --- 11 files changed, 33 insertions(+), 76 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index ff6d733997..80fa337c40 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1396,7 +1396,7 @@ sub Render { if ($self->enable_picking) { $self->mark_volumes_for_layer_height; $self->volumes->set_print_box($self->bed_bounding_box->x_min, $self->bed_bounding_box->y_min, 0.0, $self->bed_bounding_box->x_max, $self->bed_bounding_box->y_max, $self->{config}->get('max_print_height')); - $self->volumes->update_outside_state($self->{config}, 0); + $self->volumes->check_outside_state($self->{config}); # do not cull backfaces to show broken geometry, if any glDisable(GL_CULL_FACE); } diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index ce78eab8ec..f9ce75effc 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1921,7 +1921,7 @@ sub object_list_changed { } my $export_in_progress = $self->{export_gcode_output_file} || $self->{send_gcode_file}; - my $model_fits = $self->{model}->fits_print_volume($self->{config}); + my $model_fits = $self->{canvas3D} ? $self->{canvas3D}->volumes->check_outside_state($self->{config}) : 1; my $method = ($have_objects && ! $export_in_progress && $model_fits) ? 'Enable' : 'Disable'; $self->{"btn_$_"}->$method for grep $self->{"btn_$_"}, qw(reslice export_gcode print send_gcode); diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index dce60e2c44..54b9167735 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -222,13 +222,14 @@ sub reload_scene { # checks for geometry outside the print volume to render it accordingly if (scalar @{$self->volumes} > 0) { - if (!$self->{model}->fits_print_volume($self->{config})) { + my $contained = $self->volumes->check_outside_state($self->{config}); + if (!$contained) { $self->set_warning_enabled(1); Slic3r::GUI::_3DScene::generate_warning_texture(L("Detected object outside print volume")); $self->on_enable_action_buttons->(0) if ($self->on_enable_action_buttons); } else { $self->set_warning_enabled(0); - $self->volumes->update_outside_state($self->{config}, 1); + $self->volumes->reset_outside_state(); Slic3r::GUI::_3DScene::reset_warning_texture(); $self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons); } diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp index a96fd1a301..92a2bd451c 100644 --- a/xs/src/libslic3r/BoundingBox.hpp +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -147,31 +147,6 @@ public: BoundingBoxf3() : BoundingBox3Base() {}; BoundingBoxf3(const Pointf3 &pmin, const Pointf3 &pmax) : BoundingBox3Base(pmin, pmax) {}; BoundingBoxf3(const std::vector &points) : BoundingBox3Base(points) {}; - - // check if the given point is contained inside this bounding box - // all quantities are compared after being quantized to try to reduce instability due to float imprecision - bool contains_quantized(const Pointf3& point) const { - struct Helper - { - static coordf_t quantize(coordf_t value) - { - static const coordf_t INV_EPSILON = 1.0 / EPSILON; - return round(value * INV_EPSILON + 0.5) * EPSILON; - } - }; - - coordf_t x = Helper::quantize(point.x); - coordf_t y = Helper::quantize(point.y); - coordf_t z = Helper::quantize(point.z); - - return (Helper::quantize(min.x) <= x) && (x <= Helper::quantize(max.x)) - && (Helper::quantize(min.y) <= y) && (y <= Helper::quantize(max.y)) - && (Helper::quantize(min.z) <= z) && (z <= Helper::quantize(max.z)); - } - - bool contains_quantized(const BoundingBoxf3& other) const { - return contains_quantized(other.min) && contains_quantized(other.max); - } }; template diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 25e2073047..9c9b56659e 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -447,36 +447,6 @@ void Model::adjust_min_z() } } -bool Model::fits_print_volume(const DynamicPrintConfig* config) const -{ - if (config == nullptr) - return false; - - if (objects.empty()) - return true; - - const ConfigOptionPoints* opt = dynamic_cast(config->option("bed_shape")); - if (opt == nullptr) - return false; - - BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); - BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config->opt_float("max_print_height"))); - // Allow the objects to protrude below the print bed - print_volume.min.z = -1e10; - return print_volume.contains_quantized(transformed_bounding_box()); -} - -bool Model::fits_print_volume(const FullPrintConfig &config) const -{ - if (objects.empty()) - return true; - BoundingBox bed_box_2D = get_extents(Polygon::new_scale(config.bed_shape.values)); - BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config.max_print_height)); - // Allow the objects to protrude below the print bed - print_volume.min.z = -1e10; - return print_volume.contains_quantized(transformed_bounding_box()); -} - unsigned int Model::get_auto_extruder_id() { unsigned int id = s_auto_extruder_id; diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index 0c0ffe7769..0baea979c8 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -285,10 +285,6 @@ public: // Ensures that the min z of the model is not negative void adjust_min_z(); - // Returs true if this model is contained into the print volume defined inside the given config - bool fits_print_volume(const DynamicPrintConfig* config) const; - bool fits_print_volume(const FullPrintConfig &config) const; - void print_info() const { for (const ModelObject *o : this->objects) o->print_info(); } static unsigned int get_auto_extruder_id(); diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 9de5c03794..585977ba7f 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -522,7 +522,7 @@ std::string Print::validate() const // Allow the objects to protrude below the print bed, only the part of the object above the print bed will be sliced. print_volume.min.z = -1e10; for (PrintObject *po : this->objects) { - if (!print_volume.contains_quantized(po->model_object()->tight_bounding_box(false))) + if (!print_volume.contains(po->model_object()->tight_bounding_box(false))) return "Some objects are outside of the print volume."; } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 7d4e4d68c5..b9ac1966e3 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -643,29 +643,40 @@ void GLVolumeCollection::render_legacy() const glDisable(GL_BLEND); } -void GLVolumeCollection::update_outside_state(const DynamicPrintConfig* config, bool all_inside) +bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config) { if (config == nullptr) - return; + return false; const ConfigOptionPoints* opt = dynamic_cast(config->option("bed_shape")); if (opt == nullptr) - return; + return false; BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config->opt_float("max_print_height"))); // Allow the objects to protrude below the print bed print_volume.min.z = -1e10; + bool contained = true; for (GLVolume* volume : this->volumes) { - if (all_inside) + if (volume != nullptr) { - volume->is_outside = false; - continue; + bool state = print_volume.contains(volume->transformed_bounding_box()); + contained &= state; + volume->is_outside = !state; } + } - volume->is_outside = !print_volume.contains_quantized(volume->transformed_bounding_box()); + return contained; +} + +void GLVolumeCollection::reset_outside_state() +{ + for (GLVolume* volume : this->volumes) + { + if (volume != nullptr) + volume->is_outside = false; } } diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 8f03e47746..fb5d9f14b2 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -422,7 +422,9 @@ public: print_box_max[0] = max_x; print_box_max[1] = max_y; print_box_max[2] = max_z; } - void update_outside_state(const DynamicPrintConfig* config, bool all_inside); + bool check_outside_state(const DynamicPrintConfig* config); + void reset_outside_state(); + void update_colors_by_extruder(const DynamicPrintConfig* config); // Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 86d0aeba29..ee5a82ba1f 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -104,7 +104,12 @@ 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); - void update_outside_state(DynamicPrintConfig* config, bool all_inside); + 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) diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp index 7028395373..02017839a1 100644 --- a/xs/xsp/Model.xsp +++ b/xs/xsp/Model.xsp @@ -99,9 +99,6 @@ void print_info() const; - bool fits_print_volume(DynamicPrintConfig* config) const - %code%{ RETVAL = THIS->fits_print_volume(config); %}; - bool store_stl(char *path, bool binary) %code%{ TriangleMesh mesh = THIS->mesh(); RETVAL = Slic3r::store_stl(path, &mesh, binary); %}; bool store_amf(char *path, Print* print, bool export_print_config) From 1e8d302fd4e4028faa17deecf32bb811dd913bb1 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 24 Apr 2018 10:33:11 +0200 Subject: [PATCH 0239/1150] Fixed wrong updating of "Top/Bottom fill pattern" --- xs/src/slic3r/GUI/Field.cpp | 91 ++++++++++++++++++++++++------------- xs/src/slic3r/GUI/Field.hpp | 23 ++++++---- 2 files changed, 73 insertions(+), 41 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 2527202879..d0a2ccec21 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -80,12 +80,13 @@ namespace Slic3r { namespace GUI { return std::regex_match(string, regex_pattern); } - boost::any Field::get_value_by_opt_type(wxString& str) +// boost::any Field::get_value_by_opt_type(wxString& str) + void Field::get_value_by_opt_type(wxString& str) { - boost::any ret_val; +// boost::any m_value; switch (m_opt.type){ case coInt: - ret_val = wxAtoi(str); + m_value = wxAtoi(str); break; case coPercent: case coPercents: @@ -95,18 +96,18 @@ namespace Slic3r { namespace GUI { str.RemoveLast(); double val; str.ToCDouble(&val); - ret_val = val; + m_value = val; break; } case coString: case coStrings: case coFloatOrPercent: - ret_val = str.ToStdString(); + m_value = str.ToStdString(); break; default: break; } - return ret_val; +// return m_value; } void TextCtrl::BUILD() { @@ -182,12 +183,12 @@ namespace Slic3r { namespace GUI { window = dynamic_cast(temp); } - boost::any TextCtrl::get_value() + boost::any& TextCtrl::get_value() { wxString ret_str = static_cast(window)->GetValue(); - boost::any ret_val = get_value_by_opt_type(ret_str); + /*boost::any ret_val*/get_value_by_opt_type(ret_str); - return ret_val; + return m_value;//ret_val; } void TextCtrl::enable() { dynamic_cast(window)->Enable(); dynamic_cast(window)->SetEditable(true); } @@ -215,15 +216,15 @@ void CheckBox::BUILD() { window = dynamic_cast(temp); } -boost::any CheckBox::get_value() +boost::any& CheckBox::get_value() { - boost::any ret_val; +// boost::any m_value; bool value = dynamic_cast(window)->GetValue(); if (m_opt.type == coBool) - ret_val = static_cast(value); + m_value = static_cast(value); else - ret_val = static_cast(value); - return ret_val; + m_value = static_cast(value); + return m_value; } int undef_spin_val = -9999; //! Probably, It's not necessary @@ -423,7 +424,33 @@ void Choice::set_value(const boost::any& value, bool change_event) break; } case coEnum:{ - dynamic_cast(window)->SetSelection(boost::any_cast(value)); + int val = boost::any_cast(value); + if (m_opt_id.compare("external_fill_pattern") == 0) + { + if (!m_opt.enum_values.empty()){ + std::string key; + t_config_enum_values map_names = ConfigOptionEnum::get_enum_values(); + for (auto it : map_names) { + if (val == it.second) { + key = it.first; + break; + } + } + + size_t idx = 0; + for (auto el : m_opt.enum_values) + { + if (el.compare(key) == 0) + break; + ++idx; + } + + val = idx == m_opt.enum_values.size() ? 0 : idx; + } + else + val = 0; + } + dynamic_cast(window)->SetSelection(val); break; } default: @@ -453,16 +480,16 @@ void Choice::set_values(const std::vector& values) m_disable_change_event = false; } -boost::any Choice::get_value() +boost::any& Choice::get_value() { - boost::any ret_val; +// boost::any m_value; wxString ret_str = static_cast(window)->GetValue(); if (m_opt_id == "support") - return ret_str; + return m_value = boost::any(ret_str);//ret_str; if (m_opt.type != coEnum) - ret_val = get_value_by_opt_type(ret_str); + /*m_value = */get_value_by_opt_type(ret_str); else { int ret_enum = static_cast(window)->GetSelection(); @@ -473,22 +500,22 @@ boost::any Choice::get_value() t_config_enum_values map_names = ConfigOptionEnum::get_enum_values(); int value = map_names.at(key); - ret_val = static_cast(value); + m_value = static_cast(value); } else - ret_val = static_cast(0); + m_value = static_cast(0); } if (m_opt_id.compare("fill_pattern") == 0) - ret_val = static_cast(ret_enum); + m_value = static_cast(ret_enum); else if (m_opt_id.compare("gcode_flavor") == 0) - ret_val = static_cast(ret_enum); + m_value = static_cast(ret_enum); else if (m_opt_id.compare("support_material_pattern") == 0) - ret_val = static_cast(ret_enum); + m_value = static_cast(ret_enum); else if (m_opt_id.compare("seam_position") == 0) - ret_val = static_cast(ret_enum); + m_value = static_cast(ret_enum); } - return ret_val; + return m_value; } void ColourPicker::BUILD() @@ -508,14 +535,14 @@ void ColourPicker::BUILD() temp->SetToolTip(get_tooltip_text(clr)); } -boost::any ColourPicker::get_value(){ - boost::any ret_val; +boost::any& ColourPicker::get_value(){ +// boost::any m_value; auto colour = static_cast(window)->GetColour(); auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue()); - ret_val = clr_str.ToStdString(); + m_value = clr_str.ToStdString(); - return ret_val; + return m_value; } void PointCtrl::BUILD() @@ -579,7 +606,7 @@ void PointCtrl::set_value(const boost::any& value, bool change_event) set_value(pt, change_event); } -boost::any PointCtrl::get_value() +boost::any& PointCtrl::get_value() { Pointf ret_point; double val; @@ -587,7 +614,7 @@ boost::any PointCtrl::get_value() ret_point.x = val; y_textctrl->GetValue().ToDouble(&val); ret_point.y = val; - return ret_point; + return m_value = ret_point; } } // GUI diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 292bfd81f8..9e5730cf6e 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -85,7 +85,7 @@ public: /// Gets a boost::any representing this control. /// subclasses should overload with a specific version - virtual boost::any get_value() = 0; + virtual boost::any& get_value() = 0; virtual void enable() = 0; virtual void disable() = 0; @@ -106,7 +106,8 @@ public: virtual wxWindow* getWindow() { return nullptr; } bool is_matched(const std::string& string, const std::string& pattern); - boost::any get_value_by_opt_type(wxString& str); +// boost::any get_value_by_opt_type(wxString& str); + void get_value_by_opt_type(wxString& str); /// Factory method for generating new derived classes. template @@ -157,6 +158,9 @@ protected: // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. const wxColour* m_label_color; + // current value + boost::any m_value; + friend class OptionsGroup; }; @@ -191,7 +195,7 @@ public: m_disable_change_event = false; } - boost::any get_value() override; + boost::any& get_value() override; virtual void enable(); virtual void disable(); @@ -218,7 +222,7 @@ public: dynamic_cast(window)->SetValue(boost::any_cast(value)); m_disable_change_event = false; } - boost::any get_value() override; + boost::any& get_value() override; void enable() override { dynamic_cast(window)->Enable(); } void disable() override { dynamic_cast(window)->Disable(); } @@ -248,8 +252,9 @@ public: dynamic_cast(window)->SetValue(tmp_value); m_disable_change_event = false; } - boost::any get_value() override { - return boost::any(tmp_value); + boost::any& get_value() override { +// return boost::any(tmp_value); + return m_value = tmp_value; } void enable() override { dynamic_cast(window)->Enable(); } @@ -271,7 +276,7 @@ public: void set_value(const std::string& value, bool change_event = false); void set_value(const boost::any& value, bool change_event = false); void set_values(const std::vector &values); - boost::any get_value() override; + boost::any& get_value() override; void enable() override { dynamic_cast(window)->Enable(); }; void disable() override{ dynamic_cast(window)->Disable(); }; @@ -299,7 +304,7 @@ public: m_disable_change_event = false; } - boost::any get_value() override; + boost::any& get_value() override; void enable() override { dynamic_cast(window)->Enable(); }; void disable() override{ dynamic_cast(window)->Disable(); }; @@ -321,7 +326,7 @@ public: void set_value(const Pointf& value, bool change_event = false); void set_value(const boost::any& value, bool change_event = false); - boost::any get_value() override; + boost::any& get_value() override; void enable() override { x_textctrl->Enable(); From 92b67fb62ea0b0c3019c8ae601ae19970718ddc9 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 24 Apr 2018 12:12:15 +0200 Subject: [PATCH 0240/1150] Change reset buttons tooltips according to its state --- xs/src/slic3r/GUI/OptionsGroup.cpp | 3 +- xs/src/slic3r/GUI/Tab.cpp | 49 ++++++++++++++++++++---------- xs/src/slic3r/GUI/Tab.hpp | 13 ++++++-- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index c71dd5ba6b..265497e9c0 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -149,7 +149,8 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* // If there's a widget, build it and add the result to the sizer. if (line.widget != nullptr) { auto wgt = line.widget(parent()); - grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, wxOSX ? 0 : 5); + // If widget doesn't have label, don't use border + grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, (wxOSX || line.label.IsEmpty()) ? 0 : 5); if (colored_Label != nullptr) *colored_Label = label; return; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index c9c7ad6325..8200ec4b23 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -104,27 +104,41 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_undo_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); m_undo_to_sys_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); m_question_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); -// m_undo_btns_legent = new wxStaticText(panel, wxID_ANY, _(L("For more information about buttons hover the mouse cursor over them.")), wxDefaultPosition, wxDefaultSize); if (wxMSW) { m_undo_btn->SetBackgroundColour(color); m_undo_to_sys_btn->SetBackgroundColour(color); m_question_btn->SetBackgroundColour(color); } - m_undo_to_sys_btn->SetToolTip(_(L( "LOCKED LOCK icon indicates that the settings are the same as the system values " - "for the current option group.\n" - "UNLOCKED LOCK icon indicates that some settings were changed and are not equal " - "to the system values for the current option group.\n" - "WHITE BULLET icon indicates a nonsystem preset.\n\n" - "Click the UNLOCKED LOCK icon to reset all settings for current option group to " - "the system values."))); +// m_undo_to_sys_btn->SetToolTip(_(L( "LOCKED LOCK icon indicates that the settings are the same as the system values " +// "for the current option group.\n" +// "UNLOCKED LOCK icon indicates that some settings were changed and are not equal " +// "to the system values for the current option group.\n" +// "WHITE BULLET icon indicates a non system preset.\n\n" +// "Click the UNLOCKED LOCK icon to reset all settings for current option group to " +// "the system values."))); +// +// m_undo_btn->SetToolTip(_(L( "WHITE BULLET icon indicates that the settings are the same as in the last saved" +// "preset for the current option group.\n" +// "BACK ARROW icon indicates that the settings were changed and are not equal to " +// "the last saved preset for the current option group.\n\n" +// "Click the BACK ARROW icon to reset all settings for the current option group to " +// "the last saved preset."))); - m_undo_btn->SetToolTip(_(L( "WHITE BULLET icon indicates that the settings are the same as in the last saved" - "preset for the current option group.\n" - "BACK ARROW icon indicates that the settings were changed and are not equal to " - "the last saved preset for the current option group.\n\n" - "Click the BACK ARROW icon to reset all settings for the current option group to " - "the last saved preset."))); + // Text to be shown on the "Revert to system" aka "Lock to system" button next to each input field. + m_tt_value_lock = _(L("LOCKED LOCK icon indicates that the settings are the same as the system values " + "for the current option group")); + m_tt_value_unlock = _(L("UNLOCKED LOCK icon indicates that some settings were changed and are not equal " + "to the system values for the current option group.\n" + "Click it to reset all settings for current option group to the system values.")); + m_tt_white_bullet_ns= _(L("WHITE BULLET icon indicates a non system preset.")); + m_tt_non_system = &m_tt_white_bullet_ns; + // Bitmaps to be shown on the "Undo user changes" button next to each input field. + m_tt_white_bullet = _(L("WHITE BULLET icon indicates that the settings are the same as in the last saved " + "preset for the current option group.")); + m_tt_value_revert = _(L("BACK ARROW icon indicates that the settings were changed and are not equal to " + "the last saved preset for the current option group.\n" + "Click it to reset all settings for the current option group to the last saved preset.")); m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information."))); @@ -171,8 +185,6 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_hsizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL); m_hsizer->AddSpacer(32); m_hsizer->Add(m_question_btn, 0, wxALIGN_CENTER_VERTICAL); -// m_hsizer->Add(m_undo_btns_legent, 0, wxALIGN_CENTER_VERTICAL); -// m_hsizer->AddSpacer(64); // m_hsizer->Add(m_cc_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3); //Horizontal sizer to hold the tree and the selected page. @@ -265,6 +277,7 @@ void Tab::load_initial_data() { m_config = &m_presets->get_edited_preset().config; m_bmp_non_system = m_presets->get_selected_preset_parent() ? &m_bmp_value_unlock : &m_bmp_white_bullet; + m_tt_non_system = m_presets->get_selected_preset_parent() ? &m_tt_value_unlock : &m_tt_white_bullet_ns; } PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages/* = false*/) @@ -468,6 +481,9 @@ void Tab::update_undo_buttons() { m_undo_btn->SetBitmap(m_is_modified_values ? m_bmp_value_revert : m_bmp_white_bullet); m_undo_to_sys_btn->SetBitmap(m_is_nonsys_values ? *m_bmp_non_system : m_bmp_value_lock); + + m_undo_btn->SetToolTip(m_is_modified_values ? m_tt_value_revert : m_tt_white_bullet); + m_undo_to_sys_btn->SetToolTip(m_is_nonsys_values ? *m_tt_non_system : m_tt_value_lock); } void Tab::on_roll_back_value(const bool to_sys /*= true*/) @@ -1810,6 +1826,7 @@ void Tab::load_current_preset() // Reload preset pages with the new configuration values. reload_config(); m_bmp_non_system = m_presets->get_selected_preset_parent() ? &m_bmp_value_unlock : &m_bmp_white_bullet; + m_tt_non_system = m_presets->get_selected_preset_parent() ? &m_tt_value_unlock : &m_tt_white_bullet_ns; // use CallAfter because some field triggers schedule on_change calls using CallAfter, // and we don't want them to be called after this update_dirty() as they would mark the diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index eda6727a85..8c6e7f3295 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -118,7 +118,6 @@ protected: wxButton* m_undo_btn; wxButton* m_undo_to_sys_btn; wxButton* m_question_btn; -// wxStaticText* m_undo_btns_legent; wxComboCtrl* m_cc_presets_choice; wxDataViewTreeCtrl* m_presetctrl; @@ -136,7 +135,7 @@ protected: wxBitmap *m_bmp_non_system; // Bitmaps to be shown on the "Undo user changes" button next to each input field. wxBitmap m_bmp_value_revert; - wxBitmap m_bmp_value_unmodified; +// wxBitmap m_bmp_value_unmodified; wxBitmap m_bmp_question; // Colors for ui "decoration" @@ -144,6 +143,16 @@ protected: wxColour m_modified_label_clr; wxColour m_default_text_clr; + // Text for reset buttons tooltips + wxString m_tt_value_lock; + wxString m_tt_value_unlock; + wxString m_tt_white_bullet_ns; + // The following text points to either m_bmp_value_unlock or m_bmp_white_bullet, depending on whether the current preset has a parent preset. + wxString *m_tt_non_system; + // Bitmaps to be shown on the "Undo user changes" button next to each input field. + wxString m_tt_white_bullet; + wxString m_tt_value_revert; + int m_icon_count; std::map m_icon_index; // Map from an icon file name to its index std::vector m_pages; From 8c77b9645c698dd850703f3f4dbfe51dc441b82c Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 24 Apr 2018 13:02:08 +0200 Subject: [PATCH 0241/1150] Loading, unloading and cooling reworked, new filament parameters regarding cooling were added --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 101 ++++++++++---------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 11 ++- xs/src/libslic3r/Print.cpp | 8 +- xs/src/libslic3r/PrintConfig.cpp | 32 +++++-- xs/src/libslic3r/PrintConfig.hpp | 8 +- xs/src/slic3r/GUI/Preset.cpp | 8 +- xs/src/slic3r/GUI/Tab.cpp | 4 +- 7 files changed, 99 insertions(+), 73 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index bdafdfa23b..db6e933623 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -219,6 +219,17 @@ public: Writer& retract(float e, float f = 0.f) { return load(-e, f); } +// Loads filament while also moving towards given points in x-axis (x feedrate is limited by cutting the distance short if necessary) + Writer& load_move_x_advanced(float farthest_x, float loading_dist, float loading_speed, float max_x_speed = 50.f) + { + float time = std::abs(loading_dist / loading_speed); + float x_speed = std::min(max_x_speed, std::abs(farthest_x - x()) / time); + float feedrate = 60.f * std::hypot(x_speed, loading_speed); + + float end_point = x() + (farthest_x > x() ? 1.f : -1.f) * x_speed * time; + return extrude_explicit(end_point, y(), loading_dist, feedrate); + } + // Elevate the extruder head above the current print_z position. Writer& z_hop(float hop, float f = 0.f) { @@ -786,58 +797,43 @@ void WipeTowerPrusaMM::toolchange_Unload( } WipeTower::xy end_of_ramming(writer.x(),writer.y()); - // Pull the filament end to the BEGINNING of the cooling tube while still moving the print head - float oldx = writer.x(); - float turning_point = (!m_left_to_right ? std::max(xl,oldx-15.f) : std::min(xr,oldx+15.f) ); // so it's not too far - float xdist = std::abs(oldx-turning_point); - float edist = -(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42); + + // Retraction: + float old_x = writer.x(); + float turning_point = (!m_left_to_right ? xl : xr ); + float total_retraction_distance = m_cooling_tube_retraction + m_cooling_tube_length/2.f - 15.f; // the 15mm is reserved for the first part after ramming writer.suppress_preview() - .load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ); // fixed speed after ramming - - // now an ugly hack: unload the filament with a check that the x speed is 50 mm/s - const float speed = m_filpar[m_current_tool].unloading_speed; - xdist = std::min(xdist, std::abs( 50 * edist / speed )); - const float feedrate = std::abs( std::hypot(edist, xdist) / ((edist / speed) / 60.f)); - writer.load_move_x(writer.x() + (m_left_to_right ? -1.f : 1.f) * xdist ,edist, feedrate ); - xdist = std::abs(oldx-turning_point); // recover old value of xdist - - - writer.load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * m_filpar[m_current_tool].unloading_speed*0.55f ) - .load_move_x(oldx ,-12 , 60.f * std::hypot(xdist,12)/12 * m_filpar[m_current_tool].unloading_speed*0.35f ) + .load_move_x_advanced(turning_point, -15.f, 83.f, 50.f) // this is done at fixed speed + .load_move_x_advanced(old_x, -0.70f * total_retraction_distance, 1.0f * m_filpar[m_current_tool].unloading_speed) + .load_move_x_advanced(turning_point, -0.20f * total_retraction_distance, 0.5f * m_filpar[m_current_tool].unloading_speed) + .load_move_x_advanced(old_x, -0.10f * total_retraction_distance, 0.3f * m_filpar[m_current_tool].unloading_speed) + .travel(old_x, writer.y()) // in case previous move was shortened to limit feedrate .resume_preview(); - if (new_temperature != 0) // Set the extruder temperature, but don't wait. + if (new_temperature != 0) // Set the extruder temperature, but don't wait. writer.set_extruder_temp(new_temperature, false); -// cooling: - writer.suppress_preview(); - writer.travel(writer.x(), writer.y() + y_step); - const float start_x = writer.x(); - turning_point = ( xr-start_x > start_x-xl ? xr : xl ); - const float max_x_dist = 2*std::abs(start_x-turning_point); - const unsigned int N = 4 + std::max(0.f, (m_filpar[m_current_tool].cooling_time-14)/3); - float time = m_filpar[m_current_tool].cooling_time / float(N); + // Cooling: + const unsigned number_of_moves = 3; + if (number_of_moves > 0) { + const float initial_speed = 2.2f; // mm/s + const float final_speed = 3.4f; - i = 0; - while (i old_x-xl ? xr : xl; + for (unsigned i=0; i ramming_speed; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index c12cb64cd1..ec91691a1f 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -186,7 +186,9 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.filament_loading_speed.get_at(i), this->config.filament_unloading_speed.get_at(i), this->config.filament_toolchange_delay.get_at(i), - this->config.filament_cooling_time.get_at(i), + this->config.filament_cooling_moves.get_at(i), + this->config.filament_cooling_initial_speed.get_at(i), + this->config.filament_cooling_final_speed.get_at(i), this->config.filament_ramming_parameters.get_at(i), this->config.nozzle_diameter.get_at(i)); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 75129f4fdf..55a1b84e36 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -481,15 +481,31 @@ PrintConfigDef::PrintConfigDef() def->cli = "filament-toolchange-delay=f@"; def->min = 0; def->default_value = new ConfigOptionFloats { 0. }; - - def = this->add("filament_cooling_time", coFloats); - def->label = L("Cooling time"); - def->tooltip = L("The filament is slowly moved back and forth after retraction into the cooling tube " - "for this amount of time."); - def->cli = "filament_cooling_time=i@"; - def->sidetext = L("s"); + + def = this->add("filament_cooling_moves", coInts); + def->label = L("Number of cooling moves"); + def->tooltip = L("Filament is cooled by being moved back and forth in the " + "cooling tubes. Specify desired number of these moves "); + def->cli = "filament-cooling-moves=i@"; + def->max = 0; + def->max = 20; + def->default_value = new ConfigOptionInts { 6 }; + + def = this->add("filament_cooling_initial_speed", coFloats); + def->label = L("Speed of the first cooling move"); + def->tooltip = L("Cooling moves are gradually accelerating beginning at this speed. "); + def->cli = "filament-cooling-initial-speed=i@"; + def->sidetext = L("mm/s"); def->min = 0; - def->default_value = new ConfigOptionFloats { 14.f }; + def->default_value = new ConfigOptionFloats { 2.2f }; + + def = this->add("filament_cooling_final_speed", coFloats); + def->label = L("Speed of the last cooling move"); + def->tooltip = L("Cooling moves are gradually accelerating towards this speed. "); + def->cli = "filament-cooling-final-speed=i@"; + def->sidetext = L("mm/s"); + def->min = 0; + def->default_value = new ConfigOptionFloats { 3.4f }; def = this->add("filament_ramming_parameters", coStrings); def->label = L("Ramming parameters"); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 62d8c7101e..a36e5def9e 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -476,7 +476,9 @@ public: ConfigOptionFloats filament_loading_speed; ConfigOptionFloats filament_unloading_speed; ConfigOptionFloats filament_toolchange_delay; - ConfigOptionFloats filament_cooling_time; + ConfigOptionInts filament_cooling_moves; + ConfigOptionFloats filament_cooling_initial_speed; + ConfigOptionFloats filament_cooling_final_speed; ConfigOptionStrings filament_ramming_parameters; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; @@ -535,7 +537,9 @@ protected: OPT_PTR(filament_loading_speed); OPT_PTR(filament_unloading_speed); OPT_PTR(filament_toolchange_delay); - OPT_PTR(filament_cooling_time); + OPT_PTR(filament_cooling_moves); + OPT_PTR(filament_cooling_initial_speed); + OPT_PTR(filament_cooling_final_speed); OPT_PTR(filament_ramming_parameters); OPT_PTR(gcode_comments); OPT_PTR(gcode_flavor); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index e4a4b20936..db2fdfc174 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -209,10 +209,10 @@ const std::vector& Preset::filament_options() static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay", - "filament_cooling_time", "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature", - "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", - "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers", - "compatible_printers_condition", "inherits" + "filament_cooling_moves", "filament_cooling_initial_speed", "filament_cooling_final_speed", "filament_ramming_parameters", "temperature", + "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", + "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", + "start_filament_gcode", "end_filament_gcode","compatible_printers", "compatible_printers_condition", "inherits" }; return s_opts; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 8ffe273512..da5b1b0643 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1287,7 +1287,9 @@ void TabFilament::build() optgroup->append_single_option_line("filament_loading_speed"); optgroup->append_single_option_line("filament_unloading_speed"); optgroup->append_single_option_line("filament_toolchange_delay"); - optgroup->append_single_option_line("filament_cooling_time"); + optgroup->append_single_option_line("filament_cooling_moves"); + optgroup->append_single_option_line("filament_cooling_initial_speed"); + optgroup->append_single_option_line("filament_cooling_final_speed"); line = { _(L("Ramming")), "" }; line.widget = [this](wxWindow* parent){ auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); From 650489dd8a99e662d4f029c1ff82e6c29bba01c2 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 24 Apr 2018 13:43:39 +0200 Subject: [PATCH 0242/1150] New parameters actually connected to the wipe tower generator --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 8 ++++---- xs/src/libslic3r/PrintConfig.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index db6e933623..80d4fdf074 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -814,10 +814,10 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.set_extruder_temp(new_temperature, false); // Cooling: - const unsigned number_of_moves = 3; + const int& number_of_moves = m_filpar[m_current_tool].cooling_moves; if (number_of_moves > 0) { - const float initial_speed = 2.2f; // mm/s - const float final_speed = 3.4f; + const float& initial_speed = m_filpar[m_current_tool].cooling_initial_speed; + const float& final_speed = m_filpar[m_current_tool].cooling_final_speed; float speed_inc = (final_speed - initial_speed) / (2.f * number_of_moves - 1.f); @@ -825,7 +825,7 @@ void WipeTowerPrusaMM::toolchange_Unload( .travel(writer.x(), writer.y() + y_step); old_x = writer.x(); turning_point = xr-old_x > old_x-xl ? xr : xl; - for (unsigned i=0; icli = "filament-cooling-moves=i@"; def->max = 0; def->max = 20; - def->default_value = new ConfigOptionInts { 6 }; + def->default_value = new ConfigOptionInts { 4 }; def = this->add("filament_cooling_initial_speed", coFloats); def->label = L("Speed of the first cooling move"); From 7c7c37a4f4b8c4f14fc5ece0cee84e2742e3e64d Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 24 Apr 2018 14:11:23 +0200 Subject: [PATCH 0243/1150] Added tooltips for reset buttons near each option --- xs/src/slic3r/GUI/Field.hpp | 24 ++++++++- xs/src/slic3r/GUI/Tab.cpp | 105 +++++++++++++++++++++++------------- xs/src/slic3r/GUI/Tab.hpp | 18 +++++-- 3 files changed, 104 insertions(+), 43 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 9e5730cf6e..c7eb25c754 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -146,13 +146,33 @@ public: return false; } + bool set_undo_tooltip(const wxString *tip) { + if (m_undo_tooltip != tip) { + m_undo_tooltip = tip; + m_Undo_btn->SetToolTip(*tip); + return true; + } + return false; + } + + bool set_undo_to_sys_tooltip(const wxString *tip) { + if (m_undo_to_sys_tooltip != tip) { + m_undo_to_sys_tooltip = tip; + m_Undo_to_sys_btn->SetToolTip(*tip); + return true; + } + return false; + } + protected: wxButton* m_Undo_btn = nullptr; - // Bitmap for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. + // Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. const wxBitmap* m_undo_bitmap = nullptr; + const wxString* m_undo_tooltip = nullptr; wxButton* m_Undo_to_sys_btn = nullptr; - // Bitmap for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. + // Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. const wxBitmap* m_undo_to_sys_bitmap = nullptr; + const wxString* m_undo_to_sys_tooltip = nullptr; wxStaticText* m_Label = nullptr; // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 8200ec4b23..5fbd9c96da 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -110,36 +110,6 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_question_btn->SetBackgroundColour(color); } -// m_undo_to_sys_btn->SetToolTip(_(L( "LOCKED LOCK icon indicates that the settings are the same as the system values " -// "for the current option group.\n" -// "UNLOCKED LOCK icon indicates that some settings were changed and are not equal " -// "to the system values for the current option group.\n" -// "WHITE BULLET icon indicates a non system preset.\n\n" -// "Click the UNLOCKED LOCK icon to reset all settings for current option group to " -// "the system values."))); -// -// m_undo_btn->SetToolTip(_(L( "WHITE BULLET icon indicates that the settings are the same as in the last saved" -// "preset for the current option group.\n" -// "BACK ARROW icon indicates that the settings were changed and are not equal to " -// "the last saved preset for the current option group.\n\n" -// "Click the BACK ARROW icon to reset all settings for the current option group to " -// "the last saved preset."))); - - // Text to be shown on the "Revert to system" aka "Lock to system" button next to each input field. - m_tt_value_lock = _(L("LOCKED LOCK icon indicates that the settings are the same as the system values " - "for the current option group")); - m_tt_value_unlock = _(L("UNLOCKED LOCK icon indicates that some settings were changed and are not equal " - "to the system values for the current option group.\n" - "Click it to reset all settings for current option group to the system values.")); - m_tt_white_bullet_ns= _(L("WHITE BULLET icon indicates a non system preset.")); - m_tt_non_system = &m_tt_white_bullet_ns; - // Bitmaps to be shown on the "Undo user changes" button next to each input field. - m_tt_white_bullet = _(L("WHITE BULLET icon indicates that the settings are the same as in the last saved " - "preset for the current option group.")); - m_tt_value_revert = _(L("BACK ARROW icon indicates that the settings were changed and are not equal to " - "the last saved preset for the current option group.\n" - "Click it to reset all settings for the current option group to the last saved preset.")); - m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information."))); // Determine the theme color of OS (dark or light) @@ -154,6 +124,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_bmp_question .LoadFile(from_u8(var("question_mark_01.png")), wxBITMAP_TYPE_PNG); fill_icon_descriptions(); + set_tooltips_text(); m_undo_btn->SetBitmap(m_bmp_white_bullet); m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_roll_back_value(); })); @@ -277,7 +248,8 @@ void Tab::load_initial_data() { m_config = &m_presets->get_edited_preset().config; m_bmp_non_system = m_presets->get_selected_preset_parent() ? &m_bmp_value_unlock : &m_bmp_white_bullet; - m_tt_non_system = m_presets->get_selected_preset_parent() ? &m_tt_value_unlock : &m_tt_white_bullet_ns; + m_ttg_non_system = m_presets->get_selected_preset_parent() ? &m_ttg_value_unlock : &m_ttg_white_bullet_ns; + m_tt_non_system = m_presets->get_selected_preset_parent() ? &m_tt_value_unlock : &m_ttg_white_bullet_ns; } PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages/* = false*/) @@ -335,15 +307,23 @@ void Tab::update_changed_ui() { bool is_nonsys_value = false; bool is_modified_value = true; - const wxBitmap *sys_icon = &m_bmp_value_lock; - const wxBitmap *icon = &m_bmp_value_revert; - const wxColour *color = &m_sys_label_clr; + const wxBitmap *sys_icon = &m_bmp_value_lock; + const wxBitmap *icon = &m_bmp_value_revert; + const wxColour *color = &m_sys_label_clr; + + const wxString *sys_tt = &m_tt_value_lock; + const wxString *tt = &m_tt_value_revert; + + // value isn't equal to system value if ((opt.second & osSystemValue) == 0){ is_nonsys_value = true; sys_icon = m_bmp_non_system; + sys_tt = m_tt_non_system; + // value is equal to last saved if ((opt.second & osInitValue) != 0) color = &m_default_text_clr; + // value is modified else color = &m_modified_label_clr; } @@ -351,6 +331,7 @@ void Tab::update_changed_ui() { is_modified_value = false; icon = &m_bmp_white_bullet; + tt = &m_tt_white_bullet; } if (opt.first == "bed_shape" || opt.first == "compatible_printers") { if (m_colored_Label != nullptr) { @@ -366,6 +347,8 @@ void Tab::update_changed_ui() field->m_is_modified_value = is_modified_value; field->set_undo_bitmap(icon); field->set_undo_to_sys_bitmap(sys_icon); + field->set_undo_tooltip(tt); + field->set_undo_to_sys_tooltip(sys_tt); field->set_label_colour(color); } Thaw(); @@ -482,8 +465,8 @@ void Tab::update_undo_buttons() m_undo_btn->SetBitmap(m_is_modified_values ? m_bmp_value_revert : m_bmp_white_bullet); m_undo_to_sys_btn->SetBitmap(m_is_nonsys_values ? *m_bmp_non_system : m_bmp_value_lock); - m_undo_btn->SetToolTip(m_is_modified_values ? m_tt_value_revert : m_tt_white_bullet); - m_undo_to_sys_btn->SetToolTip(m_is_nonsys_values ? *m_tt_non_system : m_tt_value_lock); + m_undo_btn->SetToolTip(m_is_modified_values ? m_ttg_value_revert : m_ttg_white_bullet); + m_undo_to_sys_btn->SetToolTip(m_is_nonsys_values ? *m_ttg_non_system : m_ttg_value_lock); } void Tab::on_roll_back_value(const bool to_sys /*= true*/) @@ -1826,7 +1809,8 @@ void Tab::load_current_preset() // Reload preset pages with the new configuration values. reload_config(); m_bmp_non_system = m_presets->get_selected_preset_parent() ? &m_bmp_value_unlock : &m_bmp_white_bullet; - m_tt_non_system = m_presets->get_selected_preset_parent() ? &m_tt_value_unlock : &m_tt_white_bullet_ns; + m_ttg_non_system = m_presets->get_selected_preset_parent() ? &m_ttg_value_unlock : &m_ttg_white_bullet_ns; + m_tt_non_system = m_presets->get_selected_preset_parent() ? &m_tt_value_unlock : &m_ttg_white_bullet_ns; // use CallAfter because some field triggers schedule on_change calls using CallAfter, // and we don't want them to be called after this update_dirty() as they would mark the @@ -2400,6 +2384,53 @@ void Tab::fill_icon_descriptions() "the last saved preset."))); } +void Tab::set_tooltips_text() +{ +// m_undo_to_sys_btn->SetToolTip(_(L( "LOCKED LOCK icon indicates that the settings are the same as the system values " +// "for the current option group.\n" +// "UNLOCKED LOCK icon indicates that some settings were changed and are not equal " +// "to the system values for the current option group.\n" +// "WHITE BULLET icon indicates a non system preset.\n\n" +// "Click the UNLOCKED LOCK icon to reset all settings for current option group to " +// "the system values."))); +// +// m_undo_btn->SetToolTip(_(L( "WHITE BULLET icon indicates that the settings are the same as in the last saved" +// "preset for the current option group.\n" +// "BACK ARROW icon indicates that the settings were changed and are not equal to " +// "the last saved preset for the current option group.\n\n" +// "Click the BACK ARROW icon to reset all settings for the current option group to " +// "the last saved preset."))); + + // --- Tooltip text for reset buttons (for whole options group) + // Text to be shown on the "Revert to system" aka "Lock to system" button next to each input field. + m_ttg_value_lock = _(L("LOCKED LOCK icon indicates that the settings are the same as the system values " + "for the current option group")); + m_ttg_value_unlock = _(L("UNLOCKED LOCK icon indicates that some settings were changed and are not equal " + "to the system values for the current option group.\n" + "Click to reset all settings for current option group to the system values.")); + m_ttg_white_bullet_ns = _(L("WHITE BULLET icon indicates a non system preset.")); + m_ttg_non_system = &m_ttg_white_bullet_ns; + // Text to be shown on the "Undo user changes" button next to each input field. + m_ttg_white_bullet = _(L("WHITE BULLET icon indicates that the settings are the same as in the last saved " + "preset for the current option group.")); + m_ttg_value_revert = _(L("BACK ARROW icon indicates that the settings were changed and are not equal to " + "the last saved preset for the current option group.\n" + "Click to reset all settings for the current option group to the last saved preset.")); + + // --- Tooltip text for reset buttons (for each option in group) + // Text to be shown on the "Revert to system" aka "Lock to system" button next to each input field. + m_tt_value_lock = _(L("LOCKED LOCK icon indicates that the value is the same as the system value.")); + m_tt_value_unlock = _(L("UNLOCKED LOCK icon indicates that the value was changed and is not equal " + "to the system value.\n" + "Click to reset current value to the system value.")); + // m_tt_white_bullet_ns= _(L("WHITE BULLET icon indicates a non system preset.")); + m_tt_non_system = &m_ttg_white_bullet_ns; + // Text to be shown on the "Undo user changes" button next to each input field. + m_tt_white_bullet = _(L("WHITE BULLET icon indicates that the value is the same as in the last saved preset.")); + m_tt_value_revert = _(L("BACK ARROW icon indicates that the value was changed and is not equal to the last saved preset.\n" + "Click to reset current value to the last saved preset.")); +} + void Page::reload_config() { for (auto group : m_optgroups) diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 8c6e7f3295..de04fc4cd9 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -143,13 +143,22 @@ protected: wxColour m_modified_label_clr; wxColour m_default_text_clr; - // Text for reset buttons tooltips + // Tooltip text for reset buttons (for whole options group) + wxString m_ttg_value_lock; + wxString m_ttg_value_unlock; + wxString m_ttg_white_bullet_ns; + // The following text points to either m_ttg_value_unlock or m_ttg_white_bullet_ns, depending on whether the current preset has a parent preset. + wxString *m_ttg_non_system; + // Tooltip text to be shown on the "Undo user changes" button next to each input field. + wxString m_ttg_white_bullet; + wxString m_ttg_value_revert; + + // Tooltip text for reset buttons (for each option in group) wxString m_tt_value_lock; wxString m_tt_value_unlock; - wxString m_tt_white_bullet_ns; - // The following text points to either m_bmp_value_unlock or m_bmp_white_bullet, depending on whether the current preset has a parent preset. + // The following text points to either m_tt_value_unlock or m_ttg_white_bullet_ns, depending on whether the current preset has a parent preset. wxString *m_tt_non_system; - // Bitmaps to be shown on the "Undo user changes" button next to each input field. + // Tooltip text to be shown on the "Undo user changes" button next to each input field. wxString m_tt_white_bullet; wxString m_tt_value_revert; @@ -260,6 +269,7 @@ protected: void update_wiping_button_visibility(); void update_tab_presets(wxComboCtrl* ui, bool show_incompatible); void fill_icon_descriptions(); + void set_tooltips_text(); }; //Slic3r::GUI::Tab::Print; From ccd1c01d0b46354af7fe2a11a205ceee9f6c5a74 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 24 Apr 2018 14:21:31 +0200 Subject: [PATCH 0244/1150] Fixed automatic view type selection when changing printer --- lib/Slic3r/GUI/Plater/3DPreview.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index 4834f7aed1..9d8b822429 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -72,6 +72,9 @@ sub new { $choice_view_type->Append(L("Tool")); $choice_view_type->SetSelection(0); + # the following value needs to be changed if new items are added into $choice_view_type before "Tool" + $self->{tool_idx} = 5; + my $label_show_features = $self->{label_show_features} = Wx::StaticText->new($self, -1, L("Show")); my $combochecklist_features = $self->{combochecklist_features} = Wx::ComboCtrl->new(); @@ -204,7 +207,7 @@ sub new { }); EVT_CHOICE($self, $choice_view_type, sub { my $selection = $choice_view_type->GetCurrentSelection(); - $self->{preferred_color_mode} = ($selection == 4) ? 'tool' : 'feature'; + $self->{preferred_color_mode} = ($selection == $self->{tool_idx}) ? 'tool' : 'feature'; $self->gcode_preview_data->set_type($selection); $self->reload_print; }); @@ -334,7 +337,7 @@ sub load_print { # It is left to Slic3r to decide whether the print shall be colored by the tool or by the feature. # Color by feature if it is a single extruder print. my $extruders = $self->{print}->extruders; - my $type = (scalar(@{$extruders}) > 1) ? 4 : 0; + my $type = (scalar(@{$extruders}) > 1) ? $self->{tool_idx} : 0; $self->gcode_preview_data->set_type($type); $self->{choice_view_type}->SetSelection($type); # If the ->SetSelection changed the following line, revert it to "decide yourself". @@ -343,7 +346,7 @@ sub load_print { # Collect colors per extruder. my @colors = (); - if (! $self->gcode_preview_data->empty() || $self->gcode_preview_data->type == 4) { + if (! $self->gcode_preview_data->empty() || $self->gcode_preview_data->type == $self->{tool_idx}) { my @extruder_colors = @{$self->{config}->extruder_colour}; my @filament_colors = @{$self->{config}->filament_colour}; for (my $i = 0; $i <= $#extruder_colors; $i += 1) { @@ -464,11 +467,11 @@ sub set_number_extruders { if ($self->{number_extruders} != $number_extruders) { $self->{number_extruders} = $number_extruders; my $type = ($number_extruders > 1) ? - 4 # color by a tool number + $self->{tool_idx} # color by a tool number : 0; # color by a feature type $self->{choice_view_type}->SetSelection($type); $self->gcode_preview_data->set_type($type); - $self->{preferred_color_mode} = ($type == 4) ? 'tool_or_feature' : 'feature'; + $self->{preferred_color_mode} = ($type == $self->{tool_idx}) ? 'tool_or_feature' : 'feature'; } } From fea560340967e782849880079013014a32d3971c Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 24 Apr 2018 18:06:42 +0200 Subject: [PATCH 0245/1150] PresetUpdater: Bundle incompatibility / Slic3r downgrade scnario --- lib/Slic3r/GUI.pm | 17 +- resources/icons/Slic3r_192px_grayscale.png | Bin 0 -> 19251 bytes xs/CMakeLists.txt | 2 + xs/src/slic3r/GUI/ConfigWizard.cpp | 27 ++- xs/src/slic3r/GUI/ConfigWizard.hpp | 13 +- xs/src/slic3r/GUI/ConfigWizard_private.hpp | 5 +- xs/src/slic3r/GUI/GUI.cpp | 23 +- xs/src/slic3r/GUI/GUI.hpp | 9 +- xs/src/slic3r/GUI/UpdateDialogs.cpp | 203 +++++++++++++++++ xs/src/slic3r/GUI/UpdateDialogs.hpp | 92 ++++++++ xs/src/slic3r/Utils/PresetUpdater.cpp | 240 ++++++++++----------- xs/src/slic3r/Utils/PresetUpdater.hpp | 5 +- xs/xsp/GUI.xsp | 4 +- xs/xsp/Utils_PresetUpdater.xsp | 2 +- 14 files changed, 480 insertions(+), 162 deletions(-) create mode 100644 resources/icons/Slic3r_192px_grayscale.png create mode 100644 xs/src/slic3r/GUI/UpdateDialogs.cpp create mode 100644 xs/src/slic3r/GUI/UpdateDialogs.hpp diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 10375a9dce..89a8e79748 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -86,8 +86,9 @@ sub OnInit { Slic3r::GUI::set_wxapp($self); $self->{app_config} = Slic3r::GUI::AppConfig->new; - $self->{preset_bundle} = Slic3r::GUI::PresetBundle->new; Slic3r::GUI::set_app_config($self->{app_config}); + $self->{preset_bundle} = Slic3r::GUI::PresetBundle->new; + Slic3r::GUI::set_preset_bundle($self->{preset_bundle}); # just checking for existence of Slic3r::data_dir is not enough: it may be an empty directory # supplied as argument to --datadir; in that case we should still run the wizard @@ -104,7 +105,11 @@ sub OnInit { $self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT); Slic3r::GUI::set_preset_updater($self->{preset_updater}); - eval { $self->{preset_updater}->config_update(); }; + eval { + if (! $self->{preset_updater}->config_update()) { + exit 0; + } + }; if ($@) { warn $@ . "\n"; fatal_error(undef, $@); @@ -120,8 +125,6 @@ sub OnInit { show_error(undef, $@); } - Slic3r::GUI::set_preset_bundle($self->{preset_bundle}); - # application frame print STDERR "Creating main frame...\n"; Wx::Image::FindHandlerType(wxBITMAP_TYPE_PNG) || Wx::Image::AddHandler(Wx::PNGHandler->new); @@ -144,8 +147,10 @@ sub OnInit { # On OSX the UI was not initialized correctly if the wizard was called # before the UI was up and running. $self->CallAfter(sub { - Slic3r::GUI::config_wizard_startup($app_conf_exists); - $self->{preset_updater}->slic3r_update_notify(); + if (! Slic3r::GUI::config_wizard_startup($app_conf_exists)) { + # Only notify if there was not wizard so as not to bother too much ... + $self->{preset_updater}->slic3r_update_notify(); + } $self->{preset_updater}->sync($self->{preset_bundle}); }); diff --git a/resources/icons/Slic3r_192px_grayscale.png b/resources/icons/Slic3r_192px_grayscale.png new file mode 100644 index 0000000000000000000000000000000000000000..910f941870510c4fcc8c7c5cf728f9758af3e1d6 GIT binary patch literal 19251 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 && wizard_p()->flag_empty_datadir) { + if (wizard_p()->run_reason == ConfigWizard::RR_DATA_EMPTY) { wxString::Format(_(L("Run %s")), ConfigWizard::name()); append_text(wxString::Format( _(L("Hello, welcome to Slic3r Prusa Edition! This %s helps you with the initial configuration; just a few settings and you will be ready to print.")), @@ -709,7 +709,7 @@ void ConfigWizard::priv::on_custom_setup() set_page(page_firmware); } -void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *preset_bundle, PresetUpdater *updater) +void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater) { const bool is_custom_setup = page_welcome->page_next() == page_firmware; @@ -730,8 +730,14 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese install_bundles.emplace_back(vendor_rsrc.second); } - // If the datadir was empty don't take a snapshot (it would just be an empty snapshot) - const bool snapshot = !flag_empty_datadir || page_welcome->reset_user_profile(); + // Decide whether to create snapshot based on run_reason and the reset profile checkbox + bool snapshot = true; + switch (run_reason) { + case ConfigWizard::RR_DATA_EMPTY: snapshot = false; break; + case ConfigWizard::RR_DATA_LEGACY: snapshot = true; break; + case ConfigWizard::RR_DATA_INCOMPAT: snapshot = false; break; // In this case snapshot is done by PresetUpdater with the appropriate reason + case ConfigWizard::RR_USER: snapshot = page_welcome->reset_user_profile(); break; + } if (install_bundles.size() > 0) { // Install bundles from resources. updater->install_bundles_rsrc(std::move(install_bundles), snapshot); @@ -744,8 +750,7 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese app_config->set_vendors(appconfig_vendors); app_config->set("version_check", page_update->version_check ? "1" : "0"); app_config->set("preset_update", page_update->preset_update ? "1" : "0"); - if (flag_startup) - app_config->reset_selections(); + app_config->reset_selections(); // ^ TODO: replace with appropriate printer selection preset_bundle->load_presets(*app_config); } else { @@ -760,12 +765,11 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese // Public -ConfigWizard::ConfigWizard(wxWindow *parent, bool startup, bool empty_datadir) : +ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason) : wxDialog(parent, wxID_ANY, name(), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), p(new priv(this)) { - p->flag_startup = startup; - p->flag_empty_datadir = empty_datadir; + p->run_reason = reason; p->load_vendors(); p->custom_config.reset(DynamicPrintConfig::new_from_defaults_keys({ @@ -822,10 +826,13 @@ ConfigWizard::ConfigWizard(wxWindow *parent, bool startup, bool empty_datadir) : ConfigWizard::~ConfigWizard() {} -void ConfigWizard::run(PresetBundle *preset_bundle, PresetUpdater *updater) +bool ConfigWizard::run(PresetBundle *preset_bundle, const PresetUpdater *updater) { if (ShowModal() == wxID_OK) { p->apply_config(GUI::get_app_config(), preset_bundle, updater); + return true; + } else { + return false; } } diff --git a/xs/src/slic3r/GUI/ConfigWizard.hpp b/xs/src/slic3r/GUI/ConfigWizard.hpp index eeb64c57f6..73fce7cd21 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard.hpp @@ -16,14 +16,23 @@ namespace GUI { class ConfigWizard: public wxDialog { public: - ConfigWizard(wxWindow *parent, bool startup, bool empty_datadir); + // Why is the Wizard run + enum RunReason { + RR_DATA_EMPTY, // No or empty datadir + RR_DATA_LEGACY, // Pre-updating datadir + RR_DATA_INCOMPAT, // Incompatible datadir - Slic3r downgrade situation + RR_USER, // User requested the Wizard from the menus + }; + + ConfigWizard(wxWindow *parent, RunReason run_reason); ConfigWizard(ConfigWizard &&) = delete; ConfigWizard(const ConfigWizard &) = delete; ConfigWizard &operator=(ConfigWizard &&) = delete; ConfigWizard &operator=(const ConfigWizard &) = delete; ~ConfigWizard(); - void run(PresetBundle *preset_bundle, PresetUpdater *updater); + // Run the Wizard. Return whether it was completed. + bool run(PresetBundle *preset_bundle, const PresetUpdater *updater); static const wxString& name(); private: diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index cdab2eb3ca..474394bc34 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -190,8 +190,7 @@ private: struct ConfigWizard::priv { ConfigWizard *q; - bool flag_startup; - bool flag_empty_datadir; + ConfigWizard::RunReason run_reason; AppConfig appconfig_vendors; std::unordered_map vendors; std::unordered_map vendors_rsrc; @@ -228,7 +227,7 @@ struct ConfigWizard::priv void on_other_vendors(); void on_custom_setup(); - void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, PresetUpdater *updater); + void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater); }; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 88c3f421b2..bd74e118ee 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -390,7 +390,7 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ switch (event.GetId() - config_id_base) { case ConfigMenuWizard: - config_wizard(false, false); + config_wizard(ConfigWizard::RR_USER); break; case ConfigMenuTakeSnapshot: // Take a configuration snapshot. @@ -469,10 +469,11 @@ bool check_unsaved_changes() return dialog->ShowModal() == wxID_YES; } -void config_wizard_startup(bool app_config_exists) +bool config_wizard_startup(bool app_config_exists) { if (! app_config_exists || g_PresetBundle->has_defauls_only()) { - config_wizard(true, true); + config_wizard(ConfigWizard::RR_DATA_EMPTY); + return true; } else if (g_AppConfig->legacy_datadir()) { // Looks like user has legacy pre-vendorbundle data directory, // explain what this is and run the wizard @@ -496,20 +497,19 @@ void config_wizard_startup(bool app_config_exists) dlg.SetExtendedMessage(ext_msg); const auto res = dlg.ShowModal(); - config_wizard(true, false); + config_wizard(ConfigWizard::RR_DATA_LEGACY); + return true; } + return false; } -void config_wizard(bool startup, bool empty_datadir) +void config_wizard(int reason) { - if (g_wxMainFrame == nullptr) - throw std::runtime_error("Main frame not set"); - // Exit wizard if there are unsaved changes and the user cancels the action. if (! check_unsaved_changes()) return; - ConfigWizard wizard(g_wxMainFrame, startup, empty_datadir); + ConfigWizard wizard(nullptr, static_cast(reason)); wizard.run(g_PresetBundle, g_PresetUpdater); // Load the currently selected preset into the GUI, update the preset selection box. @@ -686,6 +686,11 @@ wxApp* get_app(){ return g_wxApp; } +PresetBundle* get_preset_bundle() +{ + return g_PresetBundle; +} + const wxColour& get_modified_label_clr() { return g_color_label_modified; } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 92a6e6ebb8..a8bbdccc73 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -82,6 +82,7 @@ void set_preset_updater(PresetUpdater *updater); AppConfig* get_app_config(); wxApp* get_app(); +PresetBundle* get_preset_bundle(); const wxColour& get_modified_label_clr(); const wxColour& get_sys_label_clr(); @@ -93,11 +94,13 @@ extern void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int // to notify the user whether he is aware that some preset changes will be lost. extern bool check_unsaved_changes(); -// Checks if configuration wizard needs to run, calls config_wizard if so -extern void config_wizard_startup(bool app_config_exists); +// Checks if configuration wizard needs to run, calls config_wizard if so. +// Returns whether the Wizard ran. +extern bool config_wizard_startup(bool app_config_exists); // Opens the configuration wizard, returns true if wizard is finished & accepted. -extern void config_wizard(bool startup, bool empty_datadir); +// The run_reason argument is actually ConfigWizard::RunReason, but int is used here because of Perl. +extern void config_wizard(int run_reason); // Create "Preferences" dialog after selecting menu "Preferences" in Perl part extern void open_preferences_dialog(int event_preferences); diff --git a/xs/src/slic3r/GUI/UpdateDialogs.cpp b/xs/src/slic3r/GUI/UpdateDialogs.cpp new file mode 100644 index 0000000000..076554e237 --- /dev/null +++ b/xs/src/slic3r/GUI/UpdateDialogs.cpp @@ -0,0 +1,203 @@ +#include "UpdateDialogs.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libslic3r/libslic3r.h" +#include "libslic3r/Utils.hpp" +#include "GUI.hpp" + +namespace Slic3r { +namespace GUI { + + +enum { + CONTENT_WIDTH = 400, + BORDER = 30, + VERT_SPACING = 15, + HORIZ_SPACING = 5, +}; + + +MsgDialog::MsgDialog(const wxString &title, const wxString &headline, wxWindowID button_id) : + MsgDialog(title, headline, wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG), button_id) +{} + +MsgDialog::MsgDialog(const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id) : + wxDialog(nullptr, wxID_ANY, title), + boldfont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)), + content_sizer(new wxBoxSizer(wxVERTICAL)), + btn_sizer(new wxBoxSizer(wxHORIZONTAL)) +{ + boldfont.SetWeight(wxFONTWEIGHT_BOLD); + + auto *topsizer = new wxBoxSizer(wxHORIZONTAL); + auto *rightsizer = new wxBoxSizer(wxVERTICAL); + + auto *headtext = new wxStaticText(this, wxID_ANY, headline); + headtext->SetFont(boldfont); + headtext->Wrap(CONTENT_WIDTH); + rightsizer->Add(headtext); + rightsizer->AddSpacer(VERT_SPACING); + + rightsizer->Add(content_sizer); + + if (button_id != wxID_NONE) { + auto *button = new wxButton(this, button_id); + button->SetFocus(); + btn_sizer->Add(button); + } + + rightsizer->Add(btn_sizer, 0, wxALIGN_CENTRE_HORIZONTAL); + + auto *logo = new wxStaticBitmap(this, wxID_ANY, std::move(bitmap)); + + topsizer->Add(logo, 0, wxALL, BORDER); + topsizer->Add(rightsizer, 0, wxALL, BORDER); + + SetSizerAndFit(topsizer); +} + +MsgDialog::~MsgDialog() {} + + +// MsgUpdateSlic3r + +MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_online) : + MsgDialog(_(L("Update available")), _(L("New version of Slic3r PE is available"))), + ver_current(ver_current), + ver_online(ver_online) +{ + const auto url = wxString::Format("https://github.com/prusa3d/Slic3r/releases/tag/version_%s", ver_online.to_string()); + auto *link = new wxHyperlinkCtrl(this, wxID_ANY, url, url); + + auto *text = new wxStaticText(this, wxID_ANY, _(L("To download, follow the link below."))); + const auto link_width = link->GetSize().GetWidth(); + text->Wrap(CONTENT_WIDTH > link_width ? CONTENT_WIDTH : link_width); + content_sizer->Add(text); + content_sizer->AddSpacer(VERT_SPACING); + + auto *versions = new wxFlexGridSizer(2, 0, VERT_SPACING); + versions->Add(new wxStaticText(this, wxID_ANY, _(L("Current version:")))); + versions->Add(new wxStaticText(this, wxID_ANY, ver_current.to_string())); + versions->Add(new wxStaticText(this, wxID_ANY, _(L("New version:")))); + versions->Add(new wxStaticText(this, wxID_ANY, ver_online.to_string())); + content_sizer->Add(versions); + content_sizer->AddSpacer(VERT_SPACING); + + content_sizer->Add(link); + content_sizer->AddSpacer(2*VERT_SPACING); + + cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new releases any more"))); + content_sizer->Add(cbox); + content_sizer->AddSpacer(VERT_SPACING); + + Fit(); +} + +MsgUpdateSlic3r::~MsgUpdateSlic3r() {} + +bool MsgUpdateSlic3r::disable_version_check() const +{ + return cbox->GetValue(); +} + + +// MsgUpdateConfig + +MsgUpdateConfig::MsgUpdateConfig(const std::unordered_map &updates) : + MsgDialog(_(L("Configuration update")), _(L("Configuration update is available")), wxID_NONE) +{ + auto *text = new wxStaticText(this, wxID_ANY, _(L( + "Would you like to install it?\n\n" + "Note that a full configuration snapshot will be created first. It can then be restored at any time " + "should there be a problem with the new version.\n\n" + "Updated configuration bundles:" + ))); + text->Wrap(CONTENT_WIDTH); + content_sizer->Add(text); + content_sizer->AddSpacer(VERT_SPACING); + + auto *versions = new wxFlexGridSizer(2, 0, VERT_SPACING); + for (const auto &update : updates) { + auto *text_vendor = new wxStaticText(this, wxID_ANY, update.first); + text_vendor->SetFont(boldfont); + versions->Add(text_vendor); + versions->Add(new wxStaticText(this, wxID_ANY, update.second)); + } + + content_sizer->Add(versions); + content_sizer->AddSpacer(2*VERT_SPACING); + + auto *btn_cancel = new wxButton(this, wxID_CANCEL); + btn_sizer->Add(btn_cancel); + btn_sizer->AddSpacer(HORIZ_SPACING); + auto *btn_ok = new wxButton(this, wxID_YES); + btn_sizer->Add(btn_ok); + btn_ok->SetFocus(); + + Fit(); +} + +MsgUpdateConfig::~MsgUpdateConfig() {} + + +// MsgDataIncompatible + +MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map &incompats) : + MsgDialog(_(L("Slic3r incompatibility")), _(L("Slic3r configuration is incompatible")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png"))), wxID_NONE) +{ + auto *text = new wxStaticText(this, wxID_ANY, _(L( + "This version of Slic3r PE is not compatible with currently installed configuration bundles.\n" + "This probably happened as a result of running an older Slic3r PE after using a newer one.\n\n" + "TODO: more instrs\n" + ))); + text->Wrap(CONTENT_WIDTH); + content_sizer->Add(text); + + auto *text2 = new wxStaticText(this, wxID_ANY, wxString::Format(_(L("This Slic3r PE version: %s")), SLIC3R_VERSION)); + text2->Wrap(CONTENT_WIDTH); + content_sizer->Add(text2); + content_sizer->AddSpacer(VERT_SPACING); + + auto *text3 = new wxStaticText(this, wxID_ANY, _(L("Incompatible bundles:"))); + text3->Wrap(CONTENT_WIDTH); + content_sizer->Add(text3); + content_sizer->AddSpacer(VERT_SPACING); + + auto *versions = new wxFlexGridSizer(2, 0, VERT_SPACING); + for (const auto &incompat : incompats) { + auto *text_vendor = new wxStaticText(this, wxID_ANY, incompat.first); + text_vendor->SetFont(boldfont); + versions->Add(text_vendor); + versions->Add(new wxStaticText(this, wxID_ANY, incompat.second)); + } + + content_sizer->Add(versions); + content_sizer->AddSpacer(2*VERT_SPACING); + + auto *btn_exit = new wxButton(this, wxID_EXIT, _(L("Exit Slic3r"))); + btn_sizer->Add(btn_exit); + btn_sizer->AddSpacer(HORIZ_SPACING); + auto *btn_reconf = new wxButton(this, wxID_REPLACE, _(L("Re-configure"))); + btn_sizer->Add(btn_reconf); + btn_exit->SetFocus(); + + auto exiter = [this](const wxCommandEvent& evt) { this->EndModal(evt.GetId()); }; + btn_exit->Bind(wxEVT_BUTTON, exiter); + btn_reconf->Bind(wxEVT_BUTTON, exiter); + + Fit(); +} + +MsgDataIncompatible::~MsgDataIncompatible() {} + + +} +} diff --git a/xs/src/slic3r/GUI/UpdateDialogs.hpp b/xs/src/slic3r/GUI/UpdateDialogs.hpp new file mode 100644 index 0000000000..ae949b8dd1 --- /dev/null +++ b/xs/src/slic3r/GUI/UpdateDialogs.hpp @@ -0,0 +1,92 @@ +#ifndef slic3r_UpdateDialogs_hpp_ +#define slic3r_UpdateDialogs_hpp_ + +#include +#include + +#include +#include +#include + +#include "slic3r/Utils/Semver.hpp" + +class wxBoxSizer; +class wxCheckBox; + +namespace Slic3r { + +namespace GUI { + + +// A message / query dialog with a bitmap on the left and any content on the right +// with buttons underneath. +struct MsgDialog : wxDialog +{ + MsgDialog(MsgDialog &&) = delete; + MsgDialog(const MsgDialog &) = delete; + MsgDialog &operator=(MsgDialog &&) = delete; + MsgDialog &operator=(const MsgDialog &) = delete; + virtual ~MsgDialog(); + +protected: + // button_id is an id of a button that can be added by default, use wxID_NONE to disable + MsgDialog(const wxString &title, const wxString &headline, wxWindowID button_id = wxID_OK); + MsgDialog(const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id = wxID_OK); + + wxFont boldfont; + wxBoxSizer *content_sizer; + wxBoxSizer *btn_sizer; +}; + +// A confirmation dialog listing configuration updates +class MsgUpdateSlic3r : public MsgDialog +{ +public: + MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_online); + MsgUpdateSlic3r(MsgUpdateSlic3r &&) = delete; + MsgUpdateSlic3r(const MsgUpdateSlic3r &) = delete; + MsgUpdateSlic3r &operator=(MsgUpdateSlic3r &&) = delete; + MsgUpdateSlic3r &operator=(const MsgUpdateSlic3r &) = delete; + virtual ~MsgUpdateSlic3r(); + + // Tells whether the user checked the "don't bother me again" checkbox + bool disable_version_check() const; + +private: + const Semver &ver_current; + const Semver &ver_online; + wxCheckBox *cbox; +}; + + +// Confirmation dialog informing about configuration update. Lists updated bundles & their versions. +class MsgUpdateConfig : public MsgDialog +{ +public: + // updates is a map of "vendor name" -> "version (comment)" + MsgUpdateConfig(const std::unordered_map &updates); + MsgUpdateConfig(MsgUpdateConfig &&) = delete; + MsgUpdateConfig(const MsgUpdateConfig &) = delete; + MsgUpdateConfig &operator=(MsgUpdateConfig &&) = delete; + MsgUpdateConfig &operator=(const MsgUpdateConfig &) = delete; + ~MsgUpdateConfig(); +}; + +// Informs about currently installed bundles not being compatible with the running Slic3r. Asks about action. +class MsgDataIncompatible : public MsgDialog +{ +public: + // incompats is a map of "vendor name" -> "version restrictions" + MsgDataIncompatible(const std::unordered_map &incompats); + MsgDataIncompatible(MsgDataIncompatible &&) = delete; + MsgDataIncompatible(const MsgDataIncompatible &) = delete; + MsgDataIncompatible &operator=(MsgDataIncompatible &&) = delete; + MsgDataIncompatible &operator=(const MsgDataIncompatible &) = delete; + ~MsgDataIncompatible(); +}; + + +} +} + +#endif diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 8dd974537e..ec152df63e 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -14,18 +14,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include #include "libslic3r/libslic3r.h" #include "libslic3r/Utils.hpp" #include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/PresetBundle.hpp" +#include "slic3r/GUI/UpdateDialogs.hpp" +#include "slic3r/GUI/ConfigWizard.hpp" #include "slic3r/Utils/Http.hpp" #include "slic3r/Config/Version.hpp" #include "slic3r/Config/Snapshot.hpp" @@ -48,90 +43,49 @@ static const char *INDEX_FILENAME = "index.idx"; static const char *TMP_EXTENSION = ".download"; -// A confirmation dialog listing configuration updates -struct UpdateNotification : wxDialog -{ - // If this dialog gets any more complex, it should probably be factored out... - - enum { - CONTENT_WIDTH = 400, - BORDER = 30, - SPACING = 15, - }; - - wxCheckBox *cbox; - - UpdateNotification(const Semver &ver_current, const Semver &ver_online) : wxDialog(nullptr, wxID_ANY, _(L("Update available"))) - { - auto *topsizer = new wxBoxSizer(wxHORIZONTAL); - auto *sizer = new wxBoxSizer(wxVERTICAL); - - const auto url = wxString::Format("https://github.com/prusa3d/Slic3r/releases/tag/version_%s", ver_online.to_string()); - auto *link = new wxHyperlinkCtrl(this, wxID_ANY, url, url); - - auto *text = new wxStaticText(this, wxID_ANY, - _(L("New version of Slic3r PE is available. To download, follow the link below."))); - const auto link_width = link->GetSize().GetWidth(); - text->Wrap(CONTENT_WIDTH > link_width ? CONTENT_WIDTH : link_width); - sizer->Add(text); - sizer->AddSpacer(SPACING); - - auto *versions = new wxFlexGridSizer(2, 0, SPACING); - versions->Add(new wxStaticText(this, wxID_ANY, _(L("Current version:")))); - versions->Add(new wxStaticText(this, wxID_ANY, ver_current.to_string())); - versions->Add(new wxStaticText(this, wxID_ANY, _(L("New version:")))); - versions->Add(new wxStaticText(this, wxID_ANY, ver_online.to_string())); - sizer->Add(versions); - sizer->AddSpacer(SPACING); - - sizer->Add(link); - sizer->AddSpacer(2*SPACING); - - cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new releases any more"))); - sizer->Add(cbox); - sizer->AddSpacer(SPACING); - - auto *ok = new wxButton(this, wxID_OK); - ok->SetFocus(); - sizer->Add(ok, 0, wxALIGN_CENTRE_HORIZONTAL); - - auto *logo = new wxStaticBitmap(this, wxID_ANY, wxBitmap(GUI::from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG)); - - topsizer->Add(logo, 0, wxALL, BORDER); - topsizer->Add(sizer, 0, wxALL, BORDER); - - SetSizerAndFit(topsizer); - } - - bool disable_version_check() const { return cbox->GetValue(); } -}; - struct Update { fs::path source; fs::path target; Version version; - Update(fs::path &&source, const fs::path &target, const Version &version) : - source(source), + Update(fs::path &&source, fs::path &&target, const Version &version) : + source(std::move(source)), target(std::move(target)), version(version) {} - Update(fs::path &&source, fs::path &&target) : - source(source), - target(std::move(target)) - {} + std::string name() const { return source.stem().string(); } - std::string name() { return source.stem().string(); } - - friend std::ostream& operator<<(std::ostream& os , const Update &update) { - os << "Update(" << update.source.string() << " -> " << update.target.string() << ')'; + friend std::ostream& operator<<(std::ostream& os , const Update &self) { + os << "Update(" << self.source.string() << " -> " << self.target.string() << ')'; return os; } }; -typedef std::vector Updates; +struct Incompat +{ + fs::path bundle; + Version version; + + Incompat(fs::path &&bundle, const Version &version) : + bundle(std::move(bundle)), + version(version) + {} + + std::string name() const { return bundle.stem().string(); } + + friend std::ostream& operator<<(std::ostream& os , const Incompat &self) { + os << "Incompat(" << self.bundle.string() << ')'; + return os; + } +}; + +struct Updates +{ + std::vector incompats; + std::vector updates; +}; struct PresetUpdater::priv @@ -206,7 +160,7 @@ bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &targe BOOST_LOG_TRIVIAL(error) << boost::format("Error getting: `%1%`: HTTP %2%, %3%") % url % http_status - % body; + % error; }) .on_complete([&](std::string body, unsigned http_status) { fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc); @@ -248,7 +202,7 @@ void PresetUpdater::priv::sync_version() const BOOST_LOG_TRIVIAL(error) << boost::format("Error getting: `%1%`: HTTP %2%, %3%") % version_check_url % http_status - % body; + % error; }) .on_complete([&](std::string body, unsigned http_status) { boost::trim(body); @@ -354,7 +308,7 @@ Updates PresetUpdater::priv::get_config_updates() const BOOST_LOG_TRIVIAL(info) << "Checking for cached configuration updates..."; for (const auto idx : index_db) { - const auto bundle_path = vendor_path / (idx.vendor() + ".ini"); + auto bundle_path = vendor_path / (idx.vendor() + ".ini"); if (! fs::exists(bundle_path)) { BOOST_LOG_TRIVIAL(info) << "Bundle not present for index, skipping: " << idx.vendor(); @@ -377,14 +331,12 @@ Updates PresetUpdater::priv::get_config_updates() const BOOST_LOG_TRIVIAL(debug) << boost::format("Vendor: %1%, version installed: %2%, version cached: %3%") % vp.name - % recommended->config_version.to_string() - % ver_current->config_version.to_string(); + % ver_current->config_version.to_string() + % recommended->config_version.to_string(); if (! ver_current->is_current_slic3r_supported()) { BOOST_LOG_TRIVIAL(warning) << "Current Slic3r incompatible with installed bundle: " << bundle_path.string(); - - // TODO: Downgrade situation - + updates.incompats.emplace_back(std::move(bundle_path), *ver_current); } else if (recommended->config_version > ver_current->config_version) { // Config bundle update situation @@ -406,7 +358,7 @@ Updates PresetUpdater::priv::get_config_updates() const const auto cached_vp = VendorProfile::from_ini(path_in_cache, false); if (cached_vp.config_version == recommended->config_version) { - updates.emplace_back(std::move(path_in_cache), bundle_path, *recommended); + updates.updates.emplace_back(std::move(path_in_cache), std::move(bundle_path), *recommended); } } } @@ -416,28 +368,43 @@ Updates PresetUpdater::priv::get_config_updates() const void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) const { - BOOST_LOG_TRIVIAL(info) << boost::format("Performing %1% updates") % updates.size(); + if (updates.incompats.size() > 0) { + if (snapshot) { + BOOST_LOG_TRIVIAL(info) << "Taking a snapshot..."; + SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_DOWNGRADE); + } - if (snapshot) { - BOOST_LOG_TRIVIAL(info) << "Taking a snapshot..."; - SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE); + BOOST_LOG_TRIVIAL(info) << boost::format("Deleting %1% incompatible bundles") % updates.incompats.size(); + + for (const auto &incompat : updates.incompats) { + BOOST_LOG_TRIVIAL(info) << '\t' << incompat; + fs::remove(incompat.bundle); + } } + else if (updates.updates.size() > 0) { + if (snapshot) { + BOOST_LOG_TRIVIAL(info) << "Taking a snapshot..."; + SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE); + } - for (const auto &update : updates) { - BOOST_LOG_TRIVIAL(info) << '\t' << update; + BOOST_LOG_TRIVIAL(info) << boost::format("Performing %1% updates") % updates.updates.size(); - fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); + for (const auto &update : updates.updates) { + BOOST_LOG_TRIVIAL(info) << '\t' << update; - PresetBundle bundle; - bundle.load_configbundle(update.target.string(), PresetBundle::LOAD_CFGBNDLE_SYSTEM); + fs::copy_file(update.source, update.target, fs::copy_option::overwrite_if_exists); - auto preset_remover = [](const Preset &preset) { - fs::remove(preset.file); - }; + PresetBundle bundle; + bundle.load_configbundle(update.target.string(), PresetBundle::LOAD_CFGBNDLE_SYSTEM); - for (const auto &preset : bundle.prints) { preset_remover(preset); } - for (const auto &preset : bundle.filaments) { preset_remover(preset); } - for (const auto &preset : bundle.printers) { preset_remover(preset); } + auto preset_remover = [](const Preset &preset) { + fs::remove(preset.file); + }; + + for (const auto &preset : bundle.prints) { preset_remover(preset); } + for (const auto &preset : bundle.filaments) { preset_remover(preset); } + for (const auto &preset : bundle.printers) { preset_remover(preset); } + } } } @@ -497,7 +464,7 @@ void PresetUpdater::slic3r_update_notify() if (ver_online) { // Only display the notification if the version available online is newer AND if we haven't seen it before if (*ver_online > *ver_slic3r && (! ver_online_seen || *ver_online_seen < *ver_online)) { - UpdateNotification notification(*ver_slic3r, *ver_online); + GUI::MsgUpdateSlic3r notification(*ver_slic3r, *ver_online); notification.ShowModal(); if (notification.disable_version_check()) { app_config->set("version_check", "0"); @@ -508,32 +475,55 @@ void PresetUpdater::slic3r_update_notify() } } -void PresetUpdater::config_update() const +bool PresetUpdater::config_update() const { - if (! p->enabled_config_update) { return; } + if (! p->enabled_config_update) { return true; } auto updates = p->get_config_updates(); - if (updates.size() > 0) { - BOOST_LOG_TRIVIAL(info) << boost::format("Update of %1% bundles available. Asking for confirmation ...") % updates.size(); + if (updates.incompats.size() > 0) { + BOOST_LOG_TRIVIAL(info) << boost::format("%1% bundles incompatible. Asking for action...") % updates.incompats.size(); - const auto msg = _(L("Configuration update is available. Would you like to install it?")); - - auto ext_msg = _(L( - "Note that a full configuration snapshot will be created first. It can then be restored at any time " - "should there be a problem with the new version.\n\n" - "Updated configuration bundles:\n" - )); - - for (const auto &update : updates) { - ext_msg += update.target.stem().string() + " " + update.version.config_version.to_string(); - if (! update.version.comment.empty()) { - ext_msg += std::string(" (") + update.version.comment + ")"; - } - ext_msg += "\n"; + std::unordered_map incompats_map; + for (const auto &incompat : updates.incompats) { + auto vendor = incompat.name(); + auto restrictions = wxString::Format(_(L("requires min. %s and max. %s")), + incompat.version.min_slic3r_version.to_string(), + incompat.version.max_slic3r_version.to_string() + ); + incompats_map.emplace(std::move(vendor), std::move(restrictions)); } - wxMessageDialog dlg(NULL, msg, _(L("Configuration update")), wxYES_NO|wxCENTRE); - dlg.SetExtendedMessage(ext_msg); + GUI::MsgDataIncompatible dlg(std::move(incompats_map)); + const auto res = dlg.ShowModal(); + if (res == wxID_REPLACE) { + BOOST_LOG_TRIVIAL(info) << "User wants to re-configure..."; + p->perform_updates(std::move(updates)); + GUI::ConfigWizard wizard(nullptr, GUI::ConfigWizard::RR_DATA_INCOMPAT); + if (wizard.run(GUI::get_preset_bundle(), this)) { + p->had_config_update = true; + } else { + return false; + } + } else { + BOOST_LOG_TRIVIAL(info) << "User wants to exit Slic3r, bye..."; + return false; + } + } + else if (updates.updates.size() > 0) { + BOOST_LOG_TRIVIAL(info) << boost::format("Update of %1% bundles available. Asking for confirmation ...") % updates.updates.size(); + + std::unordered_map updates_map; + for (const auto &update : updates.updates) { + auto vendor = update.name(); + auto ver_str = update.version.config_version.to_string(); + if (! update.version.comment.empty()) { + ver_str += std::string(" (") + update.version.comment + ")"; + } + updates_map.emplace(std::move(vendor), std::move(ver_str)); + } + + GUI::MsgUpdateConfig dlg(std::move(updates_map)); + const auto res = dlg.ShowModal(); if (res == wxID_YES) { BOOST_LOG_TRIVIAL(debug) << "User agreed to perform the update"; @@ -546,9 +536,11 @@ void PresetUpdater::config_update() const } else { BOOST_LOG_TRIVIAL(info) << "No configuration updates available."; } + + return true; } -void PresetUpdater::install_bundles_rsrc(std::vector bundles, bool snapshot) +void PresetUpdater::install_bundles_rsrc(std::vector bundles, bool snapshot) const { Updates updates; @@ -557,7 +549,7 @@ void PresetUpdater::install_bundles_rsrc(std::vector bundles, bool for (const auto &bundle : bundles) { auto path_in_rsrc = p->rsrc_path / bundle; auto path_in_vendors = p->vendor_path / bundle; - updates.emplace_back(std::move(path_in_rsrc), std::move(path_in_vendors)); + updates.updates.emplace_back(std::move(path_in_rsrc), std::move(path_in_vendors), Version()); } p->perform_updates(std::move(updates), snapshot); diff --git a/xs/src/slic3r/Utils/PresetUpdater.hpp b/xs/src/slic3r/Utils/PresetUpdater.hpp index 287f20652f..6a53cca816 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.hpp +++ b/xs/src/slic3r/Utils/PresetUpdater.hpp @@ -27,10 +27,11 @@ public: void slic3r_update_notify(); // If updating is enabled, check if updates are available in cache, if so, ask about installation. - void config_update() const; + // A false return value implies Slic3r should exit due to incompatibility of configuration. + bool config_update() const; // "Update" a list of bundles from resources (behaves like an online update). - void install_bundles_rsrc(std::vector bundles, bool snapshot = true); + void install_bundles_rsrc(std::vector bundles, bool snapshot = true) const; private: struct priv; std::unique_ptr p; diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 0d9f0b62e7..ca90c54f2d 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -60,10 +60,10 @@ void set_app_config(AppConfig *app_config) bool check_unsaved_changes() %code%{ RETVAL=Slic3r::GUI::check_unsaved_changes(); %}; -void config_wizard_startup(int app_config_exists) +bool config_wizard_startup(int app_config_exists) %code%{ try { - Slic3r::GUI::config_wizard_startup(app_config_exists != 0); + RETVAL=Slic3r::GUI::config_wizard_startup(app_config_exists != 0); } catch (std::exception& e) { croak("%s\n", e.what()); } diff --git a/xs/xsp/Utils_PresetUpdater.xsp b/xs/xsp/Utils_PresetUpdater.xsp index 53c3aa9855..dc874acabe 100644 --- a/xs/xsp/Utils_PresetUpdater.xsp +++ b/xs/xsp/Utils_PresetUpdater.xsp @@ -9,5 +9,5 @@ PresetUpdater(int version_online_event); void sync(PresetBundle* preset_bundle); void slic3r_update_notify(); - void config_update(); + bool config_update(); }; From 60f62a6463e2eaa550a2e42139906e1e87007c7b Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 24 Apr 2018 18:29:36 +0200 Subject: [PATCH 0246/1150] Fix text in UpdateDialogs --- xs/src/slic3r/GUI/UpdateDialogs.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/UpdateDialogs.cpp b/xs/src/slic3r/GUI/UpdateDialogs.cpp index 076554e237..5d198661f8 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.cpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.cpp @@ -156,7 +156,9 @@ MsgDataIncompatible::MsgDataIncompatible(const std::unordered_mapWrap(CONTENT_WIDTH); content_sizer->Add(text); From 0feb4d823f629144e8e74645a7e032f03ab2c7fc Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 24 Apr 2018 18:40:06 +0200 Subject: [PATCH 0247/1150] PresetUpdater: Fix string type --- xs/src/slic3r/GUI/UpdateDialogs.cpp | 2 +- xs/src/slic3r/GUI/UpdateDialogs.hpp | 2 +- xs/src/slic3r/Utils/PresetUpdater.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/GUI/UpdateDialogs.cpp b/xs/src/slic3r/GUI/UpdateDialogs.cpp index 5d198661f8..9a689e03df 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.cpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.cpp @@ -150,7 +150,7 @@ MsgUpdateConfig::~MsgUpdateConfig() {} // MsgDataIncompatible -MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map &incompats) : +MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map &incompats) : MsgDialog(_(L("Slic3r incompatibility")), _(L("Slic3r configuration is incompatible")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png"))), wxID_NONE) { auto *text = new wxStaticText(this, wxID_ANY, _(L( diff --git a/xs/src/slic3r/GUI/UpdateDialogs.hpp b/xs/src/slic3r/GUI/UpdateDialogs.hpp index ae949b8dd1..f12fd3333a 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.hpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.hpp @@ -77,7 +77,7 @@ class MsgDataIncompatible : public MsgDialog { public: // incompats is a map of "vendor name" -> "version restrictions" - MsgDataIncompatible(const std::unordered_map &incompats); + MsgDataIncompatible(const std::unordered_map &incompats); MsgDataIncompatible(MsgDataIncompatible &&) = delete; MsgDataIncompatible(const MsgDataIncompatible &) = delete; MsgDataIncompatible &operator=(MsgDataIncompatible &&) = delete; diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index ec152df63e..54841a3708 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -483,14 +483,14 @@ bool PresetUpdater::config_update() const if (updates.incompats.size() > 0) { BOOST_LOG_TRIVIAL(info) << boost::format("%1% bundles incompatible. Asking for action...") % updates.incompats.size(); - std::unordered_map incompats_map; + std::unordered_map incompats_map; for (const auto &incompat : updates.incompats) { auto vendor = incompat.name(); auto restrictions = wxString::Format(_(L("requires min. %s and max. %s")), incompat.version.min_slic3r_version.to_string(), incompat.version.max_slic3r_version.to_string() ); - incompats_map.emplace(std::move(vendor), std::move(restrictions)); + incompats_map.emplace(std::make_pair(std::move(vendor), std::move(restrictions))); } GUI::MsgDataIncompatible dlg(std::move(incompats_map)); @@ -519,7 +519,7 @@ bool PresetUpdater::config_update() const if (! update.version.comment.empty()) { ver_str += std::string(" (") + update.version.comment + ")"; } - updates_map.emplace(std::move(vendor), std::move(ver_str)); + updates_map.emplace(std::make_pair(std::move(vendor), std::move(ver_str))); } GUI::MsgUpdateConfig dlg(std::move(updates_map)); From 6c627be4c18cc747df9040ed3bceb2bc14823f0b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 25 Apr 2018 10:37:31 +0200 Subject: [PATCH 0248/1150] New cooling logic to equalize extrusion velocity. The old behavior caused bad outer surface print quality on Prusa i3 MK3 --- xs/src/libslic3r/GCode/CoolingBuffer.cpp | 479 +++++++++++++++-------- 1 file changed, 306 insertions(+), 173 deletions(-) diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index cd2baeffbd..121cbb0175 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -30,6 +30,174 @@ void CoolingBuffer::reset() m_current_pos[4] = float(m_gcodegen.config().travel_speed.value); } +struct CoolingLine +{ + enum Type { + TYPE_SET_TOOL = 1 << 0, + TYPE_EXTRUDE_END = 1 << 1, + TYPE_BRIDGE_FAN_START = 1 << 2, + TYPE_BRIDGE_FAN_END = 1 << 3, + TYPE_G0 = 1 << 4, + TYPE_G1 = 1 << 5, + TYPE_ADJUSTABLE = 1 << 6, + TYPE_EXTERNAL_PERIMETER = 1 << 7, + // The line sets a feedrate. + TYPE_HAS_F = 1 << 8, + TYPE_WIPE = 1 << 9, + TYPE_G4 = 1 << 10, + TYPE_G92 = 1 << 11, + }; + + CoolingLine(unsigned int type, size_t line_start, size_t line_end) : + type(type), line_start(line_start), line_end(line_end), + length(0.f), time(0.f), time_max(0.f), slowdown(false) {} + + bool adjustable(bool slowdown_external_perimeters) const { + return (this->type & TYPE_ADJUSTABLE) && + (! (this->type & TYPE_EXTERNAL_PERIMETER) || slowdown_external_perimeters) && + this->time < this->time_max; + } + + bool adjustable() const { + return (this->type & TYPE_ADJUSTABLE) && this->time < this->time_max; + } + + size_t type; + // Start of this line at the G-code snippet. + size_t line_start; + // End of this line at the G-code snippet. + size_t line_end; + // XY Euclidian length of this segment. + float length; + // Current feedrate, possibly adjusted. + float feedrate; + // Current duration of this segment. + float time; + // Maximum duration of this segment. + float time_max; + // If marked with the "slowdown" flag, the line has been slowed down. + bool slowdown; +}; + +// Calculate the required per extruder time stretches. +struct PerExtruderAdjustments +{ + // Calculate the total elapsed time per this extruder, adjusted for the slowdown. + float elapsed_time_total() { + float time_total = 0.f; + for (const CoolingLine &line : lines) + time_total += line.time; + return time_total; + } + // Calculate the maximum time when slowing down. + float maximum_time(bool slowdown_external_perimeters) { + float time_total = 0.f; + for (const CoolingLine &line : lines) + if (line.adjustable(slowdown_external_perimeters)) { + if (line.time_max == FLT_MAX) + return FLT_MAX; + else + time_total += line.time_max; + } else + time_total += line.time; + return time_total; + } + // Calculate the non-adjustable part of the total time. + float non_adjustable_time(bool slowdown_external_perimeters) { + float time_total = 0.f; + for (const CoolingLine &line : lines) + if (! line.adjustable(slowdown_external_perimeters)) + time_total += line.time; + return time_total; + } + float slow_down_maximum(bool slowdown_external_perimeters) { + float time_total = 0.f; + for (CoolingLine &line : lines) { + if (line.adjustable(slowdown_external_perimeters)) { + assert(line.time_max >= 0.f && line.time_max < FLT_MAX); + line.slowdown = true; + line.time = line.time_max; + line.feedrate = line.length / line.time; + } + time_total += line.time; + } + return time_total; + } + float slow_down_proportional(float factor, bool slowdown_external_perimeters) { + assert(factor >= 1.f); + float time_total = 0.f; + for (CoolingLine &line : lines) { + if (line.adjustable(slowdown_external_perimeters)) { + line.slowdown = true; + line.time = std::min(line.time_max, line.time * factor); + line.feedrate = line.length / line.time; + } + time_total += line.time; + } + return time_total; + } + + bool operator<(const PerExtruderAdjustments &rhs) const { return this->extruder_id < rhs.extruder_id; } + + // Sort the lines, adjustable first, higher feedrate first. + void sort_lines_by_decreasing_feedrate() { + std::sort(lines.begin(), lines.end(), [](const CoolingLine &l1, const CoolingLine &l2) { + bool adj1 = l1.adjustable(); + bool adj2 = l2.adjustable(); + return (adj1 == adj2) ? l1.feedrate > l2.feedrate : adj1; + }); + for (n_lines_adjustable = 0; n_lines_adjustable < lines.size(); ++ n_lines_adjustable) + if ((this->lines[n_lines_adjustable].type & CoolingLine::TYPE_ADJUSTABLE) == 0) + break; + time_non_adjustable = 0.f; + for (size_t i = n_lines_adjustable; i < lines.size(); ++ i) + time_non_adjustable += lines[i].time; + } + + // Calculate the maximum time when slowing down. + float time_stretch_when_slowing_down_to(float min_feedrate) { + float time_stretch = 0.f; + if (this->min_print_speed < min_feedrate + EPSILON) { + for (size_t i = 0; i < n_lines_adjustable; ++ i) { + const CoolingLine &line = lines[i]; + if (line.feedrate > min_feedrate) + time_stretch += line.time * (line.feedrate / min_feedrate - 1.f); + } + } + return time_stretch; + } + + void slow_down_to(float min_feedrate) { + if (this->min_print_speed < min_feedrate + EPSILON) { + for (size_t i = 0; i < n_lines_adjustable; ++ i) { + CoolingLine &line = lines[i]; + if (line.feedrate > min_feedrate) { + line.time *= std::max(1.f, line.feedrate / min_feedrate); + line.feedrate = min_feedrate; + line.slowdown = true; + } + } + } + } + + // Extruder, for which the G-code will be adjusted. + unsigned int extruder_id = 0; + // Minimum print speed allowed for this extruder. + float min_print_speed = 0.f; + + // Parsed lines. + std::vector lines; + // The following two values are set by sort_lines_by_decreasing_feedrate(): + // Number of adjustable lines, at the start of lines. + size_t n_lines_adjustable = 0; + // Non-adjustable time of lines starting with n_lines_adjustable. + float time_non_adjustable = 0; + + // Temporaries for processing the slow down. Both thresholds go from 0 to n_lines_adjustable. + size_t idx_line_begin = 0; + size_t idx_line_end = 0; +}; + #define EXTRUDER_CONFIG(OPT) config.OPT.get_at(m_current_extruder) std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_id) @@ -38,125 +206,23 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ const std::vector &extruders = m_gcodegen.writer().extruders(); const size_t num_extruders = extruders.size(); - // Calculate the required per extruder time stretches. - struct Adjustment { - Adjustment(unsigned int extruder_id = 0) : extruder_id(extruder_id) {} - // Calculate the total elapsed time per this extruder, adjusted for the slowdown. - float elapsed_time_total() { - float time_total = 0.f; - for (const Line &line : lines) - time_total += line.time; - return time_total; - } - // Calculate the maximum time when slowing down. - float maximum_time(bool slowdown_external_perimeters) { - float time_total = 0.f; - for (const Line &line : lines) - if (line.adjustable(slowdown_external_perimeters)) { - if (line.time_max == FLT_MAX) - return FLT_MAX; - else - time_total += line.time_max; - } else - time_total += line.time; - return time_total; - } - // Calculate the non-adjustable part of the total time. - float non_adjustable_time(bool slowdown_external_perimeters) { - float time_total = 0.f; - for (const Line &line : lines) - if (! line.adjustable(slowdown_external_perimeters)) - time_total += line.time; - return time_total; - } - float slow_down_maximum(bool slowdown_external_perimeters) { - float time_total = 0.f; - for (Line &line : lines) { - if (line.adjustable(slowdown_external_perimeters)) { - assert(line.time_max >= 0.f && line.time_max < FLT_MAX); - line.slowdown = true; - line.time = line.time_max; - } - time_total += line.time; - } - return time_total; - } - float slow_down_proportional(float factor, bool slowdown_external_perimeters) { - assert(factor >= 1.f); - float time_total = 0.f; - for (Line &line : lines) { - if (line.adjustable(slowdown_external_perimeters)) { - line.slowdown = true; - line.time = std::min(line.time_max, line.time * factor); - } - time_total += line.time; - } - return time_total; - } - - bool operator<(const Adjustment &rhs) const { return this->extruder_id < rhs.extruder_id; } - - struct Line - { - enum Type { - TYPE_SET_TOOL = 1 << 0, - TYPE_EXTRUDE_END = 1 << 1, - TYPE_BRIDGE_FAN_START = 1 << 2, - TYPE_BRIDGE_FAN_END = 1 << 3, - TYPE_G0 = 1 << 4, - TYPE_G1 = 1 << 5, - TYPE_ADJUSTABLE = 1 << 6, - TYPE_EXTERNAL_PERIMETER = 1 << 7, - // The line sets a feedrate. - TYPE_HAS_F = 1 << 8, - TYPE_WIPE = 1 << 9, - TYPE_G4 = 1 << 10, - TYPE_G92 = 1 << 11, - }; - - Line(unsigned int type, size_t line_start, size_t line_end) : - type(type), line_start(line_start), line_end(line_end), - length(0.f), time(0.f), time_max(0.f), slowdown(false) {} - - bool adjustable(bool slowdown_external_perimeters) const { - return (this->type & TYPE_ADJUSTABLE) && - (! (this->type & TYPE_EXTERNAL_PERIMETER) || slowdown_external_perimeters) && - this->time < this->time_max; - } - - size_t type; - // Start of this line at the G-code snippet. - size_t line_start; - // End of this line at the G-code snippet. - size_t line_end; - // XY Euclidian length of this segment. - float length; - // Current duration of this segment. - float time; - // Maximum duration of this segment. - float time_max; - // If marked with the "slowdown" flag, the line has been slowed down. - bool slowdown; - }; - - // Extruder, for which the G-code will be adjusted. - unsigned int extruder_id; - // Parsed lines. - std::vector lines; - }; - std::vector adjustments(num_extruders, Adjustment()); - for (size_t i = 0; i < num_extruders; ++ i) - adjustments[i].extruder_id = extruders[i].id(); - const std::string toolchange_prefix = m_gcodegen.writer().toolchange_prefix(); + std::vector per_extruder_adjustments(num_extruders); + std::vector map_extruder_to_per_extruder_adjustment(num_extruders, 0); + for (size_t i = 0; i < num_extruders; ++ i) { + unsigned int extruder_id = extruders[i].id(); + per_extruder_adjustments[i].extruder_id = extruder_id; + per_extruder_adjustments[i].min_print_speed = config.min_print_speed.get_at(i); + map_extruder_to_per_extruder_adjustment[extruder_id] = i; + } + const std::string toolchange_prefix = m_gcodegen.writer().toolchange_prefix(); // Parse the layer G-code for the moves, which could be adjusted. { - float min_print_speed = float(EXTRUDER_CONFIG(min_print_speed)); - auto adjustment = std::lower_bound(adjustments.begin(), adjustments.end(), Adjustment(m_current_extruder)); + PerExtruderAdjustments *adjustment = &per_extruder_adjustments[map_extruder_to_per_extruder_adjustment[m_current_extruder]]; unsigned int initial_extruder = m_current_extruder; const char *line_start = gcode.c_str(); const char *line_end = line_start; const char extrusion_axis = config.get_extrusion_axis()[0]; - // Index of an existing Adjustment::Line of the current adjustment, which holds the feedrate setting command + // Index of an existing CoolingLine of the current adjustment, which holds the feedrate setting command // for a sequence of extrusion moves. size_t active_speed_modifier = size_t(-1); for (; *line_start != 0; line_start = line_end) { @@ -164,16 +230,16 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ ++ line_end; // sline will not contain the trailing '\n'. std::string sline(line_start, line_end); - // Adjustment::Line will contain the trailing '\n'. + // CoolingLine will contain the trailing '\n'. if (*line_end == '\n') ++ line_end; - Adjustment::Line line(0, line_start - gcode.c_str(), line_end - gcode.c_str()); + CoolingLine line(0, line_start - gcode.c_str(), line_end - gcode.c_str()); if (boost::starts_with(sline, "G0 ")) - line.type = Adjustment::Line::TYPE_G0; + line.type = CoolingLine::TYPE_G0; else if (boost::starts_with(sline, "G1 ")) - line.type = Adjustment::Line::TYPE_G1; + line.type = CoolingLine::TYPE_G1; else if (boost::starts_with(sline, "G92 ")) - line.type = Adjustment::Line::TYPE_G92; + line.type = CoolingLine::TYPE_G92; if (line.type) { // G0, G1 or G92 // Parse the G-code line. @@ -192,9 +258,9 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ if (axis == 4) { // Convert mm/min to mm/sec. new_pos[4] /= 60.f; - if ((line.type & Adjustment::Line::TYPE_G92) == 0) + if ((line.type & CoolingLine::TYPE_G92) == 0) // This is G0 or G1 line and it sets the feedrate. This mark is used for reducing the duplicate F calls. - line.type |= Adjustment::Line::TYPE_HAS_F; + line.type |= CoolingLine::TYPE_HAS_F; } } // Skip this word. @@ -203,14 +269,14 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ bool external_perimeter = boost::contains(sline, ";_EXTERNAL_PERIMETER"); bool wipe = boost::contains(sline, ";_WIPE"); if (external_perimeter) - line.type |= Adjustment::Line::TYPE_EXTERNAL_PERIMETER; + line.type |= CoolingLine::TYPE_EXTERNAL_PERIMETER; if (wipe) - line.type |= Adjustment::Line::TYPE_WIPE; + line.type |= CoolingLine::TYPE_WIPE; if (boost::contains(sline, ";_EXTRUDE_SET_SPEED") && ! wipe) { - line.type |= Adjustment::Line::TYPE_ADJUSTABLE; + line.type |= CoolingLine::TYPE_ADJUSTABLE; active_speed_modifier = adjustment->lines.size(); } - if ((line.type & Adjustment::Line::TYPE_G92) == 0) { + if ((line.type & CoolingLine::TYPE_G92) == 0) { // G0 or G1. Calculate the duration. if (config.use_relative_e_distances.value) // Reset extruder accumulator. @@ -227,15 +293,17 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ // Movement in the extruder axis. line.length = std::abs(dif[3]); } - if (line.length > 0) - line.time = line.length / new_pos[4]; // current F + if (line.length > 0) { + line.feedrate = new_pos[4]; // current F + line.time = line.length / line.feedrate; + } line.time_max = line.time; - if ((line.type & Adjustment::Line::TYPE_ADJUSTABLE) || active_speed_modifier != size_t(-1)) - line.time_max = (min_print_speed == 0.f) ? FLT_MAX : std::max(line.time, line.length / min_print_speed); - if (active_speed_modifier < adjustment->lines.size() && (line.type & Adjustment::Line::TYPE_G1)) { + if ((line.type & CoolingLine::TYPE_ADJUSTABLE) || active_speed_modifier != size_t(-1)) + line.time_max = (adjustment->min_print_speed == 0.f) ? FLT_MAX : std::max(line.time, line.length / adjustment->min_print_speed); + if (active_speed_modifier < adjustment->lines.size() && (line.type & CoolingLine::TYPE_G1)) { // Inside the ";_EXTRUDE_SET_SPEED" blocks, there must not be a G1 Fxx entry. - assert((line.type & Adjustment::Line::TYPE_HAS_F) == 0); - Adjustment::Line &sm = adjustment->lines[active_speed_modifier]; + assert((line.type & CoolingLine::TYPE_HAS_F) == 0); + CoolingLine &sm = adjustment->lines[active_speed_modifier]; sm.length += line.length; sm.time += line.time; if (sm.time_max != FLT_MAX) { @@ -250,24 +318,23 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ } m_current_pos = std::move(new_pos); } else if (boost::starts_with(sline, ";_EXTRUDE_END")) { - line.type = Adjustment::Line::TYPE_EXTRUDE_END; + line.type = CoolingLine::TYPE_EXTRUDE_END; active_speed_modifier = size_t(-1); } else if (boost::starts_with(sline, toolchange_prefix)) { // Switch the tool. - line.type = Adjustment::Line::TYPE_SET_TOOL; + line.type = CoolingLine::TYPE_SET_TOOL; unsigned int new_extruder = (unsigned int)atoi(sline.c_str() + toolchange_prefix.size()); if (new_extruder != m_current_extruder) { m_current_extruder = new_extruder; - min_print_speed = float(EXTRUDER_CONFIG(min_print_speed)); - adjustment = std::lower_bound(adjustments.begin(), adjustments.end(), Adjustment(m_current_extruder)); + adjustment = &per_extruder_adjustments[map_extruder_to_per_extruder_adjustment[m_current_extruder]]; } } else if (boost::starts_with(sline, ";_BRIDGE_FAN_START")) { - line.type = Adjustment::Line::TYPE_BRIDGE_FAN_START; + line.type = CoolingLine::TYPE_BRIDGE_FAN_START; } else if (boost::starts_with(sline, ";_BRIDGE_FAN_END")) { - line.type = Adjustment::Line::TYPE_BRIDGE_FAN_END; + line.type = CoolingLine::TYPE_BRIDGE_FAN_END; } else if (boost::starts_with(sline, "G4 ")) { // Parse the wait time. - line.type = Adjustment::Line::TYPE_G4; + line.type = CoolingLine::TYPE_G4; size_t pos_S = sline.find('S', 3); size_t pos_P = sline.find('P', 3); line.time = line.time_max = float( @@ -281,18 +348,19 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ } // Sort the extruders by the increasing slowdown_below_layer_time. - std::vector by_slowdown_layer_time; - by_slowdown_layer_time.reserve(num_extruders); + std::vector extruder_by_slowdown_time; + extruder_by_slowdown_time.reserve(num_extruders); // Only insert entries, which are adjustable (have cooling enabled and non-zero stretchable time). // Collect total print time of non-adjustable extruders. float elapsed_time_total_non_adjustable = 0.f; for (size_t i = 0; i < num_extruders; ++ i) { - if (config.cooling.get_at(extruders[i].id())) - by_slowdown_layer_time.emplace_back(i); - else - elapsed_time_total_non_adjustable += adjustments[i].elapsed_time_total(); + if (config.cooling.get_at(extruders[i].id())) { + extruder_by_slowdown_time.emplace_back(i); + per_extruder_adjustments[i].sort_lines_by_decreasing_feedrate(); + } else + elapsed_time_total_non_adjustable += per_extruder_adjustments[i].elapsed_time_total(); } - std::sort(by_slowdown_layer_time.begin(), by_slowdown_layer_time.end(), + std::sort(extruder_by_slowdown_time.begin(), extruder_by_slowdown_time.end(), [&config, &extruders](const size_t idx1, const size_t idx2){ return config.slowdown_below_layer_time.get_at(extruders[idx1].id()) < config.slowdown_below_layer_time.get_at(extruders[idx2].id()); @@ -303,18 +371,18 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ { // Elapsed time for the already adjusted extruders. float elapsed_time_total0 = elapsed_time_total_non_adjustable; - for (size_t i_by_slowdown_layer_time = 0; i_by_slowdown_layer_time < by_slowdown_layer_time.size(); ++ i_by_slowdown_layer_time) { - // Idx in adjustments. - size_t idx = by_slowdown_layer_time[i_by_slowdown_layer_time]; - // Macro to sum or adjust all sections starting with i_by_slowdown_layer_time. + for (size_t i_extruder_by_slowdown_time = 0; i_extruder_by_slowdown_time < extruder_by_slowdown_time.size(); ++ i_extruder_by_slowdown_time) { + // Idx in per_extruder_adjustments. + size_t idx = extruder_by_slowdown_time[i_extruder_by_slowdown_time]; + // Macro to sum or adjust all sections starting with i_extruder_by_slowdown_time. #define FORALL_UNPROCESSED(ACCUMULATOR, ACTION) \ ACCUMULATOR = elapsed_time_total0;\ - for (size_t j = i_by_slowdown_layer_time; j < by_slowdown_layer_time.size(); ++ j) \ - ACCUMULATOR += adjustments[by_slowdown_layer_time[j]].ACTION + for (size_t j = i_extruder_by_slowdown_time; j < extruder_by_slowdown_time.size(); ++ j) \ + ACCUMULATOR += per_extruder_adjustments[extruder_by_slowdown_time[j]].ACTION // Calculate the current adjusted elapsed_time_total over the non-finalized extruders. float total; FORALL_UNPROCESSED(total, elapsed_time_total()); - float slowdown_below_layer_time = float(config.slowdown_below_layer_time.get_at(adjustments[idx].extruder_id)) * 1.001f; + float slowdown_below_layer_time = float(config.slowdown_below_layer_time.get_at(per_extruder_adjustments[idx].extruder_id)) * 1.001f; if (total > slowdown_below_layer_time) { // The current total time is above the minimum threshold of the rest of the extruders, don't adjust anything. } else { @@ -323,8 +391,9 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ float max_time; FORALL_UNPROCESSED(max_time, maximum_time(true)); if (max_time > slowdown_below_layer_time) { - // By slowing every possible movement, the layer time could be reached. Now decide - // whether the external perimeters shall be slowed down as well. + // By slowing every possible movement, the layer time could be reached. +#if 0 + // Now decide, whether the external perimeters shall be slowed down as well. float max_time_nep; FORALL_UNPROCESSED(max_time_nep, maximum_time(false)); if (max_time_nep > slowdown_below_layer_time) { @@ -355,34 +424,98 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ break; } } +#else + // Slow down. Try to equalize the feedrates. + std::vector by_min_print_speed; + by_min_print_speed.reserve(extruder_by_slowdown_time.size() - i_extruder_by_slowdown_time); + for (size_t j = i_extruder_by_slowdown_time; j < extruder_by_slowdown_time.size(); ++ j) + by_min_print_speed.emplace_back(&per_extruder_adjustments[extruder_by_slowdown_time[j]]); + // Find the next highest adjustable feedrate among the extruders. + float feedrate = 0; + for (PerExtruderAdjustments *adj : by_min_print_speed) + if (adj->idx_line_begin < adj->n_lines_adjustable && adj->lines[adj->idx_line_begin].feedrate > feedrate) + feedrate = adj->lines[adj->idx_line_begin].feedrate; + if (feedrate == 0) + // No adjustable line is left. + break; + // Sort by min_print_speed, maximum speed first. + std::sort(by_min_print_speed.begin(), by_min_print_speed.end(), + [](const PerExtruderAdjustments *p1, const PerExtruderAdjustments *p2){ return p1->min_print_speed > p2->min_print_speed; }); + // Slow down, fast moves first. + for (;;) { + // For each extruder, find the span of lines with a feedrate close to feedrate. + for (PerExtruderAdjustments *adj : by_min_print_speed) { + for (adj->idx_line_end = adj->idx_line_begin; + adj->idx_line_end < adj->n_lines_adjustable && adj->lines[adj->idx_line_end].feedrate > feedrate - EPSILON; + ++ adj->idx_line_end) ; + } + // Find the next highest adjustable feedrate among the extruders. + float feedrate_next = 0.f; + for (PerExtruderAdjustments *adj : by_min_print_speed) + if (adj->idx_line_end < adj->n_lines_adjustable && adj->lines[adj->idx_line_end].feedrate > feedrate_next) + feedrate_next = adj->lines[adj->idx_line_end].feedrate; + // Slow down, limited by max(feedrate_next, min_print_speed). + for (auto adj = by_min_print_speed.begin(); adj != by_min_print_speed.end();) { + float feedrate_limit = std::max(feedrate_next, (*adj)->min_print_speed); + float time_stretch = slowdown_below_layer_time - total; + float time_stretch_max = 0.f; + std::pair time_stretched(0.f, 0.f); + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + time_stretch_max += (*it)->time_stretch_when_slowing_down_to(feedrate_limit); + bool done = false; + if (time_stretch_max > time_stretch) { + feedrate_limit = feedrate - (feedrate - feedrate_limit) * time_stretch / time_stretch_max; + done = true; + } + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + (*it)->slow_down_to(feedrate_limit); + if (done) { + // Break from two levels of loops. + feedrate_next = 0.f; + break; + } + // Skip the other extruders with nearly the same min_print_speed, as they have been processed already. + auto next = adj; + for (++ next; next != by_min_print_speed.end() && (*next)->min_print_speed > (*adj)->min_print_speed - EPSILON; ++ next); + adj = next; + } + if (feedrate_next == 0.f) + // There are no other extrusions available for slow down. + break; + for (PerExtruderAdjustments *adj : by_min_print_speed) { + adj->idx_line_begin = adj->idx_line_end; + feedrate = feedrate_next; + } + } +#endif } else { // Slow down to maximum possible. FORALL_UNPROCESSED(total, slow_down_maximum(true)); } } #undef FORALL_UNPROCESSED - // Sum the final elapsed time for all extruders up to i_by_slowdown_layer_time. - if (i_by_slowdown_layer_time + 1 == by_slowdown_layer_time.size()) + // Sum the final elapsed time for all extruders up to i_extruder_by_slowdown_time. + if (i_extruder_by_slowdown_time + 1 == extruder_by_slowdown_time.size()) // Optimization for single extruder prints. elapsed_time_total0 = total; else - elapsed_time_total0 += adjustments[idx].elapsed_time_total(); + elapsed_time_total0 += per_extruder_adjustments[idx].elapsed_time_total(); } elapsed_time_total = elapsed_time_total0; } // Transform the G-code. // First sort the adjustment lines by their position in the source G-code. - std::vector lines; + std::vector lines; { size_t n_lines = 0; - for (const Adjustment &adj : adjustments) + for (const PerExtruderAdjustments &adj : per_extruder_adjustments) n_lines += adj.lines.size(); lines.reserve(n_lines); - for (const Adjustment &adj : adjustments) - for (const Adjustment::Line &line : adj.lines) + for (const PerExtruderAdjustments &adj : per_extruder_adjustments) + for (const CoolingLine &line : adj.lines) lines.emplace_back(&line); - std::sort(lines.begin(), lines.end(), [](const Adjustment::Line *ln1, const Adjustment::Line *ln2) { return ln1->line_start < ln2->line_start; } ); + std::sort(lines.begin(), lines.end(), [](const CoolingLine *ln1, const CoolingLine *ln2) { return ln1->line_start < ln2->line_start; } ); } // Second generate the adjusted G-code. std::string new_gcode; @@ -425,27 +558,27 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ const char *pos = gcode.c_str(); int current_feedrate = 0; - for (const Adjustment::Line *line : lines) { + for (const CoolingLine *line : lines) { const char *line_start = gcode.c_str() + line->line_start; const char *line_end = gcode.c_str() + line->line_end; if (line_start > pos) new_gcode.append(pos, line_start - pos); - if (line->type & Adjustment::Line::TYPE_SET_TOOL) { + if (line->type & CoolingLine::TYPE_SET_TOOL) { unsigned int new_extruder = (unsigned int)atoi(line_start + toolchange_prefix.size()); if (new_extruder != m_current_extruder) { m_current_extruder = new_extruder; change_extruder_set_fan(); } new_gcode.append(line_start, line_end - line_start); - } else if (line->type & Adjustment::Line::TYPE_BRIDGE_FAN_START) { + } else if (line->type & CoolingLine::TYPE_BRIDGE_FAN_START) { if (bridge_fan_control) new_gcode += m_gcodegen.writer().set_fan(bridge_fan_speed, true); - } else if (line->type & Adjustment::Line::TYPE_BRIDGE_FAN_END) { + } else if (line->type & CoolingLine::TYPE_BRIDGE_FAN_END) { if (bridge_fan_control) new_gcode += m_gcodegen.writer().set_fan(fan_speed, true); - } else if (line->type & Adjustment::Line::TYPE_EXTRUDE_END) { + } else if (line->type & CoolingLine::TYPE_EXTRUDE_END) { // Just remove this comment. - } else if (line->type & (Adjustment::Line::TYPE_ADJUSTABLE | Adjustment::Line::TYPE_EXTERNAL_PERIMETER | Adjustment::Line::TYPE_WIPE | Adjustment::Line::TYPE_HAS_F)) { + } else if (line->type & (CoolingLine::TYPE_ADJUSTABLE | CoolingLine::TYPE_EXTERNAL_PERIMETER | CoolingLine::TYPE_WIPE | CoolingLine::TYPE_HAS_F)) { // Find the start of a comment, or roll to the end of line. const char *end = line_start; for (; end < line_end && *end != ';'; ++ end); @@ -456,14 +589,14 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ assert(fpos != nullptr); if (line->slowdown) { modify = true; - new_feedrate = int(floor(60. * (line->length / line->time) + 0.5)); + new_feedrate = int(floor(60. * line->feedrate + 0.5)); } else { new_feedrate = atoi(fpos); if (new_feedrate != current_feedrate) { // Append the line without the comment. new_gcode.append(line_start, end - line_start); current_feedrate = new_feedrate; - } else if ((line->type & (Adjustment::Line::TYPE_ADJUSTABLE | Adjustment::Line::TYPE_EXTERNAL_PERIMETER | Adjustment::Line::TYPE_WIPE)) || line->length == 0.) { + } else if ((line->type & (CoolingLine::TYPE_ADJUSTABLE | CoolingLine::TYPE_EXTERNAL_PERIMETER | CoolingLine::TYPE_WIPE)) || line->length == 0.) { // Feedrate does not change and this line does not move the print head. Skip the complete G-code line including the G-code comment. end = line_end; } else { @@ -497,13 +630,13 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ } // Process the rest of the line. if (end < line_end) { - if (line->type & (Adjustment::Line::TYPE_ADJUSTABLE | Adjustment::Line::TYPE_EXTERNAL_PERIMETER | Adjustment::Line::TYPE_WIPE)) { + if (line->type & (CoolingLine::TYPE_ADJUSTABLE | CoolingLine::TYPE_EXTERNAL_PERIMETER | CoolingLine::TYPE_WIPE)) { // Process comments, remove ";_EXTRUDE_SET_SPEED", ";_EXTERNAL_PERIMETER", ";_WIPE" std::string comment(end, line_end); boost::replace_all(comment, ";_EXTRUDE_SET_SPEED", ""); - if (line->type & Adjustment::Line::TYPE_EXTERNAL_PERIMETER) + if (line->type & CoolingLine::TYPE_EXTERNAL_PERIMETER) boost::replace_all(comment, ";_EXTERNAL_PERIMETER", ""); - if (line->type & Adjustment::Line::TYPE_WIPE) + if (line->type & CoolingLine::TYPE_WIPE) boost::replace_all(comment, ";_WIPE", ""); new_gcode += comment; } else { From 3cd7987af4b6cbb6910eb612fa96775b34c11a0b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 25 Apr 2018 10:59:06 +0200 Subject: [PATCH 0249/1150] Fixed layer heights profile invalidated when loading model from amf file --- lib/Slic3r/GUI/Plater.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index ce78eab8ec..f41394ccc7 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -663,6 +663,9 @@ sub load_files { Slic3r::GUI::show_error($self, $@) if $@; $_->load_current_preset for (values %{$self->GetFrame->{options_tabs}}); wxTheApp->{app_config}->update_config_dir(dirname($input_file)); + # forces the update of the config here, or it will invalidate the imported layer heights profile if done using the timer + # and if the config contains a "layer_height" different from the current defined one + $self->async_apply_config; } else { From cfac6c0ebb98e0a6630ade4a81c90dd6c0b64c0d Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 25 Apr 2018 11:10:34 +0200 Subject: [PATCH 0250/1150] Aligned printer settings on Plater tab --- lib/Slic3r/GUI/Plater.pm | 2 +- xs/src/slic3r/GUI/GUI.cpp | 11 +++++------ xs/src/slic3r/GUI/OptionsGroup.cpp | 8 ++++---- xs/src/slic3r/GUI/OptionsGroup.hpp | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 893cc366bb..53176ccfe1 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -486,7 +486,7 @@ sub new { my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; - $right_sizer->Add($frequently_changed_parameters_sizer, 0, wxEXPAND | wxTOP, 10) if defined $frequently_changed_parameters_sizer; + $right_sizer->Add($frequently_changed_parameters_sizer, 0, wxEXPAND | wxTOP, 0) if defined $frequently_changed_parameters_sizer; $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5); $right_sizer->Add($self->{list}, 1, wxEXPAND, 5); $right_sizer->Add($object_info_sizer, 0, wxEXPAND, 0); diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index c4f07935c5..e85112008f 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -640,8 +640,8 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl { DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; m_optgroup = std::make_shared(parent, "", config); - const wxArrayInt& ar = preset_sizer->GetColWidths(); - m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front(); +// const wxArrayInt& ar = preset_sizer->GetColWidths(); +// m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front(); // doesn't work m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ TabPrint* tab_print = nullptr; for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { @@ -695,10 +695,9 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl tab_print->update_dirty(); }; - const int width = 250; Option option = m_optgroup->get_option("fill_density"); option.opt.sidetext = ""; - option.opt.width = width; + option.opt.full_width = true; m_optgroup->append_single_option_line(option); ConfigOptionDef def; @@ -717,7 +716,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl "Everywhere"; def.default_value = new ConfigOptionStrings { selection }; option = Option(def, "support"); - option.opt.width = width; + option.opt.full_width = true; m_optgroup->append_single_option_line(option); m_brim_width = config->opt_float("brim_width"); @@ -756,7 +755,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl - sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxBottom, 1); + sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); } ConfigOptionsGroup* get_optgroup() diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 265497e9c0..1e78a600aa 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -137,11 +137,11 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* // Build a label if we have it wxStaticText* label=nullptr; if (label_width != 0) { - label = new wxStaticText(parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ":"), - wxDefaultPosition, wxSize(label_width, -1)); + label = new wxStaticText(parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ": "), + wxDefaultPosition, staticbox ? wxSize(label_width, -1) : wxDefaultSize); label->SetFont(label_font); label->Wrap(label_width); // avoid a Linux/GTK bug - grid_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL,0); + grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT) | wxALIGN_CENTER_VERTICAL, 0); if (line.label_tooltip.compare("") != 0) label->SetToolTip(line.label_tooltip); } @@ -166,7 +166,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL); if (is_window_field(field)) - sizer->Add(field->getWindow(), 0, (option.opt.full_width ? wxEXPAND : 0) | + sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, (option.opt.full_width ? wxEXPAND : 0) | wxBOTTOM | wxTOP | wxALIGN_CENTER_VERTICAL, wxOSX ? 0 : 2); if (is_sizer_field(field)) sizer->Add(field->getSizer(), 0, (option.opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0); diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 6a00cbe0d7..8d57420a36 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -131,7 +131,7 @@ public: static_cast(m_grid_sizer)->SetFlexibleDirection(wxHORIZONTAL); static_cast(m_grid_sizer)->AddGrowableCol(label_width != 0); - sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX ? 0: 5); + sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5); } protected: From 0572a3299a61831dbd0a6308a4326673c9334c0f Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 25 Apr 2018 13:25:34 +0200 Subject: [PATCH 0251/1150] First experiment with the wxCollapsiblePane --- lib/Slic3r/GUI/Plater.pm | 2 +- xs/src/slic3r/GUI/GUI.cpp | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 53176ccfe1..7227d222cc 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -403,7 +403,7 @@ sub new { } } - my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxHORIZONTAL); + my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxVERTICAL);#(wxHORIZONTAL); Slic3r::GUI::add_frequently_changed_parameters($self, $frequently_changed_parameters_sizer, $presets); my $object_info_sizer; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index e85112008f..beae2d524a 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include "wxExtensions.hpp" @@ -638,8 +640,26 @@ wxString from_u8(const std::string &str) void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) { + // Experiments with new UI + wxCollapsiblePane *collpane = new wxCollapsiblePane(parent, wxID_ANY, "Print settings:"); + collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, collpane](wxCommandEvent e){ + wxWindowUpdateLocker noUpdates(parent); + + parent->Layout(); + collpane->Refresh(); + })); + + // add the pane with a zero proportion value to the sizer which contains it + sizer->Add(collpane, 0, wxGROW | wxALL, 5); + // now add a test label in the collapsible pane using a sizer to layout it: + wxWindow *win = collpane->GetPane(); +#ifdef __WXMSW__ + collpane->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + win->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif //__WXMSW__ + DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; - m_optgroup = std::make_shared(parent, "", config); + m_optgroup = std::make_shared(/*parent*/win, "", config); // const wxArrayInt& ar = preset_sizer->GetColWidths(); // m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front(); // doesn't work m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ @@ -755,7 +775,13 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl - sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); +// sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); + + + wxSizer *paneSz = new wxBoxSizer(wxVERTICAL); + paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | wxBOTTOM, 2); + win->SetSizer(paneSz); + paneSz->SetSizeHints(win); } ConfigOptionsGroup* get_optgroup() From e93391e0f8c7d808e0c48951e478918e28693b22 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 25 Apr 2018 13:55:45 +0200 Subject: [PATCH 0252/1150] Fixed get_zoom_to_bounding_box_factor on linux --- lib/Slic3r/GUI/3DScene.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index ff6d733997..6cdf2a3e5e 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -688,6 +688,9 @@ sub select_view { sub get_zoom_to_bounding_box_factor { my ($self, $bb) = @_; + + return undef if (! $self->init); + my $max_bb_size = max(@{ $bb->size }); return undef if ($max_bb_size == 0); From bbc3c890ea54f08037535c7fa5040030bec1ec89 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 25 Apr 2018 13:44:06 +0200 Subject: [PATCH 0253/1150] Snapshots: Disable activation of incompatible snapshots --- xs/src/slic3r/Config/Snapshot.cpp | 28 +++++++++++----------- xs/src/slic3r/Config/Snapshot.hpp | 9 ++----- xs/src/slic3r/Config/Version.cpp | 4 ++-- xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp | 16 +++++++------ xs/src/slic3r/Utils/Semver.hpp | 11 +++++++++ 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/xs/src/slic3r/Config/Snapshot.cpp b/xs/src/slic3r/Config/Snapshot.cpp index 18329aa5c8..704fbcfa1b 100644 --- a/xs/src/slic3r/Config/Snapshot.cpp +++ b/xs/src/slic3r/Config/Snapshot.cpp @@ -117,11 +117,11 @@ void Snapshot::load_ini(const std::string &path) if (! semver) throw_on_parse_error("invalid " + kvp.first + " format for " + section.first); if (kvp.first == "version") - vc.version = *semver; + vc.version.config_version = *semver; else if (kvp.first == "min_slic3r_version") - vc.min_slic3r_version = *semver; + vc.version.min_slic3r_version = *semver; else - vc.max_slic3r_version = *semver; + vc.version.max_slic3r_version = *semver; } else if (boost::starts_with(kvp.first, key_prefix_model) && kvp.first.size() > key_prefix_model.size()) { // Parse the printer variants installed for the current model. auto &set_variants = vc.models_variants_installed[kvp.first.substr(key_prefix_model.size())]; @@ -181,9 +181,9 @@ void Snapshot::save_ini(const std::string &path) // Export the vendor configs. for (const VendorConfig &vc : this->vendor_configs) { c << std::endl << "[Vendor:" << vc.name << "]" << std::endl; - c << "version = " << vc.version.to_string() << std::endl; - c << "min_slic3r_version = " << vc.min_slic3r_version.to_string() << std::endl; - c << "max_slic3r_version = " << vc.max_slic3r_version.to_string() << std::endl; + c << "version = " << vc.version.config_version.to_string() << std::endl; + c << "min_slic3r_version = " << vc.version.min_slic3r_version.to_string() << std::endl; + c << "max_slic3r_version = " << vc.version.max_slic3r_version.to_string() << std::endl; // Export installed printer models and their variants. for (const auto &model : vc.models_variants_installed) { if (model.second.size() == 0) @@ -326,10 +326,10 @@ void SnapshotDB::update_slic3r_versions(std::vector &index_db) for (Snapshot::VendorConfig &vendor_config : snapshot.vendor_configs) { auto it = std::find_if(index_db.begin(), index_db.end(), [&vendor_config](const Index &idx) { return idx.vendor() == vendor_config.name; }); if (it != index_db.end()) { - Index::const_iterator it_version = it->find(vendor_config.version); + Index::const_iterator it_version = it->find(vendor_config.version.config_version); if (it_version != it->end()) { - vendor_config.min_slic3r_version = it_version->min_slic3r_version; - vendor_config.max_slic3r_version = it_version->max_slic3r_version; + vendor_config.version.min_slic3r_version = it_version->min_slic3r_version; + vendor_config.version.max_slic3r_version = it_version->max_slic3r_version; } } } @@ -395,16 +395,16 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot: bundle.load_configbundle((data_dir / "vendor" / (cfg.name + ".ini")).string(), PresetBundle::LOAD_CFGBUNDLE_VENDOR_ONLY); for (const VendorProfile &vp : bundle.vendors) if (vp.id == cfg.name) - cfg.version = vp.config_version; + cfg.version.config_version = vp.config_version; // Fill-in the min/max slic3r version from the config index, if possible. try { // Load the config index for the vendor. Index index; index.load(data_dir / "vendor" / (cfg.name + ".idx")); - auto it = index.find(cfg.version); + auto it = index.find(cfg.version.config_version); if (it != index.end()) { - cfg.min_slic3r_version = it->min_slic3r_version; - cfg.max_slic3r_version = it->max_slic3r_version; + cfg.version.min_slic3r_version = it->min_slic3r_version; + cfg.version.max_slic3r_version = it->max_slic3r_version; } } catch (const std::runtime_error &err) { } @@ -476,7 +476,7 @@ SnapshotDB::const_iterator SnapshotDB::snapshot_with_vendor_preset(const std::st auto it_vendor_config = std::lower_bound(snapshot.vendor_configs.begin(), snapshot.vendor_configs.end(), key, [](const Snapshot::VendorConfig &cfg1, const Snapshot::VendorConfig &cfg2) { return cfg1.name < cfg2.name; }); if (it_vendor_config != snapshot.vendor_configs.end() && it_vendor_config->name == vendor_name && - config_version == it_vendor_config->version) { + config_version == it_vendor_config->version.config_version) { // Vendor config found with the correct version. // Save it, but continue searching, as we want the newest snapshot. it_found = it; diff --git a/xs/src/slic3r/Config/Snapshot.hpp b/xs/src/slic3r/Config/Snapshot.hpp index 77aee3e21a..a916dfe92a 100644 --- a/xs/src/slic3r/Config/Snapshot.hpp +++ b/xs/src/slic3r/Config/Snapshot.hpp @@ -18,7 +18,6 @@ class AppConfig; namespace GUI { namespace Config { -class Version; class Index; // A snapshot contains: @@ -76,12 +75,8 @@ public: struct VendorConfig { // Name of the vendor contained in this snapshot. std::string name; - // Version of the vendor config contained in this snapshot. - Semver version = Semver::invalid(); - // Minimum Slic3r version compatible with this vendor configuration. - Semver min_slic3r_version = Semver::zero(); - // Maximum Slic3r version compatible with this vendor configuration, or empty. - Semver max_slic3r_version = Semver::inf(); + // Version of the vendor config contained in this snapshot, along with compatibility data. + Version version; // Which printer models of this vendor were installed, and which variants of the models? std::map> models_variants_installed; }; diff --git a/xs/src/slic3r/Config/Version.cpp b/xs/src/slic3r/Config/Version.cpp index dc09ac8701..a85322ecaf 100644 --- a/xs/src/slic3r/Config/Version.cpp +++ b/xs/src/slic3r/Config/Version.cpp @@ -13,7 +13,7 @@ namespace Slic3r { namespace GUI { namespace Config { -static boost::optional s_current_slic3r_semver = Semver::parse(SLIC3R_VERSION); +static const Semver s_current_slic3r_semver(SLIC3R_VERSION); // Optimized lexicographic compare of two pre-release versions, ignoring the numeric suffix. static int compare_prerelease(const char *p1, const char *p2) @@ -62,7 +62,7 @@ bool Version::is_slic3r_supported(const Semver &slic3r_version) const bool Version::is_current_slic3r_supported() const { - return this->is_slic3r_supported(*s_current_slic3r_semver); + return this->is_slic3r_supported(s_current_slic3r_semver); } #if 0 diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp index 99af707e1c..c0affcab7c 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -39,18 +39,16 @@ static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_ text += " (" + snapshot.comment + ")"; text += "

"; // End of row header. -// text += _(L("ID:")) + " " + snapshot.id + "
"; - // text += _(L("time captured:")) + " " + Utils::format_local_date_time(snapshot.time_captured) + "
"; text += _(L("slic3r version")) + ": " + snapshot.slic3r_version_captured.to_string() + "
"; -// text += "reason: " + snapshot.reason + "
"; text += _(L("print")) + ": " + snapshot.print + "
"; text += _(L("filaments")) + ": " + snapshot.filaments.front() + "
"; text += _(L("printer")) + ": " + snapshot.printer + "
"; + bool compatible = true; for (const Config::Snapshot::VendorConfig &vc : snapshot.vendor_configs) { - text += _(L("vendor")) + ": " + vc.name + ", ver: " + vc.version.to_string() + ", min slic3r ver: " + vc.min_slic3r_version.to_string(); - if (vc.max_slic3r_version != Semver::inf()) - text += ", max slic3r ver: " + vc.max_slic3r_version.to_string(); + text += _(L("vendor")) + ": " + vc.name + ", ver: " + vc.version.config_version.to_string() + ", min slic3r ver: " + vc.version.min_slic3r_version.to_string(); + if (vc.version.max_slic3r_version != Semver::inf()) + text += ", max slic3r ver: " + vc.version.max_slic3r_version.to_string(); text += "
"; for (const std::pair> &model : vc.models_variants_installed) { text += _(L("model")) + ": " + model.first + ", " + _(L("variants")) + ": "; @@ -61,9 +59,13 @@ static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_ } text += "
"; } + if (! vc.version.is_current_slic3r_supported()) { compatible = false; } } - if (! snapshot_active) + if (! compatible) { + text += "

" + _(L("Incompatible with this Slic3r")) + "

"; + } + else if (! snapshot_active) text += "

" + _(L("Activate")) + "

"; text += ""; text += ""; diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index 87396d8124..ae9d21c6b8 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,16 @@ public: set_prerelease(prerelease); } + Semver(const std::string &str) : ver(semver_zero()) + { + auto parsed = parse(str); + if (! parsed) { + throw std::runtime_error(std::string("Could not parse version string: ") + str); + } + ver = parsed->ver; + parsed->ver = semver_zero(); + } + static boost::optional parse(const std::string &str) { semver_t ver = semver_zero(); From 1a4827ba33dfba5e6567d4e942fa91f662dc040d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 25 Apr 2018 14:38:44 +0200 Subject: [PATCH 0254/1150] Fixed incorrect z values set into GCode Preview sliders --- xs/src/slic3r/GUI/3DScene.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 7f5e632bba..a016ab5aa0 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -751,7 +751,10 @@ std::vector GLVolumeCollection::get_current_print_zs() const // Collect layer top positions of all volumes. std::vector print_zs; for (GLVolume *vol : this->volumes) - append(print_zs, vol->print_zs); + { + if (vol->is_active) + append(print_zs, vol->print_zs); + } std::sort(print_zs.begin(), print_zs.end()); // Replace intervals of layers with similar top positions with their average value. @@ -1757,6 +1760,11 @@ void _3DScene::load_gcode_preview(const Print* print, const GCodePreviewData* pr { _generate_legend_texture(*preview_data, tool_colors); _load_shells(*print, *volumes, use_VBOs); + + // removes empty volumes + volumes->volumes.erase(std::remove_if(volumes->volumes.begin(), volumes->volumes.end(), + [](const GLVolume *volume) { return volume->print_zs.empty(); }), + volumes->volumes.end()); } } From 933c0eb6508f3e972ff338bbebfb5fee19e9d104 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 25 Apr 2018 15:14:01 +0200 Subject: [PATCH 0255/1150] Fixes in SemVer and MsgUpdateConfig --- xs/src/slic3r/GUI/UpdateDialogs.cpp | 2 +- xs/src/slic3r/Utils/Semver.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/UpdateDialogs.cpp b/xs/src/slic3r/GUI/UpdateDialogs.cpp index 9a689e03df..e11ecdf5e4 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.cpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.cpp @@ -138,7 +138,7 @@ MsgUpdateConfig::MsgUpdateConfig(const std::unordered_mapAdd(btn_cancel); btn_sizer->AddSpacer(HORIZ_SPACING); - auto *btn_ok = new wxButton(this, wxID_YES); + auto *btn_ok = new wxButton(this, wxID_OK); btn_sizer->Add(btn_ok); btn_ok->SetFocus(); diff --git a/xs/src/slic3r/Utils/Semver.hpp b/xs/src/slic3r/Utils/Semver.hpp index ae9d21c6b8..736f9b891a 100644 --- a/xs/src/slic3r/Utils/Semver.hpp +++ b/xs/src/slic3r/Utils/Semver.hpp @@ -99,8 +99,8 @@ public: void set_maj(int maj) { ver.major = maj; } void set_min(int min) { ver.minor = min; } void set_patch(int patch) { ver.patch = patch; } - void set_metadata(boost::optional meta) { meta ? strdup(*meta) : nullptr; } - void set_prerelease(boost::optional pre) { pre ? strdup(*pre) : nullptr; } + void set_metadata(boost::optional meta) { ver.metadata = meta ? strdup(*meta) : nullptr; } + void set_prerelease(boost::optional pre) { ver.prerelease = pre ? strdup(*pre) : nullptr; } // Comparison bool operator<(const Semver &b) const { return ::semver_compare(ver, b.ver) == -1; } From 8096ef6844caf3662362e61b58bedba6311029c1 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 25 Apr 2018 15:16:39 +0200 Subject: [PATCH 0256/1150] Fixed wrong countours for multipart objects in cut dialog 3D view --- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 7b5752cd2b..0cc8b2decc 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -227,12 +227,14 @@ sub _update { push @objects, $self->{model_object}; } + my $z_cut = $z + $self->{model_object}->bounding_box->z_min; + # get section contour my @expolygons = (); foreach my $volume (@{$self->{model_object}->volumes}) { next if !$volume->mesh; next if $volume->modifier; - my $expp = $volume->mesh->slice([ $z + $volume->mesh->bounding_box->z_min ])->[0]; + my $expp = $volume->mesh->slice([ $z_cut ])->[0]; push @expolygons, @$expp; } foreach my $expolygon (@expolygons) { From f23f86d91c41ee0dd5fed15e31e5c73cae394d9b Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 25 Apr 2018 15:20:46 +0200 Subject: [PATCH 0257/1150] PresetUpdate: Fix UpdateConfig dialog --- xs/src/slic3r/Utils/PresetUpdater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 54841a3708..2f9fc6871c 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -525,7 +525,7 @@ bool PresetUpdater::config_update() const GUI::MsgUpdateConfig dlg(std::move(updates_map)); const auto res = dlg.ShowModal(); - if (res == wxID_YES) { + if (res == wxID_OK) { BOOST_LOG_TRIVIAL(debug) << "User agreed to perform the update"; p->perform_updates(std::move(updates)); } else { From 166ee4c2c87a068263b26c7f43ed309e2078e4ec Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 25 Apr 2018 15:31:37 +0200 Subject: [PATCH 0258/1150] Export of print config enabled as default in save file dialog when exporting to amf and 3mf files --- xs/src/slic3r/GUI/GUI.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 06929085c8..a9ce045436 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -925,6 +925,7 @@ wxWindow* export_option_creator(wxWindow* parent) wxPanel* panel = new wxPanel(parent, -1); wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); wxCheckBox* cbox = new wxCheckBox(panel, wxID_HIGHEST + 1, L("Export print config")); + cbox->SetValue(true); sizer->AddSpacer(5); sizer->Add(cbox, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5); panel->SetSizer(sizer); From 03e9da804a2a9dc8ac987616a4119af5b02e88be Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 25 Apr 2018 16:42:33 +0200 Subject: [PATCH 0259/1150] Update PrusaResearch bundle & index --- resources/profiles/PrusaResearch.idx | 18 +----------------- resources/profiles/PrusaResearch.ini | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/resources/profiles/PrusaResearch.idx b/resources/profiles/PrusaResearch.idx index 5dd09868fa..f07d8b2806 100644 --- a/resources/profiles/PrusaResearch.idx +++ b/resources/profiles/PrusaResearch.idx @@ -1,17 +1 @@ -# This is an example configuration version index. -# The index contains version numbers -min_slic3r_version =1.39.0 -1.1.3 -1.1.2 -1.1.1 -1.1.0 -0.2.0-alpha "some test comment" -max_slic3r_version= 1.39.4 -0.1.0 another test comment - -# some empty lines - -# version without a comment -min_slic3r_version = 1.0.0 -max_slic3r_version = 1.1.0 -0.0.1 +0.1.0 Initial diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 0da7f22d14..b313c4dc57 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -7,13 +7,13 @@ name = Prusa Research # This means, the server may force the Slic3r configuration to be downgraded. config_version = 0.1.0 # Where to get the updates from? -# TODO: proper URL config_update_url = https://raw.githubusercontent.com/vojtechkral/slic3r-settings-tmp/master/PrusaResearch # The printer models will be shown by the Configuration Wizard in this order, # also the first model installed & the first nozzle installed will be activated after install. #TODO: One day we may differentiate variants of the nozzles / hot ends, #for example by the melt zone size, or whether the nozzle is hardened. +# Printer model name will be shown by the installation wizard. [printer_model:MK3] name = Original Prusa i3 MK3 variants = 0.4; 0.25; 0.6 @@ -23,7 +23,6 @@ name = Original Prusa i3 MK2S variants = 0.4; 0.25; 0.6 [printer_model:MK2SMM] -# Printer model name will be shown by the installation wizard. name = Original Prusa i3 MK2SMM variants = 0.4; 0.6 @@ -69,6 +68,7 @@ infill_first = 0 infill_only_where_needed = 0 infill_overlap = 25% interface_shells = 0 +max_print_height = 200 max_print_speed = 100 max_volumetric_extrusion_rate_slope_negative = 0 max_volumetric_extrusion_rate_slope_positive = 0 @@ -120,7 +120,7 @@ thin_walls = 0 top_infill_extrusion_width = 0.45 top_solid_infill_speed = 40 travel_speed = 180 -wipe_tower = 0 +wipe_tower = 1 wipe_tower_per_color_wipe = 20 wipe_tower_width = 60 wipe_tower_x = 180 @@ -939,6 +939,8 @@ inherits = *multimaterial* end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0 +default_print_profile = 0.15mm OPTIMAL +default_filament_profile = Prusa PLA [printer:*mm-multi*] inherits = *multimaterial* @@ -948,10 +950,11 @@ nozzle_diameter = 0.4,0.4,0.4,0.4 printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0 F1000.0\nG1 X160.0 E20.0 F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0 variable_layer_height = 0 +default_print_profile = 0.15mm OPTIMAL +default_filament_profile = Prusa PLA [printer:Original Prusa i3 MK2] inherits = *common* -default_print_profile = 0.15mm OPTIMAL [printer:Original Prusa i3 MK2 0.25 nozzle] inherits = *common* @@ -989,12 +992,14 @@ nozzle_diameter = 0.4,0.4,0.4,0.4 inherits = *mm-multi* nozzle_diameter = 0.6,0.6,0.6,0.6 printer_variant = 0.6 +default_print_profile = 0.20mm NORMAL 0.6 nozzle [printer:Original Prusa i3 MK3] inherits = *common* end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 +max_print_height = 210 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = MK3 default_print_profile = 0.15mm OPTIMAL MK3 @@ -1002,21 +1007,21 @@ default_print_profile = 0.15mm OPTIMAL MK3 [printer:Original Prusa i3 MK3 0.25 nozzle] inherits = *common* nozzle_diameter = 0.25 -printer_variant = 0.25 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 +max_print_height = 210 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = MK3 -default_print_profile = 0.10mm DETAIL MK3 +default_print_profile = 0.10mm DETAIL 0.25 nozzle MK3 [printer:Original Prusa i3 MK3 0.6 nozzle] inherits = *common* nozzle_diameter = 0.6 -printer_variant = 0.6 end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n retract_lift_below = 209 +max_print_height = 210 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = MK3 -default_print_profile = 0.15mm OPTIMAL MK3 +default_print_profile = 0.15mm OPTIMAL 0.6 nozzle MK3 From dce0aa677122172ced4502d43ab42dedb551c077 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 25 Apr 2018 17:43:01 +0200 Subject: [PATCH 0260/1150] Updating: Start using proper URLs --- resources/profiles/PrusaResearch.ini | 2 +- xs/src/slic3r/GUI/AppConfig.cpp | 10 +++++++--- xs/src/slic3r/GUI/AppConfig.hpp | 7 ++++++- xs/src/slic3r/Utils/PresetUpdater.cpp | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index b313c4dc57..d82921fd8d 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -7,7 +7,7 @@ name = Prusa Research # This means, the server may force the Slic3r configuration to be downgraded. config_version = 0.1.0 # Where to get the updates from? -config_update_url = https://raw.githubusercontent.com/vojtechkral/slic3r-settings-tmp/master/PrusaResearch +config_update_url = https://raw.githubusercontent.com/prusa3d/Slic3r-settings/master/live/PrusaResearch/ # The printer models will be shown by the Configuration Wizard in this order, # also the first model installed & the first nozzle installed will be activated after install. diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 965e8185d4..70f4ba110d 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -21,6 +21,7 @@ namespace Slic3r { static const std::string VENDOR_PREFIX = "vendor:"; static const std::string MODEL_PREFIX = "model:"; +static const std::string VERSION_CHECK_URL = "https://raw.githubusercontent.com/prusa3d/Slic3r-settings/master/live/Slic3rPE.version"; void AppConfig::reset() { @@ -49,9 +50,6 @@ void AppConfig::set_defaults() if (get("version_check").empty()) set("version_check", "1"); - // TODO: proper URL - if (get("version_check_url").empty()) - set("version_check_url", "https://gist.githubusercontent.com/vojtechkral/4d8fd4a3b8699a01ec892c264178461c/raw/2f05a64db19e45a7f8fe2cedeff555d544af679b/slic3rPE.version"); if (get("preset_update").empty()) set("preset_update", "1"); @@ -241,6 +239,12 @@ std::string AppConfig::config_path() return (boost::filesystem::path(Slic3r::data_dir()) / "slic3r.ini").make_preferred().string(); } +std::string AppConfig::version_check_url() const +{ + auto from_settings = get("version_check_url"); + return from_settings.empty() ? VERSION_CHECK_URL : from_settings; +} + bool AppConfig::exists() { return boost::filesystem::exists(AppConfig::config_path()); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index 6dcfec0461..16469f0e95 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -92,9 +92,14 @@ public: // Get the default config path from Slic3r::data_dir(). static std::string config_path(); - + + // Returns true if the user's data directory comes from before Slic3r 1.40.0 (no updating) bool legacy_datadir() const { return m_legacy_datadir; } + // Get the Slic3r version check url. + // This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file. + std::string version_check_url() const; + // Does the config file exist? static bool exists(); diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 2f9fc6871c..9c5fe07481 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -135,7 +135,7 @@ PresetUpdater::priv::priv(int version_online_event) : void PresetUpdater::priv::set_download_prefs(AppConfig *app_config) { enabled_version_check = app_config->get("version_check") == "1"; - version_check_url = app_config->get("version_check_url"); + version_check_url = app_config->version_check_url(); enabled_config_update = app_config->get("preset_update") == "1"; } From 269770bbbc373f1462631f918b0bb894db7422a1 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 25 Apr 2018 22:06:44 +0200 Subject: [PATCH 0261/1150] Fix of a new cooling logic. --- t/cooling.t | 6 +-- xs/src/libslic3r/GCode/CoolingBuffer.cpp | 60 ++++++++++++++++-------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/t/cooling.t b/t/cooling.t index ee4f6abea5..f69b7e8a8e 100644 --- a/t/cooling.t +++ b/t/cooling.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 15; +plan tests => 14; BEGIN { use FindBin; @@ -203,8 +203,8 @@ $config->set('disable_fan_first_layers', [ 0 ]); ok $all_below, 'slowdown_below_layer_time is honored'; # check that all layers have at least one unaltered external perimeter speed - my $external = all { $_ > 0 } values %layer_external; - ok $external, 'slowdown_below_layer_time does not alter external perimeters'; +# my $external = all { $_ > 0 } values %layer_external; +# ok $external, 'slowdown_below_layer_time does not alter external perimeters'; } __END__ diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index 121cbb0175..ca9fc65555 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -102,6 +102,13 @@ struct PerExtruderAdjustments time_total += line.time; return time_total; } + float adjustable_time(bool slowdown_external_perimeters) { + float time_total = 0.f; + for (const CoolingLine &line : lines) + if (line.adjustable(slowdown_external_perimeters)) + time_total += line.time; + return time_total; + } // Calculate the non-adjustable part of the total time. float non_adjustable_time(bool slowdown_external_perimeters) { float time_total = 0.f; @@ -207,11 +214,14 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ const size_t num_extruders = extruders.size(); std::vector per_extruder_adjustments(num_extruders); - std::vector map_extruder_to_per_extruder_adjustment(num_extruders, 0); + unsigned int id_extruder_max = 0; + for (const Extruder &ex : extruders) + id_extruder_max = std::max(ex.id(), id_extruder_max); + std::vector map_extruder_to_per_extruder_adjustment(id_extruder_max + 1, 0); for (size_t i = 0; i < num_extruders; ++ i) { unsigned int extruder_id = extruders[i].id(); per_extruder_adjustments[i].extruder_id = extruder_id; - per_extruder_adjustments[i].min_print_speed = config.min_print_speed.get_at(i); + per_extruder_adjustments[i].min_print_speed = config.min_print_speed.get_at(extruder_id); map_extruder_to_per_extruder_adjustment[extruder_id] = i; } const std::string toolchange_prefix = m_gcodegen.writer().toolchange_prefix(); @@ -442,6 +452,7 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ std::sort(by_min_print_speed.begin(), by_min_print_speed.end(), [](const PerExtruderAdjustments *p1, const PerExtruderAdjustments *p2){ return p1->min_print_speed > p2->min_print_speed; }); // Slow down, fast moves first. + float time_stretch = slowdown_below_layer_time - total; for (;;) { // For each extruder, find the span of lines with a feedrate close to feedrate. for (PerExtruderAdjustments *adj : by_min_print_speed) { @@ -457,23 +468,34 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ // Slow down, limited by max(feedrate_next, min_print_speed). for (auto adj = by_min_print_speed.begin(); adj != by_min_print_speed.end();) { float feedrate_limit = std::max(feedrate_next, (*adj)->min_print_speed); - float time_stretch = slowdown_below_layer_time - total; - float time_stretch_max = 0.f; - std::pair time_stretched(0.f, 0.f); - for (auto it = adj; it != by_min_print_speed.end(); ++ it) - time_stretch_max += (*it)->time_stretch_when_slowing_down_to(feedrate_limit); - bool done = false; - if (time_stretch_max > time_stretch) { - feedrate_limit = feedrate - (feedrate - feedrate_limit) * time_stretch / time_stretch_max; - done = true; - } - for (auto it = adj; it != by_min_print_speed.end(); ++ it) - (*it)->slow_down_to(feedrate_limit); - if (done) { - // Break from two levels of loops. - feedrate_next = 0.f; - break; - } + if (feedrate_limit == 0.f) { + float adjustable_time = 0.f; + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + adjustable_time += (*it)->adjustable_time(true); + float ratio = (adjustable_time + time_stretch) / adjustable_time; + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + (*it)->slow_down_proportional(ratio, true); + // Break from two levels of loops. + feedrate_next = 0.f; + break; + } else { + float time_stretch_max = 0.f; + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + time_stretch_max += (*it)->time_stretch_when_slowing_down_to(feedrate_limit); + bool done = false; + if (time_stretch_max > time_stretch) { + feedrate_limit = feedrate - (feedrate - feedrate_limit) * time_stretch / time_stretch_max; + done = true; + } + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + (*it)->slow_down_to(feedrate_limit); + if (done) { + // Break from two levels of loops. + feedrate_next = 0.f; + break; + } + time_stretch -= time_stretch_max; + } // Skip the other extruders with nearly the same min_print_speed, as they have been processed already. auto next = adj; for (++ next; next != by_min_print_speed.end() && (*next)->min_print_speed > (*adj)->min_print_speed - EPSILON; ++ next); From cbaf0ccc51133db07b47e1de0177b5db4fae2a02 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 25 Apr 2018 22:54:52 +0200 Subject: [PATCH 0262/1150] Refactored cooling logic for readibility and maintainability. --- t/cooling.t | 1 + xs/src/libslic3r/GCode/CoolingBuffer.cpp | 753 ++++++++++++----------- xs/src/libslic3r/GCode/CoolingBuffer.hpp | 26 +- 3 files changed, 430 insertions(+), 350 deletions(-) diff --git a/t/cooling.t b/t/cooling.t index f69b7e8a8e..2f444cf9d1 100644 --- a/t/cooling.t +++ b/t/cooling.t @@ -79,6 +79,7 @@ $config->set('disable_fan_first_layers', [ 0 ]); "G1 X50 F2500\n" . "G1 F3000;_EXTRUDE_SET_SPEED\n" . "G1 X100 E1\n" . + ";_EXTRUDE_END\n" . "G1 E4 F400", # Print time of $gcode. my $print_time = 50 / (2500 / 60) + 100 / (3000 / 60) + 4 / (400 / 60); diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index ca9fc65555..141d197ca6 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -89,8 +89,9 @@ struct PerExtruderAdjustments time_total += line.time; return time_total; } - // Calculate the maximum time when slowing down. - float maximum_time(bool slowdown_external_perimeters) { + // Calculate the total elapsed time when slowing down + // to the minimum extrusion feed rate defined for the current material. + float maximum_time_after_slowdown(bool slowdown_external_perimeters) { float time_total = 0.f; for (const CoolingLine &line : lines) if (line.adjustable(slowdown_external_perimeters)) { @@ -102,6 +103,7 @@ struct PerExtruderAdjustments time_total += line.time; return time_total; } + // Calculate the adjustable part of the total time. float adjustable_time(bool slowdown_external_perimeters) { float time_total = 0.f; for (const CoolingLine &line : lines) @@ -117,7 +119,9 @@ struct PerExtruderAdjustments time_total += line.time; return time_total; } - float slow_down_maximum(bool slowdown_external_perimeters) { + // Slow down the adjustable extrusions to the minimum feedrate allowed for the current extruder material. + // Used by both proportional and non-proportional slow down. + float slowdown_to_minimum_feedrate(bool slowdown_external_perimeters) { float time_total = 0.f; for (CoolingLine &line : lines) { if (line.adjustable(slowdown_external_perimeters)) { @@ -130,6 +134,8 @@ struct PerExtruderAdjustments } return time_total; } + // Slow down each adjustable G-code line proportionally by a factor. + // Used by the proportional slow down. float slow_down_proportional(float factor, bool slowdown_external_perimeters) { assert(factor >= 1.f); float time_total = 0.f; @@ -144,9 +150,8 @@ struct PerExtruderAdjustments return time_total; } - bool operator<(const PerExtruderAdjustments &rhs) const { return this->extruder_id < rhs.extruder_id; } - // Sort the lines, adjustable first, higher feedrate first. + // Used by non-proportional slow down. void sort_lines_by_decreasing_feedrate() { std::sort(lines.begin(), lines.end(), [](const CoolingLine &l1, const CoolingLine &l2) { bool adj1 = l1.adjustable(); @@ -161,34 +166,41 @@ struct PerExtruderAdjustments time_non_adjustable += lines[i].time; } - // Calculate the maximum time when slowing down. - float time_stretch_when_slowing_down_to(float min_feedrate) { + // Calculate the maximum time stretch when slowing down to min_feedrate. + // Slowdown to min_feedrate shall be allowed for this extruder's material. + // Used by non-proportional slow down. + float time_stretch_when_slowing_down_to_feedrate(float min_feedrate) { float time_stretch = 0.f; - if (this->min_print_speed < min_feedrate + EPSILON) { - for (size_t i = 0; i < n_lines_adjustable; ++ i) { - const CoolingLine &line = lines[i]; - if (line.feedrate > min_feedrate) - time_stretch += line.time * (line.feedrate / min_feedrate - 1.f); - } + assert(this->min_print_speed < min_feedrate + EPSILON); + for (size_t i = 0; i < n_lines_adjustable; ++ i) { + const CoolingLine &line = lines[i]; + if (line.feedrate > min_feedrate) + time_stretch += line.time * (line.feedrate / min_feedrate - 1.f); } return time_stretch; } - void slow_down_to(float min_feedrate) { - if (this->min_print_speed < min_feedrate + EPSILON) { - for (size_t i = 0; i < n_lines_adjustable; ++ i) { - CoolingLine &line = lines[i]; - if (line.feedrate > min_feedrate) { - line.time *= std::max(1.f, line.feedrate / min_feedrate); - line.feedrate = min_feedrate; - line.slowdown = true; - } + // Slow down all adjustable lines down to min_feedrate. + // Slowdown to min_feedrate shall be allowed for this extruder's material. + // Used by non-proportional slow down. + void slow_down_to_feedrate(float min_feedrate) { + assert(this->min_print_speed < min_feedrate + EPSILON); + for (size_t i = 0; i < n_lines_adjustable; ++ i) { + CoolingLine &line = lines[i]; + if (line.feedrate > min_feedrate) { + line.time *= std::max(1.f, line.feedrate / min_feedrate); + line.feedrate = min_feedrate; + line.slowdown = true; } } } // Extruder, for which the G-code will be adjusted. unsigned int extruder_id = 0; + // Is the cooling slow down logic enabled for this extruder's material? + bool cooling_slow_down_enabled = false; + // Slow down the print down to min_print_speed if the total layer time is below slowdown_below_layer_time. + float slowdown_below_layer_time = 0.f; // Minimum print speed allowed for this extruder. float min_print_speed = 0.f; @@ -199,335 +211,387 @@ struct PerExtruderAdjustments size_t n_lines_adjustable = 0; // Non-adjustable time of lines starting with n_lines_adjustable. float time_non_adjustable = 0; + // Current total time for this extruder. + float time_total = 0; + // Maximum time for this extruder, when the maximum slow down is applied. + float time_maximum = 0; // Temporaries for processing the slow down. Both thresholds go from 0 to n_lines_adjustable. size_t idx_line_begin = 0; size_t idx_line_end = 0; }; -#define EXTRUDER_CONFIG(OPT) config.OPT.get_at(m_current_extruder) - std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_id) +{ + std::vector per_extruder_adjustments = this->parse_layer_gcode(gcode, m_current_pos); + float layer_time_stretched = this->calculate_layer_slowdown(per_extruder_adjustments); + return this->apply_layer_cooldown(gcode, layer_id, layer_time_stretched, per_extruder_adjustments); +} + +// Parse the layer G-code for the moves, which could be adjusted. +// Return the list of parsed lines, bucketed by an extruder. +std::vector CoolingBuffer::parse_layer_gcode(const std::string &gcode, std::vector ¤t_pos) const { const FullPrintConfig &config = m_gcodegen.config(); const std::vector &extruders = m_gcodegen.writer().extruders(); - const size_t num_extruders = extruders.size(); - - std::vector per_extruder_adjustments(num_extruders); - unsigned int id_extruder_max = 0; + unsigned int num_extruders = 0; for (const Extruder &ex : extruders) - id_extruder_max = std::max(ex.id(), id_extruder_max); - std::vector map_extruder_to_per_extruder_adjustment(id_extruder_max + 1, 0); - for (size_t i = 0; i < num_extruders; ++ i) { - unsigned int extruder_id = extruders[i].id(); - per_extruder_adjustments[i].extruder_id = extruder_id; - per_extruder_adjustments[i].min_print_speed = config.min_print_speed.get_at(extruder_id); + num_extruders = std::max(ex.id() + 1, num_extruders); + + std::vector per_extruder_adjustments(extruders.size()); + std::vector map_extruder_to_per_extruder_adjustment(num_extruders, 0); + for (size_t i = 0; i < extruders.size(); ++ i) { + PerExtruderAdjustments &adj = per_extruder_adjustments[i]; + unsigned int extruder_id = extruders[i].id(); + adj.extruder_id = extruder_id; + adj.cooling_slow_down_enabled = config.cooling.get_at(extruder_id); + adj.slowdown_below_layer_time = config.slowdown_below_layer_time.get_at(extruder_id); + adj.min_print_speed = config.min_print_speed.get_at(extruder_id); map_extruder_to_per_extruder_adjustment[extruder_id] = i; } - const std::string toolchange_prefix = m_gcodegen.writer().toolchange_prefix(); - // Parse the layer G-code for the moves, which could be adjusted. + + const std::string toolchange_prefix = m_gcodegen.writer().toolchange_prefix(); + unsigned int current_extruder = m_current_extruder; + PerExtruderAdjustments *adjustment = &per_extruder_adjustments[map_extruder_to_per_extruder_adjustment[current_extruder]]; + const char *line_start = gcode.c_str(); + const char *line_end = line_start; + const char extrusion_axis = config.get_extrusion_axis()[0]; + // Index of an existing CoolingLine of the current adjustment, which holds the feedrate setting command + // for a sequence of extrusion moves. + size_t active_speed_modifier = size_t(-1); + + for (; *line_start != 0; line_start = line_end) { - PerExtruderAdjustments *adjustment = &per_extruder_adjustments[map_extruder_to_per_extruder_adjustment[m_current_extruder]]; - unsigned int initial_extruder = m_current_extruder; - const char *line_start = gcode.c_str(); - const char *line_end = line_start; - const char extrusion_axis = config.get_extrusion_axis()[0]; - // Index of an existing CoolingLine of the current adjustment, which holds the feedrate setting command - // for a sequence of extrusion moves. - size_t active_speed_modifier = size_t(-1); - for (; *line_start != 0; line_start = line_end) { - while (*line_end != '\n' && *line_end != 0) - ++ line_end; - // sline will not contain the trailing '\n'. - std::string sline(line_start, line_end); - // CoolingLine will contain the trailing '\n'. - if (*line_end == '\n') - ++ line_end; - CoolingLine line(0, line_start - gcode.c_str(), line_end - gcode.c_str()); - if (boost::starts_with(sline, "G0 ")) - line.type = CoolingLine::TYPE_G0; - else if (boost::starts_with(sline, "G1 ")) - line.type = CoolingLine::TYPE_G1; - else if (boost::starts_with(sline, "G92 ")) - line.type = CoolingLine::TYPE_G92; - if (line.type) { - // G0, G1 or G92 - // Parse the G-code line. - std::vector new_pos(m_current_pos); - const char *c = sline.data() + 3; - for (;;) { - // Skip whitespaces. - for (; *c == ' ' || *c == '\t'; ++ c); - if (*c == 0 || *c == ';') - break; - // Parse the axis. - size_t axis = (*c >= 'X' && *c <= 'Z') ? (*c - 'X') : - (*c == extrusion_axis) ? 3 : (*c == 'F') ? 4 : size_t(-1); - if (axis != size_t(-1)) { - new_pos[axis] = float(atof(++c)); - if (axis == 4) { - // Convert mm/min to mm/sec. - new_pos[4] /= 60.f; - if ((line.type & CoolingLine::TYPE_G92) == 0) - // This is G0 or G1 line and it sets the feedrate. This mark is used for reducing the duplicate F calls. - line.type |= CoolingLine::TYPE_HAS_F; - } - } - // Skip this word. - for (; *c != ' ' && *c != '\t' && *c != 0; ++ c); - } - bool external_perimeter = boost::contains(sline, ";_EXTERNAL_PERIMETER"); - bool wipe = boost::contains(sline, ";_WIPE"); - if (external_perimeter) - line.type |= CoolingLine::TYPE_EXTERNAL_PERIMETER; - if (wipe) - line.type |= CoolingLine::TYPE_WIPE; - if (boost::contains(sline, ";_EXTRUDE_SET_SPEED") && ! wipe) { - line.type |= CoolingLine::TYPE_ADJUSTABLE; - active_speed_modifier = adjustment->lines.size(); - } - if ((line.type & CoolingLine::TYPE_G92) == 0) { - // G0 or G1. Calculate the duration. - if (config.use_relative_e_distances.value) - // Reset extruder accumulator. - m_current_pos[3] = 0.f; - float dif[4]; - for (size_t i = 0; i < 4; ++ i) - dif[i] = new_pos[i] - m_current_pos[i]; - float dxy2 = dif[0] * dif[0] + dif[1] * dif[1]; - float dxyz2 = dxy2 + dif[2] * dif[2]; - if (dxyz2 > 0.f) { - // Movement in xyz, calculate time from the xyz Euclidian distance. - line.length = sqrt(dxyz2); - } else if (std::abs(dif[3]) > 0.f) { - // Movement in the extruder axis. - line.length = std::abs(dif[3]); + while (*line_end != '\n' && *line_end != 0) + ++ line_end; + // sline will not contain the trailing '\n'. + std::string sline(line_start, line_end); + // CoolingLine will contain the trailing '\n'. + if (*line_end == '\n') + ++ line_end; + CoolingLine line(0, line_start - gcode.c_str(), line_end - gcode.c_str()); + if (boost::starts_with(sline, "G0 ")) + line.type = CoolingLine::TYPE_G0; + else if (boost::starts_with(sline, "G1 ")) + line.type = CoolingLine::TYPE_G1; + else if (boost::starts_with(sline, "G92 ")) + line.type = CoolingLine::TYPE_G92; + if (line.type) { + // G0, G1 or G92 + // Parse the G-code line. + std::vector new_pos(current_pos); + const char *c = sline.data() + 3; + for (;;) { + // Skip whitespaces. + for (; *c == ' ' || *c == '\t'; ++ c); + if (*c == 0 || *c == ';') + break; + // Parse the axis. + size_t axis = (*c >= 'X' && *c <= 'Z') ? (*c - 'X') : + (*c == extrusion_axis) ? 3 : (*c == 'F') ? 4 : size_t(-1); + if (axis != size_t(-1)) { + new_pos[axis] = float(atof(++c)); + if (axis == 4) { + // Convert mm/min to mm/sec. + new_pos[4] /= 60.f; + if ((line.type & CoolingLine::TYPE_G92) == 0) + // This is G0 or G1 line and it sets the feedrate. This mark is used for reducing the duplicate F calls. + line.type |= CoolingLine::TYPE_HAS_F; } - if (line.length > 0) { - line.feedrate = new_pos[4]; // current F - line.time = line.length / line.feedrate; - } - line.time_max = line.time; - if ((line.type & CoolingLine::TYPE_ADJUSTABLE) || active_speed_modifier != size_t(-1)) - line.time_max = (adjustment->min_print_speed == 0.f) ? FLT_MAX : std::max(line.time, line.length / adjustment->min_print_speed); - if (active_speed_modifier < adjustment->lines.size() && (line.type & CoolingLine::TYPE_G1)) { - // Inside the ";_EXTRUDE_SET_SPEED" blocks, there must not be a G1 Fxx entry. - assert((line.type & CoolingLine::TYPE_HAS_F) == 0); - CoolingLine &sm = adjustment->lines[active_speed_modifier]; - sm.length += line.length; - sm.time += line.time; - if (sm.time_max != FLT_MAX) { - if (line.time_max == FLT_MAX) - sm.time_max = FLT_MAX; - else - sm.time_max += line.time_max; - } - // Don't store this line. - line.type = 0; - } - } - m_current_pos = std::move(new_pos); - } else if (boost::starts_with(sline, ";_EXTRUDE_END")) { - line.type = CoolingLine::TYPE_EXTRUDE_END; - active_speed_modifier = size_t(-1); - } else if (boost::starts_with(sline, toolchange_prefix)) { - // Switch the tool. - line.type = CoolingLine::TYPE_SET_TOOL; - unsigned int new_extruder = (unsigned int)atoi(sline.c_str() + toolchange_prefix.size()); - if (new_extruder != m_current_extruder) { - m_current_extruder = new_extruder; - adjustment = &per_extruder_adjustments[map_extruder_to_per_extruder_adjustment[m_current_extruder]]; } - } else if (boost::starts_with(sline, ";_BRIDGE_FAN_START")) { - line.type = CoolingLine::TYPE_BRIDGE_FAN_START; - } else if (boost::starts_with(sline, ";_BRIDGE_FAN_END")) { - line.type = CoolingLine::TYPE_BRIDGE_FAN_END; - } else if (boost::starts_with(sline, "G4 ")) { - // Parse the wait time. - line.type = CoolingLine::TYPE_G4; - size_t pos_S = sline.find('S', 3); - size_t pos_P = sline.find('P', 3); - line.time = line.time_max = float( - (pos_S > 0) ? atof(sline.c_str() + pos_S + 1) : - (pos_P > 0) ? atof(sline.c_str() + pos_P + 1) * 0.001 : 0.); + // Skip this word. + for (; *c != ' ' && *c != '\t' && *c != 0; ++ c); } - if (line.type != 0) - adjustment->lines.emplace_back(std::move(line)); - } - m_current_extruder = initial_extruder; + bool external_perimeter = boost::contains(sline, ";_EXTERNAL_PERIMETER"); + bool wipe = boost::contains(sline, ";_WIPE"); + if (external_perimeter) + line.type |= CoolingLine::TYPE_EXTERNAL_PERIMETER; + if (wipe) + line.type |= CoolingLine::TYPE_WIPE; + if (boost::contains(sline, ";_EXTRUDE_SET_SPEED") && ! wipe) { + line.type |= CoolingLine::TYPE_ADJUSTABLE; + active_speed_modifier = adjustment->lines.size(); + } + if ((line.type & CoolingLine::TYPE_G92) == 0) { + // G0 or G1. Calculate the duration. + if (config.use_relative_e_distances.value) + // Reset extruder accumulator. + current_pos[3] = 0.f; + float dif[4]; + for (size_t i = 0; i < 4; ++ i) + dif[i] = new_pos[i] - current_pos[i]; + float dxy2 = dif[0] * dif[0] + dif[1] * dif[1]; + float dxyz2 = dxy2 + dif[2] * dif[2]; + if (dxyz2 > 0.f) { + // Movement in xyz, calculate time from the xyz Euclidian distance. + line.length = sqrt(dxyz2); + } else if (std::abs(dif[3]) > 0.f) { + // Movement in the extruder axis. + line.length = std::abs(dif[3]); + } + if (line.length > 0) { + line.feedrate = new_pos[4]; // current F + line.time = line.length / line.feedrate; + } + line.time_max = line.time; + if ((line.type & CoolingLine::TYPE_ADJUSTABLE) || active_speed_modifier != size_t(-1)) + line.time_max = (adjustment->min_print_speed == 0.f) ? FLT_MAX : std::max(line.time, line.length / adjustment->min_print_speed); + if (active_speed_modifier < adjustment->lines.size() && (line.type & CoolingLine::TYPE_G1)) { + // Inside the ";_EXTRUDE_SET_SPEED" blocks, there must not be a G1 Fxx entry. + assert((line.type & CoolingLine::TYPE_HAS_F) == 0); + CoolingLine &sm = adjustment->lines[active_speed_modifier]; + sm.length += line.length; + sm.time += line.time; + if (sm.time_max != FLT_MAX) { + if (line.time_max == FLT_MAX) + sm.time_max = FLT_MAX; + else + sm.time_max += line.time_max; + } + // Don't store this line. + line.type = 0; + } + } + current_pos = std::move(new_pos); + } else if (boost::starts_with(sline, ";_EXTRUDE_END")) { + line.type = CoolingLine::TYPE_EXTRUDE_END; + active_speed_modifier = size_t(-1); + } else if (boost::starts_with(sline, toolchange_prefix)) { + // Switch the tool. + line.type = CoolingLine::TYPE_SET_TOOL; + unsigned int new_extruder = (unsigned int)atoi(sline.c_str() + toolchange_prefix.size()); + if (new_extruder != current_extruder) { + current_extruder = new_extruder; + adjustment = &per_extruder_adjustments[map_extruder_to_per_extruder_adjustment[current_extruder]]; + } + } else if (boost::starts_with(sline, ";_BRIDGE_FAN_START")) { + line.type = CoolingLine::TYPE_BRIDGE_FAN_START; + } else if (boost::starts_with(sline, ";_BRIDGE_FAN_END")) { + line.type = CoolingLine::TYPE_BRIDGE_FAN_END; + } else if (boost::starts_with(sline, "G4 ")) { + // Parse the wait time. + line.type = CoolingLine::TYPE_G4; + size_t pos_S = sline.find('S', 3); + size_t pos_P = sline.find('P', 3); + line.time = line.time_max = float( + (pos_S > 0) ? atof(sline.c_str() + pos_S + 1) : + (pos_P > 0) ? atof(sline.c_str() + pos_P + 1) * 0.001 : 0.); + } + if (line.type != 0) + adjustment->lines.emplace_back(std::move(line)); } - // Sort the extruders by the increasing slowdown_below_layer_time. - std::vector extruder_by_slowdown_time; - extruder_by_slowdown_time.reserve(num_extruders); + return per_extruder_adjustments; +} + +// Slow down an extruder range proportionally down to slowdown_below_layer_time. +// Return the total time for the complete layer. +static inline float extruder_range_slow_down_proportional( + std::vector::iterator it_begin, + std::vector::iterator it_end, + // Elapsed time for the extruders already processed. + float elapsed_time_total0, + // Initial total elapsed time before slow down. + float elapsed_time_before_slowdown, + // Target time for the complete layer (all extruders applied). + float slowdown_below_layer_time) +{ + // Total layer time after the slow down has been applied. + float total_after_slowdown = elapsed_time_before_slowdown; + // Now decide, whether the external perimeters shall be slowed down as well. + float max_time_nep = elapsed_time_total0; + for (auto it = it_begin; it != it_end; ++ it) + max_time_nep += (*it)->maximum_time_after_slowdown(false); + if (max_time_nep > slowdown_below_layer_time) { + // It is sufficient to slow down the non-external perimeter moves to reach the target layer time. + // Slow down the non-external perimeters proportionally. + float non_adjustable_time = elapsed_time_total0; + for (auto it = it_begin; it != it_end; ++ it) + non_adjustable_time += (*it)->non_adjustable_time(false); + // The following step is a linear programming task due to the minimum movement speeds of the print moves. + // Run maximum 5 iterations until a good enough approximation is reached. + for (size_t iter = 0; iter < 5; ++ iter) { + float factor = (slowdown_below_layer_time - non_adjustable_time) / (total_after_slowdown - non_adjustable_time); + assert(factor > 1.f); + total_after_slowdown = elapsed_time_total0; + for (auto it = it_begin; it != it_end; ++ it) + total_after_slowdown += (*it)->slow_down_proportional(factor, false); + if (total_after_slowdown > 0.95f * slowdown_below_layer_time) + break; + } + } else { + // Slow down everything. First slow down the non-external perimeters to maximum. + for (auto it = it_begin; it != it_end; ++ it) + (*it)->slowdown_to_minimum_feedrate(false); + // Slow down the external perimeters proportionally. + float non_adjustable_time = elapsed_time_total0; + for (auto it = it_begin; it != it_end; ++ it) + non_adjustable_time += (*it)->non_adjustable_time(true); + for (size_t iter = 0; iter < 5; ++ iter) { + float factor = (slowdown_below_layer_time - non_adjustable_time) / (total_after_slowdown - non_adjustable_time); + assert(factor > 1.f); + total_after_slowdown = elapsed_time_total0; + for (auto it = it_begin; it != it_end; ++ it) + total_after_slowdown += (*it)->slow_down_proportional(factor, true); + if (total_after_slowdown > 0.95f * slowdown_below_layer_time) + break; + } + } + return total_after_slowdown; +} + +// Slow down an extruder range to slowdown_below_layer_time. +// Return the total time for the complete layer. +static inline void extruder_range_slow_down_non_proportional( + std::vector::iterator it_begin, + std::vector::iterator it_end, + float time_stretch) +{ + // Slow down. Try to equalize the feedrates. + std::vector by_min_print_speed(it_begin, it_end); + // Find the next highest adjustable feedrate among the extruders. + float feedrate = 0; + for (PerExtruderAdjustments *adj : by_min_print_speed) { + adj->idx_line_begin = 0; + adj->idx_line_end = 0; + assert(adj->idx_line_begin < adj->n_lines_adjustable); + if (adj->lines[adj->idx_line_begin].feedrate > feedrate) + feedrate = adj->lines[adj->idx_line_begin].feedrate; + } + assert(feedrate > 0.f); + // Sort by min_print_speed, maximum speed first. + std::sort(by_min_print_speed.begin(), by_min_print_speed.end(), + [](const PerExtruderAdjustments *p1, const PerExtruderAdjustments *p2){ return p1->min_print_speed > p2->min_print_speed; }); + // Slow down, fast moves first. + for (;;) { + // For each extruder, find the span of lines with a feedrate close to feedrate. + for (PerExtruderAdjustments *adj : by_min_print_speed) { + for (adj->idx_line_end = adj->idx_line_begin; + adj->idx_line_end < adj->n_lines_adjustable && adj->lines[adj->idx_line_end].feedrate > feedrate - EPSILON; + ++ adj->idx_line_end) ; + } + // Find the next highest adjustable feedrate among the extruders. + float feedrate_next = 0.f; + for (PerExtruderAdjustments *adj : by_min_print_speed) + if (adj->idx_line_end < adj->n_lines_adjustable && adj->lines[adj->idx_line_end].feedrate > feedrate_next) + feedrate_next = adj->lines[adj->idx_line_end].feedrate; + // Slow down, limited by max(feedrate_next, min_print_speed). + for (auto adj = by_min_print_speed.begin(); adj != by_min_print_speed.end();) { + // Slow down at most by time_stretch. + if ((*adj)->min_print_speed == 0.f) { + // All the adjustable speeds are now lowered to the same speed, + // and the minimum speed is set to zero. + float time_adjustable = 0.f; + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + time_adjustable += (*it)->adjustable_time(true); + float rate = (time_adjustable + time_stretch) / time_adjustable; + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + (*it)->slow_down_proportional(rate, true); + return; + } else { + float feedrate_limit = std::max(feedrate_next, (*adj)->min_print_speed); + bool done = false; + float time_stretch_max = 0.f; + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + time_stretch_max += (*it)->time_stretch_when_slowing_down_to_feedrate(feedrate_limit); + if (time_stretch_max >= time_stretch) { + feedrate_limit = feedrate - (feedrate - feedrate_limit) * time_stretch / time_stretch_max; + done = true; + } else + time_stretch -= time_stretch_max; + for (auto it = adj; it != by_min_print_speed.end(); ++ it) + (*it)->slow_down_to_feedrate(feedrate_limit); + if (done) + return; + } + // Skip the other extruders with nearly the same min_print_speed, as they have been processed already. + auto next = adj; + for (++ next; next != by_min_print_speed.end() && (*next)->min_print_speed > (*adj)->min_print_speed - EPSILON; ++ next); + adj = next; + } + if (feedrate_next == 0.f) + // There are no other extrusions available for slow down. + break; + for (PerExtruderAdjustments *adj : by_min_print_speed) { + adj->idx_line_begin = adj->idx_line_end; + feedrate = feedrate_next; + } + } +} + +// Calculate slow down for all the extruders. +float CoolingBuffer::calculate_layer_slowdown(std::vector &per_extruder_adjustments) +{ + // Sort the extruders by an increasing slowdown_below_layer_time. + // The layers with a lower slowdown_below_layer_time are slowed down + // together with all the other layers with slowdown_below_layer_time above. + std::vector by_slowdown_time; + by_slowdown_time.reserve(per_extruder_adjustments.size()); // Only insert entries, which are adjustable (have cooling enabled and non-zero stretchable time). // Collect total print time of non-adjustable extruders. - float elapsed_time_total_non_adjustable = 0.f; - for (size_t i = 0; i < num_extruders; ++ i) { - if (config.cooling.get_at(extruders[i].id())) { - extruder_by_slowdown_time.emplace_back(i); - per_extruder_adjustments[i].sort_lines_by_decreasing_feedrate(); + float elapsed_time_total0 = 0.f; + for (PerExtruderAdjustments &adj : per_extruder_adjustments) { + // Curren total time for this extruder. + adj.time_total = adj.elapsed_time_total(); + // Maximum time for this extruder, when all extrusion moves are slowed down to min_extrusion_speed. + adj.time_maximum = adj.maximum_time_after_slowdown(true); + if (adj.cooling_slow_down_enabled) { + by_slowdown_time.emplace_back(&adj); + if (! m_cooling_logic_proportional) + // sorts the lines, also sets adj.time_non_adjustable + adj.sort_lines_by_decreasing_feedrate(); } else - elapsed_time_total_non_adjustable += per_extruder_adjustments[i].elapsed_time_total(); + elapsed_time_total0 += adj.elapsed_time_total(); } - std::sort(extruder_by_slowdown_time.begin(), extruder_by_slowdown_time.end(), - [&config, &extruders](const size_t idx1, const size_t idx2){ - return config.slowdown_below_layer_time.get_at(extruders[idx1].id()) < - config.slowdown_below_layer_time.get_at(extruders[idx2].id()); - }); + std::sort(by_slowdown_time.begin(), by_slowdown_time.end(), + [](const PerExtruderAdjustments *adj1, const PerExtruderAdjustments *adj2) + { return adj1->slowdown_below_layer_time < adj2->slowdown_below_layer_time; }); - // Elapsed time after adjustment. - float elapsed_time_total = 0.f; - { - // Elapsed time for the already adjusted extruders. - float elapsed_time_total0 = elapsed_time_total_non_adjustable; - for (size_t i_extruder_by_slowdown_time = 0; i_extruder_by_slowdown_time < extruder_by_slowdown_time.size(); ++ i_extruder_by_slowdown_time) { - // Idx in per_extruder_adjustments. - size_t idx = extruder_by_slowdown_time[i_extruder_by_slowdown_time]; - // Macro to sum or adjust all sections starting with i_extruder_by_slowdown_time. - #define FORALL_UNPROCESSED(ACCUMULATOR, ACTION) \ - ACCUMULATOR = elapsed_time_total0;\ - for (size_t j = i_extruder_by_slowdown_time; j < extruder_by_slowdown_time.size(); ++ j) \ - ACCUMULATOR += per_extruder_adjustments[extruder_by_slowdown_time[j]].ACTION - // Calculate the current adjusted elapsed_time_total over the non-finalized extruders. - float total; - FORALL_UNPROCESSED(total, elapsed_time_total()); - float slowdown_below_layer_time = float(config.slowdown_below_layer_time.get_at(per_extruder_adjustments[idx].extruder_id)) * 1.001f; - if (total > slowdown_below_layer_time) { - // The current total time is above the minimum threshold of the rest of the extruders, don't adjust anything. + for (auto cur_begin = by_slowdown_time.begin(); cur_begin != by_slowdown_time.end(); ++ cur_begin) { + PerExtruderAdjustments &adj = *(*cur_begin); + // Calculate the current adjusted elapsed_time_total over the non-finalized extruders. + float total = elapsed_time_total0; + for (auto it = cur_begin; it != by_slowdown_time.end(); ++ it) + total += (*it)->time_total; + float slowdown_below_layer_time = adj.slowdown_below_layer_time * 1.001f; + if (total > slowdown_below_layer_time) { + // The current total time is above the minimum threshold of the rest of the extruders, don't adjust anything. + } else { + // Adjust this and all the following (higher config.slowdown_below_layer_time) extruders. + // Sum maximum slow down time as if everything was slowed down including the external perimeters. + float max_time = elapsed_time_total0; + for (auto it = cur_begin; it != by_slowdown_time.end(); ++ it) + max_time += (*it)->time_maximum; + if (max_time > slowdown_below_layer_time) { + if (m_cooling_logic_proportional) + extruder_range_slow_down_proportional(cur_begin, by_slowdown_time.end(), elapsed_time_total0, total, slowdown_below_layer_time); + else + extruder_range_slow_down_non_proportional(cur_begin, by_slowdown_time.end(), slowdown_below_layer_time - total); } else { - // Adjust this and all the following (higher config.slowdown_below_layer_time) extruders. - // Sum maximum slow down time as if everything was slowed down including the external perimeters. - float max_time; - FORALL_UNPROCESSED(max_time, maximum_time(true)); - if (max_time > slowdown_below_layer_time) { - // By slowing every possible movement, the layer time could be reached. -#if 0 - // Now decide, whether the external perimeters shall be slowed down as well. - float max_time_nep; - FORALL_UNPROCESSED(max_time_nep, maximum_time(false)); - if (max_time_nep > slowdown_below_layer_time) { - // It is sufficient to slow down the non-external perimeter moves to reach the target layer time. - // Slow down the non-external perimeters proportionally. - float non_adjustable_time; - FORALL_UNPROCESSED(non_adjustable_time, non_adjustable_time(false)); - // The following step is a linear programming task due to the minimum movement speeds of the print moves. - // Run maximum 5 iterations until a good enough approximation is reached. - for (size_t iter = 0; iter < 5; ++ iter) { - float factor = (slowdown_below_layer_time - non_adjustable_time) / (total - non_adjustable_time); - assert(factor > 1.f); - FORALL_UNPROCESSED(total, slow_down_proportional(factor, false)); - if (total > 0.95f * slowdown_below_layer_time) - break; - } - } else { - // Slow down everything. First slow down the non-external perimeters to maximum. - FORALL_UNPROCESSED(total, slow_down_maximum(false)); - // Slow down the external perimeters proportionally. - float non_adjustable_time; - FORALL_UNPROCESSED(non_adjustable_time, non_adjustable_time(true)); - for (size_t iter = 0; iter < 5; ++ iter) { - float factor = (slowdown_below_layer_time - non_adjustable_time) / (total - non_adjustable_time); - assert(factor > 1.f); - FORALL_UNPROCESSED(total, slow_down_proportional(factor, true)); - if (total > 0.95f * slowdown_below_layer_time) - break; - } - } -#else - // Slow down. Try to equalize the feedrates. - std::vector by_min_print_speed; - by_min_print_speed.reserve(extruder_by_slowdown_time.size() - i_extruder_by_slowdown_time); - for (size_t j = i_extruder_by_slowdown_time; j < extruder_by_slowdown_time.size(); ++ j) - by_min_print_speed.emplace_back(&per_extruder_adjustments[extruder_by_slowdown_time[j]]); - // Find the next highest adjustable feedrate among the extruders. - float feedrate = 0; - for (PerExtruderAdjustments *adj : by_min_print_speed) - if (adj->idx_line_begin < adj->n_lines_adjustable && adj->lines[adj->idx_line_begin].feedrate > feedrate) - feedrate = adj->lines[adj->idx_line_begin].feedrate; - if (feedrate == 0) - // No adjustable line is left. - break; - // Sort by min_print_speed, maximum speed first. - std::sort(by_min_print_speed.begin(), by_min_print_speed.end(), - [](const PerExtruderAdjustments *p1, const PerExtruderAdjustments *p2){ return p1->min_print_speed > p2->min_print_speed; }); - // Slow down, fast moves first. - float time_stretch = slowdown_below_layer_time - total; - for (;;) { - // For each extruder, find the span of lines with a feedrate close to feedrate. - for (PerExtruderAdjustments *adj : by_min_print_speed) { - for (adj->idx_line_end = adj->idx_line_begin; - adj->idx_line_end < adj->n_lines_adjustable && adj->lines[adj->idx_line_end].feedrate > feedrate - EPSILON; - ++ adj->idx_line_end) ; - } - // Find the next highest adjustable feedrate among the extruders. - float feedrate_next = 0.f; - for (PerExtruderAdjustments *adj : by_min_print_speed) - if (adj->idx_line_end < adj->n_lines_adjustable && adj->lines[adj->idx_line_end].feedrate > feedrate_next) - feedrate_next = adj->lines[adj->idx_line_end].feedrate; - // Slow down, limited by max(feedrate_next, min_print_speed). - for (auto adj = by_min_print_speed.begin(); adj != by_min_print_speed.end();) { - float feedrate_limit = std::max(feedrate_next, (*adj)->min_print_speed); - if (feedrate_limit == 0.f) { - float adjustable_time = 0.f; - for (auto it = adj; it != by_min_print_speed.end(); ++ it) - adjustable_time += (*it)->adjustable_time(true); - float ratio = (adjustable_time + time_stretch) / adjustable_time; - for (auto it = adj; it != by_min_print_speed.end(); ++ it) - (*it)->slow_down_proportional(ratio, true); - // Break from two levels of loops. - feedrate_next = 0.f; - break; - } else { - float time_stretch_max = 0.f; - for (auto it = adj; it != by_min_print_speed.end(); ++ it) - time_stretch_max += (*it)->time_stretch_when_slowing_down_to(feedrate_limit); - bool done = false; - if (time_stretch_max > time_stretch) { - feedrate_limit = feedrate - (feedrate - feedrate_limit) * time_stretch / time_stretch_max; - done = true; - } - for (auto it = adj; it != by_min_print_speed.end(); ++ it) - (*it)->slow_down_to(feedrate_limit); - if (done) { - // Break from two levels of loops. - feedrate_next = 0.f; - break; - } - time_stretch -= time_stretch_max; - } - // Skip the other extruders with nearly the same min_print_speed, as they have been processed already. - auto next = adj; - for (++ next; next != by_min_print_speed.end() && (*next)->min_print_speed > (*adj)->min_print_speed - EPSILON; ++ next); - adj = next; - } - if (feedrate_next == 0.f) - // There are no other extrusions available for slow down. - break; - for (PerExtruderAdjustments *adj : by_min_print_speed) { - adj->idx_line_begin = adj->idx_line_end; - feedrate = feedrate_next; - } - } -#endif - } else { - // Slow down to maximum possible. - FORALL_UNPROCESSED(total, slow_down_maximum(true)); - } + // Slow down to maximum possible. + for (auto it = cur_begin; it != by_slowdown_time.end(); ++ it) + (*it)->slowdown_to_minimum_feedrate(true); } - #undef FORALL_UNPROCESSED - // Sum the final elapsed time for all extruders up to i_extruder_by_slowdown_time. - if (i_extruder_by_slowdown_time + 1 == extruder_by_slowdown_time.size()) - // Optimization for single extruder prints. - elapsed_time_total0 = total; - else - elapsed_time_total0 += per_extruder_adjustments[idx].elapsed_time_total(); } - elapsed_time_total = elapsed_time_total0; + elapsed_time_total0 += adj.elapsed_time_total(); } - // Transform the G-code. - // First sort the adjustment lines by their position in the source G-code. + return elapsed_time_total0; +} + +// Apply slow down over G-code lines stored in per_extruder_adjustments, enable fan if needed. +// Returns the adjusted G-code. +std::string CoolingBuffer::apply_layer_cooldown( + // Source G-code for the current layer. + const std::string &gcode, + // ID of the current layer, used to disable fan for the first n layers. + size_t layer_id, + // Total time of this layer after slow down, used to control the fan. + float layer_time, + // Per extruder list of G-code lines and their cool down attributes. + std::vector &per_extruder_adjustments) +{ + // First sort the adjustment lines by of multiple extruders by their position in the source G-code. std::vector lines; { size_t n_lines = 0; @@ -545,8 +609,9 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ int fan_speed = -1; bool bridge_fan_control = false; int bridge_fan_speed = 0; - auto change_extruder_set_fan = [ this, layer_id, elapsed_time_total, &new_gcode, &fan_speed, &bridge_fan_control, &bridge_fan_speed ]() { + auto change_extruder_set_fan = [ this, layer_id, layer_time, &new_gcode, &fan_speed, &bridge_fan_control, &bridge_fan_speed ]() { const FullPrintConfig &config = m_gcodegen.config(); +#define EXTRUDER_CONFIG(OPT) config.OPT.get_at(m_current_extruder) int min_fan_speed = EXTRUDER_CONFIG(min_fan_speed); int fan_speed_new = EXTRUDER_CONFIG(fan_always_on) ? min_fan_speed : 0; if (layer_id >= EXTRUDER_CONFIG(disable_fan_first_layers)) { @@ -554,17 +619,18 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ float slowdown_below_layer_time = float(EXTRUDER_CONFIG(slowdown_below_layer_time)); float fan_below_layer_time = float(EXTRUDER_CONFIG(fan_below_layer_time)); if (EXTRUDER_CONFIG(cooling)) { - if (elapsed_time_total < slowdown_below_layer_time) { + if (layer_time < slowdown_below_layer_time) { // Layer time very short. Enable the fan to a full throttle. fan_speed_new = max_fan_speed; - } else if (elapsed_time_total < fan_below_layer_time) { + } else if (layer_time < fan_below_layer_time) { // Layer time quite short. Enable the fan proportionally according to the current layer time. - assert(elapsed_time_total >= slowdown_below_layer_time); - double t = (elapsed_time_total - slowdown_below_layer_time) / (fan_below_layer_time - slowdown_below_layer_time); + assert(layer_time >= slowdown_below_layer_time); + double t = (layer_time - slowdown_below_layer_time) / (fan_below_layer_time - slowdown_below_layer_time); fan_speed_new = int(floor(t * min_fan_speed + (1. - t) * max_fan_speed) + 0.5); } } bridge_fan_speed = EXTRUDER_CONFIG(bridge_fan_speed); +#undef EXTRUDER_CONFIG bridge_fan_control = bridge_fan_speed > fan_speed_new; } else { bridge_fan_control = false; @@ -576,10 +642,11 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ new_gcode += m_gcodegen.writer().set_fan(fan_speed); } }; - change_extruder_set_fan(); - const char *pos = gcode.c_str(); - int current_feedrate = 0; + const char *pos = gcode.c_str(); + int current_feedrate = 0; + const std::string toolchange_prefix = m_gcodegen.writer().toolchange_prefix(); + change_extruder_set_fan(); for (const CoolingLine *line : lines) { const char *line_start = gcode.c_str() + line->line_start; const char *line_end = gcode.c_str() + line->line_end; @@ -602,9 +669,9 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ // Just remove this comment. } else if (line->type & (CoolingLine::TYPE_ADJUSTABLE | CoolingLine::TYPE_EXTERNAL_PERIMETER | CoolingLine::TYPE_WIPE | CoolingLine::TYPE_HAS_F)) { // Find the start of a comment, or roll to the end of line. - const char *end = line_start; - for (; end < line_end && *end != ';'; ++ end); - // Find the 'F' word. + const char *end = line_start; + for (; end < line_end && *end != ';'; ++ end); + // Find the 'F' word. const char *fpos = strstr(line_start + 2, " F") + 2; int new_feedrate = current_feedrate; bool modify = false; @@ -643,7 +710,7 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ new_gcode.append(line_start, f - line_start + 1); } // Skip the non-whitespaces of the F parameter up the comment or end of line. - for (; fpos != end && *fpos != ' ' && *fpos != ';' && *fpos != '\n'; ++fpos); + for (; fpos != end && *fpos != ' ' && *fpos != ';' && *fpos != '\n'; ++fpos); // Append the rest of the line without the comment. if (fpos < end) new_gcode.append(fpos, end - fpos); @@ -653,21 +720,21 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ // Process the rest of the line. if (end < line_end) { if (line->type & (CoolingLine::TYPE_ADJUSTABLE | CoolingLine::TYPE_EXTERNAL_PERIMETER | CoolingLine::TYPE_WIPE)) { - // Process comments, remove ";_EXTRUDE_SET_SPEED", ";_EXTERNAL_PERIMETER", ";_WIPE" - std::string comment(end, line_end); - boost::replace_all(comment, ";_EXTRUDE_SET_SPEED", ""); + // Process comments, remove ";_EXTRUDE_SET_SPEED", ";_EXTERNAL_PERIMETER", ";_WIPE" + std::string comment(end, line_end); + boost::replace_all(comment, ";_EXTRUDE_SET_SPEED", ""); if (line->type & CoolingLine::TYPE_EXTERNAL_PERIMETER) boost::replace_all(comment, ";_EXTERNAL_PERIMETER", ""); if (line->type & CoolingLine::TYPE_WIPE) boost::replace_all(comment, ";_WIPE", ""); - new_gcode += comment; - } else { - // Just attach the rest of the source line. - new_gcode.append(end, line_end - end); - } + new_gcode += comment; + } else { + // Just attach the rest of the source line. + new_gcode.append(end, line_end - end); + } } } else { - new_gcode.append(line_start, line_end - line_start); + new_gcode.append(line_start, line_end - line_start); } pos = line_end; } diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.hpp b/xs/src/libslic3r/GCode/CoolingBuffer.hpp index f85c470b30..bf4b082e25 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.hpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.hpp @@ -9,13 +9,17 @@ namespace Slic3r { class GCode; class Layer; +class PerExtruderAdjustments; -/* -A standalone G-code filter, to control cooling of the print. -The G-code is processed per layer. Once a layer is collected, fan start / stop commands are edited -and the print is modified to stretch over a minimum layer time. -*/ - +// A standalone G-code filter, to control cooling of the print. +// The G-code is processed per layer. Once a layer is collected, fan start / stop commands are edited +// and the print is modified to stretch over a minimum layer time. +// +// The simple it sounds, the actual implementation is significantly more complex. +// Namely, for a multi-extruder print, each material may require a different cooling logic. +// For example, some materials may not like to print too slowly, while with some materials +// we may slow down significantly. +// class CoolingBuffer { public: CoolingBuffer(GCode &gcodegen); @@ -25,7 +29,12 @@ public: GCode* gcodegen() { return &m_gcodegen; } private: - CoolingBuffer& operator=(const CoolingBuffer&); + CoolingBuffer& operator=(const CoolingBuffer&) = delete; + std::vector parse_layer_gcode(const std::string &gcode, std::vector ¤t_pos) const; + float calculate_layer_slowdown(std::vector &per_extruder_adjustments); + // Apply slow down over G-code lines stored in per_extruder_adjustments, enable fan if needed. + // Returns the adjusted G-code. + std::string apply_layer_cooldown(const std::string &gcode, size_t layer_id, float layer_time, std::vector &per_extruder_adjustments); GCode& m_gcodegen; std::string m_gcode; @@ -34,6 +43,9 @@ private: std::vector m_axis; std::vector m_current_pos; unsigned int m_current_extruder; + + // Old logic: proportional. + bool m_cooling_logic_proportional = false; }; } From fd16357b6e1566cd7b97ed7d3166044aa35d6925 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 26 Apr 2018 11:03:15 +0200 Subject: [PATCH 0263/1150] Increase z buffer range to avoid clipping while panning/rotating the 3D view --- lib/Slic3r/GUI/3DScene.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 6cdf2a3e5e..88137185b7 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1115,7 +1115,7 @@ sub Resize { # is only a workaround for an incorrectly set camera. # This workaround harms Z-buffer accuracy! # my $depth = 1.05 * $self->max_bounding_box->radius(); - my $depth = max(@{ $self->max_bounding_box->size }); + my $depth = 5.0 * max(@{ $self->max_bounding_box->size }); glOrtho( -$x/2, $x/2, -$y/2, $y/2, -$depth, $depth, From 24dc4c0f236d53d48d81bca11b1ef6d0de3fa511 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 26 Apr 2018 11:19:51 +0200 Subject: [PATCH 0264/1150] Yet another attempt to fix the layer height profile validation --- xs/src/libslic3r/Print.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index ec91691a1f..38a41370b6 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -602,10 +602,10 @@ std::string Print::validate() const return "The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1)."; SlicingParameters slicing_params0 = this->objects.front()->slicing_parameters(); - const PrintObject* most_layered_object = this->objects.front(); // object with highest layer_height_profile.size() encountered so far + const PrintObject* tallest_object = this->objects.front(); // let's find the tallest object for (const auto* object : objects) - if (object->layer_height_profile.size() > most_layered_object->layer_height_profile.size()) - most_layered_object = object; + if (*(object->layer_height_profile.end()-2) > *(tallest_object->layer_height_profile.end()-2) ) + tallest_object = object; for (PrintObject *object : this->objects) { SlicingParameters slicing_params = object->slicing_parameters(); @@ -622,17 +622,26 @@ std::string Print::validate() const object->update_layer_height_profile(); object->layer_height_profile_valid = was_layer_height_profile_valid; - if ( this->config.variable_layer_height ) { - int i = 0; - while ( i < object->layer_height_profile.size() ) { - if (std::abs(most_layered_object->layer_height_profile[i] - object->layer_height_profile[i]) > EPSILON) - return "The Wipe tower is only supported if all objects have the same layer height profile"; - ++i; - if (i == object->layer_height_profile.size()-2) // this element contains the objects max z, if the other object is taller, - // it does not have to match - we will step over it - if (most_layered_object->layer_height_profile[i] > object->layer_height_profile[i]) - ++i; + if ( this->config.variable_layer_height ) { // comparing layer height profiles + bool failed = false; + if (tallest_object->layer_height_profile.size() >= object->layer_height_profile.size() ) { + int i = 0; + while ( i < object->layer_height_profile.size() && i < tallest_object->layer_height_profile.size()) { + if (std::abs(tallest_object->layer_height_profile[i] - object->layer_height_profile[i])) { + failed = true; + break; + } + ++i; + if (i == object->layer_height_profile.size()-2) // this element contains this objects max z + if (tallest_object->layer_height_profile[i] > object->layer_height_profile[i]) // the difference does not matter in this case + ++i; + } } + else + failed = true; + + if (failed) + return "The Wipe tower is only supported if all objects have the same layer height profile"; } /*for (size_t i = 5; i < object->layer_height_profile.size(); i += 2) From a4df0bdcc3a2b29b6f45a08d9279185811e2898b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 26 Apr 2018 12:14:49 +0200 Subject: [PATCH 0265/1150] Fixed division by zero in get_zoom_to_bounding_box_factor on Linux --- lib/Slic3r/GUI/3DScene.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 88137185b7..190e960529 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -687,10 +687,7 @@ sub select_view { } sub get_zoom_to_bounding_box_factor { - my ($self, $bb) = @_; - - return undef if (! $self->init); - + my ($self, $bb) = @_; my $max_bb_size = max(@{ $bb->size }); return undef if ($max_bb_size == 0); @@ -763,6 +760,8 @@ sub get_zoom_to_bounding_box_factor { $max_y = max($max_y, $margin_factor * 2 * abs($y_on_plane)); } + return undef if (($max_x == 0) || ($max_y == 0)); + my ($cw, $ch) = $self->GetSizeWH; my $min_ratio = min($cw / $max_x, $ch / $max_y); From b3859c49c1346d89c7a7e3d3ca12add6e34cb51c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 26 Apr 2018 12:40:17 +0200 Subject: [PATCH 0266/1150] Updated description preset line for each type of presets... Disabled m_btn_delete_preset for default and system presets. Enabled update of the current preset if it was modified and selected again. --- xs/src/slic3r/GUI/GUI.cpp | 4 +-- xs/src/slic3r/GUI/OptionsGroup.cpp | 4 +-- xs/src/slic3r/GUI/OptionsGroup.hpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 55 +++++++++++++++++++++++++----- xs/src/slic3r/GUI/Tab.hpp | 1 + 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 06929085c8..210f296701 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -201,8 +201,8 @@ static void init_label_colours() { auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); if (luma >= 128) { - g_color_label_modified = wxColour(253, 88, 0); - g_color_label_sys = wxColour(26, 132, 57); + g_color_label_modified = wxColour(255, 108, 30);//wxColour(253, 88, 0); + g_color_label_sys = wxColour(19, 100, 44); //wxColour(26, 132, 57); } else { g_color_label_modified = wxColour(253, 111, 40); g_color_label_sys = wxColour(115, 220, 103); diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 1e78a600aa..7902fa1285 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -468,10 +468,10 @@ Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int op return opt_id.empty() ? nullptr : get_field(opt_id); } -void ogStaticText::SetText(const wxString& value) +void ogStaticText::SetText(const wxString& value, bool wrap/* = true*/) { SetLabel(value); - Wrap(400); + if (wrap) Wrap(400); GetParent()->Layout(); } diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 8d57420a36..f01ef671c0 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -203,7 +203,7 @@ public: ogStaticText(wxWindow* parent, const char *text) : wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize){} ~ogStaticText(){} - void SetText(const wxString& value); + void SetText(const wxString& value, bool wrap = true); }; }} diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 4b2ecab60a..0095092820 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -218,7 +218,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) //! select_preset(m_presets_choice->GetStringSelection().ToStdString()); //! we doing next: int selected_item = m_presets_choice->GetSelection(); - if (m_selected_preset_item == selected_item) + if (m_selected_preset_item == selected_item && !m_presets->current_is_dirty()) return; if (selected_item >= 0){ std::string selected_string = m_presets_choice->GetString(selected_item).ToUTF8().data(); @@ -670,13 +670,52 @@ void Tab::on_presets_changed() event.SetString(m_name); g_wxMainFrame->ProcessWindowEvent(event); } + update_preset_description_line(); +} +void Tab::update_preset_description_line() +{ const Preset* parent = m_presets->get_selected_preset_parent(); - const wxString description_line = parent == nullptr ? - _(L("It's default preset")) : parent == &m_presets->get_selected_preset() ? - _(L("It's system preset")) : - _(L("Current preset is inherited from")) + ":\n" + parent->name; - m_parent_preset_description_line->SetText(description_line); + const Preset& preset = m_presets->get_edited_preset(); + + wxString description_line = preset.is_default ? + _(L("It's a default preset.")) : preset.is_system ? + _(L("It's a system preset.")) : + _(L("Current preset is inherited from ")) + (parent == nullptr ? + "default preset." : + ":\n\t" + parent->name); + + if (preset.is_default || preset.is_system) + description_line += "\n\t" + _(L("It can't be deleted or modified. ")) + + "\n\t" + _(L("Any modifications should be saved as a new preset inherited from this one. ")) + + "\n\t" + _(L("To do that please specify a new name for the preset.")); + + if (parent && parent->vendor) + { + description_line += "\n\n" + _(L("Additional information:")) + "\n"; + description_line += "\t" + _(L("vendor")) + ": " + (name()=="printer" ? "\n\t\t" : "") + parent->vendor->name + + ", ver: " + parent->vendor->config_version.to_string(); + if (name() == "printer"){ + const std::string &printer_model = preset.config.opt_string("printer_model"); + const std::string &default_print_profile = preset.config.opt_string("default_print_profile"); + const std::vector &default_filament_profiles = preset.config.option("default_filament_profile")->values; + if (!printer_model.empty()) + description_line += "\n\n\t" + _(L("printer model")) + ": \n\t\t" + printer_model; + if (!default_print_profile.empty()) + description_line += "\n\n\t" + _(L("default print profile")) + ": \n\t\t" + default_print_profile; + if (!default_filament_profiles.empty()) + { + description_line += "\n\n\t" + _(L("default filament profile")) + ": \n\t\t"; + for (auto& profile : default_filament_profiles){ + if (&profile != &*default_filament_profiles.begin()) + description_line += ", "; + description_line += profile; + } + } + } + } + + m_parent_preset_description_line->SetText(description_line, false); } void Tab::update_frequently_changed_parameters() @@ -1337,7 +1376,7 @@ wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticTex (*StaticText)->SetFont(font); auto sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(*StaticText); + sizer->Add(*StaticText, 1, wxEXPAND|wxALL, 0); return sizer; } @@ -1802,7 +1841,7 @@ void Tab::load_current_preset() { auto preset = m_presets->get_edited_preset(); - preset.is_default ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true); + (preset.is_default || preset.is_system) ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true); update(); // For the printer profile, generate the extruder pages. on_preset_loaded(); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index de04fc4cd9..1ed5d1b368 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -265,6 +265,7 @@ public: protected: void on_presets_changed(); + void update_preset_description_line(); void update_frequently_changed_parameters(); void update_wiping_button_visibility(); void update_tab_presets(wxComboCtrl* ui, bool show_incompatible); From ad9dca2bd937e55282dff6ffbdf571f9f9811215 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 26 Apr 2018 13:03:54 +0200 Subject: [PATCH 0267/1150] Fixed update of ranges for GCode paths colors selection --- xs/src/libslic3r/GCode/Analyzer.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xs/src/libslic3r/GCode/Analyzer.cpp b/xs/src/libslic3r/GCode/Analyzer.cpp index 799bd6661e..b7ecee5a4c 100644 --- a/xs/src/libslic3r/GCode/Analyzer.cpp +++ b/xs/src/libslic3r/GCode/Analyzer.cpp @@ -718,10 +718,10 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ Helper::store_polyline(polyline, data, z, preview_data); // updates preview ranges data - preview_data.ranges.height.set_from(height_range); - preview_data.ranges.width.set_from(width_range); - preview_data.ranges.feedrate.set_from(feedrate_range); - preview_data.ranges.volumetric_rate.set_from(volumetric_rate_range); + preview_data.ranges.height.update_from(height_range); + preview_data.ranges.width.update_from(width_range); + preview_data.ranges.feedrate.update_from(feedrate_range); + preview_data.ranges.volumetric_rate.update_from(volumetric_rate_range); } void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data) @@ -790,9 +790,9 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data) Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, preview_data); // updates preview ranges data - preview_data.ranges.height.set_from(height_range); - preview_data.ranges.width.set_from(width_range); - preview_data.ranges.feedrate.set_from(feedrate_range); + preview_data.ranges.height.update_from(height_range); + preview_data.ranges.width.update_from(width_range); + preview_data.ranges.feedrate.update_from(feedrate_range); } void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_data) From a2236559733c954fb61714b412db286891084782 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 26 Apr 2018 13:40:29 +0200 Subject: [PATCH 0268/1150] Inverted order of range items in legend texture --- xs/src/libslic3r/GCode/PreviewData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/GCode/PreviewData.cpp b/xs/src/libslic3r/GCode/PreviewData.cpp index 69fd3524da..c66de08edb 100644 --- a/xs/src/libslic3r/GCode/PreviewData.cpp +++ b/xs/src/libslic3r/GCode/PreviewData.cpp @@ -370,7 +370,7 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: list.reserve(Range::Colors_Count); float step = range.step_size(); - for (unsigned int i = 0; i < Range::Colors_Count; ++i) + for (int i = Range::Colors_Count - 1; i >= 0; --i) { char buf[1024]; sprintf(buf, "%.*f/%.*f", decimals, scale_factor * (range.min + (float)i * step), decimals, scale_factor * (range.min + (float)(i + 1) * step)); From 9548593b575689b6fbd6d670ce2b5509e3c51f19 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 26 Apr 2018 15:11:02 +0200 Subject: [PATCH 0269/1150] Forbid tabstop on resert buttons --- xs/src/slic3r/GUI/Field.cpp | 4 ++-- xs/src/slic3r/GUI/Field.hpp | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index d0a2ccec21..5a3b011d40 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -24,8 +24,8 @@ namespace Slic3r { namespace GUI { #ifdef __WXGTK__ sz = 28; #endif // __WXGTK__ - m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); - m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); + m_Undo_btn = new MyButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); + m_Undo_to_sys_btn = new MyButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); if (wxMSW) { m_Undo_btn->SetBackgroundColour(color); m_Undo_to_sys_btn->SetBackgroundColour(color); diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index c7eb25c754..1856d94cf0 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -36,6 +36,24 @@ using t_back_to_init = std::function; wxString double_to_string(double const value); +class MyButton : public wxButton +{ +public: + MyButton() {} + MyButton(wxWindow* parent, wxWindowID id, const wxString& label = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxTextCtrlNameStr) + { + this->Create(parent, id, label, pos, size, style, validator, name); + } + + // overridden from wxWindow base class + virtual bool + AcceptsFocusFromKeyboard() const { return false; } +}; + class Field { protected: // factory function to defer and enforce creation of derived type. @@ -165,11 +183,11 @@ public: } protected: - wxButton* m_Undo_btn = nullptr; + MyButton* m_Undo_btn = nullptr; // Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. const wxBitmap* m_undo_bitmap = nullptr; const wxString* m_undo_tooltip = nullptr; - wxButton* m_Undo_to_sys_btn = nullptr; + MyButton* m_Undo_to_sys_btn = nullptr; // Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. const wxBitmap* m_undo_to_sys_bitmap = nullptr; const wxString* m_undo_to_sys_tooltip = nullptr; From 6467513f60c4a5a946a1c985e5981ebbd058e26f Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 26 Apr 2018 16:33:37 +0200 Subject: [PATCH 0270/1150] Set default bitmap (white_bullet) when creating Field's reset buttons --- xs/src/slic3r/GUI/Field.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 5a3b011d40..5cae9172ef 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -20,12 +20,8 @@ namespace Slic3r { namespace GUI { void Field::PostInitialize(){ auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - auto sz = 16; - #ifdef __WXGTK__ - sz = 28; - #endif // __WXGTK__ - m_Undo_btn = new MyButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); - m_Undo_to_sys_btn = new MyButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(sz,sz), wxNO_BORDER); + m_Undo_btn = new MyButton(m_parent, wxID_ANY, "", wxDefaultPosition,wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + m_Undo_to_sys_btn = new MyButton(m_parent, wxID_ANY, "", wxDefaultPosition,wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); if (wxMSW) { m_Undo_btn->SetBackgroundColour(color); m_Undo_to_sys_btn->SetBackgroundColour(color); @@ -33,6 +29,12 @@ namespace Slic3r { namespace GUI { m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); + //set default bitmap + wxBitmap bmp; + bmp.LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG); + set_undo_bitmap(&bmp); + set_undo_to_sys_bitmap(&bmp); + BUILD(); } From 19f8e0bc63ba9689f9988aaae426a6feaefc3a4e Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 26 Apr 2018 17:46:24 +0200 Subject: [PATCH 0271/1150] Changed background color in AboutDialog from wxWHITE to wxSYS_COLOUR_WINDOW, AboutDialogLogo is replaced to wxStaticBitmap. --- xs/src/slic3r/GUI/AboutDialog.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xs/src/slic3r/GUI/AboutDialog.cpp b/xs/src/slic3r/GUI/AboutDialog.cpp index 664bbd1bbd..3c359fd66a 100644 --- a/xs/src/slic3r/GUI/AboutDialog.cpp +++ b/xs/src/slic3r/GUI/AboutDialog.cpp @@ -31,13 +31,14 @@ void AboutDialogLogo::onRepaint(wxEvent &event) AboutDialog::AboutDialog() : wxDialog(NULL, wxID_ANY, _(L("About Slic3r")), wxDefaultPosition, wxSize(600, 340), wxCAPTION) { - this->SetBackgroundColour(*wxWHITE); - + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)/**wxWHITE*/); wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL); this->SetSizer(hsizer); // logo - AboutDialogLogo* logo = new AboutDialogLogo(this); +// AboutDialogLogo* logo = new AboutDialogLogo(this); + wxBitmap logo_bmp = wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG); + auto *logo = new wxStaticBitmap(this, wxID_ANY, std::move(logo_bmp)); hsizer->Add(logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 30); wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); @@ -78,6 +79,7 @@ AboutDialog::AboutDialog() int size[] = {11,11,11,11,11,11,11}; #endif html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); + html->SetHTMLBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); html->SetBorders(2); const char* text = "" @@ -106,7 +108,6 @@ AboutDialog::AboutDialog() this->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this); logo->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this); - html->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this); } void AboutDialog::onLinkClicked(wxHtmlLinkEvent &event) From 25d47c1da8bac02d5b1408d9a39ba7356b14fc56 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 26 Apr 2018 18:56:16 +0200 Subject: [PATCH 0272/1150] Fix of the new cooling logic. --- xs/src/libslic3r/GCode/CoolingBuffer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index 141d197ca6..b786f9bce5 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -50,7 +50,7 @@ struct CoolingLine CoolingLine(unsigned int type, size_t line_start, size_t line_end) : type(type), line_start(line_start), line_end(line_end), - length(0.f), time(0.f), time_max(0.f), slowdown(false) {} + length(0.f), feedrate(0.f), time(0.f), time_max(0.f), slowdown(false) {} bool adjustable(bool slowdown_external_perimeters) const { return (this->type & TYPE_ADJUSTABLE) && @@ -158,9 +158,9 @@ struct PerExtruderAdjustments bool adj2 = l2.adjustable(); return (adj1 == adj2) ? l1.feedrate > l2.feedrate : adj1; }); - for (n_lines_adjustable = 0; n_lines_adjustable < lines.size(); ++ n_lines_adjustable) - if ((this->lines[n_lines_adjustable].type & CoolingLine::TYPE_ADJUSTABLE) == 0) - break; + for (n_lines_adjustable = 0; + n_lines_adjustable < lines.size() && this->lines[n_lines_adjustable].adjustable(); + ++ n_lines_adjustable); time_non_adjustable = 0.f; for (size_t i = n_lines_adjustable; i < lines.size(); ++ i) time_non_adjustable += lines[i].time; @@ -329,10 +329,10 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: // Movement in the extruder axis. line.length = std::abs(dif[3]); } - if (line.length > 0) { - line.feedrate = new_pos[4]; // current F - line.time = line.length / line.feedrate; - } + line.feedrate = new_pos[4]; + assert((line.type & CoolingLine::TYPE_ADJUSTABLE) == 0 || line.feedrate > 0.f); + if (line.length > 0) + line.time = line.length / line.feedrate; line.time_max = line.time; if ((line.type & CoolingLine::TYPE_ADJUSTABLE) || active_speed_modifier != size_t(-1)) line.time_max = (adjustment->min_print_speed == 0.f) ? FLT_MAX : std::max(line.time, line.length / adjustment->min_print_speed); @@ -340,6 +340,7 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: // Inside the ";_EXTRUDE_SET_SPEED" blocks, there must not be a G1 Fxx entry. assert((line.type & CoolingLine::TYPE_HAS_F) == 0); CoolingLine &sm = adjustment->lines[active_speed_modifier]; + assert(sm.feedrate > 0.f); sm.length += line.length; sm.time += line.time; if (sm.time_max != FLT_MAX) { From 4811abfa99a6286c2dbedc41bc7801fffd21af7f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 27 Apr 2018 09:54:21 +0200 Subject: [PATCH 0273/1150] Apply gradient to colors in GCode Preview --- xs/src/libslic3r/GCode/PreviewData.cpp | 40 +++++++++++++++++--------- xs/src/libslic3r/GCode/PreviewData.hpp | 11 ++++--- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/xs/src/libslic3r/GCode/PreviewData.cpp b/xs/src/libslic3r/GCode/PreviewData.cpp index c66de08edb..d431708c1b 100644 --- a/xs/src/libslic3r/GCode/PreviewData.cpp +++ b/xs/src/libslic3r/GCode/PreviewData.cpp @@ -99,17 +99,31 @@ void GCodePreviewData::Range::set_from(const Range& other) float GCodePreviewData::Range::step_size() const { - return (max - min) / (float)Colors_Count; + return (max - min) / (float)(Colors_Count - 1); } -const GCodePreviewData::Color& GCodePreviewData::Range::get_color_at_max() const +GCodePreviewData::Color GCodePreviewData::Range::get_color_at(float value) const { - return colors[Colors_Count - 1]; -} + if (empty()) + return Color::Dummy; -const GCodePreviewData::Color& GCodePreviewData::Range::get_color_at(float value) const -{ - return empty() ? get_color_at_max() : colors[clamp((unsigned int)0, Colors_Count - 1, (unsigned int)((value - min) / step_size()))]; + float global_t = (value - min) / step_size(); + + unsigned int low = (unsigned int)global_t; + unsigned int high = clamp((unsigned int)0, Colors_Count - 1, low + 1); + + Color color_low = colors[low]; + Color color_high = colors[high]; + + float local_t = global_t - (float)low; + + // interpolate in RGB space + Color ret; + for (unsigned int i = 0; i < 4; ++i) + { + ret.rgba[i] = lerp(color_low.rgba[i], color_high.rgba[i], local_t); + } + return ret; } GCodePreviewData::LegendItem::LegendItem(const std::string& text, const GCodePreviewData::Color& color) @@ -266,22 +280,22 @@ const GCodePreviewData::Color& GCodePreviewData::get_extrusion_role_color(Extrus return extrusion.role_colors[role]; } -const GCodePreviewData::Color& GCodePreviewData::get_height_color(float height) const +GCodePreviewData::Color GCodePreviewData::get_height_color(float height) const { return ranges.height.get_color_at(height); } -const GCodePreviewData::Color& GCodePreviewData::get_width_color(float width) const +GCodePreviewData::Color GCodePreviewData::get_width_color(float width) const { return ranges.width.get_color_at(width); } -const GCodePreviewData::Color& GCodePreviewData::get_feedrate_color(float feedrate) const +GCodePreviewData::Color GCodePreviewData::get_feedrate_color(float feedrate) const { return ranges.feedrate.get_color_at(feedrate); } -const GCodePreviewData::Color& GCodePreviewData::get_volumetric_rate_color(float rate) const +GCodePreviewData::Color GCodePreviewData::get_volumetric_rate_color(float rate) const { return ranges.volumetric_rate.get_color_at(rate); } @@ -373,7 +387,7 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: for (int i = Range::Colors_Count - 1; i >= 0; --i) { char buf[1024]; - sprintf(buf, "%.*f/%.*f", decimals, scale_factor * (range.min + (float)i * step), decimals, scale_factor * (range.min + (float)(i + 1) * step)); + sprintf(buf, "%.*f", decimals, scale_factor * (range.min + (float)i * step)); list.emplace_back(buf, range.colors[i]); } } @@ -408,7 +422,7 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: } case Extrusion::Feedrate: { - Helper::FillListFromRange(items, ranges.feedrate, 0, 1.0f); + Helper::FillListFromRange(items, ranges.feedrate, 1, 1.0f); break; } case Extrusion::VolumetricRate: diff --git a/xs/src/libslic3r/GCode/PreviewData.hpp b/xs/src/libslic3r/GCode/PreviewData.hpp index e9c5f75154..a7d77e0b93 100644 --- a/xs/src/libslic3r/GCode/PreviewData.hpp +++ b/xs/src/libslic3r/GCode/PreviewData.hpp @@ -41,8 +41,7 @@ public: void set_from(const Range& other); float step_size() const; - const Color& get_color_at(float value) const; - const Color& get_color_at_max() const; + Color get_color_at(float value) const; }; struct Ranges @@ -189,10 +188,10 @@ public: bool empty() const; const Color& get_extrusion_role_color(ExtrusionRole role) const; - const Color& get_height_color(float height) const; - const Color& get_width_color(float width) const; - const Color& get_feedrate_color(float feedrate) const; - const Color& get_volumetric_rate_color(float rate) const; + Color get_height_color(float height) const; + Color get_width_color(float width) const; + Color get_feedrate_color(float feedrate) const; + Color get_volumetric_rate_color(float rate) const; void set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha); void set_extrusion_paths_colors(const std::vector& colors); From 6d38943222d45415316e102c14119c837bef499c Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 27 Apr 2018 12:29:18 +0200 Subject: [PATCH 0274/1150] Fix & refactor legacy datadir dialog --- xs/src/slic3r/GUI/GUI.cpp | 21 +++---------------- xs/src/slic3r/GUI/UpdateDialogs.cpp | 32 +++++++++++++++++++++++++++++ xs/src/slic3r/GUI/UpdateDialogs.hpp | 12 +++++++++++ 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 42a9310333..6bac39bd7a 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -53,6 +53,7 @@ #include "ConfigWizard.hpp" #include "Preferences.hpp" #include "PresetBundle.hpp" +#include "UpdateDialogs.hpp" #include "../Utils/PresetUpdater.hpp" #include "../Config/Snapshot.hpp" @@ -480,24 +481,8 @@ bool config_wizard_startup(bool app_config_exists) // Looks like user has legacy pre-vendorbundle data directory, // explain what this is and run the wizard - const auto msg = _(L("Configuration update")); - const auto ext_msg = wxString::Format( - _(L( - "Slic3r PE now uses an updated configuration structure.\n\n" - - "So called 'System presets' have been introduced, which hold the built-in default settings for various " - "printers. These System presets cannot be modified, instead, users now may create their" - "own presets inheriting settings from one of the System presets.\n" - "An inheriting preset may either inherit a particular value from its parent or override it with a customized value.\n\n" - - "Please proceed with the %s that follows to set up the new presets " - "and to choose whether to enable automatic preset updates." - )), - ConfigWizard::name() - ); - wxMessageDialog dlg(NULL, msg, _(L("Configuration update")), wxOK|wxCENTRE); - dlg.SetExtendedMessage(ext_msg); - const auto res = dlg.ShowModal(); + MsgDataLegacy dlg; + dlg.ShowModal(); config_wizard(ConfigWizard::RR_DATA_LEGACY); return true; diff --git a/xs/src/slic3r/GUI/UpdateDialogs.cpp b/xs/src/slic3r/GUI/UpdateDialogs.cpp index e11ecdf5e4..62534e5981 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.cpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.cpp @@ -12,6 +12,7 @@ #include "libslic3r/libslic3r.h" #include "libslic3r/Utils.hpp" #include "GUI.hpp" +#include "ConfigWizard.hpp" namespace Slic3r { namespace GUI { @@ -201,5 +202,36 @@ MsgDataIncompatible::MsgDataIncompatible(const std::unordered_mapWrap(CONTENT_WIDTH); + content_sizer->Add(text); + content_sizer->AddSpacer(VERT_SPACING); + + // TODO: Add link to wiki? + + Fit(); +} + +MsgDataLegacy::~MsgDataLegacy() {} + + } } diff --git a/xs/src/slic3r/GUI/UpdateDialogs.hpp b/xs/src/slic3r/GUI/UpdateDialogs.hpp index f12fd3333a..e339fbe0d3 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.hpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.hpp @@ -85,6 +85,18 @@ public: ~MsgDataIncompatible(); }; +// Informs about a legacy data directory - an update from Slic3r PE < 1.40 +class MsgDataLegacy : public MsgDialog +{ +public: + MsgDataLegacy(); + MsgDataLegacy(MsgDataLegacy &&) = delete; + MsgDataLegacy(const MsgDataLegacy &) = delete; + MsgDataLegacy &operator=(MsgDataLegacy &&) = delete; + MsgDataLegacy &operator=(const MsgDataLegacy &) = delete; + ~MsgDataLegacy(); +}; + } } From ad54210c3ee75f148bd98d1f8f773a3986dff008 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 27 Apr 2018 12:56:35 +0200 Subject: [PATCH 0275/1150] 3mf I/O - Added import/export of layer heights profile --- xs/src/libslic3r/Format/3mf.cpp | 166 ++++++++++++++++++++++++++++---- 1 file changed, 146 insertions(+), 20 deletions(-) diff --git a/xs/src/libslic3r/Format/3mf.cpp b/xs/src/libslic3r/Format/3mf.cpp index 7b5bf7e8a6..dde64a28f6 100644 --- a/xs/src/libslic3r/Format/3mf.cpp +++ b/xs/src/libslic3r/Format/3mf.cpp @@ -23,6 +23,7 @@ const std::string CONTENT_TYPES_FILE = "[Content_Types].xml"; const std::string RELATIONSHIPS_FILE = "_rels/.rels"; const std::string PRINT_CONFIG_FILE = "Metadata/Slic3r_PE.config"; const std::string MODEL_CONFIG_FILE = "Metadata/Slic3r_PE_model.config"; +const std::string LAYER_HEIGHTS_PROFILE_FILE = "Metadata/Slic3r_PE_layer_heights_profile.txt"; const char* MODEL_TAG = "model"; const char* RESOURCES_TAG = "resources"; @@ -315,6 +316,7 @@ namespace Slic3r { typedef std::vector InstancesList; typedef std::map IdToMetadataMap; typedef std::map IdToGeometryMap; + typedef std::map> IdToLayerHeightsProfileMap; XML_Parser m_xml_parser; Model* m_model; @@ -326,6 +328,7 @@ namespace Slic3r { IdToGeometryMap m_geometries; CurrentConfig m_curr_config; IdToMetadataMap m_objects_metadata; + IdToLayerHeightsProfileMap m_layer_heights_profiles; public: _3MF_Importer(); @@ -339,7 +342,8 @@ namespace Slic3r { bool _load_model_from_file(const std::string& filename, Model& model, PresetBundle& bundle); bool _extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat); - bool _extract_print_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, PresetBundle& bundle, const std::string& archive_filename); + void _extract_layer_heights_profile_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat); + void _extract_print_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, PresetBundle& bundle, const std::string& archive_filename); bool _extract_model_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, Model& model); // handlers to parse the .model file @@ -437,6 +441,7 @@ namespace Slic3r { m_curr_config.object_id = -1; m_curr_config.volume_id = -1; m_objects_metadata.clear(); + m_layer_heights_profiles.clear(); clear_errors(); return _load_model_from_file(filename, model, bundle); @@ -489,15 +494,15 @@ namespace Slic3r { return false; } } + else if (boost::algorithm::iequals(name, LAYER_HEIGHTS_PROFILE_FILE)) + { + // extract slic3r lazer heights profile file + _extract_layer_heights_profile_config_from_archive(archive, stat); + } else if (boost::algorithm::iequals(name, PRINT_CONFIG_FILE)) { // extract slic3r print config file - if (!_extract_print_config_from_archive(archive, stat, bundle, filename)) - { - mz_zip_reader_end(&archive); - add_error("Archive does not contain a valid print config"); - return false; - } + _extract_print_config_from_archive(archive, stat, bundle, filename); } else if (boost::algorithm::iequals(name, MODEL_CONFIG_FILE)) { @@ -526,6 +531,13 @@ namespace Slic3r { return false; } + IdToLayerHeightsProfileMap::iterator obj_layer_heights_profile = m_layer_heights_profiles.find(object.first); + if (obj_layer_heights_profile != m_layer_heights_profiles.end()) + { + object.second->layer_height_profile = obj_layer_heights_profile->second; + object.second->layer_height_profile_valid = true; + } + IdToMetadataMap::iterator obj_metadata = m_objects_metadata.find(object.first); if (obj_metadata != m_objects_metadata.end()) { @@ -609,23 +621,90 @@ namespace Slic3r { return true; } - bool _3MF_Importer::_extract_print_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, PresetBundle& bundle, const std::string& archive_filename) + void _3MF_Importer::_extract_print_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, PresetBundle& bundle, const std::string& archive_filename) { if (stat.m_uncomp_size > 0) { - std::vector buffer((size_t)stat.m_uncomp_size + 1, 0); + std::string buffer((size_t)stat.m_uncomp_size, 0); mz_bool res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, (void*)buffer.data(), (size_t)stat.m_uncomp_size, 0); if (res == 0) { add_error("Error while reading config data to buffer"); - return false; + return; } - - buffer.back() = '\0'; bundle.load_config_string(buffer.data(), archive_filename.c_str()); } + } - return true; + void _3MF_Importer::_extract_layer_heights_profile_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat) + { + if (stat.m_uncomp_size > 0) + { + std::string buffer((size_t)stat.m_uncomp_size, 0); + mz_bool res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, (void*)buffer.data(), (size_t)stat.m_uncomp_size, 0); + if (res == 0) + { + add_error("Error while reading layer heights profile data to buffer"); + return; + } + + if (buffer.back() == '\n') + buffer.pop_back(); + + std::vector objects; + boost::split(objects, buffer, boost::is_any_of("\n"), boost::token_compress_off); + + for (const std::string& object : objects) + { + std::vector object_data; + boost::split(object_data, object, boost::is_any_of("|"), boost::token_compress_off); + if (object_data.size() != 2) + { + add_error("Error while reading object data"); + continue; + } + + std::vector object_data_id; + boost::split(object_data_id, object_data[0], boost::is_any_of("="), boost::token_compress_off); + if (object_data_id.size() != 2) + { + add_error("Error while reading object id"); + continue; + } + + int object_id = std::atoi(object_data_id[1].c_str()); + if (object_id == 0) + { + add_error("Found invalid object id"); + continue; + } + + IdToLayerHeightsProfileMap::iterator object_item = m_layer_heights_profiles.find(object_id); + if (object_item != m_layer_heights_profiles.end()) + { + add_error("Found duplicated layer heights profile"); + continue; + } + + std::vector object_data_profile; + boost::split(object_data_profile, object_data[1], boost::is_any_of(";"), boost::token_compress_off); + if ((object_data_profile.size() <= 4) || (object_data_profile.size() % 2 != 0)) + { + add_error("Found invalid layer heights profile"); + continue; + } + + std::vector profile; + profile.reserve(object_data_profile.size()); + + for (const std::string& value : object_data_profile) + { + profile.push_back((coordf_t)std::atof(value.c_str())); + } + + m_layer_heights_profiles.insert(IdToLayerHeightsProfileMap::value_type(object_id, profile)); + } + } } bool _3MF_Importer::_extract_model_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, Model& model) @@ -1429,6 +1508,7 @@ namespace Slic3r { bool _add_object_to_model_stream(std::stringstream& stream, unsigned int& object_id, ModelObject& object, BuildItemsList& build_items, VolumeToOffsetsMap& volumes_offsets); bool _add_mesh_to_object_stream(std::stringstream& stream, ModelObject& object, VolumeToOffsetsMap& volumes_offsets); bool _add_build_to_model_stream(std::stringstream& stream, const BuildItemsList& build_items); + bool _add_layer_height_profile_file_to_archive(mz_zip_archive& archive, Model& model); bool _add_print_config_file_to_archive(mz_zip_archive& archive, const Print& print); bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model); }; @@ -1477,6 +1557,14 @@ namespace Slic3r { return false; } + // adds layer height profile file + if (!_add_layer_height_profile_file_to_archive(archive, model)) + { + mz_zip_writer_end(&archive); + boost::filesystem::remove(filename); + return false; + } + // adds slic3r print config file if (export_print_config) { @@ -1736,6 +1824,44 @@ namespace Slic3r { return true; } + bool _3MF_Exporter::_add_layer_height_profile_file_to_archive(mz_zip_archive& archive, Model& model) + { + std::string out = ""; + char buffer[1024]; + + unsigned int count = 0; + for (const ModelObject* object : model.objects) + { + ++count; + std::vector layer_height_profile = object->layer_height_profile_valid ? object->layer_height_profile : std::vector(); + if ((layer_height_profile.size() >= 4) && ((layer_height_profile.size() % 2) == 0)) + { + sprintf(buffer, "object_id=%d|", count); + out += buffer; + + // Store the layer height profile as a single semicolon separated list. + for (size_t i = 0; i < layer_height_profile.size(); ++i) + { + sprintf(buffer, (i == 0) ? "%f" : ";%f", layer_height_profile[i]); + out += buffer; + } + + out += "\n"; + } + } + + if (!out.empty()) + { + if (!mz_zip_writer_add_mem(&archive, LAYER_HEIGHTS_PROFILE_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION)) + { + add_error("Unable to add layer heights profile file to archive"); + return false; + } + } + + return true; + } + bool _3MF_Exporter::_add_print_config_file_to_archive(mz_zip_archive& archive, const Print& print) { char buffer[1024]; @@ -1744,10 +1870,13 @@ namespace Slic3r { GCode::append_full_config(print, out); - if (!mz_zip_writer_add_mem(&archive, PRINT_CONFIG_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION)) + if (!out.empty()) { - add_error("Unable to add print config file to archive"); - return false; + if (!mz_zip_writer_add_mem(&archive, PRINT_CONFIG_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION)) + { + add_error("Unable to add print config file to archive"); + return false; + } } return true; @@ -1832,10 +1961,7 @@ namespace Slic3r { _3MF_Importer importer; bool res = importer.load_model_from_file(path, *model, *bundle); - - if (!res) - importer.log_errors(); - + importer.log_errors(); return res; } From b67064ef81334eec4769d35da4285af97b2fe07a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 27 Apr 2018 14:08:22 +0200 Subject: [PATCH 0276/1150] Keyboard capture by 3D view on Linux --- lib/Slic3r/GUI/3DScene.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 190e960529..17fcd46242 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -389,7 +389,7 @@ sub mouse_event { $self->_mouse_dragging($e->Dragging); - if ($e->Entering && &Wx::wxMSW) { + if ($e->Entering && (&Wx::wxMSW || $^O eq 'linux')) { # wxMSW needs focus in order to catch mouse wheel events $self->SetFocus; $self->_drag_start_xy(undef); From 285ded8bbbb2be86d1be57cff948f56597672aa6 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 27 Apr 2018 15:19:07 +0200 Subject: [PATCH 0277/1150] Add documentation for system profiles, snapshots & updating --- doc/updating/Updatig.md | 52 ++++++++++++++++++++++++++++++ doc/updating/setting_mod.png | Bin 0 -> 4050 bytes doc/updating/setting_sys.png | Bin 0 -> 3863 bytes doc/updating/setting_user.png | Bin 0 -> 3957 bytes doc/updating/snapshots_dialog.png | Bin 0 -> 78805 bytes 5 files changed, 52 insertions(+) create mode 100644 doc/updating/Updatig.md create mode 100644 doc/updating/setting_mod.png create mode 100644 doc/updating/setting_sys.png create mode 100644 doc/updating/setting_user.png create mode 100644 doc/updating/snapshots_dialog.png diff --git a/doc/updating/Updatig.md b/doc/updating/Updatig.md new file mode 100644 index 0000000000..3ce1f109c4 --- /dev/null +++ b/doc/updating/Updatig.md @@ -0,0 +1,52 @@ +# Slic3r PE 1.40 configuration update + +Slic3r PE 1.40.0 comes with a major re-work of the way configuration presets work. +There are three new features: + ++ A two-tier system of presets being divided into _System_ and _User_ groups ++ Configuration snapshots ++ Configuration updating from the internet + +## System and User presets + +- _System preset_: These are the presets that come with Slic3r PE installation. They come from a vendor configuration bundle (not individual files like before). They are **read-only** – a user cannot modify them, but may instead create a derived User preset based on a System preset +- _User preset_: These are regular presets stored in files just like before. Additionally, they may be derived (inherited) from one of the System presets + +A derived User preset keeps track of wich settings are inherited from the parent System preset and which are modified by the user. When a system preset is updated (either via installation of a new Slic3r or automatically from the internet), in a User preset the settings that are modified by the user will stay that way, while the ones that are inherited reflect the updated System preset. + +This system ensures that we don't overwrite user's settings when there is an update to the built in presets. + +Slic3r GUI now displays accurately which settings are inherited and which are modified. +A setting derived from a System preset is represeted by green label and a locked lock icon: + +![a system setting](setting_sys.png) + +A settings modified in a User preset has an open lock icon: + +![a user setting](setting_user.png) + +Clickign the open lock icon restored the system setting. + +Additionaly, any setting that is modified but not yet saved onto disk is represented by orange label and a back-arrow: + +![a modified setting](setting_mod.png) + +Clicking the back-arrow restores the value that was previously saved in this Preset. + +## Configuration snapshots + +Configuration snapshots can now be taken via the _Configuration_ menu. +A snapshot contains complete configuration from the point when the snapshot was taken. +Users may move back and forth between snapshots at will using a dialog: + +![snapshots dialog](snapshots_dialog.png) + + +# Updating from the internet + +Slic3r PE 1.40.0 checks for updates of the built-in System presets and downloads them. +The first-time configuration assistant will ask you if you want to enable this feature - it is **not** mandatory. + +Updates are checked for and downloaded in the background. If there's is an update, Slic3r will prompt about it +next time it is launched, never during normal program operation. An update may be either accepted or refused. +Before any update is applied a configuration snapshot (as described above) is taken. diff --git a/doc/updating/setting_mod.png b/doc/updating/setting_mod.png new file mode 100644 index 0000000000000000000000000000000000000000..e4d3b7e7bd40138e235882b131e1a9b1b7f46c97 GIT binary patch literal 4050 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 HeI5QkK~k^x literal 0 HcmV?d00001 diff --git a/doc/updating/snapshots_dialog.png b/doc/updating/snapshots_dialog.png new file mode 100644 index 0000000000000000000000000000000000000000..d4d28955057976f1310021e79600df0ed4681bb6 GIT binary patch literal 78805 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

O)rlq3Rya0u8?v7`@x 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 F{ul1$0T2KH literal 0 HcmV?d00001 From 879d22c7ca1e74b22aefaec82d1435a1e6acc525 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 27 Apr 2018 15:39:00 +0200 Subject: [PATCH 0278/1150] Added Freeze/Thaw and BusyCursor to selection_changed in object list (on Plater), It fixes visible rendering on MSW --- lib/Slic3r/GUI/Plater.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 869207b4da..4a013bf2d9 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1805,22 +1805,26 @@ sub on_config_change { sub list_item_deselected { my ($self, $event) = @_; return if $PreventListEvents; + $self->{_lecursor} = Wx::BusyCursor->new(); if ($self->{list}->GetFirstSelected == -1) { $self->select_object(undef); $self->{canvas}->Refresh; #FIXME VBOs are being refreshed just to change a selection color? $self->{canvas3D}->reload_scene if $self->{canvas3D}; } + undef $self->{_lecursor}; } sub list_item_selected { my ($self, $event) = @_; return if $PreventListEvents; + $self->{_lecursor} = Wx::BusyCursor->new(); my $obj_idx = $event->GetIndex; $self->select_object($obj_idx); $self->{canvas}->Refresh; #FIXME VBOs are being refreshed just to change a selection color? $self->{canvas3D}->reload_scene if $self->{canvas3D}; + undef $self->{_lecursor}; } sub list_item_activated { @@ -1954,7 +1958,8 @@ sub selection_changed { my ($self) = @_; my ($obj_idx, $object) = $self->selected_object; my $have_sel = defined $obj_idx; - + + $self->Freeze; if ($self->{htoolbar}) { # On OSX or Linux $self->{htoolbar}->EnableTool($_, $have_sel) @@ -2005,6 +2010,7 @@ sub selection_changed { # prepagate the event to the frame (a custom Wx event would be cleaner) $self->GetFrame->on_plater_selection_changed($have_sel); + $self->Thaw; } sub select_object { From bb4c4d9ecfa83e639fa3fa85946910a8190b8b67 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 27 Apr 2018 15:44:32 +0200 Subject: [PATCH 0279/1150] Legacy data update dialog: Add link to wiki --- xs/src/slic3r/GUI/UpdateDialogs.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/UpdateDialogs.cpp b/xs/src/slic3r/GUI/UpdateDialogs.cpp index 62534e5981..da212cf136 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.cpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.cpp @@ -18,6 +18,8 @@ namespace Slic3r { namespace GUI { +static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/prusa3d/Slic3r/wiki/Slic3r-PE-1.40-configuration-update"); + enum { CONTENT_WIDTH = 400, BORDER = 30, @@ -225,7 +227,13 @@ MsgDataLegacy::MsgDataLegacy() : content_sizer->Add(text); content_sizer->AddSpacer(VERT_SPACING); - // TODO: Add link to wiki? + auto *text2 = new wxStaticText(this, wxID_ANY, _(L("For more information please visit our wiki page:"))); + static const wxString url("https://github.com/prusa3d/Slic3r/wiki/Slic3r-PE-1.40-configuration-update"); + // The wiki page name is intentionally not localized: + auto *link = new wxHyperlinkCtrl(this, wxID_ANY, "Slic3r PE 1.40 configuration update", CONFIG_UPDATE_WIKI_URL); + content_sizer->Add(text2); + content_sizer->Add(link); + content_sizer->AddSpacer(VERT_SPACING); Fit(); } From a208639ce7fea9463b981a35851c676a56b9a2b9 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 30 Apr 2018 08:57:41 +0200 Subject: [PATCH 0280/1150] Fixed initial view on Linux Ubuntu --- lib/Slic3r/GUI/3DScene.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 17fcd46242..352a612643 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1152,6 +1152,8 @@ sub InitGL { $self->volumes->finalize_geometry(1) if ($^O eq 'linux' && $self->UseVBOs); + $self->zoom_to_bed; + glClearColor(0, 0, 0, 1); glColor3f(1, 0, 0); glEnable(GL_DEPTH_TEST); From 43d2027b767c59cba2fe7b935e5d40488145bab6 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 30 Apr 2018 11:11:48 +0200 Subject: [PATCH 0281/1150] ToolTips are showing on GTK --- xs/src/slic3r/GUI/OptionsGroup.cpp | 16 ++++++++-------- xs/src/slic3r/GUI/OptionsGroup.hpp | 24 ++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 7902fa1285..09a2fe50f6 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -22,13 +22,13 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co // is the normal type. if (opt.gui_type.compare("select") == 0) { } else if (opt.gui_type.compare("select_open") == 0) { - m_fields.emplace(id, STDMOVE(Choice::Create(m_parent, opt, id))); + m_fields.emplace(id, STDMOVE(Choice::Create(parent(), opt, id))); } else if (opt.gui_type.compare("color") == 0) { - m_fields.emplace(id, STDMOVE(ColourPicker::Create(m_parent, opt, id))); + m_fields.emplace(id, STDMOVE(ColourPicker::Create(parent(), opt, id))); } else if (opt.gui_type.compare("f_enum_open") == 0 || opt.gui_type.compare("i_enum_open") == 0 || opt.gui_type.compare("i_enum_closed") == 0) { - m_fields.emplace(id, STDMOVE(Choice::Create(m_parent, opt, id))); + m_fields.emplace(id, STDMOVE(Choice::Create(parent(), opt, id))); } else if (opt.gui_type.compare("slider") == 0) { } else if (opt.gui_type.compare("i_spin") == 0) { // Spinctrl } else { @@ -40,21 +40,21 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co case coPercents: case coString: case coStrings: - m_fields.emplace(id, STDMOVE(TextCtrl::Create(m_parent, opt, id))); + m_fields.emplace(id, STDMOVE(TextCtrl::Create(parent(), opt, id))); break; case coBool: case coBools: - m_fields.emplace(id, STDMOVE(CheckBox::Create(m_parent, opt, id))); + m_fields.emplace(id, STDMOVE(CheckBox::Create(parent(), opt, id))); break; case coInt: case coInts: - m_fields.emplace(id, STDMOVE(SpinCtrl::Create(m_parent, opt, id))); + m_fields.emplace(id, STDMOVE(SpinCtrl::Create(parent(), opt, id))); break; case coEnum: - m_fields.emplace(id, STDMOVE(Choice::Create(m_parent, opt, id))); + m_fields.emplace(id, STDMOVE(Choice::Create(parent(), opt, id))); break; case coPoints: - m_fields.emplace(id, STDMOVE(PointCtrl::Create(m_parent, opt, id))); + m_fields.emplace(id, STDMOVE(PointCtrl::Create(parent(), opt, id))); break; case coNone: break; default: diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index f01ef671c0..01d9184fd1 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -94,7 +94,13 @@ public: /// Returns a copy of the pointer of the parent wxWindow. /// Accessor function is because users are not allowed to change the parent /// but defining it as const means a lot of const_casts to deal with wx functions. - inline wxWindow* parent() const { return m_parent; } + inline wxWindow* parent() const { +#ifdef __WXGTK__ + return m_panel; +#else + return m_parent; +#endif /* __WXGTK__ */ + } void append_line(const Line& line, wxStaticText** colored_Label = nullptr); Line create_single_option_line(const Option& option) const; @@ -130,8 +136,15 @@ public: m_grid_sizer = new wxFlexGridSizer(0, num_columns, 0,0); static_cast(m_grid_sizer)->SetFlexibleDirection(wxHORIZONTAL); static_cast(m_grid_sizer)->AddGrowableCol(label_width != 0); - +#ifdef __WXGTK__ + m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_panel->SetSizer(m_grid_sizer); + m_panel->Layout(); + sizer->Fit(m_panel); + sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5); +#else sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5); +#endif /* __WXGTK__ */ } protected: @@ -147,6 +160,13 @@ protected: // "true" if option is created in preset tabs bool m_is_tab_opt{ false }; + // This panel is needed for correct showing of the ToolTips for Button, StaticText and CheckBox + // Tooltips on GTK doesn't work inside wxStaticBoxSizer unless you insert a panel + // inside it before you insert the other controls. +#ifdef __WXGTK__ + wxPanel* m_panel {nullptr}; +#endif /* __WXGTK__ */ + /// Generate a wxSizer or wxWindow from a configuration option /// Precondition: opt resolves to a known ConfigOption /// Postcondition: fields contains a wx gui object. From 4344eaebca629b069a976c6ce18d1f1b352d582a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 30 Apr 2018 12:03:06 +0200 Subject: [PATCH 0282/1150] Added versioning to amf file --- xs/src/libslic3r/Format/AMF.cpp | 118 ++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 43 deletions(-) diff --git a/xs/src/libslic3r/Format/AMF.cpp b/xs/src/libslic3r/Format/AMF.cpp index 98683cd8aa..b446f456b2 100644 --- a/xs/src/libslic3r/Format/AMF.cpp +++ b/xs/src/libslic3r/Format/AMF.cpp @@ -24,6 +24,12 @@ #include +// VERSION NUMBERS +// 0 : .amf, .amf.xml and .zip.amf files saved by older slic3r. No version definition in them. +// 1 : Introduction of amf versioning. No other change in data saved into amf files. +const unsigned int VERSION_AMF = 1; +const char* SLIC3RPE_AMF_VERSION = "slic3rpe_amf_version"; + const char* SLIC3R_CONFIG_TYPE = "slic3rpe_config"; namespace Slic3r @@ -32,6 +38,7 @@ namespace Slic3r struct AMFParserContext { AMFParserContext(XML_Parser parser, const std::string& archive_filename, PresetBundle* preset_bundle, Model *model) : + m_version(0), m_parser(parser), m_model(*model), m_object(nullptr), @@ -137,6 +144,8 @@ struct AMFParserContext std::vector instances; }; + // Version of the amf file + unsigned int m_version; // Current Expat XML parser instance. XML_Parser m_parser; // Model to receive objects extracted from an AMF file. @@ -360,9 +369,9 @@ void AMFParserContext::endElement(const char * /* name */) case NODE_TYPE_VERTEX: assert(m_object); // Parse the vertex data - m_object_vertices.emplace_back(atof(m_value[0].c_str())); - m_object_vertices.emplace_back(atof(m_value[1].c_str())); - m_object_vertices.emplace_back(atof(m_value[2].c_str())); + m_object_vertices.emplace_back((float)atof(m_value[0].c_str())); + m_object_vertices.emplace_back((float)atof(m_value[1].c_str())); + m_object_vertices.emplace_back((float)atof(m_value[2].c_str())); m_value[0].clear(); m_value[1].clear(); m_value[2].clear(); @@ -462,6 +471,10 @@ void AMFParserContext::endElement(const char * /* name */) if (m_volume && m_value[0] == "name") m_volume->name = std::move(m_value[1]); } + else if (strncmp(m_value[0].c_str(), SLIC3RPE_AMF_VERSION, strlen(SLIC3RPE_AMF_VERSION)) == 0) { + m_version = (unsigned int)atoi(m_value[1].c_str()); + } + m_value[0].clear(); m_value[1].clear(); break; @@ -543,46 +556,8 @@ bool load_amf_file(const char *path, PresetBundle* bundle, Model *model) return result; } -// Load an AMF archive into a provided model. -bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model) +bool extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, const char* path, PresetBundle* bundle, Model* model, unsigned int& version) { - if ((path == nullptr) || (model == nullptr)) - return false; - - mz_zip_archive archive; - mz_zip_zero_struct(&archive); - - mz_bool res = mz_zip_reader_init_file(&archive, path, 0); - if (res == 0) - { - printf("Unable to init zip reader\n"); - return false; - } - - mz_uint num_entries = mz_zip_reader_get_num_files(&archive); - if (num_entries != 1) - { - printf("Found invalid number of entries\n"); - mz_zip_reader_end(&archive); - return false; - } - - mz_zip_archive_file_stat stat; - res = mz_zip_reader_file_stat(&archive, 0, &stat); - if (res == 0) - { - printf("Unable to extract entry statistics\n"); - mz_zip_reader_end(&archive); - return false; - } - - if (!boost::iends_with(stat.m_filename, ".amf")) - { - printf("Found invalid internal filename\n"); - mz_zip_reader_end(&archive); - return false; - } - if (stat.m_uncomp_size == 0) { printf("Found invalid size\n"); @@ -610,7 +585,7 @@ bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model) return false; } - res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, parser_buffer, (size_t)stat.m_uncomp_size, 0); + mz_bool res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, parser_buffer, (size_t)stat.m_uncomp_size, 0); if (res == 0) { printf("Error while reading model data to buffer\n"); @@ -627,6 +602,62 @@ bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model) ctx.endDocument(); + version = ctx.m_version; + + return true; +} + +// Load an AMF archive into a provided model. +bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model) +{ + if ((path == nullptr) || (model == nullptr)) + return false; + + unsigned int version = 0; + + mz_zip_archive archive; + mz_zip_zero_struct(&archive); + + mz_bool res = mz_zip_reader_init_file(&archive, path, 0); + if (res == 0) + { + printf("Unable to init zip reader\n"); + return false; + } + + mz_uint num_entries = mz_zip_reader_get_num_files(&archive); + + mz_zip_archive_file_stat stat; + // we first loop the entries to read from the archive the .amf file only, in order to extract the version from it + for (mz_uint i = 0; i < num_entries; ++i) + { + if (mz_zip_reader_file_stat(&archive, i, &stat)) + { + if (boost::iends_with(stat.m_filename, ".amf")) + { + if (!extract_model_from_archive(archive, stat, path, bundle, model, version)) + { + mz_zip_reader_end(&archive); + printf("Archive does not contain a valid model"); + return false; + } + + break; + } + } + } + +#if 0 // forward compatibility + // we then loop again the entries to read other files stored in the archive + for (mz_uint i = 0; i < num_entries; ++i) + { + if (mz_zip_reader_file_stat(&archive, i, &stat)) + { + // add code to extract the file + } + } +#endif // forward compatibility + mz_zip_reader_end(&archive); return true; } @@ -664,6 +695,7 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c stream << "\n"; stream << "\n"; stream << "Slic3r " << SLIC3R_VERSION << "\n"; + stream << "" << VERSION_AMF << "\n"; if (export_print_config) { From 5624b8afd21733cf813b5664f03228176f03a9f0 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 30 Apr 2018 14:31:57 +0200 Subject: [PATCH 0283/1150] Add a new error dialog --- lib/Slic3r/GUI.pm | 2 +- xs/CMakeLists.txt | 3 + xs/src/slic3r/GUI/GUI.cpp | 20 ++++--- xs/src/slic3r/GUI/GUI.hpp | 1 + xs/src/slic3r/GUI/MsgDialog.cpp | 87 +++++++++++++++++++++++++++++ xs/src/slic3r/GUI/MsgDialog.hpp | 65 +++++++++++++++++++++ xs/src/slic3r/GUI/UpdateDialogs.cpp | 57 ++----------------- xs/src/slic3r/GUI/UpdateDialogs.hpp | 25 +-------- xs/xsp/GUI.xsp | 3 + 9 files changed, 178 insertions(+), 85 deletions(-) create mode 100644 xs/src/slic3r/GUI/MsgDialog.cpp create mode 100644 xs/src/slic3r/GUI/MsgDialog.hpp diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 89a8e79748..04dc803231 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -249,7 +249,7 @@ sub catch_error { # static method accepting a wxWindow object as first parameter sub show_error { my ($parent, $message) = @_; - Wx::MessageDialog->new($parent, $message, 'Error', wxOK | wxICON_ERROR)->ShowModal; + Slic3r::GUI::show_error_id($parent ? $parent->GetId() : 0, $message); } # static method accepting a wxWindow object as first parameter diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 5f1c11951b..f67697b13e 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -222,6 +222,8 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/Utils/ASCIIFolding.hpp ${LIBDIR}/slic3r/GUI/ConfigWizard.cpp ${LIBDIR}/slic3r/GUI/ConfigWizard.hpp + ${LIBDIR}/slic3r/GUI/MsgDialog.cpp + ${LIBDIR}/slic3r/GUI/MsgDialog.hpp ${LIBDIR}/slic3r/GUI/UpdateDialogs.cpp ${LIBDIR}/slic3r/GUI/UpdateDialogs.hpp ${LIBDIR}/slic3r/Utils/Http.cpp @@ -638,6 +640,7 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy "$" "${PERL_LOCAL_LIB_DIR}/auto/Slic3r/XS/" COMMAND ${CMAKE_COMMAND} -E make_directory "${PERL_LOCAL_LIB_DIR}/Slic3r/" COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/xs/lib/Slic3r/XS.pm" "${PERL_LOCAL_LIB_DIR}/Slic3r/" + COMMENT "Installing XS.pm and XS.{so,dll,bundle} into the local-lib directory ..." ) if(APPLE) add_custom_command( diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 6bac39bd7a..20a8a45db0 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -50,6 +50,7 @@ #include "AppConfig.hpp" #include "ConfigSnapshotDialog.hpp" #include "Utils.hpp" +#include "MsgDialog.hpp" #include "ConfigWizard.hpp" #include "Preferences.hpp" #include "PresetBundle.hpp" @@ -652,21 +653,26 @@ void add_created_tab(Tab* panel) g_wxTabPanel->AddPage(panel, panel->title()); } -void show_error(wxWindow* parent, const wxString& message){ - auto msg_wingow = new wxMessageDialog(parent, message, _(L("Error")), wxOK | wxICON_ERROR); - msg_wingow->ShowModal(); +void show_error(wxWindow* parent, const wxString& message) { + ErrorDialog msg(parent, message); + msg.ShowModal(); +} + +void show_error_id(int id, const std::string& message) { + auto *parent = id != 0 ? wxWindow::FindWindowById(id) : nullptr; + show_error(parent, message); } void show_info(wxWindow* parent, const wxString& message, const wxString& title){ - auto msg_wingow = new wxMessageDialog(parent, message, title.empty() ? _(L("Notice")) : title, wxOK | wxICON_INFORMATION); - msg_wingow->ShowModal(); + wxMessageDialog msg_wingow(parent, message, title.empty() ? _(L("Notice")) : title, wxOK | wxICON_INFORMATION); + msg_wingow.ShowModal(); } void warning_catcher(wxWindow* parent, const wxString& message){ if (message == _(L("GLUquadricObjPtr | Attempt to free unreferenced scalar")) ) return; - auto msg = new wxMessageDialog(parent, message, _(L("Warning")), wxOK | wxICON_WARNING); - msg->ShowModal(); + wxMessageDialog msg(parent, message, _(L("Warning")), wxOK | wxICON_WARNING); + msg.ShowModal(); } wxApp* get_app(){ diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index d4b5988a80..c1ecc3dfd1 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -116,6 +116,7 @@ void add_created_tab(Tab* panel); void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0); void show_error(wxWindow* parent, const wxString& message); +void show_error_id(int id, const std::string& message); // For Perl void show_info(wxWindow* parent, const wxString& message, const wxString& title); void warning_catcher(wxWindow* parent, const wxString& message); diff --git a/xs/src/slic3r/GUI/MsgDialog.cpp b/xs/src/slic3r/GUI/MsgDialog.cpp new file mode 100644 index 0000000000..532960cfc9 --- /dev/null +++ b/xs/src/slic3r/GUI/MsgDialog.cpp @@ -0,0 +1,87 @@ +#include "MsgDialog.hpp" + +#include +#include +#include +#include +#include +#include + +#include "libslic3r/libslic3r.h" +#include "libslic3r/Utils.hpp" +#include "GUI.hpp" +#include "ConfigWizard.hpp" + +namespace Slic3r { +namespace GUI { + + +MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxWindowID button_id) : + MsgDialog(parent, title, headline, wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG), button_id) +{} + +MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id) : + wxDialog(parent, wxID_ANY, title), + boldfont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)), + content_sizer(new wxBoxSizer(wxVERTICAL)), + btn_sizer(new wxBoxSizer(wxHORIZONTAL)) +{ + boldfont.SetWeight(wxFONTWEIGHT_BOLD); + + auto *topsizer = new wxBoxSizer(wxHORIZONTAL); + auto *rightsizer = new wxBoxSizer(wxVERTICAL); + + auto *headtext = new wxStaticText(this, wxID_ANY, headline); + headtext->SetFont(boldfont); + headtext->Wrap(CONTENT_WIDTH); + rightsizer->Add(headtext); + rightsizer->AddSpacer(VERT_SPACING); + + rightsizer->Add(content_sizer, 1, wxEXPAND); + + if (button_id != wxID_NONE) { + auto *button = new wxButton(this, button_id); + button->SetFocus(); + btn_sizer->Add(button); + } + + rightsizer->Add(btn_sizer, 0, wxALIGN_CENTRE_HORIZONTAL); + + auto *logo = new wxStaticBitmap(this, wxID_ANY, std::move(bitmap)); + + topsizer->Add(logo, 0, wxALL, BORDER); + topsizer->Add(rightsizer, 1, wxALL | wxEXPAND, BORDER); + + SetSizerAndFit(topsizer); +} + +MsgDialog::~MsgDialog() {} + + +// ErrorDialog + +ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg) : + MsgDialog(parent, _(L("Slic3r error")), _(L("Slic3r has encountered an error")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png")))) +{ + auto *panel = new wxScrolledWindow(this); + auto *p_sizer = new wxBoxSizer(wxVERTICAL); + panel->SetSizer(p_sizer); + + auto *text = new wxStaticText(panel, wxID_ANY, msg); + text->Wrap(CONTENT_WIDTH); + p_sizer->Add(text, 1, wxEXPAND); + + panel->SetMinSize(wxSize(CONTENT_WIDTH, CONTENT_HEIGHT)); + panel->SetScrollRate(0, 5); + + content_sizer->Add(panel, 1, wxEXPAND); + + Fit(); +} + +ErrorDialog::~ErrorDialog() {} + + + +} +} diff --git a/xs/src/slic3r/GUI/MsgDialog.hpp b/xs/src/slic3r/GUI/MsgDialog.hpp new file mode 100644 index 0000000000..a011270238 --- /dev/null +++ b/xs/src/slic3r/GUI/MsgDialog.hpp @@ -0,0 +1,65 @@ +#ifndef slic3r_MsgDialog_hpp_ +#define slic3r_MsgDialog_hpp_ + +#include +#include + +#include +#include +#include + +#include "slic3r/Utils/Semver.hpp" + +class wxBoxSizer; +class wxCheckBox; + +namespace Slic3r { + +namespace GUI { + + +// A message / query dialog with a bitmap on the left and any content on the right +// with buttons underneath. +struct MsgDialog : wxDialog +{ + MsgDialog(MsgDialog &&) = delete; + MsgDialog(const MsgDialog &) = delete; + MsgDialog &operator=(MsgDialog &&) = delete; + MsgDialog &operator=(const MsgDialog &) = delete; + virtual ~MsgDialog(); + +protected: + enum { + CONTENT_WIDTH = 500, + CONTENT_HEIGHT = 300, + BORDER = 30, + VERT_SPACING = 15, + HORIZ_SPACING = 5, + }; + + // button_id is an id of a button that can be added by default, use wxID_NONE to disable + MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxWindowID button_id = wxID_OK); + MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id = wxID_OK); + + wxFont boldfont; + wxBoxSizer *content_sizer; + wxBoxSizer *btn_sizer; +}; + + +// Generic error dialog, used for displaying exceptions +struct ErrorDialog : MsgDialog +{ + ErrorDialog(wxWindow *parent, const wxString &msg); + ErrorDialog(ErrorDialog &&) = delete; + ErrorDialog(const ErrorDialog &) = delete; + ErrorDialog &operator=(ErrorDialog &&) = delete; + ErrorDialog &operator=(const ErrorDialog &) = delete; + virtual ~ErrorDialog(); +}; + + +} +} + +#endif diff --git a/xs/src/slic3r/GUI/UpdateDialogs.cpp b/xs/src/slic3r/GUI/UpdateDialogs.cpp index da212cf136..33c9c0c286 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.cpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.cpp @@ -20,60 +20,11 @@ namespace GUI { static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/prusa3d/Slic3r/wiki/Slic3r-PE-1.40-configuration-update"); -enum { - CONTENT_WIDTH = 400, - BORDER = 30, - VERT_SPACING = 15, - HORIZ_SPACING = 5, -}; - - -MsgDialog::MsgDialog(const wxString &title, const wxString &headline, wxWindowID button_id) : - MsgDialog(title, headline, wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG), button_id) -{} - -MsgDialog::MsgDialog(const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id) : - wxDialog(nullptr, wxID_ANY, title), - boldfont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)), - content_sizer(new wxBoxSizer(wxVERTICAL)), - btn_sizer(new wxBoxSizer(wxHORIZONTAL)) -{ - boldfont.SetWeight(wxFONTWEIGHT_BOLD); - - auto *topsizer = new wxBoxSizer(wxHORIZONTAL); - auto *rightsizer = new wxBoxSizer(wxVERTICAL); - - auto *headtext = new wxStaticText(this, wxID_ANY, headline); - headtext->SetFont(boldfont); - headtext->Wrap(CONTENT_WIDTH); - rightsizer->Add(headtext); - rightsizer->AddSpacer(VERT_SPACING); - - rightsizer->Add(content_sizer); - - if (button_id != wxID_NONE) { - auto *button = new wxButton(this, button_id); - button->SetFocus(); - btn_sizer->Add(button); - } - - rightsizer->Add(btn_sizer, 0, wxALIGN_CENTRE_HORIZONTAL); - - auto *logo = new wxStaticBitmap(this, wxID_ANY, std::move(bitmap)); - - topsizer->Add(logo, 0, wxALL, BORDER); - topsizer->Add(rightsizer, 0, wxALL, BORDER); - - SetSizerAndFit(topsizer); -} - -MsgDialog::~MsgDialog() {} - // MsgUpdateSlic3r MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_online) : - MsgDialog(_(L("Update available")), _(L("New version of Slic3r PE is available"))), + MsgDialog(nullptr, _(L("Update available")), _(L("New version of Slic3r PE is available"))), ver_current(ver_current), ver_online(ver_online) { @@ -115,7 +66,7 @@ bool MsgUpdateSlic3r::disable_version_check() const // MsgUpdateConfig MsgUpdateConfig::MsgUpdateConfig(const std::unordered_map &updates) : - MsgDialog(_(L("Configuration update")), _(L("Configuration update is available")), wxID_NONE) + MsgDialog(nullptr, _(L("Configuration update")), _(L("Configuration update is available")), wxID_NONE) { auto *text = new wxStaticText(this, wxID_ANY, _(L( "Would you like to install it?\n\n" @@ -154,7 +105,7 @@ MsgUpdateConfig::~MsgUpdateConfig() {} // MsgDataIncompatible MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map &incompats) : - MsgDialog(_(L("Slic3r incompatibility")), _(L("Slic3r configuration is incompatible")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png"))), wxID_NONE) + MsgDialog(nullptr, _(L("Slic3r incompatibility")), _(L("Slic3r configuration is incompatible")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png"))), wxID_NONE) { auto *text = new wxStaticText(this, wxID_ANY, _(L( "This version of Slic3r PE is not compatible with currently installed configuration bundles.\n" @@ -207,7 +158,7 @@ MsgDataIncompatible::~MsgDataIncompatible() {} // MsgDataLegacy MsgDataLegacy::MsgDataLegacy() : - MsgDialog(_(L("Configuration update")), _(L("Configuration update"))) + MsgDialog(nullptr, _(L("Configuration update")), _(L("Configuration update"))) { auto *text = new wxStaticText(this, wxID_ANY, wxString::Format( _(L( diff --git a/xs/src/slic3r/GUI/UpdateDialogs.hpp b/xs/src/slic3r/GUI/UpdateDialogs.hpp index e339fbe0d3..62548b98be 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.hpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.hpp @@ -4,11 +4,8 @@ #include #include -#include -#include -#include - #include "slic3r/Utils/Semver.hpp" +#include "MsgDialog.hpp" class wxBoxSizer; class wxCheckBox; @@ -18,26 +15,6 @@ namespace Slic3r { namespace GUI { -// A message / query dialog with a bitmap on the left and any content on the right -// with buttons underneath. -struct MsgDialog : wxDialog -{ - MsgDialog(MsgDialog &&) = delete; - MsgDialog(const MsgDialog &) = delete; - MsgDialog &operator=(MsgDialog &&) = delete; - MsgDialog &operator=(const MsgDialog &) = delete; - virtual ~MsgDialog(); - -protected: - // button_id is an id of a button that can be added by default, use wxID_NONE to disable - MsgDialog(const wxString &title, const wxString &headline, wxWindowID button_id = wxID_OK); - MsgDialog(const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id = wxID_OK); - - wxFont boldfont; - wxBoxSizer *content_sizer; - wxBoxSizer *btn_sizer; -}; - // A confirmation dialog listing configuration updates class MsgUpdateSlic3r : public MsgDialog { diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index be04af1f93..aa95bd647d 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -42,6 +42,9 @@ void add_config_menu(SV *ui, int event_preferences_changed, int event_language_c void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) %code%{ Slic3r::GUI::create_preset_tabs(no_controller, event_value_change, event_presets_changed); %}; +void show_error_id(int id, std::string msg) + %code%{ Slic3r::GUI::show_error_id(id, msg); %}; + TabIface* get_preset_tab(char *name) %code%{ RETVAL=Slic3r::GUI::get_preset_tab_iface(name); %}; From 3c13c4f10301912c1459620fecc2efc8074c8ea2 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 30 Apr 2018 15:27:01 +0200 Subject: [PATCH 0284/1150] Added versioning to 3mf file --- xs/src/libslic3r/Format/3mf.cpp | 80 +++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/Format/3mf.cpp b/xs/src/libslic3r/Format/3mf.cpp index dde64a28f6..0467962c3d 100644 --- a/xs/src/libslic3r/Format/3mf.cpp +++ b/xs/src/libslic3r/Format/3mf.cpp @@ -16,6 +16,12 @@ #include #include +// VERSION NUMBERS +// 0 : .3mf, files saved by older slic3r or other applications. No version definition in them. +// 1 : Introduction of 3mf versioning. No other change in data saved into 3mf files. +const unsigned int VERSION_3MF = 1; +const char* SLIC3RPE_3MF_VERSION = "slic3rpe:Version3mf"; // definition of the metadata name saved into .model file + const std::string MODEL_FOLDER = "3D/"; const std::string MODEL_EXTENSION = ".model"; const std::string MODEL_FILE = "3D/3dmodel.model"; // << this is the only format of the string which works with CURA @@ -37,9 +43,9 @@ const char* COMPONENTS_TAG = "components"; const char* COMPONENT_TAG = "component"; const char* BUILD_TAG = "build"; const char* ITEM_TAG = "item"; +const char* METADATA_TAG = "metadata"; const char* CONFIG_TAG = "config"; -const char* METADATA_TAG = "metadata"; const char* VOLUME_TAG = "volume"; const char* UNIT_ATTR = "unit"; @@ -318,6 +324,9 @@ namespace Slic3r { typedef std::map IdToGeometryMap; typedef std::map> IdToLayerHeightsProfileMap; + // Version of the 3mf file + unsigned int m_version; + XML_Parser m_xml_parser; Model* m_model; float m_unit_factor; @@ -329,6 +338,8 @@ namespace Slic3r { CurrentConfig m_curr_config; IdToMetadataMap m_objects_metadata; IdToLayerHeightsProfileMap m_layer_heights_profiles; + std::string m_curr_metadata_name; + std::string m_curr_characters; public: _3MF_Importer(); @@ -349,6 +360,7 @@ namespace Slic3r { // handlers to parse the .model file void _handle_start_model_xml_element(const char* name, const char** attributes); void _handle_end_model_xml_element(const char* name); + void _handle_model_xml_characters(const XML_Char* s, int len); // handlers to parse the MODEL_CONFIG_FILE file void _handle_start_config_xml_element(const char* name, const char** attributes); @@ -390,6 +402,9 @@ namespace Slic3r { bool _handle_start_item(const char** attributes, unsigned int num_attributes); bool _handle_end_item(); + bool _handle_start_metadata(const char** attributes, unsigned int num_attributes); + bool _handle_end_metadata(); + bool _create_object_instance(int object_id, const Matrix4x4& matrix, unsigned int recur_counter); void _apply_transform(ModelInstance& instance, const Matrix4x4& matrix); @@ -411,6 +426,7 @@ namespace Slic3r { // callbacks to parse the .model file static void XMLCALL _handle_start_model_xml_element(void* userData, const char* name, const char** attributes); static void XMLCALL _handle_end_model_xml_element(void* userData, const char* name); + static void XMLCALL _handle_model_xml_characters(void* userData, const XML_Char* s, int len); // callbacks to parse the MODEL_CONFIG_FILE file static void XMLCALL _handle_start_config_xml_element(void* userData, const char* name, const char** attributes); @@ -418,9 +434,12 @@ namespace Slic3r { }; _3MF_Importer::_3MF_Importer() - : m_xml_parser(nullptr) + : m_version(0) + , m_xml_parser(nullptr) , m_model(nullptr) , m_unit_factor(1.0f) + , m_curr_metadata_name("") + , m_curr_characters("") { } @@ -431,6 +450,7 @@ namespace Slic3r { bool _3MF_Importer::load_model_from_file(const std::string& filename, Model& model, PresetBundle& bundle) { + m_version = 0; m_model = &model; m_unit_factor = 1.0f; m_curr_object.reset(); @@ -442,6 +462,8 @@ namespace Slic3r { m_curr_config.volume_id = -1; m_objects_metadata.clear(); m_layer_heights_profiles.clear(); + m_curr_metadata_name.clear(); + m_curr_characters.clear(); clear_errors(); return _load_model_from_file(filename, model, bundle); @@ -477,6 +499,8 @@ namespace Slic3r { mz_uint num_entries = mz_zip_reader_get_num_files(&archive); mz_zip_archive_file_stat stat; + + // we first loop the entries to read from the archive the .model file only, in order to extract the version from it for (mz_uint i = 0; i < num_entries; ++i) { if (mz_zip_reader_file_stat(&archive, i, &stat)) @@ -494,7 +518,18 @@ namespace Slic3r { return false; } } - else if (boost::algorithm::iequals(name, LAYER_HEIGHTS_PROFILE_FILE)) + } + } + + // we then loop again the entries to read other files stored in the archive + for (mz_uint i = 0; i < num_entries; ++i) + { + if (mz_zip_reader_file_stat(&archive, i, &stat)) + { + std::string name(stat.m_filename); + std::replace(name.begin(), name.end(), '\\', '/'); + + if (boost::algorithm::iequals(name, LAYER_HEIGHTS_PROFILE_FILE)) { // extract slic3r lazer heights profile file _extract_layer_heights_profile_config_from_archive(archive, stat); @@ -595,6 +630,7 @@ namespace Slic3r { XML_SetUserData(m_xml_parser, (void*)this); XML_SetElementHandler(m_xml_parser, _3MF_Importer::_handle_start_model_xml_element, _3MF_Importer::_handle_end_model_xml_element); + XML_SetCharacterDataHandler(m_xml_parser, _3MF_Importer::_handle_model_xml_characters); void* parser_buffer = XML_GetBuffer(m_xml_parser, (int)stat.m_uncomp_size); if (parser_buffer == nullptr) @@ -784,6 +820,8 @@ namespace Slic3r { res = _handle_start_build(attributes, num_attributes); else if (::strcmp(ITEM_TAG, name) == 0) res = _handle_start_item(attributes, num_attributes); + else if (::strcmp(METADATA_TAG, name) == 0) + res = _handle_start_metadata(attributes, num_attributes); if (!res) _stop_xml_parser(); @@ -820,11 +858,18 @@ namespace Slic3r { res = _handle_end_build(); else if (::strcmp(ITEM_TAG, name) == 0) res = _handle_end_item(); + else if (::strcmp(METADATA_TAG, name) == 0) + res = _handle_end_metadata(); if (!res) _stop_xml_parser(); } + void _3MF_Importer::_handle_model_xml_characters(const XML_Char* s, int len) + { + m_curr_characters.append(s, len); + } + void _3MF_Importer::_handle_start_config_xml_element(const char* name, const char** attributes) { if (m_xml_parser == nullptr) @@ -1131,6 +1176,25 @@ namespace Slic3r { return true; } + bool _3MF_Importer::_handle_start_metadata(const char** attributes, unsigned int num_attributes) + { + m_curr_characters.clear(); + + std::string name = get_attribute_value_string(attributes, num_attributes, NAME_ATTR); + if (!name.empty()) + m_curr_metadata_name = name; + + return true; + } + + bool _3MF_Importer::_handle_end_metadata() + { + if (m_curr_metadata_name == SLIC3RPE_3MF_VERSION) + m_version = (unsigned int)atoi(m_curr_characters.c_str()); + + return true; + } + bool _3MF_Importer::_create_object_instance(int object_id, const Matrix4x4& matrix, unsigned int recur_counter) { static const unsigned int MAX_RECURSIONS = 10; @@ -1437,6 +1501,13 @@ namespace Slic3r { importer->_handle_end_model_xml_element(name); } + void XMLCALL _3MF_Importer::_handle_model_xml_characters(void* userData, const XML_Char* s, int len) + { + _3MF_Importer* importer = (_3MF_Importer*)userData; + if (importer != nullptr) + importer->_handle_model_xml_characters(s, len); + } + void XMLCALL _3MF_Importer::_handle_start_config_xml_element(void* userData, const char* name, const char** attributes) { _3MF_Importer* importer = (_3MF_Importer*)userData; @@ -1640,7 +1711,8 @@ namespace Slic3r { { std::stringstream stream; stream << "\n"; - stream << "<" << MODEL_TAG << " unit=\"millimeter\" xml:lang=\"en-US\" xmlns=\"http://schemas.microsoft.com/3dmanufacturing/core/2015/02\">\n"; + stream << "<" << MODEL_TAG << " unit=\"millimeter\" xml:lang=\"en-US\" xmlns=\"http://schemas.microsoft.com/3dmanufacturing/core/2015/02\" xmlns:slic3rpe=\"http://schemas.slic3r.org/3mf/2017/06\">\n"; + stream << " <" << METADATA_TAG << " name=\"" << SLIC3RPE_3MF_VERSION << "\">" << VERSION_3MF << "\n"; stream << " <" << RESOURCES_TAG << ">\n"; BuildItemsList build_items; From 2d4cac00189aa75cf75637d0345a5befb2d80b8a Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 30 Apr 2018 14:20:33 +0200 Subject: [PATCH 0285/1150] Added ability to change color of the labels of the system or modified values --- xs/src/slic3r/GUI/ButtonsDescription.cpp | 46 ++++++++++++++-- xs/src/slic3r/GUI/Field.hpp | 9 +++- xs/src/slic3r/GUI/GUI.cpp | 42 +++++++++++++-- xs/src/slic3r/GUI/GUI.hpp | 8 +-- xs/src/slic3r/GUI/Tab.cpp | 68 ++++++++++++++++++++++-- xs/src/slic3r/GUI/Tab.hpp | 3 +- 6 files changed, 158 insertions(+), 18 deletions(-) diff --git a/xs/src/slic3r/GUI/ButtonsDescription.cpp b/xs/src/slic3r/GUI/ButtonsDescription.cpp index b932985bf5..7ea16d9420 100644 --- a/xs/src/slic3r/GUI/ButtonsDescription.cpp +++ b/xs/src/slic3r/GUI/ButtonsDescription.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "GUI.hpp" @@ -9,7 +10,7 @@ namespace Slic3r { namespace GUI { ButtonsDescription::ButtonsDescription(wxWindow* parent, t_icon_descriptions* icon_descriptions) : - wxDialog(parent, wxID_ANY, "Buttons Description", wxDefaultPosition, wxDefaultSize), + wxDialog(parent, wxID_ANY, "Buttons And Text Colors Description", wxDefaultPosition, wxDefaultSize), m_icon_descriptions(icon_descriptions) { auto grid_sizer = new wxFlexGridSizer(3, 20, 20); @@ -17,6 +18,7 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, t_icon_descriptions* ic auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(grid_sizer, 0, wxEXPAND | wxALL, 20); + // Icon description for (auto pair : *m_icon_descriptions) { auto icon = new wxStaticBitmap(this, wxID_ANY, *pair.first); @@ -32,8 +34,46 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, t_icon_descriptions* ic grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL | wxEXPAND); } - auto button = CreateStdDialogButtonSizer(wxOK); - main_sizer->Add(button, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); + // Text color description + auto sys_label = new wxStaticText(this, wxID_ANY, _(L("Value is the same as the system value"))); + sys_label->SetForegroundColour(get_label_clr_sys()); + auto sys_colour = new wxColourPickerCtrl(this, wxID_ANY, get_label_clr_sys()); + sys_colour->Bind(wxEVT_COLOURPICKER_CHANGED, ([sys_colour, sys_label](wxCommandEvent e) + { + sys_label->SetForegroundColour(sys_colour->GetColour()); + sys_label->Refresh(); + })); + size_t t= 0; + while (t < 3){ + grid_sizer->Add(new wxStaticText(this, wxID_ANY, ""), -1, wxALIGN_CENTRE_VERTICAL | wxEXPAND); + ++t; + } + grid_sizer->Add(0, -1, wxALIGN_CENTRE_VERTICAL); + grid_sizer->Add(sys_colour, -1, wxALIGN_CENTRE_VERTICAL); + grid_sizer->Add(sys_label, -1, wxALIGN_CENTRE_VERTICAL | wxEXPAND); + + auto mod_label = new wxStaticText(this, wxID_ANY, _(L("Value was changed and is not equal to the system value or the last saved preset"))); + mod_label->SetForegroundColour(get_label_clr_modified()); + auto mod_colour = new wxColourPickerCtrl(this, wxID_ANY, get_label_clr_modified()); + mod_colour->Bind(wxEVT_COLOURPICKER_CHANGED, ([mod_colour, mod_label](wxCommandEvent e) + { + mod_label->SetForegroundColour(mod_colour->GetColour()); + mod_label->Refresh(); + })); + grid_sizer->Add(0, -1, wxALIGN_CENTRE_VERTICAL); + grid_sizer->Add(mod_colour, -1, wxALIGN_CENTRE_VERTICAL); + grid_sizer->Add(mod_label, -1, wxALIGN_CENTRE_VERTICAL | wxEXPAND); + + + auto buttons = CreateStdDialogButtonSizer(wxOK|wxCANCEL); + main_sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); + + wxButton* btn = static_cast(FindWindowById(wxID_OK, this)); + btn->Bind(wxEVT_BUTTON, [sys_colour, mod_colour, this](wxCommandEvent&) { + set_label_clr_sys(sys_colour->GetColour()); + set_label_clr_modified(mod_colour->GetColour()); + EndModal(wxID_OK); + }); SetSizer(main_sizer); main_sizer->SetSizeHints(this); diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 1856d94cf0..729f73d160 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -164,6 +164,13 @@ public: return false; } + bool set_label_colour_force(const wxColour *clr) { + if (m_Label == nullptr) return false; + m_Label->SetForegroundColour(*clr); + m_Label->Refresh(true); + return false; + } + bool set_undo_tooltip(const wxString *tip) { if (m_undo_tooltip != tip) { m_undo_tooltip = tip; @@ -194,7 +201,7 @@ protected: wxStaticText* m_Label = nullptr; // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. - const wxColour* m_label_color; + const wxColour* m_label_color = nullptr; // current value boost::any m_value; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 6bac39bd7a..d743d8708c 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -202,8 +202,8 @@ static void init_label_colours() { auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); if (luma >= 128) { - g_color_label_modified = wxColour(255, 108, 30);//wxColour(253, 88, 0); - g_color_label_sys = wxColour(19, 100, 44); //wxColour(26, 132, 57); + g_color_label_modified = wxColour(253, 88, 0); + g_color_label_sys = wxColour(26, 132, 57); } else { g_color_label_modified = wxColour(253, 111, 40); g_color_label_sys = wxColour(115, 220, 103); @@ -211,6 +211,21 @@ static void init_label_colours() g_color_label_default = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); } +void update_label_colours_from_appconfig() +{ + if (g_AppConfig->has("label_clr_sys")){ + auto str = g_AppConfig->get("label_clr_sys"); + if (str != "") + g_color_label_sys = wxColour(str); + } + + if (g_AppConfig->has("label_clr_modified")){ + auto str = g_AppConfig->get("label_clr_modified"); + if (str != "") + g_color_label_modified = wxColour(str); + } +} + void set_wxapp(wxApp *app) { g_wxApp = app; @@ -512,6 +527,7 @@ void open_preferences_dialog(int event_preferences) void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) { + update_label_colours_from_appconfig(); add_created_tab(new TabPrint (g_wxTabPanel, no_controller)); add_created_tab(new TabFilament (g_wxTabPanel, no_controller)); add_created_tab(new TabPrinter (g_wxTabPanel, no_controller)); @@ -678,15 +694,31 @@ PresetBundle* get_preset_bundle() return g_PresetBundle; } -const wxColour& get_modified_label_clr() { +const wxColour& get_label_clr_modified() { return g_color_label_modified; } -const wxColour& get_sys_label_clr() { +const wxColour& get_label_clr_sys() { return g_color_label_sys; } -const wxColour& get_default_label_clr() { +void set_label_clr_modified(const wxColour& clr) { + g_color_label_modified = clr; + auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue()); + std::string str = clr_str.ToStdString(); + g_AppConfig->set("label_clr_modified", str); + g_AppConfig->save(); +} + +void set_label_clr_sys(const wxColour& clr) { + g_color_label_sys = clr; + auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue()); + std::string str = clr_str.ToStdString(); + g_AppConfig->set("label_clr_sys", str); + g_AppConfig->save(); +} + +const wxColour& get_label_clr_default() { return g_color_label_default; } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index d4b5988a80..62a791df54 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -84,10 +84,12 @@ AppConfig* get_app_config(); wxApp* get_app(); PresetBundle* get_preset_bundle(); -const wxColour& get_modified_label_clr(); -const wxColour& get_sys_label_clr(); -const wxColour& get_default_label_clr(); +const wxColour& get_label_clr_modified(); +const wxColour& get_label_clr_sys(); +const wxColour& get_label_clr_default(); unsigned get_colour_approx_luma(const wxColour &colour); +void set_label_clr_modified(const wxColour& clr); +void set_label_clr_sys(const wxColour& clr); extern void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 5e9b249ef5..bb1d938a85 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -110,7 +110,8 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_question_btn->SetBackgroundColour(color); } - m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information."))); + m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information \n" + "or click this button."))); // Determine the theme color of OS (dark or light) auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); @@ -134,13 +135,20 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_question_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { auto dlg = new ButtonsDescription(this, &m_icon_descriptions); - dlg->ShowModal(); + if (dlg->ShowModal() == wxID_OK){ + // Colors for ui "decoration" + for (Tab *tab : get_tabs_list()){ + tab->m_sys_label_clr = get_label_clr_sys(); + tab->m_modified_label_clr = get_label_clr_modified(); + tab->update_labels_colour(); + } + } })); // Colors for ui "decoration" - m_sys_label_clr = get_sys_label_clr(); - m_modified_label_clr = get_modified_label_clr(); - m_default_text_clr = get_default_label_clr(); + m_sys_label_clr = get_label_clr_sys(); + m_modified_label_clr = get_label_clr_modified(); + m_default_text_clr = get_label_clr_default(); m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 0, wxBOTTOM, 3); @@ -278,6 +286,56 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo return page; } +void Tab::update_labels_colour() +{ + Freeze(); + //update options "decoration" + for (const auto opt : m_options_list) + { + const wxColour *color = &m_sys_label_clr; + + // value isn't equal to system value + if ((opt.second & osSystemValue) == 0){ + // value is equal to last saved + if ((opt.second & osInitValue) != 0) + color = &m_default_text_clr; + // value is modified + else + color = &m_modified_label_clr; + } + if (opt.first == "bed_shape" || opt.first == "compatible_printers") { + if (m_colored_Label != nullptr) { + m_colored_Label->SetForegroundColour(*color); + m_colored_Label->Refresh(true); + } + continue; + } + + Field* field = get_field(opt.first); + if (field == nullptr) continue; + field->set_label_colour_force(color); + } + Thaw(); + + auto cur_item = m_treectrl->GetFirstVisibleItem(); + while (cur_item){ + auto title = m_treectrl->GetItemText(cur_item); + for (auto page : m_pages) + { + if (page->title() != title) + continue; + + const wxColor *clr = !page->m_is_nonsys_values ? &m_sys_label_clr : + page->m_is_modified_values ? &m_modified_label_clr : + &m_default_text_clr; + + m_treectrl->SetItemTextColour(cur_item, *clr); + break; + } + cur_item = m_treectrl->GetNextVisible(cur_item); + } +} + // Update UI according to changes void Tab::update_changed_ui() { diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 1ed5d1b368..62030bce34 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -57,7 +57,7 @@ public: { Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); m_vsizer = new wxBoxSizer(wxVERTICAL); - m_item_color = &get_default_label_clr(); + m_item_color = &get_label_clr_default(); SetSizer(m_vsizer); } ~Page(){} @@ -232,6 +232,7 @@ public: void toggle_show_hide_incompatible(); void update_show_hide_incompatible_button(); void update_ui_from_settings(); + void update_labels_colour(); void update_changed_ui(); void get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page); void update_changed_tree_ui(); From 28effac0f169e7fa9e143b40e4a6762e97253f53 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 30 Apr 2018 17:07:30 +0200 Subject: [PATCH 0286/1150] Fix bitmap loading in new dialogs --- xs/src/slic3r/GUI/MsgDialog.cpp | 2 +- xs/src/slic3r/GUI/UpdateDialogs.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/MsgDialog.cpp b/xs/src/slic3r/GUI/MsgDialog.cpp index 532960cfc9..6fba47a37f 100644 --- a/xs/src/slic3r/GUI/MsgDialog.cpp +++ b/xs/src/slic3r/GUI/MsgDialog.cpp @@ -61,7 +61,7 @@ MsgDialog::~MsgDialog() {} // ErrorDialog ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg) : - MsgDialog(parent, _(L("Slic3r error")), _(L("Slic3r has encountered an error")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png")))) + MsgDialog(parent, _(L("Slic3r error")), _(L("Slic3r has encountered an error")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png")), wxBITMAP_TYPE_PNG)) { auto *panel = new wxScrolledWindow(this); auto *p_sizer = new wxBoxSizer(wxVERTICAL); diff --git a/xs/src/slic3r/GUI/UpdateDialogs.cpp b/xs/src/slic3r/GUI/UpdateDialogs.cpp index 33c9c0c286..70d9c851c0 100644 --- a/xs/src/slic3r/GUI/UpdateDialogs.cpp +++ b/xs/src/slic3r/GUI/UpdateDialogs.cpp @@ -105,7 +105,7 @@ MsgUpdateConfig::~MsgUpdateConfig() {} // MsgDataIncompatible MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map &incompats) : - MsgDialog(nullptr, _(L("Slic3r incompatibility")), _(L("Slic3r configuration is incompatible")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png"))), wxID_NONE) + MsgDialog(nullptr, _(L("Slic3r incompatibility")), _(L("Slic3r configuration is incompatible")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png")), wxBITMAP_TYPE_PNG), wxID_NONE) { auto *text = new wxStaticText(this, wxID_ANY, _(L( "This version of Slic3r PE is not compatible with currently installed configuration bundles.\n" From 4758b68e55e072b10dfc77413e11d01ba64af600 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 1 May 2018 10:35:07 +0200 Subject: [PATCH 0287/1150] Fix: Turn two Preset & PresetUpdater exceptions into error logs --- xs/src/slic3r/GUI/Preset.cpp | 10 +++++++--- xs/src/slic3r/Utils/PresetUpdater.cpp | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index eca809ec1f..bc59ac2f92 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -120,14 +121,15 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem model.id = section.first.substr(printer_model_key.size()); model.name = section.second.get("name", model.id); section.second.get("variants", ""); + const auto variants_field = section.second.get("variants", ""); std::vector variants; - if (Slic3r::unescape_strings_cstyle(section.second.get("variants", ""), variants)) { + if (Slic3r::unescape_strings_cstyle(variants_field, variants)) { for (const std::string &variant_name : variants) { if (model.variant(variant_name) == nullptr) model.variants.emplace_back(VendorProfile::PrinterVariant(variant_name)); } } else { - // Log error? // XXX + BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: Malformed variants field: `%2%`") % id % variants_field; } if (! model.id.empty() && ! model.variants.empty()) res.models.push_back(std::move(model)); @@ -387,7 +389,9 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri // Remove the .ini suffix. name.erase(name.size() - 4); if (this->find_preset(name, false)) { - errors_cummulative += "The user preset \"" + name + "\" cannot be loaded. A system preset of the same name has already been loaded."; + // This happens when there's is a preset (most likely legacy one) with the same name as a system preset + // that's already been loaded from a bundle. + BOOST_LOG_TRIVIAL(warning) << "Preset already present, not loading: " << name; continue; } try { diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 9c5fe07481..3b786e0d67 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -252,7 +252,7 @@ void PresetUpdater::priv::sync_config(const std::set vendors) con // See if a there's a new version to download const auto recommended_it = new_index.recommended(); if (recommended_it == new_index.end()) { - BOOST_LOG_TRIVIAL(error) << "No recommended version for vendor: " << vendor.name << ", invalid index?"; + BOOST_LOG_TRIVIAL(error) << boost::format("No recommended version for vendor: %1%, invalid index?") % vendor.name; continue; } const auto recommended = recommended_it->config_version; @@ -326,7 +326,7 @@ Updates PresetUpdater::priv::get_config_updates() const const auto recommended = idx.recommended(); if (recommended == idx.end()) { - throw std::runtime_error((boost::format("Invalid index: `%1%`") % idx.vendor()).str()); + BOOST_LOG_TRIVIAL(error) << boost::format("No recommended version for vendor: %1%, invalid index?") % idx.vendor(); } BOOST_LOG_TRIVIAL(debug) << boost::format("Vendor: %1%, version installed: %2%, version cached: %3%") From 71b43370360ddef5a0dcded7358e0dcf13268bef Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 2 May 2018 10:52:17 +0200 Subject: [PATCH 0288/1150] Label in filament settings changed --- xs/src/slic3r/GUI/Tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 8d449b7f00..2f3a8f00eb 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1283,7 +1283,7 @@ void TabFilament::build() }; optgroup->append_line(line); - optgroup = page->new_optgroup(_(L("Toolchange behaviour"))); + optgroup = page->new_optgroup(_(L("Toolchange parameters with single extruder MM printers"))); optgroup->append_single_option_line("filament_loading_speed"); optgroup->append_single_option_line("filament_unloading_speed"); optgroup->append_single_option_line("filament_toolchange_delay"); From b4e63d47cbd96c36bc0264f924784c97d0d81bcf Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 26 Apr 2018 11:19:51 +0200 Subject: [PATCH 0289/1150] Yet another attempt to fix the layer height profile validation --- xs/src/libslic3r/Print.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index e692b1e9ee..80f68c51b6 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -598,10 +598,10 @@ std::string Print::validate() const return "The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1)."; SlicingParameters slicing_params0 = this->objects.front()->slicing_parameters(); - const PrintObject* most_layered_object = this->objects.front(); // object with highest layer_height_profile.size() encountered so far + const PrintObject* tallest_object = this->objects.front(); // let's find the tallest object for (const auto* object : objects) - if (object->layer_height_profile.size() > most_layered_object->layer_height_profile.size()) - most_layered_object = object; + if (*(object->layer_height_profile.end()-2) > *(tallest_object->layer_height_profile.end()-2) ) + tallest_object = object; for (PrintObject *object : this->objects) { SlicingParameters slicing_params = object->slicing_parameters(); @@ -618,17 +618,26 @@ std::string Print::validate() const object->update_layer_height_profile(); object->layer_height_profile_valid = was_layer_height_profile_valid; - if ( this->config.variable_layer_height ) { - int i = 0; - while ( i < object->layer_height_profile.size() ) { - if (std::abs(most_layered_object->layer_height_profile[i] - object->layer_height_profile[i]) > EPSILON) - return "The Wipe tower is only supported if all objects have the same layer height profile"; - ++i; - if (i == object->layer_height_profile.size()-2) // this element contains the objects max z, if the other object is taller, - // it does not have to match - we will step over it - if (most_layered_object->layer_height_profile[i] > object->layer_height_profile[i]) - ++i; + if ( this->config.variable_layer_height ) { // comparing layer height profiles + bool failed = false; + if (tallest_object->layer_height_profile.size() >= object->layer_height_profile.size() ) { + int i = 0; + while ( i < object->layer_height_profile.size() && i < tallest_object->layer_height_profile.size()) { + if (std::abs(tallest_object->layer_height_profile[i] - object->layer_height_profile[i])) { + failed = true; + break; + } + ++i; + if (i == object->layer_height_profile.size()-2) // this element contains this objects max z + if (tallest_object->layer_height_profile[i] > object->layer_height_profile[i]) // the difference does not matter in this case + ++i; + } } + else + failed = true; + + if (failed) + return "The Wipe tower is only supported if all objects have the same layer height profile"; } /*for (size_t i = 5; i < object->layer_height_profile.size(); i += 2) From de0d1f34f3f13701d38d9dfb83e26feca1ded63f Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 2 May 2018 10:52:17 +0200 Subject: [PATCH 0290/1150] Label in filament settings changed --- xs/src/slic3r/GUI/Tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index bb1d938a85..96419f6c85 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1311,7 +1311,7 @@ void TabFilament::build() }; optgroup->append_line(line); - optgroup = page->new_optgroup(_(L("Toolchange behaviour"))); + optgroup = page->new_optgroup(_(L("Toolchange parameters with single extruder MM printers"))); optgroup->append_single_option_line("filament_loading_speed"); optgroup->append_single_option_line("filament_unloading_speed"); optgroup->append_single_option_line("filament_toolchange_delay"); From e9b83a20d0733a1f606ed61726d99bae4f8f6f09 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 2 May 2018 12:44:53 +0200 Subject: [PATCH 0291/1150] ConfigWizard: Add additional logging --- xs/src/slic3r/GUI/ConfigWizard.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 84f401ba11..1217f86831 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -4,6 +4,8 @@ #include #include +#include + #include #include #include @@ -741,9 +743,12 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese if (install_bundles.size() > 0) { // Install bundles from resources. updater->install_bundles_rsrc(std::move(install_bundles), snapshot); + } else { + BOOST_LOG_TRIVIAL(info) << "No bundles need to be installed from resources"; } if (page_welcome->reset_user_profile()) { + BOOST_LOG_TRIVIAL(info) << "Resetting user profiles..."; preset_bundle->reset(true); } @@ -828,10 +833,13 @@ ConfigWizard::~ConfigWizard() {} bool ConfigWizard::run(PresetBundle *preset_bundle, const PresetUpdater *updater) { + BOOST_LOG_TRIVIAL(info) << "Running ConfigWizard, reason: " << p->run_reason; if (ShowModal() == wxID_OK) { p->apply_config(GUI::get_app_config(), preset_bundle, updater); + BOOST_LOG_TRIVIAL(info) << "ConfigWizard applied"; return true; } else { + BOOST_LOG_TRIVIAL(info) << "ConfigWizard cancelled"; return false; } } From 97a948fa522bab8c9ac0a8b4de62c3fe21e1e396 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 2 May 2018 12:27:46 +0200 Subject: [PATCH 0292/1150] Fix Perl path MSVC props file #857 --- cmake/msvc/{xs.wperl64d.props => xs.wperl64d.props.in} | 10 +++++++--- xs/CMakeLists.txt | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-) rename cmake/msvc/{xs.wperl64d.props => xs.wperl64d.props.in} (61%) diff --git a/cmake/msvc/xs.wperl64d.props b/cmake/msvc/xs.wperl64d.props.in similarity index 61% rename from cmake/msvc/xs.wperl64d.props rename to cmake/msvc/xs.wperl64d.props.in index b604a56e23..5c7461dc71 100644 --- a/cmake/msvc/xs.wperl64d.props +++ b/cmake/msvc/xs.wperl64d.props.in @@ -1,18 +1,22 @@ + - $(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(FxCopDir);$(PATH);c:\wperl64d\bin\; + $(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(FxCopDir);$(PATH);${PROPS_PERL_BIN_PATH}\; - C:\wperl64d\bin\perl.exe + ${PROPS_PERL_EXECUTABLE} slic3r.pl WindowsLocalDebugger - ..\.. + ${PROPS_CMAKE_SOURCE_DIR} diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index abd9c3617a..238a0df349 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -647,7 +647,12 @@ endif () if (MSVC) # Here we associate some additional properties with the MSVC project to enable compilation and debugging out of the box. - set_target_properties(XS PROPERTIES VS_USER_PROPS "${PROJECT_SOURCE_DIR}/cmake/msvc/xs.wperl64d.props") + get_filename_component(PROPS_PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY) + string(REPLACE "/" "\\" PROPS_PERL_BIN_PATH "${PROPS_PERL_BIN_PATH}") + string(REPLACE "/" "\\" PROPS_PERL_EXECUTABLE "${PERL_EXECUTABLE}") + string(REPLACE "/" "\\" PROPS_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}") + configure_file("${PROJECT_SOURCE_DIR}/cmake/msvc/xs.wperl64d.props.in" "${CMAKE_BINARY_DIR}/xs.wperl64d.props" NEWLINE_STYLE CRLF) + set_target_properties(XS PROPERTIES VS_USER_PROPS "${CMAKE_BINARY_DIR}/xs.wperl64d.props") endif() # l10n From 9d9bcfe03f641c0d951cbf603df27282b55ca347 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 2 May 2018 13:03:04 +0200 Subject: [PATCH 0293/1150] MSVC: Rename props file #857 --- cmake/msvc/{xs.wperl64d.props.in => xs.wperl.props.in} | 0 xs/CMakeLists.txt | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename cmake/msvc/{xs.wperl64d.props.in => xs.wperl.props.in} (100%) diff --git a/cmake/msvc/xs.wperl64d.props.in b/cmake/msvc/xs.wperl.props.in similarity index 100% rename from cmake/msvc/xs.wperl64d.props.in rename to cmake/msvc/xs.wperl.props.in diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 238a0df349..b8d786937a 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -651,8 +651,8 @@ if (MSVC) string(REPLACE "/" "\\" PROPS_PERL_BIN_PATH "${PROPS_PERL_BIN_PATH}") string(REPLACE "/" "\\" PROPS_PERL_EXECUTABLE "${PERL_EXECUTABLE}") string(REPLACE "/" "\\" PROPS_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}") - configure_file("${PROJECT_SOURCE_DIR}/cmake/msvc/xs.wperl64d.props.in" "${CMAKE_BINARY_DIR}/xs.wperl64d.props" NEWLINE_STYLE CRLF) - set_target_properties(XS PROPERTIES VS_USER_PROPS "${CMAKE_BINARY_DIR}/xs.wperl64d.props") + configure_file("${PROJECT_SOURCE_DIR}/cmake/msvc/xs.wperl.props.in" "${CMAKE_BINARY_DIR}/xs.wperl.props" NEWLINE_STYLE CRLF) + set_target_properties(XS PROPERTIES VS_USER_PROPS "${CMAKE_BINARY_DIR}/xs.wperl.props") endif() # l10n From e2e4310322badc30a7d62ce9d2744f117f5126c9 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 2 May 2018 13:55:04 +0200 Subject: [PATCH 0294/1150] Removed unneeded scene reloads when selecting objects --- lib/Slic3r/GUI/3DScene.pm | 6 +++++- lib/Slic3r/GUI/Plater.pm | 15 ++++++++++----- lib/Slic3r/GUI/Plater/3D.pm | 23 +++++++++++++++++++---- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 1 - lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 1 - 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 352a612643..59b5367b58 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1152,7 +1152,11 @@ sub InitGL { $self->volumes->finalize_geometry(1) if ($^O eq 'linux' && $self->UseVBOs); - $self->zoom_to_bed; + if (scalar @{$self->volumes} > 0) { + $self->zoom_to_volumes; + } else { + $self->zoom_to_bed; + } glClearColor(0, 0, 0, 1); glColor3f(1, 0, 0); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 4a013bf2d9..79f251b05c 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1809,8 +1809,7 @@ sub list_item_deselected { if ($self->{list}->GetFirstSelected == -1) { $self->select_object(undef); $self->{canvas}->Refresh; - #FIXME VBOs are being refreshed just to change a selection color? - $self->{canvas3D}->reload_scene if $self->{canvas3D}; + $self->{canvas3D}->deselect_volumes if $self->{canvas3D}; } undef $self->{_lecursor}; } @@ -1822,8 +1821,7 @@ sub list_item_selected { my $obj_idx = $event->GetIndex; $self->select_object($obj_idx); $self->{canvas}->Refresh; - #FIXME VBOs are being refreshed just to change a selection color? - $self->{canvas3D}->reload_scene if $self->{canvas3D}; + $self->{canvas3D}->update_volumes_selection if $self->{canvas3D}; undef $self->{_lecursor}; } @@ -2015,8 +2013,15 @@ sub selection_changed { sub select_object { my ($self, $obj_idx) = @_; + + # remove current selection + foreach my $o (0..$#{$self->{objects}}) { + $PreventListEvents = 1; + $self->{objects}->[$o]->selected(0); + $self->{list}->Select($o, 0); + $PreventListEvents = 0; + } - $_->selected(0) for @{ $self->{objects} }; if (defined $obj_idx) { $self->{objects}->[$obj_idx]->selected(1); # We use this flag to avoid circular event handling diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index dce60e2c44..ced6fb82ea 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -31,7 +31,9 @@ sub new { $self->{on_select_object} = sub {}; $self->{on_instances_moved} = sub {}; $self->{on_wipe_tower_moved} = sub {}; - + + $self->{objects_volumes_idxs} = (); + $self->on_select(sub { my ($volume_idx) = @_; $self->{on_select_object}->(($volume_idx == -1) ? undef : $self->volumes->[$volume_idx]->object_idx) @@ -181,6 +183,17 @@ sub set_on_enable_action_buttons { $self->on_enable_action_buttons($cb); } +sub update_volumes_selection { + my ($self) = @_; + + foreach my $obj_idx (0..$#{$self->{model}->objects}) { + if ($self->{objects}[$obj_idx]->selected) { + my @volume_idxs = @{$self->{objects_volumes_idxs}[$obj_idx]}; + $self->select_volume($_) for @volume_idxs; + } + } +} + sub reload_scene { my ($self, $force) = @_; @@ -194,12 +207,14 @@ sub reload_scene { $self->{reload_delayed} = 0; + $self->{objects_volumes_idxs} = (); foreach my $obj_idx (0..$#{$self->{model}->objects}) { my @volume_idxs = $self->load_object($self->{model}, $self->{print}, $obj_idx); - if ($self->{objects}[$obj_idx]->selected) { - $self->select_volume($_) for @volume_idxs; - } + push(@{$self->{objects_volumes_idxs}}, \@volume_idxs); } + + $self->update_volumes_selection; + if (defined $self->{config}->nozzle_diameter) { # Should the wipe tower be visualized? my $extruders_count = scalar @{ $self->{config}->nozzle_diameter }; diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 0cc8b2decc..4d55e313a6 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -116,7 +116,6 @@ sub new { $canvas->set_auto_bed_shape; $canvas->SetSize([500,500]); $canvas->SetMinSize($canvas->GetSize); - $canvas->zoom_to_volumes; } $self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL); diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index f7e38ed873..28e3bf92b5 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -163,7 +163,6 @@ sub new { $canvas->set_auto_bed_shape; $canvas->SetSize([500,700]); $canvas->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); - $canvas->zoom_to_volumes; } $self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL); From cb486522a80737e63175e79e841ad31380aa88c3 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 2 May 2018 14:55:17 +0200 Subject: [PATCH 0295/1150] Fixed crash when pressing 'A' with empty print bed --- xs/src/libslic3r/Model.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index aaea863e83..a43bf02213 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -269,6 +269,10 @@ TriangleMesh Model::mesh() const static bool _arrange(const Pointfs &sizes, coordf_t dist, const BoundingBoxf* bb, Pointfs &out) { + if (sizes.empty()) + // return if the list is empty or the following call to BoundingBoxf constructor will lead to a crash + return true; + // we supply unscaled data to arrange() bool result = Slic3r::Geometry::arrange( sizes.size(), // number of parts From 16d5faac2000fc6f210e61e18d225ecf4db84c83 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 2 May 2018 13:20:36 +0200 Subject: [PATCH 0296/1150] Preparations to the localization update & new Slic3rPE.pot --- lib/Slic3r/GUI/Plater.pm | 4 +- resources/localization/Slic3rPE.pot | 2715 +++++++++++++------- resources/localization/list.txt | 14 +- xs/src/slic3r/GUI/AboutDialog.cpp | 2 +- xs/src/slic3r/GUI/BonjourDialog.cpp | 2 +- xs/src/slic3r/GUI/ButtonsDescription.cpp | 2 +- xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp | 33 +- xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp | 2 +- xs/src/slic3r/GUI/GUI.cpp | 17 +- xs/src/slic3r/GUI/Preferences.cpp | 6 + xs/src/slic3r/GUI/Preferences.hpp | 3 +- xs/src/slic3r/GUI/Preset.cpp | 17 +- xs/src/slic3r/GUI/PresetBundle.cpp | 9 +- xs/src/slic3r/GUI/RammingChart.cpp | 6 +- xs/src/slic3r/GUI/Tab.cpp | 5 +- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 12 +- 16 files changed, 1864 insertions(+), 985 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 4a013bf2d9..ac1a1f0be2 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -549,8 +549,8 @@ sub _on_select_preset { return if ($selected_item == $self->{"selected_item_$group"}); my $selected_string = $choice->GetString($selected_item); - if ($selected_string eq "------- System presets -------" || - $selected_string eq "------- User presets -------"){ + if ($selected_string eq ("------- ".L("System presets")." -------") || + $selected_string eq ("------- ".L("User presets")." -------") ){ $choice->SetSelection($self->{"selected_item_$group"}); return; } diff --git a/resources/localization/Slic3rPE.pot b/resources/localization/Slic3rPE.pot index 0282e7aae7..e4b9e25671 100644 --- a/resources/localization/Slic3rPE.pot +++ b/resources/localization/Slic3rPE.pot @@ -3,20 +3,26 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-14 15:32+0100\n" +"POT-Creation-Date: 2018-05-02 15:27+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +#: xs/src/slic3r/GUI/AboutDialog.cpp:32 +msgid "About Slic3r" +msgstr "" + +#: xs/src/slic3r/GUI/AboutDialog.cpp:60 +msgid "Version" +msgstr "" + #: xs/src/slic3r/GUI/BedShapeDialog.cpp:39 msgid "Shape" msgstr "" @@ -25,8 +31,8 @@ msgstr "" msgid "Rectangular" msgstr "" -#: xs/src/slic3r/GUI/BedShapeDialog.cpp:50 xs/src/slic3r/GUI/Tab.cpp:1270 -#: lib/Slic3r/GUI/Plater.pm:411 +#: xs/src/slic3r/GUI/BedShapeDialog.cpp:50 xs/src/slic3r/GUI/Tab.cpp:1738 +#: lib/Slic3r/GUI/Plater.pm:421 msgid "Size" msgstr "" @@ -48,25 +54,34 @@ msgstr "" msgid "Circular" msgstr "" -#: xs/src/slic3r/GUI/BedShapeDialog.cpp:65 xs/src/libslic3r/PrintConfig.cpp:129 -#: xs/src/libslic3r/PrintConfig.cpp:200 xs/src/libslic3r/PrintConfig.cpp:211 -#: xs/src/libslic3r/PrintConfig.cpp:325 xs/src/libslic3r/PrintConfig.cpp:336 -#: xs/src/libslic3r/PrintConfig.cpp:355 xs/src/libslic3r/PrintConfig.cpp:434 -#: xs/src/libslic3r/PrintConfig.cpp:781 xs/src/libslic3r/PrintConfig.cpp:801 -#: xs/src/libslic3r/PrintConfig.cpp:860 xs/src/libslic3r/PrintConfig.cpp:878 -#: xs/src/libslic3r/PrintConfig.cpp:896 xs/src/libslic3r/PrintConfig.cpp:1051 -#: xs/src/libslic3r/PrintConfig.cpp:1059 xs/src/libslic3r/PrintConfig.cpp:1101 -#: xs/src/libslic3r/PrintConfig.cpp:1110 xs/src/libslic3r/PrintConfig.cpp:1120 -#: xs/src/libslic3r/PrintConfig.cpp:1128 xs/src/libslic3r/PrintConfig.cpp:1136 -#: xs/src/libslic3r/PrintConfig.cpp:1222 xs/src/libslic3r/PrintConfig.cpp:1428 -#: xs/src/libslic3r/PrintConfig.cpp:1498 xs/src/libslic3r/PrintConfig.cpp:1534 -#: xs/src/libslic3r/PrintConfig.cpp:1711 xs/src/libslic3r/PrintConfig.cpp:1718 -#: xs/src/libslic3r/PrintConfig.cpp:1725 xs/src/libslic3r/PrintConfig.cpp:1734 -#: xs/src/libslic3r/PrintConfig.cpp:1744 xs/src/libslic3r/PrintConfig.cpp:1754 +#: xs/src/slic3r/GUI/BedShapeDialog.cpp:65 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:85 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:432 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:446 +#: xs/src/slic3r/GUI/RammingChart.cpp:86 +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:84 +#: xs/src/libslic3r/PrintConfig.cpp:129 xs/src/libslic3r/PrintConfig.cpp:172 +#: xs/src/libslic3r/PrintConfig.cpp:180 xs/src/libslic3r/PrintConfig.cpp:228 +#: xs/src/libslic3r/PrintConfig.cpp:239 xs/src/libslic3r/PrintConfig.cpp:353 +#: xs/src/libslic3r/PrintConfig.cpp:364 xs/src/libslic3r/PrintConfig.cpp:383 +#: xs/src/libslic3r/PrintConfig.cpp:496 xs/src/libslic3r/PrintConfig.cpp:850 +#: xs/src/libslic3r/PrintConfig.cpp:870 xs/src/libslic3r/PrintConfig.cpp:878 +#: xs/src/libslic3r/PrintConfig.cpp:936 xs/src/libslic3r/PrintConfig.cpp:954 +#: xs/src/libslic3r/PrintConfig.cpp:972 xs/src/libslic3r/PrintConfig.cpp:1034 +#: xs/src/libslic3r/PrintConfig.cpp:1151 xs/src/libslic3r/PrintConfig.cpp:1159 +#: xs/src/libslic3r/PrintConfig.cpp:1201 xs/src/libslic3r/PrintConfig.cpp:1210 +#: xs/src/libslic3r/PrintConfig.cpp:1220 xs/src/libslic3r/PrintConfig.cpp:1228 +#: xs/src/libslic3r/PrintConfig.cpp:1236 xs/src/libslic3r/PrintConfig.cpp:1322 +#: xs/src/libslic3r/PrintConfig.cpp:1528 xs/src/libslic3r/PrintConfig.cpp:1598 +#: xs/src/libslic3r/PrintConfig.cpp:1632 xs/src/libslic3r/PrintConfig.cpp:1828 +#: xs/src/libslic3r/PrintConfig.cpp:1835 xs/src/libslic3r/PrintConfig.cpp:1842 +#: xs/src/libslic3r/PrintConfig.cpp:1856 xs/src/libslic3r/PrintConfig.cpp:1866 +#: xs/src/libslic3r/PrintConfig.cpp:1876 msgid "mm" msgstr "" -#: xs/src/slic3r/GUI/BedShapeDialog.cpp:66 xs/src/libslic3r/PrintConfig.cpp:431 +#: xs/src/slic3r/GUI/BedShapeDialog.cpp:66 +#: xs/src/libslic3r/PrintConfig.cpp:493 msgid "Diameter" msgstr "" @@ -77,8 +92,8 @@ msgid "" msgstr "" #: xs/src/slic3r/GUI/BedShapeDialog.cpp:71 -#: xs/src/libslic3r/GCode/PreviewData.cpp:150 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:92 +#: xs/src/libslic3r/GCode/PreviewData.cpp:170 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:95 msgid "Custom" msgstr "" @@ -90,300 +105,730 @@ msgstr "" msgid "Settings" msgstr "" -#: xs/src/slic3r/GUI/BedShapeDialog.cpp:298 +#: xs/src/slic3r/GUI/BedShapeDialog.cpp:299 msgid "Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):" msgstr "" -#: xs/src/slic3r/GUI/BedShapeDialog.cpp:315 +#: xs/src/slic3r/GUI/BedShapeDialog.cpp:316 msgid "Error! " msgstr "" -#: xs/src/slic3r/GUI/BedShapeDialog.cpp:324 +#: xs/src/slic3r/GUI/BedShapeDialog.cpp:325 msgid "The selected file contains no geometry." msgstr "" -#: xs/src/slic3r/GUI/BedShapeDialog.cpp:328 +#: xs/src/slic3r/GUI/BedShapeDialog.cpp:329 msgid "" "The selected file contains several disjoint areas. This is not supported." msgstr "" -#: xs/src/slic3r/GUI/BedShapeDialog.hpp:42 +#: xs/src/slic3r/GUI/BedShapeDialog.hpp:44 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:395 msgid "Bed Shape" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:234 +#: xs/src/slic3r/GUI/BonjourDialog.cpp:53 +msgid "Network lookup" +msgstr "" + +#: xs/src/slic3r/GUI/BonjourDialog.cpp:66 +msgid "Address" +msgstr "" + +#: xs/src/slic3r/GUI/BonjourDialog.cpp:67 +msgid "Hostname" +msgstr "" + +#: xs/src/slic3r/GUI/BonjourDialog.cpp:68 +msgid "Service name" +msgstr "" + +#: xs/src/slic3r/GUI/BonjourDialog.cpp:69 +msgid "OctoPrint version" +msgstr "" + +#: xs/src/slic3r/GUI/BonjourDialog.cpp:187 +msgid "Searching for devices" +msgstr "" + +#: xs/src/slic3r/GUI/BonjourDialog.cpp:194 +msgid "Finished" +msgstr "" + +#: xs/src/slic3r/GUI/ButtonsDescription.cpp:13 +msgid "Buttons And Text Colors Description" +msgstr "" + +#: xs/src/slic3r/GUI/ButtonsDescription.cpp:38 +msgid "Value is the same as the system value" +msgstr "" + +#: xs/src/slic3r/GUI/ButtonsDescription.cpp:55 +msgid "" +"Value was changed and is not equal to the system value or the last saved " +"preset" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:15 +msgid "Upgrade" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:17 +msgid "Downgrade" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:19 +msgid "Before roll back" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:21 +msgid "User" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:24 +msgid "Unknown" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:36 +msgid "Active: " +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:42 +msgid "slic3r version" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:43 +msgid "print" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:44 +msgid "filaments" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:45 +msgid "printer" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:49 xs/src/slic3r/GUI/Tab.cpp:755 +msgid "vendor" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:49 +msgid "version" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:50 +msgid "min slic3r version" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:52 +msgid "max slic3r version" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:55 +msgid "model" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:55 +msgid "variants" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:67 +msgid "Incompatible with this Slic3r" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:70 +msgid "Activate" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:96 xs/src/slic3r/GUI/GUI.cpp:402 +msgid "Configuration Snapshots" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:85 +msgid "nozzle" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:103 +msgid "Select all" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:104 +msgid "Select none" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:205 +#, possible-c-format +msgid "Welcome to the Slic3r %s" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:205 +msgid "Welcome" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:211 xs/src/slic3r/GUI/GUI.cpp:399 +#, possible-c-format +msgid "Run %s" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:213 +#, possible-c-format +msgid "" +"Hello, welcome to Slic3r Prusa Edition! This %s helps you with the initial " +"configuration; just a few settings and you will be ready to print." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:217 +msgid "" +"Remove user profiles - install from scratch (a snapshot will be taken " +"beforehand)" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:238 +msgid "Other vendors" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:240 +msgid "Custom setup" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:264 +msgid "Automatic updates" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:264 +msgid "Updates" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:272 xs/src/slic3r/GUI/Preferences.cpp:59 +msgid "Check for application updates" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:275 xs/src/slic3r/GUI/Preferences.cpp:61 +msgid "" +"If enabled, Slic3r checks for new versions of Slic3r PE online. When a new " +"version becomes available a notification is displayed at the next " +"application startup (never during program usage). This is only a " +"notification mechanisms, no automatic installation is done." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:279 xs/src/slic3r/GUI/Preferences.cpp:67 +msgid "Update built-in Presets automatically" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:282 xs/src/slic3r/GUI/Preferences.cpp:69 +msgid "" +"If enabled, Slic3r downloads updates of built-in system presets in the " +"background. These updates are downloaded into a separate temporary location. " +"When a new preset version becomes available it is offered at application " +"startup." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:283 +msgid "" +"Updates are never applied without user's consent and never overwrite user's " +"customized settings." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:288 +msgid "" +"Additionally a backup snapshot of the whole configuration is created before " +"an update is applied." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:295 +msgid "Other Vendors" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:297 +msgid "Pick another vendor supported by Slic3r PE:" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:356 +msgid "Firmware Type" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:356 xs/src/slic3r/GUI/Tab.cpp:1625 +msgid "Firmware" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:360 +msgid "Choose the type of firmware used by your printer." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:395 +msgid "Bed Shape and Size" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:398 +msgid "Set the shape of your printer's bed." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:412 +msgid "Filament and Nozzle Diameters" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:412 +msgid "Print Diameters" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:428 +msgid "Enter the diameter of your printer's hot end nozzle." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:431 +msgid "Nozzle Diameter:" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:441 +msgid "Enter the diameter of your filament." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:442 +msgid "" +"Good precision is required, so use a caliper and do multiple measurements " +"along the filament, then compute the average." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:445 +msgid "Filament Diameter:" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:463 +msgid "Extruder and Bed Temperatures" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:463 +msgid "Temperatures" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:479 +msgid "Enter the temperature needed for extruding your filament." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:480 +msgid "A rule of thumb is 160 to 230 °C for PLA, and 215 to 250 °C for ABS." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:483 +msgid "Extrusion Temperature:" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:484 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:498 +msgid "°C" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:493 +msgid "" +"Enter the bed temperature needed for getting your filament to stick to your " +"heated bed." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:494 +msgid "" +"A rule of thumb is 60 °C for PLA and 110 °C for ABS. Leave zero if you have " +"no heated bed." +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:497 +msgid "Bed Temperature:" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:791 +msgid "&Finish" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:844 +msgid "Configuration Wizard" +msgstr "" + +#: xs/src/slic3r/GUI/ConfigWizard.cpp:846 +msgid "Configuration Assistant" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:285 msgid "Array of language names and identifiers should have the same size." msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:245 +#: xs/src/slic3r/GUI/GUI.cpp:296 msgid "Select the language" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:245 +#: xs/src/slic3r/GUI/GUI.cpp:296 msgid "Language" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:312 xs/src/libslic3r/PrintConfig.cpp:170 +#: xs/src/slic3r/GUI/GUI.cpp:363 xs/src/libslic3r/PrintConfig.cpp:186 msgid "Default" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:337 +#: xs/src/slic3r/GUI/GUI.cpp:402 +msgid "Inspect / activate configuration snapshots" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:403 +msgid "Take Configuration Snapshot" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:403 +msgid "Capture a configuration snapshot" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:404 +msgid "Check for updates" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:404 +msgid "Check for configuration updates" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:406 xs/src/slic3r/GUI/Preferences.cpp:9 +msgid "Preferences" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:406 +msgid "Application preferences" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:408 msgid "Change Application Language" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:344 +#: xs/src/slic3r/GUI/GUI.cpp:417 +msgid "Taking configuration snapshot" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:417 +msgid "Snapshot name" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:456 msgid "Application will be restarted" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:344 +#: xs/src/slic3r/GUI/GUI.cpp:456 msgid "Attention!" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:351 -msgid "&Localization" +#: xs/src/slic3r/GUI/GUI.cpp:466 +msgid "&Configuration" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:494 lib/Slic3r/GUI/MainFrame.pm:465 -#: lib/Slic3r/GUI/Plater.pm:1304 -msgid "Error" +#: xs/src/slic3r/GUI/GUI.cpp:485 +msgid "You have unsaved changes " msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:499 +#: xs/src/slic3r/GUI/GUI.cpp:485 +msgid ". Discard changes and continue anyway?" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:486 +msgid "Unsaved Presets" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:683 msgid "Notice" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:504 -msgid "GLUquadricObjPtr | Attempt to free unreferenced scalar" +#: xs/src/slic3r/GUI/GUI.cpp:688 +msgid "Attempt to free unreferenced scalar" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:506 +#: xs/src/slic3r/GUI/GUI.cpp:690 xs/src/slic3r/GUI/WipeTowerDialog.cpp:44 +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:326 msgid "Warning" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:655 +#: xs/src/slic3r/GUI/GUI.cpp:879 msgid "Support" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:658 +#: xs/src/slic3r/GUI/GUI.cpp:882 msgid "Select what kind of support do you need" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:659 xs/src/libslic3r/GCode/PreviewData.cpp:137 +#: xs/src/slic3r/GUI/GUI.cpp:883 xs/src/libslic3r/GCode/PreviewData.cpp:157 msgid "None" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:660 xs/src/libslic3r/PrintConfig.cpp:1415 +#: xs/src/slic3r/GUI/GUI.cpp:884 xs/src/libslic3r/PrintConfig.cpp:1515 msgid "Support on build plate only" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:661 +#: xs/src/slic3r/GUI/GUI.cpp:885 msgid "Everywhere" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:673 xs/src/slic3r/GUI/Tab.cpp:441 +#: xs/src/slic3r/GUI/GUI.cpp:897 xs/src/slic3r/GUI/Tab.cpp:869 msgid "Brim" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:675 +#: xs/src/slic3r/GUI/GUI.cpp:899 msgid "" "This flag enables the brim that will be printed around each object on the " "first layer." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:57 +#: xs/src/slic3r/GUI/GUI.cpp:908 +msgid "Purging volumes" +msgstr "" + +#: xs/src/slic3r/GUI/GUI.cpp:950 +msgid "Export print config" +msgstr "" + +#: xs/src/slic3r/GUI/MsgDialog.cpp:64 +msgid "Slic3r error" +msgstr "" + +#: xs/src/slic3r/GUI/MsgDialog.cpp:64 +msgid "Slic3r has encountered an error" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:100 msgid "Save current " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:58 +#: xs/src/slic3r/GUI/Tab.cpp:101 msgid "Delete this preset" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:383 +#: xs/src/slic3r/GUI/Tab.cpp:113 +msgid "" +"Hover the cursor over buttons to find more information \n" +"or click this button." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:741 +msgid "It's a default preset." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:742 +msgid "It's a system preset." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:743 +msgid "Current preset is inherited from " +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:748 +msgid "It can't be deleted or modified. " +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:749 +msgid "" +"Any modifications should be saved as a new preset inherited from this one. " +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:750 +msgid "To do that please specify a new name for the preset." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:754 +msgid "Additional information:" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:762 +msgid "printer model" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:764 +msgid "default print profile" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:767 +msgid "default filament profile" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:811 msgid "Layers and perimeters" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:384 xs/src/libslic3r/PrintConfig.cpp:777 +#: xs/src/slic3r/GUI/Tab.cpp:812 xs/src/libslic3r/PrintConfig.cpp:846 msgid "Layer height" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:388 +#: xs/src/slic3r/GUI/Tab.cpp:816 msgid "Vertical shells" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:399 +#: xs/src/slic3r/GUI/Tab.cpp:827 msgid "Horizontal shells" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:400 xs/src/libslic3r/PrintConfig.cpp:1321 +#: xs/src/slic3r/GUI/Tab.cpp:828 xs/src/libslic3r/PrintConfig.cpp:1421 msgid "Solid layers" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:405 +#: xs/src/slic3r/GUI/Tab.cpp:833 msgid "Quality (slower slicing)" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:412 xs/src/slic3r/GUI/Tab.cpp:426 -#: xs/src/slic3r/GUI/Tab.cpp:519 xs/src/slic3r/GUI/Tab.cpp:522 -#: xs/src/slic3r/GUI/Tab.cpp:905 xs/src/slic3r/GUI/Tab.cpp:1191 -#: xs/src/libslic3r/PrintConfig.cpp:107 xs/src/libslic3r/PrintConfig.cpp:208 -#: xs/src/libslic3r/PrintConfig.cpp:736 xs/src/libslic3r/PrintConfig.cpp:1740 +#: xs/src/slic3r/GUI/Tab.cpp:840 xs/src/slic3r/GUI/Tab.cpp:854 +#: xs/src/slic3r/GUI/Tab.cpp:948 xs/src/slic3r/GUI/Tab.cpp:951 +#: xs/src/slic3r/GUI/Tab.cpp:1300 xs/src/slic3r/GUI/Tab.cpp:1628 +#: xs/src/libslic3r/PrintConfig.cpp:107 xs/src/libslic3r/PrintConfig.cpp:236 +#: xs/src/libslic3r/PrintConfig.cpp:798 xs/src/libslic3r/PrintConfig.cpp:1862 msgid "Advanced" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:416 xs/src/slic3r/GUI/Tab.cpp:417 -#: xs/src/slic3r/GUI/Tab.cpp:735 xs/src/libslic3r/PrintConfig.cpp:87 -#: xs/src/libslic3r/PrintConfig.cpp:247 xs/src/libslic3r/PrintConfig.cpp:488 -#: xs/src/libslic3r/PrintConfig.cpp:502 xs/src/libslic3r/PrintConfig.cpp:540 -#: xs/src/libslic3r/PrintConfig.cpp:681 xs/src/libslic3r/PrintConfig.cpp:691 -#: xs/src/libslic3r/PrintConfig.cpp:709 xs/src/libslic3r/PrintConfig.cpp:727 -#: xs/src/libslic3r/PrintConfig.cpp:746 xs/src/libslic3r/PrintConfig.cpp:1270 -#: xs/src/libslic3r/PrintConfig.cpp:1287 +#: xs/src/slic3r/GUI/Tab.cpp:844 xs/src/slic3r/GUI/Tab.cpp:845 +#: xs/src/slic3r/GUI/Tab.cpp:1152 xs/src/libslic3r/PrintConfig.cpp:87 +#: xs/src/libslic3r/PrintConfig.cpp:275 xs/src/libslic3r/PrintConfig.cpp:550 +#: xs/src/libslic3r/PrintConfig.cpp:564 xs/src/libslic3r/PrintConfig.cpp:602 +#: xs/src/libslic3r/PrintConfig.cpp:743 xs/src/libslic3r/PrintConfig.cpp:753 +#: xs/src/libslic3r/PrintConfig.cpp:771 xs/src/libslic3r/PrintConfig.cpp:789 +#: xs/src/libslic3r/PrintConfig.cpp:808 xs/src/libslic3r/PrintConfig.cpp:1370 +#: xs/src/libslic3r/PrintConfig.cpp:1387 msgid "Infill" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:422 +#: xs/src/slic3r/GUI/Tab.cpp:850 msgid "Reducing printing time" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:434 +#: xs/src/slic3r/GUI/Tab.cpp:862 msgid "Skirt and brim" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:435 xs/src/libslic3r/GCode/PreviewData.cpp:146 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:88 +#: xs/src/slic3r/GUI/Tab.cpp:863 xs/src/libslic3r/GCode/PreviewData.cpp:166 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:91 msgid "Skirt" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:444 xs/src/slic3r/GUI/Tab.cpp:445 -#: xs/src/libslic3r/PrintConfig.cpp:191 xs/src/libslic3r/PrintConfig.cpp:1037 -#: xs/src/libslic3r/PrintConfig.cpp:1387 xs/src/libslic3r/PrintConfig.cpp:1394 -#: xs/src/libslic3r/PrintConfig.cpp:1406 xs/src/libslic3r/PrintConfig.cpp:1416 -#: xs/src/libslic3r/PrintConfig.cpp:1424 xs/src/libslic3r/PrintConfig.cpp:1439 -#: xs/src/libslic3r/PrintConfig.cpp:1460 xs/src/libslic3r/PrintConfig.cpp:1471 -#: xs/src/libslic3r/PrintConfig.cpp:1487 xs/src/libslic3r/PrintConfig.cpp:1496 -#: xs/src/libslic3r/PrintConfig.cpp:1505 xs/src/libslic3r/PrintConfig.cpp:1516 -#: xs/src/libslic3r/PrintConfig.cpp:1532 xs/src/libslic3r/PrintConfig.cpp:1540 -#: xs/src/libslic3r/PrintConfig.cpp:1541 xs/src/libslic3r/PrintConfig.cpp:1550 -#: xs/src/libslic3r/PrintConfig.cpp:1558 xs/src/libslic3r/PrintConfig.cpp:1572 -#: xs/src/libslic3r/GCode/PreviewData.cpp:147 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:89 +#: xs/src/slic3r/GUI/Tab.cpp:872 xs/src/slic3r/GUI/Tab.cpp:873 +#: xs/src/libslic3r/PrintConfig.cpp:219 xs/src/libslic3r/PrintConfig.cpp:1137 +#: xs/src/libslic3r/PrintConfig.cpp:1487 xs/src/libslic3r/PrintConfig.cpp:1494 +#: xs/src/libslic3r/PrintConfig.cpp:1506 xs/src/libslic3r/PrintConfig.cpp:1516 +#: xs/src/libslic3r/PrintConfig.cpp:1524 xs/src/libslic3r/PrintConfig.cpp:1539 +#: xs/src/libslic3r/PrintConfig.cpp:1560 xs/src/libslic3r/PrintConfig.cpp:1571 +#: xs/src/libslic3r/PrintConfig.cpp:1587 xs/src/libslic3r/PrintConfig.cpp:1596 +#: xs/src/libslic3r/PrintConfig.cpp:1605 xs/src/libslic3r/PrintConfig.cpp:1616 +#: xs/src/libslic3r/PrintConfig.cpp:1630 xs/src/libslic3r/PrintConfig.cpp:1638 +#: xs/src/libslic3r/PrintConfig.cpp:1639 xs/src/libslic3r/PrintConfig.cpp:1648 +#: xs/src/libslic3r/PrintConfig.cpp:1656 xs/src/libslic3r/PrintConfig.cpp:1670 +#: xs/src/libslic3r/GCode/PreviewData.cpp:167 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:92 msgid "Support material" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:450 +#: xs/src/slic3r/GUI/Tab.cpp:878 msgid "Raft" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:454 +#: xs/src/slic3r/GUI/Tab.cpp:882 msgid "Options for support material and raft" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:468 xs/src/libslic3r/PrintConfig.cpp:118 -#: xs/src/libslic3r/PrintConfig.cpp:278 xs/src/libslic3r/PrintConfig.cpp:635 -#: xs/src/libslic3r/PrintConfig.cpp:747 xs/src/libslic3r/PrintConfig.cpp:986 -#: xs/src/libslic3r/PrintConfig.cpp:1208 xs/src/libslic3r/PrintConfig.cpp:1258 -#: xs/src/libslic3r/PrintConfig.cpp:1309 xs/src/libslic3r/PrintConfig.cpp:1632 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:71 +#: xs/src/slic3r/GUI/Tab.cpp:896 xs/src/libslic3r/PrintConfig.cpp:118 +#: xs/src/libslic3r/PrintConfig.cpp:306 xs/src/libslic3r/PrintConfig.cpp:697 +#: xs/src/libslic3r/PrintConfig.cpp:809 xs/src/libslic3r/PrintConfig.cpp:1071 +#: xs/src/libslic3r/PrintConfig.cpp:1308 xs/src/libslic3r/PrintConfig.cpp:1358 +#: xs/src/libslic3r/PrintConfig.cpp:1409 xs/src/libslic3r/PrintConfig.cpp:1730 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:70 msgid "Speed" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:469 +#: xs/src/slic3r/GUI/Tab.cpp:897 msgid "Speed for print moves" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:481 +#: xs/src/slic3r/GUI/Tab.cpp:909 msgid "Speed for non-print moves" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:484 +#: xs/src/slic3r/GUI/Tab.cpp:912 msgid "Modifiers" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:487 +#: xs/src/slic3r/GUI/Tab.cpp:915 msgid "Acceleration control (advanced)" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:494 +#: xs/src/slic3r/GUI/Tab.cpp:922 msgid "Autospeed (advanced)" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:500 +#: xs/src/slic3r/GUI/Tab.cpp:928 msgid "Multiple Extruders" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:501 xs/src/slic3r/GUI/Tab.cpp:1040 -#: xs/src/libslic3r/PrintConfig.cpp:308 xs/src/libslic3r/PrintConfig.cpp:702 -#: xs/src/libslic3r/PrintConfig.cpp:965 xs/src/libslic3r/PrintConfig.cpp:1279 -#: xs/src/libslic3r/PrintConfig.cpp:1452 xs/src/libslic3r/PrintConfig.cpp:1478 +#: xs/src/slic3r/GUI/Tab.cpp:929 xs/src/slic3r/GUI/Tab.cpp:1470 +#: xs/src/libslic3r/PrintConfig.cpp:336 xs/src/libslic3r/PrintConfig.cpp:764 +#: xs/src/libslic3r/PrintConfig.cpp:1050 xs/src/libslic3r/PrintConfig.cpp:1379 +#: xs/src/libslic3r/PrintConfig.cpp:1552 xs/src/libslic3r/PrintConfig.cpp:1578 msgid "Extruders" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:508 +#: xs/src/slic3r/GUI/Tab.cpp:936 msgid "Ooze prevention" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:512 xs/src/libslic3r/GCode/PreviewData.cpp:149 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:91 +#: xs/src/slic3r/GUI/Tab.cpp:940 xs/src/libslic3r/GCode/PreviewData.cpp:169 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:94 msgid "Wipe tower" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:523 +#: xs/src/slic3r/GUI/Tab.cpp:952 msgid "Extrusion width" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:533 +#: xs/src/slic3r/GUI/Tab.cpp:962 msgid "Overlap" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:536 +#: xs/src/slic3r/GUI/Tab.cpp:965 msgid "Flow" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:539 +#: xs/src/slic3r/GUI/Tab.cpp:968 msgid "Other" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:546 +#: xs/src/slic3r/GUI/Tab.cpp:975 msgid "Output options" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:547 +#: xs/src/slic3r/GUI/Tab.cpp:976 msgid "Sequential printing" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:549 +#: xs/src/slic3r/GUI/Tab.cpp:978 msgid "Extruder clearance (mm)" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:558 +#: xs/src/slic3r/GUI/Tab.cpp:987 msgid "Output file" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:564 xs/src/libslic3r/PrintConfig.cpp:1008 +#: xs/src/slic3r/GUI/Tab.cpp:993 xs/src/libslic3r/PrintConfig.cpp:1093 msgid "Post-processing scripts" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:570 xs/src/slic3r/GUI/Tab.cpp:571 -#: xs/src/slic3r/GUI/Tab.cpp:933 xs/src/slic3r/GUI/Tab.cpp:934 -#: xs/src/slic3r/GUI/Tab.cpp:1234 xs/src/slic3r/GUI/Tab.cpp:1235 +#: xs/src/slic3r/GUI/Tab.cpp:999 xs/src/slic3r/GUI/Tab.cpp:1000 +#: xs/src/slic3r/GUI/Tab.cpp:1349 xs/src/slic3r/GUI/Tab.cpp:1350 +#: xs/src/slic3r/GUI/Tab.cpp:1671 xs/src/slic3r/GUI/Tab.cpp:1672 msgid "Notes" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:577 xs/src/slic3r/GUI/Tab.cpp:941 +#: xs/src/slic3r/GUI/Tab.cpp:1006 xs/src/slic3r/GUI/Tab.cpp:1357 +#: xs/src/slic3r/GUI/Tab.cpp:1678 msgid "Dependencies" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:578 xs/src/slic3r/GUI/Tab.cpp:942 +#: xs/src/slic3r/GUI/Tab.cpp:1007 xs/src/slic3r/GUI/Tab.cpp:1358 +#: xs/src/slic3r/GUI/Tab.cpp:1679 msgid "Profile dependencies" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:579 xs/src/slic3r/GUI/Tab.cpp:943 -#: xs/src/slic3r/GUI/Tab.cpp:1746 xs/src/libslic3r/PrintConfig.cpp:143 +#: xs/src/slic3r/GUI/Tab.cpp:1008 xs/src/slic3r/GUI/Tab.cpp:1359 +#: xs/src/slic3r/GUI/Tab.cpp:2241 xs/src/libslic3r/PrintConfig.cpp:143 msgid "Compatible printers" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:603 -#, possible-c-format +#: xs/src/slic3r/GUI/Tab.cpp:1041 +#, no-c-format msgid "" "The Spiral Vase mode requires:\n" "- one perimeter\n" @@ -395,25 +840,11 @@ msgid "" "Shall I adjust those settings in order to enable Spiral Vase?" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:610 +#: xs/src/slic3r/GUI/Tab.cpp:1048 msgid "Spiral Vase" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:630 -msgid "" -"The Wipe Tower currently supports only:\n" -"- first layer height 0.2mm\n" -"- layer height from 0.15mm to 0.35mm\n" -"\n" -"Shall I adjust those settings in order to enable the Wipe Tower?" -msgstr "" - -#: xs/src/slic3r/GUI/Tab.cpp:634 xs/src/slic3r/GUI/Tab.cpp:656 -#: xs/src/slic3r/GUI/Tab.cpp:673 -msgid "Wipe Tower" -msgstr "" - -#: xs/src/slic3r/GUI/Tab.cpp:652 +#: xs/src/slic3r/GUI/Tab.cpp:1069 msgid "" "The Wipe Tower currently supports the non-soluble supports only\n" "if they are printed with the current extruder without triggering a tool " @@ -424,7 +855,11 @@ msgid "" "Shall I adjust those settings in order to enable the Wipe Tower?" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:670 +#: xs/src/slic3r/GUI/Tab.cpp:1073 xs/src/slic3r/GUI/Tab.cpp:1090 +msgid "Wipe Tower" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:1087 msgid "" "For the Wipe Tower to work with the soluble supports, the support layers\n" "need to be synchronized with the object layers.\n" @@ -432,7 +867,7 @@ msgid "" "Shall I synchronize support layers in order to enable the Wipe Tower?" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:688 +#: xs/src/slic3r/GUI/Tab.cpp:1105 msgid "" "Supports work better, if the following feature is enabled:\n" "- Detect bridging perimeters\n" @@ -440,355 +875,479 @@ msgid "" "Shall I adjust those settings for supports?" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:691 +#: xs/src/slic3r/GUI/Tab.cpp:1108 msgid "Support Generator" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:733 +#: xs/src/slic3r/GUI/Tab.cpp:1150 msgid "The " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:733 -#, possible-c-format +#: xs/src/slic3r/GUI/Tab.cpp:1150 +#, no-c-format msgid "" " infill pattern is not supposed to work at 100% density.\n" "\n" "Shall I switch to rectilinear fill pattern?" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:860 xs/src/slic3r/GUI/Tab.cpp:861 -#: lib/Slic3r/GUI/Plater.pm:368 +#: xs/src/slic3r/GUI/Tab.cpp:1255 xs/src/slic3r/GUI/Tab.cpp:1256 +#: lib/Slic3r/GUI/Plater.pm:378 msgid "Filament" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:868 +#: xs/src/slic3r/GUI/Tab.cpp:1263 msgid "Temperature " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:869 xs/src/slic3r/GUI/Tab.cpp:1313 -#: xs/src/libslic3r/PrintConfig.cpp:307 +#: xs/src/slic3r/GUI/Tab.cpp:1264 xs/src/libslic3r/PrintConfig.cpp:335 msgid "Extruder" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:874 +#: xs/src/slic3r/GUI/Tab.cpp:1269 msgid "Bed" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:879 +#: xs/src/slic3r/GUI/Tab.cpp:1274 msgid "Cooling" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:880 xs/src/libslic3r/PrintConfig.cpp:929 -#: xs/src/libslic3r/PrintConfig.cpp:1702 +#: xs/src/slic3r/GUI/Tab.cpp:1275 xs/src/libslic3r/PrintConfig.cpp:1005 +#: xs/src/libslic3r/PrintConfig.cpp:1800 msgid "Enable" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:891 +#: xs/src/slic3r/GUI/Tab.cpp:1286 msgid "Fan settings" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:892 +#: xs/src/slic3r/GUI/Tab.cpp:1287 msgid "Fan speed" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:900 +#: xs/src/slic3r/GUI/Tab.cpp:1295 msgid "Cooling thresholds" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:906 +#: xs/src/slic3r/GUI/Tab.cpp:1301 msgid "Filament properties" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:910 +#: xs/src/slic3r/GUI/Tab.cpp:1305 msgid "Print speed override" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:920 xs/src/slic3r/GUI/Tab.cpp:1197 +#: xs/src/slic3r/GUI/Tab.cpp:1315 +msgid "Toolchange behaviour" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:1319 +msgid "Ramming" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:1321 +msgid "Ramming settings" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:1336 xs/src/slic3r/GUI/Tab.cpp:1634 msgid "Custom G-code" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:921 xs/src/slic3r/GUI/Tab.cpp:1198 -#: xs/src/libslic3r/PrintConfig.cpp:1349 xs/src/libslic3r/PrintConfig.cpp:1364 +#: xs/src/slic3r/GUI/Tab.cpp:1337 xs/src/slic3r/GUI/Tab.cpp:1635 +#: xs/src/libslic3r/PrintConfig.cpp:1449 xs/src/libslic3r/PrintConfig.cpp:1464 msgid "Start G-code" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:927 xs/src/slic3r/GUI/Tab.cpp:1204 -#: xs/src/libslic3r/PrintConfig.cpp:217 xs/src/libslic3r/PrintConfig.cpp:227 +#: xs/src/slic3r/GUI/Tab.cpp:1343 xs/src/slic3r/GUI/Tab.cpp:1641 +#: xs/src/libslic3r/PrintConfig.cpp:245 xs/src/libslic3r/PrintConfig.cpp:255 msgid "End G-code" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1011 xs/src/slic3r/GUI/Preferences.cpp:11 +#: xs/src/slic3r/GUI/Tab.cpp:1438 xs/src/slic3r/GUI/Preferences.cpp:17 msgid "General" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1012 +#: xs/src/slic3r/GUI/Tab.cpp:1439 msgid "Size and coordinates" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1014 xs/src/libslic3r/PrintConfig.cpp:34 +#: xs/src/slic3r/GUI/Tab.cpp:1441 xs/src/libslic3r/PrintConfig.cpp:34 msgid "Bed shape" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1016 xs/src/slic3r/GUI/Tab.cpp:1715 +#: xs/src/slic3r/GUI/Tab.cpp:1443 xs/src/slic3r/GUI/Tab.cpp:2209 msgid " Set " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1036 +#: xs/src/slic3r/GUI/Tab.cpp:1466 msgid "Capabilities" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1041 +#: xs/src/slic3r/GUI/Tab.cpp:1471 msgid "Number of extruders of the printer." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1063 +#: xs/src/slic3r/GUI/Tab.cpp:1496 msgid "USB/Serial connection" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1064 xs/src/libslic3r/PrintConfig.cpp:1200 +#: xs/src/slic3r/GUI/Tab.cpp:1497 xs/src/libslic3r/PrintConfig.cpp:1300 msgid "Serial port" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1069 +#: xs/src/slic3r/GUI/Tab.cpp:1502 msgid "Rescan serial ports" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1078 xs/src/slic3r/GUI/Tab.cpp:1125 +#: xs/src/slic3r/GUI/Tab.cpp:1511 xs/src/slic3r/GUI/Tab.cpp:1558 msgid "Test" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1091 +#: xs/src/slic3r/GUI/Tab.cpp:1524 msgid "Connection to printer works correctly." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1091 xs/src/slic3r/GUI/Tab.cpp:1135 +#: xs/src/slic3r/GUI/Tab.cpp:1524 xs/src/slic3r/GUI/Tab.cpp:1568 msgid "Success!" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1094 +#: xs/src/slic3r/GUI/Tab.cpp:1527 msgid "Connection failed." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1106 +#: xs/src/slic3r/GUI/Tab.cpp:1539 xs/src/slic3r/Utils/OctoPrint.cpp:50 msgid "OctoPrint upload" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1109 xs/src/slic3r/GUI/Tab.cpp:1156 +#: xs/src/slic3r/GUI/Tab.cpp:1542 xs/src/slic3r/GUI/Tab.cpp:1591 msgid " Browse " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1135 lib/Slic3r/GUI/MainFrame.pm:209 +#: xs/src/slic3r/GUI/Tab.cpp:1568 msgid "Connection to OctoPrint works correctly." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1138 +#: xs/src/slic3r/GUI/Tab.cpp:1571 msgid "Could not connect to OctoPrint" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1138 +#: xs/src/slic3r/GUI/Tab.cpp:1571 msgid "Note: OctoPrint version at least 1.1.0 is required." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1162 +#: xs/src/slic3r/GUI/Tab.cpp:1597 msgid "Certificate files (*.crt, *.pem)|*.crt;*.pem|All files|*.*" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1163 +#: xs/src/slic3r/GUI/Tab.cpp:1598 msgid "Open CA certificate file" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1177 +#: xs/src/slic3r/GUI/Tab.cpp:1612 msgid "" "HTTPS CA file is optional. It is only needed if you use HTTPS with a self-" "signed certificate." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1188 -msgid "Firmware" -msgstr "" - -#: xs/src/slic3r/GUI/Tab.cpp:1210 xs/src/libslic3r/PrintConfig.cpp:48 +#: xs/src/slic3r/GUI/Tab.cpp:1647 xs/src/libslic3r/PrintConfig.cpp:48 msgid "Before layer change G-code" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1216 xs/src/libslic3r/PrintConfig.cpp:766 +#: xs/src/slic3r/GUI/Tab.cpp:1653 xs/src/libslic3r/PrintConfig.cpp:835 msgid "After layer change G-code" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1222 xs/src/libslic3r/PrintConfig.cpp:1609 +#: xs/src/slic3r/GUI/Tab.cpp:1659 xs/src/libslic3r/PrintConfig.cpp:1707 msgid "Tool change G-code" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1228 +#: xs/src/slic3r/GUI/Tab.cpp:1665 msgid "Between objects G-code (for sequential printing)" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1266 xs/src/libslic3r/GCode/PreviewData.cpp:400 +#: xs/src/slic3r/GUI/Tab.cpp:1716 xs/src/slic3r/GUI/Tab.cpp:1722 +msgid "Single extruder MM setup" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:1723 +msgid "Single extruder multimaterial parameters" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:1734 xs/src/libslic3r/GCode/PreviewData.cpp:440 #, possible-c-format msgid "Extruder %d" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1273 +#: xs/src/slic3r/GUI/Tab.cpp:1741 msgid "Layer height limits" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1278 +#: xs/src/slic3r/GUI/Tab.cpp:1746 msgid "Position (for multi-extruder printers)" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1281 +#: xs/src/slic3r/GUI/Tab.cpp:1749 msgid "Retraction" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1284 +#: xs/src/slic3r/GUI/Tab.cpp:1752 msgid "Only lift Z" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1297 +#: xs/src/slic3r/GUI/Tab.cpp:1765 msgid "" "Retraction when tool is disabled (advanced settings for multi-extruder " "setups)" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1301 lib/Slic3r/GUI/Plater.pm:150 -#: lib/Slic3r/GUI/Plater.pm:2095 +#: xs/src/slic3r/GUI/Tab.cpp:1769 lib/Slic3r/GUI/Plater.pm:160 +#: lib/Slic3r/GUI/Plater.pm:2154 msgid "Preview" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1386 +#: xs/src/slic3r/GUI/Tab.cpp:1848 msgid "" "The Wipe option is not available when using the Firmware Retraction mode.\n" "\n" "Shall I disable it in order to enable Firmware Retraction?" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1388 +#: xs/src/slic3r/GUI/Tab.cpp:1850 msgid "Firmware Retraction" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1547 +#: xs/src/slic3r/GUI/Tab.cpp:2022 msgid "Default " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1547 +#: xs/src/slic3r/GUI/Tab.cpp:2022 msgid " preset" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1548 +#: xs/src/slic3r/GUI/Tab.cpp:2023 msgid " preset\n" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1566 +#: xs/src/slic3r/GUI/Tab.cpp:2041 msgid "" "\n" "\n" "is not compatible with printer\n" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1566 +#: xs/src/slic3r/GUI/Tab.cpp:2041 msgid "" "\n" "\n" "and it has the following unsaved changes:" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1567 +#: xs/src/slic3r/GUI/Tab.cpp:2042 msgid "" "\n" "\n" "has the following unsaved changes:" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1569 +#: xs/src/slic3r/GUI/Tab.cpp:2044 msgid "" "\n" "\n" "Discard changes and continue anyway?" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1570 +#: xs/src/slic3r/GUI/Tab.cpp:2045 msgid "Unsaved Changes" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1638 +#: xs/src/slic3r/GUI/Tab.cpp:2119 msgid "The supplied name is empty. It can't be saved." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1658 +#: xs/src/slic3r/GUI/Tab.cpp:2124 +msgid "Cannot overwrite a system profile." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2128 +msgid "Cannot overwrite an external." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2152 msgid "remove" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1658 +#: xs/src/slic3r/GUI/Tab.cpp:2152 msgid "delete" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1659 +#: xs/src/slic3r/GUI/Tab.cpp:2153 msgid "Are you sure you want to " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1659 +#: xs/src/slic3r/GUI/Tab.cpp:2153 msgid " the selected preset?" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1660 +#: xs/src/slic3r/GUI/Tab.cpp:2154 msgid "Remove" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1660 lib/Slic3r/GUI/Plater.pm:178 -#: lib/Slic3r/GUI/Plater.pm:196 lib/Slic3r/GUI/Plater.pm:1991 +#: xs/src/slic3r/GUI/Tab.cpp:2154 lib/Slic3r/GUI/Plater.pm:188 +#: lib/Slic3r/GUI/Plater.pm:206 lib/Slic3r/GUI/Plater.pm:2050 msgid "Delete" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1661 +#: xs/src/slic3r/GUI/Tab.cpp:2155 msgid " Preset" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1714 +#: xs/src/slic3r/GUI/Tab.cpp:2208 msgid "All" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1745 +#: xs/src/slic3r/GUI/Tab.cpp:2240 msgid "Select the printers this profile is compatible with." msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1834 lib/Slic3r/GUI/MainFrame.pm:509 -#: lib/Slic3r/GUI/Plater.pm:1615 +#: xs/src/slic3r/GUI/Tab.cpp:2286 xs/src/slic3r/GUI/Tab.cpp:2372 +#: xs/src/slic3r/GUI/Preset.cpp:605 xs/src/slic3r/GUI/Preset.cpp:645 +#: xs/src/slic3r/GUI/Preset.cpp:670 xs/src/slic3r/GUI/Preset.cpp:702 +#: xs/src/slic3r/GUI/PresetBundle.cpp:1069 +#: xs/src/slic3r/GUI/PresetBundle.cpp:1122 lib/Slic3r/GUI/Plater.pm:552 +msgid "System presets" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2287 xs/src/slic3r/GUI/Tab.cpp:2373 +msgid "Default presets" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2442 +msgid "" +"LOCKED LOCK;indicates that the settings are the same as the system values " +"for the current option group" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2445 +msgid "" +"UNLOCKED LOCK;indicates that some settings were changed and are not equal to " +"the system values for the current option group.\n" +"Click the UNLOCKED LOCK icon to reset all settings for current option group " +"to the system values." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2451 +msgid "" +"WHITE BULLET;for the left button: \tindicates a non-system preset,\n" +"for the right button: \tindicates that the settings hasn't been modified." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2455 +msgid "" +"BACK ARROW;indicates that the settings were changed and are not equal to the " +"last saved preset for the current option group.\n" +"Click the BACK ARROW icon to reset all settings for the current option group " +"to the last saved preset." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2481 +msgid "" +"LOCKED LOCK icon indicates that the settings are the same as the system " +"values for the current option group" +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2483 +msgid "" +"UNLOCKED LOCK icon indicates that some settings were changed and are not " +"equal to the system values for the current option group.\n" +"Click to reset all settings for current option group to the system values." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2486 +msgid "WHITE BULLET icon indicates a non system preset." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2489 +msgid "" +"WHITE BULLET icon indicates that the settings are the same as in the last " +"saved preset for the current option group." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2491 +msgid "" +"BACK ARROW icon indicates that the settings were changed and are not equal " +"to the last saved preset for the current option group.\n" +"Click to reset all settings for the current option group to the last saved " +"preset." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2497 +msgid "" +"LOCKED LOCK icon indicates that the value is the same as the system value." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2498 +msgid "" +"UNLOCKED LOCK icon indicates that the value was changed and is not equal to " +"the system value.\n" +"Click to reset current value to the system value." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2504 +msgid "" +"WHITE BULLET icon indicates that the value is the same as in the last saved " +"preset." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2505 +msgid "" +"BACK ARROW icon indicates that the value was changed and is not equal to the " +"last saved preset.\n" +"Click to reset current value to the last saved preset." +msgstr "" + +#: xs/src/slic3r/GUI/Tab.cpp:2575 lib/Slic3r/GUI/MainFrame.pm:445 +#: lib/Slic3r/GUI/Plater.pm:1660 msgid "Save " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1834 +#: xs/src/slic3r/GUI/Tab.cpp:2575 msgid " as:" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1868 +#: xs/src/slic3r/GUI/Tab.cpp:2609 msgid "" "The supplied name is not valid; the following characters are not allowed:" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1871 +#: xs/src/slic3r/GUI/Tab.cpp:2612 msgid "The supplied name is not available." msgstr "" -#: xs/src/slic3r/GUI/Tab.hpp:185 +#: xs/src/slic3r/GUI/Tab.hpp:283 msgid "Print Settings" msgstr "" -#: xs/src/slic3r/GUI/Tab.hpp:205 +#: xs/src/slic3r/GUI/Tab.hpp:303 msgid "Filament Settings" msgstr "" -#: xs/src/slic3r/GUI/Tab.hpp:226 +#: xs/src/slic3r/GUI/Tab.hpp:325 msgid "Printer Settings" msgstr "" -#: xs/src/slic3r/GUI/Tab.hpp:240 +#: xs/src/slic3r/GUI/Tab.hpp:340 msgid "Save preset" msgstr "" -#: xs/src/slic3r/GUI/Field.cpp:59 +#: xs/src/slic3r/GUI/Field.cpp:72 msgid "default" msgstr "" +#: xs/src/slic3r/GUI/Preset.cpp:649 xs/src/slic3r/GUI/Preset.cpp:706 +#: xs/src/slic3r/GUI/PresetBundle.cpp:1127 lib/Slic3r/GUI/Plater.pm:553 +msgid "User presets" +msgstr "" + #: xs/src/slic3r/GUI/PresetHints.cpp:27 #, possible-c-format msgid "" @@ -915,123 +1474,300 @@ msgstr "" msgid "%d lines: %.2lf mm" msgstr "" -#: xs/src/slic3r/GUI/Preferences.hpp:17 -msgid "Preferences" -msgstr "" - -#: xs/src/slic3r/GUI/Preferences.cpp:27 +#: xs/src/slic3r/GUI/Preferences.cpp:34 msgid "Remember output directory" msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:29 +#: xs/src/slic3r/GUI/Preferences.cpp:36 msgid "" "If this is enabled, Slic3r will prompt the last output directory instead of " "the one containing the input files." msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:35 +#: xs/src/slic3r/GUI/Preferences.cpp:42 msgid "Auto-center parts" msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:37 +#: xs/src/slic3r/GUI/Preferences.cpp:44 msgid "" "If this is enabled, Slic3r will auto-center objects around the print bed " "center." msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:43 +#: xs/src/slic3r/GUI/Preferences.cpp:50 msgid "Background processing" msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:45 +#: xs/src/slic3r/GUI/Preferences.cpp:52 msgid "" "If this is enabled, Slic3r will pre-process objects as soon as they're " "loaded in order to save time when exporting G-code." msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:51 +#: xs/src/slic3r/GUI/Preferences.cpp:74 msgid "Disable USB/serial connection" msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:53 +#: xs/src/slic3r/GUI/Preferences.cpp:76 msgid "" "Disable communication with the printer over a serial / USB cable. This " "simplifies the user interface in case the printer is never attached to the " "computer." msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:59 +#: xs/src/slic3r/GUI/Preferences.cpp:82 msgid "Suppress \" - default - \" presets" msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:61 +#: xs/src/slic3r/GUI/Preferences.cpp:84 msgid "" "Suppress \" - default - \" presets in the Print / Filament / Printer " "selections once there are any other valid presets available." msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:67 +#: xs/src/slic3r/GUI/Preferences.cpp:90 msgid "Show incompatible print and filament presets" msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:69 +#: xs/src/slic3r/GUI/Preferences.cpp:92 msgid "" "When checked, the print and filament presets are shown in the preset editor " "even if they are marked as incompatible with the active printer" msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:75 +#: xs/src/slic3r/GUI/Preferences.cpp:98 msgid "Use legacy OpenGL 1.1 rendering" msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:77 +#: xs/src/slic3r/GUI/Preferences.cpp:100 msgid "" "If you have rendering issues caused by a buggy OpenGL 2.0 driver, you may " "try to check this checkbox. This will disable the layer height editing and " "anti aliasing, so it is likely better to upgrade your graphics driver." msgstr "" -#: xs/src/slic3r/GUI/Preferences.cpp:101 +#: xs/src/slic3r/GUI/Preferences.cpp:124 msgid "You need to restart Slic3r to make the changes effective." msgstr "" -#: xs/src/slic3r/GUI/BonjourDialog.cpp:53 -msgid "Network lookup" +#: xs/src/slic3r/GUI/RammingChart.cpp:28 +msgid "NO RAMMING AT ALL" msgstr "" -#: xs/src/slic3r/GUI/BonjourDialog.cpp:66 -msgid "Address" +#: xs/src/slic3r/GUI/RammingChart.cpp:81 +msgid "Time" msgstr "" -#: xs/src/slic3r/GUI/BonjourDialog.cpp:67 -msgid "Hostname" +#: xs/src/slic3r/GUI/RammingChart.cpp:81 xs/src/slic3r/GUI/RammingChart.cpp:86 +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:82 +#: xs/src/libslic3r/PrintConfig.cpp:480 +msgid "s" msgstr "" -#: xs/src/slic3r/GUI/BonjourDialog.cpp:68 -msgid "Service name" +#: xs/src/slic3r/GUI/RammingChart.cpp:86 +msgid "Volumetric speed" msgstr "" -#: xs/src/slic3r/GUI/BonjourDialog.cpp:69 -msgid "OctoPrint version" +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:27 +msgid "Update available" msgstr "" -#: xs/src/slic3r/GUI/BonjourDialog.cpp:187 -msgid "Searching for devices" +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:27 +msgid "New version of Slic3r PE is available" msgstr "" -#: xs/src/slic3r/GUI/BonjourDialog.cpp:194 -msgid "Finished." +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:34 +msgid "To download, follow the link below." msgstr "" -#: xs/src/slic3r/Utils/OctoPrint.cpp:53 -msgid "G-code file successfully uploaded to the OctoPrint server" +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:41 +msgid "Current version:" msgstr "" -#: xs/src/slic3r/Utils/OctoPrint.cpp:67 +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:43 +msgid "New version:" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:51 +msgid "Don't notify about new releases any more" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:69 +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:161 +msgid "Configuration update" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:69 +msgid "Configuration update is available" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:72 +msgid "" +"Would you like to install it?\n" +"\n" +"Note that a full configuration snapshot will be created first. It can then " +"be restored at any time should there be a problem with the new version.\n" +"\n" +"Updated configuration bundles:" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:108 +msgid "Slic3r incompatibility" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:108 +msgid "Slic3r configuration is incompatible" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:111 +msgid "" +"This version of Slic3r PE is not compatible with currently installed " +"configuration bundles.\n" +"This probably happened as a result of running an older Slic3r PE after using " +"a newer one.\n" +"\n" +"You may either exit Slic3r and try again with a newer version, or you may re-" +"run the initial configuration. Doing so will create a backup snapshot of the " +"existing configuration before installing files compatible with this Slic3r.\n" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:120 +#, possible-c-format +msgid "This Slic3r PE version: %s" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:125 +msgid "Incompatible bundles:" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:141 +msgid "Exit Slic3r" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:144 +msgid "Re-configure" +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:165 +#, possible-c-format +msgid "" +"Slic3r PE now uses an updated configuration structure.\n" +"\n" +"So called 'System presets' have been introduced, which hold the built-in " +"default settings for various printers. These System presets cannot be " +"modified, instead, users now may create their own presets inheriting " +"settings from one of the System presets.\n" +"An inheriting preset may either inherit a particular value from its parent " +"or override it with a customized value.\n" +"\n" +"Please proceed with the %s that follows to set up the new presets and to " +"choose whether to enable automatic preset updates." +msgstr "" + +#: xs/src/slic3r/GUI/UpdateDialogs.cpp:181 +msgid "For more information please visit our wiki page:" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:14 +msgid "Ramming customization" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:40 +msgid "" +"Ramming denotes the rapid extrusion just before a tool change in a single-" +"extruder MM printer. Its purpose is to properly shape the end of the " +"unloaded filament so it does not prevent insertion of the new filament and " +"can itself be reinserted later. This phase is important and different " +"materials can require different extrusion speeds to get the good shape. For " +"this reason, the extrusion rates during ramming are adjustable.\n" +"\n" +"This is an expert-level setting, incorrect adjustment will likely lead to " +"jams, extruder wheel grinding into filament etc." +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:82 +msgid "Total ramming time" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:84 +msgid "Total rammed volume" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:88 +msgid "Ramming line width" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:90 +msgid "Ramming line spacing" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:142 +msgid "Wipe tower - Purging volume adjustment" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:223 +#, possible-c-format +msgid "" +"Here you can adjust required purging volume (mm%s) for any given pair of " +"tools." +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:224 +msgid "Extruder changed to" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:232 +msgid "unloaded" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:233 +msgid "loaded" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:238 +msgid "Tool #" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:245 +msgid "" +"Total purging volume is calculated by summing two values below, depending on " +"which tools are loaded/unloaded." +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:246 +#, possible-c-format +msgid "Volume to purge (mm%s) when the filament is being" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:260 +msgid "From" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:325 +msgid "" +"Switching to simple settings will discard changes done in the advanced " +"mode!\n" +"\n" +"Do you want to proceed?" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:337 +msgid "Show simplified settings" +msgstr "" + +#: xs/src/slic3r/GUI/WipeTowerDialog.cpp:337 +msgid "Show advanced settings" +msgstr "" + +#: xs/src/slic3r/Utils/OctoPrint.cpp:47 msgid "Error while uploading to the OctoPrint server" msgstr "" -#: xs/src/slic3r/Utils/OctoPrint.cpp:102 +#: xs/src/slic3r/Utils/OctoPrint.cpp:51 lib/Slic3r/GUI/Plater.pm:1493 +msgid "Sending G-code file to the OctoPrint server..." +msgstr "" + +#: xs/src/slic3r/Utils/OctoPrint.cpp:120 msgid "Invalid API key" msgstr "" @@ -1046,7 +1782,7 @@ msgid "" "feature slows down both the print and the G-code generation." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:38 xs/src/libslic3r/PrintConfig.cpp:1579 +#: xs/src/libslic3r/PrintConfig.cpp:38 xs/src/libslic3r/PrintConfig.cpp:1677 msgid "Other layers" msgstr "" @@ -1077,20 +1813,20 @@ msgid "" "default extruder and bed temperature are reset using non-wait command; " "however if M104, M109, M140 or M190 are detected in this custom code, Slic3r " "will not add temperature commands. Note that you can use placeholder " -"variables for all Slic3r settings, so you can put a \"M109 " -"S[first_layer_temperature]\" command wherever you want." +"variables for all Slic3r settings, so you can put a \"M109 S" +"[first_layer_temperature]\" command wherever you want." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:68 lib/Slic3r/GUI/MainFrame.pm:364 +#: xs/src/libslic3r/PrintConfig.cpp:68 lib/Slic3r/GUI/MainFrame.pm:307 msgid "Bottom" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:69 xs/src/libslic3r/PrintConfig.cpp:239 -#: xs/src/libslic3r/PrintConfig.cpp:290 xs/src/libslic3r/PrintConfig.cpp:298 -#: xs/src/libslic3r/PrintConfig.cpp:604 xs/src/libslic3r/PrintConfig.cpp:762 -#: xs/src/libslic3r/PrintConfig.cpp:778 xs/src/libslic3r/PrintConfig.cpp:948 -#: xs/src/libslic3r/PrintConfig.cpp:996 xs/src/libslic3r/PrintConfig.cpp:1159 -#: xs/src/libslic3r/PrintConfig.cpp:1590 xs/src/libslic3r/PrintConfig.cpp:1646 +#: xs/src/libslic3r/PrintConfig.cpp:69 xs/src/libslic3r/PrintConfig.cpp:267 +#: xs/src/libslic3r/PrintConfig.cpp:318 xs/src/libslic3r/PrintConfig.cpp:326 +#: xs/src/libslic3r/PrintConfig.cpp:666 xs/src/libslic3r/PrintConfig.cpp:831 +#: xs/src/libslic3r/PrintConfig.cpp:847 xs/src/libslic3r/PrintConfig.cpp:1024 +#: xs/src/libslic3r/PrintConfig.cpp:1081 xs/src/libslic3r/PrintConfig.cpp:1259 +#: xs/src/libslic3r/PrintConfig.cpp:1688 xs/src/libslic3r/PrintConfig.cpp:1744 msgid "Layers and Perimeters" msgstr "" @@ -1112,9 +1848,9 @@ msgid "" "disable acceleration control for bridges." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:80 xs/src/libslic3r/PrintConfig.cpp:174 -#: xs/src/libslic3r/PrintConfig.cpp:576 xs/src/libslic3r/PrintConfig.cpp:684 -#: xs/src/libslic3r/PrintConfig.cpp:959 +#: xs/src/libslic3r/PrintConfig.cpp:80 xs/src/libslic3r/PrintConfig.cpp:190 +#: xs/src/libslic3r/PrintConfig.cpp:638 xs/src/libslic3r/PrintConfig.cpp:746 +#: xs/src/libslic3r/PrintConfig.cpp:1044 msgid "mm/s²" msgstr "" @@ -1129,9 +1865,9 @@ msgid "" "bridges. Use 180° for zero angle." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:91 xs/src/libslic3r/PrintConfig.cpp:492 -#: xs/src/libslic3r/PrintConfig.cpp:1177 xs/src/libslic3r/PrintConfig.cpp:1188 -#: xs/src/libslic3r/PrintConfig.cpp:1408 xs/src/libslic3r/PrintConfig.cpp:1564 +#: xs/src/libslic3r/PrintConfig.cpp:91 xs/src/libslic3r/PrintConfig.cpp:554 +#: xs/src/libslic3r/PrintConfig.cpp:1277 xs/src/libslic3r/PrintConfig.cpp:1288 +#: xs/src/libslic3r/PrintConfig.cpp:1508 xs/src/libslic3r/PrintConfig.cpp:1662 msgid "°" msgstr "" @@ -1143,9 +1879,9 @@ msgstr "" msgid "This fan speed is enforced during all bridges and overhangs." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:99 xs/src/libslic3r/PrintConfig.cpp:504 -#: xs/src/libslic3r/PrintConfig.cpp:789 xs/src/libslic3r/PrintConfig.cpp:850 -#: xs/src/libslic3r/PrintConfig.cpp:1067 +#: xs/src/libslic3r/PrintConfig.cpp:99 xs/src/libslic3r/PrintConfig.cpp:566 +#: xs/src/libslic3r/PrintConfig.cpp:858 xs/src/libslic3r/PrintConfig.cpp:926 +#: xs/src/libslic3r/PrintConfig.cpp:1167 msgid "%" msgstr "" @@ -1169,11 +1905,12 @@ msgstr "" msgid "Speed for printing bridges." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:120 xs/src/libslic3r/PrintConfig.cpp:638 -#: xs/src/libslic3r/PrintConfig.cpp:749 xs/src/libslic3r/PrintConfig.cpp:811 -#: xs/src/libslic3r/PrintConfig.cpp:868 xs/src/libslic3r/PrintConfig.cpp:988 -#: xs/src/libslic3r/PrintConfig.cpp:1144 xs/src/libslic3r/PrintConfig.cpp:1153 -#: xs/src/libslic3r/PrintConfig.cpp:1543 xs/src/libslic3r/PrintConfig.cpp:1656 +#: xs/src/libslic3r/PrintConfig.cpp:120 xs/src/libslic3r/PrintConfig.cpp:461 +#: xs/src/libslic3r/PrintConfig.cpp:470 xs/src/libslic3r/PrintConfig.cpp:700 +#: xs/src/libslic3r/PrintConfig.cpp:811 xs/src/libslic3r/PrintConfig.cpp:887 +#: xs/src/libslic3r/PrintConfig.cpp:944 xs/src/libslic3r/PrintConfig.cpp:1073 +#: xs/src/libslic3r/PrintConfig.cpp:1244 xs/src/libslic3r/PrintConfig.cpp:1253 +#: xs/src/libslic3r/PrintConfig.cpp:1641 xs/src/libslic3r/PrintConfig.cpp:1754 msgid "mm/s" msgstr "" @@ -1231,65 +1968,103 @@ msgid "" "fan speed according to layer printing time." msgstr "" +#: xs/src/libslic3r/PrintConfig.cpp:170 +msgid "Cooling tube position" +msgstr "" + #: xs/src/libslic3r/PrintConfig.cpp:171 +msgid "Distance of the center-point of the cooling tube from the extruder tip " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:178 +msgid "Cooling tube length" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:179 +msgid "Length of the cooling tube to limit space for cooling moves inside it " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:187 msgid "" "This is the acceleration your printer will be reset to after the role-" "specific acceleration values are used (perimeter/infill). Set zero to " "prevent resetting acceleration at all." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:180 +#: xs/src/libslic3r/PrintConfig.cpp:196 +msgid "Default filament profile" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:197 +msgid "" +"Default filament profile associated with the current printer profile. On " +"selection of the current printer profile, this filament profile will be " +"activated." +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:202 +msgid "Default print profile" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:203 +msgid "" +"Default print profile associated with the current printer profile. On " +"selection of the current printer profile, this print profile will be " +"activated." +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:208 msgid "Disable fan for the first" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:181 +#: xs/src/libslic3r/PrintConfig.cpp:209 msgid "" "You can set this to a positive value to disable fan at all during the first " "layers, so that it does not make adhesion worse." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:183 xs/src/libslic3r/PrintConfig.cpp:694 -#: xs/src/libslic3r/PrintConfig.cpp:1040 xs/src/libslic3r/PrintConfig.cpp:1231 -#: xs/src/libslic3r/PrintConfig.cpp:1292 xs/src/libslic3r/PrintConfig.cpp:1444 -#: xs/src/libslic3r/PrintConfig.cpp:1489 +#: xs/src/libslic3r/PrintConfig.cpp:211 xs/src/libslic3r/PrintConfig.cpp:756 +#: xs/src/libslic3r/PrintConfig.cpp:1140 xs/src/libslic3r/PrintConfig.cpp:1331 +#: xs/src/libslic3r/PrintConfig.cpp:1392 xs/src/libslic3r/PrintConfig.cpp:1544 +#: xs/src/libslic3r/PrintConfig.cpp:1589 msgid "layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:190 +#: xs/src/libslic3r/PrintConfig.cpp:218 msgid "Don't support bridges" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:192 +#: xs/src/libslic3r/PrintConfig.cpp:220 msgid "" "Experimental option for preventing support material from being generated " "under bridged areas." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:198 +#: xs/src/libslic3r/PrintConfig.cpp:226 msgid "Distance between copies" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:199 +#: xs/src/libslic3r/PrintConfig.cpp:227 msgid "Distance used for the auto-arrange feature of the plater." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:207 +#: xs/src/libslic3r/PrintConfig.cpp:235 msgid "Elephant foot compensation" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:209 +#: xs/src/libslic3r/PrintConfig.cpp:237 msgid "" "The first layer will be shrunk in the XY plane by the configured value to " "compensate for the 1st layer squish aka an Elephant Foot effect." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:218 +#: xs/src/libslic3r/PrintConfig.cpp:246 msgid "" "This end procedure is inserted at the end of the output file. Note that you " "can use placeholder variables for all Slic3r settings." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:228 +#: xs/src/libslic3r/PrintConfig.cpp:256 msgid "" "This end procedure is inserted at the end of the output file, before the " "printer end gcode. Note that you can use placeholder variables for all " @@ -1297,38 +2072,38 @@ msgid "" "extruder order." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:238 +#: xs/src/libslic3r/PrintConfig.cpp:266 msgid "Ensure vertical shell thickness" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:240 +#: xs/src/libslic3r/PrintConfig.cpp:268 msgid "" "Add solid infill near sloping surfaces to guarantee the vertical shell " "thickness (top+bottom solid layers)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:246 +#: xs/src/libslic3r/PrintConfig.cpp:274 msgid "Top/bottom fill pattern" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:248 +#: xs/src/libslic3r/PrintConfig.cpp:276 msgid "" "Fill pattern for top/bottom infill. This only affects the external visible " "layer, and not its adjacent solid shells." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:267 xs/src/libslic3r/PrintConfig.cpp:277 +#: xs/src/libslic3r/PrintConfig.cpp:295 xs/src/libslic3r/PrintConfig.cpp:305 msgid "External perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:268 xs/src/libslic3r/PrintConfig.cpp:377 -#: xs/src/libslic3r/PrintConfig.cpp:592 xs/src/libslic3r/PrintConfig.cpp:710 -#: xs/src/libslic3r/PrintConfig.cpp:974 xs/src/libslic3r/PrintConfig.cpp:1299 -#: xs/src/libslic3r/PrintConfig.cpp:1461 xs/src/libslic3r/PrintConfig.cpp:1621 +#: xs/src/libslic3r/PrintConfig.cpp:296 xs/src/libslic3r/PrintConfig.cpp:405 +#: xs/src/libslic3r/PrintConfig.cpp:654 xs/src/libslic3r/PrintConfig.cpp:772 +#: xs/src/libslic3r/PrintConfig.cpp:1059 xs/src/libslic3r/PrintConfig.cpp:1399 +#: xs/src/libslic3r/PrintConfig.cpp:1561 xs/src/libslic3r/PrintConfig.cpp:1719 msgid "Extrusion Width" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:269 +#: xs/src/libslic3r/PrintConfig.cpp:297 msgid "" "Set this to a non-zero value to set a manual extrusion width for external " "perimeters. If left zero, default extrusion width will be used if set, " @@ -1336,60 +2111,60 @@ msgid "" "(for example 200%), it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:272 xs/src/libslic3r/PrintConfig.cpp:597 -#: xs/src/libslic3r/PrintConfig.cpp:715 xs/src/libslic3r/PrintConfig.cpp:979 -#: xs/src/libslic3r/PrintConfig.cpp:1303 xs/src/libslic3r/PrintConfig.cpp:1465 -#: xs/src/libslic3r/PrintConfig.cpp:1626 +#: xs/src/libslic3r/PrintConfig.cpp:300 xs/src/libslic3r/PrintConfig.cpp:659 +#: xs/src/libslic3r/PrintConfig.cpp:777 xs/src/libslic3r/PrintConfig.cpp:1064 +#: xs/src/libslic3r/PrintConfig.cpp:1403 xs/src/libslic3r/PrintConfig.cpp:1565 +#: xs/src/libslic3r/PrintConfig.cpp:1724 msgid "mm or % (leave 0 for default)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:279 +#: xs/src/libslic3r/PrintConfig.cpp:307 msgid "" "This separate setting will affect the speed of external perimeters (the " "visible ones). If expressed as percentage (for example: 80%) it will be " "calculated on the perimeters speed setting above. Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:282 xs/src/libslic3r/PrintConfig.cpp:619 -#: xs/src/libslic3r/PrintConfig.cpp:1262 xs/src/libslic3r/PrintConfig.cpp:1313 -#: xs/src/libslic3r/PrintConfig.cpp:1508 xs/src/libslic3r/PrintConfig.cpp:1638 +#: xs/src/libslic3r/PrintConfig.cpp:310 xs/src/libslic3r/PrintConfig.cpp:681 +#: xs/src/libslic3r/PrintConfig.cpp:1362 xs/src/libslic3r/PrintConfig.cpp:1413 +#: xs/src/libslic3r/PrintConfig.cpp:1608 xs/src/libslic3r/PrintConfig.cpp:1736 msgid "mm/s or %" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:289 +#: xs/src/libslic3r/PrintConfig.cpp:317 msgid "External perimeters first" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:291 +#: xs/src/libslic3r/PrintConfig.cpp:319 msgid "" "Print contour perimeters from the outermost one to the innermost one instead " "of the default inverse order." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:297 +#: xs/src/libslic3r/PrintConfig.cpp:325 msgid "Extra perimeters if needed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:299 -#, possible-c-format +#: xs/src/libslic3r/PrintConfig.cpp:327 +#, no-c-format msgid "" "Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r " "keeps adding perimeters, until more than 70% of the loop immediately above " "is supported." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:309 +#: xs/src/libslic3r/PrintConfig.cpp:337 msgid "" "The extruder to use (unless more specific extruder settings are specified). " "This value overrides perimeter and infill extruders, but not the support " "extruders." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:320 lib/Slic3r/GUI/Plater/3DPreview.pm:69 +#: xs/src/libslic3r/PrintConfig.cpp:348 lib/Slic3r/GUI/Plater/3DPreview.pm:68 msgid "Height" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:321 +#: xs/src/libslic3r/PrintConfig.cpp:349 msgid "" "Set this to the vertical distance between your nozzle tip and (usually) the " "X carriage rods. In other words, this is the height of the clearance " @@ -1397,30 +2172,30 @@ msgid "" "extruder can peek before colliding with other printed objects." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:331 +#: xs/src/libslic3r/PrintConfig.cpp:359 msgid "Radius" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:332 +#: xs/src/libslic3r/PrintConfig.cpp:360 msgid "" "Set this to the clearance radius around your extruder. If the extruder is " "not centered, choose the largest value for safety. This setting is used to " "check for collisions and to display the graphical preview in the plater." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:342 +#: xs/src/libslic3r/PrintConfig.cpp:370 msgid "Extruder Color" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:343 xs/src/libslic3r/PrintConfig.cpp:406 +#: xs/src/libslic3r/PrintConfig.cpp:371 xs/src/libslic3r/PrintConfig.cpp:434 msgid "This is only used in the Slic3r interface as a visual help." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:350 +#: xs/src/libslic3r/PrintConfig.cpp:378 msgid "Extruder offset" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:351 +#: xs/src/libslic3r/PrintConfig.cpp:379 msgid "" "If your firmware doesn't handle the extruder displacement you need the G-" "code to take it into account. This option lets you specify the displacement " @@ -1428,21 +2203,21 @@ msgid "" "coordinates (they will be subtracted from the XY coordinate)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:360 +#: xs/src/libslic3r/PrintConfig.cpp:388 msgid "Extrusion axis" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:361 +#: xs/src/libslic3r/PrintConfig.cpp:389 msgid "" "Use this option to set the axis letter associated to your printer's extruder " "(usually E but some printers use A)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:367 +#: xs/src/libslic3r/PrintConfig.cpp:395 msgid "Extrusion multiplier" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:368 +#: xs/src/libslic3r/PrintConfig.cpp:396 msgid "" "This factor changes the amount of flow proportionally. You may need to tweak " "this setting to get nice surface finish and correct single wall widths. " @@ -1450,11 +2225,11 @@ msgid "" "more, check filament diameter and your firmware E steps." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:376 +#: xs/src/libslic3r/PrintConfig.cpp:404 msgid "Default extrusion width" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:378 +#: xs/src/libslic3r/PrintConfig.cpp:406 msgid "" "Set this to a non-zero value to allow a manual extrusion width. If left to " "zero, Slic3r derives extrusion widths from the nozzle diameter (see the " @@ -1463,74 +2238,113 @@ msgid "" "height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:382 +#: xs/src/libslic3r/PrintConfig.cpp:410 msgid "mm or % (leave 0 for auto)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:387 +#: xs/src/libslic3r/PrintConfig.cpp:415 msgid "Keep fan always on" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:388 +#: xs/src/libslic3r/PrintConfig.cpp:416 msgid "" "If this is enabled, fan will never be disabled and will be kept running at " "least at its minimum speed. Useful for PLA, harmful for ABS." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:394 +#: xs/src/libslic3r/PrintConfig.cpp:422 msgid "Enable fan if layer print time is below" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:395 +#: xs/src/libslic3r/PrintConfig.cpp:423 msgid "" "If layer print time is estimated below this number of seconds, fan will be " "enabled and its speed will be calculated by interpolating the minimum and " "maximum speeds." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:397 xs/src/libslic3r/PrintConfig.cpp:1249 +#: xs/src/libslic3r/PrintConfig.cpp:425 xs/src/libslic3r/PrintConfig.cpp:1349 msgid "approximate seconds" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:405 +#: xs/src/libslic3r/PrintConfig.cpp:433 msgid "Color" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:412 +#: xs/src/libslic3r/PrintConfig.cpp:440 msgid "Filament notes" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:413 +#: xs/src/libslic3r/PrintConfig.cpp:441 msgid "You can put your notes regarding the filament here." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:421 xs/src/libslic3r/PrintConfig.cpp:817 +#: xs/src/libslic3r/PrintConfig.cpp:449 xs/src/libslic3r/PrintConfig.cpp:893 msgid "Max volumetric speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:422 +#: xs/src/libslic3r/PrintConfig.cpp:450 msgid "" "Maximum volumetric speed allowed for this filament. Limits the maximum " "volumetric speed of a print to the minimum of print and filament volumetric " "speed. Set to zero for no limit." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:425 xs/src/libslic3r/PrintConfig.cpp:820 +#: xs/src/libslic3r/PrintConfig.cpp:453 xs/src/libslic3r/PrintConfig.cpp:896 msgid "mm³/s" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:432 +#: xs/src/libslic3r/PrintConfig.cpp:459 +msgid "Loading speed" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:460 +msgid "Speed used for loading the filament on the wipe tower. " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:467 +msgid "Unloading speed" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:468 +msgid "" +"Speed used for unloading the filament on the wipe tower (does not affect " +"initial part of unloading just after ramming). " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:476 +msgid "Delay after unloading" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:477 +msgid "" +"Time to wait after the filament is unloaded. May help to get reliable " +"toolchanges with flexible materials that may need more time to shrink to " +"original dimensions. " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:486 +msgid "Ramming parameters" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:487 +msgid "" +"This string is edited by RammingDialog and contains ramming specific " +"parameters " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:494 msgid "" "Enter your filament diameter here. Good precision is required, so use a " "caliper and do multiple measurements along the filament, then compute the " "average." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:440 +#: xs/src/libslic3r/PrintConfig.cpp:502 msgid "Density" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:441 +#: xs/src/libslic3r/PrintConfig.cpp:503 msgid "" "Enter your filament density here. This is only for statistical information. " "A decent way is to weigh a known length of filament and compute the ratio of " @@ -1538,15 +2352,15 @@ msgid "" "displacement." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:444 +#: xs/src/libslic3r/PrintConfig.cpp:506 msgid "g/cm³" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:450 +#: xs/src/libslic3r/PrintConfig.cpp:512 msgid "Filament type" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:451 xs/src/libslic3r/PrintConfig.cpp:1009 +#: xs/src/libslic3r/PrintConfig.cpp:513 xs/src/libslic3r/PrintConfig.cpp:1094 msgid "" "If you want to process the output G-code through custom scripts, just list " "their absolute paths here. Separate multiple scripts with a semicolon. " @@ -1555,73 +2369,74 @@ msgid "" "environment variables." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:470 +#: xs/src/libslic3r/PrintConfig.cpp:532 msgid "Soluble material" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:471 +#: xs/src/libslic3r/PrintConfig.cpp:533 msgid "Soluble material is most likely used for a soluble support." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:476 lib/Slic3r/GUI/Plater.pm:453 +#: xs/src/libslic3r/PrintConfig.cpp:538 lib/Slic3r/GUI/Plater.pm:463 msgid "Cost" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:477 +#: xs/src/libslic3r/PrintConfig.cpp:539 msgid "" "Enter your filament cost per kg here. This is only for statistical " "information." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:478 +#: xs/src/libslic3r/PrintConfig.cpp:540 msgid "money/kg" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:487 +#: xs/src/libslic3r/PrintConfig.cpp:549 msgid "Fill angle" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:489 +#: xs/src/libslic3r/PrintConfig.cpp:551 msgid "" "Default base angle for infill orientation. Cross-hatching will be applied to " "this. Bridges will be infilled using the best direction Slic3r can detect, " "so this setting does not affect them." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:501 +#: xs/src/libslic3r/PrintConfig.cpp:563 msgid "Fill density" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:503 +#: xs/src/libslic3r/PrintConfig.cpp:565 +#, possible-c-format msgid "Density of internal infill, expressed in the range 0% - 100%." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:539 +#: xs/src/libslic3r/PrintConfig.cpp:601 msgid "Fill pattern" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:541 +#: xs/src/libslic3r/PrintConfig.cpp:603 msgid "Fill pattern for general low-density infill." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:573 xs/src/libslic3r/PrintConfig.cpp:582 -#: xs/src/libslic3r/PrintConfig.cpp:591 xs/src/libslic3r/PrintConfig.cpp:625 +#: xs/src/libslic3r/PrintConfig.cpp:635 xs/src/libslic3r/PrintConfig.cpp:644 +#: xs/src/libslic3r/PrintConfig.cpp:653 xs/src/libslic3r/PrintConfig.cpp:687 msgid "First layer" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:574 +#: xs/src/libslic3r/PrintConfig.cpp:636 msgid "" "This is the acceleration your printer will use for first layer. Set zero to " "disable acceleration control for first layer." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:583 +#: xs/src/libslic3r/PrintConfig.cpp:645 msgid "" "Heated build plate temperature for the first layer. Set this to zero to " "disable bed temperature control commands in the output." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:593 +#: xs/src/libslic3r/PrintConfig.cpp:655 msgid "" "Set this to a non-zero value to set a manual extrusion width for first " "layer. You can use this to force fatter extrudates for better adhesion. If " @@ -1629,11 +2444,11 @@ msgid "" "layer height. If set to zero, it will use the default extrusion width." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:603 +#: xs/src/libslic3r/PrintConfig.cpp:665 msgid "First layer height" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:605 +#: xs/src/libslic3r/PrintConfig.cpp:667 msgid "" "When printing with very low layer heights, you might still want to print a " "thicker bottom layer to improve adhesion and tolerance for non perfect build " @@ -1641,58 +2456,58 @@ msgid "" "example: 150%) over the default layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:609 xs/src/libslic3r/PrintConfig.cpp:740 -#: xs/src/libslic3r/PrintConfig.cpp:1397 +#: xs/src/libslic3r/PrintConfig.cpp:671 xs/src/libslic3r/PrintConfig.cpp:802 +#: xs/src/libslic3r/PrintConfig.cpp:1497 msgid "mm or %" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:615 +#: xs/src/libslic3r/PrintConfig.cpp:677 msgid "First layer speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:616 +#: xs/src/libslic3r/PrintConfig.cpp:678 msgid "" "If expressed as absolute value in mm/s, this speed will be applied to all " "the print moves of the first layer, regardless of their type. If expressed " "as a percentage (for example: 40%) it will scale the default speeds." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:626 +#: xs/src/libslic3r/PrintConfig.cpp:688 msgid "" "Extruder temperature for first layer. If you want to control temperature " "manually during print, set this to zero to disable temperature control " "commands in the output file." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:634 -#: xs/src/libslic3r/GCode/PreviewData.cpp:145 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:87 +#: xs/src/libslic3r/PrintConfig.cpp:696 +#: xs/src/libslic3r/GCode/PreviewData.cpp:165 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:90 msgid "Gap fill" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:636 +#: xs/src/libslic3r/PrintConfig.cpp:698 msgid "" "Speed for filling small gaps using short zigzag moves. Keep this reasonably " "low to avoid too much shaking and resonance issues. Set zero to disable gaps " "filling." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:644 +#: xs/src/libslic3r/PrintConfig.cpp:706 msgid "Verbose G-code" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:645 +#: xs/src/libslic3r/PrintConfig.cpp:707 msgid "" "Enable this to get a commented G-code file, with each line explained by a " "descriptive text. If you print from SD card, the additional weight of the " "file could make your firmware slow down." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:652 +#: xs/src/libslic3r/PrintConfig.cpp:714 msgid "G-code flavor" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:653 +#: xs/src/libslic3r/PrintConfig.cpp:715 msgid "" "Some G/M-code commands, including temperature control and others, are not " "universal. Set this option to your printer's firmware to get a compatible " @@ -1700,35 +2515,35 @@ msgid "" "extrusion value at all." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:682 +#: xs/src/libslic3r/PrintConfig.cpp:744 msgid "" "This is the acceleration your printer will use for infill. Set zero to " "disable acceleration control for infill." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:690 +#: xs/src/libslic3r/PrintConfig.cpp:752 msgid "Combine infill every" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:692 +#: xs/src/libslic3r/PrintConfig.cpp:754 msgid "" "This feature allows to combine infill and speed up your print by extruding " "thicker infill layers while preserving thin perimeters, thus accuracy." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:696 +#: xs/src/libslic3r/PrintConfig.cpp:758 msgid "Combine infill every n layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:701 +#: xs/src/libslic3r/PrintConfig.cpp:763 msgid "Infill extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:703 +#: xs/src/libslic3r/PrintConfig.cpp:765 msgid "The extruder to use when printing infill." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:711 +#: xs/src/libslic3r/PrintConfig.cpp:773 msgid "" "Set this to a non-zero value to set a manual extrusion width for infill. If " "left zero, default extrusion width will be used if set, otherwise 1.125 x " @@ -1737,32 +2552,32 @@ msgid "" "example 90%) it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:720 +#: xs/src/libslic3r/PrintConfig.cpp:782 msgid "Infill before perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:721 +#: xs/src/libslic3r/PrintConfig.cpp:783 msgid "" "This option will switch the print order of perimeters and infill, making the " "latter first." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:726 +#: xs/src/libslic3r/PrintConfig.cpp:788 msgid "Only infill where needed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:728 +#: xs/src/libslic3r/PrintConfig.cpp:790 msgid "" "This option will limit infill to the areas actually needed for supporting " "ceilings (it will act as internal support material). If enabled, slows down " "the G-code generation due to the multiple checks involved." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:735 +#: xs/src/libslic3r/PrintConfig.cpp:797 msgid "Infill/perimeters overlap" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:737 +#: xs/src/libslic3r/PrintConfig.cpp:799 msgid "" "This setting applies an additional overlap between infill and perimeters for " "better bonding. Theoretically this shouldn't be needed, but backlash might " @@ -1770,22 +2585,30 @@ msgid "" "perimeter extrusion width." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:748 +#: xs/src/libslic3r/PrintConfig.cpp:810 msgid "Speed for printing the internal fill. Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:757 +#: xs/src/libslic3r/PrintConfig.cpp:819 +msgid "Inherits profile" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:820 +msgid "Name of the profile, from which this profile inherits." +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:826 msgid "Interface shells" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:758 +#: xs/src/libslic3r/PrintConfig.cpp:827 msgid "" "Force the generation of solid shells between adjacent materials/volumes. " "Useful for multi-extruder prints with translucent materials or manual " "soluble support material." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:767 +#: xs/src/libslic3r/PrintConfig.cpp:836 msgid "" "This custom code is inserted at every layer change, right after the Z move " "and before the extruder moves to the first layer point. Note that you can " @@ -1793,22 +2616,22 @@ msgid "" "[layer_z]." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:779 +#: xs/src/libslic3r/PrintConfig.cpp:848 msgid "" "This setting controls the height (and thus the total number) of the slices/" "layers. Thinner layers give better accuracy but take more time to print." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:787 xs/src/libslic3r/PrintConfig.cpp:796 +#: xs/src/libslic3r/PrintConfig.cpp:856 xs/src/libslic3r/PrintConfig.cpp:865 msgid "Max" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:788 +#: xs/src/libslic3r/PrintConfig.cpp:857 msgid "This setting represents the maximum speed of your fan." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:797 -#, possible-c-format +#: xs/src/libslic3r/PrintConfig.cpp:866 +#, no-c-format msgid "" "This is the highest printable layer height for this extruder, used to cap " "the variable layer height and support layer height. Maximum recommended " @@ -1816,28 +2639,38 @@ msgid "" "adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:807 +#: xs/src/libslic3r/PrintConfig.cpp:876 +msgid "Max print height" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:877 +msgid "" +"Set this to the maximum height that can be reached by your extruder while " +"printing." +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:883 msgid "Max print speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:808 +#: xs/src/libslic3r/PrintConfig.cpp:884 msgid "" "When setting other speed settings to 0 Slic3r will autocalculate the optimal " "speed in order to keep constant extruder pressure. This experimental setting " "is used to set the highest print speed you want to allow." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:818 +#: xs/src/libslic3r/PrintConfig.cpp:894 msgid "" "This experimental setting is used to set the maximum volumetric speed your " "extruder supports." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:826 +#: xs/src/libslic3r/PrintConfig.cpp:902 msgid "Max volumetric slope positive" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:827 xs/src/libslic3r/PrintConfig.cpp:838 +#: xs/src/libslic3r/PrintConfig.cpp:903 xs/src/libslic3r/PrintConfig.cpp:914 msgid "" "This experimental setting is used to limit the speed of change in extrusion " "rate. A value of 1.8 mm³/s² ensures, that a change from the extrusion rate " @@ -1845,109 +2678,109 @@ msgid "" "s) to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:831 xs/src/libslic3r/PrintConfig.cpp:842 +#: xs/src/libslic3r/PrintConfig.cpp:907 xs/src/libslic3r/PrintConfig.cpp:918 msgid "mm³/s²" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:837 +#: xs/src/libslic3r/PrintConfig.cpp:913 msgid "Max volumetric slope negative" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:848 xs/src/libslic3r/PrintConfig.cpp:857 +#: xs/src/libslic3r/PrintConfig.cpp:924 xs/src/libslic3r/PrintConfig.cpp:933 msgid "Min" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:849 +#: xs/src/libslic3r/PrintConfig.cpp:925 msgid "This setting represents the minimum PWM your fan needs to work." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:858 +#: xs/src/libslic3r/PrintConfig.cpp:934 msgid "" "This is the lowest printable layer height for this extruder and limits the " "resolution for variable layer height. Typical values are between 0.05 mm and " "0.1 mm." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:866 +#: xs/src/libslic3r/PrintConfig.cpp:942 msgid "Min print speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:867 +#: xs/src/libslic3r/PrintConfig.cpp:943 msgid "Slic3r will not scale speed down below this speed." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:874 +#: xs/src/libslic3r/PrintConfig.cpp:950 msgid "Minimum extrusion length" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:875 +#: xs/src/libslic3r/PrintConfig.cpp:951 msgid "" "Generate no less than the number of skirt loops required to consume the " "specified amount of filament on the bottom layer. For multi-extruder " "machines, this minimum applies to each extruder." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:884 +#: xs/src/libslic3r/PrintConfig.cpp:960 msgid "Configuration notes" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:885 +#: xs/src/libslic3r/PrintConfig.cpp:961 msgid "" "You can put here your personal notes. This text will be added to the G-code " "header comments." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:894 +#: xs/src/libslic3r/PrintConfig.cpp:970 msgid "Nozzle diameter" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:895 +#: xs/src/libslic3r/PrintConfig.cpp:971 msgid "" "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:901 +#: xs/src/libslic3r/PrintConfig.cpp:977 msgid "API Key" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:902 +#: xs/src/libslic3r/PrintConfig.cpp:978 msgid "" "Slic3r can upload G-code files to OctoPrint. This field should contain the " "API Key required for authentication." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:915 +#: xs/src/libslic3r/PrintConfig.cpp:991 msgid "Hostname, IP or URL" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:916 +#: xs/src/libslic3r/PrintConfig.cpp:992 msgid "" "Slic3r can upload G-code files to OctoPrint. This field should contain the " "hostname, IP address or URL of the OctoPrint instance." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:922 +#: xs/src/libslic3r/PrintConfig.cpp:998 msgid "Only retract when crossing perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:923 +#: xs/src/libslic3r/PrintConfig.cpp:999 msgid "" "Disables retraction when the travel path does not exceed the upper layer's " "perimeters (and thus any ooze will be probably invisible)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:930 +#: xs/src/libslic3r/PrintConfig.cpp:1006 msgid "" "This option will drop the temperature of the inactive extruders to prevent " "oozing. It will enable a tall skirt automatically and move extruders outside " "such skirt when changing temperatures." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:937 +#: xs/src/libslic3r/PrintConfig.cpp:1013 msgid "Output filename format" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:938 +#: xs/src/libslic3r/PrintConfig.cpp:1014 msgid "" "You can use all configuration options as variables inside this template. For " "example: [layer_height], [fill_density] etc. You can also use [timestamp], " @@ -1955,38 +2788,48 @@ msgid "" "[input_filename], [input_filename_base]." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:947 +#: xs/src/libslic3r/PrintConfig.cpp:1023 msgid "Detect bridging perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:949 +#: xs/src/libslic3r/PrintConfig.cpp:1025 msgid "" "Experimental option to adjust flow for overhangs (bridge flow will be used), " "to apply bridge speed to them and enable fan." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:955 xs/src/libslic3r/PrintConfig.cpp:973 -#: xs/src/libslic3r/PrintConfig.cpp:985 xs/src/libslic3r/PrintConfig.cpp:995 +#: xs/src/libslic3r/PrintConfig.cpp:1031 +msgid "Filament parking position" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1032 +msgid "" +"Distance of the extruder tip from the position where the filament is parked " +"when unloaded. This should match the value in printer firmware. " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1040 xs/src/libslic3r/PrintConfig.cpp:1058 +#: xs/src/libslic3r/PrintConfig.cpp:1070 xs/src/libslic3r/PrintConfig.cpp:1080 msgid "Perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:956 +#: xs/src/libslic3r/PrintConfig.cpp:1041 msgid "" "This is the acceleration your printer will use for perimeters. A high value " "like 9000 usually gives good results if your hardware is up to the job. Set " "zero to disable acceleration control for perimeters." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:964 +#: xs/src/libslic3r/PrintConfig.cpp:1049 msgid "Perimeter extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:966 +#: xs/src/libslic3r/PrintConfig.cpp:1051 msgid "" "The extruder to use when printing perimeters and brim. First extruder is 1." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:975 +#: xs/src/libslic3r/PrintConfig.cpp:1060 msgid "" "Set this to a non-zero value to set a manual extrusion width for perimeters. " "You may want to use thinner extrudates to get more accurate surfaces. If " @@ -1995,12 +2838,12 @@ msgid "" "it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:987 +#: xs/src/libslic3r/PrintConfig.cpp:1072 msgid "" "Speed for perimeters (contours, aka vertical shells). Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:997 +#: xs/src/libslic3r/PrintConfig.cpp:1082 msgid "" "This option sets the number of perimeters to generate for each layer. Note " "that Slic3r may increase this number automatically when it detects sloping " @@ -2008,33 +2851,59 @@ msgid "" "Perimeters option is enabled." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1001 +#: xs/src/libslic3r/PrintConfig.cpp:1086 msgid "(minimum)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1021 +#: xs/src/libslic3r/PrintConfig.cpp:1106 +msgid "Printer type" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1107 +msgid "Type of the printer." +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1111 msgid "Printer notes" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1022 +#: xs/src/libslic3r/PrintConfig.cpp:1112 msgid "You can put your notes regarding the printer here." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1036 +#: xs/src/libslic3r/PrintConfig.cpp:1120 +msgid "Printer vendor" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1121 +msgid "Name of the printer vendor." +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1125 +msgid "Printer variant" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1126 +msgid "" +"Name of the printer variant. For example, the printer variants may be " +"differentiated by a nozzle diameter." +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1136 msgid "Raft layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1038 +#: xs/src/libslic3r/PrintConfig.cpp:1138 msgid "" "The object will be raised by this number of layers, and support material " "will be generated under it." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1046 +#: xs/src/libslic3r/PrintConfig.cpp:1146 msgid "Resolution" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1047 +#: xs/src/libslic3r/PrintConfig.cpp:1147 msgid "" "Minimum detail resolution, used to simplify the input file for speeding up " "the slicing job and reducing memory usage. High-resolution models often " @@ -2042,266 +2911,266 @@ msgid "" "simplification and use full resolution from input." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1057 +#: xs/src/libslic3r/PrintConfig.cpp:1157 msgid "Minimum travel after retraction" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1058 +#: xs/src/libslic3r/PrintConfig.cpp:1158 msgid "" "Retraction is not triggered when travel moves are shorter than this length." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1064 +#: xs/src/libslic3r/PrintConfig.cpp:1164 msgid "Retract amount before wipe" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1065 +#: xs/src/libslic3r/PrintConfig.cpp:1165 msgid "" "With bowden extruders, it may be wise to do some amount of quick retract " "before doing the wipe movement." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1072 +#: xs/src/libslic3r/PrintConfig.cpp:1172 msgid "Retract on layer change" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1073 +#: xs/src/libslic3r/PrintConfig.cpp:1173 msgid "This flag enforces a retraction whenever a Z move is done." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1078 xs/src/libslic3r/PrintConfig.cpp:1087 +#: xs/src/libslic3r/PrintConfig.cpp:1178 xs/src/libslic3r/PrintConfig.cpp:1187 msgid "Length" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1079 +#: xs/src/libslic3r/PrintConfig.cpp:1179 msgid "Retraction Length" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1080 +#: xs/src/libslic3r/PrintConfig.cpp:1180 msgid "" "When retraction is triggered, filament is pulled back by the specified " "amount (the length is measured on raw filament, before it enters the " "extruder)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1082 xs/src/libslic3r/PrintConfig.cpp:1092 +#: xs/src/libslic3r/PrintConfig.cpp:1182 xs/src/libslic3r/PrintConfig.cpp:1192 msgid "mm (zero to disable)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1088 +#: xs/src/libslic3r/PrintConfig.cpp:1188 msgid "Retraction Length (Toolchange)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1089 +#: xs/src/libslic3r/PrintConfig.cpp:1189 msgid "" "When retraction is triggered before changing tool, filament is pulled back " "by the specified amount (the length is measured on raw filament, before it " "enters the extruder)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1097 +#: xs/src/libslic3r/PrintConfig.cpp:1197 msgid "Lift Z" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1098 +#: xs/src/libslic3r/PrintConfig.cpp:1198 msgid "" "If you set this to a positive value, Z is quickly raised every time a " "retraction is triggered. When using multiple extruders, only the setting for " "the first extruder will be considered." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1106 +#: xs/src/libslic3r/PrintConfig.cpp:1206 msgid "Above Z" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1107 +#: xs/src/libslic3r/PrintConfig.cpp:1207 msgid "Only lift Z above" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1108 +#: xs/src/libslic3r/PrintConfig.cpp:1208 msgid "" "If you set this to a positive value, Z lift will only take place above the " "specified absolute Z. You can tune this setting for skipping lift on the " "first layers." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1115 +#: xs/src/libslic3r/PrintConfig.cpp:1215 msgid "Below Z" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1116 +#: xs/src/libslic3r/PrintConfig.cpp:1216 msgid "Only lift Z below" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1117 +#: xs/src/libslic3r/PrintConfig.cpp:1217 msgid "" "If you set this to a positive value, Z lift will only take place below the " "specified absolute Z. You can tune this setting for limiting lift to the " "first layers." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1125 xs/src/libslic3r/PrintConfig.cpp:1133 +#: xs/src/libslic3r/PrintConfig.cpp:1225 xs/src/libslic3r/PrintConfig.cpp:1233 msgid "Extra length on restart" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1126 +#: xs/src/libslic3r/PrintConfig.cpp:1226 msgid "" "When the retraction is compensated after the travel move, the extruder will " "push this additional amount of filament. This setting is rarely needed." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1134 +#: xs/src/libslic3r/PrintConfig.cpp:1234 msgid "" "When the retraction is compensated after changing tool, the extruder will " "push this additional amount of filament." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1141 xs/src/libslic3r/PrintConfig.cpp:1142 +#: xs/src/libslic3r/PrintConfig.cpp:1241 xs/src/libslic3r/PrintConfig.cpp:1242 msgid "Retraction Speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1143 +#: xs/src/libslic3r/PrintConfig.cpp:1243 msgid "The speed for retractions (it only applies to the extruder motor)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1149 xs/src/libslic3r/PrintConfig.cpp:1150 +#: xs/src/libslic3r/PrintConfig.cpp:1249 xs/src/libslic3r/PrintConfig.cpp:1250 msgid "Deretraction Speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1151 +#: xs/src/libslic3r/PrintConfig.cpp:1251 msgid "" "The speed for loading of a filament into extruder after retraction (it only " "applies to the extruder motor). If left to zero, the retraction speed is " "used." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1158 +#: xs/src/libslic3r/PrintConfig.cpp:1258 msgid "Seam position" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1160 +#: xs/src/libslic3r/PrintConfig.cpp:1260 msgid "Position of perimeters starting points." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1176 +#: xs/src/libslic3r/PrintConfig.cpp:1276 msgid "Direction" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1178 +#: xs/src/libslic3r/PrintConfig.cpp:1278 msgid "Preferred direction of the seam" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1179 +#: xs/src/libslic3r/PrintConfig.cpp:1279 msgid "Seam preferred direction" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1187 +#: xs/src/libslic3r/PrintConfig.cpp:1287 msgid "Jitter" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1189 +#: xs/src/libslic3r/PrintConfig.cpp:1289 msgid "Seam preferred direction jitter" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1190 +#: xs/src/libslic3r/PrintConfig.cpp:1290 msgid "Preferred direction of the seam - jitter" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1201 +#: xs/src/libslic3r/PrintConfig.cpp:1301 msgid "USB/serial port for printer connection." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1209 +#: xs/src/libslic3r/PrintConfig.cpp:1309 msgid "Serial port speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1210 +#: xs/src/libslic3r/PrintConfig.cpp:1310 msgid "Speed (baud) of USB/serial port for printer connection." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1219 +#: xs/src/libslic3r/PrintConfig.cpp:1319 msgid "Distance from object" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1220 +#: xs/src/libslic3r/PrintConfig.cpp:1320 msgid "" "Distance between skirt and object(s). Set this to zero to attach the skirt " "to the object(s) and get a brim for better adhesion." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1228 +#: xs/src/libslic3r/PrintConfig.cpp:1328 msgid "Skirt height" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1229 +#: xs/src/libslic3r/PrintConfig.cpp:1329 msgid "" "Height of skirt expressed in layers. Set this to a tall value to use skirt " "as a shield against drafts." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1236 +#: xs/src/libslic3r/PrintConfig.cpp:1336 msgid "Loops (minimum)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1237 +#: xs/src/libslic3r/PrintConfig.cpp:1337 msgid "Skirt Loops" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1238 +#: xs/src/libslic3r/PrintConfig.cpp:1338 msgid "" "Number of loops for the skirt. If the Minimum Extrusion Length option is " "set, the number of loops might be greater than the one configured here. Set " "this to zero to disable skirt completely." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1246 +#: xs/src/libslic3r/PrintConfig.cpp:1346 msgid "Slow down if layer print time is below" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1247 +#: xs/src/libslic3r/PrintConfig.cpp:1347 msgid "" "If layer print time is estimated below this number of seconds, print moves " "speed will be scaled down to extend duration to this value." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1257 +#: xs/src/libslic3r/PrintConfig.cpp:1357 msgid "Small perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1259 +#: xs/src/libslic3r/PrintConfig.cpp:1359 msgid "" "This separate setting will affect the speed of perimeters having radius <= " "6.5mm (usually holes). If expressed as percentage (for example: 80%) it will " "be calculated on the perimeters speed setting above. Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1269 +#: xs/src/libslic3r/PrintConfig.cpp:1369 msgid "Solid infill threshold area" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1271 +#: xs/src/libslic3r/PrintConfig.cpp:1371 msgid "" "Force solid infill for regions having a smaller area than the specified " "threshold." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1272 +#: xs/src/libslic3r/PrintConfig.cpp:1372 msgid "mm²" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1278 +#: xs/src/libslic3r/PrintConfig.cpp:1378 msgid "Solid infill extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1280 +#: xs/src/libslic3r/PrintConfig.cpp:1380 msgid "The extruder to use when printing solid infill." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1286 +#: xs/src/libslic3r/PrintConfig.cpp:1386 msgid "Solid infill every" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1288 +#: xs/src/libslic3r/PrintConfig.cpp:1388 msgid "" "This feature allows to force a solid layer every given number of layers. " "Zero to disable. You can set this to any value (for example 9999); Slic3r " @@ -2309,13 +3178,13 @@ msgid "" "according to nozzle diameter and layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1298 xs/src/libslic3r/PrintConfig.cpp:1308 -#: xs/src/libslic3r/GCode/PreviewData.cpp:142 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:84 +#: xs/src/libslic3r/PrintConfig.cpp:1398 xs/src/libslic3r/PrintConfig.cpp:1408 +#: xs/src/libslic3r/GCode/PreviewData.cpp:162 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:87 msgid "Solid infill" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1300 +#: xs/src/libslic3r/PrintConfig.cpp:1400 msgid "" "Set this to a non-zero value to set a manual extrusion width for infill for " "solid surfaces. If left zero, default extrusion width will be used if set, " @@ -2323,22 +3192,22 @@ msgid "" "(for example 90%) it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1310 +#: xs/src/libslic3r/PrintConfig.cpp:1410 msgid "" "Speed for printing solid regions (top/bottom/internal horizontal shells). " "This can be expressed as a percentage (for example: 80%) over the default " "infill speed above. Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1322 +#: xs/src/libslic3r/PrintConfig.cpp:1422 msgid "Number of solid layers to generate on top and bottom surfaces." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1329 +#: xs/src/libslic3r/PrintConfig.cpp:1429 msgid "Spiral vase" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1330 +#: xs/src/libslic3r/PrintConfig.cpp:1430 msgid "" "This feature will raise Z gradually while printing a single-walled object in " "order to remove any visible seam. This option requires a single perimeter, " @@ -2347,18 +3216,18 @@ msgid "" "when printing more than an object." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1339 +#: xs/src/libslic3r/PrintConfig.cpp:1439 msgid "Temperature variation" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1340 +#: xs/src/libslic3r/PrintConfig.cpp:1440 msgid "" "Temperature difference to be applied when an extruder is not active. Enables " "a full-height \"sacrificial\" skirt on which the nozzles are periodically " "wiped." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1350 +#: xs/src/libslic3r/PrintConfig.cpp:1450 msgid "" "This start procedure is inserted at the beginning, after bed has reached the " "target temperature and extruder just started heating, and before extruder " @@ -2369,76 +3238,76 @@ msgid "" "\"M109 S[first_layer_temperature]\" command wherever you want." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1365 +#: xs/src/libslic3r/PrintConfig.cpp:1465 msgid "" "This start procedure is inserted at the beginning, after any printer start " "gcode. This is used to override settings for a specific filament. If Slic3r " "detects M104, M109, M140 or M190 in your custom codes, such commands will " "not be prepended automatically so you're free to customize the order of " "heating commands and other custom actions. Note that you can use placeholder " -"variables for all Slic3r settings, so you can put a \"M109 " -"S[first_layer_temperature]\" command wherever you want. If you have multiple " +"variables for all Slic3r settings, so you can put a \"M109 S" +"[first_layer_temperature]\" command wherever you want. If you have multiple " "extruders, the gcode is processed in extruder order." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1380 +#: xs/src/libslic3r/PrintConfig.cpp:1480 msgid "Single Extruder Multi Material" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1381 +#: xs/src/libslic3r/PrintConfig.cpp:1481 msgid "The printer multiplexes filaments into a single hot end." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1386 +#: xs/src/libslic3r/PrintConfig.cpp:1486 msgid "Generate support material" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1388 +#: xs/src/libslic3r/PrintConfig.cpp:1488 msgid "Enable support material generation." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1393 +#: xs/src/libslic3r/PrintConfig.cpp:1493 msgid "XY separation between an object and its support" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1395 +#: xs/src/libslic3r/PrintConfig.cpp:1495 msgid "" "XY separation between an object and its support. If expressed as percentage " "(for example 50%), it will be calculated over external perimeter width." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1405 +#: xs/src/libslic3r/PrintConfig.cpp:1505 msgid "Pattern angle" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1407 +#: xs/src/libslic3r/PrintConfig.cpp:1507 msgid "" "Use this setting to rotate the support material pattern on the horizontal " "plane." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1417 +#: xs/src/libslic3r/PrintConfig.cpp:1517 msgid "" "Only create support if it lies on a build plate. Don't create support on a " "print." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1423 +#: xs/src/libslic3r/PrintConfig.cpp:1523 msgid "Contact Z distance" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1425 +#: xs/src/libslic3r/PrintConfig.cpp:1525 msgid "" "The vertical distance between object and support material interface. Setting " "this to 0 will also prevent Slic3r from using bridge flow and speed for the " "first object layer." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1438 +#: xs/src/libslic3r/PrintConfig.cpp:1538 msgid "Enforce support for the first" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1440 +#: xs/src/libslic3r/PrintConfig.cpp:1540 msgid "" "Generate support material for the specified number of layers counting from " "bottom, regardless of whether normal support material is enabled or not and " @@ -2446,21 +3315,21 @@ msgid "" "of objects having a very thin or poor footprint on the build plate." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1446 +#: xs/src/libslic3r/PrintConfig.cpp:1546 msgid "Enforce support for the first n layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1451 +#: xs/src/libslic3r/PrintConfig.cpp:1551 msgid "Support material/raft/skirt extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1453 +#: xs/src/libslic3r/PrintConfig.cpp:1553 msgid "" "The extruder to use when printing support material, raft and skirt (1+, 0 to " "use the current extruder to minimize tool changes)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1462 +#: xs/src/libslic3r/PrintConfig.cpp:1562 msgid "" "Set this to a non-zero value to set a manual extrusion width for support " "material. If left zero, default extrusion width will be used if set, " @@ -2468,91 +3337,91 @@ msgid "" "example 90%) it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1470 +#: xs/src/libslic3r/PrintConfig.cpp:1570 msgid "Interface loops" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1472 +#: xs/src/libslic3r/PrintConfig.cpp:1572 msgid "" "Cover the top contact layer of the supports with loops. Disabled by default." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1477 +#: xs/src/libslic3r/PrintConfig.cpp:1577 msgid "Support material/raft interface extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1479 +#: xs/src/libslic3r/PrintConfig.cpp:1579 msgid "" "The extruder to use when printing support material interface (1+, 0 to use " "the current extruder to minimize tool changes). This affects raft too." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1486 +#: xs/src/libslic3r/PrintConfig.cpp:1586 msgid "Interface layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1488 +#: xs/src/libslic3r/PrintConfig.cpp:1588 msgid "" "Number of interface layers to insert between the object(s) and support " "material." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1495 +#: xs/src/libslic3r/PrintConfig.cpp:1595 msgid "Interface pattern spacing" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1497 +#: xs/src/libslic3r/PrintConfig.cpp:1597 msgid "Spacing between interface lines. Set zero to get a solid interface." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1504 -#: xs/src/libslic3r/GCode/PreviewData.cpp:148 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:90 +#: xs/src/libslic3r/PrintConfig.cpp:1604 +#: xs/src/libslic3r/GCode/PreviewData.cpp:168 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:93 msgid "Support material interface" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1506 +#: xs/src/libslic3r/PrintConfig.cpp:1606 msgid "" "Speed for printing support material interface layers. If expressed as " "percentage (for example 50%) it will be calculated over support material " "speed." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1515 +#: xs/src/libslic3r/PrintConfig.cpp:1615 msgid "Pattern" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1517 +#: xs/src/libslic3r/PrintConfig.cpp:1617 msgid "Pattern used to generate support material." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1531 +#: xs/src/libslic3r/PrintConfig.cpp:1629 msgid "Pattern spacing" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1533 +#: xs/src/libslic3r/PrintConfig.cpp:1631 msgid "Spacing between support material lines." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1542 +#: xs/src/libslic3r/PrintConfig.cpp:1640 msgid "Speed for printing support material." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1549 +#: xs/src/libslic3r/PrintConfig.cpp:1647 msgid "Synchronize with object layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1551 +#: xs/src/libslic3r/PrintConfig.cpp:1649 msgid "" "Synchronize support layers with the object print layers. This is useful with " "multi-material printers, where the extruder switch is expensive." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1557 +#: xs/src/libslic3r/PrintConfig.cpp:1655 msgid "Overhang threshold" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1559 +#: xs/src/libslic3r/PrintConfig.cpp:1657 msgid "" "Support material will not be generated for overhangs whose slope angle (90° " "= vertical) is above the given threshold. In other words, this value " @@ -2561,60 +3430,60 @@ msgid "" "detection (recommended)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1571 +#: xs/src/libslic3r/PrintConfig.cpp:1669 msgid "With sheath around the support" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1573 +#: xs/src/libslic3r/PrintConfig.cpp:1671 msgid "" "Add a sheath (a single perimeter line) around the base support. This makes " "the support more reliable, but also more difficult to remove." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1580 +#: xs/src/libslic3r/PrintConfig.cpp:1678 msgid "" "Extruder temperature for layers after the first one. Set this to zero to " "disable temperature control commands in the output." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1583 +#: xs/src/libslic3r/PrintConfig.cpp:1681 msgid "Temperature" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1589 +#: xs/src/libslic3r/PrintConfig.cpp:1687 msgid "Detect thin walls" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1591 +#: xs/src/libslic3r/PrintConfig.cpp:1689 msgid "" "Detect single-width walls (parts where two extrusions don't fit and we need " "to collapse them into a single trace)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1597 +#: xs/src/libslic3r/PrintConfig.cpp:1695 msgid "Threads" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1598 +#: xs/src/libslic3r/PrintConfig.cpp:1696 msgid "" "Threads are used to parallelize long-running tasks. Optimal threads number " "is slightly above the number of available cores/processors." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1610 +#: xs/src/libslic3r/PrintConfig.cpp:1708 msgid "" "This custom code is inserted right before every extruder change. Note that " "you can use placeholder variables for all Slic3r settings as well as " "[previous_extruder] and [next_extruder]." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1620 xs/src/libslic3r/PrintConfig.cpp:1631 -#: xs/src/libslic3r/GCode/PreviewData.cpp:143 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:85 +#: xs/src/libslic3r/PrintConfig.cpp:1718 xs/src/libslic3r/PrintConfig.cpp:1729 +#: xs/src/libslic3r/GCode/PreviewData.cpp:163 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:88 msgid "Top solid infill" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1622 +#: xs/src/libslic3r/PrintConfig.cpp:1720 msgid "" "Set this to a non-zero value to set a manual extrusion width for infill for " "top surfaces. You may want to use thinner extrudates to fill all narrow " @@ -2623,7 +3492,7 @@ msgid "" "percentage (for example 90%) it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1633 +#: xs/src/libslic3r/PrintConfig.cpp:1731 msgid "" "Speed for printing top solid layers (it only applies to the uppermost " "external layers and not to their internal solid layers). You may want to " @@ -2632,51 +3501,51 @@ msgid "" "for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1645 lib/Slic3r/GUI/MainFrame.pm:363 +#: xs/src/libslic3r/PrintConfig.cpp:1743 lib/Slic3r/GUI/MainFrame.pm:306 msgid "Top" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1647 +#: xs/src/libslic3r/PrintConfig.cpp:1745 msgid "Number of solid layers to generate on top surfaces." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1649 +#: xs/src/libslic3r/PrintConfig.cpp:1747 msgid "Top solid layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1654 lib/Slic3r/GUI/Plater/3DPreview.pm:95 +#: xs/src/libslic3r/PrintConfig.cpp:1752 lib/Slic3r/GUI/Plater/3DPreview.pm:98 msgid "Travel" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1655 +#: xs/src/libslic3r/PrintConfig.cpp:1753 msgid "Speed for travel moves (jumps between distant extrusion points)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1663 +#: xs/src/libslic3r/PrintConfig.cpp:1761 msgid "Use firmware retraction" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1664 +#: xs/src/libslic3r/PrintConfig.cpp:1762 msgid "" "This experimental setting uses G10 and G11 commands to have the firmware " "handle the retraction. This is only supported in recent Marlin." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1670 +#: xs/src/libslic3r/PrintConfig.cpp:1768 msgid "Use relative E distances" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1671 +#: xs/src/libslic3r/PrintConfig.cpp:1769 msgid "" "If your firmware requires relative E values, check this, otherwise leave it " "unchecked. Most firmwares use absolute values." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1677 +#: xs/src/libslic3r/PrintConfig.cpp:1775 msgid "Use volumetric E" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1678 +#: xs/src/libslic3r/PrintConfig.cpp:1776 msgid "" "This experimental setting uses outputs the E values in cubic millimeters " "instead of linear millimeters. If your firmware doesn't already know " @@ -2686,83 +3555,113 @@ msgid "" "only supported in recent Marlin." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1688 +#: xs/src/libslic3r/PrintConfig.cpp:1786 msgid "Enable variable layer height feature" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1689 +#: xs/src/libslic3r/PrintConfig.cpp:1787 msgid "" "Some printers or printer setups may have difficulties printing with a " "variable layer height. Enabled by default." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1695 +#: xs/src/libslic3r/PrintConfig.cpp:1793 msgid "Wipe while retracting" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1696 +#: xs/src/libslic3r/PrintConfig.cpp:1794 msgid "" "This flag will move the nozzle while retracting to minimize the possible " "blob on leaky extruders." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1703 +#: xs/src/libslic3r/PrintConfig.cpp:1801 msgid "" "Multi material printers may need to prime or purge extruders on tool " "changes. Extrude the excess material into the wipe tower." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1709 +#: xs/src/libslic3r/PrintConfig.cpp:1807 +msgid "Purging volumes - load/unload volumes" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1808 +msgid "" +"This vector saves required volumes to change from/to each tool used on the " +"wipe tower. These values are used to simplify creation of the full purging " +"volumes below. " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1815 +msgid "Purging volumes - matrix" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1816 +msgid "" +"This matrix describes volumes (in cubic milimetres) required to purge the " +"new filament on the wipe tower for any given pair of tools. " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1826 msgid "Position X" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1710 +#: xs/src/libslic3r/PrintConfig.cpp:1827 msgid "X coordinate of the left front corner of a wipe tower" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1716 +#: xs/src/libslic3r/PrintConfig.cpp:1833 msgid "Position Y" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1717 +#: xs/src/libslic3r/PrintConfig.cpp:1834 msgid "Y coordinate of the left front corner of a wipe tower" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1723 lib/Slic3r/GUI/Plater/3DPreview.pm:70 +#: xs/src/libslic3r/PrintConfig.cpp:1840 lib/Slic3r/GUI/Plater/3DPreview.pm:69 msgid "Width" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1724 +#: xs/src/libslic3r/PrintConfig.cpp:1841 msgid "Width of a wipe tower" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1730 -msgid "Per color change depth" +#: xs/src/libslic3r/PrintConfig.cpp:1847 +msgid "Wipe tower rotation angle" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1731 -msgid "" -"Depth of a wipe color per color change. For N colors, there will be maximum " -"(N-1) tool switches performed, therefore the total depth of the wipe tower " -"will be (N-1) times this value." +#: xs/src/libslic3r/PrintConfig.cpp:1848 +msgid "Wipe tower rotation angle with respect to x-axis " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1739 +#: xs/src/libslic3r/PrintConfig.cpp:1849 +msgid "degrees" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1854 +msgid "Maximal bridging distance" +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1855 +msgid "Maximal distance between supports on sparse infill sections. " +msgstr "" + +#: xs/src/libslic3r/PrintConfig.cpp:1861 msgid "XY Size Compensation" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1741 +#: xs/src/libslic3r/PrintConfig.cpp:1863 msgid "" "The object will be grown/shrunk in the XY plane by the configured value " "(negative = inwards, positive = outwards). This might be useful for fine-" "tuning hole sizes." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1749 +#: xs/src/libslic3r/PrintConfig.cpp:1871 msgid "Z offset" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1750 +#: xs/src/libslic3r/PrintConfig.cpp:1872 msgid "" "This value will be added (or subtracted) from all the Z coordinates in the " "output G-code. It is used to compensate for bad Z endstop position: for " @@ -2770,980 +3669,946 @@ msgid "" "print bed, set this to -0.3 (or fix your endstop)." msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:138 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:80 +#: xs/src/libslic3r/GCode/PreviewData.cpp:158 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:83 msgid "Perimeter" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:139 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:81 +#: xs/src/libslic3r/GCode/PreviewData.cpp:159 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:84 msgid "External perimeter" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:140 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:82 +#: xs/src/libslic3r/GCode/PreviewData.cpp:160 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:85 msgid "Overhang perimeter" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:141 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:83 +#: xs/src/libslic3r/GCode/PreviewData.cpp:161 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:86 msgid "Internal infill" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:144 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:86 +#: xs/src/libslic3r/GCode/PreviewData.cpp:164 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:89 msgid "Bridge infill" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:151 +#: xs/src/libslic3r/GCode/PreviewData.cpp:171 msgid "Mixed" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:330 -#: lib/Slic3r/GUI/Plater/3DPreview.pm:68 +#: xs/src/libslic3r/GCode/PreviewData.cpp:362 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:67 msgid "Feature type" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:332 +#: xs/src/libslic3r/GCode/PreviewData.cpp:364 msgid "Height (mm)" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:334 +#: xs/src/libslic3r/GCode/PreviewData.cpp:366 msgid "Width (mm)" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:336 +#: xs/src/libslic3r/GCode/PreviewData.cpp:368 msgid "Speed (mm/s)" msgstr "" -#: xs/src/libslic3r/GCode/PreviewData.cpp:338 +#: xs/src/libslic3r/GCode/PreviewData.cpp:370 +msgid "Volumetric flow rate (mm3/s)" +msgstr "" + +#: xs/src/libslic3r/GCode/PreviewData.cpp:372 #: lib/Slic3r/GUI/Plater/3DPreview.pm:72 msgid "Tool" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:66 +#: lib/Slic3r/GUI.pm:303 +msgid "Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "" + +#: lib/Slic3r/GUI/MainFrame.pm:62 msgid "Version " msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:66 +#: lib/Slic3r/GUI/MainFrame.pm:62 msgid "" " - Remember to check for updates at http://github.com/prusa3d/slic3r/releases" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:118 +#: lib/Slic3r/GUI/MainFrame.pm:114 msgid "Plater" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:120 +#: lib/Slic3r/GUI/MainFrame.pm:116 msgid "Controller" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:191 -msgid "No Bonjour device found" -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:191 -msgid "Device Browser" -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:212 -msgid "I wasn't able to connect to OctoPrint (" -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:213 -msgid "). Check hostname and OctoPrint version (at least 1.1.0 is required)." -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:245 +#: lib/Slic3r/GUI/MainFrame.pm:194 msgid "Open STL/OBJ/AMF…\tCtrl+O" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:245 +#: lib/Slic3r/GUI/MainFrame.pm:194 msgid "Open a model" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:248 +#: lib/Slic3r/GUI/MainFrame.pm:197 msgid "&Load Config…\tCtrl+L" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:248 +#: lib/Slic3r/GUI/MainFrame.pm:197 msgid "Load exported configuration file" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:251 +#: lib/Slic3r/GUI/MainFrame.pm:200 msgid "&Export Config…\tCtrl+E" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:251 +#: lib/Slic3r/GUI/MainFrame.pm:200 msgid "Export current configuration to file" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:254 +#: lib/Slic3r/GUI/MainFrame.pm:203 msgid "&Load Config Bundle…" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:254 +#: lib/Slic3r/GUI/MainFrame.pm:203 msgid "Load presets from a bundle" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:257 +#: lib/Slic3r/GUI/MainFrame.pm:206 msgid "&Export Config Bundle…" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:257 +#: lib/Slic3r/GUI/MainFrame.pm:206 msgid "Export all presets to file" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:262 +#: lib/Slic3r/GUI/MainFrame.pm:211 msgid "Q&uick Slice…\tCtrl+U" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:262 +#: lib/Slic3r/GUI/MainFrame.pm:211 msgid "Slice a file into a G-code" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:268 +#: lib/Slic3r/GUI/MainFrame.pm:217 msgid "Quick Slice and Save &As…\tCtrl+Alt+U" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:268 +#: lib/Slic3r/GUI/MainFrame.pm:217 msgid "Slice a file into a G-code, save as" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:274 +#: lib/Slic3r/GUI/MainFrame.pm:223 msgid "&Repeat Last Quick Slice\tCtrl+Shift+U" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:274 +#: lib/Slic3r/GUI/MainFrame.pm:223 msgid "Repeat last quick slice" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:281 +#: lib/Slic3r/GUI/MainFrame.pm:230 msgid "Slice to SV&G…\tCtrl+G" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:281 +#: lib/Slic3r/GUI/MainFrame.pm:230 msgid "Slice file to a multi-layer SVG" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:285 +#: lib/Slic3r/GUI/MainFrame.pm:234 msgid "(&Re)Slice Now\tCtrl+S" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:285 +#: lib/Slic3r/GUI/MainFrame.pm:234 msgid "Start new slicing process" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:288 +#: lib/Slic3r/GUI/MainFrame.pm:237 msgid "Repair STL file…" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:288 +#: lib/Slic3r/GUI/MainFrame.pm:237 msgid "Automatically repair an STL file" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:293 -msgid "Preferences…\tCtrl+," -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:293 -msgid "Application preferences" -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:298 +#: lib/Slic3r/GUI/MainFrame.pm:241 msgid "&Quit" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:298 +#: lib/Slic3r/GUI/MainFrame.pm:241 msgid "Quit Slic3r" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:308 +#: lib/Slic3r/GUI/MainFrame.pm:251 msgid "Export G-code..." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:308 +#: lib/Slic3r/GUI/MainFrame.pm:251 msgid "Export current plate as G-code" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:311 +#: lib/Slic3r/GUI/MainFrame.pm:254 msgid "Export plate as STL..." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:311 +#: lib/Slic3r/GUI/MainFrame.pm:254 msgid "Export current plate as STL" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:314 +#: lib/Slic3r/GUI/MainFrame.pm:257 msgid "Export plate as AMF..." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:314 +#: lib/Slic3r/GUI/MainFrame.pm:257 msgid "Export current plate as AMF" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:317 +#: lib/Slic3r/GUI/MainFrame.pm:260 msgid "Export plate as 3MF..." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:317 +#: lib/Slic3r/GUI/MainFrame.pm:260 msgid "Export current plate as 3MF" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:330 +#: lib/Slic3r/GUI/MainFrame.pm:273 msgid "Select &Plater Tab\tCtrl+1" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:330 +#: lib/Slic3r/GUI/MainFrame.pm:273 msgid "Show the plater" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:336 +#: lib/Slic3r/GUI/MainFrame.pm:279 msgid "Select &Controller Tab\tCtrl+T" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:336 +#: lib/Slic3r/GUI/MainFrame.pm:279 msgid "Show the printer controller" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:344 +#: lib/Slic3r/GUI/MainFrame.pm:287 msgid "Select P&rint Settings Tab\tCtrl+2" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:344 +#: lib/Slic3r/GUI/MainFrame.pm:287 msgid "Show the print settings" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:347 +#: lib/Slic3r/GUI/MainFrame.pm:290 msgid "Select &Filament Settings Tab\tCtrl+3" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:347 +#: lib/Slic3r/GUI/MainFrame.pm:290 msgid "Show the filament settings" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:350 +#: lib/Slic3r/GUI/MainFrame.pm:293 msgid "Select Print&er Settings Tab\tCtrl+4" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:350 +#: lib/Slic3r/GUI/MainFrame.pm:293 msgid "Show the printer settings" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:362 +#: lib/Slic3r/GUI/MainFrame.pm:305 msgid "Iso" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:362 +#: lib/Slic3r/GUI/MainFrame.pm:305 msgid "Iso View" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:363 +#: lib/Slic3r/GUI/MainFrame.pm:306 msgid "Top View" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:364 +#: lib/Slic3r/GUI/MainFrame.pm:307 msgid "Bottom View" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:365 +#: lib/Slic3r/GUI/MainFrame.pm:308 msgid "Front" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:365 +#: lib/Slic3r/GUI/MainFrame.pm:308 msgid "Front View" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:366 +#: lib/Slic3r/GUI/MainFrame.pm:309 msgid "Rear" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:366 +#: lib/Slic3r/GUI/MainFrame.pm:309 msgid "Rear View" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:367 +#: lib/Slic3r/GUI/MainFrame.pm:310 msgid "Left" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:367 +#: lib/Slic3r/GUI/MainFrame.pm:310 msgid "Left View" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:368 +#: lib/Slic3r/GUI/MainFrame.pm:311 msgid "Right" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:368 +#: lib/Slic3r/GUI/MainFrame.pm:311 msgid "Right View" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:374 -msgid "&Configuration " -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:374 -msgid "Run Configuration " -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:379 +#: lib/Slic3r/GUI/MainFrame.pm:317 msgid "Prusa 3D Drivers" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:379 +#: lib/Slic3r/GUI/MainFrame.pm:317 msgid "Open the Prusa3D drivers download page in your browser" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:382 +#: lib/Slic3r/GUI/MainFrame.pm:320 msgid "Prusa Edition Releases" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:382 +#: lib/Slic3r/GUI/MainFrame.pm:320 msgid "Open the Prusa Edition releases page in your browser" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:389 +#: lib/Slic3r/GUI/MainFrame.pm:327 msgid "Slic3r &Website" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:389 +#: lib/Slic3r/GUI/MainFrame.pm:327 msgid "Open the Slic3r website in your browser" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:392 +#: lib/Slic3r/GUI/MainFrame.pm:330 msgid "Slic3r &Manual" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:392 +#: lib/Slic3r/GUI/MainFrame.pm:330 msgid "Open the Slic3r manual in your browser" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:396 +#: lib/Slic3r/GUI/MainFrame.pm:334 msgid "System Info" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:396 +#: lib/Slic3r/GUI/MainFrame.pm:334 msgid "Show system information" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:399 +#: lib/Slic3r/GUI/MainFrame.pm:337 msgid "Report an Issue" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:399 +#: lib/Slic3r/GUI/MainFrame.pm:337 msgid "Report an issue on the Slic3r Prusa Edition" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:402 +#: lib/Slic3r/GUI/MainFrame.pm:340 msgid "&About Slic3r" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:402 +#: lib/Slic3r/GUI/MainFrame.pm:340 msgid "Show about dialog" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:412 +#: lib/Slic3r/GUI/MainFrame.pm:350 msgid "&File" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:413 +#: lib/Slic3r/GUI/MainFrame.pm:351 msgid "&Plater" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:414 +#: lib/Slic3r/GUI/MainFrame.pm:352 msgid "&Object" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:415 +#: lib/Slic3r/GUI/MainFrame.pm:353 msgid "&Window" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:416 +#: lib/Slic3r/GUI/MainFrame.pm:354 msgid "&View" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:420 +#: lib/Slic3r/GUI/MainFrame.pm:357 msgid "&Help" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:452 +#: lib/Slic3r/GUI/MainFrame.pm:388 msgid "Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:464 +#: lib/Slic3r/GUI/MainFrame.pm:400 msgid "No previously sliced file." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:469 +#: lib/Slic3r/GUI/MainFrame.pm:401 lib/Slic3r/GUI/Plater.pm:1342 +msgid "Error" +msgstr "" + +#: lib/Slic3r/GUI/MainFrame.pm:405 msgid "Previously sliced file (" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:469 +#: lib/Slic3r/GUI/MainFrame.pm:405 msgid ") not found." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:470 +#: lib/Slic3r/GUI/MainFrame.pm:406 msgid "File Not Found" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:509 +#: lib/Slic3r/GUI/MainFrame.pm:445 msgid "SVG" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:509 +#: lib/Slic3r/GUI/MainFrame.pm:445 msgid "G-code" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:509 lib/Slic3r/GUI/Plater.pm:1615 +#: lib/Slic3r/GUI/MainFrame.pm:445 lib/Slic3r/GUI/Plater.pm:1660 msgid " file as:" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:523 +#: lib/Slic3r/GUI/MainFrame.pm:459 msgid "Slicing…" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:523 +#: lib/Slic3r/GUI/MainFrame.pm:459 msgid "Processing " msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:543 +#: lib/Slic3r/GUI/MainFrame.pm:479 msgid " was successfully sliced." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:545 +#: lib/Slic3r/GUI/MainFrame.pm:481 msgid "Slicing Done!" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:561 +#: lib/Slic3r/GUI/MainFrame.pm:497 msgid "Select the STL file to repair:" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:575 +#: lib/Slic3r/GUI/MainFrame.pm:511 msgid "Save OBJ file (less prone to coordinate errors than STL) as:" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:589 +#: lib/Slic3r/GUI/MainFrame.pm:525 msgid "Your file was repaired." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:589 +#: lib/Slic3r/GUI/MainFrame.pm:525 msgid "Repair" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:600 +#: lib/Slic3r/GUI/MainFrame.pm:536 msgid "Save configuration as:" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:618 lib/Slic3r/GUI/MainFrame.pm:662 +#: lib/Slic3r/GUI/MainFrame.pm:554 lib/Slic3r/GUI/MainFrame.pm:598 msgid "Select configuration to load:" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:641 +#: lib/Slic3r/GUI/MainFrame.pm:577 msgid "Save presets bundle as:" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:682 +#: lib/Slic3r/GUI/MainFrame.pm:618 #, possible-perl-format msgid "%d presets successfully imported." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:744 -msgid "You have unsaved changes " -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:744 -msgid ". Discard changes and continue anyway?" -msgstr "" - -#: lib/Slic3r/GUI/MainFrame.pm:745 -msgid "Unsaved Presets" -msgstr "" - -#: lib/Slic3r/GUI/Plater.pm:104 lib/Slic3r/GUI/Plater.pm:2094 +#: lib/Slic3r/GUI/Plater.pm:112 lib/Slic3r/GUI/Plater.pm:2153 msgid "3D" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:138 +#: lib/Slic3r/GUI/Plater.pm:148 msgid "2D" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:157 +#: lib/Slic3r/GUI/Plater.pm:167 msgid "Layers" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:177 lib/Slic3r/GUI/Plater.pm:195 +#: lib/Slic3r/GUI/Plater.pm:187 lib/Slic3r/GUI/Plater.pm:205 msgid "Add…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:179 lib/Slic3r/GUI/Plater.pm:197 +#: lib/Slic3r/GUI/Plater.pm:189 lib/Slic3r/GUI/Plater.pm:207 msgid "Delete All" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:180 lib/Slic3r/GUI/Plater.pm:198 +#: lib/Slic3r/GUI/Plater.pm:190 lib/Slic3r/GUI/Plater.pm:208 msgid "Arrange" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:182 +#: lib/Slic3r/GUI/Plater.pm:192 msgid "More" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:183 +#: lib/Slic3r/GUI/Plater.pm:193 msgid "Fewer" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:185 +#: lib/Slic3r/GUI/Plater.pm:195 msgid "45° ccw" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:186 +#: lib/Slic3r/GUI/Plater.pm:196 msgid "45° cw" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:187 lib/Slic3r/GUI/Plater.pm:203 +#: lib/Slic3r/GUI/Plater.pm:197 lib/Slic3r/GUI/Plater.pm:213 msgid "Scale…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:188 lib/Slic3r/GUI/Plater.pm:204 -#: lib/Slic3r/GUI/Plater.pm:2069 +#: lib/Slic3r/GUI/Plater.pm:198 lib/Slic3r/GUI/Plater.pm:214 +#: lib/Slic3r/GUI/Plater.pm:2128 msgid "Split" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:189 lib/Slic3r/GUI/Plater.pm:205 -#: lib/Slic3r/GUI/Plater.pm:2072 +#: lib/Slic3r/GUI/Plater.pm:199 lib/Slic3r/GUI/Plater.pm:215 +#: lib/Slic3r/GUI/Plater.pm:2131 msgid "Cut…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:191 lib/Slic3r/GUI/Plater.pm:206 -#: lib/Slic3r/GUI/Plater.pm:2076 +#: lib/Slic3r/GUI/Plater.pm:201 lib/Slic3r/GUI/Plater.pm:216 +#: lib/Slic3r/GUI/Plater.pm:2135 msgid "Settings…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:192 +#: lib/Slic3r/GUI/Plater.pm:202 msgid "Layer Editing" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:207 +#: lib/Slic3r/GUI/Plater.pm:217 msgid "Layer editing" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:220 +#: lib/Slic3r/GUI/Plater.pm:230 msgid "Name" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:221 lib/Slic3r/GUI/Plater.pm:904 +#: lib/Slic3r/GUI/Plater.pm:231 lib/Slic3r/GUI/Plater.pm:942 msgid "Copies" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:222 lib/Slic3r/GUI/Plater.pm:1060 -#: lib/Slic3r/GUI/Plater.pm:1065 lib/Slic3r/GUI/Plater.pm:2038 +#: lib/Slic3r/GUI/Plater.pm:232 lib/Slic3r/GUI/Plater.pm:1098 +#: lib/Slic3r/GUI/Plater.pm:1103 lib/Slic3r/GUI/Plater.pm:2097 msgid "Scale" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:236 +#: lib/Slic3r/GUI/Plater.pm:246 msgid "Export G-code…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:237 +#: lib/Slic3r/GUI/Plater.pm:247 msgid "Slice now" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:238 +#: lib/Slic3r/GUI/Plater.pm:248 msgid "Print…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:239 +#: lib/Slic3r/GUI/Plater.pm:249 msgid "Send to printer" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:240 +#: lib/Slic3r/GUI/Plater.pm:250 msgid "Export STL…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:367 +#: lib/Slic3r/GUI/Plater.pm:377 msgid "Print settings" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:369 +#: lib/Slic3r/GUI/Plater.pm:379 msgid "Printer" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:401 +#: lib/Slic3r/GUI/Plater.pm:411 msgid "Info" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:412 +#: lib/Slic3r/GUI/Plater.pm:422 msgid "Volume" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:413 +#: lib/Slic3r/GUI/Plater.pm:423 msgid "Facets" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:414 +#: lib/Slic3r/GUI/Plater.pm:424 msgid "Materials" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:415 +#: lib/Slic3r/GUI/Plater.pm:425 msgid "Manifold" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:441 +#: lib/Slic3r/GUI/Plater.pm:451 msgid "Sliced Info" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:450 +#: lib/Slic3r/GUI/Plater.pm:460 msgid "Used Filament (m)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:451 +#: lib/Slic3r/GUI/Plater.pm:461 msgid "Used Filament (mm³)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:452 +#: lib/Slic3r/GUI/Plater.pm:462 msgid "Used Filament (g)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:454 +#: lib/Slic3r/GUI/Plater.pm:464 msgid "Estimated printing time" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:633 +#: lib/Slic3r/GUI/Plater.pm:662 msgid "Loading…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:633 lib/Slic3r/GUI/Plater.pm:647 +#: lib/Slic3r/GUI/Plater.pm:662 lib/Slic3r/GUI/Plater.pm:676 msgid "Processing input file\n" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:667 +#: lib/Slic3r/GUI/Plater.pm:699 msgid "" "This file contains several objects positioned at multiple heights. Instead " "of considering them as multiple objects, should I consider\n" "this file as a single object having multiple parts?\n" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:670 lib/Slic3r/GUI/Plater.pm:687 +#: lib/Slic3r/GUI/Plater.pm:702 lib/Slic3r/GUI/Plater.pm:719 msgid "Multi-part object detected" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:684 +#: lib/Slic3r/GUI/Plater.pm:716 msgid "" "Multiple objects were loaded for a multi-material printer.\n" "Instead of considering them as multiple objects, should I consider\n" "these files to represent a single object having multiple parts?\n" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:696 +#: lib/Slic3r/GUI/Plater.pm:728 msgid "Loaded " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:748 +#: lib/Slic3r/GUI/Plater.pm:786 msgid "" "Your object appears to be too large, so it was automatically scaled down to " "fit your print bed." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:749 +#: lib/Slic3r/GUI/Plater.pm:787 msgid "Object too large?" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:904 +#: lib/Slic3r/GUI/Plater.pm:942 msgid "Enter the number of copies of the selected object:" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:931 +#: lib/Slic3r/GUI/Plater.pm:969 msgid "" "\n" "Non-positive value." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:932 +#: lib/Slic3r/GUI/Plater.pm:970 msgid "" "\n" "Not a numeric value." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:933 +#: lib/Slic3r/GUI/Plater.pm:971 msgid "Slic3r Error" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1034 +#: lib/Slic3r/GUI/Plater.pm:992 +msgid "Enter the rotation angle:" +msgstr "" + +#: lib/Slic3r/GUI/Plater.pm:992 +msgid "Rotate around " +msgstr "" + +#: lib/Slic3r/GUI/Plater.pm:992 +msgid "Invalid rotation angle entered" +msgstr "" + +#: lib/Slic3r/GUI/Plater.pm:1072 #, possible-perl-format msgid "Enter the new size for the selected object (print bed: %smm):" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1035 lib/Slic3r/GUI/Plater.pm:1039 +#: lib/Slic3r/GUI/Plater.pm:1073 lib/Slic3r/GUI/Plater.pm:1077 msgid "Scale along " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1035 lib/Slic3r/GUI/Plater.pm:1039 -#: lib/Slic3r/GUI/Plater.pm:1060 lib/Slic3r/GUI/Plater.pm:1065 +#: lib/Slic3r/GUI/Plater.pm:1073 lib/Slic3r/GUI/Plater.pm:1077 +#: lib/Slic3r/GUI/Plater.pm:1098 lib/Slic3r/GUI/Plater.pm:1103 msgid "Invalid scaling value entered" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1039 lib/Slic3r/GUI/Plater.pm:1065 -#, possible-perl-format +#: lib/Slic3r/GUI/Plater.pm:1077 lib/Slic3r/GUI/Plater.pm:1103 +#, no-perl-format msgid "Enter the scale % for the selected object:" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1060 +#: lib/Slic3r/GUI/Plater.pm:1098 msgid "Enter the new max size for the selected object:" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1116 +#: lib/Slic3r/GUI/Plater.pm:1154 msgid "" "The selected object can't be split because it contains more than one volume/" "material." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1125 +#: lib/Slic3r/GUI/Plater.pm:1163 msgid "" "The selected object couldn't be split because it contains only one part." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1290 +#: lib/Slic3r/GUI/Plater.pm:1328 msgid "Slicing cancelled" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1304 +#: lib/Slic3r/GUI/Plater.pm:1342 msgid "Another export job is currently running." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1335 -msgid "Save G-code file as:" -msgstr "" - -#: lib/Slic3r/GUI/Plater.pm:1352 -msgid "Export cancelled" -msgstr "" - -#: lib/Slic3r/GUI/Plater.pm:1449 +#: lib/Slic3r/GUI/Plater.pm:1490 msgid "File added to print queue" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1452 -msgid "Sending G-code file to the OctoPrint server..." -msgstr "" - -#: lib/Slic3r/GUI/Plater.pm:1455 +#: lib/Slic3r/GUI/Plater.pm:1496 msgid "G-code file exported to " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1458 +#: lib/Slic3r/GUI/Plater.pm:1499 msgid "Export failed" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1509 lib/Slic3r/GUI/Plater.pm:1551 +#: lib/Slic3r/GUI/Plater.pm:1511 +msgid "OctoPrint upload finished." +msgstr "" + +#: lib/Slic3r/GUI/Plater.pm:1554 lib/Slic3r/GUI/Plater.pm:1596 msgid "STL file exported to " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1562 +#: lib/Slic3r/GUI/Plater.pm:1607 msgid "AMF file exported to " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1566 +#: lib/Slic3r/GUI/Plater.pm:1611 msgid "Error exporting AMF file " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1578 +#: lib/Slic3r/GUI/Plater.pm:1623 msgid "3MF file exported to " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1582 +#: lib/Slic3r/GUI/Plater.pm:1627 msgid "Error exporting 3MF file " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1818 -msgid "" -"Please install the OpenGL modules to use this feature (see build " -"instructions)." -msgstr "" - -#: lib/Slic3r/GUI/Plater.pm:1928 +#: lib/Slic3r/GUI/Plater.pm:1985 #, possible-perl-format msgid "%d (%d shells)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1930 +#: lib/Slic3r/GUI/Plater.pm:1987 #, possible-perl-format msgid "Auto-repaired (%d errors)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1935 +#: lib/Slic3r/GUI/Plater.pm:1992 #, possible-perl-format msgid "" "%d degenerate facets, %d edges fixed, %d facets removed, %d facets added, %d " "facets reversed, %d backwards edges" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1940 +#: lib/Slic3r/GUI/Plater.pm:1997 msgid "Yes" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1991 +#: lib/Slic3r/GUI/Plater.pm:2050 msgid "Remove the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1994 +#: lib/Slic3r/GUI/Plater.pm:2053 msgid "Increase copies" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1994 +#: lib/Slic3r/GUI/Plater.pm:2053 msgid "Place one more copy of the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1997 +#: lib/Slic3r/GUI/Plater.pm:2056 msgid "Decrease copies" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1997 +#: lib/Slic3r/GUI/Plater.pm:2056 msgid "Remove one copy of the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2000 +#: lib/Slic3r/GUI/Plater.pm:2059 msgid "Set number of copies…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2000 +#: lib/Slic3r/GUI/Plater.pm:2059 msgid "Change the number of copies of the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2004 +#: lib/Slic3r/GUI/Plater.pm:2063 msgid "Rotate 45° clockwise" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2004 +#: lib/Slic3r/GUI/Plater.pm:2063 msgid "Rotate the selected object by 45° clockwise" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2007 +#: lib/Slic3r/GUI/Plater.pm:2066 msgid "Rotate 45° counter-clockwise" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2007 +#: lib/Slic3r/GUI/Plater.pm:2066 msgid "Rotate the selected object by 45° counter-clockwise" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2012 +#: lib/Slic3r/GUI/Plater.pm:2071 msgid "Rotate" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2012 +#: lib/Slic3r/GUI/Plater.pm:2071 msgid "Rotate the selected object by an arbitrary angle" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2014 +#: lib/Slic3r/GUI/Plater.pm:2073 msgid "Around X axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2014 +#: lib/Slic3r/GUI/Plater.pm:2073 msgid "Rotate the selected object by an arbitrary angle around X axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2017 +#: lib/Slic3r/GUI/Plater.pm:2076 msgid "Around Y axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2017 +#: lib/Slic3r/GUI/Plater.pm:2076 msgid "Rotate the selected object by an arbitrary angle around Y axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2020 +#: lib/Slic3r/GUI/Plater.pm:2079 msgid "Around Z axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2020 +#: lib/Slic3r/GUI/Plater.pm:2079 msgid "Rotate the selected object by an arbitrary angle around Z axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2025 +#: lib/Slic3r/GUI/Plater.pm:2084 msgid "Mirror" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2025 +#: lib/Slic3r/GUI/Plater.pm:2084 msgid "Mirror the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2027 lib/Slic3r/GUI/Plater.pm:2043 -#: lib/Slic3r/GUI/Plater.pm:2059 +#: lib/Slic3r/GUI/Plater.pm:2086 lib/Slic3r/GUI/Plater.pm:2102 +#: lib/Slic3r/GUI/Plater.pm:2118 msgid "Along X axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2027 +#: lib/Slic3r/GUI/Plater.pm:2086 msgid "Mirror the selected object along the X axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2030 lib/Slic3r/GUI/Plater.pm:2046 -#: lib/Slic3r/GUI/Plater.pm:2062 +#: lib/Slic3r/GUI/Plater.pm:2089 lib/Slic3r/GUI/Plater.pm:2105 +#: lib/Slic3r/GUI/Plater.pm:2121 msgid "Along Y axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2030 +#: lib/Slic3r/GUI/Plater.pm:2089 msgid "Mirror the selected object along the Y axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2033 lib/Slic3r/GUI/Plater.pm:2049 -#: lib/Slic3r/GUI/Plater.pm:2065 +#: lib/Slic3r/GUI/Plater.pm:2092 lib/Slic3r/GUI/Plater.pm:2108 +#: lib/Slic3r/GUI/Plater.pm:2124 msgid "Along Z axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2033 +#: lib/Slic3r/GUI/Plater.pm:2092 msgid "Mirror the selected object along the Z axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2038 lib/Slic3r/GUI/Plater.pm:2054 +#: lib/Slic3r/GUI/Plater.pm:2097 lib/Slic3r/GUI/Plater.pm:2113 msgid "Scale the selected object along a single axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2040 lib/Slic3r/GUI/Plater.pm:2056 +#: lib/Slic3r/GUI/Plater.pm:2099 lib/Slic3r/GUI/Plater.pm:2115 msgid "Uniformly…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2040 lib/Slic3r/GUI/Plater.pm:2056 +#: lib/Slic3r/GUI/Plater.pm:2099 lib/Slic3r/GUI/Plater.pm:2115 msgid "Scale the selected object along the XYZ axes" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2043 lib/Slic3r/GUI/Plater.pm:2059 +#: lib/Slic3r/GUI/Plater.pm:2102 lib/Slic3r/GUI/Plater.pm:2118 msgid "Scale the selected object along the X axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2046 lib/Slic3r/GUI/Plater.pm:2062 +#: lib/Slic3r/GUI/Plater.pm:2105 lib/Slic3r/GUI/Plater.pm:2121 msgid "Scale the selected object along the Y axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2049 lib/Slic3r/GUI/Plater.pm:2065 +#: lib/Slic3r/GUI/Plater.pm:2108 lib/Slic3r/GUI/Plater.pm:2124 msgid "Scale the selected object along the Z axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2054 +#: lib/Slic3r/GUI/Plater.pm:2113 msgid "Scale to size" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2069 +#: lib/Slic3r/GUI/Plater.pm:2128 msgid "Split the selected object into individual parts" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2072 +#: lib/Slic3r/GUI/Plater.pm:2131 msgid "Open the 3D cutting tool" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2076 +#: lib/Slic3r/GUI/Plater.pm:2135 msgid "Open the object editor dialog" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2080 +#: lib/Slic3r/GUI/Plater.pm:2139 msgid "Reload from Disk" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2080 +#: lib/Slic3r/GUI/Plater.pm:2139 msgid "Reload the selected file from Disk" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2083 +#: lib/Slic3r/GUI/Plater.pm:2142 msgid "Export object as STL…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2083 +#: lib/Slic3r/GUI/Plater.pm:2142 msgid "Export this single object as STL file" msgstr "" @@ -3755,30 +4620,34 @@ msgstr "" msgid "Drag your objects here" msgstr "" -#: lib/Slic3r/GUI/Plater/3DPreview.pm:63 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:62 msgid "1 Layer" msgstr "" -#: lib/Slic3r/GUI/Plater/3DPreview.pm:65 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:64 msgid "View" msgstr "" -#: lib/Slic3r/GUI/Plater/3DPreview.pm:75 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:71 +msgid "Volumetric flow rate" +msgstr "" + +#: lib/Slic3r/GUI/Plater/3DPreview.pm:78 msgid "Show" msgstr "" -#: lib/Slic3r/GUI/Plater/3DPreview.pm:78 lib/Slic3r/GUI/Plater/3DPreview.pm:79 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:81 lib/Slic3r/GUI/Plater/3DPreview.pm:82 msgid "Feature types" msgstr "" -#: lib/Slic3r/GUI/Plater/3DPreview.pm:96 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:99 msgid "Retractions" msgstr "" -#: lib/Slic3r/GUI/Plater/3DPreview.pm:97 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:100 msgid "Unretractions" msgstr "" -#: lib/Slic3r/GUI/Plater/3DPreview.pm:98 +#: lib/Slic3r/GUI/Plater/3DPreview.pm:101 msgid "Shells" msgstr "" diff --git a/resources/localization/list.txt b/resources/localization/list.txt index 2925495450..2112d67c36 100644 --- a/resources/localization/list.txt +++ b/resources/localization/list.txt @@ -1,15 +1,23 @@ +xs/src/slic3r/GUI/AboutDialog.cpp xs/src/slic3r/GUI/BedShapeDialog.cpp xs/src/slic3r/GUI/BedShapeDialog.hpp +xs/src/slic3r/GUI/BonjourDialog.cpp +xs/src/slic3r/GUI/ButtonsDescription.cpp +xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp +xs/src/slic3r/GUI/ConfigWizard.cpp xs/src/slic3r/GUI/GUI.cpp +xs/src/slic3r/GUI/MsgDialog.cpp xs/src/slic3r/GUI/Tab.cpp xs/src/slic3r/GUI/Tab.hpp xs/src/slic3r/GUI/Field.cpp xs/src/slic3r/GUI/OptionsGroup.cpp -xs/src/slic3r/GUI/2DBed.cpp +xs/src/slic3r/GUI/Preset.cpp +xs/src/slic3r/GUI/PresetBundle.cpp xs/src/slic3r/GUI/PresetHints.cpp -xs/src/slic3r/GUI/Preferences.hpp xs/src/slic3r/GUI/Preferences.cpp -xs/src/slic3r/GUI/BonjourDialog.cpp +xs/src/slic3r/GUI/RammingChart.cpp +xs/src/slic3r/GUI/UpdateDialogs.cpp +xs/src/slic3r/GUI/WipeTowerDialog.cpp xs/src/slic3r/Utils/OctoPrint.cpp xs/src/libslic3r/PrintConfig.cpp xs/src/libslic3r/GCode/PreviewData.cpp diff --git a/xs/src/slic3r/GUI/AboutDialog.cpp b/xs/src/slic3r/GUI/AboutDialog.cpp index 3c359fd66a..e3c4528725 100644 --- a/xs/src/slic3r/GUI/AboutDialog.cpp +++ b/xs/src/slic3r/GUI/AboutDialog.cpp @@ -57,7 +57,7 @@ AboutDialog::AboutDialog() // version { - auto version_string = _(L("Version ")) + std::string(SLIC3R_VERSION); + auto version_string = _(L("Version"))+ " " + std::string(SLIC3R_VERSION); wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize); wxFont version_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); #ifdef __WXMSW__ diff --git a/xs/src/slic3r/GUI/BonjourDialog.cpp b/xs/src/slic3r/GUI/BonjourDialog.cpp index 34fac9a911..11cfea642d 100644 --- a/xs/src/slic3r/GUI/BonjourDialog.cpp +++ b/xs/src/slic3r/GUI/BonjourDialog.cpp @@ -191,7 +191,7 @@ void BonjourDialog::on_timer(wxTimerEvent &) label->SetLabel(wxString::Format("%s %s", search_str, dots)); timer_state = (timer_state) % 3 + 1; } else { - label->SetLabel(wxString::Format("%s: %s", search_str, _(L("Finished.")))); + label->SetLabel(wxString::Format("%s: %s", search_str, _(L("Finished"))+".")); timer->Stop(); } } diff --git a/xs/src/slic3r/GUI/ButtonsDescription.cpp b/xs/src/slic3r/GUI/ButtonsDescription.cpp index 7ea16d9420..5739fc90e3 100644 --- a/xs/src/slic3r/GUI/ButtonsDescription.cpp +++ b/xs/src/slic3r/GUI/ButtonsDescription.cpp @@ -10,7 +10,7 @@ namespace Slic3r { namespace GUI { ButtonsDescription::ButtonsDescription(wxWindow* parent, t_icon_descriptions* icon_descriptions) : - wxDialog(parent, wxID_ANY, "Buttons And Text Colors Description", wxDefaultPosition, wxDefaultSize), + wxDialog(parent, wxID_ANY, _(L("Buttons And Text Colors Description")), wxDefaultPosition, wxDefaultSize), m_icon_descriptions(icon_descriptions) { auto grid_sizer = new wxFlexGridSizer(3, 20, 20); diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp index c0affcab7c..efcbf05bdb 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -8,32 +8,32 @@ namespace Slic3r { namespace GUI { -static std::string format_reason(const Config::Snapshot::Reason reason) +static wxString format_reason(const Config::Snapshot::Reason reason) { switch (reason) { case Config::Snapshot::SNAPSHOT_UPGRADE: - return std::string(_(L("Upgrade"))); + return wxString(_(L("Upgrade"))); case Config::Snapshot::SNAPSHOT_DOWNGRADE: - return std::string(_(L("Downgrade"))); + return wxString(_(L("Downgrade"))); case Config::Snapshot::SNAPSHOT_BEFORE_ROLLBACK: - return std::string(_(L("Before roll back"))); + return wxString(_(L("Before roll back"))); case Config::Snapshot::SNAPSHOT_USER: - return std::string(_(L("User"))); + return wxString(_(L("User"))); case Config::Snapshot::SNAPSHOT_UNKNOWN: default: - return std::string(_(L("Unknown"))); + return wxString(_(L("Unknown"))); } } -static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_even, bool snapshot_active) +static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_even, bool snapshot_active) { // Start by declaring a row with an alternating background color. - std::string text = ""; text += ""; // Format the row header. - text += std::string("") + (snapshot_active ? _(L("Active: ")) : "") + + text += wxString("") + (snapshot_active ? _(L("Active: ")) : "") + Utils::format_local_date_time(snapshot.time_captured) + ": " + format_reason(snapshot.reason); if (! snapshot.comment.empty()) text += " (" + snapshot.comment + ")"; @@ -46,9 +46,10 @@ static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_ bool compatible = true; for (const Config::Snapshot::VendorConfig &vc : snapshot.vendor_configs) { - text += _(L("vendor")) + ": " + vc.name + ", ver: " + vc.version.config_version.to_string() + ", min slic3r ver: " + vc.version.min_slic3r_version.to_string(); + text += _(L("vendor")) + ": " + vc.name +", " + _(L("version")) + ": " + vc.version.config_version.to_string() + + ", " + _(L("min slic3r version")) + ": " + vc.version.min_slic3r_version.to_string(); if (vc.version.max_slic3r_version != Semver::inf()) - text += ", max slic3r ver: " + vc.version.max_slic3r_version.to_string(); + text += ", " + _(L("max slic3r version")) + ": " + vc.version.max_slic3r_version.to_string(); text += "
"; for (const std::pair> &model : vc.models_variants_installed) { text += _(L("model")) + ": " + model.first + ", " + _(L("variants")) + ": "; @@ -72,9 +73,9 @@ static std::string generate_html_row(const Config::Snapshot &snapshot, bool row_ return text; } -static std::string generate_html_page(const Config::SnapshotDB &snapshot_db, const std::string &on_snapshot) +static wxString generate_html_page(const Config::SnapshotDB &snapshot_db, const wxString &on_snapshot) { - std::string text = + wxString text = "" "" ""; @@ -91,7 +92,7 @@ static std::string generate_html_page(const Config::SnapshotDB &snapshot_db, con return text; } -ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const std::string &on_snapshot) +ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const wxString &on_snapshot) : wxDialog(NULL, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition, wxSize(600, 500), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX) { this->SetBackgroundColour(*wxWHITE); @@ -110,8 +111,8 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db #endif html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); html->SetBorders(2); - std::string text = generate_html_page(snapshot_db, on_snapshot); - html->SetPage(text.c_str()); + wxString text = generate_html_page(snapshot_db, on_snapshot); + html->SetPage(text); vsizer->Add(html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 0); html->Bind(wxEVT_HTML_LINK_CLICKED, &ConfigSnapshotDialog::onLinkClicked, this); } diff --git a/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp b/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp index 943601e731..f43fb8ed16 100644 --- a/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp +++ b/xs/src/slic3r/GUI/ConfigSnapshotDialog.hpp @@ -17,7 +17,7 @@ namespace Config { class ConfigSnapshotDialog : public wxDialog { public: - ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const std::string &id); + ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const wxString &id); const std::string& snapshot_to_activate() const { return m_snapshot_to_activate; } private: diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 8d8818126d..e6c07b470e 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -203,7 +203,7 @@ static void init_label_colours() { auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); if (luma >= 128) { - g_color_label_modified = wxColour(253, 88, 0); + g_color_label_modified = wxColour(252, 77, 1); g_color_label_sys = wxColour(26, 132, 57); } else { g_color_label_modified = wxColour(253, 111, 40); @@ -339,6 +339,7 @@ bool load_language() void save_language() { + //! TO DO !! use GetCanonicalName; long language = wxLANGUAGE_UNKNOWN; if (g_wxLocale) { language = g_wxLocale->GetLanguage(); @@ -398,12 +399,12 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l const auto config_wizard_tooltip = wxString::Format(_(L("Run %s")), ConfigWizard::name()); // Cmd+, is standard on OS X - what about other operating systems? - local_menu->Append(config_id_base + ConfigMenuWizard, ConfigWizard::name() + "\u2026", config_wizard_tooltip); - local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots\u2026")), _(L("Inspect / activate configuration snapshots"))); - local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration Snapshot")), _(L("Capture a configuration snapshot"))); - local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); + local_menu->Append(config_id_base + ConfigMenuWizard, ConfigWizard::name() + "\u2026", config_wizard_tooltip); + local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots"))+"\u2026", _(L("Inspect / activate configuration snapshots"))); + local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration Snapshot")), _(L("Capture a configuration snapshot"))); + local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); local_menu->AppendSeparator(); - local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences\u2026\tCtrl+,")), _(L("Application preferences"))); + local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences"))+"\u2026\tCtrl+,", _(L("Application preferences"))); local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ @@ -685,7 +686,7 @@ void show_info(wxWindow* parent, const wxString& message, const wxString& title) } void warning_catcher(wxWindow* parent, const wxString& message){ - if (message == _(L("GLUquadricObjPtr | Attempt to free unreferenced scalar")) ) + if (message == "GLUquadricObjPtr | " + _(L("Attempt to free unreferenced scalar")) ) return; wxMessageDialog msg(parent, message, _(L("Warning")), wxOK | wxICON_WARNING); msg.ShowModal(); @@ -903,7 +904,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl m_optgroup->append_single_option_line(option); - Line line = { _(L("")), "" }; + Line line = { "", "" }; line.widget = [config](wxWindow* parent){ g_wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes")) + "\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); diff --git a/xs/src/slic3r/GUI/Preferences.cpp b/xs/src/slic3r/GUI/Preferences.cpp index 4c60577d56..cb7ac92a69 100644 --- a/xs/src/slic3r/GUI/Preferences.cpp +++ b/xs/src/slic3r/GUI/Preferences.cpp @@ -5,6 +5,12 @@ namespace Slic3r { namespace GUI { +PreferencesDialog::PreferencesDialog(wxWindow* parent, int event_preferences) : + wxDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition, wxDefaultSize), + m_event_preferences(event_preferences) { + build(); + } + void PreferencesDialog::build() { auto app_config = get_app_config(); diff --git a/xs/src/slic3r/GUI/Preferences.hpp b/xs/src/slic3r/GUI/Preferences.hpp index f94a1db69e..d01d78b70b 100644 --- a/xs/src/slic3r/GUI/Preferences.hpp +++ b/xs/src/slic3r/GUI/Preferences.hpp @@ -17,8 +17,7 @@ class PreferencesDialog : public wxDialog std::shared_ptr m_optgroup; int m_event_preferences; public: - PreferencesDialog(wxWindow* parent, int event_preferences) : wxDialog(parent, wxID_ANY, _(L("Preferences")), - wxDefaultPosition, wxDefaultSize), m_event_preferences(event_preferences) { build(); } + PreferencesDialog(wxWindow* parent, int event_preferences); ~PreferencesDialog(){ } void build(); diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index bc59ac2f92..1388c35103 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -602,7 +602,7 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) std::map nonsys_presets; wxString selected = ""; if (!this->m_presets.front().is_visible) - ui->Append("------- System presets -------", wxNullBitmap); + ui->Append("------- " +_(L("System presets")) + " -------", wxNullBitmap); for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++i) { const Preset &preset = this->m_presets[i]; if (! preset.is_visible || (! preset.is_compatible && i != m_idx_selected)) @@ -642,11 +642,11 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); } if (preset.is_default) - ui->Append("------- System presets -------", wxNullBitmap); + ui->Append("------- " + _(L("System presets")) + " -------", wxNullBitmap); } if (!nonsys_presets.empty()) { - ui->Append("------- User presets -------", wxNullBitmap); + ui->Append("------- " + _(L("User presets")) + " -------", wxNullBitmap); for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { ui->Append(it->first, *it->second); if (it->first == selected) @@ -667,7 +667,7 @@ size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompati std::map nonsys_presets; wxString selected = ""; if (!this->m_presets.front().is_visible) - ui->Append("------- System presets -------", wxNullBitmap); + ui->Append("------- " + _(L("System presets")) + " -------", wxNullBitmap); for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++i) { const Preset &preset = this->m_presets[i]; if (! preset.is_visible || (! show_incompatible && ! preset.is_compatible && i != m_idx_selected)) @@ -699,11 +699,11 @@ size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompati selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); } if (preset.is_default) - ui->Append("------- System presets -------", wxNullBitmap); + ui->Append("------- " + _(L("System presets")) + " -------", wxNullBitmap); } if (!nonsys_presets.empty()) { - ui->Append("------- User presets -------", wxNullBitmap); + ui->Append("------- " + _(L("User presets")) + " -------", wxNullBitmap); for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { ui->Append(it->first, *it->second); if (it->first == selected) @@ -808,11 +808,6 @@ bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, b // If the first visible preset was not found, return the 0th element, which is the default preset. } - // Temporary decision - if (name_w_suffix == "------- System presets -------" || - name_w_suffix == "------- User presets -------") - return true; - // 2) Select the new preset. if (m_idx_selected != idx || force) { this->select_preset(idx); diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 9123e144b4..63b6a4e0ce 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -1011,8 +1011,7 @@ void PresetBundle::export_configbundle(const std::string &path) //, const Dynami // an optional "(modified)" suffix will be removed from the filament name. void PresetBundle::set_filament_preset(size_t idx, const std::string &name) { - if (name == "------- System presets -------" || - name == "------- User presets -------") + if (name.find_first_of("-------") == 0) return; if (idx >= filament_presets.size()) @@ -1066,7 +1065,7 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma std::map nonsys_presets; wxString selected_str = ""; if (!this->filaments().front().is_visible) - ui->Append("------- System presets -------", wxNullBitmap); + ui->Append("------- " + _(L("System presets")) + " -------", wxNullBitmap); for (int i = this->filaments().front().is_visible ? 0 : 1; i < int(this->filaments().size()); ++i) { const Preset &preset = this->filaments.preset(i); bool selected = this->filament_presets[idx_extruder] == preset.name; @@ -1119,12 +1118,12 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma selected_str = wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()); } if (preset.is_default) - ui->Append("------- System presets -------", wxNullBitmap); + ui->Append("------- " + _(L("System presets")) + " -------", wxNullBitmap); } if (!nonsys_presets.empty()) { - ui->Append("------- User presets -------", wxNullBitmap); + ui->Append("------- " + _(L("User presets")) + " -------", wxNullBitmap); for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { ui->Append(it->first, *it->second); if (it->first == selected_str) diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp index 1ef43be026..97a6b7712c 100644 --- a/xs/src/slic3r/GUI/RammingChart.cpp +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -25,7 +25,7 @@ void Chart::draw() { dc.DrawRectangle(m_rect); if (visible_area.m_width < 0.499) { - dc.DrawText("NO RAMMING AT ALL",wxPoint(m_rect.GetLeft()+m_rect.GetWidth()/2-50,m_rect.GetBottom()-m_rect.GetHeight()/2)); + dc.DrawText(_(L("NO RAMMING AT ALL")),wxPoint(m_rect.GetLeft()+m_rect.GetWidth()/2-50,m_rect.GetBottom()-m_rect.GetHeight()/2)); return; } @@ -78,12 +78,12 @@ void Chart::draw() { } // axis labels: - wxString label = L("Time (s)"); + wxString label = _(L("Time")) + " ("+_(L("s"))+")"; int text_width = 0; int text_height = 0; dc.GetTextExtent(label,&text_width,&text_height); dc.DrawText(label,wxPoint(0.5*(m_rect.GetRight()+m_rect.GetLeft())-text_width/2.f, m_rect.GetBottom()+25)); - label = L("Volumetric speed (mm\u00B3/s)"); + label = _(L("Volumetric speed")) + " (" + _(L("mm")) + "\u00B3/" + _(L("s")) + ")"; dc.GetTextExtent(label,&text_width,&text_height); dc.DrawRotatedText(label,wxPoint(0,0.5*(m_rect.GetBottom()+m_rect.GetTop())+text_width/2.f),90); } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index bb1d938a85..ee75f1920d 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -230,8 +230,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) return; if (selected_item >= 0){ std::string selected_string = m_presets_choice->GetString(selected_item).ToUTF8().data(); - if (selected_string == "------- System presets -------" || - selected_string == "------- User presets -------"){ + if (selected_string.find_first_of("-------") == 0 + /*selected_string == "------- System presets -------" || + selected_string == "------- User presets -------"*/){ m_presets_choice->SetSelection(m_selected_preset_item); return; } diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index b34de07458..4b25ccd3ad 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -79,15 +79,15 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,10,200,100); auto gsizer_param = new wxFlexGridSizer(2, 5, 15); - gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total ramming time (s):")))), 0, wxALIGN_CENTER_VERTICAL); + gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total ramming time")) + " (" + _(L("s")) + "):")), 0, wxALIGN_CENTER_VERTICAL); gsizer_param->Add(m_widget_time); - gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total rammed volume (mm"))+"\u00B3):")), 0, wxALIGN_CENTER_VERTICAL); + gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total rammed volume")) + " (" + _(L("mm")) + "\u00B3):")), 0, wxALIGN_CENTER_VERTICAL); gsizer_param->Add(m_widget_volume); gsizer_param->AddSpacer(20); gsizer_param->AddSpacer(20); - gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line width (%):")))), 0, wxALIGN_CENTER_VERTICAL); + gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line width")) + " (%):")), 0, wxALIGN_CENTER_VERTICAL); gsizer_param->Add(m_widget_ramming_line_width_multiplicator); - gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line spacing (%):")))), 0, wxALIGN_CENTER_VERTICAL); + gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line spacing")) + " (%):")), 0, wxALIGN_CENTER_VERTICAL); gsizer_param->Add(m_widget_ramming_step_multiplicator); sizer_param->Add(gsizer_param, 0, wxTOP, 100); @@ -220,7 +220,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con // collect and format sizer format_sizer(m_sizer_advanced, m_page_advanced, m_gridsizer_advanced, - _(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")), + wxString::Format(_(L("Here you can adjust required purging volume (mm%s) for any given pair of tools.")), "\u00B3"), _(L("Extruder changed to"))); // Hide preview page before new page creating @@ -243,7 +243,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con // collect and format sizer format_sizer(m_sizer_simple, m_page_simple, gridsizer_simple, _(L("Total purging volume is calculated by summing two values below, depending on which tools are loaded/unloaded.")), - _(L("Volume to purge (mm\u00B3) when the filament is being")), 50); + wxString::Format(_(L("Volume to purge (mm%s) when the filament is being")), "\u00B3"), 50); m_sizer = new wxBoxSizer(wxVERTICAL); m_sizer->Add(m_page_simple, 0, wxEXPAND | wxALL, 25); From 8ad605354460407d3462644ac811bc1bc3776c67 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 2 May 2018 17:13:39 +0200 Subject: [PATCH 0297/1150] PresetUpdater: More logging --- xs/src/slic3r/Utils/PresetUpdater.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 3b786e0d67..3b74b0c6b4 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -359,6 +359,11 @@ Updates PresetUpdater::priv::get_config_updates() const const auto cached_vp = VendorProfile::from_ini(path_in_cache, false); if (cached_vp.config_version == recommended->config_version) { updates.updates.emplace_back(std::move(path_in_cache), std::move(bundle_path), *recommended); + } else { + BOOST_LOG_TRIVIAL(warning) << boost::format("Vendor: %1%: Index indicates update (%2%) but cached bundle has a different version: %3%") + % idx.vendor() + % recommended->config_version.to_string() + % cached_vp.config_version.to_string(); } } } From a02bfdd2bc5f6cd942bf6c124a1e19ea7d066be9 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 3 May 2018 09:10:12 +0200 Subject: [PATCH 0298/1150] Initial zoom set to bed extent --- lib/Slic3r/GUI/3DScene.pm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 59b5367b58..352a612643 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1152,11 +1152,7 @@ sub InitGL { $self->volumes->finalize_geometry(1) if ($^O eq 'linux' && $self->UseVBOs); - if (scalar @{$self->volumes} > 0) { - $self->zoom_to_volumes; - } else { - $self->zoom_to_bed; - } + $self->zoom_to_bed; glClearColor(0, 0, 0, 1); glColor3f(1, 0, 0); From 20b83c5b534c6767b04338578df2d2c6ff111bd1 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 3 May 2018 09:21:01 +0200 Subject: [PATCH 0299/1150] Save the Canonical Language Name instead of the Enumerator to the Slic3r.ini --- xs/src/slic3r/GUI/GUI.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index e6c07b470e..4789f4590b 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -309,22 +309,18 @@ bool select_language(wxArrayString & names, bool load_language() { - long language; - if (!g_AppConfig->has("translation_language")) - language = wxLANGUAGE_UNKNOWN; - else { - auto str_language = g_AppConfig->get("translation_language"); - language = str_language != "" ? stol(str_language) : wxLANGUAGE_UNKNOWN; - } + wxString language = wxEmptyString; + if (g_AppConfig->has("translation_language")) + language = g_AppConfig->get("translation_language"); - if (language == wxLANGUAGE_UNKNOWN) + if (language.IsEmpty()) return false; wxArrayString names; wxArrayLong identifiers; get_installed_languages(names, identifiers); for (size_t i = 0; i < identifiers.Count(); i++) { - if (identifiers[i] == language) + if (wxLocale::GetLanguageCanonicalName(identifiers[i]) == language) { g_wxLocale = new wxLocale; g_wxLocale->Init(identifiers[i]); @@ -339,13 +335,11 @@ bool load_language() void save_language() { - //! TO DO !! use GetCanonicalName; - long language = wxLANGUAGE_UNKNOWN; - if (g_wxLocale) { - language = g_wxLocale->GetLanguage(); - } - std::string str_language = std::to_string(language); - g_AppConfig->set("translation_language", str_language); + wxString language = wxEmptyString; + if (g_wxLocale) + language = g_wxLocale->GetCanonicalName(); + + g_AppConfig->set("translation_language", language.ToStdString()); g_AppConfig->save(); } From d19b1162b3689de25af260bb958272df6bf77a3a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 3 May 2018 11:09:13 +0200 Subject: [PATCH 0300/1150] Fixed normals on wipe tower box --- xs/src/libslic3r/TriangleMesh.cpp | 10 +++++++--- xs/src/slic3r/GUI/3DScene.cpp | 11 +++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index aecb39662e..45e4b6f5dc 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -51,9 +51,6 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector& fa for (int i = 0; i < stl.stats.number_of_facets; i++) { stl_facet facet; - facet.normal.x = 0; - facet.normal.y = 0; - facet.normal.z = 0; const Pointf3& ref_f1 = points[facets[i].x]; facet.vertex[0].x = ref_f1.x; @@ -73,6 +70,13 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector& fa facet.extra[0] = 0; facet.extra[1] = 0; + float normal[3]; + stl_calculate_normal(normal, &facet); + stl_normalize_vector(normal); + facet.normal.x = normal[0]; + facet.normal.y = normal[1]; + facet.normal.z = normal[2]; + stl.facet_start[i] = facet; } stl_get_size(&stl); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index a016ab5aa0..6b2f5c8309 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -443,13 +443,16 @@ std::vector GLVolumeCollection::load_object( int GLVolumeCollection::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) { - float color[4] = { 1.0f, 1.0f, 0.0f, 0.5f }; + float color[4] = { 0.5f, 0.5f, 0.0f, 0.5f }; this->volumes.emplace_back(new GLVolume(color)); GLVolume &v = *this->volumes.back(); - auto mesh = make_cube(width, depth, height); - mesh.translate(-width/2.f,-depth/2.f,0.f); - Point origin_of_rotation(0.f,0.f); + if (height == 0.0f) + height = 0.1f; + + auto mesh = make_cube(width, depth, height); + mesh.translate(-width / 2.f, -depth / 2.f, 0.f); + Point origin_of_rotation(0.f, 0.f); mesh.rotate(rotation_angle,&origin_of_rotation); if (use_VBOs) From 993294579d93ebda300c18e0d96b902c6b846a15 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 3 May 2018 13:27:20 +0200 Subject: [PATCH 0301/1150] Button's border and background aren't use on MSW. --- xs/src/slic3r/GUI/GUI.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 83d1e246e1..2542c04c6e 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -813,24 +813,24 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl wxCollapsiblePane *collpane = new wxCollapsiblePane(parent, wxID_ANY, "Print settings:"); collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, collpane](wxCommandEvent e){ wxWindowUpdateLocker noUpdates(parent); - parent->Layout(); collpane->Refresh(); })); // add the pane with a zero proportion value to the sizer which contains it - sizer->Add(collpane, 0, wxGROW | wxALL, 5); - // now add a test label in the collapsible pane using a sizer to layout it: + sizer->Add(collpane, 0, wxGROW | wxALL, 0); + wxWindow *win = collpane->GetPane(); #ifdef __WXMSW__ - collpane->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - win->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + wxColour& clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); + collpane->GetControlWidget()->SetWindowStyleFlag(wxNO_BORDER); + collpane->GetControlWidget()->SetBackgroundColour(clr); + collpane->SetBackgroundColour(clr); + win->SetBackgroundColour(clr); #endif //__WXMSW__ DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; - m_optgroup = std::make_shared(/*parent*/win, "", config); -// const wxArrayInt& ar = preset_sizer->GetColWidths(); -// m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front(); // doesn't work + m_optgroup = std::make_shared(win, "", config); m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ TabPrint* tab_print = nullptr; for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { @@ -943,10 +943,6 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl m_optgroup->append_line(line); - -// sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); - - wxSizer *paneSz = new wxBoxSizer(wxVERTICAL); paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | wxBOTTOM, 2); win->SetSizer(paneSz); From af4e0308ae63149a5bc7bcf69b67d0967c7900b2 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 3 May 2018 13:49:37 +0200 Subject: [PATCH 0302/1150] Fixed visibility of the contents of the GCode fields --- xs/src/slic3r/GUI/OptionsGroup.cpp | 19 ++++++++++++++++--- xs/src/slic3r/GUI/OptionsGroup.hpp | 2 -- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 09a2fe50f6..50e6a688e0 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -118,21 +118,34 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* if (option_set.size() == 1 && label_width == 0 && option_set.front().opt.full_width && option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) { + wxBoxSizer* tmp_sizer; +#ifdef __WXGTK__ + tmp_sizer = new wxBoxSizer(wxVERTICAL); + m_panel->SetSizer(tmp_sizer); + m_panel->Layout(); +#else + tmp_sizer = sizer; +#endif /* __WXGTK__ */ + const auto& option = option_set.front(); const auto& field = build_field(option); auto btn_sizer = new wxBoxSizer(wxHORIZONTAL); btn_sizer->Add(field->m_Undo_to_sys_btn); btn_sizer->Add(field->m_Undo_btn); - sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0); + tmp_sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0); if (is_window_field(field)) - sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); + tmp_sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); if (is_sizer_field(field)) - sizer->Add(field->getSizer(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); + tmp_sizer->Add(field->getSizer(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); return; } auto grid_sizer = m_grid_sizer; +#ifdef __WXGTK__ + m_panel->SetSizer(m_grid_sizer); + m_panel->Layout(); +#endif /* __WXGTK__ */ // Build a label if we have it wxStaticText* label=nullptr; diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 01d9184fd1..83b5b1233f 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -138,8 +138,6 @@ public: static_cast(m_grid_sizer)->AddGrowableCol(label_width != 0); #ifdef __WXGTK__ m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_panel->SetSizer(m_grid_sizer); - m_panel->Layout(); sizer->Fit(m_panel); sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5); #else From dd4669d1a0c86e80a3aac55f4633872aba051553 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 3 May 2018 16:08:41 +0200 Subject: [PATCH 0303/1150] Fixed crash when reducing objects from 2D/preview/layers tabs --- lib/Slic3r/GUI/3DScene.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 352a612643..1b6adf800e 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -908,6 +908,9 @@ sub deselect_volumes { sub select_volume { my ($self, $volume_idx) = @_; + + return if ($volume_idx >= scalar(@{$self->volumes})); + $self->volumes->[$volume_idx]->set_selected(1) if $volume_idx != -1; } From 471f90659fcfb4c765637850de19e959a6b2110f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 3 May 2018 16:28:41 +0200 Subject: [PATCH 0304/1150] Fixed typo preventing to build on Win --- xs/src/slic3r/GUI/OptionsGroup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 50e6a688e0..657ad03c03 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -118,7 +118,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* if (option_set.size() == 1 && label_width == 0 && option_set.front().opt.full_width && option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) { - wxBoxSizer* tmp_sizer; + wxSizer* tmp_sizer; #ifdef __WXGTK__ tmp_sizer = new wxBoxSizer(wxVERTICAL); m_panel->SetSizer(tmp_sizer); From 19977edae21aba12c90a52d3d51f8d3f6d3d439a Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 3 May 2018 21:45:43 +0200 Subject: [PATCH 0305/1150] Removed the "Broken croak" support, which was useful on broken 64bit Strawberry perl only. We don't use Strawberry perl anymore, so this has been removed for clarity. Added a PerlCallback wrapper to call a Perl subroutine from a C++ code. --- CMakeLists.txt | 1 - xs/CMakeLists.txt | 4 - xs/src/libslic3r/GCode/CoolingBuffer.cpp | 2 +- xs/src/libslic3r/Utils.hpp | 15 +++ xs/src/libslic3r/utils.cpp | 123 ++++++++++++++++------- xs/src/xsinit.h | 9 -- xs/t/22_exception.t | 15 +-- 7 files changed, 104 insertions(+), 65 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb3d6dfd6c..e8b2a6faaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,6 @@ option(SLIC3R_STATIC "Compile Slic3r with static libraries (Boost, TBB, glew) option(SLIC3R_GUI "Compile Slic3r with GUI components (OpenGL, wxWidgets)" 1) option(SLIC3R_PRUSACONTROL "Compile Slic3r with the PrusaControl prject file format (requires wxWidgets base library)" 1) option(SLIC3R_PROFILE "Compile Slic3r with an invasive Shiny profiler" 0) -option(SLIC3R_HAS_BROKEN_CROAK "Compile Slic3r for a broken Strawberry Perl 64bit" 0) option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1) if (MSVC AND SLIC3R_MSVC_COMPILE_PARALLEL) diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 4f97c0acfe..4f44fc7bf7 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -475,10 +475,6 @@ if (SLIC3R_PROFILE) add_definitions(-DSLIC3R_PROFILE) endif () -if (SLIC3R_HAS_BROKEN_CROAK) - target_compile_definitions(XS PRIVATE -DSLIC3R_HAS_BROKEN_CROAK) -endif () - if (CMAKE_BUILD_TYPE MATCHES DEBUG) target_compile_definitions(XS PRIVATE -DSLIC3R_DEBUG -DDEBUG -D_DEBUG) else () diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index b786f9bce5..a15247693c 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -536,7 +536,7 @@ float CoolingBuffer::calculate_layer_slowdown(std::vector 0) { by_slowdown_time.emplace_back(&adj); if (! m_cooling_logic_proportional) // sorts the lines, also sets adj.time_non_adjustable diff --git a/xs/src/libslic3r/Utils.hpp b/xs/src/libslic3r/Utils.hpp index 0066aa5e69..e5157741ec 100644 --- a/xs/src/libslic3r/Utils.hpp +++ b/xs/src/libslic3r/Utils.hpp @@ -84,6 +84,21 @@ inline T next_highest_power_of_2(T v) return ++ v; } +class PerlCallback { +public: + PerlCallback(void *sv) : m_callback(nullptr) { this->register_callback(sv); } + PerlCallback() : m_callback(nullptr) {} + ~PerlCallback() { this->deregister_callback(); } + void register_callback(void *sv); + void deregister_callback(); + void call(); + void call(int i); + void call(int i, int j); +// void call(const std::vector &ints); +private: + void *m_callback; +}; + } // namespace Slic3r #endif // slic3r_Utils_hpp_ diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp index f2415ac072..2978783a63 100644 --- a/xs/src/libslic3r/utils.cpp +++ b/xs/src/libslic3r/utils.cpp @@ -1,3 +1,5 @@ +#include "Utils.hpp" + #include #include @@ -135,44 +137,6 @@ const std::string& data_dir() } // namespace Slic3r -#ifdef SLIC3R_HAS_BROKEN_CROAK - -// Some Strawberry Perl builds (mainly the latest 64bit builds) have a broken mechanism -// for emiting Perl exception after handling a C++ exception. Perl interpreter -// simply hangs. Better to show a message box in that case and stop the application. - -#include -#include -#include -#include - -#ifdef WIN32 -#include -#endif - -void confess_at(const char *file, int line, const char *func, const char *format, ...) -{ - char dest[1024*8]; - va_list argptr; - va_start(argptr, format); - vsprintf(dest, format, argptr); - va_end(argptr); - - char filelinefunc[1024*8]; - sprintf(filelinefunc, "\r\nin function: %s\r\nfile: %s\r\nline: %d\r\n", func, file, line); - strcat(dest, filelinefunc); - strcat(dest, "\r\n Closing the application.\r\n"); - #ifdef WIN32 - ::MessageBoxA(NULL, dest, "Slic3r Prusa Edition", MB_OK | MB_ICONERROR); - #endif - - // Give up. - printf(dest); - exit(-1); -} - -#else - #include void @@ -202,7 +166,88 @@ confess_at(const char *file, int line, const char *func, #endif } -#endif +void PerlCallback::register_callback(void *sv) +{ + if (! SvROK((SV*)sv) || SvTYPE(SvRV((SV*)sv)) != SVt_PVCV) + croak("Not a Callback %_ for PerlFunction", (SV*)sv); + if (m_callback) + SvSetSV((SV*)m_callback, (SV*)sv); + else + m_callback = newSVsv((SV*)sv); +} + +void PerlCallback::deregister_callback() +{ + if (m_callback) { + sv_2mortal((SV*)m_callback); + m_callback = nullptr; + } +} + +void PerlCallback::call() +{ + if (! m_callback) + return; + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + PUTBACK; + perl_call_sv(SvRV((SV*)m_callback), G_DISCARD); + FREETMPS; + LEAVE; +} + +void PerlCallback::call(int i) +{ + if (! m_callback) + return; + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + XPUSHs(sv_2mortal(newSViv(i))); + PUTBACK; + perl_call_sv(SvRV((SV*)m_callback), G_DISCARD); + FREETMPS; + LEAVE; +} + +void PerlCallback::call(int i, int j) +{ + if (! m_callback) + return; + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + XPUSHs(sv_2mortal(newSViv(i))); + XPUSHs(sv_2mortal(newSViv(j))); + PUTBACK; + perl_call_sv(SvRV((SV*)m_callback), G_DISCARD); + FREETMPS; + LEAVE; +} + +/* +void PerlCallback::call(const std::vector &ints) +{ + if (! m_callback) + return; + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + AV* av = newAV(); + for (int i : ints) + av_push(av, newSViv(i)); + XPUSHs(av); + PUTBACK; + perl_call_sv(SvRV((SV*)m_callback), G_DISCARD); + FREETMPS; + LEAVE; +} +*/ #ifdef WIN32 #ifndef NOMINMAX diff --git a/xs/src/xsinit.h b/xs/src/xsinit.h index 9cb60384f6..01c1293ac6 100644 --- a/xs/src/xsinit.h +++ b/xs/src/xsinit.h @@ -195,15 +195,6 @@ SV* to_SV(TriangleMesh* THIS); } -#ifdef SLIC3R_HAS_BROKEN_CROAK -#undef croak -#ifdef _MSC_VER - #define croak(...) confess_at(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) -#else - #define croak(...) confess_at(__FILE__, __LINE__, __func__, __VA_ARGS__) -#endif -#endif - // Defined in wxPerlIface.cpp // Return a pointer to the associated wxWidgets object instance given by classname. extern void* wxPli_sv_2_object( pTHX_ SV* scalar, const char* classname ); diff --git a/xs/t/22_exception.t b/xs/t/22_exception.t index c7df42670a..fead8ddee7 100644 --- a/xs/t/22_exception.t +++ b/xs/t/22_exception.t @@ -6,16 +6,9 @@ use warnings; use Slic3r::XS; use Test::More tests => 1; -if ($ENV{SLIC3R_HAS_BROKEN_CROAK}) -{ - ok 1, 'SLIC3R_HAS_BROKEN_CROAK set, croaks and confesses from a C++ code will lead to an application exit!'; -} -else -{ - eval { - Slic3r::xspp_test_croak_hangs_on_strawberry(); - }; - is $@, "xspp_test_croak_hangs_on_strawberry: exception catched\n", 'croak from inside a C++ exception delivered'; -} +eval { + Slic3r::xspp_test_croak_hangs_on_strawberry(); +}; +is $@, "xspp_test_croak_hangs_on_strawberry: exception catched\n", 'croak from inside a C++ exception delivered'; __END__ From c4885506363893518f8225904ad1968f114896ac Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 4 May 2018 11:57:37 +0200 Subject: [PATCH 0306/1150] Fixed update of 3D view when selecting objects on Linux --- lib/Slic3r/GUI/Plater.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a0fbf15470..a3ad064cd0 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1810,6 +1810,7 @@ sub list_item_deselected { $self->select_object(undef); $self->{canvas}->Refresh; $self->{canvas3D}->deselect_volumes if $self->{canvas3D}; + $self->{canvas3D}->Render if $self->{canvas3D}; } undef $self->{_lecursor}; } @@ -1822,6 +1823,7 @@ sub list_item_selected { $self->select_object($obj_idx); $self->{canvas}->Refresh; $self->{canvas3D}->update_volumes_selection if $self->{canvas3D}; + $self->{canvas3D}->Render if $self->{canvas3D}; undef $self->{_lecursor}; } From db549e86095eace3df2befe2ccca2248a58426b0 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 4 May 2018 18:32:20 +0200 Subject: [PATCH 0307/1150] First experiments with ObjectsTreeList --- lib/Slic3r/GUI/Plater.pm | 4 +- xs/src/slic3r/GUI/GUI.cpp | 136 ++++++++- xs/src/slic3r/GUI/wxExtensions.cpp | 443 +++++++++++++++++++++++++++++ xs/src/slic3r/GUI/wxExtensions.hpp | 411 ++++++++++++++++++++++++++ 4 files changed, 992 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 603d97a2ff..83a14f21a6 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -72,7 +72,7 @@ sub new { }); # Initialize preview notebook - $self->{preview_notebook} = Wx::Notebook->new($self, -1, wxDefaultPosition, [335,335], wxNB_BOTTOM); + $self->{preview_notebook} = Wx::Notebook->new($self, -1, wxDefaultPosition, [-1,335], wxNB_BOTTOM); # Initialize handlers for canvases my $on_select_object = sub { @@ -485,6 +485,7 @@ sub new { $buttons_sizer->Add($self->{btn_export_gcode}, 0, wxALIGN_RIGHT, 0); my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); + $right_sizer->SetMinSize([-1, 600]); $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; $right_sizer->Add($frequently_changed_parameters_sizer, 0, wxEXPAND | wxTOP, 0) if defined $frequently_changed_parameters_sizer; $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5); @@ -522,6 +523,7 @@ sub new { } $self->update_ui_from_settings(); + $self->Layout; return $self; } diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 2542c04c6e..0be77b6bac 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -812,6 +812,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl // Experiments with new UI wxCollapsiblePane *collpane = new wxCollapsiblePane(parent, wxID_ANY, "Print settings:"); collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, collpane](wxCommandEvent e){ + wxWindowUpdateLocker noUpdates_cp(collpane); wxWindowUpdateLocker noUpdates(parent); parent->Layout(); collpane->Refresh(); @@ -942,9 +943,142 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl }; m_optgroup->append_line(line); + auto common_sizer = new wxBoxSizer(wxVERTICAL); + common_sizer->Add(m_optgroup->sizer); + +// auto listctrl = new wxDataViewListCtrl(win, wxID_ANY, wxDefaultPosition, wxSize(-1, 100)); +// listctrl->AppendToggleColumn("Toggle"); +// listctrl->AppendTextColumn("Text"); +// wxVector data; +// data.push_back(wxVariant(true)); +// data.push_back(wxVariant("row 1")); +// listctrl->AppendItem(data); +// data.clear(); +// data.push_back(wxVariant(false)); +// data.push_back(wxVariant("row 3")); +// listctrl->AppendItem(data); +// data.clear(); +// data.push_back(wxVariant(false)); +// data.push_back(wxVariant("row 2")); +// listctrl->AppendItem(data); +// common_sizer->Add(listctrl, 0, wxEXPAND | wxALL, 1); + + // ********************************************************************************************** + auto objects_ctrl = new wxDataViewCtrl(win, wxID_ANY, wxDefaultPosition, wxDefaultSize); + wxSizer *objects_sz = new wxBoxSizer(wxVERTICAL); + objects_ctrl->SetMinSize(wxSize(-1, 200)); + objects_sz->Add(objects_ctrl, 1, wxGROW | wxALL, 5); + + auto objects_model = new MyObjectTreeModel; + objects_ctrl->AssociateModel(objects_model); +#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE + objects_ctrl->EnableDragSource(wxDF_UNICODETEXT); + objects_ctrl->EnableDropTarget(wxDF_UNICODETEXT); +#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE + + // column 0 of the view control: + + wxDataViewTextRenderer *tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); + wxDataViewColumn *column00 = new wxDataViewColumn("Name", tr, 0, 150, wxALIGN_LEFT, + wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); + objects_ctrl->AppendColumn(column00); + + // column 1 of the view control: + + tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); + wxDataViewColumn *column01 = new wxDataViewColumn("Copy", tr, 1, 95, wxALIGN_CENTER_HORIZONTAL, + wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); + objects_ctrl->AppendColumn(column01); + + // column 2 of the view control: + + tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); + wxDataViewColumn *column02 = new wxDataViewColumn("Scale", tr, 2, 95, wxALIGN_CENTER_HORIZONTAL, + wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); + objects_ctrl->AppendColumn(column02); + + common_sizer->Add(objects_sz, 0, wxEXPAND | wxALL, 1); + + // ********************************************************************************************** +/* auto view_ctrl = new wxDataViewCtrl(win, wxID_ANY, wxDefaultPosition, wxDefaultSize); + wxSizer *PanelSz = new wxBoxSizer(wxVERTICAL); + view_ctrl->SetMinSize(wxSize(-1, 200)); + PanelSz->Add(view_ctrl, 1, wxGROW | wxALL, 5); + PanelSz->Add( new wxStaticText(win, wxID_ANY, "Most of the cells above are editable!"), 0, wxGROW | wxALL, 5); + + auto m_music_model = new MyMusicTreeModel; + view_ctrl->AssociateModel(m_music_model); + +#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE + view_ctrl->EnableDragSource(wxDF_UNICODETEXT); + view_ctrl->EnableDropTarget(wxDF_UNICODETEXT); +#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE + + // column 0 of the view control: + + tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); + wxDataViewColumn *column0 = + new wxDataViewColumn("title", tr, 0, 150, wxALIGN_LEFT, + wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); + view_ctrl->AppendColumn(column0); +#if 0 + // Call this and sorting is enabled + // immediately upon start up. + column0->SetAsSortKey(); +#endif + + // column 1 of the view control: + + tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_EDITABLE); + wxDataViewColumn *column1 = + new wxDataViewColumn("artist", tr, 1, 150, wxALIGN_LEFT, + wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE | + wxDATAVIEW_COL_RESIZABLE); + column1->SetMinWidth(100); // this column can't be resized to be smaller + view_ctrl->AppendColumn(column1); + + // column 2 of the view control: + + wxDataViewSpinRenderer *sr = + new wxDataViewSpinRenderer(0, 2010, wxDATAVIEW_CELL_EDITABLE, + wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); + wxDataViewColumn *column2 = + new wxDataViewColumn("year", sr, 2, 60, wxALIGN_LEFT, + wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE); + view_ctrl->AppendColumn(column2); + + // column 3 of the view control: + + wxArrayString choices; + choices.Add("good"); + choices.Add("bad"); + choices.Add("lousy"); + wxDataViewChoiceRenderer *c = + new wxDataViewChoiceRenderer(choices, wxDATAVIEW_CELL_EDITABLE, + wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); + wxDataViewColumn *column3 = + new wxDataViewColumn("rating", c, 3, 100, wxALIGN_LEFT, + wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE); + view_ctrl->AppendColumn(column3); + + // column 4 of the view control: + + view_ctrl->AppendProgressColumn("popularity", 4, wxDATAVIEW_CELL_INERT, 80); + + // column 5 of the view control: + + MyCustomRenderer *cr = new MyCustomRenderer(wxDATAVIEW_CELL_ACTIVATABLE); + wxDataViewColumn *column5 = + new wxDataViewColumn("custom", cr, 5, -1, wxALIGN_LEFT, + wxDATAVIEW_COL_RESIZABLE); + view_ctrl->AppendColumn(column5); + + // ********************************************************************************************** + common_sizer->Add(PanelSz, 0, wxEXPAND | wxALL, 1); +*/ wxSizer *paneSz = new wxBoxSizer(wxVERTICAL); - paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | wxBOTTOM, 2); + paneSz->Add(common_sizer/*m_optgroup->sizer*/, 1, wxGROW | wxEXPAND | wxBOTTOM, 2); win->SetSizer(paneSz); paneSz->SetSizeHints(win); } diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 8bc282474e..9d691b1aa4 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -165,3 +165,446 @@ void wxDataViewTreeCtrlComboPopup::OnDataViewTreeCtrlSelection(wxCommandEvent& e auto selected = GetItemText(GetSelection()); cmb->SetText(selected); } + +// ***************************************************************************** +// ---------------------------------------------------------------------------- +// MyObjectTreeModel +// ---------------------------------------------------------------------------- + +MyObjectTreeModel::MyObjectTreeModel() +{ + auto root1 = new MyObjectTreeModelNode("Object1"); + m_objects.emplace(root1); + + auto root2 = new MyObjectTreeModelNode("Object2"); + m_objects.emplace(root2); + root2->Append(new MyObjectTreeModelNode(root2, "SubObject1")); + root2->Append(new MyObjectTreeModelNode(root2, "SubObject2")); + root2->Append(new MyObjectTreeModelNode(root2, "SubObject3")); + + auto root3 = new MyObjectTreeModelNode("Object3"); + m_objects.emplace(root3); + auto root4 = new MyObjectTreeModelNode("Object4"); + m_objects.emplace(root4); + root4->Append(new MyObjectTreeModelNode(root2, "SubObject1")); + root4->Append(new MyObjectTreeModelNode(root2, "SubObject2")); + root4->Append(new MyObjectTreeModelNode(root2, "SubObject3")); +} + +wxString MyObjectTreeModel::GetName(const wxDataViewItem &item) const +{ + MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); + if (!node) // happens if item.IsOk()==false + return wxEmptyString; + + return node->m_name; +} + +wxString MyObjectTreeModel::GetCopyCnt(const wxDataViewItem &item) const +{ + MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); + if (!node) // happens if item.IsOk()==false + return wxEmptyString; + + return node->m_copy; +} + +wxString MyObjectTreeModel::GetScale(const wxDataViewItem &item) const +{ + MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); + if (!node) // happens if item.IsOk()==false + return wxEmptyString; + + return node->m_scale; +} + +// void MyObjectTreeModel::Delete(const wxDataViewItem &item) +// { +// +// } + +void MyObjectTreeModel::GetValue(wxVariant &variant, const wxDataViewItem &item, unsigned int col) const +{ + wxASSERT(item.IsOk()); + + MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); + switch (col) + { + case 0: + variant = node->m_name; + break; + case 1: + variant = node->m_copy; + break; + case 2: + variant = node->m_scale; + break; + default: + ;// wxLogError("MyMusicTreeModel::GetValue: wrong column %d", col); + } +} + +bool MyObjectTreeModel::SetValue(const wxVariant &variant, const wxDataViewItem &item, unsigned int col) +{ + wxASSERT(item.IsOk()); + + MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); + switch (col) + { + case 0: + node->m_name = variant.GetString(); + return true; + case 1: + node->m_copy = variant.GetString(); + return true; + case 2: + node->m_scale = variant.GetString(); + return true; + + default:; + // wxLogError("MyObjectTreeModel::SetValue: wrong column"); + } + return false; +} + +// bool MyObjectTreeModel::IsEnabled(const wxDataViewItem &item, unsigned int col) const +// { +// +// } + +wxDataViewItem MyObjectTreeModel::GetParent(const wxDataViewItem &item) const +{ + // the invisible root node has no parent + if (!item.IsOk()) + return wxDataViewItem(0); + + MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); + + // objects nodes also has no parent + if (m_objects.find(node) != m_objects.end()) + return wxDataViewItem(0); + + return wxDataViewItem((void*)node->GetParent()); +} + +bool MyObjectTreeModel::IsContainer(const wxDataViewItem &item) const +{ + // the invisble root node can have children + if (!item.IsOk()) + return true; + + MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); + return node->IsContainer(); +} + +unsigned int MyObjectTreeModel::GetChildren(const wxDataViewItem &parent, wxDataViewItemArray &array) const +{ + MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)parent.GetID(); + if (!node) + { + for (auto object: m_objects) + array.Add(wxDataViewItem((void*)object)); + return m_objects.size(); + } + + if (node->GetChildCount() == 0) + { + return 0; + } + + unsigned int count = node->GetChildren().GetCount(); + for (unsigned int pos = 0; pos < count; pos++) + { + MyObjectTreeModelNode *child = node->GetChildren().Item(pos); + array.Add(wxDataViewItem((void*)child)); + } + + return count; +} + +// ***************************************************************************** +// ---------------------------------------------------------------------------- +// MyMusicTreeModel +// ---------------------------------------------------------------------------- + +MyMusicTreeModel::MyMusicTreeModel() +{ + m_root = new MyMusicTreeModelNode(NULL, "");// , "My Music"); + + // setup pop music + m_pop = new MyMusicTreeModelNode(m_root, "Pop music"); + m_pop->Append( + new MyMusicTreeModelNode(m_pop, "You are not alone", "Michael Jackson", 1995)); + m_pop->Append( + new MyMusicTreeModelNode(m_pop, "Take a bow", "Madonna", 1994)); + m_root->Append(m_pop); + + // setup classical music + m_classical = new MyMusicTreeModelNode(m_root, "Classical music"); + m_ninth = new MyMusicTreeModelNode(m_classical, "Ninth symphony", + "Ludwig van Beethoven", 1824); + m_classical->Append(m_ninth); + m_classical->Append(new MyMusicTreeModelNode(m_classical, "German Requiem", + "Johannes Brahms", 1868)); + m_root->Append(m_classical); + + m_classicalMusicIsKnownToControl = false; +} + +wxString MyMusicTreeModel::GetTitle(const wxDataViewItem &item) const +{ + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + if (!node) // happens if item.IsOk()==false + return wxEmptyString; + + return node->m_title; +} + +wxString MyMusicTreeModel::GetArtist(const wxDataViewItem &item) const +{ + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + if (!node) // happens if item.IsOk()==false + return wxEmptyString; + + return node->m_artist; +} + +int MyMusicTreeModel::GetYear(const wxDataViewItem &item) const +{ + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + if (!node) // happens if item.IsOk()==false + return 2000; + + return node->m_year; +} + +void MyMusicTreeModel::AddToClassical(const wxString &title, const wxString &artist, + unsigned int year) +{ + if (!m_classical) + { + wxASSERT(m_root); + + // it was removed: restore it + m_classical = new MyMusicTreeModelNode(m_root, "Classical music"); + m_root->Append(m_classical); + + // notify control + wxDataViewItem child((void*)m_classical); + wxDataViewItem parent((void*)m_root); + ItemAdded(parent, child); + } + + // add to the classical music node a new node: + MyMusicTreeModelNode *child_node = + new MyMusicTreeModelNode(m_classical, title, artist, year); + m_classical->Append(child_node); + + // FIXME: what's m_classicalMusicIsKnownToControl for? + if (m_classicalMusicIsKnownToControl) + { + // notify control + wxDataViewItem child((void*)child_node); + wxDataViewItem parent((void*)m_classical); + ItemAdded(parent, child); + } +} + +void MyMusicTreeModel::Delete(const wxDataViewItem &item) +{ + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + if (!node) // happens if item.IsOk()==false + return; + + wxDataViewItem parent(node->GetParent()); + if (!parent.IsOk()) + { + wxASSERT(node == m_root); + + // don't make the control completely empty: + //wxLogError("Cannot remove the root item!"); + return; + } + + // is the node one of those we keep stored in special pointers? + if (node == m_pop) + m_pop = NULL; + else if (node == m_classical) + m_classical = NULL; + else if (node == m_ninth) + m_ninth = NULL; + + // first remove the node from the parent's array of children; + // NOTE: MyMusicTreeModelNodePtrArray is only an array of _pointers_ + // thus removing the node from it doesn't result in freeing it + node->GetParent()->GetChildren().Remove(node); + + // free the node + delete node; + + // notify control + ItemDeleted(parent, item); +} + +int MyMusicTreeModel::Compare(const wxDataViewItem &item1, const wxDataViewItem &item2, + unsigned int column, bool ascending) const +{ + wxASSERT(item1.IsOk() && item2.IsOk()); + // should never happen + + if (IsContainer(item1) && IsContainer(item2)) + { + wxVariant value1, value2; + GetValue(value1, item1, 0); + GetValue(value2, item2, 0); + + wxString str1 = value1.GetString(); + wxString str2 = value2.GetString(); + int res = str1.Cmp(str2); + if (res) return res; + + // items must be different + wxUIntPtr litem1 = (wxUIntPtr)item1.GetID(); + wxUIntPtr litem2 = (wxUIntPtr)item2.GetID(); + + return litem1 - litem2; + } + + return wxDataViewModel::Compare(item1, item2, column, ascending); +} + +void MyMusicTreeModel::GetValue(wxVariant &variant, + const wxDataViewItem &item, unsigned int col) const +{ + wxASSERT(item.IsOk()); + + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + switch (col) + { + case 0: + variant = node->m_title; + break; + case 1: + variant = node->m_artist; + break; + case 2: + variant = (long)node->m_year; + break; + case 3: + variant = node->m_quality; + break; + case 4: + variant = 80L; // all music is very 80% popular + break; + case 5: + if (GetYear(item) < 1900) + variant = "old"; + else + variant = "new"; + break; + + default: + ;// wxLogError("MyMusicTreeModel::GetValue: wrong column %d", col); + } +} + +bool MyMusicTreeModel::SetValue(const wxVariant &variant, + const wxDataViewItem &item, unsigned int col) +{ + wxASSERT(item.IsOk()); + + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + switch (col) + { + case 0: + node->m_title = variant.GetString(); + return true; + case 1: + node->m_artist = variant.GetString(); + return true; + case 2: + node->m_year = variant.GetLong(); + return true; + case 3: + node->m_quality = variant.GetString(); + return true; + + default:; +// wxLogError("MyMusicTreeModel::SetValue: wrong column"); + } + return false; +} + +bool MyMusicTreeModel::IsEnabled(const wxDataViewItem &item, + unsigned int col) const +{ + wxASSERT(item.IsOk()); + + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + + // disable Beethoven's ratings, his pieces can only be good + return !(col == 3 && node->m_artist.EndsWith("Beethoven")); +} + +wxDataViewItem MyMusicTreeModel::GetParent(const wxDataViewItem &item) const +{ + // the invisible root node has no parent + if (!item.IsOk()) + return wxDataViewItem(0); + + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + + // "MyMusic" also has no parent + if (node == m_root) + return wxDataViewItem(0); + + return wxDataViewItem((void*)node->GetParent()); +} + +bool MyMusicTreeModel::IsContainer(const wxDataViewItem &item) const +{ + // the invisble root node can have children + // (in our model always "MyMusic") + if (!item.IsOk()) + return true; + + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)item.GetID(); + return node->IsContainer(); +} + +unsigned int MyMusicTreeModel::GetChildren(const wxDataViewItem &parent, + wxDataViewItemArray &array) const +{ + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*)parent.GetID(); + if (!node) + { + array.Add(wxDataViewItem((void*)m_root)); + return 1; + } + + if (node == m_classical) + { + MyMusicTreeModel *model = (MyMusicTreeModel*)(const MyMusicTreeModel*) this; + model->m_classicalMusicIsKnownToControl = true; + } + + if (node->GetChildCount() == 0) + { + return 0; + } + + unsigned int count = node->GetChildren().GetCount(); + for (unsigned int pos = 0; pos < count; pos++) + { + MyMusicTreeModelNode *child = node->GetChildren().Item(pos); + array.Add(wxDataViewItem((void*)child)); + } + + return count; +} + + +// ***************************************************************************** + + + diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index ed8bb9276a..0ed27ab74f 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup { @@ -50,4 +53,412 @@ public: void SetItemsCnt(int cnt) { m_cnt_open_items = cnt; } }; +// ***************************************************************************** +// ---------------------------------------------------------------------------- +// MyObjectTreeModelNode: a node inside MyObjectTreeModel +// ---------------------------------------------------------------------------- + +class MyObjectTreeModelNode; +WX_DEFINE_ARRAY_PTR(MyObjectTreeModelNode*, MyObjectTreeModelNodePtrArray); + +class MyObjectTreeModelNode +{ + MyObjectTreeModelNode* m_parent; + MyObjectTreeModelNodePtrArray m_children; +public: + MyObjectTreeModelNode( const wxString &name) { + m_parent = NULL; + m_name = name; + m_copy = "1"; + m_scale = "100%"; + } + + MyObjectTreeModelNode( MyObjectTreeModelNode* parent, + const wxString& sub_obj) { + m_parent = parent; + m_name = sub_obj; + m_copy = wxEmptyString; + m_scale = wxEmptyString; + } + + ~MyObjectTreeModelNode() + { + // free all our children nodes + size_t count = m_children.GetCount(); + for (size_t i = 0; i < count; i++) + { + MyObjectTreeModelNode *child = m_children[i]; + delete child; + } + } + + wxString m_name; + wxString m_copy; + wxString m_scale; + bool m_container = false; + + bool IsContainer() const + { + return m_container; + } + + MyObjectTreeModelNode* GetParent() + { + return m_parent; + } + MyObjectTreeModelNodePtrArray& GetChildren() + { + return m_children; + } + MyObjectTreeModelNode* GetNthChild(unsigned int n) + { + return m_children.Item(n); + } + void Insert(MyObjectTreeModelNode* child, unsigned int n) + { + m_children.Insert(child, n); + } + void Append(MyObjectTreeModelNode* child) + { + if (!m_container) + m_container = true; + m_children.Add(child); + } + unsigned int GetChildCount() const + { + return m_children.GetCount(); + } +}; + +// ---------------------------------------------------------------------------- +// MyObjectTreeModel +// ---------------------------------------------------------------------------- + +class MyObjectTreeModel :public wxDataViewModel +{ + std::set m_objects; +public: + MyObjectTreeModel(); + ~MyObjectTreeModel() + { + for (auto object : m_objects) + delete object; + } + + // helper method for wxLog + + wxString GetName(const wxDataViewItem &item) const; + wxString GetCopyCnt(const wxDataViewItem &item) const; + wxString GetScale(const wxDataViewItem &item) const; + + // helper methods to change the model + +// void AddToClassical(const wxString &title, const wxString &artist, +// unsigned int year); +// void Delete(const wxDataViewItem &item); + + virtual unsigned int GetColumnCount() const override { return 3;} + virtual wxString GetColumnType(unsigned int col) const override{ return wxT("string"); } + + virtual void GetValue(wxVariant &variant, + const wxDataViewItem &item, unsigned int col) const override; + virtual bool SetValue(const wxVariant &variant, + const wxDataViewItem &item, unsigned int col) override; + +// virtual bool IsEnabled(const wxDataViewItem &item, +// unsigned int col) const override; + + virtual wxDataViewItem GetParent(const wxDataViewItem &item) const override; + virtual bool IsContainer(const wxDataViewItem &item) const override; + virtual unsigned int GetChildren(const wxDataViewItem &parent, + wxDataViewItemArray &array) const override; +}; + + + + +// ***************************************************************************** +// ---------------------------------------------------------------------------- +// MyMusicTreeModelNode: a node inside MyMusicTreeModel +// ---------------------------------------------------------------------------- + +class MyMusicTreeModelNode; +WX_DEFINE_ARRAY_PTR(MyMusicTreeModelNode*, MyMusicTreeModelNodePtrArray); + +class MyMusicTreeModelNode +{ +public: + MyMusicTreeModelNode(MyMusicTreeModelNode* parent, + const wxString &title, const wxString &artist, + unsigned int year) + { + m_parent = parent; + + m_title = title; + m_artist = artist; + m_year = year; + m_quality = "good"; + + m_container = false; + } + + MyMusicTreeModelNode(MyMusicTreeModelNode* parent, + const wxString &branch) + { + m_parent = parent; + + m_title = branch; + m_year = -1; + + m_container = true; + } + + ~MyMusicTreeModelNode() + { + // free all our children nodes + size_t count = m_children.GetCount(); + for (size_t i = 0; i < count; i++) + { + MyMusicTreeModelNode *child = m_children[i]; + delete child; + } + } + + bool IsContainer() const + { + return m_container; + } + + MyMusicTreeModelNode* GetParent() + { + return m_parent; + } + MyMusicTreeModelNodePtrArray& GetChildren() + { + return m_children; + } + MyMusicTreeModelNode* GetNthChild(unsigned int n) + { + return m_children.Item(n); + } + void Insert(MyMusicTreeModelNode* child, unsigned int n) + { + m_children.Insert(child, n); + } + void Append(MyMusicTreeModelNode* child) + { + m_children.Add(child); + } + unsigned int GetChildCount() const + { + return m_children.GetCount(); + } + +public: // public to avoid getters/setters + wxString m_title; + wxString m_artist; + int m_year; + wxString m_quality; + + // TODO/FIXME: + // the GTK version of wxDVC (in particular wxDataViewCtrlInternal::ItemAdded) + // needs to know in advance if a node is or _will be_ a container. + // Thus implementing: + // bool IsContainer() const + // { return m_children.GetCount()>0; } + // doesn't work with wxGTK when MyMusicTreeModel::AddToClassical is called + // AND the classical node was removed (a new node temporary without children + // would be added to the control) + bool m_container; + +private: + MyMusicTreeModelNode *m_parent; + MyMusicTreeModelNodePtrArray m_children; +}; + + +// ---------------------------------------------------------------------------- +// MyMusicTreeModel +// ---------------------------------------------------------------------------- + +/* +Implement this data model +Title Artist Year Judgement +-------------------------------------------------------------------------- +1: My Music: +2: Pop music +3: You are not alone Michael Jackson 1995 good +4: Take a bow Madonna 1994 good +5: Classical music +6: Ninth Symphony Ludwig v. Beethoven 1824 good +7: German Requiem Johannes Brahms 1868 good +*/ + +class MyMusicTreeModel : public wxDataViewModel +{ +public: + MyMusicTreeModel(); + ~MyMusicTreeModel() + { + if (m_root) + delete m_root; + + } + + // helper method for wxLog + + wxString GetTitle(const wxDataViewItem &item) const; + wxString GetArtist(const wxDataViewItem &item) const; + int GetYear(const wxDataViewItem &item) const; + + // helper methods to change the model + + void AddToClassical(const wxString &title, const wxString &artist, + unsigned int year); + void Delete(const wxDataViewItem &item); + + wxDataViewItem GetNinthItem() const + { + return wxDataViewItem(m_ninth); + } + + // override sorting to always sort branches ascendingly + + int Compare(const wxDataViewItem &item1, const wxDataViewItem &item2, + unsigned int column, bool ascending) const override/*wxOVERRIDE*/; + + // implementation of base class virtuals to define model + + virtual unsigned int GetColumnCount() const override/*wxOVERRIDE*/ + { + return 6; + } + + virtual wxString GetColumnType(unsigned int col) const override/*wxOVERRIDE*/ + { + if (col == 2) + return wxT("long"); + + return wxT("string"); + } + + virtual void GetValue(wxVariant &variant, + const wxDataViewItem &item, unsigned int col) const override/*wxOVERRIDE*/; + virtual bool SetValue(const wxVariant &variant, + const wxDataViewItem &item, unsigned int col) override/*wxOVERRIDE*/; + + virtual bool IsEnabled(const wxDataViewItem &item, + unsigned int col) const override/*wxOVERRIDE*/; + + virtual wxDataViewItem GetParent(const wxDataViewItem &item) const override/*wxOVERRIDE*/; + virtual bool IsContainer(const wxDataViewItem &item) const override/*wxOVERRIDE*/; + virtual unsigned int GetChildren(const wxDataViewItem &parent, + wxDataViewItemArray &array) const override/*wxOVERRIDE*/; + +private: + MyMusicTreeModelNode* m_root; + + // pointers to some "special" nodes of the tree: + MyMusicTreeModelNode* m_pop; + MyMusicTreeModelNode* m_classical; + MyMusicTreeModelNode* m_ninth; + + // ?? + bool m_classicalMusicIsKnownToControl; +}; + +// ---------------------------------------------------------------------------- +// MyCustomRenderer +// ---------------------------------------------------------------------------- + +class MyCustomRenderer : public wxDataViewCustomRenderer +{ +public: + // This renderer can be either activatable or editable, for demonstration + // purposes. In real programs, you should select whether the user should be + // able to activate or edit the cell and it doesn't make sense to switch + // between the two -- but this is just an example, so it doesn't stop us. + explicit MyCustomRenderer(wxDataViewCellMode mode) + : wxDataViewCustomRenderer("string", mode, wxALIGN_CENTER) + { } + + virtual bool Render(wxRect rect, wxDC *dc, int state) override/*wxOVERRIDE*/ + { + dc->SetBrush(*wxLIGHT_GREY_BRUSH); + dc->SetPen(*wxTRANSPARENT_PEN); + + rect.Deflate(2); + dc->DrawRoundedRectangle(rect, 5); + + RenderText(m_value, + 0, // no offset + wxRect(dc->GetTextExtent(m_value)).CentreIn(rect), + dc, + state); + return true; + } + + virtual bool ActivateCell(const wxRect& WXUNUSED(cell), + wxDataViewModel *WXUNUSED(model), + const wxDataViewItem &WXUNUSED(item), + unsigned int WXUNUSED(col), + const wxMouseEvent *mouseEvent) override/*wxOVERRIDE*/ + { + wxString position; + if (mouseEvent) + position = wxString::Format("via mouse at %d, %d", mouseEvent->m_x, mouseEvent->m_y); + else + position = "from keyboard"; +// wxLogMessage("MyCustomRenderer ActivateCell() %s", position); + return false; + } + + virtual wxSize GetSize() const override/*wxOVERRIDE*/ + { + return wxSize(60, 20); + } + + virtual bool SetValue(const wxVariant &value) override/*wxOVERRIDE*/ + { + m_value = value.GetString(); + return true; + } + + virtual bool GetValue(wxVariant &WXUNUSED(value)) const override/*wxOVERRIDE*/{ return true; } + + virtual bool HasEditorCtrl() const override/*wxOVERRIDE*/{ return true; } + + virtual wxWindow* + CreateEditorCtrl(wxWindow* parent, + wxRect labelRect, + const wxVariant& value) override/*wxOVERRIDE*/ + { + wxTextCtrl* text = new wxTextCtrl(parent, wxID_ANY, value, + labelRect.GetPosition(), + labelRect.GetSize(), + wxTE_PROCESS_ENTER); + text->SetInsertionPointEnd(); + + return text; + } + + virtual bool + GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value) override/*wxOVERRIDE*/ + { + wxTextCtrl* text = wxDynamicCast(ctrl, wxTextCtrl); + if (!text) + return false; + + value = text->GetValue(); + + return true; + } + +private: + wxString m_value; +}; +// ***************************************************************************** + + + #endif // slic3r_GUI_wxExtensions_hpp_ From c579ec7f5fe92e8cce773750a73086cbe8ef074a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 7 May 2018 14:23:07 +0200 Subject: [PATCH 0308/1150] Fixed wrong extrusion paths detection with multimaterial objects --- xs/src/libslic3r/GCode.cpp | 21 ++++++++++++------ xs/src/libslic3r/GCode.hpp | 2 ++ xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 24 ++++++--------------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 8ad479532b..dc8e5d6918 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -1287,6 +1287,10 @@ void GCode::process_layer( m_wipe_tower->tool_change(*this, extruder_id, extruder_id == layer_tools.extruders.back()) : this->set_extruder(extruder_id); + // let analyzer tag generator aware of a role type change + if (m_enable_analyzer && layer_tools.has_wipe_tower && m_wipe_tower) + m_last_analyzer_extrusion_role = erWipeTower; + if (extrude_skirt) { auto loops_it = skirt_loops_per_extruder.find(extruder_id); if (loops_it != skirt_loops_per_extruder.end()) { @@ -2170,7 +2174,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, double F = speed * 60; // convert mm/sec to mm/min // extrude arc or line - if (m_enable_extrusion_role_markers || m_enable_analyzer) + if (m_enable_extrusion_role_markers) { if (path.role() != m_last_extrusion_role) { @@ -2181,18 +2185,20 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, sprintf(buf, ";_EXTRUSION_ROLE:%d\n", int(m_last_extrusion_role)); gcode += buf; } - if (m_enable_analyzer) - { - char buf[32]; - sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), int(m_last_extrusion_role)); - gcode += buf; - } } } // adds analyzer tags and updates analyzer's tracking data if (m_enable_analyzer) { + if (path.role() != m_last_analyzer_extrusion_role) + { + m_last_analyzer_extrusion_role = path.role(); + char buf[32]; + sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), int(m_last_analyzer_extrusion_role)); + gcode += buf; + } + if (m_last_mm3_per_mm != path.mm3_per_mm) { m_last_mm3_per_mm = path.mm3_per_mm; @@ -2230,6 +2236,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, if (path.role() == erExternalPerimeter) comment += ";_EXTERNAL_PERIMETER"; } + // F is mm per minute. gcode += m_writer.set_speed(F, "", comment); double path_length = 0.; diff --git a/xs/src/libslic3r/GCode.hpp b/xs/src/libslic3r/GCode.hpp index 968cd14dec..d028e90aac 100644 --- a/xs/src/libslic3r/GCode.hpp +++ b/xs/src/libslic3r/GCode.hpp @@ -121,6 +121,7 @@ public: m_enable_cooling_markers(false), m_enable_extrusion_role_markers(false), m_enable_analyzer(false), + m_last_analyzer_extrusion_role(erNone), m_layer_count(0), m_layer_index(-1), m_layer(nullptr), @@ -253,6 +254,7 @@ protected: // Extended markers will be added during G-code generation. // The G-code Analyzer will remove these comments from the final G-code. bool m_enable_analyzer; + ExtrusionRole m_last_analyzer_extrusion_role; // How many times will change_layer() be called? // change_layer() will update the progress bar. unsigned int m_layer_count; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index ad7d91c50d..b414186bed 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -126,6 +126,11 @@ public: m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(rot.x, rot.y), width, m_current_tool)); } + // adds tag for analyzer + char buf[64]; + sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); + m_gcode += buf; + m_gcode += "G1"; if (rot.x != rotated_current_pos.x) { m_gcode += set_format_X(rot.x); // Transform current position back to wipe tower coordinates (was updated by set_format_X) @@ -488,11 +493,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( .travel(cleaning_box.ld, 7200) .set_extruder_trimpot(750); // Increase the extruder driver current to allow fast ramming. - // adds tag for analyzer - char buf[32]; - sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); - writer.append(buf); - for (size_t idx_tool = 0; idx_tool < tools.size(); ++ idx_tool) { unsigned int tool = tools[idx_tool]; m_left_to_right = true; @@ -585,12 +585,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo xy initial_position = cleaning_box.ld + WipeTower::xy(0.f,m_depth_traversed); writer.set_initial_position(initial_position); - - // adds tag for analyzer - char buf[32]; - sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); - writer.append(buf); - // Increase the extruder driver current to allow fast ramming. writer.set_extruder_trimpot(750); @@ -658,12 +652,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(bool sideOnly, flo xy initial_position = wipeTower_box.lu - xy(m_perimeter_width * 6.f, 0); writer.set_initial_position(initial_position); - // adds tag for analyzer - char buf[32]; - sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); - writer.append(buf) - .extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), // Prime the extruder left of the wipe tower. - 1.5f * m_extrusion_flow * (wipeTower_box.lu.y - wipeTower_box.ld.y), 2400); + writer.extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), // Prime the extruder left of the wipe tower. + 1.5f * m_extrusion_flow * (wipeTower_box.lu.y - wipeTower_box.ld.y), 2400); // The tool is supposed to be active and primed at the time when the wipe tower brim is extruded. // Extrude 4 rounds of a brim around the future wipe tower. From 8eb9ddc2eb6c3f98cf28125ddbee4d233fa58616 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 7 May 2018 16:13:58 +0200 Subject: [PATCH 0309/1150] Max count of auto assigned extruders when splitting object set as dependent of current printer --- lib/Slic3r/GUI/Plater.pm | 4 ++-- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 3 ++- xs/src/libslic3r/Model.cpp | 16 ++++++++-------- xs/src/libslic3r/Model.hpp | 10 +++++----- xs/xsp/Model.xsp | 4 ++-- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a3ad064cd0..0a5d02b944 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -700,7 +700,7 @@ sub load_files { . "Instead of considering them as multiple objects, should I consider\n" . "this file as a single object having multiple parts?\n"), L('Multi-part object detected'), wxICON_WARNING | wxYES | wxNO); - $model->convert_multipart_object if $dialog->ShowModal() == wxID_YES; + $model->convert_multipart_object if $dialog->ShowModal(scalar(@$nozzle_dmrs)) == wxID_YES; } if ($one_by_one) { @@ -717,7 +717,7 @@ sub load_files { . "Instead of considering them as multiple objects, should I consider\n" . "these files to represent a single object having multiple parts?\n"), L('Multi-part object detected'), wxICON_WARNING | wxYES | wxNO); - $new_model->convert_multipart_object if $dialog->ShowModal() == wxID_YES; + $new_model->convert_multipart_object if $dialog->ShowModal(scalar(@$nozzle_dmrs)) == wxID_YES; push @obj_idx, $self->load_model_objects(@{$new_model->objects}); } diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 28e3bf92b5..a632edeeae 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -475,7 +475,8 @@ sub on_btn_split { my $itemData = $self->get_selection; if ($itemData && $itemData->{type} eq 'volume') { my $volume = $self->{model_object}->volumes->[$itemData->{volume_id}]; - $self->{parts_changed} = 1 if $volume->split > 1; + my $nozzle_dmrs = $self->GetParent->GetParent->GetParent->{config}->get('nozzle_diameter'); + $self->{parts_changed} = 1 if $volume->split(scalar(@$nozzle_dmrs)) > 1; } $self->_parts_changed; diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index a43bf02213..7559411448 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -404,7 +404,7 @@ bool Model::looks_like_multipart_object() const return false; } -void Model::convert_multipart_object() +void Model::convert_multipart_object(unsigned int max_extruders) { if (this->objects.empty()) return; @@ -421,7 +421,7 @@ void Model::convert_multipart_object() if (new_v != nullptr) { new_v->name = o->name; - new_v->config.set_deserialize("extruder", get_auto_extruder_id_as_string()); + new_v->config.set_deserialize("extruder", get_auto_extruder_id_as_string(max_extruders)); } } @@ -481,20 +481,20 @@ bool Model::fits_print_volume(const FullPrintConfig &config) const return print_volume.contains(transformed_bounding_box()); } -unsigned int Model::get_auto_extruder_id() +unsigned int Model::get_auto_extruder_id(unsigned int max_extruders) { unsigned int id = s_auto_extruder_id; - if (++s_auto_extruder_id > 4) + if (++s_auto_extruder_id > max_extruders) reset_auto_extruder_id(); return id; } -std::string Model::get_auto_extruder_id_as_string() +std::string Model::get_auto_extruder_id_as_string(unsigned int max_extruders) { char str_extruder[64]; - sprintf(str_extruder, "%ud", get_auto_extruder_id()); + sprintf(str_extruder, "%ud", get_auto_extruder_id(max_extruders)); return str_extruder; } @@ -996,7 +996,7 @@ ModelMaterial* ModelVolume::assign_unique_material() // Split this volume, append the result to the object owning this volume. // Return the number of volumes created from this one. // This is useful to assign different materials to different volumes of an object. -size_t ModelVolume::split() +size_t ModelVolume::split(unsigned int max_extruders) { TriangleMeshPtrs meshptrs = this->mesh.split(); if (meshptrs.size() <= 1) { @@ -1019,7 +1019,7 @@ size_t ModelVolume::split() char str_idx[64]; sprintf(str_idx, "_%d", idx + 1); this->object->volumes[ivolume]->name = name + str_idx; - this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string()); + this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string(max_extruders)); delete mesh; ++ idx; } diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index 0c0ffe7769..4835028b98 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -173,8 +173,8 @@ public: // Split this volume, append the result to the object owning this volume. // Return the number of volumes created from this one. // This is useful to assign different materials to different volumes of an object. - size_t split(); - + size_t split(unsigned int max_extruders); + ModelMaterial* assign_unique_material(); private: @@ -280,7 +280,7 @@ public: void duplicate_objects_grid(size_t x, size_t y, coordf_t dist); bool looks_like_multipart_object() const; - void convert_multipart_object(); + void convert_multipart_object(unsigned int max_extruders); // Ensures that the min z of the model is not negative void adjust_min_z(); @@ -291,8 +291,8 @@ public: void print_info() const { for (const ModelObject *o : this->objects) o->print_info(); } - static unsigned int get_auto_extruder_id(); - static std::string get_auto_extruder_id_as_string(); + static unsigned int get_auto_extruder_id(unsigned int max_extruders); + static std::string get_auto_extruder_id_as_string(unsigned int max_extruders); static void reset_auto_extruder_id(); }; diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp index 7028395373..5b83183539 100644 --- a/xs/xsp/Model.xsp +++ b/xs/xsp/Model.xsp @@ -95,7 +95,7 @@ void duplicate_objects_grid(unsigned int x, unsigned int y, double dist); bool looks_like_multipart_object() const; - void convert_multipart_object(); + void convert_multipart_object(unsigned int max_extruders); void print_info() const; @@ -346,7 +346,7 @@ ModelMaterial::attributes() void set_modifier(bool modifier) %code%{ THIS->modifier = modifier; %}; - size_t split(); + size_t split(unsigned int max_extruders); ModelMaterial* assign_unique_material(); }; From 86155ae4c00e2146ca19f42e6eca240d3d8b64fa Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 9 May 2018 10:28:26 +0200 Subject: [PATCH 0310/1150] Fixed conflict in previous merge --- xs/src/libslic3r/Model.cpp | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 7559411448..8ce23b1e54 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -451,36 +451,6 @@ void Model::adjust_min_z() } } -bool Model::fits_print_volume(const DynamicPrintConfig* config) const -{ - if (config == nullptr) - return false; - - if (objects.empty()) - return true; - - const ConfigOptionPoints* opt = dynamic_cast(config->option("bed_shape")); - if (opt == nullptr) - return false; - - BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); - BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config->opt_float("max_print_height"))); - // Allow the objects to protrude below the print bed - print_volume.min.z = -1e10; - return print_volume.contains(transformed_bounding_box()); -} - -bool Model::fits_print_volume(const FullPrintConfig &config) const -{ - if (objects.empty()) - return true; - BoundingBox bed_box_2D = get_extents(Polygon::new_scale(config.bed_shape.values)); - BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config.max_print_height)); - // Allow the objects to protrude below the print bed - print_volume.min.z = -1e10; - return print_volume.contains(transformed_bounding_box()); -} - unsigned int Model::get_auto_extruder_id(unsigned int max_extruders) { unsigned int id = s_auto_extruder_id; From 5024fc4be7b03d6b5b065d42666d1b26a6cc3c1a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 9 May 2018 10:47:04 +0200 Subject: [PATCH 0311/1150] OpenGL to c++ 1st installment - WIP --- lib/Slic3r/GUI/3DScene.pm | 179 +++++++++--- lib/Slic3r/GUI/MainFrame.pm | 13 +- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 6 + lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 7 + lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm | 3 + xs/CMakeLists.txt | 10 +- xs/lib/Slic3r/XS.pm | 2 + xs/src/slic3r/GUI/3DScene.cpp | 115 +++++++- xs/src/slic3r/GUI/3DScene.hpp | 43 ++- xs/src/slic3r/GUI/GLCanvas3D.cpp | 117 ++++++++ xs/src/slic3r/GUI/GLCanvas3D.hpp | 77 +++++ xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 263 ++++++++++++++++++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 86 ++++++ xs/xsp/GUI_3DScene.xsp | 150 +++++++++- 14 files changed, 1015 insertions(+), 56 deletions(-) create mode 100644 xs/src/slic3r/GUI/GLCanvas3D.cpp create mode 100644 xs/src/slic3r/GUI/GLCanvas3D.hpp create mode 100644 xs/src/slic3r/GUI/GLCanvas3DManager.cpp create mode 100644 xs/src/slic3r/GUI/GLCanvas3DManager.hpp diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 1b6adf800e..6cb5f398a5 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -16,7 +16,10 @@ use strict; use warnings; use Wx qw(wxTheApp :timer :bitmap :icon :dialog); -use Wx::Event qw(EVT_PAINT EVT_SIZE EVT_ERASE_BACKGROUND EVT_IDLE EVT_MOUSEWHEEL EVT_MOUSE_EVENTS EVT_CHAR EVT_TIMER); +#============================================================================================================================== +use Wx::Event qw(EVT_PAINT EVT_IDLE EVT_MOUSEWHEEL EVT_MOUSE_EVENTS EVT_CHAR EVT_TIMER); +#use Wx::Event qw(EVT_PAINT EVT_SIZE EVT_ERASE_BACKGROUND EVT_IDLE EVT_MOUSEWHEEL EVT_MOUSE_EVENTS EVT_CHAR EVT_TIMER); +#============================================================================================================================== # must load OpenGL *before* Wx::GLCanvas use OpenGL qw(:glconstants :glfunctions :glufunctions :gluconstants); use base qw(Wx::GLCanvas Class::Accessor); @@ -30,7 +33,8 @@ use Slic3r::Geometry qw(PI); # _dirty: boolean flag indicating, that the screen has to be redrawn on EVT_IDLE. # volumes: reference to vector of Slic3r::GUI::3DScene::Volume. # _camera_type: 'perspective' or 'ortho' -__PACKAGE__->mk_accessors( qw(_quat _dirty init +#============================================================================================================================== +__PACKAGE__->mk_accessors( qw(_quat init enable_picking enable_moving use_plain_shader @@ -73,6 +77,50 @@ __PACKAGE__->mk_accessors( qw(_quat _dirty init _mouse_dragging ) ); +#__PACKAGE__->mk_accessors( qw(_quat _dirty init +# enable_picking +# enable_moving +# use_plain_shader +# on_viewport_changed +# on_hover +# on_select +# on_double_click +# on_right_click +# on_move +# on_model_update +# volumes +# _sphi _stheta +# cutting_plane_z +# cut_lines_vertices +# bed_shape +# bed_triangles +# bed_grid_lines +# bed_polygon +# background +# origin +# _mouse_pos +# _hover_volume_idx +# +# _drag_volume_idx +# _drag_start_pos +# _drag_volume_center_offset +# _drag_start_xy +# _dragged +# +# _layer_height_edited +# +# _camera_type +# _camera_target +# _camera_distance +# _zoom +# +# _legend_enabled +# _warning_enabled +# _apply_zoom_to_volumes_filter +# _mouse_dragging +# +# ) ); +#============================================================================================================================== use constant TRACKBALLSIZE => 0.8; use constant TURNTABLE_MODE => 1; @@ -130,13 +178,22 @@ sub new { # we request a depth buffer explicitely because it looks like it's not created by # default on Linux, causing transparency issues my $self = $class->SUPER::new($parent, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, 0, "", $attrib); - if (Wx::wxVERSION >= 3.000003) { - # Wx 3.0.3 contains an ugly hack to support some advanced OpenGL attributes through the attribute list. - # The attribute list is transferred between the wxGLCanvas and wxGLContext constructors using a single static array s_wglContextAttribs. - # Immediatelly force creation of the OpenGL context to consume the static variable s_wglContextAttribs. - $self->GetContext(); - } +#============================================================================================================================== +# if (Wx::wxVERSION >= 3.000003) { +# # Wx 3.0.3 contains an ugly hack to support some advanced OpenGL attributes through the attribute list. +# # The attribute list is transferred between the wxGLCanvas and wxGLContext constructors using a single static array s_wglContextAttribs. +# # Immediatelly force creation of the OpenGL context to consume the static variable s_wglContextAttribs. +# $self->GetContext(); +# } +#============================================================================================================================== +#============================================================================================================================== + Slic3r::GUI::_3DScene::add_canvas($self, $self->GetContext); +# my $context = $self->GetContext; +# $self->SetCurrent($context); +# Slic3r::GUI::_3DScene::add_canvas($self, $context); +#============================================================================================================================== + $self->{can_multisample} = $can_multisample; $self->background(1); $self->_quat((0, 0, 0, 1)); @@ -171,10 +228,16 @@ sub new { my $dc = Wx::PaintDC->new($self); $self->Render($dc); }); - EVT_SIZE($self, sub { $self->_dirty(1) }); +#======================================================================================================================= +# EVT_SIZE($self, sub { $self->_dirty(1) }); +#======================================================================================================================= EVT_IDLE($self, sub { - return unless $self->_dirty; - return if !$self->IsShownOnScreen; +#============================================================================================================================== + return unless Slic3r::GUI::_3DScene::is_dirty($self); + return unless Slic3r::GUI::_3DScene::is_shown_on_screen($self); +# return unless $self->_dirty; +# return if !$self->IsShownOnScreen; +#============================================================================================================================== $self->Resize( $self->GetSizeWH ); $self->Refresh; }); @@ -237,6 +300,9 @@ sub Destroy { my ($self) = @_; $self->{layer_height_edit_timer}->Stop; $self->DestroyGL; +#============================================================================================================================== + Slic3r::GUI::_3DScene::remove_canvas($self); +#============================================================================================================================== return $self->SUPER::Destroy; } @@ -621,7 +687,10 @@ sub mouse_wheel_event { # ) if 0; $self->on_viewport_changed->() if $self->on_viewport_changed; - $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen; +#============================================================================================================================== + $self->Resize($self->GetSizeWH) if Slic3r::GUI::_3DScene::is_shown_on_screen($self); +# $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen; +#============================================================================================================================== $self->Refresh; } @@ -633,7 +702,10 @@ sub reset_objects { $self->volumes->release_geometry; } $self->volumes->erase; - $self->_dirty(1); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_dirty($self, 1); +# $self->_dirty(1); +#============================================================================================================================== } # Setup camera to view all objects. @@ -645,7 +717,10 @@ sub set_viewport_from_scene { $self->_camera_target($scene->_camera_target); $self->_zoom($scene->_zoom); $self->_quat($scene->_quat); - $self->_dirty(1); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_dirty($self, 1); +# $self->_dirty(1); +#============================================================================================================================== } # Set the camera to a default orientation, @@ -777,7 +852,10 @@ sub zoom_to_bounding_box { # center view around bounding box center $self->_camera_target($bb->center); $self->on_viewport_changed->() if $self->on_viewport_changed; - $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen; +#============================================================================================================================== + $self->Resize($self->GetSizeWH) if Slic3r::GUI::_3DScene::is_shown_on_screen($self); +# $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen; +#============================================================================================================================== $self->Refresh; } } @@ -1071,38 +1149,46 @@ sub SetCurrent { sub UseVBOs { my ($self) = @_; - if (! defined ($self->{use_VBOs})) { - my $use_legacy = wxTheApp->{app_config}->get('use_legacy_opengl'); - if ($use_legacy eq '1') { - # Disable OpenGL 2.0 rendering. - $self->{use_VBOs} = 0; - # Don't enable the layer editing tool. - $self->{layer_editing_enabled} = 0; - # 2 means failed - $self->{layer_editing_initialized} = 2; - return 0; - } - # This is a special path for wxWidgets on GTK, where an OpenGL context is initialized - # first when an OpenGL widget is shown for the first time. How ugly. - return 0 if (! $self->init && $^O eq 'linux'); - # Don't use VBOs if anything fails. - $self->{use_VBOs} = 0; - if ($self->GetContext) { - $self->SetCurrent($self->GetContext); - Slic3r::GUI::_3DScene::_glew_init; - my @gl_version = split(/\./, glGetString(GL_VERSION)); - $self->{use_VBOs} = int($gl_version[0]) >= 2; - # print "UseVBOs $self OpenGL major: $gl_version[0], minor: $gl_version[1]. Use VBOs: ", $self->{use_VBOs}, "\n"; - } - } - return $self->{use_VBOs}; +#============================================================================================================================== + return 0 if (! $self->init && $^O eq 'linux'); + return Slic3r::GUI::_3DScene::use_VBOs(); + +# if (! defined ($self->{use_VBOs})) { +# my $use_legacy = wxTheApp->{app_config}->get('use_legacy_opengl'); +# if ($use_legacy eq '1') { +# # Disable OpenGL 2.0 rendering. +# $self->{use_VBOs} = 0; +# # Don't enable the layer editing tool. +# $self->{layer_editing_enabled} = 0; +# # 2 means failed +# $self->{layer_editing_initialized} = 2; +# return 0; +# } +# # This is a special path for wxWidgets on GTK, where an OpenGL context is initialized +# # first when an OpenGL widget is shown for the first time. How ugly. +# return 0 if (! $self->init && $^O eq 'linux'); +# # Don't use VBOs if anything fails. +# $self->{use_VBOs} = 0; +# if ($self->GetContext) { +# $self->SetCurrent($self->GetContext); +# Slic3r::GUI::_3DScene::_glew_init; +# my @gl_version = split(/\./, glGetString(GL_VERSION)); +# $self->{use_VBOs} = int($gl_version[0]) >= 2; +# # print "UseVBOs $self OpenGL major: $gl_version[0], minor: $gl_version[1]. Use VBOs: ", $self->{use_VBOs}, "\n"; +# } +# } +# return $self->{use_VBOs}; +#============================================================================================================================== } sub Resize { my ($self, $x, $y) = @_; return unless $self->GetContext; - $self->_dirty(0); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_dirty($self, 0); +# $self->_dirty(0); +#============================================================================================================================== $self->SetCurrent($self->GetContext); glViewport(0, 0, $x, $y); @@ -1148,13 +1234,17 @@ sub InitGL { return unless $self->GetContext; $self->init(1); +#============================================================================================================================== + Slic3r::GUI::_3DScene::init_gl; +#============================================================================================================================== + # This is a special path for wxWidgets on GTK, where an OpenGL context is initialized # first when an OpenGL widget is shown for the first time. How ugly. # In that case the volumes are wainting to be moved to Vertex Buffer Objects # after the OpenGL context is being initialized. $self->volumes->finalize_geometry(1) if ($^O eq 'linux' && $self->UseVBOs); - + $self->zoom_to_bed; glClearColor(0, 0, 0, 1); @@ -1236,7 +1326,10 @@ sub Render { my ($self, $dc) = @_; # prevent calling SetCurrent() when window is not shown yet - return unless $self->IsShownOnScreen; +#============================================================================================================================== + return unless Slic3r::GUI::_3DScene::is_shown_on_screen($self); +# return unless $self->IsShownOnScreen; +#============================================================================================================================== return unless my $context = $self->GetContext; $self->SetCurrent($context); $self->InitGL; diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index fbcd34a3f6..d510c87e43 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -28,9 +28,9 @@ our $PRESETS_CHANGED_EVENT = Wx::NewEventType; sub new { my ($class, %params) = @_; - + my $self = $class->SUPER::new(undef, -1, $Slic3r::FORK_NAME . ' - ' . $Slic3r::VERSION, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE); - Slic3r::GUI::set_main_frame($self); + Slic3r::GUI::set_main_frame($self); if ($^O eq 'MSWin32') { # Load the icon either from the exe, or from the ico file. my $iconfile = Slic3r::decode_path($FindBin::Bin) . '\slic3r.exe'; @@ -39,7 +39,7 @@ sub new { } else { $self->SetIcon(Wx::Icon->new(Slic3r::var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG)); } - + # store input params # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden. $self->{no_controller} = $params{no_controller}; @@ -47,7 +47,7 @@ sub new { $self->{loaded} = 0; $self->{lang_ch_event} = $params{lang_ch_event}; $self->{preferences_event} = $params{preferences_event}; - + # initialize tabpanel and menubar $self->_init_tabpanel; $self->_init_menubar; @@ -63,7 +63,7 @@ sub new { $self->SetStatusBar($self->{statusbar}); $self->{loaded} = 1; - + # initialize layout { my $sizer = Wx::BoxSizer->new(wxVERTICAL); @@ -90,6 +90,9 @@ sub new { # Save the slic3r.ini. Usually the ini file is saved from "on idle" callback, # but in rare cases it may not have been called yet. wxTheApp->{app_config}->save; +#============================================================================================================================== + Slic3r::GUI::_3DScene::remove_all_canvases(); +#============================================================================================================================== # propagate event $event->Skip; }); diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 4d55e313a6..f0f50a4f3f 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -144,6 +144,9 @@ sub new { # Note that the window was already closed, so a pending update will not be executed. $self->{already_closed} = 1; $self->EndModal(wxID_OK); +#============================================================================================================================= + $self->{canvas}->Destroy; +#============================================================================================================================= $self->Destroy(); }); @@ -151,6 +154,9 @@ sub new { # Note that the window was already closed, so a pending update will not be executed. $self->{already_closed} = 1; $self->EndModal(wxID_CANCEL); +#============================================================================================================================= + $self->{canvas}->Destroy; +#============================================================================================================================= $self->Destroy(); }); diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index a632edeeae..322491f9ec 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -511,6 +511,13 @@ sub CanClose { return ! Slic3r::GUI::catch_error($self); } +#============================================================================================================================= +sub Destroy { + my ($self) = @_; + $self->{canvas}->Destroy if ($self->{canvas}); +} +#============================================================================================================================= + sub PartsChanged { my ($self) = @_; return $self->{parts_changed}; diff --git a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm index 908d5eff77..d0ee98ee6c 100644 --- a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm @@ -36,6 +36,9 @@ sub new { wxTheApp->save_window_pos($self, "object_settings"); $self->EndModal(wxID_OK); +#============================================================================================================================= + $self->{parts}->Destroy; +#============================================================================================================================= $self->Destroy; }); diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 4f44fc7bf7..7d7d371266 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -182,6 +182,12 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/3DScene.hpp ${LIBDIR}/slic3r/GUI/GLShader.cpp ${LIBDIR}/slic3r/GUI/GLShader.hpp + + ${LIBDIR}/slic3r/GUI/GLCanvas3D.hpp + ${LIBDIR}/slic3r/GUI/GLCanvas3D.cpp + ${LIBDIR}/slic3r/GUI/GLCanvas3DManager.hpp + ${LIBDIR}/slic3r/GUI/GLCanvas3DManager.cpp + ${LIBDIR}/slic3r/GUI/Preferences.cpp ${LIBDIR}/slic3r/GUI/Preferences.hpp ${LIBDIR}/slic3r/GUI/Preset.cpp @@ -550,13 +556,13 @@ if (SLIC3R_PRUSACONTROL) set(wxWidgets_UseAlienWx 1) if (wxWidgets_UseAlienWx) set(AlienWx_DEBUG 1) - find_package(AlienWx REQUIRED COMPONENTS base core adv html) + find_package(AlienWx REQUIRED COMPONENTS base core adv html gl) include_directories(${AlienWx_INCLUDE_DIRS}) #add_compile_options(${AlienWx_CXX_FLAGS}) add_definitions(${AlienWx_DEFINITIONS}) set(wxWidgets_LIBRARIES ${AlienWx_LIBRARIES}) else () - find_package(wxWidgets REQUIRED COMPONENTS base core adv html) + find_package(wxWidgets REQUIRED COMPONENTS base core adv html gl) include(${wxWidgets_USE_FILE}) endif () add_definitions(-DSLIC3R_GUI -DSLIC3R_PRUS) diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index 06eb041dfb..bd0b698eed 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -12,6 +12,8 @@ our $VERSION = '0.01'; BEGIN { if ($^O eq 'MSWin32') { eval "use Wx"; + eval "use Wx::GLCanvas"; + eval "use Wx::GLContext"; eval "use Wx::Html"; eval "use Wx::Print"; # because of some Wx bug, thread creation fails if we don't have this (looks like Wx::Printout is hard-coded in some thread cleanup code) } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 6b2f5c8309..761485a125 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1473,6 +1473,9 @@ static void point3_to_verts(const Point3& point, double width, double height, GL _3DScene::GCodePreviewVolumeIndex _3DScene::s_gcode_preview_volume_index; _3DScene::LegendTexture _3DScene::s_legend_texture; _3DScene::WarningTexture _3DScene::s_warning_texture; +//################################################################################################################## +GUI::GLCanvas3DManager _3DScene::s_canvas_mgr; +//################################################################################################################## unsigned int _3DScene::TextureBase::finalize() { @@ -1709,11 +1712,117 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con return true; } -void _3DScene::_glew_init() -{ - glewInit(); +//################################################################################################################## +void _3DScene::init_gl() +{ + s_canvas_mgr.init_gl(); } +bool _3DScene::use_VBOs() +{ + return s_canvas_mgr.use_VBOs(); +} + +bool _3DScene::add_canvas(wxGLCanvas* canvas, wxGLContext* context) +{ + std::cout << "_3DScene::add_canvas()" << std::endl; + return s_canvas_mgr.add(canvas, context); +} + +bool _3DScene::remove_canvas(wxGLCanvas* canvas) +{ + std::cout << "_3DScene::remove_canvas()" << std::endl; + return s_canvas_mgr.remove(canvas); +} + +void _3DScene::remove_all_canvases() +{ + std::cout << "_3DScene::remove_all_canvases()" << std::endl; + std::cout << "# canvases not yet released: " << s_canvas_mgr.count() << std::endl; + s_canvas_mgr.remove_all(); +} + +bool _3DScene::is_dirty(wxGLCanvas* canvas) +{ + return s_canvas_mgr.is_dirty(canvas); +} + +void _3DScene::set_dirty(wxGLCanvas* canvas, bool dirty) +{ + s_canvas_mgr.set_dirty(canvas, dirty); +} + +bool _3DScene::is_shown_on_screen(wxGLCanvas* canvas) +{ + return s_canvas_mgr.is_shown_on_screen(canvas); +} + +unsigned int _3DScene::get_camera_type(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_camera_type(canvas); +} + +void _3DScene::set_camera_type(wxGLCanvas* canvas, unsigned int type) +{ + s_canvas_mgr.set_camera_type(canvas, type); +} + +float _3DScene::get_camera_zoom(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_camera_zoom(canvas); +} + +void _3DScene::set_camera_zoom(wxGLCanvas* canvas, float zoom) +{ + s_canvas_mgr.set_camera_zoom(canvas, zoom); +} + +float _3DScene::get_camera_phi(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_camera_phi(canvas); +} + +void _3DScene::set_camera_phi(wxGLCanvas* canvas, float phi) +{ + s_canvas_mgr.set_camera_phi(canvas, phi); +} + +float _3DScene::get_camera_theta(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_camera_theta(canvas); +} + +void _3DScene::set_camera_theta(wxGLCanvas* canvas, float theta) +{ + s_canvas_mgr.set_camera_theta(canvas, theta); +} + +float _3DScene::get_camera_distance(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_camera_distance(canvas); +} + +void _3DScene::set_camera_distance(wxGLCanvas* canvas, float distance) +{ + s_canvas_mgr.set_camera_distance(canvas, distance); +} + +Pointf3 _3DScene::get_camera_target(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_camera_target(canvas); +} + +void _3DScene::set_camera_target(wxGLCanvas* canvas, const Pointf3* target) +{ + s_canvas_mgr.set_camera_target(canvas, target); +} + +//void _3DScene::_glew_init() +//{ +// glewInit(); +//} +//################################################################################################################## + static inline int hex_digit_to_int(const char c) { return diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 8f03e47746..46fbb02fb1 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -6,8 +6,14 @@ #include "../../libslic3r/Line.hpp" #include "../../libslic3r/TriangleMesh.hpp" #include "../../libslic3r/Utils.hpp" +//################################################################################################################## +#include "../../slic3r/GUI/GLCanvas3DManager.hpp" +//################################################################################################################## class wxBitmap; +//################################################################################################################## +class wxWindow; +//################################################################################################################## namespace Slic3r { @@ -523,9 +529,44 @@ class _3DScene static LegendTexture s_legend_texture; static WarningTexture s_warning_texture; +//################################################################################################################## + static GUI::GLCanvas3DManager s_canvas_mgr; +//################################################################################################################## public: - static void _glew_init(); +//################################################################################################################## + static void init_gl(); + static bool use_VBOs(); + + static bool add_canvas(wxGLCanvas* canvas, wxGLContext* context); + static bool remove_canvas(wxGLCanvas* canvas); + static void remove_all_canvases(); + + static bool is_dirty(wxGLCanvas* canvas); + static void set_dirty(wxGLCanvas* canvas, bool dirty); + + static bool is_shown_on_screen(wxGLCanvas* canvas); + + static unsigned int get_camera_type(wxGLCanvas* canvas); + static void set_camera_type(wxGLCanvas* canvas, unsigned int type); + + static float get_camera_zoom(wxGLCanvas* canvas); + static void set_camera_zoom(wxGLCanvas* canvas, float zoom); + + static float get_camera_phi(wxGLCanvas* canvas); + static void set_camera_phi(wxGLCanvas* canvas, float phi); + + static float get_camera_theta(wxGLCanvas* canvas); + static void set_camera_theta(wxGLCanvas* canvas, float theta); + + static float get_camera_distance(wxGLCanvas* canvas); + static void set_camera_distance(wxGLCanvas* canvas, float distance); + + static Pointf3 get_camera_target(wxGLCanvas* canvas); + static void set_camera_target(wxGLCanvas* canvas, const Pointf3* target); + +// static void _glew_init(); +//################################################################################################################## static void load_gcode_preview(const Print* print, const GCodePreviewData* preview_data, GLVolumeCollection* volumes, const std::vector& str_tool_colors, bool use_VBOs); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp new file mode 100644 index 0000000000..4074cdf78d --- /dev/null +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -0,0 +1,117 @@ +#include "GLCanvas3D.hpp" + +#include + +#include + +namespace Slic3r { +namespace GUI { + +GLCanvas3D::Camera::Camera() + : type(CT_Ortho) + , zoom(1.0f) + , phi(45.0f) + , theta(45.0f) + , distance(0.0f) + , target(0.0, 0.0, 0.0) + +{ +} + +GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) + : m_canvas(canvas) + , m_context(context) + , m_dirty(true) +{ +} + +void GLCanvas3D::set_current() +{ + if ((m_canvas != nullptr) && (m_context != nullptr)) + m_canvas->SetCurrent(*m_context); +} + +bool GLCanvas3D::is_dirty() const +{ + return m_dirty; +} + +void GLCanvas3D::set_dirty(bool dirty) +{ + m_dirty = dirty; +} + +bool GLCanvas3D::is_shown_on_screen() const +{ + return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false; +} + +GLCanvas3D::Camera::EType GLCanvas3D::get_camera_type() const +{ + return m_camera.type; +} + +void GLCanvas3D::set_camera_type(GLCanvas3D::Camera::EType type) +{ + m_camera.type = type; +} + +float GLCanvas3D::get_camera_zoom() const +{ + return m_camera.zoom; +} + +void GLCanvas3D::set_camera_zoom(float zoom) +{ + m_camera.zoom = zoom; +} + +float GLCanvas3D::get_camera_phi() const +{ + return m_camera.phi; +} + +void GLCanvas3D::set_camera_phi(float phi) +{ + m_camera.phi = phi; +} + +float GLCanvas3D::get_camera_theta() const +{ + return m_camera.theta; +} + +void GLCanvas3D::set_camera_theta(float theta) +{ + m_camera.theta = theta; +} + +float GLCanvas3D::get_camera_distance() const +{ + return m_camera.distance; +} + +void GLCanvas3D::set_camera_distance(float distance) +{ + m_camera.distance = distance; +} + +const Pointf3& GLCanvas3D::get_camera_target() const +{ + return m_camera.target; +} + +void GLCanvas3D::set_camera_target(const Pointf3& target) +{ + m_camera.target = target; +} + +void GLCanvas3D::on_size(wxSizeEvent& evt) +{ + std::cout << "GLCanvas3D::on_size: " << (void*)this << std::endl; + + set_dirty(true); +} + +} // namespace GUI +} // namespace Slic3r diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp new file mode 100644 index 0000000000..1548702559 --- /dev/null +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -0,0 +1,77 @@ +#ifndef slic3r_GLCanvas3D_hpp_ +#define slic3r_GLCanvas3D_hpp_ + +#include "../../libslic3r/Point.hpp" + +class wxGLCanvas; +class wxGLContext; +class wxSizeEvent; + +namespace Slic3r { +namespace GUI { + +class GLCanvas3D +{ +public: + struct Camera + { + enum EType : unsigned char + { + CT_Unknown, + CT_Perspective, + CT_Ortho, + CT_Count + }; + + EType type; + float zoom; + float phi; + float theta; + float distance; + Pointf3 target; + + Camera(); + }; + +private: + wxGLCanvas* m_canvas; + wxGLContext* m_context; + Camera m_camera; + + bool m_dirty; + +public: + GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context); + + void set_current(); + + bool is_dirty() const; + void set_dirty(bool dirty); + + bool is_shown_on_screen() const; + + Camera::EType get_camera_type() const; + void set_camera_type(Camera::EType type); + + float get_camera_zoom() const; + void set_camera_zoom(float zoom); + + float get_camera_phi() const; + void set_camera_phi(float phi); + + float get_camera_theta() const; + void set_camera_theta(float theta); + + float get_camera_distance() const; + void set_camera_distance(float distance); + + const Pointf3& get_camera_target() const; + void set_camera_target(const Pointf3& target); + + void on_size(wxSizeEvent& evt); +}; + +} // namespace GUI +} // namespace Slic3r + +#endif // slic3r_GLCanvas3D_hpp_ diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp new file mode 100644 index 0000000000..e27c6b7931 --- /dev/null +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -0,0 +1,263 @@ +#include "GLCanvas3DManager.hpp" +#include "../../slic3r/GUI/GUI.hpp" +#include "../../slic3r/GUI/AppConfig.hpp" + +#include + +#include +#include + +#include + +#include +#include +#include + +namespace Slic3r { +namespace GUI { + +GLCanvas3DManager::GLVersion::GLVersion() + : vn_major(0) + , vn_minor(0) +{ +} + +bool GLCanvas3DManager::GLVersion::detect() +{ + const char* gl_version = (const char*)::glGetString(GL_VERSION); + if (gl_version == nullptr) + return false; + + std::vector tokens; + boost::split(tokens, gl_version, boost::is_any_of(" "), boost::token_compress_on); + + if (tokens.empty()) + return false; + + std::vector numbers; + boost::split(numbers, tokens[0], boost::is_any_of("."), boost::token_compress_on); + + if (numbers.size() > 0) + vn_major = ::atoi(numbers[0].c_str()); + + if (numbers.size() > 1) + vn_minor = ::atoi(numbers[1].c_str()); + + return true; +} + +bool GLCanvas3DManager::GLVersion::is_greater_or_equal_to(unsigned int major, unsigned int minor) const +{ + if (vn_major < major) + return false; + else if (vn_major > major) + return true; + else + return vn_minor >= minor; +} + +GLCanvas3DManager::LayerEditing::LayerEditing() + : allowed(false) +{ +} + +GLCanvas3DManager::GLCanvas3DManager() + : m_gl_initialized(false) + , m_use_legacy_opengl(false) + , m_use_VBOs(false) +{ +} + +bool GLCanvas3DManager::add(wxGLCanvas* canvas, wxGLContext* context) +{ + if (_get_canvas(canvas) != m_canvases.end()) + return false; + + GLCanvas3D* canvas3D = new GLCanvas3D(canvas, context); + if (canvas3D == nullptr) + return false; + + canvas->Bind(wxEVT_SIZE, [canvas3D](wxSizeEvent& evt) { canvas3D->on_size(evt); }); + + m_canvases.insert(CanvasesMap::value_type(canvas, canvas3D)); + + std::cout << "canvas added: " << (void*)canvas << " (" << (void*)canvas3D << ")" << std::endl; + + return true; +} + +bool GLCanvas3DManager::remove(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it == m_canvases.end()) + return false; + + delete it->second; + m_canvases.erase(it); + + std::cout << "canvas removed: " << (void*)canvas << std::endl; + + return true; +} + +void GLCanvas3DManager::remove_all() +{ + for (CanvasesMap::value_type& item : m_canvases) + { + std::cout << "canvas removed: " << (void*)item.second << std::endl; + delete item.second; + } + m_canvases.clear(); +} + +unsigned int GLCanvas3DManager::count() const +{ + return (unsigned int)m_canvases.size(); +} + +void GLCanvas3DManager::init_gl() +{ + if (!m_gl_initialized) + { + std::cout << "GLCanvas3DManager::init_gl()" << std::endl; + + glewInit(); + m_gl_version.detect(); + + const AppConfig* config = GUI::get_app_config(); + m_use_legacy_opengl = (config == nullptr) || (config->get("use_legacy_opengl") == "1"); + m_use_VBOs = !m_use_legacy_opengl && m_gl_version.is_greater_or_equal_to(2, 0); + m_layer_editing.allowed = !m_use_legacy_opengl; + m_gl_initialized = true; + + std::cout << "DETECTED OPENGL: " << m_gl_version.vn_major << "." << m_gl_version.vn_minor << std::endl; + std::cout << "USE VBOS = " << (m_use_VBOs ? "YES" : "NO") << std::endl; + std::cout << "LAYER EDITING ALLOWED = " << (m_layer_editing.allowed ? "YES" : "NO") << std::endl; + } +} + +bool GLCanvas3DManager::use_VBOs() const +{ + return m_use_VBOs; +} + +bool GLCanvas3DManager::layer_editing_allowed() const +{ + return m_layer_editing.allowed; +} + +bool GLCanvas3DManager::is_dirty(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->is_dirty() : false; +} + +void GLCanvas3DManager::set_dirty(wxGLCanvas* canvas, bool dirty) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_dirty(dirty); +} + +bool GLCanvas3DManager::is_shown_on_screen(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->is_shown_on_screen() : false; +} + +unsigned int GLCanvas3DManager::get_camera_type(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? (unsigned int)it->second->get_camera_type() : 0; +} + +void GLCanvas3DManager::set_camera_type(wxGLCanvas* canvas, unsigned int type) +{ + if ((type <= (unsigned int)GLCanvas3D::Camera::CT_Unknown) || ((unsigned int)GLCanvas3D::Camera::CT_Count <= type)) + return; + + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_camera_type((GLCanvas3D::Camera::EType)type); +} + +float GLCanvas3DManager::get_camera_zoom(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_camera_zoom() : 1.0f; +} + +void GLCanvas3DManager::set_camera_zoom(wxGLCanvas* canvas, float zoom) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_camera_zoom(zoom); +} + +float GLCanvas3DManager::get_camera_phi(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_camera_phi() : 0.0f; +} + +void GLCanvas3DManager::set_camera_phi(wxGLCanvas* canvas, float phi) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_camera_phi(phi); +} + +float GLCanvas3DManager::get_camera_theta(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_camera_theta() : 0.0f; +} + +void GLCanvas3DManager::set_camera_theta(wxGLCanvas* canvas, float theta) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_camera_theta(theta); +} + +float GLCanvas3DManager::get_camera_distance(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_camera_distance() : 0.0f; +} + +void GLCanvas3DManager::set_camera_distance(wxGLCanvas* canvas, float distance) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_camera_distance(distance); +} + +Pointf3 GLCanvas3DManager::get_camera_target(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_camera_target() : Pointf3(0.0, 0.0, 0.0); +} + +void GLCanvas3DManager::set_camera_target(wxGLCanvas* canvas, const Pointf3* target) +{ + if (target == nullptr) + return; + + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_camera_target(*target); +} + +GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::_get_canvas(wxGLCanvas* canvas) +{ + return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas); +} + +GLCanvas3DManager::CanvasesMap::const_iterator GLCanvas3DManager::_get_canvas(wxGLCanvas* canvas) const +{ + return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas); +} + +} // namespace GUI +} // namespace Slic3r diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp new file mode 100644 index 0000000000..3933fc9219 --- /dev/null +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -0,0 +1,86 @@ +#ifndef slic3r_GLCanvas3DManager_hpp_ +#define slic3r_GLCanvas3DManager_hpp_ + +#include "GLCanvas3D.hpp" + +#include + +namespace Slic3r { +namespace GUI { + +class GLCanvas3DManager +{ + struct GLVersion + { + unsigned int vn_major; + unsigned int vn_minor; + + GLVersion(); + bool detect(); + + bool is_greater_or_equal_to(unsigned int major, unsigned int minor) const; + }; + + struct LayerEditing + { + bool allowed; + + LayerEditing(); + }; + + typedef std::map CanvasesMap; + + CanvasesMap m_canvases; + GLVersion m_gl_version; + LayerEditing m_layer_editing; + bool m_gl_initialized; + bool m_use_legacy_opengl; + bool m_use_VBOs; + +public: + GLCanvas3DManager(); + + bool add(wxGLCanvas* canvas, wxGLContext* context); + bool remove(wxGLCanvas* canvas); + + void remove_all(); + + unsigned int count() const; + + void init_gl(); + + bool use_VBOs() const; + bool layer_editing_allowed() const; + + bool is_dirty(wxGLCanvas* canvas) const; + void set_dirty(wxGLCanvas* canvas, bool dirty); + + bool is_shown_on_screen(wxGLCanvas* canvas) const; + + unsigned int get_camera_type(wxGLCanvas* canvas) const; + void set_camera_type(wxGLCanvas* canvas, unsigned int type); + + float get_camera_zoom(wxGLCanvas* canvas) const; + void set_camera_zoom(wxGLCanvas* canvas, float zoom); + + float get_camera_phi(wxGLCanvas* canvas) const; + void set_camera_phi(wxGLCanvas* canvas, float phi); + + float get_camera_theta(wxGLCanvas* canvas) const; + void set_camera_theta(wxGLCanvas* canvas, float theta); + + float get_camera_distance(wxGLCanvas* canvas) const; + void set_camera_distance(wxGLCanvas* canvas, float distance); + + Pointf3 get_camera_target(wxGLCanvas* canvas) const; + void set_camera_target(wxGLCanvas* canvas, const Pointf3* target); + +private: + CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas); + CanvasesMap::const_iterator _get_canvas(wxGLCanvas* canvas) const; +}; + +} // namespace GUI +} // namespace Slic3r + +#endif // slic3r_GLCanvas3DManager_hpp_ diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 86d0aeba29..c1bee85e83 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -151,12 +151,158 @@ GLVolumeCollection::arrayref() %package{Slic3r::GUI::_3DScene}; %{ +void +init_gl() + CODE: + _3DScene::init_gl(); + +bool +use_VBOs() + CODE: + RETVAL = _3DScene::use_VBOs(); + OUTPUT: + RETVAL + +bool +add_canvas(canvas, context) + SV *canvas; + SV *context; + CODE: + RETVAL = _3DScene::add_canvas((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (wxGLContext*)wxPli_sv_2_object(aTHX_ context, "Wx::GLContext")); + OUTPUT: + RETVAL + +bool +remove_canvas(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::remove_canvas((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL void -_glew_init() +remove_all_canvases() CODE: - _3DScene::_glew_init(); + _3DScene::remove_all_canvases(); +bool +is_dirty(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::is_dirty((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_dirty(canvas, dirty) + SV *canvas; + bool dirty; + CODE: + _3DScene::set_dirty((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), dirty); + +bool +is_shown_on_screen(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::is_shown_on_screen((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +unsigned int +get_camera_type(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_camera_type((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_camera_type(canvas, type) + SV *canvas; + unsigned int type; + CODE: + _3DScene::set_camera_type((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), type); + +float +get_camera_zoom(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_camera_zoom((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_camera_zoom(canvas, zoom) + SV *canvas; + float zoom; + CODE: + _3DScene::set_camera_zoom((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), zoom); + +float +get_camera_phi(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_camera_phi((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_camera_phi(canvas, phi) + SV *canvas; + float phi; + CODE: + _3DScene::set_camera_phi((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), phi); + +float +get_camera_theta(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_camera_theta((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_camera_theta(canvas, theta) + SV *canvas; + float theta; + CODE: + _3DScene::set_camera_theta((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), theta); + +float +get_camera_distance(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_camera_distance((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_camera_distance(canvas, distance) + SV *canvas; + float distance; + CODE: + _3DScene::set_camera_distance((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), distance); + +Clone +get_camera_target(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_camera_target(canvas, target) + SV *canvas; + Pointf3 *target; + CODE: + _3DScene::set_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), target); + + + + + + unsigned int finalize_legend_texture() CODE: From c07f347ff6cc952cf7cd8853cb89c6b5984d3272 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 9 May 2018 14:36:20 +0200 Subject: [PATCH 0312/1150] CollapsiblePanes are putted to ScrolledWindow --- xs/src/slic3r/GUI/GUI.cpp | 148 +++++++++++------------------ xs/src/slic3r/GUI/wxExtensions.cpp | 12 +-- xs/src/slic3r/GUI/wxExtensions.hpp | 6 +- 3 files changed, 65 insertions(+), 101 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 0be77b6bac..0e2893b574 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -809,17 +809,25 @@ wxString from_u8(const std::string &str) void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) { + sizer->SetMinSize(-1, 300); + auto main_sizer = new wxBoxSizer(wxVERTICAL); + auto main_page = new wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + main_page->SetSizer(main_sizer); + main_page->SetScrollbars(1, 1, 1, 1); + sizer->Add(main_page, 1, wxEXPAND | wxALL, 1); + // Experiments with new UI - wxCollapsiblePane *collpane = new wxCollapsiblePane(parent, wxID_ANY, "Print settings:"); - collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, collpane](wxCommandEvent e){ + wxCollapsiblePane *collpane = new wxCollapsiblePane(main_page, wxID_ANY, "Frequently Changing Parameters:"); + collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, main_page, collpane](wxCommandEvent e){ wxWindowUpdateLocker noUpdates_cp(collpane); - wxWindowUpdateLocker noUpdates(parent); - parent->Layout(); + wxWindowUpdateLocker noUpdates(main_page); + parent->Layout(); + main_page->Layout(); collpane->Refresh(); })); // add the pane with a zero proportion value to the sizer which contains it - sizer->Add(collpane, 0, wxGROW | wxALL, 0); + main_sizer->Add(collpane, 0, wxGROW | wxALL, 0); wxWindow *win = collpane->GetPane(); #ifdef __WXMSW__ @@ -943,8 +951,36 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl }; m_optgroup->append_line(line); - auto common_sizer = new wxBoxSizer(wxVERTICAL); - common_sizer->Add(m_optgroup->sizer); + wxSizer *paneSz = new wxBoxSizer(wxVERTICAL); + paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | /*wxBOTTOM*/wxALL, /*2*/5); + win->SetSizer(paneSz); + paneSz->SetSizeHints(win); + + + + + wxCollapsiblePane *collpane_objects = new wxCollapsiblePane(main_page, wxID_ANY, "Objects List:"); + collpane_objects->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, main_page, collpane_objects](wxCommandEvent e){ + wxWindowUpdateLocker noUpdates_cp(collpane_objects); + wxWindowUpdateLocker noUpdates(main_page); + parent->Layout(); + main_page->Layout(); + collpane_objects->Refresh(); + })); + + // add the pane with a zero proportion value to the sizer which contains it + main_sizer->Add(collpane_objects, 0, wxGROW | wxALL, 0); + + wxWindow *win_objects = collpane_objects->GetPane(); +#ifdef __WXMSW__ + collpane_objects->GetControlWidget()->SetWindowStyleFlag(wxNO_BORDER); + collpane_objects->GetControlWidget()->SetBackgroundColour(clr); + collpane_objects->SetBackgroundColour(clr); + win_objects->SetBackgroundColour(clr); +#endif //__WXMSW__ + +// auto common_sizer = new wxBoxSizer(wxVERTICAL); +// common_sizer->Add(m_optgroup->sizer); // auto listctrl = new wxDataViewListCtrl(win, wxID_ANY, wxDefaultPosition, wxSize(-1, 100)); // listctrl->AppendToggleColumn("Toggle"); @@ -964,9 +1000,10 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl // common_sizer->Add(listctrl, 0, wxEXPAND | wxALL, 1); // ********************************************************************************************** - auto objects_ctrl = new wxDataViewCtrl(win, wxID_ANY, wxDefaultPosition, wxDefaultSize); + auto objects_ctrl = new wxDataViewCtrl(win_objects, wxID_ANY, wxDefaultPosition, wxDefaultSize); wxSizer *objects_sz = new wxBoxSizer(wxVERTICAL); - objects_ctrl->SetMinSize(wxSize(-1, 200)); + objects_ctrl->SetBestFittingSize(wxSize(-1, 200)); +// objects_ctrl->SetMinSize(wxSize(-1, 200)); objects_sz->Add(objects_ctrl, 1, wxGROW | wxALL, 5); auto objects_model = new MyObjectTreeModel; @@ -979,108 +1016,31 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl // column 0 of the view control: wxDataViewTextRenderer *tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); - wxDataViewColumn *column00 = new wxDataViewColumn("Name", tr, 0, 150, wxALIGN_LEFT, + wxDataViewColumn *column00 = new wxDataViewColumn("Name", tr, 0, 140, wxALIGN_LEFT, wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); objects_ctrl->AppendColumn(column00); // column 1 of the view control: tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); - wxDataViewColumn *column01 = new wxDataViewColumn("Copy", tr, 1, 95, wxALIGN_CENTER_HORIZONTAL, + wxDataViewColumn *column01 = new wxDataViewColumn("Copy", tr, 1, 75, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); objects_ctrl->AppendColumn(column01); // column 2 of the view control: tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); - wxDataViewColumn *column02 = new wxDataViewColumn("Scale", tr, 2, 95, wxALIGN_CENTER_HORIZONTAL, + wxDataViewColumn *column02 = new wxDataViewColumn("Scale", tr, 2, 80, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); objects_ctrl->AppendColumn(column02); - common_sizer->Add(objects_sz, 0, wxEXPAND | wxALL, 1); +// common_sizer->Add(objects_sz, 0, wxEXPAND | wxALL, 1); - // ********************************************************************************************** -/* auto view_ctrl = new wxDataViewCtrl(win, wxID_ANY, wxDefaultPosition, wxDefaultSize); - wxSizer *PanelSz = new wxBoxSizer(wxVERTICAL); - view_ctrl->SetMinSize(wxSize(-1, 200)); - PanelSz->Add(view_ctrl, 1, wxGROW | wxALL, 5); - PanelSz->Add( new wxStaticText(win, wxID_ANY, "Most of the cells above are editable!"), 0, wxGROW | wxALL, 5); - - auto m_music_model = new MyMusicTreeModel; - view_ctrl->AssociateModel(m_music_model); + wxSizer *paneSz_objects = new wxBoxSizer(wxVERTICAL); + paneSz_objects->Add(objects_sz, 1, wxGROW | wxEXPAND | wxBOTTOM, 2); + win_objects->SetSizer(paneSz_objects); + paneSz_objects->SetSizeHints(win_objects); -#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE - view_ctrl->EnableDragSource(wxDF_UNICODETEXT); - view_ctrl->EnableDropTarget(wxDF_UNICODETEXT); -#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE - - // column 0 of the view control: - - tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); - wxDataViewColumn *column0 = - new wxDataViewColumn("title", tr, 0, 150, wxALIGN_LEFT, - wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); - view_ctrl->AppendColumn(column0); -#if 0 - // Call this and sorting is enabled - // immediately upon start up. - column0->SetAsSortKey(); -#endif - - // column 1 of the view control: - - tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_EDITABLE); - wxDataViewColumn *column1 = - new wxDataViewColumn("artist", tr, 1, 150, wxALIGN_LEFT, - wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE | - wxDATAVIEW_COL_RESIZABLE); - column1->SetMinWidth(100); // this column can't be resized to be smaller - view_ctrl->AppendColumn(column1); - - // column 2 of the view control: - - wxDataViewSpinRenderer *sr = - new wxDataViewSpinRenderer(0, 2010, wxDATAVIEW_CELL_EDITABLE, - wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); - wxDataViewColumn *column2 = - new wxDataViewColumn("year", sr, 2, 60, wxALIGN_LEFT, - wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE); - view_ctrl->AppendColumn(column2); - - // column 3 of the view control: - - wxArrayString choices; - choices.Add("good"); - choices.Add("bad"); - choices.Add("lousy"); - wxDataViewChoiceRenderer *c = - new wxDataViewChoiceRenderer(choices, wxDATAVIEW_CELL_EDITABLE, - wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); - wxDataViewColumn *column3 = - new wxDataViewColumn("rating", c, 3, 100, wxALIGN_LEFT, - wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE); - view_ctrl->AppendColumn(column3); - - // column 4 of the view control: - - view_ctrl->AppendProgressColumn("popularity", 4, wxDATAVIEW_CELL_INERT, 80); - - // column 5 of the view control: - - MyCustomRenderer *cr = new MyCustomRenderer(wxDATAVIEW_CELL_ACTIVATABLE); - wxDataViewColumn *column5 = - new wxDataViewColumn("custom", cr, 5, -1, wxALIGN_LEFT, - wxDATAVIEW_COL_RESIZABLE); - view_ctrl->AppendColumn(column5); - - // ********************************************************************************************** - common_sizer->Add(PanelSz, 0, wxEXPAND | wxALL, 1); -*/ - - wxSizer *paneSz = new wxBoxSizer(wxVERTICAL); - paneSz->Add(common_sizer/*m_optgroup->sizer*/, 1, wxGROW | wxEXPAND | wxBOTTOM, 2); - win->SetSizer(paneSz); - paneSz->SetSizeHints(win); } ConfigOptionsGroup* get_optgroup() diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 9d691b1aa4..0fb335118a 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -186,9 +186,9 @@ MyObjectTreeModel::MyObjectTreeModel() m_objects.emplace(root3); auto root4 = new MyObjectTreeModelNode("Object4"); m_objects.emplace(root4); - root4->Append(new MyObjectTreeModelNode(root2, "SubObject1")); - root4->Append(new MyObjectTreeModelNode(root2, "SubObject2")); - root4->Append(new MyObjectTreeModelNode(root2, "SubObject3")); + root4->Append(new MyObjectTreeModelNode(root4, "SubObject1")); + root4->Append(new MyObjectTreeModelNode(root4, "SubObject2")); + root4->Append(new MyObjectTreeModelNode(root4, "SubObject3")); } wxString MyObjectTreeModel::GetName(const wxDataViewItem &item) const @@ -200,7 +200,7 @@ wxString MyObjectTreeModel::GetName(const wxDataViewItem &item) const return node->m_name; } -wxString MyObjectTreeModel::GetCopyCnt(const wxDataViewItem &item) const +wxString MyObjectTreeModel::GetCopy(const wxDataViewItem &item) const { MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); if (!node) // happens if item.IsOk()==false @@ -302,8 +302,8 @@ unsigned int MyObjectTreeModel::GetChildren(const wxDataViewItem &parent, wxData MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)parent.GetID(); if (!node) { - for (auto object: m_objects) - array.Add(wxDataViewItem((void*)object)); + for (auto object : m_objects) + array.Add(wxDataViewItem((void*)object)); return m_objects.size(); } diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index 0ed27ab74f..6ebdbe8b20 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -148,7 +148,7 @@ public: // helper method for wxLog wxString GetName(const wxDataViewItem &item) const; - wxString GetCopyCnt(const wxDataViewItem &item) const; + wxString GetCopy(const wxDataViewItem &item) const; wxString GetScale(const wxDataViewItem &item) const; // helper methods to change the model @@ -172,6 +172,10 @@ public: virtual bool IsContainer(const wxDataViewItem &item) const override; virtual unsigned int GetChildren(const wxDataViewItem &parent, wxDataViewItemArray &array) const override; + + // Is the container just a header or an item with all columns + // In our case it is an item with all columns + virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const override { return true; } }; From 754bfd926b46924df2e1c56adb945c12ba900f02 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 10 May 2018 11:10:44 +0200 Subject: [PATCH 0313/1150] Auto-correction of the input values according to the admissible range --- xs/src/libslic3r/PrintConfig.cpp | 3 ++- xs/src/slic3r/GUI/Field.cpp | 25 ++++++++++++++++++------- xs/src/slic3r/GUI/Field.hpp | 1 - 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index f70a42182e..697a6f0d4a 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -111,7 +111,8 @@ PrintConfigDef::PrintConfigDef() "with cooling (use a fan) before tweaking this."); def->cli = "bridge-flow-ratio=f"; def->min = 0; - def->default_value = new ConfigOptionFloat(1); + def->max = 2; + def->default_value = new ConfigOptionFloat(1); def = this->add("bridge_speed", coFloat); def->label = L("Bridges"); diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 5cae9172ef..a5a14d368a 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -82,10 +82,8 @@ namespace Slic3r { namespace GUI { return std::regex_match(string, regex_pattern); } -// boost::any Field::get_value_by_opt_type(wxString& str) void Field::get_value_by_opt_type(wxString& str) { -// boost::any m_value; switch (m_opt.type){ case coInt: m_value = wxAtoi(str); @@ -96,9 +94,24 @@ namespace Slic3r { namespace GUI { case coFloat:{ if (m_opt.type == coPercent && str.Last() == '%') str.RemoveLast(); + else if (str.Last() == '%') { + show_error(m_parent, _(L("Current option doesn't support percentage"))); + set_value(double_to_string(m_opt.min), true); + m_value = double(m_opt.min); + break; + } double val; str.ToCDouble(&val); - m_value = val; + if (m_opt.min <= val && val <= m_opt.max) + m_value = val; + else + { + show_error(m_parent, _(L("Input value is out of range"))); + if (m_opt.min > val) val = m_opt.min; + if (val > m_opt.max) val = m_opt.max; + set_value(double_to_string(val), true); + m_value = val; + } break; } case coString: case coStrings: @@ -108,8 +121,6 @@ namespace Slic3r { namespace GUI { default: break; } - -// return m_value; } void TextCtrl::BUILD() { @@ -188,9 +199,9 @@ namespace Slic3r { namespace GUI { boost::any& TextCtrl::get_value() { wxString ret_str = static_cast(window)->GetValue(); - /*boost::any ret_val*/get_value_by_opt_type(ret_str); + get_value_by_opt_type(ret_str); - return m_value;//ret_val; + return m_value; } void TextCtrl::enable() { dynamic_cast(window)->Enable(); dynamic_cast(window)->SetEditable(true); } diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index 729f73d160..7e421244bb 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -124,7 +124,6 @@ public: virtual wxWindow* getWindow() { return nullptr; } bool is_matched(const std::string& string, const std::string& pattern); -// boost::any get_value_by_opt_type(wxString& str); void get_value_by_opt_type(wxString& str); /// Factory method for generating new derived classes. From 98d9ce31de65f70111c490a883b33408d0f30124 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 10 May 2018 12:54:02 +0200 Subject: [PATCH 0314/1150] Corrected error message to last commit --- xs/src/slic3r/GUI/Field.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index a5a14d368a..623e20b45c 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -95,23 +95,25 @@ namespace Slic3r { namespace GUI { if (m_opt.type == coPercent && str.Last() == '%') str.RemoveLast(); else if (str.Last() == '%') { - show_error(m_parent, _(L("Current option doesn't support percentage"))); + wxString label = m_Label->GetLabel(); + if (label.Last() == '\n') label.RemoveLast(); + while (label.Last() == ' ') label.RemoveLast(); + if (label.Last() == ':') label.RemoveLast(); + show_error(m_parent, wxString::Format(_(L("%s doesn't support percentage")), label)); set_value(double_to_string(m_opt.min), true); m_value = double(m_opt.min); break; } double val; str.ToCDouble(&val); - if (m_opt.min <= val && val <= m_opt.max) - m_value = val; - else + if (m_opt.min > val && val > m_opt.max) { show_error(m_parent, _(L("Input value is out of range"))); if (m_opt.min > val) val = m_opt.min; if (val > m_opt.max) val = m_opt.max; set_value(double_to_string(val), true); - m_value = val; } + m_value = val; break; } case coString: case coStrings: From 2e7d623ee40489d437badee28c4b52ec62eaceed Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 10 May 2018 16:36:12 +0200 Subject: [PATCH 0315/1150] Created PrusaCollapsiblePane for CollapsiblePane view with disclosure triangles --- resources/icons/disclosure_triangle_close.png | Bin 0 -> 212 bytes resources/icons/disclosure_triangle_open.png | Bin 0 -> 210 bytes xs/src/slic3r/GUI/GUI.cpp | 83 ++++------- xs/src/slic3r/GUI/wxExtensions.cpp | 133 +++++++++++++++++- xs/src/slic3r/GUI/wxExtensions.hpp | 61 ++++++++ 5 files changed, 218 insertions(+), 59 deletions(-) create mode 100644 resources/icons/disclosure_triangle_close.png create mode 100644 resources/icons/disclosure_triangle_open.png diff --git a/resources/icons/disclosure_triangle_close.png b/resources/icons/disclosure_triangle_close.png new file mode 100644 index 0000000000000000000000000000000000000000..0660422c7f53ee6bc352d6ce790d653214b523e0 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!AwsV#}EtuWQjQo_U)UOd39CjnE<`Y1$*|` zaGp}(4+#s~$0~J+;prs42DTceNBSw!Or{U)Z?-8&GMKS+tWG;O=OouuHJ%lj2c~y* zbyck}_{fmOP&vzyVZ~3~o3k7n7PYucUE-sD-~ab%7 literal 0 HcmV?d00001 diff --git a/resources/icons/disclosure_triangle_open.png b/resources/icons/disclosure_triangle_open.png new file mode 100644 index 0000000000000000000000000000000000000000..81112f2a2610371930c4be6fcb173a2472c5e298 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!E{d-#}EtuWC_*~makvG`UI#|CR|+=dgkfV zr=FssqVF4i2=nnw@@84tnsu1Pf%WUusZ;Ma{;-!~>%8hX^&xwJ^FD=4wvC;ad6+%g zCajZWYmi#qz!vJXb4l}-Ehb?CZAI>kVFwN{Fl?CZW##C;`XA6r22WQ%mvv4FO#qAdd(main_page, 1, wxEXPAND | wxALL, 1); // Experiments with new UI - wxCollapsiblePane *collpane = new wxCollapsiblePane(main_page, wxID_ANY, "Frequently Changing Parameters:"); - collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, main_page, collpane](wxCommandEvent e){ - wxWindowUpdateLocker noUpdates_cp(collpane); - wxWindowUpdateLocker noUpdates(main_page); - parent->Layout(); - main_page->Layout(); - collpane->Refresh(); - })); + // *** Frequently Changing Parameters *** + auto* collpane = new PrusaCollapsiblePane(main_page, wxID_ANY, "Frequently Changing Parameters:"); // add the pane with a zero proportion value to the sizer which contains it main_sizer->Add(collpane, 0, wxGROW | wxALL, 0); wxWindow *win = collpane->GetPane(); -#ifdef __WXMSW__ - wxColour& clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - collpane->GetControlWidget()->SetWindowStyleFlag(wxNO_BORDER); - collpane->GetControlWidget()->SetBackgroundColour(clr); - collpane->SetBackgroundColour(clr); - win->SetBackgroundColour(clr); -#endif //__WXMSW__ DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; m_optgroup = std::make_shared(win, "", config); @@ -952,57 +939,24 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl m_optgroup->append_line(line); wxSizer *paneSz = new wxBoxSizer(wxVERTICAL); - paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | /*wxBOTTOM*/wxALL, /*2*/5); + paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | wxLEFT | wxRIGHT, 5); win->SetSizer(paneSz); paneSz->SetSizeHints(win); - - wxCollapsiblePane *collpane_objects = new wxCollapsiblePane(main_page, wxID_ANY, "Objects List:"); - collpane_objects->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, main_page, collpane_objects](wxCommandEvent e){ - wxWindowUpdateLocker noUpdates_cp(collpane_objects); - wxWindowUpdateLocker noUpdates(main_page); - parent->Layout(); - main_page->Layout(); - collpane_objects->Refresh(); - })); - + // *** Objects List *** + auto *collpane_objects = new PrusaCollapsiblePane(main_page, wxID_ANY, "Objects List:"); // add the pane with a zero proportion value to the sizer which contains it main_sizer->Add(collpane_objects, 0, wxGROW | wxALL, 0); wxWindow *win_objects = collpane_objects->GetPane(); -#ifdef __WXMSW__ - collpane_objects->GetControlWidget()->SetWindowStyleFlag(wxNO_BORDER); - collpane_objects->GetControlWidget()->SetBackgroundColour(clr); - collpane_objects->SetBackgroundColour(clr); - win_objects->SetBackgroundColour(clr); -#endif //__WXMSW__ - -// auto common_sizer = new wxBoxSizer(wxVERTICAL); -// common_sizer->Add(m_optgroup->sizer); - -// auto listctrl = new wxDataViewListCtrl(win, wxID_ANY, wxDefaultPosition, wxSize(-1, 100)); -// listctrl->AppendToggleColumn("Toggle"); -// listctrl->AppendTextColumn("Text"); -// wxVector data; -// data.push_back(wxVariant(true)); -// data.push_back(wxVariant("row 1")); -// listctrl->AppendItem(data); -// data.clear(); -// data.push_back(wxVariant(false)); -// data.push_back(wxVariant("row 3")); -// listctrl->AppendItem(data); -// data.clear(); -// data.push_back(wxVariant(false)); -// data.push_back(wxVariant("row 2")); -// listctrl->AppendItem(data); -// common_sizer->Add(listctrl, 0, wxEXPAND | wxALL, 1); // ********************************************************************************************** auto objects_ctrl = new wxDataViewCtrl(win_objects, wxID_ANY, wxDefaultPosition, wxDefaultSize); wxSizer *objects_sz = new wxBoxSizer(wxVERTICAL); - objects_ctrl->SetBestFittingSize(wxSize(-1, 200)); + objects_ctrl->SetBestFittingSize(wxSize(-1, 200)); + // TODO - Set correct height according to the opened/closed objects // objects_ctrl->SetMinSize(wxSize(-1, 200)); objects_sz->Add(objects_ctrl, 1, wxGROW | wxALL, 5); @@ -1041,6 +995,29 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl win_objects->SetSizer(paneSz_objects); paneSz_objects->SetSizeHints(win_objects); + + +// auto common_sizer = new wxBoxSizer(wxVERTICAL); +// common_sizer->Add(m_optgroup->sizer); + +// auto listctrl = new wxDataViewListCtrl(win, wxID_ANY, wxDefaultPosition, wxSize(-1, 100)); +// listctrl->AppendToggleColumn("Toggle"); +// listctrl->AppendTextColumn("Text"); +// wxVector data; +// data.push_back(wxVariant(true)); +// data.push_back(wxVariant("row 1")); +// listctrl->AppendItem(data); +// data.clear(); +// data.push_back(wxVariant(false)); +// data.push_back(wxVariant("row 3")); +// listctrl->AppendItem(data); +// data.clear(); +// data.push_back(wxVariant(false)); +// data.push_back(wxVariant("row 2")); +// listctrl->AppendItem(data); +// common_sizer->Add(listctrl, 0, wxEXPAND | wxALL, 1); + + } ConfigOptionsGroup* get_optgroup() diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 0fb335118a..03d6bdaef9 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -1,5 +1,11 @@ #include "wxExtensions.hpp" +#include "GUI.hpp" +#include "../../libslic3r/Utils.hpp" + +#include +#include + const unsigned int wxCheckListBoxComboPopup::DefaultWidth = 200; const unsigned int wxCheckListBoxComboPopup::DefaultHeight = 200; const unsigned int wxCheckListBoxComboPopup::DefaultItemHeight = 18; @@ -166,6 +172,119 @@ void wxDataViewTreeCtrlComboPopup::OnDataViewTreeCtrlSelection(wxCommandEvent& e cmb->SetText(selected); } +// *** PrusaCollapsiblePane *** +// ---------------------------------------------------------------------------- +bool PrusaCollapsiblePane::Create(wxWindow *parent, wxWindowID id, const wxString& label, + const wxPoint& pos, const wxSize& size, long style, const wxValidator& val, const wxString& name) +{ + if (!wxControl::Create(parent, id, pos, size, style, val, name)) + return false; + m_pStaticLine = NULL; + m_strLabel = label; + + // sizer containing the expand button and possibly a static line + m_sz = new wxBoxSizer(wxHORIZONTAL); + + m_bmp_close.LoadFile(Slic3r::GUI::from_u8(Slic3r::var("disclosure_triangle_close.png")), wxBITMAP_TYPE_PNG); + m_bmp_open.LoadFile(Slic3r::GUI::from_u8(Slic3r::var("disclosure_triangle_open.png")), wxBITMAP_TYPE_PNG); + + m_pDisclosureTriangleButton = new wxButton(this, wxID_ANY, m_strLabel, wxPoint(0, 0), + wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + m_pDisclosureTriangleButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) + { + if (event.GetEventObject() != m_pDisclosureTriangleButton) + { + event.Skip(); + return; + } + + Collapse(!IsCollapsed()); + + // this change was generated by the user - send the event + wxCollapsiblePaneEvent ev(this, GetId(), IsCollapsed()); + GetEventHandler()->ProcessEvent(ev); + }); + + UpdateBtnBmp(); + + m_sz->Add(m_pDisclosureTriangleButton, 0, wxLEFT | wxTOP | wxBOTTOM, GetBorder()); + + // do not set sz as our sizers since we handle the pane window without using sizers + m_pPane = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL | wxNO_BORDER, wxT("wxCollapsiblePanePane")); + + wxColour& clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); + m_pDisclosureTriangleButton->SetBackgroundColour(clr); + this->SetBackgroundColour(clr); + m_pPane->SetBackgroundColour(clr); + + // start as collapsed: + m_pPane->Hide(); + + return true; +} + +void PrusaCollapsiblePane::UpdateBtnBmp() +{ + IsCollapsed() ? + m_pDisclosureTriangleButton->SetBitmap(m_bmp_close) : + m_pDisclosureTriangleButton->SetBitmap(m_bmp_open); + Layout(); +// m_pDisclosureTriangleButton->Refresh(); +} + +void PrusaCollapsiblePane::Collapse(bool collapse) +{ + // optimization + if (IsCollapsed() == collapse) + return; + + InvalidateBestSize(); + + // update our state + m_pPane->Show(!collapse); + + // update button label +// m_pDisclosureTriangleButton->SetLabel(m_strLabel); + UpdateBtnBmp(); + + OnStateChange(GetBestSize()); +} + +void PrusaCollapsiblePane::SetLabel(const wxString &label) +{ + m_strLabel = label; + + m_pDisclosureTriangleButton->SetLabel(m_strLabel); + + Layout(); +} + +bool PrusaCollapsiblePane::Layout() +{ + if (!m_pDisclosureTriangleButton || !m_pPane || !m_sz) + return false; // we need to complete the creation first! + + wxSize oursz(GetSize()); + + // move & resize the button and the static line + m_sz->SetDimension(0, 0, oursz.GetWidth(), m_sz->GetMinSize().GetHeight()); + m_sz->Layout(); + + if (IsExpanded()) + { + // move & resize the container window + int yoffset = m_sz->GetSize().GetHeight() + GetBorder(); + m_pPane->SetSize(0, yoffset, + oursz.x, oursz.y - yoffset); + + // this is very important to make the pane window layout show correctly + m_pPane->Layout(); + } + + return true; +} + // ***************************************************************************** // ---------------------------------------------------------------------------- // MyObjectTreeModel @@ -178,17 +297,19 @@ MyObjectTreeModel::MyObjectTreeModel() auto root2 = new MyObjectTreeModelNode("Object2"); m_objects.emplace(root2); - root2->Append(new MyObjectTreeModelNode(root2, "SubObject1")); - root2->Append(new MyObjectTreeModelNode(root2, "SubObject2")); - root2->Append(new MyObjectTreeModelNode(root2, "SubObject3")); + root2->Append(new MyObjectTreeModelNode(root2, "SubObject2_1")); + root2->Append(new MyObjectTreeModelNode(root2, "SubObject2_2")); + root2->Append(new MyObjectTreeModelNode(root2, "SubObject2_3")); auto root3 = new MyObjectTreeModelNode("Object3"); m_objects.emplace(root3); auto root4 = new MyObjectTreeModelNode("Object4"); m_objects.emplace(root4); - root4->Append(new MyObjectTreeModelNode(root4, "SubObject1")); - root4->Append(new MyObjectTreeModelNode(root4, "SubObject2")); - root4->Append(new MyObjectTreeModelNode(root4, "SubObject3")); + root4->Append(new MyObjectTreeModelNode(root4, "SubObject4_1")); + root4->Append(new MyObjectTreeModelNode(root4, "SubObject4_2")); + + auto root5 = new MyObjectTreeModelNode("Object5"); + m_objects.emplace(root5); } wxString MyObjectTreeModel::GetName(const wxDataViewItem &item) const diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index 6ebdbe8b20..ec3b0d4790 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -5,6 +5,10 @@ #include #include #include +#include +#include +#include + #include #include @@ -53,6 +57,63 @@ public: void SetItemsCnt(int cnt) { m_cnt_open_items = cnt; } }; + + +// *** PrusaCollapsiblePane *** +// ---------------------------------------------------------------------------- +class PrusaCollapsiblePane : public wxCollapsiblePane +{ +#ifdef __WXMSW__ + wxButton* m_pDisclosureTriangleButton = nullptr; + wxBitmap m_bmp_close; + wxBitmap m_bmp_open; +#endif //__WXMSW__ +public: + PrusaCollapsiblePane() {} + + + PrusaCollapsiblePane( wxWindow *parent, + wxWindowID winid, + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxCP_DEFAULT_STYLE, + const wxValidator& val = wxDefaultValidator, + const wxString& name = wxCollapsiblePaneNameStr) + { +#ifdef __WXMSW__ + Create(parent, winid, label, pos, size, style, val, name); +#else + this->Create(parent, winid, label); +#endif //__WXMSW__ + this->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, this](wxCommandEvent e){ + wxWindowUpdateLocker noUpdates_cp(this); + wxWindowUpdateLocker noUpdates(parent); + parent->GetParent()->Layout(); + parent->Layout(); + this->Refresh(); + })); + } + + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& label, + const wxPoint& pos, + const wxSize& size, + long style, + const wxValidator& val, + const wxString& name); + +#ifdef __WXMSW__ + void UpdateBtnBmp(); + void Collapse(bool collapse) override; + void SetLabel(const wxString &label) override; + bool Layout() override; +#endif //__WXMSW__ + +}; + + // ***************************************************************************** // ---------------------------------------------------------------------------- // MyObjectTreeModelNode: a node inside MyObjectTreeModel From 5e231bf8749c0eb54cd3ffc71f5d172d7c8a9c65 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 10 May 2018 17:44:04 +0200 Subject: [PATCH 0316/1150] New wipe tower parameters added to INI file with profiles --- resources/profiles/PrusaResearch.ini | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index d82921fd8d..87950bae79 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -121,7 +121,8 @@ top_infill_extrusion_width = 0.45 top_solid_infill_speed = 40 travel_speed = 180 wipe_tower = 1 -wipe_tower_per_color_wipe = 20 +wipe_tower_bridging = 10 +wipe_tower_rotation_angle = 0 wipe_tower_width = 60 wipe_tower_x = 180 wipe_tower_y = 140 @@ -538,6 +539,10 @@ compatible_printers = compatible_printers_condition = end_filament_gcode = "; Filament-specific end gcode" extrusion_multiplier = 1 +filament_loading_speed = 28 +filament_unloading_speed = 90 +filament_toolchange_delay = 0 +filament_ramming_parameters = "120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0| 0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" filament_cost = 0 filament_density = 0 filament_diameter = 1.75 @@ -591,6 +596,7 @@ fan_always_on = 0 fan_below_layer_time = 20 filament_colour = #3A80CA filament_max_volumetric_speed = 11 +filament_ramming_parameters = "120 100 5.70968 6.03226 7 8.25806 9 9.19355 9.3871 9.77419 10.129 10.3226 10.4516 10.5161| 0.05 5.69677 0.45 6.15484 0.95 8.76774 1.45 9.20323 1.95 9.95806 2.45 10.3871 2.95 10.5677 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" filament_type = ABS first_layer_bed_temperature = 100 first_layer_temperature = 255 @@ -763,6 +769,7 @@ fan_always_on = 0 filament_colour = #FFFFD7 filament_max_volumetric_speed = 10 filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH" +filament_ramming_parameters = "120 100 8.3871 8.6129 8.93548 9.22581 9.48387 9.70968 9.87097 10.0323 10.2258 10.4194 10.6452 10.8065| 0.05 8.34193 0.45 8.73548 0.95 9.34836 1.45 9.78385 1.95 10.0871 2.45 10.5161 2.95 10.8903 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" filament_soluble = 1 filament_type = PVA first_layer_temperature = 195 @@ -933,6 +940,9 @@ retract_restart_extra_toolchange = 0 retract_speed = 80 single_extruder_multi_material = 1 printer_model = MK2SMM +parking_pos_retraction = 92 +cooling_tube_length = 5 +cooling_tube_retraction = 91.5 [printer:*mm-single*] inherits = *multimaterial* From 9af6a89f20785feab4d068977957bee9ee239cad Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 10 May 2018 18:07:22 +0200 Subject: [PATCH 0317/1150] Fixed a crash when loading multipart objects --- lib/Slic3r/GUI/Plater.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 0a5d02b944..08c1065df7 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -700,7 +700,7 @@ sub load_files { . "Instead of considering them as multiple objects, should I consider\n" . "this file as a single object having multiple parts?\n"), L('Multi-part object detected'), wxICON_WARNING | wxYES | wxNO); - $model->convert_multipart_object if $dialog->ShowModal(scalar(@$nozzle_dmrs)) == wxID_YES; + $model->convert_multipart_object(scalar(@$nozzle_dmrs)) if $dialog->ShowModal() == wxID_YES; } if ($one_by_one) { @@ -717,7 +717,7 @@ sub load_files { . "Instead of considering them as multiple objects, should I consider\n" . "these files to represent a single object having multiple parts?\n"), L('Multi-part object detected'), wxICON_WARNING | wxYES | wxNO); - $new_model->convert_multipart_object if $dialog->ShowModal(scalar(@$nozzle_dmrs)) == wxID_YES; + $new_model->convert_multipart_object(scalar(@$nozzle_dmrs)) if $dialog->ShowModal() == wxID_YES; push @obj_idx, $self->load_model_objects(@{$new_model->objects}); } From d620961c34ceb8ca747ab675042abb3abf8c341a Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 10 May 2018 18:37:57 +0200 Subject: [PATCH 0318/1150] Fixed the version number. We have an alpha state as of today. --- xs/src/libslic3r/libslic3r.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/libslic3r.h b/xs/src/libslic3r/libslic3r.h index 4aef4d5c16..e7b858e8b8 100644 --- a/xs/src/libslic3r/libslic3r.h +++ b/xs/src/libslic3r/libslic3r.h @@ -14,7 +14,7 @@ #include #define SLIC3R_FORK_NAME "Slic3r Prusa Edition" -#define SLIC3R_VERSION "1.40.0" +#define SLIC3R_VERSION "1.40.0-alpha" #define SLIC3R_BUILD "UNKNOWN" typedef int32_t coord_t; From e91ebddeea4da1f6062546ee354573119c22f89b Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 11 May 2018 09:53:35 +0200 Subject: [PATCH 0319/1150] Added possibility of select all TextCtrl context using Ctrl+A --- xs/src/slic3r/GUI/Field.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 623e20b45c..0fcf480e31 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -194,6 +194,14 @@ namespace Slic3r { namespace GUI { temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent) { on_change_field(); }), temp->GetId()); + // select all text using Ctrl+A + temp->Bind(wxEVT_CHAR, ([temp](wxKeyEvent& event) + { + if (wxGetKeyState(wxKeyCode('A')) && wxGetKeyState(WXK_CONTROL)) + temp->SetSelection(-1, -1); //select all + event.Skip(); + })); + // recast as a wxWindow to fit the calling convention window = dynamic_cast(temp); } From 27769edab288a5a99bcd598530a85215e7e43d90 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 11 May 2018 11:25:28 +0200 Subject: [PATCH 0320/1150] Fixed compilation bag on GTK and OSX --- xs/src/slic3r/GUI/wxExtensions.cpp | 3 +++ xs/src/slic3r/GUI/wxExtensions.hpp | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 03d6bdaef9..ace0ad53af 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -172,8 +172,10 @@ void wxDataViewTreeCtrlComboPopup::OnDataViewTreeCtrlSelection(wxCommandEvent& e cmb->SetText(selected); } +// ---------------------------------------------------------------------------- // *** PrusaCollapsiblePane *** // ---------------------------------------------------------------------------- +#ifdef __WXMSW__ bool PrusaCollapsiblePane::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& val, const wxString& name) { @@ -284,6 +286,7 @@ bool PrusaCollapsiblePane::Layout() return true; } +#endif //__WXMSW__ // ***************************************************************************** // ---------------------------------------------------------------------------- diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index ec3b0d4790..cea4ce32b5 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -70,8 +70,6 @@ class PrusaCollapsiblePane : public wxCollapsiblePane #endif //__WXMSW__ public: PrusaCollapsiblePane() {} - - PrusaCollapsiblePane( wxWindow *parent, wxWindowID winid, const wxString& label, @@ -84,7 +82,7 @@ public: #ifdef __WXMSW__ Create(parent, winid, label, pos, size, style, val, name); #else - this->Create(parent, winid, label); + Create(parent, winid, label); #endif //__WXMSW__ this->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, this](wxCommandEvent e){ wxWindowUpdateLocker noUpdates_cp(this); @@ -95,6 +93,9 @@ public: })); } + ~PrusaCollapsiblePane() {} + +#ifdef __WXMSW__ bool Create(wxWindow *parent, wxWindowID id, const wxString& label, @@ -104,7 +105,6 @@ public: const wxValidator& val, const wxString& name); -#ifdef __WXMSW__ void UpdateBtnBmp(); void Collapse(bool collapse) override; void SetLabel(const wxString &label) override; From d89f8128cde85f45beac212847ee0f578eab26ed Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 11 May 2018 12:28:31 +0200 Subject: [PATCH 0321/1150] Fixed a GCode preview crash on Linux due to returning a reference to temporary (issue #872) --- xs/src/libslic3r/GCode/PreviewData.cpp | 2 +- xs/src/libslic3r/GCode/PreviewData.hpp | 2 +- xs/src/slic3r/GUI/3DScene.cpp | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/xs/src/libslic3r/GCode/PreviewData.cpp b/xs/src/libslic3r/GCode/PreviewData.cpp index d431708c1b..40f0747b28 100644 --- a/xs/src/libslic3r/GCode/PreviewData.cpp +++ b/xs/src/libslic3r/GCode/PreviewData.cpp @@ -275,7 +275,7 @@ bool GCodePreviewData::empty() const return extrusion.layers.empty() && travel.polylines.empty() && retraction.positions.empty() && unretraction.positions.empty(); } -const GCodePreviewData::Color& GCodePreviewData::get_extrusion_role_color(ExtrusionRole role) const +GCodePreviewData::Color GCodePreviewData::get_extrusion_role_color(ExtrusionRole role) const { return extrusion.role_colors[role]; } diff --git a/xs/src/libslic3r/GCode/PreviewData.hpp b/xs/src/libslic3r/GCode/PreviewData.hpp index a7d77e0b93..ea8ca6d58a 100644 --- a/xs/src/libslic3r/GCode/PreviewData.hpp +++ b/xs/src/libslic3r/GCode/PreviewData.hpp @@ -187,7 +187,7 @@ public: void reset(); bool empty() const; - const Color& get_extrusion_role_color(ExtrusionRole role) const; + Color get_extrusion_role_color(ExtrusionRole role) const; Color get_height_color(float height) const; Color get_width_color(float width) const; Color get_feedrate_color(float feedrate) const; diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 6b2f5c8309..85018404c9 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -2204,7 +2204,7 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, return 0.0f; } - static const GCodePreviewData::Color& path_color(const GCodePreviewData& data, const std::vector& tool_colors, float value) + static const GCodePreviewData::Color path_color(const GCodePreviewData& data, const std::vector& tool_colors, float value) { switch (data.extrusion.view_type) { @@ -2257,7 +2257,6 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, }; typedef std::vector FiltersList; - size_t initial_volumes_count = volumes.volumes.size(); // detects filters @@ -2281,7 +2280,6 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, for (Filter& filter : filters) { s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Extrusion, (unsigned int)filter.role, (unsigned int)volumes.volumes.size()); - GLVolume* volume = new GLVolume(Helper::path_color(preview_data, tool_colors, filter.value).rgba); if (volume != nullptr) { From 8c4c392cb8a47031402c215c31b3d67eafa5ad49 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 11 May 2018 14:41:21 +0200 Subject: [PATCH 0322/1150] Fixed enable/disable of the tooltips on GTK --- xs/src/slic3r/GUI/Field.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 0fcf480e31..4febae3621 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -183,14 +183,21 @@ namespace Slic3r { namespace GUI { //! to allow the default handling event.Skip(); //! eliminating the g-code pop up text description - temp->GetToolTip()->Enable(false); + bool flag = false; +#ifdef __WXGTK__ + // I have no idea why, but on GTK flag works in other way + flag = true; +#endif // __WXGTK__ + temp->GetToolTip()->Enable(flag); }), temp->GetId()); +#if !defined(__WXGTK__) temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e) { e.Skip();// on_kill_focus(e); temp->GetToolTip()->Enable(true); }), temp->GetId()); +#endif // __WXGTK__ temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent) { on_change_field(); }), temp->GetId()); From 613bcf80555ba5982797e31bed7bad9407ea8ae4 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 11 May 2018 15:41:26 +0200 Subject: [PATCH 0323/1150] Updated PrusaResearch.ini with the latest version from Slic3r-settings repository --- resources/profiles/PrusaResearch.idx | 2 ++ resources/profiles/PrusaResearch.ini | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/resources/profiles/PrusaResearch.idx b/resources/profiles/PrusaResearch.idx index f07d8b2806..e3b1e6ef54 100644 --- a/resources/profiles/PrusaResearch.idx +++ b/resources/profiles/PrusaResearch.idx @@ -1 +1,3 @@ +0.1.2 Wipe tower changes +0.1.1 Minor print speed adjustments 0.1.0 Initial diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 87950bae79..ba8e55ad41 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -5,7 +5,7 @@ name = Prusa Research # Configuration version of this file. Config file will only be installed, if the config_version differs. # This means, the server may force the Slic3r configuration to be downgraded. -config_version = 0.1.0 +config_version = 0.1.2 # Where to get the updates from? config_update_url = https://raw.githubusercontent.com/prusa3d/Slic3r-settings/master/live/PrusaResearch/ @@ -90,7 +90,7 @@ seam_position = nearest skirts = 1 skirt_distance = 2 skirt_height = 3 -small_perimeter_speed = 20 +small_perimeter_speed = 25 solid_infill_below_area = 0 solid_infill_every_layers = 0 solid_infill_extruder = 1 @@ -180,7 +180,7 @@ gap_fill_speed = 20 infill_acceleration = 800 infill_speed = 30 max_print_speed = 80 -small_perimeter_speed = 15 +small_perimeter_speed = 20 solid_infill_speed = 30 support_material_extrusion_width = 0.3 support_material_spacing = 1.5 @@ -215,7 +215,7 @@ infill_speed = 20 max_print_speed = 100 perimeter_extrusion_width = 0 perimeter_speed = 20 -small_perimeter_speed = 10 +small_perimeter_speed = 15 solid_infill_extrusion_width = 0 solid_infill_speed = 20 support_material_speed = 20 @@ -268,7 +268,7 @@ infill_acceleration = 1600 infill_speed = 40 perimeter_acceleration = 600 perimeter_speed = 25 -small_perimeter_speed = 10 +small_perimeter_speed = 15 solid_infill_speed = 40 top_solid_infill_speed = 30 @@ -341,7 +341,7 @@ infill_acceleration = 1600 infill_speed = 40 perimeter_acceleration = 600 perimeter_speed = 25 -small_perimeter_speed = 10 +small_perimeter_speed = 15 solid_infill_speed = 40 support_material_extrusion_width = 0.2 top_solid_infill_speed = 30 @@ -549,7 +549,7 @@ filament_diameter = 1.75 filament_notes = "" filament_settings_id = filament_soluble = 0 -min_print_speed = 5 +min_print_speed = 15 slowdown_below_layer_time = 20 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode" @@ -643,7 +643,6 @@ first_layer_bed_temperature = 105 first_layer_temperature = 270 max_fan_speed = 20 min_fan_speed = 10 -min_print_speed = 5 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode" temperature = 270 @@ -657,7 +656,6 @@ extrusion_multiplier = 1.2 filament_colour = #804040 filament_max_volumetric_speed = 10 first_layer_temperature = 200 -min_print_speed = 5 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" temperature = 200 @@ -823,7 +821,6 @@ first_layer_bed_temperature = 60 first_layer_temperature = 240 max_fan_speed = 5 min_fan_speed = 0 -min_print_speed = 5 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" temperature = 250 @@ -856,7 +853,6 @@ first_layer_bed_temperature = 60 first_layer_temperature = 215 max_fan_speed = 100 min_fan_speed = 100 -min_print_speed = 15 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" temperature = 210 @@ -877,7 +873,6 @@ first_layer_bed_temperature = 100 first_layer_temperature = 220 max_fan_speed = 100 min_fan_speed = 100 -min_print_speed = 15 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode" temperature = 220 @@ -938,11 +933,11 @@ retract_lift_below = 199 retract_restart_extra = 0 retract_restart_extra_toolchange = 0 retract_speed = 80 -single_extruder_multi_material = 1 -printer_model = MK2SMM parking_pos_retraction = 92 cooling_tube_length = 5 cooling_tube_retraction = 91.5 +single_extruder_multi_material = 1 +printer_model = MK2SMM [printer:*mm-single*] inherits = *multimaterial* From ae1a015494b0ac1d50f7931b71f09ba560e3a984 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 11 May 2018 16:03:07 +0200 Subject: [PATCH 0324/1150] Fixed Perl array addressing issues, leading to crashes when loading additional objects at the 3D path preview window. --- lib/Slic3r/GUI/Plater/3D.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index ced6fb82ea..c9c9542762 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -32,7 +32,7 @@ sub new { $self->{on_instances_moved} = sub {}; $self->{on_wipe_tower_moved} = sub {}; - $self->{objects_volumes_idxs} = (); + $self->{objects_volumes_idxs} = []; $self->on_select(sub { my ($volume_idx) = @_; @@ -188,8 +188,8 @@ sub update_volumes_selection { foreach my $obj_idx (0..$#{$self->{model}->objects}) { if ($self->{objects}[$obj_idx]->selected) { - my @volume_idxs = @{$self->{objects_volumes_idxs}[$obj_idx]}; - $self->select_volume($_) for @volume_idxs; + my $volume_idxs = $self->{objects_volumes_idxs}->[$obj_idx]; + $self->select_volume($_) for @{$volume_idxs}; } } } @@ -207,7 +207,7 @@ sub reload_scene { $self->{reload_delayed} = 0; - $self->{objects_volumes_idxs} = (); + $self->{objects_volumes_idxs} = []; foreach my $obj_idx (0..$#{$self->{model}->objects}) { my @volume_idxs = $self->load_object($self->{model}, $self->{print}, $obj_idx); push(@{$self->{objects_volumes_idxs}}, \@volume_idxs); From b6db3767a2dfca86cbf275e543da6ce00d035f91 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 11 May 2018 17:35:42 +0200 Subject: [PATCH 0325/1150] Bugfix: extruder temperature only changes when the temperature differs from the one last set (wipe tower) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 17 +++++++---------- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 80d4fdf074..f328d839f8 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -275,12 +275,9 @@ public: // Set extruder temperature, don't wait by default. Writer& set_extruder_temp(int temperature, bool wait = false) { - if (temperature != current_temp) { - char buf[128]; - sprintf(buf, "M%d S%d\n", wait ? 109 : 104, temperature); - m_gcode += buf; - current_temp = temperature; - } + char buf[128]; + sprintf(buf, "M%d S%d\n", wait ? 109 : 104, temperature); + m_gcode += buf; return *this; }; @@ -395,10 +392,8 @@ private: float m_wipe_tower_width = 0.f; float m_wipe_tower_depth = 0.f; float m_last_fan_speed = 0.f; - int current_temp = -1; - std::string - set_format_X(float x) + std::string set_format_X(float x) { char buf[64]; sprintf(buf, " X%.3f", x); @@ -810,8 +805,10 @@ void WipeTowerPrusaMM::toolchange_Unload( .travel(old_x, writer.y()) // in case previous move was shortened to limit feedrate .resume_preview(); - if (new_temperature != 0) // Set the extruder temperature, but don't wait. + if (new_temperature != 0 && new_temperature != m_old_temperature ) { // Set the extruder temperature, but don't wait. writer.set_extruder_temp(new_temperature, false); + m_old_temperature = new_temperature; + } // Cooling: const int& number_of_moves = m_filpar[m_current_tool].cooling_moves; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 6744aa917d..ea1c1f631e 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -196,6 +196,7 @@ private: float m_layer_height = 0.f; // Current layer height. size_t m_max_color_changes = 0; // Maximum number of color changes per layer. bool m_is_first_layer = false;// Is this the 1st layer of the print? If so, print the brim around the waste tower. + int m_old_temperature = -1; // To keep track of what was the last temp that we set (so we don't issue the command when not neccessary) // G-code generator parameters. float m_cooling_tube_retraction = 0.f; From 4cf74d6dcf6a4129915f71d79d59642ffd1981bb Mon Sep 17 00:00:00 2001 From: YuSanka Date: Sun, 13 May 2018 21:00:03 +0200 Subject: [PATCH 0326/1150] Object information is pasted to the ScrolledWindow --- lib/Slic3r/GUI/Plater.pm | 46 +++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 08c1065df7..eb655ae55a 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -225,7 +225,13 @@ sub new { $self->{btoolbar}->Add($self->{"btn_layer_editing"}); } - $self->{list} = Wx::ListView->new($self, -1, wxDefaultPosition, wxDefaultSize, + ### Scrolled Window for info boxes + my $scrolled_window_sizer = Wx::BoxSizer->new(wxVERTICAL); + my $scrolled_window_panel = Wx::ScrolledWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + $scrolled_window_panel->SetSizer($scrolled_window_sizer); + $scrolled_window_panel->SetScrollbars(1, 1, 1, 1); + + $self->{list} = Wx::ListView->new($scrolled_window_panel, -1, wxDefaultPosition, wxDefaultSize, wxLC_SINGLE_SEL | wxLC_REPORT | wxBORDER_SUNKEN | wxTAB_TRAVERSAL | wxWANTS_CHARS ); $self->{list}->InsertColumn(0, L("Name"), wxLIST_FORMAT_LEFT, 145); $self->{list}->InsertColumn(1, L("Copies"), wxLIST_FORMAT_CENTER, 45); @@ -405,12 +411,12 @@ sub new { my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxHORIZONTAL); Slic3r::GUI::add_frequently_changed_parameters($self, $frequently_changed_parameters_sizer, $presets); - + my $object_info_sizer; { - my $box = Wx::StaticBox->new($self, -1, L("Info")); + my $box = Wx::StaticBox->new($scrolled_window_panel, -1, L("Info")); $object_info_sizer = Wx::StaticBoxSizer->new($box, wxVERTICAL); - $object_info_sizer->SetMinSize([350,-1]); + $object_info_sizer->SetMinSize([300,-1]); my $grid_sizer = Wx::FlexGridSizer->new(3, 4, 5, 5); $grid_sizer->SetFlexibleDirection(wxHORIZONTAL); $grid_sizer->AddGrowableCol(1, 1); @@ -426,14 +432,14 @@ sub new { ); while (my $field = shift @info) { my $label = shift @info; - my $text = Wx::StaticText->new($self, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + my $text = Wx::StaticText->new($scrolled_window_panel, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); $text->SetFont($Slic3r::GUI::small_font); $grid_sizer->Add($text, 0); - $self->{"object_info_$field"} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + $self->{"object_info_$field"} = Wx::StaticText->new($scrolled_window_panel, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); $self->{"object_info_$field"}->SetFont($Slic3r::GUI::small_font); if ($field eq 'manifold') { - $self->{object_info_manifold_warning_icon} = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new(Slic3r::var("error.png"), wxBITMAP_TYPE_PNG)); + $self->{object_info_manifold_warning_icon} = Wx::StaticBitmap->new($scrolled_window_panel, -1, Wx::Bitmap->new(Slic3r::var("error.png"), wxBITMAP_TYPE_PNG)); $self->{object_info_manifold_warning_icon}->Hide; my $h_sizer = Wx::BoxSizer->new(wxHORIZONTAL); @@ -448,9 +454,9 @@ sub new { my $print_info_sizer; { - my $box = Wx::StaticBox->new($self, -1, L("Sliced Info")); + my $box = Wx::StaticBox->new($scrolled_window_panel, -1, L("Sliced Info")); $print_info_sizer = Wx::StaticBoxSizer->new($box, wxVERTICAL); - $print_info_sizer->SetMinSize([350,-1]); + $print_info_sizer->SetMinSize([300,-1]); my $grid_sizer = Wx::FlexGridSizer->new(2, 2, 5, 5); $grid_sizer->SetFlexibleDirection(wxHORIZONTAL); $grid_sizer->AddGrowableCol(1, 1); @@ -465,11 +471,11 @@ sub new { ); while (my $field = shift @info) { my $label = shift @info; - my $text = Wx::StaticText->new($self, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + my $text = Wx::StaticText->new($scrolled_window_panel, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); $text->SetFont($Slic3r::GUI::small_font); $grid_sizer->Add($text, 0); - $self->{"print_info_$field"} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + $self->{"print_info_$field"} = Wx::StaticText->new($scrolled_window_panel, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); $self->{"print_info_$field"}->SetFont($Slic3r::GUI::small_font); $grid_sizer->Add($self->{"print_info_$field"}, 0); } @@ -484,18 +490,24 @@ sub new { $buttons_sizer->Add($self->{btn_send_gcode}, 0, wxALIGN_RIGHT, 0); $buttons_sizer->Add($self->{btn_export_gcode}, 0, wxALIGN_RIGHT, 0); + $scrolled_window_sizer->Add($self->{list}, 1, wxEXPAND, 5); + $scrolled_window_sizer->Add($object_info_sizer, 0, wxEXPAND, 0); + $scrolled_window_sizer->Add($print_info_sizer, 0, wxEXPAND, 0); + my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; $right_sizer->Add($frequently_changed_parameters_sizer, 0, wxEXPAND | wxTOP, 0) if defined $frequently_changed_parameters_sizer; $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5); - $right_sizer->Add($self->{list}, 1, wxEXPAND, 5); - $right_sizer->Add($object_info_sizer, 0, wxEXPAND, 0); - $right_sizer->Add($print_info_sizer, 0, wxEXPAND, 0); + $right_sizer->Add($scrolled_window_panel, 1, wxEXPAND | wxALL, 1); # Callback for showing / hiding the print info box. $self->{"print_info_box_show"} = sub { - if ($right_sizer->IsShown(5) != $_[0]) { - $right_sizer->Show(5, $_[0]); - $self->Layout +# if ($right_sizer->IsShown(5) != $_[0]) { +# $right_sizer->Show(5, $_[0]); +# $self->Layout +# } + if ($scrolled_window_sizer->IsShown(2) != $_[0]) { + $scrolled_window_sizer->Show(2, $_[0]); + $scrolled_window_panel->Layout } }; # Show the box initially, let it be shown after the slicing is finished. From e90bc3fcabafb333bb6e7db8fe65e20f9ca6613d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 14 May 2018 09:00:19 +0200 Subject: [PATCH 0327/1150] Fix in _3DScene::_load_gcode_extrusion_paths::Helper::path_color() --- xs/src/slic3r/GUI/3DScene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 85018404c9..df8b1fbfc7 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -2204,7 +2204,7 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, return 0.0f; } - static const GCodePreviewData::Color path_color(const GCodePreviewData& data, const std::vector& tool_colors, float value) + static GCodePreviewData::Color path_color(const GCodePreviewData& data, const std::vector& tool_colors, float value) { switch (data.extrusion.view_type) { @@ -2220,7 +2220,7 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, return data.get_volumetric_rate_color(value); case GCodePreviewData::Extrusion::Tool: { - static GCodePreviewData::Color color; + GCodePreviewData::Color color; ::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + (unsigned int)value * 4), 4 * sizeof(float)); return color; } From 5fb81bacd526d8d460fb8eebe7d8aa464697c991 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 14 May 2018 09:54:38 +0200 Subject: [PATCH 0328/1150] Added layer index under sliders in 3D view --- lib/Slic3r/GUI/Plater/3DPreview.pm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index 9d8b822429..b746de98f4 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -58,6 +58,13 @@ sub new { [40,-1], wxALIGN_CENTRE_HORIZONTAL); $z_label_high->SetFont($Slic3r::GUI::small_font); + my $z_label_low_idx = $self->{z_label_low_idx} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, + [40,-1], wxALIGN_CENTRE_HORIZONTAL); + $z_label_low_idx->SetFont($Slic3r::GUI::small_font); + my $z_label_high_idx = $self->{z_label_high_idx} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, + [40,-1], wxALIGN_CENTRE_HORIZONTAL); + $z_label_high_idx->SetFont($Slic3r::GUI::small_font); + $self->single_layer(0); my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, L("1 Layer")); @@ -103,11 +110,13 @@ sub new { my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); my $vsizer = Wx::BoxSizer->new(wxVERTICAL); my $vsizer_outer = Wx::BoxSizer->new(wxVERTICAL); - $vsizer->Add($slider_low, 3, 0, 0); - $vsizer->Add($z_label_low, 0, 0, 0); + $vsizer->Add($slider_low, 3, wxALIGN_CENTER_HORIZONTAL, 0); + $vsizer->Add($z_label_low_idx, 0, wxALIGN_CENTER_HORIZONTAL, 0); + $vsizer->Add($z_label_low, 0, wxALIGN_CENTER_HORIZONTAL, 0); $hsizer->Add($vsizer, 0, wxEXPAND, 0); $vsizer = Wx::BoxSizer->new(wxVERTICAL); - $vsizer->Add($slider_high, 3, 0, 0); + $vsizer->Add($slider_high, 3, wxALIGN_CENTER_HORIZONTAL, 0); + $vsizer->Add($z_label_high_idx, 0, wxALIGN_CENTER_HORIZONTAL, 0); $vsizer->Add($z_label_high, 0, 0, 0); $hsizer->Add($vsizer, 0, wxEXPAND, 0); $vsizer_outer->Add($hsizer, 3, wxALIGN_CENTER_HORIZONTAL, 0); @@ -325,6 +334,8 @@ sub load_print { $self->slider_high->Hide; $self->{z_label_low}->SetLabel(""); $self->{z_label_high}->SetLabel(""); + $self->{z_label_low_idx}->SetLabel(""); + $self->{z_label_high_idx}->SetLabel(""); $self->canvas->reset_legend_texture(); $self->canvas->Refresh; # clears canvas return; @@ -427,6 +438,10 @@ sub set_z_range return if !$self->enabled; $self->{z_label_low}->SetLabel(sprintf '%.2f', $z_low); $self->{z_label_high}->SetLabel(sprintf '%.2f', $z_high); + my $z_idx_low = 1 + $self->slider_low->GetValue; + my $z_idx_high = 1 + $self->slider_high->GetValue; + $self->{z_label_low_idx}->SetLabel(sprintf '%d', $z_idx_low); + $self->{z_label_high_idx}->SetLabel(sprintf '%d', $z_idx_high); $self->canvas->set_toolpaths_range($z_low - 1e-6, $z_high + 1e-6); $self->canvas->Refresh if $self->IsShown; } From 1fd59144c7243b97f1e277bacb25ab5f080e6dc5 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 14 May 2018 11:31:58 +0200 Subject: [PATCH 0329/1150] Camera data moved to c++ - WIP --- lib/Slic3r/GUI/3DScene.pm | 193 ++++++++++++++++++------ xs/src/slic3r/GUI/3DScene.cpp | 5 + xs/src/slic3r/GUI/3DScene.hpp | 1 + xs/src/slic3r/GUI/GLCanvas3D.cpp | 19 +++ xs/src/slic3r/GUI/GLCanvas3D.hpp | 3 + xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 6 + xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 3 +- xs/xsp/GUI_3DScene.xsp | 10 +- 8 files changed, 190 insertions(+), 50 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 6cb5f398a5..6a2bec1ca2 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -46,7 +46,6 @@ __PACKAGE__->mk_accessors( qw(_quat init on_move on_model_update volumes - _sphi _stheta cutting_plane_z cut_lines_vertices bed_shape @@ -66,11 +65,6 @@ __PACKAGE__->mk_accessors( qw(_quat init _layer_height_edited - _camera_type - _camera_target - _camera_distance - _zoom - _legend_enabled _warning_enabled _apply_zoom_to_volumes_filter @@ -197,9 +191,15 @@ sub new { $self->{can_multisample} = $can_multisample; $self->background(1); $self->_quat((0, 0, 0, 1)); - $self->_stheta(45); - $self->_sphi(45); - $self->_zoom(1); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_camera_theta($self, 45.0); + Slic3r::GUI::_3DScene::set_camera_phi($self, 45.0); + Slic3r::GUI::_3DScene::set_camera_zoom($self, 1.0); + +# $self->_stheta(45); +# $self->_sphi(45); +# $self->_zoom(1); +#============================================================================================================================== $self->_legend_enabled(0); $self->_warning_enabled(0); $self->use_plain_shader(0); @@ -210,10 +210,16 @@ sub new { $self->volumes(Slic3r::GUI::_3DScene::GLVolume::Collection->new); # 3D point in model space - $self->_camera_type('ortho'); -# $self->_camera_type('perspective'); - $self->_camera_target(Slic3r::Pointf3->new(0,0,0)); - $self->_camera_distance(0.); +#============================================================================================================================== +# $self->_camera_type('ortho'); +## $self->_camera_type('perspective'); +#============================================================================================================================== +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_camera_target($self, Slic3r::Pointf3->new(0,0,0)); + Slic3r::GUI::_3DScene::set_camera_distance($self, 0.0); +# $self->_camera_target(Slic3r::Pointf3->new(0,0,0)); +# $self->_camera_distance(0.); +#============================================================================================================================== $self->layer_editing_enabled(0); $self->{layer_height_edit_band_width} = 2.; @@ -383,7 +389,11 @@ sub _variable_layer_thickness_bar_rect_screen { sub _variable_layer_thickness_bar_rect_viewport { my ($self) = @_; my ($cw, $ch) = $self->GetSizeWH; - return ((0.5*$cw-VARIABLE_LAYER_THICKNESS_BAR_WIDTH)/$self->_zoom, (-0.5*$ch+VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT)/$self->_zoom, $cw/(2*$self->_zoom), $ch/(2*$self->_zoom)); +#============================================================================================================================== + my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); + return ((0.5*$cw-VARIABLE_LAYER_THICKNESS_BAR_WIDTH)/$zoom, (-0.5*$ch+VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT)/$zoom, $cw/(2*$zoom), $ch/(2*$zoom)); +# return ((0.5*$cw-VARIABLE_LAYER_THICKNESS_BAR_WIDTH)/$self->_zoom, (-0.5*$ch+VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT)/$self->_zoom, $cw/(2*$self->_zoom), $ch/(2*$self->_zoom)); +#============================================================================================================================== } # Returns an array with (left, top, right, bottom) of the variable layer thickness bar on the screen. @@ -396,7 +406,11 @@ sub _variable_layer_thickness_reset_rect_screen { sub _variable_layer_thickness_reset_rect_viewport { my ($self) = @_; my ($cw, $ch) = $self->GetSizeWH; - return ((0.5*$cw-VARIABLE_LAYER_THICKNESS_BAR_WIDTH)/$self->_zoom, -$ch/(2*$self->_zoom), $cw/(2*$self->_zoom), (-0.5*$ch+VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT)/$self->_zoom); +#============================================================================================================================== + my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); + return ((0.5*$cw-VARIABLE_LAYER_THICKNESS_BAR_WIDTH)/$zoom, -$ch/(2*$zoom), $cw/(2*$zoom), (-0.5*$ch+VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT)/$zoom); +# return ((0.5*$cw-VARIABLE_LAYER_THICKNESS_BAR_WIDTH)/$self->_zoom, -$ch/(2*$self->_zoom), $cw/(2*$self->_zoom), (-0.5*$ch+VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT)/$self->_zoom); +#============================================================================================================================== } sub _variable_layer_thickness_bar_rect_mouse_inside { @@ -570,10 +584,17 @@ sub mouse_event { my $orig = $self->_drag_start_pos; if (TURNTABLE_MODE) { # Turntable mode is enabled by default. - $self->_sphi($self->_sphi + ($pos->x - $orig->x) * TRACKBALLSIZE); - $self->_stheta($self->_stheta - ($pos->y - $orig->y) * TRACKBALLSIZE); #- - $self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX; - $self->_stheta(0) if $self->_stheta < 0; +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_camera_phi($self, Slic3r::GUI::_3DScene::get_camera_phi($self) + ($pos->x - $orig->x) * TRACKBALLSIZE); + Slic3r::GUI::_3DScene::set_camera_theta($self, Slic3r::GUI::_3DScene::get_camera_theta($self) - ($pos->y - $orig->y) * TRACKBALLSIZE); + Slic3r::GUI::_3DScene::set_camera_theta($self, GIMBALL_LOCK_THETA_MAX) if Slic3r::GUI::_3DScene::get_camera_theta($self) > GIMBALL_LOCK_THETA_MAX; + Slic3r::GUI::_3DScene::set_camera_theta($self, 0) if Slic3r::GUI::_3DScene::get_camera_theta($self) < 0; + +# $self->_sphi($self->_sphi + ($pos->x - $orig->x) * TRACKBALLSIZE); +# $self->_stheta($self->_stheta - ($pos->y - $orig->y) * TRACKBALLSIZE); #- +# $self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX; +# $self->_stheta(0) if $self->_stheta < 0; +#============================================================================================================================== } else { my $size = $self->GetClientSize; my @quat = trackball( @@ -595,7 +616,12 @@ sub mouse_event { # get point in model space at Z = 0 my $cur_pos = $self->mouse_to_3d($e->GetX, $e->GetY, 0); my $orig = $self->mouse_to_3d($self->_drag_start_xy->x, $self->_drag_start_xy->y, 0); - $self->_camera_target->translate(@{$orig->vector_to($cur_pos)->negative}); +#============================================================================================================================== + my $camera_target = Slic3r::GUI::_3DScene::get_camera_target($self); + $camera_target->translate(@{$orig->vector_to($cur_pos)->negative}); + Slic3r::GUI::_3DScene::set_camera_target($self, $camera_target); +# $self->_camera_target->translate(@{$orig->vector_to($cur_pos)->negative}); +#============================================================================================================================== $self->on_viewport_changed->() if $self->on_viewport_changed; $self->Refresh; $self->Update; @@ -662,12 +688,18 @@ sub mouse_wheel_event { my $zoom = $e->GetWheelRotation() / $e->GetWheelDelta(); $zoom = max(min($zoom, 4), -4); $zoom /= 10; - $zoom = $self->_zoom / (1-$zoom); +#============================================================================================================================== + $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self) / (1-$zoom); +# $zoom = $self->_zoom / (1-$zoom); +#============================================================================================================================== # Don't allow to zoom too far outside the scene. my $zoom_min = $self->get_zoom_to_bounding_box_factor($self->max_bounding_box); $zoom_min *= 0.4 if defined $zoom_min; $zoom = $zoom_min if defined $zoom_min && $zoom < $zoom_min; - $self->_zoom($zoom); +#============================================================================================================================== + $zoom = Slic3r::GUI::_3DScene::set_camera_zoom($self, $zoom); +# $self->_zoom($zoom); +#============================================================================================================================== # # In order to zoom around the mouse point we need to translate # # the camera target @@ -712,10 +744,17 @@ sub reset_objects { sub set_viewport_from_scene { my ($self, $scene) = @_; - $self->_sphi($scene->_sphi); - $self->_stheta($scene->_stheta); - $self->_camera_target($scene->_camera_target); - $self->_zoom($scene->_zoom); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_camera_phi($self, Slic3r::GUI::_3DScene::get_camera_phi($scene)); + Slic3r::GUI::_3DScene::set_camera_theta($self, Slic3r::GUI::_3DScene::get_camera_theta($scene)); + Slic3r::GUI::_3DScene::set_camera_target($self, Slic3r::GUI::_3DScene::get_camera_target($scene)); + Slic3r::GUI::_3DScene::set_camera_zoom($self, Slic3r::GUI::_3DScene::get_camera_zoom($scene)); + +# $self->_sphi($scene->_sphi); +# $self->_stheta($scene->_stheta); +# $self->_camera_target($scene->_camera_target); +# $self->_zoom($scene->_zoom); +#============================================================================================================================== $self->_quat($scene->_quat); #============================================================================================================================== Slic3r::GUI::_3DScene::set_dirty($self, 1); @@ -749,11 +788,19 @@ sub select_view { } my $bb = $self->volumes_bounding_box; if (! $bb->empty) { - $self->_sphi($dirvec->[0]); - $self->_stheta($dirvec->[1]); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_camera_phi($self, $dirvec->[0]); + Slic3r::GUI::_3DScene::set_camera_theta($self, $dirvec->[1]); # Avoid gimball lock. - $self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX; - $self->_stheta(0) if $self->_stheta < 0; + Slic3r::GUI::_3DScene::set_camera_theta($self, GIMBALL_LOCK_THETA_MAX) if Slic3r::GUI::_3DScene::get_camera_theta($self) > GIMBALL_LOCK_THETA_MAX; + Slic3r::GUI::_3DScene::set_camera_theta($self, 0) if Slic3r::GUI::_3DScene::get_camera_theta($self) < 0; + +# $self->_sphi($dirvec->[0]); +# $self->_stheta($dirvec->[1]); +# # Avoid gimball lock. +# $self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX; +# $self->_stheta(0) if $self->_stheta < 0; +#============================================================================================================================== # View everything. $self->zoom_to_bounding_box($bb); $self->on_viewport_changed->() if $self->on_viewport_changed; @@ -775,22 +822,35 @@ sub get_zoom_to_bounding_box_factor { if (!TURNTABLE_MODE) { # Shift the perspective camera. - my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); +#============================================================================================================================== + my $camera_pos = Slic3r::Pointf3->new(0,0,-Slic3r::GUI::_3DScene::get_camera_distance($self)); +# my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); +#============================================================================================================================== glTranslatef(@$camera_pos); } if (TURNTABLE_MODE) { # Turntable mode is enabled by default. - glRotatef(-$self->_stheta, 1, 0, 0); # pitch - glRotatef($self->_sphi, 0, 0, 1); # yaw +#============================================================================================================================== + glRotatef(-Slic3r::GUI::_3DScene::get_camera_theta($self), 1, 0, 0); # pitch + glRotatef(Slic3r::GUI::_3DScene::get_camera_phi($self), 0, 0, 1); # yaw +# glRotatef(-$self->_stheta, 1, 0, 0); # pitch +# glRotatef($self->_sphi, 0, 0, 1); # yaw +#============================================================================================================================== } else { # Shift the perspective camera. - my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); +#============================================================================================================================== + my $camera_pos = Slic3r::Pointf3->new(0,0,-Slic3r::GUI::_3DScene::get_camera_distance($self)); +# my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); +#============================================================================================================================== glTranslatef(@$camera_pos); my @rotmat = quat_to_rotmatrix($self->quat); glMultMatrixd_p(@rotmat[0..15]); } - glTranslatef(@{ $self->_camera_target->negative }); +#============================================================================================================================== + glTranslatef(@{ Slic3r::GUI::_3DScene::get_camera_target($self)->negative }); +# glTranslatef(@{ $self->_camera_target->negative }); +#============================================================================================================================== # get the view matrix back from opengl my @matrix = glGetFloatv_p(GL_MODELVIEW_MATRIX); @@ -848,9 +908,15 @@ sub zoom_to_bounding_box { # Calculate the zoom factor needed to adjust viewport to bounding box. my $zoom = $self->get_zoom_to_bounding_box_factor($bb); if (defined $zoom) { - $self->_zoom($zoom); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_camera_zoom($self, $zoom); +# $self->_zoom($zoom); +#============================================================================================================================== # center view around bounding box center - $self->_camera_target($bb->center); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_camera_target($self, $bb->center); +# $self->_camera_target($bb->center); +#============================================================================================================================== $self->on_viewport_changed->() if $self->on_viewport_changed; #============================================================================================================================== $self->Resize($self->GetSizeWH) if Slic3r::GUI::_3DScene::is_shown_on_screen($self); @@ -1193,12 +1259,21 @@ sub Resize { $self->SetCurrent($self->GetContext); glViewport(0, 0, $x, $y); - $x /= $self->_zoom; - $y /= $self->_zoom; +#============================================================================================================================== + my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); + $x /= $zoom; + $y /= $zoom; +# $x /= $self->_zoom; +# $y /= $self->_zoom; +#============================================================================================================================== glMatrixMode(GL_PROJECTION); glLoadIdentity(); - if ($self->_camera_type eq 'ortho') { +#============================================================================================================================== + my $camera_type = Slic3r::GUI::_3DScene::get_camera_type_as_string($self); + if ($camera_type eq 'ortho') { +# if ($self->_camera_type eq 'ortho') { +#============================================================================================================================== #FIXME setting the size of the box 10x larger than necessary # is only a workaround for an incorrectly set camera. # This workaround harms Z-buffer accuracy! @@ -1209,12 +1284,18 @@ sub Resize { -$depth, $depth, ); } else { - die "Invalid camera type: ", $self->_camera_type, "\n" if ($self->_camera_type ne 'perspective'); +#============================================================================================================================== + die "Invalid camera type: ", $camera_type, "\n" if ($camera_type ne 'perspective'); +# die "Invalid camera type: ", $self->_camera_type, "\n" if ($self->_camera_type ne 'perspective'); +#============================================================================================================================== my $bbox_r = $self->max_bounding_box->radius(); my $fov = PI * 45. / 180.; my $fov_tan = tan(0.5 * $fov); my $cam_distance = 0.5 * $bbox_r / $fov_tan; - $self->_camera_distance($cam_distance); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_camera_distance($self, $cam_distance); +# $self->_camera_distance($cam_distance); +#============================================================================================================================== my $nr = $cam_distance - $bbox_r * 1.1; my $fr = $cam_distance + $bbox_r * 1.1; $nr = 1 if ($nr < 1); @@ -1344,19 +1425,29 @@ sub Render { if (!TURNTABLE_MODE) { # Shift the perspective camera. - my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); +#============================================================================================================================== + my $camera_pos = Slic3r::Pointf3->new(0,0,-Slic3r::GUI::_3DScene::get_camera_distance($self)); +# my $camera_pos = Slic3r::Pointf3->new(0,0,-$self->_camera_distance); +#============================================================================================================================== glTranslatef(@$camera_pos); } if (TURNTABLE_MODE) { # Turntable mode is enabled by default. - glRotatef(-$self->_stheta, 1, 0, 0); # pitch - glRotatef($self->_sphi, 0, 0, 1); # yaw +#============================================================================================================================== + glRotatef(-Slic3r::GUI::_3DScene::get_camera_theta($self), 1, 0, 0); # pitch + glRotatef(Slic3r::GUI::_3DScene::get_camera_phi($self), 0, 0, 1); # yaw +# glRotatef(-$self->_stheta, 1, 0, 0); # pitch +# glRotatef($self->_sphi, 0, 0, 1); # yaw +#============================================================================================================================== } else { my @rotmat = quat_to_rotmatrix($self->quat); glMultMatrixd_p(@rotmat[0..15]); } - glTranslatef(@{ $self->_camera_target->negative }); +#============================================================================================================================== + glTranslatef(@{ Slic3r::GUI::_3DScene::get_camera_target($self)->negative }); +# glTranslatef(@{ $self->_camera_target->negative }); +#============================================================================================================================== # light from above glLightfv_p(GL_LIGHT0, GL_POSITION, -0.5, -0.5, 1, 0); @@ -1745,8 +1836,14 @@ sub draw_active_object_annotations { # Paint the tooltip. if ($self->_variable_layer_thickness_load_overlay_image) { - my $gap = 10/$self->_zoom; - my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$self->_zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$self->_zoom + $gap, $reset_bottom + $gap); +#============================================================================================================================== + my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); + my $gap = 10/$zoom; + my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$zoom + $gap, $reset_bottom + $gap); + +# my $gap = 10/$self->_zoom; +# my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$self->_zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$self->_zoom + $gap, $reset_bottom + $gap); +#============================================================================================================================== $self->_render_image($self->{layer_preview_annotation}, $l, $r, $t, $b); } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index a6f26b5867..7603c9b843 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1767,6 +1767,11 @@ void _3DScene::set_camera_type(wxGLCanvas* canvas, unsigned int type) s_canvas_mgr.set_camera_type(canvas, type); } +std::string _3DScene::get_camera_type_as_string(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_camera_type_as_string(canvas); +} + float _3DScene::get_camera_zoom(wxGLCanvas* canvas) { return s_canvas_mgr.get_camera_zoom(canvas); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 46fbb02fb1..618b8ec348 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -549,6 +549,7 @@ public: static unsigned int get_camera_type(wxGLCanvas* canvas); static void set_camera_type(wxGLCanvas* canvas, unsigned int type); + static std::string get_camera_type_as_string(wxGLCanvas* canvas); static float get_camera_zoom(wxGLCanvas* canvas); static void set_camera_zoom(wxGLCanvas* canvas, float zoom); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 4074cdf78d..9e9f5e45a7 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -18,6 +18,20 @@ GLCanvas3D::Camera::Camera() { } +std::string GLCanvas3D::Camera::get_type_as_string() const +{ + switch (type) + { + default: + case CT_Unknown: + return "unknown"; + case CT_Perspective: + return "perspective"; + case CT_Ortho: + return "ortho"; + }; +} + GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) : m_canvas(canvas) , m_context(context) @@ -56,6 +70,11 @@ void GLCanvas3D::set_camera_type(GLCanvas3D::Camera::EType type) m_camera.type = type; } +std::string GLCanvas3D::get_camera_type_as_string() const +{ + return m_camera.get_type_as_string(); +} + float GLCanvas3D::get_camera_zoom() const { return m_camera.zoom; diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 1548702559..db8aa9d61c 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -31,6 +31,8 @@ public: Pointf3 target; Camera(); + + std::string get_type_as_string() const; }; private: @@ -52,6 +54,7 @@ public: Camera::EType get_camera_type() const; void set_camera_type(Camera::EType type); + std::string get_camera_type_as_string() const; float get_camera_zoom() const; void set_camera_zoom(float zoom); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index e27c6b7931..5a565be283 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -181,6 +181,12 @@ void GLCanvas3DManager::set_camera_type(wxGLCanvas* canvas, unsigned int type) it->second->set_camera_type((GLCanvas3D::Camera::EType)type); } +std::string GLCanvas3DManager::get_camera_type_as_string(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_camera_type_as_string() : "unknown"; +} + float GLCanvas3DManager::get_camera_zoom(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 3933fc9219..858c2d9e7b 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -59,7 +59,8 @@ public: unsigned int get_camera_type(wxGLCanvas* canvas) const; void set_camera_type(wxGLCanvas* canvas, unsigned int type); - + std::string get_camera_type_as_string(wxGLCanvas* canvas) const; + float get_camera_zoom(wxGLCanvas* canvas) const; void set_camera_zoom(wxGLCanvas* canvas, float zoom); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index c1bee85e83..c7933f0125 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -222,7 +222,15 @@ set_camera_type(canvas, type) unsigned int type; CODE: _3DScene::set_camera_type((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), type); - + +std::string +get_camera_type_as_string(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_camera_type_as_string((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + float get_camera_zoom(canvas) SV *canvas; From a73cb45792c95e52a46fe11e819f8ce15877492b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 14 May 2018 12:08:23 +0200 Subject: [PATCH 0330/1150] Camera angle clamping moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 9 +-- xs/src/slic3r/GUI/GLCanvas3D.cpp | 108 +++++++++++++++++++++++++------ xs/src/slic3r/GUI/GLCanvas3D.hpp | 34 ++++++++-- 3 files changed, 118 insertions(+), 33 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 6a2bec1ca2..a7de71d4d5 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -139,7 +139,9 @@ use constant MANIPULATION_IDLE => 0; use constant MANIPULATION_DRAGGING => 1; use constant MANIPULATION_LAYER_HEIGHT => 2; -use constant GIMBALL_LOCK_THETA_MAX => 180; +#============================================================================================================================== +#use constant GIMBALL_LOCK_THETA_MAX => 180; +#============================================================================================================================== use constant VARIABLE_LAYER_THICKNESS_BAR_WIDTH => 70; use constant VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT => 22; @@ -587,8 +589,6 @@ sub mouse_event { #============================================================================================================================== Slic3r::GUI::_3DScene::set_camera_phi($self, Slic3r::GUI::_3DScene::get_camera_phi($self) + ($pos->x - $orig->x) * TRACKBALLSIZE); Slic3r::GUI::_3DScene::set_camera_theta($self, Slic3r::GUI::_3DScene::get_camera_theta($self) - ($pos->y - $orig->y) * TRACKBALLSIZE); - Slic3r::GUI::_3DScene::set_camera_theta($self, GIMBALL_LOCK_THETA_MAX) if Slic3r::GUI::_3DScene::get_camera_theta($self) > GIMBALL_LOCK_THETA_MAX; - Slic3r::GUI::_3DScene::set_camera_theta($self, 0) if Slic3r::GUI::_3DScene::get_camera_theta($self) < 0; # $self->_sphi($self->_sphi + ($pos->x - $orig->x) * TRACKBALLSIZE); # $self->_stheta($self->_stheta - ($pos->y - $orig->y) * TRACKBALLSIZE); #- @@ -791,9 +791,6 @@ sub select_view { #============================================================================================================================== Slic3r::GUI::_3DScene::set_camera_phi($self, $dirvec->[0]); Slic3r::GUI::_3DScene::set_camera_theta($self, $dirvec->[1]); - # Avoid gimball lock. - Slic3r::GUI::_3DScene::set_camera_theta($self, GIMBALL_LOCK_THETA_MAX) if Slic3r::GUI::_3DScene::get_camera_theta($self) > GIMBALL_LOCK_THETA_MAX; - Slic3r::GUI::_3DScene::set_camera_theta($self, 0) if Slic3r::GUI::_3DScene::get_camera_theta($self) < 0; # $self->_sphi($dirvec->[0]); # $self->_stheta($dirvec->[1]); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 9e9f5e45a7..93186a8ab6 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -4,23 +4,34 @@ #include +static const float GIMBALL_LOCK_THETA_MAX = 180.0f; + namespace Slic3r { namespace GUI { GLCanvas3D::Camera::Camera() - : type(CT_Ortho) - , zoom(1.0f) - , phi(45.0f) - , theta(45.0f) - , distance(0.0f) - , target(0.0, 0.0, 0.0) - + : m_type(CT_Ortho) + , m_zoom(1.0f) + , m_phi(45.0f) + , m_theta(45.0f) + , m_distance(0.0f) + , m_target(0.0, 0.0, 0.0) { } +GLCanvas3D::Camera::EType GLCanvas3D::Camera::get_type() const +{ + return m_type; +} + +void GLCanvas3D::Camera::set_type(GLCanvas3D::Camera::EType type) +{ + m_type = type; +} + std::string GLCanvas3D::Camera::get_type_as_string() const { - switch (type) + switch (m_type) { default: case CT_Unknown: @@ -32,6 +43,63 @@ std::string GLCanvas3D::Camera::get_type_as_string() const }; } +float GLCanvas3D::Camera::get_zoom() const +{ + return m_zoom; +} + +void GLCanvas3D::Camera::set_zoom(float zoom) +{ + m_zoom = zoom; +} + +float GLCanvas3D::Camera::get_phi() const +{ + return m_phi; +} + +void GLCanvas3D::Camera::set_phi(float phi) +{ + m_phi = phi; +} + +float GLCanvas3D::Camera::get_theta() const +{ + return m_theta; +} + +void GLCanvas3D::Camera::set_theta(float theta) +{ + m_theta = theta; + + // clamp angle + if (m_theta > GIMBALL_LOCK_THETA_MAX) + m_theta = GIMBALL_LOCK_THETA_MAX; + + if (m_theta < 0.0f) + m_theta = 0.0f; +} + +float GLCanvas3D::Camera::get_distance() const +{ + return m_distance; +} + +void GLCanvas3D::Camera::set_distance(float distance) +{ + m_distance = distance; +} + +const Pointf3& GLCanvas3D::Camera::get_target() const +{ + return m_target; +} + +void GLCanvas3D::Camera::set_target(const Pointf3& target) +{ + m_target = target; +} + GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) : m_canvas(canvas) , m_context(context) @@ -62,12 +130,12 @@ bool GLCanvas3D::is_shown_on_screen() const GLCanvas3D::Camera::EType GLCanvas3D::get_camera_type() const { - return m_camera.type; + return m_camera.get_type(); } void GLCanvas3D::set_camera_type(GLCanvas3D::Camera::EType type) { - m_camera.type = type; + m_camera.set_type(type); } std::string GLCanvas3D::get_camera_type_as_string() const @@ -77,52 +145,52 @@ std::string GLCanvas3D::get_camera_type_as_string() const float GLCanvas3D::get_camera_zoom() const { - return m_camera.zoom; + return m_camera.get_zoom(); } void GLCanvas3D::set_camera_zoom(float zoom) { - m_camera.zoom = zoom; + m_camera.set_zoom(zoom); } float GLCanvas3D::get_camera_phi() const { - return m_camera.phi; + return m_camera.get_phi(); } void GLCanvas3D::set_camera_phi(float phi) { - m_camera.phi = phi; + m_camera.set_phi(phi); } float GLCanvas3D::get_camera_theta() const { - return m_camera.theta; + return m_camera.get_theta(); } void GLCanvas3D::set_camera_theta(float theta) { - m_camera.theta = theta; + m_camera.set_theta(theta); } float GLCanvas3D::get_camera_distance() const { - return m_camera.distance; + return m_camera.get_distance(); } void GLCanvas3D::set_camera_distance(float distance) { - m_camera.distance = distance; + m_camera.set_distance(distance); } const Pointf3& GLCanvas3D::get_camera_target() const { - return m_camera.target; + return m_camera.get_target(); } void GLCanvas3D::set_camera_target(const Pointf3& target) { - m_camera.target = target; + m_camera.set_target(target); } void GLCanvas3D::on_size(wxSizeEvent& evt) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index db8aa9d61c..14c1031dd0 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -13,8 +13,9 @@ namespace GUI { class GLCanvas3D { public: - struct Camera + class Camera { + public: enum EType : unsigned char { CT_Unknown, @@ -23,16 +24,35 @@ public: CT_Count }; - EType type; - float zoom; - float phi; - float theta; - float distance; - Pointf3 target; + private: + EType m_type; + float m_zoom; + float m_phi; + float m_theta; + float m_distance; + Pointf3 m_target; + public: Camera(); + Camera::EType get_type() const; + void set_type(Camera::EType type); std::string get_type_as_string() const; + + float get_zoom() const; + void set_zoom(float zoom); + + float get_phi() const; + void set_phi(float phi); + + float get_theta() const; + void set_theta(float theta); + + float get_distance() const; + void set_distance(float distance); + + const Pointf3& get_target() const; + void set_target(const Pointf3& target); }; private: From b07e16a3e7ed210c0dc297ed862f33ed938cb821 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Mon, 14 May 2018 21:14:33 +0930 Subject: [PATCH 0331/1150] Fix build failure (#884) --- Build.PL | 1 + 1 file changed, 1 insertion(+) diff --git a/Build.PL b/Build.PL index e006d11eb0..8f882fc4bb 100644 --- a/Build.PL +++ b/Build.PL @@ -12,6 +12,7 @@ my %prereqs = qw( ExtUtils::ParseXS 3.22 ExtUtils::XSpp 0 ExtUtils::Typemaps 0 + ExtUtils::Typemaps::Basic 0 File::Basename 0 File::Spec 0 Getopt::Long 0 From b51197b52cd0374b0cad9acee4fedf0e0900c5b9 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 14 May 2018 12:59:19 +0200 Subject: [PATCH 0332/1150] Updated POT-file, added Spanish and Polish, fixed bug with Ctrl+U,O,L in Italian --- resources/localization/Slic3rPE.pot | 1284 ++++---- resources/localization/es/Slic3rPE.mo | Bin 0 -> 108284 bytes resources/localization/es/Slic3rPE_es.po | 3512 ++++++++++++++++++++++ resources/localization/it/Slic3rPE.mo | Bin 106597 -> 106598 bytes resources/localization/it/Slic3rPE_it.po | 10 +- resources/localization/pl/Slic3rPE.mo | Bin 0 -> 106170 bytes resources/localization/pl/Slic3rPE_pl.po | 3511 +++++++++++++++++++++ xs/src/slic3r/GUI/Tab.cpp | 2 +- 8 files changed, 7676 insertions(+), 643 deletions(-) create mode 100644 resources/localization/es/Slic3rPE.mo create mode 100644 resources/localization/es/Slic3rPE_es.po create mode 100644 resources/localization/pl/Slic3rPE.mo create mode 100644 resources/localization/pl/Slic3rPE_pl.po diff --git a/resources/localization/Slic3rPE.pot b/resources/localization/Slic3rPE.pot index e4b9e25671..f4cfd15bd9 100644 --- a/resources/localization/Slic3rPE.pot +++ b/resources/localization/Slic3rPE.pot @@ -3,11 +3,12 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # +#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-05-02 15:27+0200\n" +"POT-Creation-Date: 2018-05-14 13:14+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -32,7 +33,7 @@ msgid "Rectangular" msgstr "" #: xs/src/slic3r/GUI/BedShapeDialog.cpp:50 xs/src/slic3r/GUI/Tab.cpp:1738 -#: lib/Slic3r/GUI/Plater.pm:421 +#: lib/Slic3r/GUI/Plater.pm:427 msgid "Size" msgstr "" @@ -55,33 +56,33 @@ msgid "Circular" msgstr "" #: xs/src/slic3r/GUI/BedShapeDialog.cpp:65 -#: xs/src/slic3r/GUI/ConfigWizard.cpp:85 -#: xs/src/slic3r/GUI/ConfigWizard.cpp:432 -#: xs/src/slic3r/GUI/ConfigWizard.cpp:446 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:87 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:434 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:448 #: xs/src/slic3r/GUI/RammingChart.cpp:86 #: xs/src/slic3r/GUI/WipeTowerDialog.cpp:84 -#: xs/src/libslic3r/PrintConfig.cpp:129 xs/src/libslic3r/PrintConfig.cpp:172 -#: xs/src/libslic3r/PrintConfig.cpp:180 xs/src/libslic3r/PrintConfig.cpp:228 -#: xs/src/libslic3r/PrintConfig.cpp:239 xs/src/libslic3r/PrintConfig.cpp:353 -#: xs/src/libslic3r/PrintConfig.cpp:364 xs/src/libslic3r/PrintConfig.cpp:383 -#: xs/src/libslic3r/PrintConfig.cpp:496 xs/src/libslic3r/PrintConfig.cpp:850 -#: xs/src/libslic3r/PrintConfig.cpp:870 xs/src/libslic3r/PrintConfig.cpp:878 -#: xs/src/libslic3r/PrintConfig.cpp:936 xs/src/libslic3r/PrintConfig.cpp:954 -#: xs/src/libslic3r/PrintConfig.cpp:972 xs/src/libslic3r/PrintConfig.cpp:1034 -#: xs/src/libslic3r/PrintConfig.cpp:1151 xs/src/libslic3r/PrintConfig.cpp:1159 -#: xs/src/libslic3r/PrintConfig.cpp:1201 xs/src/libslic3r/PrintConfig.cpp:1210 -#: xs/src/libslic3r/PrintConfig.cpp:1220 xs/src/libslic3r/PrintConfig.cpp:1228 -#: xs/src/libslic3r/PrintConfig.cpp:1236 xs/src/libslic3r/PrintConfig.cpp:1322 -#: xs/src/libslic3r/PrintConfig.cpp:1528 xs/src/libslic3r/PrintConfig.cpp:1598 -#: xs/src/libslic3r/PrintConfig.cpp:1632 xs/src/libslic3r/PrintConfig.cpp:1828 -#: xs/src/libslic3r/PrintConfig.cpp:1835 xs/src/libslic3r/PrintConfig.cpp:1842 -#: xs/src/libslic3r/PrintConfig.cpp:1856 xs/src/libslic3r/PrintConfig.cpp:1866 -#: xs/src/libslic3r/PrintConfig.cpp:1876 +#: xs/src/libslic3r/PrintConfig.cpp:130 xs/src/libslic3r/PrintConfig.cpp:173 +#: xs/src/libslic3r/PrintConfig.cpp:181 xs/src/libslic3r/PrintConfig.cpp:229 +#: xs/src/libslic3r/PrintConfig.cpp:240 xs/src/libslic3r/PrintConfig.cpp:354 +#: xs/src/libslic3r/PrintConfig.cpp:365 xs/src/libslic3r/PrintConfig.cpp:384 +#: xs/src/libslic3r/PrintConfig.cpp:497 xs/src/libslic3r/PrintConfig.cpp:851 +#: xs/src/libslic3r/PrintConfig.cpp:871 xs/src/libslic3r/PrintConfig.cpp:879 +#: xs/src/libslic3r/PrintConfig.cpp:937 xs/src/libslic3r/PrintConfig.cpp:955 +#: xs/src/libslic3r/PrintConfig.cpp:973 xs/src/libslic3r/PrintConfig.cpp:1035 +#: xs/src/libslic3r/PrintConfig.cpp:1152 xs/src/libslic3r/PrintConfig.cpp:1160 +#: xs/src/libslic3r/PrintConfig.cpp:1202 xs/src/libslic3r/PrintConfig.cpp:1211 +#: xs/src/libslic3r/PrintConfig.cpp:1221 xs/src/libslic3r/PrintConfig.cpp:1229 +#: xs/src/libslic3r/PrintConfig.cpp:1237 xs/src/libslic3r/PrintConfig.cpp:1323 +#: xs/src/libslic3r/PrintConfig.cpp:1529 xs/src/libslic3r/PrintConfig.cpp:1599 +#: xs/src/libslic3r/PrintConfig.cpp:1633 xs/src/libslic3r/PrintConfig.cpp:1829 +#: xs/src/libslic3r/PrintConfig.cpp:1836 xs/src/libslic3r/PrintConfig.cpp:1843 +#: xs/src/libslic3r/PrintConfig.cpp:1857 xs/src/libslic3r/PrintConfig.cpp:1867 +#: xs/src/libslic3r/PrintConfig.cpp:1877 msgid "mm" msgstr "" #: xs/src/slic3r/GUI/BedShapeDialog.cpp:66 -#: xs/src/libslic3r/PrintConfig.cpp:493 +#: xs/src/libslic3r/PrintConfig.cpp:494 msgid "Diameter" msgstr "" @@ -123,7 +124,7 @@ msgid "" msgstr "" #: xs/src/slic3r/GUI/BedShapeDialog.hpp:44 -#: xs/src/slic3r/GUI/ConfigWizard.cpp:395 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:397 msgid "Bed Shape" msgstr "" @@ -241,70 +242,70 @@ msgstr "" msgid "Activate" msgstr "" -#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:96 xs/src/slic3r/GUI/GUI.cpp:402 +#: xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp:96 xs/src/slic3r/GUI/GUI.cpp:397 msgid "Configuration Snapshots" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:85 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:87 msgid "nozzle" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:103 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:105 msgid "Select all" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:104 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:106 msgid "Select none" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:205 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:207 #, possible-c-format msgid "Welcome to the Slic3r %s" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:205 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:207 msgid "Welcome" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:211 xs/src/slic3r/GUI/GUI.cpp:399 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:213 xs/src/slic3r/GUI/GUI.cpp:394 #, possible-c-format msgid "Run %s" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:213 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:215 #, possible-c-format msgid "" "Hello, welcome to Slic3r Prusa Edition! This %s helps you with the initial " "configuration; just a few settings and you will be ready to print." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:217 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:219 msgid "" "Remove user profiles - install from scratch (a snapshot will be taken " "beforehand)" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:238 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:240 msgid "Other vendors" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:240 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:242 msgid "Custom setup" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:264 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:266 msgid "Automatic updates" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:264 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:266 msgid "Updates" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:272 xs/src/slic3r/GUI/Preferences.cpp:59 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:274 xs/src/slic3r/GUI/Preferences.cpp:59 msgid "Check for application updates" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:275 xs/src/slic3r/GUI/Preferences.cpp:61 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:277 xs/src/slic3r/GUI/Preferences.cpp:61 msgid "" "If enabled, Slic3r checks for new versions of Slic3r PE online. When a new " "version becomes available a notification is displayed at the next " @@ -312,11 +313,11 @@ msgid "" "notification mechanisms, no automatic installation is done." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:279 xs/src/slic3r/GUI/Preferences.cpp:67 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:281 xs/src/slic3r/GUI/Preferences.cpp:67 msgid "Update built-in Presets automatically" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:282 xs/src/slic3r/GUI/Preferences.cpp:69 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:284 xs/src/slic3r/GUI/Preferences.cpp:69 msgid "" "If enabled, Slic3r downloads updates of built-in system presets in the " "background. These updates are downloaded into a separate temporary location. " @@ -324,126 +325,126 @@ msgid "" "startup." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:283 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:285 msgid "" "Updates are never applied without user's consent and never overwrite user's " "customized settings." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:288 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:290 msgid "" "Additionally a backup snapshot of the whole configuration is created before " "an update is applied." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:295 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:297 msgid "Other Vendors" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:297 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:299 msgid "Pick another vendor supported by Slic3r PE:" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:356 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:358 msgid "Firmware Type" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:356 xs/src/slic3r/GUI/Tab.cpp:1625 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:358 xs/src/slic3r/GUI/Tab.cpp:1625 msgid "Firmware" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:360 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:362 msgid "Choose the type of firmware used by your printer." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:395 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:397 msgid "Bed Shape and Size" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:398 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:400 msgid "Set the shape of your printer's bed." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:412 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:414 msgid "Filament and Nozzle Diameters" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:412 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:414 msgid "Print Diameters" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:428 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:430 msgid "Enter the diameter of your printer's hot end nozzle." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:431 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:433 msgid "Nozzle Diameter:" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:441 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:443 msgid "Enter the diameter of your filament." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:442 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:444 msgid "" "Good precision is required, so use a caliper and do multiple measurements " "along the filament, then compute the average." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:445 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:447 msgid "Filament Diameter:" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:463 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:465 msgid "Extruder and Bed Temperatures" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:463 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:465 msgid "Temperatures" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:479 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:481 msgid "Enter the temperature needed for extruding your filament." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:480 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:482 msgid "A rule of thumb is 160 to 230 °C for PLA, and 215 to 250 °C for ABS." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:483 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:485 msgid "Extrusion Temperature:" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:484 -#: xs/src/slic3r/GUI/ConfigWizard.cpp:498 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:486 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:500 msgid "°C" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:493 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:495 msgid "" "Enter the bed temperature needed for getting your filament to stick to your " "heated bed." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:494 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:496 msgid "" "A rule of thumb is 60 °C for PLA and 110 °C for ABS. Leave zero if you have " "no heated bed." msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:497 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:499 msgid "Bed Temperature:" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:791 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:796 msgid "&Finish" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:844 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:852 msgid "Configuration Wizard" msgstr "" -#: xs/src/slic3r/GUI/ConfigWizard.cpp:846 +#: xs/src/slic3r/GUI/ConfigWizard.cpp:854 msgid "Configuration Assistant" msgstr "" @@ -459,122 +460,122 @@ msgstr "" msgid "Language" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:363 xs/src/libslic3r/PrintConfig.cpp:186 +#: xs/src/slic3r/GUI/GUI.cpp:358 xs/src/libslic3r/PrintConfig.cpp:187 msgid "Default" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:402 +#: xs/src/slic3r/GUI/GUI.cpp:397 msgid "Inspect / activate configuration snapshots" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:403 +#: xs/src/slic3r/GUI/GUI.cpp:398 msgid "Take Configuration Snapshot" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:403 +#: xs/src/slic3r/GUI/GUI.cpp:398 msgid "Capture a configuration snapshot" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:404 +#: xs/src/slic3r/GUI/GUI.cpp:399 msgid "Check for updates" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:404 +#: xs/src/slic3r/GUI/GUI.cpp:399 msgid "Check for configuration updates" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:406 xs/src/slic3r/GUI/Preferences.cpp:9 +#: xs/src/slic3r/GUI/GUI.cpp:401 xs/src/slic3r/GUI/Preferences.cpp:9 msgid "Preferences" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:406 +#: xs/src/slic3r/GUI/GUI.cpp:401 msgid "Application preferences" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:408 +#: xs/src/slic3r/GUI/GUI.cpp:403 msgid "Change Application Language" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:417 +#: xs/src/slic3r/GUI/GUI.cpp:412 msgid "Taking configuration snapshot" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:417 +#: xs/src/slic3r/GUI/GUI.cpp:412 msgid "Snapshot name" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:456 +#: xs/src/slic3r/GUI/GUI.cpp:451 msgid "Application will be restarted" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:456 +#: xs/src/slic3r/GUI/GUI.cpp:451 msgid "Attention!" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:466 +#: xs/src/slic3r/GUI/GUI.cpp:461 msgid "&Configuration" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:485 +#: xs/src/slic3r/GUI/GUI.cpp:480 msgid "You have unsaved changes " msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:485 +#: xs/src/slic3r/GUI/GUI.cpp:480 msgid ". Discard changes and continue anyway?" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:486 +#: xs/src/slic3r/GUI/GUI.cpp:481 msgid "Unsaved Presets" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:683 +#: xs/src/slic3r/GUI/GUI.cpp:678 msgid "Notice" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:688 +#: xs/src/slic3r/GUI/GUI.cpp:683 msgid "Attempt to free unreferenced scalar" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:690 xs/src/slic3r/GUI/WipeTowerDialog.cpp:44 +#: xs/src/slic3r/GUI/GUI.cpp:685 xs/src/slic3r/GUI/WipeTowerDialog.cpp:44 #: xs/src/slic3r/GUI/WipeTowerDialog.cpp:326 msgid "Warning" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:879 +#: xs/src/slic3r/GUI/GUI.cpp:874 msgid "Support" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:882 +#: xs/src/slic3r/GUI/GUI.cpp:877 msgid "Select what kind of support do you need" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:883 xs/src/libslic3r/GCode/PreviewData.cpp:157 +#: xs/src/slic3r/GUI/GUI.cpp:878 xs/src/libslic3r/GCode/PreviewData.cpp:157 msgid "None" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:884 xs/src/libslic3r/PrintConfig.cpp:1515 +#: xs/src/slic3r/GUI/GUI.cpp:879 xs/src/libslic3r/PrintConfig.cpp:1516 msgid "Support on build plate only" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:885 +#: xs/src/slic3r/GUI/GUI.cpp:880 msgid "Everywhere" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:897 xs/src/slic3r/GUI/Tab.cpp:869 +#: xs/src/slic3r/GUI/GUI.cpp:892 xs/src/slic3r/GUI/Tab.cpp:869 msgid "Brim" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:899 +#: xs/src/slic3r/GUI/GUI.cpp:894 msgid "" "This flag enables the brim that will be printed around each object on the " "first layer." msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:908 +#: xs/src/slic3r/GUI/GUI.cpp:903 msgid "Purging volumes" msgstr "" -#: xs/src/slic3r/GUI/GUI.cpp:950 +#: xs/src/slic3r/GUI/GUI.cpp:945 msgid "Export print config" msgstr "" @@ -645,7 +646,7 @@ msgstr "" msgid "Layers and perimeters" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:812 xs/src/libslic3r/PrintConfig.cpp:846 +#: xs/src/slic3r/GUI/Tab.cpp:812 xs/src/libslic3r/PrintConfig.cpp:847 msgid "Layer height" msgstr "" @@ -657,7 +658,7 @@ msgstr "" msgid "Horizontal shells" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:828 xs/src/libslic3r/PrintConfig.cpp:1421 +#: xs/src/slic3r/GUI/Tab.cpp:828 xs/src/libslic3r/PrintConfig.cpp:1422 msgid "Solid layers" msgstr "" @@ -668,19 +669,19 @@ msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:840 xs/src/slic3r/GUI/Tab.cpp:854 #: xs/src/slic3r/GUI/Tab.cpp:948 xs/src/slic3r/GUI/Tab.cpp:951 #: xs/src/slic3r/GUI/Tab.cpp:1300 xs/src/slic3r/GUI/Tab.cpp:1628 -#: xs/src/libslic3r/PrintConfig.cpp:107 xs/src/libslic3r/PrintConfig.cpp:236 -#: xs/src/libslic3r/PrintConfig.cpp:798 xs/src/libslic3r/PrintConfig.cpp:1862 +#: xs/src/libslic3r/PrintConfig.cpp:107 xs/src/libslic3r/PrintConfig.cpp:237 +#: xs/src/libslic3r/PrintConfig.cpp:799 xs/src/libslic3r/PrintConfig.cpp:1863 msgid "Advanced" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:844 xs/src/slic3r/GUI/Tab.cpp:845 #: xs/src/slic3r/GUI/Tab.cpp:1152 xs/src/libslic3r/PrintConfig.cpp:87 -#: xs/src/libslic3r/PrintConfig.cpp:275 xs/src/libslic3r/PrintConfig.cpp:550 -#: xs/src/libslic3r/PrintConfig.cpp:564 xs/src/libslic3r/PrintConfig.cpp:602 -#: xs/src/libslic3r/PrintConfig.cpp:743 xs/src/libslic3r/PrintConfig.cpp:753 -#: xs/src/libslic3r/PrintConfig.cpp:771 xs/src/libslic3r/PrintConfig.cpp:789 -#: xs/src/libslic3r/PrintConfig.cpp:808 xs/src/libslic3r/PrintConfig.cpp:1370 -#: xs/src/libslic3r/PrintConfig.cpp:1387 +#: xs/src/libslic3r/PrintConfig.cpp:276 xs/src/libslic3r/PrintConfig.cpp:551 +#: xs/src/libslic3r/PrintConfig.cpp:565 xs/src/libslic3r/PrintConfig.cpp:603 +#: xs/src/libslic3r/PrintConfig.cpp:744 xs/src/libslic3r/PrintConfig.cpp:754 +#: xs/src/libslic3r/PrintConfig.cpp:772 xs/src/libslic3r/PrintConfig.cpp:790 +#: xs/src/libslic3r/PrintConfig.cpp:809 xs/src/libslic3r/PrintConfig.cpp:1371 +#: xs/src/libslic3r/PrintConfig.cpp:1388 msgid "Infill" msgstr "" @@ -698,16 +699,16 @@ msgid "Skirt" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:872 xs/src/slic3r/GUI/Tab.cpp:873 -#: xs/src/libslic3r/PrintConfig.cpp:219 xs/src/libslic3r/PrintConfig.cpp:1137 -#: xs/src/libslic3r/PrintConfig.cpp:1487 xs/src/libslic3r/PrintConfig.cpp:1494 -#: xs/src/libslic3r/PrintConfig.cpp:1506 xs/src/libslic3r/PrintConfig.cpp:1516 -#: xs/src/libslic3r/PrintConfig.cpp:1524 xs/src/libslic3r/PrintConfig.cpp:1539 -#: xs/src/libslic3r/PrintConfig.cpp:1560 xs/src/libslic3r/PrintConfig.cpp:1571 -#: xs/src/libslic3r/PrintConfig.cpp:1587 xs/src/libslic3r/PrintConfig.cpp:1596 -#: xs/src/libslic3r/PrintConfig.cpp:1605 xs/src/libslic3r/PrintConfig.cpp:1616 -#: xs/src/libslic3r/PrintConfig.cpp:1630 xs/src/libslic3r/PrintConfig.cpp:1638 -#: xs/src/libslic3r/PrintConfig.cpp:1639 xs/src/libslic3r/PrintConfig.cpp:1648 -#: xs/src/libslic3r/PrintConfig.cpp:1656 xs/src/libslic3r/PrintConfig.cpp:1670 +#: xs/src/libslic3r/PrintConfig.cpp:220 xs/src/libslic3r/PrintConfig.cpp:1138 +#: xs/src/libslic3r/PrintConfig.cpp:1488 xs/src/libslic3r/PrintConfig.cpp:1495 +#: xs/src/libslic3r/PrintConfig.cpp:1507 xs/src/libslic3r/PrintConfig.cpp:1517 +#: xs/src/libslic3r/PrintConfig.cpp:1525 xs/src/libslic3r/PrintConfig.cpp:1540 +#: xs/src/libslic3r/PrintConfig.cpp:1561 xs/src/libslic3r/PrintConfig.cpp:1572 +#: xs/src/libslic3r/PrintConfig.cpp:1588 xs/src/libslic3r/PrintConfig.cpp:1597 +#: xs/src/libslic3r/PrintConfig.cpp:1606 xs/src/libslic3r/PrintConfig.cpp:1617 +#: xs/src/libslic3r/PrintConfig.cpp:1631 xs/src/libslic3r/PrintConfig.cpp:1639 +#: xs/src/libslic3r/PrintConfig.cpp:1640 xs/src/libslic3r/PrintConfig.cpp:1649 +#: xs/src/libslic3r/PrintConfig.cpp:1657 xs/src/libslic3r/PrintConfig.cpp:1671 #: xs/src/libslic3r/GCode/PreviewData.cpp:167 #: lib/Slic3r/GUI/Plater/3DPreview.pm:92 msgid "Support material" @@ -721,11 +722,11 @@ msgstr "" msgid "Options for support material and raft" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:896 xs/src/libslic3r/PrintConfig.cpp:118 -#: xs/src/libslic3r/PrintConfig.cpp:306 xs/src/libslic3r/PrintConfig.cpp:697 -#: xs/src/libslic3r/PrintConfig.cpp:809 xs/src/libslic3r/PrintConfig.cpp:1071 -#: xs/src/libslic3r/PrintConfig.cpp:1308 xs/src/libslic3r/PrintConfig.cpp:1358 -#: xs/src/libslic3r/PrintConfig.cpp:1409 xs/src/libslic3r/PrintConfig.cpp:1730 +#: xs/src/slic3r/GUI/Tab.cpp:896 xs/src/libslic3r/PrintConfig.cpp:119 +#: xs/src/libslic3r/PrintConfig.cpp:307 xs/src/libslic3r/PrintConfig.cpp:698 +#: xs/src/libslic3r/PrintConfig.cpp:810 xs/src/libslic3r/PrintConfig.cpp:1072 +#: xs/src/libslic3r/PrintConfig.cpp:1309 xs/src/libslic3r/PrintConfig.cpp:1359 +#: xs/src/libslic3r/PrintConfig.cpp:1410 xs/src/libslic3r/PrintConfig.cpp:1731 #: lib/Slic3r/GUI/Plater/3DPreview.pm:70 msgid "Speed" msgstr "" @@ -755,9 +756,9 @@ msgid "Multiple Extruders" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:929 xs/src/slic3r/GUI/Tab.cpp:1470 -#: xs/src/libslic3r/PrintConfig.cpp:336 xs/src/libslic3r/PrintConfig.cpp:764 -#: xs/src/libslic3r/PrintConfig.cpp:1050 xs/src/libslic3r/PrintConfig.cpp:1379 -#: xs/src/libslic3r/PrintConfig.cpp:1552 xs/src/libslic3r/PrintConfig.cpp:1578 +#: xs/src/libslic3r/PrintConfig.cpp:337 xs/src/libslic3r/PrintConfig.cpp:765 +#: xs/src/libslic3r/PrintConfig.cpp:1051 xs/src/libslic3r/PrintConfig.cpp:1380 +#: xs/src/libslic3r/PrintConfig.cpp:1553 xs/src/libslic3r/PrintConfig.cpp:1579 msgid "Extruders" msgstr "" @@ -802,7 +803,7 @@ msgstr "" msgid "Output file" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:993 xs/src/libslic3r/PrintConfig.cpp:1093 +#: xs/src/slic3r/GUI/Tab.cpp:993 xs/src/libslic3r/PrintConfig.cpp:1094 msgid "Post-processing scripts" msgstr "" @@ -823,12 +824,12 @@ msgid "Profile dependencies" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1008 xs/src/slic3r/GUI/Tab.cpp:1359 -#: xs/src/slic3r/GUI/Tab.cpp:2241 xs/src/libslic3r/PrintConfig.cpp:143 +#: xs/src/slic3r/GUI/Tab.cpp:2241 xs/src/libslic3r/PrintConfig.cpp:144 msgid "Compatible printers" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1041 -#, no-c-format +#, possible-c-format msgid "" "The Spiral Vase mode requires:\n" "- one perimeter\n" @@ -884,7 +885,7 @@ msgid "The " msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1150 -#, no-c-format +#, possible-c-format msgid "" " infill pattern is not supposed to work at 100% density.\n" "\n" @@ -892,7 +893,7 @@ msgid "" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1255 xs/src/slic3r/GUI/Tab.cpp:1256 -#: lib/Slic3r/GUI/Plater.pm:378 +#: lib/Slic3r/GUI/Plater.pm:384 msgid "Filament" msgstr "" @@ -900,7 +901,7 @@ msgstr "" msgid "Temperature " msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1264 xs/src/libslic3r/PrintConfig.cpp:335 +#: xs/src/slic3r/GUI/Tab.cpp:1264 xs/src/libslic3r/PrintConfig.cpp:336 msgid "Extruder" msgstr "" @@ -912,8 +913,8 @@ msgstr "" msgid "Cooling" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1275 xs/src/libslic3r/PrintConfig.cpp:1005 -#: xs/src/libslic3r/PrintConfig.cpp:1800 +#: xs/src/slic3r/GUI/Tab.cpp:1275 xs/src/libslic3r/PrintConfig.cpp:1006 +#: xs/src/libslic3r/PrintConfig.cpp:1801 msgid "Enable" msgstr "" @@ -938,7 +939,7 @@ msgid "Print speed override" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1315 -msgid "Toolchange behaviour" +msgid "Toolchange parameters with single extruder MM printers" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1319 @@ -954,12 +955,12 @@ msgid "Custom G-code" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1337 xs/src/slic3r/GUI/Tab.cpp:1635 -#: xs/src/libslic3r/PrintConfig.cpp:1449 xs/src/libslic3r/PrintConfig.cpp:1464 +#: xs/src/libslic3r/PrintConfig.cpp:1450 xs/src/libslic3r/PrintConfig.cpp:1465 msgid "Start G-code" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1343 xs/src/slic3r/GUI/Tab.cpp:1641 -#: xs/src/libslic3r/PrintConfig.cpp:245 xs/src/libslic3r/PrintConfig.cpp:255 +#: xs/src/libslic3r/PrintConfig.cpp:246 xs/src/libslic3r/PrintConfig.cpp:256 msgid "End G-code" msgstr "" @@ -991,7 +992,7 @@ msgstr "" msgid "USB/Serial connection" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1497 xs/src/libslic3r/PrintConfig.cpp:1300 +#: xs/src/slic3r/GUI/Tab.cpp:1497 xs/src/libslic3r/PrintConfig.cpp:1301 msgid "Serial port" msgstr "" @@ -1053,11 +1054,11 @@ msgstr "" msgid "Before layer change G-code" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1653 xs/src/libslic3r/PrintConfig.cpp:835 +#: xs/src/slic3r/GUI/Tab.cpp:1653 xs/src/libslic3r/PrintConfig.cpp:836 msgid "After layer change G-code" msgstr "" -#: xs/src/slic3r/GUI/Tab.cpp:1659 xs/src/libslic3r/PrintConfig.cpp:1707 +#: xs/src/slic3r/GUI/Tab.cpp:1659 xs/src/libslic3r/PrintConfig.cpp:1708 msgid "Tool change G-code" msgstr "" @@ -1101,7 +1102,7 @@ msgid "" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:1769 lib/Slic3r/GUI/Plater.pm:160 -#: lib/Slic3r/GUI/Plater.pm:2154 +#: lib/Slic3r/GUI/Plater.pm:2173 msgid "Preview" msgstr "" @@ -1169,7 +1170,7 @@ msgid "Cannot overwrite a system profile." msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:2128 -msgid "Cannot overwrite an external." +msgid "Cannot overwrite an external profile." msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:2152 @@ -1193,7 +1194,7 @@ msgid "Remove" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:2154 lib/Slic3r/GUI/Plater.pm:188 -#: lib/Slic3r/GUI/Plater.pm:206 lib/Slic3r/GUI/Plater.pm:2050 +#: lib/Slic3r/GUI/Plater.pm:206 lib/Slic3r/GUI/Plater.pm:2069 msgid "Delete" msgstr "" @@ -1212,8 +1213,8 @@ msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:2286 xs/src/slic3r/GUI/Tab.cpp:2372 #: xs/src/slic3r/GUI/Preset.cpp:605 xs/src/slic3r/GUI/Preset.cpp:645 #: xs/src/slic3r/GUI/Preset.cpp:670 xs/src/slic3r/GUI/Preset.cpp:702 -#: xs/src/slic3r/GUI/PresetBundle.cpp:1069 -#: xs/src/slic3r/GUI/PresetBundle.cpp:1122 lib/Slic3r/GUI/Plater.pm:552 +#: xs/src/slic3r/GUI/PresetBundle.cpp:1068 +#: xs/src/slic3r/GUI/PresetBundle.cpp:1121 lib/Slic3r/GUI/Plater.pm:564 msgid "System presets" msgstr "" @@ -1306,7 +1307,7 @@ msgid "" msgstr "" #: xs/src/slic3r/GUI/Tab.cpp:2575 lib/Slic3r/GUI/MainFrame.pm:445 -#: lib/Slic3r/GUI/Plater.pm:1660 +#: lib/Slic3r/GUI/Plater.pm:1672 msgid "Save " msgstr "" @@ -1343,8 +1344,17 @@ msgstr "" msgid "default" msgstr "" +#: xs/src/slic3r/GUI/Field.cpp:102 +#, possible-c-format +msgid "%s doesn't support percentage" +msgstr "" + +#: xs/src/slic3r/GUI/Field.cpp:111 +msgid "Input value is out of range" +msgstr "" + #: xs/src/slic3r/GUI/Preset.cpp:649 xs/src/slic3r/GUI/Preset.cpp:706 -#: xs/src/slic3r/GUI/PresetBundle.cpp:1127 lib/Slic3r/GUI/Plater.pm:553 +#: xs/src/slic3r/GUI/PresetBundle.cpp:1126 lib/Slic3r/GUI/Plater.pm:565 msgid "User presets" msgstr "" @@ -1560,7 +1570,7 @@ msgstr "" #: xs/src/slic3r/GUI/RammingChart.cpp:81 xs/src/slic3r/GUI/RammingChart.cpp:86 #: xs/src/slic3r/GUI/WipeTowerDialog.cpp:82 -#: xs/src/libslic3r/PrintConfig.cpp:480 +#: xs/src/libslic3r/PrintConfig.cpp:481 msgid "s" msgstr "" @@ -1763,7 +1773,7 @@ msgstr "" msgid "Error while uploading to the OctoPrint server" msgstr "" -#: xs/src/slic3r/Utils/OctoPrint.cpp:51 lib/Slic3r/GUI/Plater.pm:1493 +#: xs/src/slic3r/Utils/OctoPrint.cpp:51 lib/Slic3r/GUI/Plater.pm:1505 msgid "Sending G-code file to the OctoPrint server..." msgstr "" @@ -1782,7 +1792,7 @@ msgid "" "feature slows down both the print and the G-code generation." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:38 xs/src/libslic3r/PrintConfig.cpp:1677 +#: xs/src/libslic3r/PrintConfig.cpp:38 xs/src/libslic3r/PrintConfig.cpp:1678 msgid "Other layers" msgstr "" @@ -1821,12 +1831,12 @@ msgstr "" msgid "Bottom" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:69 xs/src/libslic3r/PrintConfig.cpp:267 -#: xs/src/libslic3r/PrintConfig.cpp:318 xs/src/libslic3r/PrintConfig.cpp:326 -#: xs/src/libslic3r/PrintConfig.cpp:666 xs/src/libslic3r/PrintConfig.cpp:831 -#: xs/src/libslic3r/PrintConfig.cpp:847 xs/src/libslic3r/PrintConfig.cpp:1024 -#: xs/src/libslic3r/PrintConfig.cpp:1081 xs/src/libslic3r/PrintConfig.cpp:1259 -#: xs/src/libslic3r/PrintConfig.cpp:1688 xs/src/libslic3r/PrintConfig.cpp:1744 +#: xs/src/libslic3r/PrintConfig.cpp:69 xs/src/libslic3r/PrintConfig.cpp:268 +#: xs/src/libslic3r/PrintConfig.cpp:319 xs/src/libslic3r/PrintConfig.cpp:327 +#: xs/src/libslic3r/PrintConfig.cpp:667 xs/src/libslic3r/PrintConfig.cpp:832 +#: xs/src/libslic3r/PrintConfig.cpp:848 xs/src/libslic3r/PrintConfig.cpp:1025 +#: xs/src/libslic3r/PrintConfig.cpp:1082 xs/src/libslic3r/PrintConfig.cpp:1260 +#: xs/src/libslic3r/PrintConfig.cpp:1689 xs/src/libslic3r/PrintConfig.cpp:1745 msgid "Layers and Perimeters" msgstr "" @@ -1848,9 +1858,9 @@ msgid "" "disable acceleration control for bridges." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:80 xs/src/libslic3r/PrintConfig.cpp:190 -#: xs/src/libslic3r/PrintConfig.cpp:638 xs/src/libslic3r/PrintConfig.cpp:746 -#: xs/src/libslic3r/PrintConfig.cpp:1044 +#: xs/src/libslic3r/PrintConfig.cpp:80 xs/src/libslic3r/PrintConfig.cpp:191 +#: xs/src/libslic3r/PrintConfig.cpp:639 xs/src/libslic3r/PrintConfig.cpp:747 +#: xs/src/libslic3r/PrintConfig.cpp:1045 msgid "mm/s²" msgstr "" @@ -1865,9 +1875,9 @@ msgid "" "bridges. Use 180° for zero angle." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:91 xs/src/libslic3r/PrintConfig.cpp:554 -#: xs/src/libslic3r/PrintConfig.cpp:1277 xs/src/libslic3r/PrintConfig.cpp:1288 -#: xs/src/libslic3r/PrintConfig.cpp:1508 xs/src/libslic3r/PrintConfig.cpp:1662 +#: xs/src/libslic3r/PrintConfig.cpp:91 xs/src/libslic3r/PrintConfig.cpp:555 +#: xs/src/libslic3r/PrintConfig.cpp:1278 xs/src/libslic3r/PrintConfig.cpp:1289 +#: xs/src/libslic3r/PrintConfig.cpp:1509 xs/src/libslic3r/PrintConfig.cpp:1663 msgid "°" msgstr "" @@ -1879,9 +1889,9 @@ msgstr "" msgid "This fan speed is enforced during all bridges and overhangs." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:99 xs/src/libslic3r/PrintConfig.cpp:566 -#: xs/src/libslic3r/PrintConfig.cpp:858 xs/src/libslic3r/PrintConfig.cpp:926 -#: xs/src/libslic3r/PrintConfig.cpp:1167 +#: xs/src/libslic3r/PrintConfig.cpp:99 xs/src/libslic3r/PrintConfig.cpp:567 +#: xs/src/libslic3r/PrintConfig.cpp:859 xs/src/libslic3r/PrintConfig.cpp:927 +#: xs/src/libslic3r/PrintConfig.cpp:1168 msgid "%" msgstr "" @@ -1897,60 +1907,60 @@ msgid "" "before tweaking this." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:117 +#: xs/src/libslic3r/PrintConfig.cpp:118 msgid "Bridges" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:119 +#: xs/src/libslic3r/PrintConfig.cpp:120 msgid "Speed for printing bridges." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:120 xs/src/libslic3r/PrintConfig.cpp:461 -#: xs/src/libslic3r/PrintConfig.cpp:470 xs/src/libslic3r/PrintConfig.cpp:700 -#: xs/src/libslic3r/PrintConfig.cpp:811 xs/src/libslic3r/PrintConfig.cpp:887 -#: xs/src/libslic3r/PrintConfig.cpp:944 xs/src/libslic3r/PrintConfig.cpp:1073 -#: xs/src/libslic3r/PrintConfig.cpp:1244 xs/src/libslic3r/PrintConfig.cpp:1253 -#: xs/src/libslic3r/PrintConfig.cpp:1641 xs/src/libslic3r/PrintConfig.cpp:1754 +#: xs/src/libslic3r/PrintConfig.cpp:121 xs/src/libslic3r/PrintConfig.cpp:462 +#: xs/src/libslic3r/PrintConfig.cpp:471 xs/src/libslic3r/PrintConfig.cpp:701 +#: xs/src/libslic3r/PrintConfig.cpp:812 xs/src/libslic3r/PrintConfig.cpp:888 +#: xs/src/libslic3r/PrintConfig.cpp:945 xs/src/libslic3r/PrintConfig.cpp:1074 +#: xs/src/libslic3r/PrintConfig.cpp:1245 xs/src/libslic3r/PrintConfig.cpp:1254 +#: xs/src/libslic3r/PrintConfig.cpp:1642 xs/src/libslic3r/PrintConfig.cpp:1755 msgid "mm/s" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:127 +#: xs/src/libslic3r/PrintConfig.cpp:128 msgid "Brim width" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:128 +#: xs/src/libslic3r/PrintConfig.cpp:129 msgid "" "Horizontal width of the brim that will be printed around each object on the " "first layer." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:135 +#: xs/src/libslic3r/PrintConfig.cpp:136 msgid "Clip multi-part objects" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:136 +#: xs/src/libslic3r/PrintConfig.cpp:137 msgid "" "When printing multi-material objects, this settings will make slic3r to clip " "the overlapping object parts one by the other (2nd part will be clipped by " "the 1st, 3rd part will be clipped by the 1st and 2nd etc)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:147 +#: xs/src/libslic3r/PrintConfig.cpp:148 msgid "Compatible printers condition" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:148 +#: xs/src/libslic3r/PrintConfig.cpp:149 msgid "" "A boolean expression using the configuration values of an active printer " "profile. If this expression evaluates to true, this profile is considered " "compatible with the active printer profile." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:154 +#: xs/src/libslic3r/PrintConfig.cpp:155 msgid "Complete individual objects" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:155 +#: xs/src/libslic3r/PrintConfig.cpp:156 msgid "" "When printing multiple objects or copies, this feature will complete each " "object before moving onto next one (and starting it from its bottom layer). " @@ -1958,113 +1968,113 @@ msgid "" "warn and prevent you from extruder collisions, but beware." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:163 +#: xs/src/libslic3r/PrintConfig.cpp:164 msgid "Enable auto cooling" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:164 +#: xs/src/libslic3r/PrintConfig.cpp:165 msgid "" "This flag enables the automatic cooling logic that adjusts print speed and " "fan speed according to layer printing time." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:170 +#: xs/src/libslic3r/PrintConfig.cpp:171 msgid "Cooling tube position" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:171 +#: xs/src/libslic3r/PrintConfig.cpp:172 msgid "Distance of the center-point of the cooling tube from the extruder tip " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:178 +#: xs/src/libslic3r/PrintConfig.cpp:179 msgid "Cooling tube length" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:179 +#: xs/src/libslic3r/PrintConfig.cpp:180 msgid "Length of the cooling tube to limit space for cooling moves inside it " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:187 +#: xs/src/libslic3r/PrintConfig.cpp:188 msgid "" "This is the acceleration your printer will be reset to after the role-" "specific acceleration values are used (perimeter/infill). Set zero to " "prevent resetting acceleration at all." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:196 +#: xs/src/libslic3r/PrintConfig.cpp:197 msgid "Default filament profile" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:197 +#: xs/src/libslic3r/PrintConfig.cpp:198 msgid "" "Default filament profile associated with the current printer profile. On " "selection of the current printer profile, this filament profile will be " "activated." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:202 +#: xs/src/libslic3r/PrintConfig.cpp:203 msgid "Default print profile" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:203 +#: xs/src/libslic3r/PrintConfig.cpp:204 msgid "" "Default print profile associated with the current printer profile. On " "selection of the current printer profile, this print profile will be " "activated." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:208 +#: xs/src/libslic3r/PrintConfig.cpp:209 msgid "Disable fan for the first" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:209 +#: xs/src/libslic3r/PrintConfig.cpp:210 msgid "" "You can set this to a positive value to disable fan at all during the first " "layers, so that it does not make adhesion worse." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:211 xs/src/libslic3r/PrintConfig.cpp:756 -#: xs/src/libslic3r/PrintConfig.cpp:1140 xs/src/libslic3r/PrintConfig.cpp:1331 -#: xs/src/libslic3r/PrintConfig.cpp:1392 xs/src/libslic3r/PrintConfig.cpp:1544 -#: xs/src/libslic3r/PrintConfig.cpp:1589 +#: xs/src/libslic3r/PrintConfig.cpp:212 xs/src/libslic3r/PrintConfig.cpp:757 +#: xs/src/libslic3r/PrintConfig.cpp:1141 xs/src/libslic3r/PrintConfig.cpp:1332 +#: xs/src/libslic3r/PrintConfig.cpp:1393 xs/src/libslic3r/PrintConfig.cpp:1545 +#: xs/src/libslic3r/PrintConfig.cpp:1590 msgid "layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:218 +#: xs/src/libslic3r/PrintConfig.cpp:219 msgid "Don't support bridges" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:220 +#: xs/src/libslic3r/PrintConfig.cpp:221 msgid "" "Experimental option for preventing support material from being generated " "under bridged areas." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:226 +#: xs/src/libslic3r/PrintConfig.cpp:227 msgid "Distance between copies" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:227 +#: xs/src/libslic3r/PrintConfig.cpp:228 msgid "Distance used for the auto-arrange feature of the plater." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:235 +#: xs/src/libslic3r/PrintConfig.cpp:236 msgid "Elephant foot compensation" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:237 +#: xs/src/libslic3r/PrintConfig.cpp:238 msgid "" "The first layer will be shrunk in the XY plane by the configured value to " "compensate for the 1st layer squish aka an Elephant Foot effect." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:246 +#: xs/src/libslic3r/PrintConfig.cpp:247 msgid "" "This end procedure is inserted at the end of the output file. Note that you " "can use placeholder variables for all Slic3r settings." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:256 +#: xs/src/libslic3r/PrintConfig.cpp:257 msgid "" "This end procedure is inserted at the end of the output file, before the " "printer end gcode. Note that you can use placeholder variables for all " @@ -2072,38 +2082,38 @@ msgid "" "extruder order." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:266 +#: xs/src/libslic3r/PrintConfig.cpp:267 msgid "Ensure vertical shell thickness" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:268 +#: xs/src/libslic3r/PrintConfig.cpp:269 msgid "" "Add solid infill near sloping surfaces to guarantee the vertical shell " "thickness (top+bottom solid layers)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:274 +#: xs/src/libslic3r/PrintConfig.cpp:275 msgid "Top/bottom fill pattern" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:276 +#: xs/src/libslic3r/PrintConfig.cpp:277 msgid "" "Fill pattern for top/bottom infill. This only affects the external visible " "layer, and not its adjacent solid shells." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:295 xs/src/libslic3r/PrintConfig.cpp:305 +#: xs/src/libslic3r/PrintConfig.cpp:296 xs/src/libslic3r/PrintConfig.cpp:306 msgid "External perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:296 xs/src/libslic3r/PrintConfig.cpp:405 -#: xs/src/libslic3r/PrintConfig.cpp:654 xs/src/libslic3r/PrintConfig.cpp:772 -#: xs/src/libslic3r/PrintConfig.cpp:1059 xs/src/libslic3r/PrintConfig.cpp:1399 -#: xs/src/libslic3r/PrintConfig.cpp:1561 xs/src/libslic3r/PrintConfig.cpp:1719 +#: xs/src/libslic3r/PrintConfig.cpp:297 xs/src/libslic3r/PrintConfig.cpp:406 +#: xs/src/libslic3r/PrintConfig.cpp:655 xs/src/libslic3r/PrintConfig.cpp:773 +#: xs/src/libslic3r/PrintConfig.cpp:1060 xs/src/libslic3r/PrintConfig.cpp:1400 +#: xs/src/libslic3r/PrintConfig.cpp:1562 xs/src/libslic3r/PrintConfig.cpp:1720 msgid "Extrusion Width" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:297 +#: xs/src/libslic3r/PrintConfig.cpp:298 msgid "" "Set this to a non-zero value to set a manual extrusion width for external " "perimeters. If left zero, default extrusion width will be used if set, " @@ -2111,60 +2121,60 @@ msgid "" "(for example 200%), it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:300 xs/src/libslic3r/PrintConfig.cpp:659 -#: xs/src/libslic3r/PrintConfig.cpp:777 xs/src/libslic3r/PrintConfig.cpp:1064 -#: xs/src/libslic3r/PrintConfig.cpp:1403 xs/src/libslic3r/PrintConfig.cpp:1565 -#: xs/src/libslic3r/PrintConfig.cpp:1724 +#: xs/src/libslic3r/PrintConfig.cpp:301 xs/src/libslic3r/PrintConfig.cpp:660 +#: xs/src/libslic3r/PrintConfig.cpp:778 xs/src/libslic3r/PrintConfig.cpp:1065 +#: xs/src/libslic3r/PrintConfig.cpp:1404 xs/src/libslic3r/PrintConfig.cpp:1566 +#: xs/src/libslic3r/PrintConfig.cpp:1725 msgid "mm or % (leave 0 for default)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:307 +#: xs/src/libslic3r/PrintConfig.cpp:308 msgid "" "This separate setting will affect the speed of external perimeters (the " "visible ones). If expressed as percentage (for example: 80%) it will be " "calculated on the perimeters speed setting above. Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:310 xs/src/libslic3r/PrintConfig.cpp:681 -#: xs/src/libslic3r/PrintConfig.cpp:1362 xs/src/libslic3r/PrintConfig.cpp:1413 -#: xs/src/libslic3r/PrintConfig.cpp:1608 xs/src/libslic3r/PrintConfig.cpp:1736 +#: xs/src/libslic3r/PrintConfig.cpp:311 xs/src/libslic3r/PrintConfig.cpp:682 +#: xs/src/libslic3r/PrintConfig.cpp:1363 xs/src/libslic3r/PrintConfig.cpp:1414 +#: xs/src/libslic3r/PrintConfig.cpp:1609 xs/src/libslic3r/PrintConfig.cpp:1737 msgid "mm/s or %" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:317 +#: xs/src/libslic3r/PrintConfig.cpp:318 msgid "External perimeters first" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:319 +#: xs/src/libslic3r/PrintConfig.cpp:320 msgid "" "Print contour perimeters from the outermost one to the innermost one instead " "of the default inverse order." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:325 +#: xs/src/libslic3r/PrintConfig.cpp:326 msgid "Extra perimeters if needed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:327 -#, no-c-format +#: xs/src/libslic3r/PrintConfig.cpp:328 +#, possible-c-format msgid "" "Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r " "keeps adding perimeters, until more than 70% of the loop immediately above " "is supported." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:337 +#: xs/src/libslic3r/PrintConfig.cpp:338 msgid "" "The extruder to use (unless more specific extruder settings are specified). " "This value overrides perimeter and infill extruders, but not the support " "extruders." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:348 lib/Slic3r/GUI/Plater/3DPreview.pm:68 +#: xs/src/libslic3r/PrintConfig.cpp:349 lib/Slic3r/GUI/Plater/3DPreview.pm:68 msgid "Height" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:349 +#: xs/src/libslic3r/PrintConfig.cpp:350 msgid "" "Set this to the vertical distance between your nozzle tip and (usually) the " "X carriage rods. In other words, this is the height of the clearance " @@ -2172,30 +2182,30 @@ msgid "" "extruder can peek before colliding with other printed objects." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:359 +#: xs/src/libslic3r/PrintConfig.cpp:360 msgid "Radius" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:360 +#: xs/src/libslic3r/PrintConfig.cpp:361 msgid "" "Set this to the clearance radius around your extruder. If the extruder is " "not centered, choose the largest value for safety. This setting is used to " "check for collisions and to display the graphical preview in the plater." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:370 +#: xs/src/libslic3r/PrintConfig.cpp:371 msgid "Extruder Color" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:371 xs/src/libslic3r/PrintConfig.cpp:434 +#: xs/src/libslic3r/PrintConfig.cpp:372 xs/src/libslic3r/PrintConfig.cpp:435 msgid "This is only used in the Slic3r interface as a visual help." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:378 +#: xs/src/libslic3r/PrintConfig.cpp:379 msgid "Extruder offset" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:379 +#: xs/src/libslic3r/PrintConfig.cpp:380 msgid "" "If your firmware doesn't handle the extruder displacement you need the G-" "code to take it into account. This option lets you specify the displacement " @@ -2203,21 +2213,21 @@ msgid "" "coordinates (they will be subtracted from the XY coordinate)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:388 +#: xs/src/libslic3r/PrintConfig.cpp:389 msgid "Extrusion axis" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:389 +#: xs/src/libslic3r/PrintConfig.cpp:390 msgid "" "Use this option to set the axis letter associated to your printer's extruder " "(usually E but some printers use A)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:395 +#: xs/src/libslic3r/PrintConfig.cpp:396 msgid "Extrusion multiplier" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:396 +#: xs/src/libslic3r/PrintConfig.cpp:397 msgid "" "This factor changes the amount of flow proportionally. You may need to tweak " "this setting to get nice surface finish and correct single wall widths. " @@ -2225,11 +2235,11 @@ msgid "" "more, check filament diameter and your firmware E steps." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:404 +#: xs/src/libslic3r/PrintConfig.cpp:405 msgid "Default extrusion width" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:406 +#: xs/src/libslic3r/PrintConfig.cpp:407 msgid "" "Set this to a non-zero value to allow a manual extrusion width. If left to " "zero, Slic3r derives extrusion widths from the nozzle diameter (see the " @@ -2238,113 +2248,113 @@ msgid "" "height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:410 +#: xs/src/libslic3r/PrintConfig.cpp:411 msgid "mm or % (leave 0 for auto)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:415 +#: xs/src/libslic3r/PrintConfig.cpp:416 msgid "Keep fan always on" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:416 +#: xs/src/libslic3r/PrintConfig.cpp:417 msgid "" "If this is enabled, fan will never be disabled and will be kept running at " "least at its minimum speed. Useful for PLA, harmful for ABS." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:422 +#: xs/src/libslic3r/PrintConfig.cpp:423 msgid "Enable fan if layer print time is below" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:423 +#: xs/src/libslic3r/PrintConfig.cpp:424 msgid "" "If layer print time is estimated below this number of seconds, fan will be " "enabled and its speed will be calculated by interpolating the minimum and " "maximum speeds." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:425 xs/src/libslic3r/PrintConfig.cpp:1349 +#: xs/src/libslic3r/PrintConfig.cpp:426 xs/src/libslic3r/PrintConfig.cpp:1350 msgid "approximate seconds" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:433 +#: xs/src/libslic3r/PrintConfig.cpp:434 msgid "Color" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:440 +#: xs/src/libslic3r/PrintConfig.cpp:441 msgid "Filament notes" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:441 +#: xs/src/libslic3r/PrintConfig.cpp:442 msgid "You can put your notes regarding the filament here." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:449 xs/src/libslic3r/PrintConfig.cpp:893 +#: xs/src/libslic3r/PrintConfig.cpp:450 xs/src/libslic3r/PrintConfig.cpp:894 msgid "Max volumetric speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:450 +#: xs/src/libslic3r/PrintConfig.cpp:451 msgid "" "Maximum volumetric speed allowed for this filament. Limits the maximum " "volumetric speed of a print to the minimum of print and filament volumetric " "speed. Set to zero for no limit." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:453 xs/src/libslic3r/PrintConfig.cpp:896 +#: xs/src/libslic3r/PrintConfig.cpp:454 xs/src/libslic3r/PrintConfig.cpp:897 msgid "mm³/s" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:459 +#: xs/src/libslic3r/PrintConfig.cpp:460 msgid "Loading speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:460 +#: xs/src/libslic3r/PrintConfig.cpp:461 msgid "Speed used for loading the filament on the wipe tower. " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:467 +#: xs/src/libslic3r/PrintConfig.cpp:468 msgid "Unloading speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:468 +#: xs/src/libslic3r/PrintConfig.cpp:469 msgid "" "Speed used for unloading the filament on the wipe tower (does not affect " "initial part of unloading just after ramming). " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:476 +#: xs/src/libslic3r/PrintConfig.cpp:477 msgid "Delay after unloading" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:477 +#: xs/src/libslic3r/PrintConfig.cpp:478 msgid "" "Time to wait after the filament is unloaded. May help to get reliable " "toolchanges with flexible materials that may need more time to shrink to " "original dimensions. " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:486 +#: xs/src/libslic3r/PrintConfig.cpp:487 msgid "Ramming parameters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:487 +#: xs/src/libslic3r/PrintConfig.cpp:488 msgid "" "This string is edited by RammingDialog and contains ramming specific " "parameters " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:494 +#: xs/src/libslic3r/PrintConfig.cpp:495 msgid "" "Enter your filament diameter here. Good precision is required, so use a " "caliper and do multiple measurements along the filament, then compute the " "average." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:502 +#: xs/src/libslic3r/PrintConfig.cpp:503 msgid "Density" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:503 +#: xs/src/libslic3r/PrintConfig.cpp:504 msgid "" "Enter your filament density here. This is only for statistical information. " "A decent way is to weigh a known length of filament and compute the ratio of " @@ -2352,15 +2362,15 @@ msgid "" "displacement." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:506 +#: xs/src/libslic3r/PrintConfig.cpp:507 msgid "g/cm³" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:512 +#: xs/src/libslic3r/PrintConfig.cpp:513 msgid "Filament type" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:513 xs/src/libslic3r/PrintConfig.cpp:1094 +#: xs/src/libslic3r/PrintConfig.cpp:514 xs/src/libslic3r/PrintConfig.cpp:1095 msgid "" "If you want to process the output G-code through custom scripts, just list " "their absolute paths here. Separate multiple scripts with a semicolon. " @@ -2369,74 +2379,74 @@ msgid "" "environment variables." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:532 +#: xs/src/libslic3r/PrintConfig.cpp:533 msgid "Soluble material" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:533 +#: xs/src/libslic3r/PrintConfig.cpp:534 msgid "Soluble material is most likely used for a soluble support." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:538 lib/Slic3r/GUI/Plater.pm:463 +#: xs/src/libslic3r/PrintConfig.cpp:539 lib/Slic3r/GUI/Plater.pm:469 msgid "Cost" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:539 +#: xs/src/libslic3r/PrintConfig.cpp:540 msgid "" "Enter your filament cost per kg here. This is only for statistical " "information." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:540 +#: xs/src/libslic3r/PrintConfig.cpp:541 msgid "money/kg" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:549 +#: xs/src/libslic3r/PrintConfig.cpp:550 msgid "Fill angle" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:551 +#: xs/src/libslic3r/PrintConfig.cpp:552 msgid "" "Default base angle for infill orientation. Cross-hatching will be applied to " "this. Bridges will be infilled using the best direction Slic3r can detect, " "so this setting does not affect them." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:563 +#: xs/src/libslic3r/PrintConfig.cpp:564 msgid "Fill density" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:565 +#: xs/src/libslic3r/PrintConfig.cpp:566 #, possible-c-format msgid "Density of internal infill, expressed in the range 0% - 100%." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:601 +#: xs/src/libslic3r/PrintConfig.cpp:602 msgid "Fill pattern" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:603 +#: xs/src/libslic3r/PrintConfig.cpp:604 msgid "Fill pattern for general low-density infill." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:635 xs/src/libslic3r/PrintConfig.cpp:644 -#: xs/src/libslic3r/PrintConfig.cpp:653 xs/src/libslic3r/PrintConfig.cpp:687 +#: xs/src/libslic3r/PrintConfig.cpp:636 xs/src/libslic3r/PrintConfig.cpp:645 +#: xs/src/libslic3r/PrintConfig.cpp:654 xs/src/libslic3r/PrintConfig.cpp:688 msgid "First layer" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:636 +#: xs/src/libslic3r/PrintConfig.cpp:637 msgid "" "This is the acceleration your printer will use for first layer. Set zero to " "disable acceleration control for first layer." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:645 +#: xs/src/libslic3r/PrintConfig.cpp:646 msgid "" "Heated build plate temperature for the first layer. Set this to zero to " "disable bed temperature control commands in the output." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:655 +#: xs/src/libslic3r/PrintConfig.cpp:656 msgid "" "Set this to a non-zero value to set a manual extrusion width for first " "layer. You can use this to force fatter extrudates for better adhesion. If " @@ -2444,11 +2454,11 @@ msgid "" "layer height. If set to zero, it will use the default extrusion width." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:665 +#: xs/src/libslic3r/PrintConfig.cpp:666 msgid "First layer height" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:667 +#: xs/src/libslic3r/PrintConfig.cpp:668 msgid "" "When printing with very low layer heights, you might still want to print a " "thicker bottom layer to improve adhesion and tolerance for non perfect build " @@ -2456,58 +2466,58 @@ msgid "" "example: 150%) over the default layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:671 xs/src/libslic3r/PrintConfig.cpp:802 -#: xs/src/libslic3r/PrintConfig.cpp:1497 +#: xs/src/libslic3r/PrintConfig.cpp:672 xs/src/libslic3r/PrintConfig.cpp:803 +#: xs/src/libslic3r/PrintConfig.cpp:1498 msgid "mm or %" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:677 +#: xs/src/libslic3r/PrintConfig.cpp:678 msgid "First layer speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:678 +#: xs/src/libslic3r/PrintConfig.cpp:679 msgid "" "If expressed as absolute value in mm/s, this speed will be applied to all " "the print moves of the first layer, regardless of their type. If expressed " "as a percentage (for example: 40%) it will scale the default speeds." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:688 +#: xs/src/libslic3r/PrintConfig.cpp:689 msgid "" "Extruder temperature for first layer. If you want to control temperature " "manually during print, set this to zero to disable temperature control " "commands in the output file." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:696 +#: xs/src/libslic3r/PrintConfig.cpp:697 #: xs/src/libslic3r/GCode/PreviewData.cpp:165 #: lib/Slic3r/GUI/Plater/3DPreview.pm:90 msgid "Gap fill" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:698 +#: xs/src/libslic3r/PrintConfig.cpp:699 msgid "" "Speed for filling small gaps using short zigzag moves. Keep this reasonably " "low to avoid too much shaking and resonance issues. Set zero to disable gaps " "filling." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:706 +#: xs/src/libslic3r/PrintConfig.cpp:707 msgid "Verbose G-code" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:707 +#: xs/src/libslic3r/PrintConfig.cpp:708 msgid "" "Enable this to get a commented G-code file, with each line explained by a " "descriptive text. If you print from SD card, the additional weight of the " "file could make your firmware slow down." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:714 +#: xs/src/libslic3r/PrintConfig.cpp:715 msgid "G-code flavor" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:715 +#: xs/src/libslic3r/PrintConfig.cpp:716 msgid "" "Some G/M-code commands, including temperature control and others, are not " "universal. Set this option to your printer's firmware to get a compatible " @@ -2515,35 +2525,35 @@ msgid "" "extrusion value at all." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:744 +#: xs/src/libslic3r/PrintConfig.cpp:745 msgid "" "This is the acceleration your printer will use for infill. Set zero to " "disable acceleration control for infill." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:752 +#: xs/src/libslic3r/PrintConfig.cpp:753 msgid "Combine infill every" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:754 +#: xs/src/libslic3r/PrintConfig.cpp:755 msgid "" "This feature allows to combine infill and speed up your print by extruding " "thicker infill layers while preserving thin perimeters, thus accuracy." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:758 +#: xs/src/libslic3r/PrintConfig.cpp:759 msgid "Combine infill every n layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:763 +#: xs/src/libslic3r/PrintConfig.cpp:764 msgid "Infill extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:765 +#: xs/src/libslic3r/PrintConfig.cpp:766 msgid "The extruder to use when printing infill." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:773 +#: xs/src/libslic3r/PrintConfig.cpp:774 msgid "" "Set this to a non-zero value to set a manual extrusion width for infill. If " "left zero, default extrusion width will be used if set, otherwise 1.125 x " @@ -2552,32 +2562,32 @@ msgid "" "example 90%) it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:782 +#: xs/src/libslic3r/PrintConfig.cpp:783 msgid "Infill before perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:783 +#: xs/src/libslic3r/PrintConfig.cpp:784 msgid "" "This option will switch the print order of perimeters and infill, making the " "latter first." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:788 +#: xs/src/libslic3r/PrintConfig.cpp:789 msgid "Only infill where needed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:790 +#: xs/src/libslic3r/PrintConfig.cpp:791 msgid "" "This option will limit infill to the areas actually needed for supporting " "ceilings (it will act as internal support material). If enabled, slows down " "the G-code generation due to the multiple checks involved." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:797 +#: xs/src/libslic3r/PrintConfig.cpp:798 msgid "Infill/perimeters overlap" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:799 +#: xs/src/libslic3r/PrintConfig.cpp:800 msgid "" "This setting applies an additional overlap between infill and perimeters for " "better bonding. Theoretically this shouldn't be needed, but backlash might " @@ -2585,30 +2595,30 @@ msgid "" "perimeter extrusion width." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:810 +#: xs/src/libslic3r/PrintConfig.cpp:811 msgid "Speed for printing the internal fill. Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:819 +#: xs/src/libslic3r/PrintConfig.cpp:820 msgid "Inherits profile" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:820 +#: xs/src/libslic3r/PrintConfig.cpp:821 msgid "Name of the profile, from which this profile inherits." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:826 +#: xs/src/libslic3r/PrintConfig.cpp:827 msgid "Interface shells" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:827 +#: xs/src/libslic3r/PrintConfig.cpp:828 msgid "" "Force the generation of solid shells between adjacent materials/volumes. " "Useful for multi-extruder prints with translucent materials or manual " "soluble support material." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:836 +#: xs/src/libslic3r/PrintConfig.cpp:837 msgid "" "This custom code is inserted at every layer change, right after the Z move " "and before the extruder moves to the first layer point. Note that you can " @@ -2616,22 +2626,22 @@ msgid "" "[layer_z]." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:848 +#: xs/src/libslic3r/PrintConfig.cpp:849 msgid "" "This setting controls the height (and thus the total number) of the slices/" "layers. Thinner layers give better accuracy but take more time to print." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:856 xs/src/libslic3r/PrintConfig.cpp:865 +#: xs/src/libslic3r/PrintConfig.cpp:857 xs/src/libslic3r/PrintConfig.cpp:866 msgid "Max" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:857 +#: xs/src/libslic3r/PrintConfig.cpp:858 msgid "This setting represents the maximum speed of your fan." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:866 -#, no-c-format +#: xs/src/libslic3r/PrintConfig.cpp:867 +#, possible-c-format msgid "" "This is the highest printable layer height for this extruder, used to cap " "the variable layer height and support layer height. Maximum recommended " @@ -2639,38 +2649,38 @@ msgid "" "adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:876 +#: xs/src/libslic3r/PrintConfig.cpp:877 msgid "Max print height" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:877 +#: xs/src/libslic3r/PrintConfig.cpp:878 msgid "" "Set this to the maximum height that can be reached by your extruder while " "printing." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:883 +#: xs/src/libslic3r/PrintConfig.cpp:884 msgid "Max print speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:884 +#: xs/src/libslic3r/PrintConfig.cpp:885 msgid "" "When setting other speed settings to 0 Slic3r will autocalculate the optimal " "speed in order to keep constant extruder pressure. This experimental setting " "is used to set the highest print speed you want to allow." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:894 +#: xs/src/libslic3r/PrintConfig.cpp:895 msgid "" "This experimental setting is used to set the maximum volumetric speed your " "extruder supports." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:902 +#: xs/src/libslic3r/PrintConfig.cpp:903 msgid "Max volumetric slope positive" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:903 xs/src/libslic3r/PrintConfig.cpp:914 +#: xs/src/libslic3r/PrintConfig.cpp:904 xs/src/libslic3r/PrintConfig.cpp:915 msgid "" "This experimental setting is used to limit the speed of change in extrusion " "rate. A value of 1.8 mm³/s² ensures, that a change from the extrusion rate " @@ -2678,109 +2688,109 @@ msgid "" "s) to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:907 xs/src/libslic3r/PrintConfig.cpp:918 +#: xs/src/libslic3r/PrintConfig.cpp:908 xs/src/libslic3r/PrintConfig.cpp:919 msgid "mm³/s²" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:913 +#: xs/src/libslic3r/PrintConfig.cpp:914 msgid "Max volumetric slope negative" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:924 xs/src/libslic3r/PrintConfig.cpp:933 +#: xs/src/libslic3r/PrintConfig.cpp:925 xs/src/libslic3r/PrintConfig.cpp:934 msgid "Min" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:925 +#: xs/src/libslic3r/PrintConfig.cpp:926 msgid "This setting represents the minimum PWM your fan needs to work." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:934 +#: xs/src/libslic3r/PrintConfig.cpp:935 msgid "" "This is the lowest printable layer height for this extruder and limits the " "resolution for variable layer height. Typical values are between 0.05 mm and " "0.1 mm." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:942 +#: xs/src/libslic3r/PrintConfig.cpp:943 msgid "Min print speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:943 +#: xs/src/libslic3r/PrintConfig.cpp:944 msgid "Slic3r will not scale speed down below this speed." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:950 +#: xs/src/libslic3r/PrintConfig.cpp:951 msgid "Minimum extrusion length" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:951 +#: xs/src/libslic3r/PrintConfig.cpp:952 msgid "" "Generate no less than the number of skirt loops required to consume the " "specified amount of filament on the bottom layer. For multi-extruder " "machines, this minimum applies to each extruder." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:960 +#: xs/src/libslic3r/PrintConfig.cpp:961 msgid "Configuration notes" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:961 +#: xs/src/libslic3r/PrintConfig.cpp:962 msgid "" "You can put here your personal notes. This text will be added to the G-code " "header comments." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:970 +#: xs/src/libslic3r/PrintConfig.cpp:971 msgid "Nozzle diameter" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:971 +#: xs/src/libslic3r/PrintConfig.cpp:972 msgid "" "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:977 +#: xs/src/libslic3r/PrintConfig.cpp:978 msgid "API Key" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:978 +#: xs/src/libslic3r/PrintConfig.cpp:979 msgid "" "Slic3r can upload G-code files to OctoPrint. This field should contain the " "API Key required for authentication." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:991 +#: xs/src/libslic3r/PrintConfig.cpp:992 msgid "Hostname, IP or URL" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:992 +#: xs/src/libslic3r/PrintConfig.cpp:993 msgid "" "Slic3r can upload G-code files to OctoPrint. This field should contain the " "hostname, IP address or URL of the OctoPrint instance." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:998 +#: xs/src/libslic3r/PrintConfig.cpp:999 msgid "Only retract when crossing perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:999 +#: xs/src/libslic3r/PrintConfig.cpp:1000 msgid "" "Disables retraction when the travel path does not exceed the upper layer's " "perimeters (and thus any ooze will be probably invisible)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1006 +#: xs/src/libslic3r/PrintConfig.cpp:1007 msgid "" "This option will drop the temperature of the inactive extruders to prevent " "oozing. It will enable a tall skirt automatically and move extruders outside " "such skirt when changing temperatures." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1013 +#: xs/src/libslic3r/PrintConfig.cpp:1014 msgid "Output filename format" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1014 +#: xs/src/libslic3r/PrintConfig.cpp:1015 msgid "" "You can use all configuration options as variables inside this template. For " "example: [layer_height], [fill_density] etc. You can also use [timestamp], " @@ -2788,48 +2798,48 @@ msgid "" "[input_filename], [input_filename_base]." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1023 +#: xs/src/libslic3r/PrintConfig.cpp:1024 msgid "Detect bridging perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1025 +#: xs/src/libslic3r/PrintConfig.cpp:1026 msgid "" "Experimental option to adjust flow for overhangs (bridge flow will be used), " "to apply bridge speed to them and enable fan." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1031 +#: xs/src/libslic3r/PrintConfig.cpp:1032 msgid "Filament parking position" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1032 +#: xs/src/libslic3r/PrintConfig.cpp:1033 msgid "" "Distance of the extruder tip from the position where the filament is parked " "when unloaded. This should match the value in printer firmware. " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1040 xs/src/libslic3r/PrintConfig.cpp:1058 -#: xs/src/libslic3r/PrintConfig.cpp:1070 xs/src/libslic3r/PrintConfig.cpp:1080 +#: xs/src/libslic3r/PrintConfig.cpp:1041 xs/src/libslic3r/PrintConfig.cpp:1059 +#: xs/src/libslic3r/PrintConfig.cpp:1071 xs/src/libslic3r/PrintConfig.cpp:1081 msgid "Perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1041 +#: xs/src/libslic3r/PrintConfig.cpp:1042 msgid "" "This is the acceleration your printer will use for perimeters. A high value " "like 9000 usually gives good results if your hardware is up to the job. Set " "zero to disable acceleration control for perimeters." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1049 +#: xs/src/libslic3r/PrintConfig.cpp:1050 msgid "Perimeter extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1051 +#: xs/src/libslic3r/PrintConfig.cpp:1052 msgid "" "The extruder to use when printing perimeters and brim. First extruder is 1." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1060 +#: xs/src/libslic3r/PrintConfig.cpp:1061 msgid "" "Set this to a non-zero value to set a manual extrusion width for perimeters. " "You may want to use thinner extrudates to get more accurate surfaces. If " @@ -2838,12 +2848,12 @@ msgid "" "it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1072 +#: xs/src/libslic3r/PrintConfig.cpp:1073 msgid "" "Speed for perimeters (contours, aka vertical shells). Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1082 +#: xs/src/libslic3r/PrintConfig.cpp:1083 msgid "" "This option sets the number of perimeters to generate for each layer. Note " "that Slic3r may increase this number automatically when it detects sloping " @@ -2851,59 +2861,59 @@ msgid "" "Perimeters option is enabled." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1086 +#: xs/src/libslic3r/PrintConfig.cpp:1087 msgid "(minimum)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1106 +#: xs/src/libslic3r/PrintConfig.cpp:1107 msgid "Printer type" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1107 +#: xs/src/libslic3r/PrintConfig.cpp:1108 msgid "Type of the printer." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1111 +#: xs/src/libslic3r/PrintConfig.cpp:1112 msgid "Printer notes" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1112 +#: xs/src/libslic3r/PrintConfig.cpp:1113 msgid "You can put your notes regarding the printer here." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1120 +#: xs/src/libslic3r/PrintConfig.cpp:1121 msgid "Printer vendor" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1121 +#: xs/src/libslic3r/PrintConfig.cpp:1122 msgid "Name of the printer vendor." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1125 +#: xs/src/libslic3r/PrintConfig.cpp:1126 msgid "Printer variant" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1126 +#: xs/src/libslic3r/PrintConfig.cpp:1127 msgid "" "Name of the printer variant. For example, the printer variants may be " "differentiated by a nozzle diameter." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1136 +#: xs/src/libslic3r/PrintConfig.cpp:1137 msgid "Raft layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1138 +#: xs/src/libslic3r/PrintConfig.cpp:1139 msgid "" "The object will be raised by this number of layers, and support material " "will be generated under it." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1146 +#: xs/src/libslic3r/PrintConfig.cpp:1147 msgid "Resolution" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1147 +#: xs/src/libslic3r/PrintConfig.cpp:1148 msgid "" "Minimum detail resolution, used to simplify the input file for speeding up " "the slicing job and reducing memory usage. High-resolution models often " @@ -2911,266 +2921,266 @@ msgid "" "simplification and use full resolution from input." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1157 +#: xs/src/libslic3r/PrintConfig.cpp:1158 msgid "Minimum travel after retraction" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1158 +#: xs/src/libslic3r/PrintConfig.cpp:1159 msgid "" "Retraction is not triggered when travel moves are shorter than this length." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1164 +#: xs/src/libslic3r/PrintConfig.cpp:1165 msgid "Retract amount before wipe" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1165 +#: xs/src/libslic3r/PrintConfig.cpp:1166 msgid "" "With bowden extruders, it may be wise to do some amount of quick retract " "before doing the wipe movement." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1172 +#: xs/src/libslic3r/PrintConfig.cpp:1173 msgid "Retract on layer change" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1173 +#: xs/src/libslic3r/PrintConfig.cpp:1174 msgid "This flag enforces a retraction whenever a Z move is done." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1178 xs/src/libslic3r/PrintConfig.cpp:1187 +#: xs/src/libslic3r/PrintConfig.cpp:1179 xs/src/libslic3r/PrintConfig.cpp:1188 msgid "Length" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1179 +#: xs/src/libslic3r/PrintConfig.cpp:1180 msgid "Retraction Length" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1180 +#: xs/src/libslic3r/PrintConfig.cpp:1181 msgid "" "When retraction is triggered, filament is pulled back by the specified " "amount (the length is measured on raw filament, before it enters the " "extruder)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1182 xs/src/libslic3r/PrintConfig.cpp:1192 +#: xs/src/libslic3r/PrintConfig.cpp:1183 xs/src/libslic3r/PrintConfig.cpp:1193 msgid "mm (zero to disable)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1188 +#: xs/src/libslic3r/PrintConfig.cpp:1189 msgid "Retraction Length (Toolchange)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1189 +#: xs/src/libslic3r/PrintConfig.cpp:1190 msgid "" "When retraction is triggered before changing tool, filament is pulled back " "by the specified amount (the length is measured on raw filament, before it " "enters the extruder)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1197 +#: xs/src/libslic3r/PrintConfig.cpp:1198 msgid "Lift Z" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1198 +#: xs/src/libslic3r/PrintConfig.cpp:1199 msgid "" "If you set this to a positive value, Z is quickly raised every time a " "retraction is triggered. When using multiple extruders, only the setting for " "the first extruder will be considered." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1206 +#: xs/src/libslic3r/PrintConfig.cpp:1207 msgid "Above Z" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1207 +#: xs/src/libslic3r/PrintConfig.cpp:1208 msgid "Only lift Z above" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1208 +#: xs/src/libslic3r/PrintConfig.cpp:1209 msgid "" "If you set this to a positive value, Z lift will only take place above the " "specified absolute Z. You can tune this setting for skipping lift on the " "first layers." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1215 +#: xs/src/libslic3r/PrintConfig.cpp:1216 msgid "Below Z" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1216 +#: xs/src/libslic3r/PrintConfig.cpp:1217 msgid "Only lift Z below" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1217 +#: xs/src/libslic3r/PrintConfig.cpp:1218 msgid "" "If you set this to a positive value, Z lift will only take place below the " "specified absolute Z. You can tune this setting for limiting lift to the " "first layers." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1225 xs/src/libslic3r/PrintConfig.cpp:1233 +#: xs/src/libslic3r/PrintConfig.cpp:1226 xs/src/libslic3r/PrintConfig.cpp:1234 msgid "Extra length on restart" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1226 +#: xs/src/libslic3r/PrintConfig.cpp:1227 msgid "" "When the retraction is compensated after the travel move, the extruder will " "push this additional amount of filament. This setting is rarely needed." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1234 +#: xs/src/libslic3r/PrintConfig.cpp:1235 msgid "" "When the retraction is compensated after changing tool, the extruder will " "push this additional amount of filament." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1241 xs/src/libslic3r/PrintConfig.cpp:1242 +#: xs/src/libslic3r/PrintConfig.cpp:1242 xs/src/libslic3r/PrintConfig.cpp:1243 msgid "Retraction Speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1243 +#: xs/src/libslic3r/PrintConfig.cpp:1244 msgid "The speed for retractions (it only applies to the extruder motor)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1249 xs/src/libslic3r/PrintConfig.cpp:1250 +#: xs/src/libslic3r/PrintConfig.cpp:1250 xs/src/libslic3r/PrintConfig.cpp:1251 msgid "Deretraction Speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1251 +#: xs/src/libslic3r/PrintConfig.cpp:1252 msgid "" "The speed for loading of a filament into extruder after retraction (it only " "applies to the extruder motor). If left to zero, the retraction speed is " "used." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1258 +#: xs/src/libslic3r/PrintConfig.cpp:1259 msgid "Seam position" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1260 +#: xs/src/libslic3r/PrintConfig.cpp:1261 msgid "Position of perimeters starting points." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1276 +#: xs/src/libslic3r/PrintConfig.cpp:1277 msgid "Direction" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1278 +#: xs/src/libslic3r/PrintConfig.cpp:1279 msgid "Preferred direction of the seam" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1279 +#: xs/src/libslic3r/PrintConfig.cpp:1280 msgid "Seam preferred direction" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1287 +#: xs/src/libslic3r/PrintConfig.cpp:1288 msgid "Jitter" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1289 +#: xs/src/libslic3r/PrintConfig.cpp:1290 msgid "Seam preferred direction jitter" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1290 +#: xs/src/libslic3r/PrintConfig.cpp:1291 msgid "Preferred direction of the seam - jitter" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1301 +#: xs/src/libslic3r/PrintConfig.cpp:1302 msgid "USB/serial port for printer connection." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1309 +#: xs/src/libslic3r/PrintConfig.cpp:1310 msgid "Serial port speed" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1310 +#: xs/src/libslic3r/PrintConfig.cpp:1311 msgid "Speed (baud) of USB/serial port for printer connection." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1319 +#: xs/src/libslic3r/PrintConfig.cpp:1320 msgid "Distance from object" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1320 +#: xs/src/libslic3r/PrintConfig.cpp:1321 msgid "" "Distance between skirt and object(s). Set this to zero to attach the skirt " "to the object(s) and get a brim for better adhesion." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1328 +#: xs/src/libslic3r/PrintConfig.cpp:1329 msgid "Skirt height" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1329 +#: xs/src/libslic3r/PrintConfig.cpp:1330 msgid "" "Height of skirt expressed in layers. Set this to a tall value to use skirt " "as a shield against drafts." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1336 +#: xs/src/libslic3r/PrintConfig.cpp:1337 msgid "Loops (minimum)" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1337 +#: xs/src/libslic3r/PrintConfig.cpp:1338 msgid "Skirt Loops" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1338 +#: xs/src/libslic3r/PrintConfig.cpp:1339 msgid "" "Number of loops for the skirt. If the Minimum Extrusion Length option is " "set, the number of loops might be greater than the one configured here. Set " "this to zero to disable skirt completely." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1346 +#: xs/src/libslic3r/PrintConfig.cpp:1347 msgid "Slow down if layer print time is below" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1347 +#: xs/src/libslic3r/PrintConfig.cpp:1348 msgid "" "If layer print time is estimated below this number of seconds, print moves " "speed will be scaled down to extend duration to this value." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1357 +#: xs/src/libslic3r/PrintConfig.cpp:1358 msgid "Small perimeters" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1359 +#: xs/src/libslic3r/PrintConfig.cpp:1360 msgid "" "This separate setting will affect the speed of perimeters having radius <= " "6.5mm (usually holes). If expressed as percentage (for example: 80%) it will " "be calculated on the perimeters speed setting above. Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1369 +#: xs/src/libslic3r/PrintConfig.cpp:1370 msgid "Solid infill threshold area" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1371 +#: xs/src/libslic3r/PrintConfig.cpp:1372 msgid "" "Force solid infill for regions having a smaller area than the specified " "threshold." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1372 +#: xs/src/libslic3r/PrintConfig.cpp:1373 msgid "mm²" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1378 +#: xs/src/libslic3r/PrintConfig.cpp:1379 msgid "Solid infill extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1380 +#: xs/src/libslic3r/PrintConfig.cpp:1381 msgid "The extruder to use when printing solid infill." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1386 +#: xs/src/libslic3r/PrintConfig.cpp:1387 msgid "Solid infill every" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1388 +#: xs/src/libslic3r/PrintConfig.cpp:1389 msgid "" "This feature allows to force a solid layer every given number of layers. " "Zero to disable. You can set this to any value (for example 9999); Slic3r " @@ -3178,13 +3188,13 @@ msgid "" "according to nozzle diameter and layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1398 xs/src/libslic3r/PrintConfig.cpp:1408 +#: xs/src/libslic3r/PrintConfig.cpp:1399 xs/src/libslic3r/PrintConfig.cpp:1409 #: xs/src/libslic3r/GCode/PreviewData.cpp:162 #: lib/Slic3r/GUI/Plater/3DPreview.pm:87 msgid "Solid infill" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1400 +#: xs/src/libslic3r/PrintConfig.cpp:1401 msgid "" "Set this to a non-zero value to set a manual extrusion width for infill for " "solid surfaces. If left zero, default extrusion width will be used if set, " @@ -3192,22 +3202,22 @@ msgid "" "(for example 90%) it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1410 +#: xs/src/libslic3r/PrintConfig.cpp:1411 msgid "" "Speed for printing solid regions (top/bottom/internal horizontal shells). " "This can be expressed as a percentage (for example: 80%) over the default " "infill speed above. Set to zero for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1422 +#: xs/src/libslic3r/PrintConfig.cpp:1423 msgid "Number of solid layers to generate on top and bottom surfaces." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1429 +#: xs/src/libslic3r/PrintConfig.cpp:1430 msgid "Spiral vase" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1430 +#: xs/src/libslic3r/PrintConfig.cpp:1431 msgid "" "This feature will raise Z gradually while printing a single-walled object in " "order to remove any visible seam. This option requires a single perimeter, " @@ -3216,18 +3226,18 @@ msgid "" "when printing more than an object." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1439 +#: xs/src/libslic3r/PrintConfig.cpp:1440 msgid "Temperature variation" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1440 +#: xs/src/libslic3r/PrintConfig.cpp:1441 msgid "" "Temperature difference to be applied when an extruder is not active. Enables " "a full-height \"sacrificial\" skirt on which the nozzles are periodically " "wiped." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1450 +#: xs/src/libslic3r/PrintConfig.cpp:1451 msgid "" "This start procedure is inserted at the beginning, after bed has reached the " "target temperature and extruder just started heating, and before extruder " @@ -3238,7 +3248,7 @@ msgid "" "\"M109 S[first_layer_temperature]\" command wherever you want." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1465 +#: xs/src/libslic3r/PrintConfig.cpp:1466 msgid "" "This start procedure is inserted at the beginning, after any printer start " "gcode. This is used to override settings for a specific filament. If Slic3r " @@ -3250,64 +3260,64 @@ msgid "" "extruders, the gcode is processed in extruder order." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1480 +#: xs/src/libslic3r/PrintConfig.cpp:1481 msgid "Single Extruder Multi Material" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1481 +#: xs/src/libslic3r/PrintConfig.cpp:1482 msgid "The printer multiplexes filaments into a single hot end." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1486 +#: xs/src/libslic3r/PrintConfig.cpp:1487 msgid "Generate support material" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1488 +#: xs/src/libslic3r/PrintConfig.cpp:1489 msgid "Enable support material generation." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1493 +#: xs/src/libslic3r/PrintConfig.cpp:1494 msgid "XY separation between an object and its support" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1495 +#: xs/src/libslic3r/PrintConfig.cpp:1496 msgid "" "XY separation between an object and its support. If expressed as percentage " "(for example 50%), it will be calculated over external perimeter width." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1505 +#: xs/src/libslic3r/PrintConfig.cpp:1506 msgid "Pattern angle" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1507 +#: xs/src/libslic3r/PrintConfig.cpp:1508 msgid "" "Use this setting to rotate the support material pattern on the horizontal " "plane." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1517 +#: xs/src/libslic3r/PrintConfig.cpp:1518 msgid "" "Only create support if it lies on a build plate. Don't create support on a " "print." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1523 +#: xs/src/libslic3r/PrintConfig.cpp:1524 msgid "Contact Z distance" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1525 +#: xs/src/libslic3r/PrintConfig.cpp:1526 msgid "" "The vertical distance between object and support material interface. Setting " "this to 0 will also prevent Slic3r from using bridge flow and speed for the " "first object layer." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1538 +#: xs/src/libslic3r/PrintConfig.cpp:1539 msgid "Enforce support for the first" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1540 +#: xs/src/libslic3r/PrintConfig.cpp:1541 msgid "" "Generate support material for the specified number of layers counting from " "bottom, regardless of whether normal support material is enabled or not and " @@ -3315,21 +3325,21 @@ msgid "" "of objects having a very thin or poor footprint on the build plate." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1546 +#: xs/src/libslic3r/PrintConfig.cpp:1547 msgid "Enforce support for the first n layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1551 +#: xs/src/libslic3r/PrintConfig.cpp:1552 msgid "Support material/raft/skirt extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1553 +#: xs/src/libslic3r/PrintConfig.cpp:1554 msgid "" "The extruder to use when printing support material, raft and skirt (1+, 0 to " "use the current extruder to minimize tool changes)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1562 +#: xs/src/libslic3r/PrintConfig.cpp:1563 msgid "" "Set this to a non-zero value to set a manual extrusion width for support " "material. If left zero, default extrusion width will be used if set, " @@ -3337,91 +3347,91 @@ msgid "" "example 90%) it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1570 +#: xs/src/libslic3r/PrintConfig.cpp:1571 msgid "Interface loops" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1572 +#: xs/src/libslic3r/PrintConfig.cpp:1573 msgid "" "Cover the top contact layer of the supports with loops. Disabled by default." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1577 +#: xs/src/libslic3r/PrintConfig.cpp:1578 msgid "Support material/raft interface extruder" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1579 +#: xs/src/libslic3r/PrintConfig.cpp:1580 msgid "" "The extruder to use when printing support material interface (1+, 0 to use " "the current extruder to minimize tool changes). This affects raft too." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1586 +#: xs/src/libslic3r/PrintConfig.cpp:1587 msgid "Interface layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1588 +#: xs/src/libslic3r/PrintConfig.cpp:1589 msgid "" "Number of interface layers to insert between the object(s) and support " "material." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1595 +#: xs/src/libslic3r/PrintConfig.cpp:1596 msgid "Interface pattern spacing" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1597 +#: xs/src/libslic3r/PrintConfig.cpp:1598 msgid "Spacing between interface lines. Set zero to get a solid interface." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1604 +#: xs/src/libslic3r/PrintConfig.cpp:1605 #: xs/src/libslic3r/GCode/PreviewData.cpp:168 #: lib/Slic3r/GUI/Plater/3DPreview.pm:93 msgid "Support material interface" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1606 +#: xs/src/libslic3r/PrintConfig.cpp:1607 msgid "" "Speed for printing support material interface layers. If expressed as " "percentage (for example 50%) it will be calculated over support material " "speed." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1615 +#: xs/src/libslic3r/PrintConfig.cpp:1616 msgid "Pattern" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1617 +#: xs/src/libslic3r/PrintConfig.cpp:1618 msgid "Pattern used to generate support material." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1629 +#: xs/src/libslic3r/PrintConfig.cpp:1630 msgid "Pattern spacing" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1631 +#: xs/src/libslic3r/PrintConfig.cpp:1632 msgid "Spacing between support material lines." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1640 +#: xs/src/libslic3r/PrintConfig.cpp:1641 msgid "Speed for printing support material." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1647 +#: xs/src/libslic3r/PrintConfig.cpp:1648 msgid "Synchronize with object layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1649 +#: xs/src/libslic3r/PrintConfig.cpp:1650 msgid "" "Synchronize support layers with the object print layers. This is useful with " "multi-material printers, where the extruder switch is expensive." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1655 +#: xs/src/libslic3r/PrintConfig.cpp:1656 msgid "Overhang threshold" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1657 +#: xs/src/libslic3r/PrintConfig.cpp:1658 msgid "" "Support material will not be generated for overhangs whose slope angle (90° " "= vertical) is above the given threshold. In other words, this value " @@ -3430,60 +3440,60 @@ msgid "" "detection (recommended)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1669 +#: xs/src/libslic3r/PrintConfig.cpp:1670 msgid "With sheath around the support" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1671 +#: xs/src/libslic3r/PrintConfig.cpp:1672 msgid "" "Add a sheath (a single perimeter line) around the base support. This makes " "the support more reliable, but also more difficult to remove." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1678 +#: xs/src/libslic3r/PrintConfig.cpp:1679 msgid "" "Extruder temperature for layers after the first one. Set this to zero to " "disable temperature control commands in the output." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1681 +#: xs/src/libslic3r/PrintConfig.cpp:1682 msgid "Temperature" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1687 +#: xs/src/libslic3r/PrintConfig.cpp:1688 msgid "Detect thin walls" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1689 +#: xs/src/libslic3r/PrintConfig.cpp:1690 msgid "" "Detect single-width walls (parts where two extrusions don't fit and we need " "to collapse them into a single trace)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1695 +#: xs/src/libslic3r/PrintConfig.cpp:1696 msgid "Threads" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1696 +#: xs/src/libslic3r/PrintConfig.cpp:1697 msgid "" "Threads are used to parallelize long-running tasks. Optimal threads number " "is slightly above the number of available cores/processors." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1708 +#: xs/src/libslic3r/PrintConfig.cpp:1709 msgid "" "This custom code is inserted right before every extruder change. Note that " "you can use placeholder variables for all Slic3r settings as well as " "[previous_extruder] and [next_extruder]." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1718 xs/src/libslic3r/PrintConfig.cpp:1729 +#: xs/src/libslic3r/PrintConfig.cpp:1719 xs/src/libslic3r/PrintConfig.cpp:1730 #: xs/src/libslic3r/GCode/PreviewData.cpp:163 #: lib/Slic3r/GUI/Plater/3DPreview.pm:88 msgid "Top solid infill" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1720 +#: xs/src/libslic3r/PrintConfig.cpp:1721 msgid "" "Set this to a non-zero value to set a manual extrusion width for infill for " "top surfaces. You may want to use thinner extrudates to fill all narrow " @@ -3492,7 +3502,7 @@ msgid "" "percentage (for example 90%) it will be computed over layer height." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1731 +#: xs/src/libslic3r/PrintConfig.cpp:1732 msgid "" "Speed for printing top solid layers (it only applies to the uppermost " "external layers and not to their internal solid layers). You may want to " @@ -3501,51 +3511,51 @@ msgid "" "for auto." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1743 lib/Slic3r/GUI/MainFrame.pm:306 +#: xs/src/libslic3r/PrintConfig.cpp:1744 lib/Slic3r/GUI/MainFrame.pm:306 msgid "Top" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1745 +#: xs/src/libslic3r/PrintConfig.cpp:1746 msgid "Number of solid layers to generate on top surfaces." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1747 +#: xs/src/libslic3r/PrintConfig.cpp:1748 msgid "Top solid layers" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1752 lib/Slic3r/GUI/Plater/3DPreview.pm:98 +#: xs/src/libslic3r/PrintConfig.cpp:1753 lib/Slic3r/GUI/Plater/3DPreview.pm:98 msgid "Travel" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1753 +#: xs/src/libslic3r/PrintConfig.cpp:1754 msgid "Speed for travel moves (jumps between distant extrusion points)." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1761 +#: xs/src/libslic3r/PrintConfig.cpp:1762 msgid "Use firmware retraction" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1762 +#: xs/src/libslic3r/PrintConfig.cpp:1763 msgid "" "This experimental setting uses G10 and G11 commands to have the firmware " "handle the retraction. This is only supported in recent Marlin." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1768 +#: xs/src/libslic3r/PrintConfig.cpp:1769 msgid "Use relative E distances" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1769 +#: xs/src/libslic3r/PrintConfig.cpp:1770 msgid "" "If your firmware requires relative E values, check this, otherwise leave it " "unchecked. Most firmwares use absolute values." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1775 +#: xs/src/libslic3r/PrintConfig.cpp:1776 msgid "Use volumetric E" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1776 +#: xs/src/libslic3r/PrintConfig.cpp:1777 msgid "" "This experimental setting uses outputs the E values in cubic millimeters " "instead of linear millimeters. If your firmware doesn't already know " @@ -3555,113 +3565,113 @@ msgid "" "only supported in recent Marlin." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1786 +#: xs/src/libslic3r/PrintConfig.cpp:1787 msgid "Enable variable layer height feature" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1787 +#: xs/src/libslic3r/PrintConfig.cpp:1788 msgid "" "Some printers or printer setups may have difficulties printing with a " "variable layer height. Enabled by default." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1793 +#: xs/src/libslic3r/PrintConfig.cpp:1794 msgid "Wipe while retracting" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1794 +#: xs/src/libslic3r/PrintConfig.cpp:1795 msgid "" "This flag will move the nozzle while retracting to minimize the possible " "blob on leaky extruders." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1801 +#: xs/src/libslic3r/PrintConfig.cpp:1802 msgid "" "Multi material printers may need to prime or purge extruders on tool " "changes. Extrude the excess material into the wipe tower." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1807 +#: xs/src/libslic3r/PrintConfig.cpp:1808 msgid "Purging volumes - load/unload volumes" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1808 +#: xs/src/libslic3r/PrintConfig.cpp:1809 msgid "" "This vector saves required volumes to change from/to each tool used on the " "wipe tower. These values are used to simplify creation of the full purging " "volumes below. " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1815 +#: xs/src/libslic3r/PrintConfig.cpp:1816 msgid "Purging volumes - matrix" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1816 +#: xs/src/libslic3r/PrintConfig.cpp:1817 msgid "" "This matrix describes volumes (in cubic milimetres) required to purge the " "new filament on the wipe tower for any given pair of tools. " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1826 +#: xs/src/libslic3r/PrintConfig.cpp:1827 msgid "Position X" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1827 +#: xs/src/libslic3r/PrintConfig.cpp:1828 msgid "X coordinate of the left front corner of a wipe tower" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1833 +#: xs/src/libslic3r/PrintConfig.cpp:1834 msgid "Position Y" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1834 +#: xs/src/libslic3r/PrintConfig.cpp:1835 msgid "Y coordinate of the left front corner of a wipe tower" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1840 lib/Slic3r/GUI/Plater/3DPreview.pm:69 +#: xs/src/libslic3r/PrintConfig.cpp:1841 lib/Slic3r/GUI/Plater/3DPreview.pm:69 msgid "Width" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1841 +#: xs/src/libslic3r/PrintConfig.cpp:1842 msgid "Width of a wipe tower" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1847 +#: xs/src/libslic3r/PrintConfig.cpp:1848 msgid "Wipe tower rotation angle" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1848 +#: xs/src/libslic3r/PrintConfig.cpp:1849 msgid "Wipe tower rotation angle with respect to x-axis " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1849 +#: xs/src/libslic3r/PrintConfig.cpp:1850 msgid "degrees" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1854 +#: xs/src/libslic3r/PrintConfig.cpp:1855 msgid "Maximal bridging distance" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1855 +#: xs/src/libslic3r/PrintConfig.cpp:1856 msgid "Maximal distance between supports on sparse infill sections. " msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1861 +#: xs/src/libslic3r/PrintConfig.cpp:1862 msgid "XY Size Compensation" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1863 +#: xs/src/libslic3r/PrintConfig.cpp:1864 msgid "" "The object will be grown/shrunk in the XY plane by the configured value " "(negative = inwards, positive = outwards). This might be useful for fine-" "tuning hole sizes." msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1871 +#: xs/src/libslic3r/PrintConfig.cpp:1872 msgid "Z offset" msgstr "" -#: xs/src/libslic3r/PrintConfig.cpp:1872 +#: xs/src/libslic3r/PrintConfig.cpp:1873 msgid "" "This value will be added (or subtracted) from all the Z coordinates in the " "output G-code. It is used to compensate for bad Z endstop position: for " @@ -4049,7 +4059,7 @@ msgstr "" msgid "No previously sliced file." msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:401 lib/Slic3r/GUI/Plater.pm:1342 +#: lib/Slic3r/GUI/MainFrame.pm:401 lib/Slic3r/GUI/Plater.pm:1354 msgid "Error" msgstr "" @@ -4073,7 +4083,7 @@ msgstr "" msgid "G-code" msgstr "" -#: lib/Slic3r/GUI/MainFrame.pm:445 lib/Slic3r/GUI/Plater.pm:1660 +#: lib/Slic3r/GUI/MainFrame.pm:445 lib/Slic3r/GUI/Plater.pm:1672 msgid " file as:" msgstr "" @@ -4126,7 +4136,7 @@ msgstr "" msgid "%d presets successfully imported." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:112 lib/Slic3r/GUI/Plater.pm:2153 +#: lib/Slic3r/GUI/Plater.pm:112 lib/Slic3r/GUI/Plater.pm:2172 msgid "3D" msgstr "" @@ -4171,17 +4181,17 @@ msgid "Scale…" msgstr "" #: lib/Slic3r/GUI/Plater.pm:198 lib/Slic3r/GUI/Plater.pm:214 -#: lib/Slic3r/GUI/Plater.pm:2128 +#: lib/Slic3r/GUI/Plater.pm:2147 msgid "Split" msgstr "" #: lib/Slic3r/GUI/Plater.pm:199 lib/Slic3r/GUI/Plater.pm:215 -#: lib/Slic3r/GUI/Plater.pm:2131 +#: lib/Slic3r/GUI/Plater.pm:2150 msgid "Cut…" msgstr "" #: lib/Slic3r/GUI/Plater.pm:201 lib/Slic3r/GUI/Plater.pm:216 -#: lib/Slic3r/GUI/Plater.pm:2135 +#: lib/Slic3r/GUI/Plater.pm:2154 msgid "Settings…" msgstr "" @@ -4193,422 +4203,422 @@ msgstr "" msgid "Layer editing" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:230 +#: lib/Slic3r/GUI/Plater.pm:236 msgid "Name" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:231 lib/Slic3r/GUI/Plater.pm:942 +#: lib/Slic3r/GUI/Plater.pm:237 lib/Slic3r/GUI/Plater.pm:954 msgid "Copies" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:232 lib/Slic3r/GUI/Plater.pm:1098 -#: lib/Slic3r/GUI/Plater.pm:1103 lib/Slic3r/GUI/Plater.pm:2097 +#: lib/Slic3r/GUI/Plater.pm:238 lib/Slic3r/GUI/Plater.pm:1110 +#: lib/Slic3r/GUI/Plater.pm:1115 lib/Slic3r/GUI/Plater.pm:2116 msgid "Scale" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:246 +#: lib/Slic3r/GUI/Plater.pm:252 msgid "Export G-code…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:247 +#: lib/Slic3r/GUI/Plater.pm:253 msgid "Slice now" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:248 +#: lib/Slic3r/GUI/Plater.pm:254 msgid "Print…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:249 +#: lib/Slic3r/GUI/Plater.pm:255 msgid "Send to printer" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:250 +#: lib/Slic3r/GUI/Plater.pm:256 msgid "Export STL…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:377 +#: lib/Slic3r/GUI/Plater.pm:383 msgid "Print settings" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:379 +#: lib/Slic3r/GUI/Plater.pm:385 msgid "Printer" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:411 +#: lib/Slic3r/GUI/Plater.pm:417 msgid "Info" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:422 +#: lib/Slic3r/GUI/Plater.pm:428 msgid "Volume" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:423 +#: lib/Slic3r/GUI/Plater.pm:429 msgid "Facets" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:424 +#: lib/Slic3r/GUI/Plater.pm:430 msgid "Materials" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:425 +#: lib/Slic3r/GUI/Plater.pm:431 msgid "Manifold" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:451 +#: lib/Slic3r/GUI/Plater.pm:457 msgid "Sliced Info" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:460 +#: lib/Slic3r/GUI/Plater.pm:466 msgid "Used Filament (m)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:461 +#: lib/Slic3r/GUI/Plater.pm:467 msgid "Used Filament (mm³)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:462 +#: lib/Slic3r/GUI/Plater.pm:468 msgid "Used Filament (g)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:464 +#: lib/Slic3r/GUI/Plater.pm:470 msgid "Estimated printing time" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:662 +#: lib/Slic3r/GUI/Plater.pm:674 msgid "Loading…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:662 lib/Slic3r/GUI/Plater.pm:676 +#: lib/Slic3r/GUI/Plater.pm:674 lib/Slic3r/GUI/Plater.pm:688 msgid "Processing input file\n" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:699 +#: lib/Slic3r/GUI/Plater.pm:711 msgid "" "This file contains several objects positioned at multiple heights. Instead " "of considering them as multiple objects, should I consider\n" "this file as a single object having multiple parts?\n" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:702 lib/Slic3r/GUI/Plater.pm:719 +#: lib/Slic3r/GUI/Plater.pm:714 lib/Slic3r/GUI/Plater.pm:731 msgid "Multi-part object detected" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:716 +#: lib/Slic3r/GUI/Plater.pm:728 msgid "" "Multiple objects were loaded for a multi-material printer.\n" "Instead of considering them as multiple objects, should I consider\n" "these files to represent a single object having multiple parts?\n" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:728 +#: lib/Slic3r/GUI/Plater.pm:740 msgid "Loaded " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:786 +#: lib/Slic3r/GUI/Plater.pm:798 msgid "" "Your object appears to be too large, so it was automatically scaled down to " "fit your print bed." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:787 +#: lib/Slic3r/GUI/Plater.pm:799 msgid "Object too large?" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:942 +#: lib/Slic3r/GUI/Plater.pm:954 msgid "Enter the number of copies of the selected object:" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:969 +#: lib/Slic3r/GUI/Plater.pm:981 msgid "" "\n" "Non-positive value." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:970 +#: lib/Slic3r/GUI/Plater.pm:982 msgid "" "\n" "Not a numeric value." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:971 +#: lib/Slic3r/GUI/Plater.pm:983 msgid "Slic3r Error" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:992 +#: lib/Slic3r/GUI/Plater.pm:1004 msgid "Enter the rotation angle:" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:992 +#: lib/Slic3r/GUI/Plater.pm:1004 msgid "Rotate around " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:992 +#: lib/Slic3r/GUI/Plater.pm:1004 msgid "Invalid rotation angle entered" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1072 +#: lib/Slic3r/GUI/Plater.pm:1084 #, possible-perl-format msgid "Enter the new size for the selected object (print bed: %smm):" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1073 lib/Slic3r/GUI/Plater.pm:1077 +#: lib/Slic3r/GUI/Plater.pm:1085 lib/Slic3r/GUI/Plater.pm:1089 msgid "Scale along " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1073 lib/Slic3r/GUI/Plater.pm:1077 -#: lib/Slic3r/GUI/Plater.pm:1098 lib/Slic3r/GUI/Plater.pm:1103 +#: lib/Slic3r/GUI/Plater.pm:1085 lib/Slic3r/GUI/Plater.pm:1089 +#: lib/Slic3r/GUI/Plater.pm:1110 lib/Slic3r/GUI/Plater.pm:1115 msgid "Invalid scaling value entered" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1077 lib/Slic3r/GUI/Plater.pm:1103 -#, no-perl-format +#: lib/Slic3r/GUI/Plater.pm:1089 lib/Slic3r/GUI/Plater.pm:1115 +#, possible-perl-format msgid "Enter the scale % for the selected object:" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1098 +#: lib/Slic3r/GUI/Plater.pm:1110 msgid "Enter the new max size for the selected object:" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1154 +#: lib/Slic3r/GUI/Plater.pm:1166 msgid "" "The selected object can't be split because it contains more than one volume/" "material." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1163 +#: lib/Slic3r/GUI/Plater.pm:1175 msgid "" "The selected object couldn't be split because it contains only one part." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1328 +#: lib/Slic3r/GUI/Plater.pm:1340 msgid "Slicing cancelled" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1342 +#: lib/Slic3r/GUI/Plater.pm:1354 msgid "Another export job is currently running." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1490 +#: lib/Slic3r/GUI/Plater.pm:1502 msgid "File added to print queue" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1496 +#: lib/Slic3r/GUI/Plater.pm:1508 msgid "G-code file exported to " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1499 +#: lib/Slic3r/GUI/Plater.pm:1511 msgid "Export failed" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1511 +#: lib/Slic3r/GUI/Plater.pm:1523 msgid "OctoPrint upload finished." msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1554 lib/Slic3r/GUI/Plater.pm:1596 +#: lib/Slic3r/GUI/Plater.pm:1566 lib/Slic3r/GUI/Plater.pm:1608 msgid "STL file exported to " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1607 +#: lib/Slic3r/GUI/Plater.pm:1619 msgid "AMF file exported to " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1611 +#: lib/Slic3r/GUI/Plater.pm:1623 msgid "Error exporting AMF file " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1623 +#: lib/Slic3r/GUI/Plater.pm:1635 msgid "3MF file exported to " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1627 +#: lib/Slic3r/GUI/Plater.pm:1639 msgid "Error exporting 3MF file " msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1985 +#: lib/Slic3r/GUI/Plater.pm:1997 #, possible-perl-format msgid "%d (%d shells)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1987 +#: lib/Slic3r/GUI/Plater.pm:1999 #, possible-perl-format msgid "Auto-repaired (%d errors)" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1992 +#: lib/Slic3r/GUI/Plater.pm:2004 #, possible-perl-format msgid "" "%d degenerate facets, %d edges fixed, %d facets removed, %d facets added, %d " "facets reversed, %d backwards edges" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:1997 +#: lib/Slic3r/GUI/Plater.pm:2009 msgid "Yes" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2050 +#: lib/Slic3r/GUI/Plater.pm:2069 msgid "Remove the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2053 +#: lib/Slic3r/GUI/Plater.pm:2072 msgid "Increase copies" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2053 +#: lib/Slic3r/GUI/Plater.pm:2072 msgid "Place one more copy of the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2056 +#: lib/Slic3r/GUI/Plater.pm:2075 msgid "Decrease copies" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2056 +#: lib/Slic3r/GUI/Plater.pm:2075 msgid "Remove one copy of the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2059 +#: lib/Slic3r/GUI/Plater.pm:2078 msgid "Set number of copies…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2059 +#: lib/Slic3r/GUI/Plater.pm:2078 msgid "Change the number of copies of the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2063 +#: lib/Slic3r/GUI/Plater.pm:2082 msgid "Rotate 45° clockwise" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2063 +#: lib/Slic3r/GUI/Plater.pm:2082 msgid "Rotate the selected object by 45° clockwise" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2066 +#: lib/Slic3r/GUI/Plater.pm:2085 msgid "Rotate 45° counter-clockwise" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2066 +#: lib/Slic3r/GUI/Plater.pm:2085 msgid "Rotate the selected object by 45° counter-clockwise" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2071 +#: lib/Slic3r/GUI/Plater.pm:2090 msgid "Rotate" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2071 +#: lib/Slic3r/GUI/Plater.pm:2090 msgid "Rotate the selected object by an arbitrary angle" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2073 +#: lib/Slic3r/GUI/Plater.pm:2092 msgid "Around X axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2073 +#: lib/Slic3r/GUI/Plater.pm:2092 msgid "Rotate the selected object by an arbitrary angle around X axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2076 +#: lib/Slic3r/GUI/Plater.pm:2095 msgid "Around Y axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2076 +#: lib/Slic3r/GUI/Plater.pm:2095 msgid "Rotate the selected object by an arbitrary angle around Y axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2079 +#: lib/Slic3r/GUI/Plater.pm:2098 msgid "Around Z axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2079 +#: lib/Slic3r/GUI/Plater.pm:2098 msgid "Rotate the selected object by an arbitrary angle around Z axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2084 +#: lib/Slic3r/GUI/Plater.pm:2103 msgid "Mirror" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2084 +#: lib/Slic3r/GUI/Plater.pm:2103 msgid "Mirror the selected object" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2086 lib/Slic3r/GUI/Plater.pm:2102 -#: lib/Slic3r/GUI/Plater.pm:2118 +#: lib/Slic3r/GUI/Plater.pm:2105 lib/Slic3r/GUI/Plater.pm:2121 +#: lib/Slic3r/GUI/Plater.pm:2137 msgid "Along X axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2086 +#: lib/Slic3r/GUI/Plater.pm:2105 msgid "Mirror the selected object along the X axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2089 lib/Slic3r/GUI/Plater.pm:2105 -#: lib/Slic3r/GUI/Plater.pm:2121 +#: lib/Slic3r/GUI/Plater.pm:2108 lib/Slic3r/GUI/Plater.pm:2124 +#: lib/Slic3r/GUI/Plater.pm:2140 msgid "Along Y axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2089 +#: lib/Slic3r/GUI/Plater.pm:2108 msgid "Mirror the selected object along the Y axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2092 lib/Slic3r/GUI/Plater.pm:2108 -#: lib/Slic3r/GUI/Plater.pm:2124 +#: lib/Slic3r/GUI/Plater.pm:2111 lib/Slic3r/GUI/Plater.pm:2127 +#: lib/Slic3r/GUI/Plater.pm:2143 msgid "Along Z axis…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2092 +#: lib/Slic3r/GUI/Plater.pm:2111 msgid "Mirror the selected object along the Z axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2097 lib/Slic3r/GUI/Plater.pm:2113 +#: lib/Slic3r/GUI/Plater.pm:2116 lib/Slic3r/GUI/Plater.pm:2132 msgid "Scale the selected object along a single axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2099 lib/Slic3r/GUI/Plater.pm:2115 +#: lib/Slic3r/GUI/Plater.pm:2118 lib/Slic3r/GUI/Plater.pm:2134 msgid "Uniformly…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2099 lib/Slic3r/GUI/Plater.pm:2115 +#: lib/Slic3r/GUI/Plater.pm:2118 lib/Slic3r/GUI/Plater.pm:2134 msgid "Scale the selected object along the XYZ axes" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2102 lib/Slic3r/GUI/Plater.pm:2118 +#: lib/Slic3r/GUI/Plater.pm:2121 lib/Slic3r/GUI/Plater.pm:2137 msgid "Scale the selected object along the X axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2105 lib/Slic3r/GUI/Plater.pm:2121 +#: lib/Slic3r/GUI/Plater.pm:2124 lib/Slic3r/GUI/Plater.pm:2140 msgid "Scale the selected object along the Y axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2108 lib/Slic3r/GUI/Plater.pm:2124 +#: lib/Slic3r/GUI/Plater.pm:2127 lib/Slic3r/GUI/Plater.pm:2143 msgid "Scale the selected object along the Z axis" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2113 +#: lib/Slic3r/GUI/Plater.pm:2132 msgid "Scale to size" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2128 +#: lib/Slic3r/GUI/Plater.pm:2147 msgid "Split the selected object into individual parts" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2131 +#: lib/Slic3r/GUI/Plater.pm:2150 msgid "Open the 3D cutting tool" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2135 +#: lib/Slic3r/GUI/Plater.pm:2154 msgid "Open the object editor dialog" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2139 +#: lib/Slic3r/GUI/Plater.pm:2158 msgid "Reload from Disk" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2139 +#: lib/Slic3r/GUI/Plater.pm:2158 msgid "Reload the selected file from Disk" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2142 +#: lib/Slic3r/GUI/Plater.pm:2161 msgid "Export object as STL…" msgstr "" -#: lib/Slic3r/GUI/Plater.pm:2142 +#: lib/Slic3r/GUI/Plater.pm:2161 msgid "Export this single object as STL file" msgstr "" diff --git a/resources/localization/es/Slic3rPE.mo b/resources/localization/es/Slic3rPE.mo new file mode 100644 index 0000000000000000000000000000000000000000..25939328bc71caab06429c14de10d48375540488 GIT binary patch literal 108284 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 UuW~n_$j1vEJFzwU{(sK?4@(8vlK=n! literal 0 HcmV?d00001 diff --git a/resources/localization/es/Slic3rPE_es.po b/resources/localization/es/Slic3rPE_es.po new file mode 100644 index 0000000000..077f9b2796 --- /dev/null +++ b/resources/localization/es/Slic3rPE_es.po @@ -0,0 +1,3512 @@ +msgid "" +msgstr "" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.6\n" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: Oleksandra Iushchenko \n" +"Language-Team: \n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 +msgid "" +"\n" +"\n" +"and it has the following unsaved changes:" +msgstr "" +"\n" +"\n" +"y tiene los siguientes cambios sin guardar:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1491 +msgid "" +"\n" +"\n" +"Discard changes and continue anyway?" +msgstr "" +"\n" +"\n" +"¿Descartar los cambios y continuar de todos modos?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1489 +msgid "" +"\n" +"\n" +"has the following unsaved changes:" +msgstr "" +"\n" +"\n" +"tiene los siguientes cambios sin guardar:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 +msgid "" +"\n" +"\n" +"is not compatible with printer\n" +msgstr "" +"\n" +"\n" +"no es compatible con la impresora\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:34 +msgid "" +"\n" +"During the other layers, fan " +msgstr "" +"\n" +"Durante las otras capas, ventilador " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:30 +#, c-format +msgid "" +"\n" +"If estimated layer time is greater, but still below ~%ds, fan will run at a proportionally decreasing speed between %d%% and %d%%." +msgstr "" +"\n" +"Si el tiempo estimado de la capa es mayor, pero todavía por debajo de ~%ds, el ventilador funcionará a una velocidad proporcionalmente menor entre %d%% y %d%%." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:927 +msgid "" +"\n" +"Non-positive value." +msgstr "" +"\n" +"Valor no positivo." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:928 +msgid "" +"\n" +"Not a numeric value." +msgstr "" +"\n" +"No es un valor numérico." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 +msgid " - Remember to check for updates at http://github.com/prusa3d/slic3r/releases" +msgstr " - Recuerda comprobar si hay actualizaciones en http://github.com/prusa3d/slic3r/releases" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 +msgid " as:" +msgstr " como:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:226 +#, c-format +msgid " at filament speed %3.2f mm/s." +msgstr "a una velocidad de filamento de %3.2f mm/s." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1035 +msgid " Browse " +msgstr " Hojea " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 +msgid " file as:" +msgstr " archivo como:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:215 +msgid " flow rate is maximized " +msgstr " la tasa de flujo se maximiza " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 +#, no-c-format +msgid "" +" infill pattern is not supposed to work at 100% density.\n" +"\n" +"Shall I switch to rectilinear fill pattern?" +msgstr "" +" ese patrón de relleno no está pensado para trabajar al 100% de densidad. \n" +"\n" +"¿Debería cambiar a un patrón de relleno rectilíneo?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1470 +msgid " preset\n" +msgstr " ajuste inicial\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 +msgid " preset" +msgstr " presente" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1583 +msgid " Preset" +msgstr " Ajuste inicial" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:942 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1637 +msgid " Set " +msgstr " Ajuste " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 +msgid " the selected preset?" +msgstr " el ajuste inicial seleccionado?" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:548 +msgid " was successfully sliced." +msgstr " fue laminado con éxito." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:220 +msgid " with a volumetric rate " +msgstr " con una tasa volumétrica " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:99 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:504 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:789 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:850 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1060 +msgid "%" +msgstr "%" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:224 +#, c-format +msgid "%3.2f mm³/s" +msgstr "%3.2f mm³/seg" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1958 +#, perl-format +msgid "%d (%d shells)" +msgstr "%d (%d pieles)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1965 +#, perl-format +msgid "%d degenerate facets, %d edges fixed, %d facets removed, %d facets added, %d facets reversed, %d backwards edges" +msgstr "%d facetas problemáticas, %d aristas corregidas, %d facetas eliminadas, %d facetas añadidas, %d facetas invertidas, %d aristas del revés" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:269 +#, c-format +msgid "%d lines: %.2lf mm" +msgstr "%d líneas: %.2lf mm" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:687 +#, perl-format +msgid "%d presets successfully imported." +msgstr "%d ajustes iniciales importados con éxito." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 +msgid "&About Slic3r" +msgstr "&Acerca de Slic3r" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 +msgid "&Configuration " +msgstr "&Configuración " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 +msgid "&Export Config Bundle…" +msgstr "&Exportar Conjunto de Ajustes…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 +msgid "&Export Config…\tCtrl+E" +msgstr "&Exportar Ajuste…\tCtrl+E" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:418 +msgid "&File" +msgstr "&Archivo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:426 +msgid "&Help" +msgstr "&Ayuda" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 +msgid "&Load Config Bundle…" +msgstr "&Cargar Conjunto de Ajustes…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 +msgid "&Load Config…\tCtrl+L" +msgstr "&Cargar configuración…\tCtrl+L" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:339 +msgid "&Localization" +msgstr "&Cambio de idioma" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:420 +msgid "&Object" +msgstr "&Objeto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:419 +msgid "&Plater" +msgstr "&Base" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 +msgid "&Quit" +msgstr "&Salir" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 +msgid "&Repeat Last Quick Slice\tCtrl+Shift+U" +msgstr "&Repetir último laminado\tCtrl+Shift+U" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:422 +msgid "&View" +msgstr "&Ver" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:421 +msgid "&Window" +msgstr "&Ventana" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 +msgid "(&Re)Slice Now\tCtrl+S" +msgstr "(&Re)Laminar Ahora\tCtrl+S" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:994 +msgid "(minimum)" +msgstr "(mínimo)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 +msgid ") not found." +msgstr ") no encontrado." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:215 +msgid "). Check hostname and OctoPrint version (at least 1.1.0 is required)." +msgstr "). Comprueba el nombre del equipo y la versión de OctoPrint (se necesita al menos la 1.1.0)." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 +msgid ". Discard changes and continue anyway?" +msgstr ". ¿Descartar los cambios y continuar de todos modos?" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:63 +msgid "1 Layer" +msgstr "1 Capa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:138 +msgid "2D" +msgstr "2D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:104 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2124 +msgid "3D" +msgstr "3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1608 +msgid "3MF file exported to " +msgstr "Archivo 3MF exportado a " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:185 +msgid "45° ccw" +msgstr "45º en sentido anti-horario" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:186 +msgid "45° cw" +msgstr "45º en sentido horario" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:148 +msgid "A boolean expression using the configuration values of an active printer profile. If this expression evaluates to true, this profile is considered compatible with the active printer profile." +msgstr "Una expresión booleana utilizando valores de configuración de un perfil existente. Si esta expresión es verdadera, el perfil será considerado compatible con el perfil de impresión activo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1099 +msgid "Above Z" +msgstr "Encima de Z" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:417 +msgid "Acceleration control (advanced)" +msgstr "Control de aceleración (avanzado)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1566 +msgid "Add a sheath (a single perimeter line) around the base support. This makes the support more reliable, but also more difficult to remove." +msgstr "Añadir una funda (una sola línea de perímetro) alrededor de la base del soporte. Esto hace el soporte más fiable pero también más difícil de retirar." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:299 +#, no-c-format +msgid "Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r keeps adding perimeters, until more than 70% of the loop immediately above is supported." +msgstr "Añadir más perímetros cuando se necesiten para evitar huecos en las paredes inclinadas. Slic3r sigue añadiendo perímetros hasta que más del 70% del perímetro superior sea soportado." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:240 +msgid "Add solid infill near sloping surfaces to guarantee the vertical shell thickness (top+bottom solid layers)." +msgstr "Añade un relleno completo cerca de las superficies inclinadas para garantizar el ancho vertical solicitado(capas sólidas arriba+abajo)." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:177 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:195 +msgid "Add…" +msgstr "Añadir…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:342 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:356 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:449 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:452 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:831 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1113 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:107 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:208 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:736 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1733 +msgid "Advanced" +msgstr "Avanzado" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1138 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:766 +msgid "After layer change G-code" +msgstr "Código G tras un cambio de capa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1636 +msgid "All" +msgstr "Todo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 +msgid "Along X axis…" +msgstr "A lo largo del eje X…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 +msgid "Along Y axis…" +msgstr "A lo largo del eje Y…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 +msgid "Along Z axis…" +msgstr "A lo largo del eje Z…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1592 +msgid "AMF file exported to " +msgstr "Archivo AMF exportado a " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 +msgid "Another export job is currently running." +msgstr "Otro trabajo de exportación está aún en marcha." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:901 +msgid "API Key" +msgstr "Clave API" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 +msgid "Application preferences" +msgstr "Preferencias de la aplicación" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 +msgid "Application will be restarted" +msgstr "El programa se reiniciará" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:397 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1242 +msgid "approximate seconds" +msgstr "segundos aproximadamente" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 +msgid "Are you sure you want to " +msgstr "¿Está seguro que quiere " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 +msgid "Around X axis…" +msgstr "Alrededor del eje X…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 +msgid "Around Y axis…" +msgstr "Alrededor del eje Y…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 +msgid "Around Z axis…" +msgstr "Alrededor del eje Z…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:180 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:198 +msgid "Arrange" +msgstr "Organiza" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:224 +msgid "Array of language names and identifiers should have the same size." +msgstr "La lista de nombres de idioma e identificadores debería tener el mismo tamaño." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 +msgid "Attention!" +msgstr "¡Atención!" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:35 +msgid "Auto-center parts" +msgstr "Piezas auto-centradas" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1960 +#, perl-format +msgid "Auto-repaired (%d errors)" +msgstr "Reparados automáticamente (%d errores)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 +msgid "Automatically repair an STL file" +msgstr "Archivo STL reparado automáticamente" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:424 +msgid "Autospeed (advanced)" +msgstr "Velocidad automática (avanzado)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:26 +msgid "Avoid crossing perimeters" +msgstr "Evita cruzar perímetros" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:43 +msgid "Background processing" +msgstr "Procesamiento en segundo plano" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:800 +msgid "Bed" +msgstr "Base" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp:42 +msgid "Bed Shape" +msgstr "Forma de la base de impresión" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:940 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:34 +msgid "Bed shape" +msgstr "Forma de la base de impresión" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:42 +msgid "Bed temperature" +msgstr "Temperatura de la base" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:39 +msgid "Bed temperature for layers after the first one. Set this to zero to disable bed temperature control commands in the output." +msgstr "Temperatura de la base calefactable para las capas después de la primera. Ajuste esto a cero para deshabilitar los comandos de control de temperatura de la base calefactable en la salida." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1132 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:48 +msgid "Before layer change G-code" +msgstr "Código G para antes del cambio de capa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1108 +msgid "Below Z" +msgstr "Por debajo de Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:59 +msgid "Between objects G-code" +msgstr "Código G para entre objetos" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1150 +msgid "Between objects G-code (for sequential printing)" +msgstr "Código G para entre objetos (para impresión secuencial)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:68 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 +msgid "Bottom" +msgstr "Inferior" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:72 +msgid "Bottom solid layers" +msgstr "Capas sólidas inferiores" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 +msgid "Bottom View" +msgstr "Vista inferior" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:77 +msgid "Bridge" +msgstr "Puente" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:106 +msgid "Bridge flow ratio" +msgstr "Relación de flujo del puente" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:144 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:86 +msgid "Bridge infill" +msgstr "Relleno de puente" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:117 +msgid "Bridges" +msgstr "Puentes" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:97 +msgid "Bridges fan speed" +msgstr "Velocidad del ventilador para puentes" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:86 +msgid "Bridging angle" +msgstr "Ãngulo de puente" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:88 +msgid "Bridging angle override. If left to zero, the bridging angle will be calculated automatically. Otherwise the provided angle will be used for all bridges. Use 180° for zero angle." +msgstr "Anulación de ángulo de puente. Si se deja en cero, el ángulo de puente se calculará automáticamente. De lo contrario, el ángulo proporcionado se usará para todos los puentes. Use 180 ° para ángulo con cero grados." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "Bridging volumetric" +msgstr "Puente volumétrico" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:371 +msgid "Brim" +msgstr "Margen" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:127 +msgid "Brim width" +msgstr "Ancho del margen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:218 +msgid "by the print profile maximum" +msgstr "por el máximo perfil de impresión" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:962 +msgid "Capabilities" +msgstr "Capacidades" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:325 +msgid "Change Application Language" +msgstr "Cambiar el Idioma de la Aplicación" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 +msgid "Change the number of copies of the selected object" +msgstr "Cambiar el número de copias del objeto seleccionado" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:298 +msgid "Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Escoja un archivo para importar la forma de la base de impresión (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:457 +msgid "Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Elija un archivo para laminar (STL / OBJ / AMF / 3MF / PRUSA):" + +#: c:\src\Slic3r\lib\Slic3r\GUI.pm:286 +msgid "Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Escoja uno o mas archivos (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:62 +msgid "Circular" +msgstr "Circular" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:135 +msgid "Clip multi-part objects" +msgstr "Enlazaar objetos de varias partes" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:405 +msgid "Color" +msgstr "Color" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:690 +msgid "Combine infill every" +msgstr "Combinar el relleno cada" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:696 +msgid "Combine infill every n layers" +msgstr "Combinar el relleno cada n capas" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:509 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:869 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1668 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:143 +msgid "Compatible printers" +msgstr "Impresoras compatibles" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:147 +msgid "Compatible printers condition" +msgstr "Condición de impresoras compatibles" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:154 +msgid "Complete individual objects" +msgstr "Completar objetos individuales" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:884 +msgid "Configuration notes" +msgstr "Notas de configuración" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1020 +msgid "Connection failed." +msgstr "Conexión fallida." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:211 +msgid "Connection to OctoPrint works correctly." +msgstr "La conexión a OctoPrint funciona correctamente." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 +msgid "Connection to printer works correctly." +msgstr "La conexión con la impresora funciona correctamente." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1416 +msgid "Contact Z distance" +msgstr "Distancia Z de contacto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:120 +msgid "Controller" +msgstr "Controlador" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:805 +msgid "Cooling" +msgstr "Enfriamiento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:826 +msgid "Cooling thresholds" +msgstr "Umbrales de enfriamiento" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:221 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 +msgid "Copies" +msgstr "Copias" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:476 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:450 +msgid "Cost" +msgstr "Coste" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1465 +msgid "Cover the top contact layer of the supports with loops. Disabled by default." +msgstr "Cubrir la capa de contacto superior de los soportes con bucles. Desactivado por defecto." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:71 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:150 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:92 +msgid "Custom" +msgstr "Personalizado" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:846 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119 +msgid "Custom G-code" +msgstr "Código G personalizado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:189 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:205 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 +msgid "Cut…" +msgstr "Cortar…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 +msgid "Decrease copies" +msgstr "Reducir copias" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:300 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:170 +msgid "Default" +msgstr "Por defecto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp:42 +msgid "default" +msgstr "por defecto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 +msgid "Default " +msgstr "Por defecto " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:489 +msgid "Default base angle for infill orientation. Cross-hatching will be applied to this. Bridges will be infilled using the best direction Slic3r can detect, so this setting does not affect them." +msgstr "Ãngulo base predeterminado para orientación de relleno. Se aplicará sombreado cruzado a esto. Los puentes se rellenarán utilizando la mejor dirección que Slic3r pueda detectar, por lo que esta configuración no los afecta." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:376 +msgid "Default extrusion width" +msgstr "Ancho de extrusión por defecto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:178 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:196 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 +msgid "Delete" +msgstr "Borra" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 +msgid "delete" +msgstr "borra" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:179 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:197 +msgid "Delete All" +msgstr "Borrar todo" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:51 +msgid "Delete this preset" +msgstr "Borra este ajuste" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:440 +msgid "Density" +msgstr "Densidad" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:503 +#, no-c-format +msgid "Density of internal infill, expressed in the range 0% - 100%." +msgstr "Densidad de relleno interior, expresado en el rango 0% - 100%." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:507 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:867 +msgid "Dependencies" +msgstr "Dependencias" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1724 +msgid "Depth of a wipe color per color change. For N colors, there will be maximum (N-1) tool switches performed, therefore the total depth of the wipe tower will be (N-1) times this value." +msgstr "La profundidad del color de limpieza por cambio de color. Para N colores, se realizarán cambios de herramienta máximos (N-1), por lo tanto, la profundidad total de la torre de limpieza será (N-1) multiplicada por este valor." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1142 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1143 +msgid "Deretraction Speed" +msgstr "Velocidad de deretracción" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:940 +msgid "Detect bridging perimeters" +msgstr "Detectar perímetros con puentes" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1584 +msgid "Detect single-width walls (parts where two extrusions don't fit and we need to collapse them into a single trace)." +msgstr "Detecta muros de ancho único (partes donde dos extrusiones no se ajustan y tenemos que colapsarlas en un solo rastro)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1582 +msgid "Detect thin walls" +msgstr "Detecta paredes delgadas" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 +msgid "Device Browser" +msgstr "Navegador de dispositivo" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:66 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:431 +msgid "Diameter" +msgstr "Diámetro" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:67 +msgid "Diameter of the print bed. It is assumed that origin (0,0) is located in the center." +msgstr "Diámetro de la base de impresión. Se supone que el origen (0,0) está ubicado en el centro." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1169 +msgid "Direction" +msgstr "Dirección" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:53 +msgid "Disable communication with the printer over a serial / USB cable. This simplifies the user interface in case the printer is never attached to the computer." +msgstr "Desactive la comunicación con la impresora a través de un puerto serie / USB. Esto simplifica la interfaz de usuario en caso de que la impresora nunca esté conectada a el ordenador." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:180 +msgid "Disable fan for the first" +msgstr "Desactivar ventilador para la primera" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:51 +msgid "Disable USB/serial connection" +msgstr "Deshabilitar la conexión USB / serie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:916 +msgid "Disables retraction when the travel path does not exceed the upper layer's perimeters (and thus any ooze will be probably invisible)." +msgstr "Desactiva la retracción cuando la trayectoria de desplazamiento no supera los perímetros de la capa superior (y, por lo tanto, cualquier goteo probablemente será invisible)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:198 +msgid "Distance between copies" +msgstr "Distancia entre copias" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1213 +msgid "Distance between skirt and object(s). Set this to zero to attach the skirt to the object(s) and get a brim for better adhesion." +msgstr "Distancia entre falda y objeto(s). Ajuste esto a cero para unir la falda a los objetos y obtener un borde para una mejor adhesión." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1212 +msgid "Distance from object" +msgstr "Distancia del objeto" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:58 +msgid "Distance of the 0,0 G-code coordinate from the front left corner of the rectangle." +msgstr "Distancia de la coordenada del código G de 0,0 de la esquina frontal izquierda del rectángulo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:199 +msgid "Distance used for the auto-arrange feature of the plater." +msgstr "Distancia utilizada para la función de organización automática de la base." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:190 +msgid "Don't support bridges" +msgstr "No soportar puentes" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:132 +msgid "Drag your objects here" +msgstr "Arrastre tus objetos aquí" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:207 +msgid "Elephant foot compensation" +msgstr "Compensación del pie de elefante" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:806 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:922 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1695 +msgid "Enable" +msgstr "Habilitar" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:163 +msgid "Enable auto cooling" +msgstr "Habilitar el enfriamiento automático" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:394 +msgid "Enable fan if layer print time is below" +msgstr "Habilitar ventilador si el tiempo de impresión de la capa está por debajo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1381 +msgid "Enable support material generation." +msgstr "Habilite la generación de material de soporte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:645 +msgid "Enable this to get a commented G-code file, with each line explained by a descriptive text. If you print from SD card, the additional weight of the file could make your firmware slow down." +msgstr "Habilítelo para obtener un archivo de código G comentado, con cada línea explicada por un texto descriptivo. Si imprime desde una tarjeta SD, el peso adicional del archivo podría ralentizar su firmware." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1681 +msgid "Enable variable layer height feature" +msgstr "Habilitar la función de altura de capa variable" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:853 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1126 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:217 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:227 +msgid "End G-code" +msgstr "Código G final" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1431 +msgid "Enforce support for the first" +msgstr "Forzar soportes para la primera" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1439 +msgid "Enforce support for the first n layers" +msgstr "Aplicar soportes para las primeras n capas" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:238 +msgid "Ensure vertical shell thickness" +msgstr "Asegurar el espesor de la carcasa vertical" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +msgid "Enter the new max size for the selected object:" +msgstr "Ingrese el nuevo tamaño máximo para el objeto seleccionado:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1030 +#, perl-format +msgid "Enter the new size for the selected object (print bed: %smm):" +msgstr "Ingrese el nuevo tamaño para el objeto seleccionado (base de impresión: %s mm):" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 +msgid "Enter the number of copies of the selected object:" +msgstr "Ingrese la cantidad de copias del objeto seleccionado:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Enter the rotation angle:" +msgstr "Ingrese el ángulo de rotación:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +#, no-perl-format +msgid "Enter the scale % for the selected object:" +msgstr "Ingrese la escala % para el objeto seleccionado:" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:477 +msgid "Enter your filament cost per kg here. This is only for statistical information." +msgstr "Ingrese su coste del filamento por kg aquí. Esto es solo para información estadística." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:441 +msgid "Enter your filament density here. This is only for statistical information. A decent way is to weigh a known length of filament and compute the ratio of the length to volume. Better is to calculate the volume directly through displacement." +msgstr "Ingrese su densidad de filamento aquí. Esto es solo para información estadística. Una forma decente es pesar una longitud conocida de filamento y calcular la relación entre la longitud y el volumen. Lo mejor es calcular el volumen directamente a través del desplazamiento." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:432 +msgid "Enter your filament diameter here. Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average." +msgstr "Ingrese el diámetro de su fila aquí. Se requiere una buena precisión, por lo tanto, use un calibre y realice múltiples mediciones a lo largo del filamento, luego calcule el promedio." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:488 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:470 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 +msgid "Error" +msgstr "Error" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1612 +msgid "Error exporting 3MF file " +msgstr "Error al exportar el archivo 3MF " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1596 +msgid "Error exporting AMF file " +msgstr "Error al exportar el archivo AMF " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1526 +msgid "Error while uploading to the OctoPrint server: " +msgstr "Error al cargar en el servidor OctoPrint: " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:315 +msgid "Error! " +msgstr "¡Error! " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:451 +msgid "Estimated printing time" +msgstr "Tiempo estimado de impresión" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:44 +#, c-format +msgid "except for the first %d layers" +msgstr "a excepción de las %d primeras capas" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:48 +msgid "except for the first layer" +msgstr "a excepción de la primera capa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:192 +msgid "Experimental option for preventing support material from being generated under bridged areas." +msgstr "Opción experimental para evitar que se genere material de soporte debajo de las áreas con puente." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:942 +msgid "Experimental option to adjust flow for overhangs (bridge flow will be used), to apply bridge speed to them and enable fan." +msgstr "Opción experimental para ajustar el flujo para salientes (se usará el flujo del puente), para aplicar la velocidad del puente a ellos y habilitar el ventilador." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 +msgid "Export all presets to file" +msgstr "Exportar todos los preajustes al archivo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 +msgid "Export current configuration to file" +msgstr "Exportar la configuración actual al archivo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 +msgid "Export current plate as 3MF" +msgstr "Exportar plataforma actual como 3MF" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 +msgid "Export current plate as AMF" +msgstr "Exportar plataforma actual como AMF" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 +msgid "Export current plate as G-code" +msgstr "Exportar plataforma actual como código G" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 +msgid "Export current plate as STL" +msgstr "Exportar plataforma actual como STL" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1454 +msgid "Export failed" +msgstr "Error al exportar" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 +msgid "Export G-code..." +msgstr "Exportar código G..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:236 +msgid "Export G-code…" +msgstr "Exportar código G…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 +msgid "Export object as STL…" +msgstr "Exportar plataforma como STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 +msgid "Export plate as 3MF..." +msgstr "Exportar plataforma como 3MF..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 +msgid "Export plate as AMF..." +msgstr "Exportar plataforma como AMF..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 +msgid "Export plate as STL..." +msgstr "Exportar plataforma como STL..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:240 +msgid "Export STL…" +msgstr "Exportar STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 +msgid "Export this single object as STL file" +msgstr "Exportar este único objeto como archivo STL" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:139 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:81 +msgid "External perimeter" +msgstr "Perímetro externo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:267 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:277 +msgid "External perimeters" +msgstr "Perímetros externos" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:151 +msgid "external perimeters" +msgstr "perímetros externos" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:289 +msgid "External perimeters first" +msgstr "Perímetros externos primero" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1118 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1126 +msgid "Extra length on restart" +msgstr "Longitud adicional en el reinicio" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:297 +msgid "Extra perimeters if needed" +msgstr "Perímetros adicionales si es necesario" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:795 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1234 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:307 +msgid "Extruder" +msgstr "Extrusor" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1187 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:400 +#, c-format +msgid "Extruder %d" +msgstr "Extrusor %d" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:479 +msgid "Extruder clearance (mm)" +msgstr "Distancia libre del extrusor (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:342 +msgid "Extruder Color" +msgstr "Color del extrusor" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:350 +msgid "Extruder offset" +msgstr "Offset del extrusor" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:626 +msgid "Extruder temperature for first layer. If you want to control temperature manually during print, set this to zero to disable temperature control commands in the output file." +msgstr "Temperatura del extrusor para la primera capa. Si desea controlar la temperatura manualmente durante la impresión, configúrela en cero para desactivar los comandos de control de temperatura en el archivo de salida." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1573 +msgid "Extruder temperature for layers after the first one. Set this to zero to disable temperature control commands in the output." +msgstr "Temperatura del extrusor para capas después del primera. Ajuste esto a cero para desactivar los comandos de control de temperatura en la salida." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:431 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:966 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:308 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:702 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:958 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1272 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1445 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1471 +msgid "Extruders" +msgstr "Extrusores" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:360 +msgid "Extrusion axis" +msgstr "Eje de extrusión" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:367 +msgid "Extrusion multiplier" +msgstr "Multiplicador de extrusión" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:453 +msgid "Extrusion width" +msgstr "Ancho de extrusión" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:268 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:377 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:592 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:710 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:967 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1292 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1454 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1614 +msgid "Extrusion Width" +msgstr "Ancho de Extrusión" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:410 +msgid "Facets" +msgstr "Facetas" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:36 +msgid "Fan " +msgstr "Ventilador " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:817 +msgid "Fan settings" +msgstr "Configuración del ventilador" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:818 +msgid "Fan speed" +msgstr "Velocidad del ventilador" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:330 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:68 +msgid "Feature type" +msgstr "Tipo de función" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:78 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:79 +msgid "Feature types" +msgstr "Tipos de funciones" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:183 +msgid "Fewer" +msgstr "Menos" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:786 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:787 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:368 +msgid "Filament" +msgstr "Filamento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:412 +msgid "Filament notes" +msgstr "Notas del filamento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:832 +msgid "Filament properties" +msgstr "Propiedades del filamento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:202 +msgid "Filament Settings" +msgstr "Configuración del filamento" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:450 +msgid "Filament type" +msgstr "Tipo de filamento" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1445 +msgid "File added to print queue" +msgstr "Archivo agregado a la cola de impresión" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:475 +msgid "File Not Found" +msgstr "Archivo no encontrado" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:487 +msgid "Fill angle" +msgstr "Ãngulo de relleno" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:501 +msgid "Fill density" +msgstr "Densidad de relleno" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:539 +msgid "Fill pattern" +msgstr "Patrón de relleno" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:541 +msgid "Fill pattern for general low-density infill." +msgstr "Patrón de relleno para el relleno general de baja densidad." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:248 +msgid "Fill pattern for top/bottom infill. This only affects the external visible layer, and not its adjacent solid shells." +msgstr "Patrón para el relleno superior / inferior. Esto solo afecta a la capa externa visible, y no a las capas sólidas adyacentes." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1110 +msgid "Firmware" +msgstr "Firmware" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1314 +msgid "Firmware Retraction" +msgstr "Retracción del firmware" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:573 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:582 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:591 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:625 +msgid "First layer" +msgstr "Primera capa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:603 +msgid "First layer height" +msgstr "Altura de la primera capa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:615 +msgid "First layer speed" +msgstr "Velocidad de la primera capa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "First layer volumetric" +msgstr "Primera capa volumétrica" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:466 +msgid "Flow" +msgstr "Flujo" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:599 +msgid "" +"For the Wipe Tower to work with the soluble supports, the support layers\n" +"need to be synchronized with the object layers.\n" +"\n" +"Shall I synchronize support layers in order to enable the Wipe Tower?" +msgstr "" +"Para que la Torre de Limpieza funcione con los soportes solubles, las capas de soporte deben sincronizarse con las capas de objeto. \n" +" \n" +" ¿Debería sincronizar las capas de soporte para habilitar la Torre de Limpieza?" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1264 +msgid "Force solid infill for regions having a smaller area than the specified threshold." +msgstr "Forzar el relleno sólido para las regiones que tienen un área más pequeña que el umbral especificado." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:758 +msgid "Force the generation of solid shells between adjacent materials/volumes. Useful for multi-extruder prints with translucent materials or manual soluble support material." +msgstr "Forzar la generación de carcasas sólidas entre materiales / volúmenes adyacentes. Útil para impresiones de múltiples extrusoras con materiales translúcidos o material de soporte soluble manual." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 +msgid "Front" +msgstr "Frontal" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 +msgid "Front View" +msgstr "Vista frontal" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +msgid "G-code" +msgstr "Código G" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1451 +msgid "G-code file exported to " +msgstr "Archivo de código G exportado a " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1524 +msgid "G-code file successfully uploaded to the OctoPrint server" +msgstr "El archivo de código G se cargó correctamente en el servidor OctoPrint" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:652 +msgid "G-code flavor" +msgstr "Tipo de código G" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:444 +msgid "g/cm³" +msgstr "g/cm³" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:634 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:145 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:87 +msgid "Gap fill" +msgstr "Relleno" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:937 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:11 +msgid "General" +msgstr "General" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:875 +msgid "Generate no less than the number of skirt loops required to consume the specified amount of filament on the bottom layer. For multi-extruder machines, this minimum applies to each extruder." +msgstr "Generar no menos que el número de bucles de falda requeridos para consumir la cantidad especificada de filamento en la capa inferior. Para máquinas multi-extrusoras, este mínimo se aplica a cada extrusora." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1379 +msgid "Generate support material" +msgstr "Generar material de soporte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1433 +msgid "Generate support material for the specified number of layers counting from bottom, regardless of whether normal support material is enabled or not and regardless of any angle threshold. This is useful for getting more adhesion of objects having a very thin or poor footprint on the build plate." +msgstr "Generar material de soporte para la cantidad especificada de capas contando desde abajo, independientemente de si el material de soporte normal está habilitado o no e independientemente de cualquier umbral de ángulo. Es útil para obtener una mayor adhesión de los objetos que tienen una huella muy delgada o deficiente en la placa de construcción." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:498 +msgid "GLUquadricObjPtr | Attempt to free unreferenced scalar" +msgstr "GLUquadricObjPtr | Intentar liberar el escalar sin referencias" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:583 +msgid "Heated build plate temperature for the first layer. Set this to zero to disable bed temperature control commands in the output." +msgstr "Temperatura de base calefactable para la primera capa. Ajuste esto a cero para deshabilitar los comandos de control de temperatura de la cama en la salida." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:320 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:69 +msgid "Height" +msgstr "Altura" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:332 +msgid "Height (mm)" +msgstr "Altura (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1222 +msgid "Height of skirt expressed in layers. Set this to a tall value to use skirt as a shield against drafts." +msgstr "Altura de la falda expresada en capas. Establezca esto en un valor alto para usar la falda como escudo contra corrientes de aire." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:329 +msgid "Horizontal shells" +msgstr "Carcasas horizontales" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:128 +msgid "Horizontal width of the brim that will be printed around each object on the first layer." +msgstr "Ancho horizontal del borde que se imprimirá alrededor de cada objeto en la primera capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:908 +msgid "Host or IP" +msgstr "Host o IP" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:214 +msgid "I wasn't able to connect to OctoPrint (" +msgstr "No pude conectarme a OctoPrint (" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:26 +#, c-format +msgid "If estimated layer time is below ~%ds, fan will run at %d%% and print speed will be reduced so that no less than %ds are spent on that layer (however, speed will never be reduced below %dmm/s)." +msgstr "Si el tiempo de capa estimado está por debajo de ~ %ds, el ventilador funcionará en %d %% y la velocidad de impresión se reducirá de modo que no se gaste menos de %d s en esa capa (sin embargo, la velocidad nunca se reducirá por debajo de %d mm/s) ." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:616 +msgid "If expressed as absolute value in mm/s, this speed will be applied to all the print moves of the first layer, regardless of their type. If expressed as a percentage (for example: 40%) it will scale the default speeds." +msgstr "Si se expresa como valor absoluto en mm / s, esta velocidad se aplicará a todos los movimientos de impresión de la primera capa, independientemente de su tipo. Si se expresa como un porcentaje (por ejemplo: 40%), escalará las velocidades predeterminadas." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:395 +msgid "If layer print time is estimated below this number of seconds, fan will be enabled and its speed will be calculated by interpolating the minimum and maximum speeds." +msgstr "Si el tiempo de impresión de capa se estima por debajo de este número de segundos, el ventilador se habilitará y su velocidad se calculará al interpolar las velocidades mínima y máxima." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1240 +msgid "If layer print time is estimated below this number of seconds, print moves speed will be scaled down to extend duration to this value." +msgstr "Si el tiempo de impresión de la capa se estima por debajo de este número de segundos, la velocidad de los movimientos de impresión se reducirá para extender la duración a este valor." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:388 +msgid "If this is enabled, fan will never be disabled and will be kept running at least at its minimum speed. Useful for PLA, harmful for ABS." +msgstr "Si esto está habilitado, el ventilador nunca se desactivará y se mantendrá funcionando al menos a su velocidad mínima. Útil para PLA, no recomendado para ABS." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:37 +msgid "If this is enabled, Slic3r will auto-center objects around the print bed center." +msgstr "Si esto está habilitado, Slic3r centrará automáticamente los objetos alrededor del centro de la base de impresión." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:45 +msgid "If this is enabled, Slic3r will pre-process objects as soon as they're loaded in order to save time when exporting G-code." +msgstr "Si esto está habilitado, Slic3r preprocesará objetos tan pronto como se carguen para ahorrar tiempo al exportar el código G." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:29 +msgid "If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files." +msgstr "Si esto está habilitado, Slic3r solicitará el último directorio de salida en lugar del que contiene los archivos de entrada." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:77 +msgid "If you have rendering issues caused by a buggy OpenGL 2.0 driver, you may try to check this checkbox. This will disable the layer height editing and anti aliasing, so it is likely better to upgrade your graphics driver." +msgstr "Si tiene problemas de procesamiento causados ​​por un controlador OpenGL 2.0 defectuoso, puede intentar marcar esta casilla de verificación. Esto desactivará la edición de altura de capa y el antialiasing, por lo que es mejor actualizar su controlador de gráficos." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1091 +msgid "If you set this to a positive value, Z is quickly raised every time a retraction is triggered. When using multiple extruders, only the setting for the first extruder will be considered." +msgstr "Si establece esto en un valor positivo, Z se levantará rápidamente cada vez que se active una retracción. Cuando se usan múltiples extrusores , solo se considerará la configuración del primer extrusor." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1101 +msgid "If you set this to a positive value, Z lift will only take place above the specified absolute Z. You can tune this setting for skipping lift on the first layers." +msgstr "Si establece esto en un valor positivo, la elevación de Z solo tendrá lugar por encima de la Z absoluta especificada. Puede ajustar esta configuración para omitir el levantamiento en las primeras capas." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1110 +msgid "If you set this to a positive value, Z lift will only take place below the specified absolute Z. You can tune this setting for limiting lift to the first layers." +msgstr "Si configura esto en un valor positivo, la elevación Z solo tendrá lugar por debajo de la Z absoluta especificada. Puede ajustar esta configuración para limitar la elevación a las primeras capas." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:451 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1002 +msgid "If you want to process the output G-code through custom scripts, just list their absolute paths here. Separate multiple scripts with a semicolon. Scripts will be passed the absolute path to the G-code file as the first argument, and they can access the Slic3r config settings by reading environment variables." +msgstr "Si desea procesar el código G de salida a través de scripts personalizados, simplemente haga una lista de sus rutas absolutas aquí. Separe los scripts múltiples con un punto y coma. Los scripts se pasarán por la ruta absoluta al archivo de código G como primer argumento, y pueden acceder a la configuración de configuración de Slic3r leyendo las variables de entorno." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:351 +msgid "If your firmware doesn't handle the extruder displacement you need the G-code to take it into account. This option lets you specify the displacement of each extruder with respect to the first one. It expects positive coordinates (they will be subtracted from the XY coordinate)." +msgstr "Si su firmware no maneja el desplazamiento del extrusor, necesita el código G para tenerlo en cuenta. Esta opción le permite especificar el desplazamiento de cada extrusora con respecto a la primera. Se esperan coordenadas positivas (se restarán de la coordenada XY)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1664 +msgid "If your firmware requires relative E values, check this, otherwise leave it unchecked. Most firmwares use absolute values." +msgstr "Si su firmware requiere valores E relativos, verifique esto, de lo contrario, deje sin marcar. La mayoría de los firmwares usan valores absolutos." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 +msgid "Increase copies" +msgstr "Aumentar copias" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:346 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:347 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:664 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:87 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:247 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:488 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:502 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:540 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:681 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:691 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:709 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:727 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:746 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1263 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1280 +msgid "Infill" +msgstr "Relleno" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:169 +msgid "infill" +msgstr "relleno" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:720 +msgid "Infill before perimeters" +msgstr "Rellenar antes que los perímetros" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:701 +msgid "Infill extruder" +msgstr "Extrusor de relleno" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:735 +msgid "Infill/perimeters overlap" +msgstr "Superposición de relleno/perímetros" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:398 +msgid "Info" +msgstr "Info" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1479 +msgid "Interface layers" +msgstr "Capas de interfaz" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1463 +msgid "Interface loops" +msgstr "Bucles de interfaz" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1488 +msgid "Interface pattern spacing" +msgstr "Espaciado de patrón de interfaz" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:757 +msgid "Interface shells" +msgstr "Carcasas de interfaz" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:141 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:83 +msgid "Internal infill" +msgstr "Relleno interno" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Invalid rotation angle entered" +msgstr "Ãngulo de rotación introducido inválido" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +msgid "Invalid scaling value entered" +msgstr "Valor de escala introducido inválido" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 +msgid "Iso" +msgstr "Iso" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 +msgid "Iso View" +msgstr "Vista Iso" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1180 +msgid "Jitter" +msgstr "Jitter" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:387 +msgid "Keep fan always on" +msgstr "Mantener el ventilador siempre encendido" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 +msgid "Language" +msgstr "Idioma" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:192 +msgid "Layer Editing" +msgstr "Edición de Capa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:207 +msgid "Layer editing" +msgstr "Edición de capa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:314 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:777 +msgid "Layer height" +msgstr "Altura de la capa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1194 +msgid "Layer height limits" +msgstr "Límites de altura de la capa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:157 +msgid "Layers" +msgstr "Capas" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:183 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:694 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1033 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1224 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1285 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1437 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1482 +msgid "layers" +msgstr "capas" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:69 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:239 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:290 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:298 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:604 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:762 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:778 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:941 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:989 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1152 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1583 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1639 +msgid "Layers and Perimeters" +msgstr "Capas y Perímetros" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:313 +msgid "Layers and perimeters" +msgstr "Capas y perímetros" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 +msgid "Left" +msgstr "Izquierda" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 +msgid "Left View" +msgstr "Vista izquierda" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1071 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1080 +msgid "Length" +msgstr "Largo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1090 +msgid "Lift Z" +msgstr "Levantar Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 +msgid "Load exported configuration file" +msgstr "Cargar archivo de configuración exportado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 +msgid "Load presets from a bundle" +msgstr "Cargar preajustes de un paquete" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:75 +msgid "Load shape from STL..." +msgstr "Cargar forma desde STL..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:692 +msgid "Loaded " +msgstr "Cargado " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 +msgid "Loading…" +msgstr "Cargando…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1229 +msgid "Loops (minimum)" +msgstr "Bucles (mínimo)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:412 +msgid "Manifold" +msgstr "Manifold" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:411 +msgid "Materials" +msgstr "Materiales" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:787 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:796 +msgid "Max" +msgstr "Max" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:807 +msgid "Max print speed" +msgstr "Velocidad máxima de impresión" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:837 +msgid "Max volumetric slope negative" +msgstr "Máx. Pendiente volumétrica negativa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:826 +msgid "Max volumetric slope positive" +msgstr "Máx. Pendiente volumétrica positiva" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:421 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:817 +msgid "Max volumetric speed" +msgstr "Velocidad volumétrica máxima" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:422 +msgid "Maximum volumetric speed allowed for this filament. Limits the maximum volumetric speed of a print to the minimum of print and filament volumetric speed. Set to zero for no limit." +msgstr "Velocidad volumétrica máxima permitida para este filamento. Limita la velocidad volumétrica máxima de una impresión al mínimo de velocidad volumétrica de impresión y filamento. Establecer en cero para usar sin límite." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:848 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:857 +msgid "Min" +msgstr "Min" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:866 +msgid "Min print speed" +msgstr "Velocidad de impresión mínima" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1040 +msgid "Minimum detail resolution, used to simplify the input file for speeding up the slicing job and reducing memory usage. High-resolution models often carry more detail than printers can render. Set to zero to disable any simplification and use full resolution from input." +msgstr "Resolución mínima de detalles, utilizada para simplificar el archivo de entrada para acelerar el trabajo de laminado y reducir el uso de memoria. Los modelos de alta resolución suelen llevar más detalles de los que las impresoras pueden ofrecer. Establézcalo en cero para desactivar cualquier simplificación y usar la resolución completa de la entrada." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:874 +msgid "Minimum extrusion length" +msgstr "Distancia mínima de extrusión" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1050 +msgid "Minimum travel after retraction" +msgstr "Distancia mínima después de la retracción" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 +msgid "Mirror" +msgstr "Duplicar" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 +msgid "Mirror the selected object" +msgstr "Duplicar el objeto seleccionado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 +msgid "Mirror the selected object along the X axis" +msgstr "Duplicar el objeto seleccionado a lo largo del eje X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 +msgid "Mirror the selected object along the Y axis" +msgstr "Duplicar el objeto seleccionado a lo largo del eje Y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 +msgid "Mirror the selected object along the Z axis" +msgstr "Duplicar el objeto seleccionado a lo largo del eje Z" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:151 +msgid "Mixed" +msgstr "Mezclado" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:65 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:129 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:200 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:211 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:325 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:336 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:355 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:434 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:781 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:801 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:860 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:878 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:896 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1044 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1052 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1094 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1103 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1113 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1121 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1129 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1215 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1421 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1491 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1527 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1704 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1711 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1718 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1727 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1737 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1747 +msgid "mm" +msgstr "mm" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1075 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1085 +msgid "mm (zero to disable)" +msgstr "mm (cero para deshabilitar)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:609 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:740 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1390 +msgid "mm or %" +msgstr "mm o %" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:382 +msgid "mm or % (leave 0 for auto)" +msgstr "mm o % (dejar 0 para automático)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:272 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:597 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:715 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:972 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1296 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1458 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1619 +msgid "mm or % (leave 0 for default)" +msgstr "mm o % (dejar 0 por defecto)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:120 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:638 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:749 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:811 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:868 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:981 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1137 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1146 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1536 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1649 +msgid "mm/s" +msgstr "mm/s" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:282 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:619 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1255 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1306 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1501 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1631 +msgid "mm/s or %" +msgstr "mm/s o %" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:80 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:174 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:576 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:684 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:952 +msgid "mm/s²" +msgstr "mm/s²" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1265 +msgid "mm²" +msgstr "mm²" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:425 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:820 +msgid "mm³/s" +msgstr "mm³/s" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:831 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:842 +msgid "mm³/s²" +msgstr "mm³/s²" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:414 +msgid "Modifiers" +msgstr "Modificadores" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:478 +msgid "money/kg" +msgstr "dinero/kg" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:182 +msgid "More" +msgstr "Más" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1696 +msgid "Multi material printers may need to prime or purge extruders on tool changes. Extrude the excess material into the wipe tower." +msgstr "Las impresoras de varios materiales pueden necesitar cebar o purgar extrusoras en los cambios de herramientas. Extruya el exceso de material en la torre de limpieza." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:666 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:683 +msgid "Multi-part object detected" +msgstr "Objeto de piezas múltiples detectado" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:430 +msgid "Multiple Extruders" +msgstr "Múltiples Extrusores" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:680 +msgid "" +"Multiple objects were loaded for a multi-material printer.\n" +"Instead of considering them as multiple objects, should I consider\n" +"these files to represent a single object having multiple parts?\n" +msgstr "" +"Se cargaron varios objetos para una impresora de varios materiales.\n" +"En lugar de considerarlos como objetos múltiples, ¿debería considerar\n" +"estos archivos para formar un solo objeto que tiene varias partes?\n" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:220 +msgid "Name" +msgstr "Nombre" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 +msgid "No Bonjour device found" +msgstr "No se encontró ningún dispositivo Bonjour" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:469 +msgid "No previously sliced file." +msgstr "Ningún archivo previamente laminado." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:137 +msgid "None" +msgstr "Ninguno" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:500 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:501 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:859 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:860 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1156 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1157 +msgid "Notes" +msgstr "Notas" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:493 +msgid "Notice" +msgstr "Date cuenta" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:894 +msgid "Nozzle diameter" +msgstr "Diámetro de la boquilla" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:967 +msgid "Number of extruders of the printer." +msgstr "Número de extrusores de la impresora." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1481 +msgid "Number of interface layers to insert between the object(s) and support material." +msgstr "Número de capas de interfaz para insertar entre el (los) objeto(s) y el material de soporte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1231 +msgid "Number of loops for the skirt. If the Minimum Extrusion Length option is set, the number of loops might be greater than the one configured here. Set this to zero to disable skirt completely." +msgstr "Número de vueltas para la falda Si se establece la opción Longitud Mínima de Extrusión, el número de bucles puede ser mayor que el configurado aquí. Ajuste esto a cero para deshabilitar la falda por completo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:70 +msgid "Number of solid layers to generate on bottom surfaces." +msgstr "Número de capas sólidas para generar en las superficies inferiores." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1315 +msgid "Number of solid layers to generate on top and bottom surfaces." +msgstr "Número de capas sólidas para generar en las superficies superior e inferior." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1640 +msgid "Number of solid layers to generate on top surfaces." +msgstr "Número de capas sólidas para generar en las superficies superiores." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:745 +msgid "Object too large?" +msgstr "Objeto demasiado grande?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1032 +msgid "OctoPrint upload" +msgstr "Cargar en OctoPrint" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1410 +msgid "Only create support if it lies on a build plate. Don't create support on a print." +msgstr "Solo crear soportes si está en contacto con la plataforma. No crea soporte en la impresión." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:726 +msgid "Only infill where needed" +msgstr "Solo rellenar cuando sea necesario" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1205 +msgid "Only lift Z" +msgstr "Solo levantar Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1100 +msgid "Only lift Z above" +msgstr "Solo levantar Z mayor que" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1109 +msgid "Only lift Z below" +msgstr "Solo levantar Z menor que" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:915 +msgid "Only retract when crossing perimeters" +msgstr "Solo retraer al cruzar perímetros" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:438 +msgid "Ooze prevention" +msgstr "Prevención de goteo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 +msgid "Open a model" +msgstr "Abrir un modelo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 +msgid "Open STL/OBJ/AMF…\tCtrl+O" +msgstr "Abrir STL/OBJ/AMF…\tCtrl+O" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 +msgid "Open the 3D cutting tool" +msgstr "Abrir la herramienta de corte 3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 +msgid "Open the object editor dialog" +msgstr "Abrir el cuadro del editor de objetos" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 +msgid "Open the Prusa Edition releases page in your browser" +msgstr "Abrir la página de lanzamientos de Prusa Edition en su navegador" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 +msgid "Open the Prusa3D drivers download page in your browser" +msgstr "Abrir la página de descarga de los controladores Prusa3D en su navegador" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 +msgid "Open the Slic3r manual in your browser" +msgstr "Abrir el manual de Slic3r en su navegador" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 +msgid "Open the Slic3r website in your browser" +msgstr "Abrir el sitio web de Slic3r en su navegador" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:27 +msgid "Optimize travel moves in order to minimize the crossing of perimeters. This is mostly useful with Bowden extruders which suffer from oozing. This feature slows down both the print and the G-code generation." +msgstr "Optimiza los movimientos de desplazamiento para minimizar el cruce de perímetros. Esto es principalmente útil con extrusores Bowden que sufren goteo. Esta característica ralentiza tanto la impresión como la generación de código G." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:384 +msgid "Options for support material and raft" +msgstr "Opciones de material de soporte y balsa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:57 +msgid "Origin" +msgstr "Origen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:469 +msgid "Other" +msgstr "Otro" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:38 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1572 +msgid "Other layers" +msgstr "Otras capas" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:488 +msgid "Output file" +msgstr "Archivo de salida" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:930 +msgid "Output filename format" +msgstr "Formato de nombre de salida" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:476 +msgid "Output options" +msgstr "Opciones de salida" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:140 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:82 +msgid "Overhang perimeter" +msgstr "Perímetro de voladizos" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1550 +msgid "Overhang threshold" +msgstr "Umbral de voladizos" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:463 +msgid "Overlap" +msgstr "Superposición" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1508 +msgid "Pattern" +msgstr "Patrón" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1398 +msgid "Pattern angle" +msgstr "Ãngulo del patrón" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1524 +msgid "Pattern spacing" +msgstr "Espaciado entre patrones" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1510 +msgid "Pattern used to generate support material." +msgstr "Patrón utilizado para generar material de soporte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1723 +msgid "Per color change depth" +msgstr "Por profundidad de cambio de color" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:138 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:80 +msgid "Perimeter" +msgstr "Perímetro" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:957 +msgid "Perimeter extruder" +msgstr "Extrusor de perímetros" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:160 +msgid "perimeters" +msgstr "perímetros" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:948 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:966 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:978 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:988 +msgid "Perimeters" +msgstr "Perímetros" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 +msgid "Place one more copy of the selected object" +msgstr "Colocar una copia más del objeto seleccionado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:118 +msgid "Plater" +msgstr "Plataforma" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1199 +msgid "Position (for multi-extruder printers)" +msgstr "Posición (para impresoras con múltiples extrusores )" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1153 +msgid "Position of perimeters starting points." +msgstr "Posición de los puntos de inicio del perímetro." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1702 +msgid "Position X" +msgstr "Posición X" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1709 +msgid "Position Y" +msgstr "Posición Y" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:494 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1001 +msgid "Post-processing scripts" +msgstr "Scripts de postprocesamiento" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp:17 +msgid "Preferences" +msgstr "Preferencias" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 +msgid "Preferences…\tCtrl+," +msgstr "Preferencias…\tCtrl+," + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1171 +msgid "Preferred direction of the seam" +msgstr "Dirección preferida de la costura" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1183 +msgid "Preferred direction of the seam - jitter" +msgstr "Dirección preferida de la unión - jitter" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1222 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:150 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2125 +msgid "Preview" +msgstr "Previsualización" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 +msgid "Previously sliced file (" +msgstr "Archivo anterior laminado (" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:291 +msgid "Print contour perimeters from the outermost one to the innermost one instead of the default inverse order." +msgstr "Imprimir perímetros de contorno desde el más externo hasta el más interno en lugar del orden inverso predeterminado." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:182 +msgid "Print Settings" +msgstr "Configuración de Impresión" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:367 +msgid "Print settings" +msgstr "Configuración de impresión" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:836 +msgid "Print speed override" +msgstr "Anular la velocidad de impresión" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:369 +msgid "Printer" +msgstr "Impresora" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1014 +msgid "Printer notes" +msgstr "Notas de la impresora" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:228 +msgid "Printer Settings" +msgstr "Configuración de la Impresora" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:238 +msgid "Print…" +msgstr "Imprimir…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 +msgid "Processing " +msgstr "Procesamiento " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:643 +msgid "Processing input file\n" +msgstr "Procesando archivo de entrada \n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:508 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:868 +msgid "Profile dependencies" +msgstr "Dependencias de perfil" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 +msgid "Prusa 3D Drivers" +msgstr "Controladores de Prusa 3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 +msgid "Prusa Edition Releases" +msgstr "Lanzamientos de la Edición Prusa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 +msgid "Q&uick Slice…\tCtrl+U" +msgstr "L&áminado Rápido…\tCtrl+U" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:335 +msgid "Quality (slower slicing)" +msgstr "Calidad (laminado más lento)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 +msgid "Quick Slice and Save &As…\tCtrl+Alt+U" +msgstr "Láminado Rápido y Guardar &Como…\tCtrl+Alt+U" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 +msgid "Quit Slic3r" +msgstr "Salir de Slic3r" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:331 +msgid "Radius" +msgstr "Radio" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:380 +msgid "Raft" +msgstr "Balsa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1029 +msgid "Raft layers" +msgstr "Capas de balsa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 +msgid "Rear" +msgstr "Trasera" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 +msgid "Rear View" +msgstr "Vista trasera" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:262 +#, c-format +msgid "Recommended object thin wall thickness for layer height %.2f and " +msgstr "Espesor de pared delgada del objeto recomendado para una altura de capa %.2f y " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:245 +msgid "Recommended object thin wall thickness: Not available due to invalid layer height." +msgstr "Grosor recomendado de la pared del objeto recomendado: no disponible debido a la altura de capa no válida." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:46 +msgid "Rectangular" +msgstr "Rectangular" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:352 +msgid "Reducing printing time" +msgstr "Reduciendo el tiempo de impresión" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 +msgid "Reload from Disk" +msgstr "Recargar desde el disco" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 +msgid "Reload the selected file from Disk" +msgstr "Recargar el archivo seleccionado del disco" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:27 +msgid "Remember output directory" +msgstr "Recordar el directorio de salida" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 +msgid "Remove" +msgstr "Eliminar" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 +msgid "remove" +msgstr "eliminar" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 +msgid "Remove one copy of the selected object" +msgstr "Eliminar una copia del objeto seleccionado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 +msgid "Remove the selected object" +msgstr "Eliminar el objeto seleccionado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 +msgid "Repair" +msgstr "Reparar" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 +msgid "Repair STL file…" +msgstr "Reparar el archivo STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 +msgid "Repeat last quick slice" +msgstr "Repetir el último laminado rápido" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 +msgid "Report an Issue" +msgstr "Informar de un problema" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 +msgid "Report an issue on the Slic3r Prusa Edition" +msgstr "Informar de un problema de Slic3r Edición Prusa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:995 +msgid "Rescan serial ports" +msgstr "Vuelver a examinar los puertos serie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1039 +msgid "Resolution" +msgstr "Resolución" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1057 +msgid "Retract amount before wipe" +msgstr "Retracta cantidad antes de limpiar" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1065 +msgid "Retract on layer change" +msgstr "Retraer en el cambio de capa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1202 +msgid "Retraction" +msgstr "Retracción" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1051 +msgid "Retraction is not triggered when travel moves are shorter than this length." +msgstr "La retracción no se activa cuando los movimientos de desplazamiento son más cortos que esta longitud." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1072 +msgid "Retraction Length" +msgstr "Longitud de retracción" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1081 +msgid "Retraction Length (Toolchange)" +msgstr "Longitud de retracción (cambio de herramienta)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1134 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1135 +msgid "Retraction Speed" +msgstr "Velocidad de retracción" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1218 +msgid "Retraction when tool is disabled (advanced settings for multi-extruder setups)" +msgstr "Retracción cuando la herramienta está desactivada (configuraciones avanzadas para configuraciones de extrusores múltiples )" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:96 +msgid "Retractions" +msgstr "Retracciones" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 +msgid "Right" +msgstr "Derecha" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 +msgid "Right View" +msgstr "Vista derecha" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 +msgid "Rotate" +msgstr "Girar" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 +msgid "Rotate 45° clockwise" +msgstr "Girar 45 ° en el sentido de las agujas del reloj" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 +msgid "Rotate 45° counter-clockwise" +msgstr "Girar 45 ° en el sentido contrario a las agujas del reloj" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Rotate around " +msgstr "Girar alrededor " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 +msgid "Rotate the selected object by 45° clockwise" +msgstr "Girar el objeto seleccionado 45 ° en el sentido de las agujas del reloj" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 +msgid "Rotate the selected object by 45° counter-clockwise" +msgstr "Girar el objeto seleccionado 45 ° en el sentido contrario a las agujas del reloj" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 +msgid "Rotate the selected object by an arbitrary angle" +msgstr "Girar el objeto seleccionado según un ángulo arbitrario" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 +msgid "Rotate the selected object by an arbitrary angle around X axis" +msgstr "Girar el objeto seleccionado por un ángulo arbitrario alrededor del eje X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 +msgid "Rotate the selected object by an arbitrary angle around Y axis" +msgstr "Gira el objeto seleccionado por un ángulo arbitrario alrededor del eje Y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 +msgid "Rotate the selected object by an arbitrary angle around Z axis" +msgstr "Gira el objeto seleccionado por un ángulo arbitrario alrededor del eje Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 +msgid "Run Configuration " +msgstr "Ejecutar configuración " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 +msgid "Save " +msgstr "Guardar " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:605 +msgid "Save configuration as:" +msgstr "Guardar la configuración como:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:50 +msgid "Save current " +msgstr "Guardar actualmente " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:580 +msgid "Save OBJ file (less prone to coordinate errors than STL) as:" +msgstr "Guardar archivo OBJ (menos propenso a errores de coordinación que STL) como:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:248 +msgid "Save preset" +msgstr "Guardar ajuste inicial" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:646 +msgid "Save presets bundle as:" +msgstr "Guarde el conjunto de ajustes iniciales como:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:222 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 +msgid "Scale" +msgstr "Escalar" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +msgid "Scale along " +msgstr "Escalar a lo largo " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 +msgid "Scale the selected object along a single axis" +msgstr "Escalar el objeto seleccionado a lo largo de un solo eje" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 +msgid "Scale the selected object along the X axis" +msgstr "Escalar el objeto seleccionado a lo largo del eje X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 +msgid "Scale the selected object along the XYZ axes" +msgstr "Escalar el objeto seleccionado a lo largo de los ejes XYZ" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 +msgid "Scale the selected object along the Y axis" +msgstr "Escalar el objeto seleccionado a lo largo del eje Y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 +msgid "Scale the selected object along the Z axis" +msgstr "Escalar el objeto seleccionado a lo largo del eje Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 +msgid "Scale to size" +msgstr "Escalar al tamaño" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:187 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:203 +msgid "Scale…" +msgstr "Escalar…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1151 +msgid "Seam position" +msgstr "Posición de la costura" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1172 +msgid "Seam preferred direction" +msgstr "Dirección de la costura" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1182 +msgid "Seam preferred direction jitter" +msgstr "Dirección preferida de unión jitter" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 +msgid "Select &Controller Tab\tCtrl+T" +msgstr "Seleccionar la pestaña Ajustes de &Controlador\tCtrl+T" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 +msgid "Select &Filament Settings Tab\tCtrl+3" +msgstr "Seleccionar la pestaña Ajustes de &Filamento\tCtrl+3" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 +msgid "Select &Plater Tab\tCtrl+1" +msgstr "Seleccionar la pestaña Ajustes de la &base\tCtrl+1" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:623 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:667 +msgid "Select configuration to load:" +msgstr "Seleccione la configuración para cargar:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 +msgid "Select P&rint Settings Tab\tCtrl+2" +msgstr "Seleccionar la pestaña Ajustes de im&presión\tCtrl+2" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 +msgid "Select Print&er Settings Tab\tCtrl+4" +msgstr "Selecccionar la pestaña Ajustes de imp&resora\tCtrl+4" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 +msgid "Select the language" +msgstr "Seleccione el idioma" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1667 +msgid "Select the printers this profile is compatible with." +msgstr "Seleccione las impresoras con las que este perfil es compatible." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:566 +msgid "Select the STL file to repair:" +msgstr "Seleccione el archivo STL para reparar:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:239 +msgid "Send to printer" +msgstr "Enviar a la impresora" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1448 +msgid "Sending G-code file to the OctoPrint server..." +msgstr "Enviando el archivo código G al servidor Octoprint..." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:477 +msgid "Sequential printing" +msgstr "Impresión secuencial" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:990 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1193 +msgid "Serial port" +msgstr "Puerto serial" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1202 +msgid "Serial port speed" +msgstr "Velocidad del puerto serial" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 +msgid "Set number of copies…" +msgstr "Establecer el número de copias…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:378 +msgid "Set this to a non-zero value to allow a manual extrusion width. If left to zero, Slic3r derives extrusion widths from the nozzle diameter (see the tooltips for perimeter extrusion width, infill extrusion width etc). If expressed as percentage (for example: 230%), it will be computed over layer height." +msgstr "Ajuste este valor distinto de cero para permitir un ancho de extrusión manual. Si se deja a cero, Slic3r obtiene anchuras de extrusión del diámetro de la boquilla (consulte la información sobre herramientas para conocer el ancho de extrusión, el ancho de extrusión de relleno, etc.). Si se expresa como porcentaje (por ejemplo: 230%), se computará sobre la altura de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:269 +msgid "Set this to a non-zero value to set a manual extrusion width for external perimeters. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 200%), it will be computed over layer height." +msgstr "Ajuste este valor distinto de cero para establecer un ancho de extrusión manual para perímetros externos. Si se deja en cero, se usará el ancho de extrusión por defecto si se establece, de lo contrario se usará 1.125 x diámetro de la boquilla. Si se expresa como porcentaje (por ejemplo, 200%), se computará sobre la altura de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:593 +msgid "Set this to a non-zero value to set a manual extrusion width for first layer. You can use this to force fatter extrudates for better adhesion. If expressed as percentage (for example 120%) it will be computed over first layer height. If set to zero, it will use the default extrusion width." +msgstr "Ajuste este valor distinto de cero para establecer un ancho de extrusión manual para la primera capa. Puede usar esto para forzar extrusiones más gordas para una mejor adhesión. Si se expresa como porcentaje (por ejemplo, 120%), se calculará sobre la altura de la primera capa. Si se establece en cero, usará el ancho de extrusión predeterminado." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1293 +msgid "Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Ajuste este valor distinto de cero para establecer un ancho de extrusión manual para el relleno de superficies sólidas. Si se deja en cero, se usará el ancho de extrusión por defecto si se establece, de lo contrario se usará 1.125 x diámetro de la boquilla. Si se expresa como porcentaje (por ejemplo, 90%), se calculará sobre la altura de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1615 +msgid "Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. You may want to use thinner extrudates to fill all narrow regions and get a smoother finish. If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Ajuste este valor distinto de cero para establecer un ancho de extrusión manual para el relleno de las superficies superiores. Es posible que desee utilizar extrusiones más delgadas para llenar todas las regiones estrechas y obtener un acabado más suave. Si se deja en cero, se usará el ancho de extrusión por defecto si se establece, de lo contrario se usará el diámetro de la boquilla. Si se expresa como porcentaje (por ejemplo, 90%), se calculará sobre la altura de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:711 +msgid "Set this to a non-zero value to set a manual extrusion width for infill. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. You may want to use fatter extrudates to speed up the infill and make your parts stronger. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Ajuste este valor distinto de cero para establecer un ancho de extrusión manual para relleno. Si se deja en cero, se usará el ancho de extrusión por defecto si se establece, de lo contrario se usará 1.125 x diámetro de la boquilla. Es posible que desee extrusiones más gordas para acelerar el relleno y fortalecer sus partes. Si se expresa como porcentaje (por ejemplo, 90%), se calculará sobre la altura de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:968 +msgid "Set this to a non-zero value to set a manual extrusion width for perimeters. You may want to use thinner extrudates to get more accurate surfaces. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 200%) it will be computed over layer height." +msgstr "Ajuste este valor distinto de cero para establecer un ancho de extrusión manual para los perímetros. Es posible que desee utilizar extrusiones más delgadas para obtener superficies más precisas. Si se deja en cero, se usará el ancho de extrusión por defecto si se establece, de lo contrario se usará 1.125 x diámetro de la boquilla. Si se expresa como porcentaje (por ejemplo, 200%), se calculará sobre la altura de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1455 +msgid "Set this to a non-zero value to set a manual extrusion width for support material. If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Ajuste este valor distinto de cero para establecer un ancho de extrusión manual para el material de soporte. Si se deja en cero, se usará el ancho de extrusión por defecto si se establece, de lo contrario se usará el diámetro de la boquilla. Si se expresa como porcentaje (por ejemplo, 90%), se calculará sobre la altura de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:332 +msgid "Set this to the clearance radius around your extruder. If the extruder is not centered, choose the largest value for safety. This setting is used to check for collisions and to display the graphical preview in the plater." +msgstr "Ajuste este parámetro según el radio de espacio libre alrededor de su extrusor. Si el extrusor no está centrado, elija el valor más grande para seguridad. Esta configuración se utiliza para verificar colisiones y mostrar la vista previa gráfica en la bandeja." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:321 +msgid "Set this to the vertical distance between your nozzle tip and (usually) the X carriage rods. In other words, this is the height of the clearance cylinder around your extruder, and it represents the maximum depth the extruder can peek before colliding with other printed objects." +msgstr "Ajuste este valor según la distancia vertical entre la punta de la boquilla y (generalmente) las barras X del carro. En otras palabras, esta es la altura del cilindro de holgura alrededor de su extrusor, y representa la profundidad máxima que el extrusor puede asomar antes de colisionar con otros objetos impresos." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:120 +msgid "Settings" +msgstr "Ajustes" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:191 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:206 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 +msgid "Settings…" +msgstr "Ajustes…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:39 +msgid "Shape" +msgstr "Aspecto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:98 +msgid "Shells" +msgstr "Carcasas" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:75 +msgid "Show" +msgstr "Mostrar" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 +msgid "Show about dialog" +msgstr "Mostrar Acerca de" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:67 +msgid "Show incompatible print and filament presets" +msgstr "Mostrar impresiones incompatibles y ajustes iniciales de filamentos" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 +msgid "Show system information" +msgstr "Mostrar la información del sistema" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 +msgid "Show the filament settings" +msgstr "Mostrar los ajustes de filamento" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 +msgid "Show the plater" +msgstr "Mostrar la base" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 +msgid "Show the print settings" +msgstr "Mostrar los ajustes de impresión" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 +msgid "Show the printer controller" +msgstr "Mostrar el controlador de la impresora" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 +msgid "Show the printer settings" +msgstr "Mostrar la configuración de la impresora" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1373 +msgid "Single Extruder Multi Material" +msgstr "Extrusor único de múltiples materiales" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:50 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1191 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:408 +msgid "Size" +msgstr "Tamaño" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:938 +msgid "Size and coordinates" +msgstr "Tamaño y coordenadas" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:51 +msgid "Size in X and Y of the rectangular plate." +msgstr "Tamaño en X e Y de la placa rectangular." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:365 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:146 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:88 +msgid "Skirt" +msgstr "Falda" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:364 +msgid "Skirt and brim" +msgstr "Falda y balsa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1221 +msgid "Skirt height" +msgstr "Altura de la falda" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1230 +msgid "Skirt Loops" +msgstr "Vueltas de la falda" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 +msgid "Slic3r &Manual" +msgstr "&Manual de Slic3r" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 +msgid "Slic3r &Website" +msgstr "&Website de Slic3r" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:902 +msgid "Slic3r can upload G-code files to OctoPrint. This field should contain the API Key required for authentication." +msgstr "Slic3r puede cargar archivos de código G a OctoPrint. Este campo debe contener la clave API requerida para la autenticación." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:909 +msgid "Slic3r can upload G-code files to OctoPrint. This field should contain the hostname or IP address of the OctoPrint instance." +msgstr "Slic3r puede cargar archivos de código G a OctoPrint. Este campo debe contener el nombre de host o la dirección IP de la instancia de OctoPrint." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:929 +msgid "Slic3r Error" +msgstr "Error de Slic3r" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:867 +msgid "Slic3r will not scale speed down below this speed." +msgstr "Slic3r no escalará la velocidad por debajo de esta velocidad." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 +msgid "Slice a file into a G-code" +msgstr "Laminar un archivo en un código G" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 +msgid "Slice a file into a G-code, save as" +msgstr "Laminar un archivo en un código G, guárdar como" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 +msgid "Slice file to a multi-layer SVG" +msgstr "Laminar archivo a un SVG multicapa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:237 +msgid "Slice now" +msgstr "Laminar ahora" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 +msgid "Slice to SV&G…\tCtrl+G" +msgstr "Laminar a SV&G…\tCtrl+G" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:438 +msgid "Sliced Info" +msgstr "Información del laminado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1286 +msgid "Slicing cancelled" +msgstr "Laminado cancelado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:550 +msgid "Slicing Done!" +msgstr "¡Laminado realizado!" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 +msgid "Slicing…" +msgstr "Laminando…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1239 +msgid "Slow down if layer print time is below" +msgstr "Disminuya la velocidad si el tiempo de impresión de la capa está por debajo" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1250 +msgid "Small perimeters" +msgstr "Perímetros pequeños" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:179 +msgid "solid infill" +msgstr "relleno sólido" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1291 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1301 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:142 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:84 +msgid "Solid infill" +msgstr "Relleno sólido" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1279 +msgid "Solid infill every" +msgstr "Relleno sólido cada" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1271 +msgid "Solid infill extruder" +msgstr "Extrusor de relleno sólido" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1262 +msgid "Solid infill threshold area" +msgstr "Ãrea del umbral de relleno sólido" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:330 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1314 +msgid "Solid layers" +msgstr "Capas sólidas" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:470 +msgid "Soluble material" +msgstr "Material soluble" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:471 +msgid "Soluble material is most likely used for a soluble support." +msgstr "El material soluble se usa muy probablemente para un soporte soluble." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:653 +msgid "Some G/M-code commands, including temperature control and others, are not universal. Set this option to your printer's firmware to get a compatible output. The \"No extrusion\" flavor prevents Slic3r from exporting any extrusion value at all." +msgstr "Algunos comandos de código G / M, incluido el control de temperatura y otros, no son universales. Establezca esta opción en el firmware de su impresora para obtener una salida compatible. El ajuste \"Sin extrusión\" evita que Slic3r exporte ningún valor de extrusión." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1682 +msgid "Some printers or printer setups may have difficulties printing with a variable layer height. Enabled by default." +msgstr "Algunas impresoras o configuraciones de impresora pueden tener dificultades para imprimir con una altura de capa variable. Habilitado por defecto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1490 +msgid "Spacing between interface lines. Set zero to get a solid interface." +msgstr "Espaciado entre líneas de interfaz. Establezca cero para obtener una interfaz sólida." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1526 +msgid "Spacing between support material lines." +msgstr "Espaciado entre las líneas de material de soporte." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:398 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:118 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:278 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:635 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:747 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:979 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1201 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1251 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1302 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1625 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:71 +msgid "Speed" +msgstr "Velocidad" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1203 +msgid "Speed (baud) of USB/serial port for printer connection." +msgstr "Velocidad (baudios) del puerto USB / serie para la conexión de la impresora." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:336 +msgid "Speed (mm/s)" +msgstr "Velocidad (mm/s)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:636 +msgid "Speed for filling small gaps using short zigzag moves. Keep this reasonably low to avoid too much shaking and resonance issues. Set zero to disable gaps filling." +msgstr "Velocidad para llenar pequeños espacios usando movimientos cortos de zigzag. Mantenga esto razonablemente bajo para evitar demasiados problemas de vibración y sacudidas. Establezca cero para desactivar el llenado de huecos." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:411 +msgid "Speed for non-print moves" +msgstr "Velocidad para movimientos sin impresión" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:980 +msgid "Speed for perimeters (contours, aka vertical shells). Set to zero for auto." +msgstr "Velocidad para perímetros (contornos, también conocidos como conchas verticales). Establecer a cero para auto." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:399 +msgid "Speed for print moves" +msgstr "Velocidad para movimientos de impresión" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:119 +msgid "Speed for printing bridges." +msgstr "Velocidad para imprimir puentes." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1303 +msgid "Speed for printing solid regions (top/bottom/internal horizontal shells). This can be expressed as a percentage (for example: 80%) over the default infill speed above. Set to zero for auto." +msgstr "Velocidad para imprimir regiones sólidas (superior / inferior / conchas horizontales internas). Esto se puede expresar como un porcentaje (por ejemplo: 80%) sobre la velocidad de relleno predeterminada anterior. Establecer a cero para auto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1499 +msgid "Speed for printing support material interface layers. If expressed as percentage (for example 50%) it will be calculated over support material speed." +msgstr "Velocidad para imprimir capas de interfaz de material de soporte. Si se expresa como porcentaje (por ejemplo, 50%), se calculará sobre la velocidad del material de soporte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1535 +msgid "Speed for printing support material." +msgstr "Velocidad para imprimir material de soporte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:748 +msgid "Speed for printing the internal fill. Set to zero for auto." +msgstr "Velocidad para imprimir el relleno interno. Establecer a cero para auto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1626 +msgid "Speed for printing top solid layers (it only applies to the uppermost external layers and not to their internal solid layers). You may want to slow down this to get a nicer surface finish. This can be expressed as a percentage (for example: 80%) over the solid infill speed above. Set to zero for auto." +msgstr "Velocidad para imprimir capas sólidas superiores (solo se aplica a las capas externas superiores y no a sus capas sólidas internas). Es posible que desee reducir la velocidad para obtener un acabado de superficie más agradable. Esto se puede expresar como un porcentaje (por ejemplo: 80%) sobre la velocidad de relleno sólido anterior. Establecer a cero para auto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1648 +msgid "Speed for travel moves (jumps between distant extrusion points)." +msgstr "Velocidad para movimientos (saltos entre puntos de extrusión distantes)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1322 +msgid "Spiral vase" +msgstr "Modo vaso" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:540 +msgid "Spiral Vase" +msgstr "Modo Vaso" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:188 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:204 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 +msgid "Split" +msgstr "Dividir" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 +msgid "Split the selected object into individual parts" +msgstr "Dividir el objeto seleccionado en partes individuales" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:847 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1120 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1342 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1357 +msgid "Start G-code" +msgstr "Comenzar el código G" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 +msgid "Start new slicing process" +msgstr "Comenzar un nuevo proceso de laminado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1539 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1581 +msgid "STL file exported to " +msgstr "Archivo STL exportado a " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 +msgid "Success!" +msgstr "¡Éxito!" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:198 +msgid "support" +msgstr "soporte" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:620 +msgid "Support Generator" +msgstr "Generador de soportes" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:208 +msgid "support interface" +msgstr "interfaz de soporte" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:374 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:375 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:191 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1030 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1380 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1387 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1399 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1409 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1417 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1432 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1453 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1464 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1480 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1489 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1498 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1509 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1525 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1533 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1534 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1543 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1551 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1565 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:147 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:89 +msgid "Support material" +msgstr "Material de soporte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1497 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:148 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:90 +msgid "Support material interface" +msgstr "Interfaz del material de soporte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1552 +msgid "Support material will not be generated for overhangs whose slope angle (90° = vertical) is above the given threshold. In other words, this value represent the most horizontal slope (measured from the horizontal plane) that you can print without support material. Set to zero for automatic detection (recommended)." +msgstr "El material de soporte no se generará para voladizos cuyo ángulo de inclinación (90 ° = vertical) esté por encima del umbral dado. En otras palabras, este valor representa la pendiente más horizontal (medida desde el plano horizontal) que puede imprimir sin material de soporte. Ajuste a cero para la detección automática (recomendado)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1470 +msgid "Support material/raft interface extruder" +msgstr "Extrusor del material de soporte/soporte de la balsa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1444 +msgid "Support material/raft/skirt extruder" +msgstr "Extrusor de material de soporte/falda/balsa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1408 +msgid "Support on build plate only" +msgstr "Soporte en la base solamente" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:617 +msgid "" +"Supports work better, if the following feature is enabled:\n" +"- Detect bridging perimeters\n" +"\n" +"Shall I adjust those settings for supports?" +msgstr "" +"Los soportes funcionan mejor, si la siguiente característica está habilitada: \n" +"- Detectar perímetros de puente\n" +"\n" +"¿Debo ajustar esas configuraciones para los soportes?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:59 +msgid "Suppress \" - default - \" presets" +msgstr "Suprima los ajustes iniciales \"- predeterminado -\"" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:61 +msgid "Suppress \" - default - \" presets in the Print / Filament / Printer selections once there are any other valid presets available." +msgstr "Suprima los ajustes iniciales \"- predeterminado -\" en las selecciones Imprimir / Filamento / Impresora una vez que haya otros ajustes preestablecidos disponibles." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +msgid "SVG" +msgstr "SVG" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1544 +msgid "Synchronize support layers with the object print layers. This is useful with multi-material printers, where the extruder switch is expensive." +msgstr "Sincronizar las capas de soporte con las capas de impresión del objeto. Esto es útil con impresoras de múltiples materiales, donde el cambio de el extrusor es costoso." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1542 +msgid "Synchronize with object layers" +msgstr "Sincronizar con capas las del objeto" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 +msgid "System Info" +msgstr "Información del Sistema" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:794 +msgid "Temperature " +msgstr "Temperatura " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1576 +msgid "Temperature" +msgstr "Temperatura" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1333 +msgid "Temperature difference to be applied when an extruder is not active. Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped." +msgstr "Diferencia de temperatura que se aplicará cuando un extrusor no esté activo. ACtiva una falda \"de sacrificio\" de altura completa en la que las boquillas se limpian periódicamente." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1332 +msgid "Temperature variation" +msgstr "Variación de temperatura" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1004 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1072 +msgid "Test" +msgstr "Test" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 +msgid "The " +msgstr "El " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:309 +msgid "The extruder to use (unless more specific extruder settings are specified). This value overrides perimeter and infill extruders, but not the support extruders." +msgstr "La extrusora que se usa (a menos que se especifiquen configuraciones de extrusión más específicas). Este valor anula los extrusores de perímetro y relleno, pero no los extrusores de soporte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:703 +msgid "The extruder to use when printing infill." +msgstr "El extrusor que se usa cuando se imprime relleno." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:959 +msgid "The extruder to use when printing perimeters and brim. First extruder is 1." +msgstr "El extrusor que se usa al imprimir perímetros y borde. El primer extrusor es 1." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1273 +msgid "The extruder to use when printing solid infill." +msgstr "El extrusor que se usa al imprimir relleno sólido." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1472 +msgid "The extruder to use when printing support material interface (1+, 0 to use the current extruder to minimize tool changes). This affects raft too." +msgstr "La extrusora que se usa al imprimir la interfaz de material de soporte (1+, 0 para usar la extrusora actual para minimizar los cambios de herramientas). Esto también afecta a la balsa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1446 +msgid "The extruder to use when printing support material, raft and skirt (1+, 0 to use the current extruder to minimize tool changes)." +msgstr "El extrusor que se usa al imprimir material de soporte, balsa y falda (1+, 0 para usar la extrusora actual para minimizar los cambios de herramientas)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:209 +msgid "The first layer will be shrunk in the XY plane by the configured value to compensate for the 1st layer squish aka an Elephant Foot effect." +msgstr "La primera capa se contraerá en el plano XY por el valor configurado para compensar el aplatamiento de la 1ª capa, también conocido como efecto Pie de Elefante." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1734 +msgid "The object will be grown/shrunk in the XY plane by the configured value (negative = inwards, positive = outwards). This might be useful for fine-tuning hole sizes." +msgstr "El objeto se crecerá / reducirá en el plano XY por el valor configurado (negativo = hacia adentro, positivo = hacia afuera). Esto podría ser útil para ajustar el tamaño de los orificios." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1031 +msgid "The object will be raised by this number of layers, and support material will be generated under it." +msgstr "El objeto será elevado por este número de capas y se generará material de soporte debajo de él." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1374 +msgid "The printer multiplexes filaments into a single hot end." +msgstr "La impresora multiplexa los filamentos en un solo fusor." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:324 +msgid "The selected file contains no geometry." +msgstr "El archivo seleccionado no contiene geometría." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:328 +msgid "The selected file contains several disjoint areas. This is not supported." +msgstr "El archivo seleccionado contiene varias áreas disjuntas. Esto no es compatible." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1112 +msgid "The selected object can't be split because it contains more than one volume/material." +msgstr "El objeto seleccionado no se puede dividir porque contiene más de un volumen / material." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1121 +msgid "The selected object couldn't be split because it contains only one part." +msgstr "El objeto seleccionado no se pudo dividir porque contiene solo una parte." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1144 +msgid "The speed for loading of a filament into extruder after retraction (it only applies to the extruder motor). If left to zero, the retraction speed is used." +msgstr "La velocidad de carga de un filamento en la extrusora después de la retracción (solo se aplica al motor del extrusor). Si se deja a cero, se usa la velocidad de retracción." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1136 +msgid "The speed for retractions (it only applies to the extruder motor)." +msgstr "La velocidad para las retracciones (solo se aplica al motor del extrusor)." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:533 +#, no-c-format +msgid "" +"The Spiral Vase mode requires:\n" +"- one perimeter\n" +"- no top solid layers\n" +"- 0% fill density\n" +"- no support material\n" +"- no ensure_vertical_shell_thickness\n" +"\n" +"Shall I adjust those settings in order to enable Spiral Vase?" +msgstr "" +"El modo Vaso requiere: \n" +"- un perímetro \n" +"- sin capas sólidas superiores \n" +"- densidad de relleno del 0% \n" +"- sin material de soporte \n" +"- no ensure_vertical_shell_thickness \n" +"\n" +"¿Debo ajustar esos ajustes para habilitar el modo Vaso?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1560 +msgid "The supplied name is empty. It can't be saved." +msgstr "El nombre proporcionado está vacío. No se puede guardar." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1788 +msgid "The supplied name is not available." +msgstr "El nombre proporcionado no está disponible." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1785 +msgid "The supplied name is not valid; the following characters are not allowed:" +msgstr "El nombre proporcionado no es válido; los siguientes caracteres no están permitidos:" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1418 +msgid "The vertical distance between object and support material interface. Setting this to 0 will also prevent Slic3r from using bridge flow and speed for the first object layer." +msgstr "La distancia vertical entre el objeto y la interfaz del material de soporte. Establecer esto en 0 también evitará que Slic3r use el flujo y la velocidad del puente para la primera capa de los objetos." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1312 +msgid "" +"The Wipe option is not available when using the Firmware Retraction mode.\n" +"\n" +"Shall I disable it in order to enable Firmware Retraction?" +msgstr "La opción Limpiar no está disponible cuando se usa el modo Retracción de firmware. ¿Lo inhabilito para habilitar la Retracción de firmware?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:560 +msgid "" +"The Wipe Tower currently supports only:\n" +"- first layer height 0.2mm\n" +"- layer height from 0.15mm to 0.35mm\n" +"\n" +"Shall I adjust those settings in order to enable the Wipe Tower?" +msgstr "" +"Actualmente, la Torre de Limpieza solo admite: \n" +"- altura de la primera capa 0.2 mm \n" +"- altura de la capa de 0.15 mm a 0.35 mm. \n" +"\n" +"¿Debo ajustar esos ajustes para habilitar la Torre de Limpieza?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:581 +msgid "" +"The Wipe Tower currently supports the non-soluble supports only\n" +"if they are printed with the current extruder without triggering a tool change.\n" +"(both support_material_extruder and support_material_interface_extruder need to be set to 0).\n" +"\n" +"Shall I adjust those settings in order to enable the Wipe Tower?" +msgstr "" +"Actualmente, la Torre de Limpieza solo admite los soportes no solubles si se imprimen con la extrusora actual sin activar un cambio de herramienta.\n" +"(ambos support_material_extruder y support_material_interface_extruder deben configurarse en 0). \n" +"\n" +"¿Debo ajustar esos ajustes para habilitar la Torre de Limpieza?" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:60 +msgid "This code is inserted between objects when using sequential printing. By default extruder and bed temperature are reset using non-wait command; however if M104, M109, M140 or M190 are detected in this custom code, Slic3r will not add temperature commands. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want." +msgstr "Este código se inserta entre los objetos cuando se utiliza la impresión secuencial. Por defecto, el extrusor y la temperatura de la cama se reinician utilizando un comando de no espera; sin embargo, si se detectan M104, M109, M140 o M190 en este código personalizado, Slic3r no agregará comandos de temperatura. Tenga en cuenta que puede usar variables de marcador de posición para todas las configuraciones de Slic3r, por lo que puede poner un comando \"M109 S [first_layer_temperature]\" donde lo desee." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:767 +msgid "This custom code is inserted at every layer change, right after the Z move and before the extruder moves to the first layer point. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z]." +msgstr "Este código personalizado se inserta en cada cambio de capa, justo después del movimiento Z y antes de que el extrusor se mueva al primer punto de capa. Tenga en cuenta que puede usar variables de marcador de posición para todos los ajustes de Slic3r, así como [layer_num] y [layer_z]." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:49 +msgid "This custom code is inserted at every layer change, right before the Z move. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z]." +msgstr "Este código personalizado se inserta en cada cambio de capa, justo antes del movimiento Z. Tenga en cuenta que puede usar variables de marcador de posición para todos los ajustes de Slic3r, así como [layer_num] y [layer_z]." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1603 +msgid "This custom code is inserted right before every extruder change. Note that you can use placeholder variables for all Slic3r settings as well as [previous_extruder] and [next_extruder]." +msgstr "Este código personalizado se inserta justo antes de cada cambio de extrusor. Tenga en cuenta que puede usar variables de marcador de posición para todas las configuraciones de Slic3r, así como para [previous_extruder] y [next_extruder]." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:228 +msgid "This end procedure is inserted at the end of the output file, before the printer end gcode. Note that you can use placeholder variables for all Slic3r settings. If you have multiple extruders, the gcode is processed in extruder order." +msgstr "Este procedimiento final se inserta al final del archivo de salida, antes del gcode final. Tenga en cuenta que puede usar variables de marcador de posición para todas las configuraciones de Slic3r. Si tiene extrusores múltiples, el gcode se procesa en el orden del extrusor." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:218 +msgid "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings." +msgstr "Este procedimiento final se inserta al final del archivo de salida. Tenga en cuenta que puede usar variables de marcador de posición para todas las configuraciones de Slic3r." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:827 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:838 +msgid "This experimental setting is used to limit the speed of change in extrusion rate. A value of 1.8 mm³/s² ensures, that a change from the extrusion rate of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds." +msgstr "Esta configuración experimental se usa para limitar la velocidad de cambio en la velocidad de extrusión. Un valor de 1,8 mm³ / s² asegura que se cambia la velocidad de extrusión de 1,8 mm³ / s (ancho de extrusión de 0,45 mm, altura de extrusión de 0,2 mm, avance de 20 mm / s) a 5,4 mm³ / s (avance de 60 mm / s) durará al menos 2 segundos." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:818 +msgid "This experimental setting is used to set the maximum volumetric speed your extruder supports." +msgstr "Esta configuración experimental se usa para establecer la velocidad volumétrica máxima que admite el extrusor." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1657 +msgid "This experimental setting uses G10 and G11 commands to have the firmware handle the retraction. This is only supported in recent Marlin." +msgstr "Esta configuración experimental utiliza comandos G10 y G11 para que el firmware maneje la retracción. Esto solo se admite en Marlin reciente." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1671 +msgid "This experimental setting uses outputs the E values in cubic millimeters instead of linear millimeters. If your firmware doesn't already know filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] T0' in your start G-code in order to turn volumetric mode on and use the filament diameter associated to the filament selected in Slic3r. This is only supported in recent Marlin." +msgstr "Este ajuste experimental utiliza como salida del E valores en milímetros cúbicos en lugar de milímetros lineales. Si su firmware aún no conoce el (los) diámetro (s) del filamento, puede poner comandos como 'M200 D [filament_diameter_0] T0' en su código G inicial para activar el modo volumétrico y usar el diámetro del filamento asociado al filamento seleccionado. en Slic3r. Esto solo se admite en Marlin reciente." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:108 +msgid "This factor affects the amount of plastic for bridging. You can decrease it slightly to pull the extrudates and prevent sagging, although default settings are usually good and you should experiment with cooling (use a fan) before tweaking this." +msgstr "Este factor afecta la cantidad de plástico para formar puentes. Puede disminuirlo ligeramente para extraer los extruidos y evitar el combado, aunque la configuración predeterminada suele ser buena y debe experimentar con la refrigeración (usar un ventilador) antes de ajustar esto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:368 +msgid "This factor changes the amount of flow proportionally. You may need to tweak this setting to get nice surface finish and correct single wall widths. Usual values are between 0.9 and 1.1. If you think you need to change this more, check filament diameter and your firmware E steps." +msgstr "Este factor cambia la cantidad de flujo proporcionalmente. Es posible que necesite ajustar esta configuración para obtener un buen acabado superficial y corregir el ancho de una sola pared. Los valores usuales están entre 0.9 y 1.1. Si cree que necesita cambiar esto más, verifique el diámetro del filamento y los pasos del E en el firmware." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:98 +msgid "This fan speed is enforced during all bridges and overhangs." +msgstr "La velocidad de este ventilador se aplica durante todos los puentes y voladizos." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:692 +msgid "This feature allows to combine infill and speed up your print by extruding thicker infill layers while preserving thin perimeters, thus accuracy." +msgstr "Esta característica permite combinar el relleno y acelerar la impresión mediante la extrusión de capas de relleno más gruesas a la vez que se preservan los finos perímetros y, por lo tanto, la precisión." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1281 +msgid "This feature allows to force a solid layer every given number of layers. Zero to disable. You can set this to any value (for example 9999); Slic3r will automatically choose the maximum possible number of layers to combine according to nozzle diameter and layer height." +msgstr "Esta característica permite forzar una capa sólida en cada número de capas. Cero para deshabilitar. Puede establecer esto en cualquier valor (por ejemplo, 9999); Slic3r seleccionará automáticamente la cantidad máxima posible de capas para combinar según el diámetro de la boquilla y la altura de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1323 +msgid "This feature will raise Z gradually while printing a single-walled object in order to remove any visible seam. This option requires a single perimeter, no infill, no top solid layers and no support material. You can still set any number of bottom solid layers as well as skirt/brim loops. It won't work when printing more than an object." +msgstr "Esta función aumentará Z gradualmente mientras imprime un objeto de pared simple para eliminar cualquier costura visible. Esta opción requiere un perímetro único, sin relleno, sin capas sólidas superiores y sin material de soporte. Todavía puede establecer cualquier cantidad de capas sólidas inferiores, así como bucles de falda / balsa. No funcionará al imprimir más de un objeto." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:663 +msgid "" +"This file contains several objects positioned at multiple heights. Instead of considering them as multiple objects, should I consider\n" +"this file as a single object having multiple parts?\n" +msgstr "" +"Este archivo contiene varios objetos posicionados en múltiples alturas. En lugar de considerarlos como objetos múltiples, ¿debería considerar\n" +" este archivo como un único objeto que tiene varias partes?\n" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:164 +msgid "This flag enables the automatic cooling logic that adjusts print speed and fan speed according to layer printing time." +msgstr "Este indicador habilita la lógica de enfriamiento automático que ajusta la velocidad de impresión y la velocidad del ventilador según el tiempo de impresión de la capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1066 +msgid "This flag enforces a retraction whenever a Z move is done." +msgstr "Esta bandera impone una retractación cada vez que se realiza un movimiento Z." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1689 +msgid "This flag will move the nozzle while retracting to minimize the possible blob on leaky extruders." +msgstr "Esta bandera moverá la boquilla mientras se retrae para minimizar la posible mancha en los extrusores con fugas." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:343 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:406 +msgid "This is only used in the Slic3r interface as a visual help." +msgstr "Esto solo se usa en la interfaz de Slic3r como ayuda visual." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:171 +msgid "This is the acceleration your printer will be reset to after the role-specific acceleration values are used (perimeter/infill). Set zero to prevent resetting acceleration at all." +msgstr "Esta es la aceleración después de que se usen los valores de aceleración específicos de cada función (perímetro / relleno). Establezca cero para evitar restablecer la aceleración." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:78 +msgid "This is the acceleration your printer will use for bridges. Set zero to disable acceleration control for bridges." +msgstr "Esta es la aceleración que su impresora usará para los puentes. Establezca cero para deshabilitar el control de aceleración para puentes." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:574 +msgid "This is the acceleration your printer will use for first layer. Set zero to disable acceleration control for first layer." +msgstr "Esta es la aceleración que su impresora usará para la primera capa. Establezca cero para deshabilitar el control de aceleración para la primera capa." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:682 +msgid "This is the acceleration your printer will use for infill. Set zero to disable acceleration control for infill." +msgstr "Esta es la aceleración que su impresora usará para el relleno. Establezca cero para deshabilitar el control de aceleración para el relleno." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:949 +msgid "This is the acceleration your printer will use for perimeters. A high value like 9000 usually gives good results if your hardware is up to the job. Set zero to disable acceleration control for perimeters." +msgstr "Esta es la aceleración que su impresora usará para los perímetros. Un valor alto como 9000 generalmente da buenos resultados si su hardware está a la altura del trabajo. Establezca cero para deshabilitar el control de aceleración para los perímetros." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:895 +msgid "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)" +msgstr "Este es el diámetro de la boquilla de su extrusor (por ejemplo: 0.5, 0.35, etc.)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:797 +#, no-c-format +msgid "This is the highest printable layer height for this extruder, used to cap the variable layer height and support layer height. Maximum recommended layer height is 75% of the extrusion width to achieve reasonable inter-layer adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter." +msgstr "Esta es la altura más alta imprimible de capa para este extrusor, que se utiliza para cubrir la altura de la capa variable y la altura de la capa de soporte. La altura máxima recomendada de la capa es del 75% del ancho de extrusión para lograr una adhesión razonable entre capas. Si se establece en 0, la altura de la capa se limita al 75% del diámetro de la boquilla." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:858 +msgid "This is the lowest printable layer height for this extruder and limits the resolution for variable layer height. Typical values are between 0.05 mm and 0.1 mm." +msgstr "Esta es la altura más baja de la capa imprimible para este extrusor y limita la resolución para la altura de la capa variable. Los valores típicos están entre 0.05 mm y 0.1 mm." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:990 +msgid "This option sets the number of perimeters to generate for each layer. Note that Slic3r may increase this number automatically when it detects sloping surfaces which benefit from a higher number of perimeters if the Extra Perimeters option is enabled." +msgstr "Esta opción establece la cantidad de perímetros que se generarán para cada capa. Tenga en cuenta que Slic3r puede aumentar este número automáticamente cuando detecta superficies inclinadas que se benefician de un mayor número de perímetros si la opción Perímetros adicionales está habilitada." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:923 +msgid "This option will drop the temperature of the inactive extruders to prevent oozing. It will enable a tall skirt automatically and move extruders outside such skirt when changing temperatures." +msgstr "Esta opción reducirá la temperatura de las extrusoras inactivas para evitar el goteo. Permitirá una falda alta automáticamente y moverá los extrusores fuera de dicha falda cuando cambie la temperatura." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:728 +msgid "This option will limit infill to the areas actually needed for supporting ceilings (it will act as internal support material). If enabled, slows down the G-code generation due to the multiple checks involved." +msgstr "Esta opción limitará el relleno a las áreas realmente necesarias para soportar techos (actuará como material de soporte interno). Si está habilitado, ralentiza la generación del código G debido a las múltiples comprobaciones involucradas." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:721 +msgid "This option will switch the print order of perimeters and infill, making the latter first." +msgstr "Esta opción cambiará el orden de impresión de los perímetros y el relleno, haciendo que el último sea el primero." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:279 +msgid "This separate setting will affect the speed of external perimeters (the visible ones). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above. Set to zero for auto." +msgstr "Esta configuración independiente afectará la velocidad de los perímetros externos (los visibles). Si se expresa como porcentaje (por ejemplo: 80%), se calculará en la configuración de velocidad de perímetros anterior. Establecer a cero para auto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1252 +msgid "This separate setting will affect the speed of perimeters having radius <= 6.5mm (usually holes). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above. Set to zero for auto." +msgstr "Esta configuración por separado afectará la velocidad de los perímetros con un radio <= 6,5 mm (generalmente agujeros). Si se expresa como porcentaje (por ejemplo: 80%), se calculará en la configuración de velocidad de perímetros anterior. Establecer a cero para auto." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:737 +msgid "This setting applies an additional overlap between infill and perimeters for better bonding. Theoretically this shouldn't be needed, but backlash might cause gaps. If expressed as percentage (example: 15%) it is calculated over perimeter extrusion width." +msgstr "Esta configuración aplica una superposición adicional entre relleno y perímetros para una mejor unión. Teóricamente, esto no debería ser necesario, pero la reacción puede causar huecos. Si se expresa como porcentaje (ejemplo: 15%), se calcula sobre el ancho de extrusión del perímetro." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:779 +msgid "This setting controls the height (and thus the total number) of the slices/layers. Thinner layers give better accuracy but take more time to print." +msgstr "Esta configuración controla la altura (y, por tanto, el número total) de las láminas / capas. Las capas más delgadas brindan una mayor precisión pero requieren más tiempo para imprimir." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:788 +msgid "This setting represents the maximum speed of your fan." +msgstr "Esta configuración representa la velocidad máxima de su ventilador." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:849 +msgid "This setting represents the minimum PWM your fan needs to work." +msgstr "Este ajuste representa el PWM mínimo que el ventilador necesita para funcionar." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1358 +msgid "This start procedure is inserted at the beginning, after any printer start gcode. This is used to override settings for a specific filament. If Slic3r detects M104, M109, M140 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want. If you have multiple extruders, the gcode is processed in extruder order." +msgstr "Este procedimiento de inicio se inserta en el principio, después de que la impresora haya realizado el g-code de inicio. Si Slic3r detecta un M104, M109, M140 o M190 en los g-codes custom, estos comandos no se iniciarán automaticamente por lo que eres libre de personalizar el orden de calentamiento y otras acciones. Fíjate que puedes utilizar variables de marcación de posición para todos los ajustes de Slic3r, como que puedes usar \"M109 S[first_layer_temperature]\" donde quieras. Si tienes varios extrusores, el g-code se procesará en el orden de estos." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1343 +msgid "This start procedure is inserted at the beginning, after bed has reached the target temperature and extruder just started heating, and before extruder has finished heating. If Slic3r detects M104 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want." +msgstr "Este procedimiento de inicio se inserta en el principio, después de que la cama ha llegado a la temperatura objetivo y el extrusor ha comenzado a calentarse, y después de que haya completado el calentamiento. Si Slic3r detecta un M104 o M190 en los g-codes custom, estos comandos no se iniciarán automaticamente por lo que eres libre de personalizar el orden de calentamiento y otras acciones. Fíjate que puedes utilizar variables de marcación de posición para todos los ajustes de Slic3r, como que puedes usar \"M109 S[first_layer_temperature]\" donde quieras." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1743 +msgid "This value will be added (or subtracted) from all the Z coordinates in the output G-code. It is used to compensate for bad Z endstop position: for example, if your endstop zero actually leaves the nozzle 0.3mm far from the print bed, set this to -0.3 (or fix your endstop)." +msgstr "Este valor será añadido (o eliminado) de todas las coordenadas Z en el G-code de salida. Se usa para compensar una mala posición del final de carrera Z: por ejemplo, si tu interruptor deja la boquilla a 0.3mm de la base de impresión, ajustalo a -0.3 (o arregla tu interruptor)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1590 +msgid "Threads" +msgstr "Núcleos" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1591 +msgid "Threads are used to parallelize long-running tasks. Optimal threads number is slightly above the number of available cores/processors." +msgstr "Núcleos usados para tareas multi-recurso. Número óptimo de núcleos es ligeramente sobre el numero de núcleos/procesadores disponibles." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:338 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:72 +msgid "Tool" +msgstr "Herramienta" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1144 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1602 +msgid "Tool change G-code" +msgstr "Código G de cambio de herramienta" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1638 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 +msgid "Top" +msgstr "Superior" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:187 +msgid "top solid infill" +msgstr "relleno sólido superior" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1613 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1624 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:143 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:85 +msgid "Top solid infill" +msgstr "Relleno sólido superior" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1642 +msgid "Top solid layers" +msgstr "Capas solidas superiores" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 +msgid "Top View" +msgstr "Vista superior" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:246 +msgid "Top/bottom fill pattern" +msgstr "Patrón de relleno superior/inferior" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1647 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:95 +msgid "Travel" +msgstr "Recorrido" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 +msgid "Uniformly…" +msgstr "Uniformemente…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:97 +msgid "Unretractions" +msgstr "Desretracciones" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1492 +msgid "Unsaved Changes" +msgstr "Cambios no guardados" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:750 +msgid "Unsaved Presets" +msgstr "Ajustes iniciales no guardados" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:989 +msgid "USB/Serial connection" +msgstr "Conexión USB/Serial" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1194 +msgid "USB/serial port for printer connection." +msgstr "Puerto USB/serial para la conexión con la impresora." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1656 +msgid "Use firmware retraction" +msgstr "Usar la retracción del firmware" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:75 +msgid "Use legacy OpenGL 1.1 rendering" +msgstr "Usar el renderizado OpenGL 1.1" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1663 +msgid "Use relative E distances" +msgstr "Usar las distancias relativas en E" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:361 +msgid "Use this option to set the axis letter associated to your printer's extruder (usually E but some printers use A)." +msgstr "Utiliza esta opción para ajustar la letra asociada al extrusor de tu impresora (normalmente se usa E pero otras usan A)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1400 +msgid "Use this setting to rotate the support material pattern on the horizontal plane." +msgstr "Use esta configuración para rotar el patrón de material de soporte en el plano horizontal." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1670 +msgid "Use volumetric E" +msgstr "Usar E volumétrico" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:449 +msgid "Used Filament (g)" +msgstr "Filamento usado (g)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:447 +msgid "Used Filament (m)" +msgstr "Filamento usado (m)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:448 +msgid "Used Filament (mm³)" +msgstr "Filamento usado (mm³)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:644 +msgid "Verbose G-code" +msgstr "Código G detallado" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 +msgid "Version " +msgstr "Versión " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:318 +msgid "Vertical shells" +msgstr "Carcasas verticales" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:65 +msgid "View" +msgstr "Vista" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:409 +msgid "Volume" +msgstr "Volumen" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "Volumetric" +msgstr "Volumétrico" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:500 +msgid "Warning" +msgstr "Peligro" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:131 +msgid "What do you want to print today? â„¢" +msgstr "¿Qué quieres imprimir hoy? â„¢" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:69 +msgid "When checked, the print and filament presets are shown in the preset editor even if they are marked as incompatible with the active printer" +msgstr "Cuando está marcada, los ajustes preestablecidos de impresión y filamento se muestran en el editor de ajustes preestablecidos, incluso si están marcados como incompatibles con la impresora activa" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:219 +msgid "when printing " +msgstr "cuando se imprime " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:136 +msgid "When printing multi-material objects, this settings will make slic3r to clip the overlapping object parts one by the other (2nd part will be clipped by the 1st, 3rd part will be clipped by the 1st and 2nd etc)." +msgstr "Al imprimir objetos multi-material, esta configuración hará que slic3r recorte las partes del objeto superpuestas una por la otra (la 2da parte será recortada por la 1ra, la 3ra parte será recortada por la 1ra y 2da, etc.)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:155 +msgid "When printing multiple objects or copies, this feature will complete each object before moving onto next one (and starting it from its bottom layer). This feature is useful to avoid the risk of ruined prints. Slic3r should warn and prevent you from extruder collisions, but beware." +msgstr "Al imprimir múltiples objetos o copias, esta característica completará cada objeto antes de pasar al siguiente (y comenzará desde la capa inferior). Esta función es útil para evitar el riesgo de impresiones arruinadas. Slic3r debería advertirte y evitar las colisiones del extrusor, pero ten cuidado." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:605 +msgid "When printing with very low layer heights, you might still want to print a thicker bottom layer to improve adhesion and tolerance for non perfect build plates. This can be expressed as an absolute value or as a percentage (for example: 150%) over the default layer height." +msgstr "Al imprimir con alturas de capa muy bajas, es posible que desee imprimir una capa inferior más gruesa para mejorar la adhesión y la tolerancia de las placas de construcción no perfectas. Esto se puede expresar como un valor absoluto o como un porcentaje (por ejemplo: 150%) sobre la altura de capa predeterminada." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1082 +msgid "When retraction is triggered before changing tool, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder)." +msgstr "Cuando se desencadena la retracción antes de cambiar la herramienta, el filamento se retira en la cantidad especificada (la longitud se mide en el filamento sin procesar, antes de que entre en el extrusor)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1073 +msgid "When retraction is triggered, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder)." +msgstr "Cuando se activa la retracción, el filamento se retira en la cantidad especificada (la longitud se mide en el filamento sin procesar, antes de que entre en el extrusor)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:808 +msgid "When setting other speed settings to 0 Slic3r will autocalculate the optimal speed in order to keep constant extruder pressure. This experimental setting is used to set the highest print speed you want to allow." +msgstr "Al establecer otras configuraciones de velocidad en 0, Slic3r calculará automáticamente la velocidad óptima para mantener constante la presión en el extrusor. Esta configuración experimental se utiliza para establecer la velocidad de impresión más alta que desea permitir." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1127 +msgid "When the retraction is compensated after changing tool, the extruder will push this additional amount of filament." +msgstr "Cuando la retracción se compensa después de cambiar la herramienta, el extrusor empujará esta cantidad adicional de filamento." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1119 +msgid "When the retraction is compensated after the travel move, the extruder will push this additional amount of filament. This setting is rarely needed." +msgstr "Cuando la retracción se compensa después de un movimiento, el extrusor necesitará introducir más filamento. Este ajuste raramente se necesita." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1716 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:70 +msgid "Width" +msgstr "Ancho" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:334 +msgid "Width (mm)" +msgstr "Ancho (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1717 +msgid "Width of a wipe tower" +msgstr "Ancho de la torre de limpieza" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:41 +#, c-format +msgid "will always run at %d%% " +msgstr "siempre funcionará al %d %% " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:50 +msgid "will be turned off." +msgstr "será apagada." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:442 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:149 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:91 +msgid "Wipe tower" +msgstr "Torre de limpieza" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:564 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:585 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:602 +msgid "Wipe Tower" +msgstr "Torre de limpieza" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1688 +msgid "Wipe while retracting" +msgstr "Limpiar mientras se retrae" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1058 +msgid "With bowden extruders, it may be wise to do some amount of quick retract before doing the wipe movement." +msgstr "Con extrusores bowden, puede ser recomendable realizar una retracción rápida antes de realizar el movimiento de limpiar." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1564 +msgid "With sheath around the support" +msgstr "Con protección alrededor del soporte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1703 +msgid "X coordinate of the left front corner of a wipe tower" +msgstr "Coordenada X de la esquina frontal izquierda de la torre de limpieza" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1386 +msgid "XY separation between an object and its support" +msgstr "Separación XY entre un objeto y su soporte" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1388 +msgid "XY separation between an object and its support. If expressed as percentage (for example 50%), it will be calculated over external perimeter width." +msgstr "Separación XY entre un objeto y su soporte. Si se expresa como porcentaje (por ejemplo 50%), se calculará sobre el ancho del perímetro externo." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1732 +msgid "XY Size Compensation" +msgstr "Compensación de tamaño XY" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1710 +msgid "Y coordinate of the left front corner of a wipe tower" +msgstr "Coordenada Y de la esquina delantera izquierda de la torre de limpieza" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1970 +msgid "Yes" +msgstr "Sí" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:885 +msgid "You can put here your personal notes. This text will be added to the G-code header comments." +msgstr "Puede poner sus notas personales aquí. Este texto se añadirá al código G como comentarios." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:413 +msgid "You can put your notes regarding the filament here." +msgstr "Puede poner sus notas con respecto al filamento aquí." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1015 +msgid "You can put your notes regarding the printer here." +msgstr "Puede poner sus notas con respecto a la impresora aquí." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:181 +msgid "You can set this to a positive value to disable fan at all during the first layers, so that it does not make adhesion worse." +msgstr "Puedes configurarlo como un valor positivo para desactivar el ventilador durante todas las capas iniciales, de manera que no empeora la adhesión." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:931 +msgid "You can use all configuration options as variables inside this template. For example: [layer_height], [fill_density] etc. You can also use [timestamp], [year], [month], [day], [hour], [minute], [second], [version], [input_filename], [input_filename_base]." +msgstr "Puedes usar todas las opciones de configuración como las variables dentro de esta muestra. Por ejemplo [layer_height], [fill_density] etc.También puedes usar [timestamp], [year], [month], [day], [hour], [minute], [second], [version], [input_filename], [input_filename_base]." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 +msgid "You have unsaved changes " +msgstr "Tienes cambios sin guardar " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:101 +msgid "You need to restart Slic3r to make the changes effective." +msgstr "Es necesario reiniciar Slic3r para hacer los cambios efectivos." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 +msgid "Your file was repaired." +msgstr "Tu fichero fue reparado." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:744 +msgid "Your object appears to be too large, so it was automatically scaled down to fit your print bed." +msgstr "Tu pieza parece demasiado grande, así que se ha escalado automáticamente para que pueda caber en la base de impresión." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1742 +msgid "Z offset" +msgstr "desplazamiento en Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:91 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:492 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1170 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1181 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1401 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1557 +msgid "°" +msgstr "°" diff --git a/resources/localization/it/Slic3rPE.mo b/resources/localization/it/Slic3rPE.mo index a6cb61ead50f1d1d2f59c78fc26018d4772d2bf0..a3ba42d507e474d64e00bb1c0665d82b111e5aaf 100644 GIT binary patch delta 3290 zcmXZedvwor9LMp`N0=E&kvntQ)v(RoY-lq^Gq)`F%SOgDjcCMg3M1q;W0P8^DAFNo zt~oBpInu>tb&yl1IA>95ISs{W^nC5}{p<00f4<+}_w)I@KcDya`zt?L``44T_kZ8s z7if&h54NTumZIXb7=yPk7CVGk6Nb|;6xU)GEX5zO-0MFbYKg3m$3{Au;c={sSFjP@!1nkLMqrDMZot9VmUtv;;Q9CxuEJ;W z4z@(U2zP%6RDWmG$_IM=qkS|qqe-YA%)+NJ50!}`)DQPyQ#^&O@EU4G|6+Y?*U6gN z7>PBpCu$*mJqKZRhH)7EX*dUc2WTk8ft{^sf}K!jVIT%$Dz?U@sJ-2R;kXkuk&CE- zD^L@^hgwLTE-o`cs0{Z;ZP|3xf>$A#^_hGcTH#^Tj4z;4e+~76zfco0^VpN|O|I8*7!$Z~+cPTK#S2gqJcfEu z89srxPy^q_L0E}8-7#I=Kx0r7nvQKS8#S>_UjH_XVtlichEjS3J7bM*E{^h?fEqXt z>);O5q1%Ppf}_|0uc8iX6{i|A8|@6*r&oAt1!2X;bjK{{$e zIjFt;7^mpDJpn)flbKlML| z#?J$+xyge<;&}lPH%M@)iyY{xAQqLnWY1Bk)Q?4#rjXFG*(XxRYi}zxIv;d zEr>gzGL@7_{VM}==+I%>fLhsh)Tu2&4g9lry&SctcTkzALJbhWDpX!AQ2i0O6#L+E zJc4~NZm>HeIT%cw@ADeRP!GO=dJ+AF+H?OTw>520ThJ9X(M0TyBT(g<=Up#EEnqLI z49}o4avk-2GsHcoKI*Xh0%_DI<^<@E@oiN`+g-e7A{D=0v%^b+2~8yJFD zldX9f%`lhREL5sDV-@bhQv5WNANGPZd0ZHZs?+aq8CK#( ze07W~FTYfm+6dGeECH3$;kXAUqPDKii|!TN4)vZ0!G=trBkm`T9m~pzD{zzQzt?!m z0>8#ym_Na7!ME6tIFy?z_L_C2K0UK5iz5mHwm* zYl?^`&$5QKn1{HScub}>g;<8i=+B(P;lt1@>Yv}3Idk3KUwOrvFSs!@oBE}{9CzXq z^W8*tziQ2AT+dj*0N7%oH7jr-#$pxzhB2>MvlWAKtl5FbJ;yJy=05QQ9ENumQ~$FW zpx^5*rJpQuD;c%anlf(4;JP2z`{r6RmpEaWHIJ|q^`Ot+;046>Pu{dfmNt74S(BJQw-{TG6Yo}Q&9K&=FteJvBv8-i220laU!OzcLSb6 zeIu@V-uC*<1~)(x)P#dk6OKf^Is2o^HxV__WUPy0kp=loI*sjgEW_Wh)kgk&k|MuN z*7U~s&DLC^e@VVIM=)gz1JLhZU`;M@v#r(~z#`NHlDD}DrD7Z68K?=Z^en(u#Jez8 z^?!zjUK9fhtr>vns5jRx)C=P@>h%7N&*9o4YuHM20cT?w#$eob=OSE3d=T3((S� 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 2 && n%10 <=4 && (n%100 < 12 || n%100 > 14)) ? 1 : ((n%10 == 0 || n%10 == 1 || (n%10 >= 5 && n%10 <=9)) || (n%100 >= 12 && n%100 <= 14)) ? 2 : 3);\n" +"X-Generator: Poedit 2.0.6\n" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: Oleksandra Iushchenko \n" +"Language-Team: \n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 +msgid "" +"\n" +"\n" +"and it has the following unsaved changes:" +msgstr "" +"\n" +"\n" +"i ma nastÄ™pujÄ…ce niezapisane zmiany:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1491 +msgid "" +"\n" +"\n" +"Discard changes and continue anyway?" +msgstr "" +"\n" +"\n" +"Odrzucić zmiany i kontynuować?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1489 +msgid "" +"\n" +"\n" +"has the following unsaved changes:" +msgstr "" +"\n" +"\n" +"ma nastÄ™pujÄ…ce niezapisane zmiany:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1488 +msgid "" +"\n" +"\n" +"is not compatible with printer\n" +msgstr "" +"\n" +"\n" +"nie jest kompatybilne z drukarkÄ…\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:34 +msgid "" +"\n" +"During the other layers, fan " +msgstr "" +"\n" +"Na pozostaÅ‚ych warstwach, wentylator " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:30 +#, c-format +msgid "" +"\n" +"If estimated layer time is greater, but still below ~%ds, fan will run at a proportionally decreasing speed between %d%% and %d%%." +msgstr "" +"\n" +"JeÅ›li szacowany czas jest wyższy, ale poniżej ~%ds, wentylator bÄ™dzie pracowaÅ‚ z proporcjonalnie zmniejszanÄ… prÄ™dkoÅ›ciÄ… poniÄ™dzy %d%% a %d%%." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:927 +msgid "" +"\n" +"Non-positive value." +msgstr "" +"\n" +"Wartość ujemna." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:928 +msgid "" +"\n" +"Not a numeric value." +msgstr "" +"\n" +"Wartość nie jest liczbÄ…." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 +msgid " - Remember to check for updates at http://github.com/prusa3d/slic3r/releases" +msgstr " - PamiÄ™taj aby sprawdzać aktualizacja na http://github.com/prusa3d/slic3r/releases" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 +msgid " as:" +msgstr " jako:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:226 +#, c-format +msgid " at filament speed %3.2f mm/s." +msgstr " z prÄ™dkociÄ… filamentu %3.2f mm/s." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1035 +msgid " Browse " +msgstr " PrzeglÄ…daj " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 +msgid " file as:" +msgstr " plik jako:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:215 +msgid " flow rate is maximized " +msgstr " przepÅ‚yw osiÄ…ga wartoÅ›ci szczytowe " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662 +#, no-c-format +msgid "" +" infill pattern is not supposed to work at 100% density.\n" +"\n" +"Shall I switch to rectilinear fill pattern?" +msgstr "" +" wzór wypeÅ‚nienia nie dziaÅ‚a z gÄ™stoÅ›ciÄ… 100%.\n" +"\n" +"Zmienić wzór wypeÅ‚nienia na linie równolegÅ‚e?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1470 +msgid " preset\n" +msgstr " zestaw ustawieÅ„\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 +msgid " preset" +msgstr " zestaw ustawieÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1583 +msgid " Preset" +msgstr " Zestaw ustawieÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:942 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1637 +msgid " Set " +msgstr " Ustaw " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 +msgid " the selected preset?" +msgstr " wybrany zestaw ustawieÅ„?" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:548 +msgid " was successfully sliced." +msgstr " zostaÅ‚ pomyÅ›lnie pociÄ™ty." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:220 +msgid " with a volumetric rate " +msgstr " ze współczynnikiem objÄ™toÅ›ciowym " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:99 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:504 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:789 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:850 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1060 +msgid "%" +msgstr "%" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:224 +#, c-format +msgid "%3.2f mm³/s" +msgstr "%3.2f mm³/s" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1958 +#, perl-format +msgid "%d (%d shells)" +msgstr "%d (%d obrysów)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1965 +#, perl-format +msgid "%d degenerate facets, %d edges fixed, %d facets removed, %d facets added, %d facets reversed, %d backwards edges" +msgstr "%d nieprawidÅ‚owych powierzchni, %d naprawionych krawÄ™dzi, %d powierzchni usuniÄ™to, %d powierzchni dodano, %d powierzchni odwrócono, %d odwróconych krawÄ™dzi" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:269 +#, c-format +msgid "%d lines: %.2lf mm" +msgstr "%d linii: %.2lf mm" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:687 +#, perl-format +msgid "%d presets successfully imported." +msgstr "%d zestawów ustawieÅ„ pomyÅ›lnie zaimportowano." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 +msgid "&About Slic3r" +msgstr "Inform&acje o Slic3r" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 +msgid "&Configuration " +msgstr "Konfigura&cja " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 +msgid "&Export Config Bundle…" +msgstr "&Eksport Paczki Konfiguracyjnej…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 +msgid "&Export Config…\tCtrl+E" +msgstr "&Eksport Konfiguracji... \tCtrl+E" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:418 +msgid "&File" +msgstr "&Plik" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:426 +msgid "&Help" +msgstr "Pomo&c" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 +msgid "&Load Config Bundle…" +msgstr "Wczytaj PaczkÄ™ &Konfiguracyjną…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 +msgid "&Load Config…\tCtrl+L" +msgstr "&Wczytaj KonfiguracjÄ™... \tCtrl+L" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:339 +msgid "&Localization" +msgstr "&JÄ™zyk" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:420 +msgid "&Object" +msgstr "&Model" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:419 +msgid "&Plater" +msgstr "&Stół" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 +msgid "&Quit" +msgstr "&WyjÅ›cie" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 +msgid "&Repeat Last Quick Slice\tCtrl+Shift+U" +msgstr "Powtórz Ostatnie Szybkie &CiÄ™cie \tCtrl+Shift+U" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:422 +msgid "&View" +msgstr "&Widok" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:421 +msgid "&Window" +msgstr "&Okno" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 +msgid "(&Re)Slice Now\tCtrl+S" +msgstr "Tnij (&ponownie) \tCtrl+S" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:994 +msgid "(minimum)" +msgstr "(minimum)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 +msgid ") not found." +msgstr ") nie znaleziono." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:215 +msgid "). Check hostname and OctoPrint version (at least 1.1.0 is required)." +msgstr "). Sprawdź nazwÄ™ hosta i wersjÄ™ OctoPrint (wymagana 1.1.0 lub wyższa)." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 +msgid ". Discard changes and continue anyway?" +msgstr ". Odrzucić zmiany i kontynuować?" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:63 +msgid "1 Layer" +msgstr "1 warstwa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:138 +msgid "2D" +msgstr "2D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:104 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2124 +msgid "3D" +msgstr "3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1608 +msgid "3MF file exported to " +msgstr "Plik 3MF zostaÅ‚ wyeksportowany do " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:185 +msgid "45° ccw" +msgstr "45° przeciwnie do wskazówek zegara" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:186 +msgid "45° cw" +msgstr "45° zgodnie ze wskazówkami zegara" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:148 +msgid "A boolean expression using the configuration values of an active printer profile. If this expression evaluates to true, this profile is considered compatible with the active printer profile." +msgstr "Wyrażenie logiczne (Boole'owskie) używajÄ…ce wartoÅ›ci konfiguracji aktywnego profilu drukarki. JeÅ›li to wyrażenie jest prawdziwe to znaczy, że aktywny profil jest kompatybilny z drukarkÄ…." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1099 +msgid "Above Z" +msgstr "Powyżej Z" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:417 +msgid "Acceleration control (advanced)" +msgstr "Ustawienia przyspieszeÅ„ (zaawansowane)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1566 +msgid "Add a sheath (a single perimeter line) around the base support. This makes the support more reliable, but also more difficult to remove." +msgstr "Dodaj osÅ‚onÄ™ (pojedynczÄ… liniÄ™) wokół podpory bazowej. Sprawi to, że podpory bÄ™dÄ… stabilniejsze, ale też trudniejsze do usuniÄ™cia." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:299 +#, no-c-format +msgid "Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r keeps adding perimeters, until more than 70% of the loop immediately above is supported." +msgstr "Dodaj wiÄ™cej obrysów, aby uniknąć przerw przy pochyÅ‚ych Å›cianach. Slic3r bÄ™dzie dodawaÅ‚ tyle obrysów, ile jest potrzebne aby podeprzeć co najmniej 70% gruboÅ›ci Å›ciany kolejnej warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:240 +msgid "Add solid infill near sloping surfaces to guarantee the vertical shell thickness (top+bottom solid layers)." +msgstr "Dodaj zwarte wypeÅ‚nienie przy pochyÅ‚ych powierzchniach aby zagwarantować odpowiedniÄ… grubość warstwy (suma górnych i dolnych zwartych warstw)." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:177 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:195 +msgid "Add…" +msgstr "Dodaj…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:342 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:356 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:449 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:452 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:831 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1113 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:107 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:208 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:736 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1733 +msgid "Advanced" +msgstr "Zaawansowane" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1138 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:766 +msgid "After layer change G-code" +msgstr "G-code wykonywany po zmianie warstwy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1636 +msgid "All" +msgstr "Wszystko" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 +msgid "Along X axis…" +msgstr "WzdÅ‚uż osi X…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 +msgid "Along Y axis…" +msgstr "WzdÅ‚uż osi Y…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 +msgid "Along Z axis…" +msgstr "WzdÅ‚uż osi Z…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1592 +msgid "AMF file exported to " +msgstr "Plik AMF zostaÅ‚ wyeksportowany do " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 +msgid "Another export job is currently running." +msgstr "W tej chwili trwa inny proces eksportu." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:901 +msgid "API Key" +msgstr "Klucz API" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 +msgid "Application preferences" +msgstr "Preferencje aplikacji" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 +msgid "Application will be restarted" +msgstr "Aplikacja zostanie uruchomiona ponownie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:397 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1242 +msgid "approximate seconds" +msgstr "szacowane sekundy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1581 +msgid "Are you sure you want to " +msgstr "Czy na pewno chcesz " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 +msgid "Around X axis…" +msgstr "Wokół osi X…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 +msgid "Around Y axis…" +msgstr "Wokół osi Y…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 +msgid "Around Z axis…" +msgstr "Wokół osi Z…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:180 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:198 +msgid "Arrange" +msgstr "Rozmieść" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:224 +msgid "Array of language names and identifiers should have the same size." +msgstr "Listy nazw jÄ™zyków i oznaczeÅ„ powinny mieć taki sam rozmiar." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:332 +msgid "Attention!" +msgstr "Uwaga!" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:35 +msgid "Auto-center parts" +msgstr "Rozmieść modele automatycznie" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1960 +#, perl-format +msgid "Auto-repaired (%d errors)" +msgstr "Naprawiono automatycznie (%d błędów)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 +msgid "Automatically repair an STL file" +msgstr "Automatyczna naprawa pliku STL" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:424 +msgid "Autospeed (advanced)" +msgstr "Automatyczne dostosowanie prÄ™dkoÅ›ci (zaawansowane)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:26 +msgid "Avoid crossing perimeters" +msgstr "Unikaj ruchów nad obrysami" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:43 +msgid "Background processing" +msgstr "Przetwarzanie w tle" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:800 +msgid "Bed" +msgstr "Stół" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp:42 +msgid "Bed Shape" +msgstr "KsztaÅ‚t stoÅ‚u" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:940 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:34 +msgid "Bed shape" +msgstr "KsztaÅ‚t stoÅ‚u" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:42 +msgid "Bed temperature" +msgstr "Temperatura stoÅ‚u" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:39 +msgid "Bed temperature for layers after the first one. Set this to zero to disable bed temperature control commands in the output." +msgstr "Temperatura stoÅ‚u dla warstw powyżej pierwszej. Ustaw 0 aby wyłączyć kontrolowanie temperatury w pliku wyjÅ›ciowym." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1132 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:48 +msgid "Before layer change G-code" +msgstr "G-code wykonywany przed zmianÄ… warstwy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1108 +msgid "Below Z" +msgstr "Poniżej Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:59 +msgid "Between objects G-code" +msgstr "G-code wykonywany przy przejÅ›ciach pomiÄ™dzy modelami" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1150 +msgid "Between objects G-code (for sequential printing)" +msgstr "G-code wykonywany przy przejÅ›ciach pomiÄ™dzy modelami (druk sekwencyjny)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:68 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 +msgid "Bottom" +msgstr "Spód" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:72 +msgid "Bottom solid layers" +msgstr "Zwarte warstwy dolne" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:370 +msgid "Bottom View" +msgstr "Widok od doÅ‚u" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:77 +msgid "Bridge" +msgstr "Most" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:106 +msgid "Bridge flow ratio" +msgstr "Współczynnik przepÅ‚ywu przy mostach" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:144 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:86 +msgid "Bridge infill" +msgstr "WypeÅ‚nienie mostu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:117 +msgid "Bridges" +msgstr "Mosty" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:97 +msgid "Bridges fan speed" +msgstr "PrÄ™dkość wentylatora przy mostach" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:86 +msgid "Bridging angle" +msgstr "KÄ…t linii mostów" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:88 +msgid "Bridging angle override. If left to zero, the bridging angle will be calculated automatically. Otherwise the provided angle will be used for all bridges. Use 180° for zero angle." +msgstr "Nadpisanie kÄ…ta linii mostów. JeÅ›li zostanie 0 to kÄ…t zostanie obliczony automatycznie. W innym przypadku ustawiony kÄ…t bÄ™dzie dotyczyÅ‚ wszystkich mostów. Ustaw 180° dla kÄ…ta zerowego." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "Bridging volumetric" +msgstr "Mosty objÄ™toÅ›ciowe" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:371 +msgid "Brim" +msgstr "Brim (obramowanie)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:127 +msgid "Brim width" +msgstr "Szerokość brim" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:218 +msgid "by the print profile maximum" +msgstr "maksimum zależny od profilu wydruku" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:962 +msgid "Capabilities" +msgstr "MożliwoÅ›ci" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:325 +msgid "Change Application Language" +msgstr "ZmieÅ„ jÄ™zyk aplikacji" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 +msgid "Change the number of copies of the selected object" +msgstr "ZmieÅ„ ilość kopii wybranego modelu" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:298 +msgid "Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Wybierz plik do importu ksztaÅ‚tu stoÅ‚u (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:457 +msgid "Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Wybierz plik do pociÄ™cia (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\lib\Slic3r\GUI.pm:286 +msgid "Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):" +msgstr "Wybierz jeden lub wiÄ™cej plików (STL/OBJ/AMF/3MF/PRUSA):" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:62 +msgid "Circular" +msgstr "OkrÄ…gÅ‚y" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:135 +msgid "Clip multi-part objects" +msgstr "Przycinaj modele zÅ‚ożone z kilku części" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:405 +msgid "Color" +msgstr "Kolor" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:690 +msgid "Combine infill every" +msgstr "Scalaj wypeÅ‚nienie co" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:696 +msgid "Combine infill every n layers" +msgstr "Scalaj wypeÅ‚nienie co n warstw" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:509 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:869 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1668 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:143 +msgid "Compatible printers" +msgstr "Kompatybilne drukarki" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:147 +msgid "Compatible printers condition" +msgstr "Warunki kompatybilnoÅ›ci z drukarkÄ…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:154 +msgid "Complete individual objects" +msgstr "Druk sekwencyjny (model po modelu)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:884 +msgid "Configuration notes" +msgstr "Notatki konfiguracyjne" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1020 +msgid "Connection failed." +msgstr "Błąd połączenia." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:211 +msgid "Connection to OctoPrint works correctly." +msgstr "Połączenie z OctoPrint pomyÅ›lne." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 +msgid "Connection to printer works correctly." +msgstr "Połączenie z drukarkÄ… pomyÅ›lne." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1416 +msgid "Contact Z distance" +msgstr "OdstÄ™p w osi Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:120 +msgid "Controller" +msgstr "Kontroler" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:805 +msgid "Cooling" +msgstr "ChÅ‚odzenie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:826 +msgid "Cooling thresholds" +msgstr "Progi chÅ‚odzenia" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:221 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 +msgid "Copies" +msgstr "Kopie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:476 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:450 +msgid "Cost" +msgstr "Koszt" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1465 +msgid "Cover the top contact layer of the supports with loops. Disabled by default." +msgstr "Pokryj pÄ™tlÄ… górnÄ… warstwÄ™ podpór. DomyÅ›lnie wyłączone." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:71 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:150 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:92 +msgid "Custom" +msgstr "WÅ‚asny" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:846 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119 +msgid "Custom G-code" +msgstr "WÅ‚asny G-code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:189 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:205 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 +msgid "Cut…" +msgstr "Tnij…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 +msgid "Decrease copies" +msgstr "Zmniejsz kopie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:300 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:170 +msgid "Default" +msgstr "DomyÅ›lnie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp:42 +msgid "default" +msgstr "domyÅ›lnie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1469 +msgid "Default " +msgstr "DomyÅ›lnie " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:489 +msgid "Default base angle for infill orientation. Cross-hatching will be applied to this. Bridges will be infilled using the best direction Slic3r can detect, so this setting does not affect them." +msgstr "DomyÅ›lny kÄ…t linii wypeÅ‚nienia. Mosty bÄ™dÄ… wypeÅ‚niane z użyciem najlepszego kierunku obliczonego przez Slic3r, wiÄ™c to ustawienie ich nie dotyczy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:376 +msgid "Default extrusion width" +msgstr "DomyÅ›lna szerokość ekstrudowanej linii" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:178 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:196 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 +msgid "Delete" +msgstr "UsuÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 +msgid "delete" +msgstr "usuÅ„" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:179 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:197 +msgid "Delete All" +msgstr "UsuÅ„ wszystko" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:51 +msgid "Delete this preset" +msgstr "UsuÅ„ ten zestaw ustawieÅ„" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:440 +msgid "Density" +msgstr "GÄ™stość" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:503 +#, no-c-format +msgid "Density of internal infill, expressed in the range 0% - 100%." +msgstr "GÄ™stość wypeÅ‚nienia wewnÄ™trznego, wyrażana w zakresie 0% - 100%." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:507 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:867 +msgid "Dependencies" +msgstr "ZależnoÅ›ci" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1724 +msgid "Depth of a wipe color per color change. For N colors, there will be maximum (N-1) tool switches performed, therefore the total depth of the wipe tower will be (N-1) times this value." +msgstr "Głębokość wieży czyszczÄ…cej dla 1 zmiany koloru. Dla N kolorów odbÄ™dzie siÄ™ (N-1) zmian narzÄ™dzia (zmian filamentu), wiÄ™c suma głębokoÅ›ci wieży bÄ™dzie równa (N-1) tej wartoÅ›ci." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1142 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1143 +msgid "Deretraction Speed" +msgstr "PrÄ™dkość powrotu retrakcji" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:940 +msgid "Detect bridging perimeters" +msgstr "Wykrywanie mostów przy obrysach" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1584 +msgid "Detect single-width walls (parts where two extrusions don't fit and we need to collapse them into a single trace)." +msgstr "Wykrywaj Å›ciany o gruboÅ›ci jednego obrysu (obszary, gdzie 2 obrysy nie zmieszczÄ… siÄ™ i trzeba bÄ™dzie połączyć je w jednÄ… liniÄ™)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1582 +msgid "Detect thin walls" +msgstr "Wykrywanie cienkich Å›cian" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 +msgid "Device Browser" +msgstr "PrzeglÄ…darka urzÄ…dzeÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:66 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:431 +msgid "Diameter" +msgstr "Åšrednica" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:67 +msgid "Diameter of the print bed. It is assumed that origin (0,0) is located in the center." +msgstr "Åšrednica stoÅ‚u. Z zaÅ‚ożenia punkt bazowy (0, 0) jest zlokalizowany na Å›rodku." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1169 +msgid "Direction" +msgstr "Kierunek" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:53 +msgid "Disable communication with the printer over a serial / USB cable. This simplifies the user interface in case the printer is never attached to the computer." +msgstr "Wyłącz komunikacjÄ™ z drukarkÄ… przez port szeregowy / kabel USB. Upraszcza to interfejs gdy np. drukarka nigdy nie bÄ™dzie podłączona do komputera." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:180 +msgid "Disable fan for the first" +msgstr "Wyłącz wentylator przy pierwszych" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:51 +msgid "Disable USB/serial connection" +msgstr "Wyłącz połączenie USB/szeregowe" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:916 +msgid "Disables retraction when the travel path does not exceed the upper layer's perimeters (and thus any ooze will be probably invisible)." +msgstr "Wyłącza retrakcjÄ™ gdy ruch jaÅ‚owy nie wykracza poza zewnÄ™trzny obrys górnej warstwy (wiÄ™c jakiekolwiek wycieki z dyszy prawdopodobnie i tak nie bÄ™dÄ… widoczne)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:198 +msgid "Distance between copies" +msgstr "OdstÄ™p pomiÄ™dzy kopiami" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1213 +msgid "Distance between skirt and object(s). Set this to zero to attach the skirt to the object(s) and get a brim for better adhesion." +msgstr "OdlegÅ‚ość skirtu od modelu. Ustaw zero aby dołączyć do modelu i uzyskać obramowanie dla lepszej przyczepnoÅ›ci." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1212 +msgid "Distance from object" +msgstr "OdstÄ™p od modelu" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:58 +msgid "Distance of the 0,0 G-code coordinate from the front left corner of the rectangle." +msgstr "OdlegÅ‚ość koordynaty punktu zerowego od przedniego lewego rogu prostokÄ…ta." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:199 +msgid "Distance used for the auto-arrange feature of the plater." +msgstr "OdstÄ™p używany przy automatycznym rozmieszczaniu modeli na stole." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:190 +msgid "Don't support bridges" +msgstr "Nie używaj podpór pod mostami" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:132 +msgid "Drag your objects here" +msgstr "PrzeciÄ…gnij modele tutaj" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:207 +msgid "Elephant foot compensation" +msgstr "Kompensacja \"stopy sÅ‚onia\"" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:806 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:922 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1695 +msgid "Enable" +msgstr "Włącz" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:163 +msgid "Enable auto cooling" +msgstr "Włącz automatyczne chÅ‚odzenie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:394 +msgid "Enable fan if layer print time is below" +msgstr "Włącz chÅ‚odzenie jeÅ›li czas druku warstwy wynosi poniżej" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1381 +msgid "Enable support material generation." +msgstr "Włącz generowanie materiaÅ‚u podporowego." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:645 +msgid "Enable this to get a commented G-code file, with each line explained by a descriptive text. If you print from SD card, the additional weight of the file could make your firmware slow down." +msgstr "Włącz tÄ… opcjÄ™ aby dodawać komentarz opsiujÄ…cy do każdej liniki pliku G-code. Przy druku z karty SD dodatkowy rozmiar pliku może sprawiać, że firmware bÄ™dzie reagować wolniej." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1681 +msgid "Enable variable layer height feature" +msgstr "Włącz funkcjÄ™ zmiennej wysokoÅ›ci warstwy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:853 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1126 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:217 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:227 +msgid "End G-code" +msgstr "KoÅ„cowy G-code" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1431 +msgid "Enforce support for the first" +msgstr "WymuÅ› podpory dla pierwszych" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1439 +msgid "Enforce support for the first n layers" +msgstr "WymuÅ› podpory dla pierwszych n warstw" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:238 +msgid "Ensure vertical shell thickness" +msgstr "Zagwarantuj odpowiedniÄ… grubość Å›cianki" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +msgid "Enter the new max size for the selected object:" +msgstr "Wprowadź maksymalny rozmiar dla wybranego modelu:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1030 +#, perl-format +msgid "Enter the new size for the selected object (print bed: %smm):" +msgstr "Wprowadź rozmiar dla wybranego modelu (stół: %s mm):" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:900 +msgid "Enter the number of copies of the selected object:" +msgstr "Wprowadź ilość kopii wybranego modelu:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Enter the rotation angle:" +msgstr "Wprowadź kÄ…t obrotu:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +#, no-perl-format +msgid "Enter the scale % for the selected object:" +msgstr "Wprowadź skalÄ™ w % dla wybranego modelu:" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:477 +msgid "Enter your filament cost per kg here. This is only for statistical information." +msgstr "Wprowadź koszt filamentu za kilogram. SÅ‚uży tylko statystykom." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:441 +msgid "Enter your filament density here. This is only for statistical information. A decent way is to weigh a known length of filament and compute the ratio of the length to volume. Better is to calculate the volume directly through displacement." +msgstr "Wprowadź gÄ™stość filamentu. SÅ‚uży tylko statystykom. DobrÄ… metodÄ… jest zważenie filamentu o zmierzonej dÅ‚ugoÅ›ci i przeliczenie stosunku wagi do objÄ™toÅ›ci." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:432 +msgid "Enter your filament diameter here. Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average." +msgstr "Wprowadź Å›rednicÄ™ filamentu. Wymagana jest precyzja, wiÄ™c użyj suwmiarki i zmierz filament w kilku miejscach, potem oblicz Å›redniÄ…." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:488 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:470 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1300 +msgid "Error" +msgstr "Błąd" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1612 +msgid "Error exporting 3MF file " +msgstr "Błąd eksportu pliku 3MF " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1596 +msgid "Error exporting AMF file " +msgstr "Błąd eksportu pliku AMF " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1526 +msgid "Error while uploading to the OctoPrint server: " +msgstr "Błąd podczas transferu do serwera OctoPrint: " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:315 +msgid "Error! " +msgstr "Błąd! " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:451 +msgid "Estimated printing time" +msgstr "Szacowany czas druku" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:44 +#, c-format +msgid "except for the first %d layers" +msgstr "za wyjÄ…tkiem pierwszych %d warstw" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:48 +msgid "except for the first layer" +msgstr "za wyjÄ…tkiem pierwszej warstwy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:192 +msgid "Experimental option for preventing support material from being generated under bridged areas." +msgstr "Funkcja eksperymentalna majÄ…ca zapobiegać tworzeniu podpór pod mostami." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:942 +msgid "Experimental option to adjust flow for overhangs (bridge flow will be used), to apply bridge speed to them and enable fan." +msgstr "Opcja eksperymentalna dostosowujÄ…ca przepÅ‚yw przy zwisach (zostanie zastosowany przepÅ‚yw taki jak dla mostów), zastosuje również prÄ™dkość takÄ… jak dla mostów i chÅ‚odzenie." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:263 +msgid "Export all presets to file" +msgstr "Eksport wszystkich zestawów ustawieÅ„ do pliku" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:257 +msgid "Export current configuration to file" +msgstr "Eksport obecnej konfiguracji do pliku" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 +msgid "Export current plate as 3MF" +msgstr "Eksport zawartoÅ›ci stoÅ‚u jako 3MF" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 +msgid "Export current plate as AMF" +msgstr "Eksport zawartoÅ›ci stoÅ‚u jako AMF" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 +msgid "Export current plate as G-code" +msgstr "Eksport zawartoÅ›ci stoÅ‚u jako G-code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 +msgid "Export current plate as STL" +msgstr "Eksport zawartoÅ›ci stoÅ‚u jako STL" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1454 +msgid "Export failed" +msgstr "Niepowodzenie eksportu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:314 +msgid "Export G-code..." +msgstr "Eksport G-code..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:236 +msgid "Export G-code…" +msgstr "Eksport G-code…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 +msgid "Export object as STL…" +msgstr "Eksport modelu jako STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:323 +msgid "Export plate as 3MF..." +msgstr "Eksport zawartoÅ›ci stoÅ‚u jako 3MF..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:320 +msgid "Export plate as AMF..." +msgstr "Eksport zawartoÅ›ci stoÅ‚u jako AMF..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:317 +msgid "Export plate as STL..." +msgstr "Eksport zawartoÅ›ci stoÅ‚u jako STL..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:240 +msgid "Export STL…" +msgstr "Eksport STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2113 +msgid "Export this single object as STL file" +msgstr "Eksport pojedynczego modelu jako plik STL" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:139 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:81 +msgid "External perimeter" +msgstr "Obrys zewnÄ™trzny" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:267 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:277 +msgid "External perimeters" +msgstr "Obrysy zewnÄ™trzne" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:151 +msgid "external perimeters" +msgstr "obrysy zewnÄ™trzne" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:289 +msgid "External perimeters first" +msgstr "Najpierw obrysy zewnÄ™trzne" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1118 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1126 +msgid "Extra length on restart" +msgstr "Dodatkowa ilość dla powrotu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:297 +msgid "Extra perimeters if needed" +msgstr "Dodatkowe obrysy jeÅ›li potrzebne" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:795 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1234 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:307 +msgid "Extruder" +msgstr "Ekstruder" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1187 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:400 +#, c-format +msgid "Extruder %d" +msgstr "Ekstruder %d" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:479 +msgid "Extruder clearance (mm)" +msgstr "OdstÄ™p od ekstrudera (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:342 +msgid "Extruder Color" +msgstr "Kolor ekstrudera" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:350 +msgid "Extruder offset" +msgstr "Margines ekstrudera" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:626 +msgid "Extruder temperature for first layer. If you want to control temperature manually during print, set this to zero to disable temperature control commands in the output file." +msgstr "Temperatura ekstrudera dla pierwszej warstwy. JeÅ›li chcesz rÄ™cznie kontrolować temperaturÄ™ podczas druku to ustaw zero aby wyłączyć komendy kontrolujÄ…ce temperaturÄ™ w pliku wyjÅ›ciowym." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1573 +msgid "Extruder temperature for layers after the first one. Set this to zero to disable temperature control commands in the output." +msgstr "Temperatura ekstrudera dla warstw powyżej pierwszej. Ustaw zero aby wyłączyć komendy kontrolujÄ…ce temperaturÄ™ w pliku wyjÅ›ciowym." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:431 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:966 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:308 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:702 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:958 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1272 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1445 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1471 +msgid "Extruders" +msgstr "Ekstrudery" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:360 +msgid "Extrusion axis" +msgstr "OÅ› ekstruzji" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:367 +msgid "Extrusion multiplier" +msgstr "Współczynnik ekstruzji" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:453 +msgid "Extrusion width" +msgstr "Szerokość ekstruzji" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:268 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:377 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:592 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:710 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:967 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1292 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1454 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1614 +msgid "Extrusion Width" +msgstr "Szerokość Ekstruzji" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:410 +msgid "Facets" +msgstr "Powierzchnie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:36 +msgid "Fan " +msgstr "Wentylator " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:817 +msgid "Fan settings" +msgstr "Ustawienia wentylatora" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:818 +msgid "Fan speed" +msgstr "PrÄ™dkość wentylatora" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:330 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:68 +msgid "Feature type" +msgstr "Rodzaj funkcji" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:78 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:79 +msgid "Feature types" +msgstr "Rodzaje funkcji" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:183 +msgid "Fewer" +msgstr "Mniej" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:786 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:787 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:368 +msgid "Filament" +msgstr "Filament" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:412 +msgid "Filament notes" +msgstr "Notatki do filamentu" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:832 +msgid "Filament properties" +msgstr "WÅ‚aÅ›ciwoÅ›ci filamentu" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:202 +msgid "Filament Settings" +msgstr "Ustawienia filamentu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:450 +msgid "Filament type" +msgstr "Typ filamentu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1445 +msgid "File added to print queue" +msgstr "Plik dodany do kolejki druku" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:475 +msgid "File Not Found" +msgstr "Nie znaleziono pliku" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:487 +msgid "Fill angle" +msgstr "KÄ…t wypeÅ‚nienia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:501 +msgid "Fill density" +msgstr "GÄ™stość wypeÅ‚nienia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:539 +msgid "Fill pattern" +msgstr "Wzór wypeÅ‚nienia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:541 +msgid "Fill pattern for general low-density infill." +msgstr "Wzór dla ogólnego wypeÅ‚nienia o niskiej gÄ™stoÅ›ci." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:248 +msgid "Fill pattern for top/bottom infill. This only affects the external visible layer, and not its adjacent solid shells." +msgstr "Wzór wypeÅ‚nienia górnego/dolnego. Ma wpÅ‚yw jedynie na zewnÄ™trzne widoczne warstwy, nie ma wpÅ‚ywu na przylegajÄ…ce do nich powÅ‚oki zwartego wypeÅ‚nienia." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1110 +msgid "Firmware" +msgstr "Firmware" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1314 +msgid "Firmware Retraction" +msgstr "Retrakcja z firmware" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:573 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:582 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:591 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:625 +msgid "First layer" +msgstr "Pierwsza warstwa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:603 +msgid "First layer height" +msgstr "Wysokość pierwszej warstwy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:615 +msgid "First layer speed" +msgstr "PrÄ™dkość pierwszej warstwy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "First layer volumetric" +msgstr "ObjÄ™toÅ›ciowa pierwszej warstwy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:466 +msgid "Flow" +msgstr "PrzepÅ‚yw" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:599 +msgid "" +"For the Wipe Tower to work with the soluble supports, the support layers\n" +"need to be synchronized with the object layers.\n" +"\n" +"Shall I synchronize support layers in order to enable the Wipe Tower?" +msgstr "" +"Aby wieża czyszczÄ…ca dziaÅ‚aÅ‚a przy rozpuszczalnych podporach, warstwy podporowe muszÄ… być zsynchronizowane z warstwami modelu.\n" +"\n" +"Zsynchronizować warstwy podporowe aby włączyć wieżę czyszczÄ…cÄ…?" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1264 +msgid "Force solid infill for regions having a smaller area than the specified threshold." +msgstr "WymuÅ› zwarte wypeÅ‚nienie dla obszarów mniejszych niż zadany próg." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:758 +msgid "Force the generation of solid shells between adjacent materials/volumes. Useful for multi-extruder prints with translucent materials or manual soluble support material." +msgstr "WymuÅ› generowanie zwartych powÅ‚ok pomiÄ™dzy przylegajÄ…cymi do siebie materiaÅ‚ami. Przydatne przy druku materiaÅ‚ami przejrzystymi lub przy rÄ™cznych podporach rozpuszczalnych." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 +msgid "Front" +msgstr "Przód" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:371 +msgid "Front View" +msgstr "Widok przodu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +msgid "G-code" +msgstr "G-code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1451 +msgid "G-code file exported to " +msgstr "Plik G-code wyeksportowany do " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1524 +msgid "G-code file successfully uploaded to the OctoPrint server" +msgstr "Plik G-code pomyÅ›lnie zaÅ‚adowany do serwera OctoPrint" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:652 +msgid "G-code flavor" +msgstr "Rodzaj G-code" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:444 +msgid "g/cm³" +msgstr "g/cm³" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:634 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:145 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:87 +msgid "Gap fill" +msgstr "WypeÅ‚nienie szpar" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:937 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:11 +msgid "General" +msgstr "Ogólne" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:875 +msgid "Generate no less than the number of skirt loops required to consume the specified amount of filament on the bottom layer. For multi-extruder machines, this minimum applies to each extruder." +msgstr "Generuj ilość pÄ™tli skirtu nie mniejszÄ… niż okreÅ›lona aby zużyć takÄ… ilość filamentu na dolnej warstwie. Dla drukarek z kilkoma ekstuderami ta wartość jest stosowana dla każdego z nich." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1379 +msgid "Generate support material" +msgstr "Generuj materiaÅ‚ podporowy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1433 +msgid "Generate support material for the specified number of layers counting from bottom, regardless of whether normal support material is enabled or not and regardless of any angle threshold. This is useful for getting more adhesion of objects having a very thin or poor footprint on the build plate." +msgstr "Generuj materiaÅ‚ podporowy dla okreÅ›lonej liczby warstw liczÄ…c od doÅ‚u, niezależnie od tego czy normalny materiaÅ‚ podporowy jest włączony i niezależnie od progu kÄ…ta. Przydaje siÄ™ aby uzyskać lepszÄ… przyczepność modelu, które majÄ… bardzo małą powierzchniÄ™ kontaktu z powierzchniÄ… druku." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:498 +msgid "GLUquadricObjPtr | Attempt to free unreferenced scalar" +msgstr "GLUquadricObjPtr | Podejmij próbÄ™ uwolnienie skalara bez odniesienia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:583 +msgid "Heated build plate temperature for the first layer. Set this to zero to disable bed temperature control commands in the output." +msgstr "Temperatura podgrzewanego stoÅ‚u dla pierwszej warstwy. Ustaw zero aby wyłączyć komendy kontrolujÄ…ce temperaturÄ™ stoÅ‚u w pliku wyjÅ›ciowym." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:320 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:69 +msgid "Height" +msgstr "Wysokość" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:332 +msgid "Height (mm)" +msgstr "Wysokość (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1222 +msgid "Height of skirt expressed in layers. Set this to a tall value to use skirt as a shield against drafts." +msgstr "Wysokość skirtu wyrażona w warstwach. Ustawienie wysokiej wartoÅ›ci spowoduje stworzenie osÅ‚ony chroniÄ…cej przed przeciÄ…gami." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:329 +msgid "Horizontal shells" +msgstr "PowÅ‚oka pozioma" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:128 +msgid "Horizontal width of the brim that will be printed around each object on the first layer." +msgstr "Szerokość brim (obramowania), drukowanego wokół każdego z modeli na pierwszej warstwie." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:908 +msgid "Host or IP" +msgstr "Host lub IP" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:214 +msgid "I wasn't able to connect to OctoPrint (" +msgstr "Nie udaÅ‚o siÄ™ nawiÄ…zać połączenia z OctoPrint (" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:26 +#, c-format +msgid "If estimated layer time is below ~%ds, fan will run at %d%% and print speed will be reduced so that no less than %ds are spent on that layer (however, speed will never be reduced below %dmm/s)." +msgstr "JeÅ›li szacowany czas druku warstwy jest mniejszy niż ~%d s, wentylator bÄ™dzie pracowaÅ‚ na %d %% a prÄ™dkość druku zostanie obniżona tak, aby warstwa byÅ‚a drukowana przez nie mniej niż %d s (jednakże prÄ™dkość nie zostanie obniżona poniżej %d mm/s)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:616 +msgid "If expressed as absolute value in mm/s, this speed will be applied to all the print moves of the first layer, regardless of their type. If expressed as a percentage (for example: 40%) it will scale the default speeds." +msgstr "JeÅ›li ustawisz wartość bezwzglÄ™dnÄ… wyrażonÄ… w mm/s, taka prÄ™dkość bÄ™dzie zastosowana dla wszystkich ruchów drukujÄ…cych dla pierwszej warstwy, nie zależnie od ich rodzajów. JeÅ›li ustawisz wartość procentowÄ… (np. 40%), bÄ™dzie ona skalowana wg domyÅ›lnej prÄ™dkoÅ›ci." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:395 +msgid "If layer print time is estimated below this number of seconds, fan will be enabled and its speed will be calculated by interpolating the minimum and maximum speeds." +msgstr "JeÅ›li szacowany czas druku warstwy bÄ™dzie mniejszy niż ta wartość to wentylator bÄ™dzie włączony a jego prÄ™dkość bÄ™dzie interpolowana na podstawie górnego i dolnego limitu prÄ™dkoÅ›ci." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1240 +msgid "If layer print time is estimated below this number of seconds, print moves speed will be scaled down to extend duration to this value." +msgstr "JeÅ›li szacowany czas druku warstwy bÄ™dzie mniejszy niż ta wartość to prÄ™dkość ruchów drukujÄ…cych bÄ™dzie zmniejszona aby wydÅ‚użyć czas druku." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:388 +msgid "If this is enabled, fan will never be disabled and will be kept running at least at its minimum speed. Useful for PLA, harmful for ABS." +msgstr "Ta opcja spowoduje, że wentylator nie wyłączy siÄ™ podczas druku, tzn. zawsze bÄ™dzie pracowaÅ‚ z przynajmniej minimalnÄ… prÄ™dkoÅ›ciÄ…. Przydatne dla PLA, może szkodzić przy ABS." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:37 +msgid "If this is enabled, Slic3r will auto-center objects around the print bed center." +msgstr "Spowoduje, że Slic3r bÄ™dzie automatycznie umieszczaÅ‚ modele wokół centrum stoÅ‚u." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:45 +msgid "If this is enabled, Slic3r will pre-process objects as soon as they're loaded in order to save time when exporting G-code." +msgstr "Spowoduje, że Slic3r bÄ™dzie automatycznie procesowaÅ‚ modele jak tylko zostanÄ… zaÅ‚adowane aby zmniejszyć czas eksportu G-code." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:29 +msgid "If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files." +msgstr "Włączenie spowoduje, że Slic3r bÄ™dzie za każdym razem pytaÅ‚ gdzie wyeksportować plik zamiast używać katalogu z plikami wejÅ›ciowymi." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:77 +msgid "If you have rendering issues caused by a buggy OpenGL 2.0 driver, you may try to check this checkbox. This will disable the layer height editing and anti aliasing, so it is likely better to upgrade your graphics driver." +msgstr "JeÅ›li napotykasz błędy spowodowane problematycznym sterownikiem OpenGL 2.0, spróbuj zaznaczyć to pole. Wyłączy to edycjÄ™ wysokoÅ›ci warstwy i anti-aliasing, wiÄ™c prawdopodobnie lepiej bÄ™dzie zaktualizować sterowniki karty graficznej." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1091 +msgid "If you set this to a positive value, Z is quickly raised every time a retraction is triggered. When using multiple extruders, only the setting for the first extruder will be considered." +msgstr "JeÅ›li ustawisz tu wartość dodatniÄ… to oÅ› Z wykona szybki ruch w górÄ™ przy każdej retrakcji. Przy używaniu kilku ekstruderów tylko ustawienia pierwszego z nich bÄ™dÄ… brane pod uwagÄ™." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1101 +msgid "If you set this to a positive value, Z lift will only take place above the specified absolute Z. You can tune this setting for skipping lift on the first layers." +msgstr "JeÅ›li ustawisz wartość dodatniÄ…, to oÅ› Z (z-hop) bÄ™dzie podnosić siÄ™ tylko powyżej ustawionej wartoÅ›ci. Możesz w ten sposób wyłączyć z-hop na pierwszej warstwie." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1110 +msgid "If you set this to a positive value, Z lift will only take place below the specified absolute Z. You can tune this setting for limiting lift to the first layers." +msgstr "JeÅ›li ustawisz wartość dodatniÄ…, to z-hop bÄ™dzie odbywaÅ‚ siÄ™ tylko poniżej ustawionej wartoÅ›ci. Możesz w ten sposób ograniczyć dziaÅ‚anie funkcji np. tylko dla pierwszych warstw." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:451 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1002 +msgid "If you want to process the output G-code through custom scripts, just list their absolute paths here. Separate multiple scripts with a semicolon. Scripts will be passed the absolute path to the G-code file as the first argument, and they can access the Slic3r config settings by reading environment variables." +msgstr "Wprowadź Å›cieżki do wÅ‚asnych skryptów jeÅ›li chcesz dodać je do wyjÅ›ciowego pliku G-code. Możesz dodać wiele skryptów, rozdzielajÄ…c je Å›rednikiem ( ; ). Skrypty bÄ™dÄ… przetwarzane jako pierwsze w kolejnoÅ›ci i majÄ… dostÄ™p do ustawieÅ„ konfiguracyjnych Slic3ra przez zmienne Å›rodowiskowe." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:351 +msgid "If your firmware doesn't handle the extruder displacement you need the G-code to take it into account. This option lets you specify the displacement of each extruder with respect to the first one. It expects positive coordinates (they will be subtracted from the XY coordinate)." +msgstr "JeÅ›li oprogramowanie ukÅ‚adowe (firmware) Twojej drukarki nie obsÅ‚uguje rozmieszczenia ekstruderów to trzeba to okreÅ›lić w G-code. Ta opcja pozwala ustawić rozmieszczenie każdego ekstrudera w relacji do pierwszego. Oczekuje koordynat dodatnich (bÄ™dÄ… odejmowane od koordynat XY)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1664 +msgid "If your firmware requires relative E values, check this, otherwise leave it unchecked. Most firmwares use absolute values." +msgstr "JeÅ›li Twój firmware wymaga wzglÄ™dnych wartoÅ›ci E, zaznacz to pole. W innym przypadku zostaw puste. WiÄ™kszość ukÅ‚adów obsÅ‚uguje wartoÅ›ci absolutne." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 +msgid "Increase copies" +msgstr "ZwiÄ™ksz kopie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:346 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:347 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:664 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:87 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:247 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:488 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:502 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:540 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:681 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:691 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:709 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:727 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:746 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1263 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1280 +msgid "Infill" +msgstr "WypeÅ‚nienie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:169 +msgid "infill" +msgstr "wypeÅ‚nienie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:720 +msgid "Infill before perimeters" +msgstr "WypeÅ‚nienie przed obrysami" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:701 +msgid "Infill extruder" +msgstr "Ekstruder dla wypeÅ‚nienia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:735 +msgid "Infill/perimeters overlap" +msgstr "NakÅ‚adanie wypeÅ‚nienia na obrysy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:398 +msgid "Info" +msgstr "Info" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1479 +msgid "Interface layers" +msgstr "Warstwy łączÄ…ce" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1463 +msgid "Interface loops" +msgstr "Warstwy łączÄ…ce" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1488 +msgid "Interface pattern spacing" +msgstr "Rozmieszczenie wzoru warstw łączÄ…cych" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:757 +msgid "Interface shells" +msgstr "Obrysy łączÄ…ce" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:141 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:83 +msgid "Internal infill" +msgstr "WypeÅ‚nienie wewnÄ™trzne" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Invalid rotation angle entered" +msgstr "NieprawidÅ‚owa wartość kÄ…ta obrotu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +msgid "Invalid scaling value entered" +msgstr "NieprawidÅ‚owa wartość skalowania" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 +msgid "Iso" +msgstr "Izometryczny" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:368 +msgid "Iso View" +msgstr "Widok izometryczny" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1180 +msgid "Jitter" +msgstr "Jitter" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:387 +msgid "Keep fan always on" +msgstr "Wentylator zawsze włączony" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 +msgid "Language" +msgstr "JÄ™zyk" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:192 +msgid "Layer Editing" +msgstr "Edycja Warstw" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:207 +msgid "Layer editing" +msgstr "Edycja warstw" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:314 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:777 +msgid "Layer height" +msgstr "Wysokość warstwy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1194 +msgid "Layer height limits" +msgstr "Limit wysokoÅ›ci warstw" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:183 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:694 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1033 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1224 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1285 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1437 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1482 +msgid "layers" +msgstr "warstwy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:157 +msgid "Layers" +msgstr "Warstwy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:69 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:239 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:290 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:298 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:604 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:762 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:778 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:941 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:989 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1152 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1583 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1639 +msgid "Layers and Perimeters" +msgstr "Warstwy i Obrysy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:313 +msgid "Layers and perimeters" +msgstr "Warstwy i obrysy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 +msgid "Left" +msgstr "Lewo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:373 +msgid "Left View" +msgstr "Widok lewy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1071 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1080 +msgid "Length" +msgstr "DÅ‚ugość" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1090 +msgid "Lift Z" +msgstr "Z-hop" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:254 +msgid "Load exported configuration file" +msgstr "Wczytaj wyeksportowany plik konfiguracyjny" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:260 +msgid "Load presets from a bundle" +msgstr "Wczytaj zestaw ustawieÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:75 +msgid "Load shape from STL..." +msgstr "Wczytaj ksztaÅ‚t z STL..." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:692 +msgid "Loaded " +msgstr "Wczytano " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 +msgid "Loading…" +msgstr "Wczytywanie…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1229 +msgid "Loops (minimum)" +msgstr "PÄ™tle (minimum)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:412 +msgid "Manifold" +msgstr "Model zamkniÄ™ty" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:411 +msgid "Materials" +msgstr "MateriaÅ‚y" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:787 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:796 +msgid "Max" +msgstr "Max" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:807 +msgid "Max print speed" +msgstr "Maksymalna prÄ™dkość druku" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:837 +msgid "Max volumetric slope negative" +msgstr "Maksymalny negatywny kÄ…t zwisu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:826 +msgid "Max volumetric slope positive" +msgstr "Maksymalny objÄ™toÅ›ciowo kÄ…t pozytywny" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:421 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:817 +msgid "Max volumetric speed" +msgstr "Maksymalna prÄ™dkość objÄ™toÅ›ciowa" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:422 +msgid "Maximum volumetric speed allowed for this filament. Limits the maximum volumetric speed of a print to the minimum of print and filament volumetric speed. Set to zero for no limit." +msgstr "Maksymalna prÄ™dkość objÄ™toÅ›ciowa dla tego filamentu. Ogranicza maksymalnÄ… prÄ™dkość objÄ™toÅ›ciowÄ… do minimum objÄ™toÅ›ciowej prÄ™dkoÅ›ci druku i filamentu. Ustaw zero aby usunąć ograniczenie." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:848 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:857 +msgid "Min" +msgstr "Min" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:866 +msgid "Min print speed" +msgstr "Minimalna prÄ™dkość druku" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1040 +msgid "Minimum detail resolution, used to simplify the input file for speeding up the slicing job and reducing memory usage. High-resolution models often carry more detail than printers can render. Set to zero to disable any simplification and use full resolution from input." +msgstr "Minimalna rozdzielczość, używana do uproszczenia modelu wejÅ›ciowego, co prowadzi do przyspieszenia procesu ciÄ™cia. Modele w wysokiej rozdzielczoÅ›ci mogÄ… zawierać wiÄ™cej szczegółów niż drukarka jest w stanie przetworzyć. Ustaw zero aby wyłączyć upraszczanie i użyć peÅ‚nej rozdzielczoÅ›ci pliku wejÅ›ciowego." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:874 +msgid "Minimum extrusion length" +msgstr "Minimalna dÅ‚ugość ekstruzji" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1050 +msgid "Minimum travel after retraction" +msgstr "Minimalny ruch jaÅ‚owy po retrakcji" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 +msgid "Mirror" +msgstr "Lustrzane" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2055 +msgid "Mirror the selected object" +msgstr "Odbicie lustrzane wybranego modelu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2057 +msgid "Mirror the selected object along the X axis" +msgstr "Odbicie lustrzane wybranego modelu w osi X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2060 +msgid "Mirror the selected object along the Y axis" +msgstr "Odbicie lustrzane wybranego modelu w osi Y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2063 +msgid "Mirror the selected object along the Z axis" +msgstr "Odbicie lustrzane wybranego modelu w osi Z" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:151 +msgid "Mixed" +msgstr "Mieszane" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:65 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:129 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:200 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:211 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:325 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:336 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:355 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:434 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:781 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:801 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:860 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:878 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:896 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1044 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1052 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1094 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1103 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1113 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1121 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1129 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1215 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1421 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1491 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1527 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1704 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1711 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1718 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1727 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1737 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1747 +msgid "mm" +msgstr "mm" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1075 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1085 +msgid "mm (zero to disable)" +msgstr "mm (zero aby wyłączyć)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:609 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:740 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1390 +msgid "mm or %" +msgstr "mm lub %" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:382 +msgid "mm or % (leave 0 for auto)" +msgstr "mm lub % (zero dla wartoÅ›ci automatycznych)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:272 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:597 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:715 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:972 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1296 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1458 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1619 +msgid "mm or % (leave 0 for default)" +msgstr "mm lub % (zero dla domyÅ›lnych)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:120 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:638 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:749 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:811 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:868 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:981 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1137 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1146 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1536 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1649 +msgid "mm/s" +msgstr "mm/s" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:282 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:619 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1255 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1306 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1501 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1631 +msgid "mm/s or %" +msgstr "mm/s lub %" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:80 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:174 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:576 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:684 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:952 +msgid "mm/s²" +msgstr "mm/s²" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1265 +msgid "mm²" +msgstr "mm²" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:425 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:820 +msgid "mm³/s" +msgstr "mm³/s" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:831 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:842 +msgid "mm³/s²" +msgstr "mm³/s²" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:414 +msgid "Modifiers" +msgstr "Modyfikatory" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:478 +msgid "money/kg" +msgstr "piniendzy/kg" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:182 +msgid "More" +msgstr "WiÄ™cej" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1696 +msgid "Multi material printers may need to prime or purge extruders on tool changes. Extrude the excess material into the wipe tower." +msgstr "Drukarki pracujÄ…ce z kilkoma filamentami na raz (multi-material) mogÄ… wymagać czyszczenia gÅ‚owicy przy zmianie filamentu. Nadmiar materiaÅ‚u jest wytÅ‚aczany w formie wieży czyszczÄ…cej." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:666 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:683 +msgid "Multi-part object detected" +msgstr "Wykryto obiekt wieloczęściowy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:430 +msgid "Multiple Extruders" +msgstr "Kilka ekstruderów" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:680 +msgid "" +"Multiple objects were loaded for a multi-material printer.\n" +"Instead of considering them as multiple objects, should I consider\n" +"these files to represent a single object having multiple parts?\n" +msgstr "" +"Kilka obiektów zostaÅ‚o zaÅ‚adowanych dla drukarki typu multi-material.\n" +"Traktować je jako jeden model zawierajÄ…cy kilka części?\n" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:220 +msgid "Name" +msgstr "Nazwa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:192 +msgid "No Bonjour device found" +msgstr "Nie znaleziono urzÄ…dzenia Bonjour" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:469 +msgid "No previously sliced file." +msgstr "Brak poprzednio pociÄ™tych pliku." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:137 +msgid "None" +msgstr "Brak" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:500 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:501 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:859 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:860 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1156 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1157 +msgid "Notes" +msgstr "Notatki" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:493 +msgid "Notice" +msgstr "Uwaga" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:894 +msgid "Nozzle diameter" +msgstr "Åšrednica dyszy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:967 +msgid "Number of extruders of the printer." +msgstr "Liczba ekstruderów drukarki." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1481 +msgid "Number of interface layers to insert between the object(s) and support material." +msgstr "Liczba warstw łączÄ…cych materiaÅ‚ podporowy z modelem wÅ‚aÅ›ciwym." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1231 +msgid "Number of loops for the skirt. If the Minimum Extrusion Length option is set, the number of loops might be greater than the one configured here. Set this to zero to disable skirt completely." +msgstr "Liczba pÄ™tli skirt. JeÅ›li włączona jest opcja \"Minimalna dÅ‚ugość ekstruzji\", to może ona nadpisać wartość wprowadzonÄ… w tym polu. Ustaw zero aby caÅ‚kowicie wyłączyć skirt." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:70 +msgid "Number of solid layers to generate on bottom surfaces." +msgstr "Liczba zwartych warstw dolnych." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1315 +msgid "Number of solid layers to generate on top and bottom surfaces." +msgstr "Liczba zwartych warstw górnych i dolnych." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1640 +msgid "Number of solid layers to generate on top surfaces." +msgstr "Liczba zwartych warstw górnych." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:745 +msgid "Object too large?" +msgstr "Model zbyt duży?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1032 +msgid "OctoPrint upload" +msgstr "Transfer do OctoPrint" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1410 +msgid "Only create support if it lies on a build plate. Don't create support on a print." +msgstr "Tworzenie podpór tylko na stole. Nie bÄ™dÄ… tworzone na wydruku." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:726 +msgid "Only infill where needed" +msgstr "Tylko potrzebne wypeÅ‚nienie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1205 +msgid "Only lift Z" +msgstr "Tylko z-hop" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1100 +msgid "Only lift Z above" +msgstr "Z-hop tylko powyżej" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1109 +msgid "Only lift Z below" +msgstr "Z-hop tylko poniżej" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:915 +msgid "Only retract when crossing perimeters" +msgstr "Retrakcja tylko przy przechodzeniu nad obrysami" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:438 +msgid "Ooze prevention" +msgstr "Zapobieganie wyciekom" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 +msgid "Open a model" +msgstr "Otwórz model" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:251 +msgid "Open STL/OBJ/AMF…\tCtrl+O" +msgstr "Otwórz STL/OBJ/AMF… \tCtrl+O" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2102 +msgid "Open the 3D cutting tool" +msgstr "Otwórz narzÄ™dzie do przecinania 3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 +msgid "Open the object editor dialog" +msgstr "Otwórz menu edytora modelu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 +msgid "Open the Prusa Edition releases page in your browser" +msgstr "Otwórz stronÄ™ z wydaniami Prusa Edition w przeglÄ…darce" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 +msgid "Open the Prusa3D drivers download page in your browser" +msgstr "Otwórz stronÄ™ Prusa3D ze sterownikami w przeglÄ…darce" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 +msgid "Open the Slic3r manual in your browser" +msgstr "Otwórz instrukcjÄ™ do Slic3ra w przeglÄ…darce" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 +msgid "Open the Slic3r website in your browser" +msgstr "Otwórz stronÄ™ Slic3ra w przeglÄ…darce" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:27 +msgid "Optimize travel moves in order to minimize the crossing of perimeters. This is mostly useful with Bowden extruders which suffer from oozing. This feature slows down both the print and the G-code generation." +msgstr "Optymalizuj ruchy jaÅ‚owe aby zminimalizować przejeżdżanie nad obrysami. Ta funkcja jest przydatna szczególne przy ekstruderach typu bowden, podatnych na wyciekanie filamentu z dyszy. Włączenie tej funkcji wydÅ‚uża zarówno czas druku jak i czas generowania G-code." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:384 +msgid "Options for support material and raft" +msgstr "Opcje materiaÅ‚u podporowego i tratwy (raft)" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:57 +msgid "Origin" +msgstr "Punkt zerowy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:469 +msgid "Other" +msgstr "Inne" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:38 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1572 +msgid "Other layers" +msgstr "Inne warstwy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:488 +msgid "Output file" +msgstr "Plik wyjÅ›ciowy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:930 +msgid "Output filename format" +msgstr "Rozszerzenie pliku wyjÅ›ciowego" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:476 +msgid "Output options" +msgstr "Opcje wyjÅ›ciowe" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:140 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:82 +msgid "Overhang perimeter" +msgstr "Obrys zwisu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1550 +msgid "Overhang threshold" +msgstr "Próg zwisu" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:463 +msgid "Overlap" +msgstr "NakÅ‚adanie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1508 +msgid "Pattern" +msgstr "Wzór" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1398 +msgid "Pattern angle" +msgstr "KÄ…t wzoru" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1524 +msgid "Pattern spacing" +msgstr "Rozmieszczenie wzoru" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1510 +msgid "Pattern used to generate support material." +msgstr "Wzór podpór." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1723 +msgid "Per color change depth" +msgstr "Głębokość zmiany koloru" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:138 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:80 +msgid "Perimeter" +msgstr "Obrys" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:957 +msgid "Perimeter extruder" +msgstr "Ekstruder dla obrysów" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:948 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:966 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:978 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:988 +msgid "Perimeters" +msgstr "Obrysy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:160 +msgid "perimeters" +msgstr "obrysy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2024 +msgid "Place one more copy of the selected object" +msgstr "Umieść jednÄ… kopiÄ™ zaznaczonego modelu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:118 +msgid "Plater" +msgstr "Zawartość stoÅ‚u" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1199 +msgid "Position (for multi-extruder printers)" +msgstr "Pozycja (dla drukarek z kilkoma ekstruderami)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1153 +msgid "Position of perimeters starting points." +msgstr "Pozycja startowa druku obrysów." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1702 +msgid "Position X" +msgstr "Pozycja X" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1709 +msgid "Position Y" +msgstr "Pozycja Y" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:494 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1001 +msgid "Post-processing scripts" +msgstr "Skrypty do przetwarzania koÅ„cowego" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp:17 +msgid "Preferences" +msgstr "Preferencje" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:299 +msgid "Preferences…\tCtrl+," +msgstr "Preferencje... \tCtrl+," + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1171 +msgid "Preferred direction of the seam" +msgstr "Preferowane ustawienie szwu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1183 +msgid "Preferred direction of the seam - jitter" +msgstr "Preferowany kierunek szwu - jitter" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1222 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:150 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2125 +msgid "Preview" +msgstr "PodglÄ…d" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:474 +msgid "Previously sliced file (" +msgstr "Poprzednio pociÄ™ty plik (" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:291 +msgid "Print contour perimeters from the outermost one to the innermost one instead of the default inverse order." +msgstr "Drukuj obrysy od zewnÄ…trz do wewnÄ…trz zamiast domyÅ›lnego ustawienia wÄ™wnÄ…trz-zewnÄ…trz." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:182 +msgid "Print Settings" +msgstr "Ustawienia Druku" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:367 +msgid "Print settings" +msgstr "Ustawienia druku" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:836 +msgid "Print speed override" +msgstr "Nadpisanie prÄ™dkoÅ›ci druku" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:369 +msgid "Printer" +msgstr "Drukarka" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1014 +msgid "Printer notes" +msgstr "Notatki o drukarce" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:228 +msgid "Printer Settings" +msgstr "Ustawienia Drukarki" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:238 +msgid "Print…" +msgstr "Druk…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 +msgid "Processing " +msgstr "Przetwarzanie " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:629 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:643 +msgid "Processing input file\n" +msgstr "Przetwarzanie pliku wejÅ›ciowego\n" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:508 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:868 +msgid "Profile dependencies" +msgstr "ZależnoÅ›ci profilowe" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:385 +msgid "Prusa 3D Drivers" +msgstr "Sterowniki Prusa3D" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:388 +msgid "Prusa Edition Releases" +msgstr "Wydania Prusa Edition" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 +msgid "Q&uick Slice…\tCtrl+U" +msgstr "Sz&ybkie ciÄ™cie \tCtrl+U" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:335 +msgid "Quality (slower slicing)" +msgstr "Jakość (wolniejsze ciÄ™cie)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 +msgid "Quick Slice and Save &As…\tCtrl+Alt+U" +msgstr "Szybkie CiÄ™cie i &Zapis... \tCtrl+Alt+U" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:304 +msgid "Quit Slic3r" +msgstr "Zamknij Slic3r" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:331 +msgid "Radius" +msgstr "PromieÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:380 +msgid "Raft" +msgstr "Tratwa (raft)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1029 +msgid "Raft layers" +msgstr "Warstwy tratwy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 +msgid "Rear" +msgstr "TyÅ‚" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:372 +msgid "Rear View" +msgstr "Widok z tyÅ‚u" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:262 +#, c-format +msgid "Recommended object thin wall thickness for layer height %.2f and " +msgstr "Zalecana grubość Å›ciany obiektu dla danej wysokoÅ›ci warstwy %.2f i " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:245 +msgid "Recommended object thin wall thickness: Not available due to invalid layer height." +msgstr "Zalecana grubość Å›cian dla modelu: niedostÄ™pna ze wzglÄ™du na niewÅ‚aÅ›ciwÄ… wysokość warstwy." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:46 +msgid "Rectangular" +msgstr "ProstokÄ…tny" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:352 +msgid "Reducing printing time" +msgstr "Obniżanie czasu wydruku" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 +msgid "Reload from Disk" +msgstr "Wczytaj ponownie z dysku" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2110 +msgid "Reload the selected file from Disk" +msgstr "Wczytaj ponownie wybrany plik z dysku" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:27 +msgid "Remember output directory" +msgstr "ZapamiÄ™taj katalog wyjÅ›ciowy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1582 +msgid "Remove" +msgstr "UsuÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1580 +msgid "remove" +msgstr "usuÅ„" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2027 +msgid "Remove one copy of the selected object" +msgstr "UsuÅ„ jednÄ… kopiÄ™ wybranego modelu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2021 +msgid "Remove the selected object" +msgstr "UsuÅ„ wybrany model" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 +msgid "Repair" +msgstr "Naprawa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:294 +msgid "Repair STL file…" +msgstr "Naprawa pliku STL…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:280 +msgid "Repeat last quick slice" +msgstr "Powtórz ostatnie szybkie ciÄ™cie" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 +msgid "Report an Issue" +msgstr "ZgÅ‚oÅ› problem" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:405 +msgid "Report an issue on the Slic3r Prusa Edition" +msgstr "ZgÅ‚oÅ› problem z Slic3r Prusa Edition" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:995 +msgid "Rescan serial ports" +msgstr "Przeskanuj porty szeregowe" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1039 +msgid "Resolution" +msgstr "Rozdzielczość" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1057 +msgid "Retract amount before wipe" +msgstr "DÅ‚ugość retrakcji przed ruchem czyszczÄ…cym" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1065 +msgid "Retract on layer change" +msgstr "Retrakcja przy zmianie warstwy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1202 +msgid "Retraction" +msgstr "Retrakcja" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1051 +msgid "Retraction is not triggered when travel moves are shorter than this length." +msgstr "Retrakcja nie zostanie wykonana przy ruchu jaÅ‚owym krótszym niż ta wartość." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1072 +msgid "Retraction Length" +msgstr "DÅ‚ugość retrakcji" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1081 +msgid "Retraction Length (Toolchange)" +msgstr "DÅ‚ugość Retrakcji (zmiana narzÄ™dzia)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1134 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1135 +msgid "Retraction Speed" +msgstr "PrÄ™dkość retrakcji" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1218 +msgid "Retraction when tool is disabled (advanced settings for multi-extruder setups)" +msgstr "Retrakcja gdy dany ekstruder nie jest w użyciu (funkcja zaawansowana dla drukarek z kilkoma ekstruderami)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:96 +msgid "Retractions" +msgstr "Retrakcje" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 +msgid "Right" +msgstr "Prawo" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:374 +msgid "Right View" +msgstr "Widok prawy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 +msgid "Rotate" +msgstr "Obróć" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 +msgid "Rotate 45° clockwise" +msgstr "Obróć o 45° zgodnie ze wskazówkami zegara" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 +msgid "Rotate 45° counter-clockwise" +msgstr "Obróć o 45° przeciwnie do wskazówek zegara" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:950 +msgid "Rotate around " +msgstr "Obróć wokół " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2034 +msgid "Rotate the selected object by 45° clockwise" +msgstr "Obróć wybrany model o 45° zgodnie ze wskazówkami zegara" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2037 +msgid "Rotate the selected object by 45° counter-clockwise" +msgstr "Obróć wybrany model o 45° przeciwnie do wskazówek zegara" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2042 +msgid "Rotate the selected object by an arbitrary angle" +msgstr "Obróć wybrany model dowolnie" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2044 +msgid "Rotate the selected object by an arbitrary angle around X axis" +msgstr "Obróć wybrany model o dowolny kÄ…t wokół osi X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2047 +msgid "Rotate the selected object by an arbitrary angle around Y axis" +msgstr "Obróć wybrany model o dowolny kÄ…t wokół osi Y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2050 +msgid "Rotate the selected object by an arbitrary angle around Z axis" +msgstr "Obróć wybrany model o dowolny kÄ…t wokół osi Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:380 +msgid "Run Configuration " +msgstr "Uruchom KonfiguracjÄ™ " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1751 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1645 +msgid "Save " +msgstr "Zapisz " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:605 +msgid "Save configuration as:" +msgstr "Zapisz konfiguracjÄ™ jako:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:50 +msgid "Save current " +msgstr "Zapisz bieżące " + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:580 +msgid "Save OBJ file (less prone to coordinate errors than STL) as:" +msgstr "Zapisz plik OBJ (mniej podatny na błędy współrzÄ™dnych niż STL) jako:" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:248 +msgid "Save preset" +msgstr "Zapisz zestaw ustawieÅ„" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:646 +msgid "Save presets bundle as:" +msgstr "Zapisz paczkÄ™ ustawieÅ„ jako:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:222 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1056 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1061 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 +msgid "Scale" +msgstr "Skalowanie" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1031 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1035 +msgid "Scale along " +msgstr "Skalowanie wzdÅ‚uż " + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2068 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 +msgid "Scale the selected object along a single axis" +msgstr "Skalowanie wybranego modelu wzdÅ‚uż jednej osi" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2073 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2089 +msgid "Scale the selected object along the X axis" +msgstr "Skalowanie wybranego modelu wzdÅ‚uż osi X" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 +msgid "Scale the selected object along the XYZ axes" +msgstr "Skalowanie wybranego modelu wzdÅ‚uż osi XYZ" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2076 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2092 +msgid "Scale the selected object along the Y axis" +msgstr "Skalowanie wybranego modelu wzdÅ‚uż osi Y" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2079 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2095 +msgid "Scale the selected object along the Z axis" +msgstr "Skalowanie wybranego modelu wzdÅ‚uż osi Z" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2084 +msgid "Scale to size" +msgstr "Skalowanie do wymiaru" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:187 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:203 +msgid "Scale…" +msgstr "Skalowanie…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1151 +msgid "Seam position" +msgstr "Pozycja szwu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1172 +msgid "Seam preferred direction" +msgstr "Preferowany kierunek szwu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1182 +msgid "Seam preferred direction jitter" +msgstr "Kierunek jitter wyznaczany przez szew" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 +msgid "Select &Controller Tab\tCtrl+T" +msgstr "Kontrole&r \tCtrl+T" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 +msgid "Select &Filament Settings Tab\tCtrl+3" +msgstr "Ustawienia &Filamentu \tCtrl+3" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 +msgid "Select &Plater Tab\tCtrl+1" +msgstr "ZakÅ‚adka &Stół\tCtrl+1" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:623 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:667 +msgid "Select configuration to load:" +msgstr "Wybierz konfiguracjÄ™ do wczytania:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 +msgid "Select P&rint Settings Tab\tCtrl+2" +msgstr "Ustawienia &Druku \tCtrl+2" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 +msgid "Select Print&er Settings Tab\tCtrl+4" +msgstr "&Ustawienia Drukarki \tCtrl+4" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:235 +msgid "Select the language" +msgstr "Wybierz jÄ™zyk" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1667 +msgid "Select the printers this profile is compatible with." +msgstr "Wybierz drukarki kompatybilne z tym profilem." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:566 +msgid "Select the STL file to repair:" +msgstr "Wybierz plik STL do naprawy:" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:239 +msgid "Send to printer" +msgstr "WyÅ›lij do drukarki" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1448 +msgid "Sending G-code file to the OctoPrint server..." +msgstr "WysyÅ‚anie pliku G-code do serwera OctoPrint..." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:477 +msgid "Sequential printing" +msgstr "Drukowanie sekwencyjne (model po modelu)" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:990 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1193 +msgid "Serial port" +msgstr "Port szeregowy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1202 +msgid "Serial port speed" +msgstr "Szybkość portu szeregowego" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2030 +msgid "Set number of copies…" +msgstr "Ustaw ilość kopii…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:378 +msgid "Set this to a non-zero value to allow a manual extrusion width. If left to zero, Slic3r derives extrusion widths from the nozzle diameter (see the tooltips for perimeter extrusion width, infill extrusion width etc). If expressed as percentage (for example: 230%), it will be computed over layer height." +msgstr "Ustaw tÄ… wartość jako niezerowÄ… aby pozwolić na rÄ™czne ustawienie szerokoÅ›ci ekstrudowanej linii. JeÅ›li ustawisz zero, Slic3r obliczy szerokość ekstruzji na podstawie Å›rednicy dyszy (zobacz wskazówki dla szerokoÅ›ci ekstruzji obrysów, wypeÅ‚nienia itp). JeÅ›li ustawisz wartość procentowÄ… (np. 230%) to zostanie obliczona z wysokoÅ›ci warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:269 +msgid "Set this to a non-zero value to set a manual extrusion width for external perimeters. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 200%), it will be computed over layer height." +msgstr "Ustaw tÄ… wartość jako niezerowÄ… aby pozwolić na rÄ™czne ustawienie szerokoÅ›ci ekstruzji obrysów zewnÄ™trznych. JeÅ›li ustawisz zero, szerokość bÄ™dzie miaÅ‚a wartość domyÅ›lnÄ…, czyli 1.125x Å›rednicy dyszy. JeÅ›li ustawisz wartość procentowÄ… (np. 200%) to zostanie obliczona z wysokoÅ›ci warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:593 +msgid "Set this to a non-zero value to set a manual extrusion width for first layer. You can use this to force fatter extrudates for better adhesion. If expressed as percentage (for example 120%) it will be computed over first layer height. If set to zero, it will use the default extrusion width." +msgstr "Ustaw tÄ… wartość jako niezerowÄ… aby pozwolić na rÄ™czne ustawienie szerokoÅ›ci ekstruzji pierwszej warstwy. DziÄ™ki tej funkcji możesz wymusić grubsze linie dla lepszej przyczepnoÅ›ci. JeÅ›li ustawisz wartość procentowÄ… (np. 120%) to bÄ™dzie oliczona z wysokoÅ›ci pierwszej warstwy. Ustaw zero dla wartoÅ›ci domyÅ›lnej." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1293 +msgid "Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Ustaw tÄ… wartość jako niezerowÄ… aby pozwolić na rÄ™czne ustawienie szerokoÅ›ci ekstruzji wypeÅ‚nienia powierzchni zwartych. JeÅ›li ustawisz zero, szerokość bÄ™dzie miaÅ‚a wartość domyÅ›lnÄ…, czyli 1.125x Å›rednicy dyszy. JeÅ›li ustawisz wartość procentowÄ… (np. 90%) to zostanie obliczona z wysokoÅ›ci warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1615 +msgid "Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. You may want to use thinner extrudates to fill all narrow regions and get a smoother finish. If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Ustaw tÄ… wartość jako niezerowÄ… aby pozwolić na rÄ™czne ustawienie szerokoÅ›ci ekstruzji zwartego wypeÅ‚nienia górnych warstw. Możesz ustawić mniejszÄ… szerokość aby wypeÅ‚nić szczeliny i uzyskać gÅ‚adsze wykoÅ„czenie. JeÅ›li ustawisz zero, szerokość bÄ™dzie miaÅ‚a wartość domyÅ›lnÄ…, czyli bÄ™dzie równa Å›rednicy dyszy. JeÅ›li ustawisz wartość procentowÄ… (np. 90%) to zostanie obliczona z wysokoÅ›ci warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:711 +msgid "Set this to a non-zero value to set a manual extrusion width for infill. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. You may want to use fatter extrudates to speed up the infill and make your parts stronger. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Ustaw tÄ… wartość jako niezerowÄ… aby pozwolić na rÄ™czne ustawienie szerokoÅ›ci ekstruzji wypeÅ‚nienia. JeÅ›li ustawisz zero to szerokość bÄ™dzie miaÅ‚a wartość domyÅ›lnÄ…, czyli 1.125x Å›rednicy dyszy. Możesz ustawić wiÄ™kszÄ… szerokość aby przyspieszyć druk wypeÅ‚nienia i zwiÄ™kszyć wytrzymaÅ‚ość wydruków. JeÅ›li ustawisz wartość procentowÄ… (np. 90%) to zostanie obliczona z wysokoÅ›ci warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:968 +msgid "Set this to a non-zero value to set a manual extrusion width for perimeters. You may want to use thinner extrudates to get more accurate surfaces. If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. If expressed as percentage (for example 200%) it will be computed over layer height." +msgstr "Ustaw tÄ… wartość jako niezerowÄ… aby pozwolić na rÄ™czne ustawienie szerokoÅ›ci ekstruzji obrysów. Możesz ustawić wiÄ™kszÄ… szerokość aby uzyskać dokÅ‚adniejsze wykoÅ„czenie powierzchni. JeÅ›li ustawisz zero to szerokość bÄ™dzie miaÅ‚a wartość domyÅ›lnÄ…, czyli 1.125x Å›rednicy dyszy. JeÅ›li ustawisz wartość procentowÄ… (np. 200%) to zostanie obliczona z wysokoÅ›ci warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1455 +msgid "Set this to a non-zero value to set a manual extrusion width for support material. If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. If expressed as percentage (for example 90%) it will be computed over layer height." +msgstr "Ustaw tÄ… wartość jako niezerowÄ… aby pozwolić na rÄ™czne ustawienie szerokoÅ›ci ekstruzji materiaÅ‚u podporowego. JeÅ›li ustawisz zero to szerokość bÄ™dzie miaÅ‚a wartość domyÅ›lnÄ…, czyli bÄ™dzie równa Å›rednicy dyszy. JeÅ›li ustawisz wartość procentowÄ… (np. 90%) to zostanie obliczona z wysokoÅ›ci warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:332 +msgid "Set this to the clearance radius around your extruder. If the extruder is not centered, choose the largest value for safety. This setting is used to check for collisions and to display the graphical preview in the plater." +msgstr "OkreÅ›la promieÅ„ okrÄ™gu opisanego na caÅ‚ym zespole ekstrudera (matematycznie - wyobraź sobie, że chcesz narysować okrÄ…g opisany na zespole ekstrudera patrzÄ…c na niego z góry). JeÅ›li sam ekstruder nie jest dokÅ‚adnie na Å›rodku, użyj najwiÄ™kszego promienia. Ta wartość jest używana do wykrywania możliwych kolizji z wydrukowanymi modelami i jako graficzna reprezentacja na wirtualnym stole." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:321 +msgid "Set this to the vertical distance between your nozzle tip and (usually) the X carriage rods. In other words, this is the height of the clearance cylinder around your extruder, and it represents the maximum depth the extruder can peek before colliding with other printed objects." +msgstr "OkreÅ›la pionowÄ… odlegÅ‚ość koÅ„cówki dyszy od (zazwyczaj) prÄ™tów osi X. Inaczej mówiÄ…c (matematycznie), jest to wysokość cylindra opisanego na zespole ekstrudera i okreÅ›la maksymalnÄ… głębokość, na którÄ… może opuÅ›cić siÄ™ ekstruder aby nie uderzyć w obiekt znajdujÄ…cy siÄ™ bezpoÅ›rednio pod prÄ™tami osi X." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:120 +msgid "Settings" +msgstr "Ustawienia" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:191 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:206 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2106 +msgid "Settings…" +msgstr "Ustawienia…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:39 +msgid "Shape" +msgstr "KsztaÅ‚t" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:98 +msgid "Shells" +msgstr "PowÅ‚oka" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:75 +msgid "Show" +msgstr "Pokaż" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:408 +msgid "Show about dialog" +msgstr "Pokaż okienko" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:67 +msgid "Show incompatible print and filament presets" +msgstr "Pokaż niekompatybilne ustawienia druku i filamentów" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 +msgid "Show system information" +msgstr "Pokaż informacje o systemie" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:353 +msgid "Show the filament settings" +msgstr "Pokaż ustawienia filamentu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:336 +msgid "Show the plater" +msgstr "Pokaż zawartość stoÅ‚u" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:350 +msgid "Show the print settings" +msgstr "Pokaż ustawienia druku" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:342 +msgid "Show the printer controller" +msgstr "Pokaż kontroler drukarki" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:356 +msgid "Show the printer settings" +msgstr "Pokaż ustawienia drukarki" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1373 +msgid "Single Extruder Multi Material" +msgstr "Multi Material z jednym ekstruderem" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:50 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1191 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:408 +msgid "Size" +msgstr "Rozmiar" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:938 +msgid "Size and coordinates" +msgstr "Rozmiar i koordynaty" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:51 +msgid "Size in X and Y of the rectangular plate." +msgstr "Rozmiar X i Y stoÅ‚u prostokÄ…tnego." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:365 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:146 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:88 +msgid "Skirt" +msgstr "Skirt" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:364 +msgid "Skirt and brim" +msgstr "Skirt i brim" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1221 +msgid "Skirt height" +msgstr "Wysokość skirt" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1230 +msgid "Skirt Loops" +msgstr "Liczba obrysów skirt" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:398 +msgid "Slic3r &Manual" +msgstr "&Instrukcja" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:395 +msgid "Slic3r &Website" +msgstr "Strona &WWW Slic3ra" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:902 +msgid "Slic3r can upload G-code files to OctoPrint. This field should contain the API Key required for authentication." +msgstr "Slic3r może przesyÅ‚ać pliki G-code do OctoPrint. To pole powinno zawierać klucz API niezbÄ™dny do uwierzytelnienia." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:909 +msgid "Slic3r can upload G-code files to OctoPrint. This field should contain the hostname or IP address of the OctoPrint instance." +msgstr "Slic3r może przesyÅ‚ać pliki G-code do OctoPrint. To pole powinno zawierać nazwÄ™ hosta lub adres IP OctoPrint." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:929 +msgid "Slic3r Error" +msgstr "Błąd Slic3ra" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:867 +msgid "Slic3r will not scale speed down below this speed." +msgstr "Slic3r nie bÄ™dzie skalowaÅ‚ prÄ™dkoÅ›ci poniżej tej wartoÅ›ci." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:268 +msgid "Slice a file into a G-code" +msgstr "Potnij plik jako G-code" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:274 +msgid "Slice a file into a G-code, save as" +msgstr "Potnij plik jako G-code, zapisz jako" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 +msgid "Slice file to a multi-layer SVG" +msgstr "Potnij plik jako wielowarstwowy SVG" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:237 +msgid "Slice now" +msgstr "Potnij teraz" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:287 +msgid "Slice to SV&G…\tCtrl+G" +msgstr "Tnij do SV&G... \tCtrl+G" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:438 +msgid "Sliced Info" +msgstr "Informacje o ciÄ™ciu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1286 +msgid "Slicing cancelled" +msgstr "CiÄ™cie przerwane" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:550 +msgid "Slicing Done!" +msgstr "CiÄ™cie zakoÅ„czone!" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:528 +msgid "Slicing…" +msgstr "CiÄ™cie…" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1239 +msgid "Slow down if layer print time is below" +msgstr "Zwolnij jeÅ›li czas warstwy wynosi mniej niż" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1250 +msgid "Small perimeters" +msgstr "MaÅ‚e obrysy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:179 +msgid "solid infill" +msgstr "zwarte wypeÅ‚nienie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1291 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1301 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:142 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:84 +msgid "Solid infill" +msgstr "Zwarte wypeÅ‚nienie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1279 +msgid "Solid infill every" +msgstr "Zwarte wypeÅ‚nienie co" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1271 +msgid "Solid infill extruder" +msgstr "Ekstruder do zwartego wypeÅ‚nienia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1262 +msgid "Solid infill threshold area" +msgstr "Próg powierzchni zwartego wypeÅ‚nienia" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:330 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1314 +msgid "Solid layers" +msgstr "Zwarte warstwy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:470 +msgid "Soluble material" +msgstr "MateriaÅ‚ rozpuszczalny" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:471 +msgid "Soluble material is most likely used for a soluble support." +msgstr "MateriaÅ‚ rozpuszczalny jest używany zazwyczaj do rozpuszczalnych podpór." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:653 +msgid "Some G/M-code commands, including temperature control and others, are not universal. Set this option to your printer's firmware to get a compatible output. The \"No extrusion\" flavor prevents Slic3r from exporting any extrusion value at all." +msgstr "Niektóre komendy G/M-code, wliczajÄ…c w to dot. kontroli temperatury i inne, nie sÄ… uniwersalne. Ustaw tÄ… opcjÄ™ zgodnie z oprogramowaniem ukÅ‚adowym Twojej drukarki aby dostać kompatybilny plik wyjÅ›ciowy. Parametr \"Bez ekstruzji\" (\"No extrusion\") zapobiega generowaniu przez Slic3r jakichkolwiek ekstruzji." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1682 +msgid "Some printers or printer setups may have difficulties printing with a variable layer height. Enabled by default." +msgstr "Niektóre drukarki mogÄ… mieć trudnoÅ›ci z drukiem ze zmiennÄ… wysokoÅ›ciÄ… warstwy. DomyÅ›lnie włączone." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1490 +msgid "Spacing between interface lines. Set zero to get a solid interface." +msgstr "Rozmieszczenie linii warstwy łączÄ…cej. Ustaw zero dla zwartej warstwy łączÄ…cej." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1526 +msgid "Spacing between support material lines." +msgstr "Rozmieszczenie linii materiaÅ‚u podporowego." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:398 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:118 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:278 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:635 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:747 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:979 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1201 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1251 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1302 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1625 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:71 +msgid "Speed" +msgstr "PrÄ™dkość" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1203 +msgid "Speed (baud) of USB/serial port for printer connection." +msgstr "Szybkość transmisji portu USB/portu szeregowego do połączenia z drukarkÄ…." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:336 +msgid "Speed (mm/s)" +msgstr "PrÄ™dkość (mm/s)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:636 +msgid "Speed for filling small gaps using short zigzag moves. Keep this reasonably low to avoid too much shaking and resonance issues. Set zero to disable gaps filling." +msgstr "PrÄ™dkość wypeÅ‚niania szczelin krótkimi ruchami typu zygzak. Ustaw tÄ… wartość na tyle nisko aby uniknąć wibracji i rezonansu. Ustaw 0 aby wyłączyć wypeÅ‚nianie szczelin." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:411 +msgid "Speed for non-print moves" +msgstr "PrÄ™dkość ruchów jaÅ‚owych" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:980 +msgid "Speed for perimeters (contours, aka vertical shells). Set to zero for auto." +msgstr "PrÄ™dkość obrysów (inaczej powÅ‚oki pionowej). Ustaw 0 dla prÄ™dkoÅ›ci automatycznej." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:399 +msgid "Speed for print moves" +msgstr "PrÄ™dkość ruchów drukujÄ…cych" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:119 +msgid "Speed for printing bridges." +msgstr "PrÄ™dkość drukowania mostów." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1303 +msgid "Speed for printing solid regions (top/bottom/internal horizontal shells). This can be expressed as a percentage (for example: 80%) over the default infill speed above. Set to zero for auto." +msgstr "PrÄ™dkość druku zwartych obszarów (góra/dół/poziome powÅ‚oki wewnÄ™trzne). Może być wyrażona procentowo (np. 80%) ponad domyÅ›lnÄ… prÄ™dkość wypeÅ‚nienia. Wpisz zero dla automatycznego ustawienia." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1499 +msgid "Speed for printing support material interface layers. If expressed as percentage (for example 50%) it will be calculated over support material speed." +msgstr "PrÄ™dkość druku warstw łączÄ…cych materiaÅ‚u podporowego. JeÅ›li ustawisz wartość procentowÄ… (np. 50%) to zostanie obliczona z prÄ™dkoÅ›ci druku materiaÅ‚u podporowego." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1535 +msgid "Speed for printing support material." +msgstr "PrÄ™dkość druku materiaÅ‚u podporowego." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:748 +msgid "Speed for printing the internal fill. Set to zero for auto." +msgstr "PrÄ™dkość druku wewnÄ™trznego wypeÅ‚nienia. Ustaw 0 dla prÄ™dkoÅ›ci automatycznej." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1626 +msgid "Speed for printing top solid layers (it only applies to the uppermost external layers and not to their internal solid layers). You may want to slow down this to get a nicer surface finish. This can be expressed as a percentage (for example: 80%) over the solid infill speed above. Set to zero for auto." +msgstr "PrÄ™dkość druku najwyższych warstw zwartych (dotyczy tylko najwyższych, zewnÄ™trznych warstw i nie obejmuje zwartych warstw umieszczonych niżej). Warto obniżyć tÄ… wartość dla Å‚adniejszego wykoÅ„czenia powierzchni. JeÅ›li ustawisz wartość procentowÄ… (np. 80%) to zosttanie obliczona z prÄ™dkoÅ›ci druku zwartego wypeÅ‚nienia. Ustaw zero dla prÄ™dkoÅ›ci automatycznej." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1648 +msgid "Speed for travel moves (jumps between distant extrusion points)." +msgstr "PrÄ™dkość ruchów jaÅ‚owych (przeskoków pomiÄ™dzy punktami ekstruzji)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1322 +msgid "Spiral vase" +msgstr "Tryb wazy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:540 +msgid "Spiral Vase" +msgstr "Tryb Wazy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:188 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:204 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 +msgid "Split" +msgstr "Podziel" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2099 +msgid "Split the selected object into individual parts" +msgstr "Podziel wybrany model na części" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:847 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1120 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1342 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1357 +msgid "Start G-code" +msgstr "G-code startowy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:291 +msgid "Start new slicing process" +msgstr "Uruchom nowy proces ciÄ™cia" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1539 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1581 +msgid "STL file exported to " +msgstr "Plik STL zostaÅ‚ wyeksportowany do " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1017 +msgid "Success!" +msgstr "Powodzenie!" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:198 +msgid "support" +msgstr "podpora" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:620 +msgid "Support Generator" +msgstr "Generator Podpór" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:208 +msgid "support interface" +msgstr "warstwa łączÄ…ca podpory z modelem" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:374 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:375 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:191 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1030 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1380 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1387 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1399 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1409 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1417 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1432 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1453 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1464 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1480 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1489 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1498 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1509 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1525 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1533 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1534 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1543 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1551 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1565 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:147 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:89 +msgid "Support material" +msgstr "MateriaÅ‚ podporowy" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1497 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:148 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:90 +msgid "Support material interface" +msgstr "Warstwa łączÄ…ca podpory z modelem" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1552 +msgid "Support material will not be generated for overhangs whose slope angle (90° = vertical) is above the given threshold. In other words, this value represent the most horizontal slope (measured from the horizontal plane) that you can print without support material. Set to zero for automatic detection (recommended)." +msgstr "Podpory nie bÄ™dÄ… generowane dla zwisów, których kÄ…t przekracza zadany próg (90° = pion). Inaczej mówiÄ…c, ta wartość okreÅ›la najwiÄ™kszy kÄ…t od poziomu (kÄ…t mierzony od pÅ‚aszczyzny poziomej), który bÄ™dzie drukowany bez podpór." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1470 +msgid "Support material/raft interface extruder" +msgstr "Ekstruder dla podpór/warstw łączÄ…cych raft z modelem" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1444 +msgid "Support material/raft/skirt extruder" +msgstr "Ekstruder dla podpór/tratwy (raft)/skirtu" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1408 +msgid "Support on build plate only" +msgstr "Podpory jedynie na powierzchni stoÅ‚u" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:617 +msgid "" +"Supports work better, if the following feature is enabled:\n" +"- Detect bridging perimeters\n" +"\n" +"Shall I adjust those settings for supports?" +msgstr "" +"Druk podpór daje lepsze efekty, gdy nastÄ™pujÄ…ca funkcja jest włączona:\n" +"- Wykrywanie mostów przy obrysach\n" +"\n" +"Zmienić tÄ… opcjÄ™ dla druku podpór?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:59 +msgid "Suppress \" - default - \" presets" +msgstr "Ukryj \" - domyÅ›lne - \" zestawy ustawieÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:61 +msgid "Suppress \" - default - \" presets in the Print / Filament / Printer selections once there are any other valid presets available." +msgstr "Ukryj \" - domyÅ›lne - \" zestawy ustawieÅ„ w zakÅ‚adkach Druk / Filament / Drukarka gdy dostÄ™pne sÄ… inne kompatybilne ustawienia." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:514 +msgid "SVG" +msgstr "SVG" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1544 +msgid "Synchronize support layers with the object print layers. This is useful with multi-material printers, where the extruder switch is expensive." +msgstr "Synchronizuj warstwy podporowe z warstwami modelu. Przydaje siÄ™ przy drukarkach typu multi-material gdy zmiana używanego materiaÅ‚u jest kosztowna." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1542 +msgid "Synchronize with object layers" +msgstr "Synchronizuj z warstwami modelu" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:402 +msgid "System Info" +msgstr "Informacje o systemie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1576 +msgid "Temperature" +msgstr "Temperatura" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:794 +msgid "Temperature " +msgstr "Temperatura " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1333 +msgid "Temperature difference to be applied when an extruder is not active. Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped." +msgstr "Różnica temperatur majÄ…ca zastosowanie gdy ekstruder nie jest używany. Włącza druk skirtu o wysokoÅ›ci równej wysokoÅ›ci modelu, dziÄ™ki której dysze bÄ™dÄ… co jakiÅ› czas czyszczone." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1332 +msgid "Temperature variation" +msgstr "Zmiana temperatury" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1004 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1072 +msgid "Test" +msgstr "Test" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:309 +msgid "The extruder to use (unless more specific extruder settings are specified). This value overrides perimeter and infill extruders, but not the support extruders." +msgstr "Używany ekstruder (jeÅ›li nie sÄ… okreÅ›lone dokÅ‚adniejsze ustawienia ekstuderów). To ustawienie nadpisuje ustawienia ekstruderów dla obrysów i wypeÅ‚nienia, ale nie tych dla podpór." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:703 +msgid "The extruder to use when printing infill." +msgstr "Ekstruder używany do druku wypeÅ‚nienia." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:959 +msgid "The extruder to use when printing perimeters and brim. First extruder is 1." +msgstr "Ekstruder używany przy druku obrysów i brim. Pierwszy ekstruder ma nr 1." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1273 +msgid "The extruder to use when printing solid infill." +msgstr "Ekstruder używany do druku zwartego wypeÅ‚nienia." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1472 +msgid "The extruder to use when printing support material interface (1+, 0 to use the current extruder to minimize tool changes). This affects raft too." +msgstr "Ekstruder używany przy druku warstw łączÄ…cych podpory z modelem (1+, zero aby użyć obecnie wybranego ekstrudera i zminimalizować zmiany filamentu). Ma wpÅ‚yw również na druk tratwy (raftu)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1446 +msgid "The extruder to use when printing support material, raft and skirt (1+, 0 to use the current extruder to minimize tool changes)." +msgstr "Ekstruder używany przy druku podpór, tratwy (raft) i skirtu (1+, zero aby użyć obecnie wybranego ekstrudera i zminimalizować zmiany filamentu)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:209 +msgid "The first layer will be shrunk in the XY plane by the configured value to compensate for the 1st layer squish aka an Elephant Foot effect." +msgstr "Pierwsza warstwa zostanie zmniejszona o tÄ… wartość w osiach X i Y aby zniwelować efekt stopy sÅ‚onia (Elephant Foot - gdy pierwsza warstwa \"rozjeżdża\" siÄ™ na boki)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1734 +msgid "The object will be grown/shrunk in the XY plane by the configured value (negative = inwards, positive = outwards). This might be useful for fine-tuning hole sizes." +msgstr "Model zostanie zmniejszony lub zwiÄ™kszony w osiach X i Y o zadanÄ… wartość (ujemna = zmniejszenie, dotatnia = zwiÄ™kszenie). Może być przydatne przy kalibracji Å›rednic otworów." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1031 +msgid "The object will be raised by this number of layers, and support material will be generated under it." +msgstr "Model zostanie podniesiony o zadanÄ… ilość warstw i umieszczony na podporach." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1374 +msgid "The printer multiplexes filaments into a single hot end." +msgstr "Drukarka przechodzi pomiÄ™dzy filamentami używajÄ…c jednego hotendu." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:324 +msgid "The selected file contains no geometry." +msgstr "Wybrany plik nie zawiera żadnego ksztaÅ‚tu." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:328 +msgid "The selected file contains several disjoint areas. This is not supported." +msgstr "Wybrany plik zawiera kilka rozłączonych obszarów. Taki plik nie jest obsÅ‚ugiwany." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1112 +msgid "The selected object can't be split because it contains more than one volume/material." +msgstr "Wybrany model nie może być podzielony ponieważ skÅ‚ada siÄ™ z wiÄ™cej niż jednej części lub zawiera wiÄ™cej niż jeden materiaÅ‚." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1121 +msgid "The selected object couldn't be split because it contains only one part." +msgstr "Wybrany model nie może być rozdzielony ponieważ zawiera tylko jednÄ… część." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1144 +msgid "The speed for loading of a filament into extruder after retraction (it only applies to the extruder motor). If left to zero, the retraction speed is used." +msgstr "PrÄ™dkość powrotu filamentu do ekstrudera po retrakcji (dotyczy tylko silnika ekstrudera). Ustaw zero aby użyć prÄ™dkoÅ›ci retrakcji." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1136 +msgid "The speed for retractions (it only applies to the extruder motor)." +msgstr "PrÄ™dkość retrakcji (stosowana tylko dla silnika ekstrudera)." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:533 +#, no-c-format +msgid "" +"The Spiral Vase mode requires:\n" +"- one perimeter\n" +"- no top solid layers\n" +"- 0% fill density\n" +"- no support material\n" +"- no ensure_vertical_shell_thickness\n" +"\n" +"Shall I adjust those settings in order to enable Spiral Vase?" +msgstr "" +"Wymagania trybu wazy:\n" +"- jeden obrys\n" +"- brak warstw górnych\n" +"- 0% wypeÅ‚nienia\n" +"- brak materiaÅ‚u podporowego\n" +"- brak opcji \"zagwarantuj odpowiedniÄ… grubość Å›cianki\"\n" +"\n" +"Czy ustawić te parametry odpowiednio dla trybu wazy?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1560 +msgid "The supplied name is empty. It can't be saved." +msgstr "Podana nazwa jest pusta. Nie można zapisać." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1788 +msgid "The supplied name is not available." +msgstr "Podana nazwa jest niedostÄ™pna." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1785 +msgid "The supplied name is not valid; the following characters are not allowed:" +msgstr "Podana nazwa jest nieprawidÅ‚owa; nastÄ™pujÄ…ce znaki sÄ… niedozwolone:" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1418 +msgid "The vertical distance between object and support material interface. Setting this to 0 will also prevent Slic3r from using bridge flow and speed for the first object layer." +msgstr "Dystans w pionie miÄ™dzy modelem a warstwÄ… łączÄ…cÄ… materiaÅ‚u podporowego. Ustawienie na 0 wyłączy ustawienie mostu (prÄ™dkoÅ›ci i przepÅ‚ywu) dla pierwszej warstwy modelu nad warstwÄ… łączÄ…cÄ…." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1312 +msgid "" +"The Wipe option is not available when using the Firmware Retraction mode.\n" +"\n" +"Shall I disable it in order to enable Firmware Retraction?" +msgstr "" +"Opcja czyszczenia dyszy nie jest dostÄ™pna z funkcjÄ… Retrakcji w Firmware (Firmware Retraction).\n" +"\n" +"Wyłączyć jÄ… aby włączyć Firmware Retraction?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:560 +msgid "" +"The Wipe Tower currently supports only:\n" +"- first layer height 0.2mm\n" +"- layer height from 0.15mm to 0.35mm\n" +"\n" +"Shall I adjust those settings in order to enable the Wipe Tower?" +msgstr "" +"Wieża czyszczÄ…ca wymaga nastÄ™pujÄ…cych opcji:\n" +"- wysokość pierwszej warstwy 0.2 mm\n" +"- wysokość pozostaÅ‚ych warstw miÄ™dzy 0.15 a 0.35 mm\n" +"\n" +"Zmienić te opcje aby włączyć wieżę czyszczÄ…cÄ…?" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:581 +msgid "" +"The Wipe Tower currently supports the non-soluble supports only\n" +"if they are printed with the current extruder without triggering a tool change.\n" +"(both support_material_extruder and support_material_interface_extruder need to be set to 0).\n" +"\n" +"Shall I adjust those settings in order to enable the Wipe Tower?" +msgstr "" +"Użycie wieży czyszczÄ…cej jest możliwe jedynie przy użyciu nierozpuszczalnych podpór\n" +"gdy sÄ… drukowane z obecnie używanego ekstrudera, bez inicjowania jego zmiany.\n" +"(zarówno support_material_extruder i support_material_interface_extruder muszÄ… być ustawione na 0).\n" +"\n" +"Zmienić te ustawienia aby włączyć wieżę czyszczÄ…cÄ…?" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:60 +msgid "This code is inserted between objects when using sequential printing. By default extruder and bed temperature are reset using non-wait command; however if M104, M109, M140 or M190 are detected in this custom code, Slic3r will not add temperature commands. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want." +msgstr "Ten kod jest wykonywany pomiÄ™dzy drukiem poszczególnych modeli w trybie druku sekwencyjnego. DomyÅ›lnie przy komendzie non-wait temperatury dyszy i stoÅ‚u sÄ… resetowane; jednakże jeÅ›li przy tej opcji zostanÄ… użyte komendy M104, M109, M140 lub M190 to Slic3r nie doda wÅ‚asnych komend do kontroli temperatury. PamiÄ™taj, że możesz używać zmiennych typu placeholder, wiÄ™c np. komendÄ™ \"M109 S[first_layer_temperature]\" (temperatura pierwszej warstwy) możesz umieÅ›cić gdzie chcesz." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:767 +msgid "This custom code is inserted at every layer change, right after the Z move and before the extruder moves to the first layer point. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z]." +msgstr "Ten kod jest wykonywany przy każdej zmianie warstwy - zaraz po podniesieniu gÅ‚owicy na wysokość kolejnej warstwy ale zanim ekstruder przejdzie do pierwszego punktu nowej warstwy. PamiÄ™taj, że możesz użyć zmiennych typu placeholder dla wszystkich ustawieÅ„ Slic3r, jak np. [layer_num] (numer warstwy) i [layer_z] (poÅ‚ożenie warstwy w osi Z)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:49 +msgid "This custom code is inserted at every layer change, right before the Z move. Note that you can use placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z]." +msgstr "Ten kod jest wykonywany przy każdej zmianie warstwy, zaraz przed podniesieniem ekstrudera na wysokość nowej warstwy. PamiÄ™taj, że możesz użyć zmiennych typu placeholder dla wszystkich ustawieÅ„ Slic3r, jak np. [layer_num] (numer warstwy) i [layer_z] (poÅ‚ożenie warstwy w osi Z)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1603 +msgid "This custom code is inserted right before every extruder change. Note that you can use placeholder variables for all Slic3r settings as well as [previous_extruder] and [next_extruder]." +msgstr "Ten kod jest wykonywany przed każdÄ… zmianÄ… ekstrudera/filamentu. PamiÄ™taj, że możesz użyć zmiennych typu placeholder dla wszystkich ustawieÅ„ Slic3r, jak np. [previous_extruder] (poprzedni ekstruder) i [next_extruder] (nastÄ™pny ekstruder)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:228 +msgid "This end procedure is inserted at the end of the output file, before the printer end gcode. Note that you can use placeholder variables for all Slic3r settings. If you have multiple extruders, the gcode is processed in extruder order." +msgstr "Ten kod jest wykonywany na samym koÅ„cu, przed samym zakoÅ„czeniem wykonywania pliku G-code. PamiÄ™taj, że możesz użyć zmiennych typu placeholder dla wszystkich ustawieÅ„ Slic3r. JeÅ›li masz kilka ekstruderów, ten G-code jest wykonywany zgodnie z ich kolejnoÅ›ciÄ…." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:218 +msgid "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings." +msgstr "Ten kod jest wykonywany jako ostatni w pliku wyjÅ›ciowym. PamiÄ™taj, że możesz użyć zmiennych typu placeholder dla wszystkich ustawieÅ„ Slic3r." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:827 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:838 +msgid "This experimental setting is used to limit the speed of change in extrusion rate. A value of 1.8 mm³/s² ensures, that a change from the extrusion rate of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds." +msgstr "To ustawienie eksperymentalne jest używane do ograniczania szybkoÅ›ci zmian iloÅ›ci ekstrudowanego materiaÅ‚u. Wartość 1.8 mm³/s² oznacza, że zmiana z iloÅ›ci ekstrudowanego materiaÅ‚u z poziomu 1.8 mm³/s (czyli 0.45 mm szerokoÅ›ci ekstruzji, 0.2 mm wysokoÅ›ci warstwy przy prÄ™dkoÅ›ci 20 mm/s) na 5.4 mm³/s (prÄ™dkość 60 mm/s) zajmie co najmniej 2 sekundy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:818 +msgid "This experimental setting is used to set the maximum volumetric speed your extruder supports." +msgstr "Ta eksperymentalna funkcja okreÅ›la maksymalnÄ… prÄ™dkość objÄ™toÅ›ciowÄ…, którÄ… jest w stanie wytÅ‚oczyć Twój ekstruder." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1657 +msgid "This experimental setting uses G10 and G11 commands to have the firmware handle the retraction. This is only supported in recent Marlin." +msgstr "Ta eksperymentalna funkcja używa komend G10 i G11 aby przerzucić kontrolÄ™ retrakcji na firmware. Jest wspierana jedynie przez najnowsze wersje Marlina." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1671 +msgid "This experimental setting uses outputs the E values in cubic millimeters instead of linear millimeters. If your firmware doesn't already know filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] T0' in your start G-code in order to turn volumetric mode on and use the filament diameter associated to the filament selected in Slic3r. This is only supported in recent Marlin." +msgstr "Ta eksperymentalna funkcja okreÅ›la wyjÅ›ciowe dane E (ilość ekstruzji) w milimetrach szeÅ›ciennych zamiast dÅ‚ugoÅ›ci. JeÅ›li Å›rednica filamentu nie zostaÅ‚a jeszcze ustawiona w firmware, możesz użyć komendy \"M200 D[filament_diameter_0] T0\" w skrypcie startowym aby włączyć tryb objÄ™toÅ›ciowy i użyć filamentu powiÄ…zanego z ustawionym w Slic3r. Ta funkcja jest wspierana jedynie przez najnowsze wersje Marlina." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:108 +msgid "This factor affects the amount of plastic for bridging. You can decrease it slightly to pull the extrudates and prevent sagging, although default settings are usually good and you should experiment with cooling (use a fan) before tweaking this." +msgstr "Ten współczynnik okreÅ›la ilość plastiku wytÅ‚aczanÄ… przy drukowaniu mostów. Możesz delikatnie zmniejszyć tÄ… wartość aby zapobiec opadaniu drukowanej linii, jednakże standardowe ustawienia sÄ… zazwyczaj dobrze dobrane i najpierw poeksperymentuj z chÅ‚odzeniem wydruku." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:368 +msgid "This factor changes the amount of flow proportionally. You may need to tweak this setting to get nice surface finish and correct single wall widths. Usual values are between 0.9 and 1.1. If you think you need to change this more, check filament diameter and your firmware E steps." +msgstr "Ten współczynnik okreÅ›la proporcjonalnÄ… ilość przepÅ‚ywu plastiku. Możesz zmienić tÄ… wartość aby uzyskać gÅ‚adsze powierzchnie i poprawnÄ… szerokość Å›cian drukowanych z 1 linii. Ten współczynnik waha siÄ™ zazwyczaj od 0.9 do 1.1. JeÅ›li musisz wykroczyć poza ten zakres to najpierw zmierz Å›rednicÄ™ filamentu i kroki ekstrudera (E steps)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:98 +msgid "This fan speed is enforced during all bridges and overhangs." +msgstr "Ta prÄ™dkość wentylatora zostanie zastosowana przy druku mostów i zwisów." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:692 +msgid "This feature allows to combine infill and speed up your print by extruding thicker infill layers while preserving thin perimeters, thus accuracy." +msgstr "Ta funkcja pozwala ustawić oddzielne wysokoÅ›ci dla wypeÅ‚nienia i obrysów modelu i przyspieszyć wydruk ustawiajÄ…c np. wyższÄ… warstwÄ™ wypeÅ‚nienia zachowujÄ…c nominalnÄ… wysokość obrysów, co pozwoli zachować wysokÄ… jakość i dokÅ‚adność wydruku." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1281 +msgid "This feature allows to force a solid layer every given number of layers. Zero to disable. You can set this to any value (for example 9999); Slic3r will automatically choose the maximum possible number of layers to combine according to nozzle diameter and layer height." +msgstr "Ta funkcja pozwoli wstawić zwartÄ… warstwÄ™ wypeÅ‚nienia pomiÄ™dzy okreÅ›lonÄ… liczbÄ… warstw. Ustaw zero aby wyłączyć. Możesz ustawić tu dowolnÄ… wartość (np. 9999) a Slic3r automatycznie wybierze maksymalnÄ… możliwÄ… liczbÄ™ warstw biorÄ…c pod uwagÄ™ Å›rednicÄ™ dyszy i wysokość warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1323 +msgid "This feature will raise Z gradually while printing a single-walled object in order to remove any visible seam. This option requires a single perimeter, no infill, no top solid layers and no support material. You can still set any number of bottom solid layers as well as skirt/brim loops. It won't work when printing more than an object." +msgstr "Ta funkcja pozwala drukować modele z 1 zewnÄ™trznÄ… Å›ciankÄ… z ciÄ…gÅ‚ym podnoszeniem Z, aby uniknąć widocznego szwu (czyli ekstruder nie bÄ™dzie drukowaÅ‚ po 1 warstwie na 1 wysokoÅ›ci, lecz bÄ™dzie podnosiÅ‚ siÄ™ pÅ‚ynnie w formie spirali). Wymaga użycia 1 obrysu, zerowego wypeÅ‚nienia, braku warstw górnych i braku podpór. Możesz ustawić dowolnÄ… ilość dolnych warstw jak i obrysów skirt/brim. Nie zadziaÅ‚a przy druku wiÄ™cej niż jednego modelu." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:663 +msgid "" +"This file contains several objects positioned at multiple heights. Instead of considering them as multiple objects, should I consider\n" +"this file as a single object having multiple parts?\n" +msgstr "" +"Ten plik zawiera kilka modeli umieszczonych na różnych wysokoÅ›ciach. Potraktować go jako\n" +"jeden model skÅ‚adajÄ…cy siÄ™ z kilku części?\n" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:164 +msgid "This flag enables the automatic cooling logic that adjusts print speed and fan speed according to layer printing time." +msgstr "Ta flaga umożliwia automatyczne sterowanie chÅ‚odzeniem przez zmianÄ™ prÄ™dkoÅ›ci druku i wentylatora wzglÄ™dem czasu druku jednej warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1066 +msgid "This flag enforces a retraction whenever a Z move is done." +msgstr "Ta flaga wymusza retrakcjÄ™ przy każdej zmianie wysokoÅ›ci Z." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1689 +msgid "This flag will move the nozzle while retracting to minimize the possible blob on leaky extruders." +msgstr "Ta flaga włączy ruch dyszy przy retrakcji aby zminimalizować formowanie siÄ™ kropli filamentu wokół koÅ„cówki dyszy przy ekstruderach, które majÄ… tendencjÄ™ do wyciekania filamentu." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:343 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:406 +msgid "This is only used in the Slic3r interface as a visual help." +msgstr "Ta funkcja jest używana jedynie w interfejsie Slic3ra jako pomoc wizualna." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:171 +msgid "This is the acceleration your printer will be reset to after the role-specific acceleration values are used (perimeter/infill). Set zero to prevent resetting acceleration at all." +msgstr "Do tej wartoÅ›ci przyspieszenia drukarka wróci gdy ustawione zostanÄ… przyspieszenia dla okreÅ›lonych ruchów (obrysy/wypeÅ‚nienie). Ustaw zero aby wyłączyć resetowanie przyspieszeÅ„." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:78 +msgid "This is the acceleration your printer will use for bridges. Set zero to disable acceleration control for bridges." +msgstr "To jest przyspieszenie stosowane przy druku mostów. Ustaw zero aby wyłączyć osobne ustawienia przyspieszenia dla mostów." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:574 +msgid "This is the acceleration your printer will use for first layer. Set zero to disable acceleration control for first layer." +msgstr "To jest przyspieszenie stosowane przy druku pierwszej warstwy. Ustaw zero aby wyłączyć osobne ustawienia przyspieszenia dla pierwszej warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:682 +msgid "This is the acceleration your printer will use for infill. Set zero to disable acceleration control for infill." +msgstr "To jest przyspieszenie stosowane przy druku wypeÅ‚nienia. Ustaw zero aby wyłączyć osobne ustawienia przyspieszenia dla wypeÅ‚nienia." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:949 +msgid "This is the acceleration your printer will use for perimeters. A high value like 9000 usually gives good results if your hardware is up to the job. Set zero to disable acceleration control for perimeters." +msgstr "To jest przyspieszenie stosowane przy druku obrysów. Wysoka wartość, np. 9000 zazwyczaj daje dobre rezultaty - pod warunkiem, że Twój sprzÄ™t siÄ™ do tego nadaje. Ustaw zero aby wyłączyć osobne ustawienia przyspieszenia dla obrysów." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:895 +msgid "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)" +msgstr "To jest Å›rednica dyszy ekstrudera (np. 0.5, 0.35 itp.)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:797 +#, no-c-format +msgid "This is the highest printable layer height for this extruder, used to cap the variable layer height and support layer height. Maximum recommended layer height is 75% of the extrusion width to achieve reasonable inter-layer adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter." +msgstr "To jest najwyższa możliwa do wydrukowania wysokość warstwy dla tego ekstrudera i jednoczeÅ›nie górny limit dla funkcji zmiennej wysokoÅ›ci warstwy i materiaÅ‚u podporowego. Zalecana jest wartość nie wiÄ™ksza niż 75% szerokoÅ›ci ekstruzji aby zapewnić dobrÄ… przyczepność warstw do siebie. JeÅ›li ustawisz zero, wysokość warstwy zostanie ograniczona do 75% Å›rednicy dyszy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:858 +msgid "This is the lowest printable layer height for this extruder and limits the resolution for variable layer height. Typical values are between 0.05 mm and 0.1 mm." +msgstr "To jest najniższa możliwa do wydrukowania wysokość warstwy dla tego ekstrudera i jednoczeÅ›nie dolny limit dla funkcji zmiennej wysokoÅ›ci warstwy. Zazwyczaj jest to 0.05 lub 0.1 mm." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:990 +msgid "This option sets the number of perimeters to generate for each layer. Note that Slic3r may increase this number automatically when it detects sloping surfaces which benefit from a higher number of perimeters if the Extra Perimeters option is enabled." +msgstr "To ustawienie okreÅ›la ilość obrysów, które bÄ™dÄ… generowane dla każdej warstwy. Weź po uwagÄ™, że Slic3r może zwiÄ™kszyć tÄ… liczbÄ™ automatycznie gdy wykryje zwisy, w których wydruku pomoże dodatkowa ilość obrysów przy jednoczeÅ›nie włączonej opcji \"Dodatkowe obrysy jeÅ›li potrzebne\"." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:923 +msgid "This option will drop the temperature of the inactive extruders to prevent oozing. It will enable a tall skirt automatically and move extruders outside such skirt when changing temperatures." +msgstr "Ta funkcja obniży temperatury nieużywanych ekstruderów aby zapobiec wyciekaniu filamentu z dyszy. RównoczeÅ›nie włączy wysoki skirt i przesunie ekstrudery poza jego obrys przy zmianie temperatury." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:728 +msgid "This option will limit infill to the areas actually needed for supporting ceilings (it will act as internal support material). If enabled, slows down the G-code generation due to the multiple checks involved." +msgstr "Ta opcja wygeneruje wypeÅ‚nienie jedynie w miejscach, gdzie jest potrzebne do podparcia górnych warstw (zadziaÅ‚a na zasadzie wewnÄ™trznych podpór). Włączenie jej spowolni generowanie G-code ze wzglÄ™du na konieczność kilkukrotnej weryfikacji." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:721 +msgid "This option will switch the print order of perimeters and infill, making the latter first." +msgstr "Ta opcja zamieni kolejność druku obrysów i wypeÅ‚nienia, aby te drugie byÅ‚y drukowane jako pierwsze." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:279 +msgid "This separate setting will affect the speed of external perimeters (the visible ones). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above. Set to zero for auto." +msgstr "To ustawienie steruje prÄ™dkoÅ›ciÄ… zewnÄ™trznych (widocznych) obrysów. JeÅ›li ustawisz wartość procentowÄ… (np. 80%) to zostanie obliczona z prÄ™dkoÅ›ci obrysów ustawionej powyżej. Ustaw zero aby pozwolić na sterowanie automatyczne." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1252 +msgid "This separate setting will affect the speed of perimeters having radius <= 6.5mm (usually holes). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above. Set to zero for auto." +msgstr "To ustawienie reguluje prÄ™dkość obrysów posiadajÄ…cych promieÅ„ mniejszy lub równy 6.5 mm (zazwyczaj chodzi o otwory). JeÅ›li ustawisz wartość procentowÄ… (np. 80%) to zostanie obliczona z prÄ™dkoÅ›ci obrysów ustawionej powyżej. Ustaw zero aby użyć nastawów automatycznych." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:737 +msgid "This setting applies an additional overlap between infill and perimeters for better bonding. Theoretically this shouldn't be needed, but backlash might cause gaps. If expressed as percentage (example: 15%) it is calculated over perimeter extrusion width." +msgstr "To ustawienie odpowiada za dodatkowe nakÅ‚adanie na siebie linii obrysów i wypeÅ‚nienia dla lepszego spojenia. Teoretycznie nie powinno być potrzebne ale luz może powodować szczeliny. JeÅ›li ustawisz wartość procentowÄ… (np. 15%) to zostanie obliczona z szerokoÅ›ci ekstruzji obrysów." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:779 +msgid "This setting controls the height (and thus the total number) of the slices/layers. Thinner layers give better accuracy but take more time to print." +msgstr "To ustawienie odpowiada za wysokość warstwy (czyli ciÄ™cia), a w konsekwencji za ich liczbÄ™. Niższe warstwy zapewniajÄ… lepszÄ… dokÅ‚adność i jakość, ale wydÅ‚użajÄ… ogólny czas wydruku." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:788 +msgid "This setting represents the maximum speed of your fan." +msgstr "To ustawienie odpowiada za maksymalnÄ… prÄ™dkość wentylatora." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:849 +msgid "This setting represents the minimum PWM your fan needs to work." +msgstr "To ustawienie wyraża minimalny PWM (Pulse Width Modulation), który jest niezbÄ™dny dla wentylatora." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1358 +msgid "This start procedure is inserted at the beginning, after any printer start gcode. This is used to override settings for a specific filament. If Slic3r detects M104, M109, M140 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want. If you have multiple extruders, the gcode is processed in extruder order." +msgstr "Ten skrypt jest wykonywany na samym poczÄ…tku G-code. Może być użyty do nadpisania okreÅ›lonych ustawieÅ„ filamentu. JeÅ›li Slic3r wykryje komendy typu M104, M109, M140 lub M190, to nie zostanÄ… one wykonane na poczÄ…tku, wiÄ™c możesz okreÅ›lić kolejność komend dot. podgrzewania i innych dodanych akcji. PamiÄ™taj, że możesz używać zmiennych typu placeholder, wiÄ™c np. komendÄ™ \"M109 S[first_layer_temperature]\" (temperatura pierwszej warstwy) możesz umieÅ›cić gdzie chcesz. JeÅ›li posiadasz kilka ekstruderów, ten G-code jest wykonywany w ich kolejnoÅ›ci." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1343 +msgid "This start procedure is inserted at the beginning, after bed has reached the target temperature and extruder just started heating, and before extruder has finished heating. If Slic3r detects M104 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want." +msgstr "Ten skrypt jest wykonywany na poczÄ…tku, po tym jak stół roboczy osiÄ…gnie zadanÄ… temperaturÄ™ i ekstruder zacznie podgrzewanie, ale zanim nagrzeje siÄ™ do zadanej temperatury. JeÅ›li Slic3r wykryje komendy typu M104, M109, M140 lub M190, to nie zostanÄ… one wykonane na poczÄ…tku, wiÄ™c możesz okreÅ›lić kolejność komend dot. podgrzewania i innych dodanych akcji. PamiÄ™taj, że możesz używać zmiennych typu placeholder, wiÄ™c np. komendÄ™ \"M109 S[first_layer_temperature]\" (temperatura pierwszej warstwy) możesz umieÅ›cić gdzie chcesz." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1743 +msgid "This value will be added (or subtracted) from all the Z coordinates in the output G-code. It is used to compensate for bad Z endstop position: for example, if your endstop zero actually leaves the nozzle 0.3mm far from the print bed, set this to -0.3 (or fix your endstop)." +msgstr "Wartość tego ustawienia zostanie dodana (lub odjÄ™ta) od wszystkich koordynat w osi Z w pliku wyjÅ›ciowym G-code. Jest używana dla korekcji zÅ‚ego poÅ‚ożenia wyłącznika kraÅ„cowego osi Z. Np. jeÅ›li koÅ„cówka dyszy znajduje siÄ™ 0.3 mm ponad poÅ‚ożeniem zerowym, ustaw tutaj -0.3 (lub napraw kraÅ„cówkÄ™)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1590 +msgid "Threads" +msgstr "WÄ…tki" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1591 +msgid "Threads are used to parallelize long-running tasks. Optimal threads number is slightly above the number of available cores/processors." +msgstr "WÄ…tki sÄ… używane do równolegÅ‚ego przetwarzania zadaÅ„ wymagajÄ…cych używa wielu zasobów. Optymalna liczba wÄ…tków powinna być odrobinÄ™ wiÄ™ksza od dostÄ™pnej liczby rdzeni lub procesorów." + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:338 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:72 +msgid "Tool" +msgstr "NarzÄ™dzie" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1144 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1602 +msgid "Tool change G-code" +msgstr "G-code wykonywany przy zmianie narzÄ™dzia" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1638 +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 +msgid "Top" +msgstr "Szczyt" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:187 +msgid "top solid infill" +msgstr "zwarte wypeÅ‚nienie na szczycie" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1613 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1624 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:143 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:85 +msgid "Top solid infill" +msgstr "Zwarte wypeÅ‚nienie górne" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1642 +msgid "Top solid layers" +msgstr "Zwarte warstwy górne" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:369 +msgid "Top View" +msgstr "Widok z góry" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:246 +msgid "Top/bottom fill pattern" +msgstr "Wzór wypeÅ‚nienia góry/doÅ‚u" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1647 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:95 +msgid "Travel" +msgstr "JaÅ‚owy" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2070 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:2086 +msgid "Uniformly…" +msgstr "Jednakowo…" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:97 +msgid "Unretractions" +msgstr "Powrót retrakcji" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1492 +msgid "Unsaved Changes" +msgstr "Niezapisane zmiany" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:750 +msgid "Unsaved Presets" +msgstr "Niezapisane zestawy ustawieÅ„" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:989 +msgid "USB/Serial connection" +msgstr "Połączenie USB/szeregowe" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1194 +msgid "USB/serial port for printer connection." +msgstr "Port USB/szeregowy do połączenia z drukarkÄ…." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1656 +msgid "Use firmware retraction" +msgstr "Użyj retrakcji z firmware" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:75 +msgid "Use legacy OpenGL 1.1 rendering" +msgstr "Użyj renderowania OpenGL 1.1 (przestarzaÅ‚e)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1663 +msgid "Use relative E distances" +msgstr "Użyj wzglÄ™dnych wartoÅ›ci E (ekstruzji)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:361 +msgid "Use this option to set the axis letter associated to your printer's extruder (usually E but some printers use A)." +msgstr "Ta opcja okreÅ›la literÄ™, którÄ… Twoja drukarka opisuje oÅ› ekstrudera (zazwyczaj jest to E ale niektóre drukarki używajÄ… A)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1400 +msgid "Use this setting to rotate the support material pattern on the horizontal plane." +msgstr "To ustawienie odpowiada za obrót materiaÅ‚u podporowego w pÅ‚aszczyźnie poziomej." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1670 +msgid "Use volumetric E" +msgstr "Użyj wolumetrycznej wartoÅ›ci E" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:449 +msgid "Used Filament (g)" +msgstr "Użyty filament (g)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:447 +msgid "Used Filament (m)" +msgstr "Użyty filament (m)" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:448 +msgid "Used Filament (mm³)" +msgstr "Użyty filament (mm³)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:644 +msgid "Verbose G-code" +msgstr "G-code rozszerzony" + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:66 +msgid "Version " +msgstr "Wersja " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:318 +msgid "Vertical shells" +msgstr "PowÅ‚oka pionowa" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:65 +msgid "View" +msgstr "Widok" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:409 +msgid "Volume" +msgstr "ObjÄ™tość" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:214 +msgid "Volumetric" +msgstr "ObjÄ™toÅ›ciowy" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:500 +msgid "Warning" +msgstr "Ostrzeżenie" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm:131 +msgid "What do you want to print today? â„¢" +msgstr "Co chcesz dziÅ› wydrukować? â„¢" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:69 +msgid "When checked, the print and filament presets are shown in the preset editor even if they are marked as incompatible with the active printer" +msgstr "Zaznaczenie tej opcji spowoduje wyÅ›wietlanie wszystkich ustawieÅ„ druku i filamentów w edytorze zestawów ustawieÅ„, nawet jeÅ›li sÄ… oznaczone jak niekompatybilne z wybranÄ… drukarkÄ…" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:219 +msgid "when printing " +msgstr "podczas druku " + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:136 +msgid "When printing multi-material objects, this settings will make slic3r to clip the overlapping object parts one by the other (2nd part will be clipped by the 1st, 3rd part will be clipped by the 1st and 2nd etc)." +msgstr "To ustawienie sprawi, że podczas druku modeli z wielu materiałów, Slic3r przytnie nachodzÄ…ce na siebie części (druga część zostanie przyciÄ™ta przez pierwszÄ…, trzecia przez pierwszÄ… i drugÄ… itd.)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:155 +msgid "When printing multiple objects or copies, this feature will complete each object before moving onto next one (and starting it from its bottom layer). This feature is useful to avoid the risk of ruined prints. Slic3r should warn and prevent you from extruder collisions, but beware." +msgstr "Włączenie tej opcji sprawi, że przy druku kilku modeli drukarka wydrukuje jeden model w caÅ‚oÅ›ci zanim przejdzie do nastÄ™pnego (zaczynajÄ…c od najniższej warstwy). Przydaje siÄ™ aby uniknąć ryzyka niepowodzenia wydruku kilku części. Slic3r powinien ostrzec przed możliwoÅ›ciÄ… kolizji z ekstruderem, ale zachowaj ostrożność." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:605 +msgid "When printing with very low layer heights, you might still want to print a thicker bottom layer to improve adhesion and tolerance for non perfect build plates. This can be expressed as an absolute value or as a percentage (for example: 150%) over the default layer height." +msgstr "Podczas druku z bardzo małą wysokoÅ›ciÄ… warstwy warto mimo wszystko wydrukować najniższÄ… warstwÄ™ o wiÄ™kszej wysokoÅ›ci aby zwiÄ™kszyć przyczepność i tolerancjÄ™ na niedoskonaÅ‚oÅ›ci powierzchni druki. Może być wyrażona jako wartość bezwzglÄ™dna lub procentowa (np. 150%) nominalnej wysokoÅ›ci warstwy." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1082 +msgid "When retraction is triggered before changing tool, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder)." +msgstr "Kiedy retrakcja zostaje wykonana przed zmianÄ… ekstrudera, filament o okreÅ›lonej dÅ‚ugoÅ›ci jest wciÄ…gany z powrotem (mierzona jest dÅ‚ugość nieprzetworzonego filamentu, zanim wejdzie do ekstrudera)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1073 +msgid "When retraction is triggered, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder)." +msgstr "Kiedy zostaje wykonana retrakcja to filament o okreÅ›lonej dÅ‚ugoÅ›ci jest wciÄ…gany z powrotem (mierzona jest dÅ‚ugość nieprzetworzonego filamentu, zanim wejdzie do ekstrudera)." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:808 +msgid "When setting other speed settings to 0 Slic3r will autocalculate the optimal speed in order to keep constant extruder pressure. This experimental setting is used to set the highest print speed you want to allow." +msgstr "Ustawienie pozostaÅ‚ych prÄ™dkoÅ›ci na 0 spowoduje, ze Slic3r bÄ™dzie automatycznie przeliczaÅ‚ optymalnÄ… prÄ™dkość dla utrzymania staÅ‚ego ciÅ›nienia materiaÅ‚u w ekstruderze. To eksperymentalne ustawienie okreÅ›la maksymalnÄ… dozwolonÄ… prÄ™dkość druku." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1127 +msgid "When the retraction is compensated after changing tool, the extruder will push this additional amount of filament." +msgstr "JeÅ›li retrakcja jest korygowana po zmianie narzÄ™dzia, ekstruder przepchnie takÄ… dodatkowÄ… ilość filamentu." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1119 +msgid "When the retraction is compensated after the travel move, the extruder will push this additional amount of filament. This setting is rarely needed." +msgstr "JeÅ›li retrakcja jest korygowana po ruchu jaÅ‚owym, ekstruder przepchnie takÄ… dodatkowÄ… ilość filamentu. Ta opcja jest rzadko potrzebna." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1716 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:70 +msgid "Width" +msgstr "Szerokość" + +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:334 +msgid "Width (mm)" +msgstr "Szerokość (mm)" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1717 +msgid "Width of a wipe tower" +msgstr "Szerokość wieży czyszczÄ…cej" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:41 +#, c-format +msgid "will always run at %d%% " +msgstr "bÄ™dzie zawsze pracować w %d %% " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp:50 +msgid "will be turned off." +msgstr "bÄ™dzie wyłączone." + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:442 +#: c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp:149 +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm:91 +msgid "Wipe tower" +msgstr "Wieża czyszczÄ…ca" + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:564 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:585 +#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:602 +msgid "Wipe Tower" +msgstr "Wieża CzyszczÄ…ca" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1688 +msgid "Wipe while retracting" +msgstr "Czyszczenie przy retrakcji" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1058 +msgid "With bowden extruders, it may be wise to do some amount of quick retract before doing the wipe movement." +msgstr "Przy ekstruderze typu bowden warto wykonać szybkÄ… retrakcjÄ™ przed ruchem czyszczÄ…cym." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1564 +msgid "With sheath around the support" +msgstr "Z osÅ‚onÄ… wokół podpór" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1703 +msgid "X coordinate of the left front corner of a wipe tower" +msgstr "Koordynata X wieży czyszczÄ…cej od przedniego lewego narożnika" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1386 +msgid "XY separation between an object and its support" +msgstr "OdstÄ™p materiaÅ‚u podporowego od modelu w osiach XY" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1388 +msgid "XY separation between an object and its support. If expressed as percentage (for example 50%), it will be calculated over external perimeter width." +msgstr "OdstÄ™p materiaÅ‚u podporowego od modelu w osiach XY. JeÅ›li ustawisz wartość procentowÄ… (np. 15%) to zostanie obliczona z szerokoÅ›ci ekstruzji obrysów zewnÄ™trznych." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1732 +msgid "XY Size Compensation" +msgstr "Korekta wymiarów XY" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1710 +msgid "Y coordinate of the left front corner of a wipe tower" +msgstr "Koordynata wieży czyszczÄ…cej w osi Y od przedniego lewego narożnika" + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:1970 +msgid "Yes" +msgstr "Tak" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:885 +msgid "You can put here your personal notes. This text will be added to the G-code header comments." +msgstr "Tutaj możesz umieÅ›cić notatki, które zostanÄ… dodane do nagłówka pliku G-code." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:413 +msgid "You can put your notes regarding the filament here." +msgstr "Tutaj możesz umieÅ›cić notatki dotyczÄ…ce filamentu." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1015 +msgid "You can put your notes regarding the printer here." +msgstr "Tutaj możesz umieÅ›cić notatki dotyczÄ…ce drukarki." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:181 +msgid "You can set this to a positive value to disable fan at all during the first layers, so that it does not make adhesion worse." +msgstr "WpisujÄ…c tutaj wartość dodatniÄ… możesz wyłączyć wentylator podczas druku pierwszych warstw, aby nie pogarszać przyczepnoÅ›ci do stoÅ‚u." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:931 +msgid "You can use all configuration options as variables inside this template. For example: [layer_height], [fill_density] etc. You can also use [timestamp], [year], [month], [day], [hour], [minute], [second], [version], [input_filename], [input_filename_base]." +msgstr "Możesz użyć wszystkich opcji konfiguracjnych jako zmiennych w tym szablonie, takich jak np: [layer_height] - wysokość warstwy, [fill_density] - gÄ™stość wypeÅ‚nienia, itp. Możesz również użyć [timestamp] - czas, [year] - rok, [month] - miesiÄ…c, [day] - dzieÅ„, [hour] - godzina, [minute] - minuta, [second] - sekunda, [version] - wersja, [input_filename] - peÅ‚na nazwa pliku wejÅ›ciowego, [input_filename_base] - nazwa pliku wejÅ›ciowego bez rozszerzenia." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:749 +msgid "You have unsaved changes " +msgstr "Masz niesapisane zmiany " + +#: c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp:101 +msgid "You need to restart Slic3r to make the changes effective." +msgstr "Trzeba zrestartować Slic3r aby wprowadzić zmiany." + +#: c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm:594 +msgid "Your file was repaired." +msgstr "Twój plik zostaÅ‚ naprawiony." + +#: c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm:744 +msgid "Your object appears to be too large, so it was automatically scaled down to fit your print bed." +msgstr "Importowany model przekracza wymiary przestrzeni roboczej i zostaÅ‚ przeskalowany do odpowiednich rozmiarów." + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1742 +msgid "Z offset" +msgstr "Margines Z" + +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:91 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:492 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1170 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1181 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1401 +#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1557 +msgid "°" +msgstr "°" diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ed86fac51d..5a47dd1e7b 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -2125,7 +2125,7 @@ void Tab::save_preset(std::string name /*= ""*/) return; } if (existing && (existing->is_external)) { - show_error(this, _(L("Cannot overwrite an external."))); + show_error(this, _(L("Cannot overwrite an external profile."))); return; } } From 0c1655b884496858971171cac863bae822896b3c Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 14 May 2018 14:14:19 +0200 Subject: [PATCH 0333/1150] 3DScene::Resize() method moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 105 +++++++-------- xs/src/slic3r/GUI/3DScene.cpp | 35 ++++- xs/src/slic3r/GUI/3DScene.hpp | 13 +- xs/src/slic3r/GUI/GLCanvas3D.cpp | 165 +++++++++++++++++++++++- xs/src/slic3r/GUI/GLCanvas3D.hpp | 44 ++++++- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 45 ++++++- xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 13 +- xs/xsp/GUI_3DScene.xsp | 38 ++++++ 8 files changed, 377 insertions(+), 81 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index a7de71d4d5..60f1199808 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -194,10 +194,6 @@ sub new { $self->background(1); $self->_quat((0, 0, 0, 1)); #============================================================================================================================== - Slic3r::GUI::_3DScene::set_camera_theta($self, 45.0); - Slic3r::GUI::_3DScene::set_camera_phi($self, 45.0); - Slic3r::GUI::_3DScene::set_camera_zoom($self, 1.0); - # $self->_stheta(45); # $self->_sphi(45); # $self->_zoom(1); @@ -210,6 +206,9 @@ sub new { # Collection of GLVolume objects $self->volumes(Slic3r::GUI::_3DScene::GLVolume::Collection->new); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_volumes($self, $self->volumes); +#============================================================================================================================== # 3D point in model space #============================================================================================================================== @@ -217,8 +216,6 @@ sub new { ## $self->_camera_type('perspective'); #============================================================================================================================== #============================================================================================================================== - Slic3r::GUI::_3DScene::set_camera_target($self, Slic3r::Pointf3->new(0,0,0)); - Slic3r::GUI::_3DScene::set_camera_distance($self, 0.0); # $self->_camera_target(Slic3r::Pointf3->new(0,0,0)); # $self->_camera_distance(0.); #============================================================================================================================== @@ -969,9 +966,13 @@ sub bed_bounding_box { sub max_bounding_box { my ($self) = @_; - my $bb = $self->bed_bounding_box; - $bb->merge($self->volumes_bounding_box); - return $bb; +#============================================================================================================================== + return Slic3r::GUI::_3DScene::get_max_bounding_box($self); + +# my $bb = $self->bed_bounding_box; +# $bb->merge($self->volumes_bounding_box); +# return $bb; +#============================================================================================================================== } # Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane @@ -1000,6 +1001,9 @@ sub set_bed_shape { my ($self, $bed_shape) = @_; $self->bed_shape($bed_shape); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_bed_shape($self, $bed_shape); +#============================================================================================================================== # triangulate bed my $expolygon = Slic3r::ExPolygon->new([ map [map scale($_), @$_], @$bed_shape ]); @@ -1246,63 +1250,48 @@ sub UseVBOs { sub Resize { my ($self, $x, $y) = @_; - - return unless $self->GetContext; -#============================================================================================================================== - Slic3r::GUI::_3DScene::set_dirty($self, 0); -# $self->_dirty(0); + #============================================================================================================================== + Slic3r::GUI::_3DScene::resize($self, $x, $y); - $self->SetCurrent($self->GetContext); - glViewport(0, 0, $x, $y); - -#============================================================================================================================== - my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); - $x /= $zoom; - $y /= $zoom; +# return unless $self->GetContext; +# $self->_dirty(0); +# +# $self->SetCurrent($self->GetContext); +# glViewport(0, 0, $x, $y); +# # $x /= $self->_zoom; # $y /= $self->_zoom; -#============================================================================================================================== - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); -#============================================================================================================================== - my $camera_type = Slic3r::GUI::_3DScene::get_camera_type_as_string($self); - if ($camera_type eq 'ortho') { +# +# glMatrixMode(GL_PROJECTION); +# glLoadIdentity(); # if ($self->_camera_type eq 'ortho') { -#============================================================================================================================== - #FIXME setting the size of the box 10x larger than necessary - # is only a workaround for an incorrectly set camera. - # This workaround harms Z-buffer accuracy! -# my $depth = 1.05 * $self->max_bounding_box->radius(); - my $depth = 5.0 * max(@{ $self->max_bounding_box->size }); - glOrtho( - -$x/2, $x/2, -$y/2, $y/2, - -$depth, $depth, - ); - } else { -#============================================================================================================================== - die "Invalid camera type: ", $camera_type, "\n" if ($camera_type ne 'perspective'); +# #FIXME setting the size of the box 10x larger than necessary +# # is only a workaround for an incorrectly set camera. +# # This workaround harms Z-buffer accuracy! +## my $depth = 1.05 * $self->max_bounding_box->radius(); +# my $depth = 5.0 * max(@{ $self->max_bounding_box->size }); +# glOrtho( +# -$x/2, $x/2, -$y/2, $y/2, +# -$depth, $depth, +# ); +# } else { # die "Invalid camera type: ", $self->_camera_type, "\n" if ($self->_camera_type ne 'perspective'); -#============================================================================================================================== - my $bbox_r = $self->max_bounding_box->radius(); - my $fov = PI * 45. / 180.; - my $fov_tan = tan(0.5 * $fov); - my $cam_distance = 0.5 * $bbox_r / $fov_tan; -#============================================================================================================================== - Slic3r::GUI::_3DScene::set_camera_distance($self, $cam_distance); +# my $bbox_r = $self->max_bounding_box->radius(); +# my $fov = PI * 45. / 180.; +# my $fov_tan = tan(0.5 * $fov); +# my $cam_distance = 0.5 * $bbox_r / $fov_tan; # $self->_camera_distance($cam_distance); +# my $nr = $cam_distance - $bbox_r * 1.1; +# my $fr = $cam_distance + $bbox_r * 1.1; +# $nr = 1 if ($nr < 1); +# $fr = $nr + 1 if ($fr < $nr + 1); +# my $h2 = $fov_tan * $nr; +# my $w2 = $h2 * $x / $y; +# glFrustum(-$w2, $w2, -$h2, $h2, $nr, $fr); +# } +# glMatrixMode(GL_MODELVIEW); #============================================================================================================================== - my $nr = $cam_distance - $bbox_r * 1.1; - my $fr = $cam_distance + $bbox_r * 1.1; - $nr = 1 if ($nr < 1); - $fr = $nr + 1 if ($fr < $nr + 1); - my $h2 = $fov_tan * $nr; - my $w2 = $h2 * $x / $y; - glFrustum(-$w2, $w2, -$h2, $h2, $nr, $fr); - } - - glMatrixMode(GL_MODELVIEW); } sub InitGL { diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 7603c9b843..6f485d5114 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1742,6 +1742,36 @@ void _3DScene::remove_all_canvases() s_canvas_mgr.remove_all(); } +void _3DScene::resize(wxGLCanvas* canvas, unsigned int w, unsigned int h) +{ + s_canvas_mgr.resize(canvas, w, h); +} + +bool _3DScene::is_shown_on_screen(wxGLCanvas* canvas) +{ + return s_canvas_mgr.is_shown_on_screen(canvas); +} + +GLVolumeCollection* _3DScene::get_volumes(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_volumes(canvas); +} + +void _3DScene::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes) +{ + s_canvas_mgr.set_volumes(canvas, volumes); +} + +void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape) +{ + return s_canvas_mgr.set_bed_shape(canvas, shape); +} + +BoundingBoxf3 _3DScene::get_max_bounding_box(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_max_bounding_box(canvas); +} + bool _3DScene::is_dirty(wxGLCanvas* canvas) { return s_canvas_mgr.is_dirty(canvas); @@ -1752,11 +1782,6 @@ void _3DScene::set_dirty(wxGLCanvas* canvas, bool dirty) s_canvas_mgr.set_dirty(canvas, dirty); } -bool _3DScene::is_shown_on_screen(wxGLCanvas* canvas) -{ - return s_canvas_mgr.is_shown_on_screen(canvas); -} - unsigned int _3DScene::get_camera_type(wxGLCanvas* canvas) { return s_canvas_mgr.get_camera_type(canvas); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 618b8ec348..0e8cd2bcc1 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -542,11 +542,20 @@ public: static bool remove_canvas(wxGLCanvas* canvas); static void remove_all_canvases(); - static bool is_dirty(wxGLCanvas* canvas); - static void set_dirty(wxGLCanvas* canvas, bool dirty); + static void resize(wxGLCanvas* canvas, unsigned int w, unsigned int h); static bool is_shown_on_screen(wxGLCanvas* canvas); + static GLVolumeCollection* get_volumes(wxGLCanvas* canvas); + static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes); + + static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); + + static BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); + + static bool is_dirty(wxGLCanvas* canvas); + static void set_dirty(wxGLCanvas* canvas, bool dirty); + static unsigned int get_camera_type(wxGLCanvas* canvas); static void set_camera_type(wxGLCanvas* canvas, unsigned int type); static std::string get_camera_type_as_string(wxGLCanvas* canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 93186a8ab6..0e539aaefa 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -1,5 +1,7 @@ #include "GLCanvas3D.hpp" +#include "../../slic3r/GUI/3DScene.hpp" + #include #include @@ -100,10 +102,37 @@ void GLCanvas3D::Camera::set_target(const Pointf3& target) m_target = target; } +const Pointfs& GLCanvas3D::Bed::get_shape() const +{ + return m_shape; +} + +void GLCanvas3D::Bed::set_shape(const Pointfs& shape) +{ + m_shape = shape; + _calc_bounding_box(); +} + +const BoundingBoxf3& GLCanvas3D::Bed::get_bounding_box() const +{ + return m_bounding_box; +} + +void GLCanvas3D::Bed::_calc_bounding_box() +{ + m_bounding_box = BoundingBoxf3(); + for (const Pointf& p : m_shape) + { + m_bounding_box.merge(Pointf3(p.x, p.y, 0.0)); + } +} + GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) : m_canvas(canvas) , m_context(context) + , m_volumes(nullptr) , m_dirty(true) + , m_apply_zoom_to_volumes_filter(false) { } @@ -113,6 +142,94 @@ void GLCanvas3D::set_current() m_canvas->SetCurrent(*m_context); } +bool GLCanvas3D::is_shown_on_screen() const +{ + return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false; +} + +void GLCanvas3D::resize(unsigned int w, unsigned int h) +{ + if (m_context == nullptr) + return; + + set_current(); + ::glViewport(0, 0, w, h); + + ::glMatrixMode(GL_PROJECTION); + ::glLoadIdentity(); + + BoundingBoxf3 bbox = max_bounding_box(); + + switch (get_camera_type()) + { + case Camera::CT_Ortho: + { + float w2 = w; + float h2 = h; + float two_zoom = 2.0f * get_camera_zoom(); + if (two_zoom != 0.0f) + { + float inv_two_zoom = 1.0f / two_zoom; + w2 *= inv_two_zoom; + h2 *= inv_two_zoom; + } + + // FIXME: calculate a tighter value for depth will improve z-fighting + Pointf3 bb_size = bbox.size(); + float depth = 5.0f * (float)std::max(bb_size.x, std::max(bb_size.y, bb_size.z)); + ::glOrtho(-w2, w2, -h2, h2, -depth, depth); + + break; + } + case Camera::CT_Perspective: + { + float bbox_r = (float)bbox.radius(); + float fov = PI * 45.0f / 180.0f; + float fov_tan = tan(0.5f * fov); + float cam_distance = 0.5f * bbox_r / fov_tan; + set_camera_distance(cam_distance); + + float nr = cam_distance - bbox_r * 1.1f; + float fr = cam_distance + bbox_r * 1.1f; + if (nr < 1.0f) + nr = 1.0f; + + if (fr < nr + 1.0f) + fr = nr + 1.0f; + + float h2 = fov_tan * nr; + float w2 = h2 * w / h; + ::glFrustum(-w2, w2, -h2, h2, nr, fr); + + break; + } + default: + { + throw std::runtime_error("Invalid camera type."); + break; + } + } + + ::glMatrixMode(GL_MODELVIEW); + + set_dirty(false); +} + +GLVolumeCollection* GLCanvas3D::get_volumes() +{ + return m_volumes; +} + +void GLCanvas3D::set_volumes(GLVolumeCollection* volumes) +{ + m_volumes = volumes; +} + +void GLCanvas3D::set_bed_shape(const Pointfs& shape) +{ + m_bed.set_shape(shape); +} + bool GLCanvas3D::is_dirty() const { return m_dirty; @@ -123,11 +240,6 @@ void GLCanvas3D::set_dirty(bool dirty) m_dirty = dirty; } -bool GLCanvas3D::is_shown_on_screen() const -{ - return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false; -} - GLCanvas3D::Camera::EType GLCanvas3D::get_camera_type() const { return m_camera.get_type(); @@ -200,5 +312,48 @@ void GLCanvas3D::on_size(wxSizeEvent& evt) set_dirty(true); } +BoundingBoxf3 GLCanvas3D::bed_bounding_box() const +{ + return m_bed.get_bounding_box(); +} + +BoundingBoxf3 GLCanvas3D::volumes_bounding_box() const +{ + BoundingBoxf3 bb; + if (m_volumes != nullptr) + { + for (const GLVolume* volume : m_volumes->volumes) + { + if (!m_apply_zoom_to_volumes_filter || ((volume != nullptr) && volume->zoom_to_volumes)) + bb.merge(volume->transformed_bounding_box()); + } + } + return bb; +} + +BoundingBoxf3 GLCanvas3D::max_bounding_box() const +{ + BoundingBoxf3 bb = bed_bounding_box(); + bb.merge(volumes_bounding_box()); + return bb; +} + +void GLCanvas3D::_zoom_to_bed() +{ + _zoom_to_bounding_box(bed_bounding_box()); +} + +void GLCanvas3D::_zoom_to_volumes() +{ + m_apply_zoom_to_volumes_filter = true; + _zoom_to_bounding_box(volumes_bounding_box()); + m_apply_zoom_to_volumes_filter = false; +} + +void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox) +{ + // >>>>>>>>>>>>>>>>>>>> TODO <<<<<<<<<<<<<<<<<<<<<<<< +} + } // namespace GUI } // namespace Slic3r diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 14c1031dd0..26d0949f09 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -1,13 +1,16 @@ #ifndef slic3r_GLCanvas3D_hpp_ #define slic3r_GLCanvas3D_hpp_ -#include "../../libslic3r/Point.hpp" +#include "../../libslic3r/BoundingBox.hpp" class wxGLCanvas; class wxGLContext; class wxSizeEvent; namespace Slic3r { + +class GLVolumeCollection; + namespace GUI { class GLCanvas3D @@ -55,23 +58,49 @@ public: void set_target(const Pointf3& target); }; + class Bed + { + Pointfs m_shape; + BoundingBoxf3 m_bounding_box; + + public: + const Pointfs& get_shape() const; + void set_shape(const Pointfs& shape); + + const BoundingBoxf3& get_bounding_box() const; + + private: + void _calc_bounding_box(); + }; + private: wxGLCanvas* m_canvas; wxGLContext* m_context; Camera m_camera; + Bed m_bed; + + GLVolumeCollection* m_volumes; bool m_dirty; + bool m_apply_zoom_to_volumes_filter; public: GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context); void set_current(); + bool is_shown_on_screen() const; + + void resize(unsigned int w, unsigned int h); + + GLVolumeCollection* get_volumes(); + void set_volumes(GLVolumeCollection* volumes); + + void set_bed_shape(const Pointfs& shape); + bool is_dirty() const; void set_dirty(bool dirty); - bool is_shown_on_screen() const; - Camera::EType get_camera_type() const; void set_camera_type(Camera::EType type); std::string get_camera_type_as_string() const; @@ -92,6 +121,15 @@ public: void set_camera_target(const Pointf3& target); void on_size(wxSizeEvent& evt); + + BoundingBoxf3 bed_bounding_box() const; + BoundingBoxf3 volumes_bounding_box() const; + BoundingBoxf3 max_bounding_box() const; + +private: + void _zoom_to_bed(); + void _zoom_to_volumes(); + void _zoom_to_bounding_box(const BoundingBoxf3& bbox); }; } // namespace GUI diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 5a565be283..b9bdde1616 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -146,6 +146,45 @@ bool GLCanvas3DManager::layer_editing_allowed() const return m_layer_editing.allowed; } +bool GLCanvas3DManager::is_shown_on_screen(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->is_shown_on_screen() : false; +} + +void GLCanvas3DManager::resize(wxGLCanvas* canvas, unsigned int w, unsigned int h) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->resize(w, h); +} + +GLVolumeCollection* GLCanvas3DManager::get_volumes(wxGLCanvas* canvas) +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_volumes() : nullptr; +} + +void GLCanvas3DManager::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_volumes(volumes); +} + +void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_bed_shape(shape); +} + +BoundingBoxf3 GLCanvas3DManager::get_max_bounding_box(wxGLCanvas* canvas) +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->max_bounding_box() : BoundingBoxf3(); +} + bool GLCanvas3DManager::is_dirty(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); @@ -159,12 +198,6 @@ void GLCanvas3DManager::set_dirty(wxGLCanvas* canvas, bool dirty) it->second->set_dirty(dirty); } -bool GLCanvas3DManager::is_shown_on_screen(wxGLCanvas* canvas) const -{ - CanvasesMap::const_iterator it = _get_canvas(canvas); - return (it != m_canvases.end()) ? it->second->is_shown_on_screen() : false; -} - unsigned int GLCanvas3DManager::get_camera_type(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 858c2d9e7b..c53d6b5d36 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -52,11 +52,20 @@ public: bool use_VBOs() const; bool layer_editing_allowed() const; + bool is_shown_on_screen(wxGLCanvas* canvas) const; + + void resize(wxGLCanvas* canvas, unsigned int w, unsigned int h); + + GLVolumeCollection* get_volumes(wxGLCanvas* canvas); + void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes); + + void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); + + BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); + bool is_dirty(wxGLCanvas* canvas) const; void set_dirty(wxGLCanvas* canvas, bool dirty); - bool is_shown_on_screen(wxGLCanvas* canvas) const; - unsigned int get_camera_type(wxGLCanvas* canvas) const; void set_camera_type(wxGLCanvas* canvas, unsigned int type); std::string get_camera_type_as_string(wxGLCanvas* canvas) const; diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index c7933f0125..7e7fbc417b 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -185,6 +185,44 @@ remove_all_canvases() CODE: _3DScene::remove_all_canvases(); +void +resize(canvas, w, h) + SV *canvas; + unsigned int w; + unsigned int h; + CODE: + _3DScene::resize((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), w, h); + +GLVolumeCollection* +get_volumes(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_volumes(canvas, volumes) + SV *canvas; + GLVolumeCollection *volumes; + CODE: + _3DScene::set_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), volumes); + +void +set_bed_shape(canvas, shape) + SV *canvas; + Pointfs shape; + CODE: + _3DScene::set_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), shape); + +Clone +get_max_bounding_box(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_max_bounding_box((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + bool is_dirty(canvas) SV *canvas; From 986630c2dc366bc93629e8a8ae790278ece3636f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 14 May 2018 14:47:13 +0200 Subject: [PATCH 0334/1150] 3DScene's idle even handler moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 10 +++---- xs/src/slic3r/GUI/GLCanvas3D.cpp | 35 ++++++++++++++++++++----- xs/src/slic3r/GUI/GLCanvas3D.hpp | 7 +++-- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 1 + 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 60f1199808..9cdc51693e 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -236,16 +236,14 @@ sub new { #======================================================================================================================= # EVT_SIZE($self, sub { $self->_dirty(1) }); #======================================================================================================================= - EVT_IDLE($self, sub { #============================================================================================================================== - return unless Slic3r::GUI::_3DScene::is_dirty($self); - return unless Slic3r::GUI::_3DScene::is_shown_on_screen($self); +# EVT_IDLE($self, sub { # return unless $self->_dirty; # return if !$self->IsShownOnScreen; +# $self->Resize( $self->GetSizeWH ); +# $self->Refresh; +# }); #============================================================================================================================== - $self->Resize( $self->GetSizeWH ); - $self->Refresh; - }); EVT_MOUSEWHEEL($self, \&mouse_wheel_event); EVT_MOUSE_EVENTS($self, \&mouse_event); # EVT_KEY_DOWN($self, sub { diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 0e539aaefa..c520279742 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -305,13 +305,6 @@ void GLCanvas3D::set_camera_target(const Pointf3& target) m_camera.set_target(target); } -void GLCanvas3D::on_size(wxSizeEvent& evt) -{ - std::cout << "GLCanvas3D::on_size: " << (void*)this << std::endl; - - set_dirty(true); -} - BoundingBoxf3 GLCanvas3D::bed_bounding_box() const { return m_bed.get_bounding_box(); @@ -338,6 +331,24 @@ BoundingBoxf3 GLCanvas3D::max_bounding_box() const return bb; } +void GLCanvas3D::on_size(wxSizeEvent& evt) +{ + set_dirty(true); +} + +void GLCanvas3D::on_idle(wxIdleEvent& evt) +{ + if (!is_dirty() || !is_shown_on_screen()) + return; + + if (m_canvas != nullptr) + { + std::pair size = _get_canvas_size(); + resize((unsigned int)size.first, (unsigned int)size.second); + m_canvas->Refresh(); + } +} + void GLCanvas3D::_zoom_to_bed() { _zoom_to_bounding_box(bed_bounding_box()); @@ -355,5 +366,15 @@ void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox) // >>>>>>>>>>>>>>>>>>>> TODO <<<<<<<<<<<<<<<<<<<<<<<< } +std::pair GLCanvas3D::_get_canvas_size() const +{ + std::pair ret(0, 0); + + if (m_canvas != nullptr) + m_canvas->GetSize(&ret.first, &ret.second); + + return ret; +} + } // namespace GUI } // namespace Slic3r diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 26d0949f09..7a8e763f93 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -6,6 +6,7 @@ class wxGLCanvas; class wxGLContext; class wxSizeEvent; +class wxIdleEvent; namespace Slic3r { @@ -120,16 +121,18 @@ public: const Pointf3& get_camera_target() const; void set_camera_target(const Pointf3& target); - void on_size(wxSizeEvent& evt); - BoundingBoxf3 bed_bounding_box() const; BoundingBoxf3 volumes_bounding_box() const; BoundingBoxf3 max_bounding_box() const; + void on_size(wxSizeEvent& evt); + void on_idle(wxIdleEvent& evt); + private: void _zoom_to_bed(); void _zoom_to_volumes(); void _zoom_to_bounding_box(const BoundingBoxf3& bbox); + std::pair _get_canvas_size() const; }; } // namespace GUI diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index b9bdde1616..a3036c2ad8 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -78,6 +78,7 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas, wxGLContext* context) return false; canvas->Bind(wxEVT_SIZE, [canvas3D](wxSizeEvent& evt) { canvas3D->on_size(evt); }); + canvas->Bind(wxEVT_IDLE, [canvas3D](wxIdleEvent& evt) { canvas3D->on_idle(evt); }); m_canvases.insert(CanvasesMap::value_type(canvas, canvas3D)); From 328eba56102329c415e130a24977b54277412cd2 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 15 May 2018 09:41:58 +0200 Subject: [PATCH 0335/1150] Removed auto zoom to volumes when changing view --- lib/Slic3r/GUI/3DScene.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 1b6adf800e..9d343c3efd 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -679,8 +679,6 @@ sub select_view { # Avoid gimball lock. $self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX; $self->_stheta(0) if $self->_stheta < 0; - # View everything. - $self->zoom_to_bounding_box($bb); $self->on_viewport_changed->() if $self->on_viewport_changed; $self->Refresh; } From f4303ebdb888c322e0298d4f951343e511b44062 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 15 May 2018 09:50:01 +0200 Subject: [PATCH 0336/1150] 1st attempt of perl callback from c++ for 3DScene --- lib/Slic3r/GUI/3DScene.pm | 16 +-- lib/Slic3r/GUI/Plater.pm | 6 ++ xs/src/libslic3r/BoundingBox.cpp | 10 ++ xs/src/libslic3r/BoundingBox.hpp | 3 + xs/src/slic3r/GUI/3DScene.cpp | 5 + xs/src/slic3r/GUI/3DScene.hpp | 2 + xs/src/slic3r/GUI/GLCanvas3D.cpp | 125 +++++++++++++++++++++++- xs/src/slic3r/GUI/GLCanvas3D.hpp | 9 ++ xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 7 ++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 2 + xs/xsp/GUI_3DScene.xsp | 6 ++ 11 files changed, 181 insertions(+), 10 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 9cdc51693e..86e5d9095d 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -926,13 +926,15 @@ sub zoom_to_bed { } } -sub zoom_to_volume { - my ($self, $volume_idx) = @_; - - my $volume = $self->volumes->[$volume_idx]; - my $bb = $volume->transformed_bounding_box; - $self->zoom_to_bounding_box($bb); -} +#============================================================================================================================== +#sub zoom_to_volume { +# my ($self, $volume_idx) = @_; +# +# my $volume = $self->volumes->[$volume_idx]; +# my $bb = $volume->transformed_bounding_box; +# $self->zoom_to_bounding_box($bb); +#} +#============================================================================================================================== sub zoom_to_volumes { my ($self) = @_; diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index eb655ae55a..fb76914f01 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -141,6 +141,9 @@ sub new { $self->{canvas3D}->on_viewport_changed(sub { $self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D}); }); +#============================================================================================================================== + Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{canvas3D}, sub { $self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D}); }); +#============================================================================================================================== } # Initialize 2D preview canvas @@ -157,6 +160,9 @@ sub new { $self->{preview3D}->canvas->on_viewport_changed(sub { $self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas); }); +#============================================================================================================================== + Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{preview3D}->canvas, sub { $self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas); }); +#============================================================================================================================== $self->{preview_notebook}->AddPage($self->{preview3D}, L('Preview')); $self->{preview3D_page_idx} = $self->{preview_notebook}->GetPageCount-1; } diff --git a/xs/src/libslic3r/BoundingBox.cpp b/xs/src/libslic3r/BoundingBox.cpp index 91ba88d84e..e23accbde2 100644 --- a/xs/src/libslic3r/BoundingBox.cpp +++ b/xs/src/libslic3r/BoundingBox.cpp @@ -222,6 +222,16 @@ BoundingBox3Base::center() const } template Pointf3 BoundingBox3Base::center() const; +//######################################################################################################################################33 +template coordf_t +BoundingBox3Base::max_size() const +{ + PointClass s = size(); + return std::max(s.x, std::max(s.y, s.z)); +} +template coordf_t BoundingBox3Base::max_size() const; +//######################################################################################################################################33 + // Align a coordinate to a grid. The coordinate may be negative, // the aligned value will never be bigger than the original one. static inline coord_t _align_to_grid(const coord_t coord, const coord_t spacing) { diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp index 92a2bd451c..7ce24f3a40 100644 --- a/xs/src/libslic3r/BoundingBox.hpp +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -94,6 +94,9 @@ public: void translate(const Pointf3 &pos) { this->translate(pos.x, pos.y, pos.z); } void offset(coordf_t delta); PointClass center() const; +//######################################################################################################################################33 + coordf_t max_size() const; +//######################################################################################################################################33 bool contains(const PointClass &point) const { return BoundingBoxBase::contains(point) && point.z >= this->min.z && point.z <= this->max.z; diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 6f485d5114..79de5e42d1 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1847,6 +1847,11 @@ void _3DScene::set_camera_target(wxGLCanvas* canvas, const Pointf3* target) s_canvas_mgr.set_camera_target(canvas, target); } +void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) +{ + s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback); +} + //void _3DScene::_glew_init() //{ // glewInit(); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 0e8cd2bcc1..219316c1ba 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -575,6 +575,8 @@ public: static Pointf3 get_camera_target(wxGLCanvas* canvas); static void set_camera_target(wxGLCanvas* canvas, const Pointf3* target); + static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); + // static void _glew_init(); //################################################################################################################## diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index c520279742..706e694d7b 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -6,6 +6,7 @@ #include +static const bool TURNTABLE_MODE = true; static const float GIMBALL_LOCK_THETA_MAX = 180.0f; namespace Slic3r { @@ -136,6 +137,11 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) { } +GLCanvas3D::~GLCanvas3D() +{ + _deregister_callbacks(); +} + void GLCanvas3D::set_current() { if ((m_canvas != nullptr) && (m_context != nullptr)) @@ -175,8 +181,7 @@ void GLCanvas3D::resize(unsigned int w, unsigned int h) } // FIXME: calculate a tighter value for depth will improve z-fighting - Pointf3 bb_size = bbox.size(); - float depth = 5.0f * (float)std::max(bb_size.x, std::max(bb_size.y, bb_size.z)); + float depth = 5.0f * (float)bbox.max_size(); ::glOrtho(-w2, w2, -h2, h2, -depth, depth); break; @@ -331,6 +336,12 @@ BoundingBoxf3 GLCanvas3D::max_bounding_box() const return bb; } +void GLCanvas3D::register_on_viewport_changed_callback(void* callback) +{ + if (callback != nullptr) + m_on_viewport_changed_callback.register_callback(callback); +} + void GLCanvas3D::on_size(wxSizeEvent& evt) { set_dirty(true); @@ -363,7 +374,24 @@ void GLCanvas3D::_zoom_to_volumes() void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox) { - // >>>>>>>>>>>>>>>>>>>> TODO <<<<<<<<<<<<<<<<<<<<<<<< + // Calculate the zoom factor needed to adjust viewport to bounding box. + float zoom = _get_zoom_to_bounding_box_factor(bbox); + if (zoom > 0.0f) + { + set_camera_zoom(zoom); + // center view around bounding box center + set_camera_target(bbox.center()); + + m_on_viewport_changed_callback.call(); + + if (is_shown_on_screen()) + { + std::pair size = _get_canvas_size(); + resize((unsigned int)size.first, (unsigned int)size.second); + if (m_canvas != nullptr) + m_canvas->Refresh(); + } + } } std::pair GLCanvas3D::_get_canvas_size() const @@ -376,5 +404,96 @@ std::pair GLCanvas3D::_get_canvas_size() const return ret; } +float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const +{ + float max_bb_size = bbox.max_size(); + if (max_bb_size == 0.0f) + return -1.0f; + + // project the bbox vertices on a plane perpendicular to the camera forward axis + // then calculates the vertices coordinate on this plane along the camera xy axes + + // we need the view matrix, we let opengl calculate it(same as done in render sub) + ::glMatrixMode(GL_MODELVIEW); + ::glLoadIdentity(); + + if (TURNTABLE_MODE) + { + // Turntable mode is enabled by default. + ::glRotatef(-get_camera_theta(), 1.0f, 0.0f, 0.0f); // pitch + ::glRotatef(get_camera_phi(), 0.0f, 0.0f, 1.0f); // yaw + } + else + { + // Shift the perspective camera. + Pointf3 camera_pos(0.0, 0.0, -(coordf_t)get_camera_distance()); + ::glTranslatef((float)camera_pos.x, (float)camera_pos.y, (float)camera_pos.z); +// my @rotmat = quat_to_rotmatrix($self->quat); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< TEMPORARY COMMENTED OUT +// glMultMatrixd_p(@rotmat[0..15]); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< TEMPORARY COMMENTED OUT + } + + const Pointf3& target = get_camera_target(); + ::glTranslatef(-(float)target.x, -(float)target.y, -(float)target.z); + + // get the view matrix back from opengl + GLfloat matrix[16]; + ::glGetFloatv(GL_MODELVIEW_MATRIX, matrix); + + // camera axes + Pointf3 right((coordf_t)matrix[0], (coordf_t)matrix[4], (coordf_t)matrix[8]); + Pointf3 up((coordf_t)matrix[1], (coordf_t)matrix[5], (coordf_t)matrix[9]); + Pointf3 forward((coordf_t)matrix[2], (coordf_t)matrix[6], (coordf_t)matrix[10]); + + Pointf3 bb_min = bbox.min; + Pointf3 bb_max = bbox.max; + Pointf3 bb_center = bbox.center(); + + // bbox vertices in world space + std::vector vertices; + vertices.reserve(8); + vertices.push_back(bb_min); + vertices.emplace_back(bb_max.x, bb_min.y, bb_min.z); + vertices.emplace_back(bb_max.x, bb_max.y, bb_min.z); + vertices.emplace_back(bb_min.x, bb_max.y, bb_min.z); + vertices.emplace_back(bb_min.x, bb_min.y, bb_max.z); + vertices.emplace_back(bb_max.x, bb_min.y, bb_max.z); + vertices.push_back(bb_max); + vertices.emplace_back(bb_min.x, bb_max.y, bb_max.z); + + coordf_t max_x = 0.0; + coordf_t max_y = 0.0; + + // margin factor to give some empty space around the bbox + coordf_t margin_factor = 1.25; + + for (const Pointf3 v : vertices) + { + // project vertex on the plane perpendicular to camera forward axis + Pointf3 pos(v.x - bb_center.x, v.y - bb_center.y, v.z - bb_center.z); + Pointf3 proj_on_plane = pos - dot(pos, forward) * forward; + + // calculates vertex coordinate along camera xy axes + coordf_t x_on_plane = dot(proj_on_plane, right); + coordf_t y_on_plane = dot(proj_on_plane, up); + + max_x = std::max(max_x, margin_factor * std::abs(x_on_plane)); + max_y = std::max(max_y, margin_factor * std::abs(y_on_plane)); + } + + if ((max_x == 0.0) || (max_y == 0.0)) + return -1.0f; + + max_x *= 2.0; + max_y *= 2.0; + + std::pair cvs_size = _get_canvas_size(); + return (float)std::min((coordf_t)cvs_size.first / max_x, (coordf_t)cvs_size.second / max_y); +} + +void GLCanvas3D::_deregister_callbacks() +{ + m_on_viewport_changed_callback.deregister_callback(); +} + } // namespace GUI } // namespace Slic3r diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 7a8e763f93..9eda704a1d 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -2,6 +2,7 @@ #define slic3r_GLCanvas3D_hpp_ #include "../../libslic3r/BoundingBox.hpp" +#include "../../libslic3r/Utils.hpp" class wxGLCanvas; class wxGLContext; @@ -85,8 +86,11 @@ private: bool m_dirty; bool m_apply_zoom_to_volumes_filter; + PerlCallback m_on_viewport_changed_callback; + public: GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context); + ~GLCanvas3D(); void set_current(); @@ -125,6 +129,8 @@ public: BoundingBoxf3 volumes_bounding_box() const; BoundingBoxf3 max_bounding_box() const; + void register_on_viewport_changed_callback(void* callback); + void on_size(wxSizeEvent& evt); void on_idle(wxIdleEvent& evt); @@ -133,6 +139,9 @@ private: void _zoom_to_volumes(); void _zoom_to_bounding_box(const BoundingBoxf3& bbox); std::pair _get_canvas_size() const; + float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const; + + void _deregister_callbacks(); }; } // namespace GUI diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index a3036c2ad8..90c72f9504 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -289,6 +289,13 @@ void GLCanvas3DManager::set_camera_target(wxGLCanvas* canvas, const Pointf3* tar it->second->set_camera_target(*target); } +void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->register_on_viewport_changed_callback(callback); +} + GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::_get_canvas(wxGLCanvas* canvas) { return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index c53d6b5d36..a092fcfa53 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -85,6 +85,8 @@ public: Pointf3 get_camera_target(wxGLCanvas* canvas) const; void set_camera_target(wxGLCanvas* canvas, const Pointf3* target); + void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); + private: CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas); CanvasesMap::const_iterator _get_canvas(wxGLCanvas* canvas) const; diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 7e7fbc417b..5e13fed652 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -344,6 +344,12 @@ set_camera_target(canvas, target) CODE: _3DScene::set_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), target); +void +register_on_viewport_changed_callback(canvas, callback) + SV *canvas; + SV *callback; + CODE: + _3DScene::register_on_viewport_changed_callback((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (void*)callback); From 75f1f832aa01af7cf0595ee3e5feef51d45e5d0b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 15 May 2018 11:07:32 +0200 Subject: [PATCH 0337/1150] 3DScene bed origin moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 48 ++++++++++++++++++------- xs/src/slic3r/GUI/3DScene.cpp | 11 ++++++ xs/src/slic3r/GUI/3DScene.hpp | 3 ++ xs/src/slic3r/GUI/GLCanvas3D.cpp | 20 +++++++++++ xs/src/slic3r/GUI/GLCanvas3D.hpp | 7 ++++ xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 13 +++++++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 3 ++ xs/xsp/GUI_3DScene.xsp | 15 ++++++++ 8 files changed, 108 insertions(+), 12 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 67f5866b77..b12f84a94d 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -53,7 +53,6 @@ __PACKAGE__->mk_accessors( qw(_quat init bed_grid_lines bed_polygon background - origin _mouse_pos _hover_volume_idx @@ -997,7 +996,10 @@ sub set_auto_bed_shape { [ $center->x - $max_size, $center->y + $max_size ], #++ ]); # Set the origin for painting of the coordinate system axes. - $self->origin(Slic3r::Pointf->new(@$center[X,Y])); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_bed_origin($self, Slic3r::Pointf->new(@$center[X,Y])); +# $self->origin(Slic3r::Pointf->new(@$center[X,Y])); +#============================================================================================================================== } # Set the bed shape to a single closed 2D polygon (array of two element arrays), @@ -1048,7 +1050,10 @@ sub set_bed_shape { } # Set the origin for painting of the coordinate system axes. - $self->origin(Slic3r::Pointf->new(0,0)); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_bed_origin($self, Slic3r::Pointf->new(0,0)); +# $self->origin(Slic3r::Pointf->new(0,0)); +#============================================================================================================================== $self->bed_polygon(offset_ex([$expolygon->contour], $bed_bb->radius * 1.7, JT_ROUND, scale(0.5))->[0]->contour->clone); } @@ -1548,7 +1553,10 @@ sub Render { # draw axes # disable depth testing so that axes are not covered by ground glDisable(GL_DEPTH_TEST); - my $origin = $self->origin; +#============================================================================================================================== + my $origin = Slic3r::GUI::_3DScene::get_bed_origin($self); +# my $origin = $self->origin; +#============================================================================================================================== my $axis_len = $self->use_plain_shader ? 0.3 * max(@{ $self->bed_bounding_box->size }) : 2 * max(@{ $volumes_bb->size }); glLineWidth(2); glBegin(GL_LINES); @@ -1906,10 +1914,18 @@ sub draw_legend { my ($cw, $ch) = $self->GetSizeWH; - my $l = (-0.5 * $cw) / $self->_zoom; - my $t = (0.5 * $ch) / $self->_zoom; - my $r = $l + $tex_w / $self->_zoom; - my $b = $t - $tex_h / $self->_zoom; +#============================================================================================================================== + my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); + my $l = (-0.5 * $cw) / $zoom; + my $t = (0.5 * $ch) / $zoom; + my $r = $l + $tex_w / $zoom; + my $b = $t - $tex_h / $zoom; + +# my $l = (-0.5 * $cw) / $self->_zoom; +# my $t = (0.5 * $ch) / $self->_zoom; +# my $r = $l + $tex_w / $self->_zoom; +# my $b = $t - $tex_h / $self->_zoom; +#============================================================================================================================== $self->_render_texture($tex_id, $l, $r, $b, $t); glPopMatrix(); @@ -1939,10 +1955,18 @@ sub draw_warning { my ($cw, $ch) = $self->GetSizeWH; - my $l = (-0.5 * $tex_w) / $self->_zoom; - my $t = (-0.5 * $ch + $tex_h) / $self->_zoom; - my $r = $l + $tex_w / $self->_zoom; - my $b = $t - $tex_h / $self->_zoom; +#============================================================================================================================== + my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); + my $l = (-0.5 * $tex_w) / $zoom; + my $t = (-0.5 * $ch + $tex_h) / $zoom; + my $r = $l + $tex_w / $zoom; + my $b = $t - $tex_h / $zoom; + +# my $l = (-0.5 * $tex_w) / $self->_zoom; +# my $t = (-0.5 * $ch + $tex_h) / $self->_zoom; +# my $r = $l + $tex_w / $self->_zoom; +# my $b = $t - $tex_h / $self->_zoom; +#============================================================================================================================== $self->_render_texture($tex_id, $l, $r, $b, $t); glPopMatrix(); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 98326e95e0..c6effb0a9b 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1767,6 +1767,17 @@ void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape) return s_canvas_mgr.set_bed_shape(canvas, shape); } +Pointf _3DScene::get_bed_origin(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_bed_origin(canvas); +} + +void _3DScene::set_bed_origin(wxGLCanvas* canvas, const Pointf* origin) +{ + if (origin != nullptr) + s_canvas_mgr.set_bed_origin(canvas, *origin); +} + BoundingBoxf3 _3DScene::get_bed_bounding_box(wxGLCanvas* canvas) { return s_canvas_mgr.get_bed_bounding_box(canvas); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 66f506a7f8..5c603028d7 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -551,6 +551,9 @@ public: static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); + static Pointf get_bed_origin(wxGLCanvas* canvas); + static void set_bed_origin(wxGLCanvas* canvas, const Pointf* origin); + static BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas); static BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas); static BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index d358ebeca3..487ffbc75d 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -119,6 +119,16 @@ const BoundingBoxf3& GLCanvas3D::Bed::get_bounding_box() const return m_bounding_box; } +const Pointf& GLCanvas3D::Bed::get_origin() const +{ + return m_origin; +} + +void GLCanvas3D::Bed::set_origin(const Pointf& origin) +{ + m_origin = origin; +} + void GLCanvas3D::Bed::_calc_bounding_box() { m_bounding_box = BoundingBoxf3(); @@ -235,6 +245,16 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape) m_bed.set_shape(shape); } +const Pointf& GLCanvas3D::get_bed_origin() const +{ + return m_bed.get_origin(); +} + +void GLCanvas3D::set_bed_origin(const Pointf& origin) +{ + m_bed.set_origin(origin); +} + bool GLCanvas3D::is_dirty() const { return m_dirty; diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 41c0e0b4af..d324215424 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -64,6 +64,7 @@ public: { Pointfs m_shape; BoundingBoxf3 m_bounding_box; + Pointf m_origin; public: const Pointfs& get_shape() const; @@ -71,6 +72,9 @@ public: const BoundingBoxf3& get_bounding_box() const; + const Pointf& get_origin() const; + void set_origin(const Pointf& origin); + private: void _calc_bounding_box(); }; @@ -103,6 +107,9 @@ public: void set_bed_shape(const Pointfs& shape); + const Pointf& get_bed_origin() const; + void set_bed_origin(const Pointf& origin); + bool is_dirty() const; void set_dirty(bool dirty); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 7c0db99d3c..9bde6210dc 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -180,6 +180,19 @@ void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape) it->second->set_bed_shape(shape); } +Pointf GLCanvas3DManager::get_bed_origin(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_bed_origin() : Pointf(); +} + +void GLCanvas3DManager::set_bed_origin(wxGLCanvas* canvas, const Pointf& origin) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_bed_origin(origin); +} + BoundingBoxf3 GLCanvas3DManager::get_bed_bounding_box(wxGLCanvas* canvas) { CanvasesMap::const_iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index d7e8f0b2f0..4edf97dd6d 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -61,6 +61,9 @@ public: void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); + Pointf get_bed_origin(wxGLCanvas* canvas) const; + void set_bed_origin(wxGLCanvas* canvas, const Pointf& origin); + BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas); BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas); BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 4d155816d7..ee1a94cc8b 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -215,6 +215,21 @@ set_bed_shape(canvas, shape) CODE: _3DScene::set_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), shape); +Clone +get_bed_origin(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_bed_origin((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_bed_origin(canvas, origin) + SV *canvas; + Pointf *origin + CODE: + _3DScene::set_bed_origin((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), origin); + Clone get_bed_bounding_box(canvas) SV *canvas; From f0d1888ca9e00f2c68d7b325b073553d49b97aba Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 15 May 2018 11:30:11 +0200 Subject: [PATCH 0338/1150] 3DScene select_view() function moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 55 ++++++++++++------------- xs/src/slic3r/GUI/3DScene.cpp | 5 +++ xs/src/slic3r/GUI/3DScene.hpp | 1 + xs/src/slic3r/GUI/GLCanvas3D.cpp | 40 ++++++++++++++++++ xs/src/slic3r/GUI/GLCanvas3D.hpp | 1 + xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 7 ++++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 1 + xs/xsp/GUI_3DScene.xsp | 7 ++++ 8 files changed, 89 insertions(+), 28 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index b12f84a94d..afe79330de 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -761,41 +761,40 @@ sub set_viewport_from_scene { # zoom to volumes. sub select_view { my ($self, $direction) = @_; - my $dirvec; - if (ref($direction)) { - $dirvec = $direction; - } else { - if ($direction eq 'iso') { - $dirvec = VIEW_DEFAULT; - } elsif ($direction eq 'left') { - $dirvec = VIEW_LEFT; - } elsif ($direction eq 'right') { - $dirvec = VIEW_RIGHT; - } elsif ($direction eq 'top') { - $dirvec = VIEW_TOP; - } elsif ($direction eq 'bottom') { - $dirvec = VIEW_BOTTOM; - } elsif ($direction eq 'front') { - $dirvec = VIEW_FRONT; - } elsif ($direction eq 'rear') { - $dirvec = VIEW_REAR; - } - } - my $bb = $self->volumes_bounding_box; - if (! $bb->empty) { #============================================================================================================================== - Slic3r::GUI::_3DScene::set_camera_phi($self, $dirvec->[0]); - Slic3r::GUI::_3DScene::set_camera_theta($self, $dirvec->[1]); - + Slic3r::GUI::_3DScene::select_view($self, $direction); + +# my $dirvec; +# if (ref($direction)) { +# $dirvec = $direction; +# } else { +# if ($direction eq 'iso') { +# $dirvec = VIEW_DEFAULT; +# } elsif ($direction eq 'left') { +# $dirvec = VIEW_LEFT; +# } elsif ($direction eq 'right') { +# $dirvec = VIEW_RIGHT; +# } elsif ($direction eq 'top') { +# $dirvec = VIEW_TOP; +# } elsif ($direction eq 'bottom') { +# $dirvec = VIEW_BOTTOM; +# } elsif ($direction eq 'front') { +# $dirvec = VIEW_FRONT; +# } elsif ($direction eq 'rear') { +# $dirvec = VIEW_REAR; +# } +# } +# my $bb = $self->volumes_bounding_box; +# if (! $bb->empty) { # $self->_sphi($dirvec->[0]); # $self->_stheta($dirvec->[1]); # # Avoid gimball lock. # $self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX; # $self->_stheta(0) if $self->_stheta < 0; +# $self->on_viewport_changed->() if $self->on_viewport_changed; +# $self->Refresh; +# } #============================================================================================================================== - $self->on_viewport_changed->() if $self->on_viewport_changed; - $self->Refresh; - } } sub get_zoom_to_bounding_box_factor { diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index c6effb0a9b..ed2b7f8b85 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1878,6 +1878,11 @@ void _3DScene::zoom_to_volumes(wxGLCanvas* canvas) s_canvas_mgr.zoom_to_volumes(canvas); } +void _3DScene::select_view(wxGLCanvas* canvas, const std::string& direction) +{ + s_canvas_mgr.select_view(canvas, direction); +} + void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) { s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 5c603028d7..5010d9c2c8 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -582,6 +582,7 @@ public: static void zoom_to_bed(wxGLCanvas* canvas); static void zoom_to_volumes(wxGLCanvas* canvas); + static void select_view(wxGLCanvas* canvas, const std::string& direction); static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 487ffbc75d..940a5b79c2 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -9,6 +9,15 @@ static const bool TURNTABLE_MODE = true; static const float GIMBALL_LOCK_THETA_MAX = 180.0f; +// phi / theta angles to orient the camera. +static const float VIEW_DEFAULT[2] = { 45.0f, 45.0f }; +static const float VIEW_LEFT[2] = { 90.0f, 90.0f }; +static const float VIEW_RIGHT[2] = { -90.0f, 90.0f }; +static const float VIEW_TOP[2] = { 0.0f, 0.0f }; +static const float VIEW_BOTTOM[2] = { 0.0f, 180.0f }; +static const float VIEW_FRONT[2] = { 0.0f, 90.0f }; +static const float VIEW_REAR[2] = { 180.0f, 90.0f }; + namespace Slic3r { namespace GUI { @@ -368,6 +377,37 @@ void GLCanvas3D::zoom_to_volumes() m_apply_zoom_to_volumes_filter = false; } +void GLCanvas3D::select_view(const std::string& direction) +{ + const float* dir_vec = nullptr; + + if (direction == "iso") + dir_vec = VIEW_DEFAULT; + else if (direction == "left") + dir_vec = VIEW_LEFT; + else if (direction == "right") + dir_vec = VIEW_RIGHT; + else if (direction == "top") + dir_vec = VIEW_TOP; + else if (direction == "bottom") + dir_vec = VIEW_BOTTOM; + else if (direction == "front") + dir_vec = VIEW_FRONT; + else if (direction == "rear") + dir_vec = VIEW_REAR; + + if ((dir_vec != nullptr) && !empty(volumes_bounding_box())) + { + m_camera.set_phi(dir_vec[0]); + m_camera.set_theta(dir_vec[1]); + + m_on_viewport_changed_callback.call(); + + if (m_canvas != nullptr) + m_canvas->Refresh(); + } +} + void GLCanvas3D::register_on_viewport_changed_callback(void* callback) { if (callback != nullptr) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index d324215424..7568dec39c 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -138,6 +138,7 @@ public: void zoom_to_bed(); void zoom_to_volumes(); + void select_view(const std::string& direction); void register_on_viewport_changed_callback(void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 9bde6210dc..f5b76fe60f 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -328,6 +328,13 @@ void GLCanvas3DManager::zoom_to_volumes(wxGLCanvas* canvas) it->second->zoom_to_volumes(); } +void GLCanvas3DManager::select_view(wxGLCanvas* canvas, const std::string& direction) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->select_view(direction); +} + void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 4edf97dd6d..c1ce8048c2 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -92,6 +92,7 @@ public: void zoom_to_bed(wxGLCanvas* canvas); void zoom_to_volumes(wxGLCanvas* canvas); + void select_view(wxGLCanvas* canvas, const std::string& direction); void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index ee1a94cc8b..7211cc513e 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -387,6 +387,13 @@ zoom_to_volumes(canvas) CODE: _3DScene::zoom_to_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); +void +select_view(canvas, direction) + SV *canvas; + std::string direction; + CODE: + _3DScene::select_view((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), direction); + void register_on_viewport_changed_callback(canvas, callback) SV *canvas; From 75a0dea93f0bb1f50b526dd52f2fd1a965609054 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 15 May 2018 12:01:33 +0200 Subject: [PATCH 0339/1150] PrusaCollapsiblePanel works correct on MSW now --- xs/src/slic3r/GUI/wxExtensions.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index ace0ad53af..2e0f7c90a5 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -192,6 +192,7 @@ bool PrusaCollapsiblePane::Create(wxWindow *parent, wxWindowID id, const wxStrin m_pDisclosureTriangleButton = new wxButton(this, wxID_ANY, m_strLabel, wxPoint(0, 0), wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); + UpdateBtnBmp(); m_pDisclosureTriangleButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { if (event.GetEventObject() != m_pDisclosureTriangleButton) @@ -207,8 +208,6 @@ bool PrusaCollapsiblePane::Create(wxWindow *parent, wxWindowID id, const wxStrin GetEventHandler()->ProcessEvent(ev); }); - UpdateBtnBmp(); - m_sz->Add(m_pDisclosureTriangleButton, 0, wxLEFT | wxTOP | wxBOTTOM, GetBorder()); // do not set sz as our sizers since we handle the pane window without using sizers @@ -228,11 +227,17 @@ bool PrusaCollapsiblePane::Create(wxWindow *parent, wxWindowID id, const wxStrin void PrusaCollapsiblePane::UpdateBtnBmp() { - IsCollapsed() ? - m_pDisclosureTriangleButton->SetBitmap(m_bmp_close) : + if (IsCollapsed()) + m_pDisclosureTriangleButton->SetBitmap(m_bmp_close); + else{ m_pDisclosureTriangleButton->SetBitmap(m_bmp_open); + // To updating button bitmap it's needed to lost focus on this button, so + // we set focus to mainframe + //GetParent()->GetParent()->GetParent()->SetFocus(); + //or to pane + GetPane()->SetFocus(); + } Layout(); -// m_pDisclosureTriangleButton->Refresh(); } void PrusaCollapsiblePane::Collapse(bool collapse) @@ -246,8 +251,7 @@ void PrusaCollapsiblePane::Collapse(bool collapse) // update our state m_pPane->Show(!collapse); - // update button label -// m_pDisclosureTriangleButton->SetLabel(m_strLabel); + // update button bitmap UpdateBtnBmp(); OnStateChange(GetBestSize()); @@ -256,9 +260,7 @@ void PrusaCollapsiblePane::Collapse(bool collapse) void PrusaCollapsiblePane::SetLabel(const wxString &label) { m_strLabel = label; - m_pDisclosureTriangleButton->SetLabel(m_strLabel); - Layout(); } From a612b5b64821e9468ed0bfe9ed1fefa67e3aad5c Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 15 May 2018 12:19:43 +0200 Subject: [PATCH 0340/1150] Replacement of xml escape characters when exporting to amf --- xs/src/libslic3r/Format/AMF.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Format/AMF.cpp b/xs/src/libslic3r/Format/AMF.cpp index b446f456b2..83b50ec9e6 100644 --- a/xs/src/libslic3r/Format/AMF.cpp +++ b/xs/src/libslic3r/Format/AMF.cpp @@ -674,6 +674,33 @@ bool load_amf(const char *path, PresetBundle* bundle, Model *model) return false; } +std::string xml_escape(std::string text) +{ + std::string::size_type pos = 0; + for (;;) + { + pos = text.find_first_of("\"\'&<>", pos); + if (pos == std::string::npos) + break; + + std::string replacement; + switch (text[pos]) + { + case '\"': replacement = """; break; + case '\'': replacement = "'"; break; + case '&': replacement = "&"; break; + case '<': replacement = "<"; break; + case '>': replacement = ">"; break; + default: break; + } + + text.replace(pos, 1, replacement); + pos += replacement.size(); + } + + return text; +} + bool store_amf(const char *path, Model *model, Print* print, bool export_print_config) { if ((path == nullptr) || (model == nullptr) || (print == nullptr)) @@ -701,7 +728,7 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c { std::string config = "\n"; GCode::append_full_config(*print, config); - stream << "" << config << "\n"; + stream << "" << xml_escape(config) << "\n"; } for (const auto &material : model->materials) { From 7645e9cb7a884a4722324b7b5a839424291299fb Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 15 May 2018 14:04:29 +0200 Subject: [PATCH 0341/1150] Added layer_num, layer_z variables to the end_gcode, end_filament_gcode, added min(.,.), max(.,.) functions to the placeholder parser syntax. --- t/custom_gcode.t | 6 +++- xs/src/libslic3r/GCode.cpp | 19 +++++++----- xs/src/libslic3r/PlaceholderParser.cpp | 41 ++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/t/custom_gcode.t b/t/custom_gcode.t index 7c2a75f293..4c1c1b108e 100644 --- a/t/custom_gcode.t +++ b/t/custom_gcode.t @@ -1,4 +1,4 @@ -use Test::More tests => 77; +use Test::More tests => 81; use strict; use warnings; @@ -71,6 +71,10 @@ use Slic3r::Test; is $parser->process('{2*foo*(3-12)}'), '0', 'math: 2*foo*(3-12)'; is $parser->process('{2*bar*(3-12)}'), '-36', 'math: 2*bar*(3-12)'; ok abs($parser->process('{2.5*bar*(3-12)}') - -45) < 1e-7, 'math: 2.5*bar*(3-12)'; + is $parser->process('{min(12, 14)}'), '12', 'math: min(12, 14)'; + is $parser->process('{max(12, 14)}'), '14', 'math: max(12, 14)'; + is $parser->process('{min(13.4, -1238.1)}'), '-1238.1', 'math: min(13.4, -1238.1)'; + is $parser->process('{max(13.4, -1238.1)}'), '13.4', 'math: max(13.4, -1238.1)'; # Test the boolean expression parser. is $parser->evaluate_boolean_expression('12 == 12'), 1, 'boolean expression parser: 12 == 12'; diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index dc8e5d6918..5e5b74efcb 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -789,14 +789,19 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) } // Process filament-specific gcode in extruder order. - if (print.config.single_extruder_multi_material) { - // Process the end_filament_gcode for the active filament only. - _writeln(file, this->placeholder_parser_process("end_filament_gcode", print.config.end_filament_gcode.get_at(m_writer.extruder()->id()), m_writer.extruder()->id())); - } else { - for (const std::string &end_gcode : print.config.end_filament_gcode.values) - _writeln(file, this->placeholder_parser_process("end_filament_gcode", end_gcode, (unsigned int)(&end_gcode - &print.config.end_filament_gcode.values.front()))); + { + DynamicConfig config; + config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index)); + config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position().z - m_config.z_offset.value)); + if (print.config.single_extruder_multi_material) { + // Process the end_filament_gcode for the active filament only. + _writeln(file, this->placeholder_parser_process("end_filament_gcode", print.config.end_filament_gcode.get_at(m_writer.extruder()->id()), m_writer.extruder()->id(), &config)); + } else { + for (const std::string &end_gcode : print.config.end_filament_gcode.values) + _writeln(file, this->placeholder_parser_process("end_filament_gcode", end_gcode, (unsigned int)(&end_gcode - &print.config.end_filament_gcode.values.front(), &config))); + } + _writeln(file, this->placeholder_parser_process("end_gcode", print.config.end_gcode, m_writer.extruder()->id(), &config)); } - _writeln(file, this->placeholder_parser_process("end_gcode", print.config.end_gcode, m_writer.extruder()->id())); _write(file, m_writer.update_progress(m_layer_count, m_layer_count, true)); // 100% _write(file, m_writer.postamble()); diff --git a/xs/src/libslic3r/PlaceholderParser.cpp b/xs/src/libslic3r/PlaceholderParser.cpp index 62b5169356..80740b20d9 100644 --- a/xs/src/libslic3r/PlaceholderParser.cpp +++ b/xs/src/libslic3r/PlaceholderParser.cpp @@ -414,6 +414,7 @@ namespace client lhs.type = TYPE_BOOL; lhs.data.b = invert ? ! value : value; } + // Compare operators, store the result into lhs. static void equal (expr &lhs, expr &rhs) { compare_op(lhs, rhs, '=', false); } static void not_equal(expr &lhs, expr &rhs) { compare_op(lhs, rhs, '=', true ); } static void lower (expr &lhs, expr &rhs) { compare_op(lhs, rhs, '<', false); } @@ -421,6 +422,40 @@ namespace client static void leq (expr &lhs, expr &rhs) { compare_op(lhs, rhs, '>', true ); } static void geq (expr &lhs, expr &rhs) { compare_op(lhs, rhs, '<', true ); } + enum Function2ParamsType { + FUNCTION_MIN, + FUNCTION_MAX, + }; + // Store the result into param1. + static void function_2params(expr ¶m1, expr ¶m2, Function2ParamsType fun) + { + const char *err_msg = "Not a numeric type."; + param1.throw_if_not_numeric(err_msg); + param2.throw_if_not_numeric(err_msg); + if (param1.type == TYPE_DOUBLE || param2.type == TYPE_DOUBLE) { + double d = 0.; + switch (fun) { + case FUNCTION_MIN: d = std::min(param1.as_d(), param2.as_d()); break; + case FUNCTION_MAX: d = std::max(param1.as_d(), param2.as_d()); break; + default: param1.throw_exception("Internal error: invalid function"); + } + param1.data.d = d; + param1.type = TYPE_DOUBLE; + } else { + int i = 0.; + switch (fun) { + case FUNCTION_MIN: i = std::min(param1.as_i(), param2.as_i()); break; + case FUNCTION_MAX: i = std::max(param1.as_i(), param2.as_i()); break; + default: param1.throw_exception("Internal error: invalid function"); + } + param1.data.i = i; + param1.type = TYPE_INT; + } + } + // Store the result into param1. + static void min(expr ¶m1, expr ¶m2) { function_2params(param1, param2, FUNCTION_MIN); } + static void max(expr ¶m1, expr ¶m2) { function_2params(param1, param2, FUNCTION_MAX); } + static void regex_op(expr &lhs, boost::iterator_range &rhs, char op) { const std::string *subject = nullptr; @@ -1019,6 +1054,10 @@ namespace client | (lit('-') > unary_expression(_r1) ) [ px::bind(&FactorActions::minus_, _1, _val) ] | (lit('+') > unary_expression(_r1) > iter_pos) [ px::bind(&FactorActions::expr_, _1, _2, _val) ] | ((kw["not"] | '!') > unary_expression(_r1) > iter_pos) [ px::bind(&FactorActions::not_, _1, _val) ] + | (kw["min"] > '(' > conditional_expression(_r1) [_val = _1] > ',' > conditional_expression(_r1) > ')') + [ px::bind(&expr::min, _val, _2) ] + | (kw["max"] > '(' > conditional_expression(_r1) [_val = _1] > ',' > conditional_expression(_r1) > ')') + [ px::bind(&expr::max, _val, _2) ] | (strict_double > iter_pos) [ px::bind(&FactorActions::double_, _1, _2, _val) ] | (int_ > iter_pos) [ px::bind(&FactorActions::int_, _1, _2, _val) ] | (kw[bool_] > iter_pos) [ px::bind(&FactorActions::bool_, _1, _2, _val) ] @@ -1051,6 +1090,8 @@ namespace client ("elsif") ("endif") ("false") + ("min") + ("max") ("not") ("or") ("true"); From 4b87f71bbc46e2b974850fab2846c2dfadd70fd2 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 15 May 2018 14:20:32 +0200 Subject: [PATCH 0342/1150] Fix of the previous commmit. gcc and clang rightfully complained about a typo. --- xs/src/libslic3r/GCode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 5e5b74efcb..b581b3e76a 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -798,7 +798,7 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) _writeln(file, this->placeholder_parser_process("end_filament_gcode", print.config.end_filament_gcode.get_at(m_writer.extruder()->id()), m_writer.extruder()->id(), &config)); } else { for (const std::string &end_gcode : print.config.end_filament_gcode.values) - _writeln(file, this->placeholder_parser_process("end_filament_gcode", end_gcode, (unsigned int)(&end_gcode - &print.config.end_filament_gcode.values.front(), &config))); + _writeln(file, this->placeholder_parser_process("end_filament_gcode", end_gcode, (unsigned int)(&end_gcode - &print.config.end_filament_gcode.values.front()), &config)); } _writeln(file, this->placeholder_parser_process("end_gcode", print.config.end_gcode, m_writer.extruder()->id(), &config)); } From 2b4829a4b9605194076c48778f03f4592c28c04b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 15 May 2018 15:38:25 +0200 Subject: [PATCH 0343/1150] 3DScene bed variables moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 241 +++++++++++----------- lib/Slic3r/GUI/Plater/3D.pm | 5 +- lib/Slic3r/GUI/Plater/3DPreview.pm | 5 +- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 5 +- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 5 +- xs/src/slic3r/GUI/3DScene.cpp | 30 ++- xs/src/slic3r/GUI/3DScene.hpp | 9 +- xs/src/slic3r/GUI/GLCanvas3D.cpp | 197 +++++++++++++++++- xs/src/slic3r/GUI/GLCanvas3D.hpp | 34 ++- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 40 ++-- xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 9 +- xs/xsp/GUI_3DScene.xsp | 12 ++ 12 files changed, 425 insertions(+), 167 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index afe79330de..89e46a55db 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -48,10 +48,6 @@ __PACKAGE__->mk_accessors( qw(_quat init volumes cutting_plane_z cut_lines_vertices - bed_shape - bed_triangles - bed_grid_lines - bed_polygon background _mouse_pos _hover_volume_idx @@ -124,14 +120,16 @@ use constant SELECTED_COLOR => [0,1,0,1]; # For mesh selection: Mouse hovers over the object, but object not selected yet - dark green. use constant HOVER_COLOR => [0.4,0.9,0,1]; -# phi / theta angles to orient the camera. -use constant VIEW_DEFAULT => [45.0,45.0]; -use constant VIEW_LEFT => [90.0,90.0]; -use constant VIEW_RIGHT => [-90.0,90.0]; -use constant VIEW_TOP => [0.0,0.0]; -use constant VIEW_BOTTOM => [0.0,180.0]; -use constant VIEW_FRONT => [0.0,90.0]; -use constant VIEW_REAR => [180.0,90.0]; +#============================================================================================================================== +## phi / theta angles to orient the camera. +#use constant VIEW_DEFAULT => [45.0,45.0]; +#use constant VIEW_LEFT => [90.0,90.0]; +#use constant VIEW_RIGHT => [-90.0,90.0]; +#use constant VIEW_TOP => [0.0,0.0]; +#use constant VIEW_BOTTOM => [0.0,180.0]; +#use constant VIEW_FRONT => [0.0,90.0]; +#use constant VIEW_REAR => [180.0,90.0]; +#============================================================================================================================== use constant MANIPULATION_IDLE => 0; use constant MANIPULATION_DRAGGING => 1; @@ -547,17 +545,21 @@ sub mouse_event { $self->mouse_to_3d($e->GetX, $e->GetY, 0), $self->mouse_to_3d($e->GetX, $e->GetY, 1)) ->intersect_plane($self->_drag_start_pos->z); - # Clip the new position, so the object center remains close to the bed. - { - $cur_pos->translate(@{$self->_drag_volume_center_offset}); - my $cur_pos2 = Slic3r::Point->new(scale($cur_pos->x), scale($cur_pos->y)); - if (! $self->bed_polygon->contains_point($cur_pos2)) { - my $ip = $self->bed_polygon->point_projection($cur_pos2); - $cur_pos->set_x(unscale($ip->x)); - $cur_pos->set_y(unscale($ip->y)); - } - $cur_pos->translate(@{$self->_drag_volume_center_offset->negative}); - } +#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +# >>>>>>>>>>>>>>>>>>>>>>>>>> TEMPORARY DISABLED DUE TO bed_polygon REMOVAL <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +# +# # Clip the new position, so the object center remains close to the bed. +# { +# $cur_pos->translate(@{$self->_drag_volume_center_offset}); +# my $cur_pos2 = Slic3r::Point->new(scale($cur_pos->x), scale($cur_pos->y)); +# if (! $self->bed_polygon->contains_point($cur_pos2)) { +# my $ip = $self->bed_polygon->point_projection($cur_pos2); +# $cur_pos->set_x(unscale($ip->x)); +# $cur_pos->set_y(unscale($ip->y)); +# } +# $cur_pos->translate(@{$self->_drag_volume_center_offset->negative}); +# } +#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ # Calculate the translation vector. my $vector = $self->_drag_start_pos->vector_to($cur_pos); # Get the volume being dragged. @@ -980,83 +982,76 @@ sub max_bounding_box { #============================================================================================================================== } -# Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane -# to support the scene objects. -sub set_auto_bed_shape { - my ($self, $bed_shape) = @_; - - # draw a default square bed around object center - my $max_size = max(@{ $self->volumes_bounding_box->size }); - my $center = $self->volumes_bounding_box->center; - $self->set_bed_shape([ - [ $center->x - $max_size, $center->y - $max_size ], #-- - [ $center->x + $max_size, $center->y - $max_size ], #-- - [ $center->x + $max_size, $center->y + $max_size ], #++ - [ $center->x - $max_size, $center->y + $max_size ], #++ - ]); - # Set the origin for painting of the coordinate system axes. #============================================================================================================================== - Slic3r::GUI::_3DScene::set_bed_origin($self, Slic3r::Pointf->new(@$center[X,Y])); +## Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane +## to support the scene objects. +#sub set_auto_bed_shape { +# my ($self, $bed_shape) = @_; +# +# # draw a default square bed around object center +# my $max_size = max(@{ $self->volumes_bounding_box->size }); +# my $center = $self->volumes_bounding_box->center; +# $self->set_bed_shape([ +# [ $center->x - $max_size, $center->y - $max_size ], #-- +# [ $center->x + $max_size, $center->y - $max_size ], #-- +# [ $center->x + $max_size, $center->y + $max_size ], #++ +# [ $center->x - $max_size, $center->y + $max_size ], #++ +# ]); +# # Set the origin for painting of the coordinate system axes. # $self->origin(Slic3r::Pointf->new(@$center[X,Y])); -#============================================================================================================================== -} - -# Set the bed shape to a single closed 2D polygon (array of two element arrays), -# triangulate the bed and store the triangles into $self->bed_triangles, -# fills the $self->bed_grid_lines and sets $self->origin. -# Sets $self->bed_polygon to limit the object placement. -sub set_bed_shape { - my ($self, $bed_shape) = @_; - - $self->bed_shape($bed_shape); -#============================================================================================================================== - Slic3r::GUI::_3DScene::set_bed_shape($self, $bed_shape); -#============================================================================================================================== - - # triangulate bed - my $expolygon = Slic3r::ExPolygon->new([ map [map scale($_), @$_], @$bed_shape ]); - my $bed_bb = $expolygon->bounding_box; - - { - my @points = (); - foreach my $triangle (@{ $expolygon->triangulate }) { - push @points, map {+ unscale($_->x), unscale($_->y), GROUND_Z } @$triangle; - } - $self->bed_triangles(OpenGL::Array->new_list(GL_FLOAT, @points)); - } - - { - my @polylines = (); - for (my $x = $bed_bb->x_min; $x <= $bed_bb->x_max; $x += scale 10) { - push @polylines, Slic3r::Polyline->new([$x,$bed_bb->y_min], [$x,$bed_bb->y_max]); - } - for (my $y = $bed_bb->y_min; $y <= $bed_bb->y_max; $y += scale 10) { - push @polylines, Slic3r::Polyline->new([$bed_bb->x_min,$y], [$bed_bb->x_max,$y]); - } - # clip with a slightly grown expolygon because our lines lay on the contours and - # may get erroneously clipped - my @lines = map Slic3r::Line->new(@$_[0,-1]), - @{intersection_pl(\@polylines, [ @{$expolygon->offset(+scaled_epsilon)} ])}; - - # append bed contours - push @lines, map @{$_->lines}, @$expolygon; - - my @points = (); - foreach my $line (@lines) { - push @points, map {+ unscale($_->x), unscale($_->y), GROUND_Z } @$line; #)) - } - $self->bed_grid_lines(OpenGL::Array->new_list(GL_FLOAT, @points)); - } - - # Set the origin for painting of the coordinate system axes. -#============================================================================================================================== - Slic3r::GUI::_3DScene::set_bed_origin($self, Slic3r::Pointf->new(0,0)); +#} +# +## Set the bed shape to a single closed 2D polygon (array of two element arrays), +## triangulate the bed and store the triangles into $self->bed_triangles, +## fills the $self->bed_grid_lines and sets $self->origin. +## Sets $self->bed_polygon to limit the object placement. +#sub set_bed_shape { +# my ($self, $bed_shape) = @_; +# +# $self->bed_shape($bed_shape); +# +# # triangulate bed +# my $expolygon = Slic3r::ExPolygon->new([ map [map scale($_), @$_], @$bed_shape ]); +# my $bed_bb = $expolygon->bounding_box; +# +# { +# my @points = (); +# foreach my $triangle (@{ $expolygon->triangulate }) { +# push @points, map {+ unscale($_->x), unscale($_->y), GROUND_Z } @$triangle; +# } +# $self->bed_triangles(OpenGL::Array->new_list(GL_FLOAT, @points)); +# } +# +# { +# my @polylines = (); +# for (my $x = $bed_bb->x_min; $x <= $bed_bb->x_max; $x += scale 10) { +# push @polylines, Slic3r::Polyline->new([$x,$bed_bb->y_min], [$x,$bed_bb->y_max]); +# } +# for (my $y = $bed_bb->y_min; $y <= $bed_bb->y_max; $y += scale 10) { +# push @polylines, Slic3r::Polyline->new([$bed_bb->x_min,$y], [$bed_bb->x_max,$y]); +# } +# # clip with a slightly grown expolygon because our lines lay on the contours and +# # may get erroneously clipped +# my @lines = map Slic3r::Line->new(@$_[0,-1]), +# @{intersection_pl(\@polylines, [ @{$expolygon->offset(+scaled_epsilon)} ])}; +# +# # append bed contours +# push @lines, map @{$_->lines}, @$expolygon; +# +# my @points = (); +# foreach my $line (@lines) { +# push @points, map {+ unscale($_->x), unscale($_->y), GROUND_Z } @$line; #)) +# } +# $self->bed_grid_lines(OpenGL::Array->new_list(GL_FLOAT, @points)); +# } +# +# # Set the origin for painting of the coordinate system axes. # $self->origin(Slic3r::Pointf->new(0,0)); +# +# $self->bed_polygon(offset_ex([$expolygon->contour], $bed_bb->radius * 1.7, JT_ROUND, scale(0.5))->[0]->contour->clone); +#} #============================================================================================================================== - $self->bed_polygon(offset_ex([$expolygon->contour], $bed_bb->radius * 1.7, JT_ROUND, scale(0.5))->[0]->contour->clone); -} - sub deselect_volumes { my ($self) = @_; $_->set_selected(0) for @{$self->volumes}; @@ -1518,33 +1513,37 @@ sub Render { # draw ground my $ground_z = GROUND_Z; - if ($self->bed_triangles) { - glDisable(GL_DEPTH_TEST); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnableClientState(GL_VERTEX_ARRAY); - glColor4f(0.8, 0.6, 0.5, 0.4); - glNormal3d(0,0,1); - glVertexPointer_c(3, GL_FLOAT, 0, $self->bed_triangles->ptr()); - glDrawArrays(GL_TRIANGLES, 0, $self->bed_triangles->elements / 3); - glDisableClientState(GL_VERTEX_ARRAY); - - # we need depth test for grid, otherwise it would disappear when looking - # the object from below - glEnable(GL_DEPTH_TEST); +#============================================================================================================================== + Slic3r::GUI::_3DScene::render($self); - # draw grid - glLineWidth(3); - glColor4f(0.2, 0.2, 0.2, 0.4); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer_c(3, GL_FLOAT, 0, $self->bed_grid_lines->ptr()); - glDrawArrays(GL_LINES, 0, $self->bed_grid_lines->elements / 3); - glDisableClientState(GL_VERTEX_ARRAY); - - glDisable(GL_BLEND); - } +# if ($self->bed_triangles) { +# glDisable(GL_DEPTH_TEST); +# +# glEnable(GL_BLEND); +# glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +# +# glEnableClientState(GL_VERTEX_ARRAY); +# glColor4f(0.8, 0.6, 0.5, 0.4); +# glNormal3d(0,0,1); +# glVertexPointer_c(3, GL_FLOAT, 0, $self->bed_triangles->ptr()); +# glDrawArrays(GL_TRIANGLES, 0, $self->bed_triangles->elements / 3); +# glDisableClientState(GL_VERTEX_ARRAY); +# +# # we need depth test for grid, otherwise it would disappear when looking +# # the object from below +# glEnable(GL_DEPTH_TEST); +# +# # draw grid +# glLineWidth(3); +# glColor4f(0.2, 0.2, 0.2, 0.4); +# glEnableClientState(GL_VERTEX_ARRAY); +# glVertexPointer_c(3, GL_FLOAT, 0, $self->bed_grid_lines->ptr()); +# glDrawArrays(GL_LINES, 0, $self->bed_grid_lines->elements / 3); +# glDisableClientState(GL_VERTEX_ARRAY); +# +# glDisable(GL_BLEND); +# } +#============================================================================================================================== my $volumes_bb = $self->volumes_bounding_box; diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index c9c9542762..2706df509f 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -255,7 +255,10 @@ sub reload_scene { sub update_bed_size { my ($self) = @_; - $self->set_bed_shape($self->{config}->bed_shape); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_bed_shape($self, $self->{config}->bed_shape); +# $self->set_bed_shape($self->{config}->bed_shape); +#============================================================================================================================== } # Called by the Platter wxNotebook when this page is activated. diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index b746de98f4..88aab7786e 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -474,7 +474,10 @@ sub set_z_idx_high sub set_bed_shape { my ($self, $bed_shape) = @_; - $self->canvas->set_bed_shape($bed_shape); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_bed_shape($self->canvas, $bed_shape); +# $self->canvas->set_bed_shape($bed_shape); +#============================================================================================================================== } sub set_number_extruders { diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index f0f50a4f3f..6d3234ff3f 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -113,7 +113,10 @@ sub new { if ($Slic3r::GUI::have_OpenGL) { $canvas = $self->{canvas} = Slic3r::GUI::3DScene->new($self); $canvas->load_object($self->{model_object}, undef, undef, [0]); - $canvas->set_auto_bed_shape; +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas); +# $canvas->set_auto_bed_shape; +#============================================================================================================================== $canvas->SetSize([500,500]); $canvas->SetMinSize($canvas->GetSize); } diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 322491f9ec..ee1bf22d10 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -160,7 +160,10 @@ sub new { }); $canvas->load_object($self->{model_object}, undef, undef, [0]); - $canvas->set_auto_bed_shape; +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas); +# $canvas->set_auto_bed_shape; +#============================================================================================================================== $canvas->SetSize([500,700]); $canvas->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index ed2b7f8b85..f5193668b4 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1747,6 +1747,16 @@ void _3DScene::resize(wxGLCanvas* canvas, unsigned int w, unsigned int h) s_canvas_mgr.resize(canvas, w, h); } +bool _3DScene::is_dirty(wxGLCanvas* canvas) +{ + return s_canvas_mgr.is_dirty(canvas); +} + +void _3DScene::set_dirty(wxGLCanvas* canvas, bool dirty) +{ + s_canvas_mgr.set_dirty(canvas, dirty); +} + bool _3DScene::is_shown_on_screen(wxGLCanvas* canvas) { return s_canvas_mgr.is_shown_on_screen(canvas); @@ -1767,6 +1777,11 @@ void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape) return s_canvas_mgr.set_bed_shape(canvas, shape); } +void _3DScene::set_auto_bed_shape(wxGLCanvas* canvas) +{ + return s_canvas_mgr.set_auto_bed_shape(canvas); +} + Pointf _3DScene::get_bed_origin(wxGLCanvas* canvas) { return s_canvas_mgr.get_bed_origin(canvas); @@ -1793,16 +1808,6 @@ BoundingBoxf3 _3DScene::get_max_bounding_box(wxGLCanvas* canvas) return s_canvas_mgr.get_max_bounding_box(canvas); } -bool _3DScene::is_dirty(wxGLCanvas* canvas) -{ - return s_canvas_mgr.is_dirty(canvas); -} - -void _3DScene::set_dirty(wxGLCanvas* canvas, bool dirty) -{ - s_canvas_mgr.set_dirty(canvas, dirty); -} - unsigned int _3DScene::get_camera_type(wxGLCanvas* canvas) { return s_canvas_mgr.get_camera_type(canvas); @@ -1883,6 +1888,11 @@ void _3DScene::select_view(wxGLCanvas* canvas, const std::string& direction) s_canvas_mgr.select_view(canvas, direction); } +void _3DScene::render(wxGLCanvas* canvas) +{ + s_canvas_mgr.render(canvas); +} + void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) { s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 5010d9c2c8..8d6345f971 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -544,12 +544,16 @@ public: static void resize(wxGLCanvas* canvas, unsigned int w, unsigned int h); + static bool is_dirty(wxGLCanvas* canvas); + static void set_dirty(wxGLCanvas* canvas, bool dirty); + static bool is_shown_on_screen(wxGLCanvas* canvas); static GLVolumeCollection* get_volumes(wxGLCanvas* canvas); static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes); static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); + static void set_auto_bed_shape(wxGLCanvas* canvas); static Pointf get_bed_origin(wxGLCanvas* canvas); static void set_bed_origin(wxGLCanvas* canvas, const Pointf* origin); @@ -558,9 +562,6 @@ public: static BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas); static BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); - static bool is_dirty(wxGLCanvas* canvas); - static void set_dirty(wxGLCanvas* canvas, bool dirty); - static unsigned int get_camera_type(wxGLCanvas* canvas); static void set_camera_type(wxGLCanvas* canvas, unsigned int type); static std::string get_camera_type_as_string(wxGLCanvas* canvas); @@ -584,6 +585,8 @@ public: static void zoom_to_volumes(wxGLCanvas* canvas); static void select_view(wxGLCanvas* canvas, const std::string& direction); + static void render(wxGLCanvas* canvas); + static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); // static void _glew_init(); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 940a5b79c2..2e4b15af4b 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -1,6 +1,7 @@ #include "GLCanvas3D.hpp" #include "../../slic3r/GUI/3DScene.hpp" +#include "../../libslic3r/ClipperUtils.hpp" #include @@ -8,6 +9,7 @@ static const bool TURNTABLE_MODE = true; static const float GIMBALL_LOCK_THETA_MAX = 180.0f; +static const float GROUND_Z = -0.02f; // phi / theta angles to orient the camera. static const float VIEW_DEFAULT[2] = { 45.0f, 45.0f }; @@ -21,6 +23,65 @@ static const float VIEW_REAR[2] = { 180.0f, 90.0f }; namespace Slic3r { namespace GUI { +bool GeometryBuffer::set_from_triangles(const Polygons& triangles, float z) +{ + m_data.clear(); + + unsigned int size = 9 * (unsigned int)triangles.size(); + if (size == 0) + return false; + + m_data = std::vector(size, 0.0f); + + unsigned int coord = 0; + for (const Polygon& t : triangles) + { + for (unsigned int v = 0; v < 3; ++v) + { + const Point& p = t.points[v]; + m_data[coord++] = (float)unscale(p.x); + m_data[coord++] = (float)unscale(p.y); + m_data[coord++] = z; + } + } + + return true; +} + +bool GeometryBuffer::set_from_lines(const Lines& lines, float z) +{ + m_data.clear(); + + unsigned int size = 6 * (unsigned int)lines.size(); + if (size == 0) + return false; + + m_data = std::vector(size, 0.0f); + + unsigned int coord = 0; + for (const Line& l : lines) + { + m_data[coord++] = (float)unscale(l.a.x); + m_data[coord++] = (float)unscale(l.a.y); + m_data[coord++] = z; + m_data[coord++] = (float)unscale(l.b.x); + m_data[coord++] = (float)unscale(l.b.y); + m_data[coord++] = z; + } + + return true; +} + +const float* GeometryBuffer::get_data() const +{ + return m_data.data(); +} + +unsigned int GeometryBuffer::get_data_size() const +{ + return (unsigned int)m_data.size(); +} + GLCanvas3D::Camera::Camera() : m_type(CT_Ortho) , m_zoom(1.0f) @@ -120,7 +181,23 @@ const Pointfs& GLCanvas3D::Bed::get_shape() const void GLCanvas3D::Bed::set_shape(const Pointfs& shape) { m_shape = shape; + _calc_bounding_box(); + + ExPolygon poly; + for (const Pointf& p : m_shape) + { + poly.contour.append(Point(scale_(p.x), scale_(p.y))); + } + + _calc_triangles(poly); + + const BoundingBox& bed_bbox = poly.contour.bounding_box(); + _calc_gridlines(poly, bed_bbox); + + m_polygon = offset_ex(poly.contour, bed_bbox.radius() * 1.7, jtRound, scale_(0.5))[0].contour; + + set_origin(Pointf(0.0, 0.0)); } const BoundingBoxf3& GLCanvas3D::Bed::get_bounding_box() const @@ -138,6 +215,43 @@ void GLCanvas3D::Bed::set_origin(const Pointf& origin) m_origin = origin; } +void GLCanvas3D::Bed::render() +{ + unsigned int triangles_vcount = m_triangles.get_data_size() / 3; + if (triangles_vcount > 0) + { + ::glDisable(GL_DEPTH_TEST); + + ::glEnable(GL_BLEND); + ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + ::glEnableClientState(GL_VERTEX_ARRAY); + + ::glColor4f(0.8f, 0.6f, 0.5f, 0.4f); + ::glNormal3d(0.0f, 0.0f, 1.0f); + ::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_triangles.get_data()); + ::glDrawArrays(GL_TRIANGLES, 0, triangles_vcount); +// ::glDisableClientState(GL_VERTEX_ARRAY); + + // we need depth test for grid, otherwise it would disappear when looking + // the object from below + glEnable(GL_DEPTH_TEST); + + // draw grid + unsigned int gridlines_vcount = m_gridlines.get_data_size() / 3; + + ::glLineWidth(3.0f); + ::glColor4f(0.2f, 0.2f, 0.2f, 0.4f); +// ::glEnableClientState(GL_VERTEX_ARRAY); + ::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_gridlines.get_data()); + ::glDrawArrays(GL_LINES, 0, gridlines_vcount); + + ::glDisableClientState(GL_VERTEX_ARRAY); + + ::glDisable(GL_BLEND); + } +} + void GLCanvas3D::Bed::_calc_bounding_box() { m_bounding_box = BoundingBoxf3(); @@ -147,6 +261,44 @@ void GLCanvas3D::Bed::_calc_bounding_box() } } +void GLCanvas3D::Bed::_calc_triangles(const ExPolygon& poly) +{ + Polygons triangles; + poly.triangulate(&triangles); + + if (!m_triangles.set_from_triangles(triangles, GROUND_Z)) + printf("Unable to create bed triangles\n"); +} + +void GLCanvas3D::Bed::_calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox) +{ + Polylines axes_lines; + for (coord_t x = bed_bbox.min.x; x <= bed_bbox.max.x; x += scale_(10.0)) + { + Polyline line; + line.append(Point(x, bed_bbox.min.y)); + line.append(Point(x, bed_bbox.max.y)); + axes_lines.push_back(line); + } + for (coord_t y = bed_bbox.min.y; y <= bed_bbox.max.y; y += scale_(10.0)) + { + Polyline line; + line.append(Point(bed_bbox.min.x, y)); + line.append(Point(bed_bbox.max.x, y)); + axes_lines.push_back(line); + } + + // clip with a slightly grown expolygon because our lines lay on the contours and may get erroneously clipped + Lines gridlines = to_lines(intersection_pl(axes_lines, offset(poly, SCALED_EPSILON))); + + // append bed contours + Lines contour_lines = to_lines(poly); + std::copy(contour_lines.begin(), contour_lines.end(), std::back_inserter(gridlines)); + + if (!m_gridlines.set_from_lines(gridlines, GROUND_Z)) + printf("Unable to create bed grid lines\n"); +} + GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) : m_canvas(canvas) , m_context(context) @@ -167,6 +319,16 @@ void GLCanvas3D::set_current() m_canvas->SetCurrent(*m_context); } +bool GLCanvas3D::is_dirty() const +{ + return m_dirty; +} + +void GLCanvas3D::set_dirty(bool dirty) +{ + m_dirty = dirty; +} + bool GLCanvas3D::is_shown_on_screen() const { return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false; @@ -254,6 +416,26 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape) m_bed.set_shape(shape); } +void GLCanvas3D::set_auto_bed_shape() +{ + // draw a default square bed around object center + const BoundingBoxf3& bbox = volumes_bounding_box(); + coordf_t max_size = bbox.max_size(); + const Pointf3& center = bbox.center(); + + Pointfs bed_shape; + bed_shape.reserve(4); + bed_shape.emplace_back(center.x - max_size, center.y - max_size); + bed_shape.emplace_back(center.x + max_size, center.y - max_size); + bed_shape.emplace_back(center.x + max_size, center.y + max_size); + bed_shape.emplace_back(center.x - max_size, center.y + max_size); + + set_bed_shape(bed_shape); + + // Set the origin for painting of the coordinate system axes. + set_bed_origin(Pointf(center.x, center.y)); +} + const Pointf& GLCanvas3D::get_bed_origin() const { return m_bed.get_origin(); @@ -264,16 +446,6 @@ void GLCanvas3D::set_bed_origin(const Pointf& origin) m_bed.set_origin(origin); } -bool GLCanvas3D::is_dirty() const -{ - return m_dirty; -} - -void GLCanvas3D::set_dirty(bool dirty) -{ - m_dirty = dirty; -} - GLCanvas3D::Camera::EType GLCanvas3D::get_camera_type() const { return m_camera.get_type(); @@ -408,6 +580,11 @@ void GLCanvas3D::select_view(const std::string& direction) } } +void GLCanvas3D::render() +{ + m_bed.render(); +} + void GLCanvas3D::register_on_viewport_changed_callback(void* callback) { if (callback != nullptr) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 7568dec39c..f3b459b968 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -12,9 +12,22 @@ class wxIdleEvent; namespace Slic3r { class GLVolumeCollection; +class ExPolygon; namespace GUI { +class GeometryBuffer +{ + std::vector m_data; + +public: + bool set_from_triangles(const Polygons& triangles, float z); + bool set_from_lines(const Lines& lines, float z); + + const float* get_data() const; + unsigned int get_data_size() const; +}; + class GLCanvas3D { public: @@ -65,6 +78,9 @@ public: Pointfs m_shape; BoundingBoxf3 m_bounding_box; Pointf m_origin; + Polygon m_polygon; + GeometryBuffer m_triangles; + GeometryBuffer m_gridlines; public: const Pointfs& get_shape() const; @@ -75,8 +91,12 @@ public: const Pointf& get_origin() const; void set_origin(const Pointf& origin); + void render(); + private: void _calc_bounding_box(); + void _calc_triangles(const ExPolygon& poly); + void _calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); }; private: @@ -98,6 +118,9 @@ public: void set_current(); + bool is_dirty() const; + void set_dirty(bool dirty); + bool is_shown_on_screen() const; void resize(unsigned int w, unsigned int h); @@ -105,14 +128,17 @@ public: GLVolumeCollection* get_volumes(); void set_volumes(GLVolumeCollection* volumes); + // Set the bed shape to a single closed 2D polygon(array of two element arrays), + // triangulate the bed and store the triangles into m_bed.m_triangles, + // fills the m_bed.m_grid_lines and sets m_bed.m_origin. + // Sets m_bed.m_polygon to limit the object placement. void set_bed_shape(const Pointfs& shape); + // Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane to support the scene objects. + void set_auto_bed_shape(); const Pointf& get_bed_origin() const; void set_bed_origin(const Pointf& origin); - bool is_dirty() const; - void set_dirty(bool dirty); - Camera::EType get_camera_type() const; void set_camera_type(Camera::EType type); std::string get_camera_type_as_string() const; @@ -140,6 +166,8 @@ public: void zoom_to_volumes(); void select_view(const std::string& direction); + void render(); + void register_on_viewport_changed_callback(void* callback); void on_size(wxSizeEvent& evt); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index f5b76fe60f..f4b367c95b 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -147,6 +147,19 @@ bool GLCanvas3DManager::layer_editing_allowed() const return m_layer_editing.allowed; } +bool GLCanvas3DManager::is_dirty(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->is_dirty() : false; +} + +void GLCanvas3DManager::set_dirty(wxGLCanvas* canvas, bool dirty) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_dirty(dirty); +} + bool GLCanvas3DManager::is_shown_on_screen(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); @@ -180,6 +193,13 @@ void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape) it->second->set_bed_shape(shape); } +void GLCanvas3DManager::set_auto_bed_shape(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_auto_bed_shape(); +} + Pointf GLCanvas3DManager::get_bed_origin(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); @@ -211,19 +231,6 @@ BoundingBoxf3 GLCanvas3DManager::get_max_bounding_box(wxGLCanvas* canvas) return (it != m_canvases.end()) ? it->second->max_bounding_box() : BoundingBoxf3(); } -bool GLCanvas3DManager::is_dirty(wxGLCanvas* canvas) const -{ - CanvasesMap::const_iterator it = _get_canvas(canvas); - return (it != m_canvases.end()) ? it->second->is_dirty() : false; -} - -void GLCanvas3DManager::set_dirty(wxGLCanvas* canvas, bool dirty) -{ - CanvasesMap::iterator it = _get_canvas(canvas); - if (it != m_canvases.end()) - it->second->set_dirty(dirty); -} - unsigned int GLCanvas3DManager::get_camera_type(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); @@ -335,6 +342,13 @@ void GLCanvas3DManager::select_view(wxGLCanvas* canvas, const std::string& direc it->second->select_view(direction); } +void GLCanvas3DManager::render(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->render(); +} + void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index c1ce8048c2..bf0b9c0668 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -52,6 +52,9 @@ public: bool use_VBOs() const; bool layer_editing_allowed() const; + bool is_dirty(wxGLCanvas* canvas) const; + void set_dirty(wxGLCanvas* canvas, bool dirty); + bool is_shown_on_screen(wxGLCanvas* canvas) const; void resize(wxGLCanvas* canvas, unsigned int w, unsigned int h); @@ -60,6 +63,7 @@ public: void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes); void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); + void set_auto_bed_shape(wxGLCanvas* canvas); Pointf get_bed_origin(wxGLCanvas* canvas) const; void set_bed_origin(wxGLCanvas* canvas, const Pointf& origin); @@ -68,9 +72,6 @@ public: BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas); BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); - bool is_dirty(wxGLCanvas* canvas) const; - void set_dirty(wxGLCanvas* canvas, bool dirty); - unsigned int get_camera_type(wxGLCanvas* canvas) const; void set_camera_type(wxGLCanvas* canvas, unsigned int type); std::string get_camera_type_as_string(wxGLCanvas* canvas) const; @@ -94,6 +95,8 @@ public: void zoom_to_volumes(wxGLCanvas* canvas); void select_view(wxGLCanvas* canvas, const std::string& direction); + void render(wxGLCanvas* canvas); + void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); private: diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 7211cc513e..c62c7e9581 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -215,6 +215,12 @@ set_bed_shape(canvas, shape) CODE: _3DScene::set_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), shape); +void +set_auto_bed_shape(canvas) + SV *canvas; + CODE: + _3DScene::set_auto_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + Clone get_bed_origin(canvas) SV *canvas; @@ -393,6 +399,12 @@ select_view(canvas, direction) std::string direction; CODE: _3DScene::select_view((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), direction); + +void +render(canvas) + SV *canvas; + CODE: + _3DScene::render((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); void register_on_viewport_changed_callback(canvas, callback) From 41c51d761446214866c5551c373984e6f77ea2c9 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 15 May 2018 16:09:04 +0200 Subject: [PATCH 0344/1150] 3DScene's char event handler moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 62 +++++++++++++------------ xs/src/slic3r/GUI/GLCanvas3D.cpp | 35 ++++++++++++++ xs/src/slic3r/GUI/GLCanvas3D.hpp | 2 + xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 1 + 4 files changed, 70 insertions(+), 30 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 89e46a55db..a654f6554f 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -244,36 +244,38 @@ sub new { #============================================================================================================================== EVT_MOUSEWHEEL($self, \&mouse_wheel_event); EVT_MOUSE_EVENTS($self, \&mouse_event); -# EVT_KEY_DOWN($self, sub { - EVT_CHAR($self, sub { - my ($s, $event) = @_; - if ($event->HasModifiers) { - $event->Skip; - } else { - my $key = $event->GetKeyCode; - if ($key == ord('0')) { - $self->select_view('iso'); - } elsif ($key == ord('1')) { - $self->select_view('top'); - } elsif ($key == ord('2')) { - $self->select_view('bottom'); - } elsif ($key == ord('3')) { - $self->select_view('front'); - } elsif ($key == ord('4')) { - $self->select_view('rear'); - } elsif ($key == ord('5')) { - $self->select_view('left'); - } elsif ($key == ord('6')) { - $self->select_view('right'); - } elsif ($key == ord('z')) { - $self->zoom_to_volumes; - } elsif ($key == ord('b')) { - $self->zoom_to_bed; - } else { - $event->Skip; - } - } - }); +#============================================================================================================================== +## EVT_KEY_DOWN($self, sub { +# EVT_CHAR($self, sub { +# my ($s, $event) = @_; +# if ($event->HasModifiers) { +# $event->Skip; +# } else { +# my $key = $event->GetKeyCode; +# if ($key == ord('0')) { +# $self->select_view('iso'); +# } elsif ($key == ord('1')) { +# $self->select_view('top'); +# } elsif ($key == ord('2')) { +# $self->select_view('bottom'); +# } elsif ($key == ord('3')) { +# $self->select_view('front'); +# } elsif ($key == ord('4')) { +# $self->select_view('rear'); +# } elsif ($key == ord('5')) { +# $self->select_view('left'); +# } elsif ($key == ord('6')) { +# $self->select_view('right'); +# } elsif ($key == ord('z')) { +# $self->zoom_to_volumes; +# } elsif ($key == ord('b')) { +# $self->zoom_to_bed; +# } else { +# $event->Skip; +# } +# } +# }); +#============================================================================================================================== $self->{layer_height_edit_timer_id} = &Wx::NewId(); $self->{layer_height_edit_timer} = Wx::Timer->new($self, $self->{layer_height_edit_timer_id}); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 2e4b15af4b..4a5a97c95e 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -609,6 +609,41 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt) } } +void GLCanvas3D::on_char(wxKeyEvent& evt) +{ + if (evt.HasModifiers()) + evt.Skip(); + else + { + int keyCode = evt.GetKeyCode(); + switch (keyCode - 48) + { + // numerical input + case 0: { select_view("iso"); break; } + case 1: { select_view("top"); break; } + case 2: { select_view("bottom"); break; } + case 3: { select_view("front"); break; } + case 4: { select_view("rear"); break; } + case 5: { select_view("left"); break; } + case 6: { select_view("right"); break; } + default: + { + // text input + switch (keyCode) + { + // key B/b + case 66: + case 98: { zoom_to_bed(); break; } + // key Z/z + case 90: + case 122: { zoom_to_volumes(); break; } + default: { evt.Skip(); break; } + } + } + } + } +} + void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox) { // Calculate the zoom factor needed to adjust viewport to bounding box. diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index f3b459b968..507964136e 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -8,6 +8,7 @@ class wxGLCanvas; class wxGLContext; class wxSizeEvent; class wxIdleEvent; +class wxKeyEvent; namespace Slic3r { @@ -172,6 +173,7 @@ public: void on_size(wxSizeEvent& evt); void on_idle(wxIdleEvent& evt); + void on_char(wxKeyEvent& evt); private: void _zoom_to_bounding_box(const BoundingBoxf3& bbox); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index f4b367c95b..61867c61ca 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -79,6 +79,7 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas, wxGLContext* context) canvas->Bind(wxEVT_SIZE, [canvas3D](wxSizeEvent& evt) { canvas3D->on_size(evt); }); canvas->Bind(wxEVT_IDLE, [canvas3D](wxIdleEvent& evt) { canvas3D->on_idle(evt); }); + canvas->Bind(wxEVT_CHAR, [canvas3D](wxKeyEvent& evt) { canvas3D->on_char(evt); }); m_canvases.insert(CanvasesMap::value_type(canvas, canvas3D)); From d9ff63c0222623a8c8a449f7f10351e3dc346223 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 15 May 2018 18:01:47 +0200 Subject: [PATCH 0345/1150] Basic svg export ported from perl to the point where actual svg is assembled. Empty PNG files are genereted for each sliced layer. --- lib/Slic3r/GUI/MainFrame.pm | 19 ++++- lib/Slic3r/Print.pm | 10 +++ lib/Slic3r/Print/Simple.pm | 10 +++ xs/src/libslic3r/Print.cpp | 164 +++++++++++++++++++++++++++++++++++- xs/src/libslic3r/Print.hpp | 14 ++- xs/xsp/Print.xsp | 3 + 6 files changed, 216 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index fbcd34a3f6..b9572ad621 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -9,7 +9,7 @@ use File::Basename qw(basename dirname); use FindBin; use List::Util qw(min first); use Slic3r::Geometry qw(X Y); -use Wx qw(:frame :bitmap :id :misc :notebook :panel :sizer :menu :dialog :filedialog +use Wx qw(:frame :bitmap :id :misc :notebook :panel :sizer :menu :dialog :filedialog :dirdialog :font :icon wxTheApp); use Wx::Event qw(EVT_CLOSE EVT_COMMAND EVT_MENU EVT_NOTEBOOK_PAGE_CHANGED); use base 'Wx::Frame'; @@ -230,6 +230,9 @@ sub _init_menubar { $self->_append_menu_item($fileMenu, L("Slice to SV&G…\tCtrl+G"), L('Slice file to a multi-layer SVG'), sub { $self->quick_slice(save_as => 1, export_svg => 1); }, undef, 'shape_handles.png'); + $self->_append_menu_item($fileMenu, L("Slice to PNG…"), L('Slice file to a set of PNG files'), sub { + $self->quick_slice(save_as => 0, export_png => 1); + }, undef, 'shape_handles.png'); $self->{menu_item_reslice_now} = $self->_append_menu_item( $fileMenu, L("(&Re)Slice Now\tCtrl+S"), L('Start new slicing process'), sub { $self->reslice_now; }, undef, 'shape_handles.png'); @@ -453,6 +456,14 @@ sub quick_slice { $qs_last_output_file = $output_file unless $params{export_svg}; wxTheApp->{app_config}->update_last_output_dir(dirname($output_file)); $dlg->Destroy; + } elsif($params{export_png}) { + my $dlg = Wx::DirDialog->new($self, L('Choose output directory')); + if ($dlg->ShowModal != wxID_OK) { + $dlg->Destroy; + return; + } + $output_file = $dlg->GetPath; + $dlg->Destroy; } # show processbar dialog @@ -467,7 +478,11 @@ sub quick_slice { $sprint->output_file($output_file); if ($params{export_svg}) { $sprint->export_svg; - } else { + } + elsif($params{export_png}) { + $sprint->export_png; + } + else { $sprint->export_gcode; } $sprint->status_cb(undef); diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 8300fdbede..fc28a192eb 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -109,6 +109,16 @@ sub export_gcode { } } +sub export_png { + my $self = shift; + my %params = @_; + + $_->slice for @{$self->objects}; + + my $fh = $params{output_file}; + $self->print_to_png($fh); +} + # Export SVG slices for the offline SLA printing. # The export_svg is expected to be executed inside an eval block. sub export_svg { diff --git a/lib/Slic3r/Print/Simple.pm b/lib/Slic3r/Print/Simple.pm index 4fe3eb820b..b171e65363 100644 --- a/lib/Slic3r/Print/Simple.pm +++ b/lib/Slic3r/Print/Simple.pm @@ -121,4 +121,14 @@ sub export_svg { $self->_after_export; } +sub export_png { + my ($self) = @_; + + $self->_before_export; + + $self->_print->export_png(output_file => $self->output_file); + + $self->_after_export; +} + 1; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 80f68c51b6..8a96654481 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -11,6 +11,11 @@ #include #include +// For png export of the sliced model +#include +#include +#include + namespace Slic3r { template class PrintState; @@ -444,7 +449,7 @@ bool Print::apply_config(DynamicPrintConfig config) const ModelVolume &volume = *object->model_object()->volumes[volume_id]; if (this_region_config_set) { // If the new config for this volume differs from the other - // volume configs currently associated to this region, it means + // volume configs currently associated to this region, it means // the region subdivision does not make sense anymore. if (! this_region_config.equals(this->_region_config_from_model_volume(volume))) { rearrange_regions = true; @@ -1242,4 +1247,161 @@ void Print::set_status(int percent, const std::string &message) printf("Print::status %d => %s\n", percent, message.c_str()); } +template +class FilePrinter { +public: + void drawPolygon(const ExPolygon& p); + void save(const std::string& path); +}; + +template<> +class FilePrinter { + wxBitmap bitmap_; + wxMemoryDC dc_; + std::unique_ptr gc_; +public: + inline FilePrinter(unsigned width, unsigned height): + bitmap_(width, height), + dc_(bitmap_), + gc_(wxGraphicsContext::Create(dc_)) { + gc_->SetAntialiasMode(wxANTIALIAS_DEFAULT); + } + + void drawPolygon(const ExPolygon& p) { + gc_->SetPen( *wxRED_PEN ); + std::vector points; + points.reserve(p.contour.points.size()); + for(auto pp : p.contour.points) points.emplace_back(pp.x, pp.y); + gc_->DrawLines(points.size(), points.data()); + } + + void save(const std::string& path) { + if(!bitmap_.SaveFile(path, wxBITMAP_TYPE_PNG)) { + std::cout << "fail for " << path << std::endl; + } + } +}; + +template +void Print::print_to(std::string dirpath, Args...args) +{ + + std::string dir = dirpath; + +#ifdef WIN32 + if(dir.back() != '\\') dir.push_back('\\'); +#else + if(dir.back() != '/') dir.push_back('/'); +#endif + + FilePrinter printer(std::forward(args)...); + + LayerPtrs layers; + + std::for_each(objects.begin(), objects.end(), [&layers](PrintObject *o){ + layers.insert(layers.end(), o->layers.begin(), o->layers.end()); + layers.insert(layers.end(), o->support_layers.begin(), + o->support_layers.end()); + }); + + std::sort(layers.begin(), layers.end(), [](Layer *l1, Layer *l2){ + return l1->print_z < l2->print_z; + }); + +// auto printSlice = [&printer](ExPolygon path) { + +// }; + + int layer_id = -1; + ExPolygons previous_layer_slices; + auto print_bb = bounding_box(); + + for(auto lp : layers) { + Layer& l = *lp; + ++layer_id; + + auto slices = l.slices; + using Sl = ExPolygons::value_type; + std::sort(slices.expolygons.begin(), + slices.expolygons.end(), + [](Sl a, Sl b){ + return a.contains(b.contour.first_point()) ? false : true; + }); + + ExPolygons current_layer_slices; + + // please enable C++14 ... + std::for_each(l.object()->_shifted_copies.begin(), + l.object()->_shifted_copies.end(), + [&] (Point d) + { + std::for_each(slices.expolygons.begin(), + slices.expolygons.end(), + [&] (ExPolygon slice) + { + slice.translate(d.x, d.y); + slice.translate(-print_bb.min.x, -print_bb.min.y); + printer.drawPolygon(slice); + // $print_polygon->($expolygon->contour, 'contour'); + // $print_polygon->($_, 'hole') for @{$expolygon->holes}; + current_layer_slices.push_back(slice); + }); + }); + + printer.save(dir + "layer" + std::to_string(layer_id) + ".png"); + +// layer_id++; +// if ($layer->slice_z == -1) { +// printf $fh qq{ \n}, $layer_id; +// } else { +// printf $fh qq{ \n}, $layer_id, unscale($layer->slice_z); +// } + +// my @current_layer_slices = (); +// # sort slices so that the outermost ones come first +// my @slices = sort { $a->contour->contains_point($b->contour->first_point) ? 0 : 1 } @{$layer->slices}; +// foreach my $copy (@{$layer->object->_shifted_copies}) { +// foreach my $slice (@slices) { +// my $expolygon = $slice->clone; +// $expolygon->translate(@$copy); +// $expolygon->translate(-$print_bb->x_min, -$print_bb->y_min); +// $print_polygon->($expolygon->contour, 'contour'); +// $print_polygon->($_, 'hole') for @{$expolygon->holes}; +// push @current_layer_slices, $expolygon; +// } +// } +// # generate support material +// if ($self->has_support_material && $layer->id > 0) { +// my (@supported_slices, @unsupported_slices) = (); +// foreach my $expolygon (@current_layer_slices) { +// my $intersection = intersection_ex( +// [ map @$_, @previous_layer_slices ], +// [ @$expolygon ], +// ); +// @$intersection +// ? push @supported_slices, $expolygon +// : push @unsupported_slices, $expolygon; +// } +// my @supported_points = map @$_, @$_, @supported_slices; +// foreach my $expolygon (@unsupported_slices) { +// # look for the nearest point to this island among all +// # supported points +// my $contour = $expolygon->contour; +// my $support_point = $contour->first_point->nearest_point(\@supported_points) +// or next; +// my $anchor_point = $support_point->nearest_point([ @$contour ]); +// printf $fh qq{ \n}, +// map @$_, $support_point, $anchor_point; +// } +// } +// print $fh qq{ \n}; +// @previous_layer_slices = @current_layer_slices; + previous_layer_slices = current_layer_slices; + } +} + +void Print::print_to_png(std::string dirpath) { + print_to(dirpath, 800, 600); +} + } diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index c56e64c6c4..01561dad36 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -309,7 +309,19 @@ public: void restart() { m_canceled = false; } // Has the calculation been canceled? bool canceled() { return m_canceled; } - + + enum class FilePrinterFormat { + PNG, + SVG + }; + + void print_to_png(std::string dirpath); + +private: + + template + void print_to(std::string dirpath, Args...args); + private: bool invalidate_state_by_config_options(const std::vector &opt_keys); PrintRegionConfig _region_config_from_model_volume(const ModelVolume &volume); diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index ef9c5345f4..0e3c9b7a1d 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -215,6 +215,9 @@ _constant() croak("%s\n", e.what()); } %}; + + + void print_to_png(std::string dirpath); void add_model_object(ModelObject* model_object, int idx = -1); bool apply_config(DynamicPrintConfig* config) From 5c44453ced6a1b80061220bbc79d754a4f4a6b8e Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 16 May 2018 10:11:00 +0200 Subject: [PATCH 0346/1150] Fixed loading of configuration files after reverting to a snapshot storing the old configuration format. --- xs/src/slic3r/GUI/PresetBundle.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 63b6a4e0ce..84fa3a92f5 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -210,6 +210,10 @@ std::string PresetBundle::load_system_presets() errors_cummulative += "\n"; } } + if (first) { + // No config bundle loaded, reset. + this->reset(false); + } return errors_cummulative; } From a97226ae54fc28c6bff790a51f45842868105478 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 15 May 2018 12:14:26 +0200 Subject: [PATCH 0347/1150] PresetUpdater: Fix: Don't offer updates on legacy datadir --- xs/src/slic3r/Utils/PresetUpdater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 3b74b0c6b4..fcbe20fb7f 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -136,7 +136,7 @@ void PresetUpdater::priv::set_download_prefs(AppConfig *app_config) { enabled_version_check = app_config->get("version_check") == "1"; version_check_url = app_config->version_check_url(); - enabled_config_update = app_config->get("preset_update") == "1"; + enabled_config_update = app_config->get("preset_update") == "1" && !app_config->legacy_datadir(); } // Downloads a file (http get operation). Cancels if the Updater is being destroyed. From 0b4a61a8bad7d507a6ad93314346a879682a2b5c Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 16 May 2018 12:16:30 +0200 Subject: [PATCH 0348/1150] Fix of https://github.com/prusa3d/Slic3r/issues/791 The preset names have to be set at the PlaceholderParser before querying Print for a recommended file name. --- lib/Slic3r/GUI/Plater.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index eb655ae55a..9d546db9dc 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1375,6 +1375,8 @@ sub export_gcode { }; Slic3r::GUI::catch_error($self) and return; + # Copy the names of active presets into the placeholder parser. + wxTheApp->{preset_bundle}->export_selections_pp($self->{print}->placeholder_parser); # select output file if ($output_file) { $self->{export_gcode_output_file} = eval { $self->{print}->output_filepath($output_file) }; @@ -1666,6 +1668,8 @@ sub _get_export_file { $suffix = '.3mf'; $wildcard = 'threemf'; } + # Copy the names of active presets into the placeholder parser. + wxTheApp->{preset_bundle}->export_selections_pp($self->{print}->placeholder_parser); my $output_file = eval { $self->{print}->output_filepath($main::opt{output} // '') }; Slic3r::GUI::catch_error($self) and return undef; $output_file =~ s/\.[gG][cC][oO][dD][eE]$/$suffix/; From b8fe48c56339333f67b33c2d9cfa612997a96d09 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 16 May 2018 13:56:03 +0200 Subject: [PATCH 0349/1150] Modification of the AboutDialog to be correct showing on dark theme of Linux --- xs/src/slic3r/GUI/AboutDialog.cpp | 50 ++++++++++++++++++------------- xs/src/slic3r/GUI/Field.cpp | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/xs/src/slic3r/GUI/AboutDialog.cpp b/xs/src/slic3r/GUI/AboutDialog.cpp index e3c4528725..0fed8d1751 100644 --- a/xs/src/slic3r/GUI/AboutDialog.cpp +++ b/xs/src/slic3r/GUI/AboutDialog.cpp @@ -29,20 +29,27 @@ void AboutDialogLogo::onRepaint(wxEvent &event) } AboutDialog::AboutDialog() - : wxDialog(NULL, wxID_ANY, _(L("About Slic3r")), wxDefaultPosition, wxSize(600, 340), wxCAPTION) + : wxDialog(NULL, wxID_ANY, _(L("About Slic3r")), wxDefaultPosition, wxDefaultSize, wxCAPTION) { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)/**wxWHITE*/); + wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); + SetBackgroundColour(bgr_clr); wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL); - this->SetSizer(hsizer); + + auto main_sizer = new wxBoxSizer(wxVERTICAL); + main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20); // logo -// AboutDialogLogo* logo = new AboutDialogLogo(this); wxBitmap logo_bmp = wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG); auto *logo = new wxStaticBitmap(this, wxID_ANY, std::move(logo_bmp)); - hsizer->Add(logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 30); + hsizer->Add(logo, 1, wxALIGN_CENTRE_VERTICAL | wxEXPAND | wxTOP | wxBOTTOM, 35); wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); - hsizer->Add(vsizer, 1, wxEXPAND, 0); +#ifdef __WXMSW__ + int proportion = 2; +#else + int proportion = 3; +#endif + hsizer->Add(vsizer, proportion, wxEXPAND|wxLEFT, 20); // title { @@ -52,7 +59,7 @@ AboutDialog::AboutDialog() title_font.SetFamily(wxFONTFAMILY_ROMAN); title_font.SetPointSize(24); title->SetFont(title_font); - vsizer->Add(title, 0, wxALIGN_LEFT | wxTOP, 30); + vsizer->Add(title, 0, wxALIGN_LEFT | wxTOP, 10); } // version @@ -70,34 +77,34 @@ AboutDialog::AboutDialog() } // text - wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER); + wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO/*NEVER*/); { wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - #ifdef __WXMSW__ - int size[] = {8,8,8,8,8,8,8}; - #else - int size[] = {11,11,11,11,11,11,11}; - #endif + const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue()); + auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()); + + const int fs = font.GetPointSize()-1; + int size[] = {fs,fs,fs,fs,fs,fs,fs}; html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); - html->SetHTMLBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); html->SetBorders(2); - const char* text = + const auto text = wxString::Format( "" - "" - "" + "" + "" "Copyright © 2016-2018 Prusa Research.
" "Copyright © 2011-2017 Alessandro Ranellucci.
" "
Slic3r is licensed under the " "GNU Affero General Public License, version 3." - "


" + "

" "Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others. " "Manual by Gary Hodgson. Inspired by the RepRap community.
" "Slic3r logo designed by Corey Daniels, Silk Icon Set designed by Mark James. " "
" "" - ""; + "", bgr_clr_str, text_clr_str, text_clr_str); html->SetPage(text); - vsizer->Add(html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 20); + vsizer->Add(html, 1, wxEXPAND | wxBOTTOM, 10); html->Bind(wxEVT_HTML_LINK_CLICKED, &AboutDialog::onLinkClicked, this); } @@ -108,6 +115,9 @@ AboutDialog::AboutDialog() this->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this); logo->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this); + + SetSizer(main_sizer); + main_sizer->SetSizeHints(this); } void AboutDialog::onLinkClicked(wxHtmlLinkEvent &event) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 4febae3621..64f3426c48 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -106,7 +106,7 @@ namespace Slic3r { namespace GUI { } double val; str.ToCDouble(&val); - if (m_opt.min > val && val > m_opt.max) + if (m_opt.min > val || val > m_opt.max) { show_error(m_parent, _(L("Input value is out of range"))); if (m_opt.min > val) val = m_opt.min; From 146a02a300f90562e353c294278dbd47879767d7 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 16 May 2018 14:38:37 +0200 Subject: [PATCH 0350/1150] Added view mode selection to the config_menu --- xs/src/slic3r/GUI/GUI.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 2d487edd58..f97f7e31e9 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -378,12 +378,20 @@ void get_installed_languages(wxArrayString & names, } } +std::string get_view_mode() +{ + return g_AppConfig->has("view_mode") ? + g_AppConfig->get("view_mode") : "simple"; +} + enum ConfigMenuIDs { ConfigMenuWizard, ConfigMenuSnapshots, ConfigMenuTakeSnapshot, ConfigMenuUpdate, ConfigMenuPreferences, + ConfigMenuModeSimple, + ConfigMenuModeExpert, ConfigMenuLanguage, ConfigMenuCnt, }; @@ -402,7 +410,14 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences"))+"\u2026\tCtrl+,", _(L("Application preferences"))); local_menu->AppendSeparator(); - local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); + auto mode_menu = new wxMenu(); + mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("&Simple")), _(L("Simple View Mode"))); + mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeExpert, _(L("&Expert")), _(L("Expert View Mode"))); + if (get_view_mode() == "expert") + mode_menu->Check(config_id_base + ConfigMenuModeExpert, true); + local_menu->AppendSubMenu(mode_menu, _(L("&Mode")), _(L("Slic3r View Mode"))); + local_menu->AppendSeparator(); + local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ switch (event.GetId() - config_id_base) { case ConfigMenuWizard: @@ -457,8 +472,21 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l } } break; - } } + } + }); + mode_menu->Bind(wxEVT_MENU, [config_id_base](wxEvent& event) { + std::string mode = ""; + switch (event.GetId() - config_id_base){ + case ConfigMenuModeExpert: + mode = "expert"; + break; + case ConfigMenuModeSimple: + mode = "simple"; + break; + } + g_AppConfig->set("view_mode", mode); + g_AppConfig->save(); }); menu->Append(local_menu, _(L("&Configuration"))); } From 687c91d6e965065af4e39589c7713df23a9cd078 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 16 May 2018 16:34:07 +0200 Subject: [PATCH 0351/1150] Parsing of obsolete presets from Config Bundle to remove them from user's profile when upgrading to a new configuration structure. --- resources/profiles/PrusaResearch.ini | 5 +++++ xs/src/slic3r/GUI/PresetBundle.cpp | 24 +++++++++++++++++++++++- xs/src/slic3r/GUI/PresetBundle.hpp | 7 +++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index ba8e55ad41..a28405921b 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -1030,3 +1030,8 @@ max_print_height = 210 start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} printer_model = MK3 default_print_profile = 0.15mm OPTIMAL 0.6 nozzle MK3 + +# The obsolete presets will be removed when upgrading from the legacy configuration structure (up to Slic3r 1.39.2) to 1.40.0 and newer. +[obsolete_presets] +print="0.05mm DETAIL 0.25 nozzle";"0.05mm DETAIL MK3";"0.05mm DETAIL";"0.20mm NORMAL MK3";"0.35mm FAST MK3" +filament="ColorFabb Brass Bronze 1.75mm";"ColorFabb HT 1.75mm";"ColorFabb nGen 1.75mm";"ColorFabb Woodfil 1.75mm";"ColorFabb XT 1.75mm";"ColorFabb XT-CF20 1.75mm";"E3D PC-ABS 1.75mm";"Fillamentum ABS 1.75mm";"Fillamentum ASA 1.75mm";"Generic ABS 1.75mm";"Generic PET 1.75mm";"Generic PLA 1.75mm";"Prusa ABS 1.75mm";"Prusa HIPS 1.75mm";"Prusa PET 1.75mm";"Prusa PLA 1.75mm";"Taulman Bridge 1.75mm";"Taulman T-Glase 1.75mm" diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index 84fa3a92f5..ef48eb6d4a 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -104,6 +104,9 @@ void PresetBundle::reset(bool delete_files) this->printers .reset(delete_files); this->filament_presets.clear(); this->filament_presets.emplace_back(this->filaments.get_selected_preset().name); + this->obsolete_presets.prints.clear(); + this->obsolete_presets.filaments.clear(); + this->obsolete_presets.printers.clear(); } void PresetBundle::setup_directories() @@ -224,7 +227,10 @@ std::vector PresetBundle::merge_presets(PresetBundle &&other) std::vector duplicate_prints = this->prints .merge_presets(std::move(other.prints), this->vendors); std::vector duplicate_filaments = this->filaments.merge_presets(std::move(other.filaments), this->vendors); std::vector duplicate_printers = this->printers .merge_presets(std::move(other.printers), this->vendors); - append(duplicate_prints, std::move(duplicate_filaments)); + append(this->obsolete_presets.prints, std::move(other.obsolete_presets.prints)); + append(this->obsolete_presets.filaments, std::move(other.obsolete_presets.filaments)); + append(this->obsolete_presets.printers, std::move(other.obsolete_presets.printers)); + append(duplicate_prints, std::move(duplicate_filaments)); append(duplicate_prints, std::move(duplicate_printers)); return duplicate_prints; } @@ -365,6 +371,7 @@ DynamicPrintConfig PresetBundle::full_config() const } else { // Retrieve filament presets and build a single config object for them. // First collect the filament configurations based on the user selection of this->filament_presets. + // Here this->filaments.find_preset() and this->filaments.first_visible() return the edited copy of the preset if active. std::vector filament_configs; for (const std::string &filament_preset_name : this->filament_presets) filament_configs.emplace_back(&this->filaments.find_preset(filament_preset_name, true)->config); @@ -760,6 +767,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla flatten_configbundle_hierarchy(tree); // 2) Parse the property_tree, extract the active preset names and the profiles, save them into local config files. + // Parse the obsolete preset names, to be deleted when upgrading from the old configuration structure. std::vector loaded_prints; std::vector loaded_filaments; std::vector loaded_printers; @@ -799,6 +807,20 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla active_printer = kvp.second.data(); } } + } else if (section.first == "obsolete_presets") { + // Parse the names of obsolete presets. These presets will be deleted from user's + // profile directory on installation of this vendor preset. + for (auto &kvp : section.second) { + std::vector *dst = nullptr; + if (kvp.first == "print") + dst = &this->obsolete_presets.prints; + else if (kvp.first == "filament") + dst = &this->obsolete_presets.filaments; + else if (kvp.first == "printer") + dst = &this->obsolete_presets.printers; + if (dst) + unescape_strings_cstyle(kvp.second.data(), *dst); + } } else if (section.first == "settings") { // Load the settings. for (auto &kvp : section.second) { diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp index 9f2afbead2..a5c5682f94 100644 --- a/xs/src/slic3r/GUI/PresetBundle.hpp +++ b/xs/src/slic3r/GUI/PresetBundle.hpp @@ -54,6 +54,13 @@ public: // and the system profiles will point to the VendorProfile instances owned by PresetBundle::vendors. std::set vendors; + struct ObsoletePresets { + std::vector prints; + std::vector filaments; + std::vector printers; + }; + ObsoletePresets obsolete_presets; + bool has_defauls_only() const { return prints.size() <= 1 && filaments.size() <= 1 && printers.size() <= 1; } From e1b9c13024f82ebcb047b2e181f279f052059de3 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 16 May 2018 18:51:28 +0200 Subject: [PATCH 0352/1150] Rasterizer skeleton --- xs/CMakeLists.txt | 14 +++ xs/src/libslic3r/Print.cpp | 124 +++++++++++++-------- xs/src/libslic3r/Print.hpp | 12 +- xs/src/libslic3r/Rasterizer/Rasterizer.cpp | 40 +++++++ xs/src/libslic3r/Rasterizer/Rasterizer.hpp | 43 +++++++ 5 files changed, 184 insertions(+), 49 deletions(-) create mode 100644 xs/src/libslic3r/Rasterizer/Rasterizer.cpp create mode 100644 xs/src/libslic3r/Rasterizer/Rasterizer.hpp diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 4f44fc7bf7..f2c44dde84 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -167,6 +167,7 @@ add_library(libslic3r STATIC ${LIBDIR}/libslic3r/TriangleMesh.hpp # ${LIBDIR}/libslic3r/utils.cpp ${LIBDIR}/libslic3r/Utils.hpp + ) add_library(libslic3r_gui STATIC @@ -331,6 +332,19 @@ add_library(semver STATIC ${LIBDIR}/semver/semver.c ) + +find_package(PNG REQUIRED) + +add_library(rasterizer STATIC + ${LIBDIR}/libslic3r/Rasterizer/Rasterizer.hpp + ${LIBDIR}/libslic3r/Rasterizer/Rasterizer.cpp +) + +target_link_libraries(rasterizer ${PNG_LIBRARIES}) +target_include_directories(rasterizer PRIVATE ${PNG_INCLUDE_DIRS}) +target_compile_definitions(rasterizer PRIVATE ${PNG_DEFINITIONS}) +target_link_libraries(libslic3r rasterizer) + # Generate the Slic3r Perl module (XS) typemap file. set(MyTypemap ${CMAKE_CURRENT_BINARY_DIR}/typemap) add_custom_command( diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 8a96654481..05d635afeb 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -14,8 +14,11 @@ // For png export of the sliced model #include #include +#include #include +#include + namespace Slic3r { template class PrintState; @@ -1251,30 +1254,54 @@ template class FilePrinter { public: void drawPolygon(const ExPolygon& p); + void finish(); void save(const std::string& path); }; template<> class FilePrinter { wxBitmap bitmap_; - wxMemoryDC dc_; + std::unique_ptr dc_; std::unique_ptr gc_; + double pxw_; + double pxh_; public: - inline FilePrinter(unsigned width, unsigned height): - bitmap_(width, height), - dc_(bitmap_), - gc_(wxGraphicsContext::Create(dc_)) { + inline FilePrinter(unsigned width_px, unsigned height_px, + double width_mm, double height_mm): + bitmap_(width_px, height_px), + dc_(new wxMemoryDC(bitmap_)), + gc_(wxGraphicsContext::Create(*dc_)), + pxw_(width_mm/width_px), + pxh_(height_mm/width_px) + { gc_->SetAntialiasMode(wxANTIALIAS_DEFAULT); } - void drawPolygon(const ExPolygon& p) { - gc_->SetPen( *wxRED_PEN ); + FilePrinter(const FilePrinter& ) = delete; + FilePrinter(FilePrinter&& m): + bitmap_(std::move(m.bitmap_)), dc_(std::move(m.dc_)), + gc_(std::move(m.gc_)), pxw_(m.pxw_), pxh_(m.pxh_) {} + + void drawPolygon(const Polygon& p) { + + gc_->SetPen(*wxWHITE_PEN); std::vector points; - points.reserve(p.contour.points.size()); - for(auto pp : p.contour.points) points.emplace_back(pp.x, pp.y); + points.reserve(p.points.size()); + + for(auto pp : p.points) { + points.emplace_back( + std::round(pp.x * SCALING_FACTOR/pxw_), + std::round(pp.y * SCALING_FACTOR/pxh_) + ); + } + gc_->DrawLines(points.size(), points.data()); } + void finish() { + + } + void save(const std::string& path) { if(!bitmap_.SaveFile(path, wxBITMAP_TYPE_PNG)) { std::cout << "fail for " << path << std::endl; @@ -1294,8 +1321,6 @@ void Print::print_to(std::string dirpath, Args...args) if(dir.back() != '/') dir.push_back('/'); #endif - FilePrinter printer(std::forward(args)...); - LayerPtrs layers; std::for_each(objects.begin(), objects.end(), [&layers](PrintObject *o){ @@ -1308,17 +1333,17 @@ void Print::print_to(std::string dirpath, Args...args) return l1->print_z < l2->print_z; }); -// auto printSlice = [&printer](ExPolygon path) { - -// }; - - int layer_id = -1; ExPolygons previous_layer_slices; auto print_bb = bounding_box(); - for(auto lp : layers) { - Layer& l = *lp; - ++layer_id; + std::vector> printers; + printers.reserve(layers.size()); + for(unsigned i = 0; i < layers.size(); i++) + printers.emplace_back(std::forward(args)...); + +#pragma omp parallel for + for(int layer_id = 0; layer_id < layers.size(); layer_id++) { + Layer& l = *(layers[layer_id]); auto slices = l.slices; using Sl = ExPolygons::value_type; @@ -1330,7 +1355,8 @@ void Print::print_to(std::string dirpath, Args...args) ExPolygons current_layer_slices; - // please enable C++14 ... + auto& printer = printers[layer_id]; + std::for_each(l.object()->_shifted_copies.begin(), l.object()->_shifted_copies.end(), [&] (Point d) @@ -1341,35 +1367,39 @@ void Print::print_to(std::string dirpath, Args...args) { slice.translate(d.x, d.y); slice.translate(-print_bb.min.x, -print_bb.min.y); - printer.drawPolygon(slice); - // $print_polygon->($expolygon->contour, 'contour'); - // $print_polygon->($_, 'hole') for @{$expolygon->holes}; + + printer.drawPolygon(slice.contour); + std::for_each(slice.holes.begin(), slice.holes.end(), + [&printer](const Polygon& hole){ + printer.drawPolygon(hole); + }); + current_layer_slices.push_back(slice); }); }); - printer.save(dir + "layer" + std::to_string(layer_id) + ".png"); + printer.finish(); -// layer_id++; -// if ($layer->slice_z == -1) { -// printf $fh qq{ \n}, $layer_id; -// } else { -// printf $fh qq{ \n}, $layer_id, unscale($layer->slice_z); -// } + // layer_id++; + // if ($layer->slice_z == -1) { + // printf $fh qq{ \n}, $layer_id; + // } else { + // printf $fh qq{ \n}, $layer_id, unscale($layer->slice_z); + // } -// my @current_layer_slices = (); -// # sort slices so that the outermost ones come first -// my @slices = sort { $a->contour->contains_point($b->contour->first_point) ? 0 : 1 } @{$layer->slices}; -// foreach my $copy (@{$layer->object->_shifted_copies}) { -// foreach my $slice (@slices) { -// my $expolygon = $slice->clone; -// $expolygon->translate(@$copy); -// $expolygon->translate(-$print_bb->x_min, -$print_bb->y_min); -// $print_polygon->($expolygon->contour, 'contour'); -// $print_polygon->($_, 'hole') for @{$expolygon->holes}; -// push @current_layer_slices, $expolygon; -// } -// } + // my @current_layer_slices = (); + // # sort slices so that the outermost ones come first + // my @slices = sort { $a->contour->contains_point($b->contour->first_point) ? 0 : 1 } @{$layer->slices}; + // foreach my $copy (@{$layer->object->_shifted_copies}) { + // foreach my $slice (@slices) { + // my $expolygon = $slice->clone; + // $expolygon->translate(@$copy); + // $expolygon->translate(-$print_bb->x_min, -$print_bb->y_min); + // $print_polygon->($expolygon->contour, 'contour'); + // $print_polygon->($_, 'hole') for @{$expolygon->holes}; + // push @current_layer_slices, $expolygon; + // } + // } // # generate support material // if ($self->has_support_material && $layer->id > 0) { // my (@supported_slices, @unsupported_slices) = (); @@ -1398,10 +1428,14 @@ void Print::print_to(std::string dirpath, Args...args) // @previous_layer_slices = @current_layer_slices; previous_layer_slices = current_layer_slices; } + +// for(unsigned i = 0; i < printers.size(); i++) +// printers[i].save(dir + "layer" + std::to_string(i) + ".png"); } -void Print::print_to_png(std::string dirpath) { - print_to(dirpath, 800, 600); +void Print::print_to_png(std::string dirpath, long width_px, long height_px, + Pointf pixel_size_mm) { + print_to(dirpath, 2560, 1440, 700, 400); } } diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index 01561dad36..48cb0898af 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -315,13 +315,17 @@ public: SVG }; - void print_to_png(std::string dirpath); - -private: - template void print_to(std::string dirpath, Args...args); + void print_to_png(std::string dirpath, long width_px, long height_px, + Pointf pixel_size_mm); + + void print_to_png(std::string dirpath) { + // Where should this be specified? + print_to_png(dirpath, 2560, 1440, Pointf{2560/700.0, 2560/400.0}); + } + private: bool invalidate_state_by_config_options(const std::vector &opt_keys); PrintRegionConfig _region_config_from_model_volume(const ModelVolume &volume); diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp new file mode 100644 index 0000000000..99d3968b26 --- /dev/null +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -0,0 +1,40 @@ +#include "Rasterizer.hpp" + +#include + + +namespace Slic3r { + +class Raster::Impl { + +}; + +Raster::Raster(const Raster::Resolution &r, const Raster::PixelDim &pd): + impl_(new Impl), resolution_(r), pxdim_(pd) {} + +Raster::~Raster() {} + +Raster::Raster(const Raster &cpy): resolution_(cpy.resolution_), + pxdim_(cpy.pxdim_) { + *impl_ = *(cpy.impl_); +} + +Raster::Raster(Raster &&m): + impl_(std::move(m.impl_)), resolution_(m.resolution_), pxdim_(m.pxdim_) {} + +void Raster::clear() +{ + +} + +void Raster::draw(const Polygon &poly) +{ + png_image ifo; +} + +void Raster::finish() +{ + +} + +} diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp new file mode 100644 index 0000000000..db4ee02f33 --- /dev/null +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp @@ -0,0 +1,43 @@ +#ifndef RASTERIZER_HPP +#define RASTERIZER_HPP + +#include + +namespace Slic3r { + +class Raster { + class Impl; + std::unique_ptr impl_; +public: + + struct Resolution { + unsigned width_px; + unsigned height_px; + inline Resolution(unsigned w, unsigned h): width_px(w), height_px(h) {} + }; + + struct PixelDim { + double w_mm; + double h_mm; + inline PixelDim(double px_width_mm, double px_height_mm ): + w_mm(px_width_mm), h_mm(px_height_mm) {} + }; + + inline explicit Raster(const Resolution& r, const PixelDim& pd ); + ~Raster(); + Raster(const Raster& cpy); + Raster(Raster&& m); + + void clear(); + + void draw(const Polygon& poly); + + void finish(); + +private: + Resolution resolution_; + PixelDim pxdim_; +}; + +} +#endif // RASTERIZER_HPP From cc52654db3d7b214a31eef05d43545f5eabede9b Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 17 May 2018 08:50:05 +0200 Subject: [PATCH 0353/1150] Set minimum width for the right sizer --- lib/Slic3r/GUI/Plater.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 9d546db9dc..00579ba877 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -495,6 +495,7 @@ sub new { $scrolled_window_sizer->Add($print_info_sizer, 0, wxEXPAND, 0); my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); + $right_sizer->SetMinSize([320,-1]); $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; $right_sizer->Add($frequently_changed_parameters_sizer, 0, wxEXPAND | wxTOP, 0) if defined $frequently_changed_parameters_sizer; $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5); From 77578f4a3e36d1efd184c458429101a65d7cba53 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 17 May 2018 09:26:50 +0200 Subject: [PATCH 0354/1150] Reset tooltips for manifold objects into object info panel --- lib/Slic3r/GUI/Plater.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 9d546db9dc..0b3aea1e6d 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -2012,6 +2012,8 @@ sub selection_changed { } else { $self->{object_info_manifold}->SetLabel(L("Yes")); $self->{object_info_manifold_warning_icon}->Hide; + $self->{object_info_manifold}->SetToolTipString(""); + $self->{object_info_manifold_warning_icon}->SetToolTipString(""); } } else { $self->{object_info_facets}->SetLabel($object->facets); @@ -2020,6 +2022,7 @@ sub selection_changed { $self->{"object_info_$_"}->SetLabel("") for qw(size volume facets materials manifold); $self->{object_info_manifold_warning_icon}->Hide; $self->{object_info_manifold}->SetToolTipString(""); + $self->{object_info_manifold_warning_icon}->SetToolTipString(""); } $self->Layout; } From e13564cb190458a818f6ad40dc8705c9c6ae8a5e Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 17 May 2018 09:50:40 +0200 Subject: [PATCH 0355/1150] Fixed shell visualization in g-code preview --- xs/src/slic3r/GUI/3DScene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index df8b1fbfc7..6569f480fb 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1762,12 +1762,13 @@ void _3DScene::load_gcode_preview(const Print* print, const GCodePreviewData* pr else { _generate_legend_texture(*preview_data, tool_colors); - _load_shells(*print, *volumes, use_VBOs); // removes empty volumes volumes->volumes.erase(std::remove_if(volumes->volumes.begin(), volumes->volumes.end(), [](const GLVolume *volume) { return volume->print_zs.empty(); }), volumes->volumes.end()); + + _load_shells(*print, *volumes, use_VBOs); } } From 6f792b7ffbc90ef535ba7ced09cf77a8110e87c0 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 17 May 2018 10:23:02 +0200 Subject: [PATCH 0356/1150] Horrible workaround to make the gcode preview dropdown (show feature types) work on all platforms --- xs/src/slic3r/GUI/wxExtensions.cpp | 31 +++++++++++++++++++++++------- xs/src/slic3r/GUI/wxExtensions.hpp | 15 +++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 8bc282474e..5949efb377 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -82,15 +82,27 @@ void wxCheckListBoxComboPopup::OnCheckListBox(wxCommandEvent& evt) { // forwards the checklistbox event to the owner wxComboCtrl - wxComboCtrl* cmb = GetComboCtrl(); - if (cmb != nullptr) + if (m_check_box_events_status == OnCheckListBoxFunction::FreeToProceed ) { - wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId()); - event.SetEventObject(cmb); - cmb->ProcessWindowEvent(event); + wxComboCtrl* cmb = GetComboCtrl(); + if (cmb != nullptr) { + wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId()); + event.SetEventObject(cmb); + cmb->ProcessWindowEvent(event); + } } evt.Skip(); + + #ifndef _WIN32 // events are sent differently on OSX+Linux vs Win (more description in header file) + if ( m_check_box_events_status == OnCheckListBoxFunction::RefuseToProceed ) + // this happens if the event was resent by OnListBoxSelection - next call to OnListBoxSelection is due to user clicking the text, so the function should + // explicitly change the state on the checkbox + m_check_box_events_status = OnCheckListBoxFunction::WasRefusedLastTime; + else + // if the user clicked the checkbox square, this event was sent before OnListBoxSelection was called, so we don't want it to resend it + m_check_box_events_status = OnCheckListBoxFunction::RefuseToProceed; + #endif } void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt) @@ -100,9 +112,14 @@ void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt) int selId = GetSelection(); if (selId != wxNOT_FOUND) { - Check((unsigned int)selId, !IsChecked((unsigned int)selId)); - SetSelection(wxNOT_FOUND); + #ifndef _WIN32 + if (m_check_box_events_status == OnCheckListBoxFunction::RefuseToProceed) + #endif + Check((unsigned int)selId, !IsChecked((unsigned int)selId)); + m_check_box_events_status = OnCheckListBoxFunction::FreeToProceed; // so the checkbox reacts to square-click the next time + + SetSelection(wxNOT_FOUND); wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId()); event.SetInt(selId); event.SetEventObject(this); diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index ed8bb9276a..3667c7905b 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -13,6 +13,21 @@ class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup wxString m_text; + // Events sent on mouseclick are quite complex. Function OnListBoxSelection is supposed to pass the event to the checkbox, which works fine on + // Win. On OSX and Linux the events are generated differently - clicking on the checkbox square generates the event twice (and the square + // therefore seems not to respond). + // This enum is meant to save current state of affairs, i.e., if the event forwarding is ok to do or not. It is only used on Linux + // and OSX by some #ifdefs. It also stores information whether OnListBoxSelection is supposed to change the checkbox status, + // or if it changed status on its own already (which happens when the square is clicked). More comments in OnCheckListBox(...) + // There indeed is a better solution, maybe making a custom event used for the event passing to distinguish the original and passed message + // and blocking one of them on OSX and Linux. Feel free to refactor, but carefully test on all platforms. + enum class OnCheckListBoxFunction{ + FreeToProceed, + RefuseToProceed, + WasRefusedLastTime + } m_check_box_events_status = OnCheckListBoxFunction::FreeToProceed; + + public: virtual bool Create(wxWindow* parent); virtual wxWindow* GetControl(); From e3d84407e0412c2fcc9e81dbb540b2872a37300b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 17 May 2018 10:30:20 +0200 Subject: [PATCH 0357/1150] Fix of https://github.com/prusa3d/Slic3r/issues/896 Fixed a bug in parsering a Point from a config file. --- xs/src/libslic3r/Config.hpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 14050c6cc5..bde1eb651d 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -644,12 +644,9 @@ public: bool deserialize(const std::string &str, bool append = false) override { UNUSED(append); - std::istringstream iss(str); - iss >> this->value.x; - iss.ignore(std::numeric_limits::max(), ','); - iss.ignore(std::numeric_limits::max(), 'x'); - iss >> this->value.y; - return true; + char dummy; + return sscanf(str.data(), " %lf , %lf %c", &this->value.x, &this->value.y, &dummy) == 2 || + sscanf(str.data(), " %lf x %lf %c", &this->value.x, &this->value.y, &dummy) == 2; } }; From fd829580e9c9c1f92e4a2338bcee35a5b319030a Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Thu, 17 May 2018 10:37:26 +0200 Subject: [PATCH 0358/1150] Working arrange_objects with DJD selection heuristic and a bottom-left placement strategy. --- CMakeLists.txt | 3 +- xs/CMakeLists.txt | 29 + xs/src/libnest2d/CMakeLists.txt | 81 ++ xs/src/libnest2d/LICENSE.txt | 661 +++++++++++++++ xs/src/libnest2d/README.md | 36 + .../DownloadProject.CMakeLists.cmake.in | 17 + .../cmake_modules/DownloadProject.cmake | 182 ++++ .../libnest2d/cmake_modules/FindClipper.cmake | 46 + xs/src/libnest2d/libnest2d.h | 37 + xs/src/libnest2d/libnest2d/boost_alg.hpp | 431 ++++++++++ .../libnest2d/clipper_backend/CMakeLists.txt | 48 ++ .../clipper_backend/clipper_backend.cpp | 77 ++ .../clipper_backend/clipper_backend.hpp | 240 ++++++ xs/src/libnest2d/libnest2d/common.hpp | 94 ++ xs/src/libnest2d/libnest2d/geometries_io.hpp | 18 + xs/src/libnest2d/libnest2d/geometries_nfp.hpp | 125 +++ .../libnest2d/libnest2d/geometry_traits.hpp | 501 +++++++++++ xs/src/libnest2d/libnest2d/libnest2d.hpp | 802 ++++++++++++++++++ .../libnest2d/placers/bottomleftplacer.hpp | 391 +++++++++ .../libnest2d/libnest2d/placers/nfpplacer.hpp | 31 + .../libnest2d/placers/placer_boilerplate.hpp | 102 +++ .../libnest2d/selections/djd_heuristic.hpp | 514 +++++++++++ .../libnest2d/libnest2d/selections/filler.hpp | 71 ++ .../libnest2d/selections/firstfit.hpp | 77 ++ .../selections/selection_boilerplate.hpp | 36 + xs/src/libnest2d/tests/CMakeLists.txt | 48 ++ xs/src/libnest2d/tests/benchmark.h | 58 ++ xs/src/libnest2d/tests/main.cpp | 260 ++++++ xs/src/libnest2d/tests/printer_parts.cpp | 339 ++++++++ xs/src/libnest2d/tests/printer_parts.h | 9 + xs/src/libnest2d/tests/test.cpp | 474 +++++++++++ xs/src/libslic3r/Fill/FillRectilinear3.cpp | 10 +- xs/src/libslic3r/Int128.hpp | 17 - xs/src/libslic3r/Model.cpp | 239 +++++- xs/src/libslic3r/Point.cpp | 17 + xs/src/libslic3r/Point.hpp | 11 + 36 files changed, 6087 insertions(+), 45 deletions(-) create mode 100644 xs/src/libnest2d/CMakeLists.txt create mode 100644 xs/src/libnest2d/LICENSE.txt create mode 100644 xs/src/libnest2d/README.md create mode 100644 xs/src/libnest2d/cmake_modules/DownloadProject.CMakeLists.cmake.in create mode 100644 xs/src/libnest2d/cmake_modules/DownloadProject.cmake create mode 100644 xs/src/libnest2d/cmake_modules/FindClipper.cmake create mode 100644 xs/src/libnest2d/libnest2d.h create mode 100644 xs/src/libnest2d/libnest2d/boost_alg.hpp create mode 100644 xs/src/libnest2d/libnest2d/clipper_backend/CMakeLists.txt create mode 100644 xs/src/libnest2d/libnest2d/clipper_backend/clipper_backend.cpp create mode 100644 xs/src/libnest2d/libnest2d/clipper_backend/clipper_backend.hpp create mode 100644 xs/src/libnest2d/libnest2d/common.hpp create mode 100644 xs/src/libnest2d/libnest2d/geometries_io.hpp create mode 100644 xs/src/libnest2d/libnest2d/geometries_nfp.hpp create mode 100644 xs/src/libnest2d/libnest2d/geometry_traits.hpp create mode 100644 xs/src/libnest2d/libnest2d/libnest2d.hpp create mode 100644 xs/src/libnest2d/libnest2d/placers/bottomleftplacer.hpp create mode 100644 xs/src/libnest2d/libnest2d/placers/nfpplacer.hpp create mode 100644 xs/src/libnest2d/libnest2d/placers/placer_boilerplate.hpp create mode 100644 xs/src/libnest2d/libnest2d/selections/djd_heuristic.hpp create mode 100644 xs/src/libnest2d/libnest2d/selections/filler.hpp create mode 100644 xs/src/libnest2d/libnest2d/selections/firstfit.hpp create mode 100644 xs/src/libnest2d/libnest2d/selections/selection_boilerplate.hpp create mode 100644 xs/src/libnest2d/tests/CMakeLists.txt create mode 100644 xs/src/libnest2d/tests/benchmark.h create mode 100644 xs/src/libnest2d/tests/main.cpp create mode 100644 xs/src/libnest2d/tests/printer_parts.cpp create mode 100644 xs/src/libnest2d/tests/printer_parts.h create mode 100644 xs/src/libnest2d/tests/test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e8b2a6faaa..db8c052fd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,8 @@ if(NOT DEFINED CMAKE_PREFIX_PATH) endif() endif() +enable_testing () + add_subdirectory(xs) get_filename_component(PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY) @@ -63,7 +65,6 @@ else () set(PERL_PROVE "${PERL_BIN_PATH}/prove") endif () -enable_testing () add_test (NAME xs COMMAND "${PERL_EXECUTABLE}" ${PERL_PROVE} -I ${PROJECT_SOURCE_DIR}/local-lib/lib/perl5 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/xs) add_test (NAME integration COMMAND "${PERL_EXECUTABLE}" ${PERL_PROVE} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 4f44fc7bf7..fc8dab8836 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -679,6 +679,35 @@ add_custom_target(pot COMMENT "Generate pot file from strings in the source tree" ) +# ############################################################################## +# Adding libnest2d project for bin packing... +# ############################################################################## + +set(LIBNEST2D_UNITTESTS ON CACHE BOOL "Force generating unittests for libnest2d") + +if(LIBNEST2D_UNITTESTS) + # If we want the libnest2d unit tests we need to build and executable with + # all the libslic3r dependencies. This is needed because the clipper library + # in the slic3r project is hacked so that it depends on the slic3r sources. + # Unfortunately, this implies that the test executable is also dependent on + # the libslic3r target. + +# add_library(libslic3r_standalone STATIC ${LIBDIR}/libslic3r/utils.cpp) +# set(LIBNEST2D_TEST_LIBRARIES +# libslic3r libslic3r_standalone nowide libslic3r_gui admesh miniz +# ${Boost_LIBRARIES} clipper ${EXPAT_LIBRARIES} ${GLEW_LIBRARIES} +# polypartition poly2tri ${TBB_LIBRARIES} ${wxWidgets_LIBRARIES} +# ${CURL_LIBRARIES} +# ) +endif() + +add_subdirectory(${LIBDIR}/libnest2d) +target_include_directories(libslic3r PUBLIC BEFORE ${LIBNEST2D_INCLUDES}) + +# Add the binpack2d main sources and link them to libslic3r +target_link_libraries(libslic3r libnest2d) +# ############################################################################## + # Installation install(TARGETS XS DESTINATION ${PERL_VENDORARCH}/auto/Slic3r/XS) install(FILES lib/Slic3r/XS.pm DESTINATION ${PERL_VENDORLIB}/Slic3r) diff --git a/xs/src/libnest2d/CMakeLists.txt b/xs/src/libnest2d/CMakeLists.txt new file mode 100644 index 0000000000..568d1a5a91 --- /dev/null +++ b/xs/src/libnest2d/CMakeLists.txt @@ -0,0 +1,81 @@ +cmake_minimum_required(VERSION 2.8) + +project(Libnest2D) + +enable_testing() + +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + # Update if necessary +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long ") +endif() + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED) + +# Add our own cmake module path. +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/) + +option(LIBNEST2D_UNITTESTS "If enabled, googletest framework will be downloaded + and the provided unit tests will be included in the build." OFF) + +#set(LIBNEST2D_GEOMETRIES_TARGET "" CACHE STRING +# "Build libnest2d with geometry classes implemented by the chosen target.") + +#set(libnest2D_TEST_LIBRARIES "" CACHE STRING +# "Libraries needed to compile the test executable for libnest2d.") + + +set(LIBNEST2D_SRCFILES + libnest2d/libnest2d.hpp # Templates only + libnest2d.h # Exports ready made types using template arguments + libnest2d/geometry_traits.hpp + libnest2d/geometries_io.hpp + libnest2d/common.hpp + libnest2d/placers/placer_boilerplate.hpp + libnest2d/placers/bottomleftplacer.hpp + libnest2d/placers/nfpplacer.hpp + libnest2d/geometries_nfp.hpp + libnest2d/selections/selection_boilerplate.hpp + libnest2d/selections/filler.hpp + libnest2d/selections/firstfit.hpp + libnest2d/selections/djd_heuristic.hpp + ) + +if((NOT LIBNEST2D_GEOMETRIES_TARGET) OR (LIBNEST2D_GEOMETRIES_TARGET STREQUAL "")) + message(STATUS "libnest2D backend is default") + + if(NOT Boost_INCLUDE_DIRS_FOUND) + find_package(Boost REQUIRED) + # TODO automatic download of boost geometry headers + endif() + + add_subdirectory(libnest2d/clipper_backend) + + set(LIBNEST2D_GEOMETRIES_TARGET ${CLIPPER_LIBRARIES}) + + include_directories(BEFORE ${CLIPPER_INCLUDE_DIRS}) + include_directories(${Boost_INCLUDE_DIRS}) + + list(APPEND LIBNEST2D_SRCFILES libnest2d/clipper_backend/clipper_backend.cpp + libnest2d/clipper_backend/clipper_backend.hpp + libnest2d/boost_alg.hpp) + +else() + message(STATUS "Libnest2D backend is: ${LIBNEST2D_GEOMETRIES_TARGET}") +endif() + +add_library(libnest2d STATIC ${LIBNEST2D_SRCFILES} ) +target_link_libraries(libnest2d ${LIBNEST2D_GEOMETRIES_TARGET}) +target_include_directories(libnest2d PUBLIC ${CMAKE_SOURCE_DIR}) + +set(LIBNEST2D_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}) + +get_directory_property(hasParent PARENT_DIRECTORY) +if(hasParent) + set(LIBNEST2D_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) +endif() + +if(LIBNEST2D_UNITTESTS) + add_subdirectory(tests) +endif() diff --git a/xs/src/libnest2d/LICENSE.txt b/xs/src/libnest2d/LICENSE.txt new file mode 100644 index 0000000000..dba13ed2dd --- /dev/null +++ b/xs/src/libnest2d/LICENSE.txt @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/xs/src/libnest2d/README.md b/xs/src/libnest2d/README.md new file mode 100644 index 0000000000..f2182d6490 --- /dev/null +++ b/xs/src/libnest2d/README.md @@ -0,0 +1,36 @@ +# Introduction + +Libnest2D is a library and framework for the 2D bin packaging problem. +Inspired from the [SVGNest](svgnest.com) Javascript library the project is is +built from scratch in C++11. The library is written with a policy that it should +be usable out of the box with a very simple interface but has to be customizable +to the very core as well. This has led to a design where the algorithms are +defined in a header only fashion with template only geometry types. These +geometries can have custom or already existing implementation to avoid copying +or having unnecessary dependencies. + +A default backend is provided if a user just wants to use the library out of the +box without implementing the interface of these geometry types. The default +backend is built on top of boost geometry and the +[polyclipping](http://www.angusj.com/delphi/clipper.php) library and implies the +dependency on these packages as well as the compilation of the backend (although +I may find a solution in the future to make the backend header only as well). + +This software is currently under heavy construction and lacks a throughout +documentation and some essential algorithms as well. At this point a fairly +untested version of the DJD selection heuristic is working with a bottom-left +placing strategy which may produce usable arrangements in most cases. + +The no-fit polygon based placement strategy will be implemented in the very near +future which should produce high quality results for convex and non convex +polygons with holes as well. + +# References +- [SVGNest](https://github.com/Jack000/SVGnest) +- [An effective heuristic for the two-dimensional irregular +bin packing problem](http://www.cs.stir.ac.uk/~goc/papers/EffectiveHueristic2DAOR2013.pdf) +- [Complete and robust no-fit polygon generation for the irregular stock cutting problem](https://www.sciencedirect.com/science/article/abs/pii/S0377221706001639) +- [Applying Meta-Heuristic Algorithms to the Nesting +Problem Utilising the No Fit Polygon](http://www.graham-kendall.com/papers/k2001.pdf) +- [A comprehensive and robust procedure for obtaining the nofit polygon +using Minkowski sums](https://www.sciencedirect.com/science/article/pii/S0305054806000669) \ No newline at end of file diff --git a/xs/src/libnest2d/cmake_modules/DownloadProject.CMakeLists.cmake.in b/xs/src/libnest2d/cmake_modules/DownloadProject.CMakeLists.cmake.in new file mode 100644 index 0000000000..d5cf3c1d93 --- /dev/null +++ b/xs/src/libnest2d/cmake_modules/DownloadProject.CMakeLists.cmake.in @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved MIT License. See accompanying +# file LICENSE or https://github.com/Crascit/DownloadProject for details. + +cmake_minimum_required(VERSION 2.8.2) + +project(${DL_ARGS_PROJ}-download NONE) + +include(ExternalProject) +ExternalProject_Add(${DL_ARGS_PROJ}-download + ${DL_ARGS_UNPARSED_ARGUMENTS} + SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" + BINARY_DIR "${DL_ARGS_BINARY_DIR}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) \ No newline at end of file diff --git a/xs/src/libnest2d/cmake_modules/DownloadProject.cmake b/xs/src/libnest2d/cmake_modules/DownloadProject.cmake new file mode 100644 index 0000000000..1709e09adc --- /dev/null +++ b/xs/src/libnest2d/cmake_modules/DownloadProject.cmake @@ -0,0 +1,182 @@ +# Distributed under the OSI-approved MIT License. See accompanying +# file LICENSE or https://github.com/Crascit/DownloadProject for details. +# +# MODULE: DownloadProject +# +# PROVIDES: +# download_project( PROJ projectName +# [PREFIX prefixDir] +# [DOWNLOAD_DIR downloadDir] +# [SOURCE_DIR srcDir] +# [BINARY_DIR binDir] +# [QUIET] +# ... +# ) +# +# Provides the ability to download and unpack a tarball, zip file, git repository, +# etc. at configure time (i.e. when the cmake command is run). How the downloaded +# and unpacked contents are used is up to the caller, but the motivating case is +# to download source code which can then be included directly in the build with +# add_subdirectory() after the call to download_project(). Source and build +# directories are set up with this in mind. +# +# The PROJ argument is required. The projectName value will be used to construct +# the following variables upon exit (obviously replace projectName with its actual +# value): +# +# projectName_SOURCE_DIR +# projectName_BINARY_DIR +# +# The SOURCE_DIR and BINARY_DIR arguments are optional and would not typically +# need to be provided. They can be specified if you want the downloaded source +# and build directories to be located in a specific place. The contents of +# projectName_SOURCE_DIR and projectName_BINARY_DIR will be populated with the +# locations used whether you provide SOURCE_DIR/BINARY_DIR or not. +# +# The DOWNLOAD_DIR argument does not normally need to be set. It controls the +# location of the temporary CMake build used to perform the download. +# +# The PREFIX argument can be provided to change the base location of the default +# values of DOWNLOAD_DIR, SOURCE_DIR and BINARY_DIR. If all of those three arguments +# are provided, then PREFIX will have no effect. The default value for PREFIX is +# CMAKE_BINARY_DIR. +# +# The QUIET option can be given if you do not want to show the output associated +# with downloading the specified project. +# +# In addition to the above, any other options are passed through unmodified to +# ExternalProject_Add() to perform the actual download, patch and update steps. +# The following ExternalProject_Add() options are explicitly prohibited (they +# are reserved for use by the download_project() command): +# +# CONFIGURE_COMMAND +# BUILD_COMMAND +# INSTALL_COMMAND +# TEST_COMMAND +# +# Only those ExternalProject_Add() arguments which relate to downloading, patching +# and updating of the project sources are intended to be used. Also note that at +# least one set of download-related arguments are required. +# +# If using CMake 3.2 or later, the UPDATE_DISCONNECTED option can be used to +# prevent a check at the remote end for changes every time CMake is run +# after the first successful download. See the documentation of the ExternalProject +# module for more information. It is likely you will want to use this option if it +# is available to you. Note, however, that the ExternalProject implementation contains +# bugs which result in incorrect handling of the UPDATE_DISCONNECTED option when +# using the URL download method or when specifying a SOURCE_DIR with no download +# method. Fixes for these have been created, the last of which is scheduled for +# inclusion in CMake 3.8.0. Details can be found here: +# +# https://gitlab.kitware.com/cmake/cmake/commit/bdca68388bd57f8302d3c1d83d691034b7ffa70c +# https://gitlab.kitware.com/cmake/cmake/issues/16428 +# +# If you experience build errors related to the update step, consider avoiding +# the use of UPDATE_DISCONNECTED. +# +# EXAMPLE USAGE: +# +# include(DownloadProject) +# download_project(PROJ googletest +# GIT_REPOSITORY https://github.com/google/googletest.git +# GIT_TAG master +# UPDATE_DISCONNECTED 1 +# QUIET +# ) +# +# add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) +# +#======================================================================================== + + +set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}") + +include(CMakeParseArguments) + +function(download_project) + + set(options QUIET) + set(oneValueArgs + PROJ + PREFIX + DOWNLOAD_DIR + SOURCE_DIR + BINARY_DIR + # Prevent the following from being passed through + CONFIGURE_COMMAND + BUILD_COMMAND + INSTALL_COMMAND + TEST_COMMAND + ) + set(multiValueArgs "") + + cmake_parse_arguments(DL_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Hide output if requested + if (DL_ARGS_QUIET) + set(OUTPUT_QUIET "OUTPUT_QUIET") + else() + unset(OUTPUT_QUIET) + message(STATUS "Downloading/updating ${DL_ARGS_PROJ}") + endif() + + # Set up where we will put our temporary CMakeLists.txt file and also + # the base point below which the default source and binary dirs will be. + # The prefix must always be an absolute path. + if (NOT DL_ARGS_PREFIX) + set(DL_ARGS_PREFIX "${CMAKE_BINARY_DIR}") + else() + get_filename_component(DL_ARGS_PREFIX "${DL_ARGS_PREFIX}" ABSOLUTE + BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + if (NOT DL_ARGS_DOWNLOAD_DIR) + set(DL_ARGS_DOWNLOAD_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-download") + endif() + + # Ensure the caller can know where to find the source and build directories + if (NOT DL_ARGS_SOURCE_DIR) + set(DL_ARGS_SOURCE_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-src") + endif() + if (NOT DL_ARGS_BINARY_DIR) + set(DL_ARGS_BINARY_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-build") + endif() + set(${DL_ARGS_PROJ}_SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" PARENT_SCOPE) + set(${DL_ARGS_PROJ}_BINARY_DIR "${DL_ARGS_BINARY_DIR}" PARENT_SCOPE) + + # The way that CLion manages multiple configurations, it causes a copy of + # the CMakeCache.txt to be copied across due to it not expecting there to + # be a project within a project. This causes the hard-coded paths in the + # cache to be copied and builds to fail. To mitigate this, we simply + # remove the cache if it exists before we configure the new project. It + # is safe to do so because it will be re-generated. Since this is only + # executed at the configure step, it should not cause additional builds or + # downloads. + file(REMOVE "${DL_ARGS_DOWNLOAD_DIR}/CMakeCache.txt") + + # Create and build a separate CMake project to carry out the download. + # If we've already previously done these steps, they will not cause + # anything to be updated, so extra rebuilds of the project won't occur. + # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project + # has this set to something not findable on the PATH. + configure_file("${_DownloadProjectDir}/DownloadProject.CMakeLists.cmake.in" + "${DL_ARGS_DOWNLOAD_DIR}/CMakeLists.txt") + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" + -D "CMAKE_MAKE_PROGRAM:FILE=${CMAKE_MAKE_PROGRAM}" + . + RESULT_VARIABLE result + ${OUTPUT_QUIET} + WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" + ) + if(result) + message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + ${OUTPUT_QUIET} + WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" + ) + if(result) + message(FATAL_ERROR "Build step for ${DL_ARGS_PROJ} failed: ${result}") + endif() + +endfunction() \ No newline at end of file diff --git a/xs/src/libnest2d/cmake_modules/FindClipper.cmake b/xs/src/libnest2d/cmake_modules/FindClipper.cmake new file mode 100644 index 0000000000..ad4460c35e --- /dev/null +++ b/xs/src/libnest2d/cmake_modules/FindClipper.cmake @@ -0,0 +1,46 @@ +# Find Clipper library (http://www.angusj.com/delphi/clipper.php). +# The following variables are set +# +# CLIPPER_FOUND +# CLIPPER_INCLUDE_DIRS +# CLIPPER_LIBRARIES +# +# It searches the environment variable $CLIPPER_PATH automatically. + +FIND_PATH(CLIPPER_INCLUDE_DIRS clipper.hpp + $ENV{CLIPPER_PATH} + $ENV{CLIPPER_PATH}/cpp/ + $ENV{CLIPPER_PATH}/include/ + $ENV{CLIPPER_PATH}/include/polyclipping/ + ${PROJECT_SOURCE_DIR}/python/pymesh/third_party/include/ + ${PROJECT_SOURCE_DIR}/python/pymesh/third_party/include/polyclipping/ + /opt/local/include/ + /opt/local/include/polyclipping/ + /usr/local/include/ + /usr/local/include/polyclipping/ + /usr/include + /usr/include/polyclipping/) + +FIND_LIBRARY(CLIPPER_LIBRARIES polyclipping + $ENV{CLIPPER_PATH} + $ENV{CLIPPER_PATH}/cpp/ + $ENV{CLIPPER_PATH}/cpp/build/ + $ENV{CLIPPER_PATH}/lib/ + $ENV{CLIPPER_PATH}/lib/polyclipping/ + ${PROJECT_SOURCE_DIR}/python/pymesh/third_party/lib/ + ${PROJECT_SOURCE_DIR}/python/pymesh/third_party/lib/polyclipping/ + /opt/local/lib/ + /opt/local/lib/polyclipping/ + /usr/local/lib/ + /usr/local/lib/polyclipping/ + /usr/lib/polyclipping) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Clipper + "Clipper library cannot be found. Consider set CLIPPER_PATH environment variable" + CLIPPER_INCLUDE_DIRS + CLIPPER_LIBRARIES) + +MARK_AS_ADVANCED( + CLIPPER_INCLUDE_DIRS + CLIPPER_LIBRARIES) \ No newline at end of file diff --git a/xs/src/libnest2d/libnest2d.h b/xs/src/libnest2d/libnest2d.h new file mode 100644 index 0000000000..dcdb812dc6 --- /dev/null +++ b/xs/src/libnest2d/libnest2d.h @@ -0,0 +1,37 @@ +#ifndef LIBNEST2D_H +#define LIBNEST2D_H + +// The type of backend should be set conditionally by the cmake configuriation +// for now we set it statically to clipper backend +#include + +#include +#include +#include +#include +#include +#include + +namespace libnest2d { + +using Point = PointImpl; +using Coord = TCoord; +using Box = _Box; +using Segment = _Segment; + +using Item = _Item; +using Rectangle = _Rectangle; + +using PackGroup = _PackGroup; +using IndexedPackGroup = _IndexedPackGroup; + +using FillerSelection = strategies::_FillerSelection; +using FirstFitSelection = strategies::_FirstFitSelection; +using DJDHeuristic = strategies::_DJDHeuristic; + +using BottomLeftPlacer = strategies::_BottomLeftPlacer; +using NofitPolyPlacer = strategies::_NofitPolyPlacer; + +} + +#endif // LIBNEST2D_H diff --git a/xs/src/libnest2d/libnest2d/boost_alg.hpp b/xs/src/libnest2d/libnest2d/boost_alg.hpp new file mode 100644 index 0000000000..5f1c2806f9 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/boost_alg.hpp @@ -0,0 +1,431 @@ +#ifndef BOOST_ALG_HPP +#define BOOST_ALG_HPP + +#ifndef DISABLE_BOOST_SERIALIZE + #include +#endif + +#include + +// this should be removed to not confuse the compiler +// #include + +namespace bp2d { + +using libnest2d::TCoord; +using libnest2d::PointImpl; +using Coord = TCoord; +using libnest2d::PolygonImpl; +using libnest2d::PathImpl; +using libnest2d::Orientation; +using libnest2d::OrientationType; +using libnest2d::getX; +using libnest2d::getY; +using libnest2d::setX; +using libnest2d::setY; +using Box = libnest2d::_Box; +using Segment = libnest2d::_Segment; + +} + +/** + * We have to make all the binpack2d geometry types available to boost. The real + * models of the geometries remain the same if a conforming model for binpack2d + * was defined by the library client. Boost is used only as an optional + * implementer of some algorithms that can be implemented by the model itself + * if a faster alternative exists. + * + * However, boost has its own type traits and we have to define the needed + * specializations to be able to use boost::geometry. This can be done with the + * already provided model. + */ +namespace boost { +namespace geometry { +namespace traits { + +/* ************************************************************************** */ +/* Point concept adaptaion ************************************************** */ +/* ************************************************************************** */ + +template<> struct tag { + using type = point_tag; +}; + +template<> struct coordinate_type { + using type = bp2d::Coord; +}; + +template<> struct coordinate_system { + using type = cs::cartesian; +}; + +template<> struct dimension: boost::mpl::int_<2> {}; + +template<> +struct access { + static inline bp2d::Coord get(bp2d::PointImpl const& a) { + return libnest2d::getX(a); + } + + static inline void set(bp2d::PointImpl& a, + bp2d::Coord const& value) { + libnest2d::setX(a, value); + } +}; + +template<> +struct access { + static inline bp2d::Coord get(bp2d::PointImpl const& a) { + return libnest2d::getY(a); + } + + static inline void set(bp2d::PointImpl& a, + bp2d::Coord const& value) { + libnest2d::setY(a, value); + } +}; + + +/* ************************************************************************** */ +/* Box concept adaptaion **************************************************** */ +/* ************************************************************************** */ + +template<> struct tag { + using type = box_tag; +}; + +template<> struct point_type { + using type = bp2d::PointImpl; +}; + +template<> struct indexed_access { + static inline bp2d::Coord get(bp2d::Box const& box) { + return bp2d::getX(box.minCorner()); + } + static inline void set(bp2d::Box &box, bp2d::Coord const& coord) { + bp2d::setX(box.minCorner(), coord); + } +}; + +template<> struct indexed_access { + static inline bp2d::Coord get(bp2d::Box const& box) { + return bp2d::getY(box.minCorner()); + } + static inline void set(bp2d::Box &box, bp2d::Coord const& coord) { + bp2d::setY(box.minCorner(), coord); + } +}; + +template<> struct indexed_access { + static inline bp2d::Coord get(bp2d::Box const& box) { + return bp2d::getX(box.maxCorner()); + } + static inline void set(bp2d::Box &box, bp2d::Coord const& coord) { + bp2d::setX(box.maxCorner(), coord); + } +}; + +template<> struct indexed_access { + static inline bp2d::Coord get(bp2d::Box const& box) { + return bp2d::getY(box.maxCorner()); + } + static inline void set(bp2d::Box &box, bp2d::Coord const& coord) { + bp2d::setY(box.maxCorner(), coord); + } +}; + +/* ************************************************************************** */ +/* Segement concept adaptaion *********************************************** */ +/* ************************************************************************** */ + +template<> struct tag { + using type = segment_tag; +}; + +template<> struct point_type { + using type = bp2d::PointImpl; +}; + +template<> struct indexed_access { + static inline bp2d::Coord get(bp2d::Segment const& seg) { + return bp2d::getX(seg.first()); + } + static inline void set(bp2d::Segment &seg, bp2d::Coord const& coord) { + bp2d::setX(seg.first(), coord); + } +}; + +template<> struct indexed_access { + static inline bp2d::Coord get(bp2d::Segment const& seg) { + return bp2d::getY(seg.first()); + } + static inline void set(bp2d::Segment &seg, bp2d::Coord const& coord) { + bp2d::setY(seg.first(), coord); + } +}; + +template<> struct indexed_access { + static inline bp2d::Coord get(bp2d::Segment const& seg) { + return bp2d::getX(seg.second()); + } + static inline void set(bp2d::Segment &seg, bp2d::Coord const& coord) { + bp2d::setX(seg.second(), coord); + } +}; + +template<> struct indexed_access { + static inline bp2d::Coord get(bp2d::Segment const& seg) { + return bp2d::getY(seg.second()); + } + static inline void set(bp2d::Segment &seg, bp2d::Coord const& coord) { + bp2d::setY(seg.second(), coord); + } +}; + + +/* ************************************************************************** */ +/* Polygon concept adaptaion ************************************************ */ +/* ************************************************************************** */ + +// Connversion between binpack2d::Orientation and order_selector /////////////// + +template struct ToBoostOrienation {}; + +template<> +struct ToBoostOrienation { + static const order_selector Value = clockwise; +}; + +template<> +struct ToBoostOrienation { + static const order_selector Value = counterclockwise; +}; + +static const bp2d::Orientation RealOrientation = + bp2d::OrientationType::Value; + +// Ring implementation ///////////////////////////////////////////////////////// + +// Boost would refer to ClipperLib::Path (alias bp2d::PolygonImpl) as a ring +template<> struct tag { + using type = ring_tag; +}; + +template<> struct point_order { + static const order_selector value = + ToBoostOrienation::Value; +}; + +// All our Paths should be closed for the bin packing application +template<> struct closure { + static const closure_selector value = closed; +}; + +// Polygon implementation ////////////////////////////////////////////////////// + +template<> struct tag { + using type = polygon_tag; +}; + +template<> struct exterior_ring { + static inline bp2d::PathImpl& get(bp2d::PolygonImpl& p) { + return libnest2d::ShapeLike::getContour(p); + } + + static inline bp2d::PathImpl const& get(bp2d::PolygonImpl const& p) { + return libnest2d::ShapeLike::getContour(p); + } +}; + +template<> struct ring_const_type { + using type = const bp2d::PathImpl&; +}; + +template<> struct ring_mutable_type { + using type = bp2d::PathImpl&; +}; + +template<> struct interior_const_type { + using type = const libnest2d::THolesContainer&; +}; + +template<> struct interior_mutable_type { + using type = libnest2d::THolesContainer&; +}; + +template<> +struct interior_rings { + + static inline libnest2d::THolesContainer& get( + bp2d::PolygonImpl& p) + { + return libnest2d::ShapeLike::holes(p); + } + + static inline const libnest2d::THolesContainer& get( + bp2d::PolygonImpl const& p) + { + return libnest2d::ShapeLike::holes(p); + } +}; + +} // traits +} // geometry + +// This is an addition to the ring implementation +template<> +struct range_value { + using type = bp2d::PointImpl; +}; + +} // boost + +namespace libnest2d { // Now the algorithms that boost can provide... + +template<> +inline double PointLike::distance(const PointImpl& p1, + const PointImpl& p2 ) +{ + return boost::geometry::distance(p1, p2); +} + +template<> +inline double PointLike::distance(const PointImpl& p, + const bp2d::Segment& seg ) +{ + return boost::geometry::distance(p, seg); +} + +// Tell binpack2d how to make string out of a ClipperPolygon object +template<> +inline bool ShapeLike::intersects(const PathImpl& sh1, + const PathImpl& sh2) +{ + return boost::geometry::intersects(sh1, sh2); +} + +// Tell binpack2d how to make string out of a ClipperPolygon object +template<> +inline bool ShapeLike::intersects(const PolygonImpl& sh1, + const PolygonImpl& sh2) { + return boost::geometry::intersects(sh1, sh2); +} + +// Tell binpack2d how to make string out of a ClipperPolygon object +template<> +inline bool ShapeLike::intersects(const bp2d::Segment& s1, + const bp2d::Segment& s2) { + return boost::geometry::intersects(s1, s2); +} + +#ifndef DISABLE_BOOST_AREA +template<> +inline double ShapeLike::area(const PolygonImpl& shape) { + return boost::geometry::area(shape); +} +#endif + +template<> +inline bool ShapeLike::isInside(const PointImpl& point, + const PolygonImpl& shape) +{ + return boost::geometry::within(point, shape); +} + +template<> +inline bool ShapeLike::isInside(const PolygonImpl& sh1, + const PolygonImpl& sh2) +{ + return boost::geometry::within(sh1, sh2); +} + +template<> +inline bool ShapeLike::touches( const PolygonImpl& sh1, + const PolygonImpl& sh2) +{ + return boost::geometry::touches(sh1, sh2); +} + +template<> +inline bp2d::Box ShapeLike::boundingBox(const PolygonImpl& sh) { + bp2d::Box b; + boost::geometry::envelope(sh, b); + return b; +} + +template<> +inline void ShapeLike::rotate(PolygonImpl& sh, const Radians& rads) { + namespace trans = boost::geometry::strategy::transform; + + PolygonImpl cpy = sh; + + trans::rotate_transformer + rotate(rads); + boost::geometry::transform(cpy, sh, rotate); +} + +template<> +inline void ShapeLike::translate(PolygonImpl& sh, const PointImpl& offs) { + namespace trans = boost::geometry::strategy::transform; + + PolygonImpl cpy = sh; + trans::translate_transformer translate( + bp2d::getX(offs), bp2d::getY(offs)); + + boost::geometry::transform(cpy, sh, translate); +} + +#ifndef DISABLE_BOOST_OFFSET +template<> +inline void ShapeLike::offset(PolygonImpl& sh, bp2d::Coord distance) { + PolygonImpl cpy = sh; + boost::geometry::buffer(cpy, sh, distance); +} +#endif + +#ifndef DISABLE_BOOST_MINKOWSKI_ADD +template<> +inline PolygonImpl& Nfp::minkowskiAdd(PolygonImpl& sh, + const PolygonImpl& /*other*/) { + return sh; +} +#endif + +#ifndef DISABLE_BOOST_SERIALIZE +template<> +inline std::string ShapeLike::serialize( + const PolygonImpl& sh) +{ + + std::stringstream ss; + std::string style = "fill: orange; stroke: black; stroke-width: 1px;"; + auto svg_data = boost::geometry::svg(sh, style); + + ss << svg_data << std::endl; + + return ss.str(); +} +#endif + +#ifndef DISABLE_BOOST_UNSERIALIZE +template<> +inline void ShapeLike::unserialize( + PolygonImpl& sh, + const std::string& str) +{ +} +#endif + +template<> inline std::pair +ShapeLike::isValid(const PolygonImpl& sh) { + std::string message; + bool ret = boost::geometry::is_valid(sh, message); + + return {ret, message}; +} + +} + + + +#endif // BOOST_ALG_HPP diff --git a/xs/src/libnest2d/libnest2d/clipper_backend/CMakeLists.txt b/xs/src/libnest2d/libnest2d/clipper_backend/CMakeLists.txt new file mode 100644 index 0000000000..9e6a48cf6f --- /dev/null +++ b/xs/src/libnest2d/libnest2d/clipper_backend/CMakeLists.txt @@ -0,0 +1,48 @@ +if(NOT TARGET clipper) # If there is a clipper target in the parent project we are good to go. + + find_package(Clipper QUIET) + + if(NOT CLIPPER_FOUND) + find_package(Subversion QUIET) + if(Subversion_FOUND) + message(STATUS "Clipper not found so it will be downloaded.") + # Silently download and build the library in the build dir + + if (CMAKE_VERSION VERSION_LESS 3.2) + set(UPDATE_DISCONNECTED_IF_AVAILABLE "") + else() + set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1") + endif() + + include(DownloadProject) + download_project( PROJ clipper_library + SVN_REPOSITORY https://svn.code.sf.net/p/polyclipping/code/trunk/cpp + SVN_REVISION -r540 + #SOURCE_SUBDIR cpp + INSTALL_COMMAND "" + CONFIGURE_COMMAND "" # Not working, I will just add the source files + ${UPDATE_DISCONNECTED_IF_AVAILABLE} + ) + + # This is not working and I dont have time to fix it + # add_subdirectory(${clipper_library_SOURCE_DIR}/cpp + # ${clipper_library_BINARY_DIR} + # ) + + add_library(clipper_lib STATIC + ${clipper_library_SOURCE_DIR}/clipper.cpp + ${clipper_library_SOURCE_DIR}/clipper.hpp) + + set(CLIPPER_INCLUDE_DIRS ${clipper_library_SOURCE_DIR} + PARENT_SCOPE) + + set(CLIPPER_LIBRARIES clipper_lib PARENT_SCOPE) + + else() + message(FATAL_ERROR "Can't find clipper library and no SVN client found to download. + You can download the clipper sources and define a clipper target in your project, that will work for libnest2d.") + endif() + endif() +else() + set(CLIPPER_LIBRARIES clipper PARENT_SCOPE) +endif() diff --git a/xs/src/libnest2d/libnest2d/clipper_backend/clipper_backend.cpp b/xs/src/libnest2d/libnest2d/clipper_backend/clipper_backend.cpp new file mode 100644 index 0000000000..08b0950871 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/clipper_backend/clipper_backend.cpp @@ -0,0 +1,77 @@ +#include "clipper_backend.hpp" + +namespace libnest2d { + +namespace { +class HoleCache { + friend struct libnest2d::ShapeLike; + + std::unordered_map< const PolygonImpl*, ClipperLib::Paths> map; + + ClipperLib::Paths& _getHoles(const PolygonImpl* p) { + ClipperLib::Paths& paths = map[p]; + + if(paths.size() != p->Childs.size()) { + paths.reserve(p->Childs.size()); + + for(auto np : p->Childs) { + paths.emplace_back(np->Contour); + } + } + + return paths; + } + + ClipperLib::Paths& getHoles(PolygonImpl& p) { + return _getHoles(&p); + } + + const ClipperLib::Paths& getHoles(const PolygonImpl& p) { + return _getHoles(&p); + } +}; +} + +HoleCache holeCache; + +template<> +std::string ShapeLike::toString(const PolygonImpl& sh) +{ + std::stringstream ss; + + for(auto p : sh.Contour) { + ss << p.X << " " << p.Y << "\n"; + } + + return ss.str(); +} + +template<> PolygonImpl ShapeLike::create( std::initializer_list< PointImpl > il) +{ + PolygonImpl p; + p.Contour = il; + + // Expecting that the coordinate system Y axis is positive in upwards + // direction + if(ClipperLib::Orientation(p.Contour)) { + // Not clockwise then reverse the b*tch + ClipperLib::ReversePath(p.Contour); + } + + return p; +} + +template<> +const THolesContainer& ShapeLike::holes( + const PolygonImpl& sh) +{ + return holeCache.getHoles(sh); +} + +template<> +THolesContainer& ShapeLike::holes(PolygonImpl& sh) { + return holeCache.getHoles(sh); +} + +} + diff --git a/xs/src/libnest2d/libnest2d/clipper_backend/clipper_backend.hpp b/xs/src/libnest2d/libnest2d/clipper_backend/clipper_backend.hpp new file mode 100644 index 0000000000..92a8067272 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/clipper_backend/clipper_backend.hpp @@ -0,0 +1,240 @@ +#ifndef CLIPPER_BACKEND_HPP +#define CLIPPER_BACKEND_HPP + +#include +#include +#include + +#include + +#include "../geometry_traits.hpp" +#include "../geometries_nfp.hpp" + +#include + +namespace libnest2d { + +// Aliases for convinience +using PointImpl = ClipperLib::IntPoint; +using PolygonImpl = ClipperLib::PolyNode; +using PathImpl = ClipperLib::Path; + +inline PointImpl& operator +=(PointImpl& p, const PointImpl& pa ) { + p.X += pa.X; + p.Y += pa.Y; + return p; +} + +inline PointImpl operator+(const PointImpl& p1, const PointImpl& p2) { + PointImpl ret = p1; + ret += p2; + return ret; +} + +inline PointImpl& operator -=(PointImpl& p, const PointImpl& pa ) { + p.X -= pa.X; + p.Y -= pa.Y; + return p; +} + +inline PointImpl operator-(const PointImpl& p1, const PointImpl& p2) { + PointImpl ret = p1; + ret -= p2; + return ret; +} + +//extern HoleCache holeCache; + +// Type of coordinate units used by Clipper +template<> struct CoordType { + using Type = ClipperLib::cInt; +}; + +// Type of point used by Clipper +template<> struct PointType { + using Type = PointImpl; +}; + +// Type of vertex iterator used by Clipper +template<> struct VertexIteratorType { + using Type = ClipperLib::Path::iterator; +}; + +// Type of vertex iterator used by Clipper +template<> struct VertexConstIteratorType { + using Type = ClipperLib::Path::const_iterator; +}; + +template<> struct CountourType { + using Type = PathImpl; +}; + +// Tell binpack2d how to extract the X coord from a ClipperPoint object +template<> inline TCoord PointLike::x(const PointImpl& p) +{ + return p.X; +} + +// Tell binpack2d how to extract the Y coord from a ClipperPoint object +template<> inline TCoord PointLike::y(const PointImpl& p) +{ + return p.Y; +} + +// Tell binpack2d how to extract the X coord from a ClipperPoint object +template<> inline TCoord& PointLike::x(PointImpl& p) +{ + return p.X; +} + +// Tell binpack2d how to extract the Y coord from a ClipperPoint object +template<> +inline TCoord& PointLike::y(PointImpl& p) +{ + return p.Y; +} + +template<> +inline void ShapeLike::reserve(PolygonImpl& sh, unsigned long vertex_capacity) +{ + return sh.Contour.reserve(vertex_capacity); +} + +// Tell binpack2d how to make string out of a ClipperPolygon object +template<> +inline double ShapeLike::area(const PolygonImpl& sh) { + #define DISABLE_BOOST_AREA + double ret = ClipperLib::Area(sh.Contour); +// if(OrientationType::Value == Orientation::COUNTER_CLOCKWISE) +// ret = -ret; + return ret; +} + +template<> +inline void ShapeLike::offset(PolygonImpl& sh, TCoord distance) { + #define DISABLE_BOOST_OFFSET + + using ClipperLib::ClipperOffset; + using ClipperLib::jtMiter; + using ClipperLib::etClosedPolygon; + using ClipperLib::Paths; + + ClipperOffset offs; + Paths result; + offs.AddPath(sh.Contour, jtMiter, etClosedPolygon); + offs.Execute(result, static_cast(distance)); + + // I dont know why does the offsetting revert the orientation and + // it removes the last vertex as well so boost will not have a closed + // polygon + + assert(result.size() == 1); + sh.Contour = result.front(); + + // recreate closed polygon + sh.Contour.push_back(sh.Contour.front()); + + if(ClipperLib::Orientation(sh.Contour)) { + // Not clockwise then reverse the b*tch + ClipperLib::ReversePath(sh.Contour); + } + +} + +template<> +inline PolygonImpl& Nfp::minkowskiAdd(PolygonImpl& sh, + const PolygonImpl& other) +{ + #define DISABLE_BOOST_MINKOWSKI_ADD + + ClipperLib::Paths solution; + + ClipperLib::MinkowskiSum(sh.Contour, other.Contour, solution, true); + + assert(solution.size() == 1); + + sh.Contour = solution.front(); + + return sh; +} + +// Tell binpack2d how to make string out of a ClipperPolygon object +template<> std::string ShapeLike::toString(const PolygonImpl& sh); + +template<> +inline TVertexIterator ShapeLike::begin(PolygonImpl& sh) +{ + return sh.Contour.begin(); +} + +template<> +inline TVertexIterator ShapeLike::end(PolygonImpl& sh) +{ + return sh.Contour.end(); +} + +template<> +inline TVertexConstIterator ShapeLike::cbegin( + const PolygonImpl& sh) +{ + return sh.Contour.cbegin(); +} + +template<> +inline TVertexConstIterator ShapeLike::cend( + const PolygonImpl& sh) +{ + return sh.Contour.cend(); +} + +template<> struct HolesContainer { + using Type = ClipperLib::Paths; +}; + +template<> +PolygonImpl ShapeLike::create( std::initializer_list< PointImpl > il); + +template<> +const THolesContainer& ShapeLike::holes( + const PolygonImpl& sh); + +template<> +THolesContainer& ShapeLike::holes(PolygonImpl& sh); + +template<> +inline TCountour& ShapeLike::getHole(PolygonImpl& sh, + unsigned long idx) +{ + return sh.Childs[idx]->Contour; +} + +template<> +inline const TCountour& ShapeLike::getHole(const PolygonImpl& sh, + unsigned long idx) { + return sh.Childs[idx]->Contour; +} + +template<> +inline size_t ShapeLike::holeCount(const PolygonImpl& sh) { + return sh.Childs.size(); +} + +template<> +inline PathImpl& ShapeLike::getContour(PolygonImpl& sh) { + return sh.Contour; +} + +template<> +inline const PathImpl& ShapeLike::getContour(const PolygonImpl& sh) { + return sh.Contour; +} + +} + +//#define DISABLE_BOOST_SERIALIZE +//#define DISABLE_BOOST_UNSERIALIZE + +// All other operators and algorithms are implemented with boost +#include "../boost_alg.hpp" + +#endif // CLIPPER_BACKEND_HPP diff --git a/xs/src/libnest2d/libnest2d/common.hpp b/xs/src/libnest2d/libnest2d/common.hpp new file mode 100644 index 0000000000..6e6174352b --- /dev/null +++ b/xs/src/libnest2d/libnest2d/common.hpp @@ -0,0 +1,94 @@ +#ifndef LIBNEST2D_CONFIG_HPP +#define LIBNEST2D_CONFIG_HPP + +#if defined(_MSC_VER) && _MSC_VER <= 1800 || __cplusplus < 201103L + #define BP2D_NOEXCEPT + #define BP2D_CONSTEXPR +#elif __cplusplus >= 201103L + #define BP2D_NOEXCEPT noexcept + #define BP2D_CONSTEXPR constexpr +#endif + +#include +#include +#include + +namespace libnest2d { + +template< class T > +struct remove_cvref { + using type = typename std::remove_cv< + typename std::remove_reference::type>::type; +}; + +template< class T > +using remove_cvref_t = typename remove_cvref::type; + +template +using enable_if_t = typename std::enable_if::type; + +/** + * A useful little tool for triggering static_assert error messages e.g. when + * a mandatory template specialization (implementation) is missing. + * + * \tparam T A template argument that may come from and outer template method. + */ +template struct always_false { enum { value = false }; }; + +const auto BP2D_CONSTEXPR Pi = 3.141592653589793238463; // 2*std::acos(0); + +/** + * @brief Only for the Radian and Degrees classes to behave as doubles. + */ +class Double { + double val_; +public: + Double(): val_(double{}) { } + Double(double d) : val_(d) { } + + operator double() const BP2D_NOEXCEPT { return val_; } + operator double&() BP2D_NOEXCEPT { return val_; } +}; + +class Degrees; + +/** + * @brief Data type representing radians. It supports conversion to degrees. + */ +class Radians: public Double { +public: + Radians(double rads = Double() ): Double(rads) {} + inline Radians(const Degrees& degs); + + inline operator Degrees(); + inline double toDegrees(); +}; + +/** + * @brief Data type representing degrees. It supports conversion to radians. + */ +class Degrees: public Double { +public: + Degrees(double deg = Double()): Double(deg) {} + Degrees(const Radians& rads): Double( rads * 180/Pi ) {} + inline double toRadians() { return Radians(*this);} +}; + +inline bool operator==(const Degrees& deg, const Radians& rads) { + Degrees deg2 = rads; + auto diff = std::abs(deg - deg2); + return diff < 0.0001; +} + +inline bool operator==(const Radians& rads, const Degrees& deg) { + return deg == rads; +} + +inline Radians::operator Degrees() { return *this * 180/Pi; } + +inline Radians::Radians(const Degrees °s): Double( degs * Pi/180) {} + +inline double Radians::toDegrees() { return operator Degrees(); } + +} +#endif // LIBNEST2D_CONFIG_HPP diff --git a/xs/src/libnest2d/libnest2d/geometries_io.hpp b/xs/src/libnest2d/libnest2d/geometries_io.hpp new file mode 100644 index 0000000000..dbcae52562 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/geometries_io.hpp @@ -0,0 +1,18 @@ +#ifndef GEOMETRIES_IO_HPP +#define GEOMETRIES_IO_HPP + +#include "libnest2d.hpp" + +#include + +namespace libnest2d { + +template +std::ostream& operator<<(std::ostream& stream, const _Item& sh) { + stream << sh.toString() << "\n"; + return stream; +} + +} + +#endif // GEOMETRIES_IO_HPP diff --git a/xs/src/libnest2d/libnest2d/geometries_nfp.hpp b/xs/src/libnest2d/libnest2d/geometries_nfp.hpp new file mode 100644 index 0000000000..219c4b5654 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/geometries_nfp.hpp @@ -0,0 +1,125 @@ +#ifndef GEOMETRIES_NOFITPOLYGON_HPP +#define GEOMETRIES_NOFITPOLYGON_HPP + +#include "geometry_traits.hpp" +#include + +namespace libnest2d { + +struct Nfp { + +template +static RawShape& minkowskiAdd(RawShape& sh, const RawShape& /*other*/) { + static_assert(always_false::value, + "ShapeLike::minkowskiAdd() unimplemented!"); + return sh; +} + +template +static RawShape noFitPolygon(const RawShape& sh, const RawShape& other) { + auto isConvex = [](const RawShape& sh) { + + return true; + }; + + using Vertex = TPoint; + using Edge = _Segment; + + auto nfpConvexConvex = [] ( + const RawShape& sh, + const RawShape& cother) + { + RawShape other = cother; + + // Make it counter-clockwise + for(auto shit = ShapeLike::begin(other); + shit != ShapeLike::end(other); ++shit ) { + auto& v = *shit; + setX(v, -getX(v)); + setY(v, -getY(v)); + } + + RawShape rsh; + std::vector edgelist; + + size_t cap = ShapeLike::contourVertexCount(sh) + + ShapeLike::contourVertexCount(other); + + edgelist.reserve(cap); + ShapeLike::reserve(rsh, cap); + + { + auto first = ShapeLike::cbegin(sh); + auto next = first + 1; + auto endit = ShapeLike::cend(sh); + + while(next != endit) edgelist.emplace_back(*(first++), *(next++)); + } + + { + auto first = ShapeLike::cbegin(other); + auto next = first + 1; + auto endit = ShapeLike::cend(other); + + while(next != endit) edgelist.emplace_back(*(first++), *(next++)); + } + + std::sort(edgelist.begin(), edgelist.end(), + [](const Edge& e1, const Edge& e2) + { + return e1.angleToXaxis() > e2.angleToXaxis(); + }); + + ShapeLike::addVertex(rsh, edgelist.front().first()); + ShapeLike::addVertex(rsh, edgelist.front().second()); + + auto tmp = std::next(ShapeLike::begin(rsh)); + + // Construct final nfp + for(auto eit = std::next(edgelist.begin()); + eit != edgelist.end(); + ++eit) { + + auto dx = getX(*tmp) - getX(eit->first()); + auto dy = getY(*tmp) - getY(eit->first()); + + ShapeLike::addVertex(rsh, getX(eit->second())+dx, + getY(eit->second())+dy ); + + tmp = std::next(tmp); + } + + return rsh; + }; + + RawShape rsh; + + enum e_dispatch { + CONVEX_CONVEX, + CONCAVE_CONVEX, + CONVEX_CONCAVE, + CONCAVE_CONCAVE + }; + + int sel = isConvex(sh) ? CONVEX_CONVEX : CONCAVE_CONVEX; + sel += isConvex(other) ? CONVEX_CONVEX : CONVEX_CONCAVE; + + switch(sel) { + case CONVEX_CONVEX: + rsh = nfpConvexConvex(sh, other); break; + case CONCAVE_CONVEX: + break; + case CONVEX_CONCAVE: + break; + case CONCAVE_CONCAVE: + break; + } + + return rsh; +} + +}; + +} + +#endif // GEOMETRIES_NOFITPOLYGON_HPP diff --git a/xs/src/libnest2d/libnest2d/geometry_traits.hpp b/xs/src/libnest2d/libnest2d/geometry_traits.hpp new file mode 100644 index 0000000000..2ab2d1c498 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/geometry_traits.hpp @@ -0,0 +1,501 @@ +#ifndef GEOMETRY_TRAITS_HPP +#define GEOMETRY_TRAITS_HPP + +#include +#include +#include +#include +#include + +#include "common.hpp" + +namespace libnest2d { + +/// Getting the coordinate data type for a geometry class. +template struct CoordType { using Type = long; }; + +/// TCoord as shorthand for typename `CoordType::Type`. +template +using TCoord = typename CoordType>::Type; + +/// Getting the type of point structure used by a shape. +template struct PointType { using Type = void; }; + +/// TPoint as shorthand for `typename PointType::Type`. +template +using TPoint = typename PointType>::Type; + +/// Getting the VertexIterator type of a shape class. +template struct VertexIteratorType { using Type = void; }; + +/// Getting the const vertex iterator for a shape class. +template struct VertexConstIteratorType { using Type = void; }; + +/** + * TVertexIterator as shorthand for + * `typename VertexIteratorType::Type` + */ +template +using TVertexIterator = +typename VertexIteratorType>::Type; + +/** + * \brief TVertexConstIterator as shorthand for + * `typename VertexConstIteratorType::Type` + */ +template +using TVertexConstIterator = +typename VertexConstIteratorType>::Type; + +/** + * \brief A point pair base class for other point pairs (segment, box, ...). + * \tparam RawPoint The actual point type to use. + */ +template +struct PointPair { + RawPoint p1; + RawPoint p2; +}; + +/** + * \brief An abstraction of a box; + */ +template +class _Box: PointPair { + using PointPair::p1; + using PointPair::p2; +public: + + inline _Box() {} + inline _Box(const RawPoint& p, const RawPoint& pp): + PointPair({p, pp}) {} + + inline _Box(TCoord width, TCoord height): + _Box(RawPoint{0, 0}, RawPoint{width, height}) {} + + inline const RawPoint& minCorner() const BP2D_NOEXCEPT { return p1; } + inline const RawPoint& maxCorner() const BP2D_NOEXCEPT { return p2; } + + inline RawPoint& minCorner() BP2D_NOEXCEPT { return p1; } + inline RawPoint& maxCorner() BP2D_NOEXCEPT { return p2; } + + inline TCoord width() const BP2D_NOEXCEPT; + inline TCoord height() const BP2D_NOEXCEPT; +}; + +template +class _Segment: PointPair { + using PointPair::p1; + using PointPair::p2; +public: + + inline _Segment() {} + inline _Segment(const RawPoint& p, const RawPoint& pp): + PointPair({p, pp}) {} + + inline const RawPoint& first() const BP2D_NOEXCEPT { return p1; } + inline const RawPoint& second() const BP2D_NOEXCEPT { return p2; } + + inline RawPoint& first() BP2D_NOEXCEPT { return p1; } + inline RawPoint& second() BP2D_NOEXCEPT { return p2; } + + inline Radians angleToXaxis() const; +}; + +class PointLike { +public: + + template + static TCoord x(const RawPoint& p) + { + return p.x(); + } + + template + static TCoord y(const RawPoint& p) + { + return p.y(); + } + + template + static TCoord& x(RawPoint& p) + { + return p.x(); + } + + template + static TCoord& y(RawPoint& p) + { + return p.y(); + } + + template + static double distance(const RawPoint& /*p1*/, const RawPoint& /*p2*/) + { + static_assert(always_false::value, + "PointLike::distance(point, point) unimplemented"); + return 0; + } + + template + static double distance(const RawPoint& /*p1*/, + const _Segment& /*s*/) + { + static_assert(always_false::value, + "PointLike::distance(point, segment) unimplemented"); + return 0; + } + + template + static std::pair, bool> horizontalDistance( + const RawPoint& p, const _Segment& s) + { + using Unit = TCoord; + auto x = PointLike::x(p), y = PointLike::y(p); + auto x1 = PointLike::x(s.first()), y1 = PointLike::y(s.first()); + auto x2 = PointLike::x(s.second()), y2 = PointLike::y(s.second()); + + TCoord ret; + + if( (y < y1 && y < y2) || (y > y1 && y > y2) ) + return {0, false}; + else if ((y == y1 && y == y2) && (x > x1 && x > x2)) + ret = std::min( x-x1, x -x2); + else if( (y == y1 && y == y2) && (x < x1 && x < x2)) + ret = -std::min(x1 - x, x2 - x); + else if(std::abs(y - y1) <= std::numeric_limits::epsilon() && + std::abs(y - y2) <= std::numeric_limits::epsilon()) + ret = 0; + else + ret = x - x1 + (x1 - x2)*(y1 - y)/(y1 - y2); + + return {ret, true}; + } + + template + static std::pair, bool> verticalDistance( + const RawPoint& p, const _Segment& s) + { + using Unit = TCoord; + auto x = PointLike::x(p), y = PointLike::y(p); + auto x1 = PointLike::x(s.first()), y1 = PointLike::y(s.first()); + auto x2 = PointLike::x(s.second()), y2 = PointLike::y(s.second()); + + TCoord ret; + + if( (x < x1 && x < x2) || (x > x1 && x > x2) ) + return {0, false}; + else if ((x == x1 && x == x2) && (y > y1 && y > y2)) + ret = std::min( y-y1, y -y2); + else if( (x == x1 && x == x2) && (y < y1 && y < y2)) + ret = -std::min(y1 - y, y2 - y); + else if(std::abs(x - x1) <= std::numeric_limits::epsilon() && + std::abs(x - x2) <= std::numeric_limits::epsilon()) + ret = 0; + else + ret = y - y1 + (y1 - y2)*(x1 - x)/(x1 - x2); + + return {ret, true}; + } +}; + +template +TCoord _Box::width() const BP2D_NOEXCEPT { + return PointLike::x(maxCorner()) - PointLike::x(minCorner()); +} + + +template +TCoord _Box::height() const BP2D_NOEXCEPT { + return PointLike::y(maxCorner()) - PointLike::y(minCorner()); +} + +template +TCoord getX(const RawPoint& p) { return PointLike::x(p); } + +template +TCoord getY(const RawPoint& p) { return PointLike::y(p); } + +template +void setX(RawPoint& p, const TCoord& val) { + PointLike::x(p) = val; +} + +template +void setY(RawPoint& p, const TCoord& val) { + PointLike::y(p) = val; +} + +template +inline Radians _Segment::angleToXaxis() const +{ + TCoord dx = getX(second()) - getX(first()); + TCoord dy = getY(second()) - getY(first()); + + if(dx == 0 && dy >= 0) return Pi/2; + if(dx == 0 && dy < 0) return 3*Pi/2; + if(dy == 0 && dx >= 0) return 0; + if(dy == 0 && dx < 0) return Pi; + + double ddx = static_cast(dx); + auto s = std::signbit(ddx); + double a = std::atan(ddx/dy); + if(s) a += Pi; + return a; +} + +template +struct HolesContainer { + using Type = std::vector; +}; + +template +using THolesContainer = typename HolesContainer>::Type; + +template +struct CountourType { + using Type = RawShape; +}; + +template +using TCountour = typename CountourType>::Type; + +enum class Orientation { + CLOCKWISE, + COUNTER_CLOCKWISE +}; + +template +struct OrientationType { + + // Default Polygon orientation that the library expects + static const Orientation Value = Orientation::CLOCKWISE; +}; + +enum class Formats { + WKT, + SVG +}; + +struct ShapeLike { + + template + static RawShape create( std::initializer_list< TPoint > il) + { + return RawShape(il); + } + + // Optional, does nothing by default + template + static void reserve(RawShape& /*sh*/, unsigned long /*vertex_capacity*/) {} + + template + static void addVertex(RawShape& sh, Args...args) + { + return getContour(sh).emplace_back(std::forward(args)...); + } + + template + static TVertexIterator begin(RawShape& sh) + { + return sh.begin(); + } + + template + static TVertexIterator end(RawShape& sh) + { + return sh.end(); + } + + template + static TVertexConstIterator cbegin(const RawShape& sh) + { + return sh.cbegin(); + } + + template + static TVertexConstIterator cend(const RawShape& sh) + { + return sh.cend(); + } + + template + static TPoint& vertex(RawShape& sh, unsigned long idx) + { + return *(begin(sh) + idx); + } + + template + static const TPoint& vertex(const RawShape& sh, + unsigned long idx) + { + return *(cbegin(sh) + idx); + } + + template + static size_t contourVertexCount(const RawShape& sh) + { + return cend(sh) - cbegin(sh); + } + + template + static std::string toString(const RawShape& /*sh*/) + { + return ""; + } + + template + static std::string serialize(const RawShape& /*sh*/) + { + static_assert(always_false::value, + "ShapeLike::serialize() unimplemented"); + return ""; + } + + template + static void unserialize(RawShape& /*sh*/, const std::string& /*str*/) + { + static_assert(always_false::value, + "ShapeLike::unserialize() unimplemented"); + } + + template + static double area(const RawShape& /*sh*/) + { + static_assert(always_false::value, + "ShapeLike::area() unimplemented"); + return 0; + } + + template + static double area(const _Box>& box) + { + return box.width() * box.height(); + return 0; + } + + template + static bool intersects(const RawShape& /*sh*/, const RawShape& /*sh*/) + { + static_assert(always_false::value, + "ShapeLike::intersects() unimplemented"); + return false; + } + + template + static bool isInside(const TPoint& /*point*/, + const RawShape& /*shape*/) + { + static_assert(always_false::value, + "ShapeLike::isInside(point, shape) unimplemented"); + return false; + } + + template + static bool isInside(const RawShape& /*shape*/, + const RawShape& /*shape*/) + { + static_assert(always_false::value, + "ShapeLike::isInside(shape, shape) unimplemented"); + return false; + } + + template + static bool touches( const RawShape& /*shape*/, + const RawShape& /*shape*/) + { + static_assert(always_false::value, + "ShapeLike::touches(shape, shape) unimplemented"); + return false; + } + + template + static _Box> boundingBox(const RawShape& /*sh*/) + { + static_assert(always_false::value, + "ShapeLike::boundingBox(shape) unimplemented"); + } + + template + static _Box> boundingBox(const _Box>& box) + { + return box; + } + + template + static THolesContainer& holes(RawShape& /*sh*/) + { + static THolesContainer empty; + return empty; + } + + template + static const THolesContainer& holes(const RawShape& /*sh*/) + { + static THolesContainer empty; + return empty; + } + + template + static TCountour& getHole(RawShape& sh, unsigned long idx) + { + return holes(sh)[idx]; + } + + template + static const TCountour& getHole(const RawShape& sh, + unsigned long idx) + { + return holes(sh)[idx]; + } + + template + static size_t holeCount(const RawShape& sh) + { + return holes(sh).size(); + } + + template + static TCountour& getContour(RawShape& sh) + { + return sh; + } + + template + static const TCountour& getContour(const RawShape& sh) + { + return sh; + } + + template + static void rotate(RawShape& /*sh*/, const Radians& /*rads*/) + { + static_assert(always_false::value, + "ShapeLike::rotate() unimplemented"); + } + + template + static void translate(RawShape& /*sh*/, const RawPoint& /*offs*/) + { + static_assert(always_false::value, + "ShapeLike::translate() unimplemented"); + } + + template + static void offset(RawShape& /*sh*/, TCoord> /*distance*/) + { + static_assert(always_false::value, + "ShapeLike::offset() unimplemented!"); + } + + template + static std::pair isValid(const RawShape& /*sh*/) { + return {false, "ShapeLike::isValid() unimplemented"}; + } + +}; + + +} + +#endif // GEOMETRY_TRAITS_HPP diff --git a/xs/src/libnest2d/libnest2d/libnest2d.hpp b/xs/src/libnest2d/libnest2d/libnest2d.hpp new file mode 100644 index 0000000000..e57e49779d --- /dev/null +++ b/xs/src/libnest2d/libnest2d/libnest2d.hpp @@ -0,0 +1,802 @@ +#ifndef LIBNEST2D_HPP +#define LIBNEST2D_HPP + +#include +#include +#include +#include +#include +#include + +#include "geometry_traits.hpp" + +namespace libnest2d { + +/** + * \brief An item to be placed on a bin. + * + * It holds a copy of the original shape object but supports move construction + * from the shape objects if its an rvalue reference. This way we can construct + * the items without the cost of copying a potentially large amount of input. + * + * The results of some calculations are cached for maintaining fast run times. + * For this reason, memory demands are much higher but this should pay off. + */ +template +class _Item { + using Coord = TCoord>; + using Vertex = TPoint; + using Box = _Box; + + // The original shape that gets encapsulated. + RawShape sh_; + + // Transformation data + Vertex translation_; + Radians rotation_; + Coord offset_distance_; + + // Info about whether the tranformations will have to take place + // This is needed because if floating point is used, it is hard to say + // that a zero angle is not a rotation because of testing for equality. + bool has_rotation_ = false, has_translation_ = false, has_offset_ = false; + + // For caching the calculations as they can get pretty expensive. + mutable RawShape tr_cache_; + mutable bool tr_cache_valid_ = false; + mutable double area_cache_ = 0; + mutable bool area_cache_valid_ = false; + mutable RawShape offset_cache_; + mutable bool offset_cache_valid_ = false; +public: + + /// The type of the shape which was handed over as the template argument. + using ShapeType = RawShape; + + /** + * \brief Iterator type for the outer vertices. + * + * Only const iterators can be used. The _Item type is not intended to + * modify the carried shapes from the outside. The main purpose of this type + * is to cache the calculation results from the various operators it + * supports. Giving out a non const iterator would make it impossible to + * perform correct cache invalidation. + */ + using Iterator = TVertexConstIterator; + + /** + * @brief Get the orientation of the polygon. + * + * The orientation have to be specified as a specialization of the + * OrientationType struct which has a Value constant. + * + * @return The orientation type identifier for the _Item type. + */ + static BP2D_CONSTEXPR Orientation orientation() { + return OrientationType::Value; + } + + /** + * @brief Constructing an _Item form an existing raw shape. The shape will + * be copied into the _Item object. + * @param sh The original shape object. + */ + explicit inline _Item(const RawShape& sh): sh_(sh) {} + + /** + * @brief Construction of an item by moving the content of the raw shape, + * assuming that it supports move semantics. + * @param sh The original shape object. + */ + explicit inline _Item(RawShape&& sh): sh_(std::move(sh)) {} + + /** + * @brief Create an item from an initilizer list. + * @param il The initializer list of vertices. + */ + inline _Item(const std::initializer_list< Vertex >& il): + sh_(ShapeLike::create(il)) {} + + /** + * @brief Convert the polygon to string representation. The format depends + * on the implementation of the polygon. + * @return + */ + inline std::string toString() const + { + return ShapeLike::toString(sh_); + } + + /// Iterator tho the first vertex in the polygon. + inline Iterator begin() const + { + return ShapeLike::cbegin(sh_); + } + + /// Alias to begin() + inline Iterator cbegin() const + { + return ShapeLike::cbegin(sh_); + } + + /// Iterator to the last element. + inline Iterator end() const + { + return ShapeLike::cend(sh_); + } + + /// Alias to end() + inline Iterator cend() const + { + return ShapeLike::cend(sh_); + } + + /** + * @brief Get a copy of an outer vertex whithin the carried shape. + * + * Note that the vertex considered here is taken from the original shape + * that this item is constructed from. This means that no transformation is + * applied to the shape in this call. + * + * @param idx The index of the requested vertex. + * @return A copy of the requested vertex. + */ + inline Vertex vertex(unsigned long idx) const + { + return ShapeLike::vertex(sh_, idx); + } + + /** + * @brief Modify a vertex. + * + * Note that this method will invalidate every cached calculation result + * including polygon offset and transformations. + * + * @param idx The index of the requested vertex. + * @param v The new vertex data. + */ + inline void setVertex(unsigned long idx, + const Vertex& v ) + { + invalidateCache(); + ShapeLike::vertex(sh_, idx) = v; + } + + /** + * @brief Calculate the shape area. + * + * The method returns absolute value and does not reflect polygon + * orientation. The result is cached, subsequent calls will have very little + * cost. + * @return The shape area in floating point double precision. + */ + inline double area() const { + double ret ; + if(area_cache_valid_) ret = area_cache_; + else { + ret = std::abs(ShapeLike::area(offsettedShape())); + area_cache_ = ret; + area_cache_valid_ = true; + } + return ret; + } + + /// The number of the outer ring vertices. + inline unsigned long vertexCount() const { + return ShapeLike::contourVertexCount(sh_); + } + + /** + * @brief isPointInside + * @param p + * @return + */ + inline bool isPointInside(const Vertex& p) + { + return ShapeLike::isInside(p, sh_); + } + + inline bool isInside(const _Item& sh) const + { + return ShapeLike::isInside(transformedShape(), sh.transformedShape()); + } + + inline void translate(const Vertex& d) BP2D_NOEXCEPT + { + translation_ += d; has_translation_ = true; + tr_cache_valid_ = false; + } + + inline void rotate(const Radians& rads) BP2D_NOEXCEPT + { + rotation_ += rads; + has_rotation_ = true; + tr_cache_valid_ = false; + } + + inline void addOffset(Coord distance) BP2D_NOEXCEPT + { + offset_distance_ = distance; + has_offset_ = true; + offset_cache_valid_ = false; + } + + inline void removeOffset() BP2D_NOEXCEPT { + has_offset_ = false; + invalidateCache(); + } + + inline Radians rotation() const BP2D_NOEXCEPT + { + return rotation_; + } + + inline TPoint translation() const BP2D_NOEXCEPT + { + return translation_; + } + + inline void rotation(Radians rot) BP2D_NOEXCEPT + { + if(rotation_ != rot) { + rotation_ = rot; has_rotation_ = true; tr_cache_valid_ = false; + } + } + + inline void translation(const TPoint& tr) BP2D_NOEXCEPT + { + if(translation_ != tr) { + translation_ = tr; has_translation_ = true; tr_cache_valid_ = false; + } + } + + inline RawShape transformedShape() const + { + if(tr_cache_valid_) return tr_cache_; + + RawShape cpy = offsettedShape(); + if(has_rotation_) ShapeLike::rotate(cpy, rotation_); + if(has_translation_) ShapeLike::translate(cpy, translation_); + tr_cache_ = cpy; tr_cache_valid_ = true; + + return cpy; + } + + inline operator RawShape() const + { + return transformedShape(); + } + + inline const RawShape& rawShape() const BP2D_NOEXCEPT + { + return sh_; + } + + inline void resetTransformation() BP2D_NOEXCEPT + { + has_translation_ = false; has_rotation_ = false; has_offset_ = false; + } + + inline Box boundingBox() const { + return ShapeLike::boundingBox(transformedShape()); + } + + //Static methods: + + inline static bool intersects(const _Item& sh1, const _Item& sh2) + { + return ShapeLike::intersects(sh1.transformedShape(), + sh2.transformedShape()); + } + + inline static bool touches(const _Item& sh1, const _Item& sh2) + { + return ShapeLike::touches(sh1.transformedShape(), + sh2.transformedShape()); + } + +private: + + inline const RawShape& offsettedShape() const { + if(has_offset_ ) { + if(offset_cache_valid_) return offset_cache_; + else { + offset_cache_ = sh_; + ShapeLike::offset(offset_cache_, offset_distance_); + offset_cache_valid_ = true; + return offset_cache_; + } + } + return sh_; + } + + inline void invalidateCache() const BP2D_NOEXCEPT + { + tr_cache_valid_ = false; + area_cache_valid_ = false; + offset_cache_valid_ = false; + } +}; + +/** + * \brief Subclass of _Item for regular rectangle items. + */ +template +class _Rectangle: public _Item { + RawShape sh_; + using _Item::vertex; + using TO = Orientation; +public: + + using Unit = TCoord; + + template::Value> + inline _Rectangle(Unit width, Unit height, + // disable this ctor if o != CLOCKWISE + enable_if_t< o == TO::CLOCKWISE, int> = 0 ): + _Item( ShapeLike::create( { + {0, 0}, + {0, height}, + {width, height}, + {width, 0}, + {0, 0} + } )) + { + } + + template::Value> + inline _Rectangle(Unit width, Unit height, + // disable this ctor if o != COUNTER_CLOCKWISE + enable_if_t< o == TO::COUNTER_CLOCKWISE, int> = 0 ): + _Item( ShapeLike::create( { + {0, 0}, + {width, 0}, + {width, height}, + {0, height}, + {0, 0} + } )) + { + } + + inline Unit width() const BP2D_NOEXCEPT { + return getX(vertex(2)); + } + + inline Unit height() const BP2D_NOEXCEPT { + return getY(vertex(2)); + } +}; + +/** + * \brief A wrapper interface (trait) class for any placement strategy provider. + * + * If a client want's to use its own placement algorithm, all it has to do is to + * specialize this class template and define all the ten methods it has. It can + * use the strategies::PlacerBoilerplace class for creating a new placement + * strategy where only the constructor and the trypack method has to be provided + * and it will work out of the box. + */ +template +class PlacementStrategyLike { + PlacementStrategy impl_; +public: + + /// The item type that the placer works with. + using Item = typename PlacementStrategy::Item; + + /// The placer's config type. Should be a simple struct but can be anything. + using Config = typename PlacementStrategy::Config; + + /** + * \brief The type of the bin that the placer works with. + * + * Can be a box or an arbitrary shape or just a width or height without a + * second dimension if an infinite bin is considered. + */ + using BinType = typename PlacementStrategy::BinType; + + /** + * \brief Pack result that can be used to accept or discard it. See trypack + * method. + */ + using PackResult = typename PlacementStrategy::PackResult; + + using ItemRef = std::reference_wrapper; + using ItemGroup = std::vector; + + /** + * @brief Constructor taking the bin and an optional configuration. + * @param bin The bin object whose type is defined by the placement strategy. + * @param config The configuration for the particular placer. + */ + explicit PlacementStrategyLike(const BinType& bin, + const Config& config = Config()): + impl_(bin) + { + configure(config); + } + + /** + * @brief Provide a different configuration for the placer. + * + * Note that it depends on the particular placer implementation how it + * reacts to config changes in the middle of a calculation. + * + * @param config The configuration object defined by the placement startegy. + */ + inline void configure(const Config& config) { impl_.configure(config); } + + /** + * @brief A method that tries to pack an item and returns an object + * describing the pack result. + * + * The result can be casted to bool and used as an argument to the accept + * method to accept a succesfully packed item. This way the next packing + * will consider the accepted item as well. The PackResult should carry the + * transformation info so that if the tried item is later modified or tried + * multiple times, the result object should set it to the originally + * determied position. An implementation can be found in the + * strategies::PlacerBoilerplate::PackResult class. + * + * @param item Ithe item to be packed. + * @return The PackResult object that can be implicitly casted to bool. + */ + inline PackResult trypack(Item& item) { return impl_.trypack(item); } + + /** + * @brief A method to accept a previously tried item. + * + * If the pack result is a failure the method should ignore it. + * @param r The result of a previous trypack call. + */ + inline void accept(PackResult& r) { impl_.accept(r); } + + /** + * @brief pack Try to pack an item and immediately accept it on success. + * + * A default implementation would be to call + * { auto&& r = trypack(item); accept(r); return r; } but we should let the + * implementor of the placement strategy to harvest any optimizations from + * the absence of an intermadiate step. The above version can still be used + * in the implementation. + * + * @param item The item to pack. + * @return Returns true if the item was packed or false if it could not be + * packed. + */ + inline bool pack(Item& item) { return impl_.pack(item); } + + /// Unpack the last element (remove it from the list of packed items). + inline void unpackLast() { impl_.unpackLast(); } + + /// Get the bin object. + inline const BinType& bin() const { return impl_.bin(); } + + /// Set a new bin object. + inline void bin(const BinType& bin) { impl_.bin(bin); } + + /// Get the packed items. + inline ItemGroup getItems() { return impl_.getItems(); } + + /// Clear the packed items so a new session can be started. + inline void clearItems() { impl_.clearItems(); } + +}; + +/** + * A wrapper interface (trait) class for any selections strategy provider. + */ +template +class SelectionStrategyLike { + SelectionStrategy impl_; +public: + using Item = typename SelectionStrategy::Item; + using Config = typename SelectionStrategy::Config; + + using ItemRef = std::reference_wrapper; + using ItemGroup = std::vector; + + /** + * @brief Provide a different configuration for the selection strategy. + * + * Note that it depends on the particular placer implementation how it + * reacts to config changes in the middle of a calculation. + * + * @param config The configuration object defined by the selection startegy. + */ + inline void configure(const Config& config) { + impl_.configure(config); + } + + /** + * \brief A method to start the calculation on the input sequence. + * + * \tparam TPlacer The only mandatory template parameter is the type of + * placer compatible with the PlacementStrategyLike interface. + * + * \param first, last The first and last iterator if the input sequence. It + * can be only an iterator of a type converitible to Item. + * \param bin. The shape of the bin. It has to be supported by the placement + * strategy. + * \param An optional config object for the placer. + */ + template::BinType, + class PConfig = typename PlacementStrategyLike::Config> + inline void packItems( + TIterator first, + TIterator last, + TBin&& bin, + PConfig&& config = PConfig() ) + { + impl_.template packItems(first, last, + std::forward(bin), + std::forward(config)); + } + + /** + * \brief Get the number of bins opened by the selection algorithm. + * + * Initially it is zero and after the call to packItems it will return + * the number of bins opened by the packing procedure. + * + * \return The number of bins opened. + */ + inline size_t binCount() const { return impl_.binCount(); } + + /** + * @brief Get the items for a particular bin. + * @param binIndex The index of the requested bin. + * @return Returns a list of allitems packed into the requested bin. + */ + inline ItemGroup itemsForBin(size_t binIndex) { + return impl_.itemsForBin(binIndex); + } + + /// Same as itemsForBin but for a const context. + inline const ItemGroup itemsForBin(size_t binIndex) const { + return impl_.itemsForBin(binIndex); + } +}; + + +/** + * \brief A list of packed item vectors. Each vector represents a bin. + */ +template +using _PackGroup = std::vector< + std::vector< + std::reference_wrapper<_Item> + > + >; + +/** + * \brief A list of packed (index, item) pair vectors. Each vector represents a + * bin. + * + * The index is points to the position of the item in the original input + * sequence. This way the caller can use the items as a transformation data + * carrier and transform the original objects manually. + */ +template +using _IndexedPackGroup = std::vector< + std::vector< + std::pair< + unsigned, + std::reference_wrapper<_Item> + > + > + >; + +/** + * The Arranger is the frontend class for the binpack2d library. It takes the + * input items and outputs the items with the proper transformations to be + * inside the provided bin. + */ +template +class Arranger { + using TSel = SelectionStrategyLike; + TSel selector_; + +public: + using Item = typename PlacementStrategy::Item; + using ItemRef = std::reference_wrapper; + using TPlacer = PlacementStrategyLike; + using BinType = typename TPlacer::BinType; + using PlacementConfig = typename TPlacer::Config; + using SelectionConfig = typename TSel::Config; + + using Unit = TCoord>; + + using IndexedPackGroup = _IndexedPackGroup; + using PackGroup = _PackGroup; + +private: + BinType bin_; + PlacementConfig pconfig_; + TCoord min_obj_distance_; + + using SItem = typename SelectionStrategy::Item; + using TPItem = remove_cvref_t; + using TSItem = remove_cvref_t; + + std::vector item_cache_; + +public: + + /** + * \brief Constructor taking the bin as the only mandatory parameter. + * + * \param bin The bin shape that will be used by the placers. The type + * of the bin should be one that is supported by the placer type. + */ + template + Arranger( TBinType&& bin, + Unit min_obj_distance = 0, + PConf&& pconfig = PConf(), + SConf&& sconfig = SConf()): + bin_(std::forward(bin)), + pconfig_(std::forward(pconfig)), + min_obj_distance_(min_obj_distance) + { + static_assert( std::is_same::value, + "Incompatible placement and selection strategy!"); + + selector_.configure(std::forward(sconfig)); + } + + /** + * \brief Arrange an input sequence and return a PackGroup object with + * the packed groups corresponding to the bins. + * + * The number of groups in the pack group is the number of bins opened by + * the selection algorithm. + */ + template + inline PackGroup arrange(TIterator from, TIterator to) + { + return _arrange(from, to); + } + + /** + * A version of the arrange method returning an IndexedPackGroup with + * the item indexes into the original input sequence. + * + * Takes a little longer to collect the indices. Scales linearly with the + * input sequence size. + */ + template + inline IndexedPackGroup arrangeIndexed(TIterator from, TIterator to) + { + return _arrangeIndexed(from, to); + } + + /// Shorthand to normal arrange method. + template + inline PackGroup operator() (TIterator from, TIterator to) + { + return _arrange(from, to); + } + +private: + + template, + + // This funtion will be used only if the iterators are pointing to + // a type compatible with the binpack2d::_Item template. + // This way we can use references to input elements as they will + // have to exist for the lifetime of this call. + class T = enable_if_t< std::is_convertible::value, IT> + > + inline PackGroup _arrange(TIterator from, TIterator to, bool = false) + { + __arrange(from, to); + + PackGroup ret; + for(size_t i = 0; i < selector_.binCount(); i++) { + auto items = selector_.itemsForBin(i); + ret.push_back(items); + } + + return ret; + } + + template, + class T = enable_if_t::value, IT> + > + inline PackGroup _arrange(TIterator from, TIterator to, int = false) + { + item_cache_ = {from, to}; + + __arrange(item_cache_.begin(), item_cache_.end()); + + PackGroup ret; + for(size_t i = 0; i < selector_.binCount(); i++) { + auto items = selector_.itemsForBin(i); + ret.push_back(items); + } + + return ret; + } + + template, + + // This funtion will be used only if the iterators are pointing to + // a type compatible with the binpack2d::_Item template. + // This way we can use references to input elements as they will + // have to exist for the lifetime of this call. + class T = enable_if_t< std::is_convertible::value, IT> + > + inline IndexedPackGroup _arrangeIndexed(TIterator from, + TIterator to, + bool = false) + { + __arrange(from, to); + return createIndexedPackGroup(from, to, selector_); + } + + template, + class T = enable_if_t::value, IT> + > + inline IndexedPackGroup _arrangeIndexed(TIterator from, + TIterator to, + int = false) + { + item_cache_ = {from, to}; + __arrange(item_cache_.begin(), item_cache_.end()); + return createIndexedPackGroup(from, to, selector_); + } + + template + static IndexedPackGroup createIndexedPackGroup(TIterator from, + TIterator to, + TSel& selector) + { + IndexedPackGroup pg; + pg.reserve(selector.binCount()); + + for(size_t i = 0; i < selector.binCount(); i++) { + auto items = selector.itemsForBin(i); + pg.push_back({}); + pg[i].reserve(items.size()); + + for(Item& itemA : items) { + auto it = from; + unsigned idx = 0; + while(it != to) { + Item& itemB = *it; + if(&itemB == &itemA) break; + it++; idx++; + } + pg[i].emplace_back(idx, itemA); + } + } + + return pg; + } + + template inline void __arrange(TIter from, TIter to) + { + if(min_obj_distance_ > 0) std::for_each(from, to, [this](Item& item) { + item.addOffset(std::ceil(min_obj_distance_/2.0)); + }); + + selector_.template packItems( + from, to, bin_, pconfig_); + + if(min_obj_distance_ > 0) std::for_each(from, to, [this](Item& item) { + item.removeOffset(); + }); + + } +}; + +} + +#endif // LIBNEST2D_HPP diff --git a/xs/src/libnest2d/libnest2d/placers/bottomleftplacer.hpp b/xs/src/libnest2d/libnest2d/placers/bottomleftplacer.hpp new file mode 100644 index 0000000000..d343012052 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/placers/bottomleftplacer.hpp @@ -0,0 +1,391 @@ +#ifndef BOTTOMLEFT_HPP +#define BOTTOMLEFT_HPP + +#include + +#include "placer_boilerplate.hpp" + +namespace libnest2d { namespace strategies { + +template +struct BLConfig { + TCoord> min_obj_distance = 0; + bool allow_rotations = false; +}; + +template +class _BottomLeftPlacer: public PlacerBoilerplate< + _BottomLeftPlacer, + RawShape, _Box>, + BLConfig > +{ + using Base = PlacerBoilerplate<_BottomLeftPlacer, RawShape, + _Box>, BLConfig>; + DECLARE_PLACER(Base) + +public: + + explicit _BottomLeftPlacer(const BinType& bin): Base(bin) {} + + PackResult trypack(Item& item) { + auto r = _trypack(item); + if(!r && Base::config_.allow_rotations) { + item.rotate(Degrees(90)); + r =_trypack(item); + } + return r; + } + + enum class Dir { + LEFT, + DOWN + }; + + inline RawShape leftPoly(const Item& item) const { + return toWallPoly(item, Dir::LEFT); + } + + inline RawShape downPoly(const Item& item) const { + return toWallPoly(item, Dir::DOWN); + } + + inline Unit availableSpaceLeft(const Item& item) { + return availableSpace(item, Dir::LEFT); + } + + inline Unit availableSpaceDown(const Item& item) { + return availableSpace(item, Dir::DOWN); + } + +protected: + + PackResult _trypack(Item& item) { + + // Get initial position for item in the top right corner + setInitialPosition(item); + + Unit d = availableSpaceDown(item); + bool can_move = d > 1 /*std::numeric_limits::epsilon()*/; + bool can_be_packed = can_move; + bool left = true; + + while(can_move) { + if(left) { // write previous down move and go down + item.translate({0, -d+1}); + d = availableSpaceLeft(item); + can_move = d > 1/*std::numeric_limits::epsilon()*/; + left = false; + } else { // write previous left move and go down + item.translate({-d+1, 0}); + d = availableSpaceDown(item); + can_move = d > 1/*std::numeric_limits::epsilon()*/; + left = true; + } + } + + if(can_be_packed) { + Item trsh(item.transformedShape()); + for(auto& v : trsh) can_be_packed = can_be_packed && + getX(v) < bin_.width() && + getY(v) < bin_.height(); + } + + return can_be_packed? PackResult(item) : PackResult(); + } + + void setInitialPosition(Item& item) { + auto bb = item.boundingBox(); + + Vertex v = { getX(bb.maxCorner()), getY(bb.minCorner()) }; + + + Coord dx = getX(bin_.maxCorner()) - getX(v); + Coord dy = getY(bin_.maxCorner()) - getY(v); + + item.translate({dx, dy}); + } + + template + static enable_if_t::value, bool> + isInTheWayOf( const Item& item, + const Item& other, + const RawShape& scanpoly) + { + auto tsh = other.transformedShape(); + return ( ShapeLike::intersects(tsh, scanpoly) || + ShapeLike::isInside(tsh, scanpoly) ) && + ( !ShapeLike::intersects(tsh, item.rawShape()) && + !ShapeLike::isInside(tsh, item.rawShape()) ); + } + + template + static enable_if_t::value, bool> + isInTheWayOf( const Item& item, + const Item& other, + const RawShape& scanpoly) + { + auto tsh = other.transformedShape(); + + bool inters_scanpoly = ShapeLike::intersects(tsh, scanpoly) && + !ShapeLike::touches(tsh, scanpoly); + bool inters_item = ShapeLike::intersects(tsh, item.rawShape()) && + !ShapeLike::touches(tsh, item.rawShape()); + + return ( inters_scanpoly || + ShapeLike::isInside(tsh, scanpoly)) && + ( !inters_item && + !ShapeLike::isInside(tsh, item.rawShape()) + ); + } + + Container itemsInTheWayOf(const Item& item, const Dir dir) { + // Get the left or down polygon, that has the same area as the shadow + // of input item reflected to the left or downwards + auto&& scanpoly = dir == Dir::LEFT? leftPoly(item) : + downPoly(item); + + Container ret; // packed items 'in the way' of item + ret.reserve(items_.size()); + + // Predicate to find items that are 'in the way' for left (down) move + auto predicate = [&scanpoly, &item](const Item& it) { + return isInTheWayOf(item, it, scanpoly); + }; + + // Get the items that are in the way for the left (or down) movement + std::copy_if(items_.begin(), items_.end(), + std::back_inserter(ret), predicate); + + return ret; + } + + Unit availableSpace(const Item& _item, const Dir dir) { + + Item item (_item.transformedShape()); + + + std::function getCoord; + std::function< std::pair(const Segment&, const Vertex&) > + availableDistanceSV; + + std::function< std::pair(const Vertex&, const Segment&) > + availableDistance; + + if(dir == Dir::LEFT) { + getCoord = [](const Vertex& v) { return getX(v); }; + availableDistance = PointLike::horizontalDistance; + availableDistanceSV = [](const Segment& s, const Vertex& v) { + auto ret = PointLike::horizontalDistance(v, s); + if(ret.second) ret.first = -ret.first; + return ret; + }; + } + else { + getCoord = [](const Vertex& v) { return getY(v); }; + availableDistance = PointLike::verticalDistance; + availableDistanceSV = [](const Segment& s, const Vertex& v) { + auto ret = PointLike::verticalDistance(v, s); + if(ret.second) ret.first = -ret.first; + return ret; + }; + } + + auto&& items_in_the_way = itemsInTheWayOf(item, dir); + + // Comparison function for finding min vertex + auto cmp = [&getCoord](const Vertex& v1, const Vertex& v2) { + return getCoord(v1) < getCoord(v2); + }; + + // find minimum left or down coordinate of item + auto minvertex_it = std::min_element(item.begin(), + item.end(), + cmp); + + // Get the initial distance in floating point + Unit m = getCoord(*minvertex_it); + + // Check available distance for every vertex of item to the objects + // in the way for the nearest intersection + if(!items_in_the_way.empty()) { // This is crazy, should be optimized... + for(Item& pleft : items_in_the_way) { + // For all segments in items_to_left + + assert(pleft.vertexCount() > 0); + + auto trpleft = pleft.transformedShape(); + auto first = ShapeLike::begin(trpleft); + auto next = first + 1; + auto endit = ShapeLike::end(trpleft); + + while(next != endit) { + Segment seg(*(first++), *(next++)); + for(auto& v : item) { // For all vertices in item + + auto d = availableDistance(v, seg); + + if(d.second && d.first < m) m = d.first; + } + } + } + + auto first = item.begin(); + auto next = first + 1; + auto endit = item.end(); + + // For all edges in item: + while(next != endit) { + Segment seg(*(first++), *(next++)); + + // for all shapes in items_to_left + for(Item& sh : items_in_the_way) { + assert(sh.vertexCount() > 0); + + Item tsh(sh.transformedShape()); + for(auto& v : tsh) { // For all vertices in item + + auto d = availableDistanceSV(seg, v); + + if(d.second && d.first < m) m = d.first; + } + } + } + } + + return m; + } + + /** + * Implementation of the left (and down) polygon as described by + * [López-Camacho et al. 2013]\ + * (http://www.cs.stir.ac.uk/~goc/papers/EffectiveHueristic2DAOR2013.pdf) + * see algorithm 8 for details... + */ + RawShape toWallPoly(const Item& _item, const Dir dir) const { + // The variable names reflect the case of left polygon calculation. + // + // We will iterate through the item's vertices and search for the top + // and bottom vertices (or right and left if dir==Dir::DOWN). + // Save the relevant vertices and their indices into `bottom` and + // `top` vectors. In case of left polygon construction these will + // contain the top and bottom polygons which have the same vertical + // coordinates (in case there is more of them). + // + // We get the leftmost (or downmost) vertex from the `bottom` and `top` + // vectors and construct the final polygon. + + Item item (_item.transformedShape()); + + auto getCoord = [dir](const Vertex& v) { + return dir == Dir::LEFT? getY(v) : getX(v); + }; + + Coord max_y = std::numeric_limits::min(); + Coord min_y = std::numeric_limits::max(); + + using El = std::pair>; + + std::function cmp; + + if(dir == Dir::LEFT) + cmp = [](const El& e1, const El& e2) { + return getX(e1.second.get()) < getX(e2.second.get()); + }; + else + cmp = [](const El& e1, const El& e2) { + return getY(e1.second.get()) < getY(e2.second.get()); + }; + + std::vector< El > top; + std::vector< El > bottom; + + size_t idx = 0; + for(auto& v : item) { // Find the bottom and top vertices and save them + auto vref = std::cref(v); + auto vy = getCoord(v); + + if( vy > max_y ) { + max_y = vy; + top.clear(); + top.emplace_back(idx, vref); + } + else if(vy == max_y) { top.emplace_back(idx, vref); } + + if(vy < min_y) { + min_y = vy; + bottom.clear(); + bottom.emplace_back(idx, vref); + } + else if(vy == min_y) { bottom.emplace_back(idx, vref); } + + idx++; + } + + // Get the top and bottom leftmost vertices, or the right and left + // downmost vertices (if dir == Dir::DOWN) + auto topleft_it = std::min_element(top.begin(), top.end(), cmp); + auto bottomleft_it = + std::min_element(bottom.begin(), bottom.end(), cmp); + + auto& topleft_vertex = topleft_it->second.get(); + auto& bottomleft_vertex = bottomleft_it->second.get(); + + // Start and finish positions for the vertices that will be part of the + // new polygon + auto start = std::min(topleft_it->first, bottomleft_it->first); + auto finish = std::max(topleft_it->first, bottomleft_it->first); + + // the return shape + RawShape rsh; + + // reserve for all vertices plus 2 for the left horizontal wall, 2 for + // the additional vertices for maintaning min object distance + ShapeLike::reserve(rsh, finish-start+4); + + /*auto addOthers = [&rsh, finish, start, &item](){ + for(size_t i = start+1; i < finish; i++) + ShapeLike::addVertex(rsh, item.vertex(i)); + };*/ + + auto reverseAddOthers = [&rsh, finish, start, &item](){ + for(size_t i = finish-1; i > start; i--) + ShapeLike::addVertex(rsh, item.vertex(i)); + }; + + // Final polygon construction... + + static_assert(OrientationType::Value == + Orientation::CLOCKWISE, + "Counter clockwise toWallPoly() Unimplemented!"); + + // Clockwise polygon construction + + ShapeLike::addVertex(rsh, topleft_vertex); + + if(dir == Dir::LEFT) reverseAddOthers(); + else { + ShapeLike::addVertex(rsh, getX(topleft_vertex), 0); + ShapeLike::addVertex(rsh, getX(bottomleft_vertex), 0); + } + + ShapeLike::addVertex(rsh, bottomleft_vertex); + + if(dir == Dir::LEFT) { + ShapeLike::addVertex(rsh, 0, getY(bottomleft_vertex)); + ShapeLike::addVertex(rsh, 0, getY(topleft_vertex)); + } + else reverseAddOthers(); + + + // Close the polygon + ShapeLike::addVertex(rsh, topleft_vertex); + + return rsh; + } + +}; + +} +} + +#endif //BOTTOMLEFT_HPP diff --git a/xs/src/libnest2d/libnest2d/placers/nfpplacer.hpp b/xs/src/libnest2d/libnest2d/placers/nfpplacer.hpp new file mode 100644 index 0000000000..b9d6741d02 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/placers/nfpplacer.hpp @@ -0,0 +1,31 @@ +#ifndef NOFITPOLY_HPP +#define NOFITPOLY_HPP + +#include "placer_boilerplate.hpp" + +namespace libnest2d { namespace strategies { + +template +class _NofitPolyPlacer: public PlacerBoilerplate<_NofitPolyPlacer, + RawShape, _Box>> { + + using Base = PlacerBoilerplate<_NofitPolyPlacer, + RawShape, _Box>>; + + DECLARE_PLACER(Base) + +public: + + inline explicit _NofitPolyPlacer(const BinType& bin): Base(bin) {} + + PackResult trypack(Item& item) { + + return PackResult(); + } + +}; + +} +} + +#endif // NOFITPOLY_H diff --git a/xs/src/libnest2d/libnest2d/placers/placer_boilerplate.hpp b/xs/src/libnest2d/libnest2d/placers/placer_boilerplate.hpp new file mode 100644 index 0000000000..1d82a5e66c --- /dev/null +++ b/xs/src/libnest2d/libnest2d/placers/placer_boilerplate.hpp @@ -0,0 +1,102 @@ +#ifndef PLACER_BOILERPLATE_HPP +#define PLACER_BOILERPLATE_HPP + +#include "../libnest2d.hpp" + +namespace libnest2d { namespace strategies { + +struct EmptyConfig {}; + +template>> + > +class PlacerBoilerplate { +public: + using Item = _Item; + using Vertex = TPoint; + using Segment = _Segment; + using BinType = TBin; + using Coord = TCoord; + using Unit = Coord; + using Config = Cfg; + using Container = Store; + + class PackResult { + Item *item_ptr_; + Vertex move_; + Radians rot_; + friend class PlacerBoilerplate; + friend Subclass; + PackResult(Item& item): + item_ptr_(&item), + move_(item.translation()), + rot_(item.rotation()) {} + PackResult(): item_ptr_(nullptr) {} + public: + operator bool() { return item_ptr_ != nullptr; } + }; + + using ItemGroup = const Container&; + + inline PlacerBoilerplate(const BinType& bin): bin_(bin) {} + + inline const BinType& bin() const BP2D_NOEXCEPT { return bin_; } + + template inline void bin(TB&& b) { + bin_ = std::forward(b); + } + + inline void configure(const Config& config) BP2D_NOEXCEPT { + config_ = config; + } + + bool pack(Item& item) { + auto&& r = static_cast(this)->trypack(item); + if(r) items_.push_back(*(r.item_ptr_)); + return r; + } + + void accept(PackResult& r) { + if(r) { + r.item_ptr_->translation(r.move_); + r.item_ptr_->rotation(r.rot_); + items_.push_back(*(r.item_ptr_)); + } + } + + void unpackLast() { items_.pop_back(); } + + inline ItemGroup getItems() { return items_; } + + inline void clearItems() { items_.clear(); } + +protected: + + BinType bin_; + Container items_; + Cfg config_; + +}; + + +#define DECLARE_PLACER(Base) \ +using Base::bin_; \ +using Base::items_; \ +using Base::config_; \ +public: \ +using typename Base::Item; \ +using typename Base::BinType; \ +using typename Base::Config; \ +using typename Base::Vertex; \ +using typename Base::Segment; \ +using typename Base::PackResult; \ +using typename Base::Coord; \ +using typename Base::Unit; \ +using typename Base::Container; \ +private: + +} +} + +#endif // PLACER_BOILERPLATE_HPP diff --git a/xs/src/libnest2d/libnest2d/selections/djd_heuristic.hpp b/xs/src/libnest2d/libnest2d/selections/djd_heuristic.hpp new file mode 100644 index 0000000000..8ae77bbb32 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/selections/djd_heuristic.hpp @@ -0,0 +1,514 @@ +#ifndef DJD_HEURISTIC_HPP +#define DJD_HEURISTIC_HPP + +#include +#include "selection_boilerplate.hpp" + +namespace libnest2d { namespace strategies { + +/** + * Selection heuristic based on [López-Camacho]\ + * (http://www.cs.stir.ac.uk/~goc/papers/EffectiveHueristic2DAOR2013.pdf) + */ +template +class _DJDHeuristic: public SelectionBoilerplate { + using Base = SelectionBoilerplate; +public: + using typename Base::Item; + using typename Base::ItemRef; + + /** + * @brief The Config for DJD heuristic. + */ + struct Config { + /// Max number of bins. + unsigned max_bins = 0; + + /** + * If true, the algorithm will try to place pair and driplets in all + * possible order. + */ + bool try_reverse_order = true; + }; + +private: + using Base::packed_bins_; + using ItemGroup = typename Base::ItemGroup; + + using Container = ItemGroup;//typename std::vector; + Container store_; + Config config_; + + // The initial fill proportion of the bin area that will be filled before + // trying items one by one, or pairs or triplets. + static const double INITIAL_FILL_PROPORTION; + +public: + + inline void configure(const Config& config) { + config_ = config; + } + + template::BinType, + class PConfig = typename PlacementStrategyLike::Config> + void packItems( TIterator first, + TIterator last, + const TBin& bin, + PConfig&& pconfig = PConfig() ) + { + using Placer = PlacementStrategyLike; + using ItemList = std::list; + + const double bin_area = ShapeLike::area(bin); + const double w = bin_area * 0.1; + const double INITIAL_FILL_AREA = bin_area*INITIAL_FILL_PROPORTION; + + store_.clear(); + store_.reserve(last-first); + packed_bins_.clear(); + + std::copy(first, last, std::back_inserter(store_)); + + std::sort(store_.begin(), store_.end(), [](Item& i1, Item& i2) { + return i1.area() > i2.area(); + }); + + ItemList not_packed(store_.begin(), store_.end()); + + std::vector placers; + + double free_area = 0; + double filled_area = 0; + double waste = 0; + bool try_reverse = config_.try_reverse_order; + + // Will use a subroutine to add a new bin + auto addBin = [&placers, &free_area, &filled_area, &bin, &pconfig]() + { + placers.emplace_back(bin); + placers.back().configure(pconfig); + free_area = ShapeLike::area(bin); + filled_area = 0; + }; + + // Types for pairs and triplets + using TPair = std::tuple; + using TTriplet = std::tuple; + + + // Method for checking a pair whether it was a pack failure. + auto check_pair = [](const std::vector& wrong_pairs, + ItemRef i1, ItemRef i2) + { + return std::any_of(wrong_pairs.begin(), wrong_pairs.end(), + [&i1, &i2](const TPair& pair) + { + Item& pi1 = std::get<0>(pair), pi2 = std::get<1>(pair); + Item& ri1 = i1, ri2 = i2; + return (&pi1 == &ri1 && &pi2 == &ri2) || + (&pi1 == &ri2 && &pi2 == &ri1); + }); + }; + + // Method for checking if a triplet was a pack failure + auto check_triplet = []( + const std::vector& wrong_triplets, + ItemRef i1, + ItemRef i2, + ItemRef i3) + { + return std::any_of(wrong_triplets.begin(), + wrong_triplets.end(), + [&i1, &i2, &i3](const TTriplet& tripl) + { + Item& pi1 = std::get<0>(tripl); + Item& pi2 = std::get<1>(tripl); + Item& pi3 = std::get<2>(tripl); + Item& ri1 = i1, ri2 = i2, ri3 = i3; + return (&pi1 == &ri1 && &pi2 == &ri2 && &pi3 == &ri3) || + (&pi1 == &ri1 && &pi2 == &ri3 && &pi3 == &ri2) || + (&pi1 == &ri2 && &pi2 == &ri1 && &pi3 == &ri3) || + (&pi1 == &ri3 && &pi2 == &ri2 && &pi3 == &ri1); + }); + }; + + auto tryOneByOne = // Subroutine to try adding items one by one. + [¬_packed, &bin_area, &free_area, &filled_area] + (Placer& placer, double waste) + { + double item_area = 0; + bool ret = false; + auto it = not_packed.begin(); + + while(it != not_packed.end() && !ret && + free_area - (item_area = it->get().area()) <= waste) + { + if(item_area <= free_area && placer.pack(*it) ) { + free_area -= item_area; + filled_area = bin_area - free_area; + ret = true; + } else + it++; + } + + if(ret) not_packed.erase(it); + + return ret; + }; + + auto tryGroupsOfTwo = // Try adding groups of two items into the bin. + [¬_packed, &bin_area, &free_area, &filled_area, &check_pair, + try_reverse] + (Placer& placer, double waste) + { + double item_area = 0, largest_area = 0, smallest_area = 0; + double second_largest = 0, second_smallest = 0; + + const auto endit = not_packed.end(); + + if(not_packed.size() < 2) + return false; // No group of two items + else { + largest_area = not_packed.front().get().area(); + auto itmp = not_packed.begin(); itmp++; + second_largest = itmp->get().area(); + if( free_area - second_largest - largest_area > waste) + return false; // If even the largest two items do not fill + // the bin to the desired waste than we can end here. + + smallest_area = not_packed.back().get().area(); + itmp = endit; std::advance(itmp, -2); + second_smallest = itmp->get().area(); + } + + bool ret = false; + auto it = not_packed.begin(); + auto it2 = it; + + std::vector wrong_pairs; + + double largest = second_largest; + double smallest= smallest_area; + while(it != endit && !ret && free_area - + (item_area = it->get().area()) - largest <= waste ) + { + // if this is the last element, the next smallest is the + // previous item + auto itmp = it; std::advance(itmp, 1); + if(itmp == endit) smallest = second_smallest; + + if(item_area + smallest > free_area ) { it++; continue; } + + auto pr = placer.trypack(*it); + + // First would fit + it2 = not_packed.begin(); + double item2_area = 0; + while(it2 != endit && pr && !ret && free_area - + (item2_area = it2->get().area()) - item_area <= waste) + { + double area_sum = item_area + item2_area; + + if(it == it2 || area_sum > free_area || + check_pair(wrong_pairs, *it, *it2)) { + it2++; continue; + } + + placer.accept(pr); + auto pr2 = placer.trypack(*it2); + if(!pr2) { + placer.unpackLast(); // remove first + if(try_reverse) { + pr2 = placer.trypack(*it2); + if(pr2) { + placer.accept(pr2); + auto pr12 = placer.trypack(*it); + if(pr12) { + placer.accept(pr12); + ret = true; + } else { + placer.unpackLast(); + } + } + } + } else { + placer.accept(pr2); ret = true; + } + + if(ret) + { // Second fits as well + free_area -= area_sum; + filled_area = bin_area - free_area; + } else { + wrong_pairs.emplace_back(*it, *it2); + it2++; + } + } + + if(!ret) it++; + + largest = largest_area; + } + + if(ret) { not_packed.erase(it); not_packed.erase(it2); } + + return ret; + }; + + auto tryGroupsOfThree = // Try adding groups of three items. + [¬_packed, &bin_area, &free_area, &filled_area, + &check_pair, &check_triplet, try_reverse] + (Placer& placer, double waste) + { + + if(not_packed.size() < 3) return false; + + auto it = not_packed.begin(); // from + const auto endit = not_packed.end(); // to + auto it2 = it, it3 = it; + + // Containers for pairs and triplets that were tried before and + // do not work. + std::vector wrong_pairs; + std::vector wrong_triplets; + + // Will be true if a succesfull pack can be made. + bool ret = false; + + while (it != endit && !ret) { // drill down 1st level + + // We need to determine in each iteration the largest, second + // largest, smallest and second smallest item in terms of area. + + auto first = not_packed.begin(); + Item& largest = it == first? *std::next(it) : *first; + + auto second = std::next(first); + Item& second_largest = it == second ? *std::next(it) : *second; + + double area_of_two_largest = + largest.area() + second_largest.area(); + + // Check if there is enough free area for the item and the two + // largest item + if(free_area - it->get().area() - area_of_two_largest > waste) + break; + + // Determine the area of the two smallest item. + auto last = std::prev(endit); + Item& smallest = it == last? *std::prev(it) : *last; + auto second_last = std::prev(last); + Item& second_smallest = it == second_last? *std::prev(it) : + *second_last; + + // Check if there is enough free area for the item and the two + // smallest item. + double area_of_two_smallest = + smallest.area() + second_smallest.area(); + + auto pr = placer.trypack(*it); + + // Check for free area and try to pack the 1st item... + if(!pr || it->get().area() + area_of_two_smallest > free_area) { + it++; continue; + } + + it2 = not_packed.begin(); + double rem2_area = free_area - largest.area(); + double a2_sum = it->get().area() + it2->get().area(); + + while(it2 != endit && !ret && + rem2_area - a2_sum <= waste) { // Drill down level 2 + + if(it == it2 || check_pair(wrong_pairs, *it, *it2)) { + it2++; continue; + } + + a2_sum = it->get().area() + it2->get().area(); + if(a2_sum + smallest.area() > free_area) { + it2++; continue; + } + + bool can_pack2 = false; + + placer.accept(pr); + auto pr2 = placer.trypack(*it2); + auto pr12 = pr; + if(!pr2) { + placer.unpackLast(); // remove first + if(try_reverse) { + pr2 = placer.trypack(*it2); + if(pr2) { + placer.accept(pr2); + pr12 = placer.trypack(*it); + if(pr12) can_pack2 = true; + placer.unpackLast(); + } + } + } else { + placer.unpackLast(); + can_pack2 = true; + } + + if(!can_pack2) { + wrong_pairs.emplace_back(*it, *it2); + it2++; + continue; + } + + // Now we have packed a group of 2 items. + // The 'smallest' variable now could be identical with + // it2 but we don't bother with that + + if(!can_pack2) { it2++; continue; } + + it3 = not_packed.begin(); + + double a3_sum = a2_sum + it3->get().area(); + + while(it3 != endit && !ret && + free_area - a3_sum <= waste) { // 3rd level + + if(it3 == it || it3 == it2 || + check_triplet(wrong_triplets, *it, *it2, *it3)) + { it3++; continue; } + + placer.accept(pr12); placer.accept(pr2); + bool can_pack3 = placer.pack(*it3); + + if(!can_pack3) { + placer.unpackLast(); + placer.unpackLast(); + } + + if(!can_pack3 && try_reverse) { + + std::array indices = {0, 1, 2}; + std::array + candidates = {*it, *it2, *it3}; + + auto tryPack = [&placer, &candidates]( + const decltype(indices)& idx) + { + std::array packed = {false}; + + for(auto id : idx) packed[id] = + placer.pack(candidates[id]); + + bool check = + std::all_of(packed.begin(), + packed.end(), + [](bool b) { return b; }); + + if(!check) for(bool b : packed) if(b) + placer.unpackLast(); + + return check; + }; + + while (!can_pack3 && std::next_permutation( + indices.begin(), + indices.end())){ + can_pack3 = tryPack(indices); + }; + } + + if(can_pack3) { + // finishit + free_area -= a3_sum; + filled_area = bin_area - free_area; + ret = true; + } else { + wrong_triplets.emplace_back(*it, *it2, *it3); + it3++; + } + + } // 3rd while + + if(!ret) it2++; + + } // Second while + + if(!ret) it++; + + } // First while + + if(ret) { // If we eventually succeeded, remove all the packed ones. + not_packed.erase(it); + not_packed.erase(it2); + not_packed.erase(it3); + } + + return ret; + }; + + addBin(); + + // Safety test: try to pack each item into an empty bin. If it fails + // then it should be removed from the not_packed list + { auto it = not_packed.begin(); + while (it != not_packed.end()) { + Placer p(bin); + if(!p.pack(*it)) { + auto itmp = it++; + not_packed.erase(itmp); + } else it++; + } + } + + while(!not_packed.empty()) { + + auto& placer = placers.back(); + + {// Fill the bin up to INITIAL_FILL_PROPORTION of its capacity + auto it = not_packed.begin(); + + while(it != not_packed.end() && + filled_area < INITIAL_FILL_AREA) + { + if(placer.pack(*it)) { + filled_area += it->get().area(); + free_area = bin_area - filled_area; + auto itmp = it++; + not_packed.erase(itmp); + } else it++; + } + } + + // try pieses one by one + while(tryOneByOne(placer, waste)) + waste = 0; + + // try groups of 2 pieses + while(tryGroupsOfTwo(placer, waste)) + waste = 0; + + // try groups of 3 pieses + while(tryGroupsOfThree(placer, waste)) + waste = 0; + + if(waste < free_area) waste += w; + else if(!not_packed.empty()) addBin(); + } + + std::for_each(placers.begin(), placers.end(), + [this](Placer& placer){ + packed_bins_.push_back(placer.getItems()); + }); + } +}; + +/* + * The initial fill proportion suggested by + * [López-Camacho]\ + * (http://www.cs.stir.ac.uk/~goc/papers/EffectiveHueristic2DAOR2013.pdf) + * is one third of the area of bin. + */ +template +const double _DJDHeuristic::INITIAL_FILL_PROPORTION = 1.0/3.0; + +} +} + +#endif // DJD_HEURISTIC_HPP diff --git a/xs/src/libnest2d/libnest2d/selections/filler.hpp b/xs/src/libnest2d/libnest2d/selections/filler.hpp new file mode 100644 index 0000000000..96c5da4a1a --- /dev/null +++ b/xs/src/libnest2d/libnest2d/selections/filler.hpp @@ -0,0 +1,71 @@ +#ifndef FILLER_HPP +#define FILLER_HPP + +#include "selection_boilerplate.hpp" + +namespace libnest2d { namespace strategies { + +template +class _FillerSelection: public SelectionBoilerplate { + using Base = SelectionBoilerplate; +public: + using typename Base::Item; + using Config = int; //dummy + +private: + using Base::packed_bins_; + using typename Base::ItemGroup; + using Container = ItemGroup; + Container store_; + +public: + + void configure(const Config& /*config*/) { } + + template::BinType, + class PConfig = typename PlacementStrategyLike::Config> + void packItems(TIterator first, + TIterator last, + TBin&& bin, + PConfig&& pconfig = PConfig()) + { + + store_.clear(); + store_.reserve(last-first); + packed_bins_.clear(); + + std::copy(first, last, std::back_inserter(store_)); + + auto sortfunc = [](Item& i1, Item& i2) { + return i1.area() > i2.area(); + }; + + std::sort(store_.begin(), store_.end(), sortfunc); + +// Container a = {store_[0], store_[1], store_[4], store_[5] }; +//// a.insert(a.end(), store_.end()-10, store_.end()); +// store_ = a; + + PlacementStrategyLike placer(bin); + placer.configure(pconfig); + + bool was_packed = false; + for(auto& item : store_ ) { + if(!placer.pack(item)) { + packed_bins_.push_back(placer.getItems()); + placer.clearItems(); + was_packed = placer.pack(item); + } else was_packed = true; + } + + if(was_packed) { + packed_bins_.push_back(placer.getItems()); + } + } +}; + +} +} + +#endif //BOTTOMLEFT_HPP diff --git a/xs/src/libnest2d/libnest2d/selections/firstfit.hpp b/xs/src/libnest2d/libnest2d/selections/firstfit.hpp new file mode 100644 index 0000000000..cf8f6da0bf --- /dev/null +++ b/xs/src/libnest2d/libnest2d/selections/firstfit.hpp @@ -0,0 +1,77 @@ +#ifndef FIRSTFIT_HPP +#define FIRSTFIT_HPP + +#include "../libnest2d.hpp" +#include "selection_boilerplate.hpp" + +namespace libnest2d { namespace strategies { + +template +class _FirstFitSelection: public SelectionBoilerplate { + using Base = SelectionBoilerplate; +public: + using typename Base::Item; + using Config = int; //dummy + +private: + using Base::packed_bins_; + using typename Base::ItemGroup; + using Container = ItemGroup;//typename std::vector<_Item>; + + Container store_; + +public: + + void configure(const Config& /*config*/) { } + + template::BinType, + class PConfig = typename PlacementStrategyLike::Config> + void packItems(TIterator first, + TIterator last, + TBin&& bin, + PConfig&& pconfig = PConfig()) + { + + using Placer = PlacementStrategyLike; + + store_.clear(); + store_.reserve(last-first); + packed_bins_.clear(); + + std::vector placers; + + std::copy(first, last, std::back_inserter(store_)); + + auto sortfunc = [](Item& i1, Item& i2) { + return i1.area() > i2.area(); + }; + + std::sort(store_.begin(), store_.end(), sortfunc); + + for(auto& item : store_ ) { + bool was_packed = false; + while(!was_packed) { + + for(size_t j = 0; j < placers.size() && !was_packed; j++) + was_packed = placers[j].pack(item); + + if(!was_packed) { + placers.emplace_back(bin); + placers.back().configure(pconfig); + } + } + } + + std::for_each(placers.begin(), placers.end(), + [this](Placer& placer){ + packed_bins_.push_back(placer.getItems()); + }); + } + +}; + +} +} + +#endif // FIRSTFIT_HPP diff --git a/xs/src/libnest2d/libnest2d/selections/selection_boilerplate.hpp b/xs/src/libnest2d/libnest2d/selections/selection_boilerplate.hpp new file mode 100644 index 0000000000..8af489a302 --- /dev/null +++ b/xs/src/libnest2d/libnest2d/selections/selection_boilerplate.hpp @@ -0,0 +1,36 @@ +#ifndef SELECTION_BOILERPLATE_HPP +#define SELECTION_BOILERPLATE_HPP + +#include "../libnest2d.hpp" + +namespace libnest2d { +namespace strategies { + +template +class SelectionBoilerplate { +public: + using Item = _Item; + using ItemRef = std::reference_wrapper; + using ItemGroup = std::vector; + using PackGroup = std::vector; + + size_t binCount() const { return packed_bins_.size(); } + + ItemGroup itemsForBin(size_t binIndex) { + assert(binIndex < packed_bins_.size()); + return packed_bins_[binIndex]; + } + + inline const ItemGroup itemsForBin(size_t binIndex) const { + assert(binIndex < packed_bins_.size()); + return packed_bins_[binIndex]; + } + +protected: + PackGroup packed_bins_; +}; + +} +} + +#endif // SELECTION_BOILERPLATE_HPP diff --git a/xs/src/libnest2d/tests/CMakeLists.txt b/xs/src/libnest2d/tests/CMakeLists.txt new file mode 100644 index 0000000000..bfe32bfeb0 --- /dev/null +++ b/xs/src/libnest2d/tests/CMakeLists.txt @@ -0,0 +1,48 @@ + +# Try to find existing GTest installation +find_package(GTest QUIET) + +if(NOT GTEST_FOUND) + # Go and download google test framework, integrate it with the build + set(GTEST_LIBRARIES gtest gmock) + + if (CMAKE_VERSION VERSION_LESS 3.2) + set(UPDATE_DISCONNECTED_IF_AVAILABLE "") + else() + set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1") + endif() + + include(DownloadProject) + download_project(PROJ googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG release-1.8.0 + ${UPDATE_DISCONNECTED_IF_AVAILABLE} + ) + + # Prevent GoogleTest from overriding our compiler/linker options + # when building with Visual Studio + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + + add_subdirectory(${googletest_SOURCE_DIR} + ${googletest_BINARY_DIR} + ) + +else() + include_directories(${GTEST_INCLUDE_DIRS} ) +endif() + +include_directories(BEFORE ${LIBNEST2D_HEADERS}) +add_executable(bp2d_tests test.cpp printer_parts.h printer_parts.cpp) +target_link_libraries(bp2d_tests libnest2d + ${GTEST_LIBRARIES} +) + +if(DEFINED LIBNEST2D_TEST_LIBRARIES) + target_link_libraries(bp2d_tests ${LIBNEST2D_TEST_LIBRARIES}) +endif() + +add_test(gtests bp2d_tests) + +add_executable(main EXCLUDE_FROM_ALL main.cpp printer_parts.cpp printer_parts.h) +target_link_libraries(main libnest2d) +target_include_directories(main PUBLIC ${CMAKE_SOURCE_DIR}) diff --git a/xs/src/libnest2d/tests/benchmark.h b/xs/src/libnest2d/tests/benchmark.h new file mode 100644 index 0000000000..19870b37b1 --- /dev/null +++ b/xs/src/libnest2d/tests/benchmark.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) Tamás Mészáros + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDE_BENCHMARK_H_ +#define INCLUDE_BENCHMARK_H_ + +#include +#include + +/** + * A class for doing benchmarks. + */ +class Benchmark { + typedef std::chrono::high_resolution_clock Clock; + typedef Clock::duration Duration; + typedef Clock::time_point TimePoint; + + TimePoint t1, t2; + Duration d; + + inline double to_sec(Duration d) { + return d.count() * double(Duration::period::num) / Duration::period::den; + } + +public: + + /** + * Measure time from the moment of this call. + */ + void start() { t1 = Clock::now(); } + + /** + * Measure time to the moment of this call. + */ + void stop() { t2 = Clock::now(); } + + /** + * Get the time elapsed between a start() end a stop() call. + * @return Returns the elapsed time in seconds. + */ + double getElapsedSec() { d = t2 - t1; return to_sec(d); } +}; + + +#endif /* INCLUDE_BENCHMARK_H_ */ diff --git a/xs/src/libnest2d/tests/main.cpp b/xs/src/libnest2d/tests/main.cpp new file mode 100644 index 0000000000..3d5baca766 --- /dev/null +++ b/xs/src/libnest2d/tests/main.cpp @@ -0,0 +1,260 @@ +#include +#include +#include + +#include +#include + +#include "printer_parts.h" +#include "benchmark.h" + +namespace { +using namespace libnest2d; +using ItemGroup = std::vector>; +//using PackGroup = std::vector; + +template +void exportSVG(PackGroup& result, const Bin& bin) { + + std::string loc = "out"; + + static std::string svg_header = +R"raw( + + +)raw"; + + int i = 0; + for(auto r : result) { + std::fstream out(loc + std::to_string(i) + ".svg", std::fstream::out); + if(out.is_open()) { + out << svg_header; + Item rbin( Rectangle(bin.width(), bin.height()) ); + for(unsigned i = 0; i < rbin.vertexCount(); i++) { + auto v = rbin.vertex(i); + setY(v, -getY(v)/SCALE + 500 ); + setX(v, getX(v)/SCALE); + rbin.setVertex(i, v); + } + out << ShapeLike::serialize(rbin.rawShape()) << std::endl; + for(Item& sh : r) { + Item tsh(sh.transformedShape()); + for(unsigned i = 0; i < tsh.vertexCount(); i++) { + auto v = tsh.vertex(i); + setY(v, -getY(v)/SCALE + 500); + setX(v, getX(v)/SCALE); + tsh.setVertex(i, v); + } + out << ShapeLike::serialize(tsh.rawShape()) << std::endl; + } + out << "\n" << std::endl; + } + out.close(); + + i++; + } +} + +template< int SCALE, class Bin> +void exportSVG(ItemGroup& result, const Bin& bin, int idx) { + + std::string loc = "out"; + + static std::string svg_header = +R"raw( + + +)raw"; + + int i = idx; + auto r = result; +// for(auto r : result) { + std::fstream out(loc + std::to_string(i) + ".svg", std::fstream::out); + if(out.is_open()) { + out << svg_header; + Item rbin( Rectangle(bin.width(), bin.height()) ); + for(unsigned i = 0; i < rbin.vertexCount(); i++) { + auto v = rbin.vertex(i); + setY(v, -getY(v)/SCALE + 500 ); + setX(v, getX(v)/SCALE); + rbin.setVertex(i, v); + } + out << ShapeLike::serialize(rbin.rawShape()) << std::endl; + for(Item& sh : r) { + Item tsh(sh.transformedShape()); + for(unsigned i = 0; i < tsh.vertexCount(); i++) { + auto v = tsh.vertex(i); + setY(v, -getY(v)/SCALE + 500); + setX(v, getX(v)/SCALE); + tsh.setVertex(i, v); + } + out << ShapeLike::serialize(tsh.rawShape()) << std::endl; + } + out << "\n" << std::endl; + } + out.close(); + +// i++; +// } +} +} + + +void findDegenerateCase() { + using namespace libnest2d; + + auto input = PRINTER_PART_POLYGONS; + + auto scaler = [](Item& item) { + for(unsigned i = 0; i < item.vertexCount(); i++) { + auto v = item.vertex(i); + setX(v, 100*getX(v)); setY(v, 100*getY(v)); + item.setVertex(i, v); + } + }; + + auto cmp = [](const Item& t1, const Item& t2) { + return t1.area() > t2.area(); + }; + + std::for_each(input.begin(), input.end(), scaler); + + std::sort(input.begin(), input.end(), cmp); + + Box bin(210*100, 250*100); + BottomLeftPlacer placer(bin); + + auto it = input.begin(); + auto next = it; + int i = 0; + while(it != input.end() && ++next != input.end()) { + placer.pack(*it); + placer.pack(*next); + + auto result = placer.getItems(); + bool valid = true; + + if(result.size() == 2) { + Item& r1 = result[0]; + Item& r2 = result[1]; + valid = !Item::intersects(r1, r2) || Item::touches(r1, r2); + valid = (valid && !r1.isInside(r2) && !r2.isInside(r1)); + if(!valid) { + std::cout << "error index: " << i << std::endl; + exportSVG<100>(result, bin, i); + } + } else { + std::cout << "something went terribly wrong!" << std::endl; + } + + + placer.clearItems(); + it++; + i++; + } +} + +void arrangeRectangles() { + using namespace libnest2d; + + +// std::vector input = { +// {80, 80}, +// {110, 10}, +// {200, 5}, +// {80, 30}, +// {60, 90}, +// {70, 30}, +// {80, 60}, +// {60, 60}, +// {60, 40}, +// {40, 40}, +// {10, 10}, +// {10, 10}, +// {10, 10}, +// {10, 10}, +// {10, 10}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {20, 20}, +// {80, 80}, +// {110, 10}, +// {200, 5}, +// {80, 30}, +// {60, 90}, +// {70, 30}, +// {80, 60}, +// {60, 60}, +// {60, 40}, +// {40, 40}, +// {10, 10}, +// {10, 10}, +// {10, 10}, +// {10, 10}, +// {10, 10}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {5, 5}, +// {20, 20} +// }; + + auto input = PRINTER_PART_POLYGONS; + + const int SCALE = 1000000; +// const int SCALE = 1; + + Box bin(210*SCALE, 250*SCALE); + + auto scaler = [&SCALE, &bin](Item& item) { +// double max_area = 0; + for(unsigned i = 0; i < item.vertexCount(); i++) { + auto v = item.vertex(i); + setX(v, SCALE*getX(v)); setY(v, SCALE*getY(v)); + item.setVertex(i, v); +// double area = item.area(); +// if(max_area < area) { +// max_area = area; +// bin = item.boundingBox(); +// } + } + }; + + Coord min_obj_distance = 2*SCALE; + + std::for_each(input.begin(), input.end(), scaler); + + Arranger arrange(bin, min_obj_distance); + + Benchmark bench; + + bench.start(); + auto result = arrange(input.begin(), + input.end()); + + bench.stop(); + + std::cout << bench.getElapsedSec() << std::endl; + + for(auto& it : input) { + auto ret = ShapeLike::isValid(it.transformedShape()); + std::cout << ret.second << std::endl; + } + + exportSVG(result, bin); + +} + +int main(void /*int argc, char **argv*/) { + arrangeRectangles(); +// findDegenerateCase(); + return EXIT_SUCCESS; +} diff --git a/xs/src/libnest2d/tests/printer_parts.cpp b/xs/src/libnest2d/tests/printer_parts.cpp new file mode 100644 index 0000000000..02ea6bb7f9 --- /dev/null +++ b/xs/src/libnest2d/tests/printer_parts.cpp @@ -0,0 +1,339 @@ +#include "printer_parts.h" + +const std::vector PRINTER_PART_POLYGONS = { +{ + {120, 114}, + {130, 114}, + {130, 103}, + {128, 96}, + {122, 96}, + {120, 103}, + {120, 114} +}, +{ + {61, 97}, + {70, 151}, + {176, 151}, + {189, 138}, + {189, 59}, + {70, 59}, + {61, 77}, + {61, 97} +}, +{ + {72, 147}, + {94, 151}, + {178, 151}, + {178, 59}, + {72, 59}, + {72, 147} +}, +{ + {121, 119}, + {123, 119}, + {129, 109}, + {129, 107}, + {128, 100}, + {127, 98}, + {123, 91}, + {121, 91}, + {121, 119}, +}, +{ + {93, 104}, + {100, 146}, + {107, 152}, + {136, 152}, + {142, 146}, + {157, 68}, + {157, 61}, + {154, 58}, + {104, 58}, + {93, 101}, + {93, 104}, +}, +{ + {90, 91}, + {114, 130}, + {158, 130}, + {163, 126}, + {163, 123}, + {152, 80}, + {116, 80}, + {90, 81}, + {87, 86}, + {90, 91}, +}, +{ + {111, 114}, + {114, 122}, + {139, 122}, + {139, 88}, + {114, 88}, + {111, 97}, + {111, 114}, +}, +{ + {120, 107}, + {125, 110}, + {130, 110}, + {130, 100}, + {120, 100}, + {120, 107}, +}, +{ + {113, 123}, + {137, 123}, + {137, 87}, + {113, 87}, + {113, 123}, +}, +{ + {107, 104}, + {110, 127}, + {114, 131}, + {136, 131}, + {140, 127}, + {143, 104}, + {143, 79}, + {107, 79}, + {107, 104}, +}, +{ + {48, 135}, + {50, 138}, + {52, 140}, + {198, 140}, + {202, 135}, + {202, 72}, + {200, 70}, + {50, 70}, + {48, 72}, + {48, 135}, +}, +{ + {115, 104}, + {116, 106}, + {123, 119}, + {127, 119}, + {134, 106}, + {135, 104}, + {135, 98}, + {134, 96}, + {132, 93}, + {128, 91}, + {122, 91}, + {118, 93}, + {116, 96}, + {115, 98}, + {115, 104}, +}, +{ + {91, 100}, + {94, 144}, + {117, 153}, + {118, 153}, + {159, 112}, + {159, 110}, + {156, 66}, + {133, 57}, + {132, 57}, + {91, 98}, + {91, 100}, +}, +{ + {101, 90}, + {103, 98}, + {107, 113}, + {114, 125}, + {115, 126}, + {135, 126}, + {136, 125}, + {144, 114}, + {149, 90}, + {149, 89}, + {148, 87}, + {145, 84}, + {105, 84}, + {102, 87}, + {101, 89}, + {101, 90}, +}, +{ + {93, 116}, + {94, 118}, + {141, 121}, + {151, 121}, + {156, 118}, + {157, 116}, + {157, 91}, + {156, 89}, + {94, 89}, + {93, 91}, + {93, 116}, +}, +{ + {89, 60}, + {91, 66}, + {134, 185}, + {139, 198}, + {140, 200}, + {141, 201}, + {159, 201}, + {161, 199}, + {161, 195}, + {157, 179}, + {114, 26}, + {110, 12}, + {108, 10}, + {106, 9}, + {92, 9}, + {89, 50}, + {89, 60}, +}, +{ + {99, 130}, + {101, 133}, + {118, 150}, + {142, 150}, + {145, 148}, + {151, 142}, + {151, 80}, + {142, 62}, + {139, 60}, + {111, 60}, + {108, 62}, + {102, 80}, + {99, 95}, + {99, 130}, +}, +{ + {99, 122}, + {108, 140}, + {110, 142}, + {139, 142}, + {151, 122}, + {151, 102}, + {142, 70}, + {139, 68}, + {111, 68}, + {108, 70}, + {99, 102}, + {99, 122}, +}, +{ + {107, 124}, + {128, 125}, + {133, 125}, + {136, 124}, + {140, 121}, + {142, 119}, + {143, 116}, + {143, 109}, + {141, 93}, + {139, 89}, + {136, 86}, + {134, 85}, + {108, 85}, + {107, 86}, + {107, 124}, +}, +{ + {107, 146}, + {124, 146}, + {141, 96}, + {143, 79}, + {143, 73}, + {142, 70}, + {140, 68}, + {136, 65}, + {134, 64}, + {127, 64}, + {107, 65}, + {107, 146}, +}, +{ + {113, 118}, + {115, 120}, + {129, 129}, + {137, 129}, + {137, 81}, + {129, 81}, + {115, 90}, + {113, 92}, + {113, 118}, +}, +{ + {112, 122}, + {138, 122}, + {138, 88}, + {112, 88}, + {112, 122}, +}, +{ + {102, 116}, + {111, 126}, + {114, 126}, + {144, 106}, + {148, 100}, + {148, 85}, + {147, 84}, + {102, 84}, + {102, 116}, +}, +{ + {112, 110}, + {121, 112}, + {129, 112}, + {138, 110}, + {138, 106}, + {134, 98}, + {117, 98}, + {114, 102}, + {112, 106}, + {112, 110}, +}, +{ + {100, 156}, + {102, 158}, + {104, 159}, + {143, 159}, + {150, 152}, + {150, 58}, + {143, 51}, + {104, 51}, + {102, 52}, + {100, 54}, + {100, 156} +}, +{ + {106, 151}, + {108, 151}, + {139, 139}, + {144, 134}, + {144, 76}, + {139, 71}, + {108, 59}, + {106, 59}, + {106, 151} +}, +{ + {117, 107}, + {118, 109}, + {120, 112}, + {122, 113}, + {128, 113}, + {130, 112}, + {132, 109}, + {133, 107}, + {133, 103}, + {132, 101}, + {130, 98}, + {128, 97}, + {122, 97}, + {120, 98}, + {118, 101}, + {117, 103}, + {117, 107} +} +}; diff --git a/xs/src/libnest2d/tests/printer_parts.h b/xs/src/libnest2d/tests/printer_parts.h new file mode 100644 index 0000000000..3d101810e0 --- /dev/null +++ b/xs/src/libnest2d/tests/printer_parts.h @@ -0,0 +1,9 @@ +#ifndef PRINTER_PARTS_H +#define PRINTER_PARTS_H + +#include +#include + +extern const std::vector PRINTER_PART_POLYGONS; + +#endif // PRINTER_PARTS_H diff --git a/xs/src/libnest2d/tests/test.cpp b/xs/src/libnest2d/tests/test.cpp new file mode 100644 index 0000000000..c7fef3246e --- /dev/null +++ b/xs/src/libnest2d/tests/test.cpp @@ -0,0 +1,474 @@ +#include "gtest/gtest.h" +#include "gmock/gmock.h" +#include + +#include +#include "printer_parts.h" +#include +#include + +TEST(BasicFunctionality, Angles) +{ + + using namespace libnest2d; + + Degrees deg(180); + Radians rad(deg); + Degrees deg2(rad); + + ASSERT_DOUBLE_EQ(rad, Pi); + ASSERT_DOUBLE_EQ(deg, 180); + ASSERT_DOUBLE_EQ(deg2, 180); + ASSERT_DOUBLE_EQ(rad, (Radians) deg); + ASSERT_DOUBLE_EQ( (Degrees) rad, deg); + + ASSERT_TRUE(rad == deg); + +} + +// Simple test, does not use gmock +TEST(BasicFunctionality, creationAndDestruction) +{ + using namespace libnest2d; + + Item sh = { {0, 0}, {1, 0}, {1, 1}, {0, 1} }; + + ASSERT_EQ(sh.vertexCount(), 4); + + Item sh2 ({ {0, 0}, {1, 0}, {1, 1}, {0, 1} }); + + ASSERT_EQ(sh2.vertexCount(), 4); + + // copy + Item sh3 = sh2; + + ASSERT_EQ(sh3.vertexCount(), 4); + + sh2 = {}; + + ASSERT_EQ(sh2.vertexCount(), 0); + ASSERT_EQ(sh3.vertexCount(), 4); + +} + +TEST(GeometryAlgorithms, Distance) { + using namespace libnest2d; + + Point p1 = {0, 0}; + + Point p2 = {10, 0}; + Point p3 = {10, 10}; + + ASSERT_DOUBLE_EQ(PointLike::distance(p1, p2), 10); + ASSERT_DOUBLE_EQ(PointLike::distance(p1, p3), sqrt(200)); + + Segment seg(p1, p3); + + ASSERT_DOUBLE_EQ(PointLike::distance(p2, seg), 7.0710678118654755); + + auto result = PointLike::horizontalDistance(p2, seg); + + auto check = [](Coord val, Coord expected) { + if(std::is_floating_point::value) + ASSERT_DOUBLE_EQ(static_cast(val), expected); + else + ASSERT_EQ(val, expected); + }; + + ASSERT_TRUE(result.second); + check(result.first, 10); + + result = PointLike::verticalDistance(p2, seg); + ASSERT_TRUE(result.second); + check(result.first, -10); + + result = PointLike::verticalDistance(Point{10, 20}, seg); + ASSERT_TRUE(result.second); + check(result.first, 10); + + + Point p4 = {80, 0}; + Segment seg2 = { {0, 0}, {0, 40} }; + + result = PointLike::horizontalDistance(p4, seg2); + + ASSERT_TRUE(result.second); + check(result.first, 80); + + result = PointLike::verticalDistance(p4, seg2); + // Point should not be related to the segment + ASSERT_FALSE(result.second); + +} + +TEST(GeometryAlgorithms, Area) { + using namespace libnest2d; + + Rectangle rect(10, 10); + + ASSERT_EQ(rect.area(), 100); + + Rectangle rect2 = {100, 100}; + + ASSERT_EQ(rect2.area(), 10000); + +} + +TEST(GeometryAlgorithms, IsPointInsidePolygon) { + using namespace libnest2d; + + Rectangle rect(10, 10); + + Point p = {1, 1}; + + ASSERT_TRUE(rect.isPointInside(p)); + + p = {11, 11}; + + ASSERT_FALSE(rect.isPointInside(p)); + + + p = {11, 12}; + + ASSERT_FALSE(rect.isPointInside(p)); + + + p = {3, 3}; + + ASSERT_TRUE(rect.isPointInside(p)); + +} + +//TEST(GeometryAlgorithms, Intersections) { +// using namespace binpack2d; + +// Rectangle rect(70, 30); + +// rect.translate({80, 60}); + +// Rectangle rect2(80, 60); +// rect2.translate({80, 0}); + +//// ASSERT_FALSE(Item::intersects(rect, rect2)); + +// Segment s1({0, 0}, {10, 10}); +// Segment s2({1, 1}, {11, 11}); +// ASSERT_FALSE(ShapeLike::intersects(s1, s1)); +// ASSERT_FALSE(ShapeLike::intersects(s1, s2)); +//} + +// Simple test, does not use gmock +TEST(GeometryAlgorithms, LeftAndDownPolygon) +{ + using namespace libnest2d; + using namespace libnest2d; + + Box bin(100, 100); + BottomLeftPlacer placer(bin); + + Item item = {{70, 75}, {88, 60}, {65, 50}, {60, 30}, {80, 20}, {42, 20}, + {35, 35}, {35, 55}, {40, 75}, {70, 75}}; + + Item leftControl = { {40, 75}, + {35, 55}, + {35, 35}, + {42, 20}, + {0, 20}, + {0, 75}, + {40, 75}}; + + Item downControl = {{88, 60}, + {88, 0}, + {35, 0}, + {35, 35}, + {42, 20}, + {80, 20}, + {60, 30}, + {65, 50}, + {88, 60}}; + + Item leftp(placer.leftPoly(item)); + + ASSERT_TRUE(ShapeLike::isValid(leftp.rawShape()).first); + ASSERT_EQ(leftp.vertexCount(), leftControl.vertexCount()); + + for(size_t i = 0; i < leftControl.vertexCount(); i++) { + ASSERT_EQ(getX(leftp.vertex(i)), getX(leftControl.vertex(i))); + ASSERT_EQ(getY(leftp.vertex(i)), getY(leftControl.vertex(i))); + } + + Item downp(placer.downPoly(item)); + + ASSERT_TRUE(ShapeLike::isValid(downp.rawShape()).first); + ASSERT_EQ(downp.vertexCount(), downControl.vertexCount()); + + for(size_t i = 0; i < downControl.vertexCount(); i++) { + ASSERT_EQ(getX(downp.vertex(i)), getX(downControl.vertex(i))); + ASSERT_EQ(getY(downp.vertex(i)), getY(downControl.vertex(i))); + } +} + +// Simple test, does not use gmock +TEST(GeometryAlgorithms, ArrangeRectanglesTight) +{ + using namespace libnest2d; + + std::vector rects = { + {80, 80}, + {60, 90}, + {70, 30}, + {80, 60}, + {60, 60}, + {60, 40}, + {40, 40}, + {10, 10}, + {10, 10}, + {10, 10}, + {10, 10}, + {10, 10}, + {5, 5}, + {5, 5}, + {5, 5}, + {5, 5}, + {5, 5}, + {5, 5}, + {5, 5}, + {20, 20} }; + + + Arranger arrange(Box(210, 250)); + + auto groups = arrange(rects.begin(), rects.end()); + + ASSERT_EQ(groups.size(), 1); + ASSERT_EQ(groups[0].size(), rects.size()); + + // check for no intersections, no containment: + + for(auto result : groups) { + bool valid = true; + for(Item& r1 : result) { + for(Item& r2 : result) { + if(&r1 != &r2 ) { + valid = !Item::intersects(r1, r2) || Item::touches(r1, r2); + valid = (valid && !r1.isInside(r2) && !r2.isInside(r1)); + ASSERT_TRUE(valid); + } + } + } + } + +} + +TEST(GeometryAlgorithms, ArrangeRectanglesLoose) +{ + using namespace libnest2d; + +// std::vector rects = { {40, 40}, {10, 10}, {20, 20} }; + std::vector rects = { + {80, 80}, + {60, 90}, + {70, 30}, + {80, 60}, + {60, 60}, + {60, 40}, + {40, 40}, + {10, 10}, + {10, 10}, + {10, 10}, + {10, 10}, + {10, 10}, + {5, 5}, + {5, 5}, + {5, 5}, + {5, 5}, + {5, 5}, + {5, 5}, + {5, 5}, + {20, 20} }; + + Coord min_obj_distance = 5; + + Arranger arrange(Box(210, 250), + min_obj_distance); + + auto groups = arrange(rects.begin(), rects.end()); + + ASSERT_EQ(groups.size(), 1); + ASSERT_EQ(groups[0].size(), rects.size()); + + // check for no intersections, no containment: + auto result = groups[0]; + bool valid = true; + for(Item& r1 : result) { + for(Item& r2 : result) { + if(&r1 != &r2 ) { + valid = !Item::intersects(r1, r2); + valid = (valid && !r1.isInside(r2) && !r2.isInside(r1)); + ASSERT_TRUE(valid); + } + } + } + +} + +namespace { +using namespace libnest2d; + +template +void exportSVG(std::vector>& result, const Bin& bin, int idx = 0) { + + + std::string loc = "out"; + + static std::string svg_header = +R"raw( + + +)raw"; + + int i = idx; + auto r = result; +// for(auto r : result) { + std::fstream out(loc + std::to_string(i) + ".svg", std::fstream::out); + if(out.is_open()) { + out << svg_header; + Item rbin( Rectangle(bin.width(), bin.height()) ); + for(unsigned i = 0; i < rbin.vertexCount(); i++) { + auto v = rbin.vertex(i); + setY(v, -getY(v)/SCALE + 500 ); + setX(v, getX(v)/SCALE); + rbin.setVertex(i, v); + } + out << ShapeLike::serialize(rbin.rawShape()) << std::endl; + for(Item& sh : r) { + Item tsh(sh.transformedShape()); + for(unsigned i = 0; i < tsh.vertexCount(); i++) { + auto v = tsh.vertex(i); + setY(v, -getY(v)/SCALE + 500); + setX(v, getX(v)/SCALE); + tsh.setVertex(i, v); + } + out << ShapeLike::serialize(tsh.rawShape()) << std::endl; + } + out << "\n" << std::endl; + } + out.close(); + +// i++; +// } +} +} + +TEST(GeometryAlgorithms, BottomLeftStressTest) { + using namespace libnest2d; + + auto input = PRINTER_PART_POLYGONS; + + Box bin(210, 250); + BottomLeftPlacer placer(bin); + + auto it = input.begin(); + auto next = it; + int i = 0; + while(it != input.end() && ++next != input.end()) { + placer.pack(*it); + placer.pack(*next); + + auto result = placer.getItems(); + bool valid = true; + + if(result.size() == 2) { + Item& r1 = result[0]; + Item& r2 = result[1]; + valid = !Item::intersects(r1, r2) || Item::touches(r1, r2); + valid = (valid && !r1.isInside(r2) && !r2.isInside(r1)); + if(!valid) { + std::cout << "error index: " << i << std::endl; + exportSVG(result, bin, i); + } +// ASSERT_TRUE(valid); + } else { + std::cout << "something went terribly wrong!" << std::endl; + } + + + placer.clearItems(); + it++; + i++; + } +} + +TEST(GeometryAlgorithms, nfpConvexConvex) { + using namespace libnest2d; + + const unsigned long SCALE = 1; + + Box bin(210*SCALE, 250*SCALE); + + Item stationary = { + {120, 114}, + {130, 114}, + {130, 103}, + {128, 96}, + {122, 96}, + {120, 103}, + {120, 114} + }; + + Item orbiter = { + {72, 147}, + {94, 151}, + {178, 151}, + {178, 59}, + {72, 59}, + {72, 147} + }; + + orbiter.translate({210*SCALE, 0}); + + auto&& nfp = Nfp::noFitPolygon(stationary.rawShape(), + orbiter.transformedShape()); + + auto v = ShapeLike::isValid(nfp); + + if(!v.first) { + std::cout << v.second << std::endl; + } + + ASSERT_TRUE(v.first); + + Item infp(nfp); + + int i = 0; + auto rorbiter = orbiter.transformedShape(); + auto vo = *(ShapeLike::begin(rorbiter)); + for(auto v : infp) { + auto dx = getX(v) - getX(vo); + auto dy = getY(v) - getY(vo); + + Item tmp = orbiter; + + tmp.translate({dx, dy}); + + bool notinside = !tmp.isInside(stationary); + bool notintersecting = !Item::intersects(tmp, stationary); + + if(!(notinside && notintersecting)) { + std::vector> inp = { + std::ref(stationary), std::ref(tmp), std::ref(infp) + }; + + exportSVG(inp, bin, i++); + } + + //ASSERT_TRUE(notintersecting); + ASSERT_TRUE(notinside); + } + +} + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/xs/src/libslic3r/Fill/FillRectilinear3.cpp b/xs/src/libslic3r/Fill/FillRectilinear3.cpp index 1e7e3a1cdd..cccea30301 100644 --- a/xs/src/libslic3r/Fill/FillRectilinear3.cpp +++ b/xs/src/libslic3r/Fill/FillRectilinear3.cpp @@ -470,9 +470,9 @@ static bool prepare_infill_hatching_segments( int ir = std::min(int(out.segs.size()) - 1, (r - x0) / line_spacing); // The previous tests were done with floating point arithmetics over an epsilon-extended interval. // Now do the same tests with exact arithmetics over the exact interval. - while (il <= ir && Int128::orient(out.segs[il].pos, out.segs[il].pos + out.direction, *pl) < 0) + while (il <= ir && int128::orient(out.segs[il].pos, out.segs[il].pos + out.direction, *pl) < 0) ++ il; - while (il <= ir && Int128::orient(out.segs[ir].pos, out.segs[ir].pos + out.direction, *pr) > 0) + while (il <= ir && int128::orient(out.segs[ir].pos, out.segs[ir].pos + out.direction, *pr) > 0) -- ir; // Here it is ensured, that // 1) out.seg is not parallel to (pl, pr) @@ -489,8 +489,8 @@ static bool prepare_infill_hatching_segments( is.iSegment = iSegment; // Test whether the calculated intersection point falls into the bounding box of the input segment. // +-1 to take rounding into account. - assert(Int128::orient(out.segs[i].pos, out.segs[i].pos + out.direction, *pl) >= 0); - assert(Int128::orient(out.segs[i].pos, out.segs[i].pos + out.direction, *pr) <= 0); + assert(int128::orient(out.segs[i].pos, out.segs[i].pos + out.direction, *pl) >= 0); + assert(int128::orient(out.segs[i].pos, out.segs[i].pos + out.direction, *pr) <= 0); assert(is.pos().x + 1 >= std::min(pl->x, pr->x)); assert(is.pos().y + 1 >= std::min(pl->y, pr->y)); assert(is.pos().x <= std::max(pl->x, pr->x) + 1); @@ -527,7 +527,7 @@ static bool prepare_infill_hatching_segments( const Points &contour = poly_with_offset.contour(iContour).points; size_t iSegment = sil.intersections[i].iSegment; size_t iPrev = ((iSegment == 0) ? contour.size() : iSegment) - 1; - int dir = Int128::cross(contour[iSegment] - contour[iPrev], sil.dir); + int dir = int128::cross(contour[iSegment] - contour[iPrev], sil.dir); bool low = dir > 0; sil.intersections[i].type = poly_with_offset.is_contour_outer(iContour) ? (low ? SegmentIntersection::OUTER_LOW : SegmentIntersection::OUTER_HIGH) : diff --git a/xs/src/libslic3r/Int128.hpp b/xs/src/libslic3r/Int128.hpp index 7bf0c87b42..d54b753427 100644 --- a/xs/src/libslic3r/Int128.hpp +++ b/xs/src/libslic3r/Int128.hpp @@ -48,7 +48,6 @@ #endif #include -#include "Point.hpp" #if ! defined(_MSC_VER) && defined(__SIZEOF_INT128__) #define HAS_INTRINSIC_128_TYPE @@ -288,20 +287,4 @@ public: } return sign_determinant_2x2(p1, q1, p2, q2) * invert; } - - // Exact orientation predicate, - // returns +1: CCW, 0: collinear, -1: CW. - static int orient(const Slic3r::Point &p1, const Slic3r::Point &p2, const Slic3r::Point &p3) - { - Slic3r::Vector v1(p2 - p1); - Slic3r::Vector v2(p3 - p1); - return sign_determinant_2x2_filtered(v1.x, v1.y, v2.x, v2.y); - } - - // Exact orientation predicate, - // returns +1: CCW, 0: collinear, -1: CW. - static int cross(const Slic3r::Point &v1, const Slic3r::Point &v2) - { - return sign_determinant_2x2_filtered(v1.x, v1.y, v2.x, v2.y); - } }; diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 7559411448..e9a385eaf1 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -7,6 +7,12 @@ #include "Format/STL.hpp" #include "Format/3mf.hpp" +#include +#include +#include +#include +#include "slic3r/GUI/GUI.hpp" + #include #include @@ -296,35 +302,224 @@ static bool _arrange(const Pointfs &sizes, coordf_t dist, const BoundingBoxf* bb return result; } +namespace arr { + +using namespace libnest2d; + +// A container which stores a pointer to the 3D object and its projected +// 2D shape from top view. +using ShapeData2D = + std::vector>; + +ShapeData2D projectModelFromTop(const Slic3r::Model &model) { + ShapeData2D ret; + + auto s = std::accumulate(model.objects.begin(), model.objects.end(), 0, + [](size_t s, ModelObject* o){ + return s + o->instances.size(); + }); + + ret.reserve(s); + + for(auto objptr : model.objects) { + if(objptr) { + + auto rmesh = objptr->raw_mesh(); + + for(auto objinst : objptr->instances) { + if(objinst) { + Slic3r::TriangleMesh tmpmesh = rmesh; + objinst->transform_mesh(&tmpmesh); + ClipperLib::PolyNode pn; + auto p = tmpmesh.convex_hull(); + p.make_clockwise(); + p.append(p.first_point()); + pn.Contour = Slic3rMultiPoint_to_ClipperPath( p ); + + ret.emplace_back(objinst, Item(std::move(pn))); + } + } + } + } + + return ret; +} + +/** + * \brief Arranges the model objects on the screen. + * + * The arrangement considers multiple bins (aka. print beds) for placing all + * the items provided in the model argument. If the items don't fit on one + * print bed, the remaining will be placed onto newly created print beds. + * The first_bin_only parameter, if set to true, disables this behaviour and + * makes sure that only one print bed is filled and the remaining items will be + * untouched. When set to false, the items which could not fit onto the + * print bed will be placed next to the print bed so the user should see a + * pile of items on the print bed and some other piles outside the print + * area that can be dragged later onto the print bed as a group. + * + * \param model The model object with the 3D content. + * \param dist The minimum distance which is allowed for any pair of items + * on the print bed in any direction. + * \param bb The bounding box of the print bed. It corresponds to the 'bin' + * for bin packing. + * \param first_bin_only This parameter controls whether to place the + * remaining items which do not fit onto the print area next to the print + * bed or leave them untouched (let the user arrange them by hand or remove + * them). + */ +bool arrange(Model &model, coordf_t dist, const Slic3r::BoundingBoxf* bb, + bool first_bin_only) +{ + using ArrangeResult = _IndexedPackGroup; + + bool ret = true; + + // Create the arranger config + auto min_obj_distance = static_cast(dist/SCALING_FACTOR); + + // Get the 2D projected shapes with their 3D model instance pointers + auto shapemap = arr::projectModelFromTop(model); + + double area = 0; + double area_max = 0; + Item *biggest = nullptr; + + // Copy the references for the shapes only as the arranger expects a + // sequence of objects convertible to Item or ClipperPolygon + std::vector> shapes; + shapes.reserve(shapemap.size()); + std::for_each(shapemap.begin(), shapemap.end(), + [&shapes, &area, min_obj_distance, &area_max, &biggest] + (ShapeData2D::value_type& it) + { + Item& item = it.second; + item.addOffset(min_obj_distance); + auto b = ShapeLike::boundingBox(item.transformedShape()); + auto a = b.width()*b.height(); + if(area_max < a) { + area_max = static_cast(a); + biggest = &item; + } + area += b.width()*b.height(); + shapes.push_back(std::ref(it.second)); + }); + + Box bin; + + if(bb != nullptr && bb->defined) { + // Scale up the bounding box to clipper scale. + BoundingBoxf bbb = *bb; + bbb.scale(1.0/SCALING_FACTOR); + + bin = Box({ + static_cast(bbb.min.x), + static_cast(bbb.min.y) + }, + { + static_cast(bbb.max.x), + static_cast(bbb.max.y) + }); + } else { + // Just take the biggest item as bin... ? + bin = ShapeLike::boundingBox(biggest->transformedShape()); + } + + // Will use the DJD selection heuristic with the BottomLeft placement + // strategy + using Arranger = Arranger; + + Arranger arranger(bin, min_obj_distance); + + // Arrange and return the items with their respective indices within the + // input sequence. + ArrangeResult result = + arranger.arrangeIndexed(shapes.begin(), shapes.end()); + + + auto applyResult = [&shapemap](ArrangeResult::value_type& group, + Coord batch_offset) + { + for(auto& r : group) { + auto idx = r.first; // get the original item index + Item& item = r.second; // get the item itself + + // Get the model instance from the shapemap using the index + ModelInstance *inst_ptr = shapemap[idx].first; + + // Get the tranformation data from the item object and scale it + // appropriately + Radians rot = item.rotation(); + auto off = item.translation(); + Pointf foff(off.X*SCALING_FACTOR + batch_offset, + off.Y*SCALING_FACTOR); + + // write the tranformation data into the model instance + inst_ptr->rotation += rot; + inst_ptr->offset += foff; + + // Debug + /*std::cout << "item " << idx << ": \n" << "\toffset_x: " + * << foff.x << "\n\toffset_y: " << foff.y << std::endl;*/ + } + }; + + if(first_bin_only) { + applyResult(result.front(), 0); + } else { + Coord batch_offset = 0; + for(auto& group : result) { + applyResult(group, batch_offset); + + // Only the first pack group can be placed onto the print bed. The + // other objects which could not fit will be placed next to the + // print bed + batch_offset += static_cast(2*bin.width()*SCALING_FACTOR); + } + } + + for(auto objptr : model.objects) objptr->invalidate_bounding_box(); + + return ret && result.size() == 1; +} +} + /* arrange objects preserving their instance count but altering their instance positions */ bool Model::arrange_objects(coordf_t dist, const BoundingBoxf* bb) { - // get the (transformed) size of each instance so that we take - // into account their different transformations when packing - Pointfs instance_sizes; - Pointfs instance_centers; - for (const ModelObject *o : this->objects) - for (size_t i = 0; i < o->instances.size(); ++ i) { - // an accurate snug bounding box around the transformed mesh. - BoundingBoxf3 bbox(o->instance_bounding_box(i, true)); - instance_sizes.push_back(bbox.size()); - instance_centers.push_back(bbox.center()); - } + bool ret = false; + if(bb != nullptr && bb->defined) { + const bool FIRST_BIN_ONLY = true; + ret = arr::arrange(*this, dist, bb, FIRST_BIN_ONLY); + } else { + // get the (transformed) size of each instance so that we take + // into account their different transformations when packing + Pointfs instance_sizes; + Pointfs instance_centers; + for (const ModelObject *o : this->objects) + for (size_t i = 0; i < o->instances.size(); ++ i) { + // an accurate snug bounding box around the transformed mesh. + BoundingBoxf3 bbox(o->instance_bounding_box(i, true)); + instance_sizes.push_back(bbox.size()); + instance_centers.push_back(bbox.center()); + } - Pointfs positions; - if (! _arrange(instance_sizes, dist, bb, positions)) - return false; - - size_t idx = 0; - for (ModelObject *o : this->objects) { - for (ModelInstance *i : o->instances) { - i->offset = positions[idx] - instance_centers[idx]; - ++ idx; + Pointfs positions; + if (! _arrange(instance_sizes, dist, bb, positions)) + return false; + + size_t idx = 0; + for (ModelObject *o : this->objects) { + for (ModelInstance *i : o->instances) { + i->offset = positions[idx] - instance_centers[idx]; + ++ idx; + } + o->invalidate_bounding_box(); } - o->invalidate_bounding_box(); } - return true; + + return ret; } // Duplicate the entire model preserving instance relative positions. diff --git a/xs/src/libslic3r/Point.cpp b/xs/src/libslic3r/Point.cpp index 7c1dc91f57..2abcd26af4 100644 --- a/xs/src/libslic3r/Point.cpp +++ b/xs/src/libslic3r/Point.cpp @@ -1,6 +1,7 @@ #include "Point.hpp" #include "Line.hpp" #include "MultiPoint.hpp" +#include "Int128.hpp" #include #include @@ -375,4 +376,20 @@ Pointf3::vector_to(const Pointf3 &point) const return Vectorf3(point.x - this->x, point.y - this->y, point.z - this->z); } +namespace int128 { + +int orient(const Point &p1, const Point &p2, const Point &p3) +{ + Slic3r::Vector v1(p2 - p1); + Slic3r::Vector v2(p3 - p1); + return Int128::sign_determinant_2x2_filtered(v1.x, v1.y, v2.x, v2.y); +} + +int cross(const Point &v1, const Point &v2) +{ + return Int128::sign_determinant_2x2_filtered(v1.x, v1.y, v2.x, v2.y); +} + +} + } diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp index 6c9096a3d1..a7569a0062 100644 --- a/xs/src/libslic3r/Point.hpp +++ b/xs/src/libslic3r/Point.hpp @@ -81,6 +81,17 @@ inline Point operator*(double scalar, const Point& point2) { return Point(scalar inline int64_t cross(const Point &v1, const Point &v2) { return int64_t(v1.x) * int64_t(v2.y) - int64_t(v1.y) * int64_t(v2.x); } inline int64_t dot(const Point &v1, const Point &v2) { return int64_t(v1.x) * int64_t(v2.x) + int64_t(v1.y) * int64_t(v2.y); } +namespace int128 { + +// Exact orientation predicate, +// returns +1: CCW, 0: collinear, -1: CW. +int orient(const Point &p1, const Point &p2, const Point &p3); + +// Exact orientation predicate, +// returns +1: CCW, 0: collinear, -1: CW. +int cross(const Point &v1, const Slic3r::Point &v2); +} + // To be used by std::unordered_map, std::unordered_multimap and friends. struct PointHash { size_t operator()(const Point &pt) const { From d3106684620e8bac7f422daac25e6d959d0ba63b Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 17 May 2018 10:46:32 +0200 Subject: [PATCH 0359/1150] Added Regular view mode to the menu. Right column objects send fron Perl to C++ --- lib/Slic3r/GUI/Plater.pm | 17 ++- xs/src/slic3r/GUI/GUI.cpp | 313 +++++++++++++++++++++----------------- xs/src/slic3r/GUI/GUI.hpp | 11 ++ xs/xsp/GUI.xsp | 23 +++ 4 files changed, 225 insertions(+), 139 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 21cbcca45f..93b41af1c8 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -409,8 +409,10 @@ sub new { } } - my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxVERTICAL);#(wxHORIZONTAL); + my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxVERTICAL); Slic3r::GUI::add_frequently_changed_parameters($self, $frequently_changed_parameters_sizer, $presets); + my $expert_mode_part_sizer = Wx::BoxSizer->new(wxVERTICAL); + Slic3r::GUI::add_expert_mode_part($self, $expert_mode_part_sizer); my $object_info_sizer; { @@ -495,9 +497,10 @@ sub new { $scrolled_window_sizer->Add($print_info_sizer, 0, wxEXPAND, 0); my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); - $right_sizer->SetMinSize([-1, 600]); + $right_sizer->SetMinSize([320, 600]); $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; $right_sizer->Add($frequently_changed_parameters_sizer, 0, wxEXPAND | wxTOP, 0) if defined $frequently_changed_parameters_sizer; + $right_sizer->Add($expert_mode_part_sizer, 0, wxEXPAND | wxTOP, 0) if defined $expert_mode_part_sizer; $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5); $right_sizer->Add($scrolled_window_panel, 1, wxEXPAND | wxALL, 1); # Callback for showing / hiding the print info box. @@ -525,6 +528,16 @@ sub new { $sizer->SetSizeHints($self); $self->SetSizer($sizer); + + # Send sizers/buttons to C++ + Slic3r::GUI::set_objects_from_perl( $frequently_changed_parameters_sizer, + $expert_mode_part_sizer, + $scrolled_window_sizer, + $self->{btn_export_stl}, + $self->{btn_reslice}, + $self->{btn_print}, + $self->{btn_send_gcode}, + $self->{btn_export_gcode}); } # Last correct selected item for each preset diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index f97f7e31e9..3cf3c8d0d0 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -201,6 +201,16 @@ std::shared_ptr m_optgroup; double m_brim_width = 0.0; wxButton* g_wiping_dialog_button = nullptr; +//showed/hided controls according to the view mode +wxBoxSizer *g_frequently_changed_parameters_sizer = nullptr; +wxBoxSizer *g_expert_mode_part_sizer = nullptr; +wxBoxSizer *g_scrolled_window_sizer = nullptr; +wxButton *g_btn_export_stl = nullptr; +wxButton *g_btn_reslice = nullptr; +wxButton *g_btn_print = nullptr; +wxButton *g_btn_send_gcode = nullptr; +wxButton *g_btn_export_gcode = nullptr; + static void init_label_colours() { auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); @@ -260,6 +270,21 @@ void set_preset_updater(PresetUpdater *updater) g_PresetUpdater = updater; } +void set_objects_from_perl( wxBoxSizer *frequently_changed_parameters_sizer, + wxBoxSizer *expert_mode_part_sizer, wxBoxSizer *scrolled_window_sizer, + wxButton *btn_export_stl, wxButton *btn_reslice, wxButton *btn_print, + wxButton *btn_send_gcode, wxButton *btn_export_gcode) +{ + g_frequently_changed_parameters_sizer = frequently_changed_parameters_sizer; + g_expert_mode_part_sizer = expert_mode_part_sizer; + g_scrolled_window_sizer = scrolled_window_sizer; + g_btn_export_stl = btn_export_stl; + g_btn_reslice = btn_reslice; + g_btn_print = btn_print; + g_btn_send_gcode = btn_send_gcode; + g_btn_export_gcode = btn_export_gcode; +} + std::vector& get_tabs_list() { return g_tabs_list; @@ -378,12 +403,6 @@ void get_installed_languages(wxArrayString & names, } } -std::string get_view_mode() -{ - return g_AppConfig->has("view_mode") ? - g_AppConfig->get("view_mode") : "simple"; -} - enum ConfigMenuIDs { ConfigMenuWizard, ConfigMenuSnapshots, @@ -391,10 +410,24 @@ enum ConfigMenuIDs { ConfigMenuUpdate, ConfigMenuPreferences, ConfigMenuModeSimple, + ConfigMenuModeRegular, ConfigMenuModeExpert, ConfigMenuLanguage, ConfigMenuCnt, }; + +ConfigMenuIDs get_view_mode() +{ + if (!g_AppConfig->has("view_mode")) + return ConfigMenuModeSimple; + + const auto mode = g_AppConfig->get("view_mode"); + return mode == "expert" ? + ConfigMenuModeExpert : + mode == "regular" ? + ConfigMenuModeRegular : + ConfigMenuModeSimple; +} void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change) { @@ -412,9 +445,9 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->AppendSeparator(); auto mode_menu = new wxMenu(); mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("&Simple")), _(L("Simple View Mode"))); + mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeRegular, _(L("&Regular")), _(L("Regular View Mode"))); mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeExpert, _(L("&Expert")), _(L("Expert View Mode"))); - if (get_view_mode() == "expert") - mode_menu->Check(config_id_base + ConfigMenuModeExpert, true); + mode_menu->Check(config_id_base + get_view_mode(), true); local_menu->AppendSubMenu(mode_menu, _(L("&Mode")), _(L("Slic3r View Mode"))); local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); @@ -481,12 +514,16 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l case ConfigMenuModeExpert: mode = "expert"; break; + case ConfigMenuModeRegular: + mode = "regular"; + break; case ConfigMenuModeSimple: mode = "simple"; break; } g_AppConfig->set("view_mode", mode); g_AppConfig->save(); + update_mode(); }); menu->Append(local_menu, _(L("&Configuration"))); } @@ -835,9 +872,9 @@ wxString from_u8(const std::string &str) } -void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) +void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer) { - sizer->SetMinSize(-1, 300); + sizer->SetMinSize(-1, 150); auto main_sizer = new wxBoxSizer(wxVERTICAL); auto main_page = new wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); main_page->SetSizer(main_sizer); @@ -845,133 +882,10 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl sizer->Add(main_page, 1, wxEXPAND | wxALL, 1); // Experiments with new UI - - // *** Frequently Changing Parameters *** - auto* collpane = new PrusaCollapsiblePane(main_page, wxID_ANY, "Frequently Changing Parameters:"); - // add the pane with a zero proportion value to the sizer which contains it - main_sizer->Add(collpane, 0, wxGROW | wxALL, 0); - - wxWindow *win = collpane->GetPane(); - - DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; - m_optgroup = std::make_shared(win, "", config); - m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ - TabPrint* tab_print = nullptr; - for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { - Tab *tab = dynamic_cast(g_wxTabPanel->GetPage(i)); - if (!tab) - continue; - if (tab->name() == "print"){ - tab_print = static_cast(tab); - break; - } - } - if (tab_print == nullptr) - return; - - if (opt_key == "fill_density"){ - value = m_optgroup->get_config_value(*config, opt_key); - tab_print->set_value(opt_key, value); - tab_print->update(); - } - else{ - DynamicPrintConfig new_conf = *config; - if (opt_key == "brim"){ - double new_val; - double brim_width = config->opt_float("brim_width"); - if (boost::any_cast(value) == true) - { - new_val = m_brim_width == 0.0 ? 10 : - m_brim_width < 0.0 ? m_brim_width * (-1) : - m_brim_width; - } - else{ - m_brim_width = brim_width * (-1); - new_val = 0; - } - new_conf.set_key_value("brim_width", new ConfigOptionFloat(new_val)); - } - else{ //(opt_key == "support") - const wxString& selection = boost::any_cast(value); - - auto support_material = selection == _("None") ? false : true; - new_conf.set_key_value("support_material", new ConfigOptionBool(support_material)); - - if (selection == _("Everywhere")) - new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(false)); - else if (selection == _("Support on build plate only")) - new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(true)); - } - tab_print->load_config(new_conf); - } - - tab_print->update_dirty(); - }; - - Option option = m_optgroup->get_option("fill_density"); - option.opt.sidetext = ""; - option.opt.full_width = true; - m_optgroup->append_single_option_line(option); - - ConfigOptionDef def; - - def.label = L("Support"); - def.type = coStrings; - def.gui_type = "select_open"; - def.tooltip = L("Select what kind of support do you need"); - def.enum_labels.push_back(L("None")); - def.enum_labels.push_back(L("Support on build plate only")); - def.enum_labels.push_back(L("Everywhere")); - std::string selection = !config->opt_bool("support_material") ? - "None" : - config->opt_bool("support_material_buildplate_only") ? - "Support on build plate only" : - "Everywhere"; - def.default_value = new ConfigOptionStrings { selection }; - option = Option(def, "support"); - option.opt.full_width = true; - m_optgroup->append_single_option_line(option); - - m_brim_width = config->opt_float("brim_width"); - def.label = L("Brim"); - def.type = coBool; - def.tooltip = L("This flag enables the brim that will be printed around each object on the first layer."); - def.gui_type = ""; - def.default_value = new ConfigOptionBool{ m_brim_width > 0.0 ? true : false }; - option = Option(def, "brim"); - m_optgroup->append_single_option_line(option); - - - Line line = { "", "" }; - line.widget = [config](wxWindow* parent){ - g_wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes")) + "\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); - auto sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(g_wiping_dialog_button); - g_wiping_dialog_button->Bind(wxEVT_BUTTON, ([parent](wxCommandEvent& e) - { - auto &config = g_PresetBundle->project_config; - std::vector init_matrix = (config.option("wiping_volumes_matrix"))->values; - std::vector init_extruders = (config.option("wiping_volumes_extruders"))->values; - - WipingDialog dlg(parent,std::vector(init_matrix.begin(),init_matrix.end()),std::vector(init_extruders.begin(),init_extruders.end())); - - if (dlg.ShowModal() == wxID_OK) { - std::vector matrix = dlg.get_matrix(); - std::vector extruders = dlg.get_extruders(); - (config.option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(),matrix.end()); - (config.option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(),extruders.end()); - } - })); - return sizer; - }; - m_optgroup->append_line(line); - - wxSizer *paneSz = new wxBoxSizer(wxVERTICAL); - paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | wxLEFT | wxRIGHT, 5); - win->SetSizer(paneSz); - paneSz->SetSizeHints(win); - - +// wxSizer *paneSz = new wxBoxSizer(wxVERTICAL); +// paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | wxLEFT | wxRIGHT, 5); +// win->SetSizer(paneSz); +// paneSz->SetSizeHints(win); // *** Objects List *** auto *collpane_objects = new PrusaCollapsiblePane(main_page, wxID_ANY, "Objects List:"); @@ -1046,6 +960,131 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl // common_sizer->Add(listctrl, 0, wxEXPAND | wxALL, 1); +} + +void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) +{ + DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; + m_optgroup = std::make_shared(parent, "", config); + // const wxArrayInt& ar = preset_sizer->GetColWidths(); + // m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front(); // doesn't work + m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ + TabPrint* tab_print = nullptr; + for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { + Tab *tab = dynamic_cast(g_wxTabPanel->GetPage(i)); + if (!tab) + continue; + if (tab->name() == "print"){ + tab_print = static_cast(tab); + break; + } + } + if (tab_print == nullptr) + return; + + if (opt_key == "fill_density"){ + value = m_optgroup->get_config_value(*config, opt_key); + tab_print->set_value(opt_key, value); + tab_print->update(); + } + else{ + DynamicPrintConfig new_conf = *config; + if (opt_key == "brim"){ + double new_val; + double brim_width = config->opt_float("brim_width"); + if (boost::any_cast(value) == true) + { + new_val = m_brim_width == 0.0 ? 10 : + m_brim_width < 0.0 ? m_brim_width * (-1) : + m_brim_width; + } + else{ + m_brim_width = brim_width * (-1); + new_val = 0; + } + new_conf.set_key_value("brim_width", new ConfigOptionFloat(new_val)); + } + else{ //(opt_key == "support") + const wxString& selection = boost::any_cast(value); + + auto support_material = selection == _("None") ? false : true; + new_conf.set_key_value("support_material", new ConfigOptionBool(support_material)); + + if (selection == _("Everywhere")) + new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(false)); + else if (selection == _("Support on build plate only")) + new_conf.set_key_value("support_material_buildplate_only", new ConfigOptionBool(true)); + } + tab_print->load_config(new_conf); + } + + tab_print->update_dirty(); + }; + + Option option = m_optgroup->get_option("fill_density"); + option.opt.sidetext = ""; + option.opt.full_width = true; + m_optgroup->append_single_option_line(option); + + ConfigOptionDef def; + + def.label = L("Support"); + def.type = coStrings; + def.gui_type = "select_open"; + def.tooltip = L("Select what kind of support do you need"); + def.enum_labels.push_back(L("None")); + def.enum_labels.push_back(L("Support on build plate only")); + def.enum_labels.push_back(L("Everywhere")); + std::string selection = !config->opt_bool("support_material") ? + "None" : + config->opt_bool("support_material_buildplate_only") ? + "Support on build plate only" : + "Everywhere"; + def.default_value = new ConfigOptionStrings { selection }; + option = Option(def, "support"); + option.opt.full_width = true; + m_optgroup->append_single_option_line(option); + + m_brim_width = config->opt_float("brim_width"); + def.label = L("Brim"); + def.type = coBool; + def.tooltip = L("This flag enables the brim that will be printed around each object on the first layer."); + def.gui_type = ""; + def.default_value = new ConfigOptionBool{ m_brim_width > 0.0 ? true : false }; + option = Option(def, "brim"); + m_optgroup->append_single_option_line(option); + + + Line line = { "", "" }; + line.widget = [config](wxWindow* parent){ + g_wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes")) + "\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); + auto sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(g_wiping_dialog_button); + g_wiping_dialog_button->Bind(wxEVT_BUTTON, ([parent](wxCommandEvent& e) + { + auto &config = g_PresetBundle->project_config; + std::vector init_matrix = (config.option("wiping_volumes_matrix"))->values; + std::vector init_extruders = (config.option("wiping_volumes_extruders"))->values; + + WipingDialog dlg(parent,std::vector(init_matrix.begin(),init_matrix.end()),std::vector(init_extruders.begin(),init_extruders.end())); + + if (dlg.ShowModal() == wxID_OK) { + std::vector matrix = dlg.get_matrix(); + std::vector extruders = dlg.get_extruders(); + (config.option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(),matrix.end()); + (config.option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(),extruders.end()); + } + })); + return sizer; + }; + m_optgroup->append_line(line); + + sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); +} + +void update_mode() +{ + } ConfigOptionsGroup* get_optgroup() diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 3752b5a7a4..28359decdf 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -79,6 +79,14 @@ void set_tab_panel(wxNotebook *tab_panel); void set_app_config(AppConfig *app_config); void set_preset_bundle(PresetBundle *preset_bundle); void set_preset_updater(PresetUpdater *updater); +void set_objects_from_perl( wxBoxSizer *frequently_changed_parameters_sizer, + wxBoxSizer *expert_mode_part_sizer, + wxBoxSizer *scrolled_window_sizer, + wxButton *btn_export_stl, + wxButton *btn_reslice, + wxButton *btn_print, + wxButton *btn_send_gcode, + wxButton *btn_export_gcode); AppConfig* get_app_config(); wxApp* get_app(); @@ -150,7 +158,10 @@ wxString L_str(const std::string &str); wxString from_u8(const std::string &str); +void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer); void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer); +// Update view mode according to selected menu +void update_mode(); ConfigOptionsGroup* get_optgroup(); wxButton* get_wiping_dialog_button(); diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index aa95bd647d..8b173161bd 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -86,6 +86,29 @@ void add_frequently_changed_parameters(SV *ui_parent, SV *ui_sizer, SV *ui_p_siz (wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"), (wxFlexGridSizer*)wxPli_sv_2_object(aTHX_ ui_p_sizer, "Wx::FlexGridSizer")); %}; +void add_expert_mode_part(SV *ui_parent, SV *ui_sizer) + %code%{ Slic3r::GUI::add_expert_mode_part((wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), + (wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer")); %}; + +void set_objects_from_perl( SV *frequently_changed_parameters_sizer, + SV *expert_mode_part_sizer, + SV *scrolled_window_sizer, + SV *btn_export_stl, + SV *btn_reslice, + SV *btn_print, + SV *btn_send_gcode, + SV *btn_export_gcode) + %code%{ Slic3r::GUI::set_objects_from_perl( + (wxBoxSizer *)wxPli_sv_2_object(aTHX_ frequently_changed_parameters_sizer, "Wx::BoxSizer"), + (wxBoxSizer *)wxPli_sv_2_object(aTHX_ expert_mode_part_sizer, "Wx::BoxSizer"), + (wxBoxSizer *)wxPli_sv_2_object(aTHX_ scrolled_window_sizer, "Wx::BoxSizer"), + (wxButton *)wxPli_sv_2_object(aTHX_ btn_export_stl, "Wx::Button"), + (wxButton *)wxPli_sv_2_object(aTHX_ btn_reslice, "Wx::Button"), + (wxButton *)wxPli_sv_2_object(aTHX_ btn_print, "Wx::Button"), + (wxButton *)wxPli_sv_2_object(aTHX_ btn_send_gcode, "Wx::Button"), + (wxButton *)wxPli_sv_2_object(aTHX_ btn_export_gcode, "Wx::Button")); %}; + + std::string fold_utf8_to_ascii(const char *src) %code%{ RETVAL = Slic3r::fold_utf8_to_ascii(src); %}; From 2cb108fbf841a3fe5be317e8cbf3d863ff8ec6a2 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 17 May 2018 12:56:14 +0200 Subject: [PATCH 0360/1150] Fix in File menu --- lib/Slic3r/GUI/MainFrame.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index fbcd34a3f6..a8de4a135d 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -191,7 +191,7 @@ sub _init_menubar { # File menu my $fileMenu = Wx::Menu->new; { - wxTheApp->append_menu_item($fileMenu, L("Open STL/OBJ/AMF…\tCtrl+O"), L('Open a model'), sub { + wxTheApp->append_menu_item($fileMenu, L("Open STL/OBJ/AMF/3MF…\tCtrl+O"), L('Open a model'), sub { $self->{plater}->add if $self->{plater}; }, undef, undef); #'brick_add.png'); $self->_append_menu_item($fileMenu, L("&Load Config…\tCtrl+L"), L('Load exported configuration file'), sub { From 96c7c4a58b819b8cc0ca0dd1c9e00717a9b04e42 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 16 May 2018 19:41:35 +0200 Subject: [PATCH 0361/1150] PresetUpdater: Remove obsolete presets --- xs/src/slic3r/Utils/PresetUpdater.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index fcbe20fb7f..a5208e3c26 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -409,6 +409,17 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons for (const auto &preset : bundle.prints) { preset_remover(preset); } for (const auto &preset : bundle.filaments) { preset_remover(preset); } for (const auto &preset : bundle.printers) { preset_remover(preset); } + + // Also apply the `obsolete_presets` property, removing obsolete ini files + auto obsolete_remover = [](const char *subdir, const std::string &preset) { + auto path = fs::path(Slic3r::data_dir()) / subdir / preset; + path += ".ini"; + fs::remove(path); + }; + + for (const auto &name : bundle.obsolete_presets.prints) { obsolete_remover("print", name); } + for (const auto &name : bundle.obsolete_presets.filaments) { obsolete_remover("filament", name); } + for (const auto &name : bundle.obsolete_presets.printers) { obsolete_remover("printer", name); } } } } From 35bf4aee7df3baee5f64b769d58d20199bb5268a Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 17 May 2018 14:08:50 +0200 Subject: [PATCH 0362/1150] Fixed loading of configuraton values octoprint_host, support_material_threshold They were incorrectly handled by the handle_legacy() function, which has been ported from the upstream Slic3r without inspecting its content. --- xs/src/libslic3r/PrintConfig.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 697a6f0d4a..dcfc3ffe74 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1911,8 +1911,10 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va std::ostringstream oss; oss << "0x0," << p.value.x << "x0," << p.value.x << "x" << p.value.y << ",0x" << p.value.y; value = oss.str(); - } else if (opt_key == "octoprint_host" && !value.empty()) { - opt_key = "print_host"; +// Maybe one day we will rename octoprint_host to print_host as it has been done in the upstream Slic3r. +// Commenting this out fixes github issue #869 for now. +// } else if (opt_key == "octoprint_host" && !value.empty()) { +// opt_key = "print_host"; } else if ((opt_key == "perimeter_acceleration" && value == "25") || (opt_key == "infill_acceleration" && value == "50")) { /* For historical reasons, the world's full of configs having these very low values; @@ -1923,10 +1925,6 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va } else if (opt_key == "support_material_pattern" && value == "pillars") { // Slic3r PE does not support the pillars. They never worked well. value = "rectilinear"; - } else if (opt_key == "support_material_threshold" && value == "0") { - // 0 used to be automatic threshold, but we introduced percent values so let's - // transform it into the default value - value = "60%"; } // Ignore the following obsolete configuration keys: From 9b4afb77d159dab56b0496319344f8623a2da175 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 17 May 2018 15:18:52 +0200 Subject: [PATCH 0363/1150] Hide legend texture when invalidating gcode by editing config data --- lib/Slic3r/GUI/Plater/3DPreview.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index b746de98f4..6b448080d3 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -380,6 +380,7 @@ sub load_print { #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids; } $self->show_hide_ui_elements('simple'); + $self->canvas->reset_legend_texture(); } else { $self->{force_sliders_full_range} = (scalar(@{$self->canvas->volumes}) == 0); $self->canvas->load_gcode_preview($self->print, $self->gcode_preview_data, \@colors); From de0b8226e1eaf26a529b65af87598daf50ca3350 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 17 May 2018 16:02:31 +0200 Subject: [PATCH 0364/1150] Tweaks to logic for sliders update in 3D Preview --- lib/Slic3r/GUI/Plater/3DPreview.pm | 64 +++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index 6b448080d3..fec463682b 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -328,22 +328,12 @@ sub load_print { } if ($n_layers == 0) { - $self->enabled(0); - $self->set_z_range(0,0); - $self->slider_low->Hide; - $self->slider_high->Hide; - $self->{z_label_low}->SetLabel(""); - $self->{z_label_high}->SetLabel(""); - $self->{z_label_low_idx}->SetLabel(""); - $self->{z_label_high_idx}->SetLabel(""); + $self->reset_sliders; $self->canvas->reset_legend_texture(); $self->canvas->Refresh; # clears canvas return; } - # used to set the sliders to the extremes of the current zs range - $self->{force_sliders_full_range} = 0; - if ($self->{preferred_color_mode} eq 'tool_or_feature') { # It is left to Slic3r to decide whether the print shall be colored by the tool or by the feature. # Color by feature if it is a single extruder print. @@ -369,6 +359,9 @@ sub load_print { } if ($self->IsShown) { + # used to set the sliders to the extremes of the current zs range + $self->{force_sliders_full_range} = 0; + if ($self->gcode_preview_data->empty) { # load skirt and brim $self->canvas->load_print_toolpaths($self->print, \@colors); @@ -389,13 +382,30 @@ sub load_print { # recalculates zs and update sliders accordingly $self->{layers_z} = $self->canvas->get_current_print_zs(); $n_layers = scalar(@{$self->{layers_z}}); - } + if ($n_layers == 0) { + # all layers filtered out + $self->reset_sliders; + $self->canvas->Refresh; # clears canvas + } + } - $self->update_sliders($n_layers); + $self->update_sliders($n_layers) if ($n_layers > 0); $self->_loaded(1); } } +sub reset_sliders { + my ($self) = @_; + $self->enabled(0); + $self->set_z_range(0,0); + $self->slider_low->Hide; + $self->slider_high->Hide; + $self->{z_label_low}->SetLabel(""); + $self->{z_label_high}->SetLabel(""); + $self->{z_label_low_idx}->SetLabel(""); + $self->{z_label_high_idx}->SetLabel(""); +} + sub update_sliders { my ($self, $n_layers) = @_; @@ -410,18 +420,32 @@ sub update_sliders $z_idx_low = 0; $z_idx_high = $n_layers - 1; } elsif ($z_idx_high < $n_layers && ($self->single_layer || $z_idx_high != 0)) { - # use $z_idx - } else { + # search new indices for nearest z (size of $self->{layers_z} may change in dependence of what is shown) + if (defined($self->{z_low})) { + for (my $i = scalar(@{$self->{layers_z}}) - 1; $i >= 0; $i -= 1) { + if ($self->{layers_z}[$i] <= $self->{z_low}) { + $z_idx_low = $i; + last; + } + } + } + if (defined($self->{z_high})) { + for (my $i = scalar(@{$self->{layers_z}}) - 1; $i >= 0; $i -= 1) { + if ($self->{layers_z}[$i] <= $self->{z_high}) { + $z_idx_high = $i; + last; + } + } + } + } elsif ($z_idx_high >= $n_layers) { # Out of range. Disable 'single layer' view. $self->single_layer(0); $self->{checkbox_singlelayer}->SetValue(0); $z_idx_low = 0; $z_idx_high = $n_layers - 1; - } - if ($self->single_layer) { - $z_idx_low = $z_idx_high; - } elsif ($z_idx_low > $z_idx_high) { + } else { $z_idx_low = 0; + $z_idx_high = $n_layers - 1; } $self->slider_low->SetValue($z_idx_low); @@ -437,6 +461,8 @@ sub set_z_range my ($self, $z_low, $z_high) = @_; return if !$self->enabled; + $self->{z_low} = $z_low; + $self->{z_high} = $z_high; $self->{z_label_low}->SetLabel(sprintf '%.2f', $z_low); $self->{z_label_high}->SetLabel(sprintf '%.2f', $z_high); my $z_idx_low = 1 + $self->slider_low->GetValue; From 4e47f4973cc7ac151ce6bc16f9a12ae2af48888d Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 17 May 2018 14:07:50 +0200 Subject: [PATCH 0365/1150] Updating of the right column according selected view mode --- lib/Slic3r/GUI/Plater.pm | 13 +++++-- xs/src/slic3r/GUI/GUI.cpp | 59 +++++++++++++++++++++++++++--- xs/src/slic3r/GUI/GUI.hpp | 7 ++-- xs/src/slic3r/GUI/OptionsGroup.cpp | 27 ++++++++------ xs/src/slic3r/GUI/OptionsGroup.hpp | 1 + xs/src/slic3r/GUI/Tab.hpp | 2 +- xs/xsp/GUI.xsp | 14 ++++--- 7 files changed, 92 insertions(+), 31 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 93b41af1c8..ebb561a9e5 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -509,7 +509,12 @@ sub new { # $right_sizer->Show(5, $_[0]); # $self->Layout # } - if ($scrolled_window_sizer->IsShown(2) != $_[0]) { + if ($scrolled_window_sizer->IsShown(2) != $_[0]) { + Slic3r::GUI::set_show_print_info($_[0]); + my $mode = wxTheApp->{app_config}->get("view_mode"); + printf $mode."\n"; + return if ($mode eq "simple"); + print "non-simple\n"; $scrolled_window_sizer->Show(2, $_[0]); $scrolled_window_panel->Layout } @@ -530,14 +535,14 @@ sub new { $self->SetSizer($sizer); # Send sizers/buttons to C++ - Slic3r::GUI::set_objects_from_perl( $frequently_changed_parameters_sizer, + Slic3r::GUI::set_objects_from_perl( $self, + $frequently_changed_parameters_sizer, $expert_mode_part_sizer, $scrolled_window_sizer, $self->{btn_export_stl}, $self->{btn_reslice}, $self->{btn_print}, - $self->{btn_send_gcode}, - $self->{btn_export_gcode}); + $self->{btn_send_gcode} ); } # Last correct selected item for each preset diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 3cf3c8d0d0..09ede75beb 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -202,6 +202,7 @@ double m_brim_width = 0.0; wxButton* g_wiping_dialog_button = nullptr; //showed/hided controls according to the view mode +wxWindow *g_plater = nullptr; wxBoxSizer *g_frequently_changed_parameters_sizer = nullptr; wxBoxSizer *g_expert_mode_part_sizer = nullptr; wxBoxSizer *g_scrolled_window_sizer = nullptr; @@ -209,7 +210,7 @@ wxButton *g_btn_export_stl = nullptr; wxButton *g_btn_reslice = nullptr; wxButton *g_btn_print = nullptr; wxButton *g_btn_send_gcode = nullptr; -wxButton *g_btn_export_gcode = nullptr; +bool g_show_print_info = false; static void init_label_colours() { @@ -270,11 +271,12 @@ void set_preset_updater(PresetUpdater *updater) g_PresetUpdater = updater; } -void set_objects_from_perl( wxBoxSizer *frequently_changed_parameters_sizer, +void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_parameters_sizer, wxBoxSizer *expert_mode_part_sizer, wxBoxSizer *scrolled_window_sizer, - wxButton *btn_export_stl, wxButton *btn_reslice, wxButton *btn_print, - wxButton *btn_send_gcode, wxButton *btn_export_gcode) + wxButton *btn_export_stl, wxButton *btn_reslice, + wxButton *btn_print, wxButton *btn_send_gcode) { + g_plater = parent; g_frequently_changed_parameters_sizer = frequently_changed_parameters_sizer; g_expert_mode_part_sizer = expert_mode_part_sizer; g_scrolled_window_sizer = scrolled_window_sizer; @@ -282,7 +284,11 @@ void set_objects_from_perl( wxBoxSizer *frequently_changed_parameters_sizer, g_btn_reslice = btn_reslice; g_btn_print = btn_print; g_btn_send_gcode = btn_send_gcode; - g_btn_export_gcode = btn_export_gcode; +} + +void set_show_print_info(bool show) +{ + g_show_print_info = show; } std::vector& get_tabs_list() @@ -601,6 +607,7 @@ void create_preset_tabs(bool no_controller, int event_value_change, int event_pr tab->set_event_value_change(wxEventType(event_value_change)); tab->set_event_presets_changed(wxEventType(event_presets_changed)); } + update_mode();// TODO change place of call this function } TabIface* get_preset_tab_iface(char *name) @@ -1082,9 +1089,51 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); } +void show_frequently_changed_parameters(bool show) +{ + g_frequently_changed_parameters_sizer->Show(show); + if (!show) return; + + for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { + Tab *tab = dynamic_cast(g_wxTabPanel->GetPage(i)); + if (!tab) + continue; + tab->update_wiping_button_visibility(); + break; + } +} + +void show_buttons(bool show) +{ + g_btn_export_stl->Show(show); + g_btn_reslice->Show(show); + for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { + TabPrinter *tab = dynamic_cast(g_wxTabPanel->GetPage(i)); + if (!tab) + continue; + g_btn_print->Show(show && !tab->m_config->opt_string("serial_port").empty()); + g_btn_send_gcode->Show(show && !tab->m_config->opt_string("octoprint_host").empty()); + break; + } +} + +void show_scrolled_window_sizer(bool show) +{ + g_scrolled_window_sizer->Show(static_cast(0), show); + g_scrolled_window_sizer->Show(1, show); + g_scrolled_window_sizer->Show(2, show && g_show_print_info); +} + void update_mode() { + wxWindowUpdateLocker noUpdates(g_plater); + ConfigMenuIDs mode = get_view_mode(); + show_frequently_changed_parameters(mode >= ConfigMenuModeRegular); + g_expert_mode_part_sizer->Show(mode == ConfigMenuModeExpert); + show_scrolled_window_sizer(mode >= ConfigMenuModeRegular); + show_buttons(mode >= ConfigMenuModeRegular); + g_plater->Layout(); } ConfigOptionsGroup* get_optgroup() diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 28359decdf..1cca993197 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -79,14 +79,15 @@ void set_tab_panel(wxNotebook *tab_panel); void set_app_config(AppConfig *app_config); void set_preset_bundle(PresetBundle *preset_bundle); void set_preset_updater(PresetUpdater *updater); -void set_objects_from_perl( wxBoxSizer *frequently_changed_parameters_sizer, +void set_objects_from_perl( wxWindow* parent, + wxBoxSizer *frequently_changed_parameters_sizer, wxBoxSizer *expert_mode_part_sizer, wxBoxSizer *scrolled_window_sizer, wxButton *btn_export_stl, wxButton *btn_reslice, wxButton *btn_print, - wxButton *btn_send_gcode, - wxButton *btn_export_gcode); + wxButton *btn_send_gcode); +void set_show_print_info(bool show); AppConfig* get_app_config(); wxApp* get_app(); diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 657ad03c03..40176a0007 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -86,17 +86,23 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co if (!this->m_disabled) this->back_to_sys_value(opt_id); }; - if (!m_is_tab_opt) { - field->m_Undo_btn->Hide(); - field->m_Undo_to_sys_btn->Hide(); - } -// if (nonsys_btn_icon != nullptr) -// field->set_nonsys_btn_icon(*nonsys_btn_icon); // assign function objects for callbacks, etc. return field; } +void OptionsGroup::add_undo_buttuns_to_sizer(wxBoxSizer* sizer, const t_field& field) +{ + if (!m_is_tab_opt) { + field->m_Undo_btn->Hide(); + field->m_Undo_to_sys_btn->Hide(); + return; + } + + sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); + sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL); +} + void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* = nullptr*/) { //! if (line.sizer != nullptr || (line.widget != nullptr && line.full_width > 0)){ if ( (line.sizer != nullptr || line.widget != nullptr) && line.full_width){ @@ -131,8 +137,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* const auto& field = build_field(option); auto btn_sizer = new wxBoxSizer(wxHORIZONTAL); - btn_sizer->Add(field->m_Undo_to_sys_btn); - btn_sizer->Add(field->m_Undo_btn); + add_undo_buttuns_to_sizer(btn_sizer, field); tmp_sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0); if (is_window_field(field)) tmp_sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); @@ -176,8 +181,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* const auto& option = option_set.front(); const auto& field = build_field(option, label); - sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); - sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL); + add_undo_buttuns_to_sizer(sizer, field); if (is_window_field(field)) sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, (option.opt.full_width ? wxEXPAND : 0) | wxBOTTOM | wxTOP | wxALIGN_CENTER_VERTICAL, wxOSX ? 0 : 2); @@ -205,8 +209,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* // add field const Option& opt_ref = opt; auto& field = build_field(opt_ref, label); - sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); - sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL, 0); + add_undo_buttuns_to_sizer(sizer, field); is_sizer_field(field) ? sizer->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) : sizer->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0); diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 83b5b1233f..55a8dc70b9 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -171,6 +171,7 @@ protected: const t_field& build_field(const t_config_option_key& id, const ConfigOptionDef& opt, wxStaticText* label = nullptr); const t_field& build_field(const t_config_option_key& id, wxStaticText* label = nullptr); const t_field& build_field(const Option& opt, wxStaticText* label = nullptr); + void add_undo_buttuns_to_sizer(wxBoxSizer* sizer, const t_field& field); virtual void on_kill_focus (){}; virtual void on_change_OG(const t_config_option_key& opt_id, const boost::any& value); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 62030bce34..8f540b1977 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -264,11 +264,11 @@ public: void on_value_change(const std::string& opt_key, const boost::any& value); + void update_wiping_button_visibility(); protected: void on_presets_changed(); void update_preset_description_line(); void update_frequently_changed_parameters(); - void update_wiping_button_visibility(); void update_tab_presets(wxComboCtrl* ui, bool show_incompatible); void fill_icon_descriptions(); void set_tooltips_text(); diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 8b173161bd..b402ab656e 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -90,24 +90,26 @@ void add_expert_mode_part(SV *ui_parent, SV *ui_sizer) %code%{ Slic3r::GUI::add_expert_mode_part((wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), (wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer")); %}; -void set_objects_from_perl( SV *frequently_changed_parameters_sizer, +void set_objects_from_perl( SV *ui_parent, + SV *frequently_changed_parameters_sizer, SV *expert_mode_part_sizer, SV *scrolled_window_sizer, SV *btn_export_stl, SV *btn_reslice, SV *btn_print, - SV *btn_send_gcode, - SV *btn_export_gcode) - %code%{ Slic3r::GUI::set_objects_from_perl( + SV *btn_send_gcode) + %code%{ Slic3r::GUI::set_objects_from_perl( + (wxWindow *)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), (wxBoxSizer *)wxPli_sv_2_object(aTHX_ frequently_changed_parameters_sizer, "Wx::BoxSizer"), (wxBoxSizer *)wxPli_sv_2_object(aTHX_ expert_mode_part_sizer, "Wx::BoxSizer"), (wxBoxSizer *)wxPli_sv_2_object(aTHX_ scrolled_window_sizer, "Wx::BoxSizer"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_export_stl, "Wx::Button"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_reslice, "Wx::Button"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_print, "Wx::Button"), - (wxButton *)wxPli_sv_2_object(aTHX_ btn_send_gcode, "Wx::Button"), - (wxButton *)wxPli_sv_2_object(aTHX_ btn_export_gcode, "Wx::Button")); %}; + (wxButton *)wxPli_sv_2_object(aTHX_ btn_send_gcode, "Wx::Button")); %}; +void set_show_print_info(bool show) + %code%{ Slic3r::GUI::set_show_print_info(show); %}; std::string fold_utf8_to_ascii(const char *src) %code%{ RETVAL = Slic3r::fold_utf8_to_ascii(src); %}; From e783e005787f5ed91da1a15e9a30e81923af965e Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 17 May 2018 16:19:40 +0200 Subject: [PATCH 0366/1150] AppConfig: Remember previous Slic3r version --- xs/src/slic3r/GUI/AppConfig.cpp | 1 + xs/src/slic3r/GUI/AppConfig.hpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp index 70f4ba110d..c1c90fb729 100644 --- a/xs/src/slic3r/GUI/AppConfig.cpp +++ b/xs/src/slic3r/GUI/AppConfig.cpp @@ -100,6 +100,7 @@ void AppConfig::load() auto ini_ver = Semver::parse(get("version")); m_legacy_datadir = false; if (ini_ver) { + m_orig_version = *ini_ver; // Make 1.40.0 alphas compare well ini_ver->set_metadata(boost::none); ini_ver->set_prerelease(boost::none); diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index 16469f0e95..a9d8f93073 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -13,7 +13,13 @@ namespace Slic3r { class AppConfig { public: - AppConfig() : m_dirty(false), m_legacy_datadir(false) { this->reset(); } + AppConfig() : + m_dirty(false), + m_orig_version(Semver::invalid()), + m_legacy_datadir(false) + { + this->reset(); + } // Clear and reset to defaults. void reset(); @@ -100,6 +106,10 @@ public: // This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file. std::string version_check_url() const; + // Returns the original Slic3r version found in the ini file before it was overwritten + // by the current version + Semver orig_version() const { return m_orig_version; } + // Does the config file exist? static bool exists(); @@ -110,6 +120,8 @@ private: VendorMap m_vendors; // Has any value been modified since the config.ini has been last saved or loaded? bool m_dirty; + // Original version found in the ini file before it was overwritten + Semver m_orig_version; // Whether the existing version is before system profiles & configuration updating bool m_legacy_datadir; }; From 5fd216461266dd14ce611643f66b6771edfe0bca Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 17 May 2018 17:19:33 +0200 Subject: [PATCH 0367/1150] ConfigWizard: Fix incorrent wizard run after a language change --- xs/src/slic3r/GUI/AppConfig.hpp | 1 + xs/src/slic3r/GUI/ConfigWizard.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index a9d8f93073..08741e1e4b 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -101,6 +101,7 @@ public: // Returns true if the user's data directory comes from before Slic3r 1.40.0 (no updating) bool legacy_datadir() const { return m_legacy_datadir; } + bool set_legacy_datadir(bool value) { m_legacy_datadir = value; } // Get the Slic3r version check url. // This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file. diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 1217f86831..6b8e8abaf3 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -835,7 +835,9 @@ bool ConfigWizard::run(PresetBundle *preset_bundle, const PresetUpdater *updater { BOOST_LOG_TRIVIAL(info) << "Running ConfigWizard, reason: " << p->run_reason; if (ShowModal() == wxID_OK) { - p->apply_config(GUI::get_app_config(), preset_bundle, updater); + auto *app_config = GUI::get_app_config(); + p->apply_config(app_config, preset_bundle, updater); + app_config->set_legacy_datadir(false); BOOST_LOG_TRIVIAL(info) << "ConfigWizard applied"; return true; } else { From c3a944ef97c398f098eaecfb4191f2741ae0e324 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Thu, 17 May 2018 18:17:15 +0200 Subject: [PATCH 0368/1150] Can rasterize polygons with holes using AGG. Export is raw ppm for now. --- xs/src/agg/agg_alpha_mask_u8.h | 499 +++ xs/src/agg/agg_arc.h | 74 + xs/src/agg/agg_array.h | 1119 +++++++ xs/src/agg/agg_arrowhead.h | 82 + xs/src/agg/agg_basics.h | 574 ++++ xs/src/agg/agg_bezier_arc.h | 159 + xs/src/agg/agg_bitset_iterator.h | 54 + xs/src/agg/agg_blur.h | 1503 +++++++++ xs/src/agg/agg_bounding_rect.h | 116 + xs/src/agg/agg_bspline.h | 76 + xs/src/agg/agg_clip_liang_barsky.h | 333 ++ xs/src/agg/agg_color_gray.h | 1047 ++++++ xs/src/agg/agg_color_rgba.h | 1353 ++++++++ xs/src/agg/agg_config.h | 44 + xs/src/agg/agg_conv_adaptor_vcgen.h | 157 + xs/src/agg/agg_conv_adaptor_vpgen.h | 159 + xs/src/agg/agg_conv_bspline.h | 48 + xs/src/agg/agg_conv_clip_polygon.h | 63 + xs/src/agg/agg_conv_clip_polyline.h | 63 + xs/src/agg/agg_conv_close_polygon.h | 125 + xs/src/agg/agg_conv_concat.h | 73 + xs/src/agg/agg_conv_contour.h | 65 + xs/src/agg/agg_conv_curve.h | 201 ++ xs/src/agg/agg_conv_dash.h | 68 + xs/src/agg/agg_conv_gpc.h | 432 +++ xs/src/agg/agg_conv_marker.h | 148 + xs/src/agg/agg_conv_marker_adaptor.h | 51 + xs/src/agg/agg_conv_segmentator.h | 48 + xs/src/agg/agg_conv_shorten_path.h | 50 + xs/src/agg/agg_conv_smooth_poly1.h | 80 + xs/src/agg/agg_conv_stroke.h | 73 + xs/src/agg/agg_conv_transform.h | 68 + xs/src/agg/agg_conv_unclose_polygon.h | 52 + xs/src/agg/agg_curves.h | 693 ++++ xs/src/agg/agg_dda_line.h | 290 ++ xs/src/agg/agg_ellipse.h | 123 + xs/src/agg/agg_ellipse_bresenham.h | 113 + xs/src/agg/agg_embedded_raster_fonts.h | 59 + xs/src/agg/agg_font_cache_manager.h | 409 +++ xs/src/agg/agg_font_cache_manager2.h | 311 ++ xs/src/agg/agg_gamma_functions.h | 132 + xs/src/agg/agg_gamma_lut.h | 300 ++ xs/src/agg/agg_glyph_raster_bin.h | 155 + xs/src/agg/agg_gradient_lut.h | 244 ++ xs/src/agg/agg_gsv_text.h | 153 + xs/src/agg/agg_image_accessors.h | 481 +++ xs/src/agg/agg_image_filters.h | 449 +++ xs/src/agg/agg_line_aa_basics.h | 189 ++ xs/src/agg/agg_math.h | 437 +++ xs/src/agg/agg_math_stroke.h | 526 ++++ xs/src/agg/agg_path_length.h | 65 + xs/src/agg/agg_path_storage.h | 1582 ++++++++++ xs/src/agg/agg_path_storage_integer.h | 295 ++ xs/src/agg/agg_pattern_filters_rgba.h | 123 + xs/src/agg/agg_pixfmt_amask_adaptor.h | 240 ++ xs/src/agg/agg_pixfmt_base.h | 97 + xs/src/agg/agg_pixfmt_gray.h | 738 +++++ xs/src/agg/agg_pixfmt_rgb.h | 995 ++++++ xs/src/agg/agg_pixfmt_rgb_packed.h | 1311 ++++++++ xs/src/agg/agg_pixfmt_rgba.h | 2803 +++++++++++++++++ xs/src/agg/agg_pixfmt_transposer.h | 157 + xs/src/agg/agg_rasterizer_cells_aa.h | 741 +++++ xs/src/agg/agg_rasterizer_compound_aa.h | 665 ++++ xs/src/agg/agg_rasterizer_outline.h | 147 + xs/src/agg/agg_rasterizer_outline_aa.h | 599 ++++ xs/src/agg/agg_rasterizer_scanline_aa.h | 481 +++ .../agg/agg_rasterizer_scanline_aa_nogamma.h | 483 +++ xs/src/agg/agg_rasterizer_sl_clip.h | 351 +++ xs/src/agg/agg_renderer_base.h | 731 +++++ xs/src/agg/agg_renderer_markers.h | 711 +++++ xs/src/agg/agg_renderer_mclip.h | 349 ++ xs/src/agg/agg_renderer_outline_aa.h | 1836 +++++++++++ xs/src/agg/agg_renderer_outline_image.h | 1036 ++++++ xs/src/agg/agg_renderer_primitives.h | 224 ++ xs/src/agg/agg_renderer_raster_text.h | 264 ++ xs/src/agg/agg_renderer_scanline.h | 854 +++++ xs/src/agg/agg_rendering_buffer.h | 300 ++ xs/src/agg/agg_rendering_buffer_dynarow.h | 137 + xs/src/agg/agg_rounded_rect.h | 72 + xs/src/agg/agg_scanline_bin.h | 264 ++ xs/src/agg/agg_scanline_boolean_algebra.h | 1567 +++++++++ xs/src/agg/agg_scanline_p.h | 329 ++ xs/src/agg/agg_scanline_storage_aa.h | 816 +++++ xs/src/agg/agg_scanline_storage_bin.h | 587 ++++ xs/src/agg/agg_scanline_u.h | 499 +++ xs/src/agg/agg_shorten_path.h | 66 + xs/src/agg/agg_simul_eq.h | 147 + xs/src/agg/agg_span_allocator.h | 54 + xs/src/agg/agg_span_converter.h | 56 + xs/src/agg/agg_span_gouraud.h | 172 + xs/src/agg/agg_span_gouraud_gray.h | 241 ++ xs/src/agg/agg_span_gouraud_rgba.h | 277 ++ xs/src/agg/agg_span_gradient.h | 377 +++ xs/src/agg/agg_span_gradient_alpha.h | 126 + xs/src/agg/agg_span_gradient_contour.h | 362 +++ xs/src/agg/agg_span_gradient_image.h | 188 ++ xs/src/agg/agg_span_image_filter.h | 247 ++ xs/src/agg/agg_span_image_filter_gray.h | 723 +++++ xs/src/agg/agg_span_image_filter_rgb.h | 861 +++++ xs/src/agg/agg_span_image_filter_rgba.h | 890 ++++++ xs/src/agg/agg_span_interpolator_adaptor.h | 77 + xs/src/agg/agg_span_interpolator_linear.h | 232 ++ xs/src/agg/agg_span_interpolator_persp.h | 462 +++ xs/src/agg/agg_span_interpolator_trans.h | 92 + xs/src/agg/agg_span_pattern_gray.h | 93 + xs/src/agg/agg_span_pattern_rgb.h | 96 + xs/src/agg/agg_span_pattern_rgba.h | 94 + xs/src/agg/agg_span_solid.h | 53 + xs/src/agg/agg_span_subdiv_adaptor.h | 141 + xs/src/agg/agg_trans_affine.h | 518 +++ xs/src/agg/agg_trans_bilinear.h | 166 + xs/src/agg/agg_trans_double_path.h | 131 + xs/src/agg/agg_trans_perspective.h | 731 +++++ xs/src/agg/agg_trans_single_path.h | 97 + xs/src/agg/agg_trans_viewport.h | 303 ++ xs/src/agg/agg_trans_warp_magnifier.h | 56 + xs/src/agg/agg_vcgen_bspline.h | 74 + xs/src/agg/agg_vcgen_contour.h | 94 + xs/src/agg/agg_vcgen_dash.h | 93 + xs/src/agg/agg_vcgen_markers_term.h | 66 + xs/src/agg/agg_vcgen_smooth_poly1.h | 87 + xs/src/agg/agg_vcgen_stroke.h | 102 + xs/src/agg/agg_vcgen_vertex_sequence.h | 135 + xs/src/agg/agg_vertex_sequence.h | 172 + xs/src/agg/agg_vpgen_clip_polygon.h | 83 + xs/src/agg/agg_vpgen_clip_polyline.h | 78 + xs/src/agg/agg_vpgen_segmentator.h | 61 + xs/src/libslic3r/Print.cpp | 165 +- xs/src/libslic3r/Print.hpp | 4 +- xs/src/libslic3r/Rasterizer/Rasterizer.cpp | 134 +- xs/src/libslic3r/Rasterizer/Rasterizer.hpp | 17 +- 131 files changed, 45962 insertions(+), 102 deletions(-) create mode 100644 xs/src/agg/agg_alpha_mask_u8.h create mode 100644 xs/src/agg/agg_arc.h create mode 100644 xs/src/agg/agg_array.h create mode 100644 xs/src/agg/agg_arrowhead.h create mode 100644 xs/src/agg/agg_basics.h create mode 100644 xs/src/agg/agg_bezier_arc.h create mode 100644 xs/src/agg/agg_bitset_iterator.h create mode 100644 xs/src/agg/agg_blur.h create mode 100644 xs/src/agg/agg_bounding_rect.h create mode 100644 xs/src/agg/agg_bspline.h create mode 100644 xs/src/agg/agg_clip_liang_barsky.h create mode 100644 xs/src/agg/agg_color_gray.h create mode 100644 xs/src/agg/agg_color_rgba.h create mode 100644 xs/src/agg/agg_config.h create mode 100644 xs/src/agg/agg_conv_adaptor_vcgen.h create mode 100644 xs/src/agg/agg_conv_adaptor_vpgen.h create mode 100644 xs/src/agg/agg_conv_bspline.h create mode 100644 xs/src/agg/agg_conv_clip_polygon.h create mode 100644 xs/src/agg/agg_conv_clip_polyline.h create mode 100644 xs/src/agg/agg_conv_close_polygon.h create mode 100644 xs/src/agg/agg_conv_concat.h create mode 100644 xs/src/agg/agg_conv_contour.h create mode 100644 xs/src/agg/agg_conv_curve.h create mode 100644 xs/src/agg/agg_conv_dash.h create mode 100644 xs/src/agg/agg_conv_gpc.h create mode 100644 xs/src/agg/agg_conv_marker.h create mode 100644 xs/src/agg/agg_conv_marker_adaptor.h create mode 100644 xs/src/agg/agg_conv_segmentator.h create mode 100644 xs/src/agg/agg_conv_shorten_path.h create mode 100644 xs/src/agg/agg_conv_smooth_poly1.h create mode 100644 xs/src/agg/agg_conv_stroke.h create mode 100644 xs/src/agg/agg_conv_transform.h create mode 100644 xs/src/agg/agg_conv_unclose_polygon.h create mode 100644 xs/src/agg/agg_curves.h create mode 100644 xs/src/agg/agg_dda_line.h create mode 100644 xs/src/agg/agg_ellipse.h create mode 100644 xs/src/agg/agg_ellipse_bresenham.h create mode 100644 xs/src/agg/agg_embedded_raster_fonts.h create mode 100644 xs/src/agg/agg_font_cache_manager.h create mode 100644 xs/src/agg/agg_font_cache_manager2.h create mode 100644 xs/src/agg/agg_gamma_functions.h create mode 100644 xs/src/agg/agg_gamma_lut.h create mode 100644 xs/src/agg/agg_glyph_raster_bin.h create mode 100644 xs/src/agg/agg_gradient_lut.h create mode 100644 xs/src/agg/agg_gsv_text.h create mode 100644 xs/src/agg/agg_image_accessors.h create mode 100644 xs/src/agg/agg_image_filters.h create mode 100644 xs/src/agg/agg_line_aa_basics.h create mode 100644 xs/src/agg/agg_math.h create mode 100644 xs/src/agg/agg_math_stroke.h create mode 100644 xs/src/agg/agg_path_length.h create mode 100644 xs/src/agg/agg_path_storage.h create mode 100644 xs/src/agg/agg_path_storage_integer.h create mode 100644 xs/src/agg/agg_pattern_filters_rgba.h create mode 100644 xs/src/agg/agg_pixfmt_amask_adaptor.h create mode 100644 xs/src/agg/agg_pixfmt_base.h create mode 100644 xs/src/agg/agg_pixfmt_gray.h create mode 100644 xs/src/agg/agg_pixfmt_rgb.h create mode 100644 xs/src/agg/agg_pixfmt_rgb_packed.h create mode 100644 xs/src/agg/agg_pixfmt_rgba.h create mode 100644 xs/src/agg/agg_pixfmt_transposer.h create mode 100644 xs/src/agg/agg_rasterizer_cells_aa.h create mode 100644 xs/src/agg/agg_rasterizer_compound_aa.h create mode 100644 xs/src/agg/agg_rasterizer_outline.h create mode 100644 xs/src/agg/agg_rasterizer_outline_aa.h create mode 100644 xs/src/agg/agg_rasterizer_scanline_aa.h create mode 100644 xs/src/agg/agg_rasterizer_scanline_aa_nogamma.h create mode 100644 xs/src/agg/agg_rasterizer_sl_clip.h create mode 100644 xs/src/agg/agg_renderer_base.h create mode 100644 xs/src/agg/agg_renderer_markers.h create mode 100644 xs/src/agg/agg_renderer_mclip.h create mode 100644 xs/src/agg/agg_renderer_outline_aa.h create mode 100644 xs/src/agg/agg_renderer_outline_image.h create mode 100644 xs/src/agg/agg_renderer_primitives.h create mode 100644 xs/src/agg/agg_renderer_raster_text.h create mode 100644 xs/src/agg/agg_renderer_scanline.h create mode 100644 xs/src/agg/agg_rendering_buffer.h create mode 100644 xs/src/agg/agg_rendering_buffer_dynarow.h create mode 100644 xs/src/agg/agg_rounded_rect.h create mode 100644 xs/src/agg/agg_scanline_bin.h create mode 100644 xs/src/agg/agg_scanline_boolean_algebra.h create mode 100644 xs/src/agg/agg_scanline_p.h create mode 100644 xs/src/agg/agg_scanline_storage_aa.h create mode 100644 xs/src/agg/agg_scanline_storage_bin.h create mode 100644 xs/src/agg/agg_scanline_u.h create mode 100644 xs/src/agg/agg_shorten_path.h create mode 100644 xs/src/agg/agg_simul_eq.h create mode 100644 xs/src/agg/agg_span_allocator.h create mode 100644 xs/src/agg/agg_span_converter.h create mode 100644 xs/src/agg/agg_span_gouraud.h create mode 100644 xs/src/agg/agg_span_gouraud_gray.h create mode 100644 xs/src/agg/agg_span_gouraud_rgba.h create mode 100644 xs/src/agg/agg_span_gradient.h create mode 100644 xs/src/agg/agg_span_gradient_alpha.h create mode 100644 xs/src/agg/agg_span_gradient_contour.h create mode 100644 xs/src/agg/agg_span_gradient_image.h create mode 100644 xs/src/agg/agg_span_image_filter.h create mode 100644 xs/src/agg/agg_span_image_filter_gray.h create mode 100644 xs/src/agg/agg_span_image_filter_rgb.h create mode 100644 xs/src/agg/agg_span_image_filter_rgba.h create mode 100644 xs/src/agg/agg_span_interpolator_adaptor.h create mode 100644 xs/src/agg/agg_span_interpolator_linear.h create mode 100644 xs/src/agg/agg_span_interpolator_persp.h create mode 100644 xs/src/agg/agg_span_interpolator_trans.h create mode 100644 xs/src/agg/agg_span_pattern_gray.h create mode 100644 xs/src/agg/agg_span_pattern_rgb.h create mode 100644 xs/src/agg/agg_span_pattern_rgba.h create mode 100644 xs/src/agg/agg_span_solid.h create mode 100644 xs/src/agg/agg_span_subdiv_adaptor.h create mode 100644 xs/src/agg/agg_trans_affine.h create mode 100644 xs/src/agg/agg_trans_bilinear.h create mode 100644 xs/src/agg/agg_trans_double_path.h create mode 100644 xs/src/agg/agg_trans_perspective.h create mode 100644 xs/src/agg/agg_trans_single_path.h create mode 100644 xs/src/agg/agg_trans_viewport.h create mode 100644 xs/src/agg/agg_trans_warp_magnifier.h create mode 100644 xs/src/agg/agg_vcgen_bspline.h create mode 100644 xs/src/agg/agg_vcgen_contour.h create mode 100644 xs/src/agg/agg_vcgen_dash.h create mode 100644 xs/src/agg/agg_vcgen_markers_term.h create mode 100644 xs/src/agg/agg_vcgen_smooth_poly1.h create mode 100644 xs/src/agg/agg_vcgen_stroke.h create mode 100644 xs/src/agg/agg_vcgen_vertex_sequence.h create mode 100644 xs/src/agg/agg_vertex_sequence.h create mode 100644 xs/src/agg/agg_vpgen_clip_polygon.h create mode 100644 xs/src/agg/agg_vpgen_clip_polyline.h create mode 100644 xs/src/agg/agg_vpgen_segmentator.h diff --git a/xs/src/agg/agg_alpha_mask_u8.h b/xs/src/agg/agg_alpha_mask_u8.h new file mode 100644 index 0000000000..e301c10088 --- /dev/null +++ b/xs/src/agg/agg_alpha_mask_u8.h @@ -0,0 +1,499 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// scanline_u8 class +// +//---------------------------------------------------------------------------- +#ifndef AGG_ALPHA_MASK_U8_INCLUDED +#define AGG_ALPHA_MASK_U8_INCLUDED + +#include +#include "agg_basics.h" +#include "agg_rendering_buffer.h" + +namespace agg +{ + //===================================================one_component_mask_u8 + struct one_component_mask_u8 + { + static unsigned calculate(const int8u* p) { return *p; } + }; + + + //=====================================================rgb_to_gray_mask_u8 + template + struct rgb_to_gray_mask_u8 + { + static unsigned calculate(const int8u* p) + { + return (p[R]*77 + p[G]*150 + p[B]*29) >> 8; + } + }; + + //==========================================================alpha_mask_u8 + template + class alpha_mask_u8 + { + public: + typedef int8u cover_type; + typedef alpha_mask_u8 self_type; + enum cover_scale_e + { + cover_shift = 8, + cover_none = 0, + cover_full = 255 + }; + + alpha_mask_u8() : m_rbuf(0) {} + explicit alpha_mask_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {} + + void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; } + + MaskF& mask_function() { return m_mask_function; } + const MaskF& mask_function() const { return m_mask_function; } + + + //-------------------------------------------------------------------- + cover_type pixel(int x, int y) const + { + if(x >= 0 && y >= 0 && + x < (int)m_rbuf->width() && + y < (int)m_rbuf->height()) + { + return (cover_type)m_mask_function.calculate( + m_rbuf->row_ptr(y) + x * Step + Offset); + } + return 0; + } + + //-------------------------------------------------------------------- + cover_type combine_pixel(int x, int y, cover_type val) const + { + if(x >= 0 && y >= 0 && + x < (int)m_rbuf->width() && + y < (int)m_rbuf->height()) + { + return (cover_type)((cover_full + val * + m_mask_function.calculate( + m_rbuf->row_ptr(y) + x * Step + Offset)) >> + cover_shift); + } + return 0; + } + + + //-------------------------------------------------------------------- + void fill_hspan(int x, int y, cover_type* dst, int num_pix) const + { + int xmax = m_rbuf->width() - 1; + int ymax = m_rbuf->height() - 1; + + int count = num_pix; + cover_type* covers = dst; + + if(y < 0 || y > ymax) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + + if(x < 0) + { + count += x; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers, 0, -x * sizeof(cover_type)); + covers -= x; + x = 0; + } + + if(x + count > xmax) + { + int rest = x + count - xmax - 1; + count -= rest; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, 0, rest * sizeof(cover_type)); + } + + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *covers++ = (cover_type)m_mask_function.calculate(mask); + mask += Step; + } + while(--count); + } + + + //-------------------------------------------------------------------- + void combine_hspan(int x, int y, cover_type* dst, int num_pix) const + { + int xmax = m_rbuf->width() - 1; + int ymax = m_rbuf->height() - 1; + + int count = num_pix; + cover_type* covers = dst; + + if(y < 0 || y > ymax) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + + if(x < 0) + { + count += x; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers, 0, -x * sizeof(cover_type)); + covers -= x; + x = 0; + } + + if(x + count > xmax) + { + int rest = x + count - xmax - 1; + count -= rest; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, 0, rest * sizeof(cover_type)); + } + + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *covers = (cover_type)((cover_full + (*covers) * + m_mask_function.calculate(mask)) >> + cover_shift); + ++covers; + mask += Step; + } + while(--count); + } + + //-------------------------------------------------------------------- + void fill_vspan(int x, int y, cover_type* dst, int num_pix) const + { + int xmax = m_rbuf->width() - 1; + int ymax = m_rbuf->height() - 1; + + int count = num_pix; + cover_type* covers = dst; + + if(x < 0 || x > xmax) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + + if(y < 0) + { + count += y; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers, 0, -y * sizeof(cover_type)); + covers -= y; + y = 0; + } + + if(y + count > ymax) + { + int rest = y + count - ymax - 1; + count -= rest; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, 0, rest * sizeof(cover_type)); + } + + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *covers++ = (cover_type)m_mask_function.calculate(mask); + mask += m_rbuf->stride(); + } + while(--count); + } + + //-------------------------------------------------------------------- + void combine_vspan(int x, int y, cover_type* dst, int num_pix) const + { + int xmax = m_rbuf->width() - 1; + int ymax = m_rbuf->height() - 1; + + int count = num_pix; + cover_type* covers = dst; + + if(x < 0 || x > xmax) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + + if(y < 0) + { + count += y; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers, 0, -y * sizeof(cover_type)); + covers -= y; + y = 0; + } + + if(y + count > ymax) + { + int rest = y + count - ymax - 1; + count -= rest; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, 0, rest * sizeof(cover_type)); + } + + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *covers = (cover_type)((cover_full + (*covers) * + m_mask_function.calculate(mask)) >> + cover_shift); + ++covers; + mask += m_rbuf->stride(); + } + while(--count); + } + + + private: + alpha_mask_u8(const self_type&); + const self_type& operator = (const self_type&); + + rendering_buffer* m_rbuf; + MaskF m_mask_function; + }; + + + typedef alpha_mask_u8<1, 0> alpha_mask_gray8; //----alpha_mask_gray8 + + typedef alpha_mask_u8<3, 0> alpha_mask_rgb24r; //----alpha_mask_rgb24r + typedef alpha_mask_u8<3, 1> alpha_mask_rgb24g; //----alpha_mask_rgb24g + typedef alpha_mask_u8<3, 2> alpha_mask_rgb24b; //----alpha_mask_rgb24b + + typedef alpha_mask_u8<3, 2> alpha_mask_bgr24r; //----alpha_mask_bgr24r + typedef alpha_mask_u8<3, 1> alpha_mask_bgr24g; //----alpha_mask_bgr24g + typedef alpha_mask_u8<3, 0> alpha_mask_bgr24b; //----alpha_mask_bgr24b + + typedef alpha_mask_u8<4, 0> alpha_mask_rgba32r; //----alpha_mask_rgba32r + typedef alpha_mask_u8<4, 1> alpha_mask_rgba32g; //----alpha_mask_rgba32g + typedef alpha_mask_u8<4, 2> alpha_mask_rgba32b; //----alpha_mask_rgba32b + typedef alpha_mask_u8<4, 3> alpha_mask_rgba32a; //----alpha_mask_rgba32a + + typedef alpha_mask_u8<4, 1> alpha_mask_argb32r; //----alpha_mask_argb32r + typedef alpha_mask_u8<4, 2> alpha_mask_argb32g; //----alpha_mask_argb32g + typedef alpha_mask_u8<4, 3> alpha_mask_argb32b; //----alpha_mask_argb32b + typedef alpha_mask_u8<4, 0> alpha_mask_argb32a; //----alpha_mask_argb32a + + typedef alpha_mask_u8<4, 2> alpha_mask_bgra32r; //----alpha_mask_bgra32r + typedef alpha_mask_u8<4, 1> alpha_mask_bgra32g; //----alpha_mask_bgra32g + typedef alpha_mask_u8<4, 0> alpha_mask_bgra32b; //----alpha_mask_bgra32b + typedef alpha_mask_u8<4, 3> alpha_mask_bgra32a; //----alpha_mask_bgra32a + + typedef alpha_mask_u8<4, 3> alpha_mask_abgr32r; //----alpha_mask_abgr32r + typedef alpha_mask_u8<4, 2> alpha_mask_abgr32g; //----alpha_mask_abgr32g + typedef alpha_mask_u8<4, 1> alpha_mask_abgr32b; //----alpha_mask_abgr32b + typedef alpha_mask_u8<4, 0> alpha_mask_abgr32a; //----alpha_mask_abgr32a + + typedef alpha_mask_u8<3, 0, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_rgb24gray; //----alpha_mask_rgb24gray + typedef alpha_mask_u8<3, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgr24gray; //----alpha_mask_bgr24gray + typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_rgba32gray; //----alpha_mask_rgba32gray + typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_argb32gray; //----alpha_mask_argb32gray + typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgra32gray; //----alpha_mask_bgra32gray + typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_abgr32gray; //----alpha_mask_abgr32gray + + + + //==========================================================amask_no_clip_u8 + template + class amask_no_clip_u8 + { + public: + typedef int8u cover_type; + typedef amask_no_clip_u8 self_type; + enum cover_scale_e + { + cover_shift = 8, + cover_none = 0, + cover_full = 255 + }; + + amask_no_clip_u8() : m_rbuf(0) {} + explicit amask_no_clip_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {} + + void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; } + + MaskF& mask_function() { return m_mask_function; } + const MaskF& mask_function() const { return m_mask_function; } + + + //-------------------------------------------------------------------- + cover_type pixel(int x, int y) const + { + return (cover_type)m_mask_function.calculate( + m_rbuf->row_ptr(y) + x * Step + Offset); + } + + + //-------------------------------------------------------------------- + cover_type combine_pixel(int x, int y, cover_type val) const + { + return (cover_type)((cover_full + val * + m_mask_function.calculate( + m_rbuf->row_ptr(y) + x * Step + Offset)) >> + cover_shift); + } + + + //-------------------------------------------------------------------- + void fill_hspan(int x, int y, cover_type* dst, int num_pix) const + { + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *dst++ = (cover_type)m_mask_function.calculate(mask); + mask += Step; + } + while(--num_pix); + } + + + + //-------------------------------------------------------------------- + void combine_hspan(int x, int y, cover_type* dst, int num_pix) const + { + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *dst = (cover_type)((cover_full + (*dst) * + m_mask_function.calculate(mask)) >> + cover_shift); + ++dst; + mask += Step; + } + while(--num_pix); + } + + + //-------------------------------------------------------------------- + void fill_vspan(int x, int y, cover_type* dst, int num_pix) const + { + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *dst++ = (cover_type)m_mask_function.calculate(mask); + mask += m_rbuf->stride(); + } + while(--num_pix); + } + + + //-------------------------------------------------------------------- + void combine_vspan(int x, int y, cover_type* dst, int num_pix) const + { + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *dst = (cover_type)((cover_full + (*dst) * + m_mask_function.calculate(mask)) >> + cover_shift); + ++dst; + mask += m_rbuf->stride(); + } + while(--num_pix); + } + + private: + amask_no_clip_u8(const self_type&); + const self_type& operator = (const self_type&); + + rendering_buffer* m_rbuf; + MaskF m_mask_function; + }; + + + typedef amask_no_clip_u8<1, 0> amask_no_clip_gray8; //----amask_no_clip_gray8 + + typedef amask_no_clip_u8<3, 0> amask_no_clip_rgb24r; //----amask_no_clip_rgb24r + typedef amask_no_clip_u8<3, 1> amask_no_clip_rgb24g; //----amask_no_clip_rgb24g + typedef amask_no_clip_u8<3, 2> amask_no_clip_rgb24b; //----amask_no_clip_rgb24b + + typedef amask_no_clip_u8<3, 2> amask_no_clip_bgr24r; //----amask_no_clip_bgr24r + typedef amask_no_clip_u8<3, 1> amask_no_clip_bgr24g; //----amask_no_clip_bgr24g + typedef amask_no_clip_u8<3, 0> amask_no_clip_bgr24b; //----amask_no_clip_bgr24b + + typedef amask_no_clip_u8<4, 0> amask_no_clip_rgba32r; //----amask_no_clip_rgba32r + typedef amask_no_clip_u8<4, 1> amask_no_clip_rgba32g; //----amask_no_clip_rgba32g + typedef amask_no_clip_u8<4, 2> amask_no_clip_rgba32b; //----amask_no_clip_rgba32b + typedef amask_no_clip_u8<4, 3> amask_no_clip_rgba32a; //----amask_no_clip_rgba32a + + typedef amask_no_clip_u8<4, 1> amask_no_clip_argb32r; //----amask_no_clip_argb32r + typedef amask_no_clip_u8<4, 2> amask_no_clip_argb32g; //----amask_no_clip_argb32g + typedef amask_no_clip_u8<4, 3> amask_no_clip_argb32b; //----amask_no_clip_argb32b + typedef amask_no_clip_u8<4, 0> amask_no_clip_argb32a; //----amask_no_clip_argb32a + + typedef amask_no_clip_u8<4, 2> amask_no_clip_bgra32r; //----amask_no_clip_bgra32r + typedef amask_no_clip_u8<4, 1> amask_no_clip_bgra32g; //----amask_no_clip_bgra32g + typedef amask_no_clip_u8<4, 0> amask_no_clip_bgra32b; //----amask_no_clip_bgra32b + typedef amask_no_clip_u8<4, 3> amask_no_clip_bgra32a; //----amask_no_clip_bgra32a + + typedef amask_no_clip_u8<4, 3> amask_no_clip_abgr32r; //----amask_no_clip_abgr32r + typedef amask_no_clip_u8<4, 2> amask_no_clip_abgr32g; //----amask_no_clip_abgr32g + typedef amask_no_clip_u8<4, 1> amask_no_clip_abgr32b; //----amask_no_clip_abgr32b + typedef amask_no_clip_u8<4, 0> amask_no_clip_abgr32a; //----amask_no_clip_abgr32a + + typedef amask_no_clip_u8<3, 0, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_rgb24gray; //----amask_no_clip_rgb24gray + typedef amask_no_clip_u8<3, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgr24gray; //----amask_no_clip_bgr24gray + typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_rgba32gray; //----amask_no_clip_rgba32gray + typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_argb32gray; //----amask_no_clip_argb32gray + typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgra32gray; //----amask_no_clip_bgra32gray + typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_abgr32gray; //----amask_no_clip_abgr32gray + + +} + + + +#endif diff --git a/xs/src/agg/agg_arc.h b/xs/src/agg/agg_arc.h new file mode 100644 index 0000000000..17e1d43473 --- /dev/null +++ b/xs/src/agg/agg_arc.h @@ -0,0 +1,74 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Arc vertex generator +// +//---------------------------------------------------------------------------- + +#ifndef AGG_ARC_INCLUDED +#define AGG_ARC_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + + //=====================================================================arc + // + // See Implementation agg_arc.cpp + // + class arc + { + public: + arc() : m_scale(1.0), m_initialized(false) {} + arc(double x, double y, + double rx, double ry, + double a1, double a2, + bool ccw=true); + + void init(double x, double y, + double rx, double ry, + double a1, double a2, + bool ccw=true); + + void approximation_scale(double s); + double approximation_scale() const { return m_scale; } + + void rewind(unsigned); + unsigned vertex(double* x, double* y); + + private: + void normalize(double a1, double a2, bool ccw); + + double m_x; + double m_y; + double m_rx; + double m_ry; + double m_angle; + double m_start; + double m_end; + double m_scale; + double m_da; + bool m_ccw; + bool m_initialized; + unsigned m_path_cmd; + }; + + +} + + +#endif diff --git a/xs/src/agg/agg_array.h b/xs/src/agg/agg_array.h new file mode 100644 index 0000000000..8d56683840 --- /dev/null +++ b/xs/src/agg/agg_array.h @@ -0,0 +1,1119 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_ARRAY_INCLUDED +#define AGG_ARRAY_INCLUDED + +#include +#include +#include "agg_basics.h" + +namespace agg +{ + + //-------------------------------------------------------pod_array_adaptor + template class pod_array_adaptor + { + public: + typedef T value_type; + pod_array_adaptor(T* array, unsigned size) : + m_array(array), m_size(size) {} + + unsigned size() const { return m_size; } + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + private: + T* m_array; + unsigned m_size; + }; + + + //---------------------------------------------------------pod_auto_array + template class pod_auto_array + { + public: + typedef T value_type; + typedef pod_auto_array self_type; + + pod_auto_array() {} + explicit pod_auto_array(const T* c) + { + memcpy(m_array, c, sizeof(T) * Size); + } + + const self_type& operator = (const T* c) + { + memcpy(m_array, c, sizeof(T) * Size); + return *this; + } + + static unsigned size() { return Size; } + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + private: + T m_array[Size]; + }; + + + //--------------------------------------------------------pod_auto_vector + template class pod_auto_vector + { + public: + typedef T value_type; + typedef pod_auto_vector self_type; + + pod_auto_vector() : m_size(0) {} + + void remove_all() { m_size = 0; } + void clear() { m_size = 0; } + void add(const T& v) { m_array[m_size++] = v; } + void push_back(const T& v) { m_array[m_size++] = v; } + void inc_size(unsigned size) { m_size += size; } + + unsigned size() const { return m_size; } + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + private: + T m_array[Size]; + unsigned m_size; + }; + + + //---------------------------------------------------------------pod_array + template class pod_array + { + public: + typedef T value_type; + typedef pod_array self_type; + + ~pod_array() { pod_allocator::deallocate(m_array, m_size); } + pod_array() : m_array(0), m_size(0) {} + + pod_array(unsigned size) : + m_array(pod_allocator::allocate(size)), + m_size(size) + {} + + pod_array(const self_type& v) : + m_array(pod_allocator::allocate(v.m_size)), + m_size(v.m_size) + { + memcpy(m_array, v.m_array, sizeof(T) * m_size); + } + + void resize(unsigned size) + { + if(size != m_size) + { + pod_allocator::deallocate(m_array, m_size); + m_array = pod_allocator::allocate(m_size = size); + } + } + const self_type& operator = (const self_type& v) + { + resize(v.size()); + memcpy(m_array, v.m_array, sizeof(T) * m_size); + return *this; + } + + unsigned size() const { return m_size; } + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + const T* data() const { return m_array; } + T* data() { return m_array; } + private: + T* m_array; + unsigned m_size; + }; + + + + //--------------------------------------------------------------pod_vector + // A simple class template to store Plain Old Data, a vector + // of a fixed size. The data is continous in memory + //------------------------------------------------------------------------ + template class pod_vector + { + public: + typedef T value_type; + + ~pod_vector() { pod_allocator::deallocate(m_array, m_capacity); } + pod_vector() : m_size(0), m_capacity(0), m_array(0) {} + pod_vector(unsigned cap, unsigned extra_tail=0); + + // Copying + pod_vector(const pod_vector&); + const pod_vector& operator = (const pod_vector&); + + // Set new capacity. All data is lost, size is set to zero. + void capacity(unsigned cap, unsigned extra_tail=0); + unsigned capacity() const { return m_capacity; } + + // Allocate n elements. All data is lost, + // but elements can be accessed in range 0...size-1. + void allocate(unsigned size, unsigned extra_tail=0); + + // Resize keeping the content. + void resize(unsigned new_size); + + void zero() + { + memset(m_array, 0, sizeof(T) * m_size); + } + + void add(const T& v) { m_array[m_size++] = v; } + void push_back(const T& v) { m_array[m_size++] = v; } + void insert_at(unsigned pos, const T& val); + void inc_size(unsigned size) { m_size += size; } + unsigned size() const { return m_size; } + unsigned byte_size() const { return m_size * sizeof(T); } + void serialize(int8u* ptr) const; + void deserialize(const int8u* data, unsigned byte_size); + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + const T* data() const { return m_array; } + T* data() { return m_array; } + + void remove_all() { m_size = 0; } + void clear() { m_size = 0; } + void cut_at(unsigned num) { if(num < m_size) m_size = num; } + + private: + unsigned m_size; + unsigned m_capacity; + T* m_array; + }; + + //------------------------------------------------------------------------ + template + void pod_vector::capacity(unsigned cap, unsigned extra_tail) + { + m_size = 0; + if(cap > m_capacity) + { + pod_allocator::deallocate(m_array, m_capacity); + m_capacity = cap + extra_tail; + m_array = m_capacity ? pod_allocator::allocate(m_capacity) : 0; + } + } + + //------------------------------------------------------------------------ + template + void pod_vector::allocate(unsigned size, unsigned extra_tail) + { + capacity(size, extra_tail); + m_size = size; + } + + + //------------------------------------------------------------------------ + template + void pod_vector::resize(unsigned new_size) + { + if(new_size > m_size) + { + if(new_size > m_capacity) + { + T* data = pod_allocator::allocate(new_size); + memcpy(data, m_array, m_size * sizeof(T)); + pod_allocator::deallocate(m_array, m_capacity); + m_array = data; + } + } + else + { + m_size = new_size; + } + } + + //------------------------------------------------------------------------ + template pod_vector::pod_vector(unsigned cap, unsigned extra_tail) : + m_size(0), + m_capacity(cap + extra_tail), + m_array(pod_allocator::allocate(m_capacity)) {} + + //------------------------------------------------------------------------ + template pod_vector::pod_vector(const pod_vector& v) : + m_size(v.m_size), + m_capacity(v.m_capacity), + m_array(v.m_capacity ? pod_allocator::allocate(v.m_capacity) : 0) + { + memcpy(m_array, v.m_array, sizeof(T) * v.m_size); + } + + //------------------------------------------------------------------------ + template const pod_vector& + pod_vector::operator = (const pod_vector&v) + { + allocate(v.m_size); + if(v.m_size) memcpy(m_array, v.m_array, sizeof(T) * v.m_size); + return *this; + } + + //------------------------------------------------------------------------ + template void pod_vector::serialize(int8u* ptr) const + { + if(m_size) memcpy(ptr, m_array, m_size * sizeof(T)); + } + + //------------------------------------------------------------------------ + template + void pod_vector::deserialize(const int8u* data, unsigned byte_size) + { + byte_size /= sizeof(T); + allocate(byte_size); + if(byte_size) memcpy(m_array, data, byte_size * sizeof(T)); + } + + //------------------------------------------------------------------------ + template + void pod_vector::insert_at(unsigned pos, const T& val) + { + if(pos >= m_size) + { + m_array[m_size] = val; + } + else + { + memmove(m_array + pos + 1, m_array + pos, (m_size - pos) * sizeof(T)); + m_array[pos] = val; + } + ++m_size; + } + + //---------------------------------------------------------------pod_bvector + // A simple class template to store Plain Old Data, similar to std::deque + // It doesn't reallocate memory but instead, uses blocks of data of size + // of (1 << S), that is, power of two. The data is NOT contiguous in memory, + // so the only valid access method is operator [] or curr(), prev(), next() + // + // There reallocs occure only when the pool of pointers to blocks needs + // to be extended (it happens very rarely). You can control the value + // of increment to reallocate the pointer buffer. See the second constructor. + // By default, the incremeent value equals (1 << S), i.e., the block size. + //------------------------------------------------------------------------ + template class pod_bvector + { + public: + enum block_scale_e + { + block_shift = S, + block_size = 1 << block_shift, + block_mask = block_size - 1 + }; + + typedef T value_type; + + ~pod_bvector(); + pod_bvector(); + pod_bvector(unsigned block_ptr_inc); + + // Copying + pod_bvector(const pod_bvector& v); + const pod_bvector& operator = (const pod_bvector& v); + + void remove_all() { m_size = 0; } + void clear() { m_size = 0; } + void free_all() { free_tail(0); } + void free_tail(unsigned size); + void add(const T& val); + void push_back(const T& val) { add(val); } + void modify_last(const T& val); + void remove_last(); + + int allocate_continuous_block(unsigned num_elements); + + void add_array(const T* ptr, unsigned num_elem) + { + while(num_elem--) + { + add(*ptr++); + } + } + + template void add_data(DataAccessor& data) + { + while(data.size()) + { + add(*data); + ++data; + } + } + + void cut_at(unsigned size) + { + if(size < m_size) m_size = size; + } + + unsigned size() const { return m_size; } + + const T& operator [] (unsigned i) const + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + T& operator [] (unsigned i) + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + const T& at(unsigned i) const + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + T& at(unsigned i) + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + T value_at(unsigned i) const + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + const T& curr(unsigned idx) const + { + return (*this)[idx]; + } + + T& curr(unsigned idx) + { + return (*this)[idx]; + } + + const T& prev(unsigned idx) const + { + return (*this)[(idx + m_size - 1) % m_size]; + } + + T& prev(unsigned idx) + { + return (*this)[(idx + m_size - 1) % m_size]; + } + + const T& next(unsigned idx) const + { + return (*this)[(idx + 1) % m_size]; + } + + T& next(unsigned idx) + { + return (*this)[(idx + 1) % m_size]; + } + + const T& last() const + { + return (*this)[m_size - 1]; + } + + T& last() + { + return (*this)[m_size - 1]; + } + + unsigned byte_size() const; + void serialize(int8u* ptr) const; + void deserialize(const int8u* data, unsigned byte_size); + void deserialize(unsigned start, const T& empty_val, + const int8u* data, unsigned byte_size); + + template + void deserialize(ByteAccessor data) + { + remove_all(); + unsigned elem_size = data.size() / sizeof(T); + + for(unsigned i = 0; i < elem_size; ++i) + { + int8u* ptr = (int8u*)data_ptr(); + for(unsigned j = 0; j < sizeof(T); ++j) + { + *ptr++ = *data; + ++data; + } + ++m_size; + } + } + + template + void deserialize(unsigned start, const T& empty_val, ByteAccessor data) + { + while(m_size < start) + { + add(empty_val); + } + + unsigned elem_size = data.size() / sizeof(T); + for(unsigned i = 0; i < elem_size; ++i) + { + int8u* ptr; + if(start + i < m_size) + { + ptr = (int8u*)(&((*this)[start + i])); + } + else + { + ptr = (int8u*)data_ptr(); + ++m_size; + } + for(unsigned j = 0; j < sizeof(T); ++j) + { + *ptr++ = *data; + ++data; + } + } + } + + const T* block(unsigned nb) const { return m_blocks[nb]; } + + private: + void allocate_block(unsigned nb); + T* data_ptr(); + + unsigned m_size; + unsigned m_num_blocks; + unsigned m_max_blocks; + T** m_blocks; + unsigned m_block_ptr_inc; + }; + + + //------------------------------------------------------------------------ + template pod_bvector::~pod_bvector() + { + if(m_num_blocks) + { + T** blk = m_blocks + m_num_blocks - 1; + while(m_num_blocks--) + { + pod_allocator::deallocate(*blk, block_size); + --blk; + } + } + pod_allocator::deallocate(m_blocks, m_max_blocks); + } + + + //------------------------------------------------------------------------ + template + void pod_bvector::free_tail(unsigned size) + { + if(size < m_size) + { + unsigned nb = (size + block_mask) >> block_shift; + while(m_num_blocks > nb) + { + pod_allocator::deallocate(m_blocks[--m_num_blocks], block_size); + } + if(m_num_blocks == 0) + { + pod_allocator::deallocate(m_blocks, m_max_blocks); + m_blocks = 0; + m_max_blocks = 0; + } + m_size = size; + } + } + + + //------------------------------------------------------------------------ + template pod_bvector::pod_bvector() : + m_size(0), + m_num_blocks(0), + m_max_blocks(0), + m_blocks(0), + m_block_ptr_inc(block_size) + { + } + + + //------------------------------------------------------------------------ + template + pod_bvector::pod_bvector(unsigned block_ptr_inc) : + m_size(0), + m_num_blocks(0), + m_max_blocks(0), + m_blocks(0), + m_block_ptr_inc(block_ptr_inc) + { + } + + + //------------------------------------------------------------------------ + template + pod_bvector::pod_bvector(const pod_bvector& v) : + m_size(v.m_size), + m_num_blocks(v.m_num_blocks), + m_max_blocks(v.m_max_blocks), + m_blocks(v.m_max_blocks ? + pod_allocator::allocate(v.m_max_blocks) : + 0), + m_block_ptr_inc(v.m_block_ptr_inc) + { + unsigned i; + for(i = 0; i < v.m_num_blocks; ++i) + { + m_blocks[i] = pod_allocator::allocate(block_size); + memcpy(m_blocks[i], v.m_blocks[i], block_size * sizeof(T)); + } + } + + + //------------------------------------------------------------------------ + template + const pod_bvector& + pod_bvector::operator = (const pod_bvector& v) + { + unsigned i; + for(i = m_num_blocks; i < v.m_num_blocks; ++i) + { + allocate_block(i); + } + for(i = 0; i < v.m_num_blocks; ++i) + { + memcpy(m_blocks[i], v.m_blocks[i], block_size * sizeof(T)); + } + m_size = v.m_size; + return *this; + } + + + //------------------------------------------------------------------------ + template + void pod_bvector::allocate_block(unsigned nb) + { + if(nb >= m_max_blocks) + { + T** new_blocks = pod_allocator::allocate(m_max_blocks + m_block_ptr_inc); + + if(m_blocks) + { + memcpy(new_blocks, + m_blocks, + m_num_blocks * sizeof(T*)); + + pod_allocator::deallocate(m_blocks, m_max_blocks); + } + m_blocks = new_blocks; + m_max_blocks += m_block_ptr_inc; + } + m_blocks[nb] = pod_allocator::allocate(block_size); + m_num_blocks++; + } + + + + //------------------------------------------------------------------------ + template + inline T* pod_bvector::data_ptr() + { + unsigned nb = m_size >> block_shift; + if(nb >= m_num_blocks) + { + allocate_block(nb); + } + return m_blocks[nb] + (m_size & block_mask); + } + + + + //------------------------------------------------------------------------ + template + inline void pod_bvector::add(const T& val) + { + *data_ptr() = val; + ++m_size; + } + + + //------------------------------------------------------------------------ + template + inline void pod_bvector::remove_last() + { + if(m_size) --m_size; + } + + + //------------------------------------------------------------------------ + template + void pod_bvector::modify_last(const T& val) + { + remove_last(); + add(val); + } + + + //------------------------------------------------------------------------ + template + int pod_bvector::allocate_continuous_block(unsigned num_elements) + { + if(num_elements < block_size) + { + data_ptr(); // Allocate initial block if necessary + unsigned rest = block_size - (m_size & block_mask); + unsigned index; + if(num_elements <= rest) + { + // The rest of the block is good, we can use it + //----------------- + index = m_size; + m_size += num_elements; + return index; + } + + // New block + //--------------- + m_size += rest; + data_ptr(); + index = m_size; + m_size += num_elements; + return index; + } + return -1; // Impossible to allocate + } + + + //------------------------------------------------------------------------ + template + unsigned pod_bvector::byte_size() const + { + return m_size * sizeof(T); + } + + + //------------------------------------------------------------------------ + template + void pod_bvector::serialize(int8u* ptr) const + { + unsigned i; + for(i = 0; i < m_size; i++) + { + memcpy(ptr, &(*this)[i], sizeof(T)); + ptr += sizeof(T); + } + } + + //------------------------------------------------------------------------ + template + void pod_bvector::deserialize(const int8u* data, unsigned byte_size) + { + remove_all(); + byte_size /= sizeof(T); + for(unsigned i = 0; i < byte_size; ++i) + { + T* ptr = data_ptr(); + memcpy(ptr, data, sizeof(T)); + ++m_size; + data += sizeof(T); + } + } + + + // Replace or add a number of elements starting from "start" position + //------------------------------------------------------------------------ + template + void pod_bvector::deserialize(unsigned start, const T& empty_val, + const int8u* data, unsigned byte_size) + { + while(m_size < start) + { + add(empty_val); + } + + byte_size /= sizeof(T); + for(unsigned i = 0; i < byte_size; ++i) + { + if(start + i < m_size) + { + memcpy(&((*this)[start + i]), data, sizeof(T)); + } + else + { + T* ptr = data_ptr(); + memcpy(ptr, data, sizeof(T)); + ++m_size; + } + data += sizeof(T); + } + } + + + //---------------------------------------------------------block_allocator + // Allocator for arbitrary POD data. Most usable in different cache + // systems for efficient memory allocations. + // Memory is allocated with blocks of fixed size ("block_size" in + // the constructor). If required size exceeds the block size the allocator + // creates a new block of the required size. However, the most efficient + // use is when the average reqired size is much less than the block size. + //------------------------------------------------------------------------ + class block_allocator + { + struct block_type + { + int8u* data; + unsigned size; + }; + + public: + void remove_all() + { + if(m_num_blocks) + { + block_type* blk = m_blocks + m_num_blocks - 1; + while(m_num_blocks--) + { + pod_allocator::deallocate(blk->data, blk->size); + --blk; + } + pod_allocator::deallocate(m_blocks, m_max_blocks); + } + m_num_blocks = 0; + m_max_blocks = 0; + m_blocks = 0; + m_buf_ptr = 0; + m_rest = 0; + } + + ~block_allocator() + { + remove_all(); + } + + block_allocator(unsigned block_size, unsigned block_ptr_inc=256-8) : + m_block_size(block_size), + m_block_ptr_inc(block_ptr_inc), + m_num_blocks(0), + m_max_blocks(0), + m_blocks(0), + m_buf_ptr(0), + m_rest(0) + { + } + + + int8u* allocate(unsigned size, unsigned alignment=1) + { + if(size == 0) return 0; + if(size <= m_rest) + { + int8u* ptr = m_buf_ptr; + if(alignment > 1) + { + unsigned align = + (alignment - unsigned((size_t)ptr) % alignment) % alignment; + + size += align; + ptr += align; + if(size <= m_rest) + { + m_rest -= size; + m_buf_ptr += size; + return ptr; + } + allocate_block(size); + return allocate(size - align, alignment); + } + m_rest -= size; + m_buf_ptr += size; + return ptr; + } + allocate_block(size + alignment - 1); + return allocate(size, alignment); + } + + + private: + void allocate_block(unsigned size) + { + if(size < m_block_size) size = m_block_size; + if(m_num_blocks >= m_max_blocks) + { + block_type* new_blocks = + pod_allocator::allocate(m_max_blocks + m_block_ptr_inc); + + if(m_blocks) + { + memcpy(new_blocks, + m_blocks, + m_num_blocks * sizeof(block_type)); + pod_allocator::deallocate(m_blocks, m_max_blocks); + } + m_blocks = new_blocks; + m_max_blocks += m_block_ptr_inc; + } + + m_blocks[m_num_blocks].size = size; + m_blocks[m_num_blocks].data = + m_buf_ptr = + pod_allocator::allocate(size); + + m_num_blocks++; + m_rest = size; + } + + unsigned m_block_size; + unsigned m_block_ptr_inc; + unsigned m_num_blocks; + unsigned m_max_blocks; + block_type* m_blocks; + int8u* m_buf_ptr; + unsigned m_rest; + }; + + + + + + + + + //------------------------------------------------------------------------ + enum quick_sort_threshold_e + { + quick_sort_threshold = 9 + }; + + + //-----------------------------------------------------------swap_elements + template inline void swap_elements(T& a, T& b) + { + T temp = a; + a = b; + b = temp; + } + + + //--------------------------------------------------------------quick_sort + template + void quick_sort(Array& arr, Less less) + { + if(arr.size() < 2) return; + + typename Array::value_type* e1; + typename Array::value_type* e2; + + int stack[80]; + int* top = stack; + int limit = arr.size(); + int base = 0; + + for(;;) + { + int len = limit - base; + + int i; + int j; + int pivot; + + if(len > quick_sort_threshold) + { + // we use base + len/2 as the pivot + pivot = base + len / 2; + swap_elements(arr[base], arr[pivot]); + + i = base + 1; + j = limit - 1; + + // now ensure that *i <= *base <= *j + e1 = &(arr[j]); + e2 = &(arr[i]); + if(less(*e1, *e2)) swap_elements(*e1, *e2); + + e1 = &(arr[base]); + e2 = &(arr[i]); + if(less(*e1, *e2)) swap_elements(*e1, *e2); + + e1 = &(arr[j]); + e2 = &(arr[base]); + if(less(*e1, *e2)) swap_elements(*e1, *e2); + + for(;;) + { + do i++; while( less(arr[i], arr[base]) ); + do j--; while( less(arr[base], arr[j]) ); + + if( i > j ) + { + break; + } + + swap_elements(arr[i], arr[j]); + } + + swap_elements(arr[base], arr[j]); + + // now, push the largest sub-array + if(j - base > limit - i) + { + top[0] = base; + top[1] = j; + base = i; + } + else + { + top[0] = i; + top[1] = limit; + limit = j; + } + top += 2; + } + else + { + // the sub-array is small, perform insertion sort + j = base; + i = j + 1; + + for(; i < limit; j = i, i++) + { + for(; less(*(e1 = &(arr[j + 1])), *(e2 = &(arr[j]))); j--) + { + swap_elements(*e1, *e2); + if(j == base) + { + break; + } + } + } + if(top > stack) + { + top -= 2; + base = top[0]; + limit = top[1]; + } + else + { + break; + } + } + } + } + + + + + //------------------------------------------------------remove_duplicates + // Remove duplicates from a sorted array. It doesn't cut the + // tail of the array, it just returns the number of remaining elements. + //----------------------------------------------------------------------- + template + unsigned remove_duplicates(Array& arr, Equal equal) + { + if(arr.size() < 2) return arr.size(); + + unsigned i, j; + for(i = 1, j = 1; i < arr.size(); i++) + { + typename Array::value_type& e = arr[i]; + if(!equal(e, arr[i - 1])) + { + arr[j++] = e; + } + } + return j; + } + + //--------------------------------------------------------invert_container + template void invert_container(Array& arr) + { + int i = 0; + int j = arr.size() - 1; + while(i < j) + { + swap_elements(arr[i++], arr[j--]); + } + } + + //------------------------------------------------------binary_search_pos + template + unsigned binary_search_pos(const Array& arr, const Value& val, Less less) + { + if(arr.size() == 0) return 0; + + unsigned beg = 0; + unsigned end = arr.size() - 1; + + if(less(val, arr[0])) return 0; + if(less(arr[end], val)) return end + 1; + + while(end - beg > 1) + { + unsigned mid = (end + beg) >> 1; + if(less(val, arr[mid])) end = mid; + else beg = mid; + } + + //if(beg <= 0 && less(val, arr[0])) return 0; + //if(end >= arr.size() - 1 && less(arr[end], val)) ++end; + + return end; + } + + //----------------------------------------------------------range_adaptor + template class range_adaptor + { + public: + typedef typename Array::value_type value_type; + + range_adaptor(Array& array, unsigned start, unsigned size) : + m_array(array), m_start(start), m_size(size) + {} + + unsigned size() const { return m_size; } + const value_type& operator [] (unsigned i) const { return m_array[m_start + i]; } + value_type& operator [] (unsigned i) { return m_array[m_start + i]; } + const value_type& at(unsigned i) const { return m_array[m_start + i]; } + value_type& at(unsigned i) { return m_array[m_start + i]; } + value_type value_at(unsigned i) const { return m_array[m_start + i]; } + + private: + Array& m_array; + unsigned m_start; + unsigned m_size; + }; + + //---------------------------------------------------------------int_less + inline bool int_less(int a, int b) { return a < b; } + + //------------------------------------------------------------int_greater + inline bool int_greater(int a, int b) { return a > b; } + + //----------------------------------------------------------unsigned_less + inline bool unsigned_less(unsigned a, unsigned b) { return a < b; } + + //-------------------------------------------------------unsigned_greater + inline bool unsigned_greater(unsigned a, unsigned b) { return a > b; } +} + +#endif diff --git a/xs/src/agg/agg_arrowhead.h b/xs/src/agg/agg_arrowhead.h new file mode 100644 index 0000000000..5e029ddee0 --- /dev/null +++ b/xs/src/agg/agg_arrowhead.h @@ -0,0 +1,82 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Simple arrowhead/arrowtail generator +// +//---------------------------------------------------------------------------- +#ifndef AGG_ARROWHEAD_INCLUDED +#define AGG_ARROWHEAD_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //===============================================================arrowhead + // + // See implementation agg_arrowhead.cpp + // + class arrowhead + { + public: + arrowhead(); + + void head(double d1, double d2, double d3, double d4) + { + m_head_d1 = d1; + m_head_d2 = d2; + m_head_d3 = d3; + m_head_d4 = d4; + m_head_flag = true; + } + + void head() { m_head_flag = true; } + void no_head() { m_head_flag = false; } + + void tail(double d1, double d2, double d3, double d4) + { + m_tail_d1 = d1; + m_tail_d2 = d2; + m_tail_d3 = d3; + m_tail_d4 = d4; + m_tail_flag = true; + } + + void tail() { m_tail_flag = true; } + void no_tail() { m_tail_flag = false; } + + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + double m_head_d1; + double m_head_d2; + double m_head_d3; + double m_head_d4; + double m_tail_d1; + double m_tail_d2; + double m_tail_d3; + double m_tail_d4; + bool m_head_flag; + bool m_tail_flag; + double m_coord[16]; + unsigned m_cmd[8]; + unsigned m_curr_id; + unsigned m_curr_coord; + }; + +} + +#endif diff --git a/xs/src/agg/agg_basics.h b/xs/src/agg/agg_basics.h new file mode 100644 index 0000000000..273850ba1b --- /dev/null +++ b/xs/src/agg/agg_basics.h @@ -0,0 +1,574 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_BASICS_INCLUDED +#define AGG_BASICS_INCLUDED + +#include +#include "agg_config.h" + +//---------------------------------------------------------AGG_CUSTOM_ALLOCATOR +#ifdef AGG_CUSTOM_ALLOCATOR +#include "agg_allocator.h" +#else +namespace agg +{ + // The policy of all AGG containers and memory allocation strategy + // in general is that no allocated data requires explicit construction. + // It means that the allocator can be really simple; you can even + // replace new/delete to malloc/free. The constructors and destructors + // won't be called in this case, however everything will remain working. + // The second argument of deallocate() is the size of the allocated + // block. You can use this information if you wish. + //------------------------------------------------------------pod_allocator + template struct pod_allocator + { + static T* allocate(unsigned num) { return new T [num]; } + static void deallocate(T* ptr, unsigned) { delete [] ptr; } + }; + + // Single object allocator. It's also can be replaced with your custom + // allocator. The difference is that it can only allocate a single + // object and the constructor and destructor must be called. + // In AGG there is no need to allocate an array of objects with + // calling their constructors (only single ones). So that, if you + // replace these new/delete to malloc/free make sure that the in-place + // new is called and take care of calling the destructor too. + //------------------------------------------------------------obj_allocator + template struct obj_allocator + { + static T* allocate() { return new T; } + static void deallocate(T* ptr) { delete ptr; } + }; +} +#endif + + +//-------------------------------------------------------- Default basic types +// +// If the compiler has different capacity of the basic types you can redefine +// them via the compiler command line or by generating agg_config.h that is +// empty by default. +// +#ifndef AGG_INT8 +#define AGG_INT8 signed char +#endif + +#ifndef AGG_INT8U +#define AGG_INT8U unsigned char +#endif + +#ifndef AGG_INT16 +#define AGG_INT16 short +#endif + +#ifndef AGG_INT16U +#define AGG_INT16U unsigned short +#endif + +#ifndef AGG_INT32 +#define AGG_INT32 int +#endif + +#ifndef AGG_INT32U +#define AGG_INT32U unsigned +#endif + +#ifndef AGG_INT64 +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define AGG_INT64 signed __int64 +#else +#define AGG_INT64 signed long long +#endif +#endif + +#ifndef AGG_INT64U +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define AGG_INT64U unsigned __int64 +#else +#define AGG_INT64U unsigned long long +#endif +#endif + +//------------------------------------------------ Some fixes for MS Visual C++ +#if defined(_MSC_VER) +#pragma warning(disable:4786) // Identifier was truncated... +#endif + +#if defined(_MSC_VER) +#define AGG_INLINE __forceinline +#else +#define AGG_INLINE inline +#endif + +namespace agg +{ + //------------------------------------------------------------------------- + typedef AGG_INT8 int8; //----int8 + typedef AGG_INT8U int8u; //----int8u + typedef AGG_INT16 int16; //----int16 + typedef AGG_INT16U int16u; //----int16u + typedef AGG_INT32 int32; //----int32 + typedef AGG_INT32U int32u; //----int32u + typedef AGG_INT64 int64; //----int64 + typedef AGG_INT64U int64u; //----int64u + +#if defined(AGG_FISTP) +#pragma warning(push) +#pragma warning(disable : 4035) //Disable warning "no return value" + AGG_INLINE int iround(double v) //-------iround + { + int t; + __asm fld qword ptr [v] + __asm fistp dword ptr [t] + __asm mov eax, dword ptr [t] + } + AGG_INLINE unsigned uround(double v) //-------uround + { + unsigned t; + __asm fld qword ptr [v] + __asm fistp dword ptr [t] + __asm mov eax, dword ptr [t] + } +#pragma warning(pop) + AGG_INLINE int ifloor(double v) + { + return int(floor(v)); + } + AGG_INLINE unsigned ufloor(double v) //-------ufloor + { + return unsigned(floor(v)); + } + AGG_INLINE int iceil(double v) + { + return int(ceil(v)); + } + AGG_INLINE unsigned uceil(double v) //--------uceil + { + return unsigned(ceil(v)); + } +#elif defined(AGG_QIFIST) + AGG_INLINE int iround(double v) + { + return int(v); + } + AGG_INLINE int uround(double v) + { + return unsigned(v); + } + AGG_INLINE int ifloor(double v) + { + return int(floor(v)); + } + AGG_INLINE unsigned ufloor(double v) + { + return unsigned(floor(v)); + } + AGG_INLINE int iceil(double v) + { + return int(ceil(v)); + } + AGG_INLINE unsigned uceil(double v) + { + return unsigned(ceil(v)); + } +#else + AGG_INLINE int iround(double v) + { + return int((v < 0.0) ? v - 0.5 : v + 0.5); + } + AGG_INLINE int uround(double v) + { + return unsigned(v + 0.5); + } + AGG_INLINE int ifloor(double v) + { + int i = int(v); + return i - (i > v); + } + AGG_INLINE unsigned ufloor(double v) + { + return unsigned(v); + } + AGG_INLINE int iceil(double v) + { + return int(ceil(v)); + } + AGG_INLINE unsigned uceil(double v) + { + return unsigned(ceil(v)); + } +#endif + + //---------------------------------------------------------------saturation + template struct saturation + { + AGG_INLINE static int iround(double v) + { + if(v < double(-Limit)) return -Limit; + if(v > double( Limit)) return Limit; + return agg::iround(v); + } + }; + + //------------------------------------------------------------------mul_one + template struct mul_one + { + AGG_INLINE static unsigned mul(unsigned a, unsigned b) + { + unsigned q = a * b + (1 << (Shift-1)); + return (q + (q >> Shift)) >> Shift; + } + }; + + //------------------------------------------------------------------------- + typedef unsigned char cover_type; //----cover_type + enum cover_scale_e + { + cover_shift = 8, //----cover_shift + cover_size = 1 << cover_shift, //----cover_size + cover_mask = cover_size - 1, //----cover_mask + cover_none = 0, //----cover_none + cover_full = cover_mask //----cover_full + }; + + //----------------------------------------------------poly_subpixel_scale_e + // These constants determine the subpixel accuracy, to be more precise, + // the number of bits of the fractional part of the coordinates. + // The possible coordinate capacity in bits can be calculated by formula: + // sizeof(int) * 8 - poly_subpixel_shift, i.e, for 32-bit integers and + // 8-bits fractional part the capacity is 24 bits. + enum poly_subpixel_scale_e + { + poly_subpixel_shift = 8, //----poly_subpixel_shift + poly_subpixel_scale = 1< struct rect_base + { + typedef T value_type; + typedef rect_base self_type; + T x1, y1, x2, y2; + + rect_base() {} + rect_base(T x1_, T y1_, T x2_, T y2_) : + x1(x1_), y1(y1_), x2(x2_), y2(y2_) {} + + void init(T x1_, T y1_, T x2_, T y2_) + { + x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_; + } + + const self_type& normalize() + { + T t; + if(x1 > x2) { t = x1; x1 = x2; x2 = t; } + if(y1 > y2) { t = y1; y1 = y2; y2 = t; } + return *this; + } + + bool clip(const self_type& r) + { + if(x2 > r.x2) x2 = r.x2; + if(y2 > r.y2) y2 = r.y2; + if(x1 < r.x1) x1 = r.x1; + if(y1 < r.y1) y1 = r.y1; + return x1 <= x2 && y1 <= y2; + } + + bool is_valid() const + { + return x1 <= x2 && y1 <= y2; + } + + bool hit_test(T x, T y) const + { + return (x >= x1 && x <= x2 && y >= y1 && y <= y2); + } + + bool overlaps(const self_type& r) const + { + return !(r.x1 > x2 || r.x2 < x1 + || r.y1 > y2 || r.y2 < y1); + } + }; + + //-----------------------------------------------------intersect_rectangles + template + inline Rect intersect_rectangles(const Rect& r1, const Rect& r2) + { + Rect r = r1; + + // First process x2,y2 because the other order + // results in Internal Compiler Error under + // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in + // case of "Maximize Speed" optimization option. + //----------------- + if(r.x2 > r2.x2) r.x2 = r2.x2; + if(r.y2 > r2.y2) r.y2 = r2.y2; + if(r.x1 < r2.x1) r.x1 = r2.x1; + if(r.y1 < r2.y1) r.y1 = r2.y1; + return r; + } + + + //---------------------------------------------------------unite_rectangles + template + inline Rect unite_rectangles(const Rect& r1, const Rect& r2) + { + Rect r = r1; + if(r.x2 < r2.x2) r.x2 = r2.x2; + if(r.y2 < r2.y2) r.y2 = r2.y2; + if(r.x1 > r2.x1) r.x1 = r2.x1; + if(r.y1 > r2.y1) r.y1 = r2.y1; + return r; + } + + typedef rect_base rect_i; //----rect_i + typedef rect_base rect_f; //----rect_f + typedef rect_base rect_d; //----rect_d + + //---------------------------------------------------------path_commands_e + enum path_commands_e + { + path_cmd_stop = 0, //----path_cmd_stop + path_cmd_move_to = 1, //----path_cmd_move_to + path_cmd_line_to = 2, //----path_cmd_line_to + path_cmd_curve3 = 3, //----path_cmd_curve3 + path_cmd_curve4 = 4, //----path_cmd_curve4 + path_cmd_curveN = 5, //----path_cmd_curveN + path_cmd_catrom = 6, //----path_cmd_catrom + path_cmd_ubspline = 7, //----path_cmd_ubspline + path_cmd_end_poly = 0x0F, //----path_cmd_end_poly + path_cmd_mask = 0x0F //----path_cmd_mask + }; + + //------------------------------------------------------------path_flags_e + enum path_flags_e + { + path_flags_none = 0, //----path_flags_none + path_flags_ccw = 0x10, //----path_flags_ccw + path_flags_cw = 0x20, //----path_flags_cw + path_flags_close = 0x40, //----path_flags_close + path_flags_mask = 0xF0 //----path_flags_mask + }; + + //---------------------------------------------------------------is_vertex + inline bool is_vertex(unsigned c) + { + return c >= path_cmd_move_to && c < path_cmd_end_poly; + } + + //--------------------------------------------------------------is_drawing + inline bool is_drawing(unsigned c) + { + return c >= path_cmd_line_to && c < path_cmd_end_poly; + } + + //-----------------------------------------------------------------is_stop + inline bool is_stop(unsigned c) + { + return c == path_cmd_stop; + } + + //--------------------------------------------------------------is_move_to + inline bool is_move_to(unsigned c) + { + return c == path_cmd_move_to; + } + + //--------------------------------------------------------------is_line_to + inline bool is_line_to(unsigned c) + { + return c == path_cmd_line_to; + } + + //----------------------------------------------------------------is_curve + inline bool is_curve(unsigned c) + { + return c == path_cmd_curve3 || c == path_cmd_curve4; + } + + //---------------------------------------------------------------is_curve3 + inline bool is_curve3(unsigned c) + { + return c == path_cmd_curve3; + } + + //---------------------------------------------------------------is_curve4 + inline bool is_curve4(unsigned c) + { + return c == path_cmd_curve4; + } + + //-------------------------------------------------------------is_end_poly + inline bool is_end_poly(unsigned c) + { + return (c & path_cmd_mask) == path_cmd_end_poly; + } + + //----------------------------------------------------------------is_close + inline bool is_close(unsigned c) + { + return (c & ~(path_flags_cw | path_flags_ccw)) == + (path_cmd_end_poly | path_flags_close); + } + + //------------------------------------------------------------is_next_poly + inline bool is_next_poly(unsigned c) + { + return is_stop(c) || is_move_to(c) || is_end_poly(c); + } + + //-------------------------------------------------------------------is_cw + inline bool is_cw(unsigned c) + { + return (c & path_flags_cw) != 0; + } + + //------------------------------------------------------------------is_ccw + inline bool is_ccw(unsigned c) + { + return (c & path_flags_ccw) != 0; + } + + //-------------------------------------------------------------is_oriented + inline bool is_oriented(unsigned c) + { + return (c & (path_flags_cw | path_flags_ccw)) != 0; + } + + //---------------------------------------------------------------is_closed + inline bool is_closed(unsigned c) + { + return (c & path_flags_close) != 0; + } + + //----------------------------------------------------------get_close_flag + inline unsigned get_close_flag(unsigned c) + { + return c & path_flags_close; + } + + //-------------------------------------------------------clear_orientation + inline unsigned clear_orientation(unsigned c) + { + return c & ~(path_flags_cw | path_flags_ccw); + } + + //---------------------------------------------------------get_orientation + inline unsigned get_orientation(unsigned c) + { + return c & (path_flags_cw | path_flags_ccw); + } + + //---------------------------------------------------------set_orientation + inline unsigned set_orientation(unsigned c, unsigned o) + { + return clear_orientation(c) | o; + } + + //--------------------------------------------------------------point_base + template struct point_base + { + typedef T value_type; + T x,y; + point_base() {} + point_base(T x_, T y_) : x(x_), y(y_) {} + }; + typedef point_base point_i; //-----point_i + typedef point_base point_f; //-----point_f + typedef point_base point_d; //-----point_d + + //-------------------------------------------------------------vertex_base + template struct vertex_base + { + typedef T value_type; + T x,y; + unsigned cmd; + vertex_base() {} + vertex_base(T x_, T y_, unsigned cmd_) : x(x_), y(y_), cmd(cmd_) {} + }; + typedef vertex_base vertex_i; //-----vertex_i + typedef vertex_base vertex_f; //-----vertex_f + typedef vertex_base vertex_d; //-----vertex_d + + //----------------------------------------------------------------row_info + template struct row_info + { + int x1, x2; + T* ptr; + row_info() {} + row_info(int x1_, int x2_, T* ptr_) : x1(x1_), x2(x2_), ptr(ptr_) {} + }; + + //----------------------------------------------------------const_row_info + template struct const_row_info + { + int x1, x2; + const T* ptr; + const_row_info() {} + const_row_info(int x1_, int x2_, const T* ptr_) : + x1(x1_), x2(x2_), ptr(ptr_) {} + }; + + //------------------------------------------------------------is_equal_eps + template inline bool is_equal_eps(T v1, T v2, T epsilon) + { + bool neg1 = v1 < 0.0; + bool neg2 = v2 < 0.0; + + if (neg1 != neg2) + return std::fabs(v1) < epsilon && std::fabs(v2) < epsilon; + + int int1, int2; + std::frexp(v1, &int1); + std::frexp(v2, &int2); + int min12 = int1 < int2 ? int1 : int2; + + v1 = std::ldexp(v1, -min12); + v2 = std::ldexp(v2, -min12); + + return std::fabs(v1 - v2) < epsilon; + } +} + + +#endif + diff --git a/xs/src/agg/agg_bezier_arc.h b/xs/src/agg/agg_bezier_arc.h new file mode 100644 index 0000000000..cfd9308ea5 --- /dev/null +++ b/xs/src/agg/agg_bezier_arc.h @@ -0,0 +1,159 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e., +// 4, 7, 10, or 13 vertices. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_BEZIER_ARC_INCLUDED +#define AGG_BEZIER_ARC_INCLUDED + +#include "agg_conv_transform.h" + +namespace agg +{ + + //----------------------------------------------------------------------- + void arc_to_bezier(double cx, double cy, double rx, double ry, + double start_angle, double sweep_angle, + double* curve); + + + //==============================================================bezier_arc + // + // See implemantaion agg_bezier_arc.cpp + // + class bezier_arc + { + public: + //-------------------------------------------------------------------- + bezier_arc() : m_vertex(26), m_num_vertices(0), m_cmd(path_cmd_line_to) {} + bezier_arc(double x, double y, + double rx, double ry, + double start_angle, + double sweep_angle) + { + init(x, y, rx, ry, start_angle, sweep_angle); + } + + //-------------------------------------------------------------------- + void init(double x, double y, + double rx, double ry, + double start_angle, + double sweep_angle); + + //-------------------------------------------------------------------- + void rewind(unsigned) + { + m_vertex = 0; + } + + //-------------------------------------------------------------------- + unsigned vertex(double* x, double* y) + { + if(m_vertex >= m_num_vertices) return path_cmd_stop; + *x = m_vertices[m_vertex]; + *y = m_vertices[m_vertex + 1]; + m_vertex += 2; + return (m_vertex == 2) ? unsigned(path_cmd_move_to) : m_cmd; + } + + // Supplemantary functions. num_vertices() actually returns doubled + // number of vertices. That is, for 1 vertex it returns 2. + //-------------------------------------------------------------------- + unsigned num_vertices() const { return m_num_vertices; } + const double* vertices() const { return m_vertices; } + double* vertices() { return m_vertices; } + + private: + unsigned m_vertex; + unsigned m_num_vertices; + double m_vertices[26]; + unsigned m_cmd; + }; + + + + //==========================================================bezier_arc_svg + // Compute an SVG-style bezier arc. + // + // Computes an elliptical arc from (x1, y1) to (x2, y2). The size and + // orientation of the ellipse are defined by two radii (rx, ry) + // and an x-axis-rotation, which indicates how the ellipse as a whole + // is rotated relative to the current coordinate system. The center + // (cx, cy) of the ellipse is calculated automatically to satisfy the + // constraints imposed by the other parameters. + // large-arc-flag and sweep-flag contribute to the automatic calculations + // and help determine how the arc is drawn. + class bezier_arc_svg + { + public: + //-------------------------------------------------------------------- + bezier_arc_svg() : m_arc(), m_radii_ok(false) {} + + bezier_arc_svg(double x1, double y1, + double rx, double ry, + double angle, + bool large_arc_flag, + bool sweep_flag, + double x2, double y2) : + m_arc(), m_radii_ok(false) + { + init(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2); + } + + //-------------------------------------------------------------------- + void init(double x1, double y1, + double rx, double ry, + double angle, + bool large_arc_flag, + bool sweep_flag, + double x2, double y2); + + //-------------------------------------------------------------------- + bool radii_ok() const { return m_radii_ok; } + + //-------------------------------------------------------------------- + void rewind(unsigned) + { + m_arc.rewind(0); + } + + //-------------------------------------------------------------------- + unsigned vertex(double* x, double* y) + { + return m_arc.vertex(x, y); + } + + // Supplemantary functions. num_vertices() actually returns doubled + // number of vertices. That is, for 1 vertex it returns 2. + //-------------------------------------------------------------------- + unsigned num_vertices() const { return m_arc.num_vertices(); } + const double* vertices() const { return m_arc.vertices(); } + double* vertices() { return m_arc.vertices(); } + + private: + bezier_arc m_arc; + bool m_radii_ok; + }; + + + + +} + + +#endif diff --git a/xs/src/agg/agg_bitset_iterator.h b/xs/src/agg/agg_bitset_iterator.h new file mode 100644 index 0000000000..7382d5c335 --- /dev/null +++ b/xs/src/agg/agg_bitset_iterator.h @@ -0,0 +1,54 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_BITSET_ITERATOR_INCLUDED +#define AGG_BITSET_ITERATOR_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + class bitset_iterator + { + public: + bitset_iterator(const int8u* bits, unsigned offset = 0) : + m_bits(bits + (offset >> 3)), + m_mask(0x80 >> (offset & 7)) + {} + + void operator ++ () + { + m_mask >>= 1; + if(m_mask == 0) + { + ++m_bits; + m_mask = 0x80; + } + } + + unsigned bit() const + { + return (*m_bits) & m_mask; + } + + private: + const int8u* m_bits; + int8u m_mask; + }; + +} + +#endif diff --git a/xs/src/agg/agg_blur.h b/xs/src/agg/agg_blur.h new file mode 100644 index 0000000000..cd5713f314 --- /dev/null +++ b/xs/src/agg/agg_blur.h @@ -0,0 +1,1503 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// The Stack Blur Algorithm was invented by Mario Klingemann, +// mario@quasimondo.com and described here: +// http://incubator.quasimondo.com/processing/fast_blur_deluxe.php +// (search phrase "Stackblur: Fast But Goodlooking"). +// The major improvement is that there's no more division table +// that was very expensive to create for large blur radii. Insted, +// for 8-bit per channel and radius not exceeding 254 the division is +// replaced by multiplication and shift. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_BLUR_INCLUDED +#define AGG_BLUR_INCLUDED + +#include "agg_array.h" +#include "agg_pixfmt_base.h" +#include "agg_pixfmt_transposer.h" + +namespace agg +{ + + template struct stack_blur_tables + { + static int16u const g_stack_blur8_mul[255]; + static int8u const g_stack_blur8_shr[255]; + }; + + //------------------------------------------------------------------------ + template + int16u const stack_blur_tables::g_stack_blur8_mul[255] = + { + 512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512, + 454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512, + 482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456, + 437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512, + 497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328, + 320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456, + 446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335, + 329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512, + 505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405, + 399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328, + 324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271, + 268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456, + 451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388, + 385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335, + 332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292, + 289,287,285,282,280,278,275,273,271,269,267,265,263,261,259 + }; + + //------------------------------------------------------------------------ + template + int8u const stack_blur_tables::g_stack_blur8_shr[255] = + { + 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, + 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 + }; + + + + //==============================================================stack_blur + template class stack_blur + { + public: + typedef ColorT color_type; + typedef CalculatorT calculator_type; + + //-------------------------------------------------------------------- + template void blur_x(Img& img, unsigned radius) + { + if(radius < 1) return; + + unsigned x, y, xp, i; + unsigned stack_ptr; + unsigned stack_start; + + color_type pix; + color_type* stack_pix; + calculator_type sum; + calculator_type sum_in; + calculator_type sum_out; + + unsigned w = img.width(); + unsigned h = img.height(); + unsigned wm = w - 1; + unsigned div = radius * 2 + 1; + + unsigned div_sum = (radius + 1) * (radius + 1); + unsigned mul_sum = 0; + unsigned shr_sum = 0; + unsigned max_val = color_type::base_mask; + + if(max_val <= 255 && radius < 255) + { + mul_sum = stack_blur_tables::g_stack_blur8_mul[radius]; + shr_sum = stack_blur_tables::g_stack_blur8_shr[radius]; + } + + m_buf.allocate(w, 128); + m_stack.allocate(div, 32); + + for(y = 0; y < h; y++) + { + sum.clear(); + sum_in.clear(); + sum_out.clear(); + + pix = img.pixel(0, y); + for(i = 0; i <= radius; i++) + { + m_stack[i] = pix; + sum.add(pix, i + 1); + sum_out.add(pix); + } + for(i = 1; i <= radius; i++) + { + pix = img.pixel((i > wm) ? wm : i, y); + m_stack[i + radius] = pix; + sum.add(pix, radius + 1 - i); + sum_in.add(pix); + } + + stack_ptr = radius; + for(x = 0; x < w; x++) + { + if(mul_sum) sum.calc_pix(m_buf[x], mul_sum, shr_sum); + else sum.calc_pix(m_buf[x], div_sum); + + sum.sub(sum_out); + + stack_start = stack_ptr + div - radius; + if(stack_start >= div) stack_start -= div; + stack_pix = &m_stack[stack_start]; + + sum_out.sub(*stack_pix); + + xp = x + radius + 1; + if(xp > wm) xp = wm; + pix = img.pixel(xp, y); + + *stack_pix = pix; + + sum_in.add(pix); + sum.add(sum_in); + + ++stack_ptr; + if(stack_ptr >= div) stack_ptr = 0; + stack_pix = &m_stack[stack_ptr]; + + sum_out.add(*stack_pix); + sum_in.sub(*stack_pix); + } + img.copy_color_hspan(0, y, w, &m_buf[0]); + } + } + + //-------------------------------------------------------------------- + template void blur_y(Img& img, unsigned radius) + { + pixfmt_transposer img2(img); + blur_x(img2, radius); + } + + //-------------------------------------------------------------------- + template void blur(Img& img, unsigned radius) + { + blur_x(img, radius); + pixfmt_transposer img2(img); + blur_x(img2, radius); + } + + private: + pod_vector m_buf; + pod_vector m_stack; + }; + + //====================================================stack_blur_calc_rgba + template struct stack_blur_calc_rgba + { + typedef T value_type; + value_type r,g,b,a; + + AGG_INLINE void clear() + { + r = g = b = a = 0; + } + + template AGG_INLINE void add(const ArgT& v) + { + r += v.r; + g += v.g; + b += v.b; + a += v.a; + } + + template AGG_INLINE void add(const ArgT& v, unsigned k) + { + r += v.r * k; + g += v.g * k; + b += v.b * k; + a += v.a * k; + } + + template AGG_INLINE void sub(const ArgT& v) + { + r -= v.r; + g -= v.g; + b -= v.b; + a -= v.a; + } + + template AGG_INLINE void calc_pix(ArgT& v, unsigned div) + { + typedef typename ArgT::value_type value_type; + v.r = value_type(r / div); + v.g = value_type(g / div); + v.b = value_type(b / div); + v.a = value_type(a / div); + } + + template + AGG_INLINE void calc_pix(ArgT& v, unsigned mul, unsigned shr) + { + typedef typename ArgT::value_type value_type; + v.r = value_type((r * mul) >> shr); + v.g = value_type((g * mul) >> shr); + v.b = value_type((b * mul) >> shr); + v.a = value_type((a * mul) >> shr); + } + }; + + + //=====================================================stack_blur_calc_rgb + template struct stack_blur_calc_rgb + { + typedef T value_type; + value_type r,g,b; + + AGG_INLINE void clear() + { + r = g = b = 0; + } + + template AGG_INLINE void add(const ArgT& v) + { + r += v.r; + g += v.g; + b += v.b; + } + + template AGG_INLINE void add(const ArgT& v, unsigned k) + { + r += v.r * k; + g += v.g * k; + b += v.b * k; + } + + template AGG_INLINE void sub(const ArgT& v) + { + r -= v.r; + g -= v.g; + b -= v.b; + } + + template AGG_INLINE void calc_pix(ArgT& v, unsigned div) + { + typedef typename ArgT::value_type value_type; + v.r = value_type(r / div); + v.g = value_type(g / div); + v.b = value_type(b / div); + } + + template + AGG_INLINE void calc_pix(ArgT& v, unsigned mul, unsigned shr) + { + typedef typename ArgT::value_type value_type; + v.r = value_type((r * mul) >> shr); + v.g = value_type((g * mul) >> shr); + v.b = value_type((b * mul) >> shr); + } + }; + + + //====================================================stack_blur_calc_gray + template struct stack_blur_calc_gray + { + typedef T value_type; + value_type v; + + AGG_INLINE void clear() + { + v = 0; + } + + template AGG_INLINE void add(const ArgT& a) + { + v += a.v; + } + + template AGG_INLINE void add(const ArgT& a, unsigned k) + { + v += a.v * k; + } + + template AGG_INLINE void sub(const ArgT& a) + { + v -= a.v; + } + + template AGG_INLINE void calc_pix(ArgT& a, unsigned div) + { + typedef typename ArgT::value_type value_type; + a.v = value_type(v / div); + } + + template + AGG_INLINE void calc_pix(ArgT& a, unsigned mul, unsigned shr) + { + typedef typename ArgT::value_type value_type; + a.v = value_type((v * mul) >> shr); + } + }; + + + + //========================================================stack_blur_gray8 + template + void stack_blur_gray8(Img& img, unsigned rx, unsigned ry) + { + unsigned x, y, xp, yp, i; + unsigned stack_ptr; + unsigned stack_start; + + const int8u* src_pix_ptr; + int8u* dst_pix_ptr; + unsigned pix; + unsigned stack_pix; + unsigned sum; + unsigned sum_in; + unsigned sum_out; + + unsigned w = img.width(); + unsigned h = img.height(); + unsigned wm = w - 1; + unsigned hm = h - 1; + + unsigned div; + unsigned mul_sum; + unsigned shr_sum; + + pod_vector stack; + + if(rx > 0) + { + if(rx > 254) rx = 254; + div = rx * 2 + 1; + mul_sum = stack_blur_tables::g_stack_blur8_mul[rx]; + shr_sum = stack_blur_tables::g_stack_blur8_shr[rx]; + stack.allocate(div); + + for(y = 0; y < h; y++) + { + sum = sum_in = sum_out = 0; + + src_pix_ptr = img.pix_ptr(0, y); + pix = *src_pix_ptr; + for(i = 0; i <= rx; i++) + { + stack[i] = pix; + sum += pix * (i + 1); + sum_out += pix; + } + for(i = 1; i <= rx; i++) + { + if(i <= wm) src_pix_ptr += Img::pix_width; + pix = *src_pix_ptr; + stack[i + rx] = pix; + sum += pix * (rx + 1 - i); + sum_in += pix; + } + + stack_ptr = rx; + xp = rx; + if(xp > wm) xp = wm; + src_pix_ptr = img.pix_ptr(xp, y); + dst_pix_ptr = img.pix_ptr(0, y); + for(x = 0; x < w; x++) + { + *dst_pix_ptr = (sum * mul_sum) >> shr_sum; + dst_pix_ptr += Img::pix_width; + + sum -= sum_out; + + stack_start = stack_ptr + div - rx; + if(stack_start >= div) stack_start -= div; + sum_out -= stack[stack_start]; + + if(xp < wm) + { + src_pix_ptr += Img::pix_width; + pix = *src_pix_ptr; + ++xp; + } + + stack[stack_start] = pix; + + sum_in += pix; + sum += sum_in; + + ++stack_ptr; + if(stack_ptr >= div) stack_ptr = 0; + stack_pix = stack[stack_ptr]; + + sum_out += stack_pix; + sum_in -= stack_pix; + } + } + } + + if(ry > 0) + { + if(ry > 254) ry = 254; + div = ry * 2 + 1; + mul_sum = stack_blur_tables::g_stack_blur8_mul[ry]; + shr_sum = stack_blur_tables::g_stack_blur8_shr[ry]; + stack.allocate(div); + + int stride = img.stride(); + for(x = 0; x < w; x++) + { + sum = sum_in = sum_out = 0; + + src_pix_ptr = img.pix_ptr(x, 0); + pix = *src_pix_ptr; + for(i = 0; i <= ry; i++) + { + stack[i] = pix; + sum += pix * (i + 1); + sum_out += pix; + } + for(i = 1; i <= ry; i++) + { + if(i <= hm) src_pix_ptr += stride; + pix = *src_pix_ptr; + stack[i + ry] = pix; + sum += pix * (ry + 1 - i); + sum_in += pix; + } + + stack_ptr = ry; + yp = ry; + if(yp > hm) yp = hm; + src_pix_ptr = img.pix_ptr(x, yp); + dst_pix_ptr = img.pix_ptr(x, 0); + for(y = 0; y < h; y++) + { + *dst_pix_ptr = (sum * mul_sum) >> shr_sum; + dst_pix_ptr += stride; + + sum -= sum_out; + + stack_start = stack_ptr + div - ry; + if(stack_start >= div) stack_start -= div; + sum_out -= stack[stack_start]; + + if(yp < hm) + { + src_pix_ptr += stride; + pix = *src_pix_ptr; + ++yp; + } + + stack[stack_start] = pix; + + sum_in += pix; + sum += sum_in; + + ++stack_ptr; + if(stack_ptr >= div) stack_ptr = 0; + stack_pix = stack[stack_ptr]; + + sum_out += stack_pix; + sum_in -= stack_pix; + } + } + } + } + + + + //========================================================stack_blur_rgb24 + template + void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry) + { + typedef typename Img::color_type color_type; + typedef typename Img::order_type order_type; + enum order_e + { + R = order_type::R, + G = order_type::G, + B = order_type::B + }; + + unsigned x, y, xp, yp, i; + unsigned stack_ptr; + unsigned stack_start; + + const int8u* src_pix_ptr; + int8u* dst_pix_ptr; + color_type* stack_pix_ptr; + + unsigned sum_r; + unsigned sum_g; + unsigned sum_b; + unsigned sum_in_r; + unsigned sum_in_g; + unsigned sum_in_b; + unsigned sum_out_r; + unsigned sum_out_g; + unsigned sum_out_b; + + unsigned w = img.width(); + unsigned h = img.height(); + unsigned wm = w - 1; + unsigned hm = h - 1; + + unsigned div; + unsigned mul_sum; + unsigned shr_sum; + + pod_vector stack; + + if(rx > 0) + { + if(rx > 254) rx = 254; + div = rx * 2 + 1; + mul_sum = stack_blur_tables::g_stack_blur8_mul[rx]; + shr_sum = stack_blur_tables::g_stack_blur8_shr[rx]; + stack.allocate(div); + + for(y = 0; y < h; y++) + { + sum_r = + sum_g = + sum_b = + sum_in_r = + sum_in_g = + sum_in_b = + sum_out_r = + sum_out_g = + sum_out_b = 0; + + src_pix_ptr = img.pix_ptr(0, y); + for(i = 0; i <= rx; i++) + { + stack_pix_ptr = &stack[i]; + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + sum_r += src_pix_ptr[R] * (i + 1); + sum_g += src_pix_ptr[G] * (i + 1); + sum_b += src_pix_ptr[B] * (i + 1); + sum_out_r += src_pix_ptr[R]; + sum_out_g += src_pix_ptr[G]; + sum_out_b += src_pix_ptr[B]; + } + for(i = 1; i <= rx; i++) + { + if(i <= wm) src_pix_ptr += Img::pix_width; + stack_pix_ptr = &stack[i + rx]; + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + sum_r += src_pix_ptr[R] * (rx + 1 - i); + sum_g += src_pix_ptr[G] * (rx + 1 - i); + sum_b += src_pix_ptr[B] * (rx + 1 - i); + sum_in_r += src_pix_ptr[R]; + sum_in_g += src_pix_ptr[G]; + sum_in_b += src_pix_ptr[B]; + } + + stack_ptr = rx; + xp = rx; + if(xp > wm) xp = wm; + src_pix_ptr = img.pix_ptr(xp, y); + dst_pix_ptr = img.pix_ptr(0, y); + for(x = 0; x < w; x++) + { + dst_pix_ptr[R] = (sum_r * mul_sum) >> shr_sum; + dst_pix_ptr[G] = (sum_g * mul_sum) >> shr_sum; + dst_pix_ptr[B] = (sum_b * mul_sum) >> shr_sum; + dst_pix_ptr += Img::pix_width; + + sum_r -= sum_out_r; + sum_g -= sum_out_g; + sum_b -= sum_out_b; + + stack_start = stack_ptr + div - rx; + if(stack_start >= div) stack_start -= div; + stack_pix_ptr = &stack[stack_start]; + + sum_out_r -= stack_pix_ptr->r; + sum_out_g -= stack_pix_ptr->g; + sum_out_b -= stack_pix_ptr->b; + + if(xp < wm) + { + src_pix_ptr += Img::pix_width; + ++xp; + } + + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + + sum_in_r += src_pix_ptr[R]; + sum_in_g += src_pix_ptr[G]; + sum_in_b += src_pix_ptr[B]; + sum_r += sum_in_r; + sum_g += sum_in_g; + sum_b += sum_in_b; + + ++stack_ptr; + if(stack_ptr >= div) stack_ptr = 0; + stack_pix_ptr = &stack[stack_ptr]; + + sum_out_r += stack_pix_ptr->r; + sum_out_g += stack_pix_ptr->g; + sum_out_b += stack_pix_ptr->b; + sum_in_r -= stack_pix_ptr->r; + sum_in_g -= stack_pix_ptr->g; + sum_in_b -= stack_pix_ptr->b; + } + } + } + + if(ry > 0) + { + if(ry > 254) ry = 254; + div = ry * 2 + 1; + mul_sum = stack_blur_tables::g_stack_blur8_mul[ry]; + shr_sum = stack_blur_tables::g_stack_blur8_shr[ry]; + stack.allocate(div); + + int stride = img.stride(); + for(x = 0; x < w; x++) + { + sum_r = + sum_g = + sum_b = + sum_in_r = + sum_in_g = + sum_in_b = + sum_out_r = + sum_out_g = + sum_out_b = 0; + + src_pix_ptr = img.pix_ptr(x, 0); + for(i = 0; i <= ry; i++) + { + stack_pix_ptr = &stack[i]; + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + sum_r += src_pix_ptr[R] * (i + 1); + sum_g += src_pix_ptr[G] * (i + 1); + sum_b += src_pix_ptr[B] * (i + 1); + sum_out_r += src_pix_ptr[R]; + sum_out_g += src_pix_ptr[G]; + sum_out_b += src_pix_ptr[B]; + } + for(i = 1; i <= ry; i++) + { + if(i <= hm) src_pix_ptr += stride; + stack_pix_ptr = &stack[i + ry]; + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + sum_r += src_pix_ptr[R] * (ry + 1 - i); + sum_g += src_pix_ptr[G] * (ry + 1 - i); + sum_b += src_pix_ptr[B] * (ry + 1 - i); + sum_in_r += src_pix_ptr[R]; + sum_in_g += src_pix_ptr[G]; + sum_in_b += src_pix_ptr[B]; + } + + stack_ptr = ry; + yp = ry; + if(yp > hm) yp = hm; + src_pix_ptr = img.pix_ptr(x, yp); + dst_pix_ptr = img.pix_ptr(x, 0); + for(y = 0; y < h; y++) + { + dst_pix_ptr[R] = (sum_r * mul_sum) >> shr_sum; + dst_pix_ptr[G] = (sum_g * mul_sum) >> shr_sum; + dst_pix_ptr[B] = (sum_b * mul_sum) >> shr_sum; + dst_pix_ptr += stride; + + sum_r -= sum_out_r; + sum_g -= sum_out_g; + sum_b -= sum_out_b; + + stack_start = stack_ptr + div - ry; + if(stack_start >= div) stack_start -= div; + + stack_pix_ptr = &stack[stack_start]; + sum_out_r -= stack_pix_ptr->r; + sum_out_g -= stack_pix_ptr->g; + sum_out_b -= stack_pix_ptr->b; + + if(yp < hm) + { + src_pix_ptr += stride; + ++yp; + } + + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + + sum_in_r += src_pix_ptr[R]; + sum_in_g += src_pix_ptr[G]; + sum_in_b += src_pix_ptr[B]; + sum_r += sum_in_r; + sum_g += sum_in_g; + sum_b += sum_in_b; + + ++stack_ptr; + if(stack_ptr >= div) stack_ptr = 0; + stack_pix_ptr = &stack[stack_ptr]; + + sum_out_r += stack_pix_ptr->r; + sum_out_g += stack_pix_ptr->g; + sum_out_b += stack_pix_ptr->b; + sum_in_r -= stack_pix_ptr->r; + sum_in_g -= stack_pix_ptr->g; + sum_in_b -= stack_pix_ptr->b; + } + } + } + } + + + + //=======================================================stack_blur_rgba32 + template + void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry) + { + typedef typename Img::color_type color_type; + typedef typename Img::order_type order_type; + enum order_e + { + R = order_type::R, + G = order_type::G, + B = order_type::B, + A = order_type::A + }; + + unsigned x, y, xp, yp, i; + unsigned stack_ptr; + unsigned stack_start; + + const int8u* src_pix_ptr; + int8u* dst_pix_ptr; + color_type* stack_pix_ptr; + + unsigned sum_r; + unsigned sum_g; + unsigned sum_b; + unsigned sum_a; + unsigned sum_in_r; + unsigned sum_in_g; + unsigned sum_in_b; + unsigned sum_in_a; + unsigned sum_out_r; + unsigned sum_out_g; + unsigned sum_out_b; + unsigned sum_out_a; + + unsigned w = img.width(); + unsigned h = img.height(); + unsigned wm = w - 1; + unsigned hm = h - 1; + + unsigned div; + unsigned mul_sum; + unsigned shr_sum; + + pod_vector stack; + + if(rx > 0) + { + if(rx > 254) rx = 254; + div = rx * 2 + 1; + mul_sum = stack_blur_tables::g_stack_blur8_mul[rx]; + shr_sum = stack_blur_tables::g_stack_blur8_shr[rx]; + stack.allocate(div); + + for(y = 0; y < h; y++) + { + sum_r = + sum_g = + sum_b = + sum_a = + sum_in_r = + sum_in_g = + sum_in_b = + sum_in_a = + sum_out_r = + sum_out_g = + sum_out_b = + sum_out_a = 0; + + src_pix_ptr = img.pix_ptr(0, y); + for(i = 0; i <= rx; i++) + { + stack_pix_ptr = &stack[i]; + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + stack_pix_ptr->a = src_pix_ptr[A]; + sum_r += src_pix_ptr[R] * (i + 1); + sum_g += src_pix_ptr[G] * (i + 1); + sum_b += src_pix_ptr[B] * (i + 1); + sum_a += src_pix_ptr[A] * (i + 1); + sum_out_r += src_pix_ptr[R]; + sum_out_g += src_pix_ptr[G]; + sum_out_b += src_pix_ptr[B]; + sum_out_a += src_pix_ptr[A]; + } + for(i = 1; i <= rx; i++) + { + if(i <= wm) src_pix_ptr += Img::pix_width; + stack_pix_ptr = &stack[i + rx]; + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + stack_pix_ptr->a = src_pix_ptr[A]; + sum_r += src_pix_ptr[R] * (rx + 1 - i); + sum_g += src_pix_ptr[G] * (rx + 1 - i); + sum_b += src_pix_ptr[B] * (rx + 1 - i); + sum_a += src_pix_ptr[A] * (rx + 1 - i); + sum_in_r += src_pix_ptr[R]; + sum_in_g += src_pix_ptr[G]; + sum_in_b += src_pix_ptr[B]; + sum_in_a += src_pix_ptr[A]; + } + + stack_ptr = rx; + xp = rx; + if(xp > wm) xp = wm; + src_pix_ptr = img.pix_ptr(xp, y); + dst_pix_ptr = img.pix_ptr(0, y); + for(x = 0; x < w; x++) + { + dst_pix_ptr[R] = (sum_r * mul_sum) >> shr_sum; + dst_pix_ptr[G] = (sum_g * mul_sum) >> shr_sum; + dst_pix_ptr[B] = (sum_b * mul_sum) >> shr_sum; + dst_pix_ptr[A] = (sum_a * mul_sum) >> shr_sum; + dst_pix_ptr += Img::pix_width; + + sum_r -= sum_out_r; + sum_g -= sum_out_g; + sum_b -= sum_out_b; + sum_a -= sum_out_a; + + stack_start = stack_ptr + div - rx; + if(stack_start >= div) stack_start -= div; + stack_pix_ptr = &stack[stack_start]; + + sum_out_r -= stack_pix_ptr->r; + sum_out_g -= stack_pix_ptr->g; + sum_out_b -= stack_pix_ptr->b; + sum_out_a -= stack_pix_ptr->a; + + if(xp < wm) + { + src_pix_ptr += Img::pix_width; + ++xp; + } + + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + stack_pix_ptr->a = src_pix_ptr[A]; + + sum_in_r += src_pix_ptr[R]; + sum_in_g += src_pix_ptr[G]; + sum_in_b += src_pix_ptr[B]; + sum_in_a += src_pix_ptr[A]; + sum_r += sum_in_r; + sum_g += sum_in_g; + sum_b += sum_in_b; + sum_a += sum_in_a; + + ++stack_ptr; + if(stack_ptr >= div) stack_ptr = 0; + stack_pix_ptr = &stack[stack_ptr]; + + sum_out_r += stack_pix_ptr->r; + sum_out_g += stack_pix_ptr->g; + sum_out_b += stack_pix_ptr->b; + sum_out_a += stack_pix_ptr->a; + sum_in_r -= stack_pix_ptr->r; + sum_in_g -= stack_pix_ptr->g; + sum_in_b -= stack_pix_ptr->b; + sum_in_a -= stack_pix_ptr->a; + } + } + } + + if(ry > 0) + { + if(ry > 254) ry = 254; + div = ry * 2 + 1; + mul_sum = stack_blur_tables::g_stack_blur8_mul[ry]; + shr_sum = stack_blur_tables::g_stack_blur8_shr[ry]; + stack.allocate(div); + + int stride = img.stride(); + for(x = 0; x < w; x++) + { + sum_r = + sum_g = + sum_b = + sum_a = + sum_in_r = + sum_in_g = + sum_in_b = + sum_in_a = + sum_out_r = + sum_out_g = + sum_out_b = + sum_out_a = 0; + + src_pix_ptr = img.pix_ptr(x, 0); + for(i = 0; i <= ry; i++) + { + stack_pix_ptr = &stack[i]; + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + stack_pix_ptr->a = src_pix_ptr[A]; + sum_r += src_pix_ptr[R] * (i + 1); + sum_g += src_pix_ptr[G] * (i + 1); + sum_b += src_pix_ptr[B] * (i + 1); + sum_a += src_pix_ptr[A] * (i + 1); + sum_out_r += src_pix_ptr[R]; + sum_out_g += src_pix_ptr[G]; + sum_out_b += src_pix_ptr[B]; + sum_out_a += src_pix_ptr[A]; + } + for(i = 1; i <= ry; i++) + { + if(i <= hm) src_pix_ptr += stride; + stack_pix_ptr = &stack[i + ry]; + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + stack_pix_ptr->a = src_pix_ptr[A]; + sum_r += src_pix_ptr[R] * (ry + 1 - i); + sum_g += src_pix_ptr[G] * (ry + 1 - i); + sum_b += src_pix_ptr[B] * (ry + 1 - i); + sum_a += src_pix_ptr[A] * (ry + 1 - i); + sum_in_r += src_pix_ptr[R]; + sum_in_g += src_pix_ptr[G]; + sum_in_b += src_pix_ptr[B]; + sum_in_a += src_pix_ptr[A]; + } + + stack_ptr = ry; + yp = ry; + if(yp > hm) yp = hm; + src_pix_ptr = img.pix_ptr(x, yp); + dst_pix_ptr = img.pix_ptr(x, 0); + for(y = 0; y < h; y++) + { + dst_pix_ptr[R] = (sum_r * mul_sum) >> shr_sum; + dst_pix_ptr[G] = (sum_g * mul_sum) >> shr_sum; + dst_pix_ptr[B] = (sum_b * mul_sum) >> shr_sum; + dst_pix_ptr[A] = (sum_a * mul_sum) >> shr_sum; + dst_pix_ptr += stride; + + sum_r -= sum_out_r; + sum_g -= sum_out_g; + sum_b -= sum_out_b; + sum_a -= sum_out_a; + + stack_start = stack_ptr + div - ry; + if(stack_start >= div) stack_start -= div; + + stack_pix_ptr = &stack[stack_start]; + sum_out_r -= stack_pix_ptr->r; + sum_out_g -= stack_pix_ptr->g; + sum_out_b -= stack_pix_ptr->b; + sum_out_a -= stack_pix_ptr->a; + + if(yp < hm) + { + src_pix_ptr += stride; + ++yp; + } + + stack_pix_ptr->r = src_pix_ptr[R]; + stack_pix_ptr->g = src_pix_ptr[G]; + stack_pix_ptr->b = src_pix_ptr[B]; + stack_pix_ptr->a = src_pix_ptr[A]; + + sum_in_r += src_pix_ptr[R]; + sum_in_g += src_pix_ptr[G]; + sum_in_b += src_pix_ptr[B]; + sum_in_a += src_pix_ptr[A]; + sum_r += sum_in_r; + sum_g += sum_in_g; + sum_b += sum_in_b; + sum_a += sum_in_a; + + ++stack_ptr; + if(stack_ptr >= div) stack_ptr = 0; + stack_pix_ptr = &stack[stack_ptr]; + + sum_out_r += stack_pix_ptr->r; + sum_out_g += stack_pix_ptr->g; + sum_out_b += stack_pix_ptr->b; + sum_out_a += stack_pix_ptr->a; + sum_in_r -= stack_pix_ptr->r; + sum_in_g -= stack_pix_ptr->g; + sum_in_b -= stack_pix_ptr->b; + sum_in_a -= stack_pix_ptr->a; + } + } + } + } + + + + //===========================================================recursive_blur + template class recursive_blur + { + public: + typedef ColorT color_type; + typedef CalculatorT calculator_type; + typedef typename color_type::value_type value_type; + typedef typename calculator_type::value_type calc_type; + + //-------------------------------------------------------------------- + template void blur_x(Img& img, double radius) + { + if(radius < 0.62) return; + if(img.width() < 3) return; + + calc_type s = calc_type(radius * 0.5); + calc_type q = calc_type((s < 2.5) ? + 3.97156 - 4.14554 * sqrt(1 - 0.26891 * s) : + 0.98711 * s - 0.96330); + + calc_type q2 = calc_type(q * q); + calc_type q3 = calc_type(q2 * q); + + calc_type b0 = calc_type(1.0 / (1.578250 + + 2.444130 * q + + 1.428100 * q2 + + 0.422205 * q3)); + + calc_type b1 = calc_type( 2.44413 * q + + 2.85619 * q2 + + 1.26661 * q3); + + calc_type b2 = calc_type(-1.42810 * q2 + + -1.26661 * q3); + + calc_type b3 = calc_type(0.422205 * q3); + + calc_type b = calc_type(1 - (b1 + b2 + b3) * b0); + + b1 *= b0; + b2 *= b0; + b3 *= b0; + + int w = img.width(); + int h = img.height(); + int wm = w-1; + int x, y; + + m_sum1.allocate(w); + m_sum2.allocate(w); + m_buf.allocate(w); + + for(y = 0; y < h; y++) + { + calculator_type c; + c.from_pix(img.pixel(0, y)); + m_sum1[0].calc(b, b1, b2, b3, c, c, c, c); + c.from_pix(img.pixel(1, y)); + m_sum1[1].calc(b, b1, b2, b3, c, m_sum1[0], m_sum1[0], m_sum1[0]); + c.from_pix(img.pixel(2, y)); + m_sum1[2].calc(b, b1, b2, b3, c, m_sum1[1], m_sum1[0], m_sum1[0]); + + for(x = 3; x < w; ++x) + { + c.from_pix(img.pixel(x, y)); + m_sum1[x].calc(b, b1, b2, b3, c, m_sum1[x-1], m_sum1[x-2], m_sum1[x-3]); + } + + m_sum2[wm ].calc(b, b1, b2, b3, m_sum1[wm ], m_sum1[wm ], m_sum1[wm], m_sum1[wm]); + m_sum2[wm-1].calc(b, b1, b2, b3, m_sum1[wm-1], m_sum2[wm ], m_sum2[wm], m_sum2[wm]); + m_sum2[wm-2].calc(b, b1, b2, b3, m_sum1[wm-2], m_sum2[wm-1], m_sum2[wm], m_sum2[wm]); + m_sum2[wm ].to_pix(m_buf[wm ]); + m_sum2[wm-1].to_pix(m_buf[wm-1]); + m_sum2[wm-2].to_pix(m_buf[wm-2]); + + for(x = wm-3; x >= 0; --x) + { + m_sum2[x].calc(b, b1, b2, b3, m_sum1[x], m_sum2[x+1], m_sum2[x+2], m_sum2[x+3]); + m_sum2[x].to_pix(m_buf[x]); + } + img.copy_color_hspan(0, y, w, &m_buf[0]); + } + } + + //-------------------------------------------------------------------- + template void blur_y(Img& img, double radius) + { + pixfmt_transposer img2(img); + blur_x(img2, radius); + } + + //-------------------------------------------------------------------- + template void blur(Img& img, double radius) + { + blur_x(img, radius); + pixfmt_transposer img2(img); + blur_x(img2, radius); + } + + private: + agg::pod_vector m_sum1; + agg::pod_vector m_sum2; + agg::pod_vector m_buf; + }; + + + //=================================================recursive_blur_calc_rgba + template struct recursive_blur_calc_rgba + { + typedef T value_type; + typedef recursive_blur_calc_rgba self_type; + + value_type r,g,b,a; + + template + AGG_INLINE void from_pix(const ColorT& c) + { + r = c.r; + g = c.g; + b = c.b; + a = c.a; + } + + AGG_INLINE void calc(value_type b1, + value_type b2, + value_type b3, + value_type b4, + const self_type& c1, + const self_type& c2, + const self_type& c3, + const self_type& c4) + { + r = b1*c1.r + b2*c2.r + b3*c3.r + b4*c4.r; + g = b1*c1.g + b2*c2.g + b3*c3.g + b4*c4.g; + b = b1*c1.b + b2*c2.b + b3*c3.b + b4*c4.b; + a = b1*c1.a + b2*c2.a + b3*c3.a + b4*c4.a; + } + + template + AGG_INLINE void to_pix(ColorT& c) const + { + typedef typename ColorT::value_type cv_type; + c.r = cv_type(r); + c.g = cv_type(g); + c.b = cv_type(b); + c.a = cv_type(a); + } + }; + + + //=================================================recursive_blur_calc_rgb + template struct recursive_blur_calc_rgb + { + typedef T value_type; + typedef recursive_blur_calc_rgb self_type; + + value_type r,g,b; + + template + AGG_INLINE void from_pix(const ColorT& c) + { + r = c.r; + g = c.g; + b = c.b; + } + + AGG_INLINE void calc(value_type b1, + value_type b2, + value_type b3, + value_type b4, + const self_type& c1, + const self_type& c2, + const self_type& c3, + const self_type& c4) + { + r = b1*c1.r + b2*c2.r + b3*c3.r + b4*c4.r; + g = b1*c1.g + b2*c2.g + b3*c3.g + b4*c4.g; + b = b1*c1.b + b2*c2.b + b3*c3.b + b4*c4.b; + } + + template + AGG_INLINE void to_pix(ColorT& c) const + { + typedef typename ColorT::value_type cv_type; + c.r = cv_type(r); + c.g = cv_type(g); + c.b = cv_type(b); + } + }; + + + //================================================recursive_blur_calc_gray + template struct recursive_blur_calc_gray + { + typedef T value_type; + typedef recursive_blur_calc_gray self_type; + + value_type v; + + template + AGG_INLINE void from_pix(const ColorT& c) + { + v = c.v; + } + + AGG_INLINE void calc(value_type b1, + value_type b2, + value_type b3, + value_type b4, + const self_type& c1, + const self_type& c2, + const self_type& c3, + const self_type& c4) + { + v = b1*c1.v + b2*c2.v + b3*c3.v + b4*c4.v; + } + + template + AGG_INLINE void to_pix(ColorT& c) const + { + typedef typename ColorT::value_type cv_type; + c.v = cv_type(v); + } + }; + + //================================================slight_blur + // Special-purpose filter for applying a Gaussian blur with a radius small enough + // that the blur only affects adjacent pixels. A Gaussian curve with a standard + // deviation of r/2 is used, as per the HTML/CSS spec. At 3 standard deviations, + // the contribution drops to less than 0.005, i.e. less than half a percent, + // therefore the radius can be at least 1.33 before errors become significant. + // This filter is useful for smoothing artifacts caused by detail rendered + // at the pixel scale, e.g. single-pixel lines. Note that the filter should + // only be used with premultiplied pixel formats (or those without alpha). + // See the "line_thickness" example for a demonstration. + template + class slight_blur + { + public: + typedef typename PixFmt::pixel_type pixel_type; + typedef typename PixFmt::value_type value_type; + typedef typename PixFmt::order_type order_type; + + slight_blur(double r = 1.33) + { + radius(r); + } + + void radius(double r) + { + if (r > 0) + { + // Sample the gaussian curve at 0 and r/2 standard deviations. + // At 3 standard deviations, the response is < 0.005. + double pi = 3.14159; + double n = 2 / r; + m_g0 = 1 / sqrt(2 * pi); + m_g1 = m_g0 * exp(-n * n); + + // Normalize. + double sum = m_g0 + 2 * m_g1; + m_g0 /= sum; + m_g1 /= sum; + } + else + { + m_g0 = 1; + m_g1 = 0; + } + } + + void blur(PixFmt& img, rect_i bounds) + { + // Make sure we stay within the image area. + bounds.clip(rect_i(0, 0, img.width() - 1, img.height() - 1)); + + int w = bounds.x2 - bounds.x1 + 1; + int h = bounds.y2 - bounds.y1 + 1; + + if (w < 3 || h < 3) return; + + // Allocate 3 rows of buffer space. + m_buf.allocate(w * 3); + + // Set up row pointers + pixel_type * begin = &m_buf[0]; + pixel_type * r0 = begin; + pixel_type * r1 = r0 + w; + pixel_type * r2 = r1 + w; + pixel_type * end = r2 + w; + + // Horizontally blur the first two input rows. + calc_row(img, bounds.x1, bounds.y1, w, r0); + memcpy(r1, r0, w * sizeof(pixel_type)); + + for (int y = 0; ; ) + { + // Get pointer to first pixel. + pixel_type* p = img.pix_value_ptr(bounds.x1, bounds.y1 + y, bounds.x1 + w); + + // Horizontally blur the row below. + if (y + 1 < h) + { + calc_row(img, bounds.x1, bounds.y1 + y + 1, w, r2); + } + else + { + memcpy(r2, r1, w * sizeof(pixel_type)); // duplicate bottom row + } + + // Combine blurred rows into destination. + for (int x = 0; x < w; ++x) + { + calc_pixel(*r0++, *r1++, *r2++, *p++); + } + + if (++y >= h) break; + + // Wrap bottom row pointer around to top of buffer. + if (r2 == end) r2 = begin; + else if (r1 == end) r1 = begin; + else if (r0 == end) r0 = begin; + } + } + + private: + void calc_row(PixFmt& img, int x, int y, int w, pixel_type* row) + { + const int wm = w - 1; + + pixel_type* p = img.pix_value_ptr(x, y, w); + + pixel_type c[3]; + pixel_type* p0 = c; + pixel_type* p1 = c + 1; + pixel_type* p2 = c + 2; + pixel_type* end = c + 3; + *p0 = *p1 = *p; + + for (int x = 0; x < wm; ++x) + { + *p2 = *(p = p->next()); + + calc_pixel(*p0++, *p1++, *p2++, *row++); + + if (p0 == end) p0 = c; + else if (p1 == end) p1 = c; + else if (p2 == end) p2 = c; + } + + calc_pixel(*p0, *p1, *p1, *row); + } + + void calc_pixel( + pixel_type const & c1, + pixel_type const & c2, + pixel_type const & c3, + pixel_type & x) + { + calc_pixel(c1, c2, c3, x, PixFmt::pixfmt_category()); + } + + void calc_pixel( + pixel_type const & c1, + pixel_type const & c2, + pixel_type const & c3, + pixel_type & x, + pixfmt_gray_tag) + { + x.c[0] = calc_value(c1.c[0], c2.c[0], c3.c[0]); + } + + void calc_pixel( + pixel_type const & c1, + pixel_type const & c2, + pixel_type const & c3, + pixel_type & x, + pixfmt_rgb_tag) + { + enum { R = order_type::R, G = order_type::G, B = order_type::B }; + x.c[R] = calc_value(c1.c[R], c2.c[R], c3.c[R]); + x.c[G] = calc_value(c1.c[G], c2.c[G], c3.c[G]); + x.c[B] = calc_value(c1.c[B], c2.c[B], c3.c[B]); + } + + void calc_pixel( + pixel_type const & c1, + pixel_type const & c2, + pixel_type const & c3, + pixel_type & x, + pixfmt_rgba_tag) + { + enum { R = order_type::R, G = order_type::G, B = order_type::B, A = order_type::A }; + x.c[R] = calc_value(c1.c[R], c2.c[R], c3.c[R]); + x.c[G] = calc_value(c1.c[G], c2.c[G], c3.c[G]); + x.c[B] = calc_value(c1.c[B], c2.c[B], c3.c[B]); + x.c[A] = calc_value(c1.c[A], c2.c[A], c3.c[A]); + } + + value_type calc_value(value_type v1, value_type v2, value_type v3) + { + return value_type(m_g1 * v1 + m_g0 * v2 + m_g1 * v3); + } + + double m_g0, m_g1; + pod_vector m_buf; + }; + + // Helper functions for applying blur to a surface without having to create an intermediate object. + + template + void apply_slight_blur(PixFmt& img, const rect_i& bounds, double r = 1) + { + if (r > 0) slight_blur(r).blur(img, bounds); + } + + template + void apply_slight_blur(PixFmt& img, double r = 1) + { + if (r > 0) slight_blur(r).blur(img, rect_i(0, 0, img.width() - 1, img.height() - 1)); + } + + template + void apply_slight_blur(renderer_base& img, const rect_i& bounds, double r = 1) + { + if (r > 0) slight_blur(r).blur(img.ren(), bounds); + } + + template + void apply_slight_blur(renderer_base& img, double r = 1) + { + if (r > 0) slight_blur(r).blur(img.ren(), img.clip_box()); + } +} + + + + +#endif diff --git a/xs/src/agg/agg_bounding_rect.h b/xs/src/agg/agg_bounding_rect.h new file mode 100644 index 0000000000..f13b863f0f --- /dev/null +++ b/xs/src/agg/agg_bounding_rect.h @@ -0,0 +1,116 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// bounding_rect function template +// +//---------------------------------------------------------------------------- +#ifndef AGG_BOUNDING_RECT_INCLUDED +#define AGG_BOUNDING_RECT_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //-----------------------------------------------------------bounding_rect + template + bool bounding_rect(VertexSource& vs, GetId& gi, + unsigned start, unsigned num, + CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2) + { + unsigned i; + double x; + double y; + bool first = true; + + *x1 = CoordT(1); + *y1 = CoordT(1); + *x2 = CoordT(0); + *y2 = CoordT(0); + + for(i = 0; i < num; i++) + { + vs.rewind(gi[start + i]); + unsigned cmd; + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + if(is_vertex(cmd)) + { + if(first) + { + *x1 = CoordT(x); + *y1 = CoordT(y); + *x2 = CoordT(x); + *y2 = CoordT(y); + first = false; + } + else + { + if(CoordT(x) < *x1) *x1 = CoordT(x); + if(CoordT(y) < *y1) *y1 = CoordT(y); + if(CoordT(x) > *x2) *x2 = CoordT(x); + if(CoordT(y) > *y2) *y2 = CoordT(y); + } + } + } + } + return *x1 <= *x2 && *y1 <= *y2; + } + + + //-----------------------------------------------------bounding_rect_single + template + bool bounding_rect_single(VertexSource& vs, unsigned path_id, + CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2) + { + double x; + double y; + bool first = true; + + *x1 = CoordT(1); + *y1 = CoordT(1); + *x2 = CoordT(0); + *y2 = CoordT(0); + + vs.rewind(path_id); + unsigned cmd; + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + if(is_vertex(cmd)) + { + if(first) + { + *x1 = CoordT(x); + *y1 = CoordT(y); + *x2 = CoordT(x); + *y2 = CoordT(y); + first = false; + } + else + { + if(CoordT(x) < *x1) *x1 = CoordT(x); + if(CoordT(y) < *y1) *y1 = CoordT(y); + if(CoordT(x) > *x2) *x2 = CoordT(x); + if(CoordT(y) > *y2) *y2 = CoordT(y); + } + } + } + return *x1 <= *x2 && *y1 <= *y2; + } + + +} + +#endif diff --git a/xs/src/agg/agg_bspline.h b/xs/src/agg/agg_bspline.h new file mode 100644 index 0000000000..2c1ed9a38c --- /dev/null +++ b/xs/src/agg/agg_bspline.h @@ -0,0 +1,76 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class bspline +// +//---------------------------------------------------------------------------- + +#ifndef AGG_BSPLINE_INCLUDED +#define AGG_BSPLINE_INCLUDED + +#include "agg_array.h" + +namespace agg +{ + //----------------------------------------------------------------bspline + // A very simple class of Bi-cubic Spline interpolation. + // First call init(num, x[], y[]) where num - number of source points, + // x, y - arrays of X and Y values respectively. Here Y must be a function + // of X. It means that all the X-coordinates must be arranged in the ascending + // order. + // Then call get(x) that calculates a value Y for the respective X. + // The class supports extrapolation, i.e. you can call get(x) where x is + // outside the given with init() X-range. Extrapolation is a simple linear + // function. + // + // See Implementation agg_bspline.cpp + //------------------------------------------------------------------------ + class bspline + { + public: + bspline(); + bspline(int num); + bspline(int num, const double* x, const double* y); + + void init(int num); + void add_point(double x, double y); + void prepare(); + + void init(int num, const double* x, const double* y); + + double get(double x) const; + double get_stateful(double x) const; + + private: + bspline(const bspline&); + const bspline& operator = (const bspline&); + + static void bsearch(int n, const double *x, double x0, int *i); + double extrapolation_left(double x) const; + double extrapolation_right(double x) const; + double interpolation(double x, int i) const; + + int m_max; + int m_num; + double* m_x; + double* m_y; + pod_array m_am; + mutable int m_last_idx; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_clip_liang_barsky.h b/xs/src/agg/agg_clip_liang_barsky.h new file mode 100644 index 0000000000..4b5fedbab5 --- /dev/null +++ b/xs/src/agg/agg_clip_liang_barsky.h @@ -0,0 +1,333 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Liang-Barsky clipping +// +//---------------------------------------------------------------------------- +#ifndef AGG_CLIP_LIANG_BARSKY_INCLUDED +#define AGG_CLIP_LIANG_BARSKY_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //------------------------------------------------------------------------ + enum clipping_flags_e + { + clipping_flags_x1_clipped = 4, + clipping_flags_x2_clipped = 1, + clipping_flags_y1_clipped = 8, + clipping_flags_y2_clipped = 2, + clipping_flags_x_clipped = clipping_flags_x1_clipped | clipping_flags_x2_clipped, + clipping_flags_y_clipped = clipping_flags_y1_clipped | clipping_flags_y2_clipped + }; + + //----------------------------------------------------------clipping_flags + // Determine the clipping code of the vertex according to the + // Cyrus-Beck line clipping algorithm + // + // | | + // 0110 | 0010 | 0011 + // | | + // -------+--------+-------- clip_box.y2 + // | | + // 0100 | 0000 | 0001 + // | | + // -------+--------+-------- clip_box.y1 + // | | + // 1100 | 1000 | 1001 + // | | + // clip_box.x1 clip_box.x2 + // + // + template + inline unsigned clipping_flags(T x, T y, const rect_base& clip_box) + { + return (x > clip_box.x2) | + ((y > clip_box.y2) << 1) | + ((x < clip_box.x1) << 2) | + ((y < clip_box.y1) << 3); + } + + //--------------------------------------------------------clipping_flags_x + template + inline unsigned clipping_flags_x(T x, const rect_base& clip_box) + { + return (x > clip_box.x2) | ((x < clip_box.x1) << 2); + } + + + //--------------------------------------------------------clipping_flags_y + template + inline unsigned clipping_flags_y(T y, const rect_base& clip_box) + { + return ((y > clip_box.y2) << 1) | ((y < clip_box.y1) << 3); + } + + + //-------------------------------------------------------clip_liang_barsky + template + inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2, + const rect_base& clip_box, + T* x, T* y) + { + const double nearzero = 1e-30; + + double deltax = x2 - x1; + double deltay = y2 - y1; + double xin; + double xout; + double yin; + double yout; + double tinx; + double tiny; + double toutx; + double touty; + double tin1; + double tin2; + double tout1; + unsigned np = 0; + + if(deltax == 0.0) + { + // bump off of the vertical + deltax = (x1 > clip_box.x1) ? -nearzero : nearzero; + } + + if(deltay == 0.0) + { + // bump off of the horizontal + deltay = (y1 > clip_box.y1) ? -nearzero : nearzero; + } + + if(deltax > 0.0) + { + // points to right + xin = clip_box.x1; + xout = clip_box.x2; + } + else + { + xin = clip_box.x2; + xout = clip_box.x1; + } + + if(deltay > 0.0) + { + // points up + yin = clip_box.y1; + yout = clip_box.y2; + } + else + { + yin = clip_box.y2; + yout = clip_box.y1; + } + + tinx = (xin - x1) / deltax; + tiny = (yin - y1) / deltay; + + if (tinx < tiny) + { + // hits x first + tin1 = tinx; + tin2 = tiny; + } + else + { + // hits y first + tin1 = tiny; + tin2 = tinx; + } + + if(tin1 <= 1.0) + { + if(0.0 < tin1) + { + *x++ = (T)xin; + *y++ = (T)yin; + ++np; + } + + if(tin2 <= 1.0) + { + toutx = (xout - x1) / deltax; + touty = (yout - y1) / deltay; + + tout1 = (toutx < touty) ? toutx : touty; + + if(tin2 > 0.0 || tout1 > 0.0) + { + if(tin2 <= tout1) + { + if(tin2 > 0.0) + { + if(tinx > tiny) + { + *x++ = (T)xin; + *y++ = (T)(y1 + tinx * deltay); + } + else + { + *x++ = (T)(x1 + tiny * deltax); + *y++ = (T)yin; + } + ++np; + } + + if(tout1 < 1.0) + { + if(toutx < touty) + { + *x++ = (T)xout; + *y++ = (T)(y1 + toutx * deltay); + } + else + { + *x++ = (T)(x1 + touty * deltax); + *y++ = (T)yout; + } + } + else + { + *x++ = x2; + *y++ = y2; + } + ++np; + } + else + { + if(tinx > tiny) + { + *x++ = (T)xin; + *y++ = (T)yout; + } + else + { + *x++ = (T)xout; + *y++ = (T)yin; + } + ++np; + } + } + } + } + return np; + } + + + //---------------------------------------------------------------------------- + template + bool clip_move_point(T x1, T y1, T x2, T y2, + const rect_base& clip_box, + T* x, T* y, unsigned flags) + { + T bound; + + if(flags & clipping_flags_x_clipped) + { + if(x1 == x2) + { + return false; + } + bound = (flags & clipping_flags_x1_clipped) ? clip_box.x1 : clip_box.x2; + *y = (T)(double(bound - x1) * (y2 - y1) / (x2 - x1) + y1); + *x = bound; + } + + flags = clipping_flags_y(*y, clip_box); + if(flags & clipping_flags_y_clipped) + { + if(y1 == y2) + { + return false; + } + bound = (flags & clipping_flags_y1_clipped) ? clip_box.y1 : clip_box.y2; + *x = (T)(double(bound - y1) * (x2 - x1) / (y2 - y1) + x1); + *y = bound; + } + return true; + } + + //-------------------------------------------------------clip_line_segment + // Returns: ret >= 4 - Fully clipped + // (ret & 1) != 0 - First point has been moved + // (ret & 2) != 0 - Second point has been moved + // + template + unsigned clip_line_segment(T* x1, T* y1, T* x2, T* y2, + const rect_base& clip_box) + { + unsigned f1 = clipping_flags(*x1, *y1, clip_box); + unsigned f2 = clipping_flags(*x2, *y2, clip_box); + unsigned ret = 0; + + if((f2 | f1) == 0) + { + // Fully visible + return 0; + } + + if((f1 & clipping_flags_x_clipped) != 0 && + (f1 & clipping_flags_x_clipped) == (f2 & clipping_flags_x_clipped)) + { + // Fully clipped + return 4; + } + + if((f1 & clipping_flags_y_clipped) != 0 && + (f1 & clipping_flags_y_clipped) == (f2 & clipping_flags_y_clipped)) + { + // Fully clipped + return 4; + } + + T tx1 = *x1; + T ty1 = *y1; + T tx2 = *x2; + T ty2 = *y2; + if(f1) + { + if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x1, y1, f1)) + { + return 4; + } + if(*x1 == *x2 && *y1 == *y2) + { + return 4; + } + ret |= 1; + } + if(f2) + { + if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x2, y2, f2)) + { + return 4; + } + if(*x1 == *x2 && *y1 == *y2) + { + return 4; + } + ret |= 2; + } + return ret; + } + + +} + + +#endif diff --git a/xs/src/agg/agg_color_gray.h b/xs/src/agg/agg_color_gray.h new file mode 100644 index 0000000000..f66588c119 --- /dev/null +++ b/xs/src/agg/agg_color_gray.h @@ -0,0 +1,1047 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +// +// color types gray8, gray16 +// +//---------------------------------------------------------------------------- + +#ifndef AGG_COLOR_GRAY_INCLUDED +#define AGG_COLOR_GRAY_INCLUDED + +#include "agg_basics.h" +#include "agg_color_rgba.h" + +namespace agg +{ + + //===================================================================gray8 + template + struct gray8T + { + typedef int8u value_type; + typedef int32u calc_type; + typedef int32 long_type; + enum base_scale_e + { + base_shift = 8, + base_scale = 1 << base_shift, + base_mask = base_scale - 1, + base_MSB = 1 << (base_shift - 1) + }; + typedef gray8T self_type; + + value_type v; + value_type a; + + static value_type luminance(const rgba& c) + { + // Calculate grayscale value as per ITU-R BT.709. + return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) * base_mask)); + } + + static value_type luminance(const rgba8& c) + { + // Calculate grayscale value as per ITU-R BT.709. + return value_type((55u * c.r + 184u * c.g + 18u * c.b) >> 8); + } + + static void convert(gray8T& dst, const gray8T& src) + { + dst.v = sRGB_conv::rgb_from_sRGB(src.v); + dst.a = src.a; + } + + static void convert(gray8T& dst, const gray8T& src) + { + dst.v = sRGB_conv::rgb_to_sRGB(src.v); + dst.a = src.a; + } + + static void convert(gray8T& dst, const rgba8& src) + { + dst.v = luminance(src); + dst.a = src.a; + } + + static void convert(gray8T& dst, const srgba8& src) + { + // The RGB weights are only valid for linear values. + convert(dst, rgba8(src)); + } + + static void convert(gray8T& dst, const rgba8& src) + { + dst.v = sRGB_conv::rgb_to_sRGB(luminance(src)); + dst.a = src.a; + } + + static void convert(gray8T& dst, const srgba8& src) + { + // The RGB weights are only valid for linear values. + convert(dst, rgba8(src)); + } + + //-------------------------------------------------------------------- + gray8T() {} + + //-------------------------------------------------------------------- + explicit gray8T(unsigned v_, unsigned a_ = base_mask) : + v(int8u(v_)), a(int8u(a_)) {} + + //-------------------------------------------------------------------- + gray8T(const self_type& c, unsigned a_) : + v(c.v), a(value_type(a_)) {} + + //-------------------------------------------------------------------- + gray8T(const rgba& c) : + v(luminance(c)), + a(value_type(uround(c.a * base_mask))) {} + + //-------------------------------------------------------------------- + template + gray8T(const gray8T& c) + { + convert(*this, c); + } + + //-------------------------------------------------------------------- + template + gray8T(const rgba8T& c) + { + convert(*this, c); + } + + //-------------------------------------------------------------------- + template + T convert_from_sRGB() const + { + typename T::value_type y = sRGB_conv::rgb_from_sRGB(v); + return T(y, y, y, sRGB_conv::alpha_from_sRGB(a)); + } + + template + T convert_to_sRGB() const + { + typename T::value_type y = sRGB_conv::rgb_to_sRGB(v); + return T(y, y, y, sRGB_conv::alpha_to_sRGB(a)); + } + + //-------------------------------------------------------------------- + rgba8 make_rgba8(const linear&) const + { + return rgba8(v, v, v, a); + } + + rgba8 make_rgba8(const sRGB&) const + { + return convert_from_sRGB(); + } + + operator rgba8() const + { + return make_rgba8(Colorspace()); + } + + //-------------------------------------------------------------------- + srgba8 make_srgba8(const linear&) const + { + return convert_to_sRGB(); + } + + srgba8 make_srgba8(const sRGB&) const + { + return srgba8(v, v, v, a); + } + + operator srgba8() const + { + return make_rgba8(Colorspace()); + } + + //-------------------------------------------------------------------- + rgba16 make_rgba16(const linear&) const + { + rgba16::value_type rgb = (v << 8) | v; + return rgba16(rgb, rgb, rgb, (a << 8) | a); + } + + rgba16 make_rgba16(const sRGB&) const + { + return convert_from_sRGB(); + } + + operator rgba16() const + { + return make_rgba16(Colorspace()); + } + + //-------------------------------------------------------------------- + rgba32 make_rgba32(const linear&) const + { + rgba32::value_type v32 = v / 255.0f; + return rgba32(v32, v32, v32, a / 255.0f); + } + + rgba32 make_rgba32(const sRGB&) const + { + return convert_from_sRGB(); + } + + operator rgba32() const + { + return make_rgba32(Colorspace()); + } + + //-------------------------------------------------------------------- + static AGG_INLINE double to_double(value_type a) + { + return double(a) / base_mask; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type from_double(double a) + { + return value_type(uround(a * base_mask)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type empty_value() + { + return 0; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type full_value() + { + return base_mask; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_transparent() const + { + return a == 0; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_opaque() const + { + return a == base_mask; + } + + //-------------------------------------------------------------------- + // Fixed-point multiply, exact over int8u. + static AGG_INLINE value_type multiply(value_type a, value_type b) + { + calc_type t = a * b + base_MSB; + return value_type(((t >> base_shift) + t) >> base_shift); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type demultiply(value_type a, value_type b) + { + if (a * b == 0) + { + return 0; + } + else if (a >= b) + { + return base_mask; + } + else return value_type((a * base_mask + (b >> 1)) / b); + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downscale(T a) + { + return a >> base_shift; + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downshift(T a, unsigned n) + { + return a >> n; + } + + //-------------------------------------------------------------------- + // Fixed-point multiply, exact over int8u. + // Specifically for multiplying a color component by a cover. + static AGG_INLINE value_type mult_cover(value_type a, value_type b) + { + return multiply(a, b); + } + + //-------------------------------------------------------------------- + static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) + { + return multiply(b, a); + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a, assuming q is premultiplied by a. + static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) + { + return p + q - multiply(p, a); + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a. + static AGG_INLINE value_type lerp(value_type p, value_type q, value_type a) + { + int t = (q - p) * a + base_MSB - (p > q); + return value_type(p + (((t >> base_shift) + t) >> base_shift)); + } + + //-------------------------------------------------------------------- + self_type& clear() + { + v = a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& transparent() + { + a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& opacity(double a_) + { + if (a_ < 0) a = 0; + else if (a_ > 1) a = 1; + else a = (value_type)uround(a_ * double(base_mask)); + return *this; + } + + //-------------------------------------------------------------------- + double opacity() const + { + return double(a) / double(base_mask); + } + + //-------------------------------------------------------------------- + self_type& premultiply() + { + if (a < base_mask) + { + if (a == 0) v = 0; + else v = multiply(v, a); + } + return *this; + } + + //-------------------------------------------------------------------- + self_type& demultiply() + { + if (a < base_mask) + { + if (a == 0) + { + v = 0; + } + else + { + calc_type v_ = (calc_type(v) * base_mask) / a; + v = value_type((v_ > base_mask) ? (value_type)base_mask : v_); + } + } + return *this; + } + + //-------------------------------------------------------------------- + self_type gradient(self_type c, double k) const + { + self_type ret; + calc_type ik = uround(k * base_scale); + ret.v = lerp(v, c.v, ik); + ret.a = lerp(a, c.a, ik); + return ret; + } + + //-------------------------------------------------------------------- + AGG_INLINE void add(const self_type& c, unsigned cover) + { + calc_type cv, ca; + if (cover == cover_mask) + { + if (c.a == base_mask) + { + *this = c; + return; + } + else + { + cv = v + c.v; + ca = a + c.a; + } + } + else + { + cv = v + mult_cover(c.v, cover); + ca = a + mult_cover(c.a, cover); + } + v = (value_type)((cv > calc_type(base_mask)) ? calc_type(base_mask) : cv); + a = (value_type)((ca > calc_type(base_mask)) ? calc_type(base_mask) : ca); + } + + //-------------------------------------------------------------------- + static self_type no_color() { return self_type(0,0); } + }; + + typedef gray8T gray8; + typedef gray8T sgray8; + + + //==================================================================gray16 + struct gray16 + { + typedef int16u value_type; + typedef int32u calc_type; + typedef int64 long_type; + enum base_scale_e + { + base_shift = 16, + base_scale = 1 << base_shift, + base_mask = base_scale - 1, + base_MSB = 1 << (base_shift - 1) + }; + typedef gray16 self_type; + + value_type v; + value_type a; + + static value_type luminance(const rgba& c) + { + // Calculate grayscale value as per ITU-R BT.709. + return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) * base_mask)); + } + + static value_type luminance(const rgba16& c) + { + // Calculate grayscale value as per ITU-R BT.709. + return value_type((13933u * c.r + 46872u * c.g + 4732u * c.b) >> 16); + } + + static value_type luminance(const rgba8& c) + { + return luminance(rgba16(c)); + } + + static value_type luminance(const srgba8& c) + { + return luminance(rgba16(c)); + } + + static value_type luminance(const rgba32& c) + { + return luminance(rgba(c)); + } + + //-------------------------------------------------------------------- + gray16() {} + + //-------------------------------------------------------------------- + explicit gray16(unsigned v_, unsigned a_ = base_mask) : + v(int16u(v_)), a(int16u(a_)) {} + + //-------------------------------------------------------------------- + gray16(const self_type& c, unsigned a_) : + v(c.v), a(value_type(a_)) {} + + //-------------------------------------------------------------------- + gray16(const rgba& c) : + v(luminance(c)), + a((value_type)uround(c.a * double(base_mask))) {} + + //-------------------------------------------------------------------- + gray16(const rgba8& c) : + v(luminance(c)), + a((value_type(c.a) << 8) | c.a) {} + + //-------------------------------------------------------------------- + gray16(const srgba8& c) : + v(luminance(c)), + a((value_type(c.a) << 8) | c.a) {} + + //-------------------------------------------------------------------- + gray16(const rgba16& c) : + v(luminance(c)), + a(c.a) {} + + //-------------------------------------------------------------------- + gray16(const gray8& c) : + v((value_type(c.v) << 8) | c.v), + a((value_type(c.a) << 8) | c.a) {} + + //-------------------------------------------------------------------- + gray16(const sgray8& c) : + v(sRGB_conv::rgb_from_sRGB(c.v)), + a(sRGB_conv::alpha_from_sRGB(c.a)) {} + + //-------------------------------------------------------------------- + operator rgba8() const + { + return rgba8(v >> 8, v >> 8, v >> 8, a >> 8); + } + + //-------------------------------------------------------------------- + operator srgba8() const + { + value_type y = sRGB_conv::rgb_to_sRGB(v); + return srgba8(y, y, y, sRGB_conv::alpha_to_sRGB(a)); + } + + //-------------------------------------------------------------------- + operator rgba16() const + { + return rgba16(v, v, v, a); + } + + //-------------------------------------------------------------------- + operator rgba32() const + { + rgba32::value_type v32 = v / 65535.0f; + return rgba32(v32, v32, v32, a / 65535.0f); + } + + //-------------------------------------------------------------------- + operator gray8() const + { + return gray8(v >> 8, a >> 8); + } + + //-------------------------------------------------------------------- + operator sgray8() const + { + return sgray8( + sRGB_conv::rgb_to_sRGB(v), + sRGB_conv::alpha_to_sRGB(a)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE double to_double(value_type a) + { + return double(a) / base_mask; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type from_double(double a) + { + return value_type(uround(a * base_mask)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type empty_value() + { + return 0; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type full_value() + { + return base_mask; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_transparent() const + { + return a == 0; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_opaque() const + { + return a == base_mask; + } + + //-------------------------------------------------------------------- + // Fixed-point multiply, exact over int16u. + static AGG_INLINE value_type multiply(value_type a, value_type b) + { + calc_type t = a * b + base_MSB; + return value_type(((t >> base_shift) + t) >> base_shift); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type demultiply(value_type a, value_type b) + { + if (a * b == 0) + { + return 0; + } + else if (a >= b) + { + return base_mask; + } + else return value_type((a * base_mask + (b >> 1)) / b); + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downscale(T a) + { + return a >> base_shift; + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downshift(T a, unsigned n) + { + return a >> n; + } + + //-------------------------------------------------------------------- + // Fixed-point multiply, almost exact over int16u. + // Specifically for multiplying a color component by a cover. + static AGG_INLINE value_type mult_cover(value_type a, cover_type b) + { + return multiply(a, b << 8 | b); + } + + //-------------------------------------------------------------------- + static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) + { + return mult_cover(b, a) >> 8; + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a, assuming q is premultiplied by a. + static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) + { + return p + q - multiply(p, a); + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a. + static AGG_INLINE value_type lerp(value_type p, value_type q, value_type a) + { + int t = (q - p) * a + base_MSB - (p > q); + return value_type(p + (((t >> base_shift) + t) >> base_shift)); + } + + //-------------------------------------------------------------------- + self_type& clear() + { + v = a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& transparent() + { + a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& opacity(double a_) + { + if (a_ < 0) a = 0; + else if(a_ > 1) a = 1; + else a = (value_type)uround(a_ * double(base_mask)); + return *this; + } + + //-------------------------------------------------------------------- + double opacity() const + { + return double(a) / double(base_mask); + } + + + //-------------------------------------------------------------------- + self_type& premultiply() + { + if (a < base_mask) + { + if(a == 0) v = 0; + else v = multiply(v, a); + } + return *this; + } + + //-------------------------------------------------------------------- + self_type& demultiply() + { + if (a < base_mask) + { + if (a == 0) + { + v = 0; + } + else + { + calc_type v_ = (calc_type(v) * base_mask) / a; + v = (v_ > base_mask) ? value_type(base_mask) : value_type(v_); + } + } + return *this; + } + + //-------------------------------------------------------------------- + self_type gradient(self_type c, double k) const + { + self_type ret; + calc_type ik = uround(k * base_scale); + ret.v = lerp(v, c.v, ik); + ret.a = lerp(a, c.a, ik); + return ret; + } + + //-------------------------------------------------------------------- + AGG_INLINE void add(const self_type& c, unsigned cover) + { + calc_type cv, ca; + if (cover == cover_mask) + { + if (c.a == base_mask) + { + *this = c; + return; + } + else + { + cv = v + c.v; + ca = a + c.a; + } + } + else + { + cv = v + mult_cover(c.v, cover); + ca = a + mult_cover(c.a, cover); + } + v = (value_type)((cv > calc_type(base_mask)) ? calc_type(base_mask) : cv); + a = (value_type)((ca > calc_type(base_mask)) ? calc_type(base_mask) : ca); + } + + //-------------------------------------------------------------------- + static self_type no_color() { return self_type(0,0); } + }; + + + //===================================================================gray32 + struct gray32 + { + typedef float value_type; + typedef double calc_type; + typedef double long_type; + typedef gray32 self_type; + + value_type v; + value_type a; + + // Calculate grayscale value as per ITU-R BT.709. + static value_type luminance(double r, double g, double b) + { + return value_type(0.2126 * r + 0.7152 * g + 0.0722 * b); + } + + static value_type luminance(const rgba& c) + { + return luminance(c.r, c.g, c.b); + } + + static value_type luminance(const rgba32& c) + { + return luminance(c.r, c.g, c.b); + } + + static value_type luminance(const rgba8& c) + { + return luminance(c.r / 255.0, c.g / 255.0, c.g / 255.0); + } + + static value_type luminance(const rgba16& c) + { + return luminance(c.r / 65535.0, c.g / 65535.0, c.g / 65535.0); + } + + //-------------------------------------------------------------------- + gray32() {} + + //-------------------------------------------------------------------- + explicit gray32(value_type v_, value_type a_ = 1) : + v(v_), a(a_) {} + + //-------------------------------------------------------------------- + gray32(const self_type& c, value_type a_) : + v(c.v), a(a_) {} + + //-------------------------------------------------------------------- + gray32(const rgba& c) : + v(luminance(c)), + a(value_type(c.a)) {} + + //-------------------------------------------------------------------- + gray32(const rgba8& c) : + v(luminance(c)), + a(value_type(c.a / 255.0)) {} + + //-------------------------------------------------------------------- + gray32(const srgba8& c) : + v(luminance(rgba32(c))), + a(value_type(c.a / 255.0)) {} + + //-------------------------------------------------------------------- + gray32(const rgba16& c) : + v(luminance(c)), + a(value_type(c.a / 65535.0)) {} + + //-------------------------------------------------------------------- + gray32(const rgba32& c) : + v(luminance(c)), + a(value_type(c.a)) {} + + //-------------------------------------------------------------------- + gray32(const gray8& c) : + v(value_type(c.v / 255.0)), + a(value_type(c.a / 255.0)) {} + + //-------------------------------------------------------------------- + gray32(const sgray8& c) : + v(sRGB_conv::rgb_from_sRGB(c.v)), + a(sRGB_conv::alpha_from_sRGB(c.a)) {} + + //-------------------------------------------------------------------- + gray32(const gray16& c) : + v(value_type(c.v / 65535.0)), + a(value_type(c.a / 65535.0)) {} + + //-------------------------------------------------------------------- + operator rgba() const + { + return rgba(v, v, v, a); + } + + //-------------------------------------------------------------------- + operator gray8() const + { + return gray8(uround(v * 255.0), uround(a * 255.0)); + } + + //-------------------------------------------------------------------- + operator sgray8() const + { + // Return (non-premultiplied) sRGB values. + return sgray8( + sRGB_conv::rgb_to_sRGB(v), + sRGB_conv::alpha_to_sRGB(a)); + } + + //-------------------------------------------------------------------- + operator gray16() const + { + return gray16(uround(v * 65535.0), uround(a * 65535.0)); + } + + //-------------------------------------------------------------------- + operator rgba8() const + { + rgba8::value_type y = uround(v * 255.0); + return rgba8(y, y, y, uround(a * 255.0)); + } + + //-------------------------------------------------------------------- + operator srgba8() const + { + srgba8::value_type y = sRGB_conv::rgb_to_sRGB(v); + return srgba8(y, y, y, sRGB_conv::alpha_to_sRGB(a)); + } + + //-------------------------------------------------------------------- + operator rgba16() const + { + rgba16::value_type y = uround(v * 65535.0); + return rgba16(y, y, y, uround(a * 65535.0)); + } + + //-------------------------------------------------------------------- + operator rgba32() const + { + return rgba32(v, v, v, a); + } + + //-------------------------------------------------------------------- + static AGG_INLINE double to_double(value_type a) + { + return a; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type from_double(double a) + { + return value_type(a); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type empty_value() + { + return 0; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type full_value() + { + return 1; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_transparent() const + { + return a <= 0; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_opaque() const + { + return a >= 1; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type invert(value_type x) + { + return 1 - x; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type multiply(value_type a, value_type b) + { + return value_type(a * b); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type demultiply(value_type a, value_type b) + { + return (b == 0) ? 0 : value_type(a / b); + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downscale(T a) + { + return a; + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downshift(T a, unsigned n) + { + return n > 0 ? a / (1 << n) : a; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type mult_cover(value_type a, cover_type b) + { + return value_type(a * b / cover_mask); + } + + //-------------------------------------------------------------------- + static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) + { + return cover_type(uround(a * b)); + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a, assuming q is premultiplied by a. + static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) + { + return (1 - a) * p + q; // more accurate than "p + q - p * a" + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a. + static AGG_INLINE value_type lerp(value_type p, value_type q, value_type a) + { + // The form "p + a * (q - p)" avoids a multiplication, but may produce an + // inaccurate result. For example, "p + (q - p)" may not be exactly equal + // to q. Therefore, stick to the basic expression, which at least produces + // the correct result at either extreme. + return (1 - a) * p + a * q; + } + + //-------------------------------------------------------------------- + self_type& clear() + { + v = a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& transparent() + { + a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& opacity(double a_) + { + if (a_ < 0) a = 0; + else if (a_ > 1) a = 1; + else a = value_type(a_); + return *this; + } + + //-------------------------------------------------------------------- + double opacity() const + { + return a; + } + + + //-------------------------------------------------------------------- + self_type& premultiply() + { + if (a < 0) v = 0; + else if(a < 1) v *= a; + return *this; + } + + //-------------------------------------------------------------------- + self_type& demultiply() + { + if (a < 0) v = 0; + else if (a < 1) v /= a; + return *this; + } + + //-------------------------------------------------------------------- + self_type gradient(self_type c, double k) const + { + return self_type( + value_type(v + (c.v - v) * k), + value_type(a + (c.a - a) * k)); + } + + //-------------------------------------------------------------------- + static self_type no_color() { return self_type(0,0); } + }; +} + + + + +#endif diff --git a/xs/src/agg/agg_color_rgba.h b/xs/src/agg/agg_color_rgba.h new file mode 100644 index 0000000000..ff33a1179c --- /dev/null +++ b/xs/src/agg/agg_color_rgba.h @@ -0,0 +1,1353 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_COLOR_RGBA_INCLUDED +#define AGG_COLOR_RGBA_INCLUDED + +#include +#include "agg_basics.h" +#include "agg_gamma_lut.h" + +namespace agg +{ + // Supported component orders for RGB and RGBA pixel formats + //======================================================================= + struct order_rgb { enum rgb_e { R=0, G=1, B=2, N=3 }; }; + struct order_bgr { enum bgr_e { B=0, G=1, R=2, N=3 }; }; + struct order_rgba { enum rgba_e { R=0, G=1, B=2, A=3, N=4 }; }; + struct order_argb { enum argb_e { A=0, R=1, G=2, B=3, N=4 }; }; + struct order_abgr { enum abgr_e { A=0, B=1, G=2, R=3, N=4 }; }; + struct order_bgra { enum bgra_e { B=0, G=1, R=2, A=3, N=4 }; }; + + // Colorspace tag types. + struct linear {}; + struct sRGB {}; + + //====================================================================rgba + struct rgba + { + typedef double value_type; + + double r; + double g; + double b; + double a; + + //-------------------------------------------------------------------- + rgba() {} + + //-------------------------------------------------------------------- + rgba(double r_, double g_, double b_, double a_=1.0) : + r(r_), g(g_), b(b_), a(a_) {} + + //-------------------------------------------------------------------- + rgba(const rgba& c, double a_) : r(c.r), g(c.g), b(c.b), a(a_) {} + + //-------------------------------------------------------------------- + rgba& clear() + { + r = g = b = a = 0; + return *this; + } + + //-------------------------------------------------------------------- + rgba& transparent() + { + a = 0; + return *this; + } + + //-------------------------------------------------------------------- + rgba& opacity(double a_) + { + if (a_ < 0) a = 0; + else if (a_ > 1) a = 1; + else a = a_; + return *this; + } + + //-------------------------------------------------------------------- + double opacity() const + { + return a; + } + + //-------------------------------------------------------------------- + rgba& premultiply() + { + r *= a; + g *= a; + b *= a; + return *this; + } + + //-------------------------------------------------------------------- + rgba& premultiply(double a_) + { + if (a <= 0 || a_ <= 0) + { + r = g = b = a = 0; + } + else + { + a_ /= a; + r *= a_; + g *= a_; + b *= a_; + a = a_; + } + return *this; + } + + //-------------------------------------------------------------------- + rgba& demultiply() + { + if (a == 0) + { + r = g = b = 0; + } + else + { + double a_ = 1.0 / a; + r *= a_; + g *= a_; + b *= a_; + } + return *this; + } + + + //-------------------------------------------------------------------- + rgba gradient(rgba c, double k) const + { + rgba ret; + ret.r = r + (c.r - r) * k; + ret.g = g + (c.g - g) * k; + ret.b = b + (c.b - b) * k; + ret.a = a + (c.a - a) * k; + return ret; + } + + rgba& operator+=(const rgba& c) + { + r += c.r; + g += c.g; + b += c.b; + a += c.a; + return *this; + } + + rgba& operator*=(double k) + { + r *= k; + g *= k; + b *= k; + a *= k; + return *this; + } + + //-------------------------------------------------------------------- + static rgba no_color() { return rgba(0,0,0,0); } + + //-------------------------------------------------------------------- + static rgba from_wavelength(double wl, double gamma = 1.0); + + //-------------------------------------------------------------------- + explicit rgba(double wavelen, double gamma=1.0) + { + *this = from_wavelength(wavelen, gamma); + } + + }; + + inline rgba operator+(const rgba& a, const rgba& b) + { + return rgba(a) += b; + } + + inline rgba operator*(const rgba& a, double b) + { + return rgba(a) *= b; + } + + //------------------------------------------------------------------------ + inline rgba rgba::from_wavelength(double wl, double gamma) + { + rgba t(0.0, 0.0, 0.0); + + if (wl >= 380.0 && wl <= 440.0) + { + t.r = -1.0 * (wl - 440.0) / (440.0 - 380.0); + t.b = 1.0; + } + else if (wl >= 440.0 && wl <= 490.0) + { + t.g = (wl - 440.0) / (490.0 - 440.0); + t.b = 1.0; + } + else if (wl >= 490.0 && wl <= 510.0) + { + t.g = 1.0; + t.b = -1.0 * (wl - 510.0) / (510.0 - 490.0); + } + else if (wl >= 510.0 && wl <= 580.0) + { + t.r = (wl - 510.0) / (580.0 - 510.0); + t.g = 1.0; + } + else if (wl >= 580.0 && wl <= 645.0) + { + t.r = 1.0; + t.g = -1.0 * (wl - 645.0) / (645.0 - 580.0); + } + else if (wl >= 645.0 && wl <= 780.0) + { + t.r = 1.0; + } + + double s = 1.0; + if (wl > 700.0) s = 0.3 + 0.7 * (780.0 - wl) / (780.0 - 700.0); + else if (wl < 420.0) s = 0.3 + 0.7 * (wl - 380.0) / (420.0 - 380.0); + + t.r = pow(t.r * s, gamma); + t.g = pow(t.g * s, gamma); + t.b = pow(t.b * s, gamma); + return t; + } + + inline rgba rgba_pre(double r, double g, double b, double a) + { + return rgba(r, g, b, a).premultiply(); + } + + + //===================================================================rgba8 + template + struct rgba8T + { + typedef int8u value_type; + typedef int32u calc_type; + typedef int32 long_type; + enum base_scale_e + { + base_shift = 8, + base_scale = 1 << base_shift, + base_mask = base_scale - 1, + base_MSB = 1 << (base_shift - 1) + }; + typedef rgba8T self_type; + + + value_type r; + value_type g; + value_type b; + value_type a; + + static void convert(rgba8T& dst, const rgba8T& src) + { + dst.r = sRGB_conv::rgb_from_sRGB(src.r); + dst.g = sRGB_conv::rgb_from_sRGB(src.g); + dst.b = sRGB_conv::rgb_from_sRGB(src.b); + dst.a = src.a; + } + + static void convert(rgba8T& dst, const rgba8T& src) + { + dst.r = sRGB_conv::rgb_to_sRGB(src.r); + dst.g = sRGB_conv::rgb_to_sRGB(src.g); + dst.b = sRGB_conv::rgb_to_sRGB(src.b); + dst.a = src.a; + } + + static void convert(rgba8T& dst, const rgba& src) + { + dst.r = value_type(uround(src.r * base_mask)); + dst.g = value_type(uround(src.g * base_mask)); + dst.b = value_type(uround(src.b * base_mask)); + dst.a = value_type(uround(src.a * base_mask)); + } + + static void convert(rgba8T& dst, const rgba& src) + { + // Use the "float" table. + dst.r = sRGB_conv::rgb_to_sRGB(float(src.r)); + dst.g = sRGB_conv::rgb_to_sRGB(float(src.g)); + dst.b = sRGB_conv::rgb_to_sRGB(float(src.b)); + dst.a = sRGB_conv::alpha_to_sRGB(float(src.a)); + } + + static void convert(rgba& dst, const rgba8T& src) + { + dst.r = src.r / 255.0; + dst.g = src.g / 255.0; + dst.b = src.b / 255.0; + dst.a = src.a / 255.0; + } + + static void convert(rgba& dst, const rgba8T& src) + { + // Use the "float" table. + dst.r = sRGB_conv::rgb_from_sRGB(src.r); + dst.g = sRGB_conv::rgb_from_sRGB(src.g); + dst.b = sRGB_conv::rgb_from_sRGB(src.b); + dst.a = sRGB_conv::alpha_from_sRGB(src.a); + } + + //-------------------------------------------------------------------- + rgba8T() {} + + //-------------------------------------------------------------------- + rgba8T(unsigned r_, unsigned g_, unsigned b_, unsigned a_ = base_mask) : + r(value_type(r_)), + g(value_type(g_)), + b(value_type(b_)), + a(value_type(a_)) {} + + //-------------------------------------------------------------------- + rgba8T(const rgba& c) + { + convert(*this, c); + } + + //-------------------------------------------------------------------- + rgba8T(const self_type& c, unsigned a_) : + r(c.r), g(c.g), b(c.b), a(value_type(a_)) {} + + //-------------------------------------------------------------------- + template + rgba8T(const rgba8T& c) + { + convert(*this, c); + } + + //-------------------------------------------------------------------- + operator rgba() const + { + rgba c; + convert(c, *this); + return c; + } + + //-------------------------------------------------------------------- + static AGG_INLINE double to_double(value_type a) + { + return double(a) / base_mask; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type from_double(double a) + { + return value_type(uround(a * base_mask)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type empty_value() + { + return 0; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type full_value() + { + return base_mask; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_transparent() const + { + return a == 0; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_opaque() const + { + return a == base_mask; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type invert(value_type x) + { + return base_mask - x; + } + + //-------------------------------------------------------------------- + // Fixed-point multiply, exact over int8u. + static AGG_INLINE value_type multiply(value_type a, value_type b) + { + calc_type t = a * b + base_MSB; + return value_type(((t >> base_shift) + t) >> base_shift); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type demultiply(value_type a, value_type b) + { + if (a * b == 0) + { + return 0; + } + else if (a >= b) + { + return base_mask; + } + else return value_type((a * base_mask + (b >> 1)) / b); + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downscale(T a) + { + return a >> base_shift; + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downshift(T a, unsigned n) + { + return a >> n; + } + + //-------------------------------------------------------------------- + // Fixed-point multiply, exact over int8u. + // Specifically for multiplying a color component by a cover. + static AGG_INLINE value_type mult_cover(value_type a, cover_type b) + { + return multiply(a, b); + } + + //-------------------------------------------------------------------- + static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) + { + return multiply(b, a); + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a, assuming q is premultiplied by a. + static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) + { + return p + q - multiply(p, a); + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a. + static AGG_INLINE value_type lerp(value_type p, value_type q, value_type a) + { + int t = (q - p) * a + base_MSB - (p > q); + return value_type(p + (((t >> base_shift) + t) >> base_shift)); + } + + //-------------------------------------------------------------------- + self_type& clear() + { + r = g = b = a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& transparent() + { + a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& opacity(double a_) + { + if (a_ < 0) a = 0; + else if (a_ > 1) a = 1; + else a = (value_type)uround(a_ * double(base_mask)); + return *this; + } + + //-------------------------------------------------------------------- + double opacity() const + { + return double(a) / double(base_mask); + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& premultiply() + { + if (a != base_mask) + { + if (a == 0) + { + r = g = b = 0; + } + else + { + r = multiply(r, a); + g = multiply(g, a); + b = multiply(b, a); + } + } + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& premultiply(unsigned a_) + { + if (a != base_mask || a_ < base_mask) + { + if (a == 0 || a_ == 0) + { + r = g = b = a = 0; + } + else + { + calc_type r_ = (calc_type(r) * a_) / a; + calc_type g_ = (calc_type(g) * a_) / a; + calc_type b_ = (calc_type(b) * a_) / a; + r = value_type((r_ > a_) ? a_ : r_); + g = value_type((g_ > a_) ? a_ : g_); + b = value_type((b_ > a_) ? a_ : b_); + a = value_type(a_); + } + } + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& demultiply() + { + if (a < base_mask) + { + if (a == 0) + { + r = g = b = 0; + } + else + { + calc_type r_ = (calc_type(r) * base_mask) / a; + calc_type g_ = (calc_type(g) * base_mask) / a; + calc_type b_ = (calc_type(b) * base_mask) / a; + r = value_type((r_ > calc_type(base_mask)) ? calc_type(base_mask) : r_); + g = value_type((g_ > calc_type(base_mask)) ? calc_type(base_mask) : g_); + b = value_type((b_ > calc_type(base_mask)) ? calc_type(base_mask) : b_); + } + } + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type gradient(const self_type& c, double k) const + { + self_type ret; + calc_type ik = uround(k * base_mask); + ret.r = lerp(r, c.r, ik); + ret.g = lerp(g, c.g, ik); + ret.b = lerp(b, c.b, ik); + ret.a = lerp(a, c.a, ik); + return ret; + } + + //-------------------------------------------------------------------- + AGG_INLINE void add(const self_type& c, unsigned cover) + { + calc_type cr, cg, cb, ca; + if (cover == cover_mask) + { + if (c.a == base_mask) + { + *this = c; + return; + } + else + { + cr = r + c.r; + cg = g + c.g; + cb = b + c.b; + ca = a + c.a; + } + } + else + { + cr = r + mult_cover(c.r, cover); + cg = g + mult_cover(c.g, cover); + cb = b + mult_cover(c.b, cover); + ca = a + mult_cover(c.a, cover); + } + r = (value_type)((cr > calc_type(base_mask)) ? calc_type(base_mask) : cr); + g = (value_type)((cg > calc_type(base_mask)) ? calc_type(base_mask) : cg); + b = (value_type)((cb > calc_type(base_mask)) ? calc_type(base_mask) : cb); + a = (value_type)((ca > calc_type(base_mask)) ? calc_type(base_mask) : ca); + } + + //-------------------------------------------------------------------- + template + AGG_INLINE void apply_gamma_dir(const GammaLUT& gamma) + { + r = gamma.dir(r); + g = gamma.dir(g); + b = gamma.dir(b); + } + + //-------------------------------------------------------------------- + template + AGG_INLINE void apply_gamma_inv(const GammaLUT& gamma) + { + r = gamma.inv(r); + g = gamma.inv(g); + b = gamma.inv(b); + } + + //-------------------------------------------------------------------- + static self_type no_color() { return self_type(0,0,0,0); } + + //-------------------------------------------------------------------- + static self_type from_wavelength(double wl, double gamma = 1.0) + { + return self_type(rgba::from_wavelength(wl, gamma)); + } + }; + + typedef rgba8T rgba8; + typedef rgba8T srgba8; + + + //-------------------------------------------------------------rgb8_packed + inline rgba8 rgb8_packed(unsigned v) + { + return rgba8((v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); + } + + //-------------------------------------------------------------bgr8_packed + inline rgba8 bgr8_packed(unsigned v) + { + return rgba8(v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF); + } + + //------------------------------------------------------------argb8_packed + inline rgba8 argb8_packed(unsigned v) + { + return rgba8((v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF, v >> 24); + } + + //---------------------------------------------------------rgba8_gamma_dir + template + rgba8 rgba8_gamma_dir(rgba8 c, const GammaLUT& gamma) + { + return rgba8(gamma.dir(c.r), gamma.dir(c.g), gamma.dir(c.b), c.a); + } + + //---------------------------------------------------------rgba8_gamma_inv + template + rgba8 rgba8_gamma_inv(rgba8 c, const GammaLUT& gamma) + { + return rgba8(gamma.inv(c.r), gamma.inv(c.g), gamma.inv(c.b), c.a); + } + + + + //==================================================================rgba16 + struct rgba16 + { + typedef int16u value_type; + typedef int32u calc_type; + typedef int64 long_type; + enum base_scale_e + { + base_shift = 16, + base_scale = 1 << base_shift, + base_mask = base_scale - 1, + base_MSB = 1 << (base_shift - 1) + }; + typedef rgba16 self_type; + + value_type r; + value_type g; + value_type b; + value_type a; + + //-------------------------------------------------------------------- + rgba16() {} + + //-------------------------------------------------------------------- + rgba16(unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask) : + r(value_type(r_)), + g(value_type(g_)), + b(value_type(b_)), + a(value_type(a_)) {} + + //-------------------------------------------------------------------- + rgba16(const self_type& c, unsigned a_) : + r(c.r), g(c.g), b(c.b), a(value_type(a_)) {} + + //-------------------------------------------------------------------- + rgba16(const rgba& c) : + r((value_type)uround(c.r * double(base_mask))), + g((value_type)uround(c.g * double(base_mask))), + b((value_type)uround(c.b * double(base_mask))), + a((value_type)uround(c.a * double(base_mask))) {} + + //-------------------------------------------------------------------- + rgba16(const rgba8& c) : + r(value_type((value_type(c.r) << 8) | c.r)), + g(value_type((value_type(c.g) << 8) | c.g)), + b(value_type((value_type(c.b) << 8) | c.b)), + a(value_type((value_type(c.a) << 8) | c.a)) {} + + //-------------------------------------------------------------------- + rgba16(const srgba8& c) : + r(sRGB_conv::rgb_from_sRGB(c.r)), + g(sRGB_conv::rgb_from_sRGB(c.g)), + b(sRGB_conv::rgb_from_sRGB(c.b)), + a(sRGB_conv::alpha_from_sRGB(c.a)) {} + + //-------------------------------------------------------------------- + operator rgba() const + { + return rgba( + r / 65535.0, + g / 65535.0, + b / 65535.0, + a / 65535.0); + } + + //-------------------------------------------------------------------- + operator rgba8() const + { + return rgba8(r >> 8, g >> 8, b >> 8, a >> 8); + } + + //-------------------------------------------------------------------- + operator srgba8() const + { + // Return (non-premultiplied) sRGB values. + return srgba8( + sRGB_conv::rgb_to_sRGB(r), + sRGB_conv::rgb_to_sRGB(g), + sRGB_conv::rgb_to_sRGB(b), + sRGB_conv::alpha_to_sRGB(a)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE double to_double(value_type a) + { + return double(a) / base_mask; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type from_double(double a) + { + return value_type(uround(a * base_mask)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type empty_value() + { + return 0; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type full_value() + { + return base_mask; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_transparent() const + { + return a == 0; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_opaque() const + { + return a == base_mask; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type invert(value_type x) + { + return base_mask - x; + } + + //-------------------------------------------------------------------- + // Fixed-point multiply, exact over int16u. + static AGG_INLINE value_type multiply(value_type a, value_type b) + { + calc_type t = a * b + base_MSB; + return value_type(((t >> base_shift) + t) >> base_shift); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type demultiply(value_type a, value_type b) + { + if (a * b == 0) + { + return 0; + } + else if (a >= b) + { + return base_mask; + } + else return value_type((a * base_mask + (b >> 1)) / b); + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downscale(T a) + { + return a >> base_shift; + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downshift(T a, unsigned n) + { + return a >> n; + } + + //-------------------------------------------------------------------- + // Fixed-point multiply, almost exact over int16u. + // Specifically for multiplying a color component by a cover. + static AGG_INLINE value_type mult_cover(value_type a, cover_type b) + { + return multiply(a, (b << 8) | b); + } + + //-------------------------------------------------------------------- + static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) + { + return multiply((a << 8) | a, b) >> 8; + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a, assuming q is premultiplied by a. + static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) + { + return p + q - multiply(p, a); + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a. + static AGG_INLINE value_type lerp(value_type p, value_type q, value_type a) + { + int t = (q - p) * a + base_MSB - (p > q); + return value_type(p + (((t >> base_shift) + t) >> base_shift)); + } + + //-------------------------------------------------------------------- + self_type& clear() + { + r = g = b = a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& transparent() + { + a = 0; + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& opacity(double a_) + { + if (a_ < 0) a = 0; + if (a_ > 1) a = 1; + a = value_type(uround(a_ * double(base_mask))); + return *this; + } + + //-------------------------------------------------------------------- + double opacity() const + { + return double(a) / double(base_mask); + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& premultiply() + { + if (a != base_mask) + { + if (a == 0) + { + r = g = b = 0; + } + else + { + r = multiply(r, a); + g = multiply(g, a); + b = multiply(b, a); + } + } + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& premultiply(unsigned a_) + { + if (a < base_mask || a_ < base_mask) + { + if (a == 0 || a_ == 0) + { + r = g = b = a = 0; + } + else + { + calc_type r_ = (calc_type(r) * a_) / a; + calc_type g_ = (calc_type(g) * a_) / a; + calc_type b_ = (calc_type(b) * a_) / a; + r = value_type((r_ > a_) ? a_ : r_); + g = value_type((g_ > a_) ? a_ : g_); + b = value_type((b_ > a_) ? a_ : b_); + a = value_type(a_); + } + } + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& demultiply() + { + if (a < base_mask) + { + if (a == 0) + { + r = g = b = 0; + } + else + { + calc_type r_ = (calc_type(r) * base_mask) / a; + calc_type g_ = (calc_type(g) * base_mask) / a; + calc_type b_ = (calc_type(b) * base_mask) / a; + r = value_type((r_ > calc_type(base_mask)) ? calc_type(base_mask) : r_); + g = value_type((g_ > calc_type(base_mask)) ? calc_type(base_mask) : g_); + b = value_type((b_ > calc_type(base_mask)) ? calc_type(base_mask) : b_); + } + } + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type gradient(const self_type& c, double k) const + { + self_type ret; + calc_type ik = uround(k * base_mask); + ret.r = lerp(r, c.r, ik); + ret.g = lerp(g, c.g, ik); + ret.b = lerp(b, c.b, ik); + ret.a = lerp(a, c.a, ik); + return ret; + } + + //-------------------------------------------------------------------- + AGG_INLINE void add(const self_type& c, unsigned cover) + { + calc_type cr, cg, cb, ca; + if (cover == cover_mask) + { + if (c.a == base_mask) + { + *this = c; + return; + } + else + { + cr = r + c.r; + cg = g + c.g; + cb = b + c.b; + ca = a + c.a; + } + } + else + { + cr = r + mult_cover(c.r, cover); + cg = g + mult_cover(c.g, cover); + cb = b + mult_cover(c.b, cover); + ca = a + mult_cover(c.a, cover); + } + r = (value_type)((cr > calc_type(base_mask)) ? calc_type(base_mask) : cr); + g = (value_type)((cg > calc_type(base_mask)) ? calc_type(base_mask) : cg); + b = (value_type)((cb > calc_type(base_mask)) ? calc_type(base_mask) : cb); + a = (value_type)((ca > calc_type(base_mask)) ? calc_type(base_mask) : ca); + } + + //-------------------------------------------------------------------- + template + AGG_INLINE void apply_gamma_dir(const GammaLUT& gamma) + { + r = gamma.dir(r); + g = gamma.dir(g); + b = gamma.dir(b); + } + + //-------------------------------------------------------------------- + template + AGG_INLINE void apply_gamma_inv(const GammaLUT& gamma) + { + r = gamma.inv(r); + g = gamma.inv(g); + b = gamma.inv(b); + } + + //-------------------------------------------------------------------- + static self_type no_color() { return self_type(0,0,0,0); } + + //-------------------------------------------------------------------- + static self_type from_wavelength(double wl, double gamma = 1.0) + { + return self_type(rgba::from_wavelength(wl, gamma)); + } + }; + + + //------------------------------------------------------rgba16_gamma_dir + template + rgba16 rgba16_gamma_dir(rgba16 c, const GammaLUT& gamma) + { + return rgba16(gamma.dir(c.r), gamma.dir(c.g), gamma.dir(c.b), c.a); + } + + //------------------------------------------------------rgba16_gamma_inv + template + rgba16 rgba16_gamma_inv(rgba16 c, const GammaLUT& gamma) + { + return rgba16(gamma.inv(c.r), gamma.inv(c.g), gamma.inv(c.b), c.a); + } + + //====================================================================rgba32 + struct rgba32 + { + typedef float value_type; + typedef double calc_type; + typedef double long_type; + typedef rgba32 self_type; + + value_type r; + value_type g; + value_type b; + value_type a; + + //-------------------------------------------------------------------- + rgba32() {} + + //-------------------------------------------------------------------- + rgba32(value_type r_, value_type g_, value_type b_, value_type a_= 1) : + r(r_), g(g_), b(b_), a(a_) {} + + //-------------------------------------------------------------------- + rgba32(const self_type& c, float a_) : + r(c.r), g(c.g), b(c.b), a(a_) {} + + //-------------------------------------------------------------------- + rgba32(const rgba& c) : + r(value_type(c.r)), g(value_type(c.g)), b(value_type(c.b)), a(value_type(c.a)) {} + + //-------------------------------------------------------------------- + rgba32(const rgba8& c) : + r(value_type(c.r / 255.0)), + g(value_type(c.g / 255.0)), + b(value_type(c.b / 255.0)), + a(value_type(c.a / 255.0)) {} + + //-------------------------------------------------------------------- + rgba32(const srgba8& c) : + r(sRGB_conv::rgb_from_sRGB(c.r)), + g(sRGB_conv::rgb_from_sRGB(c.g)), + b(sRGB_conv::rgb_from_sRGB(c.b)), + a(sRGB_conv::alpha_from_sRGB(c.a)) {} + + //-------------------------------------------------------------------- + rgba32(const rgba16& c) : + r(value_type(c.r / 65535.0)), + g(value_type(c.g / 65535.0)), + b(value_type(c.b / 65535.0)), + a(value_type(c.a / 65535.0)) {} + + //-------------------------------------------------------------------- + operator rgba() const + { + return rgba(r, g, b, a); + } + + //-------------------------------------------------------------------- + operator rgba8() const + { + return rgba8( + uround(r * 255.0), + uround(g * 255.0), + uround(b * 255.0), + uround(a * 255.0)); + } + + //-------------------------------------------------------------------- + operator srgba8() const + { + return srgba8( + sRGB_conv::rgb_to_sRGB(r), + sRGB_conv::rgb_to_sRGB(g), + sRGB_conv::rgb_to_sRGB(b), + sRGB_conv::alpha_to_sRGB(a)); + } + + //-------------------------------------------------------------------- + operator rgba16() const + { + return rgba8( + uround(r * 65535.0), + uround(g * 65535.0), + uround(b * 65535.0), + uround(a * 65535.0)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE double to_double(value_type a) + { + return a; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type from_double(double a) + { + return value_type(a); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type empty_value() + { + return 0; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type full_value() + { + return 1; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_transparent() const + { + return a <= 0; + } + + //-------------------------------------------------------------------- + AGG_INLINE bool is_opaque() const + { + return a >= 1; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type invert(value_type x) + { + return 1 - x; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type multiply(value_type a, value_type b) + { + return value_type(a * b); + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type demultiply(value_type a, value_type b) + { + return (b == 0) ? 0 : value_type(a / b); + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downscale(T a) + { + return a; + } + + //-------------------------------------------------------------------- + template + static AGG_INLINE T downshift(T a, unsigned n) + { + return n > 0 ? a / (1 << n) : a; + } + + //-------------------------------------------------------------------- + static AGG_INLINE value_type mult_cover(value_type a, cover_type b) + { + return value_type(a * b / cover_mask); + } + + //-------------------------------------------------------------------- + static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) + { + return cover_type(uround(a * b)); + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a, assuming q is premultiplied by a. + static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) + { + return (1 - a) * p + q; // more accurate than "p + q - p * a" + } + + //-------------------------------------------------------------------- + // Interpolate p to q by a. + static AGG_INLINE value_type lerp(value_type p, value_type q, value_type a) + { + // The form "p + a * (q - p)" avoids a multiplication, but may produce an + // inaccurate result. For example, "p + (q - p)" may not be exactly equal + // to q. Therefore, stick to the basic expression, which at least produces + // the correct result at either extreme. + return (1 - a) * p + a * q; + } + + //-------------------------------------------------------------------- + self_type& clear() + { + r = g = b = a = 0; + return *this; + } + + //-------------------------------------------------------------------- + self_type& transparent() + { + a = 0; + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& opacity(double a_) + { + if (a_ < 0) a = 0; + else if (a_ > 1) a = 1; + else a = value_type(a_); + return *this; + } + + //-------------------------------------------------------------------- + double opacity() const + { + return a; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& premultiply() + { + if (a < 1) + { + if (a <= 0) + { + r = g = b = 0; + } + else + { + r *= a; + g *= a; + b *= a; + } + } + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type& demultiply() + { + if (a < 1) + { + if (a <= 0) + { + r = g = b = 0; + } + else + { + r /= a; + g /= a; + b /= a; + } + } + return *this; + } + + //-------------------------------------------------------------------- + AGG_INLINE self_type gradient(const self_type& c, double k) const + { + self_type ret; + ret.r = value_type(r + (c.r - r) * k); + ret.g = value_type(g + (c.g - g) * k); + ret.b = value_type(b + (c.b - b) * k); + ret.a = value_type(a + (c.a - a) * k); + return ret; + } + + //-------------------------------------------------------------------- + AGG_INLINE void add(const self_type& c, unsigned cover) + { + if (cover == cover_mask) + { + if (c.is_opaque()) + { + *this = c; + return; + } + else + { + r += c.r; + g += c.g; + b += c.b; + a += c.a; + } + } + else + { + r += mult_cover(c.r, cover); + g += mult_cover(c.g, cover); + b += mult_cover(c.b, cover); + a += mult_cover(c.a, cover); + } + if (a > 1) a = 1; + if (r > a) r = a; + if (g > a) g = a; + if (b > a) b = a; + } + + //-------------------------------------------------------------------- + template + AGG_INLINE void apply_gamma_dir(const GammaLUT& gamma) + { + r = gamma.dir(r); + g = gamma.dir(g); + b = gamma.dir(b); + } + + //-------------------------------------------------------------------- + template + AGG_INLINE void apply_gamma_inv(const GammaLUT& gamma) + { + r = gamma.inv(r); + g = gamma.inv(g); + b = gamma.inv(b); + } + + //-------------------------------------------------------------------- + static self_type no_color() { return self_type(0,0,0,0); } + + //-------------------------------------------------------------------- + static self_type from_wavelength(double wl, double gamma = 1) + { + return self_type(rgba::from_wavelength(wl, gamma)); + } + }; +} + + + +#endif diff --git a/xs/src/agg/agg_config.h b/xs/src/agg/agg_config.h new file mode 100644 index 0000000000..fa1dae2ba7 --- /dev/null +++ b/xs/src/agg/agg_config.h @@ -0,0 +1,44 @@ +#ifndef AGG_CONFIG_INCLUDED +#define AGG_CONFIG_INCLUDED + +// This file can be used to redefine certain data types. + +//--------------------------------------- +// 1. Default basic types such as: +// +// AGG_INT8 +// AGG_INT8U +// AGG_INT16 +// AGG_INT16U +// AGG_INT32 +// AGG_INT32U +// AGG_INT64 +// AGG_INT64U +// +// Just replace this file with new defines if necessary. +// For example, if your compiler doesn't have a 64 bit integer type +// you can still use AGG if you define the follows: +// +// #define AGG_INT64 int +// #define AGG_INT64U unsigned +// +// It will result in overflow in 16 bit-per-component image/pattern resampling +// but it won't result any crash and the rest of the library will remain +// fully functional. + + +//--------------------------------------- +// 2. Default rendering_buffer type. Can be: +// +// Provides faster access for massive pixel operations, +// such as blur, image filtering: +// #define AGG_RENDERING_BUFFER row_ptr_cache +// +// Provides cheaper creation and destruction (no mem allocs): +// #define AGG_RENDERING_BUFFER row_accessor +// +// You can still use both of them simultaneously in your applications +// This #define is used only for default rendering_buffer type, +// in short hand typedefs like pixfmt_rgba32. + +#endif diff --git a/xs/src/agg/agg_conv_adaptor_vcgen.h b/xs/src/agg/agg_conv_adaptor_vcgen.h new file mode 100644 index 0000000000..a79f2208c6 --- /dev/null +++ b/xs/src/agg/agg_conv_adaptor_vcgen.h @@ -0,0 +1,157 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_ADAPTOR_VCGEN_INCLUDED +#define AGG_CONV_ADAPTOR_VCGEN_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + //------------------------------------------------------------null_markers + struct null_markers + { + void remove_all() {} + void add_vertex(double, double, unsigned) {} + void prepare_src() {} + + void rewind(unsigned) {} + unsigned vertex(double*, double*) { return path_cmd_stop; } + }; + + + //------------------------------------------------------conv_adaptor_vcgen + template class conv_adaptor_vcgen + { + enum status + { + initial, + accumulate, + generate + }; + + public: + explicit conv_adaptor_vcgen(VertexSource& source) : + m_source(&source), + m_status(initial) + {} + void attach(VertexSource& source) { m_source = &source; } + + Generator& generator() { return m_generator; } + const Generator& generator() const { return m_generator; } + + Markers& markers() { return m_markers; } + const Markers& markers() const { return m_markers; } + + void rewind(unsigned path_id) + { + m_source->rewind(path_id); + m_status = initial; + } + + unsigned vertex(double* x, double* y); + + private: + // Prohibit copying + conv_adaptor_vcgen(const conv_adaptor_vcgen&); + const conv_adaptor_vcgen& + operator = (const conv_adaptor_vcgen&); + + VertexSource* m_source; + Generator m_generator; + Markers m_markers; + status m_status; + unsigned m_last_cmd; + double m_start_x; + double m_start_y; + }; + + + + + + //------------------------------------------------------------------------ + template + unsigned conv_adaptor_vcgen::vertex(double* x, double* y) + { + unsigned cmd = path_cmd_stop; + bool done = false; + while(!done) + { + switch(m_status) + { + case initial: + m_markers.remove_all(); + m_last_cmd = m_source->vertex(&m_start_x, &m_start_y); + m_status = accumulate; + + case accumulate: + if(is_stop(m_last_cmd)) return path_cmd_stop; + + m_generator.remove_all(); + m_generator.add_vertex(m_start_x, m_start_y, path_cmd_move_to); + m_markers.add_vertex(m_start_x, m_start_y, path_cmd_move_to); + + for(;;) + { + cmd = m_source->vertex(x, y); + if(is_vertex(cmd)) + { + m_last_cmd = cmd; + if(is_move_to(cmd)) + { + m_start_x = *x; + m_start_y = *y; + break; + } + m_generator.add_vertex(*x, *y, cmd); + m_markers.add_vertex(*x, *y, path_cmd_line_to); + } + else + { + if(is_stop(cmd)) + { + m_last_cmd = path_cmd_stop; + break; + } + if(is_end_poly(cmd)) + { + m_generator.add_vertex(*x, *y, cmd); + break; + } + } + } + m_generator.rewind(0); + m_status = generate; + + case generate: + cmd = m_generator.vertex(x, y); + if(is_stop(cmd)) + { + m_status = accumulate; + break; + } + done = true; + break; + } + } + return cmd; + } + +} + +#endif diff --git a/xs/src/agg/agg_conv_adaptor_vpgen.h b/xs/src/agg/agg_conv_adaptor_vpgen.h new file mode 100644 index 0000000000..d6b545ef1f --- /dev/null +++ b/xs/src/agg/agg_conv_adaptor_vpgen.h @@ -0,0 +1,159 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_ADAPTOR_VPGEN_INCLUDED +#define AGG_CONV_ADAPTOR_VPGEN_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //======================================================conv_adaptor_vpgen + template class conv_adaptor_vpgen + { + public: + explicit conv_adaptor_vpgen(VertexSource& source) : m_source(&source) {} + void attach(VertexSource& source) { m_source = &source; } + + VPGen& vpgen() { return m_vpgen; } + const VPGen& vpgen() const { return m_vpgen; } + + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + conv_adaptor_vpgen(const conv_adaptor_vpgen&); + const conv_adaptor_vpgen& + operator = (const conv_adaptor_vpgen&); + + VertexSource* m_source; + VPGen m_vpgen; + double m_start_x; + double m_start_y; + unsigned m_poly_flags; + int m_vertices; + }; + + + + //------------------------------------------------------------------------ + template + void conv_adaptor_vpgen::rewind(unsigned path_id) + { + m_source->rewind(path_id); + m_vpgen.reset(); + m_start_x = 0; + m_start_y = 0; + m_poly_flags = 0; + m_vertices = 0; + } + + + //------------------------------------------------------------------------ + template + unsigned conv_adaptor_vpgen::vertex(double* x, double* y) + { + unsigned cmd = path_cmd_stop; + for(;;) + { + cmd = m_vpgen.vertex(x, y); + if(!is_stop(cmd)) break; + + if(m_poly_flags && !m_vpgen.auto_unclose()) + { + *x = 0.0; + *y = 0.0; + cmd = m_poly_flags; + m_poly_flags = 0; + break; + } + + if(m_vertices < 0) + { + if(m_vertices < -1) + { + m_vertices = 0; + return path_cmd_stop; + } + m_vpgen.move_to(m_start_x, m_start_y); + m_vertices = 1; + continue; + } + + double tx, ty; + cmd = m_source->vertex(&tx, &ty); + if(is_vertex(cmd)) + { + if(is_move_to(cmd)) + { + if(m_vpgen.auto_close() && m_vertices > 2) + { + m_vpgen.line_to(m_start_x, m_start_y); + m_poly_flags = path_cmd_end_poly | path_flags_close; + m_start_x = tx; + m_start_y = ty; + m_vertices = -1; + continue; + } + m_vpgen.move_to(tx, ty); + m_start_x = tx; + m_start_y = ty; + m_vertices = 1; + } + else + { + m_vpgen.line_to(tx, ty); + ++m_vertices; + } + } + else + { + if(is_end_poly(cmd)) + { + m_poly_flags = cmd; + if(is_closed(cmd) || m_vpgen.auto_close()) + { + if(m_vpgen.auto_close()) m_poly_flags |= path_flags_close; + if(m_vertices > 2) + { + m_vpgen.line_to(m_start_x, m_start_y); + } + m_vertices = 0; + } + } + else + { + // path_cmd_stop + if(m_vpgen.auto_close() && m_vertices > 2) + { + m_vpgen.line_to(m_start_x, m_start_y); + m_poly_flags = path_cmd_end_poly | path_flags_close; + m_vertices = -2; + continue; + } + break; + } + } + } + return cmd; + } + + +} + + +#endif + diff --git a/xs/src/agg/agg_conv_bspline.h b/xs/src/agg/agg_conv_bspline.h new file mode 100644 index 0000000000..13d22d9297 --- /dev/null +++ b/xs/src/agg/agg_conv_bspline.h @@ -0,0 +1,48 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_BSPLINE_INCLUDED +#define AGG_CONV_BSPLINE_INCLUDED + +#include "agg_basics.h" +#include "agg_vcgen_bspline.h" +#include "agg_conv_adaptor_vcgen.h" + + +namespace agg +{ + + //---------------------------------------------------------conv_bspline + template + struct conv_bspline : public conv_adaptor_vcgen + { + typedef conv_adaptor_vcgen base_type; + + conv_bspline(VertexSource& vs) : + conv_adaptor_vcgen(vs) {} + + void interpolation_step(double v) { base_type::generator().interpolation_step(v); } + double interpolation_step() const { return base_type::generator().interpolation_step(); } + + private: + conv_bspline(const conv_bspline&); + const conv_bspline& + operator = (const conv_bspline&); + }; + +} + + +#endif + diff --git a/xs/src/agg/agg_conv_clip_polygon.h b/xs/src/agg/agg_conv_clip_polygon.h new file mode 100644 index 0000000000..87537638dc --- /dev/null +++ b/xs/src/agg/agg_conv_clip_polygon.h @@ -0,0 +1,63 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Polygon clipping converter +// There an optimized Liang-Basky algorithm is used. +// The algorithm doesn't optimize the degenerate edges, i.e. it will never +// break a closed polygon into two or more ones, instead, there will be +// degenerate edges coinciding with the respective clipping boundaries. +// This is a sub-optimal solution, because that optimization would require +// extra, rather expensive math while the rasterizer tolerates it quite well, +// without any considerable overhead. +// +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_CLIP_POLYGON_INCLUDED +#define AGG_CONV_CLIP_POLYGON_INCLUDED + +#include "agg_basics.h" +#include "agg_conv_adaptor_vpgen.h" +#include "agg_vpgen_clip_polygon.h" + +namespace agg +{ + + //=======================================================conv_clip_polygon + template + struct conv_clip_polygon : public conv_adaptor_vpgen + { + typedef conv_adaptor_vpgen base_type; + + conv_clip_polygon(VertexSource& vs) : + conv_adaptor_vpgen(vs) {} + + void clip_box(double x1, double y1, double x2, double y2) + { + base_type::vpgen().clip_box(x1, y1, x2, y2); + } + + double x1() const { return base_type::vpgen().x1(); } + double y1() const { return base_type::vpgen().y1(); } + double x2() const { return base_type::vpgen().x2(); } + double y2() const { return base_type::vpgen().y2(); } + + private: + conv_clip_polygon(const conv_clip_polygon&); + const conv_clip_polygon& + operator = (const conv_clip_polygon&); + }; + +} + +#endif diff --git a/xs/src/agg/agg_conv_clip_polyline.h b/xs/src/agg/agg_conv_clip_polyline.h new file mode 100644 index 0000000000..f3fc2888c2 --- /dev/null +++ b/xs/src/agg/agg_conv_clip_polyline.h @@ -0,0 +1,63 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// polyline clipping converter +// There an optimized Liang-Basky algorithm is used. +// The algorithm doesn't optimize the degenerate edges, i.e. it will never +// break a closed polyline into two or more ones, instead, there will be +// degenerate edges coinciding with the respective clipping boundaries. +// This is a sub-optimal solution, because that optimization would require +// extra, rather expensive math while the rasterizer tolerates it quite well, +// without any considerable overhead. +// +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_CLIP_polyline_INCLUDED +#define AGG_CONV_CLIP_polyline_INCLUDED + +#include "agg_basics.h" +#include "agg_conv_adaptor_vpgen.h" +#include "agg_vpgen_clip_polyline.h" + +namespace agg +{ + + //=======================================================conv_clip_polyline + template + struct conv_clip_polyline : public conv_adaptor_vpgen + { + typedef conv_adaptor_vpgen base_type; + + conv_clip_polyline(VertexSource& vs) : + conv_adaptor_vpgen(vs) {} + + void clip_box(double x1, double y1, double x2, double y2) + { + base_type::vpgen().clip_box(x1, y1, x2, y2); + } + + double x1() const { return base_type::vpgen().x1(); } + double y1() const { return base_type::vpgen().y1(); } + double x2() const { return base_type::vpgen().x2(); } + double y2() const { return base_type::vpgen().y2(); } + + private: + conv_clip_polyline(const conv_clip_polyline&); + const conv_clip_polyline& + operator = (const conv_clip_polyline&); + }; + +} + +#endif diff --git a/xs/src/agg/agg_conv_close_polygon.h b/xs/src/agg/agg_conv_close_polygon.h new file mode 100644 index 0000000000..c46594fdfb --- /dev/null +++ b/xs/src/agg/agg_conv_close_polygon.h @@ -0,0 +1,125 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_CLOSE_POLYGON_INCLUDED +#define AGG_CONV_CLOSE_POLYGON_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //======================================================conv_close_polygon + template class conv_close_polygon + { + public: + explicit conv_close_polygon(VertexSource& vs) : m_source(&vs) {} + void attach(VertexSource& source) { m_source = &source; } + + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + conv_close_polygon(const conv_close_polygon&); + const conv_close_polygon& + operator = (const conv_close_polygon&); + + VertexSource* m_source; + unsigned m_cmd[2]; + double m_x[2]; + double m_y[2]; + unsigned m_vertex; + bool m_line_to; + }; + + + + //------------------------------------------------------------------------ + template + void conv_close_polygon::rewind(unsigned path_id) + { + m_source->rewind(path_id); + m_vertex = 2; + m_line_to = false; + } + + + + //------------------------------------------------------------------------ + template + unsigned conv_close_polygon::vertex(double* x, double* y) + { + unsigned cmd = path_cmd_stop; + for(;;) + { + if(m_vertex < 2) + { + *x = m_x[m_vertex]; + *y = m_y[m_vertex]; + cmd = m_cmd[m_vertex]; + ++m_vertex; + break; + } + + cmd = m_source->vertex(x, y); + + if(is_end_poly(cmd)) + { + cmd |= path_flags_close; + break; + } + + if(is_stop(cmd)) + { + if(m_line_to) + { + m_cmd[0] = path_cmd_end_poly | path_flags_close; + m_cmd[1] = path_cmd_stop; + m_vertex = 0; + m_line_to = false; + continue; + } + break; + } + + if(is_move_to(cmd)) + { + if(m_line_to) + { + m_x[0] = 0.0; + m_y[0] = 0.0; + m_cmd[0] = path_cmd_end_poly | path_flags_close; + m_x[1] = *x; + m_y[1] = *y; + m_cmd[1] = cmd; + m_vertex = 0; + m_line_to = false; + continue; + } + break; + } + + if(is_vertex(cmd)) + { + m_line_to = true; + break; + } + } + return cmd; + } + +} + +#endif diff --git a/xs/src/agg/agg_conv_concat.h b/xs/src/agg/agg_conv_concat.h new file mode 100644 index 0000000000..745d349c6f --- /dev/null +++ b/xs/src/agg/agg_conv_concat.h @@ -0,0 +1,73 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_CONCAT_INCLUDED +#define AGG_CONV_CONCAT_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + //=============================================================conv_concat + // Concatenation of two paths. Usually used to combine lines or curves + // with markers such as arrowheads + template class conv_concat + { + public: + conv_concat(VS1& source1, VS2& source2) : + m_source1(&source1), m_source2(&source2), m_status(2) {} + void attach1(VS1& source) { m_source1 = &source; } + void attach2(VS2& source) { m_source2 = &source; } + + + void rewind(unsigned path_id) + { + m_source1->rewind(path_id); + m_source2->rewind(0); + m_status = 0; + } + + unsigned vertex(double* x, double* y) + { + unsigned cmd; + if(m_status == 0) + { + cmd = m_source1->vertex(x, y); + if(!is_stop(cmd)) return cmd; + m_status = 1; + } + if(m_status == 1) + { + cmd = m_source2->vertex(x, y); + if(!is_stop(cmd)) return cmd; + m_status = 2; + } + return path_cmd_stop; + } + + private: + conv_concat(const conv_concat&); + const conv_concat& + operator = (const conv_concat&); + + VS1* m_source1; + VS2* m_source2; + int m_status; + + }; +} + + +#endif diff --git a/xs/src/agg/agg_conv_contour.h b/xs/src/agg/agg_conv_contour.h new file mode 100644 index 0000000000..b4b5a9047e --- /dev/null +++ b/xs/src/agg/agg_conv_contour.h @@ -0,0 +1,65 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// conv_stroke +// +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_CONTOUR_INCLUDED +#define AGG_CONV_CONTOUR_INCLUDED + +#include "agg_basics.h" +#include "agg_vcgen_contour.h" +#include "agg_conv_adaptor_vcgen.h" + +namespace agg +{ + + //-----------------------------------------------------------conv_contour + template + struct conv_contour : public conv_adaptor_vcgen + { + typedef conv_adaptor_vcgen base_type; + + conv_contour(VertexSource& vs) : + conv_adaptor_vcgen(vs) + { + } + + void line_join(line_join_e lj) { base_type::generator().line_join(lj); } + void inner_join(inner_join_e ij) { base_type::generator().inner_join(ij); } + void width(double w) { base_type::generator().width(w); } + void miter_limit(double ml) { base_type::generator().miter_limit(ml); } + void miter_limit_theta(double t) { base_type::generator().miter_limit_theta(t); } + void inner_miter_limit(double ml) { base_type::generator().inner_miter_limit(ml); } + void approximation_scale(double as) { base_type::generator().approximation_scale(as); } + void auto_detect_orientation(bool v) { base_type::generator().auto_detect_orientation(v); } + + line_join_e line_join() const { return base_type::generator().line_join(); } + inner_join_e inner_join() const { return base_type::generator().inner_join(); } + double width() const { return base_type::generator().width(); } + double miter_limit() const { return base_type::generator().miter_limit(); } + double inner_miter_limit() const { return base_type::generator().inner_miter_limit(); } + double approximation_scale() const { return base_type::generator().approximation_scale(); } + bool auto_detect_orientation() const { return base_type::generator().auto_detect_orientation(); } + + private: + conv_contour(const conv_contour&); + const conv_contour& + operator = (const conv_contour&); + }; + +} + +#endif diff --git a/xs/src/agg/agg_conv_curve.h b/xs/src/agg/agg_conv_curve.h new file mode 100644 index 0000000000..0be3b6fd74 --- /dev/null +++ b/xs/src/agg/agg_conv_curve.h @@ -0,0 +1,201 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// classes conv_curve +// +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_CURVE_INCLUDED +#define AGG_CONV_CURVE_INCLUDED + +#include "agg_basics.h" +#include "agg_curves.h" + +namespace agg +{ + + + //---------------------------------------------------------------conv_curve + // Curve converter class. Any path storage can have Bezier curves defined + // by their control points. There're two types of curves supported: curve3 + // and curve4. Curve3 is a conic Bezier curve with 2 endpoints and 1 control + // point. Curve4 has 2 control points (4 points in total) and can be used + // to interpolate more complicated curves. Curve4, unlike curve3 can be used + // to approximate arcs, both circular and elliptical. Curves are approximated + // with straight lines and one of the approaches is just to store the whole + // sequence of vertices that approximate our curve. It takes additional + // memory, and at the same time the consecutive vertices can be calculated + // on demand. + // + // Initially, path storages are not suppose to keep all the vertices of the + // curves (although, nothing prevents us from doing so). Instead, path_storage + // keeps only vertices, needed to calculate a curve on demand. Those vertices + // are marked with special commands. So, if the path_storage contains curves + // (which are not real curves yet), and we render this storage directly, + // all we will see is only 2 or 3 straight line segments (for curve3 and + // curve4 respectively). If we need to see real curves drawn we need to + // include this class into the conversion pipeline. + // + // Class conv_curve recognizes commands path_cmd_curve3 and path_cmd_curve4 + // and converts these vertices into a move_to/line_to sequence. + //----------------------------------------------------------------------- + template class conv_curve + { + public: + typedef Curve3 curve3_type; + typedef Curve4 curve4_type; + typedef conv_curve self_type; + + explicit conv_curve(VertexSource& source) : + m_source(&source), m_last_x(0.0), m_last_y(0.0) {} + void attach(VertexSource& source) { m_source = &source; } + + void approximation_method(curve_approximation_method_e v) + { + m_curve3.approximation_method(v); + m_curve4.approximation_method(v); + } + + curve_approximation_method_e approximation_method() const + { + return m_curve4.approximation_method(); + } + + void approximation_scale(double s) + { + m_curve3.approximation_scale(s); + m_curve4.approximation_scale(s); + } + + double approximation_scale() const + { + return m_curve4.approximation_scale(); + } + + void angle_tolerance(double v) + { + m_curve3.angle_tolerance(v); + m_curve4.angle_tolerance(v); + } + + double angle_tolerance() const + { + return m_curve4.angle_tolerance(); + } + + void cusp_limit(double v) + { + m_curve3.cusp_limit(v); + m_curve4.cusp_limit(v); + } + + double cusp_limit() const + { + return m_curve4.cusp_limit(); + } + + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + conv_curve(const self_type&); + const self_type& operator = (const self_type&); + + VertexSource* m_source; + double m_last_x; + double m_last_y; + curve3_type m_curve3; + curve4_type m_curve4; + }; + + + + //------------------------------------------------------------------------ + template + void conv_curve::rewind(unsigned path_id) + { + m_source->rewind(path_id); + m_last_x = 0.0; + m_last_y = 0.0; + m_curve3.reset(); + m_curve4.reset(); + } + + + //------------------------------------------------------------------------ + template + unsigned conv_curve::vertex(double* x, double* y) + { + if(!is_stop(m_curve3.vertex(x, y))) + { + m_last_x = *x; + m_last_y = *y; + return path_cmd_line_to; + } + + if(!is_stop(m_curve4.vertex(x, y))) + { + m_last_x = *x; + m_last_y = *y; + return path_cmd_line_to; + } + + double ct2_x = 0; + double ct2_y = 0; + double end_x = 0; + double end_y = 0; + + unsigned cmd = m_source->vertex(x, y); + switch(cmd) + { + case path_cmd_curve3: + m_source->vertex(&end_x, &end_y); + + m_curve3.init(m_last_x, m_last_y, + *x, *y, + end_x, end_y); + + m_curve3.vertex(x, y); // First call returns path_cmd_move_to + m_curve3.vertex(x, y); // This is the first vertex of the curve + cmd = path_cmd_line_to; + break; + + case path_cmd_curve4: + m_source->vertex(&ct2_x, &ct2_y); + m_source->vertex(&end_x, &end_y); + + m_curve4.init(m_last_x, m_last_y, + *x, *y, + ct2_x, ct2_y, + end_x, end_y); + + m_curve4.vertex(x, y); // First call returns path_cmd_move_to + m_curve4.vertex(x, y); // This is the first vertex of the curve + cmd = path_cmd_line_to; + break; + } + m_last_x = *x; + m_last_y = *y; + return cmd; + } + + +} + + + +#endif diff --git a/xs/src/agg/agg_conv_dash.h b/xs/src/agg/agg_conv_dash.h new file mode 100644 index 0000000000..23c13ad0ab --- /dev/null +++ b/xs/src/agg/agg_conv_dash.h @@ -0,0 +1,68 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// conv_dash +// +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_DASH_INCLUDED +#define AGG_CONV_DASH_INCLUDED + +#include "agg_basics.h" +#include "agg_vcgen_dash.h" +#include "agg_conv_adaptor_vcgen.h" + +namespace agg +{ + + //---------------------------------------------------------------conv_dash + template + struct conv_dash : public conv_adaptor_vcgen + { + typedef Markers marker_type; + typedef conv_adaptor_vcgen base_type; + + conv_dash(VertexSource& vs) : + conv_adaptor_vcgen(vs) + { + } + + void remove_all_dashes() + { + base_type::generator().remove_all_dashes(); + } + + void add_dash(double dash_len, double gap_len) + { + base_type::generator().add_dash(dash_len, gap_len); + } + + void dash_start(double ds) + { + base_type::generator().dash_start(ds); + } + + void shorten(double s) { base_type::generator().shorten(s); } + double shorten() const { return base_type::generator().shorten(); } + + private: + conv_dash(const conv_dash&); + const conv_dash& + operator = (const conv_dash&); + }; + + +} + +#endif diff --git a/xs/src/agg/agg_conv_gpc.h b/xs/src/agg/agg_conv_gpc.h new file mode 100644 index 0000000000..698ae900f4 --- /dev/null +++ b/xs/src/agg/agg_conv_gpc.h @@ -0,0 +1,432 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// General Polygon Clipper based on the GPC library by Alan Murta +// Union, Intersection, XOR, A-B, B-A +// Contact the author if you intend to use it in commercial applications! +// http://www.cs.man.ac.uk/aig/staff/alan/software/ +// Alan Murta (email: gpc@cs.man.ac.uk) +// +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_GPC_INCLUDED +#define AGG_CONV_GPC_INCLUDED + +#include +#include "agg_basics.h" +#include "agg_array.h" + +extern "C" +{ +#include "gpc.h" +} + +namespace agg +{ + enum gpc_op_e + { + gpc_or, + gpc_and, + gpc_xor, + gpc_a_minus_b, + gpc_b_minus_a + }; + + + //================================================================conv_gpc + template class conv_gpc + { + enum status + { + status_move_to, + status_line_to, + status_stop + }; + + struct contour_header_type + { + int num_vertices; + int hole_flag; + gpc_vertex* vertices; + }; + + typedef pod_bvector vertex_array_type; + typedef pod_bvector contour_header_array_type; + + + public: + typedef VSA source_a_type; + typedef VSB source_b_type; + typedef conv_gpc self_type; + + ~conv_gpc() + { + free_gpc_data(); + } + + conv_gpc(source_a_type& a, source_b_type& b, gpc_op_e op = gpc_or) : + m_src_a(&a), + m_src_b(&b), + m_status(status_move_to), + m_vertex(-1), + m_contour(-1), + m_operation(op) + { + memset(&m_poly_a, 0, sizeof(m_poly_a)); + memset(&m_poly_b, 0, sizeof(m_poly_b)); + memset(&m_result, 0, sizeof(m_result)); + } + + void attach1(VSA& source) { m_src_a = &source; } + void attach2(VSB& source) { m_src_b = &source; } + + void operation(gpc_op_e v) { m_operation = v; } + + // Vertex Source Interface + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + conv_gpc(const conv_gpc&); + const conv_gpc& operator = (const conv_gpc&); + + //-------------------------------------------------------------------- + void free_polygon(gpc_polygon& p); + void free_result(); + void free_gpc_data(); + void start_contour(); + void add_vertex(double x, double y); + void end_contour(unsigned orientation); + void make_polygon(gpc_polygon& p); + void start_extracting(); + bool next_contour(); + bool next_vertex(double* x, double* y); + + + //-------------------------------------------------------------------- + template void add(VS& src, gpc_polygon& p) + { + unsigned cmd; + double x, y; + double start_x = 0.0; + double start_y = 0.0; + bool line_to = false; + unsigned orientation = 0; + + m_contour_accumulator.remove_all(); + + while(!is_stop(cmd = src.vertex(&x, &y))) + { + if(is_vertex(cmd)) + { + if(is_move_to(cmd)) + { + if(line_to) + { + end_contour(orientation); + orientation = 0; + } + start_contour(); + start_x = x; + start_y = y; + } + add_vertex(x, y); + line_to = true; + } + else + { + if(is_end_poly(cmd)) + { + orientation = get_orientation(cmd); + if(line_to && is_closed(cmd)) + { + add_vertex(start_x, start_y); + } + } + } + } + if(line_to) + { + end_contour(orientation); + } + make_polygon(p); + } + + + private: + //-------------------------------------------------------------------- + source_a_type* m_src_a; + source_b_type* m_src_b; + status m_status; + int m_vertex; + int m_contour; + gpc_op_e m_operation; + vertex_array_type m_vertex_accumulator; + contour_header_array_type m_contour_accumulator; + gpc_polygon m_poly_a; + gpc_polygon m_poly_b; + gpc_polygon m_result; + }; + + + + + + //------------------------------------------------------------------------ + template + void conv_gpc::free_polygon(gpc_polygon& p) + { + int i; + for(i = 0; i < p.num_contours; i++) + { + pod_allocator::deallocate(p.contour[i].vertex, + p.contour[i].num_vertices); + } + pod_allocator::deallocate(p.contour, p.num_contours); + memset(&p, 0, sizeof(gpc_polygon)); + } + + + //------------------------------------------------------------------------ + template + void conv_gpc::free_result() + { + if(m_result.contour) + { + gpc_free_polygon(&m_result); + } + memset(&m_result, 0, sizeof(m_result)); + } + + + //------------------------------------------------------------------------ + template + void conv_gpc::free_gpc_data() + { + free_polygon(m_poly_a); + free_polygon(m_poly_b); + free_result(); + } + + + //------------------------------------------------------------------------ + template + void conv_gpc::start_contour() + { + contour_header_type h; + memset(&h, 0, sizeof(h)); + m_contour_accumulator.add(h); + m_vertex_accumulator.remove_all(); + } + + + //------------------------------------------------------------------------ + template + inline void conv_gpc::add_vertex(double x, double y) + { + gpc_vertex v; + v.x = x; + v.y = y; + m_vertex_accumulator.add(v); + } + + + //------------------------------------------------------------------------ + template + void conv_gpc::end_contour(unsigned /*orientation*/) + { + if(m_contour_accumulator.size()) + { + if(m_vertex_accumulator.size() > 2) + { + contour_header_type& h = + m_contour_accumulator[m_contour_accumulator.size() - 1]; + + h.num_vertices = m_vertex_accumulator.size(); + h.hole_flag = 0; + + // TO DO: Clarify the "holes" + //if(is_cw(orientation)) h.hole_flag = 1; + + h.vertices = pod_allocator::allocate(h.num_vertices); + gpc_vertex* d = h.vertices; + int i; + for(i = 0; i < h.num_vertices; i++) + { + const gpc_vertex& s = m_vertex_accumulator[i]; + d->x = s.x; + d->y = s.y; + ++d; + } + } + else + { + m_vertex_accumulator.remove_last(); + } + } + } + + + //------------------------------------------------------------------------ + template + void conv_gpc::make_polygon(gpc_polygon& p) + { + free_polygon(p); + if(m_contour_accumulator.size()) + { + p.num_contours = m_contour_accumulator.size(); + + p.hole = 0; + p.contour = pod_allocator::allocate(p.num_contours); + + int i; + gpc_vertex_list* pv = p.contour; + for(i = 0; i < p.num_contours; i++) + { + const contour_header_type& h = m_contour_accumulator[i]; + pv->num_vertices = h.num_vertices; + pv->vertex = h.vertices; + ++pv; + } + } + } + + + //------------------------------------------------------------------------ + template + void conv_gpc::start_extracting() + { + m_status = status_move_to; + m_contour = -1; + m_vertex = -1; + } + + + //------------------------------------------------------------------------ + template + bool conv_gpc::next_contour() + { + if(++m_contour < m_result.num_contours) + { + m_vertex = -1; + return true; + } + return false; + } + + + //------------------------------------------------------------------------ + template + inline bool conv_gpc::next_vertex(double* x, double* y) + { + const gpc_vertex_list& vlist = m_result.contour[m_contour]; + if(++m_vertex < vlist.num_vertices) + { + const gpc_vertex& v = vlist.vertex[m_vertex]; + *x = v.x; + *y = v.y; + return true; + } + return false; + } + + + //------------------------------------------------------------------------ + template + void conv_gpc::rewind(unsigned path_id) + { + free_result(); + m_src_a->rewind(path_id); + m_src_b->rewind(path_id); + add(*m_src_a, m_poly_a); + add(*m_src_b, m_poly_b); + switch(m_operation) + { + case gpc_or: + gpc_polygon_clip(GPC_UNION, + &m_poly_a, + &m_poly_b, + &m_result); + break; + + case gpc_and: + gpc_polygon_clip(GPC_INT, + &m_poly_a, + &m_poly_b, + &m_result); + break; + + case gpc_xor: + gpc_polygon_clip(GPC_XOR, + &m_poly_a, + &m_poly_b, + &m_result); + break; + + case gpc_a_minus_b: + gpc_polygon_clip(GPC_DIFF, + &m_poly_a, + &m_poly_b, + &m_result); + break; + + case gpc_b_minus_a: + gpc_polygon_clip(GPC_DIFF, + &m_poly_b, + &m_poly_a, + &m_result); + break; + } + start_extracting(); + } + + + //------------------------------------------------------------------------ + template + unsigned conv_gpc::vertex(double* x, double* y) + { + if(m_status == status_move_to) + { + if(next_contour()) + { + if(next_vertex(x, y)) + { + m_status = status_line_to; + return path_cmd_move_to; + } + m_status = status_stop; + return path_cmd_end_poly | path_flags_close; + } + } + else + { + if(next_vertex(x, y)) + { + return path_cmd_line_to; + } + else + { + m_status = status_move_to; + } + return path_cmd_end_poly | path_flags_close; + } + return path_cmd_stop; + } + + +} + + +#endif diff --git a/xs/src/agg/agg_conv_marker.h b/xs/src/agg/agg_conv_marker.h new file mode 100644 index 0000000000..2cd3cb403f --- /dev/null +++ b/xs/src/agg/agg_conv_marker.h @@ -0,0 +1,148 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// conv_marker +// +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_MARKER_INCLUDED +#define AGG_CONV_MARKER_INCLUDED + +#include "agg_basics.h" +#include "agg_trans_affine.h" + +namespace agg +{ + //-------------------------------------------------------------conv_marker + template + class conv_marker + { + public: + conv_marker(MarkerLocator& ml, MarkerShapes& ms); + + trans_affine& transform() { return m_transform; } + const trans_affine& transform() const { return m_transform; } + + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + conv_marker(const conv_marker&); + const conv_marker& + operator = (const conv_marker&); + + enum status_e + { + initial, + markers, + polygon, + stop + }; + + MarkerLocator* m_marker_locator; + MarkerShapes* m_marker_shapes; + trans_affine m_transform; + trans_affine m_mtx; + status_e m_status; + unsigned m_marker; + unsigned m_num_markers; + }; + + + //------------------------------------------------------------------------ + template + conv_marker::conv_marker(MarkerLocator& ml, MarkerShapes& ms) : + m_marker_locator(&ml), + m_marker_shapes(&ms), + m_status(initial), + m_marker(0), + m_num_markers(1) + { + } + + + //------------------------------------------------------------------------ + template + void conv_marker::rewind(unsigned) + { + m_status = initial; + m_marker = 0; + m_num_markers = 1; + } + + + //------------------------------------------------------------------------ + template + unsigned conv_marker::vertex(double* x, double* y) + { + unsigned cmd = path_cmd_move_to; + double x1, y1, x2, y2; + + while(!is_stop(cmd)) + { + switch(m_status) + { + case initial: + if(m_num_markers == 0) + { + cmd = path_cmd_stop; + break; + } + m_marker_locator->rewind(m_marker); + ++m_marker; + m_num_markers = 0; + m_status = markers; + + case markers: + if(is_stop(m_marker_locator->vertex(&x1, &y1))) + { + m_status = initial; + break; + } + if(is_stop(m_marker_locator->vertex(&x2, &y2))) + { + m_status = initial; + break; + } + ++m_num_markers; + m_mtx = m_transform; + m_mtx *= trans_affine_rotation(atan2(y2 - y1, x2 - x1)); + m_mtx *= trans_affine_translation(x1, y1); + m_marker_shapes->rewind(m_marker - 1); + m_status = polygon; + + case polygon: + cmd = m_marker_shapes->vertex(x, y); + if(is_stop(cmd)) + { + cmd = path_cmd_move_to; + m_status = markers; + break; + } + m_mtx.transform(x, y); + return cmd; + + case stop: + cmd = path_cmd_stop; + break; + } + } + return cmd; + } + +} + + +#endif + diff --git a/xs/src/agg/agg_conv_marker_adaptor.h b/xs/src/agg/agg_conv_marker_adaptor.h new file mode 100644 index 0000000000..4486d6ace9 --- /dev/null +++ b/xs/src/agg/agg_conv_marker_adaptor.h @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_MARKER_ADAPTOR_INCLUDED +#define AGG_CONV_MARKER_ADAPTOR_INCLUDED + +#include "agg_basics.h" +#include "agg_conv_adaptor_vcgen.h" +#include "agg_vcgen_vertex_sequence.h" + +namespace agg +{ + + //=====================================================conv_marker_adaptor + template + struct conv_marker_adaptor : + public conv_adaptor_vcgen + { + typedef Markers marker_type; + typedef conv_adaptor_vcgen base_type; + + conv_marker_adaptor(VertexSource& vs) : + conv_adaptor_vcgen(vs) + { + } + + void shorten(double s) { base_type::generator().shorten(s); } + double shorten() const { return base_type::generator().shorten(); } + + private: + conv_marker_adaptor(const conv_marker_adaptor&); + const conv_marker_adaptor& + operator = (const conv_marker_adaptor&); + }; + + +} + +#endif diff --git a/xs/src/agg/agg_conv_segmentator.h b/xs/src/agg/agg_conv_segmentator.h new file mode 100644 index 0000000000..e69a9e7d7d --- /dev/null +++ b/xs/src/agg/agg_conv_segmentator.h @@ -0,0 +1,48 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_SEGMENTATOR_INCLUDED +#define AGG_CONV_SEGMENTATOR_INCLUDED + +#include "agg_basics.h" +#include "agg_conv_adaptor_vpgen.h" +#include "agg_vpgen_segmentator.h" + +namespace agg +{ + + //========================================================conv_segmentator + template + struct conv_segmentator : public conv_adaptor_vpgen + { + typedef conv_adaptor_vpgen base_type; + + conv_segmentator(VertexSource& vs) : + conv_adaptor_vpgen(vs) {} + + void approximation_scale(double s) { base_type::vpgen().approximation_scale(s); } + double approximation_scale() const { return base_type::vpgen().approximation_scale(); } + + private: + conv_segmentator(const conv_segmentator&); + const conv_segmentator& + operator = (const conv_segmentator&); + }; + + +} + +#endif + diff --git a/xs/src/agg/agg_conv_shorten_path.h b/xs/src/agg/agg_conv_shorten_path.h new file mode 100644 index 0000000000..5617e51d17 --- /dev/null +++ b/xs/src/agg/agg_conv_shorten_path.h @@ -0,0 +1,50 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_SHORTEN_PATH_INCLUDED +#define AGG_CONV_SHORTEN_PATH_INCLUDED + +#include "agg_basics.h" +#include "agg_conv_adaptor_vcgen.h" +#include "agg_vcgen_vertex_sequence.h" + +namespace agg +{ + + //=======================================================conv_shorten_path + template class conv_shorten_path : + public conv_adaptor_vcgen + { + public: + typedef conv_adaptor_vcgen base_type; + + conv_shorten_path(VertexSource& vs) : + conv_adaptor_vcgen(vs) + { + } + + void shorten(double s) { base_type::generator().shorten(s); } + double shorten() const { return base_type::generator().shorten(); } + + private: + conv_shorten_path(const conv_shorten_path&); + const conv_shorten_path& + operator = (const conv_shorten_path&); + }; + + +} + +#endif diff --git a/xs/src/agg/agg_conv_smooth_poly1.h b/xs/src/agg/agg_conv_smooth_poly1.h new file mode 100644 index 0000000000..4ac4e3d6e2 --- /dev/null +++ b/xs/src/agg/agg_conv_smooth_poly1.h @@ -0,0 +1,80 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Smooth polygon generator +// +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_SMOOTH_POLY1_INCLUDED +#define AGG_CONV_SMOOTH_POLY1_INCLUDED + +#include "agg_basics.h" +#include "agg_vcgen_smooth_poly1.h" +#include "agg_conv_adaptor_vcgen.h" +#include "agg_conv_curve.h" + + +namespace agg +{ + + //-------------------------------------------------------conv_smooth_poly1 + template + struct conv_smooth_poly1 : + public conv_adaptor_vcgen + { + typedef conv_adaptor_vcgen base_type; + + conv_smooth_poly1(VertexSource& vs) : + conv_adaptor_vcgen(vs) + { + } + + void smooth_value(double v) { base_type::generator().smooth_value(v); } + double smooth_value() const { return base_type::generator().smooth_value(); } + + private: + conv_smooth_poly1(const conv_smooth_poly1&); + const conv_smooth_poly1& + operator = (const conv_smooth_poly1&); + }; + + + + //-------------------------------------------------conv_smooth_poly1_curve + template + struct conv_smooth_poly1_curve : + public conv_curve > + { + conv_smooth_poly1_curve(VertexSource& vs) : + conv_curve >(m_smooth), + m_smooth(vs) + { + } + + void smooth_value(double v) { m_smooth.generator().smooth_value(v); } + double smooth_value() const { return m_smooth.generator().smooth_value(); } + + private: + conv_smooth_poly1_curve(const conv_smooth_poly1_curve&); + const conv_smooth_poly1_curve& + operator = (const conv_smooth_poly1_curve&); + + conv_smooth_poly1 m_smooth; + }; + +} + + +#endif + diff --git a/xs/src/agg/agg_conv_stroke.h b/xs/src/agg/agg_conv_stroke.h new file mode 100644 index 0000000000..e19a6b61f4 --- /dev/null +++ b/xs/src/agg/agg_conv_stroke.h @@ -0,0 +1,73 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// conv_stroke +// +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_STROKE_INCLUDED +#define AGG_CONV_STROKE_INCLUDED + +#include "agg_basics.h" +#include "agg_vcgen_stroke.h" +#include "agg_conv_adaptor_vcgen.h" + +namespace agg +{ + + //-------------------------------------------------------------conv_stroke + template + struct conv_stroke : + public conv_adaptor_vcgen + { + typedef Markers marker_type; + typedef conv_adaptor_vcgen base_type; + + conv_stroke(VertexSource& vs) : + conv_adaptor_vcgen(vs) + { + } + + void line_cap(line_cap_e lc) { base_type::generator().line_cap(lc); } + void line_join(line_join_e lj) { base_type::generator().line_join(lj); } + void inner_join(inner_join_e ij) { base_type::generator().inner_join(ij); } + + line_cap_e line_cap() const { return base_type::generator().line_cap(); } + line_join_e line_join() const { return base_type::generator().line_join(); } + inner_join_e inner_join() const { return base_type::generator().inner_join(); } + + void width(double w) { base_type::generator().width(w); } + void miter_limit(double ml) { base_type::generator().miter_limit(ml); } + void miter_limit_theta(double t) { base_type::generator().miter_limit_theta(t); } + void inner_miter_limit(double ml) { base_type::generator().inner_miter_limit(ml); } + void approximation_scale(double as) { base_type::generator().approximation_scale(as); } + + double width() const { return base_type::generator().width(); } + double miter_limit() const { return base_type::generator().miter_limit(); } + double inner_miter_limit() const { return base_type::generator().inner_miter_limit(); } + double approximation_scale() const { return base_type::generator().approximation_scale(); } + + void shorten(double s) { base_type::generator().shorten(s); } + double shorten() const { return base_type::generator().shorten(); } + + private: + conv_stroke(const conv_stroke&); + const conv_stroke& + operator = (const conv_stroke&); + + }; + +} + +#endif diff --git a/xs/src/agg/agg_conv_transform.h b/xs/src/agg/agg_conv_transform.h new file mode 100644 index 0000000000..0c88a245bd --- /dev/null +++ b/xs/src/agg/agg_conv_transform.h @@ -0,0 +1,68 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class conv_transform +// +//---------------------------------------------------------------------------- +#ifndef AGG_CONV_TRANSFORM_INCLUDED +#define AGG_CONV_TRANSFORM_INCLUDED + +#include "agg_basics.h" +#include "agg_trans_affine.h" + +namespace agg +{ + + //----------------------------------------------------------conv_transform + template class conv_transform + { + public: + conv_transform(VertexSource& source, Transformer& tr) : + m_source(&source), m_trans(&tr) {} + void attach(VertexSource& source) { m_source = &source; } + + void rewind(unsigned path_id) + { + m_source->rewind(path_id); + } + + unsigned vertex(double* x, double* y) + { + unsigned cmd = m_source->vertex(x, y); + if(is_vertex(cmd)) + { + m_trans->transform(x, y); + } + return cmd; + } + + void transformer(Transformer& tr) + { + m_trans = &tr; + } + + private: + conv_transform(const conv_transform&); + const conv_transform& + operator = (const conv_transform&); + + VertexSource* m_source; + Transformer* m_trans; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_conv_unclose_polygon.h b/xs/src/agg/agg_conv_unclose_polygon.h new file mode 100644 index 0000000000..fe5c263810 --- /dev/null +++ b/xs/src/agg/agg_conv_unclose_polygon.h @@ -0,0 +1,52 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CONV_UNCLOSE_POLYGON_INCLUDED +#define AGG_CONV_UNCLOSE_POLYGON_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + //====================================================conv_unclose_polygon + template class conv_unclose_polygon + { + public: + explicit conv_unclose_polygon(VertexSource& vs) : m_source(&vs) {} + void attach(VertexSource& source) { m_source = &source; } + + void rewind(unsigned path_id) + { + m_source->rewind(path_id); + } + + unsigned vertex(double* x, double* y) + { + unsigned cmd = m_source->vertex(x, y); + if(is_end_poly(cmd)) cmd &= ~path_flags_close; + return cmd; + } + + private: + conv_unclose_polygon(const conv_unclose_polygon&); + const conv_unclose_polygon& + operator = (const conv_unclose_polygon&); + + VertexSource* m_source; + }; + +} + +#endif diff --git a/xs/src/agg/agg_curves.h b/xs/src/agg/agg_curves.h new file mode 100644 index 0000000000..1ef02e8783 --- /dev/null +++ b/xs/src/agg/agg_curves.h @@ -0,0 +1,693 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// Copyright (C) 2005 Tony Juricic (tonygeek@yahoo.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_CURVES_INCLUDED +#define AGG_CURVES_INCLUDED + +#include "agg_array.h" + +namespace agg +{ + + // See Implementation agg_curves.cpp + + //--------------------------------------------curve_approximation_method_e + enum curve_approximation_method_e + { + curve_inc, + curve_div + }; + + //--------------------------------------------------------------curve3_inc + class curve3_inc + { + public: + curve3_inc() : + m_num_steps(0), m_step(0), m_scale(1.0) { } + + curve3_inc(double x1, double y1, + double x2, double y2, + double x3, double y3) : + m_num_steps(0), m_step(0), m_scale(1.0) + { + init(x1, y1, x2, y2, x3, y3); + } + + void reset() { m_num_steps = 0; m_step = -1; } + void init(double x1, double y1, + double x2, double y2, + double x3, double y3); + + void approximation_method(curve_approximation_method_e) {} + curve_approximation_method_e approximation_method() const { return curve_inc; } + + void approximation_scale(double s); + double approximation_scale() const; + + void angle_tolerance(double) {} + double angle_tolerance() const { return 0.0; } + + void cusp_limit(double) {} + double cusp_limit() const { return 0.0; } + + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + int m_num_steps; + int m_step; + double m_scale; + double m_start_x; + double m_start_y; + double m_end_x; + double m_end_y; + double m_fx; + double m_fy; + double m_dfx; + double m_dfy; + double m_ddfx; + double m_ddfy; + double m_saved_fx; + double m_saved_fy; + double m_saved_dfx; + double m_saved_dfy; + }; + + + + + + //-------------------------------------------------------------curve3_div + class curve3_div + { + public: + curve3_div() : + m_approximation_scale(1.0), + m_angle_tolerance(0.0), + m_count(0) + {} + + curve3_div(double x1, double y1, + double x2, double y2, + double x3, double y3) : + m_approximation_scale(1.0), + m_angle_tolerance(0.0), + m_count(0) + { + init(x1, y1, x2, y2, x3, y3); + } + + void reset() { m_points.remove_all(); m_count = 0; } + void init(double x1, double y1, + double x2, double y2, + double x3, double y3); + + void approximation_method(curve_approximation_method_e) {} + curve_approximation_method_e approximation_method() const { return curve_div; } + + void approximation_scale(double s) { m_approximation_scale = s; } + double approximation_scale() const { return m_approximation_scale; } + + void angle_tolerance(double a) { m_angle_tolerance = a; } + double angle_tolerance() const { return m_angle_tolerance; } + + void cusp_limit(double) {} + double cusp_limit() const { return 0.0; } + + void rewind(unsigned) + { + m_count = 0; + } + + unsigned vertex(double* x, double* y) + { + if(m_count >= m_points.size()) return path_cmd_stop; + const point_d& p = m_points[m_count++]; + *x = p.x; + *y = p.y; + return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; + } + + private: + void bezier(double x1, double y1, + double x2, double y2, + double x3, double y3); + void recursive_bezier(double x1, double y1, + double x2, double y2, + double x3, double y3, + unsigned level); + + double m_approximation_scale; + double m_distance_tolerance_square; + double m_angle_tolerance; + unsigned m_count; + pod_bvector m_points; + }; + + + + + + + + //-------------------------------------------------------------curve4_points + struct curve4_points + { + double cp[8]; + curve4_points() {} + curve4_points(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) + { + cp[0] = x1; cp[1] = y1; cp[2] = x2; cp[3] = y2; + cp[4] = x3; cp[5] = y3; cp[6] = x4; cp[7] = y4; + } + void init(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) + { + cp[0] = x1; cp[1] = y1; cp[2] = x2; cp[3] = y2; + cp[4] = x3; cp[5] = y3; cp[6] = x4; cp[7] = y4; + } + double operator [] (unsigned i) const { return cp[i]; } + double& operator [] (unsigned i) { return cp[i]; } + }; + + + + //-------------------------------------------------------------curve4_inc + class curve4_inc + { + public: + curve4_inc() : + m_num_steps(0), m_step(0), m_scale(1.0) { } + + curve4_inc(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) : + m_num_steps(0), m_step(0), m_scale(1.0) + { + init(x1, y1, x2, y2, x3, y3, x4, y4); + } + + curve4_inc(const curve4_points& cp) : + m_num_steps(0), m_step(0), m_scale(1.0) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + + void reset() { m_num_steps = 0; m_step = -1; } + void init(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4); + + void init(const curve4_points& cp) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + + void approximation_method(curve_approximation_method_e) {} + curve_approximation_method_e approximation_method() const { return curve_inc; } + + void approximation_scale(double s); + double approximation_scale() const; + + void angle_tolerance(double) {} + double angle_tolerance() const { return 0.0; } + + void cusp_limit(double) {} + double cusp_limit() const { return 0.0; } + + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + int m_num_steps; + int m_step; + double m_scale; + double m_start_x; + double m_start_y; + double m_end_x; + double m_end_y; + double m_fx; + double m_fy; + double m_dfx; + double m_dfy; + double m_ddfx; + double m_ddfy; + double m_dddfx; + double m_dddfy; + double m_saved_fx; + double m_saved_fy; + double m_saved_dfx; + double m_saved_dfy; + double m_saved_ddfx; + double m_saved_ddfy; + }; + + + + //-------------------------------------------------------catrom_to_bezier + inline curve4_points catrom_to_bezier(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) + { + // Trans. matrix Catmull-Rom to Bezier + // + // 0 1 0 0 + // -1/6 1 1/6 0 + // 0 1/6 1 -1/6 + // 0 0 1 0 + // + return curve4_points( + x2, + y2, + (-x1 + 6*x2 + x3) / 6, + (-y1 + 6*y2 + y3) / 6, + ( x2 + 6*x3 - x4) / 6, + ( y2 + 6*y3 - y4) / 6, + x3, + y3); + } + + + //----------------------------------------------------------------------- + inline curve4_points + catrom_to_bezier(const curve4_points& cp) + { + return catrom_to_bezier(cp[0], cp[1], cp[2], cp[3], + cp[4], cp[5], cp[6], cp[7]); + } + + + + //-----------------------------------------------------ubspline_to_bezier + inline curve4_points ubspline_to_bezier(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) + { + // Trans. matrix Uniform BSpline to Bezier + // + // 1/6 4/6 1/6 0 + // 0 4/6 2/6 0 + // 0 2/6 4/6 0 + // 0 1/6 4/6 1/6 + // + return curve4_points( + (x1 + 4*x2 + x3) / 6, + (y1 + 4*y2 + y3) / 6, + (4*x2 + 2*x3) / 6, + (4*y2 + 2*y3) / 6, + (2*x2 + 4*x3) / 6, + (2*y2 + 4*y3) / 6, + (x2 + 4*x3 + x4) / 6, + (y2 + 4*y3 + y4) / 6); + } + + + //----------------------------------------------------------------------- + inline curve4_points + ubspline_to_bezier(const curve4_points& cp) + { + return ubspline_to_bezier(cp[0], cp[1], cp[2], cp[3], + cp[4], cp[5], cp[6], cp[7]); + } + + + + + //------------------------------------------------------hermite_to_bezier + inline curve4_points hermite_to_bezier(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) + { + // Trans. matrix Hermite to Bezier + // + // 1 0 0 0 + // 1 0 1/3 0 + // 0 1 0 -1/3 + // 0 1 0 0 + // + return curve4_points( + x1, + y1, + (3*x1 + x3) / 3, + (3*y1 + y3) / 3, + (3*x2 - x4) / 3, + (3*y2 - y4) / 3, + x2, + y2); + } + + + + //----------------------------------------------------------------------- + inline curve4_points + hermite_to_bezier(const curve4_points& cp) + { + return hermite_to_bezier(cp[0], cp[1], cp[2], cp[3], + cp[4], cp[5], cp[6], cp[7]); + } + + + //-------------------------------------------------------------curve4_div + class curve4_div + { + public: + curve4_div() : + m_approximation_scale(1.0), + m_angle_tolerance(0.0), + m_cusp_limit(0.0), + m_count(0) + {} + + curve4_div(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) : + m_approximation_scale(1.0), + m_angle_tolerance(0.0), + m_cusp_limit(0.0), + m_count(0) + { + init(x1, y1, x2, y2, x3, y3, x4, y4); + } + + curve4_div(const curve4_points& cp) : + m_approximation_scale(1.0), + m_angle_tolerance(0.0), + m_count(0) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + + void reset() { m_points.remove_all(); m_count = 0; } + void init(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4); + + void init(const curve4_points& cp) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + + void approximation_method(curve_approximation_method_e) {} + + curve_approximation_method_e approximation_method() const + { + return curve_div; + } + + void approximation_scale(double s) { m_approximation_scale = s; } + double approximation_scale() const { return m_approximation_scale; } + + void angle_tolerance(double a) { m_angle_tolerance = a; } + double angle_tolerance() const { return m_angle_tolerance; } + + void cusp_limit(double v) + { + m_cusp_limit = (v == 0.0) ? 0.0 : pi - v; + } + + double cusp_limit() const + { + return (m_cusp_limit == 0.0) ? 0.0 : pi - m_cusp_limit; + } + + void rewind(unsigned) + { + m_count = 0; + } + + unsigned vertex(double* x, double* y) + { + if(m_count >= m_points.size()) return path_cmd_stop; + const point_d& p = m_points[m_count++]; + *x = p.x; + *y = p.y; + return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; + } + + private: + void bezier(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4); + + void recursive_bezier(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4, + unsigned level); + + double m_approximation_scale; + double m_distance_tolerance_square; + double m_angle_tolerance; + double m_cusp_limit; + unsigned m_count; + pod_bvector m_points; + }; + + + //-----------------------------------------------------------------curve3 + class curve3 + { + public: + curve3() : m_approximation_method(curve_div) {} + curve3(double x1, double y1, + double x2, double y2, + double x3, double y3) : + m_approximation_method(curve_div) + { + init(x1, y1, x2, y2, x3, y3); + } + + void reset() + { + m_curve_inc.reset(); + m_curve_div.reset(); + } + + void init(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + if(m_approximation_method == curve_inc) + { + m_curve_inc.init(x1, y1, x2, y2, x3, y3); + } + else + { + m_curve_div.init(x1, y1, x2, y2, x3, y3); + } + } + + void approximation_method(curve_approximation_method_e v) + { + m_approximation_method = v; + } + + curve_approximation_method_e approximation_method() const + { + return m_approximation_method; + } + + void approximation_scale(double s) + { + m_curve_inc.approximation_scale(s); + m_curve_div.approximation_scale(s); + } + + double approximation_scale() const + { + return m_curve_inc.approximation_scale(); + } + + void angle_tolerance(double a) + { + m_curve_div.angle_tolerance(a); + } + + double angle_tolerance() const + { + return m_curve_div.angle_tolerance(); + } + + void cusp_limit(double v) + { + m_curve_div.cusp_limit(v); + } + + double cusp_limit() const + { + return m_curve_div.cusp_limit(); + } + + void rewind(unsigned path_id) + { + if(m_approximation_method == curve_inc) + { + m_curve_inc.rewind(path_id); + } + else + { + m_curve_div.rewind(path_id); + } + } + + unsigned vertex(double* x, double* y) + { + if(m_approximation_method == curve_inc) + { + return m_curve_inc.vertex(x, y); + } + return m_curve_div.vertex(x, y); + } + + private: + curve3_inc m_curve_inc; + curve3_div m_curve_div; + curve_approximation_method_e m_approximation_method; + }; + + + + + + //-----------------------------------------------------------------curve4 + class curve4 + { + public: + curve4() : m_approximation_method(curve_div) {} + curve4(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) : + m_approximation_method(curve_div) + { + init(x1, y1, x2, y2, x3, y3, x4, y4); + } + + curve4(const curve4_points& cp) : + m_approximation_method(curve_div) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + + void reset() + { + m_curve_inc.reset(); + m_curve_div.reset(); + } + + void init(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) + { + if(m_approximation_method == curve_inc) + { + m_curve_inc.init(x1, y1, x2, y2, x3, y3, x4, y4); + } + else + { + m_curve_div.init(x1, y1, x2, y2, x3, y3, x4, y4); + } + } + + void init(const curve4_points& cp) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + + void approximation_method(curve_approximation_method_e v) + { + m_approximation_method = v; + } + + curve_approximation_method_e approximation_method() const + { + return m_approximation_method; + } + + void approximation_scale(double s) + { + m_curve_inc.approximation_scale(s); + m_curve_div.approximation_scale(s); + } + double approximation_scale() const { return m_curve_inc.approximation_scale(); } + + void angle_tolerance(double v) + { + m_curve_div.angle_tolerance(v); + } + + double angle_tolerance() const + { + return m_curve_div.angle_tolerance(); + } + + void cusp_limit(double v) + { + m_curve_div.cusp_limit(v); + } + + double cusp_limit() const + { + return m_curve_div.cusp_limit(); + } + + void rewind(unsigned path_id) + { + if(m_approximation_method == curve_inc) + { + m_curve_inc.rewind(path_id); + } + else + { + m_curve_div.rewind(path_id); + } + } + + unsigned vertex(double* x, double* y) + { + if(m_approximation_method == curve_inc) + { + return m_curve_inc.vertex(x, y); + } + return m_curve_div.vertex(x, y); + } + + private: + curve4_inc m_curve_inc; + curve4_div m_curve_div; + curve_approximation_method_e m_approximation_method; + }; + + + + +} + +#endif diff --git a/xs/src/agg/agg_dda_line.h b/xs/src/agg/agg_dda_line.h new file mode 100644 index 0000000000..f589e76b83 --- /dev/null +++ b/xs/src/agg/agg_dda_line.h @@ -0,0 +1,290 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// classes dda_line_interpolator, dda2_line_interpolator +// +//---------------------------------------------------------------------------- + +#ifndef AGG_DDA_LINE_INCLUDED +#define AGG_DDA_LINE_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + + //===================================================dda_line_interpolator + template class dda_line_interpolator + { + public: + //-------------------------------------------------------------------- + dda_line_interpolator() {} + + //-------------------------------------------------------------------- + dda_line_interpolator(int y1, int y2, unsigned count) : + m_y(y1), + m_inc(((y2 - y1) << FractionShift) / int(count)), + m_dy(0) + { + } + + //-------------------------------------------------------------------- + void operator ++ () + { + m_dy += m_inc; + } + + //-------------------------------------------------------------------- + void operator -- () + { + m_dy -= m_inc; + } + + //-------------------------------------------------------------------- + void operator += (unsigned n) + { + m_dy += m_inc * n; + } + + //-------------------------------------------------------------------- + void operator -= (unsigned n) + { + m_dy -= m_inc * n; + } + + + //-------------------------------------------------------------------- + int y() const { return m_y + (m_dy >> (FractionShift-YShift)); } + int dy() const { return m_dy; } + + + private: + int m_y; + int m_inc; + int m_dy; + }; + + + + + + //=================================================dda2_line_interpolator + class dda2_line_interpolator + { + public: + typedef int save_data_type; + enum save_size_e { save_size = 2 }; + + //-------------------------------------------------------------------- + dda2_line_interpolator() {} + + //-------------------------------------------- Forward-adjusted line + dda2_line_interpolator(int y1, int y2, int count) : + m_cnt(count <= 0 ? 1 : count), + m_lft((y2 - y1) / m_cnt), + m_rem((y2 - y1) % m_cnt), + m_mod(m_rem), + m_y(y1) + { + if(m_mod <= 0) + { + m_mod += count; + m_rem += count; + m_lft--; + } + m_mod -= count; + } + + //-------------------------------------------- Backward-adjusted line + dda2_line_interpolator(int y1, int y2, int count, int) : + m_cnt(count <= 0 ? 1 : count), + m_lft((y2 - y1) / m_cnt), + m_rem((y2 - y1) % m_cnt), + m_mod(m_rem), + m_y(y1) + { + if(m_mod <= 0) + { + m_mod += count; + m_rem += count; + m_lft--; + } + } + + //-------------------------------------------- Backward-adjusted line + dda2_line_interpolator(int y, int count) : + m_cnt(count <= 0 ? 1 : count), + m_lft(y / m_cnt), + m_rem(y % m_cnt), + m_mod(m_rem), + m_y(0) + { + if(m_mod <= 0) + { + m_mod += count; + m_rem += count; + m_lft--; + } + } + + + //-------------------------------------------------------------------- + void save(save_data_type* data) const + { + data[0] = m_mod; + data[1] = m_y; + } + + //-------------------------------------------------------------------- + void load(const save_data_type* data) + { + m_mod = data[0]; + m_y = data[1]; + } + + //-------------------------------------------------------------------- + void operator++() + { + m_mod += m_rem; + m_y += m_lft; + if(m_mod > 0) + { + m_mod -= m_cnt; + m_y++; + } + } + + //-------------------------------------------------------------------- + void operator--() + { + if(m_mod <= m_rem) + { + m_mod += m_cnt; + m_y--; + } + m_mod -= m_rem; + m_y -= m_lft; + } + + //-------------------------------------------------------------------- + void adjust_forward() + { + m_mod -= m_cnt; + } + + //-------------------------------------------------------------------- + void adjust_backward() + { + m_mod += m_cnt; + } + + //-------------------------------------------------------------------- + int mod() const { return m_mod; } + int rem() const { return m_rem; } + int lft() const { return m_lft; } + + //-------------------------------------------------------------------- + int y() const { return m_y; } + + private: + int m_cnt; + int m_lft; + int m_rem; + int m_mod; + int m_y; + }; + + + + + + + + //---------------------------------------------line_bresenham_interpolator + class line_bresenham_interpolator + { + public: + enum subpixel_scale_e + { + subpixel_shift = 8, + subpixel_scale = 1 << subpixel_shift, + subpixel_mask = subpixel_scale - 1 + }; + + //-------------------------------------------------------------------- + static int line_lr(int v) { return v >> subpixel_shift; } + + //-------------------------------------------------------------------- + line_bresenham_interpolator(int x1, int y1, int x2, int y2) : + m_x1_lr(line_lr(x1)), + m_y1_lr(line_lr(y1)), + m_x2_lr(line_lr(x2)), + m_y2_lr(line_lr(y2)), + m_ver(abs(m_x2_lr - m_x1_lr) < abs(m_y2_lr - m_y1_lr)), + m_len(m_ver ? abs(m_y2_lr - m_y1_lr) : + abs(m_x2_lr - m_x1_lr)), + m_inc(m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1)), + m_interpolator(m_ver ? x1 : y1, + m_ver ? x2 : y2, + m_len) + { + } + + //-------------------------------------------------------------------- + bool is_ver() const { return m_ver; } + unsigned len() const { return m_len; } + int inc() const { return m_inc; } + + //-------------------------------------------------------------------- + void hstep() + { + ++m_interpolator; + m_x1_lr += m_inc; + } + + //-------------------------------------------------------------------- + void vstep() + { + ++m_interpolator; + m_y1_lr += m_inc; + } + + //-------------------------------------------------------------------- + int x1() const { return m_x1_lr; } + int y1() const { return m_y1_lr; } + int x2() const { return line_lr(m_interpolator.y()); } + int y2() const { return line_lr(m_interpolator.y()); } + int x2_hr() const { return m_interpolator.y(); } + int y2_hr() const { return m_interpolator.y(); } + + private: + int m_x1_lr; + int m_y1_lr; + int m_x2_lr; + int m_y2_lr; + bool m_ver; + unsigned m_len; + int m_inc; + dda2_line_interpolator m_interpolator; + + }; + + +} + + + +#endif diff --git a/xs/src/agg/agg_ellipse.h b/xs/src/agg/agg_ellipse.h new file mode 100644 index 0000000000..e78ce27dd9 --- /dev/null +++ b/xs/src/agg/agg_ellipse.h @@ -0,0 +1,123 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class ellipse +// +//---------------------------------------------------------------------------- + +#ifndef AGG_ELLIPSE_INCLUDED +#define AGG_ELLIPSE_INCLUDED + +#include "agg_basics.h" +#include + +namespace agg +{ + + //----------------------------------------------------------------ellipse + class ellipse + { + public: + ellipse() : + m_x(0.0), m_y(0.0), m_rx(1.0), m_ry(1.0), m_scale(1.0), + m_num(4), m_step(0), m_cw(false) {} + + ellipse(double x, double y, double rx, double ry, + unsigned num_steps=0, bool cw=false) : + m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0), + m_num(num_steps), m_step(0), m_cw(cw) + { + if(m_num == 0) calc_num_steps(); + } + + void init(double x, double y, double rx, double ry, + unsigned num_steps=0, bool cw=false); + + void approximation_scale(double scale); + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + void calc_num_steps(); + + double m_x; + double m_y; + double m_rx; + double m_ry; + double m_scale; + unsigned m_num; + unsigned m_step; + bool m_cw; + }; + + //------------------------------------------------------------------------ + inline void ellipse::init(double x, double y, double rx, double ry, + unsigned num_steps, bool cw) + { + m_x = x; + m_y = y; + m_rx = rx; + m_ry = ry; + m_num = num_steps; + m_step = 0; + m_cw = cw; + if(m_num == 0) calc_num_steps(); + } + + //------------------------------------------------------------------------ + inline void ellipse::approximation_scale(double scale) + { + m_scale = scale; + calc_num_steps(); + } + + //------------------------------------------------------------------------ + inline void ellipse::calc_num_steps() + { + double ra = (fabs(m_rx) + fabs(m_ry)) / 2; + double da = acos(ra / (ra + 0.125 / m_scale)) * 2; + m_num = uround(2*pi / da); + } + + //------------------------------------------------------------------------ + inline void ellipse::rewind(unsigned) + { + m_step = 0; + } + + //------------------------------------------------------------------------ + inline unsigned ellipse::vertex(double* x, double* y) + { + if(m_step == m_num) + { + ++m_step; + return path_cmd_end_poly | path_flags_close | path_flags_ccw; + } + if(m_step > m_num) return path_cmd_stop; + double angle = double(m_step) / double(m_num) * 2.0 * pi; + if(m_cw) angle = 2.0 * pi - angle; + *x = m_x + cos(angle) * m_rx; + *y = m_y + sin(angle) * m_ry; + m_step++; + return ((m_step == 1) ? path_cmd_move_to : path_cmd_line_to); + } + +} + + + +#endif + + diff --git a/xs/src/agg/agg_ellipse_bresenham.h b/xs/src/agg/agg_ellipse_bresenham.h new file mode 100644 index 0000000000..ee3b9c4638 --- /dev/null +++ b/xs/src/agg/agg_ellipse_bresenham.h @@ -0,0 +1,113 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Simple Bresenham interpolator for ellipsees +// +//---------------------------------------------------------------------------- + +#ifndef AGG_ELLIPSE_BRESENHAM_INCLUDED +#define AGG_ELLIPSE_BRESENHAM_INCLUDED + + +#include "agg_basics.h" + + +namespace agg +{ + + //------------------------------------------ellipse_bresenham_interpolator + class ellipse_bresenham_interpolator + { + public: + ellipse_bresenham_interpolator(int rx, int ry) : + m_rx2(rx * rx), + m_ry2(ry * ry), + m_two_rx2(m_rx2 << 1), + m_two_ry2(m_ry2 << 1), + m_dx(0), + m_dy(0), + m_inc_x(0), + m_inc_y(-ry * m_two_rx2), + m_cur_f(0) + {} + + int dx() const { return m_dx; } + int dy() const { return m_dy; } + + void operator++ () + { + int mx, my, mxy, min_m; + int fx, fy, fxy; + + mx = fx = m_cur_f + m_inc_x + m_ry2; + if(mx < 0) mx = -mx; + + my = fy = m_cur_f + m_inc_y + m_rx2; + if(my < 0) my = -my; + + mxy = fxy = m_cur_f + m_inc_x + m_ry2 + m_inc_y + m_rx2; + if(mxy < 0) mxy = -mxy; + + min_m = mx; + bool flag = true; + + if(min_m > my) + { + min_m = my; + flag = false; + } + + m_dx = m_dy = 0; + + if(min_m > mxy) + { + m_inc_x += m_two_ry2; + m_inc_y += m_two_rx2; + m_cur_f = fxy; + m_dx = 1; + m_dy = 1; + return; + } + + if(flag) + { + m_inc_x += m_two_ry2; + m_cur_f = fx; + m_dx = 1; + return; + } + + m_inc_y += m_two_rx2; + m_cur_f = fy; + m_dy = 1; + } + + private: + int m_rx2; + int m_ry2; + int m_two_rx2; + int m_two_ry2; + int m_dx; + int m_dy; + int m_inc_x; + int m_inc_y; + int m_cur_f; + + }; + +} + +#endif + diff --git a/xs/src/agg/agg_embedded_raster_fonts.h b/xs/src/agg/agg_embedded_raster_fonts.h new file mode 100644 index 0000000000..9d522d671c --- /dev/null +++ b/xs/src/agg/agg_embedded_raster_fonts.h @@ -0,0 +1,59 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_EMBEDDED_RASTER_FONTS_INCLUDED +#define AGG_EMBEDDED_RASTER_FONTS_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + extern const int8u gse4x6[]; + extern const int8u gse4x8[]; + extern const int8u gse5x7[]; + extern const int8u gse5x9[]; + extern const int8u gse6x12[]; + extern const int8u gse6x9[]; + extern const int8u gse7x11[]; + extern const int8u gse7x11_bold[]; + extern const int8u gse7x15[]; + extern const int8u gse7x15_bold[]; + extern const int8u gse8x16[]; + extern const int8u gse8x16_bold[]; + extern const int8u mcs11_prop[]; + extern const int8u mcs11_prop_condensed[]; + extern const int8u mcs12_prop[]; + extern const int8u mcs13_prop[]; + extern const int8u mcs5x10_mono[]; + extern const int8u mcs5x11_mono[]; + extern const int8u mcs6x10_mono[]; + extern const int8u mcs6x11_mono[]; + extern const int8u mcs7x12_mono_high[]; + extern const int8u mcs7x12_mono_low[]; + extern const int8u verdana12[]; + extern const int8u verdana12_bold[]; + extern const int8u verdana13[]; + extern const int8u verdana13_bold[]; + extern const int8u verdana14[]; + extern const int8u verdana14_bold[]; + extern const int8u verdana16[]; + extern const int8u verdana16_bold[]; + extern const int8u verdana17[]; + extern const int8u verdana17_bold[]; + extern const int8u verdana18[]; + extern const int8u verdana18_bold[]; +} + +#endif diff --git a/xs/src/agg/agg_font_cache_manager.h b/xs/src/agg/agg_font_cache_manager.h new file mode 100644 index 0000000000..fe9a9280fa --- /dev/null +++ b/xs/src/agg/agg_font_cache_manager.h @@ -0,0 +1,409 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_FONT_CACHE_MANAGER_INCLUDED +#define AGG_FONT_CACHE_MANAGER_INCLUDED + +#include +#include "agg_array.h" + +namespace agg +{ + + //---------------------------------------------------------glyph_data_type + enum glyph_data_type + { + glyph_data_invalid = 0, + glyph_data_mono = 1, + glyph_data_gray8 = 2, + glyph_data_outline = 3 + }; + + + //-------------------------------------------------------------glyph_cache + struct glyph_cache + { + unsigned glyph_index; + int8u* data; + unsigned data_size; + glyph_data_type data_type; + rect_i bounds; + double advance_x; + double advance_y; + }; + + + //--------------------------------------------------------------font_cache + class font_cache + { + public: + enum block_size_e { block_size = 16384-16 }; + + //-------------------------------------------------------------------- + font_cache() : + m_allocator(block_size), + m_font_signature(0) + {} + + //-------------------------------------------------------------------- + void signature(const char* font_signature) + { + m_font_signature = (char*)m_allocator.allocate(strlen(font_signature) + 1); + strcpy(m_font_signature, font_signature); + memset(m_glyphs, 0, sizeof(m_glyphs)); + } + + //-------------------------------------------------------------------- + bool font_is(const char* font_signature) const + { + return strcmp(font_signature, m_font_signature) == 0; + } + + //-------------------------------------------------------------------- + const glyph_cache* find_glyph(unsigned glyph_code) const + { + unsigned msb = (glyph_code >> 8) & 0xFF; + if(m_glyphs[msb]) + { + return m_glyphs[msb][glyph_code & 0xFF]; + } + return 0; + } + + //-------------------------------------------------------------------- + glyph_cache* cache_glyph(unsigned glyph_code, + unsigned glyph_index, + unsigned data_size, + glyph_data_type data_type, + const rect_i& bounds, + double advance_x, + double advance_y) + { + unsigned msb = (glyph_code >> 8) & 0xFF; + if(m_glyphs[msb] == 0) + { + m_glyphs[msb] = + (glyph_cache**)m_allocator.allocate(sizeof(glyph_cache*) * 256, + sizeof(glyph_cache*)); + memset(m_glyphs[msb], 0, sizeof(glyph_cache*) * 256); + } + + unsigned lsb = glyph_code & 0xFF; + if(m_glyphs[msb][lsb]) return 0; // Already exists, do not overwrite + + glyph_cache* glyph = + (glyph_cache*)m_allocator.allocate(sizeof(glyph_cache), + sizeof(double)); + + glyph->glyph_index = glyph_index; + glyph->data = m_allocator.allocate(data_size); + glyph->data_size = data_size; + glyph->data_type = data_type; + glyph->bounds = bounds; + glyph->advance_x = advance_x; + glyph->advance_y = advance_y; + return m_glyphs[msb][lsb] = glyph; + } + + private: + block_allocator m_allocator; + glyph_cache** m_glyphs[256]; + char* m_font_signature; + }; + + + + + + + + //---------------------------------------------------------font_cache_pool + class font_cache_pool + { + public: + //-------------------------------------------------------------------- + ~font_cache_pool() + { + unsigned i; + for(i = 0; i < m_num_fonts; ++i) + { + obj_allocator::deallocate(m_fonts[i]); + } + pod_allocator::deallocate(m_fonts, m_max_fonts); + } + + //-------------------------------------------------------------------- + font_cache_pool(unsigned max_fonts=32) : + m_fonts(pod_allocator::allocate(max_fonts)), + m_max_fonts(max_fonts), + m_num_fonts(0), + m_cur_font(0) + {} + + + //-------------------------------------------------------------------- + void font(const char* font_signature, bool reset_cache = false) + { + int idx = find_font(font_signature); + if(idx >= 0) + { + if(reset_cache) + { + obj_allocator::deallocate(m_fonts[idx]); + m_fonts[idx] = obj_allocator::allocate(); + m_fonts[idx]->signature(font_signature); + } + m_cur_font = m_fonts[idx]; + } + else + { + if(m_num_fonts >= m_max_fonts) + { + obj_allocator::deallocate(m_fonts[0]); + memcpy(m_fonts, + m_fonts + 1, + (m_max_fonts - 1) * sizeof(font_cache*)); + m_num_fonts = m_max_fonts - 1; + } + m_fonts[m_num_fonts] = obj_allocator::allocate(); + m_fonts[m_num_fonts]->signature(font_signature); + m_cur_font = m_fonts[m_num_fonts]; + ++m_num_fonts; + } + } + + //-------------------------------------------------------------------- + const font_cache* font() const + { + return m_cur_font; + } + + //-------------------------------------------------------------------- + const glyph_cache* find_glyph(unsigned glyph_code) const + { + if(m_cur_font) return m_cur_font->find_glyph(glyph_code); + return 0; + } + + //-------------------------------------------------------------------- + glyph_cache* cache_glyph(unsigned glyph_code, + unsigned glyph_index, + unsigned data_size, + glyph_data_type data_type, + const rect_i& bounds, + double advance_x, + double advance_y) + { + if(m_cur_font) + { + return m_cur_font->cache_glyph(glyph_code, + glyph_index, + data_size, + data_type, + bounds, + advance_x, + advance_y); + } + return 0; + } + + + //-------------------------------------------------------------------- + int find_font(const char* font_signature) + { + unsigned i; + for(i = 0; i < m_num_fonts; i++) + { + if(m_fonts[i]->font_is(font_signature)) return int(i); + } + return -1; + } + + private: + font_cache** m_fonts; + unsigned m_max_fonts; + unsigned m_num_fonts; + font_cache* m_cur_font; + }; + + + + + //------------------------------------------------------------------------ + enum glyph_rendering + { + glyph_ren_native_mono, + glyph_ren_native_gray8, + glyph_ren_outline, + glyph_ren_agg_mono, + glyph_ren_agg_gray8 + }; + + + + + //------------------------------------------------------font_cache_manager + template class font_cache_manager + { + public: + typedef FontEngine font_engine_type; + typedef font_cache_manager self_type; + typedef typename font_engine_type::path_adaptor_type path_adaptor_type; + typedef typename font_engine_type::gray8_adaptor_type gray8_adaptor_type; + typedef typename gray8_adaptor_type::embedded_scanline gray8_scanline_type; + typedef typename font_engine_type::mono_adaptor_type mono_adaptor_type; + typedef typename mono_adaptor_type::embedded_scanline mono_scanline_type; + + //-------------------------------------------------------------------- + font_cache_manager(font_engine_type& engine, unsigned max_fonts=32) : + m_fonts(max_fonts), + m_engine(engine), + m_change_stamp(-1), + m_prev_glyph(0), + m_last_glyph(0) + {} + + //-------------------------------------------------------------------- + void reset_last_glyph() + { + m_prev_glyph = m_last_glyph = 0; + } + + //-------------------------------------------------------------------- + const glyph_cache* glyph(unsigned glyph_code) + { + synchronize(); + const glyph_cache* gl = m_fonts.find_glyph(glyph_code); + if(gl) + { + m_prev_glyph = m_last_glyph; + return m_last_glyph = gl; + } + else + { + if(m_engine.prepare_glyph(glyph_code)) + { + m_prev_glyph = m_last_glyph; + m_last_glyph = m_fonts.cache_glyph(glyph_code, + m_engine.glyph_index(), + m_engine.data_size(), + m_engine.data_type(), + m_engine.bounds(), + m_engine.advance_x(), + m_engine.advance_y()); + m_engine.write_glyph_to(m_last_glyph->data); + return m_last_glyph; + } + } + return 0; + } + + //-------------------------------------------------------------------- + void init_embedded_adaptors(const glyph_cache* gl, + double x, double y, + double scale=1.0) + { + if(gl) + { + switch(gl->data_type) + { + default: return; + case glyph_data_mono: + m_mono_adaptor.init(gl->data, gl->data_size, x, y); + break; + + case glyph_data_gray8: + m_gray8_adaptor.init(gl->data, gl->data_size, x, y); + break; + + case glyph_data_outline: + m_path_adaptor.init(gl->data, gl->data_size, x, y, scale); + break; + } + } + } + + + //-------------------------------------------------------------------- + path_adaptor_type& path_adaptor() { return m_path_adaptor; } + gray8_adaptor_type& gray8_adaptor() { return m_gray8_adaptor; } + gray8_scanline_type& gray8_scanline() { return m_gray8_scanline; } + mono_adaptor_type& mono_adaptor() { return m_mono_adaptor; } + mono_scanline_type& mono_scanline() { return m_mono_scanline; } + + //-------------------------------------------------------------------- + const glyph_cache* perv_glyph() const { return m_prev_glyph; } + const glyph_cache* last_glyph() const { return m_last_glyph; } + + //-------------------------------------------------------------------- + bool add_kerning(double* x, double* y) + { + if(m_prev_glyph && m_last_glyph) + { + return m_engine.add_kerning(m_prev_glyph->glyph_index, + m_last_glyph->glyph_index, + x, y); + } + return false; + } + + //-------------------------------------------------------------------- + void precache(unsigned from, unsigned to) + { + for(; from <= to; ++from) glyph(from); + } + + //-------------------------------------------------------------------- + void reset_cache() + { + m_fonts.font(m_engine.font_signature(), true); + m_change_stamp = m_engine.change_stamp(); + m_prev_glyph = m_last_glyph = 0; + } + + private: + //-------------------------------------------------------------------- + font_cache_manager(const self_type&); + const self_type& operator = (const self_type&); + + //-------------------------------------------------------------------- + void synchronize() + { + if(m_change_stamp != m_engine.change_stamp()) + { + m_fonts.font(m_engine.font_signature()); + m_change_stamp = m_engine.change_stamp(); + m_prev_glyph = m_last_glyph = 0; + } + } + + font_cache_pool m_fonts; + font_engine_type& m_engine; + int m_change_stamp; + double m_dx; + double m_dy; + const glyph_cache* m_prev_glyph; + const glyph_cache* m_last_glyph; + path_adaptor_type m_path_adaptor; + gray8_adaptor_type m_gray8_adaptor; + gray8_scanline_type m_gray8_scanline; + mono_adaptor_type m_mono_adaptor; + mono_scanline_type m_mono_scanline; + }; + +} + +#endif + diff --git a/xs/src/agg/agg_font_cache_manager2.h b/xs/src/agg/agg_font_cache_manager2.h new file mode 100644 index 0000000000..75d311eff7 --- /dev/null +++ b/xs/src/agg/agg_font_cache_manager2.h @@ -0,0 +1,311 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_FONT_CACHE_MANAGER2_INCLUDED +#define AGG_FONT_CACHE_MANAGER2_INCLUDED + +#include +#include +#include +#include "agg_array.h" + +namespace agg { + +namespace fman { + //---------------------------------------------------------glyph_data_type + enum glyph_data_type + { + glyph_data_invalid = 0, + glyph_data_mono = 1, + glyph_data_gray8 = 2, + glyph_data_outline = 3 + }; + + + //-------------------------------------------------------------cached_glyph + struct cached_glyph + { + void * cached_font; + unsigned glyph_code; + unsigned glyph_index; + int8u* data; + unsigned data_size; + glyph_data_type data_type; + rect_i bounds; + double advance_x; + double advance_y; + }; + + + //--------------------------------------------------------------cached_glyphs + class cached_glyphs + { + public: + enum block_size_e { block_size = 16384-16 }; + + //-------------------------------------------------------------------- + cached_glyphs() + : m_allocator(block_size) + { memset(m_glyphs, 0, sizeof(m_glyphs)); } + + //-------------------------------------------------------------------- + const cached_glyph* find_glyph(unsigned glyph_code) const + { + unsigned msb = (glyph_code >> 8) & 0xFF; + if(m_glyphs[msb]) + { + return m_glyphs[msb][glyph_code & 0xFF]; + } + return 0; + } + + //-------------------------------------------------------------------- + cached_glyph* cache_glyph( + void * cached_font, + unsigned glyph_code, + unsigned glyph_index, + unsigned data_size, + glyph_data_type data_type, + const rect_i& bounds, + double advance_x, + double advance_y) + { + unsigned msb = (glyph_code >> 8) & 0xFF; + if(m_glyphs[msb] == 0) + { + m_glyphs[msb] = + (cached_glyph**)m_allocator.allocate(sizeof(cached_glyph*) * 256, + sizeof(cached_glyph*)); + memset(m_glyphs[msb], 0, sizeof(cached_glyph*) * 256); + } + + unsigned lsb = glyph_code & 0xFF; + if(m_glyphs[msb][lsb]) return 0; // Already exists, do not overwrite + + cached_glyph* glyph = + (cached_glyph*)m_allocator.allocate(sizeof(cached_glyph), + sizeof(double)); + + glyph->cached_font = cached_font; + glyph->glyph_code = glyph_code; + glyph->glyph_index = glyph_index; + glyph->data = m_allocator.allocate(data_size); + glyph->data_size = data_size; + glyph->data_type = data_type; + glyph->bounds = bounds; + glyph->advance_x = advance_x; + glyph->advance_y = advance_y; + return m_glyphs[msb][lsb] = glyph; + } + + private: + block_allocator m_allocator; + cached_glyph** m_glyphs[256]; + }; + + + + //------------------------------------------------------------------------ + enum glyph_rendering + { + glyph_ren_native_mono, + glyph_ren_native_gray8, + glyph_ren_outline, + glyph_ren_agg_mono, + glyph_ren_agg_gray8 + }; + + + + + //------------------------------------------------------font_cache_manager + template class font_cache_manager + { + public: + typedef FontEngine font_engine_type; + typedef font_cache_manager self_type; + typedef typename font_engine_type::path_adaptor_type path_adaptor_type; + typedef typename font_engine_type::gray8_adaptor_type gray8_adaptor_type; + typedef typename gray8_adaptor_type::embedded_scanline gray8_scanline_type; + typedef typename font_engine_type::mono_adaptor_type mono_adaptor_type; + typedef typename mono_adaptor_type::embedded_scanline mono_scanline_type; + + struct cached_font + { + cached_font( + font_engine_type& engine, + typename FontEngine::loaded_face *face, + double height, + double width, + bool hinting, + glyph_rendering rendering ) + : m_engine( engine ) + , m_face( face ) + , m_height( height ) + , m_width( width ) + , m_hinting( hinting ) + , m_rendering( rendering ) + { + select_face(); + m_face_height=m_face->height(); + m_face_width=m_face->width(); + m_face_ascent=m_face->ascent(); + m_face_descent=m_face->descent(); + m_face_ascent_b=m_face->ascent_b(); + m_face_descent_b=m_face->descent_b(); + } + + double height() const + { + return m_face_height; + } + + double width() const + { + return m_face_width; + } + + double ascent() const + { + return m_face_ascent; + } + + double descent() const + { + return m_face_descent; + } + + double ascent_b() const + { + return m_face_ascent_b; + } + + double descent_b() const + { + return m_face_descent_b; + } + + bool add_kerning( const cached_glyph *first, const cached_glyph *second, double* x, double* y) + { + if( !first || !second ) + return false; + select_face(); + return m_face->add_kerning( + first->glyph_index, second->glyph_index, x, y ); + } + + void select_face() + { + m_face->select_instance( m_height, m_width, m_hinting, m_rendering ); + } + + const cached_glyph *get_glyph(unsigned cp) + { + const cached_glyph *glyph=m_glyphs.find_glyph(cp); + if( glyph==0 ) + { + typename FontEngine::prepared_glyph prepared; + select_face(); + bool success=m_face->prepare_glyph(cp, &prepared); + if( success ) + { + glyph=m_glyphs.cache_glyph( + this, + prepared.glyph_code, + prepared.glyph_index, + prepared.data_size, + prepared.data_type, + prepared.bounds, + prepared.advance_x, + prepared.advance_y ); + assert( glyph!=0 ); + m_face->write_glyph_to(&prepared,glyph->data); + } + } + return glyph; + } + + font_engine_type& m_engine; + typename FontEngine::loaded_face *m_face; + double m_height; + double m_width; + bool m_hinting; + glyph_rendering m_rendering; + double m_face_height; + double m_face_width; + double m_face_ascent; + double m_face_descent; + double m_face_ascent_b; + double m_face_descent_b; + cached_glyphs m_glyphs; + }; + + //-------------------------------------------------------------------- + font_cache_manager(font_engine_type& engine, unsigned max_fonts=32) + :m_engine(engine) + { } + + //-------------------------------------------------------------------- + void init_embedded_adaptors(const cached_glyph* gl, + double x, double y, + double scale=1.0) + { + if(gl) + { + switch(gl->data_type) + { + default: return; + case glyph_data_mono: + m_mono_adaptor.init(gl->data, gl->data_size, x, y); + break; + + case glyph_data_gray8: + m_gray8_adaptor.init(gl->data, gl->data_size, x, y); + break; + + case glyph_data_outline: + m_path_adaptor.init(gl->data, gl->data_size, x, y, scale); + break; + } + } + } + + + //-------------------------------------------------------------------- + path_adaptor_type& path_adaptor() { return m_path_adaptor; } + gray8_adaptor_type& gray8_adaptor() { return m_gray8_adaptor; } + gray8_scanline_type& gray8_scanline() { return m_gray8_scanline; } + mono_adaptor_type& mono_adaptor() { return m_mono_adaptor; } + mono_scanline_type& mono_scanline() { return m_mono_scanline; } + + + private: + //-------------------------------------------------------------------- + font_cache_manager(const self_type&); + const self_type& operator = (const self_type&); + + font_engine_type& m_engine; + path_adaptor_type m_path_adaptor; + gray8_adaptor_type m_gray8_adaptor; + gray8_scanline_type m_gray8_scanline; + mono_adaptor_type m_mono_adaptor; + mono_scanline_type m_mono_scanline; + }; + +} +} + +#endif + diff --git a/xs/src/agg/agg_gamma_functions.h b/xs/src/agg/agg_gamma_functions.h new file mode 100644 index 0000000000..5d720daa9a --- /dev/null +++ b/xs/src/agg/agg_gamma_functions.h @@ -0,0 +1,132 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_GAMMA_FUNCTIONS_INCLUDED +#define AGG_GAMMA_FUNCTIONS_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + //===============================================================gamma_none + struct gamma_none + { + double operator()(double x) const { return x; } + }; + + + //==============================================================gamma_power + class gamma_power + { + public: + gamma_power() : m_gamma(1.0) {} + gamma_power(double g) : m_gamma(g) {} + + void gamma(double g) { m_gamma = g; } + double gamma() const { return m_gamma; } + + double operator() (double x) const + { + return pow(x, m_gamma); + } + + private: + double m_gamma; + }; + + + //==========================================================gamma_threshold + class gamma_threshold + { + public: + gamma_threshold() : m_threshold(0.5) {} + gamma_threshold(double t) : m_threshold(t) {} + + void threshold(double t) { m_threshold = t; } + double threshold() const { return m_threshold; } + + double operator() (double x) const + { + return (x < m_threshold) ? 0.0 : 1.0; + } + + private: + double m_threshold; + }; + + + //============================================================gamma_linear + class gamma_linear + { + public: + gamma_linear() : m_start(0.0), m_end(1.0) {} + gamma_linear(double s, double e) : m_start(s), m_end(e) {} + + void set(double s, double e) { m_start = s; m_end = e; } + void start(double s) { m_start = s; } + void end(double e) { m_end = e; } + double start() const { return m_start; } + double end() const { return m_end; } + + double operator() (double x) const + { + if(x < m_start) return 0.0; + if(x > m_end) return 1.0; + return (x - m_start) / (m_end - m_start); + } + + private: + double m_start; + double m_end; + }; + + + //==========================================================gamma_multiply + class gamma_multiply + { + public: + gamma_multiply() : m_mul(1.0) {} + gamma_multiply(double v) : m_mul(v) {} + + void value(double v) { m_mul = v; } + double value() const { return m_mul; } + + double operator() (double x) const + { + double y = x * m_mul; + if(y > 1.0) y = 1.0; + return y; + } + + private: + double m_mul; + }; + + inline double sRGB_to_linear(double x) + { + return (x <= 0.04045) ? (x / 12.92) : pow((x + 0.055) / (1.055), 2.4); + } + + inline double linear_to_sRGB(double x) + { + return (x <= 0.0031308) ? (x * 12.92) : (1.055 * pow(x, 1 / 2.4) - 0.055); + } +} + +#endif + + + diff --git a/xs/src/agg/agg_gamma_lut.h b/xs/src/agg/agg_gamma_lut.h new file mode 100644 index 0000000000..e30873632a --- /dev/null +++ b/xs/src/agg/agg_gamma_lut.h @@ -0,0 +1,300 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_GAMMA_LUT_INCLUDED +#define AGG_GAMMA_LUT_INCLUDED + +#include +#include "agg_basics.h" +#include "agg_gamma_functions.h" + +namespace agg +{ + template class gamma_lut + { + public: + typedef gamma_lut self_type; + + enum gamma_scale_e + { + gamma_shift = GammaShift, + gamma_size = 1 << gamma_shift, + gamma_mask = gamma_size - 1 + }; + + enum hi_res_scale_e + { + hi_res_shift = HiResShift, + hi_res_size = 1 << hi_res_shift, + hi_res_mask = hi_res_size - 1 + }; + + ~gamma_lut() + { + pod_allocator::deallocate(m_inv_gamma, hi_res_size); + pod_allocator::deallocate(m_dir_gamma, gamma_size); + } + + gamma_lut() : + m_gamma(1.0), + m_dir_gamma(pod_allocator::allocate(gamma_size)), + m_inv_gamma(pod_allocator::allocate(hi_res_size)) + { + unsigned i; + for(i = 0; i < gamma_size; i++) + { + m_dir_gamma[i] = HiResT(i << (hi_res_shift - gamma_shift)); + } + + for(i = 0; i < hi_res_size; i++) + { + m_inv_gamma[i] = LoResT(i >> (hi_res_shift - gamma_shift)); + } + } + + gamma_lut(double g) : + m_gamma(1.0), + m_dir_gamma(pod_allocator::allocate(gamma_size)), + m_inv_gamma(pod_allocator::allocate(hi_res_size)) + { + gamma(g); + } + + void gamma(double g) + { + m_gamma = g; + + unsigned i; + for(i = 0; i < gamma_size; i++) + { + m_dir_gamma[i] = (HiResT) + uround(pow(i / double(gamma_mask), m_gamma) * double(hi_res_mask)); + } + + double inv_g = 1.0 / g; + for(i = 0; i < hi_res_size; i++) + { + m_inv_gamma[i] = (LoResT) + uround(pow(i / double(hi_res_mask), inv_g) * double(gamma_mask)); + } + } + + double gamma() const + { + return m_gamma; + } + + HiResT dir(LoResT v) const + { + return m_dir_gamma[unsigned(v)]; + } + + LoResT inv(HiResT v) const + { + return m_inv_gamma[unsigned(v)]; + } + + private: + gamma_lut(const self_type&); + const self_type& operator = (const self_type&); + + double m_gamma; + HiResT* m_dir_gamma; + LoResT* m_inv_gamma; + }; + + // + // sRGB support classes + // + + // sRGB_lut - implements sRGB conversion for the various types. + // Base template is undefined, specializations are provided below. + template + class sRGB_lut; + + template<> + class sRGB_lut + { + public: + sRGB_lut() + { + // Generate lookup tables. + for (int i = 0; i <= 255; ++i) + { + m_dir_table[i] = float(sRGB_to_linear(i / 255.0)); + } + for (int i = 0; i <= 65535; ++i) + { + m_inv_table[i] = uround(255.0 * linear_to_sRGB(i / 65535.0)); + } + } + + float dir(int8u v) const + { + return m_dir_table[v]; + } + + int8u inv(float v) const + { + return m_inv_table[int16u(0.5 + v * 65535)]; + } + + private: + float m_dir_table[256]; + int8u m_inv_table[65536]; + }; + + template<> + class sRGB_lut + { + public: + sRGB_lut() + { + // Generate lookup tables. + for (int i = 0; i <= 255; ++i) + { + m_dir_table[i] = uround(65535.0 * sRGB_to_linear(i / 255.0)); + } + for (int i = 0; i <= 65535; ++i) + { + m_inv_table[i] = uround(255.0 * linear_to_sRGB(i / 65535.0)); + } + } + + int16u dir(int8u v) const + { + return m_dir_table[v]; + } + + int8u inv(int16u v) const + { + return m_inv_table[v]; + } + + private: + int16u m_dir_table[256]; + int8u m_inv_table[65536]; + }; + + template<> + class sRGB_lut + { + public: + sRGB_lut() + { + // Generate lookup tables. + for (int i = 0; i <= 255; ++i) + { + m_dir_table[i] = uround(255.0 * sRGB_to_linear(i / 255.0)); + m_inv_table[i] = uround(255.0 * linear_to_sRGB(i / 255.0)); + } + } + + int8u dir(int8u v) const + { + return m_dir_table[v]; + } + + int8u inv(int8u v) const + { + return m_inv_table[v]; + } + + private: + int8u m_dir_table[256]; + int8u m_inv_table[256]; + }; + + // Common base class for sRGB_conv objects. Defines an internal + // sRGB_lut object so that users don't have to. + template + class sRGB_conv_base + { + public: + static T rgb_from_sRGB(int8u x) + { + return lut.dir(x); + } + + static int8u rgb_to_sRGB(T x) + { + return lut.inv(x); + } + + private: + static sRGB_lut lut; + }; + + // Definition of sRGB_conv_base::lut. Due to the fact that this a template, + // we don't need to place the definition in a cpp file. Hurrah. + template + sRGB_lut sRGB_conv_base::lut; + + // Wrapper for sRGB-linear conversion. + // Base template is undefined, specializations are provided below. + template + class sRGB_conv; + + template<> + class sRGB_conv : public sRGB_conv_base + { + public: + static float alpha_from_sRGB(int8u x) + { + static const double y = 1 / 255.0; + return float(x * y); + } + + static int8u alpha_to_sRGB(float x) + { + return int8u(0.5 + x * 255); + } + }; + + template<> + class sRGB_conv : public sRGB_conv_base + { + public: + static int16u alpha_from_sRGB(int8u x) + { + return (x << 8) | x; + } + + static int8u alpha_to_sRGB(int16u x) + { + return x >> 8; + } + }; + + template<> + class sRGB_conv : public sRGB_conv_base + { + public: + static int8u alpha_from_sRGB(int8u x) + { + return x; + } + + static int8u alpha_to_sRGB(int8u x) + { + return x; + } + }; +} + +#endif diff --git a/xs/src/agg/agg_glyph_raster_bin.h b/xs/src/agg/agg_glyph_raster_bin.h new file mode 100644 index 0000000000..b0bf858efd --- /dev/null +++ b/xs/src/agg/agg_glyph_raster_bin.h @@ -0,0 +1,155 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_GLYPH_RASTER_BIN_INCLUDED +#define AGG_GLYPH_RASTER_BIN_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + + //========================================================glyph_raster_bin + template class glyph_raster_bin + { + public: + typedef ColorT color_type; + + //-------------------------------------------------------------------- + struct glyph_rect + { + int x1,y1,x2,y2; + double dx, dy; + }; + + //-------------------------------------------------------------------- + glyph_raster_bin(const int8u* font) : + m_font(font), + m_big_endian(false) + { + int t = 1; + if(*(char*)&t == 0) m_big_endian = true; + memset(m_span, 0, sizeof(m_span)); + } + + //-------------------------------------------------------------------- + const int8u* font() const { return m_font; } + void font(const int8u* f) { m_font = f; } + + //-------------------------------------------------------------------- + double height() const { return m_font[0]; } + double base_line() const { return m_font[1]; } + + //-------------------------------------------------------------------- + template + double width(const CharT* str) const + { + unsigned start_char = m_font[2]; + unsigned num_chars = m_font[3]; + + unsigned w = 0; + while(*str) + { + unsigned glyph = *str; + const int8u* bits = m_font + 4 + num_chars * 2 + + value(m_font + 4 + (glyph - start_char) * 2); + w += *bits; + ++str; + } + return w; + } + + //-------------------------------------------------------------------- + void prepare(glyph_rect* r, double x, double y, unsigned glyph, bool flip) + { + unsigned start_char = m_font[2]; + unsigned num_chars = m_font[3]; + + m_bits = m_font + 4 + num_chars * 2 + + value(m_font + 4 + (glyph - start_char) * 2); + + m_glyph_width = *m_bits++; + m_glyph_byte_width = (m_glyph_width + 7) >> 3; + + r->x1 = int(x); + r->x2 = r->x1 + m_glyph_width - 1; + if(flip) + { + r->y1 = int(y) - m_font[0] + m_font[1]; + r->y2 = r->y1 + m_font[0] - 1; + } + else + { + r->y1 = int(y) - m_font[1] + 1; + r->y2 = r->y1 + m_font[0] - 1; + } + r->dx = m_glyph_width; + r->dy = 0; + } + + //-------------------------------------------------------------------- + const cover_type* span(unsigned i) + { + i = m_font[0] - i - 1; + const int8u* bits = m_bits + i * m_glyph_byte_width; + unsigned j; + unsigned val = *bits; + unsigned nb = 0; + for(j = 0; j < m_glyph_width; ++j) + { + m_span[j] = (cover_type)((val & 0x80) ? cover_full : cover_none); + val <<= 1; + if(++nb >= 8) + { + val = *++bits; + nb = 0; + } + } + return m_span; + } + + private: + //-------------------------------------------------------------------- + int16u value(const int8u* p) const + { + int16u v; + if(m_big_endian) + { + *(int8u*)&v = p[1]; + *((int8u*)&v + 1) = p[0]; + } + else + { + *(int8u*)&v = p[0]; + *((int8u*)&v + 1) = p[1]; + } + return v; + } + + + //-------------------------------------------------------------------- + const int8u* m_font; + bool m_big_endian; + cover_type m_span[32]; + const int8u* m_bits; + unsigned m_glyph_width; + unsigned m_glyph_byte_width; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_gradient_lut.h b/xs/src/agg/agg_gradient_lut.h new file mode 100644 index 0000000000..9aaa426815 --- /dev/null +++ b/xs/src/agg/agg_gradient_lut.h @@ -0,0 +1,244 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_GRADIENT_LUT_INCLUDED +#define AGG_GRADIENT_LUT_INCLUDED + +#include "agg_array.h" +#include "agg_dda_line.h" +#include "agg_color_rgba.h" +#include "agg_color_gray.h" + +namespace agg +{ + + //======================================================color_interpolator + template struct color_interpolator + { + public: + typedef ColorT color_type; + + color_interpolator(const color_type& c1, + const color_type& c2, + unsigned len) : + m_c1(c1), + m_c2(c2), + m_len(len), + m_count(0) + {} + + void operator ++ () + { + ++m_count; + } + + color_type color() const + { + return m_c1.gradient(m_c2, double(m_count) / m_len); + } + + private: + color_type m_c1; + color_type m_c2; + unsigned m_len; + unsigned m_count; + }; + + //======================================================================== + // Fast specialization for rgba8 + template<> struct color_interpolator + { + public: + typedef rgba8 color_type; + + color_interpolator(const color_type& c1, + const color_type& c2, + unsigned len) : + r(c1.r, c2.r, len), + g(c1.g, c2.g, len), + b(c1.b, c2.b, len), + a(c1.a, c2.a, len) + {} + + void operator ++ () + { + ++r; ++g; ++b; ++a; + } + + color_type color() const + { + return color_type(r.y(), g.y(), b.y(), a.y()); + } + + private: + agg::dda_line_interpolator<14> r, g, b, a; + }; + + //======================================================================== + // Fast specialization for gray8 + template<> struct color_interpolator + { + public: + typedef gray8 color_type; + + color_interpolator(const color_type& c1, + const color_type& c2, + unsigned len) : + v(c1.v, c2.v, len), + a(c1.a, c2.a, len) + {} + + void operator ++ () + { + ++v; ++a; + } + + color_type color() const + { + return color_type(v.y(), a.y()); + } + + private: + agg::dda_line_interpolator<14> v,a; + }; + + //============================================================gradient_lut + template class gradient_lut + { + public: + typedef ColorInterpolator interpolator_type; + typedef typename interpolator_type::color_type color_type; + enum { color_lut_size = ColorLutSize }; + + //-------------------------------------------------------------------- + gradient_lut() : m_color_lut(color_lut_size) {} + + // Build Gradient Lut + // First, call remove_all(), then add_color() at least twice, + // then build_lut(). Argument "offset" in add_color must be + // in range [0...1] and defines a color stop as it is described + // in SVG specification, section Gradients and Patterns. + // The simplest linear gradient is: + // gradient_lut.add_color(0.0, start_color); + // gradient_lut.add_color(1.0, end_color); + //-------------------------------------------------------------------- + void remove_all(); + void add_color(double offset, const color_type& color); + void build_lut(); + + // Size-index Interface. This class can be used directly as the + // ColorF in span_gradient. All it needs is two access methods + // size() and operator []. + //-------------------------------------------------------------------- + static unsigned size() + { + return color_lut_size; + } + const color_type& operator [] (unsigned i) const + { + return m_color_lut[i]; + } + + private: + //-------------------------------------------------------------------- + struct color_point + { + double offset; + color_type color; + + color_point() {} + color_point(double off, const color_type& c) : + offset(off), color(c) + { + if(offset < 0.0) offset = 0.0; + if(offset > 1.0) offset = 1.0; + } + }; + typedef agg::pod_bvector color_profile_type; + typedef agg::pod_array color_lut_type; + + static bool offset_less(const color_point& a, const color_point& b) + { + return a.offset < b.offset; + } + static bool offset_equal(const color_point& a, const color_point& b) + { + return a.offset == b.offset; + } + + //-------------------------------------------------------------------- + color_profile_type m_color_profile; + color_lut_type m_color_lut; + }; + + + + //------------------------------------------------------------------------ + template + void gradient_lut::remove_all() + { + m_color_profile.remove_all(); + } + + //------------------------------------------------------------------------ + template + void gradient_lut::add_color(double offset, const color_type& color) + { + m_color_profile.add(color_point(offset, color)); + } + + //------------------------------------------------------------------------ + template + void gradient_lut::build_lut() + { + quick_sort(m_color_profile, offset_less); + m_color_profile.cut_at(remove_duplicates(m_color_profile, offset_equal)); + if(m_color_profile.size() >= 2) + { + unsigned i; + unsigned start = uround(m_color_profile[0].offset * color_lut_size); + unsigned end; + color_type c = m_color_profile[0].color; + for(i = 0; i < start; i++) + { + m_color_lut[i] = c; + } + for(i = 1; i < m_color_profile.size(); i++) + { + end = uround(m_color_profile[i].offset * color_lut_size); + interpolator_type ci(m_color_profile[i-1].color, + m_color_profile[i ].color, + end - start + 1); + while(start < end) + { + m_color_lut[start] = ci.color(); + ++ci; + ++start; + } + } + c = m_color_profile.last().color; + for(; end < m_color_lut.size(); end++) + { + m_color_lut[end] = c; + } + } + } +} + + + + +#endif diff --git a/xs/src/agg/agg_gsv_text.h b/xs/src/agg/agg_gsv_text.h new file mode 100644 index 0000000000..16b3aeb33d --- /dev/null +++ b/xs/src/agg/agg_gsv_text.h @@ -0,0 +1,153 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Class gsv_text +// +//---------------------------------------------------------------------------- + +#ifndef AGG_GSV_TEXT_INCLUDED +#define AGG_GSV_TEXT_INCLUDED + +#include "agg_array.h" +#include "agg_conv_stroke.h" +#include "agg_conv_transform.h" + +namespace agg +{ + + + //---------------------------------------------------------------gsv_text + // + // See Implementation agg_gsv_text.cpp + // + class gsv_text + { + enum status + { + initial, + next_char, + start_glyph, + glyph + }; + + public: + gsv_text(); + + void font(const void* font); + void flip(bool flip_y) { m_flip = flip_y; } + void load_font(const char* file); + void size(double height, double width=0.0); + void space(double space); + void line_space(double line_space); + void start_point(double x, double y); + void text(const char* text); + + double text_width(); + + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + // not supposed to be copied + gsv_text(const gsv_text&); + const gsv_text& operator = (const gsv_text&); + + int16u value(const int8u* p) const + { + int16u v; + if(m_big_endian) + { + *(int8u*)&v = p[1]; + *((int8u*)&v + 1) = p[0]; + } + else + { + *(int8u*)&v = p[0]; + *((int8u*)&v + 1) = p[1]; + } + return v; + } + + private: + double m_x; + double m_y; + double m_start_x; + double m_width; + double m_height; + double m_space; + double m_line_space; + char m_chr[2]; + char* m_text; + pod_array m_text_buf; + char* m_cur_chr; + const void* m_font; + pod_array m_loaded_font; + status m_status; + bool m_big_endian; + bool m_flip; + int8u* m_indices; + int8* m_glyphs; + int8* m_bglyph; + int8* m_eglyph; + double m_w; + double m_h; + }; + + + + + //--------------------------------------------------------gsv_text_outline + template class gsv_text_outline + { + public: + gsv_text_outline(gsv_text& text, Transformer& trans) : + m_polyline(text), + m_trans(m_polyline, trans) + { + } + + void width(double w) + { + m_polyline.width(w); + } + + void transformer(const Transformer* trans) + { + m_trans->transformer(trans); + } + + void rewind(unsigned path_id) + { + m_trans.rewind(path_id); + m_polyline.line_join(round_join); + m_polyline.line_cap(round_cap); + } + + unsigned vertex(double* x, double* y) + { + return m_trans.vertex(x, y); + } + + private: + conv_stroke m_polyline; + conv_transform, Transformer> m_trans; + }; + + + +} + + +#endif diff --git a/xs/src/agg/agg_image_accessors.h b/xs/src/agg/agg_image_accessors.h new file mode 100644 index 0000000000..c651d6d2e8 --- /dev/null +++ b/xs/src/agg/agg_image_accessors.h @@ -0,0 +1,481 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_IMAGE_ACCESSORS_INCLUDED +#define AGG_IMAGE_ACCESSORS_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //-----------------------------------------------------image_accessor_clip + template class image_accessor_clip + { + public: + typedef PixFmt pixfmt_type; + typedef typename pixfmt_type::color_type color_type; + typedef typename pixfmt_type::order_type order_type; + typedef typename pixfmt_type::value_type value_type; + enum pix_width_e { pix_width = pixfmt_type::pix_width }; + + image_accessor_clip() {} + explicit image_accessor_clip(pixfmt_type& pixf, + const color_type& bk) : + m_pixf(&pixf) + { + pixfmt_type::make_pix(m_bk_buf, bk); + } + + void attach(pixfmt_type& pixf) + { + m_pixf = &pixf; + } + + void background_color(const color_type& bk) + { + pixfmt_type::make_pix(m_bk_buf, bk); + } + + private: + AGG_INLINE const int8u* pixel() const + { + if(m_y >= 0 && m_y < (int)m_pixf->height() && + m_x >= 0 && m_x < (int)m_pixf->width()) + { + return m_pixf->pix_ptr(m_x, m_y); + } + return m_bk_buf; + } + + public: + AGG_INLINE const int8u* span(int x, int y, unsigned len) + { + m_x = m_x0 = x; + m_y = y; + if(y >= 0 && y < (int)m_pixf->height() && + x >= 0 && x+(int)len <= (int)m_pixf->width()) + { + return m_pix_ptr = m_pixf->pix_ptr(x, y); + } + m_pix_ptr = 0; + return pixel(); + } + + AGG_INLINE const int8u* next_x() + { + if(m_pix_ptr) return m_pix_ptr += pix_width; + ++m_x; + return pixel(); + } + + AGG_INLINE const int8u* next_y() + { + ++m_y; + m_x = m_x0; + if(m_pix_ptr && + m_y >= 0 && m_y < (int)m_pixf->height()) + { + return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); + } + m_pix_ptr = 0; + return pixel(); + } + + private: + const pixfmt_type* m_pixf; + int8u m_bk_buf[pix_width]; + int m_x, m_x0, m_y; + const int8u* m_pix_ptr; + }; + + + + + //--------------------------------------------------image_accessor_no_clip + template class image_accessor_no_clip + { + public: + typedef PixFmt pixfmt_type; + typedef typename pixfmt_type::color_type color_type; + typedef typename pixfmt_type::order_type order_type; + typedef typename pixfmt_type::value_type value_type; + enum pix_width_e { pix_width = pixfmt_type::pix_width }; + + image_accessor_no_clip() {} + explicit image_accessor_no_clip(pixfmt_type& pixf) : + m_pixf(&pixf) + {} + + void attach(pixfmt_type& pixf) + { + m_pixf = &pixf; + } + + AGG_INLINE const int8u* span(int x, int y, unsigned) + { + m_x = x; + m_y = y; + return m_pix_ptr = m_pixf->pix_ptr(x, y); + } + + AGG_INLINE const int8u* next_x() + { + return m_pix_ptr += pix_width; + } + + AGG_INLINE const int8u* next_y() + { + ++m_y; + return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); + } + + private: + const pixfmt_type* m_pixf; + int m_x, m_y; + const int8u* m_pix_ptr; + }; + + + + + //----------------------------------------------------image_accessor_clone + template class image_accessor_clone + { + public: + typedef PixFmt pixfmt_type; + typedef typename pixfmt_type::color_type color_type; + typedef typename pixfmt_type::order_type order_type; + typedef typename pixfmt_type::value_type value_type; + enum pix_width_e { pix_width = pixfmt_type::pix_width }; + + image_accessor_clone() {} + explicit image_accessor_clone(pixfmt_type& pixf) : + m_pixf(&pixf) + {} + + void attach(pixfmt_type& pixf) + { + m_pixf = &pixf; + } + + private: + AGG_INLINE const int8u* pixel() const + { + int x = m_x; + int y = m_y; + if(x < 0) x = 0; + if(y < 0) y = 0; + if(x >= (int)m_pixf->width()) x = m_pixf->width() - 1; + if(y >= (int)m_pixf->height()) y = m_pixf->height() - 1; + return m_pixf->pix_ptr(x, y); + } + + public: + AGG_INLINE const int8u* span(int x, int y, unsigned len) + { + m_x = m_x0 = x; + m_y = y; + if(y >= 0 && y < (int)m_pixf->height() && + x >= 0 && x+len <= (int)m_pixf->width()) + { + return m_pix_ptr = m_pixf->pix_ptr(x, y); + } + m_pix_ptr = 0; + return pixel(); + } + + AGG_INLINE const int8u* next_x() + { + if(m_pix_ptr) return m_pix_ptr += pix_width; + ++m_x; + return pixel(); + } + + AGG_INLINE const int8u* next_y() + { + ++m_y; + m_x = m_x0; + if(m_pix_ptr && + m_y >= 0 && m_y < (int)m_pixf->height()) + { + return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); + } + m_pix_ptr = 0; + return pixel(); + } + + private: + const pixfmt_type* m_pixf; + int m_x, m_x0, m_y; + const int8u* m_pix_ptr; + }; + + + + + + //-----------------------------------------------------image_accessor_wrap + template class image_accessor_wrap + { + public: + typedef PixFmt pixfmt_type; + typedef typename pixfmt_type::color_type color_type; + typedef typename pixfmt_type::order_type order_type; + typedef typename pixfmt_type::value_type value_type; + enum pix_width_e { pix_width = pixfmt_type::pix_width }; + + image_accessor_wrap() {} + explicit image_accessor_wrap(pixfmt_type& pixf) : + m_pixf(&pixf), + m_wrap_x(pixf.width()), + m_wrap_y(pixf.height()) + {} + + void attach(pixfmt_type& pixf) + { + m_pixf = &pixf; + } + + AGG_INLINE const int8u* span(int x, int y, unsigned) + { + m_x = x; + m_row_ptr = m_pixf->pix_ptr(0, m_wrap_y(y)); + return m_row_ptr + m_wrap_x(x) * pix_width; + } + + AGG_INLINE const int8u* next_x() + { + int x = ++m_wrap_x; + return m_row_ptr + x * pix_width; + } + + AGG_INLINE const int8u* next_y() + { + m_row_ptr = m_pixf->pix_ptr(0, ++m_wrap_y); + return m_row_ptr + m_wrap_x(m_x) * pix_width; + } + + private: + const pixfmt_type* m_pixf; + const int8u* m_row_ptr; + int m_x; + WrapX m_wrap_x; + WrapY m_wrap_y; + }; + + + + + //--------------------------------------------------------wrap_mode_repeat + class wrap_mode_repeat + { + public: + wrap_mode_repeat() {} + wrap_mode_repeat(unsigned size) : + m_size(size), + m_add(size * (0x3FFFFFFF / size)), + m_value(0) + {} + + AGG_INLINE unsigned operator() (int v) + { + return m_value = (unsigned(v) + m_add) % m_size; + } + + AGG_INLINE unsigned operator++ () + { + ++m_value; + if(m_value >= m_size) m_value = 0; + return m_value; + } + private: + unsigned m_size; + unsigned m_add; + unsigned m_value; + }; + + + //---------------------------------------------------wrap_mode_repeat_pow2 + class wrap_mode_repeat_pow2 + { + public: + wrap_mode_repeat_pow2() {} + wrap_mode_repeat_pow2(unsigned size) : m_value(0) + { + m_mask = 1; + while(m_mask < size) m_mask = (m_mask << 1) | 1; + m_mask >>= 1; + } + AGG_INLINE unsigned operator() (int v) + { + return m_value = unsigned(v) & m_mask; + } + AGG_INLINE unsigned operator++ () + { + ++m_value; + if(m_value > m_mask) m_value = 0; + return m_value; + } + private: + unsigned m_mask; + unsigned m_value; + }; + + + //----------------------------------------------wrap_mode_repeat_auto_pow2 + class wrap_mode_repeat_auto_pow2 + { + public: + wrap_mode_repeat_auto_pow2() {} + wrap_mode_repeat_auto_pow2(unsigned size) : + m_size(size), + m_add(size * (0x3FFFFFFF / size)), + m_mask((m_size & (m_size-1)) ? 0 : m_size-1), + m_value(0) + {} + + AGG_INLINE unsigned operator() (int v) + { + if(m_mask) return m_value = unsigned(v) & m_mask; + return m_value = (unsigned(v) + m_add) % m_size; + } + AGG_INLINE unsigned operator++ () + { + ++m_value; + if(m_value >= m_size) m_value = 0; + return m_value; + } + + private: + unsigned m_size; + unsigned m_add; + unsigned m_mask; + unsigned m_value; + }; + + + //-------------------------------------------------------wrap_mode_reflect + class wrap_mode_reflect + { + public: + wrap_mode_reflect() {} + wrap_mode_reflect(unsigned size) : + m_size(size), + m_size2(size * 2), + m_add(m_size2 * (0x3FFFFFFF / m_size2)), + m_value(0) + {} + + AGG_INLINE unsigned operator() (int v) + { + m_value = (unsigned(v) + m_add) % m_size2; + if(m_value >= m_size) return m_size2 - m_value - 1; + return m_value; + } + + AGG_INLINE unsigned operator++ () + { + ++m_value; + if(m_value >= m_size2) m_value = 0; + if(m_value >= m_size) return m_size2 - m_value - 1; + return m_value; + } + private: + unsigned m_size; + unsigned m_size2; + unsigned m_add; + unsigned m_value; + }; + + + + //--------------------------------------------------wrap_mode_reflect_pow2 + class wrap_mode_reflect_pow2 + { + public: + wrap_mode_reflect_pow2() {} + wrap_mode_reflect_pow2(unsigned size) : m_value(0) + { + m_mask = 1; + m_size = 1; + while(m_mask < size) + { + m_mask = (m_mask << 1) | 1; + m_size <<= 1; + } + } + AGG_INLINE unsigned operator() (int v) + { + m_value = unsigned(v) & m_mask; + if(m_value >= m_size) return m_mask - m_value; + return m_value; + } + AGG_INLINE unsigned operator++ () + { + ++m_value; + m_value &= m_mask; + if(m_value >= m_size) return m_mask - m_value; + return m_value; + } + private: + unsigned m_size; + unsigned m_mask; + unsigned m_value; + }; + + + + //---------------------------------------------wrap_mode_reflect_auto_pow2 + class wrap_mode_reflect_auto_pow2 + { + public: + wrap_mode_reflect_auto_pow2() {} + wrap_mode_reflect_auto_pow2(unsigned size) : + m_size(size), + m_size2(size * 2), + m_add(m_size2 * (0x3FFFFFFF / m_size2)), + m_mask((m_size2 & (m_size2-1)) ? 0 : m_size2-1), + m_value(0) + {} + + AGG_INLINE unsigned operator() (int v) + { + m_value = m_mask ? unsigned(v) & m_mask : + (unsigned(v) + m_add) % m_size2; + if(m_value >= m_size) return m_size2 - m_value - 1; + return m_value; + } + AGG_INLINE unsigned operator++ () + { + ++m_value; + if(m_value >= m_size2) m_value = 0; + if(m_value >= m_size) return m_size2 - m_value - 1; + return m_value; + } + + private: + unsigned m_size; + unsigned m_size2; + unsigned m_add; + unsigned m_mask; + unsigned m_value; + }; + + +} + + +#endif diff --git a/xs/src/agg/agg_image_filters.h b/xs/src/agg/agg_image_filters.h new file mode 100644 index 0000000000..0e7c598daf --- /dev/null +++ b/xs/src/agg/agg_image_filters.h @@ -0,0 +1,449 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Image transformation filters, +// Filtering classes (image_filter_lut, image_filter), +// Basic filter shape classes +//---------------------------------------------------------------------------- +#ifndef AGG_IMAGE_FILTERS_INCLUDED +#define AGG_IMAGE_FILTERS_INCLUDED + +#include "agg_array.h" +#include "agg_math.h" + +namespace agg +{ + + // See Implementation agg_image_filters.cpp + + enum image_filter_scale_e + { + image_filter_shift = 14, //----image_filter_shift + image_filter_scale = 1 << image_filter_shift, //----image_filter_scale + image_filter_mask = image_filter_scale - 1 //----image_filter_mask + }; + + enum image_subpixel_scale_e + { + image_subpixel_shift = 8, //----image_subpixel_shift + image_subpixel_scale = 1 << image_subpixel_shift, //----image_subpixel_scale + image_subpixel_mask = image_subpixel_scale - 1 //----image_subpixel_mask + }; + + + //-----------------------------------------------------image_filter_lut + class image_filter_lut + { + public: + template void calculate(const FilterF& filter, + bool normalization=true) + { + filter; // prevent erroneous C4100 in MSVC + double r = filter.radius(); + realloc_lut(r); + unsigned i; + unsigned pivot = diameter() << (image_subpixel_shift - 1); + for(i = 0; i < pivot; i++) + { + double x = double(i) / double(image_subpixel_scale); + double y = filter.calc_weight(x); + m_weight_array[pivot + i] = + m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale); + } + unsigned end = (diameter() << image_subpixel_shift) - 1; + m_weight_array[0] = m_weight_array[end]; + if(normalization) + { + normalize(); + } + } + + image_filter_lut() : m_radius(0), m_diameter(0), m_start(0) {} + + template image_filter_lut(const FilterF& filter, + bool normalization=true) + { + calculate(filter, normalization); + } + + double radius() const { return m_radius; } + unsigned diameter() const { return m_diameter; } + int start() const { return m_start; } + const int16* weight_array() const { return &m_weight_array[0]; } + void normalize(); + + private: + void realloc_lut(double radius); + image_filter_lut(const image_filter_lut&); + const image_filter_lut& operator = (const image_filter_lut&); + + double m_radius; + unsigned m_diameter; + int m_start; + pod_array m_weight_array; + }; + + + + //--------------------------------------------------------image_filter + template class image_filter : public image_filter_lut + { + public: + image_filter() + { + calculate(m_filter_function); + } + private: + FilterF m_filter_function; + }; + + + //-----------------------------------------------image_filter_bilinear + struct image_filter_bilinear + { + static double radius() { return 1.0; } + static double calc_weight(double x) + { + return 1.0 - x; + } + }; + + + //-----------------------------------------------image_filter_hanning + struct image_filter_hanning + { + static double radius() { return 1.0; } + static double calc_weight(double x) + { + return 0.5 + 0.5 * cos(pi * x); + } + }; + + + //-----------------------------------------------image_filter_hamming + struct image_filter_hamming + { + static double radius() { return 1.0; } + static double calc_weight(double x) + { + return 0.54 + 0.46 * cos(pi * x); + } + }; + + //-----------------------------------------------image_filter_hermite + struct image_filter_hermite + { + static double radius() { return 1.0; } + static double calc_weight(double x) + { + return (2.0 * x - 3.0) * x * x + 1.0; + } + }; + + //------------------------------------------------image_filter_quadric + struct image_filter_quadric + { + static double radius() { return 1.5; } + static double calc_weight(double x) + { + double t; + if(x < 0.5) return 0.75 - x * x; + if(x < 1.5) {t = x - 1.5; return 0.5 * t * t;} + return 0.0; + } + }; + + //------------------------------------------------image_filter_bicubic + class image_filter_bicubic + { + static double pow3(double x) + { + return (x <= 0.0) ? 0.0 : x * x * x; + } + + public: + static double radius() { return 2.0; } + static double calc_weight(double x) + { + return + (1.0/6.0) * + (pow3(x + 2) - 4 * pow3(x + 1) + 6 * pow3(x) - 4 * pow3(x - 1)); + } + }; + + //-------------------------------------------------image_filter_kaiser + class image_filter_kaiser + { + double a; + double i0a; + double epsilon; + + public: + image_filter_kaiser(double b = 6.33) : + a(b), epsilon(1e-12) + { + i0a = 1.0 / bessel_i0(b); + } + + static double radius() { return 1.0; } + double calc_weight(double x) const + { + return bessel_i0(a * sqrt(1. - x * x)) * i0a; + } + + private: + double bessel_i0(double x) const + { + int i; + double sum, y, t; + + sum = 1.; + y = x * x / 4.; + t = y; + + for(i = 2; t > epsilon; i++) + { + sum += t; + t *= (double)y / (i * i); + } + return sum; + } + }; + + //----------------------------------------------image_filter_catrom + struct image_filter_catrom + { + static double radius() { return 2.0; } + static double calc_weight(double x) + { + if(x < 1.0) return 0.5 * (2.0 + x * x * (-5.0 + x * 3.0)); + if(x < 2.0) return 0.5 * (4.0 + x * (-8.0 + x * (5.0 - x))); + return 0.; + } + }; + + //---------------------------------------------image_filter_mitchell + class image_filter_mitchell + { + double p0, p2, p3; + double q0, q1, q2, q3; + + public: + image_filter_mitchell(double b = 1.0/3.0, double c = 1.0/3.0) : + p0((6.0 - 2.0 * b) / 6.0), + p2((-18.0 + 12.0 * b + 6.0 * c) / 6.0), + p3((12.0 - 9.0 * b - 6.0 * c) / 6.0), + q0((8.0 * b + 24.0 * c) / 6.0), + q1((-12.0 * b - 48.0 * c) / 6.0), + q2((6.0 * b + 30.0 * c) / 6.0), + q3((-b - 6.0 * c) / 6.0) + {} + + static double radius() { return 2.0; } + double calc_weight(double x) const + { + if(x < 1.0) return p0 + x * x * (p2 + x * p3); + if(x < 2.0) return q0 + x * (q1 + x * (q2 + x * q3)); + return 0.0; + } + }; + + + //----------------------------------------------image_filter_spline16 + struct image_filter_spline16 + { + static double radius() { return 2.0; } + static double calc_weight(double x) + { + if(x < 1.0) + { + return ((x - 9.0/5.0 ) * x - 1.0/5.0 ) * x + 1.0; + } + return ((-1.0/3.0 * (x-1) + 4.0/5.0) * (x-1) - 7.0/15.0 ) * (x-1); + } + }; + + + //---------------------------------------------image_filter_spline36 + struct image_filter_spline36 + { + static double radius() { return 3.0; } + static double calc_weight(double x) + { + if(x < 1.0) + { + return ((13.0/11.0 * x - 453.0/209.0) * x - 3.0/209.0) * x + 1.0; + } + if(x < 2.0) + { + return ((-6.0/11.0 * (x-1) + 270.0/209.0) * (x-1) - 156.0/ 209.0) * (x-1); + } + return ((1.0/11.0 * (x-2) - 45.0/209.0) * (x-2) + 26.0/209.0) * (x-2); + } + }; + + + //----------------------------------------------image_filter_gaussian + struct image_filter_gaussian + { + static double radius() { return 2.0; } + static double calc_weight(double x) + { + return exp(-2.0 * x * x) * sqrt(2.0 / pi); + } + }; + + + //------------------------------------------------image_filter_bessel + struct image_filter_bessel + { + static double radius() { return 3.2383; } + static double calc_weight(double x) + { + return (x == 0.0) ? pi / 4.0 : besj(pi * x, 1) / (2.0 * x); + } + }; + + + //-------------------------------------------------image_filter_sinc + class image_filter_sinc + { + public: + image_filter_sinc(double r) : m_radius(r < 2.0 ? 2.0 : r) {} + double radius() const { return m_radius; } + double calc_weight(double x) const + { + if(x == 0.0) return 1.0; + x *= pi; + return sin(x) / x; + } + private: + double m_radius; + }; + + + //-----------------------------------------------image_filter_lanczos + class image_filter_lanczos + { + public: + image_filter_lanczos(double r) : m_radius(r < 2.0 ? 2.0 : r) {} + double radius() const { return m_radius; } + double calc_weight(double x) const + { + if(x == 0.0) return 1.0; + if(x > m_radius) return 0.0; + x *= pi; + double xr = x / m_radius; + return (sin(x) / x) * (sin(xr) / xr); + } + private: + double m_radius; + }; + + + //----------------------------------------------image_filter_blackman + class image_filter_blackman + { + public: + image_filter_blackman(double r) : m_radius(r < 2.0 ? 2.0 : r) {} + double radius() const { return m_radius; } + double calc_weight(double x) const + { + if(x == 0.0) return 1.0; + if(x > m_radius) return 0.0; + x *= pi; + double xr = x / m_radius; + return (sin(x) / x) * (0.42 + 0.5*cos(xr) + 0.08*cos(2*xr)); + } + private: + double m_radius; + }; + + //------------------------------------------------image_filter_sinc36 + class image_filter_sinc36 : public image_filter_sinc + { public: image_filter_sinc36() : image_filter_sinc(3.0){} }; + + //------------------------------------------------image_filter_sinc64 + class image_filter_sinc64 : public image_filter_sinc + { public: image_filter_sinc64() : image_filter_sinc(4.0){} }; + + //-----------------------------------------------image_filter_sinc100 + class image_filter_sinc100 : public image_filter_sinc + { public: image_filter_sinc100() : image_filter_sinc(5.0){} }; + + //-----------------------------------------------image_filter_sinc144 + class image_filter_sinc144 : public image_filter_sinc + { public: image_filter_sinc144() : image_filter_sinc(6.0){} }; + + //-----------------------------------------------image_filter_sinc196 + class image_filter_sinc196 : public image_filter_sinc + { public: image_filter_sinc196() : image_filter_sinc(7.0){} }; + + //-----------------------------------------------image_filter_sinc256 + class image_filter_sinc256 : public image_filter_sinc + { public: image_filter_sinc256() : image_filter_sinc(8.0){} }; + + //---------------------------------------------image_filter_lanczos36 + class image_filter_lanczos36 : public image_filter_lanczos + { public: image_filter_lanczos36() : image_filter_lanczos(3.0){} }; + + //---------------------------------------------image_filter_lanczos64 + class image_filter_lanczos64 : public image_filter_lanczos + { public: image_filter_lanczos64() : image_filter_lanczos(4.0){} }; + + //--------------------------------------------image_filter_lanczos100 + class image_filter_lanczos100 : public image_filter_lanczos + { public: image_filter_lanczos100() : image_filter_lanczos(5.0){} }; + + //--------------------------------------------image_filter_lanczos144 + class image_filter_lanczos144 : public image_filter_lanczos + { public: image_filter_lanczos144() : image_filter_lanczos(6.0){} }; + + //--------------------------------------------image_filter_lanczos196 + class image_filter_lanczos196 : public image_filter_lanczos + { public: image_filter_lanczos196() : image_filter_lanczos(7.0){} }; + + //--------------------------------------------image_filter_lanczos256 + class image_filter_lanczos256 : public image_filter_lanczos + { public: image_filter_lanczos256() : image_filter_lanczos(8.0){} }; + + //--------------------------------------------image_filter_blackman36 + class image_filter_blackman36 : public image_filter_blackman + { public: image_filter_blackman36() : image_filter_blackman(3.0){} }; + + //--------------------------------------------image_filter_blackman64 + class image_filter_blackman64 : public image_filter_blackman + { public: image_filter_blackman64() : image_filter_blackman(4.0){} }; + + //-------------------------------------------image_filter_blackman100 + class image_filter_blackman100 : public image_filter_blackman + { public: image_filter_blackman100() : image_filter_blackman(5.0){} }; + + //-------------------------------------------image_filter_blackman144 + class image_filter_blackman144 : public image_filter_blackman + { public: image_filter_blackman144() : image_filter_blackman(6.0){} }; + + //-------------------------------------------image_filter_blackman196 + class image_filter_blackman196 : public image_filter_blackman + { public: image_filter_blackman196() : image_filter_blackman(7.0){} }; + + //-------------------------------------------image_filter_blackman256 + class image_filter_blackman256 : public image_filter_blackman + { public: image_filter_blackman256() : image_filter_blackman(8.0){} }; + + +} + +#endif diff --git a/xs/src/agg/agg_line_aa_basics.h b/xs/src/agg/agg_line_aa_basics.h new file mode 100644 index 0000000000..c5acb18e79 --- /dev/null +++ b/xs/src/agg/agg_line_aa_basics.h @@ -0,0 +1,189 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_LINE_AA_BASICS_INCLUDED +#define AGG_LINE_AA_BASICS_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + + // See Implementation agg_line_aa_basics.cpp + + //------------------------------------------------------------------------- + enum line_subpixel_scale_e + { + line_subpixel_shift = 8, //----line_subpixel_shift + line_subpixel_scale = 1 << line_subpixel_shift, //----line_subpixel_scale + line_subpixel_mask = line_subpixel_scale - 1, //----line_subpixel_mask + line_max_coord = (1 << 28) - 1, //----line_max_coord + line_max_length = 1 << (line_subpixel_shift + 10) //----line_max_length + }; + + //------------------------------------------------------------------------- + enum line_mr_subpixel_scale_e + { + line_mr_subpixel_shift = 4, //----line_mr_subpixel_shift + line_mr_subpixel_scale = 1 << line_mr_subpixel_shift, //----line_mr_subpixel_scale + line_mr_subpixel_mask = line_mr_subpixel_scale - 1 //----line_mr_subpixel_mask + }; + + //------------------------------------------------------------------line_mr + AGG_INLINE int line_mr(int x) + { + return x >> (line_subpixel_shift - line_mr_subpixel_shift); + } + + //-------------------------------------------------------------------line_hr + AGG_INLINE int line_hr(int x) + { + return x << (line_subpixel_shift - line_mr_subpixel_shift); + } + + //---------------------------------------------------------------line_dbl_hr + AGG_INLINE int line_dbl_hr(int x) + { + return x << line_subpixel_shift; + } + + //---------------------------------------------------------------line_coord + struct line_coord + { + AGG_INLINE static int conv(double x) + { + return iround(x * line_subpixel_scale); + } + }; + + //-----------------------------------------------------------line_coord_sat + struct line_coord_sat + { + AGG_INLINE static int conv(double x) + { + return saturation::iround(x * line_subpixel_scale); + } + }; + + //==========================================================line_parameters + struct line_parameters + { + //--------------------------------------------------------------------- + line_parameters() {} + line_parameters(int x1_, int y1_, int x2_, int y2_, int len_) : + x1(x1_), y1(y1_), x2(x2_), y2(y2_), + dx(abs(x2_ - x1_)), + dy(abs(y2_ - y1_)), + sx((x2_ > x1_) ? 1 : -1), + sy((y2_ > y1_) ? 1 : -1), + vertical(dy >= dx), + inc(vertical ? sy : sx), + len(len_), + octant((sy & 4) | (sx & 2) | int(vertical)) + { + } + + //--------------------------------------------------------------------- + unsigned orthogonal_quadrant() const { return s_orthogonal_quadrant[octant]; } + unsigned diagonal_quadrant() const { return s_diagonal_quadrant[octant]; } + + //--------------------------------------------------------------------- + bool same_orthogonal_quadrant(const line_parameters& lp) const + { + return s_orthogonal_quadrant[octant] == s_orthogonal_quadrant[lp.octant]; + } + + //--------------------------------------------------------------------- + bool same_diagonal_quadrant(const line_parameters& lp) const + { + return s_diagonal_quadrant[octant] == s_diagonal_quadrant[lp.octant]; + } + + //--------------------------------------------------------------------- + void divide(line_parameters& lp1, line_parameters& lp2) const + { + int xmid = (x1 + x2) >> 1; + int ymid = (y1 + y2) >> 1; + int len2 = len >> 1; + + lp1 = *this; + lp2 = *this; + + lp1.x2 = xmid; + lp1.y2 = ymid; + lp1.len = len2; + lp1.dx = abs(lp1.x2 - lp1.x1); + lp1.dy = abs(lp1.y2 - lp1.y1); + + lp2.x1 = xmid; + lp2.y1 = ymid; + lp2.len = len2; + lp2.dx = abs(lp2.x2 - lp2.x1); + lp2.dy = abs(lp2.y2 - lp2.y1); + } + + //--------------------------------------------------------------------- + int x1, y1, x2, y2, dx, dy, sx, sy; + bool vertical; + int inc; + int len; + int octant; + + //--------------------------------------------------------------------- + static const int8u s_orthogonal_quadrant[8]; + static const int8u s_diagonal_quadrant[8]; + }; + + + + // See Implementation agg_line_aa_basics.cpp + + //----------------------------------------------------------------bisectrix + void bisectrix(const line_parameters& l1, + const line_parameters& l2, + int* x, int* y); + + + //-------------------------------------------fix_degenerate_bisectrix_start + void inline fix_degenerate_bisectrix_start(const line_parameters& lp, + int* x, int* y) + { + int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - + double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len); + if(d < line_subpixel_scale/2) + { + *x = lp.x1 + (lp.y2 - lp.y1); + *y = lp.y1 - (lp.x2 - lp.x1); + } + } + + + //---------------------------------------------fix_degenerate_bisectrix_end + void inline fix_degenerate_bisectrix_end(const line_parameters& lp, + int* x, int* y) + { + int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - + double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len); + if(d < line_subpixel_scale/2) + { + *x = lp.x2 + (lp.y2 - lp.y1); + *y = lp.y2 - (lp.x2 - lp.x1); + } + } + + +} + +#endif diff --git a/xs/src/agg/agg_math.h b/xs/src/agg/agg_math.h new file mode 100644 index 0000000000..2ec49cf3ff --- /dev/null +++ b/xs/src/agg/agg_math.h @@ -0,0 +1,437 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// Bessel function (besj) was adapted for use in AGG library by Andy Wilk +// Contact: castor.vulgaris@gmail.com +//---------------------------------------------------------------------------- + +#ifndef AGG_MATH_INCLUDED +#define AGG_MATH_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + + //------------------------------------------------------vertex_dist_epsilon + // Coinciding points maximal distance (Epsilon) + const double vertex_dist_epsilon = 1e-14; + + //-----------------------------------------------------intersection_epsilon + // See calc_intersection + const double intersection_epsilon = 1.0e-30; + + //------------------------------------------------------------cross_product + AGG_INLINE double cross_product(double x1, double y1, + double x2, double y2, + double x, double y) + { + return (x - x2) * (y2 - y1) - (y - y2) * (x2 - x1); + } + + //--------------------------------------------------------point_in_triangle + AGG_INLINE bool point_in_triangle(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x, double y) + { + bool cp1 = cross_product(x1, y1, x2, y2, x, y) < 0.0; + bool cp2 = cross_product(x2, y2, x3, y3, x, y) < 0.0; + bool cp3 = cross_product(x3, y3, x1, y1, x, y) < 0.0; + return cp1 == cp2 && cp2 == cp3 && cp3 == cp1; + } + + //-----------------------------------------------------------calc_distance + AGG_INLINE double calc_distance(double x1, double y1, double x2, double y2) + { + double dx = x2-x1; + double dy = y2-y1; + return sqrt(dx * dx + dy * dy); + } + + //--------------------------------------------------------calc_sq_distance + AGG_INLINE double calc_sq_distance(double x1, double y1, double x2, double y2) + { + double dx = x2-x1; + double dy = y2-y1; + return dx * dx + dy * dy; + } + + //------------------------------------------------calc_line_point_distance + AGG_INLINE double calc_line_point_distance(double x1, double y1, + double x2, double y2, + double x, double y) + { + double dx = x2-x1; + double dy = y2-y1; + double d = sqrt(dx * dx + dy * dy); + if(d < vertex_dist_epsilon) + { + return calc_distance(x1, y1, x, y); + } + return ((x - x2) * dy - (y - y2) * dx) / d; + } + + //-------------------------------------------------------calc_line_point_u + AGG_INLINE double calc_segment_point_u(double x1, double y1, + double x2, double y2, + double x, double y) + { + double dx = x2 - x1; + double dy = y2 - y1; + + if(dx == 0 && dy == 0) + { + return 0; + } + + double pdx = x - x1; + double pdy = y - y1; + + return (pdx * dx + pdy * dy) / (dx * dx + dy * dy); + } + + //---------------------------------------------calc_line_point_sq_distance + AGG_INLINE double calc_segment_point_sq_distance(double x1, double y1, + double x2, double y2, + double x, double y, + double u) + { + if(u <= 0) + { + return calc_sq_distance(x, y, x1, y1); + } + else + if(u >= 1) + { + return calc_sq_distance(x, y, x2, y2); + } + return calc_sq_distance(x, y, x1 + u * (x2 - x1), y1 + u * (y2 - y1)); + } + + //---------------------------------------------calc_line_point_sq_distance + AGG_INLINE double calc_segment_point_sq_distance(double x1, double y1, + double x2, double y2, + double x, double y) + { + return + calc_segment_point_sq_distance( + x1, y1, x2, y2, x, y, + calc_segment_point_u(x1, y1, x2, y2, x, y)); + } + + //-------------------------------------------------------calc_intersection + AGG_INLINE bool calc_intersection(double ax, double ay, double bx, double by, + double cx, double cy, double dx, double dy, + double* x, double* y) + { + double num = (ay-cy) * (dx-cx) - (ax-cx) * (dy-cy); + double den = (bx-ax) * (dy-cy) - (by-ay) * (dx-cx); + if(fabs(den) < intersection_epsilon) return false; + double r = num / den; + *x = ax + r * (bx-ax); + *y = ay + r * (by-ay); + return true; + } + + //-----------------------------------------------------intersection_exists + AGG_INLINE bool intersection_exists(double x1, double y1, double x2, double y2, + double x3, double y3, double x4, double y4) + { + // It's less expensive but you can't control the + // boundary conditions: Less or LessEqual + double dx1 = x2 - x1; + double dy1 = y2 - y1; + double dx2 = x4 - x3; + double dy2 = y4 - y3; + return ((x3 - x2) * dy1 - (y3 - y2) * dx1 < 0.0) != + ((x4 - x2) * dy1 - (y4 - y2) * dx1 < 0.0) && + ((x1 - x4) * dy2 - (y1 - y4) * dx2 < 0.0) != + ((x2 - x4) * dy2 - (y2 - y4) * dx2 < 0.0); + + // It's is more expensive but more flexible + // in terms of boundary conditions. + //-------------------- + //double den = (x2-x1) * (y4-y3) - (y2-y1) * (x4-x3); + //if(fabs(den) < intersection_epsilon) return false; + //double nom1 = (x4-x3) * (y1-y3) - (y4-y3) * (x1-x3); + //double nom2 = (x2-x1) * (y1-y3) - (y2-y1) * (x1-x3); + //double ua = nom1 / den; + //double ub = nom2 / den; + //return ua >= 0.0 && ua <= 1.0 && ub >= 0.0 && ub <= 1.0; + } + + //--------------------------------------------------------calc_orthogonal + AGG_INLINE void calc_orthogonal(double thickness, + double x1, double y1, + double x2, double y2, + double* x, double* y) + { + double dx = x2 - x1; + double dy = y2 - y1; + double d = sqrt(dx*dx + dy*dy); + *x = thickness * dy / d; + *y = -thickness * dx / d; + } + + //--------------------------------------------------------dilate_triangle + AGG_INLINE void dilate_triangle(double x1, double y1, + double x2, double y2, + double x3, double y3, + double *x, double* y, + double d) + { + double dx1=0.0; + double dy1=0.0; + double dx2=0.0; + double dy2=0.0; + double dx3=0.0; + double dy3=0.0; + double loc = cross_product(x1, y1, x2, y2, x3, y3); + if(fabs(loc) > intersection_epsilon) + { + if(cross_product(x1, y1, x2, y2, x3, y3) > 0.0) + { + d = -d; + } + calc_orthogonal(d, x1, y1, x2, y2, &dx1, &dy1); + calc_orthogonal(d, x2, y2, x3, y3, &dx2, &dy2); + calc_orthogonal(d, x3, y3, x1, y1, &dx3, &dy3); + } + *x++ = x1 + dx1; *y++ = y1 + dy1; + *x++ = x2 + dx1; *y++ = y2 + dy1; + *x++ = x2 + dx2; *y++ = y2 + dy2; + *x++ = x3 + dx2; *y++ = y3 + dy2; + *x++ = x3 + dx3; *y++ = y3 + dy3; + *x++ = x1 + dx3; *y++ = y1 + dy3; + } + + //------------------------------------------------------calc_triangle_area + AGG_INLINE double calc_triangle_area(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + return (x1*y2 - x2*y1 + x2*y3 - x3*y2 + x3*y1 - x1*y3) * 0.5; + } + + //-------------------------------------------------------calc_polygon_area + template double calc_polygon_area(const Storage& st) + { + unsigned i; + double sum = 0.0; + double x = st[0].x; + double y = st[0].y; + double xs = x; + double ys = y; + + for(i = 1; i < st.size(); i++) + { + const typename Storage::value_type& v = st[i]; + sum += x * v.y - y * v.x; + x = v.x; + y = v.y; + } + return (sum + x * ys - y * xs) * 0.5; + } + + //------------------------------------------------------------------------ + // Tables for fast sqrt + extern int16u g_sqrt_table[1024]; + extern int8 g_elder_bit_table[256]; + + + //---------------------------------------------------------------fast_sqrt + //Fast integer Sqrt - really fast: no cycles, divisions or multiplications + #if defined(_MSC_VER) + #pragma warning(push) + #pragma warning(disable : 4035) //Disable warning "no return value" + #endif + AGG_INLINE unsigned fast_sqrt(unsigned val) + { + #if defined(_M_IX86) && defined(_MSC_VER) && !defined(AGG_NO_ASM) + //For Ix86 family processors this assembler code is used. + //The key command here is bsr - determination the number of the most + //significant bit of the value. For other processors + //(and maybe compilers) the pure C "#else" section is used. + __asm + { + mov ebx, val + mov edx, 11 + bsr ecx, ebx + sub ecx, 9 + jle less_than_9_bits + shr ecx, 1 + adc ecx, 0 + sub edx, ecx + shl ecx, 1 + shr ebx, cl + less_than_9_bits: + xor eax, eax + mov ax, g_sqrt_table[ebx*2] + mov ecx, edx + shr eax, cl + } + #else + + //This code is actually pure C and portable to most + //arcitectures including 64bit ones. + unsigned t = val; + int bit=0; + unsigned shift = 11; + + //The following piece of code is just an emulation of the + //Ix86 assembler command "bsr" (see above). However on old + //Intels (like Intel MMX 233MHz) this code is about twice + //faster (sic!) then just one "bsr". On PIII and PIV the + //bsr is optimized quite well. + bit = t >> 24; + if(bit) + { + bit = g_elder_bit_table[bit] + 24; + } + else + { + bit = (t >> 16) & 0xFF; + if(bit) + { + bit = g_elder_bit_table[bit] + 16; + } + else + { + bit = (t >> 8) & 0xFF; + if(bit) + { + bit = g_elder_bit_table[bit] + 8; + } + else + { + bit = g_elder_bit_table[t]; + } + } + } + + //This code calculates the sqrt. + bit -= 9; + if(bit > 0) + { + bit = (bit >> 1) + (bit & 1); + shift -= bit; + val >>= (bit << 1); + } + return g_sqrt_table[val] >> shift; + #endif + } + #if defined(_MSC_VER) + #pragma warning(pop) + #endif + + + + + //--------------------------------------------------------------------besj + // Function BESJ calculates Bessel function of first kind of order n + // Arguments: + // n - an integer (>=0), the order + // x - value at which the Bessel function is required + //-------------------- + // C++ Mathematical Library + // Convereted from equivalent FORTRAN library + // Converetd by Gareth Walker for use by course 392 computational project + // All functions tested and yield the same results as the corresponding + // FORTRAN versions. + // + // If you have any problems using these functions please report them to + // M.Muldoon@UMIST.ac.uk + // + // Documentation available on the web + // http://www.ma.umist.ac.uk/mrm/Teaching/392/libs/392.html + // Version 1.0 8/98 + // 29 October, 1999 + //-------------------- + // Adapted for use in AGG library by Andy Wilk (castor.vulgaris@gmail.com) + //------------------------------------------------------------------------ + inline double besj(double x, int n) + { + if(n < 0) + { + return 0; + } + double d = 1E-6; + double b = 0; + if(fabs(x) <= d) + { + if(n != 0) return 0; + return 1; + } + double b1 = 0; // b1 is the value from the previous iteration + // Set up a starting order for recurrence + int m1 = (int)fabs(x) + 6; + if(fabs(x) > 5) + { + m1 = (int)(fabs(1.4 * x + 60 / x)); + } + int m2 = (int)(n + 2 + fabs(x) / 4); + if (m1 > m2) + { + m2 = m1; + } + + // Apply recurrence down from curent max order + for(;;) + { + double c3 = 0; + double c2 = 1E-30; + double c4 = 0; + int m8 = 1; + if (m2 / 2 * 2 == m2) + { + m8 = -1; + } + int imax = m2 - 2; + for (int i = 1; i <= imax; i++) + { + double c6 = 2 * (m2 - i) * c2 / x - c3; + c3 = c2; + c2 = c6; + if(m2 - i - 1 == n) + { + b = c6; + } + m8 = -1 * m8; + if (m8 > 0) + { + c4 = c4 + 2 * c6; + } + } + double c6 = 2 * c2 / x - c3; + if(n == 0) + { + b = c6; + } + c4 += c6; + b /= c4; + if(fabs(b - b1) < d) + { + return b; + } + b1 = b; + m2 += 3; + } + } + +} + + +#endif diff --git a/xs/src/agg/agg_math_stroke.h b/xs/src/agg/agg_math_stroke.h new file mode 100644 index 0000000000..4806dcd4bf --- /dev/null +++ b/xs/src/agg/agg_math_stroke.h @@ -0,0 +1,526 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Stroke math +// +//---------------------------------------------------------------------------- + +#ifndef AGG_STROKE_MATH_INCLUDED +#define AGG_STROKE_MATH_INCLUDED + +#include "agg_math.h" +#include "agg_vertex_sequence.h" + +namespace agg +{ + //-------------------------------------------------------------line_cap_e + enum line_cap_e + { + butt_cap, + square_cap, + round_cap + }; + + //------------------------------------------------------------line_join_e + enum line_join_e + { + miter_join = 0, + miter_join_revert = 1, + round_join = 2, + bevel_join = 3, + miter_join_round = 4 + }; + + + //-----------------------------------------------------------inner_join_e + enum inner_join_e + { + inner_bevel, + inner_miter, + inner_jag, + inner_round + }; + + //------------------------------------------------------------math_stroke + template class math_stroke + { + public: + typedef typename VertexConsumer::value_type coord_type; + + math_stroke(); + + void line_cap(line_cap_e lc) { m_line_cap = lc; } + void line_join(line_join_e lj) { m_line_join = lj; } + void inner_join(inner_join_e ij) { m_inner_join = ij; } + + line_cap_e line_cap() const { return m_line_cap; } + line_join_e line_join() const { return m_line_join; } + inner_join_e inner_join() const { return m_inner_join; } + + void width(double w); + void miter_limit(double ml) { m_miter_limit = ml; } + void miter_limit_theta(double t); + void inner_miter_limit(double ml) { m_inner_miter_limit = ml; } + void approximation_scale(double as) { m_approx_scale = as; } + + double width() const { return m_width * 2.0; } + double miter_limit() const { return m_miter_limit; } + double inner_miter_limit() const { return m_inner_miter_limit; } + double approximation_scale() const { return m_approx_scale; } + + void calc_cap(VertexConsumer& vc, + const vertex_dist& v0, + const vertex_dist& v1, + double len); + + void calc_join(VertexConsumer& vc, + const vertex_dist& v0, + const vertex_dist& v1, + const vertex_dist& v2, + double len1, + double len2); + + private: + AGG_INLINE void add_vertex(VertexConsumer& vc, double x, double y) + { + vc.add(coord_type(x, y)); + } + + void calc_arc(VertexConsumer& vc, + double x, double y, + double dx1, double dy1, + double dx2, double dy2); + + void calc_miter(VertexConsumer& vc, + const vertex_dist& v0, + const vertex_dist& v1, + const vertex_dist& v2, + double dx1, double dy1, + double dx2, double dy2, + line_join_e lj, + double mlimit, + double dbevel); + + double m_width; + double m_width_abs; + double m_width_eps; + int m_width_sign; + double m_miter_limit; + double m_inner_miter_limit; + double m_approx_scale; + line_cap_e m_line_cap; + line_join_e m_line_join; + inner_join_e m_inner_join; + }; + + //----------------------------------------------------------------------- + template math_stroke::math_stroke() : + m_width(0.5), + m_width_abs(0.5), + m_width_eps(0.5/1024.0), + m_width_sign(1), + m_miter_limit(4.0), + m_inner_miter_limit(1.01), + m_approx_scale(1.0), + m_line_cap(butt_cap), + m_line_join(miter_join), + m_inner_join(inner_miter) + { + } + + //----------------------------------------------------------------------- + template void math_stroke::width(double w) + { + m_width = w * 0.5; + if(m_width < 0) + { + m_width_abs = -m_width; + m_width_sign = -1; + } + else + { + m_width_abs = m_width; + m_width_sign = 1; + } + m_width_eps = m_width / 1024.0; + } + + //----------------------------------------------------------------------- + template void math_stroke::miter_limit_theta(double t) + { + m_miter_limit = 1.0 / sin(t * 0.5) ; + } + + //----------------------------------------------------------------------- + template + void math_stroke::calc_arc(VC& vc, + double x, double y, + double dx1, double dy1, + double dx2, double dy2) + { + double a1 = atan2(dy1 * m_width_sign, dx1 * m_width_sign); + double a2 = atan2(dy2 * m_width_sign, dx2 * m_width_sign); + double da = a1 - a2; + int i, n; + + da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2; + + add_vertex(vc, x + dx1, y + dy1); + if(m_width_sign > 0) + { + if(a1 > a2) a2 += 2 * pi; + n = int((a2 - a1) / da); + da = (a2 - a1) / (n + 1); + a1 += da; + for(i = 0; i < n; i++) + { + add_vertex(vc, x + cos(a1) * m_width, y + sin(a1) * m_width); + a1 += da; + } + } + else + { + if(a1 < a2) a2 -= 2 * pi; + n = int((a1 - a2) / da); + da = (a1 - a2) / (n + 1); + a1 -= da; + for(i = 0; i < n; i++) + { + add_vertex(vc, x + cos(a1) * m_width, y + sin(a1) * m_width); + a1 -= da; + } + } + add_vertex(vc, x + dx2, y + dy2); + } + + //----------------------------------------------------------------------- + template + void math_stroke::calc_miter(VC& vc, + const vertex_dist& v0, + const vertex_dist& v1, + const vertex_dist& v2, + double dx1, double dy1, + double dx2, double dy2, + line_join_e lj, + double mlimit, + double dbevel) + { + double xi = v1.x; + double yi = v1.y; + double di = 1; + double lim = m_width_abs * mlimit; + bool miter_limit_exceeded = true; // Assume the worst + bool intersection_failed = true; // Assume the worst + + if(calc_intersection(v0.x + dx1, v0.y - dy1, + v1.x + dx1, v1.y - dy1, + v1.x + dx2, v1.y - dy2, + v2.x + dx2, v2.y - dy2, + &xi, &yi)) + { + // Calculation of the intersection succeeded + //--------------------- + di = calc_distance(v1.x, v1.y, xi, yi); + if(di <= lim) + { + // Inside the miter limit + //--------------------- + add_vertex(vc, xi, yi); + miter_limit_exceeded = false; + } + intersection_failed = false; + } + else + { + // Calculation of the intersection failed, most probably + // the three points lie one straight line. + // First check if v0 and v2 lie on the opposite sides of vector: + // (v1.x, v1.y) -> (v1.x+dx1, v1.y-dy1), that is, the perpendicular + // to the line determined by vertices v0 and v1. + // This condition determines whether the next line segments continues + // the previous one or goes back. + //---------------- + double x2 = v1.x + dx1; + double y2 = v1.y - dy1; + if((cross_product(v0.x, v0.y, v1.x, v1.y, x2, y2) < 0.0) == + (cross_product(v1.x, v1.y, v2.x, v2.y, x2, y2) < 0.0)) + { + // This case means that the next segment continues + // the previous one (straight line) + //----------------- + add_vertex(vc, v1.x + dx1, v1.y - dy1); + miter_limit_exceeded = false; + } + } + + if(miter_limit_exceeded) + { + // Miter limit exceeded + //------------------------ + switch(lj) + { + case miter_join_revert: + // For the compatibility with SVG, PDF, etc, + // we use a simple bevel join instead of + // "smart" bevel + //------------------- + add_vertex(vc, v1.x + dx1, v1.y - dy1); + add_vertex(vc, v1.x + dx2, v1.y - dy2); + break; + + case miter_join_round: + calc_arc(vc, v1.x, v1.y, dx1, -dy1, dx2, -dy2); + break; + + default: + // If no miter-revert, calculate new dx1, dy1, dx2, dy2 + //---------------- + if(intersection_failed) + { + mlimit *= m_width_sign; + add_vertex(vc, v1.x + dx1 + dy1 * mlimit, + v1.y - dy1 + dx1 * mlimit); + add_vertex(vc, v1.x + dx2 - dy2 * mlimit, + v1.y - dy2 - dx2 * mlimit); + } + else + { + double x1 = v1.x + dx1; + double y1 = v1.y - dy1; + double x2 = v1.x + dx2; + double y2 = v1.y - dy2; + di = (lim - dbevel) / (di - dbevel); + add_vertex(vc, x1 + (xi - x1) * di, + y1 + (yi - y1) * di); + add_vertex(vc, x2 + (xi - x2) * di, + y2 + (yi - y2) * di); + } + break; + } + } + } + + //--------------------------------------------------------stroke_calc_cap + template + void math_stroke::calc_cap(VC& vc, + const vertex_dist& v0, + const vertex_dist& v1, + double len) + { + vc.remove_all(); + + double dx1 = (v1.y - v0.y) / len; + double dy1 = (v1.x - v0.x) / len; + double dx2 = 0; + double dy2 = 0; + + dx1 *= m_width; + dy1 *= m_width; + + if(m_line_cap != round_cap) + { + if(m_line_cap == square_cap) + { + dx2 = dy1 * m_width_sign; + dy2 = dx1 * m_width_sign; + } + add_vertex(vc, v0.x - dx1 - dx2, v0.y + dy1 - dy2); + add_vertex(vc, v0.x + dx1 - dx2, v0.y - dy1 - dy2); + } + else + { + double da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2; + double a1; + int i; + int n = int(pi / da); + + da = pi / (n + 1); + add_vertex(vc, v0.x - dx1, v0.y + dy1); + if(m_width_sign > 0) + { + a1 = atan2(dy1, -dx1); + a1 += da; + for(i = 0; i < n; i++) + { + add_vertex(vc, v0.x + cos(a1) * m_width, + v0.y + sin(a1) * m_width); + a1 += da; + } + } + else + { + a1 = atan2(-dy1, dx1); + a1 -= da; + for(i = 0; i < n; i++) + { + add_vertex(vc, v0.x + cos(a1) * m_width, + v0.y + sin(a1) * m_width); + a1 -= da; + } + } + add_vertex(vc, v0.x + dx1, v0.y - dy1); + } + } + + //----------------------------------------------------------------------- + template + void math_stroke::calc_join(VC& vc, + const vertex_dist& v0, + const vertex_dist& v1, + const vertex_dist& v2, + double len1, + double len2) + { + double dx1 = m_width * (v1.y - v0.y) / len1; + double dy1 = m_width * (v1.x - v0.x) / len1; + double dx2 = m_width * (v2.y - v1.y) / len2; + double dy2 = m_width * (v2.x - v1.x) / len2; + + vc.remove_all(); + + double cp = cross_product(v0.x, v0.y, v1.x, v1.y, v2.x, v2.y); + if(cp != 0 && (cp > 0) == (m_width > 0)) + { + // Inner join + //--------------- + double limit = ((len1 < len2) ? len1 : len2) / m_width_abs; + if(limit < m_inner_miter_limit) + { + limit = m_inner_miter_limit; + } + + switch(m_inner_join) + { + default: // inner_bevel + add_vertex(vc, v1.x + dx1, v1.y - dy1); + add_vertex(vc, v1.x + dx2, v1.y - dy2); + break; + + case inner_miter: + calc_miter(vc, + v0, v1, v2, dx1, dy1, dx2, dy2, + miter_join_revert, + limit, 0); + break; + + case inner_jag: + case inner_round: + cp = (dx1-dx2) * (dx1-dx2) + (dy1-dy2) * (dy1-dy2); + if(cp < len1 * len1 && cp < len2 * len2) + { + calc_miter(vc, + v0, v1, v2, dx1, dy1, dx2, dy2, + miter_join_revert, + limit, 0); + } + else + { + if(m_inner_join == inner_jag) + { + add_vertex(vc, v1.x + dx1, v1.y - dy1); + add_vertex(vc, v1.x, v1.y ); + add_vertex(vc, v1.x + dx2, v1.y - dy2); + } + else + { + add_vertex(vc, v1.x + dx1, v1.y - dy1); + add_vertex(vc, v1.x, v1.y ); + calc_arc(vc, v1.x, v1.y, dx2, -dy2, dx1, -dy1); + add_vertex(vc, v1.x, v1.y ); + add_vertex(vc, v1.x + dx2, v1.y - dy2); + } + } + break; + } + } + else + { + // Outer join + //--------------- + + // Calculate the distance between v1 and + // the central point of the bevel line segment + //--------------- + double dx = (dx1 + dx2) / 2; + double dy = (dy1 + dy2) / 2; + double dbevel = sqrt(dx * dx + dy * dy); + + if(m_line_join == round_join || m_line_join == bevel_join) + { + // This is an optimization that reduces the number of points + // in cases of almost collinear segments. If there's no + // visible difference between bevel and miter joins we'd rather + // use miter join because it adds only one point instead of two. + // + // Here we calculate the middle point between the bevel points + // and then, the distance between v1 and this middle point. + // At outer joins this distance always less than stroke width, + // because it's actually the height of an isosceles triangle of + // v1 and its two bevel points. If the difference between this + // width and this value is small (no visible bevel) we can + // add just one point. + // + // The constant in the expression makes the result approximately + // the same as in round joins and caps. You can safely comment + // out this entire "if". + //------------------- + if(m_approx_scale * (m_width_abs - dbevel) < m_width_eps) + { + if(calc_intersection(v0.x + dx1, v0.y - dy1, + v1.x + dx1, v1.y - dy1, + v1.x + dx2, v1.y - dy2, + v2.x + dx2, v2.y - dy2, + &dx, &dy)) + { + add_vertex(vc, dx, dy); + } + else + { + add_vertex(vc, v1.x + dx1, v1.y - dy1); + } + return; + } + } + + switch(m_line_join) + { + case miter_join: + case miter_join_revert: + case miter_join_round: + calc_miter(vc, + v0, v1, v2, dx1, dy1, dx2, dy2, + m_line_join, + m_miter_limit, + dbevel); + break; + + case round_join: + calc_arc(vc, v1.x, v1.y, dx1, -dy1, dx2, -dy2); + break; + + default: // Bevel join + add_vertex(vc, v1.x + dx1, v1.y - dy1); + add_vertex(vc, v1.x + dx2, v1.y - dy2); + break; + } + } + } + + + + +} + +#endif diff --git a/xs/src/agg/agg_path_length.h b/xs/src/agg/agg_path_length.h new file mode 100644 index 0000000000..740ba31df2 --- /dev/null +++ b/xs/src/agg/agg_path_length.h @@ -0,0 +1,65 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_PATH_LENGTH_INCLUDED +#define AGG_PATH_LENGTH_INCLUDED + +#include "agg_math.h" + +namespace agg +{ + template + double path_length(VertexSource& vs, unsigned path_id = 0) + { + double len = 0.0; + double start_x = 0.0; + double start_y = 0.0; + double x1 = 0.0; + double y1 = 0.0; + double x2 = 0.0; + double y2 = 0.0; + bool first = true; + + unsigned cmd; + vs.rewind(path_id); + while(!is_stop(cmd = vs.vertex(&x2, &y2))) + { + if(is_vertex(cmd)) + { + if(first || is_move_to(cmd)) + { + start_x = x2; + start_y = y2; + } + else + { + len += calc_distance(x1, y1, x2, y2); + } + x1 = x2; + y1 = y2; + first = false; + } + else + { + if(is_close(cmd) && !first) + { + len += calc_distance(x1, y1, start_x, start_y); + } + } + } + return len; + } +} + +#endif diff --git a/xs/src/agg/agg_path_storage.h b/xs/src/agg/agg_path_storage.h new file mode 100644 index 0000000000..f55c89957b --- /dev/null +++ b/xs/src/agg/agg_path_storage.h @@ -0,0 +1,1582 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_PATH_STORAGE_INCLUDED +#define AGG_PATH_STORAGE_INCLUDED + +#include +#include +#include "agg_math.h" +#include "agg_array.h" +#include "agg_bezier_arc.h" + +namespace agg +{ + + + //----------------------------------------------------vertex_block_storage + template + class vertex_block_storage + { + public: + // Allocation parameters + enum block_scale_e + { + block_shift = BlockShift, + block_size = 1 << block_shift, + block_mask = block_size - 1, + block_pool = BlockPool + }; + + typedef T value_type; + typedef vertex_block_storage self_type; + + ~vertex_block_storage(); + vertex_block_storage(); + vertex_block_storage(const self_type& v); + const self_type& operator = (const self_type& ps); + + void remove_all(); + void free_all(); + + void add_vertex(double x, double y, unsigned cmd); + void modify_vertex(unsigned idx, double x, double y); + void modify_vertex(unsigned idx, double x, double y, unsigned cmd); + void modify_command(unsigned idx, unsigned cmd); + void swap_vertices(unsigned v1, unsigned v2); + + unsigned last_command() const; + unsigned last_vertex(double* x, double* y) const; + unsigned prev_vertex(double* x, double* y) const; + + double last_x() const; + double last_y() const; + + unsigned total_vertices() const; + unsigned vertex(unsigned idx, double* x, double* y) const; + unsigned command(unsigned idx) const; + + private: + void allocate_block(unsigned nb); + int8u* storage_ptrs(T** xy_ptr); + + private: + unsigned m_total_vertices; + unsigned m_total_blocks; + unsigned m_max_blocks; + T** m_coord_blocks; + int8u** m_cmd_blocks; + }; + + + //------------------------------------------------------------------------ + template + void vertex_block_storage::free_all() + { + if(m_total_blocks) + { + T** coord_blk = m_coord_blocks + m_total_blocks - 1; + while(m_total_blocks--) + { + pod_allocator::deallocate( + *coord_blk, + block_size * 2 + + block_size / (sizeof(T) / sizeof(unsigned char))); + --coord_blk; + } + pod_allocator::deallocate(m_coord_blocks, m_max_blocks * 2); + m_total_blocks = 0; + m_max_blocks = 0; + m_coord_blocks = 0; + m_cmd_blocks = 0; + m_total_vertices = 0; + } + } + + //------------------------------------------------------------------------ + template + vertex_block_storage::~vertex_block_storage() + { + free_all(); + } + + //------------------------------------------------------------------------ + template + vertex_block_storage::vertex_block_storage() : + m_total_vertices(0), + m_total_blocks(0), + m_max_blocks(0), + m_coord_blocks(0), + m_cmd_blocks(0) + { + } + + //------------------------------------------------------------------------ + template + vertex_block_storage::vertex_block_storage(const vertex_block_storage& v) : + m_total_vertices(0), + m_total_blocks(0), + m_max_blocks(0), + m_coord_blocks(0), + m_cmd_blocks(0) + { + *this = v; + } + + //------------------------------------------------------------------------ + template + const vertex_block_storage& + vertex_block_storage::operator = (const vertex_block_storage& v) + { + remove_all(); + unsigned i; + for(i = 0; i < v.total_vertices(); i++) + { + double x, y; + unsigned cmd = v.vertex(i, &x, &y); + add_vertex(x, y, cmd); + } + return *this; + } + + //------------------------------------------------------------------------ + template + inline void vertex_block_storage::remove_all() + { + m_total_vertices = 0; + } + + //------------------------------------------------------------------------ + template + inline void vertex_block_storage::add_vertex(double x, double y, + unsigned cmd) + { + T* coord_ptr = 0; + *storage_ptrs(&coord_ptr) = (int8u)cmd; + coord_ptr[0] = T(x); + coord_ptr[1] = T(y); + m_total_vertices++; + } + + //------------------------------------------------------------------------ + template + inline void vertex_block_storage::modify_vertex(unsigned idx, + double x, double y) + { + T* pv = m_coord_blocks[idx >> block_shift] + ((idx & block_mask) << 1); + pv[0] = T(x); + pv[1] = T(y); + } + + //------------------------------------------------------------------------ + template + inline void vertex_block_storage::modify_vertex(unsigned idx, + double x, double y, + unsigned cmd) + { + unsigned block = idx >> block_shift; + unsigned offset = idx & block_mask; + T* pv = m_coord_blocks[block] + (offset << 1); + pv[0] = T(x); + pv[1] = T(y); + m_cmd_blocks[block][offset] = (int8u)cmd; + } + + //------------------------------------------------------------------------ + template + inline void vertex_block_storage::modify_command(unsigned idx, + unsigned cmd) + { + m_cmd_blocks[idx >> block_shift][idx & block_mask] = (int8u)cmd; + } + + //------------------------------------------------------------------------ + template + inline void vertex_block_storage::swap_vertices(unsigned v1, unsigned v2) + { + unsigned b1 = v1 >> block_shift; + unsigned b2 = v2 >> block_shift; + unsigned o1 = v1 & block_mask; + unsigned o2 = v2 & block_mask; + T* pv1 = m_coord_blocks[b1] + (o1 << 1); + T* pv2 = m_coord_blocks[b2] + (o2 << 1); + T val; + val = pv1[0]; pv1[0] = pv2[0]; pv2[0] = val; + val = pv1[1]; pv1[1] = pv2[1]; pv2[1] = val; + int8u cmd = m_cmd_blocks[b1][o1]; + m_cmd_blocks[b1][o1] = m_cmd_blocks[b2][o2]; + m_cmd_blocks[b2][o2] = cmd; + } + + //------------------------------------------------------------------------ + template + inline unsigned vertex_block_storage::last_command() const + { + if(m_total_vertices) return command(m_total_vertices - 1); + return path_cmd_stop; + } + + //------------------------------------------------------------------------ + template + inline unsigned vertex_block_storage::last_vertex(double* x, double* y) const + { + if(m_total_vertices) return vertex(m_total_vertices - 1, x, y); + return path_cmd_stop; + } + + //------------------------------------------------------------------------ + template + inline unsigned vertex_block_storage::prev_vertex(double* x, double* y) const + { + if(m_total_vertices > 1) return vertex(m_total_vertices - 2, x, y); + return path_cmd_stop; + } + + //------------------------------------------------------------------------ + template + inline double vertex_block_storage::last_x() const + { + if(m_total_vertices) + { + unsigned idx = m_total_vertices - 1; + return m_coord_blocks[idx >> block_shift][(idx & block_mask) << 1]; + } + return 0.0; + } + + //------------------------------------------------------------------------ + template + inline double vertex_block_storage::last_y() const + { + if(m_total_vertices) + { + unsigned idx = m_total_vertices - 1; + return m_coord_blocks[idx >> block_shift][((idx & block_mask) << 1) + 1]; + } + return 0.0; + } + + //------------------------------------------------------------------------ + template + inline unsigned vertex_block_storage::total_vertices() const + { + return m_total_vertices; + } + + //------------------------------------------------------------------------ + template + inline unsigned vertex_block_storage::vertex(unsigned idx, + double* x, double* y) const + { + unsigned nb = idx >> block_shift; + const T* pv = m_coord_blocks[nb] + ((idx & block_mask) << 1); + *x = pv[0]; + *y = pv[1]; + return m_cmd_blocks[nb][idx & block_mask]; + } + + //------------------------------------------------------------------------ + template + inline unsigned vertex_block_storage::command(unsigned idx) const + { + return m_cmd_blocks[idx >> block_shift][idx & block_mask]; + } + + //------------------------------------------------------------------------ + template + void vertex_block_storage::allocate_block(unsigned nb) + { + if(nb >= m_max_blocks) + { + T** new_coords = + pod_allocator::allocate((m_max_blocks + block_pool) * 2); + + unsigned char** new_cmds = + (unsigned char**)(new_coords + m_max_blocks + block_pool); + + if(m_coord_blocks) + { + memcpy(new_coords, + m_coord_blocks, + m_max_blocks * sizeof(T*)); + + memcpy(new_cmds, + m_cmd_blocks, + m_max_blocks * sizeof(unsigned char*)); + + pod_allocator::deallocate(m_coord_blocks, m_max_blocks * 2); + } + m_coord_blocks = new_coords; + m_cmd_blocks = new_cmds; + m_max_blocks += block_pool; + } + m_coord_blocks[nb] = + pod_allocator::allocate(block_size * 2 + + block_size / (sizeof(T) / sizeof(unsigned char))); + + m_cmd_blocks[nb] = + (unsigned char*)(m_coord_blocks[nb] + block_size * 2); + + m_total_blocks++; + } + + //------------------------------------------------------------------------ + template + int8u* vertex_block_storage::storage_ptrs(T** xy_ptr) + { + unsigned nb = m_total_vertices >> block_shift; + if(nb >= m_total_blocks) + { + allocate_block(nb); + } + *xy_ptr = m_coord_blocks[nb] + ((m_total_vertices & block_mask) << 1); + return m_cmd_blocks[nb] + (m_total_vertices & block_mask); + } + + + + + //-----------------------------------------------------poly_plain_adaptor + template class poly_plain_adaptor + { + public: + typedef T value_type; + + poly_plain_adaptor() : + m_data(0), + m_ptr(0), + m_end(0), + m_closed(false), + m_stop(false) + {} + + poly_plain_adaptor(const T* data, unsigned num_points, bool closed) : + m_data(data), + m_ptr(data), + m_end(data + num_points * 2), + m_closed(closed), + m_stop(false) + {} + + void init(const T* data, unsigned num_points, bool closed) + { + m_data = data; + m_ptr = data; + m_end = data + num_points * 2; + m_closed = closed; + m_stop = false; + } + + void rewind(unsigned) + { + m_ptr = m_data; + m_stop = false; + } + + unsigned vertex(double* x, double* y) + { + if(m_ptr < m_end) + { + bool first = m_ptr == m_data; + *x = *m_ptr++; + *y = *m_ptr++; + return first ? path_cmd_move_to : path_cmd_line_to; + } + *x = *y = 0.0; + if(m_closed && !m_stop) + { + m_stop = true; + return path_cmd_end_poly | path_flags_close; + } + return path_cmd_stop; + } + + private: + const T* m_data; + const T* m_ptr; + const T* m_end; + bool m_closed; + bool m_stop; + }; + + + + + + //-------------------------------------------------poly_container_adaptor + template class poly_container_adaptor + { + public: + typedef typename Container::value_type vertex_type; + + poly_container_adaptor() : + m_container(0), + m_index(0), + m_closed(false), + m_stop(false) + {} + + poly_container_adaptor(const Container& data, bool closed) : + m_container(&data), + m_index(0), + m_closed(closed), + m_stop(false) + {} + + void init(const Container& data, bool closed) + { + m_container = &data; + m_index = 0; + m_closed = closed; + m_stop = false; + } + + void rewind(unsigned) + { + m_index = 0; + m_stop = false; + } + + unsigned vertex(double* x, double* y) + { + if(m_index < m_container->size()) + { + bool first = m_index == 0; + const vertex_type& v = (*m_container)[m_index++]; + *x = v.x; + *y = v.y; + return first ? path_cmd_move_to : path_cmd_line_to; + } + *x = *y = 0.0; + if(m_closed && !m_stop) + { + m_stop = true; + return path_cmd_end_poly | path_flags_close; + } + return path_cmd_stop; + } + + private: + const Container* m_container; + unsigned m_index; + bool m_closed; + bool m_stop; + }; + + + + //-----------------------------------------poly_container_reverse_adaptor + template class poly_container_reverse_adaptor + { + public: + typedef typename Container::value_type vertex_type; + + poly_container_reverse_adaptor() : + m_container(0), + m_index(-1), + m_closed(false), + m_stop(false) + {} + + poly_container_reverse_adaptor(Container& data, bool closed) : + m_container(&data), + m_index(-1), + m_closed(closed), + m_stop(false) + {} + + void init(Container& data, bool closed) + { + m_container = &data; + m_index = m_container->size() - 1; + m_closed = closed; + m_stop = false; + } + + void rewind(unsigned) + { + m_index = m_container->size() - 1; + m_stop = false; + } + + unsigned vertex(double* x, double* y) + { + if(m_index >= 0) + { + bool first = m_index == int(m_container->size() - 1); + const vertex_type& v = (*m_container)[m_index--]; + *x = v.x; + *y = v.y; + return first ? path_cmd_move_to : path_cmd_line_to; + } + *x = *y = 0.0; + if(m_closed && !m_stop) + { + m_stop = true; + return path_cmd_end_poly | path_flags_close; + } + return path_cmd_stop; + } + + private: + Container* m_container; + int m_index; + bool m_closed; + bool m_stop; + }; + + + + + + //--------------------------------------------------------line_adaptor + class line_adaptor + { + public: + typedef double value_type; + + line_adaptor() : m_line(m_coord, 2, false) {} + line_adaptor(double x1, double y1, double x2, double y2) : + m_line(m_coord, 2, false) + { + m_coord[0] = x1; + m_coord[1] = y1; + m_coord[2] = x2; + m_coord[3] = y2; + } + + void init(double x1, double y1, double x2, double y2) + { + m_coord[0] = x1; + m_coord[1] = y1; + m_coord[2] = x2; + m_coord[3] = y2; + m_line.rewind(0); + } + + void rewind(unsigned) + { + m_line.rewind(0); + } + + unsigned vertex(double* x, double* y) + { + return m_line.vertex(x, y); + } + + private: + double m_coord[4]; + poly_plain_adaptor m_line; + }; + + + + + + + + + + + + + + //---------------------------------------------------------------path_base + // A container to store vertices with their flags. + // A path consists of a number of contours separated with "move_to" + // commands. The path storage can keep and maintain more than one + // path. + // To navigate to the beginning of a particular path, use rewind(path_id); + // Where path_id is what start_new_path() returns. So, when you call + // start_new_path() you need to store its return value somewhere else + // to navigate to the path afterwards. + // + // See also: vertex_source concept + //------------------------------------------------------------------------ + template class path_base + { + public: + typedef VertexContainer container_type; + typedef path_base self_type; + + //-------------------------------------------------------------------- + path_base() : m_vertices(), m_iterator(0) {} + void remove_all() { m_vertices.remove_all(); m_iterator = 0; } + void free_all() { m_vertices.free_all(); m_iterator = 0; } + + // Make path functions + //-------------------------------------------------------------------- + unsigned start_new_path(); + + void move_to(double x, double y); + void move_rel(double dx, double dy); + + void line_to(double x, double y); + void line_rel(double dx, double dy); + + void hline_to(double x); + void hline_rel(double dx); + + void vline_to(double y); + void vline_rel(double dy); + + void arc_to(double rx, double ry, + double angle, + bool large_arc_flag, + bool sweep_flag, + double x, double y); + + void arc_rel(double rx, double ry, + double angle, + bool large_arc_flag, + bool sweep_flag, + double dx, double dy); + + void curve3(double x_ctrl, double y_ctrl, + double x_to, double y_to); + + void curve3_rel(double dx_ctrl, double dy_ctrl, + double dx_to, double dy_to); + + void curve3(double x_to, double y_to); + + void curve3_rel(double dx_to, double dy_to); + + void curve4(double x_ctrl1, double y_ctrl1, + double x_ctrl2, double y_ctrl2, + double x_to, double y_to); + + void curve4_rel(double dx_ctrl1, double dy_ctrl1, + double dx_ctrl2, double dy_ctrl2, + double dx_to, double dy_to); + + void curve4(double x_ctrl2, double y_ctrl2, + double x_to, double y_to); + + void curve4_rel(double x_ctrl2, double y_ctrl2, + double x_to, double y_to); + + + void end_poly(unsigned flags = path_flags_close); + void close_polygon(unsigned flags = path_flags_none); + + // Accessors + //-------------------------------------------------------------------- + const container_type& vertices() const { return m_vertices; } + container_type& vertices() { return m_vertices; } + + unsigned total_vertices() const; + + void rel_to_abs(double* x, double* y) const; + + unsigned last_vertex(double* x, double* y) const; + unsigned prev_vertex(double* x, double* y) const; + + double last_x() const; + double last_y() const; + + unsigned vertex(unsigned idx, double* x, double* y) const; + unsigned command(unsigned idx) const; + + void modify_vertex(unsigned idx, double x, double y); + void modify_vertex(unsigned idx, double x, double y, unsigned cmd); + void modify_command(unsigned idx, unsigned cmd); + + // VertexSource interface + //-------------------------------------------------------------------- + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + // Arrange the orientation of a polygon, all polygons in a path, + // or in all paths. After calling arrange_orientations() or + // arrange_orientations_all_paths(), all the polygons will have + // the same orientation, i.e. path_flags_cw or path_flags_ccw + //-------------------------------------------------------------------- + unsigned arrange_polygon_orientation(unsigned start, path_flags_e orientation); + unsigned arrange_orientations(unsigned path_id, path_flags_e orientation); + void arrange_orientations_all_paths(path_flags_e orientation); + void invert_polygon(unsigned start); + + // Flip all vertices horizontally or vertically, + // between x1 and x2, or between y1 and y2 respectively + //-------------------------------------------------------------------- + void flip_x(double x1, double x2); + void flip_y(double y1, double y2); + + // Concatenate path. The path is added as is. + //-------------------------------------------------------------------- + template + void concat_path(VertexSource& vs, unsigned path_id = 0) + { + double x, y; + unsigned cmd; + vs.rewind(path_id); + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + m_vertices.add_vertex(x, y, cmd); + } + } + + //-------------------------------------------------------------------- + // Join path. The path is joined with the existing one, that is, + // it behaves as if the pen of a plotter was always down (drawing) + template + void join_path(VertexSource& vs, unsigned path_id = 0) + { + double x, y; + unsigned cmd; + vs.rewind(path_id); + cmd = vs.vertex(&x, &y); + if(!is_stop(cmd)) + { + if(is_vertex(cmd)) + { + double x0, y0; + unsigned cmd0 = last_vertex(&x0, &y0); + if(is_vertex(cmd0)) + { + if(calc_distance(x, y, x0, y0) > vertex_dist_epsilon) + { + if(is_move_to(cmd)) cmd = path_cmd_line_to; + m_vertices.add_vertex(x, y, cmd); + } + } + else + { + if(is_stop(cmd0)) + { + cmd = path_cmd_move_to; + } + else + { + if(is_move_to(cmd)) cmd = path_cmd_line_to; + } + m_vertices.add_vertex(x, y, cmd); + } + } + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + m_vertices.add_vertex(x, y, is_move_to(cmd) ? + unsigned(path_cmd_line_to) : + cmd); + } + } + } + + // Concatenate polygon/polyline. + //-------------------------------------------------------------------- + template void concat_poly(const T* data, + unsigned num_points, + bool closed) + { + poly_plain_adaptor poly(data, num_points, closed); + concat_path(poly); + } + + // Join polygon/polyline continuously. + //-------------------------------------------------------------------- + template void join_poly(const T* data, + unsigned num_points, + bool closed) + { + poly_plain_adaptor poly(data, num_points, closed); + join_path(poly); + } + + //-------------------------------------------------------------------- + void translate(double dx, double dy, unsigned path_id=0); + void translate_all_paths(double dx, double dy); + + //-------------------------------------------------------------------- + template + void transform(const Trans& trans, unsigned path_id=0) + { + unsigned num_ver = m_vertices.total_vertices(); + for(; path_id < num_ver; path_id++) + { + double x, y; + unsigned cmd = m_vertices.vertex(path_id, &x, &y); + if(is_stop(cmd)) break; + if(is_vertex(cmd)) + { + trans.transform(&x, &y); + m_vertices.modify_vertex(path_id, x, y); + } + } + } + + //-------------------------------------------------------------------- + template + void transform_all_paths(const Trans& trans) + { + unsigned idx; + unsigned num_ver = m_vertices.total_vertices(); + for(idx = 0; idx < num_ver; idx++) + { + double x, y; + if(is_vertex(m_vertices.vertex(idx, &x, &y))) + { + trans.transform(&x, &y); + m_vertices.modify_vertex(idx, x, y); + } + } + } + + + //-------------------------------------------------------------------- + // If the end points of a path are very, very close then make them + // exactly equal so that the stroke converter is not confused. + //-------------------------------------------------------------------- + unsigned align_path(unsigned idx = 0) + { + if (idx >= total_vertices() || !is_move_to(command(idx))) + { + return total_vertices(); + } + + double start_x, start_y; + for (; idx < total_vertices() && is_move_to(command(idx)); ++idx) + { + vertex(idx, &start_x, &start_y); + } + while (idx < total_vertices() && is_drawing(command(idx))) + ++idx; + + double x, y; + if (is_drawing(vertex(idx - 1, &x, &y)) && + is_equal_eps(x, start_x, 1e-8) && + is_equal_eps(y, start_y, 1e-8)) + { + modify_vertex(idx - 1, start_x, start_y); + } + + while (idx < total_vertices() && !is_move_to(command(idx))) + ++idx; + return idx; + } + + void align_all_paths() + { + for (unsigned i = 0; i < total_vertices(); i = align_path(i)); + } + + + private: + unsigned perceive_polygon_orientation(unsigned start, unsigned end); + void invert_polygon(unsigned start, unsigned end); + + VertexContainer m_vertices; + unsigned m_iterator; + }; + + //------------------------------------------------------------------------ + template + unsigned path_base::start_new_path() + { + if(!is_stop(m_vertices.last_command())) + { + m_vertices.add_vertex(0.0, 0.0, path_cmd_stop); + } + return m_vertices.total_vertices(); + } + + + //------------------------------------------------------------------------ + template + inline void path_base::rel_to_abs(double* x, double* y) const + { + if(m_vertices.total_vertices()) + { + double x2; + double y2; + if(is_vertex(m_vertices.last_vertex(&x2, &y2))) + { + *x += x2; + *y += y2; + } + } + } + + //------------------------------------------------------------------------ + template + inline void path_base::move_to(double x, double y) + { + m_vertices.add_vertex(x, y, path_cmd_move_to); + } + + //------------------------------------------------------------------------ + template + inline void path_base::move_rel(double dx, double dy) + { + rel_to_abs(&dx, &dy); + m_vertices.add_vertex(dx, dy, path_cmd_move_to); + } + + //------------------------------------------------------------------------ + template + inline void path_base::line_to(double x, double y) + { + m_vertices.add_vertex(x, y, path_cmd_line_to); + } + + //------------------------------------------------------------------------ + template + inline void path_base::line_rel(double dx, double dy) + { + rel_to_abs(&dx, &dy); + m_vertices.add_vertex(dx, dy, path_cmd_line_to); + } + + //------------------------------------------------------------------------ + template + inline void path_base::hline_to(double x) + { + m_vertices.add_vertex(x, last_y(), path_cmd_line_to); + } + + //------------------------------------------------------------------------ + template + inline void path_base::hline_rel(double dx) + { + double dy = 0; + rel_to_abs(&dx, &dy); + m_vertices.add_vertex(dx, dy, path_cmd_line_to); + } + + //------------------------------------------------------------------------ + template + inline void path_base::vline_to(double y) + { + m_vertices.add_vertex(last_x(), y, path_cmd_line_to); + } + + //------------------------------------------------------------------------ + template + inline void path_base::vline_rel(double dy) + { + double dx = 0; + rel_to_abs(&dx, &dy); + m_vertices.add_vertex(dx, dy, path_cmd_line_to); + } + + //------------------------------------------------------------------------ + template + void path_base::arc_to(double rx, double ry, + double angle, + bool large_arc_flag, + bool sweep_flag, + double x, double y) + { + if(m_vertices.total_vertices() && is_vertex(m_vertices.last_command())) + { + const double epsilon = 1e-30; + double x0 = 0.0; + double y0 = 0.0; + m_vertices.last_vertex(&x0, &y0); + + rx = fabs(rx); + ry = fabs(ry); + + // Ensure radii are valid + //------------------------- + if(rx < epsilon || ry < epsilon) + { + line_to(x, y); + return; + } + + if(calc_distance(x0, y0, x, y) < epsilon) + { + // If the endpoints (x, y) and (x0, y0) are identical, then this + // is equivalent to omitting the elliptical arc segment entirely. + return; + } + bezier_arc_svg a(x0, y0, rx, ry, angle, large_arc_flag, sweep_flag, x, y); + if(a.radii_ok()) + { + join_path(a); + } + else + { + line_to(x, y); + } + } + else + { + move_to(x, y); + } + } + + //------------------------------------------------------------------------ + template + void path_base::arc_rel(double rx, double ry, + double angle, + bool large_arc_flag, + bool sweep_flag, + double dx, double dy) + { + rel_to_abs(&dx, &dy); + arc_to(rx, ry, angle, large_arc_flag, sweep_flag, dx, dy); + } + + //------------------------------------------------------------------------ + template + void path_base::curve3(double x_ctrl, double y_ctrl, + double x_to, double y_to) + { + m_vertices.add_vertex(x_ctrl, y_ctrl, path_cmd_curve3); + m_vertices.add_vertex(x_to, y_to, path_cmd_curve3); + } + + //------------------------------------------------------------------------ + template + void path_base::curve3_rel(double dx_ctrl, double dy_ctrl, + double dx_to, double dy_to) + { + rel_to_abs(&dx_ctrl, &dy_ctrl); + rel_to_abs(&dx_to, &dy_to); + m_vertices.add_vertex(dx_ctrl, dy_ctrl, path_cmd_curve3); + m_vertices.add_vertex(dx_to, dy_to, path_cmd_curve3); + } + + //------------------------------------------------------------------------ + template + void path_base::curve3(double x_to, double y_to) + { + double x0; + double y0; + if(is_vertex(m_vertices.last_vertex(&x0, &y0))) + { + double x_ctrl; + double y_ctrl; + unsigned cmd = m_vertices.prev_vertex(&x_ctrl, &y_ctrl); + if(is_curve(cmd)) + { + x_ctrl = x0 + x0 - x_ctrl; + y_ctrl = y0 + y0 - y_ctrl; + } + else + { + x_ctrl = x0; + y_ctrl = y0; + } + curve3(x_ctrl, y_ctrl, x_to, y_to); + } + } + + //------------------------------------------------------------------------ + template + void path_base::curve3_rel(double dx_to, double dy_to) + { + rel_to_abs(&dx_to, &dy_to); + curve3(dx_to, dy_to); + } + + //------------------------------------------------------------------------ + template + void path_base::curve4(double x_ctrl1, double y_ctrl1, + double x_ctrl2, double y_ctrl2, + double x_to, double y_to) + { + m_vertices.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4); + m_vertices.add_vertex(x_ctrl2, y_ctrl2, path_cmd_curve4); + m_vertices.add_vertex(x_to, y_to, path_cmd_curve4); + } + + //------------------------------------------------------------------------ + template + void path_base::curve4_rel(double dx_ctrl1, double dy_ctrl1, + double dx_ctrl2, double dy_ctrl2, + double dx_to, double dy_to) + { + rel_to_abs(&dx_ctrl1, &dy_ctrl1); + rel_to_abs(&dx_ctrl2, &dy_ctrl2); + rel_to_abs(&dx_to, &dy_to); + m_vertices.add_vertex(dx_ctrl1, dy_ctrl1, path_cmd_curve4); + m_vertices.add_vertex(dx_ctrl2, dy_ctrl2, path_cmd_curve4); + m_vertices.add_vertex(dx_to, dy_to, path_cmd_curve4); + } + + //------------------------------------------------------------------------ + template + void path_base::curve4(double x_ctrl2, double y_ctrl2, + double x_to, double y_to) + { + double x0; + double y0; + if(is_vertex(last_vertex(&x0, &y0))) + { + double x_ctrl1; + double y_ctrl1; + unsigned cmd = prev_vertex(&x_ctrl1, &y_ctrl1); + if(is_curve(cmd)) + { + x_ctrl1 = x0 + x0 - x_ctrl1; + y_ctrl1 = y0 + y0 - y_ctrl1; + } + else + { + x_ctrl1 = x0; + y_ctrl1 = y0; + } + curve4(x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x_to, y_to); + } + } + + //------------------------------------------------------------------------ + template + void path_base::curve4_rel(double dx_ctrl2, double dy_ctrl2, + double dx_to, double dy_to) + { + rel_to_abs(&dx_ctrl2, &dy_ctrl2); + rel_to_abs(&dx_to, &dy_to); + curve4(dx_ctrl2, dy_ctrl2, dx_to, dy_to); + } + + //------------------------------------------------------------------------ + template + inline void path_base::end_poly(unsigned flags) + { + if(is_vertex(m_vertices.last_command())) + { + m_vertices.add_vertex(0.0, 0.0, path_cmd_end_poly | flags); + } + } + + //------------------------------------------------------------------------ + template + inline void path_base::close_polygon(unsigned flags) + { + end_poly(path_flags_close | flags); + } + + //------------------------------------------------------------------------ + template + inline unsigned path_base::total_vertices() const + { + return m_vertices.total_vertices(); + } + + //------------------------------------------------------------------------ + template + inline unsigned path_base::last_vertex(double* x, double* y) const + { + return m_vertices.last_vertex(x, y); + } + + //------------------------------------------------------------------------ + template + inline unsigned path_base::prev_vertex(double* x, double* y) const + { + return m_vertices.prev_vertex(x, y); + } + + //------------------------------------------------------------------------ + template + inline double path_base::last_x() const + { + return m_vertices.last_x(); + } + + //------------------------------------------------------------------------ + template + inline double path_base::last_y() const + { + return m_vertices.last_y(); + } + + //------------------------------------------------------------------------ + template + inline unsigned path_base::vertex(unsigned idx, double* x, double* y) const + { + return m_vertices.vertex(idx, x, y); + } + + //------------------------------------------------------------------------ + template + inline unsigned path_base::command(unsigned idx) const + { + return m_vertices.command(idx); + } + + //------------------------------------------------------------------------ + template + void path_base::modify_vertex(unsigned idx, double x, double y) + { + m_vertices.modify_vertex(idx, x, y); + } + + //------------------------------------------------------------------------ + template + void path_base::modify_vertex(unsigned idx, double x, double y, unsigned cmd) + { + m_vertices.modify_vertex(idx, x, y, cmd); + } + + //------------------------------------------------------------------------ + template + void path_base::modify_command(unsigned idx, unsigned cmd) + { + m_vertices.modify_command(idx, cmd); + } + + //------------------------------------------------------------------------ + template + inline void path_base::rewind(unsigned path_id) + { + m_iterator = path_id; + } + + //------------------------------------------------------------------------ + template + inline unsigned path_base::vertex(double* x, double* y) + { + if(m_iterator >= m_vertices.total_vertices()) return path_cmd_stop; + return m_vertices.vertex(m_iterator++, x, y); + } + + //------------------------------------------------------------------------ + template + unsigned path_base::perceive_polygon_orientation(unsigned start, + unsigned end) + { + // Calculate signed area (double area to be exact) + //--------------------- + unsigned np = end - start; + double area = 0.0; + unsigned i; + for(i = 0; i < np; i++) + { + double x1, y1, x2, y2; + m_vertices.vertex(start + i, &x1, &y1); + m_vertices.vertex(start + (i + 1) % np, &x2, &y2); + area += x1 * y2 - y1 * x2; + } + return (area < 0.0) ? path_flags_cw : path_flags_ccw; + } + + //------------------------------------------------------------------------ + template + void path_base::invert_polygon(unsigned start, unsigned end) + { + unsigned i; + unsigned tmp_cmd = m_vertices.command(start); + + --end; // Make "end" inclusive + + // Shift all commands to one position + for(i = start; i < end; i++) + { + m_vertices.modify_command(i, m_vertices.command(i + 1)); + } + + // Assign starting command to the ending command + m_vertices.modify_command(end, tmp_cmd); + + // Reverse the polygon + while(end > start) + { + m_vertices.swap_vertices(start++, end--); + } + } + + //------------------------------------------------------------------------ + template + void path_base::invert_polygon(unsigned start) + { + // Skip all non-vertices at the beginning + while(start < m_vertices.total_vertices() && + !is_vertex(m_vertices.command(start))) ++start; + + // Skip all insignificant move_to + while(start+1 < m_vertices.total_vertices() && + is_move_to(m_vertices.command(start)) && + is_move_to(m_vertices.command(start+1))) ++start; + + // Find the last vertex + unsigned end = start + 1; + while(end < m_vertices.total_vertices() && + !is_next_poly(m_vertices.command(end))) ++end; + + invert_polygon(start, end); + } + + //------------------------------------------------------------------------ + template + unsigned path_base::arrange_polygon_orientation(unsigned start, + path_flags_e orientation) + { + if(orientation == path_flags_none) return start; + + // Skip all non-vertices at the beginning + while(start < m_vertices.total_vertices() && + !is_vertex(m_vertices.command(start))) ++start; + + // Skip all insignificant move_to + while(start+1 < m_vertices.total_vertices() && + is_move_to(m_vertices.command(start)) && + is_move_to(m_vertices.command(start+1))) ++start; + + // Find the last vertex + unsigned end = start + 1; + while(end < m_vertices.total_vertices() && + !is_next_poly(m_vertices.command(end))) ++end; + + if(end - start > 2) + { + if(perceive_polygon_orientation(start, end) != unsigned(orientation)) + { + // Invert polygon, set orientation flag, and skip all end_poly + invert_polygon(start, end); + unsigned cmd; + while(end < m_vertices.total_vertices() && + is_end_poly(cmd = m_vertices.command(end))) + { + m_vertices.modify_command(end++, set_orientation(cmd, orientation)); + } + } + } + return end; + } + + //------------------------------------------------------------------------ + template + unsigned path_base::arrange_orientations(unsigned start, + path_flags_e orientation) + { + if(orientation != path_flags_none) + { + while(start < m_vertices.total_vertices()) + { + start = arrange_polygon_orientation(start, orientation); + if(is_stop(m_vertices.command(start))) + { + ++start; + break; + } + } + } + return start; + } + + //------------------------------------------------------------------------ + template + void path_base::arrange_orientations_all_paths(path_flags_e orientation) + { + if(orientation != path_flags_none) + { + unsigned start = 0; + while(start < m_vertices.total_vertices()) + { + start = arrange_orientations(start, orientation); + } + } + } + + //------------------------------------------------------------------------ + template + void path_base::flip_x(double x1, double x2) + { + unsigned i; + double x, y; + for(i = 0; i < m_vertices.total_vertices(); i++) + { + unsigned cmd = m_vertices.vertex(i, &x, &y); + if(is_vertex(cmd)) + { + m_vertices.modify_vertex(i, x2 - x + x1, y); + } + } + } + + //------------------------------------------------------------------------ + template + void path_base::flip_y(double y1, double y2) + { + unsigned i; + double x, y; + for(i = 0; i < m_vertices.total_vertices(); i++) + { + unsigned cmd = m_vertices.vertex(i, &x, &y); + if(is_vertex(cmd)) + { + m_vertices.modify_vertex(i, x, y2 - y + y1); + } + } + } + + //------------------------------------------------------------------------ + template + void path_base::translate(double dx, double dy, unsigned path_id) + { + unsigned num_ver = m_vertices.total_vertices(); + for(; path_id < num_ver; path_id++) + { + double x, y; + unsigned cmd = m_vertices.vertex(path_id, &x, &y); + if(is_stop(cmd)) break; + if(is_vertex(cmd)) + { + x += dx; + y += dy; + m_vertices.modify_vertex(path_id, x, y); + } + } + } + + //------------------------------------------------------------------------ + template + void path_base::translate_all_paths(double dx, double dy) + { + unsigned idx; + unsigned num_ver = m_vertices.total_vertices(); + for(idx = 0; idx < num_ver; idx++) + { + double x, y; + if(is_vertex(m_vertices.vertex(idx, &x, &y))) + { + x += dx; + y += dy; + m_vertices.modify_vertex(idx, x, y); + } + } + } + + //-----------------------------------------------------vertex_stl_storage + template class vertex_stl_storage + { + public: + typedef typename Container::value_type vertex_type; + typedef typename vertex_type::value_type value_type; + + void remove_all() { m_vertices.clear(); } + void free_all() { m_vertices.clear(); } + + void add_vertex(double x, double y, unsigned cmd) + { + m_vertices.push_back(vertex_type(value_type(x), + value_type(y), + int8u(cmd))); + } + + void modify_vertex(unsigned idx, double x, double y) + { + vertex_type& v = m_vertices[idx]; + v.x = value_type(x); + v.y = value_type(y); + } + + void modify_vertex(unsigned idx, double x, double y, unsigned cmd) + { + vertex_type& v = m_vertices[idx]; + v.x = value_type(x); + v.y = value_type(y); + v.cmd = int8u(cmd); + } + + void modify_command(unsigned idx, unsigned cmd) + { + m_vertices[idx].cmd = int8u(cmd); + } + + void swap_vertices(unsigned v1, unsigned v2) + { + vertex_type t = m_vertices[v1]; + m_vertices[v1] = m_vertices[v2]; + m_vertices[v2] = t; + } + + unsigned last_command() const + { + return m_vertices.size() ? + m_vertices[m_vertices.size() - 1].cmd : + path_cmd_stop; + } + + unsigned last_vertex(double* x, double* y) const + { + if(m_vertices.size() == 0) + { + *x = *y = 0.0; + return path_cmd_stop; + } + return vertex(m_vertices.size() - 1, x, y); + } + + unsigned prev_vertex(double* x, double* y) const + { + if(m_vertices.size() < 2) + { + *x = *y = 0.0; + return path_cmd_stop; + } + return vertex(m_vertices.size() - 2, x, y); + } + + double last_x() const + { + return m_vertices.size() ? m_vertices[m_vertices.size() - 1].x : 0.0; + } + + double last_y() const + { + return m_vertices.size() ? m_vertices[m_vertices.size() - 1].y : 0.0; + } + + unsigned total_vertices() const + { + return m_vertices.size(); + } + + unsigned vertex(unsigned idx, double* x, double* y) const + { + const vertex_type& v = m_vertices[idx]; + *x = v.x; + *y = v.y; + return v.cmd; + } + + unsigned command(unsigned idx) const + { + return m_vertices[idx].cmd; + } + + private: + Container m_vertices; + }; + + //-----------------------------------------------------------path_storage + typedef path_base > path_storage; + + // Example of declarations path_storage with pod_bvector as a container + //----------------------------------------------------------------------- + //typedef path_base > > path_storage; + +} + + + +// Example of declarations path_storage with std::vector as a container +//--------------------------------------------------------------------------- +//#include +//namespace agg +//{ +// typedef path_base > > stl_path_storage; +//} + + + + +#endif diff --git a/xs/src/agg/agg_path_storage_integer.h b/xs/src/agg/agg_path_storage_integer.h new file mode 100644 index 0000000000..7c48355993 --- /dev/null +++ b/xs/src/agg/agg_path_storage_integer.h @@ -0,0 +1,295 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_PATH_STORAGE_INTEGER_INCLUDED +#define AGG_PATH_STORAGE_INTEGER_INCLUDED + +#include +#include "agg_array.h" + +namespace agg +{ + //---------------------------------------------------------vertex_integer + template struct vertex_integer + { + enum path_cmd + { + cmd_move_to = 0, + cmd_line_to = 1, + cmd_curve3 = 2, + cmd_curve4 = 3 + }; + + enum coord_scale_e + { + coord_shift = CoordShift, + coord_scale = 1 << coord_shift + }; + + T x,y; + vertex_integer() {} + vertex_integer(T x_, T y_, unsigned flag) : + x(((x_ << 1) & ~1) | (flag & 1)), + y(((y_ << 1) & ~1) | (flag >> 1)) {} + + unsigned vertex(double* x_, double* y_, + double dx=0, double dy=0, + double scale=1.0) const + { + *x_ = dx + (double(x >> 1) / coord_scale) * scale; + *y_ = dy + (double(y >> 1) / coord_scale) * scale; + switch(((y & 1) << 1) | (x & 1)) + { + case cmd_move_to: return path_cmd_move_to; + case cmd_line_to: return path_cmd_line_to; + case cmd_curve3: return path_cmd_curve3; + case cmd_curve4: return path_cmd_curve4; + } + return path_cmd_stop; + } + }; + + + //---------------------------------------------------path_storage_integer + template class path_storage_integer + { + public: + typedef T value_type; + typedef vertex_integer vertex_integer_type; + + //-------------------------------------------------------------------- + path_storage_integer() : m_storage(), m_vertex_idx(0), m_closed(true) {} + + //-------------------------------------------------------------------- + void remove_all() { m_storage.remove_all(); } + + //-------------------------------------------------------------------- + void move_to(T x, T y) + { + m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_move_to)); + } + + //-------------------------------------------------------------------- + void line_to(T x, T y) + { + m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_line_to)); + } + + //-------------------------------------------------------------------- + void curve3(T x_ctrl, T y_ctrl, + T x_to, T y_to) + { + m_storage.add(vertex_integer_type(x_ctrl, y_ctrl, vertex_integer_type::cmd_curve3)); + m_storage.add(vertex_integer_type(x_to, y_to, vertex_integer_type::cmd_curve3)); + } + + //-------------------------------------------------------------------- + void curve4(T x_ctrl1, T y_ctrl1, + T x_ctrl2, T y_ctrl2, + T x_to, T y_to) + { + m_storage.add(vertex_integer_type(x_ctrl1, y_ctrl1, vertex_integer_type::cmd_curve4)); + m_storage.add(vertex_integer_type(x_ctrl2, y_ctrl2, vertex_integer_type::cmd_curve4)); + m_storage.add(vertex_integer_type(x_to, y_to, vertex_integer_type::cmd_curve4)); + } + + //-------------------------------------------------------------------- + void close_polygon() {} + + //-------------------------------------------------------------------- + unsigned size() const { return m_storage.size(); } + unsigned vertex(unsigned idx, double* x, double* y) const + { + return m_storage[idx].vertex(x, y); + } + + //-------------------------------------------------------------------- + unsigned byte_size() const { return m_storage.size() * sizeof(vertex_integer_type); } + void serialize(int8u* ptr) const + { + unsigned i; + for(i = 0; i < m_storage.size(); i++) + { + memcpy(ptr, &m_storage[i], sizeof(vertex_integer_type)); + ptr += sizeof(vertex_integer_type); + } + } + + //-------------------------------------------------------------------- + void rewind(unsigned) + { + m_vertex_idx = 0; + m_closed = true; + } + + //-------------------------------------------------------------------- + unsigned vertex(double* x, double* y) + { + if(m_storage.size() < 2 || m_vertex_idx > m_storage.size()) + { + *x = 0; + *y = 0; + return path_cmd_stop; + } + if(m_vertex_idx == m_storage.size()) + { + *x = 0; + *y = 0; + ++m_vertex_idx; + return path_cmd_end_poly | path_flags_close; + } + unsigned cmd = m_storage[m_vertex_idx].vertex(x, y); + if(is_move_to(cmd) && !m_closed) + { + *x = 0; + *y = 0; + m_closed = true; + return path_cmd_end_poly | path_flags_close; + } + m_closed = false; + ++m_vertex_idx; + return cmd; + } + + //-------------------------------------------------------------------- + rect_d bounding_rect() const + { + rect_d bounds(1e100, 1e100, -1e100, -1e100); + if(m_storage.size() == 0) + { + bounds.x1 = bounds.y1 = bounds.x2 = bounds.y2 = 0.0; + } + else + { + unsigned i; + for(i = 0; i < m_storage.size(); i++) + { + double x, y; + m_storage[i].vertex(&x, &y); + if(x < bounds.x1) bounds.x1 = x; + if(y < bounds.y1) bounds.y1 = y; + if(x > bounds.x2) bounds.x2 = x; + if(y > bounds.y2) bounds.y2 = y; + } + } + return bounds; + } + + private: + pod_bvector m_storage; + unsigned m_vertex_idx; + bool m_closed; + }; + + + + + //-----------------------------------------serialized_integer_path_adaptor + template class serialized_integer_path_adaptor + { + public: + typedef vertex_integer vertex_integer_type; + + //-------------------------------------------------------------------- + serialized_integer_path_adaptor() : + m_data(0), + m_end(0), + m_ptr(0), + m_dx(0.0), + m_dy(0.0), + m_scale(1.0), + m_vertices(0) + {} + + //-------------------------------------------------------------------- + serialized_integer_path_adaptor(const int8u* data, unsigned size, + double dx, double dy) : + m_data(data), + m_end(data + size), + m_ptr(data), + m_dx(dx), + m_dy(dy), + m_vertices(0) + {} + + //-------------------------------------------------------------------- + void init(const int8u* data, unsigned size, + double dx, double dy, double scale=1.0) + { + m_data = data; + m_end = data + size; + m_ptr = data; + m_dx = dx; + m_dy = dy; + m_scale = scale; + m_vertices = 0; + } + + + //-------------------------------------------------------------------- + void rewind(unsigned) + { + m_ptr = m_data; + m_vertices = 0; + } + + //-------------------------------------------------------------------- + unsigned vertex(double* x, double* y) + { + if(m_data == 0 || m_ptr > m_end) + { + *x = 0; + *y = 0; + return path_cmd_stop; + } + + if(m_ptr == m_end) + { + *x = 0; + *y = 0; + m_ptr += sizeof(vertex_integer_type); + return path_cmd_end_poly | path_flags_close; + } + + vertex_integer_type v; + memcpy(&v, m_ptr, sizeof(vertex_integer_type)); + unsigned cmd = v.vertex(x, y, m_dx, m_dy, m_scale); + if(is_move_to(cmd) && m_vertices > 2) + { + *x = 0; + *y = 0; + m_vertices = 0; + return path_cmd_end_poly | path_flags_close; + } + ++m_vertices; + m_ptr += sizeof(vertex_integer_type); + return cmd; + } + + private: + const int8u* m_data; + const int8u* m_end; + const int8u* m_ptr; + double m_dx; + double m_dy; + double m_scale; + unsigned m_vertices; + }; + +} + + +#endif + diff --git a/xs/src/agg/agg_pattern_filters_rgba.h b/xs/src/agg/agg_pattern_filters_rgba.h new file mode 100644 index 0000000000..c1d174cacb --- /dev/null +++ b/xs/src/agg/agg_pattern_filters_rgba.h @@ -0,0 +1,123 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_PATTERN_FILTERS_RGBA8_INCLUDED +#define AGG_PATTERN_FILTERS_RGBA8_INCLUDED + +#include "agg_basics.h" +#include "agg_line_aa_basics.h" +#include "agg_color_rgba.h" + + +namespace agg +{ + + //=======================================================pattern_filter_nn + template struct pattern_filter_nn + { + typedef ColorT color_type; + static unsigned dilation() { return 0; } + + static void AGG_INLINE pixel_low_res(color_type const* const* buf, + color_type* p, int x, int y) + { + *p = buf[y][x]; + } + + static void AGG_INLINE pixel_high_res(color_type const* const* buf, + color_type* p, int x, int y) + { + *p = buf[y >> line_subpixel_shift] + [x >> line_subpixel_shift]; + } + }; + + typedef pattern_filter_nn pattern_filter_nn_rgba8; + typedef pattern_filter_nn pattern_filter_nn_rgba16; + + + //===========================================pattern_filter_bilinear_rgba + template struct pattern_filter_bilinear_rgba + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + + + static unsigned dilation() { return 1; } + + static AGG_INLINE void pixel_low_res(color_type const* const* buf, + color_type* p, int x, int y) + { + *p = buf[y][x]; + } + + static AGG_INLINE void pixel_high_res(color_type const* const* buf, + color_type* p, int x, int y) + { + calc_type r, g, b, a; + r = g = b = a = 0; + + calc_type weight; + int x_lr = x >> line_subpixel_shift; + int y_lr = y >> line_subpixel_shift; + + x &= line_subpixel_mask; + y &= line_subpixel_mask; + const color_type* ptr = buf[y_lr] + x_lr; + + weight = (line_subpixel_scale - x) * + (line_subpixel_scale - y); + r += weight * ptr->r; + g += weight * ptr->g; + b += weight * ptr->b; + a += weight * ptr->a; + + ++ptr; + + weight = x * (line_subpixel_scale - y); + r += weight * ptr->r; + g += weight * ptr->g; + b += weight * ptr->b; + a += weight * ptr->a; + + ptr = buf[y_lr + 1] + x_lr; + + weight = (line_subpixel_scale - x) * y; + r += weight * ptr->r; + g += weight * ptr->g; + b += weight * ptr->b; + a += weight * ptr->a; + + ++ptr; + + weight = x * y; + r += weight * ptr->r; + g += weight * ptr->g; + b += weight * ptr->b; + a += weight * ptr->a; + + p->r = (value_type)color_type::downshift(r, line_subpixel_shift * 2); + p->g = (value_type)color_type::downshift(g, line_subpixel_shift * 2); + p->b = (value_type)color_type::downshift(b, line_subpixel_shift * 2); + p->a = (value_type)color_type::downshift(a, line_subpixel_shift * 2); + } + }; + + typedef pattern_filter_bilinear_rgba pattern_filter_bilinear_rgba8; + typedef pattern_filter_bilinear_rgba pattern_filter_bilinear_rgba16; + typedef pattern_filter_bilinear_rgba pattern_filter_bilinear_rgba32; +} + +#endif diff --git a/xs/src/agg/agg_pixfmt_amask_adaptor.h b/xs/src/agg/agg_pixfmt_amask_adaptor.h new file mode 100644 index 0000000000..568a74dac9 --- /dev/null +++ b/xs/src/agg/agg_pixfmt_amask_adaptor.h @@ -0,0 +1,240 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED +#define AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED + + +#include +#include "agg_array.h" +#include "agg_rendering_buffer.h" + + +namespace agg +{ + //==================================================pixfmt_amask_adaptor + template class pixfmt_amask_adaptor + { + public: + typedef PixFmt pixfmt_type; + typedef typename pixfmt_type::color_type color_type; + typedef typename pixfmt_type::row_data row_data; + typedef AlphaMask amask_type; + typedef typename amask_type::cover_type cover_type; + + private: + enum span_extra_tail_e { span_extra_tail = 256 }; + + void realloc_span(unsigned len) + { + if(len > m_span.size()) + { + m_span.resize(len + span_extra_tail); + } + } + + void init_span(unsigned len) + { + realloc_span(len); + memset(&m_span[0], amask_type::cover_full, len * sizeof(cover_type)); + } + + void init_span(unsigned len, const cover_type* covers) + { + realloc_span(len); + memcpy(&m_span[0], covers, len * sizeof(cover_type)); + } + + + public: + pixfmt_amask_adaptor(pixfmt_type& pixf, amask_type& mask) : + m_pixf(&pixf), m_mask(&mask), m_span() + {} + + void attach_pixfmt(pixfmt_type& pixf) { m_pixf = &pixf; } + void attach_alpha_mask(amask_type& mask) { m_mask = &mask; } + + //-------------------------------------------------------------------- + template + bool attach_pixfmt(PixFmt2& pixf, int x1, int y1, int x2, int y2) + { + return m_pixf->attach(pixf, x1, y1, x2, y2); + } + + //-------------------------------------------------------------------- + unsigned width() const { return m_pixf->width(); } + unsigned height() const { return m_pixf->height(); } + + //-------------------------------------------------------------------- + color_type pixel(int x, int y) + { + return m_pixf->pixel(x, y); + } + + //-------------------------------------------------------------------- + void copy_pixel(int x, int y, const color_type& c) + { + m_pixf->blend_pixel(x, y, c, m_mask->pixel(x, y)); + } + + //-------------------------------------------------------------------- + void blend_pixel(int x, int y, const color_type& c, cover_type cover) + { + m_pixf->blend_pixel(x, y, c, m_mask->combine_pixel(x, y, cover)); + } + + //-------------------------------------------------------------------- + void copy_hline(int x, int y, + unsigned len, + const color_type& c) + { + realloc_span(len); + m_mask->fill_hspan(x, y, &m_span[0], len); + m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); + } + + //-------------------------------------------------------------------- + void blend_hline(int x, int y, + unsigned len, + const color_type& c, + cover_type) + { + init_span(len); + m_mask->combine_hspan(x, y, &m_span[0], len); + m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); + } + + //-------------------------------------------------------------------- + void copy_vline(int x, int y, + unsigned len, + const color_type& c) + { + realloc_span(len); + m_mask->fill_vspan(x, y, &m_span[0], len); + m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); + } + + //-------------------------------------------------------------------- + void blend_vline(int x, int y, + unsigned len, + const color_type& c, + cover_type) + { + init_span(len); + m_mask->combine_vspan(x, y, &m_span[0], len); + m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); + } + + //-------------------------------------------------------------------- + void copy_from(const rendering_buffer& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len) + { + m_pixf->copy_from(from, xdst, ydst, xsrc, ysrc, len); + } + + + //-------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, + unsigned len, + const color_type& c, + const cover_type* covers) + { + init_span(len, covers); + m_mask->combine_hspan(x, y, &m_span[0], len); + m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); + } + + + //-------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, + unsigned len, + const color_type& c, + const cover_type* covers) + { + init_span(len, covers); + m_mask->combine_vspan(x, y, &m_span[0], len); + m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); + } + + + //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, unsigned len, const color_type* colors) + { + realloc_span(len); + m_mask->fill_hspan(x, y, &m_span[0], len); + m_pixf->blend_color_hspan(x, y, len, colors, &m_span[0], cover_full); + } + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, unsigned len, const color_type* colors) + { + realloc_span(len); + m_mask->fill_vspan(x, y, &m_span[0], len); + m_pixf->blend_color_vspan(x, y, len, colors, &m_span[0], cover_full); + } + + //-------------------------------------------------------------------- + void blend_color_hspan(int x, int y, + unsigned len, + const color_type* colors, + const cover_type* covers, + cover_type cover = cover_full) + { + if(covers) + { + init_span(len, covers); + m_mask->combine_hspan(x, y, &m_span[0], len); + } + else + { + realloc_span(len); + m_mask->fill_hspan(x, y, &m_span[0], len); + } + m_pixf->blend_color_hspan(x, y, len, colors, &m_span[0], cover); + } + + + //-------------------------------------------------------------------- + void blend_color_vspan(int x, int y, + unsigned len, + const color_type* colors, + const cover_type* covers, + cover_type cover = cover_full) + { + if(covers) + { + init_span(len, covers); + m_mask->combine_vspan(x, y, &m_span[0], len); + } + else + { + realloc_span(len); + m_mask->fill_vspan(x, y, &m_span[0], len); + } + m_pixf->blend_color_vspan(x, y, len, colors, &m_span[0], cover); + } + + private: + pixfmt_type* m_pixf; + const amask_type* m_mask; + pod_array m_span; + }; + +} + +#endif + diff --git a/xs/src/agg/agg_pixfmt_base.h b/xs/src/agg/agg_pixfmt_base.h new file mode 100644 index 0000000000..57ae19cfe0 --- /dev/null +++ b/xs/src/agg/agg_pixfmt_base.h @@ -0,0 +1,97 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_PIXFMT_BASE_INCLUDED +#define AGG_PIXFMT_BASE_INCLUDED + +#include "agg_basics.h" +#include "agg_color_gray.h" +#include "agg_color_rgba.h" + +namespace agg +{ + struct pixfmt_gray_tag + { + }; + + struct pixfmt_rgb_tag + { + }; + + struct pixfmt_rgba_tag + { + }; + + //--------------------------------------------------------------blender_base + template + struct blender_base + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + + static rgba get(value_type r, value_type g, value_type b, value_type a, cover_type cover = cover_full) + { + if (cover > cover_none) + { + rgba c( + color_type::to_double(r), + color_type::to_double(g), + color_type::to_double(b), + color_type::to_double(a)); + + if (cover < cover_full) + { + double x = double(cover) / cover_full; + c.r *= x; + c.g *= x; + c.b *= x; + c.a *= x; + } + + return c; + } + else return rgba::no_color(); + } + + static rgba get(const value_type* p, cover_type cover = cover_full) + { + return get( + p[order_type::R], + p[order_type::G], + p[order_type::B], + p[order_type::A], + cover); + } + + static void set(value_type* p, value_type r, value_type g, value_type b, value_type a) + { + p[order_type::R] = r; + p[order_type::G] = g; + p[order_type::B] = b; + p[order_type::A] = a; + } + + static void set(value_type* p, const rgba& c) + { + p[order_type::R] = color_type::from_double(c.r); + p[order_type::G] = color_type::from_double(c.g); + p[order_type::B] = color_type::from_double(c.b); + p[order_type::A] = color_type::from_double(c.a); + } + }; +} + +#endif diff --git a/xs/src/agg/agg_pixfmt_gray.h b/xs/src/agg/agg_pixfmt_gray.h new file mode 100644 index 0000000000..d03dc86501 --- /dev/null +++ b/xs/src/agg/agg_pixfmt_gray.h @@ -0,0 +1,738 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_PIXFMT_GRAY_INCLUDED +#define AGG_PIXFMT_GRAY_INCLUDED + +#include +#include "agg_pixfmt_base.h" +#include "agg_rendering_buffer.h" + +namespace agg +{ + + //============================================================blender_gray + template struct blender_gray + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + // Blend pixels using the non-premultiplied form of Alvy-Ray Smith's + // compositing function. Since the render buffer is opaque we skip the + // initial premultiply and final demultiply. + + static AGG_INLINE void blend_pix(value_type* p, + value_type cv, value_type alpha, cover_type cover) + { + blend_pix(p, cv, color_type::mult_cover(alpha, cover)); + } + + static AGG_INLINE void blend_pix(value_type* p, + value_type cv, value_type alpha) + { + *p = color_type::lerp(*p, cv, alpha); + } + }; + + + //======================================================blender_gray_pre + template struct blender_gray_pre + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + // Blend pixels using the premultiplied form of Alvy-Ray Smith's + // compositing function. + + static AGG_INLINE void blend_pix(value_type* p, + value_type cv, value_type alpha, cover_type cover) + { + blend_pix(p, color_type::mult_cover(cv, cover), color_type::mult_cover(alpha, cover)); + } + + static AGG_INLINE void blend_pix(value_type* p, + value_type cv, value_type alpha) + { + *p = color_type::prelerp(*p, cv, alpha); + } + }; + + + + //=====================================================apply_gamma_dir_gray + template class apply_gamma_dir_gray + { + public: + typedef typename ColorT::value_type value_type; + + apply_gamma_dir_gray(const GammaLut& gamma) : m_gamma(gamma) {} + + AGG_INLINE void operator () (value_type* p) + { + *p = m_gamma.dir(*p); + } + + private: + const GammaLut& m_gamma; + }; + + + + //=====================================================apply_gamma_inv_gray + template class apply_gamma_inv_gray + { + public: + typedef typename ColorT::value_type value_type; + + apply_gamma_inv_gray(const GammaLut& gamma) : m_gamma(gamma) {} + + AGG_INLINE void operator () (value_type* p) + { + *p = m_gamma.inv(*p); + } + + private: + const GammaLut& m_gamma; + }; + + + + //=================================================pixfmt_alpha_blend_gray + template + class pixfmt_alpha_blend_gray + { + public: + typedef pixfmt_gray_tag pixfmt_category; + typedef RenBuf rbuf_type; + typedef typename rbuf_type::row_data row_data; + typedef Blender blender_type; + typedef typename blender_type::color_type color_type; + typedef int order_type; // A fake one + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + enum + { + num_components = 1, + pix_width = sizeof(value_type) * Step, + pix_step = Step, + pix_offset = Offset, + }; + struct pixel_type + { + value_type c[num_components]; + + void set(value_type v) + { + c[0] = v; + } + + void set(const color_type& color) + { + set(color.v); + } + + void get(value_type& v) const + { + v = c[0]; + } + + color_type get() const + { + return color_type(c[0]); + } + + pixel_type* next() + { + return (pixel_type*)(c + pix_step); + } + + const pixel_type* next() const + { + return (const pixel_type*)(c + pix_step); + } + + pixel_type* advance(int n) + { + return (pixel_type*)(c + n * pix_step); + } + + const pixel_type* advance(int n) const + { + return (const pixel_type*)(c + n * pix_step); + } + }; + + private: + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, + value_type v, value_type a, + unsigned cover) + { + blender_type::blend_pix(p->c, v, a, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, value_type v, value_type a) + { + blender_type::blend_pix(p->c, v, a); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover) + { + blender_type::blend_pix(p->c, c.v, c.a, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, const color_type& c) + { + blender_type::blend_pix(p->c, c.v, c.a); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover) + { + if (!c.is_transparent()) + { + if (c.is_opaque() && cover == cover_mask) + { + p->set(c); + } + else + { + blend_pix(p, c, cover); + } + } + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c) + { + if (!c.is_transparent()) + { + if (c.is_opaque()) + { + p->set(c); + } + else + { + blend_pix(p, c); + } + } + } + + public: + //-------------------------------------------------------------------- + explicit pixfmt_alpha_blend_gray(rbuf_type& rb) : + m_rbuf(&rb) + {} + void attach(rbuf_type& rb) { m_rbuf = &rb; } + //-------------------------------------------------------------------- + + template + bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) + { + rect_i r(x1, y1, x2, y2); + if (r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) + { + int stride = pixf.stride(); + m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), + (r.x2 - r.x1) + 1, + (r.y2 - r.y1) + 1, + stride); + return true; + } + return false; + } + + //-------------------------------------------------------------------- + AGG_INLINE unsigned width() const { return m_rbuf->width(); } + AGG_INLINE unsigned height() const { return m_rbuf->height(); } + AGG_INLINE int stride() const { return m_rbuf->stride(); } + + //-------------------------------------------------------------------- + int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } + const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } + row_data row(int y) const { return m_rbuf->row(y); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* pix_ptr(int x, int y) + { + return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step + pix_offset); + } + + AGG_INLINE const int8u* pix_ptr(int x, int y) const + { + return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step + pix_offset); + } + + // Return pointer to pixel value, forcing row to be allocated. + AGG_INLINE pixel_type* pix_value_ptr(int x, int y, unsigned len) + { + return (pixel_type*)(m_rbuf->row_ptr(x, y, len) + sizeof(value_type) * (x * pix_step + pix_offset)); + } + + // Return pointer to pixel value, or null if row not allocated. + AGG_INLINE const pixel_type* pix_value_ptr(int x, int y) const + { + int8u* p = m_rbuf->row_ptr(y); + return p ? (pixel_type*)(p + sizeof(value_type) * (x * pix_step + pix_offset)) : 0; + } + + // Get pixel pointer from raw buffer pointer. + AGG_INLINE static pixel_type* pix_value_ptr(void* p) + { + return (pixel_type*)((value_type*)p + pix_offset); + } + + // Get pixel pointer from raw buffer pointer. + AGG_INLINE static const pixel_type* pix_value_ptr(const void* p) + { + return (const pixel_type*)((const value_type*)p + pix_offset); + } + + //-------------------------------------------------------------------- + AGG_INLINE static void write_plain_color(void* p, color_type c) + { + // Grayscale formats are implicitly premultiplied. + c.premultiply(); + pix_value_ptr(p)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE static color_type read_plain_color(const void* p) + { + return pix_value_ptr(p)->get(); + } + + //-------------------------------------------------------------------- + AGG_INLINE static void make_pix(int8u* p, const color_type& c) + { + ((pixel_type*)p)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE color_type pixel(int x, int y) const + { + if (const pixel_type* p = pix_value_ptr(x, y)) + { + return p->get(); + } + return color_type::no_color(); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_pixel(int x, int y, const color_type& c) + { + pix_value_ptr(x, y, 1)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) + { + copy_or_blend_pix(pix_value_ptr(x, y, 1), c, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_hline(int x, int y, + unsigned len, + const color_type& c) + { + pixel_type* p = pix_value_ptr(x, y, len); + do + { + p->set(c); + p = p->next(); + } + while(--len); + } + + + //-------------------------------------------------------------------- + AGG_INLINE void copy_vline(int x, int y, + unsigned len, + const color_type& c) + { + do + { + pix_value_ptr(x, y++, 1)->set(c); + } + while (--len); + } + + + //-------------------------------------------------------------------- + void blend_hline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + if (!c.is_transparent()) + { + pixel_type* p = pix_value_ptr(x, y, len); + + if (c.is_opaque() && cover == cover_mask) + { + do + { + p->set(c); + p = p->next(); + } + while (--len); + } + else + { + do + { + blend_pix(p, c, cover); + p = p->next(); + } + while (--len); + } + } + } + + + //-------------------------------------------------------------------- + void blend_vline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + if (!c.is_transparent()) + { + if (c.is_opaque() && cover == cover_mask) + { + do + { + pix_value_ptr(x, y++, 1)->set(c); + } + while (--len); + } + else + { + do + { + blend_pix(pix_value_ptr(x, y++, 1), c, cover); + } + while (--len); + } + } + } + + + //-------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + if (!c.is_transparent()) + { + pixel_type* p = pix_value_ptr(x, y, len); + + do + { + if (c.is_opaque() && *covers == cover_mask) + { + p->set(c); + } + else + { + blend_pix(p, c, *covers); + } + p = p->next(); + ++covers; + } + while (--len); + } + } + + + //-------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + if (!c.is_transparent()) + { + do + { + pixel_type* p = pix_value_ptr(x, y++, 1); + + if (c.is_opaque() && *covers == cover_mask) + { + p->set(c); + } + else + { + blend_pix(p, c, *covers); + } + ++covers; + } + while (--len); + } + } + + + //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, + unsigned len, + const color_type* colors) + { + pixel_type* p = pix_value_ptr(x, y, len); + + do + { + p->set(*colors++); + p = p->next(); + } + while (--len); + } + + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, + unsigned len, + const color_type* colors) + { + do + { + pix_value_ptr(x, y++, 1)->set(*colors++); + } + while (--len); + } + + + //-------------------------------------------------------------------- + void blend_color_hspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + pixel_type* p = pix_value_ptr(x, y, len); + + if (covers) + { + do + { + copy_or_blend_pix(p, *colors++, *covers++); + p = p->next(); + } + while (--len); + } + else + { + if (cover == cover_mask) + { + do + { + copy_or_blend_pix(p, *colors++); + p = p->next(); + } + while (--len); + } + else + { + do + { + copy_or_blend_pix(p, *colors++, cover); + p = p->next(); + } + while (--len); + } + } + } + + + //-------------------------------------------------------------------- + void blend_color_vspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + if (covers) + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, *covers++); + } + while (--len); + } + else + { + if (cover == cover_mask) + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++); + } + while (--len); + } + else + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, cover); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + template void for_each_pixel(Function f) + { + unsigned y; + for (y = 0; y < height(); ++y) + { + row_data r = m_rbuf->row(y); + if (r.ptr) + { + unsigned len = r.x2 - r.x1 + 1; + pixel_type* p = pix_value_ptr(r.x1, y, len); + do + { + f(p->c); + p = p->next(); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + template void apply_gamma_dir(const GammaLut& g) + { + for_each_pixel(apply_gamma_dir_gray(g)); + } + + //-------------------------------------------------------------------- + template void apply_gamma_inv(const GammaLut& g) + { + for_each_pixel(apply_gamma_inv_gray(g)); + } + + //-------------------------------------------------------------------- + template + void copy_from(const RenBuf2& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len) + { + if (const int8u* p = from.row_ptr(ysrc)) + { + memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, + p + xsrc * pix_width, + len * pix_width); + } + } + + //-------------------------------------------------------------------- + // Blend from single color, using grayscale surface as alpha channel. + template + void blend_from_color(const SrcPixelFormatRenderer& from, + const color_type& color, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + typedef typename SrcPixelFormatRenderer::color_type src_color_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + do + { + copy_or_blend_pix(pdst, color, src_color_type::scale_cover(cover, psrc->c[0])); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + } + + //-------------------------------------------------------------------- + // Blend from color table, using grayscale surface as indexes into table. + // Obviously, this only works for integer value types. + template + void blend_from_lut(const SrcPixelFormatRenderer& from, + const color_type* color_lut, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + do + { + copy_or_blend_pix(pdst, color_lut[psrc->c[0]], cover); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + } + + private: + rbuf_type* m_rbuf; + }; + + typedef blender_gray blender_gray8; + typedef blender_gray blender_sgray8; + typedef blender_gray blender_gray16; + typedef blender_gray blender_gray32; + + typedef blender_gray_pre blender_gray8_pre; + typedef blender_gray_pre blender_sgray8_pre; + typedef blender_gray_pre blender_gray16_pre; + typedef blender_gray_pre blender_gray32_pre; + + typedef pixfmt_alpha_blend_gray pixfmt_gray8; + typedef pixfmt_alpha_blend_gray pixfmt_sgray8; + typedef pixfmt_alpha_blend_gray pixfmt_gray16; + typedef pixfmt_alpha_blend_gray pixfmt_gray32; + + typedef pixfmt_alpha_blend_gray pixfmt_gray8_pre; + typedef pixfmt_alpha_blend_gray pixfmt_sgray8_pre; + typedef pixfmt_alpha_blend_gray pixfmt_gray16_pre; + typedef pixfmt_alpha_blend_gray pixfmt_gray32_pre; +} + +#endif + diff --git a/xs/src/agg/agg_pixfmt_rgb.h b/xs/src/agg/agg_pixfmt_rgb.h new file mode 100644 index 0000000000..6fa8772ce0 --- /dev/null +++ b/xs/src/agg/agg_pixfmt_rgb.h @@ -0,0 +1,995 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_PIXFMT_RGB_INCLUDED +#define AGG_PIXFMT_RGB_INCLUDED + +#include +#include "agg_pixfmt_base.h" +#include "agg_rendering_buffer.h" + +namespace agg +{ + + //=====================================================apply_gamma_dir_rgb + template class apply_gamma_dir_rgb + { + public: + typedef typename ColorT::value_type value_type; + + apply_gamma_dir_rgb(const GammaLut& gamma) : m_gamma(gamma) {} + + AGG_INLINE void operator () (value_type* p) + { + p[Order::R] = m_gamma.dir(p[Order::R]); + p[Order::G] = m_gamma.dir(p[Order::G]); + p[Order::B] = m_gamma.dir(p[Order::B]); + } + + private: + const GammaLut& m_gamma; + }; + + + + //=====================================================apply_gamma_inv_rgb + template class apply_gamma_inv_rgb + { + public: + typedef typename ColorT::value_type value_type; + + apply_gamma_inv_rgb(const GammaLut& gamma) : m_gamma(gamma) {} + + AGG_INLINE void operator () (value_type* p) + { + p[Order::R] = m_gamma.inv(p[Order::R]); + p[Order::G] = m_gamma.inv(p[Order::G]); + p[Order::B] = m_gamma.inv(p[Order::B]); + } + + private: + const GammaLut& m_gamma; + }; + + + //=========================================================blender_rgb + template + struct blender_rgb + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + // Blend pixels using the non-premultiplied form of Alvy-Ray Smith's + // compositing function. Since the render buffer is opaque we skip the + // initial premultiply and final demultiply. + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) + { + blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha) + { + p[Order::R] = color_type::lerp(p[Order::R], cr, alpha); + p[Order::G] = color_type::lerp(p[Order::G], cg, alpha); + p[Order::B] = color_type::lerp(p[Order::B], cb, alpha); + } + }; + + //======================================================blender_rgb_pre + template + struct blender_rgb_pre + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + // Blend pixels using the premultiplied form of Alvy-Ray Smith's + // compositing function. + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) + { + blend_pix(p, + color_type::mult_cover(cr, cover), + color_type::mult_cover(cg, cover), + color_type::mult_cover(cb, cover), + color_type::mult_cover(alpha, cover)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha) + { + p[Order::R] = color_type::prelerp(p[Order::R], cr, alpha); + p[Order::G] = color_type::prelerp(p[Order::G], cg, alpha); + p[Order::B] = color_type::prelerp(p[Order::B], cb, alpha); + } + }; + + //===================================================blender_rgb_gamma + template + class blender_rgb_gamma : public blender_base + { + public: + typedef ColorT color_type; + typedef Order order_type; + typedef Gamma gamma_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + blender_rgb_gamma() : m_gamma(0) {} + void gamma(const gamma_type& g) { m_gamma = &g; } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) + { + blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover)); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha) + { + calc_type r = m_gamma->dir(p[Order::R]); + calc_type g = m_gamma->dir(p[Order::G]); + calc_type b = m_gamma->dir(p[Order::B]); + p[Order::R] = m_gamma->inv(color_type::downscale((m_gamma->dir(cr) - r) * alpha) + r); + p[Order::G] = m_gamma->inv(color_type::downscale((m_gamma->dir(cg) - g) * alpha) + g); + p[Order::B] = m_gamma->inv(color_type::downscale((m_gamma->dir(cb) - b) * alpha) + b); + } + + private: + const gamma_type* m_gamma; + }; + + + //==================================================pixfmt_alpha_blend_rgb + template + class pixfmt_alpha_blend_rgb + { + public: + typedef pixfmt_rgb_tag pixfmt_category; + typedef RenBuf rbuf_type; + typedef Blender blender_type; + typedef typename rbuf_type::row_data row_data; + typedef typename blender_type::color_type color_type; + typedef typename blender_type::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + enum + { + num_components = 3, + pix_step = Step, + pix_offset = Offset, + pix_width = sizeof(value_type) * pix_step + }; + struct pixel_type + { + value_type c[num_components]; + + void set(value_type r, value_type g, value_type b) + { + c[order_type::R] = r; + c[order_type::G] = g; + c[order_type::B] = b; + } + + void set(const color_type& color) + { + set(color.r, color.g, color.b); + } + + void get(value_type& r, value_type& g, value_type& b) const + { + r = c[order_type::R]; + g = c[order_type::G]; + b = c[order_type::B]; + } + + color_type get() const + { + return color_type( + c[order_type::R], + c[order_type::G], + c[order_type::B]); + } + + pixel_type* next() + { + return (pixel_type*)(c + pix_step); + } + + const pixel_type* next() const + { + return (const pixel_type*)(c + pix_step); + } + + pixel_type* advance(int n) + { + return (pixel_type*)(c + n * pix_step); + } + + const pixel_type* advance(int n) const + { + return (const pixel_type*)(c + n * pix_step); + } + }; + + private: + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, + value_type r, value_type g, value_type b, value_type a, + unsigned cover) + { + m_blender.blend_pix(p->c, r, g, b, a, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, + value_type r, value_type g, value_type b, value_type a) + { + m_blender.blend_pix(p->c, r, g, b, a); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover) + { + m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, const color_type& c) + { + m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover) + { + if (!c.is_transparent()) + { + if (c.is_opaque() && cover == cover_mask) + { + p->set(c); + } + else + { + blend_pix(p, c, cover); + } + } + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c) + { + if (!c.is_transparent()) + { + if (c.is_opaque()) + { + p->set(c); + } + else + { + blend_pix(p, c); + } + } + } + + public: + //-------------------------------------------------------------------- + explicit pixfmt_alpha_blend_rgb(rbuf_type& rb) : + m_rbuf(&rb) + {} + void attach(rbuf_type& rb) { m_rbuf = &rb; } + + //-------------------------------------------------------------------- + template + bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) + { + rect_i r(x1, y1, x2, y2); + if (r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) + { + int stride = pixf.stride(); + m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), + (r.x2 - r.x1) + 1, + (r.y2 - r.y1) + 1, + stride); + return true; + } + return false; + } + + //-------------------------------------------------------------------- + Blender& blender() { return m_blender; } + + //-------------------------------------------------------------------- + AGG_INLINE unsigned width() const { return m_rbuf->width(); } + AGG_INLINE unsigned height() const { return m_rbuf->height(); } + AGG_INLINE int stride() const { return m_rbuf->stride(); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } + AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } + AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* pix_ptr(int x, int y) + { + return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step + pix_offset); + } + + AGG_INLINE const int8u* pix_ptr(int x, int y) const + { + return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step + pix_offset); + } + + // Return pointer to pixel value, forcing row to be allocated. + AGG_INLINE pixel_type* pix_value_ptr(int x, int y, unsigned len) + { + return (pixel_type*)(m_rbuf->row_ptr(x, y, len) + sizeof(value_type) * (x * pix_step + pix_offset)); + } + + // Return pointer to pixel value, or null if row not allocated. + AGG_INLINE const pixel_type* pix_value_ptr(int x, int y) const + { + int8u* p = m_rbuf->row_ptr(y); + return p ? (pixel_type*)(p + sizeof(value_type) * (x * pix_step + pix_offset)) : 0; + } + + // Get pixel pointer from raw buffer pointer. + AGG_INLINE static pixel_type* pix_value_ptr(void* p) + { + return (pixel_type*)((value_type*)p + pix_offset); + } + + // Get pixel pointer from raw buffer pointer. + AGG_INLINE static const pixel_type* pix_value_ptr(const void* p) + { + return (const pixel_type*)((const value_type*)p + pix_offset); + } + + //-------------------------------------------------------------------- + AGG_INLINE static void write_plain_color(void* p, color_type c) + { + // RGB formats are implicitly premultiplied. + c.premultiply(); + pix_value_ptr(p)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE static color_type read_plain_color(const void* p) + { + return pix_value_ptr(p)->get(); + } + + //-------------------------------------------------------------------- + AGG_INLINE static void make_pix(int8u* p, const color_type& c) + { + ((pixel_type*)p)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE color_type pixel(int x, int y) const + { + if (const pixel_type* p = pix_value_ptr(x, y)) + { + return p->get(); + } + return color_type::no_color(); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_pixel(int x, int y, const color_type& c) + { + pix_value_ptr(x, y, 1)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) + { + copy_or_blend_pix(pix_value_ptr(x, y, 1), c, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_hline(int x, int y, + unsigned len, + const color_type& c) + { + pixel_type* p = pix_value_ptr(x, y, len); + do + { + p->set(c); + p = p->next(); + } + while(--len); + } + + + //-------------------------------------------------------------------- + AGG_INLINE void copy_vline(int x, int y, + unsigned len, + const color_type& c) + { + do + { + pix_value_ptr(x, y++, 1)->set(c); + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_hline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + if (!c.is_transparent()) + { + pixel_type* p = pix_value_ptr(x, y, len); + + if (c.is_opaque() && cover == cover_mask) + { + do + { + p->set(c); + p = p->next(); + } + while (--len); + } + else + { + do + { + blend_pix(p, c, cover); + p = p->next(); + } + while (--len); + } + } + } + + + //-------------------------------------------------------------------- + void blend_vline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + if (!c.is_transparent()) + { + if (c.is_opaque() && cover == cover_mask) + { + do + { + pix_value_ptr(x, y++, 1)->set(c); + } + while (--len); + } + else + { + do + { + blend_pix(pix_value_ptr(x, y++, 1), c, cover); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + if (!c.is_transparent()) + { + pixel_type* p = pix_value_ptr(x, y, len); + + do + { + if (c.is_opaque() && *covers == cover_mask) + { + p->set(c); + } + else + { + blend_pix(p, c, *covers); + } + p = p->next(); + ++covers; + } + while (--len); + } + } + + + //-------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + if (!c.is_transparent()) + { + do + { + pixel_type* p = pix_value_ptr(x, y++, 1); + + if (c.is_opaque() && *covers == cover_mask) + { + p->set(c); + } + else + { + blend_pix(p, c, *covers); + } + ++covers; + } + while (--len); + } + } + + //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, + unsigned len, + const color_type* colors) + { + pixel_type* p = pix_value_ptr(x, y, len); + + do + { + p->set(*colors++); + p = p->next(); + } + while (--len); + } + + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, + unsigned len, + const color_type* colors) + { + do + { + pix_value_ptr(x, y++, 1)->set(*colors++); + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_color_hspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + pixel_type* p = pix_value_ptr(x, y, len); + + if (covers) + { + do + { + copy_or_blend_pix(p, *colors++, *covers++); + p = p->next(); + } + while (--len); + } + else + { + if (cover == cover_mask) + { + do + { + copy_or_blend_pix(p, *colors++); + p = p->next(); + } + while (--len); + } + else + { + do + { + copy_or_blend_pix(p, *colors++, cover); + p = p->next(); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + void blend_color_vspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + if (covers) + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, *covers++); + } + while (--len); + } + else + { + if (cover == cover_mask) + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++); + } + while (--len); + } + else + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, cover); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + template void for_each_pixel(Function f) + { + for (unsigned y = 0; y < height(); ++y) + { + row_data r = m_rbuf->row(y); + if (r.ptr) + { + unsigned len = r.x2 - r.x1 + 1; + pixel_type* p = pix_value_ptr(r.x1, y, len); + do + { + f(p->c); + p = p->next(); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + template void apply_gamma_dir(const GammaLut& g) + { + for_each_pixel(apply_gamma_dir_rgb(g)); + } + + //-------------------------------------------------------------------- + template void apply_gamma_inv(const GammaLut& g) + { + for_each_pixel(apply_gamma_inv_rgb(g)); + } + + //-------------------------------------------------------------------- + template + void copy_from(const RenBuf2& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len) + { + if (const int8u* p = from.row_ptr(ysrc)) + { + memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, + p + xsrc * pix_width, + len * pix_width); + } + } + + //-------------------------------------------------------------------- + // Blend from an RGBA surface. + template + void blend_from(const SrcPixelFormatRenderer& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + typedef typename SrcPixelFormatRenderer::order_type src_order; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + if (cover == cover_mask) + { + do + { + value_type alpha = psrc->c[src_order::A]; + if (alpha <= color_type::empty_value()) + { + if (alpha >= color_type::full_value()) + { + pdst->c[order_type::R] = psrc->c[src_order::R]; + pdst->c[order_type::G] = psrc->c[src_order::G]; + pdst->c[order_type::B] = psrc->c[src_order::B]; + } + else + { + blend_pix(pdst, + psrc->c[src_order::R], + psrc->c[src_order::G], + psrc->c[src_order::B], + alpha); + } + } + psrc = psrc->next(); + pdst = pdst->next(); + } + while(--len); + } + else + { + do + { + copy_or_blend_pix(pdst, psrc->get(), cover); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + // Blend from single color, using grayscale surface as alpha channel. + template + void blend_from_color(const SrcPixelFormatRenderer& from, + const color_type& color, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + typedef typename SrcPixelFormatRenderer::color_type src_color_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + do + { + copy_or_blend_pix(pdst, color, src_color_type::scale_cover(cover, psrc->c[0])); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + } + + //-------------------------------------------------------------------- + // Blend from color table, using grayscale surface as indexes into table. + // Obviously, this only works for integer value types. + template + void blend_from_lut(const SrcPixelFormatRenderer& from, + const color_type* color_lut, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + if (cover == cover_mask) + { + do + { + const color_type& color = color_lut[psrc->c[0]]; + blend_pix(pdst, color); + psrc = psrc->next(); + pdst = pdst->next(); + } + while(--len); + } + else + { + do + { + copy_or_blend_pix(pdst, color_lut[psrc->c[0]], cover); + psrc = psrc->next(); + pdst = pdst->next(); + } + while(--len); + } + } + } + + private: + rbuf_type* m_rbuf; + Blender m_blender; + }; + + //----------------------------------------------------------------------- + typedef blender_rgb blender_rgb24; + typedef blender_rgb blender_bgr24; + typedef blender_rgb blender_srgb24; + typedef blender_rgb blender_sbgr24; + typedef blender_rgb blender_rgb48; + typedef blender_rgb blender_bgr48; + typedef blender_rgb blender_rgb96; + typedef blender_rgb blender_bgr96; + + typedef blender_rgb_pre blender_rgb24_pre; + typedef blender_rgb_pre blender_bgr24_pre; + typedef blender_rgb_pre blender_srgb24_pre; + typedef blender_rgb_pre blender_sbgr24_pre; + typedef blender_rgb_pre blender_rgb48_pre; + typedef blender_rgb_pre blender_bgr48_pre; + typedef blender_rgb_pre blender_rgb96_pre; + typedef blender_rgb_pre blender_bgr96_pre; + + typedef pixfmt_alpha_blend_rgb pixfmt_rgb24; + typedef pixfmt_alpha_blend_rgb pixfmt_bgr24; + typedef pixfmt_alpha_blend_rgb pixfmt_srgb24; + typedef pixfmt_alpha_blend_rgb pixfmt_sbgr24; + typedef pixfmt_alpha_blend_rgb pixfmt_rgb48; + typedef pixfmt_alpha_blend_rgb pixfmt_bgr48; + typedef pixfmt_alpha_blend_rgb pixfmt_rgb96; + typedef pixfmt_alpha_blend_rgb pixfmt_bgr96; + + typedef pixfmt_alpha_blend_rgb pixfmt_rgb24_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_bgr24_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_srgb24_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_sbgr24_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_rgb48_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_bgr48_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_rgb96_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_bgr96_pre; + + typedef pixfmt_alpha_blend_rgb pixfmt_rgbx32; + typedef pixfmt_alpha_blend_rgb pixfmt_xrgb32; + typedef pixfmt_alpha_blend_rgb pixfmt_xbgr32; + typedef pixfmt_alpha_blend_rgb pixfmt_bgrx32; + typedef pixfmt_alpha_blend_rgb pixfmt_srgbx32; + typedef pixfmt_alpha_blend_rgb pixfmt_sxrgb32; + typedef pixfmt_alpha_blend_rgb pixfmt_sxbgr32; + typedef pixfmt_alpha_blend_rgb pixfmt_sbgrx32; + typedef pixfmt_alpha_blend_rgb pixfmt_rgbx64; + typedef pixfmt_alpha_blend_rgb pixfmt_xrgb64; + typedef pixfmt_alpha_blend_rgb pixfmt_xbgr64; + typedef pixfmt_alpha_blend_rgb pixfmt_bgrx64; + typedef pixfmt_alpha_blend_rgb pixfmt_rgbx128; + typedef pixfmt_alpha_blend_rgb pixfmt_xrgb128; + typedef pixfmt_alpha_blend_rgb pixfmt_xbgr128; + typedef pixfmt_alpha_blend_rgb pixfmt_bgrx128; + + typedef pixfmt_alpha_blend_rgb pixfmt_rgbx32_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_xrgb32_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_xbgr32_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_bgrx32_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_srgbx32_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_sxrgb32_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_sxbgr32_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_sbgrx32_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_rgbx64_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_xrgb64_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_xbgr64_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_bgrx64_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_rgbx128_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_xrgb128_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_xbgr128_pre; + typedef pixfmt_alpha_blend_rgb pixfmt_bgrx128_pre; + + + //-----------------------------------------------------pixfmt_rgb24_gamma + template class pixfmt_rgb24_gamma : + public pixfmt_alpha_blend_rgb, rendering_buffer, 3> + { + public: + pixfmt_rgb24_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb, rendering_buffer, 3>(rb) + { + this->blender().gamma(g); + } + }; + + //-----------------------------------------------------pixfmt_srgb24_gamma + template class pixfmt_srgb24_gamma : + public pixfmt_alpha_blend_rgb, rendering_buffer, 3> + { + public: + pixfmt_srgb24_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb, rendering_buffer, 3>(rb) + { + this->blender().gamma(g); + } + }; + + //-----------------------------------------------------pixfmt_bgr24_gamma + template class pixfmt_bgr24_gamma : + public pixfmt_alpha_blend_rgb, rendering_buffer, 3> + { + public: + pixfmt_bgr24_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb, rendering_buffer, 3>(rb) + { + this->blender().gamma(g); + } + }; + + //-----------------------------------------------------pixfmt_sbgr24_gamma + template class pixfmt_sbgr24_gamma : + public pixfmt_alpha_blend_rgb, rendering_buffer, 3> + { + public: + pixfmt_sbgr24_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb, rendering_buffer, 3>(rb) + { + this->blender().gamma(g); + } + }; + + //-----------------------------------------------------pixfmt_rgb48_gamma + template class pixfmt_rgb48_gamma : + public pixfmt_alpha_blend_rgb, rendering_buffer, 3> + { + public: + pixfmt_rgb48_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb, rendering_buffer, 3>(rb) + { + this->blender().gamma(g); + } + }; + + //-----------------------------------------------------pixfmt_bgr48_gamma + template class pixfmt_bgr48_gamma : + public pixfmt_alpha_blend_rgb, rendering_buffer, 3> + { + public: + pixfmt_bgr48_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb, rendering_buffer, 3>(rb) + { + this->blender().gamma(g); + } + }; + +} + +#endif + diff --git a/xs/src/agg/agg_pixfmt_rgb_packed.h b/xs/src/agg/agg_pixfmt_rgb_packed.h new file mode 100644 index 0000000000..9152cf060f --- /dev/null +++ b/xs/src/agg/agg_pixfmt_rgb_packed.h @@ -0,0 +1,1311 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_PIXFMT_RGB_PACKED_INCLUDED +#define AGG_PIXFMT_RGB_PACKED_INCLUDED + +#include +#include "agg_basics.h" +#include "agg_color_rgba.h" +#include "agg_rendering_buffer.h" + +namespace agg +{ + //=========================================================blender_rgb555 + struct blender_rgb555 + { + typedef rgba8 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int16u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type rgb = *p; + calc_type r = (rgb >> 7) & 0xF8; + calc_type g = (rgb >> 2) & 0xF8; + calc_type b = (rgb << 3) & 0xF8; + *p = (pixel_type) + (((((cr - r) * alpha + (r << 8)) >> 1) & 0x7C00) | + ((((cg - g) * alpha + (g << 8)) >> 6) & 0x03E0) | + (((cb - b) * alpha + (b << 8)) >> 11) | 0x8000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xF8) << 7) | + ((g & 0xF8) << 2) | + (b >> 3) | 0x8000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 7) & 0xF8, + (p >> 2) & 0xF8, + (p << 3) & 0xF8); + } + }; + + + //=====================================================blender_rgb555_pre + struct blender_rgb555_pre + { + typedef rgba8 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int16u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned cover) + { + alpha = color_type::base_mask - alpha; + pixel_type rgb = *p; + calc_type r = (rgb >> 7) & 0xF8; + calc_type g = (rgb >> 2) & 0xF8; + calc_type b = (rgb << 3) & 0xF8; + *p = (pixel_type) + ((((r * alpha + cr * cover) >> 1) & 0x7C00) | + (((g * alpha + cg * cover) >> 6) & 0x03E0) | + ((b * alpha + cb * cover) >> 11) | 0x8000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xF8) << 7) | + ((g & 0xF8) << 2) | + (b >> 3) | 0x8000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 7) & 0xF8, + (p >> 2) & 0xF8, + (p << 3) & 0xF8); + } + }; + + + + + //=====================================================blender_rgb555_gamma + template class blender_rgb555_gamma + { + public: + typedef rgba8 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int16u pixel_type; + typedef Gamma gamma_type; + + blender_rgb555_gamma() : m_gamma(0) {} + void gamma(const gamma_type& g) { m_gamma = &g; } + + AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type rgb = *p; + calc_type r = m_gamma->dir((rgb >> 7) & 0xF8); + calc_type g = m_gamma->dir((rgb >> 2) & 0xF8); + calc_type b = m_gamma->dir((rgb << 3) & 0xF8); + *p = (pixel_type) + (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 8)) >> 8) << 7) & 0x7C00) | + ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 8)) >> 8) << 2) & 0x03E0) | + (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 8)) >> 8) >> 3) | 0x8000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xF8) << 7) | + ((g & 0xF8) << 2) | + (b >> 3) | 0x8000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 7) & 0xF8, + (p >> 2) & 0xF8, + (p << 3) & 0xF8); + } + + private: + const Gamma* m_gamma; + }; + + + + + + //=========================================================blender_rgb565 + struct blender_rgb565 + { + typedef rgba8 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int16u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type rgb = *p; + calc_type r = (rgb >> 8) & 0xF8; + calc_type g = (rgb >> 3) & 0xFC; + calc_type b = (rgb << 3) & 0xF8; + *p = (pixel_type) + (((((cr - r) * alpha + (r << 8)) ) & 0xF800) | + ((((cg - g) * alpha + (g << 8)) >> 5) & 0x07E0) | + (((cb - b) * alpha + (b << 8)) >> 11)); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 8) & 0xF8, + (p >> 3) & 0xFC, + (p << 3) & 0xF8); + } + }; + + + + //=====================================================blender_rgb565_pre + struct blender_rgb565_pre + { + typedef rgba8 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int16u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned cover) + { + alpha = color_type::base_mask - alpha; + pixel_type rgb = *p; + calc_type r = (rgb >> 8) & 0xF8; + calc_type g = (rgb >> 3) & 0xFC; + calc_type b = (rgb << 3) & 0xF8; + *p = (pixel_type) + ((((r * alpha + cr * cover) ) & 0xF800) | + (((g * alpha + cg * cover) >> 5 ) & 0x07E0) | + ((b * alpha + cb * cover) >> 11)); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 8) & 0xF8, + (p >> 3) & 0xFC, + (p << 3) & 0xF8); + } + }; + + + + //=====================================================blender_rgb565_gamma + template class blender_rgb565_gamma + { + public: + typedef rgba8 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int16u pixel_type; + typedef Gamma gamma_type; + + blender_rgb565_gamma() : m_gamma(0) {} + void gamma(const gamma_type& g) { m_gamma = &g; } + + AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type rgb = *p; + calc_type r = m_gamma->dir((rgb >> 8) & 0xF8); + calc_type g = m_gamma->dir((rgb >> 3) & 0xFC); + calc_type b = m_gamma->dir((rgb << 3) & 0xF8); + *p = (pixel_type) + (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 8)) >> 8) << 8) & 0xF800) | + ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 8)) >> 8) << 3) & 0x07E0) | + (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 8)) >> 8) >> 3)); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 8) & 0xF8, + (p >> 3) & 0xFC, + (p << 3) & 0xF8); + } + + private: + const Gamma* m_gamma; + }; + + + + //=====================================================blender_rgbAAA + struct blender_rgbAAA + { + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type rgb = *p; + calc_type r = (rgb >> 14) & 0xFFC0; + calc_type g = (rgb >> 4) & 0xFFC0; + calc_type b = (rgb << 6) & 0xFFC0; + *p = (pixel_type) + (((((cr - r) * alpha + (r << 16)) >> 2) & 0x3FF00000) | + ((((cg - g) * alpha + (g << 16)) >> 12) & 0x000FFC00) | + (((cb - b) * alpha + (b << 16)) >> 22) | 0xC0000000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xFFC0) << 14) | + ((g & 0xFFC0) << 4) | + (b >> 6) | 0xC0000000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 14) & 0xFFC0, + (p >> 4) & 0xFFC0, + (p << 6) & 0xFFC0); + } + }; + + + + //==================================================blender_rgbAAA_pre + struct blender_rgbAAA_pre + { + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned cover) + { + alpha = color_type::base_mask - alpha; + cover = (cover + 1) << (color_type::base_shift - 8); + pixel_type rgb = *p; + calc_type r = (rgb >> 14) & 0xFFC0; + calc_type g = (rgb >> 4) & 0xFFC0; + calc_type b = (rgb << 6) & 0xFFC0; + *p = (pixel_type) + ((((r * alpha + cr * cover) >> 2) & 0x3FF00000) | + (((g * alpha + cg * cover) >> 12) & 0x000FFC00) | + ((b * alpha + cb * cover) >> 22) | 0xC0000000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xFFC0) << 14) | + ((g & 0xFFC0) << 4) | + (b >> 6) | 0xC0000000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 14) & 0xFFC0, + (p >> 4) & 0xFFC0, + (p << 6) & 0xFFC0); + } + }; + + + + //=================================================blender_rgbAAA_gamma + template class blender_rgbAAA_gamma + { + public: + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + typedef Gamma gamma_type; + + blender_rgbAAA_gamma() : m_gamma(0) {} + void gamma(const gamma_type& g) { m_gamma = &g; } + + AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type rgb = *p; + calc_type r = m_gamma->dir((rgb >> 14) & 0xFFC0); + calc_type g = m_gamma->dir((rgb >> 4) & 0xFFC0); + calc_type b = m_gamma->dir((rgb << 6) & 0xFFC0); + *p = (pixel_type) + (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) << 14) & 0x3FF00000) | + ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 4 ) & 0x000FFC00) | + (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) >> 6 ) | 0xC0000000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xFFC0) << 14) | + ((g & 0xFFC0) << 4) | + (b >> 6) | 0xC0000000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 14) & 0xFFC0, + (p >> 4) & 0xFFC0, + (p << 6) & 0xFFC0); + } + private: + const Gamma* m_gamma; + }; + + + //=====================================================blender_bgrAAA + struct blender_bgrAAA + { + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type bgr = *p; + calc_type b = (bgr >> 14) & 0xFFC0; + calc_type g = (bgr >> 4) & 0xFFC0; + calc_type r = (bgr << 6) & 0xFFC0; + *p = (pixel_type) + (((((cb - b) * alpha + (b << 16)) >> 2) & 0x3FF00000) | + ((((cg - g) * alpha + (g << 16)) >> 12) & 0x000FFC00) | + (((cr - r) * alpha + (r << 16)) >> 22) | 0xC0000000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((b & 0xFFC0) << 14) | + ((g & 0xFFC0) << 4) | + (r >> 6) | 0xC0000000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p << 6) & 0xFFC0, + (p >> 4) & 0xFFC0, + (p >> 14) & 0xFFC0); + } + }; + + + + //=================================================blender_bgrAAA_pre + struct blender_bgrAAA_pre + { + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned cover) + { + alpha = color_type::base_mask - alpha; + cover = (cover + 1) << (color_type::base_shift - 8); + pixel_type bgr = *p; + calc_type b = (bgr >> 14) & 0xFFC0; + calc_type g = (bgr >> 4) & 0xFFC0; + calc_type r = (bgr << 6) & 0xFFC0; + *p = (pixel_type) + ((((b * alpha + cb * cover) >> 2) & 0x3FF00000) | + (((g * alpha + cg * cover) >> 12) & 0x000FFC00) | + ((r * alpha + cr * cover) >> 22) | 0xC0000000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((b & 0xFFC0) << 14) | + ((g & 0xFFC0) << 4) | + (r >> 6) | 0xC0000000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p << 6) & 0xFFC0, + (p >> 4) & 0xFFC0, + (p >> 14) & 0xFFC0); + } + }; + + + + //=================================================blender_bgrAAA_gamma + template class blender_bgrAAA_gamma + { + public: + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + typedef Gamma gamma_type; + + blender_bgrAAA_gamma() : m_gamma(0) {} + void gamma(const gamma_type& g) { m_gamma = &g; } + + AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type bgr = *p; + calc_type b = m_gamma->dir((bgr >> 14) & 0xFFC0); + calc_type g = m_gamma->dir((bgr >> 4) & 0xFFC0); + calc_type r = m_gamma->dir((bgr << 6) & 0xFFC0); + *p = (pixel_type) + (((m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) << 14) & 0x3FF00000) | + ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 4 ) & 0x000FFC00) | + (m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) >> 6 ) | 0xC0000000); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((b & 0xFFC0) << 14) | + ((g & 0xFFC0) << 4) | + (r >> 6) | 0xC0000000); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p << 6) & 0xFFC0, + (p >> 4) & 0xFFC0, + (p >> 14) & 0xFFC0); + } + + private: + const Gamma* m_gamma; + }; + + + + //=====================================================blender_rgbBBA + struct blender_rgbBBA + { + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type rgb = *p; + calc_type r = (rgb >> 16) & 0xFFE0; + calc_type g = (rgb >> 5) & 0xFFE0; + calc_type b = (rgb << 6) & 0xFFC0; + *p = (pixel_type) + (((((cr - r) * alpha + (r << 16)) ) & 0xFFE00000) | + ((((cg - g) * alpha + (g << 16)) >> 11) & 0x001FFC00) | + (((cb - b) * alpha + (b << 16)) >> 22)); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 16) & 0xFFE0, + (p >> 5) & 0xFFE0, + (p << 6) & 0xFFC0); + } + }; + + + //=================================================blender_rgbBBA_pre + struct blender_rgbBBA_pre + { + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned cover) + { + alpha = color_type::base_mask - alpha; + cover = (cover + 1) << (color_type::base_shift - 8); + pixel_type rgb = *p; + calc_type r = (rgb >> 16) & 0xFFE0; + calc_type g = (rgb >> 5) & 0xFFE0; + calc_type b = (rgb << 6) & 0xFFC0; + *p = (pixel_type) + ((((r * alpha + cr * cover) ) & 0xFFE00000) | + (((g * alpha + cg * cover) >> 11) & 0x001FFC00) | + ((b * alpha + cb * cover) >> 22)); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 16) & 0xFFE0, + (p >> 5) & 0xFFE0, + (p << 6) & 0xFFC0); + } + }; + + + + //=================================================blender_rgbBBA_gamma + template class blender_rgbBBA_gamma + { + public: + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + typedef Gamma gamma_type; + + blender_rgbBBA_gamma() : m_gamma(0) {} + void gamma(const gamma_type& g) { m_gamma = &g; } + + AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type rgb = *p; + calc_type r = m_gamma->dir((rgb >> 16) & 0xFFE0); + calc_type g = m_gamma->dir((rgb >> 5) & 0xFFE0); + calc_type b = m_gamma->dir((rgb << 6) & 0xFFC0); + *p = (pixel_type) + (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) << 16) & 0xFFE00000) | + ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 5 ) & 0x001FFC00) | + (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) >> 6 )); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p >> 16) & 0xFFE0, + (p >> 5) & 0xFFE0, + (p << 6) & 0xFFC0); + } + + private: + const Gamma* m_gamma; + }; + + + //=====================================================blender_bgrABB + struct blender_bgrABB + { + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type bgr = *p; + calc_type b = (bgr >> 16) & 0xFFC0; + calc_type g = (bgr >> 6) & 0xFFE0; + calc_type r = (bgr << 5) & 0xFFE0; + *p = (pixel_type) + (((((cb - b) * alpha + (b << 16)) ) & 0xFFC00000) | + ((((cg - g) * alpha + (g << 16)) >> 10) & 0x003FF800) | + (((cr - r) * alpha + (r << 16)) >> 21)); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p << 5) & 0xFFE0, + (p >> 6) & 0xFFE0, + (p >> 16) & 0xFFC0); + } + }; + + + //=================================================blender_bgrABB_pre + struct blender_bgrABB_pre + { + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + + static AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned cover) + { + alpha = color_type::base_mask - alpha; + cover = (cover + 1) << (color_type::base_shift - 8); + pixel_type bgr = *p; + calc_type b = (bgr >> 16) & 0xFFC0; + calc_type g = (bgr >> 6) & 0xFFE0; + calc_type r = (bgr << 5) & 0xFFE0; + *p = (pixel_type) + ((((b * alpha + cb * cover) ) & 0xFFC00000) | + (((g * alpha + cg * cover) >> 10) & 0x003FF800) | + ((r * alpha + cr * cover) >> 21)); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p << 5) & 0xFFE0, + (p >> 6) & 0xFFE0, + (p >> 16) & 0xFFC0); + } + }; + + + + //=================================================blender_bgrABB_gamma + template class blender_bgrABB_gamma + { + public: + typedef rgba16 color_type; + typedef color_type::value_type value_type; + typedef color_type::calc_type calc_type; + typedef int32u pixel_type; + typedef Gamma gamma_type; + + blender_bgrABB_gamma() : m_gamma(0) {} + void gamma(const gamma_type& g) { m_gamma = &g; } + + AGG_INLINE void blend_pix(pixel_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha, + unsigned) + { + pixel_type bgr = *p; + calc_type b = m_gamma->dir((bgr >> 16) & 0xFFC0); + calc_type g = m_gamma->dir((bgr >> 6) & 0xFFE0); + calc_type r = m_gamma->dir((bgr << 5) & 0xFFE0); + *p = (pixel_type) + (((m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) << 16) & 0xFFC00000) | + ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 6 ) & 0x003FF800) | + (m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) >> 5 )); + } + + static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) + { + return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); + } + + static AGG_INLINE color_type make_color(pixel_type p) + { + return color_type((p << 5) & 0xFFE0, + (p >> 6) & 0xFFE0, + (p >> 16) & 0xFFC0); + } + + private: + const Gamma* m_gamma; + }; + + + + //===========================================pixfmt_alpha_blend_rgb_packed + template class pixfmt_alpha_blend_rgb_packed + { + public: + typedef RenBuf rbuf_type; + typedef typename rbuf_type::row_data row_data; + typedef Blender blender_type; + typedef typename blender_type::color_type color_type; + typedef typename blender_type::pixel_type pixel_type; + typedef int order_type; // A fake one + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + enum base_scale_e + { + base_shift = color_type::base_shift, + base_scale = color_type::base_scale, + base_mask = color_type::base_mask, + pix_width = sizeof(pixel_type), + }; + + private: + //-------------------------------------------------------------------- + AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover) + { + if (c.a) + { + calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; + if(alpha == base_mask) + { + *p = m_blender.make_pix(c.r, c.g, c.b); + } + else + { + m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); + } + } + } + + public: + //-------------------------------------------------------------------- + explicit pixfmt_alpha_blend_rgb_packed(rbuf_type& rb) : m_rbuf(&rb) {} + void attach(rbuf_type& rb) { m_rbuf = &rb; } + + //-------------------------------------------------------------------- + template + bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) + { + rect_i r(x1, y1, x2, y2); + if(r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) + { + int stride = pixf.stride(); + m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), + (r.x2 - r.x1) + 1, + (r.y2 - r.y1) + 1, + stride); + return true; + } + return false; + } + + Blender& blender() { return m_blender; } + + //-------------------------------------------------------------------- + AGG_INLINE unsigned width() const { return m_rbuf->width(); } + AGG_INLINE unsigned height() const { return m_rbuf->height(); } + AGG_INLINE int stride() const { return m_rbuf->stride(); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } + AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } + AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* pix_ptr(int x, int y) + { + return m_rbuf->row_ptr(y) + x * pix_width; + } + + AGG_INLINE const int8u* pix_ptr(int x, int y) const + { + return m_rbuf->row_ptr(y) + x * pix_width; + } + + //-------------------------------------------------------------------- + AGG_INLINE void make_pix(int8u* p, const color_type& c) + { + *(pixel_type*)p = m_blender.make_pix(c.r, c.g, c.b); + } + + //-------------------------------------------------------------------- + AGG_INLINE color_type pixel(int x, int y) const + { + return m_blender.make_color(((pixel_type*)m_rbuf->row_ptr(y))[x]); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_pixel(int x, int y, const color_type& c) + { + ((pixel_type*) + m_rbuf->row_ptr(x, y, 1))[x] = + m_blender.make_pix(c.r, c.g, c.b); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) + { + copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y, 1) + x, c, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_hline(int x, int y, + unsigned len, + const color_type& c) + { + pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; + pixel_type v = m_blender.make_pix(c.r, c.g, c.b); + do + { + *p++ = v; + } + while(--len); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_vline(int x, int y, + unsigned len, + const color_type& c) + { + pixel_type v = m_blender.make_pix(c.r, c.g, c.b); + do + { + pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x; + *p = v; + } + while(--len); + } + + //-------------------------------------------------------------------- + void blend_hline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + if (c.a) + { + pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; + calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; + if(alpha == base_mask) + { + pixel_type v = m_blender.make_pix(c.r, c.g, c.b); + do + { + *p++ = v; + } + while(--len); + } + else + { + do + { + m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); + ++p; + } + while(--len); + } + } + } + + //-------------------------------------------------------------------- + void blend_vline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + if (c.a) + { + calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; + if(alpha == base_mask) + { + pixel_type v = m_blender.make_pix(c.r, c.g, c.b); + do + { + ((pixel_type*)m_rbuf->row_ptr(x, y++, 1))[x] = v; + } + while(--len); + } + else + { + do + { + m_blender.blend_pix( + (pixel_type*)m_rbuf->row_ptr(x, y++, 1), + c.r, c.g, c.b, alpha, cover); + } + while(--len); + } + } + } + + //-------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; + do + { + copy_or_blend_pix(p, c, *covers++); + ++p; + } + while(--len); + } + + //-------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + do + { + copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x, + c, *covers++); + } + while(--len); + } + + //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, + unsigned len, + const color_type* colors) + { + pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; + do + { + *p++ = m_blender.make_pix(colors->r, colors->g, colors->b); + ++colors; + } + while(--len); + } + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, + unsigned len, + const color_type* colors) + { + do + { + pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x; + *p = m_blender.make_pix(colors->r, colors->g, colors->b); + ++colors; + } + while(--len); + } + + //-------------------------------------------------------------------- + void blend_color_hspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; + do + { + copy_or_blend_pix(p++, *colors++, covers ? *covers++ : cover); + } + while(--len); + } + + //-------------------------------------------------------------------- + void blend_color_vspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + do + { + copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x, + *colors++, covers ? *covers++ : cover); + } + while(--len); + } + + //-------------------------------------------------------------------- + template + void copy_from(const RenBuf2& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len) + { + const int8u* p = from.row_ptr(ysrc); + if(p) + { + memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, + p + xsrc * pix_width, + len * pix_width); + } + } + + //-------------------------------------------------------------------- + template + void blend_from(const SrcPixelFormatRenderer& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::order_type src_order; + + const value_type* psrc = (const value_type*)from.row_ptr(ysrc); + if(psrc) + { + psrc += xsrc * 4; + pixel_type* pdst = + (pixel_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; + do + { + value_type alpha = psrc[src_order::A]; + if(alpha) + { + if(alpha == base_mask && cover == 255) + { + *pdst = m_blender.make_pix(psrc[src_order::R], + psrc[src_order::G], + psrc[src_order::B]); + } + else + { + m_blender.blend_pix(pdst, + psrc[src_order::R], + psrc[src_order::G], + psrc[src_order::B], + alpha, + cover); + } + } + psrc += 4; + ++pdst; + } + while(--len); + } + } + + //-------------------------------------------------------------------- + template + void blend_from_color(const SrcPixelFormatRenderer& from, + const color_type& color, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::value_type src_value_type; + const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc); + if(psrc) + { + psrc += xsrc * SrcPixelFormatRenderer::pix_step + SrcPixelFormatRenderer::pix_offset; + pixel_type* pdst = + (pixel_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; + + do + { + m_blender.blend_pix(pdst, + color.r, color.g, color.b, color.a, + cover); + psrc += SrcPixelFormatRenderer::pix_step; + ++pdst; + } + while(--len); + } + } + + //-------------------------------------------------------------------- + template + void blend_from_lut(const SrcPixelFormatRenderer& from, + const color_type* color_lut, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::value_type src_value_type; + const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc); + if(psrc) + { + psrc += xsrc * SrcPixelFormatRenderer::pix_step + SrcPixelFormatRenderer::pix_offset; + pixel_type* pdst = + (pixel_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; + + do + { + const color_type& color = color_lut[*psrc]; + m_blender.blend_pix(pdst, + color.r, color.g, color.b, color.a, + cover); + psrc += SrcPixelFormatRenderer::pix_step; + ++pdst; + } + while(--len); + } + } + + + + private: + rbuf_type* m_rbuf; + Blender m_blender; + }; + + typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb555; //----pixfmt_rgb555 + typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb565; //----pixfmt_rgb565 + + typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb555_pre; //----pixfmt_rgb555_pre + typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb565_pre; //----pixfmt_rgb565_pre + + typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbAAA; //----pixfmt_rgbAAA + typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrAAA; //----pixfmt_bgrAAA + typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbBBA; //----pixfmt_rgbBBA + typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrABB; //----pixfmt_bgrABB + + typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbAAA_pre; //----pixfmt_rgbAAA_pre + typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrAAA_pre; //----pixfmt_bgrAAA_pre + typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbBBA_pre; //----pixfmt_rgbBBA_pre + typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrABB_pre; //----pixfmt_bgrABB_pre + + + //-----------------------------------------------------pixfmt_rgb555_gamma + template class pixfmt_rgb555_gamma : + public pixfmt_alpha_blend_rgb_packed, + rendering_buffer> + { + public: + pixfmt_rgb555_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb_packed, + rendering_buffer>(rb) + { + this->blender().gamma(g); + } + }; + + + //-----------------------------------------------------pixfmt_rgb565_gamma + template class pixfmt_rgb565_gamma : + public pixfmt_alpha_blend_rgb_packed, rendering_buffer> + { + public: + pixfmt_rgb565_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb_packed, rendering_buffer>(rb) + { + this->blender().gamma(g); + } + }; + + + //-----------------------------------------------------pixfmt_rgbAAA_gamma + template class pixfmt_rgbAAA_gamma : + public pixfmt_alpha_blend_rgb_packed, + rendering_buffer> + { + public: + pixfmt_rgbAAA_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb_packed, + rendering_buffer>(rb) + { + this->blender().gamma(g); + } + }; + + + //-----------------------------------------------------pixfmt_bgrAAA_gamma + template class pixfmt_bgrAAA_gamma : + public pixfmt_alpha_blend_rgb_packed, + rendering_buffer> + { + public: + pixfmt_bgrAAA_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb_packed, + rendering_buffer>(rb) + { + this->blender().gamma(g); + } + }; + + + //-----------------------------------------------------pixfmt_rgbBBA_gamma + template class pixfmt_rgbBBA_gamma : + public pixfmt_alpha_blend_rgb_packed, + rendering_buffer> + { + public: + pixfmt_rgbBBA_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb_packed, + rendering_buffer>(rb) + { + this->blender().gamma(g); + } + }; + + + //-----------------------------------------------------pixfmt_bgrABB_gamma + template class pixfmt_bgrABB_gamma : + public pixfmt_alpha_blend_rgb_packed, + rendering_buffer> + { + public: + pixfmt_bgrABB_gamma(rendering_buffer& rb, const Gamma& g) : + pixfmt_alpha_blend_rgb_packed, + rendering_buffer>(rb) + { + this->blender().gamma(g); + } + }; + + +} + +#endif + diff --git a/xs/src/agg/agg_pixfmt_rgba.h b/xs/src/agg/agg_pixfmt_rgba.h new file mode 100644 index 0000000000..9c4ab449ac --- /dev/null +++ b/xs/src/agg/agg_pixfmt_rgba.h @@ -0,0 +1,2803 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_PIXFMT_RGBA_INCLUDED +#define AGG_PIXFMT_RGBA_INCLUDED + +#include +#include +#include "agg_pixfmt_base.h" +#include "agg_rendering_buffer.h" + +namespace agg +{ + template inline T sd_min(T a, T b) { return (a < b) ? a : b; } + template inline T sd_max(T a, T b) { return (a > b) ? a : b; } + + inline rgba & clip(rgba & c) + { + if (c.a > 1) c.a = 1; else if (c.a < 0) c.a = 0; + if (c.r > c.a) c.r = c.a; else if (c.r < 0) c.r = 0; + if (c.g > c.a) c.g = c.a; else if (c.g < 0) c.g = 0; + if (c.b > c.a) c.b = c.a; else if (c.b < 0) c.b = 0; + return c; + } + + //=========================================================multiplier_rgba + template + struct multiplier_rgba + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + + //-------------------------------------------------------------------- + static AGG_INLINE void premultiply(value_type* p) + { + value_type a = p[Order::A]; + p[Order::R] = color_type::multiply(p[Order::R], a); + p[Order::G] = color_type::multiply(p[Order::G], a); + p[Order::B] = color_type::multiply(p[Order::B], a); + } + + + //-------------------------------------------------------------------- + static AGG_INLINE void demultiply(value_type* p) + { + value_type a = p[Order::A]; + p[Order::R] = color_type::demultiply(p[Order::R], a); + p[Order::G] = color_type::demultiply(p[Order::G], a); + p[Order::B] = color_type::demultiply(p[Order::B], a); + } + }; + + //=====================================================apply_gamma_dir_rgba + template + class apply_gamma_dir_rgba + { + public: + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + + apply_gamma_dir_rgba(const GammaLut& gamma) : m_gamma(gamma) {} + + AGG_INLINE void operator () (value_type* p) + { + p[Order::R] = m_gamma.dir(p[Order::R]); + p[Order::G] = m_gamma.dir(p[Order::G]); + p[Order::B] = m_gamma.dir(p[Order::B]); + } + + private: + const GammaLut& m_gamma; + }; + + //=====================================================apply_gamma_inv_rgba + template class apply_gamma_inv_rgba + { + public: + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + + apply_gamma_inv_rgba(const GammaLut& gamma) : m_gamma(gamma) {} + + AGG_INLINE void operator () (value_type* p) + { + p[Order::R] = m_gamma.inv(p[Order::R]); + p[Order::G] = m_gamma.inv(p[Order::G]); + p[Order::B] = m_gamma.inv(p[Order::B]); + } + + private: + const GammaLut& m_gamma; + }; + + + template + struct conv_rgba_pre + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + + //-------------------------------------------------------------------- + static AGG_INLINE void set_plain_color(value_type* p, color_type c) + { + c.premultiply(); + p[Order::R] = c.r; + p[Order::G] = c.g; + p[Order::B] = c.b; + p[Order::A] = c.a; + } + + //-------------------------------------------------------------------- + static AGG_INLINE color_type get_plain_color(const value_type* p) + { + return color_type( + p[Order::R], + p[Order::G], + p[Order::B], + p[Order::A]).demultiply(); + } + }; + + template + struct conv_rgba_plain + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + + //-------------------------------------------------------------------- + static AGG_INLINE void set_plain_color(value_type* p, color_type c) + { + p[Order::R] = c.r; + p[Order::G] = c.g; + p[Order::B] = c.b; + p[Order::A] = c.a; + } + + //-------------------------------------------------------------------- + static AGG_INLINE color_type get_plain_color(const value_type* p) + { + return color_type( + p[Order::R], + p[Order::G], + p[Order::B], + p[Order::A]); + } + }; + + //=============================================================blender_rgba + // Blends "plain" (i.e. non-premultiplied) colors into a premultiplied buffer. + template + struct blender_rgba : conv_rgba_pre + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + // Blend pixels using the non-premultiplied form of Alvy-Ray Smith's + // compositing function. Since the render buffer is in fact premultiplied + // we omit the initial premultiplication and final demultiplication. + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) + { + blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha) + { + p[Order::R] = color_type::lerp(p[Order::R], cr, alpha); + p[Order::G] = color_type::lerp(p[Order::G], cg, alpha); + p[Order::B] = color_type::lerp(p[Order::B], cb, alpha); + p[Order::A] = color_type::prelerp(p[Order::A], alpha, alpha); + } + }; + + + //========================================================blender_rgba_pre + // Blends premultiplied colors into a premultiplied buffer. + template + struct blender_rgba_pre : conv_rgba_pre + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + // Blend pixels using the premultiplied form of Alvy-Ray Smith's + // compositing function. + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) + { + blend_pix(p, + color_type::mult_cover(cr, cover), + color_type::mult_cover(cg, cover), + color_type::mult_cover(cb, cover), + color_type::mult_cover(alpha, cover)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha) + { + p[Order::R] = color_type::prelerp(p[Order::R], cr, alpha); + p[Order::G] = color_type::prelerp(p[Order::G], cg, alpha); + p[Order::B] = color_type::prelerp(p[Order::B], cb, alpha); + p[Order::A] = color_type::prelerp(p[Order::A], alpha, alpha); + } + }; + + //======================================================blender_rgba_plain + // Blends "plain" (non-premultiplied) colors into a plain (non-premultiplied) buffer. + template + struct blender_rgba_plain : conv_rgba_plain + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + // Blend pixels using the non-premultiplied form of Alvy-Ray Smith's + // compositing function. + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) + { + blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover)); + } + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + value_type cr, value_type cg, value_type cb, value_type alpha) + { + if (alpha > color_type::empty_value()) + { + calc_type a = p[Order::A]; + calc_type r = color_type::multiply(p[Order::R], a); + calc_type g = color_type::multiply(p[Order::G], a); + calc_type b = color_type::multiply(p[Order::B], a); + p[Order::R] = color_type::lerp(r, cr, alpha); + p[Order::G] = color_type::lerp(g, cg, alpha); + p[Order::B] = color_type::lerp(b, cb, alpha); + p[Order::A] = color_type::prelerp(a, alpha, alpha); + multiplier_rgba::demultiply(p); + } + } + }; + + // SVG compositing operations. + // For specifications, see http://www.w3.org/TR/SVGCompositing/ + + //=========================================================comp_op_rgba_clear + template + struct comp_op_rgba_clear : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = 0 + // Da' = 0 + static AGG_INLINE void blend_pix(value_type* p, + value_type, value_type, value_type, value_type, cover_type cover) + { + if (cover >= cover_full) + { + p[0] = p[1] = p[2] = p[3] = color_type::empty_value(); + } + else if (cover > cover_none) + { + set(p, get(p, cover_full - cover)); + } + } + }; + + //===========================================================comp_op_rgba_src + template + struct comp_op_rgba_src : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca + // Da' = Sa + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + if (cover >= cover_full) + { + set(p, r, g, b, a); + } + else + { + rgba s = get(r, g, b, a, cover); + rgba d = get(p, cover_full - cover); + d.r += s.r; + d.g += s.g; + d.b += s.b; + d.a += s.a; + set(p, d); + } + } + }; + + //===========================================================comp_op_rgba_dst + template + struct comp_op_rgba_dst : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + + // Dca' = Dca.Sa + Dca.(1 - Sa) = Dca + // Da' = Da.Sa + Da.(1 - Sa) = Da + static AGG_INLINE void blend_pix(value_type*, + value_type, value_type, value_type, value_type, cover_type) + { + // Well, that was easy! + } + }; + + //======================================================comp_op_rgba_src_over + template + struct comp_op_rgba_src_over : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca + Dca.(1 - Sa) = Dca + Sca - Dca.Sa + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { +#if 1 + blender_rgba_pre::blend_pix(p, r, g, b, a, cover); +#else + rgba s = get(r, g, b, a, cover); + rgba d = get(p); + d.r += s.r - d.r * s.a; + d.g += s.g - d.g * s.a; + d.b += s.b - d.b * s.a; + d.a += s.a - d.a * s.a; + set(p, d); +#endif + } + }; + + //======================================================comp_op_rgba_dst_over + template + struct comp_op_rgba_dst_over : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Dca + Sca.(1 - Da) + // Da' = Sa + Da - Sa.Da = Da + Sa.(1 - Da) + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + rgba d = get(p); + double d1a = 1 - d.a; + d.r += s.r * d1a; + d.g += s.g * d1a; + d.b += s.b * d1a; + d.a += s.a * d1a; + set(p, d); + } + }; + + //======================================================comp_op_rgba_src_in + template + struct comp_op_rgba_src_in : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca.Da + // Da' = Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + double da = ColorT::to_double(p[Order::A]); + if (da > 0) + { + rgba s = get(r, g, b, a, cover); + rgba d = get(p, cover_full - cover); + d.r += s.r * da; + d.g += s.g * da; + d.b += s.b * da; + d.a += s.a * da; + set(p, d); + } + } + }; + + //======================================================comp_op_rgba_dst_in + template + struct comp_op_rgba_dst_in : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Dca.Sa + // Da' = Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type, value_type, value_type, value_type a, cover_type cover) + { + double sa = ColorT::to_double(a); + rgba d = get(p, cover_full - cover); + rgba d2 = get(p, cover); + d.r += d2.r * sa; + d.g += d2.g * sa; + d.b += d2.b * sa; + d.a += d2.a * sa; + set(p, d); + } + }; + + //======================================================comp_op_rgba_src_out + template + struct comp_op_rgba_src_out : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca.(1 - Da) + // Da' = Sa.(1 - Da) + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + rgba d = get(p, cover_full - cover); + double d1a = 1 - ColorT::to_double(p[Order::A]); + d.r += s.r * d1a; + d.g += s.g * d1a; + d.b += s.b * d1a; + d.a += s.a * d1a; + set(p, d); + } + }; + + //======================================================comp_op_rgba_dst_out + template + struct comp_op_rgba_dst_out : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Dca.(1 - Sa) + // Da' = Da.(1 - Sa) + static AGG_INLINE void blend_pix(value_type* p, + value_type, value_type, value_type, value_type a, cover_type cover) + { + rgba d = get(p, cover_full - cover); + rgba dc = get(p, cover); + double s1a = 1 - ColorT::to_double(a); + d.r += dc.r * s1a; + d.g += dc.g * s1a; + d.b += dc.b * s1a; + d.a += dc.a * s1a; + set(p, d); + } + }; + + //=====================================================comp_op_rgba_src_atop + template + struct comp_op_rgba_src_atop : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca.Da + Dca.(1 - Sa) + // Da' = Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + rgba d = get(p); + double s1a = 1 - s.a; + d.r = s.r * d.a + d.r * s1a; + d.g = s.g * d.a + d.g * s1a; + d.b = s.b * d.a + d.g * s1a; + set(p, d); + } + }; + + //=====================================================comp_op_rgba_dst_atop + template + struct comp_op_rgba_dst_atop : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Dca.Sa + Sca.(1 - Da) + // Da' = Sa + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba sc = get(r, g, b, a, cover); + rgba dc = get(p, cover); + rgba d = get(p, cover_full - cover); + double sa = ColorT::to_double(a); + double d1a = 1 - ColorT::to_double(p[Order::A]); + d.r += dc.r * sa + sc.r * d1a; + d.g += dc.g * sa + sc.g * d1a; + d.b += dc.b * sa + sc.b * d1a; + d.a += sc.a; + set(p, d); + } + }; + + //=========================================================comp_op_rgba_xor + template + struct comp_op_rgba_xor : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca.(1 - Da) + Dca.(1 - Sa) + // Da' = Sa + Da - 2.Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + rgba d = get(p); + double s1a = 1 - s.a; + double d1a = 1 - ColorT::to_double(p[Order::A]); + d.r = s.r * d1a + d.r * s1a; + d.g = s.g * d1a + d.g * s1a; + d.b = s.b * d1a + d.b * s1a; + d.a = s.a + d.a - 2 * s.a * d.a; + set(p, d); + } + }; + + //=========================================================comp_op_rgba_plus + template + struct comp_op_rgba_plus : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca + Dca + // Da' = Sa + Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + d.a = sd_min(d.a + s.a, 1.0); + d.r = sd_min(d.r + s.r, d.a); + d.g = sd_min(d.g + s.g, d.a); + d.b = sd_min(d.b + s.b, d.a); + set(p, clip(d)); + } + } + }; + + //========================================================comp_op_rgba_minus + // Note: not included in SVG spec. + template + struct comp_op_rgba_minus : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Dca - Sca + // Da' = 1 - (1 - Sa).(1 - Da) = Da + Sa - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + d.a += s.a - s.a * d.a; + d.r = sd_max(d.r - s.r, 0.0); + d.g = sd_max(d.g - s.g, 0.0); + d.b = sd_max(d.b - s.b, 0.0); + set(p, clip(d)); + } + } + }; + + //=====================================================comp_op_rgba_multiply + template + struct comp_op_rgba_multiply : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + double s1a = 1 - s.a; + double d1a = 1 - d.a; + d.r = s.r * d.r + s.r * d1a + d.r * s1a; + d.g = s.g * d.g + s.g * d1a + d.g * s1a; + d.b = s.b * d.b + s.b * d1a + d.b * s1a; + d.a += s.a - s.a * d.a; + set(p, clip(d)); + } + } + }; + + //=====================================================comp_op_rgba_screen + template + struct comp_op_rgba_screen : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca + Dca - Sca.Dca + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + d.r += s.r - s.r * d.r; + d.g += s.g - s.g * d.g; + d.b += s.b - s.b * d.b; + d.a += s.a - s.a * d.a; + set(p, clip(d)); + } + } + }; + + //=====================================================comp_op_rgba_overlay + template + struct comp_op_rgba_overlay : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // if 2.Dca <= Da + // Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) + // otherwise + // Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) + // + // Da' = Sa + Da - Sa.Da + static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) + { + return (2 * dca <= da) ? + 2 * sca * dca + sca * d1a + dca * s1a : + sada - 2 * (da - dca) * (sa - sca) + sca * d1a + dca * s1a; + } + + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + double d1a = 1 - d.a; + double s1a = 1 - s.a; + double sada = s.a * d.a; + d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); + d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); + d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); + d.a += s.a - s.a * d.a; + set(p, clip(d)); + } + } + }; + + //=====================================================comp_op_rgba_darken + template + struct comp_op_rgba_darken : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = min(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + double d1a = 1 - d.a; + double s1a = 1 - s.a; + d.r = sd_min(s.r * d.a, d.r * s.a) + s.r * d1a + d.r * s1a; + d.g = sd_min(s.g * d.a, d.g * s.a) + s.g * d1a + d.g * s1a; + d.b = sd_min(s.b * d.a, d.b * s.a) + s.b * d1a + d.b * s1a; + d.a += s.a - s.a * d.a; + set(p, clip(d)); + } + } + }; + + //=====================================================comp_op_rgba_lighten + template + struct comp_op_rgba_lighten : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = max(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + double d1a = 1 - d.a; + double s1a = 1 - s.a; + d.r = sd_max(s.r * d.a, d.r * s.a) + s.r * d1a + d.r * s1a; + d.g = sd_max(s.g * d.a, d.g * s.a) + s.g * d1a + d.g * s1a; + d.b = sd_max(s.b * d.a, d.b * s.a) + s.b * d1a + d.b * s1a; + d.a += s.a - s.a * d.a; + set(p, clip(d)); + } + } + }; + + //=====================================================comp_op_rgba_color_dodge + template + struct comp_op_rgba_color_dodge : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // if Sca == Sa and Dca == 0 + // Dca' = Sca.(1 - Da) + Dca.(1 - Sa) = Sca.(1 - Da) + // otherwise if Sca == Sa + // Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa) + // otherwise if Sca < Sa + // Dca' = Sa.Da.min(1, Dca/Da.Sa/(Sa - Sca)) + Sca.(1 - Da) + Dca.(1 - Sa) + // + // Da' = Sa + Da - Sa.Da + static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) + { + if (sca < sa) return sada * sd_min(1.0, (dca / da) * sa / (sa - sca)) + sca * d1a + dca * s1a; + if (dca > 0) return sada + sca * d1a + dca * s1a; + return sca * d1a; + } + + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + if (d.a > 0) + { + double sada = s.a * d.a; + double s1a = 1 - s.a; + double d1a = 1 - d.a; + d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); + d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); + d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); + d.a += s.a - s.a * d.a; + set(p, clip(d)); + } + else set(p, s); + } + } + }; + + //=====================================================comp_op_rgba_color_burn + template + struct comp_op_rgba_color_burn : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // if Sca == 0 and Dca == Da + // Dca' = Sa.Da + Dca.(1 - Sa) + // otherwise if Sca == 0 + // Dca' = Dca.(1 - Sa) + // otherwise if Sca > 0 + // Dca' = Sa.Da.(1 - min(1, (1 - Dca/Da).Sa/Sca)) + Sca.(1 - Da) + Dca.(1 - Sa) + static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) + { + if (sca > 0) return sada * (1 - sd_min(1.0, (1 - dca / da) * sa / sca)) + sca * d1a + dca * s1a; + if (dca > da) return sada + dca * s1a; + return dca * s1a; + } + + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + if (d.a > 0) + { + double sada = s.a * d.a; + double s1a = 1 - s.a; + double d1a = 1 - d.a; + d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); + d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); + d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); + d.a += s.a - sada; + set(p, clip(d)); + } + else set(p, s); + } + } + }; + + //=====================================================comp_op_rgba_hard_light + template + struct comp_op_rgba_hard_light : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // if 2.Sca < Sa + // Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) + // otherwise + // Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) + // + // Da' = Sa + Da - Sa.Da + static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) + { + return (2 * sca < sa) ? + 2 * sca * dca + sca * d1a + dca * s1a : + sada - 2 * (da - dca) * (sa - sca) + sca * d1a + dca * s1a; + } + + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + double d1a = 1 - d.a; + double s1a = 1 - s.a; + double sada = s.a * d.a; + d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); + d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); + d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); + d.a += s.a - sada; + set(p, clip(d)); + } + } + }; + + //=====================================================comp_op_rgba_soft_light + template + struct comp_op_rgba_soft_light : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // if 2.Sca <= Sa + // Dca' = Dca.Sa - (Sa.Da - 2.Sca.Da).Dca.Sa.(Sa.Da - Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) + // otherwise if 2.Sca > Sa and 4.Dca <= Da + // Dca' = Dca.Sa + (2.Sca.Da - Sa.Da).((((16.Dsa.Sa - 12).Dsa.Sa + 4).Dsa.Da) - Dsa.Da) + Sca.(1 - Da) + Dca.(1 - Sa) + // otherwise if 2.Sca > Sa and 4.Dca > Da + // Dca' = Dca.Sa + (2.Sca.Da - Sa.Da).((Dca.Sa)^0.5 - Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) + // + // Da' = Sa + Da - Sa.Da + static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) + { + double dcasa = dca * sa; + if (2 * sca <= sa) return dcasa - (sada - 2 * sca * da) * dcasa * (sada - dcasa) + sca * d1a + dca * s1a; + if (4 * dca <= da) return dcasa + (2 * sca * da - sada) * ((((16 * dcasa - 12) * dcasa + 4) * dca * da) - dca * da) + sca * d1a + dca * s1a; + return dcasa + (2 * sca * da - sada) * (sqrt(dcasa) - dcasa) + sca * d1a + dca * s1a; + } + + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + if (d.a > 0) + { + double sada = s.a * d.a; + double s1a = 1 - s.a; + double d1a = 1 - d.a; + d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); + d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); + d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); + d.a += s.a - sada; + set(p, clip(d)); + } + else set(p, s); + } + } + }; + + //=====================================================comp_op_rgba_difference + template + struct comp_op_rgba_difference : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = Sca + Dca - 2.min(Sca.Da, Dca.Sa) + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + d.r += s.r - 2 * sd_min(s.r * d.a, d.r * s.a); + d.g += s.g - 2 * sd_min(s.g * d.a, d.g * s.a); + d.b += s.b - 2 * sd_min(s.b * d.a, d.b * s.a); + d.a += s.a - s.a * d.a; + set(p, clip(d)); + } + } + }; + + //=====================================================comp_op_rgba_exclusion + template + struct comp_op_rgba_exclusion : blender_base + { + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + using blender_base::get; + using blender_base::set; + + // Dca' = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + rgba s = get(r, g, b, a, cover); + if (s.a > 0) + { + rgba d = get(p); + double d1a = 1 - d.a; + double s1a = 1 - s.a; + d.r = (s.r * d.a + d.r * s.a - 2 * s.r * d.r) + s.r * d1a + d.r * s1a; + d.g = (s.g * d.a + d.g * s.a - 2 * s.g * d.g) + s.g * d1a + d.g * s1a; + d.b = (s.b * d.a + d.b * s.a - 2 * s.b * d.b) + s.b * d1a + d.b * s1a; + d.a += s.a - s.a * d.a; + set(p, clip(d)); + } + } + }; + +#if 0 + //=====================================================comp_op_rgba_contrast + template struct comp_op_rgba_contrast + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + base_shift = color_type::base_shift, + base_mask = color_type::base_mask + }; + + + static AGG_INLINE void blend_pix(value_type* p, + unsigned sr, unsigned sg, unsigned sb, + unsigned sa, unsigned cover) + { + if (cover < 255) + { + sr = (sr * cover + 255) >> 8; + sg = (sg * cover + 255) >> 8; + sb = (sb * cover + 255) >> 8; + sa = (sa * cover + 255) >> 8; + } + long_type dr = p[Order::R]; + long_type dg = p[Order::G]; + long_type db = p[Order::B]; + int da = p[Order::A]; + long_type d2a = da >> 1; + unsigned s2a = sa >> 1; + + int r = (int)((((dr - d2a) * int((sr - s2a)*2 + base_mask)) >> base_shift) + d2a); + int g = (int)((((dg - d2a) * int((sg - s2a)*2 + base_mask)) >> base_shift) + d2a); + int b = (int)((((db - d2a) * int((sb - s2a)*2 + base_mask)) >> base_shift) + d2a); + + r = (r < 0) ? 0 : r; + g = (g < 0) ? 0 : g; + b = (b < 0) ? 0 : b; + + p[Order::R] = (value_type)((r > da) ? da : r); + p[Order::G] = (value_type)((g > da) ? da : g); + p[Order::B] = (value_type)((b > da) ? da : b); + } + }; + + //=====================================================comp_op_rgba_invert + template struct comp_op_rgba_invert + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + base_shift = color_type::base_shift, + base_mask = color_type::base_mask + }; + + // Dca' = (Da - Dca) * Sa + Dca.(1 - Sa) + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + unsigned sr, unsigned sg, unsigned sb, + unsigned sa, unsigned cover) + { + sa = (sa * cover + 255) >> 8; + if (sa) + { + calc_type da = p[Order::A]; + calc_type dr = ((da - p[Order::R]) * sa + base_mask) >> base_shift; + calc_type dg = ((da - p[Order::G]) * sa + base_mask) >> base_shift; + calc_type db = ((da - p[Order::B]) * sa + base_mask) >> base_shift; + calc_type s1a = base_mask - sa; + p[Order::R] = (value_type)(dr + ((p[Order::R] * s1a + base_mask) >> base_shift)); + p[Order::G] = (value_type)(dg + ((p[Order::G] * s1a + base_mask) >> base_shift)); + p[Order::B] = (value_type)(db + ((p[Order::B] * s1a + base_mask) >> base_shift)); + p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); + } + } + }; + + //=================================================comp_op_rgba_invert_rgb + template struct comp_op_rgba_invert_rgb + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + base_shift = color_type::base_shift, + base_mask = color_type::base_mask + }; + + // Dca' = (Da - Dca) * Sca + Dca.(1 - Sa) + // Da' = Sa + Da - Sa.Da + static AGG_INLINE void blend_pix(value_type* p, + unsigned sr, unsigned sg, unsigned sb, + unsigned sa, unsigned cover) + { + if (cover < 255) + { + sr = (sr * cover + 255) >> 8; + sg = (sg * cover + 255) >> 8; + sb = (sb * cover + 255) >> 8; + sa = (sa * cover + 255) >> 8; + } + if (sa) + { + calc_type da = p[Order::A]; + calc_type dr = ((da - p[Order::R]) * sr + base_mask) >> base_shift; + calc_type dg = ((da - p[Order::G]) * sg + base_mask) >> base_shift; + calc_type db = ((da - p[Order::B]) * sb + base_mask) >> base_shift; + calc_type s1a = base_mask - sa; + p[Order::R] = (value_type)(dr + ((p[Order::R] * s1a + base_mask) >> base_shift)); + p[Order::G] = (value_type)(dg + ((p[Order::G] * s1a + base_mask) >> base_shift)); + p[Order::B] = (value_type)(db + ((p[Order::B] * s1a + base_mask) >> base_shift)); + p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); + } + } + }; +#endif + + + //======================================================comp_op_table_rgba + template struct comp_op_table_rgba + { + typedef typename ColorT::value_type value_type; + typedef typename ColorT::calc_type calc_type; + typedef void (*comp_op_func_type)(value_type* p, + value_type cr, + value_type cg, + value_type cb, + value_type ca, + cover_type cover); + static comp_op_func_type g_comp_op_func[]; + }; + + //==========================================================g_comp_op_func + template + typename comp_op_table_rgba::comp_op_func_type + comp_op_table_rgba::g_comp_op_func[] = + { + comp_op_rgba_clear ::blend_pix, + comp_op_rgba_src ::blend_pix, + comp_op_rgba_dst ::blend_pix, + comp_op_rgba_src_over ::blend_pix, + comp_op_rgba_dst_over ::blend_pix, + comp_op_rgba_src_in ::blend_pix, + comp_op_rgba_dst_in ::blend_pix, + comp_op_rgba_src_out ::blend_pix, + comp_op_rgba_dst_out ::blend_pix, + comp_op_rgba_src_atop ::blend_pix, + comp_op_rgba_dst_atop ::blend_pix, + comp_op_rgba_xor ::blend_pix, + comp_op_rgba_plus ::blend_pix, + //comp_op_rgba_minus ::blend_pix, + comp_op_rgba_multiply ::blend_pix, + comp_op_rgba_screen ::blend_pix, + comp_op_rgba_overlay ::blend_pix, + comp_op_rgba_darken ::blend_pix, + comp_op_rgba_lighten ::blend_pix, + comp_op_rgba_color_dodge::blend_pix, + comp_op_rgba_color_burn ::blend_pix, + comp_op_rgba_hard_light ::blend_pix, + comp_op_rgba_soft_light ::blend_pix, + comp_op_rgba_difference ::blend_pix, + comp_op_rgba_exclusion ::blend_pix, + //comp_op_rgba_contrast ::blend_pix, + //comp_op_rgba_invert ::blend_pix, + //comp_op_rgba_invert_rgb ::blend_pix, + 0 + }; + + + //==============================================================comp_op_e + enum comp_op_e + { + comp_op_clear, //----comp_op_clear + comp_op_src, //----comp_op_src + comp_op_dst, //----comp_op_dst + comp_op_src_over, //----comp_op_src_over + comp_op_dst_over, //----comp_op_dst_over + comp_op_src_in, //----comp_op_src_in + comp_op_dst_in, //----comp_op_dst_in + comp_op_src_out, //----comp_op_src_out + comp_op_dst_out, //----comp_op_dst_out + comp_op_src_atop, //----comp_op_src_atop + comp_op_dst_atop, //----comp_op_dst_atop + comp_op_xor, //----comp_op_xor + comp_op_plus, //----comp_op_plus + //comp_op_minus, //----comp_op_minus + comp_op_multiply, //----comp_op_multiply + comp_op_screen, //----comp_op_screen + comp_op_overlay, //----comp_op_overlay + comp_op_darken, //----comp_op_darken + comp_op_lighten, //----comp_op_lighten + comp_op_color_dodge, //----comp_op_color_dodge + comp_op_color_burn, //----comp_op_color_burn + comp_op_hard_light, //----comp_op_hard_light + comp_op_soft_light, //----comp_op_soft_light + comp_op_difference, //----comp_op_difference + comp_op_exclusion, //----comp_op_exclusion + //comp_op_contrast, //----comp_op_contrast + //comp_op_invert, //----comp_op_invert + //comp_op_invert_rgb, //----comp_op_invert_rgb + + end_of_comp_op_e + }; + + + + + + + + //====================================================comp_op_adaptor_rgba + template + struct comp_op_adaptor_rgba + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned op, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + comp_op_table_rgba::g_comp_op_func[op](p, + color_type::multiply(r, a), + color_type::multiply(g, a), + color_type::multiply(b, a), + a, cover); + } + }; + + //=========================================comp_op_adaptor_clip_to_dst_rgba + template + struct comp_op_adaptor_clip_to_dst_rgba + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned op, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + r = color_type::multiply(r, a); + g = color_type::multiply(g, a); + b = color_type::multiply(b, a); + value_type da = p[Order::A]; + comp_op_table_rgba::g_comp_op_func[op](p, + color_type::multiply(r, da), + color_type::multiply(g, da), + color_type::multiply(b, da), + color_type::multiply(a, da), cover); + } + }; + + //================================================comp_op_adaptor_rgba_pre + template + struct comp_op_adaptor_rgba_pre + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned op, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + comp_op_table_rgba::g_comp_op_func[op](p, r, g, b, a, cover); + } + }; + + //=====================================comp_op_adaptor_clip_to_dst_rgba_pre + template + struct comp_op_adaptor_clip_to_dst_rgba_pre + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned op, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + value_type da = p[Order::A]; + comp_op_table_rgba::g_comp_op_func[op](p, + color_type::multiply(r, da), + color_type::multiply(g, da), + color_type::multiply(b, da), + color_type::multiply(a, da), cover); + } + }; + + //====================================================comp_op_adaptor_rgba_plain + template + struct comp_op_adaptor_rgba_plain + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned op, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + multiplier_rgba::premultiply(p); + comp_op_adaptor_rgba::blend_pix(op, p, r, g, b, a, cover); + multiplier_rgba::demultiply(p); + } + }; + + //=========================================comp_op_adaptor_clip_to_dst_rgba_plain + template + struct comp_op_adaptor_clip_to_dst_rgba_plain + { + typedef ColorT color_type; + typedef Order order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned op, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + multiplier_rgba::premultiply(p); + comp_op_adaptor_clip_to_dst_rgba::blend_pix(op, p, r, g, b, a, cover); + multiplier_rgba::demultiply(p); + } + }; + + //=======================================================comp_adaptor_rgba + template + struct comp_adaptor_rgba + { + typedef typename BlenderPre::color_type color_type; + typedef typename BlenderPre::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + BlenderPre::blend_pix(p, + color_type::multiply(r, a), + color_type::multiply(g, a), + color_type::multiply(b, a), + a, cover); + } + }; + + //==========================================comp_adaptor_clip_to_dst_rgba + template + struct comp_adaptor_clip_to_dst_rgba + { + typedef typename BlenderPre::color_type color_type; + typedef typename BlenderPre::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + r = color_type::multiply(r, a); + g = color_type::multiply(g, a); + b = color_type::multiply(b, a); + value_type da = p[order_type::A]; + BlenderPre::blend_pix(p, + color_type::multiply(r, da), + color_type::multiply(g, da), + color_type::multiply(b, da), + color_type::multiply(a, da), cover); + } + }; + + //=======================================================comp_adaptor_rgba_pre + template + struct comp_adaptor_rgba_pre + { + typedef typename BlenderPre::color_type color_type; + typedef typename BlenderPre::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + BlenderPre::blend_pix(p, r, g, b, a, cover); + } + }; + + //======================================comp_adaptor_clip_to_dst_rgba_pre + template + struct comp_adaptor_clip_to_dst_rgba_pre + { + typedef typename BlenderPre::color_type color_type; + typedef typename BlenderPre::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + unsigned da = p[order_type::A]; + BlenderPre::blend_pix(p, + color_type::multiply(r, da), + color_type::multiply(g, da), + color_type::multiply(b, da), + color_type::multiply(a, da), + cover); + } + }; + + //=======================================================comp_adaptor_rgba_plain + template + struct comp_adaptor_rgba_plain + { + typedef typename BlenderPre::color_type color_type; + typedef typename BlenderPre::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned op, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + multiplier_rgba::premultiply(p); + comp_adaptor_rgba::blend_pix(op, p, r, g, b, a, cover); + multiplier_rgba::demultiply(p); + } + }; + + //==========================================comp_adaptor_clip_to_dst_rgba_plain + template + struct comp_adaptor_clip_to_dst_rgba_plain + { + typedef typename BlenderPre::color_type color_type; + typedef typename BlenderPre::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + static AGG_INLINE void blend_pix(unsigned op, value_type* p, + value_type r, value_type g, value_type b, value_type a, cover_type cover) + { + multiplier_rgba::premultiply(p); + comp_adaptor_clip_to_dst_rgba::blend_pix(op, p, r, g, b, a, cover); + multiplier_rgba::demultiply(p); + } + }; + + + //=================================================pixfmt_alpha_blend_rgba + template + class pixfmt_alpha_blend_rgba + { + public: + typedef pixfmt_rgba_tag pixfmt_category; + typedef RenBuf rbuf_type; + typedef typename rbuf_type::row_data row_data; + typedef Blender blender_type; + typedef typename blender_type::color_type color_type; + typedef typename blender_type::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + enum + { + num_components = 4, + pix_step = 4, + pix_width = sizeof(value_type) * pix_step, + }; + struct pixel_type + { + value_type c[num_components]; + + void set(value_type r, value_type g, value_type b, value_type a) + { + c[order_type::R] = r; + c[order_type::G] = g; + c[order_type::B] = b; + c[order_type::A] = a; + } + + void set(const color_type& color) + { + set(color.r, color.g, color.b, color.a); + } + + void get(value_type& r, value_type& g, value_type& b, value_type& a) const + { + r = c[order_type::R]; + g = c[order_type::G]; + b = c[order_type::B]; + a = c[order_type::A]; + } + + color_type get() const + { + return color_type( + c[order_type::R], + c[order_type::G], + c[order_type::B], + c[order_type::A]); + } + + pixel_type* next() + { + return (pixel_type*)(c + pix_step); + } + + const pixel_type* next() const + { + return (const pixel_type*)(c + pix_step); + } + + pixel_type* advance(int n) + { + return (pixel_type*)(c + n * pix_step); + } + + const pixel_type* advance(int n) const + { + return (const pixel_type*)(c + n * pix_step); + } + }; + + private: + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover) + { + m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, const color_type& c) + { + m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover) + { + if (!c.is_transparent()) + { + if (c.is_opaque() && cover == cover_mask) + { + p->set(c.r, c.g, c.b, c.a); + } + else + { + m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a, cover); + } + } + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c) + { + if (!c.is_transparent()) + { + if (c.is_opaque()) + { + p->set(c.r, c.g, c.b, c.a); + } + else + { + m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a); + } + } + } + + public: + //-------------------------------------------------------------------- + pixfmt_alpha_blend_rgba() : m_rbuf(0) {} + explicit pixfmt_alpha_blend_rgba(rbuf_type& rb) : m_rbuf(&rb) {} + void attach(rbuf_type& rb) { m_rbuf = &rb; } + + //-------------------------------------------------------------------- + template + bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) + { + rect_i r(x1, y1, x2, y2); + if (r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) + { + int stride = pixf.stride(); + m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), + (r.x2 - r.x1) + 1, + (r.y2 - r.y1) + 1, + stride); + return true; + } + return false; + } + + //-------------------------------------------------------------------- + AGG_INLINE unsigned width() const { return m_rbuf->width(); } + AGG_INLINE unsigned height() const { return m_rbuf->height(); } + AGG_INLINE int stride() const { return m_rbuf->stride(); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } + AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } + AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* pix_ptr(int x, int y) + { + return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step); + } + + AGG_INLINE const int8u* pix_ptr(int x, int y) const + { + return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step); + } + + // Return pointer to pixel value, forcing row to be allocated. + AGG_INLINE pixel_type* pix_value_ptr(int x, int y, unsigned len) + { + return (pixel_type*)(m_rbuf->row_ptr(x, y, len) + sizeof(value_type) * (x * pix_step)); + } + + // Return pointer to pixel value, or null if row not allocated. + AGG_INLINE const pixel_type* pix_value_ptr(int x, int y) const + { + int8u* p = m_rbuf->row_ptr(y); + return p ? (pixel_type*)(p + sizeof(value_type) * (x * pix_step)) : 0; + } + + // Get pixel pointer from raw buffer pointer. + AGG_INLINE static pixel_type* pix_value_ptr(void* p) + { + return (pixel_type*)p; + } + + // Get pixel pointer from raw buffer pointer. + AGG_INLINE static const pixel_type* pix_value_ptr(const void* p) + { + return (const pixel_type*)p; + } + + //-------------------------------------------------------------------- + AGG_INLINE static void write_plain_color(void* p, color_type c) + { + blender_type::set_plain_color(pix_value_ptr(p)->c, c); + } + + //-------------------------------------------------------------------- + AGG_INLINE static color_type read_plain_color(const void* p) + { + return blender_type::get_plain_color(pix_value_ptr(p)->c); + } + + //-------------------------------------------------------------------- + AGG_INLINE static void make_pix(int8u* p, const color_type& c) + { + ((pixel_type*)p)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE color_type pixel(int x, int y) const + { + if (const pixel_type* p = pix_value_ptr(x, y)) + { + return p->get(); + } + return color_type::no_color(); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_pixel(int x, int y, const color_type& c) + { + pix_value_ptr(x, y, 1)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) + { + copy_or_blend_pix(pix_value_ptr(x, y, 1), c, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_hline(int x, int y, + unsigned len, + const color_type& c) + { + pixel_type v; + v.set(c); + pixel_type* p = pix_value_ptr(x, y, len); + do + { + *p = v; + p = p->next(); + } + while (--len); + } + + + //-------------------------------------------------------------------- + AGG_INLINE void copy_vline(int x, int y, + unsigned len, + const color_type& c) + { + pixel_type v; + v.set(c); + do + { + *pix_value_ptr(x, y++, 1) = v; + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_hline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + if (!c.is_transparent()) + { + pixel_type* p = pix_value_ptr(x, y, len); + if (c.is_opaque() && cover == cover_mask) + { + pixel_type v; + v.set(c); + do + { + *p = v; + p = p->next(); + } + while (--len); + } + else + { + if (cover == cover_mask) + { + do + { + blend_pix(p, c); + p = p->next(); + } + while (--len); + } + else + { + do + { + blend_pix(p, c, cover); + p = p->next(); + } + while (--len); + } + } + } + } + + + //-------------------------------------------------------------------- + void blend_vline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + if (!c.is_transparent()) + { + if (c.is_opaque() && cover == cover_mask) + { + pixel_type v; + v.set(c); + do + { + *pix_value_ptr(x, y++, 1) = v; + } + while (--len); + } + else + { + if (cover == cover_mask) + { + do + { + blend_pix(pix_value_ptr(x, y++, 1), c, c.a); + } + while (--len); + } + else + { + do + { + blend_pix(pix_value_ptr(x, y++, 1), c, cover); + } + while (--len); + } + } + } + } + + + //-------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + if (!c.is_transparent()) + { + pixel_type* p = pix_value_ptr(x, y, len); + do + { + if (c.is_opaque() && *covers == cover_mask) + { + p->set(c); + } + else + { + blend_pix(p, c, *covers); + } + p = p->next(); + ++covers; + } + while (--len); + } + } + + + //-------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + if (!c.is_transparent()) + { + do + { + pixel_type* p = pix_value_ptr(x, y++, 1); + if (c.is_opaque() && *covers == cover_mask) + { + p->set(c); + } + else + { + blend_pix(p, c, *covers); + } + ++covers; + } + while (--len); + } + } + + //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, + unsigned len, + const color_type* colors) + { + pixel_type* p = pix_value_ptr(x, y, len); + do + { + p->set(*colors++); + p = p->next(); + } + while (--len); + } + + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, + unsigned len, + const color_type* colors) + { + do + { + pix_value_ptr(x, y++, 1)->set(*colors++); + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_color_hspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + pixel_type* p = pix_value_ptr(x, y, len); + if (covers) + { + do + { + copy_or_blend_pix(p, *colors++, *covers++); + p = p->next(); + } + while (--len); + } + else + { + if (cover == cover_mask) + { + do + { + copy_or_blend_pix(p, *colors++); + p = p->next(); + } + while (--len); + } + else + { + do + { + copy_or_blend_pix(p, *colors++, cover); + p = p->next(); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + void blend_color_vspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + if (covers) + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, *covers++); + } + while (--len); + } + else + { + if (cover == cover_mask) + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++); + } + while (--len); + } + else + { + do + { + copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, cover); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + template void for_each_pixel(Function f) + { + for (unsigned y = 0; y < height(); ++y) + { + row_data r = m_rbuf->row(y); + if (r.ptr) + { + unsigned len = r.x2 - r.x1 + 1; + pixel_type* p = pix_value_ptr(r.x1, y, len); + do + { + f(p->c); + p = p->next(); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + void premultiply() + { + for_each_pixel(multiplier_rgba::premultiply); + } + + //-------------------------------------------------------------------- + void demultiply() + { + for_each_pixel(multiplier_rgba::demultiply); + } + + //-------------------------------------------------------------------- + template void apply_gamma_dir(const GammaLut& g) + { + for_each_pixel(apply_gamma_dir_rgba(g)); + } + + //-------------------------------------------------------------------- + template void apply_gamma_inv(const GammaLut& g) + { + for_each_pixel(apply_gamma_inv_rgba(g)); + } + + //-------------------------------------------------------------------- + template void copy_from(const RenBuf2& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len) + { + if (const int8u* p = from.row_ptr(ysrc)) + { + memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, + p + xsrc * pix_width, + len * pix_width); + } + } + + //-------------------------------------------------------------------- + // Blend from another RGBA surface. + template + void blend_from(const SrcPixelFormatRenderer& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + int srcinc = 1; + int dstinc = 1; + + if (xdst > xsrc) + { + psrc = psrc->advance(len - 1); + pdst = pdst->advance(len - 1); + srcinc = -1; + dstinc = -1; + } + + if (cover == cover_mask) + { + do + { + copy_or_blend_pix(pdst, psrc->get()); + psrc = psrc->advance(srcinc); + pdst = pdst->advance(dstinc); + } + while (--len); + } + else + { + do + { + copy_or_blend_pix(pdst, psrc->get(), cover); + psrc = psrc->advance(srcinc); + pdst = pdst->advance(dstinc); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + // Combine single color with grayscale surface and blend. + template + void blend_from_color(const SrcPixelFormatRenderer& from, + const color_type& color, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + typedef typename SrcPixelFormatRenderer::color_type src_color_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + do + { + copy_or_blend_pix(pdst, color, + src_color_type::scale_cover(cover, psrc->c[0])); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + } + + //-------------------------------------------------------------------- + // Blend from color table, using grayscale surface as indexes into table. + // Obviously, this only works for integer value types. + template + void blend_from_lut(const SrcPixelFormatRenderer& from, + const color_type* color_lut, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + if (cover == cover_mask) + { + do + { + copy_or_blend_pix(pdst, color_lut[psrc->c[0]]); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + else + { + do + { + copy_or_blend_pix(pdst, color_lut[psrc->c[0]], cover); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + } + } + + private: + rbuf_type* m_rbuf; + Blender m_blender; + }; + + //================================================pixfmt_custom_blend_rgba + template class pixfmt_custom_blend_rgba + { + public: + typedef pixfmt_rgba_tag pixfmt_category; + typedef RenBuf rbuf_type; + typedef typename rbuf_type::row_data row_data; + typedef Blender blender_type; + typedef typename blender_type::color_type color_type; + typedef typename blender_type::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + enum + { + num_components = 4, + pix_step = 4, + pix_width = sizeof(value_type) * pix_step, + }; + struct pixel_type + { + value_type c[num_components]; + + void set(value_type r, value_type g, value_type b, value_type a) + { + c[order_type::R] = r; + c[order_type::G] = g; + c[order_type::B] = b; + c[order_type::A] = a; + } + + void set(const color_type& color) + { + set(color.r, color.g, color.b, color.a); + } + + void get(value_type& r, value_type& g, value_type& b, value_type& a) const + { + r = c[order_type::R]; + g = c[order_type::G]; + b = c[order_type::B]; + a = c[order_type::A]; + } + + color_type get() const + { + return color_type( + c[order_type::R], + c[order_type::G], + c[order_type::B], + c[order_type::A]); + } + + pixel_type* next() + { + return (pixel_type*)(c + pix_step); + } + + const pixel_type* next() const + { + return (const pixel_type*)(c + pix_step); + } + + pixel_type* advance(int n) + { + return (pixel_type*)(c + n * pix_step); + } + + const pixel_type* advance(int n) const + { + return (const pixel_type*)(c + n * pix_step); + } + }; + + + private: + //-------------------------------------------------------------------- + AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover = cover_full) + { + m_blender.blend_pix(m_comp_op, p->c, c.r, c.g, c.b, c.a, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover = cover_full) + { + if (!c.is_transparent()) + { + if (c.is_opaque() && cover == cover_mask) + { + p->set(c.r, c.g, c.b, c.a); + } + else + { + blend_pix(p, c, cover); + } + } + } + + public: + //-------------------------------------------------------------------- + pixfmt_custom_blend_rgba() : m_rbuf(0), m_comp_op(3) {} + explicit pixfmt_custom_blend_rgba(rbuf_type& rb, unsigned comp_op=3) : + m_rbuf(&rb), + m_comp_op(comp_op) + {} + void attach(rbuf_type& rb) { m_rbuf = &rb; } + + //-------------------------------------------------------------------- + template + bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) + { + rect_i r(x1, y1, x2, y2); + if (r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) + { + int stride = pixf.stride(); + m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), + (r.x2 - r.x1) + 1, + (r.y2 - r.y1) + 1, + stride); + return true; + } + return false; + } + + //-------------------------------------------------------------------- + void comp_op(unsigned op) { m_comp_op = op; } + unsigned comp_op() const { return m_comp_op; } + + //-------------------------------------------------------------------- + AGG_INLINE unsigned width() const { return m_rbuf->width(); } + AGG_INLINE unsigned height() const { return m_rbuf->height(); } + AGG_INLINE int stride() const { return m_rbuf->stride(); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } + AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } + AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* pix_ptr(int x, int y) + { + return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step); + } + + AGG_INLINE const int8u* pix_ptr(int x, int y) const + { + return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step); + } + + // Return pointer to pixel value, forcing row to be allocated. + AGG_INLINE pixel_type* pix_value_ptr(int x, int y, unsigned len) + { + return (pixel_type*)(m_rbuf->row_ptr(x, y, len) + sizeof(value_type) * (x * pix_step)); + } + + // Return pointer to pixel value, or null if row not allocated. + AGG_INLINE const pixel_type* pix_value_ptr(int x, int y) const + { + int8u* p = m_rbuf->row_ptr(y); + return p ? (pixel_type*)(p + sizeof(value_type) * (x * pix_step)) : 0; + } + + // Get pixel pointer from raw buffer pointer. + AGG_INLINE static pixel_type* pix_value_ptr(void* p) + { + return (pixel_type*)p; + } + + // Get pixel pointer from raw buffer pointer. + AGG_INLINE static const pixel_type* pix_value_ptr(const void* p) + { + return (const pixel_type*)p; + } + + //-------------------------------------------------------------------- + AGG_INLINE static void make_pix(int8u* p, const color_type& c) + { + ((pixel_type*)p)->set(c); + } + + //-------------------------------------------------------------------- + AGG_INLINE color_type pixel(int x, int y) const + { + if (const pixel_type* p = pix_value_ptr(x, y)) + { + return p->get(); + } + return color_type::no_color(); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_pixel(int x, int y, const color_type& c) + { + make_pix(pix_value_ptr(x, y, 1), c); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) + { + blend_pix(pix_value_ptr(x, y, 1), c, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_hline(int x, int y, + unsigned len, + const color_type& c) + { + pixel_type v; + v.set(c); + pixel_type* p = pix_value_ptr(x, y, len); + do + { + *p = v; + p = p->next(); + } + while (--len); + } + + + //-------------------------------------------------------------------- + AGG_INLINE void copy_vline(int x, int y, + unsigned len, + const color_type& c) + { + pixel_type v; + v.set(c); + do + { + *pix_value_ptr(x, y++, 1) = v; + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_hline(int x, int y, unsigned len, + const color_type& c, int8u cover) + { + + pixel_type* p = pix_value_ptr(x, y, len); + do + { + blend_pix(p, c, cover); + p = p->next(); + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_vline(int x, int y, unsigned len, + const color_type& c, int8u cover) + { + do + { + blend_pix(pix_value_ptr(x, y++, 1), c, cover); + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, unsigned len, + const color_type& c, const int8u* covers) + { + pixel_type* p = pix_value_ptr(x, y, len); + + do + { + blend_pix(p, c, *covers++); + p = p->next(); + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, unsigned len, + const color_type& c, const int8u* covers) + { + do + { + blend_pix(pix_value_ptr(x, y++, 1), c, *covers++); + } + while (--len); + } + + //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, + unsigned len, + const color_type* colors) + { + pixel_type* p = pix_value_ptr(x, y, len); + + do + { + p->set(*colors++); + p = p->next(); + } + while (--len); + } + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, + unsigned len, + const color_type* colors) + { + do + { + pix_value_ptr(x, y++, 1)->set(*colors++); + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_color_hspan(int x, int y, unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + pixel_type* p = pix_value_ptr(x, y, len); + + do + { + blend_pix(p, *colors++, covers ? *covers++ : cover); + p = p->next(); + } + while (--len); + } + + //-------------------------------------------------------------------- + void blend_color_vspan(int x, int y, unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + do + { + blend_pix(pix_value_ptr(x, y++, 1), *colors++, covers ? *covers++ : cover); + } + while (--len); + + } + + //-------------------------------------------------------------------- + template void for_each_pixel(Function f) + { + unsigned y; + for (y = 0; y < height(); ++y) + { + row_data r = m_rbuf->row(y); + if (r.ptr) + { + unsigned len = r.x2 - r.x1 + 1; + pixel_type* p = pix_value_ptr(r.x1, y, len); + do + { + f(p->c); + p = p->next(); + } + while (--len); + } + } + } + + //-------------------------------------------------------------------- + void premultiply() + { + for_each_pixel(multiplier_rgba::premultiply); + } + + //-------------------------------------------------------------------- + void demultiply() + { + for_each_pixel(multiplier_rgba::demultiply); + } + + //-------------------------------------------------------------------- + template void apply_gamma_dir(const GammaLut& g) + { + for_each_pixel(apply_gamma_dir_rgba(g)); + } + + //-------------------------------------------------------------------- + template void apply_gamma_inv(const GammaLut& g) + { + for_each_pixel(apply_gamma_inv_rgba(g)); + } + + //-------------------------------------------------------------------- + template void copy_from(const RenBuf2& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len) + { + if (const int8u* p = from.row_ptr(ysrc)) + { + memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, + p + xsrc * pix_width, + len * pix_width); + } + } + + //-------------------------------------------------------------------- + // Blend from another RGBA surface. + template + void blend_from(const SrcPixelFormatRenderer& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + int srcinc = 1; + int dstinc = 1; + + if (xdst > xsrc) + { + psrc = psrc->advance(len - 1); + pdst = pdst->advance(len - 1); + srcinc = -1; + dstinc = -1; + } + + do + { + blend_pix(pdst, psrc->get(), cover); + psrc = psrc->advance(srcinc); + pdst = pdst->advance(dstinc); + } + while (--len); + } + } + + //-------------------------------------------------------------------- + // Blend from single color, using grayscale surface as alpha channel. + template + void blend_from_color(const SrcPixelFormatRenderer& from, + const color_type& color, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + typedef typename SrcPixelFormatRenderer::color_type src_color_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + do + { + blend_pix(pdst, color, + src_color_type::scale_cover(cover, psrc->c[0])); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + } + + //-------------------------------------------------------------------- + // Blend from color table, using grayscale surface as indexes into table. + // Obviously, this only works for integer value types. + template + void blend_from_lut(const SrcPixelFormatRenderer& from, + const color_type* color_lut, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; + + if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) + { + pixel_type* pdst = pix_value_ptr(xdst, ydst, len); + + do + { + blend_pix(pdst, color_lut[psrc->c[0]], cover); + psrc = psrc->next(); + pdst = pdst->next(); + } + while (--len); + } + } + + private: + rbuf_type* m_rbuf; + Blender m_blender; + unsigned m_comp_op; + }; + + + //----------------------------------------------------------------------- + typedef blender_rgba blender_rgba32; + typedef blender_rgba blender_argb32; + typedef blender_rgba blender_abgr32; + typedef blender_rgba blender_bgra32; + + typedef blender_rgba blender_srgba32; + typedef blender_rgba blender_sargb32; + typedef blender_rgba blender_sabgr32; + typedef blender_rgba blender_sbgra32; + + typedef blender_rgba_pre blender_rgba32_pre; + typedef blender_rgba_pre blender_argb32_pre; + typedef blender_rgba_pre blender_abgr32_pre; + typedef blender_rgba_pre blender_bgra32_pre; + + typedef blender_rgba_pre blender_srgba32_pre; + typedef blender_rgba_pre blender_sargb32_pre; + typedef blender_rgba_pre blender_sabgr32_pre; + typedef blender_rgba_pre blender_sbgra32_pre; + + typedef blender_rgba_plain blender_rgba32_plain; + typedef blender_rgba_plain blender_argb32_plain; + typedef blender_rgba_plain blender_abgr32_plain; + typedef blender_rgba_plain blender_bgra32_plain; + + typedef blender_rgba_plain blender_srgba32_plain; + typedef blender_rgba_plain blender_sargb32_plain; + typedef blender_rgba_plain blender_sabgr32_plain; + typedef blender_rgba_plain blender_sbgra32_plain; + + typedef blender_rgba blender_rgba64; + typedef blender_rgba blender_argb64; + typedef blender_rgba blender_abgr64; + typedef blender_rgba blender_bgra64; + + typedef blender_rgba_pre blender_rgba64_pre; + typedef blender_rgba_pre blender_argb64_pre; + typedef blender_rgba_pre blender_abgr64_pre; + typedef blender_rgba_pre blender_bgra64_pre; + + typedef blender_rgba_plain blender_rgba64_plain; + typedef blender_rgba_plain blender_argb64_plain; + typedef blender_rgba_plain blender_abgr64_plain; + typedef blender_rgba_plain blender_bgra64_plain; + + typedef blender_rgba blender_rgba128; + typedef blender_rgba blender_argb128; + typedef blender_rgba blender_abgr128; + typedef blender_rgba blender_bgra128; + + typedef blender_rgba_pre blender_rgba128_pre; + typedef blender_rgba_pre blender_argb128_pre; + typedef blender_rgba_pre blender_abgr128_pre; + typedef blender_rgba_pre blender_bgra128_pre; + + typedef blender_rgba_plain blender_rgba128_plain; + typedef blender_rgba_plain blender_argb128_plain; + typedef blender_rgba_plain blender_abgr128_plain; + typedef blender_rgba_plain blender_bgra128_plain; + + + //----------------------------------------------------------------------- + typedef pixfmt_alpha_blend_rgba pixfmt_rgba32; + typedef pixfmt_alpha_blend_rgba pixfmt_argb32; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr32; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra32; + + typedef pixfmt_alpha_blend_rgba pixfmt_srgba32; + typedef pixfmt_alpha_blend_rgba pixfmt_sargb32; + typedef pixfmt_alpha_blend_rgba pixfmt_sabgr32; + typedef pixfmt_alpha_blend_rgba pixfmt_sbgra32; + + typedef pixfmt_alpha_blend_rgba pixfmt_rgba32_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_argb32_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr32_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra32_pre; + + typedef pixfmt_alpha_blend_rgba pixfmt_srgba32_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_sargb32_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_sabgr32_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_sbgra32_pre; + + typedef pixfmt_alpha_blend_rgba pixfmt_rgba32_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_argb32_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr32_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra32_plain; + + typedef pixfmt_alpha_blend_rgba pixfmt_srgba32_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_sargb32_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_sabgr32_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_sbgra32_plain; + + typedef pixfmt_alpha_blend_rgba pixfmt_rgba64; + typedef pixfmt_alpha_blend_rgba pixfmt_argb64; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr64; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra64; + + typedef pixfmt_alpha_blend_rgba pixfmt_rgba64_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_argb64_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr64_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra64_pre; + + typedef pixfmt_alpha_blend_rgba pixfmt_rgba64_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_argb64_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr64_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra64_plain; + + typedef pixfmt_alpha_blend_rgba pixfmt_rgba128; + typedef pixfmt_alpha_blend_rgba pixfmt_argb128; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr128; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra128; + + typedef pixfmt_alpha_blend_rgba pixfmt_rgba128_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_argb128_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr128_pre; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra128_pre; + + typedef pixfmt_alpha_blend_rgba pixfmt_rgba128_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_argb128_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_abgr128_plain; + typedef pixfmt_alpha_blend_rgba pixfmt_bgra128_plain; + +} + +#endif + diff --git a/xs/src/agg/agg_pixfmt_transposer.h b/xs/src/agg/agg_pixfmt_transposer.h new file mode 100644 index 0000000000..64738b6c75 --- /dev/null +++ b/xs/src/agg/agg_pixfmt_transposer.h @@ -0,0 +1,157 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_PIXFMT_TRANSPOSER_INCLUDED +#define AGG_PIXFMT_TRANSPOSER_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + //=======================================================pixfmt_transposer + template class pixfmt_transposer + { + public: + typedef PixFmt pixfmt_type; + typedef typename pixfmt_type::color_type color_type; + typedef typename pixfmt_type::row_data row_data; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + + //-------------------------------------------------------------------- + pixfmt_transposer() : m_pixf(0) {} + explicit pixfmt_transposer(pixfmt_type& pixf) : m_pixf(&pixf) {} + void attach(pixfmt_type& pixf) { m_pixf = &pixf; } + + //-------------------------------------------------------------------- + AGG_INLINE unsigned width() const { return m_pixf->height(); } + AGG_INLINE unsigned height() const { return m_pixf->width(); } + + //-------------------------------------------------------------------- + AGG_INLINE color_type pixel(int x, int y) const + { + return m_pixf->pixel(y, x); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_pixel(int x, int y, const color_type& c) + { + m_pixf->copy_pixel(y, x, c); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_pixel(int x, int y, + const color_type& c, + int8u cover) + { + m_pixf->blend_pixel(y, x, c, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_hline(int x, int y, + unsigned len, + const color_type& c) + { + m_pixf->copy_vline(y, x, len, c); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_vline(int x, int y, + unsigned len, + const color_type& c) + { + m_pixf->copy_hline(y, x, len, c); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_hline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + m_pixf->blend_vline(y, x, len, c, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_vline(int x, int y, + unsigned len, + const color_type& c, + int8u cover) + { + m_pixf->blend_hline(y, x, len, c, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_solid_hspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + m_pixf->blend_solid_vspan(y, x, len, c, covers); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_solid_vspan(int x, int y, + unsigned len, + const color_type& c, + const int8u* covers) + { + m_pixf->blend_solid_hspan(y, x, len, c, covers); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_color_hspan(int x, int y, + unsigned len, + const color_type* colors) + { + m_pixf->copy_color_vspan(y, x, len, colors); + } + + //-------------------------------------------------------------------- + AGG_INLINE void copy_color_vspan(int x, int y, + unsigned len, + const color_type* colors) + { + m_pixf->copy_color_hspan(y, x, len, colors); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_color_hspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + m_pixf->blend_color_vspan(y, x, len, colors, covers, cover); + } + + //-------------------------------------------------------------------- + AGG_INLINE void blend_color_vspan(int x, int y, + unsigned len, + const color_type* colors, + const int8u* covers, + int8u cover) + { + m_pixf->blend_color_hspan(y, x, len, colors, covers, cover); + } + + private: + pixfmt_type* m_pixf; + }; +} + +#endif + + diff --git a/xs/src/agg/agg_rasterizer_cells_aa.h b/xs/src/agg/agg_rasterizer_cells_aa.h new file mode 100644 index 0000000000..79050c7bad --- /dev/null +++ b/xs/src/agg/agg_rasterizer_cells_aa.h @@ -0,0 +1,741 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// +// The author gratefully acknowleges the support of David Turner, +// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType +// libray - in producing this work. See http://www.freetype.org for details. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED +#define AGG_RASTERIZER_CELLS_AA_INCLUDED + +#include +#include +#include +#include "agg_math.h" +#include "agg_array.h" + + +namespace agg +{ + + //-----------------------------------------------------rasterizer_cells_aa + // An internal class that implements the main rasterization algorithm. + // Used in the rasterizer. Should not be used direcly. + template class rasterizer_cells_aa + { + enum cell_block_scale_e + { + cell_block_shift = 12, + cell_block_size = 1 << cell_block_shift, + cell_block_mask = cell_block_size - 1, + cell_block_pool = 256, + cell_block_limit = 1024 + }; + + struct sorted_y + { + unsigned start; + unsigned num; + }; + + public: + typedef Cell cell_type; + typedef rasterizer_cells_aa self_type; + + ~rasterizer_cells_aa(); + rasterizer_cells_aa(); + + void reset(); + void style(const cell_type& style_cell); + void line(int x1, int y1, int x2, int y2); + + int min_x() const { return m_min_x; } + int min_y() const { return m_min_y; } + int max_x() const { return m_max_x; } + int max_y() const { return m_max_y; } + + void sort_cells(); + + unsigned total_cells() const + { + return m_num_cells; + } + + unsigned scanline_num_cells(unsigned y) const + { + return m_sorted_y[y - m_min_y].num; + } + + const cell_type* const* scanline_cells(unsigned y) const + { + return m_sorted_cells.data() + m_sorted_y[y - m_min_y].start; + } + + bool sorted() const { return m_sorted; } + + private: + rasterizer_cells_aa(const self_type&); + const self_type& operator = (const self_type&); + + void set_curr_cell(int x, int y); + void add_curr_cell(); + void render_hline(int ey, int x1, int y1, int x2, int y2); + void allocate_block(); + + private: + unsigned m_num_blocks; + unsigned m_max_blocks; + unsigned m_curr_block; + unsigned m_num_cells; + cell_type** m_cells; + cell_type* m_curr_cell_ptr; + pod_vector m_sorted_cells; + pod_vector m_sorted_y; + cell_type m_curr_cell; + cell_type m_style_cell; + int m_min_x; + int m_min_y; + int m_max_x; + int m_max_y; + bool m_sorted; + }; + + + + + //------------------------------------------------------------------------ + template + rasterizer_cells_aa::~rasterizer_cells_aa() + { + if(m_num_blocks) + { + cell_type** ptr = m_cells + m_num_blocks - 1; + while(m_num_blocks--) + { + pod_allocator::deallocate(*ptr, cell_block_size); + ptr--; + } + pod_allocator::deallocate(m_cells, m_max_blocks); + } + } + + //------------------------------------------------------------------------ + template + rasterizer_cells_aa::rasterizer_cells_aa() : + m_num_blocks(0), + m_max_blocks(0), + m_curr_block(0), + m_num_cells(0), + m_cells(0), + m_curr_cell_ptr(0), + m_sorted_cells(), + m_sorted_y(), + m_min_x(std::numeric_limits::max()), + m_min_y(std::numeric_limits::max()), + m_max_x(std::numeric_limits::min()), + m_max_y(std::numeric_limits::min()), + m_sorted(false) + { + m_style_cell.initial(); + m_curr_cell.initial(); + } + + //------------------------------------------------------------------------ + template + void rasterizer_cells_aa::reset() + { + m_num_cells = 0; + m_curr_block = 0; + m_curr_cell.initial(); + m_style_cell.initial(); + m_sorted = false; + m_min_x = std::numeric_limits::max(); + m_min_y = std::numeric_limits::max(); + m_max_x = std::numeric_limits::min(); + m_max_y = std::numeric_limits::min(); + } + + //------------------------------------------------------------------------ + template + AGG_INLINE void rasterizer_cells_aa::add_curr_cell() + { + if(m_curr_cell.area | m_curr_cell.cover) + { + if((m_num_cells & cell_block_mask) == 0) + { + if(m_num_blocks >= cell_block_limit) return; + allocate_block(); + } + *m_curr_cell_ptr++ = m_curr_cell; + ++m_num_cells; + } + } + + //------------------------------------------------------------------------ + template + AGG_INLINE void rasterizer_cells_aa::set_curr_cell(int x, int y) + { + if(m_curr_cell.not_equal(x, y, m_style_cell)) + { + add_curr_cell(); + m_curr_cell.style(m_style_cell); + m_curr_cell.x = x; + m_curr_cell.y = y; + m_curr_cell.cover = 0; + m_curr_cell.area = 0; + } + } + + //------------------------------------------------------------------------ + template + AGG_INLINE void rasterizer_cells_aa::render_hline(int ey, + int x1, int y1, + int x2, int y2) + { + int ex1 = x1 >> poly_subpixel_shift; + int ex2 = x2 >> poly_subpixel_shift; + int fx1 = x1 & poly_subpixel_mask; + int fx2 = x2 & poly_subpixel_mask; + + int delta, p, first; + long long dx; + int incr, lift, mod, rem; + + //trivial case. Happens often + if(y1 == y2) + { + set_curr_cell(ex2, ey); + return; + } + + //everything is located in a single cell. That is easy! + if(ex1 == ex2) + { + delta = y2 - y1; + m_curr_cell.cover += delta; + m_curr_cell.area += (fx1 + fx2) * delta; + return; + } + + //ok, we'll have to render a run of adjacent cells on the same + //hline... + p = (poly_subpixel_scale - fx1) * (y2 - y1); + first = poly_subpixel_scale; + incr = 1; + + dx = (long long)x2 - (long long)x1; + + if(dx < 0) + { + p = fx1 * (y2 - y1); + first = 0; + incr = -1; + dx = -dx; + } + + delta = (int)(p / dx); + mod = (int)(p % dx); + + if(mod < 0) + { + delta--; + mod += dx; + } + + m_curr_cell.cover += delta; + m_curr_cell.area += (fx1 + first) * delta; + + ex1 += incr; + set_curr_cell(ex1, ey); + y1 += delta; + + if(ex1 != ex2) + { + p = poly_subpixel_scale * (y2 - y1 + delta); + lift = (int)(p / dx); + rem = (int)(p % dx); + + if (rem < 0) + { + lift--; + rem += dx; + } + + mod -= dx; + + while (ex1 != ex2) + { + delta = lift; + mod += rem; + if(mod >= 0) + { + mod -= dx; + delta++; + } + + m_curr_cell.cover += delta; + m_curr_cell.area += poly_subpixel_scale * delta; + y1 += delta; + ex1 += incr; + set_curr_cell(ex1, ey); + } + } + delta = y2 - y1; + m_curr_cell.cover += delta; + m_curr_cell.area += (fx2 + poly_subpixel_scale - first) * delta; + } + + //------------------------------------------------------------------------ + template + AGG_INLINE void rasterizer_cells_aa::style(const cell_type& style_cell) + { + m_style_cell.style(style_cell); + } + + //------------------------------------------------------------------------ + template + void rasterizer_cells_aa::line(int x1, int y1, int x2, int y2) + { + enum dx_limit_e { dx_limit = 16384 << poly_subpixel_shift }; + + long long dx = (long long)x2 - (long long)x1; + + if(dx >= dx_limit || dx <= -dx_limit) + { + int cx = (int)(((long long)x1 + (long long)x2) >> 1); + int cy = (int)(((long long)y1 + (long long)y2) >> 1); + line(x1, y1, cx, cy); + line(cx, cy, x2, y2); + } + + long long dy = (long long)y2 - (long long)y1; + int ex1 = x1 >> poly_subpixel_shift; + int ex2 = x2 >> poly_subpixel_shift; + int ey1 = y1 >> poly_subpixel_shift; + int ey2 = y2 >> poly_subpixel_shift; + int fy1 = y1 & poly_subpixel_mask; + int fy2 = y2 & poly_subpixel_mask; + + int x_from, x_to; + int rem, mod, lift, delta, first, incr; + long long p; + + if(ex1 < m_min_x) m_min_x = ex1; + if(ex1 > m_max_x) m_max_x = ex1; + if(ey1 < m_min_y) m_min_y = ey1; + if(ey1 > m_max_y) m_max_y = ey1; + if(ex2 < m_min_x) m_min_x = ex2; + if(ex2 > m_max_x) m_max_x = ex2; + if(ey2 < m_min_y) m_min_y = ey2; + if(ey2 > m_max_y) m_max_y = ey2; + + set_curr_cell(ex1, ey1); + + //everything is on a single hline + if(ey1 == ey2) + { + render_hline(ey1, x1, fy1, x2, fy2); + return; + } + + //Vertical line - we have to calculate start and end cells, + //and then - the common values of the area and coverage for + //all cells of the line. We know exactly there's only one + //cell, so, we don't have to call render_hline(). + incr = 1; + if(dx == 0) + { + int ex = x1 >> poly_subpixel_shift; + int two_fx = (x1 - (ex << poly_subpixel_shift)) << 1; + int area; + + first = poly_subpixel_scale; + if(dy < 0) + { + first = 0; + incr = -1; + } + + x_from = x1; + + //render_hline(ey1, x_from, fy1, x_from, first); + delta = first - fy1; + m_curr_cell.cover += delta; + m_curr_cell.area += two_fx * delta; + + ey1 += incr; + set_curr_cell(ex, ey1); + + delta = first + first - poly_subpixel_scale; + area = two_fx * delta; + while(ey1 != ey2) + { + //render_hline(ey1, x_from, poly_subpixel_scale - first, x_from, first); + m_curr_cell.cover = delta; + m_curr_cell.area = area; + ey1 += incr; + set_curr_cell(ex, ey1); + } + //render_hline(ey1, x_from, poly_subpixel_scale - first, x_from, fy2); + delta = fy2 - poly_subpixel_scale + first; + m_curr_cell.cover += delta; + m_curr_cell.area += two_fx * delta; + return; + } + + //ok, we have to render several hlines + p = (poly_subpixel_scale - fy1) * dx; + first = poly_subpixel_scale; + + if(dy < 0) + { + p = fy1 * dx; + first = 0; + incr = -1; + dy = -dy; + } + + delta = (int)(p / dy); + mod = (int)(p % dy); + + if(mod < 0) + { + delta--; + mod += dy; + } + + x_from = x1 + delta; + render_hline(ey1, x1, fy1, x_from, first); + + ey1 += incr; + set_curr_cell(x_from >> poly_subpixel_shift, ey1); + + if(ey1 != ey2) + { + p = poly_subpixel_scale * dx; + lift = (int)(p / dy); + rem = (int)(p % dy); + + if(rem < 0) + { + lift--; + rem += dy; + } + mod -= dy; + + while(ey1 != ey2) + { + delta = lift; + mod += rem; + if (mod >= 0) + { + mod -= dy; + delta++; + } + + x_to = x_from + delta; + render_hline(ey1, x_from, poly_subpixel_scale - first, x_to, first); + x_from = x_to; + + ey1 += incr; + set_curr_cell(x_from >> poly_subpixel_shift, ey1); + } + } + render_hline(ey1, x_from, poly_subpixel_scale - first, x2, fy2); + } + + //------------------------------------------------------------------------ + template + void rasterizer_cells_aa::allocate_block() + { + if(m_curr_block >= m_num_blocks) + { + if(m_num_blocks >= m_max_blocks) + { + cell_type** new_cells = + pod_allocator::allocate(m_max_blocks + + cell_block_pool); + + if(m_cells) + { + memcpy(new_cells, m_cells, m_max_blocks * sizeof(cell_type*)); + pod_allocator::deallocate(m_cells, m_max_blocks); + } + m_cells = new_cells; + m_max_blocks += cell_block_pool; + } + + m_cells[m_num_blocks++] = + pod_allocator::allocate(cell_block_size); + + } + m_curr_cell_ptr = m_cells[m_curr_block++]; + } + + + + //------------------------------------------------------------------------ + template static AGG_INLINE void swap_cells(T* a, T* b) + { + T temp = *a; + *a = *b; + *b = temp; + } + + + //------------------------------------------------------------------------ + enum + { + qsort_threshold = 9 + }; + + + //------------------------------------------------------------------------ + template + void qsort_cells(Cell** start, unsigned num) + { + Cell** stack[80]; + Cell*** top; + Cell** limit; + Cell** base; + + limit = start + num; + base = start; + top = stack; + + for (;;) + { + int len = int(limit - base); + + Cell** i; + Cell** j; + Cell** pivot; + + if(len > qsort_threshold) + { + // we use base + len/2 as the pivot + pivot = base + len / 2; + swap_cells(base, pivot); + + i = base + 1; + j = limit - 1; + + // now ensure that *i <= *base <= *j + if((*j)->x < (*i)->x) + { + swap_cells(i, j); + } + + if((*base)->x < (*i)->x) + { + swap_cells(base, i); + } + + if((*j)->x < (*base)->x) + { + swap_cells(base, j); + } + + for(;;) + { + int x = (*base)->x; + do i++; while( (*i)->x < x ); + do j--; while( x < (*j)->x ); + + if(i > j) + { + break; + } + + swap_cells(i, j); + } + + swap_cells(base, j); + + // now, push the largest sub-array + if(j - base > limit - i) + { + top[0] = base; + top[1] = j; + base = i; + } + else + { + top[0] = i; + top[1] = limit; + limit = j; + } + top += 2; + } + else + { + // the sub-array is small, perform insertion sort + j = base; + i = j + 1; + + for(; i < limit; j = i, i++) + { + for(; j[1]->x < (*j)->x; j--) + { + swap_cells(j + 1, j); + if (j == base) + { + break; + } + } + } + + if(top > stack) + { + top -= 2; + base = top[0]; + limit = top[1]; + } + else + { + break; + } + } + } + } + + + //------------------------------------------------------------------------ + template + void rasterizer_cells_aa::sort_cells() + { + if(m_sorted) return; //Perform sort only the first time. + + add_curr_cell(); + m_curr_cell.x = std::numeric_limits::max(); + m_curr_cell.y = std::numeric_limits::max(); + m_curr_cell.cover = 0; + m_curr_cell.area = 0; + + if(m_num_cells == 0) return; + +// DBG: Check to see if min/max works well. +//for(unsigned nc = 0; nc < m_num_cells; nc++) +//{ +// cell_type* cell = m_cells[nc >> cell_block_shift] + (nc & cell_block_mask); +// if(cell->x < m_min_x || +// cell->y < m_min_y || +// cell->x > m_max_x || +// cell->y > m_max_y) +// { +// cell = cell; // Breakpoint here +// } +//} + // Allocate the array of cell pointers + m_sorted_cells.allocate(m_num_cells, 16); + + // Allocate and zero the Y array + m_sorted_y.allocate(m_max_y - m_min_y + 1, 16); + m_sorted_y.zero(); + + // Create the Y-histogram (count the numbers of cells for each Y) + cell_type** block_ptr = m_cells; + cell_type* cell_ptr; + unsigned nb = m_num_cells; + unsigned i; + while(nb) + { + cell_ptr = *block_ptr++; + i = (nb > cell_block_size) ? unsigned(cell_block_size) : nb; + nb -= i; + while(i--) + { + m_sorted_y[cell_ptr->y - m_min_y].start++; + ++cell_ptr; + } + } + + // Convert the Y-histogram into the array of starting indexes + unsigned start = 0; + for(i = 0; i < m_sorted_y.size(); i++) + { + unsigned v = m_sorted_y[i].start; + m_sorted_y[i].start = start; + start += v; + } + + // Fill the cell pointer array sorted by Y + block_ptr = m_cells; + nb = m_num_cells; + while(nb) + { + cell_ptr = *block_ptr++; + i = (nb > cell_block_size) ? unsigned(cell_block_size) : nb; + nb -= i; + while(i--) + { + sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y]; + m_sorted_cells[curr_y.start + curr_y.num] = cell_ptr; + ++curr_y.num; + ++cell_ptr; + } + } + + // Finally arrange the X-arrays + for(i = 0; i < m_sorted_y.size(); i++) + { + const sorted_y& curr_y = m_sorted_y[i]; + if(curr_y.num) + { + qsort_cells(m_sorted_cells.data() + curr_y.start, curr_y.num); + } + } + m_sorted = true; + } + + + + //------------------------------------------------------scanline_hit_test + class scanline_hit_test + { + public: + scanline_hit_test(int x) : m_x(x), m_hit(false) {} + + void reset_spans() {} + void finalize(int) {} + void add_cell(int x, int) + { + if(m_x == x) m_hit = true; + } + void add_span(int x, int len, int) + { + if(m_x >= x && m_x < x+len) m_hit = true; + } + unsigned num_spans() const { return 1; } + bool hit() const { return m_hit; } + + private: + int m_x; + bool m_hit; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_rasterizer_compound_aa.h b/xs/src/agg/agg_rasterizer_compound_aa.h new file mode 100644 index 0000000000..72d811be0f --- /dev/null +++ b/xs/src/agg/agg_rasterizer_compound_aa.h @@ -0,0 +1,665 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.3 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// +// The author gratefully acknowleges the support of David Turner, +// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType +// libray - in producing this work. See http://www.freetype.org for details. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +#ifndef AGG_RASTERIZER_COMPOUND_AA_INCLUDED +#define AGG_RASTERIZER_COMPOUND_AA_INCLUDED + +#include +#include "agg_rasterizer_cells_aa.h" +#include "agg_rasterizer_sl_clip.h" + +namespace agg +{ + + //-----------------------------------------------------------cell_style_aa + // A pixel cell. There're no constructors defined and it was done + // intentionally in order to avoid extra overhead when allocating an + // array of cells. + struct cell_style_aa + { + int x; + int y; + int cover; + int area; + int16 left, right; + + void initial() + { + x = std::numeric_limits::max(); + y = std::numeric_limits::max(); + cover = 0; + area = 0; + left = -1; + right = -1; + } + + void style(const cell_style_aa& c) + { + left = c.left; + right = c.right; + } + + int not_equal(int ex, int ey, const cell_style_aa& c) const + { + return ((unsigned)ex - (unsigned)x) | ((unsigned)ey - (unsigned)y) | + ((unsigned)left - (unsigned)c.left) | ((unsigned)right - (unsigned)c.right); + } + }; + + + //===========================================================layer_order_e + enum layer_order_e + { + layer_unsorted, //------layer_unsorted + layer_direct, //------layer_direct + layer_inverse //------layer_inverse + }; + + + //==================================================rasterizer_compound_aa + template class rasterizer_compound_aa + { + struct style_info + { + unsigned start_cell; + unsigned num_cells; + int last_x; + }; + + struct cell_info + { + int x, area, cover; + }; + + public: + typedef Clip clip_type; + typedef typename Clip::conv_type conv_type; + typedef typename Clip::coord_type coord_type; + + enum aa_scale_e + { + aa_shift = 8, + aa_scale = 1 << aa_shift, + aa_mask = aa_scale - 1, + aa_scale2 = aa_scale * 2, + aa_mask2 = aa_scale2 - 1 + }; + + //-------------------------------------------------------------------- + rasterizer_compound_aa() : + m_outline(), + m_clipper(), + m_filling_rule(fill_non_zero), + m_layer_order(layer_direct), + m_styles(), // Active Styles + m_ast(), // Active Style Table (unique values) + m_asm(), // Active Style Mask + m_cells(), + m_cover_buf(), + m_min_style(std::numeric_limits::max()), + m_max_style(std::numeric_limits::min()), + m_start_x(0), + m_start_y(0), + m_scan_y(std::numeric_limits::max()), + m_sl_start(0), + m_sl_len(0) + {} + + //-------------------------------------------------------------------- + void reset(); + void reset_clipping(); + void clip_box(double x1, double y1, double x2, double y2); + void filling_rule(filling_rule_e filling_rule); + void layer_order(layer_order_e order); + + //-------------------------------------------------------------------- + void styles(int left, int right); + void move_to(int x, int y); + void line_to(int x, int y); + void move_to_d(double x, double y); + void line_to_d(double x, double y); + void add_vertex(double x, double y, unsigned cmd); + + void edge(int x1, int y1, int x2, int y2); + void edge_d(double x1, double y1, double x2, double y2); + + //------------------------------------------------------------------- + template + void add_path(VertexSource& vs, unsigned path_id=0) + { + double x; + double y; + + unsigned cmd; + vs.rewind(path_id); + if(m_outline.sorted()) reset(); + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + add_vertex(x, y, cmd); + } + } + + + //-------------------------------------------------------------------- + int min_x() const { return m_outline.min_x(); } + int min_y() const { return m_outline.min_y(); } + int max_x() const { return m_outline.max_x(); } + int max_y() const { return m_outline.max_y(); } + int min_style() const { return m_min_style; } + int max_style() const { return m_max_style; } + + //-------------------------------------------------------------------- + void sort(); + bool rewind_scanlines(); + unsigned sweep_styles(); + int scanline_start() const { return m_sl_start; } + unsigned scanline_length() const { return m_sl_len; } + unsigned style(unsigned style_idx) const; + + cover_type* allocate_cover_buffer(unsigned len); + + //-------------------------------------------------------------------- + bool navigate_scanline(int y); + bool hit_test(int tx, int ty); + + //-------------------------------------------------------------------- + AGG_INLINE unsigned calculate_alpha(int area) const + { + int cover = area >> (poly_subpixel_shift*2 + 1 - aa_shift); + if(cover < 0) cover = -cover; + if(m_filling_rule == fill_even_odd) + { + cover &= aa_mask2; + if(cover > aa_scale) + { + cover = aa_scale2 - cover; + } + } + if(cover > aa_mask) cover = aa_mask; + return cover; + } + + //-------------------------------------------------------------------- + // Sweeps one scanline with one style index. The style ID can be + // determined by calling style(). + template bool sweep_scanline(Scanline& sl, int style_idx) + { + int scan_y = m_scan_y - 1; + if(scan_y > m_outline.max_y()) return false; + + sl.reset_spans(); + + if(style_idx < 0) + { + style_idx = 0; + } + else + { + style_idx++; + } + + const style_info& st = m_styles[m_ast[style_idx]]; + + unsigned num_cells = st.num_cells; + cell_info* cell = &m_cells[st.start_cell]; + + int cover = 0; + while(num_cells--) + { + unsigned alpha; + int x = cell->x; + int area = cell->area; + + cover += cell->cover; + + ++cell; + + if(area) + { + alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area); + sl.add_cell(x, alpha); + x++; + } + + if(num_cells && cell->x > x) + { + alpha = calculate_alpha(cover << (poly_subpixel_shift + 1)); + if(alpha) + { + sl.add_span(x, cell->x - x, alpha); + } + } + } + + if(sl.num_spans() == 0) return false; + sl.finalize(scan_y); + return true; + } + + private: + void add_style(int style_id); + + //-------------------------------------------------------------------- + // Disable copying + rasterizer_compound_aa(const rasterizer_compound_aa&); + const rasterizer_compound_aa& + operator = (const rasterizer_compound_aa&); + + private: + rasterizer_cells_aa m_outline; + clip_type m_clipper; + filling_rule_e m_filling_rule; + layer_order_e m_layer_order; + pod_vector m_styles; // Active Styles + pod_vector m_ast; // Active Style Table (unique values) + pod_vector m_asm; // Active Style Mask + pod_vector m_cells; + pod_vector m_cover_buf; + + int m_min_style; + int m_max_style; + coord_type m_start_x; + coord_type m_start_y; + int m_scan_y; + int m_sl_start; + unsigned m_sl_len; + }; + + + + + + + + + + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::reset() + { + m_outline.reset(); + m_min_style = std::numeric_limits::max(); + m_max_style = std::numeric_limits::min(); + m_scan_y = std::numeric_limits::max(); + m_sl_start = 0; + m_sl_len = 0; + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::filling_rule(filling_rule_e filling_rule) + { + m_filling_rule = filling_rule; + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::layer_order(layer_order_e order) + { + m_layer_order = order; + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::clip_box(double x1, double y1, + double x2, double y2) + { + reset(); + m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1), + conv_type::upscale(x2), conv_type::upscale(y2)); + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::reset_clipping() + { + reset(); + m_clipper.reset_clipping(); + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::styles(int left, int right) + { + cell_style_aa cell; + cell.initial(); + cell.left = (int16)left; + cell.right = (int16)right; + m_outline.style(cell); + if(left >= 0 && left < m_min_style) m_min_style = left; + if(left >= 0 && left > m_max_style) m_max_style = left; + if(right >= 0 && right < m_min_style) m_min_style = right; + if(right >= 0 && right > m_max_style) m_max_style = right; + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::move_to(int x, int y) + { + if(m_outline.sorted()) reset(); + m_clipper.move_to(m_start_x = conv_type::downscale(x), + m_start_y = conv_type::downscale(y)); + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::line_to(int x, int y) + { + m_clipper.line_to(m_outline, + conv_type::downscale(x), + conv_type::downscale(y)); + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::move_to_d(double x, double y) + { + if(m_outline.sorted()) reset(); + m_clipper.move_to(m_start_x = conv_type::upscale(x), + m_start_y = conv_type::upscale(y)); + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::line_to_d(double x, double y) + { + m_clipper.line_to(m_outline, + conv_type::upscale(x), + conv_type::upscale(y)); + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::add_vertex(double x, double y, unsigned cmd) + { + if(is_move_to(cmd)) + { + move_to_d(x, y); + } + else + if(is_vertex(cmd)) + { + line_to_d(x, y); + } + else + if(is_close(cmd)) + { + m_clipper.line_to(m_outline, m_start_x, m_start_y); + } + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::edge(int x1, int y1, int x2, int y2) + { + if(m_outline.sorted()) reset(); + m_clipper.move_to(conv_type::downscale(x1), conv_type::downscale(y1)); + m_clipper.line_to(m_outline, + conv_type::downscale(x2), + conv_type::downscale(y2)); + } + + //------------------------------------------------------------------------ + template + void rasterizer_compound_aa::edge_d(double x1, double y1, + double x2, double y2) + { + if(m_outline.sorted()) reset(); + m_clipper.move_to(conv_type::upscale(x1), conv_type::upscale(y1)); + m_clipper.line_to(m_outline, + conv_type::upscale(x2), + conv_type::upscale(y2)); + } + + //------------------------------------------------------------------------ + template + AGG_INLINE void rasterizer_compound_aa::sort() + { + m_outline.sort_cells(); + } + + //------------------------------------------------------------------------ + template + AGG_INLINE bool rasterizer_compound_aa::rewind_scanlines() + { + m_outline.sort_cells(); + if(m_outline.total_cells() == 0) + { + return false; + } + if(m_max_style < m_min_style) + { + return false; + } + m_scan_y = m_outline.min_y(); + m_styles.allocate(m_max_style - m_min_style + 2, 128); + return true; + } + + //------------------------------------------------------------------------ + template + AGG_INLINE void rasterizer_compound_aa::add_style(int style_id) + { + if(style_id < 0) style_id = 0; + else style_id -= m_min_style - 1; + + unsigned nbyte = style_id >> 3; + unsigned mask = 1 << (style_id & 7); + + style_info* style = &m_styles[style_id]; + if((m_asm[nbyte] & mask) == 0) + { + m_ast.add(style_id); + m_asm[nbyte] |= mask; + style->start_cell = 0; + style->num_cells = 0; + style->last_x = std::numeric_limits::min(); + } + ++style->start_cell; + } + + //------------------------------------------------------------------------ + // Returns the number of styles + template + unsigned rasterizer_compound_aa::sweep_styles() + { + for(;;) + { + if(m_scan_y > m_outline.max_y()) return 0; + unsigned num_cells = m_outline.scanline_num_cells(m_scan_y); + const cell_style_aa* const* cells = m_outline.scanline_cells(m_scan_y); + unsigned num_styles = m_max_style - m_min_style + 2; + const cell_style_aa* curr_cell; + unsigned style_id; + style_info* style; + cell_info* cell; + + m_cells.allocate(num_cells * 2, 256); // Each cell can have two styles + m_ast.capacity(num_styles, 64); + m_asm.allocate((num_styles + 7) >> 3, 8); + m_asm.zero(); + + if(num_cells) + { + // Pre-add zero (for no-fill style, that is, -1). + // We need that to ensure that the "-1 style" would go first. + m_asm[0] |= 1; + m_ast.add(0); + style = &m_styles[0]; + style->start_cell = 0; + style->num_cells = 0; + style->last_x = std::numeric_limits::min(); + + m_sl_start = cells[0]->x; + m_sl_len = cells[num_cells-1]->x - m_sl_start + 1; + while(num_cells--) + { + curr_cell = *cells++; + add_style(curr_cell->left); + add_style(curr_cell->right); + } + + // Convert the Y-histogram into the array of starting indexes + unsigned i; + unsigned start_cell = 0; + for(i = 0; i < m_ast.size(); i++) + { + style_info& st = m_styles[m_ast[i]]; + unsigned v = st.start_cell; + st.start_cell = start_cell; + start_cell += v; + } + + cells = m_outline.scanline_cells(m_scan_y); + num_cells = m_outline.scanline_num_cells(m_scan_y); + + while(num_cells--) + { + curr_cell = *cells++; + style_id = (curr_cell->left < 0) ? 0 : + curr_cell->left - m_min_style + 1; + + style = &m_styles[style_id]; + if(curr_cell->x == style->last_x) + { + cell = &m_cells[style->start_cell + style->num_cells - 1]; + cell->area += curr_cell->area; + cell->cover += curr_cell->cover; + } + else + { + cell = &m_cells[style->start_cell + style->num_cells]; + cell->x = curr_cell->x; + cell->area = curr_cell->area; + cell->cover = curr_cell->cover; + style->last_x = curr_cell->x; + style->num_cells++; + } + + style_id = (curr_cell->right < 0) ? 0 : + curr_cell->right - m_min_style + 1; + + style = &m_styles[style_id]; + if(curr_cell->x == style->last_x) + { + cell = &m_cells[style->start_cell + style->num_cells - 1]; + cell->area -= curr_cell->area; + cell->cover -= curr_cell->cover; + } + else + { + cell = &m_cells[style->start_cell + style->num_cells]; + cell->x = curr_cell->x; + cell->area = -curr_cell->area; + cell->cover = -curr_cell->cover; + style->last_x = curr_cell->x; + style->num_cells++; + } + } + } + if(m_ast.size() > 1) break; + ++m_scan_y; + } + ++m_scan_y; + + if(m_layer_order != layer_unsorted) + { + range_adaptor > ra(m_ast, 1, m_ast.size() - 1); + if(m_layer_order == layer_direct) quick_sort(ra, unsigned_greater); + else quick_sort(ra, unsigned_less); + } + + return m_ast.size() - 1; + } + + //------------------------------------------------------------------------ + // Returns style ID depending of the existing style index + template + AGG_INLINE + unsigned rasterizer_compound_aa::style(unsigned style_idx) const + { + return m_ast[style_idx + 1] + m_min_style - 1; + } + + //------------------------------------------------------------------------ + template + AGG_INLINE bool rasterizer_compound_aa::navigate_scanline(int y) + { + m_outline.sort_cells(); + if(m_outline.total_cells() == 0) + { + return false; + } + if(m_max_style < m_min_style) + { + return false; + } + if(y < m_outline.min_y() || y > m_outline.max_y()) + { + return false; + } + m_scan_y = y; + m_styles.allocate(m_max_style - m_min_style + 2, 128); + return true; + } + + //------------------------------------------------------------------------ + template + bool rasterizer_compound_aa::hit_test(int tx, int ty) + { + if(!navigate_scanline(ty)) + { + return false; + } + + unsigned num_styles = sweep_styles(); + if(num_styles <= 0) + { + return false; + } + + scanline_hit_test sl(tx); + sweep_scanline(sl, -1); + return sl.hit(); + } + + //------------------------------------------------------------------------ + template + cover_type* rasterizer_compound_aa::allocate_cover_buffer(unsigned len) + { + m_cover_buf.allocate(len, 256); + return &m_cover_buf[0]; + } + +} + + + +#endif + diff --git a/xs/src/agg/agg_rasterizer_outline.h b/xs/src/agg/agg_rasterizer_outline.h new file mode 100644 index 0000000000..65203e34c5 --- /dev/null +++ b/xs/src/agg/agg_rasterizer_outline.h @@ -0,0 +1,147 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_RASTERIZER_OUTLINE_INCLUDED +#define AGG_RASTERIZER_OUTLINE_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + //======================================================rasterizer_outline + template class rasterizer_outline + { + public: + explicit rasterizer_outline(Renderer& ren) : + m_ren(&ren), + m_start_x(0), + m_start_y(0), + m_vertices(0) + {} + void attach(Renderer& ren) { m_ren = &ren; } + + + //-------------------------------------------------------------------- + void move_to(int x, int y) + { + m_vertices = 1; + m_ren->move_to(m_start_x = x, m_start_y = y); + } + + //-------------------------------------------------------------------- + void line_to(int x, int y) + { + ++m_vertices; + m_ren->line_to(x, y); + } + + //-------------------------------------------------------------------- + void move_to_d(double x, double y) + { + move_to(m_ren->coord(x), m_ren->coord(y)); + } + + //-------------------------------------------------------------------- + void line_to_d(double x, double y) + { + line_to(m_ren->coord(x), m_ren->coord(y)); + } + + //-------------------------------------------------------------------- + void close() + { + if(m_vertices > 2) + { + line_to(m_start_x, m_start_y); + } + m_vertices = 0; + } + + //-------------------------------------------------------------------- + void add_vertex(double x, double y, unsigned cmd) + { + if(is_move_to(cmd)) + { + move_to_d(x, y); + } + else + { + if(is_end_poly(cmd)) + { + if(is_closed(cmd)) close(); + } + else + { + line_to_d(x, y); + } + } + } + + + //-------------------------------------------------------------------- + template + void add_path(VertexSource& vs, unsigned path_id=0) + { + double x; + double y; + + unsigned cmd; + vs.rewind(path_id); + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + add_vertex(x, y, cmd); + } + } + + + //-------------------------------------------------------------------- + template + void render_all_paths(VertexSource& vs, + const ColorStorage& colors, + const PathId& path_id, + unsigned num_paths) + { + for(unsigned i = 0; i < num_paths; i++) + { + m_ren->line_color(colors[i]); + add_path(vs, path_id[i]); + } + } + + + //-------------------------------------------------------------------- + template void render_ctrl(Ctrl& c) + { + unsigned i; + for(i = 0; i < c.num_paths(); i++) + { + m_ren->line_color(c.color(i)); + add_path(c, i); + } + } + + + private: + Renderer* m_ren; + int m_start_x; + int m_start_y; + unsigned m_vertices; + }; + + +} + + +#endif + diff --git a/xs/src/agg/agg_rasterizer_outline_aa.h b/xs/src/agg/agg_rasterizer_outline_aa.h new file mode 100644 index 0000000000..a06bd1e843 --- /dev/null +++ b/xs/src/agg/agg_rasterizer_outline_aa.h @@ -0,0 +1,599 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_RASTERIZER_OUTLINE_AA_INCLUDED +#define AGG_RASTERIZER_OUTLINE_AA_INCLUDED + +#include "agg_basics.h" +#include "agg_line_aa_basics.h" +#include "agg_vertex_sequence.h" + +namespace agg +{ + + //------------------------------------------------------------------------- + inline bool cmp_dist_start(int d) { return d > 0; } + inline bool cmp_dist_end(int d) { return d <= 0; } + + + + //-----------------------------------------------------------line_aa_vertex + // Vertex (x, y) with the distance to the next one. The last vertex has + // the distance between the last and the first points + struct line_aa_vertex + { + int x; + int y; + int len; + + line_aa_vertex() {} + line_aa_vertex(int x_, int y_) : + x(x_), + y(y_), + len(0) + { + } + + bool operator () (const line_aa_vertex& val) + { + double dx = val.x - x; + double dy = val.y - y; + return (len = uround(sqrt(dx * dx + dy * dy))) > + (line_subpixel_scale + line_subpixel_scale / 2); + } + }; + + + //----------------------------------------------------------outline_aa_join_e + enum outline_aa_join_e + { + outline_no_join, //-----outline_no_join + outline_miter_join, //-----outline_miter_join + outline_round_join, //-----outline_round_join + outline_miter_accurate_join //-----outline_accurate_join + }; + + //=======================================================rasterizer_outline_aa + template class rasterizer_outline_aa + { + private: + //------------------------------------------------------------------------ + struct draw_vars + { + unsigned idx; + int x1, y1, x2, y2; + line_parameters curr, next; + int lcurr, lnext; + int xb1, yb1, xb2, yb2; + unsigned flags; + }; + + void draw(draw_vars& dv, unsigned start, unsigned end); + + public: + typedef line_aa_vertex vertex_type; + typedef vertex_sequence vertex_storage_type; + + explicit rasterizer_outline_aa(Renderer& ren) : + m_ren(&ren), + m_line_join(ren.accurate_join_only() ? + outline_miter_accurate_join : + outline_round_join), + m_round_cap(false), + m_start_x(0), + m_start_y(0) + {} + void attach(Renderer& ren) { m_ren = &ren; } + + //------------------------------------------------------------------------ + void line_join(outline_aa_join_e join) + { + m_line_join = m_ren->accurate_join_only() ? + outline_miter_accurate_join : + join; + } + bool line_join() const { return m_line_join; } + + //------------------------------------------------------------------------ + void round_cap(bool v) { m_round_cap = v; } + bool round_cap() const { return m_round_cap; } + + //------------------------------------------------------------------------ + void move_to(int x, int y) + { + m_src_vertices.modify_last(vertex_type(m_start_x = x, m_start_y = y)); + } + + //------------------------------------------------------------------------ + void line_to(int x, int y) + { + m_src_vertices.add(vertex_type(x, y)); + } + + //------------------------------------------------------------------------ + void move_to_d(double x, double y) + { + move_to(Coord::conv(x), Coord::conv(y)); + } + + //------------------------------------------------------------------------ + void line_to_d(double x, double y) + { + line_to(Coord::conv(x), Coord::conv(y)); + } + + //------------------------------------------------------------------------ + void render(bool close_polygon); + + //------------------------------------------------------------------------ + void add_vertex(double x, double y, unsigned cmd) + { + if(is_move_to(cmd)) + { + render(false); + move_to_d(x, y); + } + else + { + if(is_end_poly(cmd)) + { + render(is_closed(cmd)); + if(is_closed(cmd)) + { + move_to(m_start_x, m_start_y); + } + } + else + { + line_to_d(x, y); + } + } + } + + //------------------------------------------------------------------------ + template + void add_path(VertexSource& vs, unsigned path_id=0) + { + double x; + double y; + + unsigned cmd; + vs.rewind(path_id); + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + add_vertex(x, y, cmd); + } + render(false); + } + + + //------------------------------------------------------------------------ + template + void render_all_paths(VertexSource& vs, + const ColorStorage& colors, + const PathId& path_id, + unsigned num_paths) + { + for(unsigned i = 0; i < num_paths; i++) + { + m_ren->color(colors[i]); + add_path(vs, path_id[i]); + } + } + + + //------------------------------------------------------------------------ + template void render_ctrl(Ctrl& c) + { + unsigned i; + for(i = 0; i < c.num_paths(); i++) + { + m_ren->color(c.color(i)); + add_path(c, i); + } + } + + private: + rasterizer_outline_aa(const rasterizer_outline_aa&); + const rasterizer_outline_aa& operator = + (const rasterizer_outline_aa&); + + Renderer* m_ren; + vertex_storage_type m_src_vertices; + outline_aa_join_e m_line_join; + bool m_round_cap; + int m_start_x; + int m_start_y; + }; + + + + + + + + + //---------------------------------------------------------------------------- + template + void rasterizer_outline_aa::draw(draw_vars& dv, + unsigned start, + unsigned end) + { + unsigned i; + const vertex_storage_type::value_type* v; + + for(i = start; i < end; i++) + { + if(m_line_join == outline_round_join) + { + dv.xb1 = dv.curr.x1 + (dv.curr.y2 - dv.curr.y1); + dv.yb1 = dv.curr.y1 - (dv.curr.x2 - dv.curr.x1); + dv.xb2 = dv.curr.x2 + (dv.curr.y2 - dv.curr.y1); + dv.yb2 = dv.curr.y2 - (dv.curr.x2 - dv.curr.x1); + } + + switch(dv.flags) + { + case 0: m_ren->line3(dv.curr, dv.xb1, dv.yb1, dv.xb2, dv.yb2); break; + case 1: m_ren->line2(dv.curr, dv.xb2, dv.yb2); break; + case 2: m_ren->line1(dv.curr, dv.xb1, dv.yb1); break; + case 3: m_ren->line0(dv.curr); break; + } + + if(m_line_join == outline_round_join && (dv.flags & 2) == 0) + { + m_ren->pie(dv.curr.x2, dv.curr.y2, + dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), + dv.curr.y2 - (dv.curr.x2 - dv.curr.x1), + dv.curr.x2 + (dv.next.y2 - dv.next.y1), + dv.curr.y2 - (dv.next.x2 - dv.next.x1)); + } + + dv.x1 = dv.x2; + dv.y1 = dv.y2; + dv.lcurr = dv.lnext; + dv.lnext = m_src_vertices[dv.idx].len; + + ++dv.idx; + if(dv.idx >= m_src_vertices.size()) dv.idx = 0; + + v = &m_src_vertices[dv.idx]; + dv.x2 = v->x; + dv.y2 = v->y; + + dv.curr = dv.next; + dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); + dv.xb1 = dv.xb2; + dv.yb1 = dv.yb2; + + switch(m_line_join) + { + case outline_no_join: + dv.flags = 3; + break; + + case outline_miter_join: + dv.flags >>= 1; + dv.flags |= ((dv.curr.diagonal_quadrant() == + dv.next.diagonal_quadrant()) << 1); + if((dv.flags & 2) == 0) + { + bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); + } + break; + + case outline_round_join: + dv.flags >>= 1; + dv.flags |= ((dv.curr.diagonal_quadrant() == + dv.next.diagonal_quadrant()) << 1); + break; + + case outline_miter_accurate_join: + dv.flags = 0; + bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); + break; + } + } + } + + + + + //---------------------------------------------------------------------------- + template + void rasterizer_outline_aa::render(bool close_polygon) + { + m_src_vertices.close(close_polygon); + draw_vars dv; + const vertex_storage_type::value_type* v; + int x1; + int y1; + int x2; + int y2; + int lprev; + + if(close_polygon) + { + if(m_src_vertices.size() >= 3) + { + dv.idx = 2; + + v = &m_src_vertices[m_src_vertices.size() - 1]; + x1 = v->x; + y1 = v->y; + lprev = v->len; + + v = &m_src_vertices[0]; + x2 = v->x; + y2 = v->y; + dv.lcurr = v->len; + line_parameters prev(x1, y1, x2, y2, lprev); + + v = &m_src_vertices[1]; + dv.x1 = v->x; + dv.y1 = v->y; + dv.lnext = v->len; + dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr); + + v = &m_src_vertices[dv.idx]; + dv.x2 = v->x; + dv.y2 = v->y; + dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); + + dv.xb1 = 0; + dv.yb1 = 0; + dv.xb2 = 0; + dv.yb2 = 0; + + switch(m_line_join) + { + case outline_no_join: + dv.flags = 3; + break; + + case outline_miter_join: + case outline_round_join: + dv.flags = + (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) | + ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1); + break; + + case outline_miter_accurate_join: + dv.flags = 0; + break; + } + + if((dv.flags & 1) == 0 && m_line_join != outline_round_join) + { + bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1); + } + + if((dv.flags & 2) == 0 && m_line_join != outline_round_join) + { + bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); + } + draw(dv, 0, m_src_vertices.size()); + } + } + else + { + switch(m_src_vertices.size()) + { + case 0: + case 1: + break; + + case 2: + { + v = &m_src_vertices[0]; + x1 = v->x; + y1 = v->y; + lprev = v->len; + v = &m_src_vertices[1]; + x2 = v->x; + y2 = v->y; + line_parameters lp(x1, y1, x2, y2, lprev); + if(m_round_cap) + { + m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); + } + m_ren->line3(lp, + x1 + (y2 - y1), + y1 - (x2 - x1), + x2 + (y2 - y1), + y2 - (x2 - x1)); + if(m_round_cap) + { + m_ren->semidot(cmp_dist_end, x2, y2, x2 + (y2 - y1), y2 - (x2 - x1)); + } + } + break; + + case 3: + { + int x3, y3; + int lnext; + v = &m_src_vertices[0]; + x1 = v->x; + y1 = v->y; + lprev = v->len; + v = &m_src_vertices[1]; + x2 = v->x; + y2 = v->y; + lnext = v->len; + v = &m_src_vertices[2]; + x3 = v->x; + y3 = v->y; + line_parameters lp1(x1, y1, x2, y2, lprev); + line_parameters lp2(x2, y2, x3, y3, lnext); + + if(m_round_cap) + { + m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); + } + + if(m_line_join == outline_round_join) + { + m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), + x2 + (y2 - y1), y2 - (x2 - x1)); + + m_ren->pie(x2, y2, x2 + (y2 - y1), y2 - (x2 - x1), + x2 + (y3 - y2), y2 - (x3 - x2)); + + m_ren->line3(lp2, x2 + (y3 - y2), y2 - (x3 - x2), + x3 + (y3 - y2), y3 - (x3 - x2)); + } + else + { + bisectrix(lp1, lp2, &dv.xb1, &dv.yb1); + m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), + dv.xb1, dv.yb1); + + m_ren->line3(lp2, dv.xb1, dv.yb1, + x3 + (y3 - y2), y3 - (x3 - x2)); + } + if(m_round_cap) + { + m_ren->semidot(cmp_dist_end, x3, y3, x3 + (y3 - y2), y3 - (x3 - x2)); + } + } + break; + + default: + { + dv.idx = 3; + + v = &m_src_vertices[0]; + x1 = v->x; + y1 = v->y; + lprev = v->len; + + v = &m_src_vertices[1]; + x2 = v->x; + y2 = v->y; + dv.lcurr = v->len; + line_parameters prev(x1, y1, x2, y2, lprev); + + v = &m_src_vertices[2]; + dv.x1 = v->x; + dv.y1 = v->y; + dv.lnext = v->len; + dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr); + + v = &m_src_vertices[dv.idx]; + dv.x2 = v->x; + dv.y2 = v->y; + dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); + + dv.xb1 = 0; + dv.yb1 = 0; + dv.xb2 = 0; + dv.yb2 = 0; + + switch(m_line_join) + { + case outline_no_join: + dv.flags = 3; + break; + + case outline_miter_join: + case outline_round_join: + dv.flags = + (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) | + ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1); + break; + + case outline_miter_accurate_join: + dv.flags = 0; + break; + } + + if(m_round_cap) + { + m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); + } + if((dv.flags & 1) == 0) + { + if(m_line_join == outline_round_join) + { + m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), + x2 + (y2 - y1), y2 - (x2 - x1)); + m_ren->pie(prev.x2, prev.y2, + x2 + (y2 - y1), y2 - (x2 - x1), + dv.curr.x1 + (dv.curr.y2 - dv.curr.y1), + dv.curr.y1 - (dv.curr.x2 - dv.curr.x1)); + } + else + { + bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1); + m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), + dv.xb1, dv.yb1); + } + } + else + { + m_ren->line1(prev, + x1 + (y2 - y1), + y1 - (x2 - x1)); + } + if((dv.flags & 2) == 0 && m_line_join != outline_round_join) + { + bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); + } + + draw(dv, 1, m_src_vertices.size() - 2); + + if((dv.flags & 1) == 0) + { + if(m_line_join == outline_round_join) + { + m_ren->line3(dv.curr, + dv.curr.x1 + (dv.curr.y2 - dv.curr.y1), + dv.curr.y1 - (dv.curr.x2 - dv.curr.x1), + dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), + dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); + } + else + { + m_ren->line3(dv.curr, dv.xb1, dv.yb1, + dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), + dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); + } + } + else + { + m_ren->line2(dv.curr, + dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), + dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); + } + if(m_round_cap) + { + m_ren->semidot(cmp_dist_end, dv.curr.x2, dv.curr.y2, + dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), + dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); + } + + } + break; + } + } + m_src_vertices.remove_all(); + } + + +} + + +#endif + diff --git a/xs/src/agg/agg_rasterizer_scanline_aa.h b/xs/src/agg/agg_rasterizer_scanline_aa.h new file mode 100644 index 0000000000..ffc2ddf941 --- /dev/null +++ b/xs/src/agg/agg_rasterizer_scanline_aa.h @@ -0,0 +1,481 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// +// The author gratefully acknowleges the support of David Turner, +// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType +// libray - in producing this work. See http://www.freetype.org for details. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +#ifndef AGG_RASTERIZER_SCANLINE_AA_INCLUDED +#define AGG_RASTERIZER_SCANLINE_AA_INCLUDED + +#include "agg_rasterizer_cells_aa.h" +#include "agg_rasterizer_sl_clip.h" +#include "agg_rasterizer_scanline_aa_nogamma.h" +#include "agg_gamma_functions.h" + + +namespace agg +{ + //==================================================rasterizer_scanline_aa + // Polygon rasterizer that is used to render filled polygons with + // high-quality Anti-Aliasing. Internally, by default, the class uses + // integer coordinates in format 24.8, i.e. 24 bits for integer part + // and 8 bits for fractional - see poly_subpixel_shift. This class can be + // used in the following way: + // + // 1. filling_rule(filling_rule_e ft) - optional. + // + // 2. gamma() - optional. + // + // 3. reset() + // + // 4. move_to(x, y) / line_to(x, y) - make the polygon. One can create + // more than one contour, but each contour must consist of at least 3 + // vertices, i.e. move_to(x1, y1); line_to(x2, y2); line_to(x3, y3); + // is the absolute minimum of vertices that define a triangle. + // The algorithm does not check either the number of vertices nor + // coincidence of their coordinates, but in the worst case it just + // won't draw anything. + // The orger of the vertices (clockwise or counterclockwise) + // is important when using the non-zero filling rule (fill_non_zero). + // In this case the vertex order of all the contours must be the same + // if you want your intersecting polygons to be without "holes". + // You actually can use different vertices order. If the contours do not + // intersect each other the order is not important anyway. If they do, + // contours with the same vertex order will be rendered without "holes" + // while the intersecting contours with different orders will have "holes". + // + // filling_rule() and gamma() can be called anytime before "sweeping". + //------------------------------------------------------------------------ + template class rasterizer_scanline_aa + { + enum status + { + status_initial, + status_move_to, + status_line_to, + status_closed + }; + + public: + typedef Clip clip_type; + typedef typename Clip::conv_type conv_type; + typedef typename Clip::coord_type coord_type; + + enum aa_scale_e + { + aa_shift = 8, + aa_scale = 1 << aa_shift, + aa_mask = aa_scale - 1, + aa_scale2 = aa_scale * 2, + aa_mask2 = aa_scale2 - 1 + }; + + //-------------------------------------------------------------------- + rasterizer_scanline_aa() : + m_outline(), + m_clipper(), + m_filling_rule(fill_non_zero), + m_auto_close(true), + m_start_x(0), + m_start_y(0), + m_status(status_initial) + { + int i; + for(i = 0; i < aa_scale; i++) m_gamma[i] = i; + } + + //-------------------------------------------------------------------- + template + rasterizer_scanline_aa(const GammaF& gamma_function) : + m_outline(), + m_clipper(m_outline), + m_filling_rule(fill_non_zero), + m_auto_close(true), + m_start_x(0), + m_start_y(0), + m_status(status_initial) + { + gamma(gamma_function); + } + + //-------------------------------------------------------------------- + void reset(); + void reset_clipping(); + void clip_box(double x1, double y1, double x2, double y2); + void filling_rule(filling_rule_e filling_rule); + void auto_close(bool flag) { m_auto_close = flag; } + + //-------------------------------------------------------------------- + template void gamma(const GammaF& gamma_function) + { + int i; + for(i = 0; i < aa_scale; i++) + { + m_gamma[i] = uround(gamma_function(double(i) / aa_mask) * aa_mask); + } + } + + //-------------------------------------------------------------------- + unsigned apply_gamma(unsigned cover) const + { + return m_gamma[cover]; + } + + //-------------------------------------------------------------------- + void move_to(int x, int y); + void line_to(int x, int y); + void move_to_d(double x, double y); + void line_to_d(double x, double y); + void close_polygon(); + void add_vertex(double x, double y, unsigned cmd); + + void edge(int x1, int y1, int x2, int y2); + void edge_d(double x1, double y1, double x2, double y2); + + //------------------------------------------------------------------- + template + void add_path(VertexSource& vs, unsigned path_id=0) + { + double x; + double y; + + unsigned cmd; + vs.rewind(path_id); + if(m_outline.sorted()) reset(); + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + add_vertex(x, y, cmd); + } + } + + //-------------------------------------------------------------------- + int min_x() const { return m_outline.min_x(); } + int min_y() const { return m_outline.min_y(); } + int max_x() const { return m_outline.max_x(); } + int max_y() const { return m_outline.max_y(); } + + //-------------------------------------------------------------------- + void sort(); + bool rewind_scanlines(); + bool navigate_scanline(int y); + + //-------------------------------------------------------------------- + AGG_INLINE unsigned calculate_alpha(int area) const + { + int cover = area >> (poly_subpixel_shift*2 + 1 - aa_shift); + + if(cover < 0) cover = -cover; + if(m_filling_rule == fill_even_odd) + { + cover &= aa_mask2; + if(cover > aa_scale) + { + cover = aa_scale2 - cover; + } + } + if(cover > aa_mask) cover = aa_mask; + return m_gamma[cover]; + } + + //-------------------------------------------------------------------- + template bool sweep_scanline(Scanline& sl) + { + for(;;) + { + if(m_scan_y > m_outline.max_y()) return false; + sl.reset_spans(); + unsigned num_cells = m_outline.scanline_num_cells(m_scan_y); + const cell_aa* const* cells = m_outline.scanline_cells(m_scan_y); + int cover = 0; + + while(num_cells) + { + const cell_aa* cur_cell = *cells; + int x = cur_cell->x; + int area = cur_cell->area; + unsigned alpha; + + cover += cur_cell->cover; + + //accumulate all cells with the same X + while(--num_cells) + { + cur_cell = *++cells; + if(cur_cell->x != x) break; + area += cur_cell->area; + cover += cur_cell->cover; + } + + if(area) + { + alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area); + if(alpha) + { + sl.add_cell(x, alpha); + } + x++; + } + + if(num_cells && cur_cell->x > x) + { + alpha = calculate_alpha(cover << (poly_subpixel_shift + 1)); + if(alpha) + { + sl.add_span(x, cur_cell->x - x, alpha); + } + } + } + + if(sl.num_spans()) break; + ++m_scan_y; + } + + sl.finalize(m_scan_y); + ++m_scan_y; + return true; + } + + //-------------------------------------------------------------------- + bool hit_test(int tx, int ty); + + + private: + //-------------------------------------------------------------------- + // Disable copying + rasterizer_scanline_aa(const rasterizer_scanline_aa&); + const rasterizer_scanline_aa& + operator = (const rasterizer_scanline_aa&); + + private: + rasterizer_cells_aa m_outline; + clip_type m_clipper; + int m_gamma[aa_scale]; + filling_rule_e m_filling_rule; + bool m_auto_close; + coord_type m_start_x; + coord_type m_start_y; + unsigned m_status; + int m_scan_y; + }; + + + + + + + + + + + + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::reset() + { + m_outline.reset(); + m_status = status_initial; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::filling_rule(filling_rule_e filling_rule) + { + m_filling_rule = filling_rule; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::clip_box(double x1, double y1, + double x2, double y2) + { + reset(); + m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1), + conv_type::upscale(x2), conv_type::upscale(y2)); + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::reset_clipping() + { + reset(); + m_clipper.reset_clipping(); + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::close_polygon() + { + if(m_status == status_line_to) + { + m_clipper.line_to(m_outline, m_start_x, m_start_y); + m_status = status_closed; + } + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::move_to(int x, int y) + { + if(m_outline.sorted()) reset(); + if(m_auto_close) close_polygon(); + m_clipper.move_to(m_start_x = conv_type::downscale(x), + m_start_y = conv_type::downscale(y)); + m_status = status_move_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::line_to(int x, int y) + { + m_clipper.line_to(m_outline, + conv_type::downscale(x), + conv_type::downscale(y)); + m_status = status_line_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::move_to_d(double x, double y) + { + if(m_outline.sorted()) reset(); + if(m_auto_close) close_polygon(); + m_clipper.move_to(m_start_x = conv_type::upscale(x), + m_start_y = conv_type::upscale(y)); + m_status = status_move_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::line_to_d(double x, double y) + { + m_clipper.line_to(m_outline, + conv_type::upscale(x), + conv_type::upscale(y)); + m_status = status_line_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::add_vertex(double x, double y, unsigned cmd) + { + if(is_move_to(cmd)) + { + move_to_d(x, y); + } + else + if(is_vertex(cmd)) + { + line_to_d(x, y); + } + else + if(is_close(cmd)) + { + close_polygon(); + } + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::edge(int x1, int y1, int x2, int y2) + { + if(m_outline.sorted()) reset(); + m_clipper.move_to(conv_type::downscale(x1), conv_type::downscale(y1)); + m_clipper.line_to(m_outline, + conv_type::downscale(x2), + conv_type::downscale(y2)); + m_status = status_move_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::edge_d(double x1, double y1, + double x2, double y2) + { + if(m_outline.sorted()) reset(); + m_clipper.move_to(conv_type::upscale(x1), conv_type::upscale(y1)); + m_clipper.line_to(m_outline, + conv_type::upscale(x2), + conv_type::upscale(y2)); + m_status = status_move_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa::sort() + { + if(m_auto_close) close_polygon(); + m_outline.sort_cells(); + } + + //------------------------------------------------------------------------ + template + AGG_INLINE bool rasterizer_scanline_aa::rewind_scanlines() + { + if(m_auto_close) close_polygon(); + m_outline.sort_cells(); + if(m_outline.total_cells() == 0) + { + return false; + } + m_scan_y = m_outline.min_y(); + return true; + } + + + //------------------------------------------------------------------------ + template + AGG_INLINE bool rasterizer_scanline_aa::navigate_scanline(int y) + { + if(m_auto_close) close_polygon(); + m_outline.sort_cells(); + if(m_outline.total_cells() == 0 || + y < m_outline.min_y() || + y > m_outline.max_y()) + { + return false; + } + m_scan_y = y; + return true; + } + + //------------------------------------------------------------------------ + template + bool rasterizer_scanline_aa::hit_test(int tx, int ty) + { + if(!navigate_scanline(ty)) return false; + scanline_hit_test sl(tx); + sweep_scanline(sl); + return sl.hit(); + } + + + +} + + + +#endif + diff --git a/xs/src/agg/agg_rasterizer_scanline_aa_nogamma.h b/xs/src/agg/agg_rasterizer_scanline_aa_nogamma.h new file mode 100644 index 0000000000..9a809aa5ae --- /dev/null +++ b/xs/src/agg/agg_rasterizer_scanline_aa_nogamma.h @@ -0,0 +1,483 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// +// The author gratefully acknowleges the support of David Turner, +// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType +// libray - in producing this work. See http://www.freetype.org for details. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +#ifndef AGG_RASTERIZER_SCANLINE_AA_NOGAMMA_INCLUDED +#define AGG_RASTERIZER_SCANLINE_AA_NOGAMMA_INCLUDED + +#include +#include "agg_rasterizer_cells_aa.h" +#include "agg_rasterizer_sl_clip.h" + + +namespace agg +{ + + + //-----------------------------------------------------------------cell_aa + // A pixel cell. There're no constructors defined and it was done + // intentionally in order to avoid extra overhead when allocating an + // array of cells. + struct cell_aa + { + int x; + int y; + int cover; + int area; + + void initial() + { + x = std::numeric_limits::max(); + y = std::numeric_limits::max(); + cover = 0; + area = 0; + } + + void style(const cell_aa&) {} + + int not_equal(int ex, int ey, const cell_aa&) const + { + return ((unsigned)ex - (unsigned)x) | ((unsigned)ey - (unsigned)y); + } + }; + + + //==================================================rasterizer_scanline_aa_nogamma + // Polygon rasterizer that is used to render filled polygons with + // high-quality Anti-Aliasing. Internally, by default, the class uses + // integer coordinates in format 24.8, i.e. 24 bits for integer part + // and 8 bits for fractional - see poly_subpixel_shift. This class can be + // used in the following way: + // + // 1. filling_rule(filling_rule_e ft) - optional. + // + // 2. gamma() - optional. + // + // 3. reset() + // + // 4. move_to(x, y) / line_to(x, y) - make the polygon. One can create + // more than one contour, but each contour must consist of at least 3 + // vertices, i.e. move_to(x1, y1); line_to(x2, y2); line_to(x3, y3); + // is the absolute minimum of vertices that define a triangle. + // The algorithm does not check either the number of vertices nor + // coincidence of their coordinates, but in the worst case it just + // won't draw anything. + // The orger of the vertices (clockwise or counterclockwise) + // is important when using the non-zero filling rule (fill_non_zero). + // In this case the vertex order of all the contours must be the same + // if you want your intersecting polygons to be without "holes". + // You actually can use different vertices order. If the contours do not + // intersect each other the order is not important anyway. If they do, + // contours with the same vertex order will be rendered without "holes" + // while the intersecting contours with different orders will have "holes". + // + // filling_rule() and gamma() can be called anytime before "sweeping". + //------------------------------------------------------------------------ + template class rasterizer_scanline_aa_nogamma + { + enum status + { + status_initial, + status_move_to, + status_line_to, + status_closed + }; + + public: + typedef Clip clip_type; + typedef typename Clip::conv_type conv_type; + typedef typename Clip::coord_type coord_type; + + enum aa_scale_e + { + aa_shift = 8, + aa_scale = 1 << aa_shift, + aa_mask = aa_scale - 1, + aa_scale2 = aa_scale * 2, + aa_mask2 = aa_scale2 - 1 + }; + + //-------------------------------------------------------------------- + rasterizer_scanline_aa_nogamma() : + m_outline(), + m_clipper(), + m_filling_rule(fill_non_zero), + m_auto_close(true), + m_start_x(0), + m_start_y(0), + m_status(status_initial) + { + } + + //-------------------------------------------------------------------- + void reset(); + void reset_clipping(); + void clip_box(double x1, double y1, double x2, double y2); + void filling_rule(filling_rule_e filling_rule); + void auto_close(bool flag) { m_auto_close = flag; } + + //-------------------------------------------------------------------- + unsigned apply_gamma(unsigned cover) const + { + return cover; + } + + //-------------------------------------------------------------------- + void move_to(int x, int y); + void line_to(int x, int y); + void move_to_d(double x, double y); + void line_to_d(double x, double y); + void close_polygon(); + void add_vertex(double x, double y, unsigned cmd); + + void edge(int x1, int y1, int x2, int y2); + void edge_d(double x1, double y1, double x2, double y2); + + //------------------------------------------------------------------- + template + void add_path(VertexSource& vs, unsigned path_id=0) + { + double x; + double y; + + unsigned cmd; + vs.rewind(path_id); + if(m_outline.sorted()) reset(); + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + add_vertex(x, y, cmd); + } + } + + //-------------------------------------------------------------------- + int min_x() const { return m_outline.min_x(); } + int min_y() const { return m_outline.min_y(); } + int max_x() const { return m_outline.max_x(); } + int max_y() const { return m_outline.max_y(); } + + //-------------------------------------------------------------------- + void sort(); + bool rewind_scanlines(); + bool navigate_scanline(int y); + + //-------------------------------------------------------------------- + AGG_INLINE unsigned calculate_alpha(int area) const + { + int cover = area >> (poly_subpixel_shift*2 + 1 - aa_shift); + + if(cover < 0) cover = -cover; + if(m_filling_rule == fill_even_odd) + { + cover &= aa_mask2; + if(cover > aa_scale) + { + cover = aa_scale2 - cover; + } + } + if(cover > aa_mask) cover = aa_mask; + return cover; + } + + //-------------------------------------------------------------------- + template bool sweep_scanline(Scanline& sl) + { + for(;;) + { + if(m_scan_y > m_outline.max_y()) return false; + sl.reset_spans(); + unsigned num_cells = m_outline.scanline_num_cells(m_scan_y); + const cell_aa* const* cells = m_outline.scanline_cells(m_scan_y); + int cover = 0; + + while(num_cells) + { + const cell_aa* cur_cell = *cells; + int x = cur_cell->x; + int area = cur_cell->area; + unsigned alpha; + + cover += cur_cell->cover; + + //accumulate all cells with the same X + while(--num_cells) + { + cur_cell = *++cells; + if(cur_cell->x != x) break; + area += cur_cell->area; + cover += cur_cell->cover; + } + + if(area) + { + alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area); + if(alpha) + { + sl.add_cell(x, alpha); + } + x++; + } + + if(num_cells && cur_cell->x > x) + { + alpha = calculate_alpha(cover << (poly_subpixel_shift + 1)); + if(alpha) + { + sl.add_span(x, cur_cell->x - x, alpha); + } + } + } + + if(sl.num_spans()) break; + ++m_scan_y; + } + + sl.finalize(m_scan_y); + ++m_scan_y; + return true; + } + + //-------------------------------------------------------------------- + bool hit_test(int tx, int ty); + + + private: + //-------------------------------------------------------------------- + // Disable copying + rasterizer_scanline_aa_nogamma(const rasterizer_scanline_aa_nogamma&); + const rasterizer_scanline_aa_nogamma& + operator = (const rasterizer_scanline_aa_nogamma&); + + private: + rasterizer_cells_aa m_outline; + clip_type m_clipper; + filling_rule_e m_filling_rule; + bool m_auto_close; + coord_type m_start_x; + coord_type m_start_y; + unsigned m_status; + int m_scan_y; + }; + + + + + + + + + + + + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::reset() + { + m_outline.reset(); + m_status = status_initial; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::filling_rule(filling_rule_e filling_rule) + { + m_filling_rule = filling_rule; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::clip_box(double x1, double y1, + double x2, double y2) + { + reset(); + m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1), + conv_type::upscale(x2), conv_type::upscale(y2)); + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::reset_clipping() + { + reset(); + m_clipper.reset_clipping(); + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::close_polygon() + { + if(m_status == status_line_to) + { + m_clipper.line_to(m_outline, m_start_x, m_start_y); + m_status = status_closed; + } + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::move_to(int x, int y) + { + if(m_outline.sorted()) reset(); + if(m_auto_close) close_polygon(); + m_clipper.move_to(m_start_x = conv_type::downscale(x), + m_start_y = conv_type::downscale(y)); + m_status = status_move_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::line_to(int x, int y) + { + m_clipper.line_to(m_outline, + conv_type::downscale(x), + conv_type::downscale(y)); + m_status = status_line_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::move_to_d(double x, double y) + { + if(m_outline.sorted()) reset(); + if(m_auto_close) close_polygon(); + m_clipper.move_to(m_start_x = conv_type::upscale(x), + m_start_y = conv_type::upscale(y)); + m_status = status_move_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::line_to_d(double x, double y) + { + m_clipper.line_to(m_outline, + conv_type::upscale(x), + conv_type::upscale(y)); + m_status = status_line_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::add_vertex(double x, double y, unsigned cmd) + { + if(is_move_to(cmd)) + { + move_to_d(x, y); + } + else + if(is_vertex(cmd)) + { + line_to_d(x, y); + } + else + if(is_close(cmd)) + { + close_polygon(); + } + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::edge(int x1, int y1, int x2, int y2) + { + if(m_outline.sorted()) reset(); + m_clipper.move_to(conv_type::downscale(x1), conv_type::downscale(y1)); + m_clipper.line_to(m_outline, + conv_type::downscale(x2), + conv_type::downscale(y2)); + m_status = status_move_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::edge_d(double x1, double y1, + double x2, double y2) + { + if(m_outline.sorted()) reset(); + m_clipper.move_to(conv_type::upscale(x1), conv_type::upscale(y1)); + m_clipper.line_to(m_outline, + conv_type::upscale(x2), + conv_type::upscale(y2)); + m_status = status_move_to; + } + + //------------------------------------------------------------------------ + template + void rasterizer_scanline_aa_nogamma::sort() + { + if(m_auto_close) close_polygon(); + m_outline.sort_cells(); + } + + //------------------------------------------------------------------------ + template + AGG_INLINE bool rasterizer_scanline_aa_nogamma::rewind_scanlines() + { + if(m_auto_close) close_polygon(); + m_outline.sort_cells(); + if(m_outline.total_cells() == 0) + { + return false; + } + m_scan_y = m_outline.min_y(); + return true; + } + + + //------------------------------------------------------------------------ + template + AGG_INLINE bool rasterizer_scanline_aa_nogamma::navigate_scanline(int y) + { + if(m_auto_close) close_polygon(); + m_outline.sort_cells(); + if(m_outline.total_cells() == 0 || + y < m_outline.min_y() || + y > m_outline.max_y()) + { + return false; + } + m_scan_y = y; + return true; + } + + //------------------------------------------------------------------------ + template + bool rasterizer_scanline_aa_nogamma::hit_test(int tx, int ty) + { + if(!navigate_scanline(ty)) return false; + scanline_hit_test sl(tx); + sweep_scanline(sl); + return sl.hit(); + } + + + +} + + + +#endif + diff --git a/xs/src/agg/agg_rasterizer_sl_clip.h b/xs/src/agg/agg_rasterizer_sl_clip.h new file mode 100644 index 0000000000..3a7f3a1033 --- /dev/null +++ b/xs/src/agg/agg_rasterizer_sl_clip.h @@ -0,0 +1,351 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_RASTERIZER_SL_CLIP_INCLUDED +#define AGG_RASTERIZER_SL_CLIP_INCLUDED + +#include "agg_clip_liang_barsky.h" + +namespace agg +{ + //--------------------------------------------------------poly_max_coord_e + enum poly_max_coord_e + { + poly_max_coord = (1 << 30) - 1 //----poly_max_coord + }; + + //------------------------------------------------------------ras_conv_int + struct ras_conv_int + { + typedef int coord_type; + static AGG_INLINE int mul_div(double a, double b, double c) + { + return iround(a * b / c); + } + static int xi(int v) { return v; } + static int yi(int v) { return v; } + static int upscale(double v) { return iround(v * poly_subpixel_scale); } + static int downscale(int v) { return v; } + }; + + //--------------------------------------------------------ras_conv_int_sat + struct ras_conv_int_sat + { + typedef int coord_type; + static AGG_INLINE int mul_div(double a, double b, double c) + { + return saturation::iround(a * b / c); + } + static int xi(int v) { return v; } + static int yi(int v) { return v; } + static int upscale(double v) + { + return saturation::iround(v * poly_subpixel_scale); + } + static int downscale(int v) { return v; } + }; + + //---------------------------------------------------------ras_conv_int_3x + struct ras_conv_int_3x + { + typedef int coord_type; + static AGG_INLINE int mul_div(double a, double b, double c) + { + return iround(a * b / c); + } + static int xi(int v) { return v * 3; } + static int yi(int v) { return v; } + static int upscale(double v) { return iround(v * poly_subpixel_scale); } + static int downscale(int v) { return v; } + }; + + //-----------------------------------------------------------ras_conv_dbl + struct ras_conv_dbl + { + typedef double coord_type; + static AGG_INLINE double mul_div(double a, double b, double c) + { + return a * b / c; + } + static int xi(double v) { return iround(v * poly_subpixel_scale); } + static int yi(double v) { return iround(v * poly_subpixel_scale); } + static double upscale(double v) { return v; } + static double downscale(int v) { return v / double(poly_subpixel_scale); } + }; + + //--------------------------------------------------------ras_conv_dbl_3x + struct ras_conv_dbl_3x + { + typedef double coord_type; + static AGG_INLINE double mul_div(double a, double b, double c) + { + return a * b / c; + } + static int xi(double v) { return iround(v * poly_subpixel_scale * 3); } + static int yi(double v) { return iround(v * poly_subpixel_scale); } + static double upscale(double v) { return v; } + static double downscale(int v) { return v / double(poly_subpixel_scale); } + }; + + + + + + //------------------------------------------------------rasterizer_sl_clip + template class rasterizer_sl_clip + { + public: + typedef Conv conv_type; + typedef typename Conv::coord_type coord_type; + typedef rect_base rect_type; + + //-------------------------------------------------------------------- + rasterizer_sl_clip() : + m_clip_box(0,0,0,0), + m_x1(0), + m_y1(0), + m_f1(0), + m_clipping(false) + {} + + //-------------------------------------------------------------------- + void reset_clipping() + { + m_clipping = false; + } + + //-------------------------------------------------------------------- + void clip_box(coord_type x1, coord_type y1, coord_type x2, coord_type y2) + { + m_clip_box = rect_type(x1, y1, x2, y2); + m_clip_box.normalize(); + m_clipping = true; + } + + //-------------------------------------------------------------------- + void move_to(coord_type x1, coord_type y1) + { + m_x1 = x1; + m_y1 = y1; + if(m_clipping) m_f1 = clipping_flags(x1, y1, m_clip_box); + } + + private: + //------------------------------------------------------------------------ + template + AGG_INLINE void line_clip_y(Rasterizer& ras, + coord_type x1, coord_type y1, + coord_type x2, coord_type y2, + unsigned f1, unsigned f2) const + { + f1 &= 10; + f2 &= 10; + if((f1 | f2) == 0) + { + // Fully visible + ras.line(Conv::xi(x1), Conv::yi(y1), Conv::xi(x2), Conv::yi(y2)); + } + else + { + if(f1 == f2) + { + // Invisible by Y + return; + } + + coord_type tx1 = x1; + coord_type ty1 = y1; + coord_type tx2 = x2; + coord_type ty2 = y2; + + if(f1 & 8) // y1 < clip.y1 + { + tx1 = x1 + Conv::mul_div(m_clip_box.y1-y1, x2-x1, y2-y1); + ty1 = m_clip_box.y1; + } + + if(f1 & 2) // y1 > clip.y2 + { + tx1 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1); + ty1 = m_clip_box.y2; + } + + if(f2 & 8) // y2 < clip.y1 + { + tx2 = x1 + Conv::mul_div(m_clip_box.y1-y1, x2-x1, y2-y1); + ty2 = m_clip_box.y1; + } + + if(f2 & 2) // y2 > clip.y2 + { + tx2 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1); + ty2 = m_clip_box.y2; + } + ras.line(Conv::xi(tx1), Conv::yi(ty1), + Conv::xi(tx2), Conv::yi(ty2)); + } + } + + + public: + //-------------------------------------------------------------------- + template + void line_to(Rasterizer& ras, coord_type x2, coord_type y2) + { + if(m_clipping) + { + unsigned f2 = clipping_flags(x2, y2, m_clip_box); + + if((m_f1 & 10) == (f2 & 10) && (m_f1 & 10) != 0) + { + // Invisible by Y + m_x1 = x2; + m_y1 = y2; + m_f1 = f2; + return; + } + + coord_type x1 = m_x1; + coord_type y1 = m_y1; + unsigned f1 = m_f1; + coord_type y3, y4; + unsigned f3, f4; + + switch(((f1 & 5) << 1) | (f2 & 5)) + { + case 0: // Visible by X + line_clip_y(ras, x1, y1, x2, y2, f1, f2); + break; + + case 1: // x2 > clip.x2 + y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1); + f3 = clipping_flags_y(y3, m_clip_box); + line_clip_y(ras, x1, y1, m_clip_box.x2, y3, f1, f3); + line_clip_y(ras, m_clip_box.x2, y3, m_clip_box.x2, y2, f3, f2); + break; + + case 2: // x1 > clip.x2 + y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1); + f3 = clipping_flags_y(y3, m_clip_box); + line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y3, f1, f3); + line_clip_y(ras, m_clip_box.x2, y3, x2, y2, f3, f2); + break; + + case 3: // x1 > clip.x2 && x2 > clip.x2 + line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y2, f1, f2); + break; + + case 4: // x2 < clip.x1 + y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1); + f3 = clipping_flags_y(y3, m_clip_box); + line_clip_y(ras, x1, y1, m_clip_box.x1, y3, f1, f3); + line_clip_y(ras, m_clip_box.x1, y3, m_clip_box.x1, y2, f3, f2); + break; + + case 6: // x1 > clip.x2 && x2 < clip.x1 + y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1); + y4 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1); + f3 = clipping_flags_y(y3, m_clip_box); + f4 = clipping_flags_y(y4, m_clip_box); + line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y3, f1, f3); + line_clip_y(ras, m_clip_box.x2, y3, m_clip_box.x1, y4, f3, f4); + line_clip_y(ras, m_clip_box.x1, y4, m_clip_box.x1, y2, f4, f2); + break; + + case 8: // x1 < clip.x1 + y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1); + f3 = clipping_flags_y(y3, m_clip_box); + line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y3, f1, f3); + line_clip_y(ras, m_clip_box.x1, y3, x2, y2, f3, f2); + break; + + case 9: // x1 < clip.x1 && x2 > clip.x2 + y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1); + y4 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1); + f3 = clipping_flags_y(y3, m_clip_box); + f4 = clipping_flags_y(y4, m_clip_box); + line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y3, f1, f3); + line_clip_y(ras, m_clip_box.x1, y3, m_clip_box.x2, y4, f3, f4); + line_clip_y(ras, m_clip_box.x2, y4, m_clip_box.x2, y2, f4, f2); + break; + + case 12: // x1 < clip.x1 && x2 < clip.x1 + line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y2, f1, f2); + break; + } + m_f1 = f2; + } + else + { + ras.line(Conv::xi(m_x1), Conv::yi(m_y1), + Conv::xi(x2), Conv::yi(y2)); + } + m_x1 = x2; + m_y1 = y2; + } + + + private: + rect_type m_clip_box; + coord_type m_x1; + coord_type m_y1; + unsigned m_f1; + bool m_clipping; + }; + + + + + //---------------------------------------------------rasterizer_sl_no_clip + class rasterizer_sl_no_clip + { + public: + typedef ras_conv_int conv_type; + typedef int coord_type; + + rasterizer_sl_no_clip() : m_x1(0), m_y1(0) {} + + void reset_clipping() {} + void clip_box(coord_type, coord_type, coord_type, coord_type) {} + void move_to(coord_type x1, coord_type y1) { m_x1 = x1; m_y1 = y1; } + + template + void line_to(Rasterizer& ras, coord_type x2, coord_type y2) + { + ras.line(m_x1, m_y1, x2, y2); + m_x1 = x2; + m_y1 = y2; + } + + private: + int m_x1, m_y1; + }; + + + // -----rasterizer_sl_clip_int + // -----rasterizer_sl_clip_int_sat + // -----rasterizer_sl_clip_int_3x + // -----rasterizer_sl_clip_dbl + // -----rasterizer_sl_clip_dbl_3x + //------------------------------------------------------------------------ + typedef rasterizer_sl_clip rasterizer_sl_clip_int; + typedef rasterizer_sl_clip rasterizer_sl_clip_int_sat; + typedef rasterizer_sl_clip rasterizer_sl_clip_int_3x; + typedef rasterizer_sl_clip rasterizer_sl_clip_dbl; + typedef rasterizer_sl_clip rasterizer_sl_clip_dbl_3x; + + +} + +#endif diff --git a/xs/src/agg/agg_renderer_base.h b/xs/src/agg/agg_renderer_base.h new file mode 100644 index 0000000000..527c62f789 --- /dev/null +++ b/xs/src/agg/agg_renderer_base.h @@ -0,0 +1,731 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class renderer_base +// +//---------------------------------------------------------------------------- + +#ifndef AGG_RENDERER_BASE_INCLUDED +#define AGG_RENDERER_BASE_INCLUDED + +#include "agg_basics.h" +#include "agg_rendering_buffer.h" + +namespace agg +{ + + //-----------------------------------------------------------renderer_base + template class renderer_base + { + public: + typedef PixelFormat pixfmt_type; + typedef typename pixfmt_type::color_type color_type; + typedef typename pixfmt_type::row_data row_data; + + //-------------------------------------------------------------------- + renderer_base() : m_ren(0), m_clip_box(1, 1, 0, 0) {} + explicit renderer_base(pixfmt_type& ren) : + m_ren(&ren), + m_clip_box(0, 0, ren.width() - 1, ren.height() - 1) + {} + void attach(pixfmt_type& ren) + { + m_ren = &ren; + m_clip_box = rect_i(0, 0, ren.width() - 1, ren.height() - 1); + } + + //-------------------------------------------------------------------- + const pixfmt_type& ren() const { return *m_ren; } + pixfmt_type& ren() { return *m_ren; } + + //-------------------------------------------------------------------- + unsigned width() const { return m_ren->width(); } + unsigned height() const { return m_ren->height(); } + + //-------------------------------------------------------------------- + bool clip_box(int x1, int y1, int x2, int y2) + { + rect_i cb(x1, y1, x2, y2); + cb.normalize(); + if(cb.clip(rect_i(0, 0, width() - 1, height() - 1))) + { + m_clip_box = cb; + return true; + } + m_clip_box.x1 = 1; + m_clip_box.y1 = 1; + m_clip_box.x2 = 0; + m_clip_box.y2 = 0; + return false; + } + + //-------------------------------------------------------------------- + void reset_clipping(bool visibility) + { + if(visibility) + { + m_clip_box.x1 = 0; + m_clip_box.y1 = 0; + m_clip_box.x2 = width() - 1; + m_clip_box.y2 = height() - 1; + } + else + { + m_clip_box.x1 = 1; + m_clip_box.y1 = 1; + m_clip_box.x2 = 0; + m_clip_box.y2 = 0; + } + } + + //-------------------------------------------------------------------- + void clip_box_naked(int x1, int y1, int x2, int y2) + { + m_clip_box.x1 = x1; + m_clip_box.y1 = y1; + m_clip_box.x2 = x2; + m_clip_box.y2 = y2; + } + + //-------------------------------------------------------------------- + bool inbox(int x, int y) const + { + return x >= m_clip_box.x1 && y >= m_clip_box.y1 && + x <= m_clip_box.x2 && y <= m_clip_box.y2; + } + + //-------------------------------------------------------------------- + const rect_i& clip_box() const { return m_clip_box; } + int xmin() const { return m_clip_box.x1; } + int ymin() const { return m_clip_box.y1; } + int xmax() const { return m_clip_box.x2; } + int ymax() const { return m_clip_box.y2; } + + //-------------------------------------------------------------------- + const rect_i& bounding_clip_box() const { return m_clip_box; } + int bounding_xmin() const { return m_clip_box.x1; } + int bounding_ymin() const { return m_clip_box.y1; } + int bounding_xmax() const { return m_clip_box.x2; } + int bounding_ymax() const { return m_clip_box.y2; } + + //-------------------------------------------------------------------- + void clear(const color_type& c) + { + unsigned y; + if(width()) + { + for(y = 0; y < height(); y++) + { + m_ren->copy_hline(0, y, width(), c); + } + } + } + + + //-------------------------------------------------------------------- + void fill(const color_type& c) + { + unsigned y; + if(width()) + { + for(y = 0; y < height(); y++) + { + m_ren->blend_hline(0, y, width(), c, cover_mask); + } + } + } + + //-------------------------------------------------------------------- + void copy_pixel(int x, int y, const color_type& c) + { + if(inbox(x, y)) + { + m_ren->copy_pixel(x, y, c); + } + } + + //-------------------------------------------------------------------- + void blend_pixel(int x, int y, const color_type& c, cover_type cover) + { + if(inbox(x, y)) + { + m_ren->blend_pixel(x, y, c, cover); + } + } + + //-------------------------------------------------------------------- + color_type pixel(int x, int y) const + { + return inbox(x, y) ? + m_ren->pixel(x, y) : + color_type::no_color(); + } + + //-------------------------------------------------------------------- + void copy_hline(int x1, int y, int x2, const color_type& c) + { + if(x1 > x2) { int t = x2; x2 = x1; x1 = t; } + if(y > ymax()) return; + if(y < ymin()) return; + if(x1 > xmax()) return; + if(x2 < xmin()) return; + + if(x1 < xmin()) x1 = xmin(); + if(x2 > xmax()) x2 = xmax(); + + m_ren->copy_hline(x1, y, x2 - x1 + 1, c); + } + + //-------------------------------------------------------------------- + void copy_vline(int x, int y1, int y2, const color_type& c) + { + if(y1 > y2) { int t = y2; y2 = y1; y1 = t; } + if(x > xmax()) return; + if(x < xmin()) return; + if(y1 > ymax()) return; + if(y2 < ymin()) return; + + if(y1 < ymin()) y1 = ymin(); + if(y2 > ymax()) y2 = ymax(); + + m_ren->copy_vline(x, y1, y2 - y1 + 1, c); + } + + //-------------------------------------------------------------------- + void blend_hline(int x1, int y, int x2, + const color_type& c, cover_type cover) + { + if(x1 > x2) { int t = x2; x2 = x1; x1 = t; } + if(y > ymax()) return; + if(y < ymin()) return; + if(x1 > xmax()) return; + if(x2 < xmin()) return; + + if(x1 < xmin()) x1 = xmin(); + if(x2 > xmax()) x2 = xmax(); + + m_ren->blend_hline(x1, y, x2 - x1 + 1, c, cover); + } + + //-------------------------------------------------------------------- + void blend_vline(int x, int y1, int y2, + const color_type& c, cover_type cover) + { + if(y1 > y2) { int t = y2; y2 = y1; y1 = t; } + if(x > xmax()) return; + if(x < xmin()) return; + if(y1 > ymax()) return; + if(y2 < ymin()) return; + + if(y1 < ymin()) y1 = ymin(); + if(y2 > ymax()) y2 = ymax(); + + m_ren->blend_vline(x, y1, y2 - y1 + 1, c, cover); + } + + + //-------------------------------------------------------------------- + void copy_bar(int x1, int y1, int x2, int y2, const color_type& c) + { + rect_i rc(x1, y1, x2, y2); + rc.normalize(); + if(rc.clip(clip_box())) + { + int y; + for(y = rc.y1; y <= rc.y2; y++) + { + m_ren->copy_hline(rc.x1, y, unsigned(rc.x2 - rc.x1 + 1), c); + } + } + } + + //-------------------------------------------------------------------- + void blend_bar(int x1, int y1, int x2, int y2, + const color_type& c, cover_type cover) + { + rect_i rc(x1, y1, x2, y2); + rc.normalize(); + if(rc.clip(clip_box())) + { + int y; + for(y = rc.y1; y <= rc.y2; y++) + { + m_ren->blend_hline(rc.x1, + y, + unsigned(rc.x2 - rc.x1 + 1), + c, + cover); + } + } + } + + //-------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, int len, + const color_type& c, + const cover_type* covers) + { + if(y > ymax()) return; + if(y < ymin()) return; + + if(x < xmin()) + { + len -= xmin() - x; + if(len <= 0) return; + covers += xmin() - x; + x = xmin(); + } + if(x + len > xmax()) + { + len = xmax() - x + 1; + if(len <= 0) return; + } + m_ren->blend_solid_hspan(x, y, len, c, covers); + } + + //-------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, int len, + const color_type& c, + const cover_type* covers) + { + if(x > xmax()) return; + if(x < xmin()) return; + + if(y < ymin()) + { + len -= ymin() - y; + if(len <= 0) return; + covers += ymin() - y; + y = ymin(); + } + if(y + len > ymax()) + { + len = ymax() - y + 1; + if(len <= 0) return; + } + m_ren->blend_solid_vspan(x, y, len, c, covers); + } + + + //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, int len, const color_type* colors) + { + if(y > ymax()) return; + if(y < ymin()) return; + + if(x < xmin()) + { + int d = xmin() - x; + len -= d; + if(len <= 0) return; + colors += d; + x = xmin(); + } + if(x + len > xmax()) + { + len = xmax() - x + 1; + if(len <= 0) return; + } + m_ren->copy_color_hspan(x, y, len, colors); + } + + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, int len, const color_type* colors) + { + if(x > xmax()) return; + if(x < xmin()) return; + + if(y < ymin()) + { + int d = ymin() - y; + len -= d; + if(len <= 0) return; + colors += d; + y = ymin(); + } + if(y + len > ymax()) + { + len = ymax() - y + 1; + if(len <= 0) return; + } + m_ren->copy_color_vspan(x, y, len, colors); + } + + + //-------------------------------------------------------------------- + void blend_color_hspan(int x, int y, int len, + const color_type* colors, + const cover_type* covers, + cover_type cover = agg::cover_full) + { + if(y > ymax()) return; + if(y < ymin()) return; + + if(x < xmin()) + { + int d = xmin() - x; + len -= d; + if(len <= 0) return; + if(covers) covers += d; + colors += d; + x = xmin(); + } + if(x + len > xmax()) + { + len = xmax() - x + 1; + if(len <= 0) return; + } + m_ren->blend_color_hspan(x, y, len, colors, covers, cover); + } + + //-------------------------------------------------------------------- + void blend_color_vspan(int x, int y, int len, + const color_type* colors, + const cover_type* covers, + cover_type cover = agg::cover_full) + { + if(x > xmax()) return; + if(x < xmin()) return; + + if(y < ymin()) + { + int d = ymin() - y; + len -= d; + if(len <= 0) return; + if(covers) covers += d; + colors += d; + y = ymin(); + } + if(y + len > ymax()) + { + len = ymax() - y + 1; + if(len <= 0) return; + } + m_ren->blend_color_vspan(x, y, len, colors, covers, cover); + } + + //-------------------------------------------------------------------- + rect_i clip_rect_area(rect_i& dst, rect_i& src, int wsrc, int hsrc) const + { + rect_i rc(0,0,0,0); + rect_i cb = clip_box(); + ++cb.x2; + ++cb.y2; + + if(src.x1 < 0) + { + dst.x1 -= src.x1; + src.x1 = 0; + } + if(src.y1 < 0) + { + dst.y1 -= src.y1; + src.y1 = 0; + } + + if(src.x2 > wsrc) src.x2 = wsrc; + if(src.y2 > hsrc) src.y2 = hsrc; + + if(dst.x1 < cb.x1) + { + src.x1 += cb.x1 - dst.x1; + dst.x1 = cb.x1; + } + if(dst.y1 < cb.y1) + { + src.y1 += cb.y1 - dst.y1; + dst.y1 = cb.y1; + } + + if(dst.x2 > cb.x2) dst.x2 = cb.x2; + if(dst.y2 > cb.y2) dst.y2 = cb.y2; + + rc.x2 = dst.x2 - dst.x1; + rc.y2 = dst.y2 - dst.y1; + + if(rc.x2 > src.x2 - src.x1) rc.x2 = src.x2 - src.x1; + if(rc.y2 > src.y2 - src.y1) rc.y2 = src.y2 - src.y1; + return rc; + } + + //-------------------------------------------------------------------- + template + void copy_from(const RenBuf& src, + const rect_i* rect_src_ptr = 0, + int dx = 0, + int dy = 0) + { + rect_i rsrc(0, 0, src.width(), src.height()); + if(rect_src_ptr) + { + rsrc.x1 = rect_src_ptr->x1; + rsrc.y1 = rect_src_ptr->y1; + rsrc.x2 = rect_src_ptr->x2 + 1; + rsrc.y2 = rect_src_ptr->y2 + 1; + } + + // Version with xdst, ydst (absolute positioning) + //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1); + + // Version with dx, dy (relative positioning) + rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy); + + rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height()); + + if(rc.x2 > 0) + { + int incy = 1; + if(rdst.y1 > rsrc.y1) + { + rsrc.y1 += rc.y2 - 1; + rdst.y1 += rc.y2 - 1; + incy = -1; + } + while(rc.y2 > 0) + { + m_ren->copy_from(src, + rdst.x1, rdst.y1, + rsrc.x1, rsrc.y1, + rc.x2); + rdst.y1 += incy; + rsrc.y1 += incy; + --rc.y2; + } + } + } + + //-------------------------------------------------------------------- + template + void blend_from(const SrcPixelFormatRenderer& src, + const rect_i* rect_src_ptr = 0, + int dx = 0, + int dy = 0, + cover_type cover = agg::cover_full) + { + rect_i rsrc(0, 0, src.width(), src.height()); + if(rect_src_ptr) + { + rsrc.x1 = rect_src_ptr->x1; + rsrc.y1 = rect_src_ptr->y1; + rsrc.x2 = rect_src_ptr->x2 + 1; + rsrc.y2 = rect_src_ptr->y2 + 1; + } + + // Version with xdst, ydst (absolute positioning) + //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1); + + // Version with dx, dy (relative positioning) + rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy); + rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height()); + + if(rc.x2 > 0) + { + int incy = 1; + if(rdst.y1 > rsrc.y1) + { + rsrc.y1 += rc.y2 - 1; + rdst.y1 += rc.y2 - 1; + incy = -1; + } + while(rc.y2 > 0) + { + typename SrcPixelFormatRenderer::row_data rw = src.row(rsrc.y1); + if(rw.ptr) + { + int x1src = rsrc.x1; + int x1dst = rdst.x1; + int len = rc.x2; + if(rw.x1 > x1src) + { + x1dst += rw.x1 - x1src; + len -= rw.x1 - x1src; + x1src = rw.x1; + } + if(len > 0) + { + if(x1src + len-1 > rw.x2) + { + len -= x1src + len - rw.x2 - 1; + } + if(len > 0) + { + m_ren->blend_from(src, + x1dst, rdst.y1, + x1src, rsrc.y1, + len, + cover); + } + } + } + rdst.y1 += incy; + rsrc.y1 += incy; + --rc.y2; + } + } + } + + //-------------------------------------------------------------------- + template + void blend_from_color(const SrcPixelFormatRenderer& src, + const color_type& color, + const rect_i* rect_src_ptr = 0, + int dx = 0, + int dy = 0, + cover_type cover = agg::cover_full) + { + rect_i rsrc(0, 0, src.width(), src.height()); + if(rect_src_ptr) + { + rsrc.x1 = rect_src_ptr->x1; + rsrc.y1 = rect_src_ptr->y1; + rsrc.x2 = rect_src_ptr->x2 + 1; + rsrc.y2 = rect_src_ptr->y2 + 1; + } + + // Version with xdst, ydst (absolute positioning) + //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1); + + // Version with dx, dy (relative positioning) + rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy); + rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height()); + + if(rc.x2 > 0) + { + int incy = 1; + if(rdst.y1 > rsrc.y1) + { + rsrc.y1 += rc.y2 - 1; + rdst.y1 += rc.y2 - 1; + incy = -1; + } + while(rc.y2 > 0) + { + typename SrcPixelFormatRenderer::row_data rw = src.row(rsrc.y1); + if(rw.ptr) + { + int x1src = rsrc.x1; + int x1dst = rdst.x1; + int len = rc.x2; + if(rw.x1 > x1src) + { + x1dst += rw.x1 - x1src; + len -= rw.x1 - x1src; + x1src = rw.x1; + } + if(len > 0) + { + if(x1src + len-1 > rw.x2) + { + len -= x1src + len - rw.x2 - 1; + } + if(len > 0) + { + m_ren->blend_from_color(src, + color, + x1dst, rdst.y1, + x1src, rsrc.y1, + len, + cover); + } + } + } + rdst.y1 += incy; + rsrc.y1 += incy; + --rc.y2; + } + } + } + + //-------------------------------------------------------------------- + template + void blend_from_lut(const SrcPixelFormatRenderer& src, + const color_type* color_lut, + const rect_i* rect_src_ptr = 0, + int dx = 0, + int dy = 0, + cover_type cover = agg::cover_full) + { + rect_i rsrc(0, 0, src.width(), src.height()); + if(rect_src_ptr) + { + rsrc.x1 = rect_src_ptr->x1; + rsrc.y1 = rect_src_ptr->y1; + rsrc.x2 = rect_src_ptr->x2 + 1; + rsrc.y2 = rect_src_ptr->y2 + 1; + } + + // Version with xdst, ydst (absolute positioning) + //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1); + + // Version with dx, dy (relative positioning) + rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy); + rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height()); + + if(rc.x2 > 0) + { + int incy = 1; + if(rdst.y1 > rsrc.y1) + { + rsrc.y1 += rc.y2 - 1; + rdst.y1 += rc.y2 - 1; + incy = -1; + } + while(rc.y2 > 0) + { + typename SrcPixelFormatRenderer::row_data rw = src.row(rsrc.y1); + if(rw.ptr) + { + int x1src = rsrc.x1; + int x1dst = rdst.x1; + int len = rc.x2; + if(rw.x1 > x1src) + { + x1dst += rw.x1 - x1src; + len -= rw.x1 - x1src; + x1src = rw.x1; + } + if(len > 0) + { + if(x1src + len-1 > rw.x2) + { + len -= x1src + len - rw.x2 - 1; + } + if(len > 0) + { + m_ren->blend_from_lut(src, + color_lut, + x1dst, rdst.y1, + x1src, rsrc.y1, + len, + cover); + } + } + } + rdst.y1 += incy; + rsrc.y1 += incy; + --rc.y2; + } + } + } + + private: + pixfmt_type* m_ren; + rect_i m_clip_box; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_renderer_markers.h b/xs/src/agg/agg_renderer_markers.h new file mode 100644 index 0000000000..6ff0534943 --- /dev/null +++ b/xs/src/agg/agg_renderer_markers.h @@ -0,0 +1,711 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class renderer_markers +// +//---------------------------------------------------------------------------- + +#ifndef AGG_RENDERER_MARKERS_INCLUDED +#define AGG_RENDERER_MARKERS_INCLUDED + +#include "agg_basics.h" +#include "agg_renderer_primitives.h" + +namespace agg +{ + + //---------------------------------------------------------------marker_e + enum marker_e + { + marker_square, + marker_diamond, + marker_circle, + marker_crossed_circle, + marker_semiellipse_left, + marker_semiellipse_right, + marker_semiellipse_up, + marker_semiellipse_down, + marker_triangle_left, + marker_triangle_right, + marker_triangle_up, + marker_triangle_down, + marker_four_rays, + marker_cross, + marker_x, + marker_dash, + marker_dot, + marker_pixel, + + end_of_markers + }; + + + + //--------------------------------------------------------renderer_markers + template class renderer_markers : + public renderer_primitives + { + public: + typedef renderer_primitives base_type; + typedef BaseRenderer base_ren_type; + typedef typename base_ren_type::color_type color_type; + + //-------------------------------------------------------------------- + renderer_markers(base_ren_type& rbuf) : + base_type(rbuf) + {} + + //-------------------------------------------------------------------- + bool visible(int x, int y, int r) const + { + rect_i rc(x-r, y-r, x+y, y+r); + return rc.clip(base_type::ren().bounding_clip_box()); + } + + //-------------------------------------------------------------------- + void square(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) base_type::outlined_rectangle(x-r, y-r, x+r, y+r); + else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + + //-------------------------------------------------------------------- + void diamond(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int dy = -r; + int dx = 0; + do + { + base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); + + if(dx) + { + base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); + base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); + } + ++dy; + ++dx; + } + while(dy <= 0); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + //-------------------------------------------------------------------- + void circle(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) base_type::outlined_ellipse(x, y, r, r); + else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + + + + //-------------------------------------------------------------------- + void crossed_circle(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + base_type::outlined_ellipse(x, y, r, r); + int r6 = r + (r >> 1); + if(r <= 2) r6++; + r >>= 1; + base_type::ren().blend_hline(x-r6, y, x-r, base_type::line_color(), cover_full); + base_type::ren().blend_hline(x+r, y, x+r6, base_type::line_color(), cover_full); + base_type::ren().blend_vline(x, y-r6, y-r, base_type::line_color(), cover_full); + base_type::ren().blend_vline(x, y+r, y+r6, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //------------------------------------------------------------------------ + void semiellipse_left(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int r8 = r * 4 / 5; + int dy = -r; + int dx = 0; + ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); + do + { + dx += ei.dx(); + dy += ei.dy(); + + base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); + + if(ei.dy() && dx) + { + base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); + } + ++ei; + } + while(dy < r8); + base_type::ren().blend_vline(x+dy, y-dx, y+dx, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void semiellipse_right(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int r8 = r * 4 / 5; + int dy = -r; + int dx = 0; + ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); + do + { + dx += ei.dx(); + dy += ei.dy(); + + base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); + + if(ei.dy() && dx) + { + base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); + } + ++ei; + } + while(dy < r8); + base_type::ren().blend_vline(x-dy, y-dx, y+dx, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void semiellipse_up(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int r8 = r * 4 / 5; + int dy = -r; + int dx = 0; + ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); + do + { + dx += ei.dx(); + dy += ei.dy(); + + base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); + + if(ei.dy() && dx) + { + base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); + } + ++ei; + } + while(dy < r8); + base_type::ren().blend_hline(x-dx, y-dy-1, x+dx, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void semiellipse_down(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int r8 = r * 4 / 5; + int dy = -r; + int dx = 0; + ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); + do + { + dx += ei.dx(); + dy += ei.dy(); + + base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); + + if(ei.dy() && dx) + { + base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); + } + ++ei; + } + while(dy < r8); + base_type::ren().blend_hline(x-dx, y+dy+1, x+dx, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void triangle_left(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int dy = -r; + int dx = 0; + int flip = 0; + int r6 = r * 3 / 5; + do + { + base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); + + if(dx) + { + base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); + } + ++dy; + dx += flip; + flip ^= 1; + } + while(dy < r6); + base_type::ren().blend_vline(x+dy, y-dx, y+dx, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void triangle_right(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int dy = -r; + int dx = 0; + int flip = 0; + int r6 = r * 3 / 5; + do + { + base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); + + if(dx) + { + base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); + } + ++dy; + dx += flip; + flip ^= 1; + } + while(dy < r6); + base_type::ren().blend_vline(x-dy, y-dx, y+dx, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void triangle_up(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int dy = -r; + int dx = 0; + int flip = 0; + int r6 = r * 3 / 5; + do + { + base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); + + if(dx) + { + base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); + } + ++dy; + dx += flip; + flip ^= 1; + } + while(dy < r6); + base_type::ren().blend_hline(x-dx, y-dy, x+dx, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void triangle_down(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int dy = -r; + int dx = 0; + int flip = 0; + int r6 = r * 3 / 5; + do + { + base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); + + if(dx) + { + base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); + } + ++dy; + dx += flip; + flip ^= 1; + } + while(dy < r6); + base_type::ren().blend_hline(x-dx, y+dy, x+dx, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void four_rays(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int dy = -r; + int dx = 0; + int flip = 0; + int r3 = -(r / 3); + do + { + base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); + + if(dx) + { + base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); + base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); + base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); + base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); + } + ++dy; + dx += flip; + flip ^= 1; + } + while(dy <= r3); + base_type::solid_rectangle(x+r3+1, y+r3+1, x-r3-1, y-r3-1); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void cross(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + base_type::ren().blend_vline(x, y-r, y+r, base_type::line_color(), cover_full); + base_type::ren().blend_hline(x-r, y, x+r, base_type::line_color(), cover_full); + } + else + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + } + + + //-------------------------------------------------------------------- + void xing(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) + { + int dy = -r * 7 / 10; + do + { + base_type::ren().blend_pixel(x + dy, y + dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dy, y + dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x + dy, y - dy, base_type::line_color(), cover_full); + base_type::ren().blend_pixel(x - dy, y - dy, base_type::line_color(), cover_full); + ++dy; + } + while(dy < 0); + } + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + + + //-------------------------------------------------------------------- + void dash(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) base_type::ren().blend_hline(x-r, y, x+r, base_type::line_color(), cover_full); + else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + + + //-------------------------------------------------------------------- + void dot(int x, int y, int r) + { + if(visible(x, y, r)) + { + if(r) base_type::solid_ellipse(x, y, r, r); + else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + } + + //-------------------------------------------------------------------- + void pixel(int x, int y, int) + { + base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); + } + + //-------------------------------------------------------------------- + void marker(int x, int y, int r, marker_e type) + { + switch(type) + { + case marker_square: square(x, y, r); break; + case marker_diamond: diamond(x, y, r); break; + case marker_circle: circle(x, y, r); break; + case marker_crossed_circle: crossed_circle(x, y, r); break; + case marker_semiellipse_left: semiellipse_left(x, y, r); break; + case marker_semiellipse_right: semiellipse_right(x, y, r); break; + case marker_semiellipse_up: semiellipse_up(x, y, r); break; + case marker_semiellipse_down: semiellipse_down(x, y, r); break; + case marker_triangle_left: triangle_left(x, y, r); break; + case marker_triangle_right: triangle_right(x, y, r); break; + case marker_triangle_up: triangle_up(x, y, r); break; + case marker_triangle_down: triangle_down(x, y, r); break; + case marker_four_rays: four_rays(x, y, r); break; + case marker_cross: cross(x, y, r); break; + case marker_x: xing(x, y, r); break; + case marker_dash: dash(x, y, r); break; + case marker_dot: dot(x, y, r); break; + case marker_pixel: pixel(x, y, r); break; + case end_of_markers: break; + } + } + + + //-------------------------------------------------------------------- + template + void markers(int n, const T* x, const T* y, T r, marker_e type) + { + if(n <= 0) return; + if(r == 0) + { + do + { + base_type::ren().blend_pixel(int(*x), int(*y), base_type::fill_color(), cover_full); + ++x; + ++y; + } + while(--n); + return; + } + + switch(type) + { + case marker_square: do { square (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_diamond: do { diamond (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_circle: do { circle (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_crossed_circle: do { crossed_circle (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_semiellipse_left: do { semiellipse_left (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_semiellipse_right: do { semiellipse_right(int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_semiellipse_up: do { semiellipse_up (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_semiellipse_down: do { semiellipse_down (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_triangle_left: do { triangle_left (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_triangle_right: do { triangle_right (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_triangle_up: do { triangle_up (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_triangle_down: do { triangle_down (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_four_rays: do { four_rays (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_cross: do { cross (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_x: do { xing (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_dash: do { dash (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_dot: do { dot (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case marker_pixel: do { pixel (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; + case end_of_markers: break; + } + } + + //-------------------------------------------------------------------- + template + void markers(int n, const T* x, const T* y, const T* r, marker_e type) + { + if(n <= 0) return; + switch(type) + { + case marker_square: do { square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_diamond: do { diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_circle: do { circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_crossed_circle: do { crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_semiellipse_left: do { semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_semiellipse_right: do { semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_semiellipse_up: do { semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_semiellipse_down: do { semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_triangle_left: do { triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_triangle_right: do { triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_triangle_up: do { triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_triangle_down: do { triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_four_rays: do { four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_cross: do { cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_x: do { xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_dash: do { dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_dot: do { dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case marker_pixel: do { pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; + case end_of_markers: break; + } + } + + //-------------------------------------------------------------------- + template + void markers(int n, const T* x, const T* y, const T* r, const color_type* fc, marker_e type) + { + if(n <= 0) return; + switch(type) + { + case marker_square: do { base_type::fill_color(*fc); square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_diamond: do { base_type::fill_color(*fc); diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_circle: do { base_type::fill_color(*fc); circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_crossed_circle: do { base_type::fill_color(*fc); crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_semiellipse_left: do { base_type::fill_color(*fc); semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_semiellipse_right: do { base_type::fill_color(*fc); semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_semiellipse_up: do { base_type::fill_color(*fc); semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_semiellipse_down: do { base_type::fill_color(*fc); semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_triangle_left: do { base_type::fill_color(*fc); triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_triangle_right: do { base_type::fill_color(*fc); triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_triangle_up: do { base_type::fill_color(*fc); triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_triangle_down: do { base_type::fill_color(*fc); triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_four_rays: do { base_type::fill_color(*fc); four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_cross: do { base_type::fill_color(*fc); cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_x: do { base_type::fill_color(*fc); xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_dash: do { base_type::fill_color(*fc); dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_dot: do { base_type::fill_color(*fc); dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case marker_pixel: do { base_type::fill_color(*fc); pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; + case end_of_markers: break; + } + } + + //-------------------------------------------------------------------- + template + void markers(int n, const T* x, const T* y, const T* r, const color_type* fc, const color_type* lc, marker_e type) + { + if(n <= 0) return; + switch(type) + { + case marker_square: do { base_type::fill_color(*fc); base_type::line_color(*lc); square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_diamond: do { base_type::fill_color(*fc); base_type::line_color(*lc); diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_circle: do { base_type::fill_color(*fc); base_type::line_color(*lc); circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_crossed_circle: do { base_type::fill_color(*fc); base_type::line_color(*lc); crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_semiellipse_left: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_semiellipse_right: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_semiellipse_up: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_semiellipse_down: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_triangle_left: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_triangle_right: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_triangle_up: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_triangle_down: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_four_rays: do { base_type::fill_color(*fc); base_type::line_color(*lc); four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_cross: do { base_type::fill_color(*fc); base_type::line_color(*lc); cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_x: do { base_type::fill_color(*fc); base_type::line_color(*lc); xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_dash: do { base_type::fill_color(*fc); base_type::line_color(*lc); dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_dot: do { base_type::fill_color(*fc); base_type::line_color(*lc); dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case marker_pixel: do { base_type::fill_color(*fc); base_type::line_color(*lc); pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; + case end_of_markers: break; + } + } + }; + +} + +#endif diff --git a/xs/src/agg/agg_renderer_mclip.h b/xs/src/agg/agg_renderer_mclip.h new file mode 100644 index 0000000000..96a7d4e094 --- /dev/null +++ b/xs/src/agg/agg_renderer_mclip.h @@ -0,0 +1,349 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class renderer_mclip +// +//---------------------------------------------------------------------------- + +#ifndef AGG_RENDERER_MCLIP_INCLUDED +#define AGG_RENDERER_MCLIP_INCLUDED + +#include "agg_basics.h" +#include "agg_array.h" +#include "agg_renderer_base.h" + +namespace agg +{ + + //----------------------------------------------------------renderer_mclip + template class renderer_mclip + { + public: + typedef PixelFormat pixfmt_type; + typedef typename pixfmt_type::color_type color_type; + typedef typename pixfmt_type::row_data row_data; + typedef renderer_base base_ren_type; + + //-------------------------------------------------------------------- + explicit renderer_mclip(pixfmt_type& pixf) : + m_ren(pixf), + m_curr_cb(0), + m_bounds(m_ren.xmin(), m_ren.ymin(), m_ren.xmax(), m_ren.ymax()) + {} + void attach(pixfmt_type& pixf) + { + m_ren.attach(pixf); + reset_clipping(true); + } + + //-------------------------------------------------------------------- + const pixfmt_type& ren() const { return m_ren.ren(); } + pixfmt_type& ren() { return m_ren.ren(); } + + //-------------------------------------------------------------------- + unsigned width() const { return m_ren.width(); } + unsigned height() const { return m_ren.height(); } + + //-------------------------------------------------------------------- + const rect_i& clip_box() const { return m_ren.clip_box(); } + int xmin() const { return m_ren.xmin(); } + int ymin() const { return m_ren.ymin(); } + int xmax() const { return m_ren.xmax(); } + int ymax() const { return m_ren.ymax(); } + + //-------------------------------------------------------------------- + const rect_i& bounding_clip_box() const { return m_bounds; } + int bounding_xmin() const { return m_bounds.x1; } + int bounding_ymin() const { return m_bounds.y1; } + int bounding_xmax() const { return m_bounds.x2; } + int bounding_ymax() const { return m_bounds.y2; } + + //-------------------------------------------------------------------- + void first_clip_box() + { + m_curr_cb = 0; + if(m_clip.size()) + { + const rect_i& cb = m_clip[0]; + m_ren.clip_box_naked(cb.x1, cb.y1, cb.x2, cb.y2); + } + } + + //-------------------------------------------------------------------- + bool next_clip_box() + { + if(++m_curr_cb < m_clip.size()) + { + const rect_i& cb = m_clip[m_curr_cb]; + m_ren.clip_box_naked(cb.x1, cb.y1, cb.x2, cb.y2); + return true; + } + return false; + } + + //-------------------------------------------------------------------- + void reset_clipping(bool visibility) + { + m_ren.reset_clipping(visibility); + m_clip.remove_all(); + m_curr_cb = 0; + m_bounds = m_ren.clip_box(); + } + + //-------------------------------------------------------------------- + void add_clip_box(int x1, int y1, int x2, int y2) + { + rect_i cb(x1, y1, x2, y2); + cb.normalize(); + if(cb.clip(rect_i(0, 0, width() - 1, height() - 1))) + { + m_clip.add(cb); + if(cb.x1 < m_bounds.x1) m_bounds.x1 = cb.x1; + if(cb.y1 < m_bounds.y1) m_bounds.y1 = cb.y1; + if(cb.x2 > m_bounds.x2) m_bounds.x2 = cb.x2; + if(cb.y2 > m_bounds.y2) m_bounds.y2 = cb.y2; + } + } + + //-------------------------------------------------------------------- + void clear(const color_type& c) + { + m_ren.clear(c); + } + + //-------------------------------------------------------------------- + void copy_pixel(int x, int y, const color_type& c) + { + first_clip_box(); + do + { + if(m_ren.inbox(x, y)) + { + m_ren.ren().copy_pixel(x, y, c); + break; + } + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void blend_pixel(int x, int y, const color_type& c, cover_type cover) + { + first_clip_box(); + do + { + if(m_ren.inbox(x, y)) + { + m_ren.ren().blend_pixel(x, y, c, cover); + break; + } + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + color_type pixel(int x, int y) const + { + first_clip_box(); + do + { + if(m_ren.inbox(x, y)) + { + return m_ren.ren().pixel(x, y); + } + } + while(next_clip_box()); + return color_type::no_color(); + } + + //-------------------------------------------------------------------- + void copy_hline(int x1, int y, int x2, const color_type& c) + { + first_clip_box(); + do + { + m_ren.copy_hline(x1, y, x2, c); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void copy_vline(int x, int y1, int y2, const color_type& c) + { + first_clip_box(); + do + { + m_ren.copy_vline(x, y1, y2, c); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void blend_hline(int x1, int y, int x2, + const color_type& c, cover_type cover) + { + first_clip_box(); + do + { + m_ren.blend_hline(x1, y, x2, c, cover); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void blend_vline(int x, int y1, int y2, + const color_type& c, cover_type cover) + { + first_clip_box(); + do + { + m_ren.blend_vline(x, y1, y2, c, cover); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void copy_bar(int x1, int y1, int x2, int y2, const color_type& c) + { + first_clip_box(); + do + { + m_ren.copy_bar(x1, y1, x2, y2, c); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void blend_bar(int x1, int y1, int x2, int y2, + const color_type& c, cover_type cover) + { + first_clip_box(); + do + { + m_ren.blend_bar(x1, y1, x2, y2, c, cover); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, int len, + const color_type& c, const cover_type* covers) + { + first_clip_box(); + do + { + m_ren.blend_solid_hspan(x, y, len, c, covers); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, int len, + const color_type& c, const cover_type* covers) + { + first_clip_box(); + do + { + m_ren.blend_solid_vspan(x, y, len, c, covers); + } + while(next_clip_box()); + } + + + //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, int len, const color_type* colors) + { + first_clip_box(); + do + { + m_ren.copy_color_hspan(x, y, len, colors); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void blend_color_hspan(int x, int y, int len, + const color_type* colors, + const cover_type* covers, + cover_type cover = cover_full) + { + first_clip_box(); + do + { + m_ren.blend_color_hspan(x, y, len, colors, covers, cover); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void blend_color_vspan(int x, int y, int len, + const color_type* colors, + const cover_type* covers, + cover_type cover = cover_full) + { + first_clip_box(); + do + { + m_ren.blend_color_vspan(x, y, len, colors, covers, cover); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + void copy_from(const rendering_buffer& from, + const rect_i* rc=0, + int x_to=0, + int y_to=0) + { + first_clip_box(); + do + { + m_ren.copy_from(from, rc, x_to, y_to); + } + while(next_clip_box()); + } + + //-------------------------------------------------------------------- + template + void blend_from(const SrcPixelFormatRenderer& src, + const rect_i* rect_src_ptr = 0, + int dx = 0, + int dy = 0, + cover_type cover = cover_full) + { + first_clip_box(); + do + { + m_ren.blend_from(src, rect_src_ptr, dx, dy, cover); + } + while(next_clip_box()); + } + + + private: + renderer_mclip(const renderer_mclip&); + const renderer_mclip& + operator = (const renderer_mclip&); + + base_ren_type m_ren; + pod_bvector m_clip; + unsigned m_curr_cb; + rect_i m_bounds; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_renderer_outline_aa.h b/xs/src/agg/agg_renderer_outline_aa.h new file mode 100644 index 0000000000..394c58ca69 --- /dev/null +++ b/xs/src/agg/agg_renderer_outline_aa.h @@ -0,0 +1,1836 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_RENDERER_OUTLINE_AA_INCLUDED +#define AGG_RENDERER_OUTLINE_AA_INCLUDED + +#include "agg_array.h" +#include "agg_math.h" +#include "agg_line_aa_basics.h" +#include "agg_dda_line.h" +#include "agg_ellipse_bresenham.h" +#include "agg_renderer_base.h" +#include "agg_gamma_functions.h" +#include "agg_clip_liang_barsky.h" + +namespace agg +{ + + //===================================================distance_interpolator0 + class distance_interpolator0 + { + public: + //--------------------------------------------------------------------- + distance_interpolator0() {} + distance_interpolator0(int x1, int y1, int x2, int y2, int x, int y) : + m_dx(line_mr(x2) - line_mr(x1)), + m_dy(line_mr(y2) - line_mr(y1)), + m_dist((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy - + (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx) + { + m_dx <<= line_mr_subpixel_shift; + m_dy <<= line_mr_subpixel_shift; + } + + //--------------------------------------------------------------------- + void inc_x() { m_dist += m_dy; } + int dist() const { return m_dist; } + + private: + //--------------------------------------------------------------------- + int m_dx; + int m_dy; + int m_dist; + }; + + //==================================================distance_interpolator00 + class distance_interpolator00 + { + public: + //--------------------------------------------------------------------- + distance_interpolator00() {} + distance_interpolator00(int xc, int yc, + int x1, int y1, int x2, int y2, + int x, int y) : + m_dx1(line_mr(x1) - line_mr(xc)), + m_dy1(line_mr(y1) - line_mr(yc)), + m_dx2(line_mr(x2) - line_mr(xc)), + m_dy2(line_mr(y2) - line_mr(yc)), + m_dist1((line_mr(x + line_subpixel_scale/2) - line_mr(x1)) * m_dy1 - + (line_mr(y + line_subpixel_scale/2) - line_mr(y1)) * m_dx1), + m_dist2((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy2 - + (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx2) + { + m_dx1 <<= line_mr_subpixel_shift; + m_dy1 <<= line_mr_subpixel_shift; + m_dx2 <<= line_mr_subpixel_shift; + m_dy2 <<= line_mr_subpixel_shift; + } + + //--------------------------------------------------------------------- + void inc_x() { m_dist1 += m_dy1; m_dist2 += m_dy2; } + int dist1() const { return m_dist1; } + int dist2() const { return m_dist2; } + + private: + //--------------------------------------------------------------------- + int m_dx1; + int m_dy1; + int m_dx2; + int m_dy2; + int m_dist1; + int m_dist2; + }; + + //===================================================distance_interpolator1 + class distance_interpolator1 + { + public: + //--------------------------------------------------------------------- + distance_interpolator1() {} + distance_interpolator1(int x1, int y1, int x2, int y2, int x, int y) : + m_dx(x2 - x1), + m_dy(y2 - y1), + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + double(y + line_subpixel_scale/2 - y2) * double(m_dx))) + { + m_dx <<= line_subpixel_shift; + m_dy <<= line_subpixel_shift; + } + + //--------------------------------------------------------------------- + void inc_x() { m_dist += m_dy; } + void dec_x() { m_dist -= m_dy; } + void inc_y() { m_dist -= m_dx; } + void dec_y() { m_dist += m_dx; } + + //--------------------------------------------------------------------- + void inc_x(int dy) + { + m_dist += m_dy; + if(dy > 0) m_dist -= m_dx; + if(dy < 0) m_dist += m_dx; + } + + //--------------------------------------------------------------------- + void dec_x(int dy) + { + m_dist -= m_dy; + if(dy > 0) m_dist -= m_dx; + if(dy < 0) m_dist += m_dx; + } + + //--------------------------------------------------------------------- + void inc_y(int dx) + { + m_dist -= m_dx; + if(dx > 0) m_dist += m_dy; + if(dx < 0) m_dist -= m_dy; + } + + void dec_y(int dx) + //--------------------------------------------------------------------- + { + m_dist += m_dx; + if(dx > 0) m_dist += m_dy; + if(dx < 0) m_dist -= m_dy; + } + + //--------------------------------------------------------------------- + int dist() const { return m_dist; } + int dx() const { return m_dx; } + int dy() const { return m_dy; } + + private: + //--------------------------------------------------------------------- + int m_dx; + int m_dy; + int m_dist; + }; + + + + + + //===================================================distance_interpolator2 + class distance_interpolator2 + { + public: + //--------------------------------------------------------------------- + distance_interpolator2() {} + distance_interpolator2(int x1, int y1, int x2, int y2, + int sx, int sy, int x, int y) : + m_dx(x2 - x1), + m_dy(y2 - y1), + m_dx_start(line_mr(sx) - line_mr(x1)), + m_dy_start(line_mr(sy) - line_mr(y1)), + + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + double(y + line_subpixel_scale/2 - y2) * double(m_dx))), + + m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - + (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start) + { + m_dx <<= line_subpixel_shift; + m_dy <<= line_subpixel_shift; + m_dx_start <<= line_mr_subpixel_shift; + m_dy_start <<= line_mr_subpixel_shift; + } + + distance_interpolator2(int x1, int y1, int x2, int y2, + int ex, int ey, int x, int y, int) : + m_dx(x2 - x1), + m_dy(y2 - y1), + m_dx_start(line_mr(ex) - line_mr(x2)), + m_dy_start(line_mr(ey) - line_mr(y2)), + + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + double(y + line_subpixel_scale/2 - y2) * double(m_dx))), + + m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_start - + (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_start) + { + m_dx <<= line_subpixel_shift; + m_dy <<= line_subpixel_shift; + m_dx_start <<= line_mr_subpixel_shift; + m_dy_start <<= line_mr_subpixel_shift; + } + + + //--------------------------------------------------------------------- + void inc_x() { m_dist += m_dy; m_dist_start += m_dy_start; } + void dec_x() { m_dist -= m_dy; m_dist_start -= m_dy_start; } + void inc_y() { m_dist -= m_dx; m_dist_start -= m_dx_start; } + void dec_y() { m_dist += m_dx; m_dist_start += m_dx_start; } + + //--------------------------------------------------------------------- + void inc_x(int dy) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + if(dy > 0) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + } + if(dy < 0) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + } + } + + //--------------------------------------------------------------------- + void dec_x(int dy) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + if(dy > 0) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + } + if(dy < 0) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + } + } + + //--------------------------------------------------------------------- + void inc_y(int dx) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + if(dx > 0) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + } + if(dx < 0) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + } + } + + //--------------------------------------------------------------------- + void dec_y(int dx) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + if(dx > 0) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + } + if(dx < 0) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + } + } + + //--------------------------------------------------------------------- + int dist() const { return m_dist; } + int dist_start() const { return m_dist_start; } + int dist_end() const { return m_dist_start; } + + //--------------------------------------------------------------------- + int dx() const { return m_dx; } + int dy() const { return m_dy; } + int dx_start() const { return m_dx_start; } + int dy_start() const { return m_dy_start; } + int dx_end() const { return m_dx_start; } + int dy_end() const { return m_dy_start; } + + private: + //--------------------------------------------------------------------- + int m_dx; + int m_dy; + int m_dx_start; + int m_dy_start; + + int m_dist; + int m_dist_start; + }; + + + + + + //===================================================distance_interpolator3 + class distance_interpolator3 + { + public: + //--------------------------------------------------------------------- + distance_interpolator3() {} + distance_interpolator3(int x1, int y1, int x2, int y2, + int sx, int sy, int ex, int ey, + int x, int y) : + m_dx(x2 - x1), + m_dy(y2 - y1), + m_dx_start(line_mr(sx) - line_mr(x1)), + m_dy_start(line_mr(sy) - line_mr(y1)), + m_dx_end(line_mr(ex) - line_mr(x2)), + m_dy_end(line_mr(ey) - line_mr(y2)), + + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + double(y + line_subpixel_scale/2 - y2) * double(m_dx))), + + m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - + (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start), + + m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - + (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end) + { + m_dx <<= line_subpixel_shift; + m_dy <<= line_subpixel_shift; + m_dx_start <<= line_mr_subpixel_shift; + m_dy_start <<= line_mr_subpixel_shift; + m_dx_end <<= line_mr_subpixel_shift; + m_dy_end <<= line_mr_subpixel_shift; + } + + //--------------------------------------------------------------------- + void inc_x() { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_end += m_dy_end; } + void dec_x() { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; } + void inc_y() { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; } + void dec_y() { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_end += m_dx_end; } + + //--------------------------------------------------------------------- + void inc_x(int dy) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_end += m_dy_end; + if(dy > 0) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_end -= m_dx_end; + } + if(dy < 0) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_end += m_dx_end; + } + } + + //--------------------------------------------------------------------- + void dec_x(int dy) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_end -= m_dy_end; + if(dy > 0) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_end -= m_dx_end; + } + if(dy < 0) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_end += m_dx_end; + } + } + + //--------------------------------------------------------------------- + void inc_y(int dx) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_end -= m_dx_end; + if(dx > 0) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_end += m_dy_end; + } + if(dx < 0) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_end -= m_dy_end; + } + } + + //--------------------------------------------------------------------- + void dec_y(int dx) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_end += m_dx_end; + if(dx > 0) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_end += m_dy_end; + } + if(dx < 0) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_end -= m_dy_end; + } + } + + //--------------------------------------------------------------------- + int dist() const { return m_dist; } + int dist_start() const { return m_dist_start; } + int dist_end() const { return m_dist_end; } + + //--------------------------------------------------------------------- + int dx() const { return m_dx; } + int dy() const { return m_dy; } + int dx_start() const { return m_dx_start; } + int dy_start() const { return m_dy_start; } + int dx_end() const { return m_dx_end; } + int dy_end() const { return m_dy_end; } + + private: + //--------------------------------------------------------------------- + int m_dx; + int m_dy; + int m_dx_start; + int m_dy_start; + int m_dx_end; + int m_dy_end; + + int m_dist; + int m_dist_start; + int m_dist_end; + }; + + + + + + //================================================line_interpolator_aa_base + template class line_interpolator_aa_base + { + public: + typedef Renderer renderer_type; + typedef typename Renderer::color_type color_type; + + //--------------------------------------------------------------------- + enum max_half_width_e + { + max_half_width = 64 + }; + + //--------------------------------------------------------------------- + line_interpolator_aa_base(renderer_type& ren, line_parameters& lp) : + m_lp(&lp), + m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : + line_dbl_hr(lp.y2 - lp.y1), + lp.vertical ? abs(lp.y2 - lp.y1) : + abs(lp.x2 - lp.x1) + 1), + m_ren(ren), + m_len((lp.vertical == (lp.inc > 0)) ? -lp.len : lp.len), + m_x(lp.x1 >> line_subpixel_shift), + m_y(lp.y1 >> line_subpixel_shift), + m_old_x(m_x), + m_old_y(m_y), + m_count((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) : + abs((lp.x2 >> line_subpixel_shift) - m_x))), + m_width(ren.subpixel_width()), + //m_max_extent(m_width >> (line_subpixel_shift - 2)), + m_max_extent((m_width + line_subpixel_mask) >> line_subpixel_shift), + m_step(0) + { + agg::dda2_line_interpolator li(0, lp.vertical ? + (lp.dy << agg::line_subpixel_shift) : + (lp.dx << agg::line_subpixel_shift), + lp.len); + + unsigned i; + int stop = m_width + line_subpixel_scale * 2; + for(i = 0; i < max_half_width; ++i) + { + m_dist[i] = li.y(); + if(m_dist[i] >= stop) break; + ++li; + } + m_dist[i++] = 0x7FFF0000; + } + + //--------------------------------------------------------------------- + template int step_hor_base(DI& di) + { + ++m_li; + m_x += m_lp->inc; + m_y = (m_lp->y1 + m_li.y()) >> line_subpixel_shift; + + if(m_lp->inc > 0) di.inc_x(m_y - m_old_y); + else di.dec_x(m_y - m_old_y); + + m_old_y = m_y; + + return di.dist() / m_len; + } + + //--------------------------------------------------------------------- + template int step_ver_base(DI& di) + { + ++m_li; + m_y += m_lp->inc; + m_x = (m_lp->x1 + m_li.y()) >> line_subpixel_shift; + + if(m_lp->inc > 0) di.inc_y(m_x - m_old_x); + else di.dec_y(m_x - m_old_x); + + m_old_x = m_x; + + return di.dist() / m_len; + } + + //--------------------------------------------------------------------- + bool vertical() const { return m_lp->vertical; } + int width() const { return m_width; } + int count() const { return m_count; } + + private: + line_interpolator_aa_base(const line_interpolator_aa_base&); + const line_interpolator_aa_base& + operator = (const line_interpolator_aa_base&); + + protected: + line_parameters* m_lp; + dda2_line_interpolator m_li; + renderer_type& m_ren; + int m_len; + int m_x; + int m_y; + int m_old_x; + int m_old_y; + int m_count; + int m_width; + int m_max_extent; + int m_step; + int m_dist[max_half_width + 1]; + cover_type m_covers[max_half_width * 2 + 4]; + }; + + + + + + + + //====================================================line_interpolator_aa0 + template class line_interpolator_aa0 : + public line_interpolator_aa_base + { + public: + typedef Renderer renderer_type; + typedef typename Renderer::color_type color_type; + typedef line_interpolator_aa_base base_type; + + //--------------------------------------------------------------------- + line_interpolator_aa0(renderer_type& ren, line_parameters& lp) : + line_interpolator_aa_base(ren, lp), + m_di(lp.x1, lp.y1, lp.x2, lp.y2, + lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) + { + base_type::m_li.adjust_forward(); + } + + //--------------------------------------------------------------------- + bool step_hor() + { + int dist; + int dy; + int s1 = base_type::step_hor_base(m_di); + cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; + cover_type* p1 = p0; + + *p1++ = (cover_type)base_type::m_ren.cover(s1); + + dy = 1; + while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) + { + *p1++ = (cover_type)base_type::m_ren.cover(dist); + ++dy; + } + + dy = 1; + while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) + { + *--p0 = (cover_type)base_type::m_ren.cover(dist); + ++dy; + } + base_type::m_ren.blend_solid_vspan(base_type::m_x, + base_type::m_y - dy + 1, + unsigned(p1 - p0), + p0); + return ++base_type::m_step < base_type::m_count; + } + + //--------------------------------------------------------------------- + bool step_ver() + { + int dist; + int dx; + int s1 = base_type::step_ver_base(m_di); + cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; + cover_type* p1 = p0; + + *p1++ = (cover_type)base_type::m_ren.cover(s1); + + dx = 1; + while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) + { + *p1++ = (cover_type)base_type::m_ren.cover(dist); + ++dx; + } + + dx = 1; + while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) + { + *--p0 = (cover_type)base_type::m_ren.cover(dist); + ++dx; + } + base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, + base_type::m_y, + unsigned(p1 - p0), + p0); + return ++base_type::m_step < base_type::m_count; + } + + private: + line_interpolator_aa0(const line_interpolator_aa0&); + const line_interpolator_aa0& + operator = (const line_interpolator_aa0&); + + //--------------------------------------------------------------------- + distance_interpolator1 m_di; + }; + + + + + + + //====================================================line_interpolator_aa1 + template class line_interpolator_aa1 : + public line_interpolator_aa_base + { + public: + typedef Renderer renderer_type; + typedef typename Renderer::color_type color_type; + typedef line_interpolator_aa_base base_type; + + //--------------------------------------------------------------------- + line_interpolator_aa1(renderer_type& ren, line_parameters& lp, + int sx, int sy) : + line_interpolator_aa_base(ren, lp), + m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, + lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) + { + int dist1_start; + int dist2_start; + + int npix = 1; + + if(lp.vertical) + { + do + { + --base_type::m_li; + base_type::m_y -= lp.inc; + base_type::m_x = (base_type::m_lp->x1 + base_type::m_li.y()) >> line_subpixel_shift; + + if(lp.inc > 0) m_di.dec_y(base_type::m_x - base_type::m_old_x); + else m_di.inc_y(base_type::m_x - base_type::m_old_x); + + base_type::m_old_x = base_type::m_x; + + dist1_start = dist2_start = m_di.dist_start(); + + int dx = 0; + if(dist1_start < 0) ++npix; + do + { + dist1_start += m_di.dy_start(); + dist2_start -= m_di.dy_start(); + if(dist1_start < 0) ++npix; + if(dist2_start < 0) ++npix; + ++dx; + } + while(base_type::m_dist[dx] <= base_type::m_width); + --base_type::m_step; + if(npix == 0) break; + npix = 0; + } + while(base_type::m_step >= -base_type::m_max_extent); + } + else + { + do + { + --base_type::m_li; + base_type::m_x -= lp.inc; + base_type::m_y = (base_type::m_lp->y1 + base_type::m_li.y()) >> line_subpixel_shift; + + if(lp.inc > 0) m_di.dec_x(base_type::m_y - base_type::m_old_y); + else m_di.inc_x(base_type::m_y - base_type::m_old_y); + + base_type::m_old_y = base_type::m_y; + + dist1_start = dist2_start = m_di.dist_start(); + + int dy = 0; + if(dist1_start < 0) ++npix; + do + { + dist1_start -= m_di.dx_start(); + dist2_start += m_di.dx_start(); + if(dist1_start < 0) ++npix; + if(dist2_start < 0) ++npix; + ++dy; + } + while(base_type::m_dist[dy] <= base_type::m_width); + --base_type::m_step; + if(npix == 0) break; + npix = 0; + } + while(base_type::m_step >= -base_type::m_max_extent); + } + base_type::m_li.adjust_forward(); + } + + //--------------------------------------------------------------------- + bool step_hor() + { + int dist_start; + int dist; + int dy; + int s1 = base_type::step_hor_base(m_di); + + dist_start = m_di.dist_start(); + cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; + cover_type* p1 = p0; + + *p1 = 0; + if(dist_start <= 0) + { + *p1 = (cover_type)base_type::m_ren.cover(s1); + } + ++p1; + + dy = 1; + while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) + { + dist_start -= m_di.dx_start(); + *p1 = 0; + if(dist_start <= 0) + { + *p1 = (cover_type)base_type::m_ren.cover(dist); + } + ++p1; + ++dy; + } + + dy = 1; + dist_start = m_di.dist_start(); + while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) + { + dist_start += m_di.dx_start(); + *--p0 = 0; + if(dist_start <= 0) + { + *p0 = (cover_type)base_type::m_ren.cover(dist); + } + ++dy; + } + + base_type::m_ren.blend_solid_vspan(base_type::m_x, + base_type::m_y - dy + 1, + unsigned(p1 - p0), + p0); + return ++base_type::m_step < base_type::m_count; + } + + //--------------------------------------------------------------------- + bool step_ver() + { + int dist_start; + int dist; + int dx; + int s1 = base_type::step_ver_base(m_di); + cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; + cover_type* p1 = p0; + + dist_start = m_di.dist_start(); + + *p1 = 0; + if(dist_start <= 0) + { + *p1 = (cover_type)base_type::m_ren.cover(s1); + } + ++p1; + + dx = 1; + while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) + { + dist_start += m_di.dy_start(); + *p1 = 0; + if(dist_start <= 0) + { + *p1 = (cover_type)base_type::m_ren.cover(dist); + } + ++p1; + ++dx; + } + + dx = 1; + dist_start = m_di.dist_start(); + while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) + { + dist_start -= m_di.dy_start(); + *--p0 = 0; + if(dist_start <= 0) + { + *p0 = (cover_type)base_type::m_ren.cover(dist); + } + ++dx; + } + base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, + base_type::m_y, + unsigned(p1 - p0), + p0); + return ++base_type::m_step < base_type::m_count; + } + + private: + line_interpolator_aa1(const line_interpolator_aa1&); + const line_interpolator_aa1& + operator = (const line_interpolator_aa1&); + + //--------------------------------------------------------------------- + distance_interpolator2 m_di; + }; + + + + + + + + + + + + + //====================================================line_interpolator_aa2 + template class line_interpolator_aa2 : + public line_interpolator_aa_base + { + public: + typedef Renderer renderer_type; + typedef typename Renderer::color_type color_type; + typedef line_interpolator_aa_base base_type; + + //--------------------------------------------------------------------- + line_interpolator_aa2(renderer_type& ren, line_parameters& lp, + int ex, int ey) : + line_interpolator_aa_base(ren, lp), + m_di(lp.x1, lp.y1, lp.x2, lp.y2, ex, ey, + lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask, + 0) + { + base_type::m_li.adjust_forward(); + base_type::m_step -= base_type::m_max_extent; + } + + //--------------------------------------------------------------------- + bool step_hor() + { + int dist_end; + int dist; + int dy; + int s1 = base_type::step_hor_base(m_di); + cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; + cover_type* p1 = p0; + + dist_end = m_di.dist_end(); + + int npix = 0; + *p1 = 0; + if(dist_end > 0) + { + *p1 = (cover_type)base_type::m_ren.cover(s1); + ++npix; + } + ++p1; + + dy = 1; + while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) + { + dist_end -= m_di.dx_end(); + *p1 = 0; + if(dist_end > 0) + { + *p1 = (cover_type)base_type::m_ren.cover(dist); + ++npix; + } + ++p1; + ++dy; + } + + dy = 1; + dist_end = m_di.dist_end(); + while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) + { + dist_end += m_di.dx_end(); + *--p0 = 0; + if(dist_end > 0) + { + *p0 = (cover_type)base_type::m_ren.cover(dist); + ++npix; + } + ++dy; + } + base_type::m_ren.blend_solid_vspan(base_type::m_x, + base_type::m_y - dy + 1, + unsigned(p1 - p0), + p0); + return npix && ++base_type::m_step < base_type::m_count; + } + + //--------------------------------------------------------------------- + bool step_ver() + { + int dist_end; + int dist; + int dx; + int s1 = base_type::step_ver_base(m_di); + cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; + cover_type* p1 = p0; + + dist_end = m_di.dist_end(); + + int npix = 0; + *p1 = 0; + if(dist_end > 0) + { + *p1 = (cover_type)base_type::m_ren.cover(s1); + ++npix; + } + ++p1; + + dx = 1; + while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) + { + dist_end += m_di.dy_end(); + *p1 = 0; + if(dist_end > 0) + { + *p1 = (cover_type)base_type::m_ren.cover(dist); + ++npix; + } + ++p1; + ++dx; + } + + dx = 1; + dist_end = m_di.dist_end(); + while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) + { + dist_end -= m_di.dy_end(); + *--p0 = 0; + if(dist_end > 0) + { + *p0 = (cover_type)base_type::m_ren.cover(dist); + ++npix; + } + ++dx; + } + base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, + base_type::m_y, + unsigned(p1 - p0), + p0); + return npix && ++base_type::m_step < base_type::m_count; + } + + private: + line_interpolator_aa2(const line_interpolator_aa2&); + const line_interpolator_aa2& + operator = (const line_interpolator_aa2&); + + //--------------------------------------------------------------------- + distance_interpolator2 m_di; + }; + + + + + + + + + + + //====================================================line_interpolator_aa3 + template class line_interpolator_aa3 : + public line_interpolator_aa_base + { + public: + typedef Renderer renderer_type; + typedef typename Renderer::color_type color_type; + typedef line_interpolator_aa_base base_type; + + //--------------------------------------------------------------------- + line_interpolator_aa3(renderer_type& ren, line_parameters& lp, + int sx, int sy, int ex, int ey) : + line_interpolator_aa_base(ren, lp), + m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, + lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) + { + int dist1_start; + int dist2_start; + int npix = 1; + if(lp.vertical) + { + do + { + --base_type::m_li; + base_type::m_y -= lp.inc; + base_type::m_x = (base_type::m_lp->x1 + base_type::m_li.y()) >> line_subpixel_shift; + + if(lp.inc > 0) m_di.dec_y(base_type::m_x - base_type::m_old_x); + else m_di.inc_y(base_type::m_x - base_type::m_old_x); + + base_type::m_old_x = base_type::m_x; + + dist1_start = dist2_start = m_di.dist_start(); + + int dx = 0; + if(dist1_start < 0) ++npix; + do + { + dist1_start += m_di.dy_start(); + dist2_start -= m_di.dy_start(); + if(dist1_start < 0) ++npix; + if(dist2_start < 0) ++npix; + ++dx; + } + while(base_type::m_dist[dx] <= base_type::m_width); + if(npix == 0) break; + npix = 0; + } + while(--base_type::m_step >= -base_type::m_max_extent); + } + else + { + do + { + --base_type::m_li; + base_type::m_x -= lp.inc; + base_type::m_y = (base_type::m_lp->y1 + base_type::m_li.y()) >> line_subpixel_shift; + + if(lp.inc > 0) m_di.dec_x(base_type::m_y - base_type::m_old_y); + else m_di.inc_x(base_type::m_y - base_type::m_old_y); + + base_type::m_old_y = base_type::m_y; + + dist1_start = dist2_start = m_di.dist_start(); + + int dy = 0; + if(dist1_start < 0) ++npix; + do + { + dist1_start -= m_di.dx_start(); + dist2_start += m_di.dx_start(); + if(dist1_start < 0) ++npix; + if(dist2_start < 0) ++npix; + ++dy; + } + while(base_type::m_dist[dy] <= base_type::m_width); + if(npix == 0) break; + npix = 0; + } + while(--base_type::m_step >= -base_type::m_max_extent); + } + base_type::m_li.adjust_forward(); + base_type::m_step -= base_type::m_max_extent; + } + + + //--------------------------------------------------------------------- + bool step_hor() + { + int dist_start; + int dist_end; + int dist; + int dy; + int s1 = base_type::step_hor_base(m_di); + cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; + cover_type* p1 = p0; + + dist_start = m_di.dist_start(); + dist_end = m_di.dist_end(); + + int npix = 0; + *p1 = 0; + if(dist_end > 0) + { + if(dist_start <= 0) + { + *p1 = (cover_type)base_type::m_ren.cover(s1); + } + ++npix; + } + ++p1; + + dy = 1; + while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) + { + dist_start -= m_di.dx_start(); + dist_end -= m_di.dx_end(); + *p1 = 0; + if(dist_end > 0 && dist_start <= 0) + { + *p1 = (cover_type)base_type::m_ren.cover(dist); + ++npix; + } + ++p1; + ++dy; + } + + dy = 1; + dist_start = m_di.dist_start(); + dist_end = m_di.dist_end(); + while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) + { + dist_start += m_di.dx_start(); + dist_end += m_di.dx_end(); + *--p0 = 0; + if(dist_end > 0 && dist_start <= 0) + { + *p0 = (cover_type)base_type::m_ren.cover(dist); + ++npix; + } + ++dy; + } + base_type::m_ren.blend_solid_vspan(base_type::m_x, + base_type::m_y - dy + 1, + unsigned(p1 - p0), + p0); + return npix && ++base_type::m_step < base_type::m_count; + } + + //--------------------------------------------------------------------- + bool step_ver() + { + int dist_start; + int dist_end; + int dist; + int dx; + int s1 = base_type::step_ver_base(m_di); + cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; + cover_type* p1 = p0; + + dist_start = m_di.dist_start(); + dist_end = m_di.dist_end(); + + int npix = 0; + *p1 = 0; + if(dist_end > 0) + { + if(dist_start <= 0) + { + *p1 = (cover_type)base_type::m_ren.cover(s1); + } + ++npix; + } + ++p1; + + dx = 1; + while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) + { + dist_start += m_di.dy_start(); + dist_end += m_di.dy_end(); + *p1 = 0; + if(dist_end > 0 && dist_start <= 0) + { + *p1 = (cover_type)base_type::m_ren.cover(dist); + ++npix; + } + ++p1; + ++dx; + } + + dx = 1; + dist_start = m_di.dist_start(); + dist_end = m_di.dist_end(); + while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) + { + dist_start -= m_di.dy_start(); + dist_end -= m_di.dy_end(); + *--p0 = 0; + if(dist_end > 0 && dist_start <= 0) + { + *p0 = (cover_type)base_type::m_ren.cover(dist); + ++npix; + } + ++dx; + } + base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, + base_type::m_y, + unsigned(p1 - p0), + p0); + return npix && ++base_type::m_step < base_type::m_count; + } + + private: + line_interpolator_aa3(const line_interpolator_aa3&); + const line_interpolator_aa3& + operator = (const line_interpolator_aa3&); + + //--------------------------------------------------------------------- + distance_interpolator3 m_di; + }; + + + + + //==========================================================line_profile_aa + // + // See Implementation agg_line_profile_aa.cpp + // + class line_profile_aa + { + public: + //--------------------------------------------------------------------- + typedef int8u value_type; + enum subpixel_scale_e + { + subpixel_shift = line_subpixel_shift, + subpixel_scale = 1 << subpixel_shift, + subpixel_mask = subpixel_scale - 1 + }; + + enum aa_scale_e + { + aa_shift = 8, + aa_scale = 1 << aa_shift, + aa_mask = aa_scale - 1 + }; + + //--------------------------------------------------------------------- + line_profile_aa() : + m_subpixel_width(0), + m_min_width(1.0), + m_smoother_width(1.0) + { + int i; + for(i = 0; i < aa_scale; i++) m_gamma[i] = (value_type)i; + } + + //--------------------------------------------------------------------- + template + line_profile_aa(double w, const GammaF& gamma_function) : + m_subpixel_width(0), + m_min_width(1.0), + m_smoother_width(1.0) + { + gamma(gamma_function); + width(w); + } + + //--------------------------------------------------------------------- + void min_width(double w) { m_min_width = w; } + void smoother_width(double w) { m_smoother_width = w; } + + //--------------------------------------------------------------------- + template void gamma(const GammaF& gamma_function) + { + int i; + for(i = 0; i < aa_scale; i++) + { + m_gamma[i] = value_type( + uround(gamma_function(double(i) / aa_mask) * aa_mask)); + } + } + + void width(double w); + + unsigned profile_size() const { return m_profile.size(); } + int subpixel_width() const { return m_subpixel_width; } + + //--------------------------------------------------------------------- + double min_width() const { return m_min_width; } + double smoother_width() const { return m_smoother_width; } + + //--------------------------------------------------------------------- + value_type value(int dist) const + { + return m_profile[dist + subpixel_scale*2]; + } + + private: + line_profile_aa(const line_profile_aa&); + const line_profile_aa& operator = (const line_profile_aa&); + + value_type* profile(double w); + void set(double center_width, double smoother_width); + + //--------------------------------------------------------------------- + pod_array m_profile; + value_type m_gamma[aa_scale]; + int m_subpixel_width; + double m_min_width; + double m_smoother_width; + }; + + + //======================================================renderer_outline_aa + template class renderer_outline_aa + { + public: + //--------------------------------------------------------------------- + typedef BaseRenderer base_ren_type; + typedef renderer_outline_aa self_type; + typedef typename base_ren_type::color_type color_type; + + //--------------------------------------------------------------------- + renderer_outline_aa(base_ren_type& ren, line_profile_aa& prof) : + m_ren(&ren), + m_profile(&prof), + m_clip_box(0,0,0,0), + m_clipping(false) + {} + void attach(base_ren_type& ren) { m_ren = &ren; } + + //--------------------------------------------------------------------- + void color(const color_type& c) { m_color = c; } + const color_type& color() const { return m_color; } + + //--------------------------------------------------------------------- + void profile(line_profile_aa& prof) { m_profile = &prof; } + line_profile_aa& profile() const { return *m_profile; } + + //--------------------------------------------------------------------- + int subpixel_width() const { return m_profile->subpixel_width(); } + + //--------------------------------------------------------------------- + void reset_clipping() { m_clipping = false; } + void clip_box(double x1, double y1, double x2, double y2) + { + m_clip_box.x1 = line_coord_sat::conv(x1); + m_clip_box.y1 = line_coord_sat::conv(y1); + m_clip_box.x2 = line_coord_sat::conv(x2); + m_clip_box.y2 = line_coord_sat::conv(y2); + m_clipping = true; + } + + //--------------------------------------------------------------------- + int cover(int d) const + { + return m_profile->value(d); + } + + //------------------------------------------------------------------------- + void blend_solid_hspan(int x, int y, unsigned len, const cover_type* covers) + { + m_ren->blend_solid_hspan(x, y, len, m_color, covers); + } + + //------------------------------------------------------------------------- + void blend_solid_vspan(int x, int y, unsigned len, const cover_type* covers) + { + m_ren->blend_solid_vspan(x, y, len, m_color, covers); + } + + //------------------------------------------------------------------------- + static bool accurate_join_only() { return false; } + + //------------------------------------------------------------------------- + template + void semidot_hline(Cmp cmp, + int xc1, int yc1, int xc2, int yc2, + int x1, int y1, int x2) + { + cover_type covers[line_interpolator_aa_base::max_half_width * 2 + 4]; + cover_type* p0 = covers; + cover_type* p1 = covers; + int x = x1 << line_subpixel_shift; + int y = y1 << line_subpixel_shift; + int w = subpixel_width(); + distance_interpolator0 di(xc1, yc1, xc2, yc2, x, y); + x += line_subpixel_scale/2; + y += line_subpixel_scale/2; + + int x0 = x1; + int dx = x - xc1; + int dy = y - yc1; + do + { + int d = int(fast_sqrt(dx*dx + dy*dy)); + *p1 = 0; + if(cmp(di.dist()) && d <= w) + { + *p1 = (cover_type)cover(d); + } + ++p1; + dx += line_subpixel_scale; + di.inc_x(); + } + while(++x1 <= x2); + m_ren->blend_solid_hspan(x0, y1, + unsigned(p1 - p0), + color(), + p0); + } + + //------------------------------------------------------------------------- + template + void semidot(Cmp cmp, int xc1, int yc1, int xc2, int yc2) + { + if(m_clipping && clipping_flags(xc1, yc1, m_clip_box)) return; + + int r = ((subpixel_width() + line_subpixel_mask) >> line_subpixel_shift); + if(r < 1) r = 1; + ellipse_bresenham_interpolator ei(r, r); + int dx = 0; + int dy = -r; + int dy0 = dy; + int dx0 = dx; + int x = xc1 >> line_subpixel_shift; + int y = yc1 >> line_subpixel_shift; + + do + { + dx += ei.dx(); + dy += ei.dy(); + + if(dy != dy0) + { + semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y+dy0, x+dx0); + semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y-dy0, x+dx0); + } + dx0 = dx; + dy0 = dy; + ++ei; + } + while(dy < 0); + semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y+dy0, x+dx0); + } + + //------------------------------------------------------------------------- + void pie_hline(int xc, int yc, int xp1, int yp1, int xp2, int yp2, + int xh1, int yh1, int xh2) + { + if(m_clipping && clipping_flags(xc, yc, m_clip_box)) return; + + cover_type covers[line_interpolator_aa_base::max_half_width * 2 + 4]; + cover_type* p0 = covers; + cover_type* p1 = covers; + int x = xh1 << line_subpixel_shift; + int y = yh1 << line_subpixel_shift; + int w = subpixel_width(); + + distance_interpolator00 di(xc, yc, xp1, yp1, xp2, yp2, x, y); + x += line_subpixel_scale/2; + y += line_subpixel_scale/2; + + int xh0 = xh1; + int dx = x - xc; + int dy = y - yc; + do + { + int d = int(fast_sqrt(dx*dx + dy*dy)); + *p1 = 0; + if(di.dist1() <= 0 && di.dist2() > 0 && d <= w) + { + *p1 = (cover_type)cover(d); + } + ++p1; + dx += line_subpixel_scale; + di.inc_x(); + } + while(++xh1 <= xh2); + m_ren->blend_solid_hspan(xh0, yh1, + unsigned(p1 - p0), + color(), + p0); + } + + + //------------------------------------------------------------------------- + void pie(int xc, int yc, int x1, int y1, int x2, int y2) + { + int r = ((subpixel_width() + line_subpixel_mask) >> line_subpixel_shift); + if(r < 1) r = 1; + ellipse_bresenham_interpolator ei(r, r); + int dx = 0; + int dy = -r; + int dy0 = dy; + int dx0 = dx; + int x = xc >> line_subpixel_shift; + int y = yc >> line_subpixel_shift; + + do + { + dx += ei.dx(); + dy += ei.dy(); + + if(dy != dy0) + { + pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y+dy0, x+dx0); + pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y-dy0, x+dx0); + } + dx0 = dx; + dy0 = dy; + ++ei; + } + while(dy < 0); + pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y+dy0, x+dx0); + } + + //------------------------------------------------------------------------- + void line0_no_clip(line_parameters& lp) + { + if(lp.len > line_max_length) + { + line_parameters lp1, lp2; + lp.divide(lp1, lp2); + line0_no_clip(lp1); + line0_no_clip(lp2); + return; + } + + line_interpolator_aa0 li(*this, lp); + if(li.count()) + { + if(li.vertical()) + { + while(li.step_ver()); + } + else + { + while(li.step_hor()); + } + } + } + + //------------------------------------------------------------------------- + void line0(line_parameters& lp) + { + if(m_clipping) + { + int x1 = lp.x1; + int y1 = lp.y1; + int x2 = lp.x2; + int y2 = lp.y2; + unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); + if((flags & 4) == 0) + { + if(flags) + { + line_parameters lp2(x1, y1, x2, y2, + uround(calc_distance(x1, y1, x2, y2))); + line0_no_clip(lp2); + } + else + { + line0_no_clip(lp); + } + } + } + else + { + line0_no_clip(lp); + } + } + + //------------------------------------------------------------------------- + void line1_no_clip(line_parameters& lp, int sx, int sy) + { + if(lp.len > line_max_length) + { + line_parameters lp1, lp2; + lp.divide(lp1, lp2); + line1_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1); + line1_no_clip(lp2, lp1.x2 + (lp1.y2 - lp1.y1), lp1.y2 - (lp1.x2 - lp1.x1)); + return; + } + + fix_degenerate_bisectrix_start(lp, &sx, &sy); + line_interpolator_aa1 li(*this, lp, sx, sy); + if(li.vertical()) + { + while(li.step_ver()); + } + else + { + while(li.step_hor()); + } + } + + + //------------------------------------------------------------------------- + void line1(line_parameters& lp, int sx, int sy) + { + if(m_clipping) + { + int x1 = lp.x1; + int y1 = lp.y1; + int x2 = lp.x2; + int y2 = lp.y2; + unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); + if((flags & 4) == 0) + { + if(flags) + { + line_parameters lp2(x1, y1, x2, y2, + uround(calc_distance(x1, y1, x2, y2))); + if(flags & 1) + { + sx = x1 + (y2 - y1); + sy = y1 - (x2 - x1); + } + else + { + while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) + { + sx = (lp.x1 + sx) >> 1; + sy = (lp.y1 + sy) >> 1; + } + } + line1_no_clip(lp2, sx, sy); + } + else + { + line1_no_clip(lp, sx, sy); + } + } + } + else + { + line1_no_clip(lp, sx, sy); + } + } + + //------------------------------------------------------------------------- + void line2_no_clip(line_parameters& lp, int ex, int ey) + { + if(lp.len > line_max_length) + { + line_parameters lp1, lp2; + lp.divide(lp1, lp2); + line2_no_clip(lp1, lp1.x2 + (lp1.y2 - lp1.y1), lp1.y2 - (lp1.x2 - lp1.x1)); + line2_no_clip(lp2, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); + return; + } + + fix_degenerate_bisectrix_end(lp, &ex, &ey); + line_interpolator_aa2 li(*this, lp, ex, ey); + if(li.vertical()) + { + while(li.step_ver()); + } + else + { + while(li.step_hor()); + } + } + + //------------------------------------------------------------------------- + void line2(line_parameters& lp, int ex, int ey) + { + if(m_clipping) + { + int x1 = lp.x1; + int y1 = lp.y1; + int x2 = lp.x2; + int y2 = lp.y2; + unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); + if((flags & 4) == 0) + { + if(flags) + { + line_parameters lp2(x1, y1, x2, y2, + uround(calc_distance(x1, y1, x2, y2))); + if(flags & 2) + { + ex = x2 + (y2 - y1); + ey = y2 - (x2 - x1); + } + else + { + while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) + { + ex = (lp.x2 + ex) >> 1; + ey = (lp.y2 + ey) >> 1; + } + } + line2_no_clip(lp2, ex, ey); + } + else + { + line2_no_clip(lp, ex, ey); + } + } + } + else + { + line2_no_clip(lp, ex, ey); + } + } + + //------------------------------------------------------------------------- + void line3_no_clip(line_parameters& lp, + int sx, int sy, int ex, int ey) + { + if(lp.len > line_max_length) + { + line_parameters lp1, lp2; + lp.divide(lp1, lp2); + int mx = lp1.x2 + (lp1.y2 - lp1.y1); + int my = lp1.y2 - (lp1.x2 - lp1.x1); + line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my); + line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); + return; + } + + fix_degenerate_bisectrix_start(lp, &sx, &sy); + fix_degenerate_bisectrix_end(lp, &ex, &ey); + line_interpolator_aa3 li(*this, lp, sx, sy, ex, ey); + if(li.vertical()) + { + while(li.step_ver()); + } + else + { + while(li.step_hor()); + } + } + + //------------------------------------------------------------------------- + void line3(line_parameters& lp, + int sx, int sy, int ex, int ey) + { + if(m_clipping) + { + int x1 = lp.x1; + int y1 = lp.y1; + int x2 = lp.x2; + int y2 = lp.y2; + unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); + if((flags & 4) == 0) + { + if(flags) + { + line_parameters lp2(x1, y1, x2, y2, + uround(calc_distance(x1, y1, x2, y2))); + if(flags & 1) + { + sx = x1 + (y2 - y1); + sy = y1 - (x2 - x1); + } + else + { + while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) + { + sx = (lp.x1 + sx) >> 1; + sy = (lp.y1 + sy) >> 1; + } + } + if(flags & 2) + { + ex = x2 + (y2 - y1); + ey = y2 - (x2 - x1); + } + else + { + while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) + { + ex = (lp.x2 + ex) >> 1; + ey = (lp.y2 + ey) >> 1; + } + } + line3_no_clip(lp2, sx, sy, ex, ey); + } + else + { + line3_no_clip(lp, sx, sy, ex, ey); + } + } + } + else + { + line3_no_clip(lp, sx, sy, ex, ey); + } + } + + + private: + base_ren_type* m_ren; + line_profile_aa* m_profile; + color_type m_color; + rect_i m_clip_box; + bool m_clipping; + }; + + + +} + +#endif diff --git a/xs/src/agg/agg_renderer_outline_image.h b/xs/src/agg/agg_renderer_outline_image.h new file mode 100644 index 0000000000..2ccc5beddf --- /dev/null +++ b/xs/src/agg/agg_renderer_outline_image.h @@ -0,0 +1,1036 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_RENDERER_OUTLINE_IMAGE_INCLUDED +#define AGG_RENDERER_OUTLINE_IMAGE_INCLUDED + +#include "agg_array.h" +#include "agg_math.h" +#include "agg_line_aa_basics.h" +#include "agg_dda_line.h" +#include "agg_rendering_buffer.h" +#include "agg_clip_liang_barsky.h" + + +namespace agg +{ + //========================================================line_image_scale + template class line_image_scale + { + public: + typedef typename Source::color_type color_type; + + line_image_scale(const Source& src, double height) : + m_source(src), + m_height(height), + m_scale(src.height() / height), + m_scale_inv(height / src.height()) + { + } + + double width() const { return m_source.width(); } + double height() const { return m_height; } + + color_type pixel(int x, int y) const + { + if (m_scale < 1.0) + { + // Interpolate between nearest source pixels. + double src_y = (y + 0.5) * m_scale - 0.5; + int h = m_source.height() - 1; + int y1 = ifloor(src_y); + int y2 = y1 + 1; + rgba pix1 = (y1 < 0) ? rgba::no_color() : rgba(m_source.pixel(x, y1)); + rgba pix2 = (y2 > h) ? rgba::no_color() : rgba(m_source.pixel(x, y2)); + return pix1.gradient(pix2, src_y - y1); + } + else + { + // Average source pixels between y and y+1. + double src_y1 = (y + 0.5) * m_scale - 0.5; + double src_y2 = src_y1 + m_scale; + int h = m_source.height() - 1; + int y1 = ifloor(src_y1); + int y2 = ifloor(src_y2); + rgba c = rgba::no_color(); + if (y1 >= 0) c += rgba(m_source.pixel(x, y1)) *= y1 + 1 - src_y1; + while (++y1 < y2) + { + if (y1 <= h) c += m_source.pixel(x, y1); + } + if (y2 <= h) c += rgba(m_source.pixel(x, y2)) *= src_y2 - y2; + return c *= m_scale_inv; + } + } + + private: + line_image_scale(const line_image_scale&); + const line_image_scale& operator = (const line_image_scale&); + + const Source& m_source; + double m_height; + double m_scale; + double m_scale_inv; + }; + + + + //======================================================line_image_pattern + template class line_image_pattern + { + public: + typedef Filter filter_type; + typedef typename filter_type::color_type color_type; + + //-------------------------------------------------------------------- + line_image_pattern(Filter& filter) : + m_filter(&filter), + m_dilation(filter.dilation() + 1), + m_dilation_hr(m_dilation << line_subpixel_shift), + m_data(), + m_width(0), + m_height(0), + m_width_hr(0), + m_half_height_hr(0), + m_offset_y_hr(0) + { + } + + // Create + //-------------------------------------------------------------------- + template + line_image_pattern(Filter& filter, const Source& src) : + m_filter(&filter), + m_dilation(filter.dilation() + 1), + m_dilation_hr(m_dilation << line_subpixel_shift), + m_data(), + m_width(0), + m_height(0), + m_width_hr(0), + m_half_height_hr(0), + m_offset_y_hr(0) + { + create(src); + } + + // Create + //-------------------------------------------------------------------- + template void create(const Source& src) + { + m_height = uceil(src.height()); + m_width = uceil(src.width()); + m_width_hr = uround(src.width() * line_subpixel_scale); + m_half_height_hr = uround(src.height() * line_subpixel_scale/2); + m_offset_y_hr = m_dilation_hr + m_half_height_hr - line_subpixel_scale/2; + m_half_height_hr += line_subpixel_scale/2; + + m_data.resize((m_width + m_dilation * 2) * (m_height + m_dilation * 2)); + + m_buf.attach(&m_data[0], m_width + m_dilation * 2, + m_height + m_dilation * 2, + m_width + m_dilation * 2); + unsigned x, y; + color_type* d1; + color_type* d2; + for(y = 0; y < m_height; y++) + { + d1 = m_buf.row_ptr(y + m_dilation) + m_dilation; + for(x = 0; x < m_width; x++) + { + *d1++ = src.pixel(x, y); + } + } + + const color_type* s1; + const color_type* s2; + for(y = 0; y < m_dilation; y++) + { + //s1 = m_buf.row_ptr(m_height + m_dilation - 1) + m_dilation; + //s2 = m_buf.row_ptr(m_dilation) + m_dilation; + d1 = m_buf.row_ptr(m_dilation + m_height + y) + m_dilation; + d2 = m_buf.row_ptr(m_dilation - y - 1) + m_dilation; + for(x = 0; x < m_width; x++) + { + //*d1++ = color_type(*s1++, 0); + //*d2++ = color_type(*s2++, 0); + *d1++ = color_type::no_color(); + *d2++ = color_type::no_color(); + } + } + + unsigned h = m_height + m_dilation * 2; + for(y = 0; y < h; y++) + { + s1 = m_buf.row_ptr(y) + m_dilation; + s2 = m_buf.row_ptr(y) + m_dilation + m_width; + d1 = m_buf.row_ptr(y) + m_dilation + m_width; + d2 = m_buf.row_ptr(y) + m_dilation; + + for(x = 0; x < m_dilation; x++) + { + *d1++ = *s1++; + *--d2 = *--s2; + } + } + } + + //-------------------------------------------------------------------- + int pattern_width() const { return m_width_hr; } + int line_width() const { return m_half_height_hr; } + double width() const { return m_height; } + + //-------------------------------------------------------------------- + void pixel(color_type* p, int x, int y) const + { + m_filter->pixel_high_res(m_buf.rows(), + p, + x % m_width_hr + m_dilation_hr, + y + m_offset_y_hr); + } + + //-------------------------------------------------------------------- + const filter_type& filter() const { return *m_filter; } + + private: + line_image_pattern(const line_image_pattern&); + const line_image_pattern& + operator = (const line_image_pattern&); + + protected: + row_ptr_cache m_buf; + const filter_type* m_filter; + unsigned m_dilation; + int m_dilation_hr; + pod_array m_data; + unsigned m_width; + unsigned m_height; + int m_width_hr; + int m_half_height_hr; + int m_offset_y_hr; + }; + + + + + + + //=================================================line_image_pattern_pow2 + template class line_image_pattern_pow2 : + public line_image_pattern + { + public: + typedef Filter filter_type; + typedef typename filter_type::color_type color_type; + typedef line_image_pattern base_type; + + //-------------------------------------------------------------------- + line_image_pattern_pow2(Filter& filter) : + line_image_pattern(filter), m_mask(line_subpixel_mask) {} + + //-------------------------------------------------------------------- + template + line_image_pattern_pow2(Filter& filter, const Source& src) : + line_image_pattern(filter), m_mask(line_subpixel_mask) + { + create(src); + } + + //-------------------------------------------------------------------- + template void create(const Source& src) + { + line_image_pattern::create(src); + m_mask = 1; + while(m_mask < base_type::m_width) + { + m_mask <<= 1; + m_mask |= 1; + } + m_mask <<= line_subpixel_shift - 1; + m_mask |= line_subpixel_mask; + base_type::m_width_hr = m_mask + 1; + } + + //-------------------------------------------------------------------- + void pixel(color_type* p, int x, int y) const + { + base_type::m_filter->pixel_high_res( + base_type::m_buf.rows(), + p, + (x & m_mask) + base_type::m_dilation_hr, + y + base_type::m_offset_y_hr); + } + private: + unsigned m_mask; + }; + + + + + + + + //===================================================distance_interpolator4 + class distance_interpolator4 + { + public: + //--------------------------------------------------------------------- + distance_interpolator4() {} + distance_interpolator4(int x1, int y1, int x2, int y2, + int sx, int sy, int ex, int ey, + int len, double scale, int x, int y) : + m_dx(x2 - x1), + m_dy(y2 - y1), + m_dx_start(line_mr(sx) - line_mr(x1)), + m_dy_start(line_mr(sy) - line_mr(y1)), + m_dx_end(line_mr(ex) - line_mr(x2)), + m_dy_end(line_mr(ey) - line_mr(y2)), + + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + double(y + line_subpixel_scale/2 - y2) * double(m_dx))), + + m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - + (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start), + + m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - + (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end), + m_len(uround(len / scale)) + { + double d = len * scale; + int dx = iround(((x2 - x1) << line_subpixel_shift) / d); + int dy = iround(((y2 - y1) << line_subpixel_shift) / d); + m_dx_pict = -dy; + m_dy_pict = dx; + m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict - + (y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >> + line_subpixel_shift; + + m_dx <<= line_subpixel_shift; + m_dy <<= line_subpixel_shift; + m_dx_start <<= line_mr_subpixel_shift; + m_dy_start <<= line_mr_subpixel_shift; + m_dx_end <<= line_mr_subpixel_shift; + m_dy_end <<= line_mr_subpixel_shift; + } + + //--------------------------------------------------------------------- + void inc_x() + { + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_pict += m_dy_pict; + m_dist_end += m_dy_end; + } + + //--------------------------------------------------------------------- + void dec_x() + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_pict -= m_dy_pict; + m_dist_end -= m_dy_end; + } + + //--------------------------------------------------------------------- + void inc_y() + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_pict -= m_dx_pict; + m_dist_end -= m_dx_end; + } + + //--------------------------------------------------------------------- + void dec_y() + { + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_pict += m_dx_pict; + m_dist_end += m_dx_end; + } + + //--------------------------------------------------------------------- + void inc_x(int dy) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_pict += m_dy_pict; + m_dist_end += m_dy_end; + if(dy > 0) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_pict -= m_dx_pict; + m_dist_end -= m_dx_end; + } + if(dy < 0) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_pict += m_dx_pict; + m_dist_end += m_dx_end; + } + } + + //--------------------------------------------------------------------- + void dec_x(int dy) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_pict -= m_dy_pict; + m_dist_end -= m_dy_end; + if(dy > 0) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_pict -= m_dx_pict; + m_dist_end -= m_dx_end; + } + if(dy < 0) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_pict += m_dx_pict; + m_dist_end += m_dx_end; + } + } + + //--------------------------------------------------------------------- + void inc_y(int dx) + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_pict -= m_dx_pict; + m_dist_end -= m_dx_end; + if(dx > 0) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_pict += m_dy_pict; + m_dist_end += m_dy_end; + } + if(dx < 0) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_pict -= m_dy_pict; + m_dist_end -= m_dy_end; + } + } + + //--------------------------------------------------------------------- + void dec_y(int dx) + { + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_pict += m_dx_pict; + m_dist_end += m_dx_end; + if(dx > 0) + { + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_pict += m_dy_pict; + m_dist_end += m_dy_end; + } + if(dx < 0) + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_pict -= m_dy_pict; + m_dist_end -= m_dy_end; + } + } + + //--------------------------------------------------------------------- + int dist() const { return m_dist; } + int dist_start() const { return m_dist_start; } + int dist_pict() const { return m_dist_pict; } + int dist_end() const { return m_dist_end; } + + //--------------------------------------------------------------------- + int dx() const { return m_dx; } + int dy() const { return m_dy; } + int dx_start() const { return m_dx_start; } + int dy_start() const { return m_dy_start; } + int dx_pict() const { return m_dx_pict; } + int dy_pict() const { return m_dy_pict; } + int dx_end() const { return m_dx_end; } + int dy_end() const { return m_dy_end; } + int len() const { return m_len; } + + private: + //--------------------------------------------------------------------- + int m_dx; + int m_dy; + int m_dx_start; + int m_dy_start; + int m_dx_pict; + int m_dy_pict; + int m_dx_end; + int m_dy_end; + + int m_dist; + int m_dist_start; + int m_dist_pict; + int m_dist_end; + int m_len; + }; + + + + + + //==================================================line_interpolator_image + template class line_interpolator_image + { + public: + typedef Renderer renderer_type; + typedef typename Renderer::color_type color_type; + + //--------------------------------------------------------------------- + enum max_half_width_e + { + max_half_width = 64 + }; + + //--------------------------------------------------------------------- + line_interpolator_image(renderer_type& ren, const line_parameters& lp, + int sx, int sy, int ex, int ey, + int pattern_start, + double scale_x) : + m_lp(lp), + m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : + line_dbl_hr(lp.y2 - lp.y1), + lp.vertical ? abs(lp.y2 - lp.y1) : + abs(lp.x2 - lp.x1) + 1), + m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x, + lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask), + m_ren(ren), + m_x(lp.x1 >> line_subpixel_shift), + m_y(lp.y1 >> line_subpixel_shift), + m_old_x(m_x), + m_old_y(m_y), + m_count((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) : + abs((lp.x2 >> line_subpixel_shift) - m_x))), + m_width(ren.subpixel_width()), + //m_max_extent(m_width >> (line_subpixel_shift - 2)), + m_max_extent((m_width + line_subpixel_scale) >> line_subpixel_shift), + m_start(pattern_start + (m_max_extent + 2) * ren.pattern_width()), + m_step(0) + { + agg::dda2_line_interpolator li(0, lp.vertical ? + (lp.dy << agg::line_subpixel_shift) : + (lp.dx << agg::line_subpixel_shift), + lp.len); + + unsigned i; + int stop = m_width + line_subpixel_scale * 2; + for(i = 0; i < max_half_width; ++i) + { + m_dist_pos[i] = li.y(); + if(m_dist_pos[i] >= stop) break; + ++li; + } + m_dist_pos[i] = 0x7FFF0000; + + int dist1_start; + int dist2_start; + int npix = 1; + + if(lp.vertical) + { + do + { + --m_li; + m_y -= lp.inc; + m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift; + + if(lp.inc > 0) m_di.dec_y(m_x - m_old_x); + else m_di.inc_y(m_x - m_old_x); + + m_old_x = m_x; + + dist1_start = dist2_start = m_di.dist_start(); + + int dx = 0; + if(dist1_start < 0) ++npix; + do + { + dist1_start += m_di.dy_start(); + dist2_start -= m_di.dy_start(); + if(dist1_start < 0) ++npix; + if(dist2_start < 0) ++npix; + ++dx; + } + while(m_dist_pos[dx] <= m_width); + if(npix == 0) break; + + npix = 0; + } + while(--m_step >= -m_max_extent); + } + else + { + do + { + --m_li; + + m_x -= lp.inc; + m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift; + + if(lp.inc > 0) m_di.dec_x(m_y - m_old_y); + else m_di.inc_x(m_y - m_old_y); + + m_old_y = m_y; + + dist1_start = dist2_start = m_di.dist_start(); + + int dy = 0; + if(dist1_start < 0) ++npix; + do + { + dist1_start -= m_di.dx_start(); + dist2_start += m_di.dx_start(); + if(dist1_start < 0) ++npix; + if(dist2_start < 0) ++npix; + ++dy; + } + while(m_dist_pos[dy] <= m_width); + if(npix == 0) break; + + npix = 0; + } + while(--m_step >= -m_max_extent); + } + m_li.adjust_forward(); + m_step -= m_max_extent; + } + + //--------------------------------------------------------------------- + bool step_hor() + { + ++m_li; + m_x += m_lp.inc; + m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift; + + if(m_lp.inc > 0) m_di.inc_x(m_y - m_old_y); + else m_di.dec_x(m_y - m_old_y); + + m_old_y = m_y; + + int s1 = m_di.dist() / m_lp.len; + int s2 = -s1; + + if(m_lp.inc < 0) s1 = -s1; + + int dist_start; + int dist_pict; + int dist_end; + int dy; + int dist; + + dist_start = m_di.dist_start(); + dist_pict = m_di.dist_pict() + m_start; + dist_end = m_di.dist_end(); + color_type* p0 = m_colors + max_half_width + 2; + color_type* p1 = p0; + + int npix = 0; + p1->clear(); + if(dist_end > 0) + { + if(dist_start <= 0) + { + m_ren.pixel(p1, dist_pict, s2); + } + ++npix; + } + ++p1; + + dy = 1; + while((dist = m_dist_pos[dy]) - s1 <= m_width) + { + dist_start -= m_di.dx_start(); + dist_pict -= m_di.dx_pict(); + dist_end -= m_di.dx_end(); + p1->clear(); + if(dist_end > 0 && dist_start <= 0) + { + if(m_lp.inc > 0) dist = -dist; + m_ren.pixel(p1, dist_pict, s2 - dist); + ++npix; + } + ++p1; + ++dy; + } + + dy = 1; + dist_start = m_di.dist_start(); + dist_pict = m_di.dist_pict() + m_start; + dist_end = m_di.dist_end(); + while((dist = m_dist_pos[dy]) + s1 <= m_width) + { + dist_start += m_di.dx_start(); + dist_pict += m_di.dx_pict(); + dist_end += m_di.dx_end(); + --p0; + p0->clear(); + if(dist_end > 0 && dist_start <= 0) + { + if(m_lp.inc > 0) dist = -dist; + m_ren.pixel(p0, dist_pict, s2 + dist); + ++npix; + } + ++dy; + } + m_ren.blend_color_vspan(m_x, + m_y - dy + 1, + unsigned(p1 - p0), + p0); + return npix && ++m_step < m_count; + } + + + + //--------------------------------------------------------------------- + bool step_ver() + { + ++m_li; + m_y += m_lp.inc; + m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift; + + if(m_lp.inc > 0) m_di.inc_y(m_x - m_old_x); + else m_di.dec_y(m_x - m_old_x); + + m_old_x = m_x; + + int s1 = m_di.dist() / m_lp.len; + int s2 = -s1; + + if(m_lp.inc > 0) s1 = -s1; + + int dist_start; + int dist_pict; + int dist_end; + int dist; + int dx; + + dist_start = m_di.dist_start(); + dist_pict = m_di.dist_pict() + m_start; + dist_end = m_di.dist_end(); + color_type* p0 = m_colors + max_half_width + 2; + color_type* p1 = p0; + + int npix = 0; + p1->clear(); + if(dist_end > 0) + { + if(dist_start <= 0) + { + m_ren.pixel(p1, dist_pict, s2); + } + ++npix; + } + ++p1; + + dx = 1; + while((dist = m_dist_pos[dx]) - s1 <= m_width) + { + dist_start += m_di.dy_start(); + dist_pict += m_di.dy_pict(); + dist_end += m_di.dy_end(); + p1->clear(); + if(dist_end > 0 && dist_start <= 0) + { + if(m_lp.inc > 0) dist = -dist; + m_ren.pixel(p1, dist_pict, s2 + dist); + ++npix; + } + ++p1; + ++dx; + } + + dx = 1; + dist_start = m_di.dist_start(); + dist_pict = m_di.dist_pict() + m_start; + dist_end = m_di.dist_end(); + while((dist = m_dist_pos[dx]) + s1 <= m_width) + { + dist_start -= m_di.dy_start(); + dist_pict -= m_di.dy_pict(); + dist_end -= m_di.dy_end(); + --p0; + p0->clear(); + if(dist_end > 0 && dist_start <= 0) + { + if(m_lp.inc > 0) dist = -dist; + m_ren.pixel(p0, dist_pict, s2 - dist); + ++npix; + } + ++dx; + } + m_ren.blend_color_hspan(m_x - dx + 1, + m_y, + unsigned(p1 - p0), + p0); + return npix && ++m_step < m_count; + } + + + //--------------------------------------------------------------------- + int pattern_end() const { return m_start + m_di.len(); } + + //--------------------------------------------------------------------- + bool vertical() const { return m_lp.vertical; } + int width() const { return m_width; } + int count() const { return m_count; } + + private: + line_interpolator_image(const line_interpolator_image&); + const line_interpolator_image& + operator = (const line_interpolator_image&); + + protected: + const line_parameters& m_lp; + dda2_line_interpolator m_li; + distance_interpolator4 m_di; + renderer_type& m_ren; + int m_plen; + int m_x; + int m_y; + int m_old_x; + int m_old_y; + int m_count; + int m_width; + int m_max_extent; + int m_start; + int m_step; + int m_dist_pos[max_half_width + 1]; + color_type m_colors[max_half_width * 2 + 4]; + }; + + + + + + + + + //===================================================renderer_outline_image + template + class renderer_outline_image + { + public: + //--------------------------------------------------------------------- + typedef BaseRenderer base_ren_type; + typedef renderer_outline_image self_type; + typedef typename base_ren_type::color_type color_type; + typedef ImagePattern pattern_type; + + + //--------------------------------------------------------------------- + renderer_outline_image(base_ren_type& ren, pattern_type& patt) : + m_ren(&ren), + m_pattern(&patt), + m_start(0), + m_scale_x(1.0), + m_clip_box(0,0,0,0), + m_clipping(false) + {} + void attach(base_ren_type& ren) { m_ren = &ren; } + + //--------------------------------------------------------------------- + void pattern(pattern_type& p) { m_pattern = &p; } + pattern_type& pattern() const { return *m_pattern; } + + //--------------------------------------------------------------------- + void reset_clipping() { m_clipping = false; } + void clip_box(double x1, double y1, double x2, double y2) + { + m_clip_box.x1 = line_coord_sat::conv(x1); + m_clip_box.y1 = line_coord_sat::conv(y1); + m_clip_box.x2 = line_coord_sat::conv(x2); + m_clip_box.y2 = line_coord_sat::conv(y2); + m_clipping = true; + } + + //--------------------------------------------------------------------- + void scale_x(double s) { m_scale_x = s; } + double scale_x() const { return m_scale_x; } + + //--------------------------------------------------------------------- + void start_x(double s) { m_start = iround(s * line_subpixel_scale); } + double start_x() const { return double(m_start) / line_subpixel_scale; } + + //--------------------------------------------------------------------- + int subpixel_width() const { return m_pattern->line_width(); } + int pattern_width() const { return m_pattern->pattern_width(); } + double width() const { return double(subpixel_width()) / line_subpixel_scale; } + + //------------------------------------------------------------------------- + void pixel(color_type* p, int x, int y) const + { + m_pattern->pixel(p, x, y); + } + + //------------------------------------------------------------------------- + void blend_color_hspan(int x, int y, unsigned len, const color_type* colors) + { + m_ren->blend_color_hspan(x, y, len, colors, 0); + } + + //------------------------------------------------------------------------- + void blend_color_vspan(int x, int y, unsigned len, const color_type* colors) + { + m_ren->blend_color_vspan(x, y, len, colors, 0); + } + + //------------------------------------------------------------------------- + static bool accurate_join_only() { return true; } + + //------------------------------------------------------------------------- + template + void semidot(Cmp, int, int, int, int) + { + } + + //------------------------------------------------------------------------- + void pie(int, int, int, int, int, int) + { + } + + //------------------------------------------------------------------------- + void line0(const line_parameters&) + { + } + + //------------------------------------------------------------------------- + void line1(const line_parameters&, int, int) + { + } + + //------------------------------------------------------------------------- + void line2(const line_parameters&, int, int) + { + } + + //------------------------------------------------------------------------- + void line3_no_clip(const line_parameters& lp, + int sx, int sy, int ex, int ey) + { + if(lp.len > line_max_length) + { + line_parameters lp1, lp2; + lp.divide(lp1, lp2); + int mx = lp1.x2 + (lp1.y2 - lp1.y1); + int my = lp1.y2 - (lp1.x2 - lp1.x1); + line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my); + line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); + return; + } + + fix_degenerate_bisectrix_start(lp, &sx, &sy); + fix_degenerate_bisectrix_end(lp, &ex, &ey); + line_interpolator_image li(*this, lp, + sx, sy, + ex, ey, + m_start, m_scale_x); + if(li.vertical()) + { + while(li.step_ver()); + } + else + { + while(li.step_hor()); + } + m_start += uround(lp.len / m_scale_x); + } + + //------------------------------------------------------------------------- + void line3(const line_parameters& lp, + int sx, int sy, int ex, int ey) + { + if(m_clipping) + { + int x1 = lp.x1; + int y1 = lp.y1; + int x2 = lp.x2; + int y2 = lp.y2; + unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); + int start = m_start; + if((flags & 4) == 0) + { + if(flags) + { + line_parameters lp2(x1, y1, x2, y2, + uround(calc_distance(x1, y1, x2, y2))); + if(flags & 1) + { + m_start += uround(calc_distance(lp.x1, lp.y1, x1, y1) / m_scale_x); + sx = x1 + (y2 - y1); + sy = y1 - (x2 - x1); + } + else + { + while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) + { + sx = (lp.x1 + sx) >> 1; + sy = (lp.y1 + sy) >> 1; + } + } + if(flags & 2) + { + ex = x2 + (y2 - y1); + ey = y2 - (x2 - x1); + } + else + { + while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) + { + ex = (lp.x2 + ex) >> 1; + ey = (lp.y2 + ey) >> 1; + } + } + line3_no_clip(lp2, sx, sy, ex, ey); + } + else + { + line3_no_clip(lp, sx, sy, ex, ey); + } + } + m_start = start + uround(lp.len / m_scale_x); + } + else + { + line3_no_clip(lp, sx, sy, ex, ey); + } + } + + private: + base_ren_type* m_ren; + pattern_type* m_pattern; + int m_start; + double m_scale_x; + rect_i m_clip_box; + bool m_clipping; + }; + + + + + +} + + + +#endif diff --git a/xs/src/agg/agg_renderer_primitives.h b/xs/src/agg/agg_renderer_primitives.h new file mode 100644 index 0000000000..f008db7c94 --- /dev/null +++ b/xs/src/agg/agg_renderer_primitives.h @@ -0,0 +1,224 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class renderer_primitives +// +//---------------------------------------------------------------------------- + +#ifndef AGG_RENDERER_PRIMITIVES_INCLUDED +#define AGG_RENDERER_PRIMITIVES_INCLUDED + +#include "agg_basics.h" +#include "agg_renderer_base.h" +#include "agg_dda_line.h" +#include "agg_ellipse_bresenham.h" + +namespace agg +{ + //-----------------------------------------------------renderer_primitives + template class renderer_primitives + { + public: + typedef BaseRenderer base_ren_type; + typedef typename base_ren_type::color_type color_type; + + //-------------------------------------------------------------------- + explicit renderer_primitives(base_ren_type& ren) : + m_ren(&ren), + m_fill_color(), + m_line_color(), + m_curr_x(0), + m_curr_y(0) + {} + void attach(base_ren_type& ren) { m_ren = &ren; } + + //-------------------------------------------------------------------- + static int coord(double c) + { + return iround(c * line_bresenham_interpolator::subpixel_scale); + } + + //-------------------------------------------------------------------- + void fill_color(const color_type& c) { m_fill_color = c; } + void line_color(const color_type& c) { m_line_color = c; } + const color_type& fill_color() const { return m_fill_color; } + const color_type& line_color() const { return m_line_color; } + + //-------------------------------------------------------------------- + void rectangle(int x1, int y1, int x2, int y2) + { + m_ren->blend_hline(x1, y1, x2-1, m_line_color, cover_full); + m_ren->blend_vline(x2, y1, y2-1, m_line_color, cover_full); + m_ren->blend_hline(x1+1, y2, x2, m_line_color, cover_full); + m_ren->blend_vline(x1, y1+1, y2, m_line_color, cover_full); + } + + //-------------------------------------------------------------------- + void solid_rectangle(int x1, int y1, int x2, int y2) + { + m_ren->blend_bar(x1, y1, x2, y2, m_fill_color, cover_full); + } + + //-------------------------------------------------------------------- + void outlined_rectangle(int x1, int y1, int x2, int y2) + { + rectangle(x1, y1, x2, y2); + m_ren->blend_bar(x1+1, y1+1, x2-1, y2-1, m_fill_color, cover_full); + } + + //-------------------------------------------------------------------- + void ellipse(int x, int y, int rx, int ry) + { + ellipse_bresenham_interpolator ei(rx, ry); + int dx = 0; + int dy = -ry; + do + { + dx += ei.dx(); + dy += ei.dy(); + m_ren->blend_pixel(x + dx, y + dy, m_line_color, cover_full); + m_ren->blend_pixel(x + dx, y - dy, m_line_color, cover_full); + m_ren->blend_pixel(x - dx, y - dy, m_line_color, cover_full); + m_ren->blend_pixel(x - dx, y + dy, m_line_color, cover_full); + ++ei; + } + while(dy < 0); + } + + //-------------------------------------------------------------------- + void solid_ellipse(int x, int y, int rx, int ry) + { + ellipse_bresenham_interpolator ei(rx, ry); + int dx = 0; + int dy = -ry; + int dy0 = dy; + int dx0 = dx; + + do + { + dx += ei.dx(); + dy += ei.dy(); + + if(dy != dy0) + { + m_ren->blend_hline(x-dx0, y+dy0, x+dx0, m_fill_color, cover_full); + m_ren->blend_hline(x-dx0, y-dy0, x+dx0, m_fill_color, cover_full); + } + dx0 = dx; + dy0 = dy; + ++ei; + } + while(dy < 0); + m_ren->blend_hline(x-dx0, y+dy0, x+dx0, m_fill_color, cover_full); + } + + //-------------------------------------------------------------------- + void outlined_ellipse(int x, int y, int rx, int ry) + { + ellipse_bresenham_interpolator ei(rx, ry); + int dx = 0; + int dy = -ry; + + do + { + dx += ei.dx(); + dy += ei.dy(); + + m_ren->blend_pixel(x + dx, y + dy, m_line_color, cover_full); + m_ren->blend_pixel(x + dx, y - dy, m_line_color, cover_full); + m_ren->blend_pixel(x - dx, y - dy, m_line_color, cover_full); + m_ren->blend_pixel(x - dx, y + dy, m_line_color, cover_full); + + if(ei.dy() && dx) + { + m_ren->blend_hline(x-dx+1, y+dy, x+dx-1, m_fill_color, cover_full); + m_ren->blend_hline(x-dx+1, y-dy, x+dx-1, m_fill_color, cover_full); + } + ++ei; + } + while(dy < 0); + } + + //-------------------------------------------------------------------- + void line(int x1, int y1, int x2, int y2, bool last=false) + { + line_bresenham_interpolator li(x1, y1, x2, y2); + + unsigned len = li.len(); + if(len == 0) + { + if(last) + { + m_ren->blend_pixel(li.line_lr(x1), li.line_lr(y1), m_line_color, cover_full); + } + return; + } + + if(last) ++len; + + if(li.is_ver()) + { + do + { + m_ren->blend_pixel(li.x2(), li.y1(), m_line_color, cover_full); + li.vstep(); + } + while(--len); + } + else + { + do + { + m_ren->blend_pixel(li.x1(), li.y2(), m_line_color, cover_full); + li.hstep(); + } + while(--len); + } + } + + //-------------------------------------------------------------------- + void move_to(int x, int y) + { + m_curr_x = x; + m_curr_y = y; + } + + //-------------------------------------------------------------------- + void line_to(int x, int y, bool last=false) + { + line(m_curr_x, m_curr_y, x, y, last); + m_curr_x = x; + m_curr_y = y; + } + + //-------------------------------------------------------------------- + const base_ren_type& ren() const { return *m_ren; } + base_ren_type& ren() { return *m_ren; } + + //-------------------------------------------------------------------- + const rendering_buffer& rbuf() const { return m_ren->rbuf(); } + rendering_buffer& rbuf() { return m_ren->rbuf(); } + + private: + base_ren_type* m_ren; + color_type m_fill_color; + color_type m_line_color; + int m_curr_x; + int m_curr_y; + }; + +} + +#endif diff --git a/xs/src/agg/agg_renderer_raster_text.h b/xs/src/agg/agg_renderer_raster_text.h new file mode 100644 index 0000000000..87b43f9600 --- /dev/null +++ b/xs/src/agg/agg_renderer_raster_text.h @@ -0,0 +1,264 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_RENDERER_RASTER_TEXT_INCLUDED +#define AGG_RENDERER_RASTER_TEXT_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //==============================================renderer_raster_htext_solid + template + class renderer_raster_htext_solid + { + public: + typedef BaseRenderer ren_type; + typedef GlyphGenerator glyph_gen_type; + typedef typename glyph_gen_type::glyph_rect glyph_rect; + typedef typename ren_type::color_type color_type; + + renderer_raster_htext_solid(ren_type& ren, glyph_gen_type& glyph) : + m_ren(&ren), + m_glyph(&glyph) + {} + void attach(ren_type& ren) { m_ren = &ren; } + + //-------------------------------------------------------------------- + void color(const color_type& c) { m_color = c; } + const color_type& color() const { return m_color; } + + //-------------------------------------------------------------------- + template + void render_text(double x, double y, const CharT* str, bool flip=false) + { + glyph_rect r; + while(*str) + { + m_glyph->prepare(&r, x, y, *str, flip); + if(r.x2 >= r.x1) + { + int i; + if(flip) + { + for(i = r.y1; i <= r.y2; i++) + { + m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1), + m_color, + m_glyph->span(r.y2 - i)); + } + } + else + { + for(i = r.y1; i <= r.y2; i++) + { + m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1), + m_color, + m_glyph->span(i - r.y1)); + } + } + } + x += r.dx; + y += r.dy; + ++str; + } + } + + private: + ren_type* m_ren; + glyph_gen_type* m_glyph; + color_type m_color; + }; + + + + //=============================================renderer_raster_vtext_solid + template + class renderer_raster_vtext_solid + { + public: + typedef BaseRenderer ren_type; + typedef GlyphGenerator glyph_gen_type; + typedef typename glyph_gen_type::glyph_rect glyph_rect; + typedef typename ren_type::color_type color_type; + + renderer_raster_vtext_solid(ren_type& ren, glyph_gen_type& glyph) : + m_ren(&ren), + m_glyph(&glyph) + { + } + + //-------------------------------------------------------------------- + void color(const color_type& c) { m_color = c; } + const color_type& color() const { return m_color; } + + //-------------------------------------------------------------------- + template + void render_text(double x, double y, const CharT* str, bool flip=false) + { + glyph_rect r; + while(*str) + { + m_glyph->prepare(&r, x, y, *str, !flip); + if(r.x2 >= r.x1) + { + int i; + if(flip) + { + for(i = r.y1; i <= r.y2; i++) + { + m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1), + m_color, + m_glyph->span(i - r.y1)); + } + } + else + { + for(i = r.y1; i <= r.y2; i++) + { + m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1), + m_color, + m_glyph->span(r.y2 - i)); + } + } + } + x += r.dx; + y += r.dy; + ++str; + } + } + + private: + ren_type* m_ren; + glyph_gen_type* m_glyph; + color_type m_color; + }; + + + + + + + //===================================================renderer_raster_htext + template + class renderer_raster_htext + { + public: + typedef ScanlineRenderer ren_type; + typedef GlyphGenerator glyph_gen_type; + typedef typename glyph_gen_type::glyph_rect glyph_rect; + + class scanline_single_span + { + public: + typedef agg::cover_type cover_type; + + //---------------------------------------------------------------- + struct const_span + { + int x; + unsigned len; + const cover_type* covers; + + const_span() {} + const_span(int x_, unsigned len_, const cover_type* covers_) : + x(x_), len(len_), covers(covers_) + {} + }; + + typedef const const_span* const_iterator; + + //---------------------------------------------------------------- + scanline_single_span(int x, int y, unsigned len, + const cover_type* covers) : + m_y(y), + m_span(x, len, covers) + {} + + //---------------------------------------------------------------- + int y() const { return m_y; } + unsigned num_spans() const { return 1; } + const_iterator begin() const { return &m_span; } + + private: + //---------------------------------------------------------------- + int m_y; + const_span m_span; + }; + + + + //-------------------------------------------------------------------- + renderer_raster_htext(ren_type& ren, glyph_gen_type& glyph) : + m_ren(&ren), + m_glyph(&glyph) + { + } + + + //-------------------------------------------------------------------- + template + void render_text(double x, double y, const CharT* str, bool flip=false) + { + glyph_rect r; + while(*str) + { + m_glyph->prepare(&r, x, y, *str, flip); + if(r.x2 >= r.x1) + { + m_ren->prepare(); + int i; + if(flip) + { + for(i = r.y1; i <= r.y2; i++) + { + m_ren->render( + scanline_single_span(r.x1, + i, + (r.x2 - r.x1 + 1), + m_glyph->span(r.y2 - i))); + } + } + else + { + for(i = r.y1; i <= r.y2; i++) + { + m_ren->render( + scanline_single_span(r.x1, + i, + (r.x2 - r.x1 + 1), + m_glyph->span(i - r.y1))); + } + } + } + x += r.dx; + y += r.dy; + ++str; + } + } + + private: + ren_type* m_ren; + glyph_gen_type* m_glyph; + }; + + + + +} + +#endif + diff --git a/xs/src/agg/agg_renderer_scanline.h b/xs/src/agg/agg_renderer_scanline.h new file mode 100644 index 0000000000..311e9f739a --- /dev/null +++ b/xs/src/agg/agg_renderer_scanline.h @@ -0,0 +1,854 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_RENDERER_SCANLINE_INCLUDED +#define AGG_RENDERER_SCANLINE_INCLUDED + +#include +#include +#include "agg_basics.h" +#include "agg_renderer_base.h" + +namespace agg +{ + + //================================================render_scanline_aa_solid + template + void render_scanline_aa_solid(const Scanline& sl, + BaseRenderer& ren, + const ColorT& color) + { + int y = sl.y(); + unsigned num_spans = sl.num_spans(); + typename Scanline::const_iterator span = sl.begin(); + + for(;;) + { + int x = span->x; + if(span->len > 0) + { + ren.blend_solid_hspan(x, y, (unsigned)span->len, + color, + span->covers); + } + else + { + ren.blend_hline(x, y, (unsigned)(x - span->len - 1), + color, + *(span->covers)); + } + if(--num_spans == 0) break; + ++span; + } + } + + //===============================================render_scanlines_aa_solid + template + void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl, + BaseRenderer& ren, const ColorT& color) + { + if(ras.rewind_scanlines()) + { + // Explicitly convert "color" to the BaseRenderer color type. + // For example, it can be called with color type "rgba", while + // "rgba8" is needed. Otherwise it will be implicitly + // converted in the loop many times. + //---------------------- + typename BaseRenderer::color_type ren_color = color; + + sl.reset(ras.min_x(), ras.max_x()); + while(ras.sweep_scanline(sl)) + { + //render_scanline_aa_solid(sl, ren, ren_color); + + // This code is equivalent to the above call (copy/paste). + // It's just a "manual" optimization for old compilers, + // like Microsoft Visual C++ v6.0 + //------------------------------- + int y = sl.y(); + unsigned num_spans = sl.num_spans(); + typename Scanline::const_iterator span = sl.begin(); + + for(;;) + { + int x = span->x; + if(span->len > 0) + { + ren.blend_solid_hspan(x, y, (unsigned)span->len, + ren_color, + span->covers); + } + else + { + ren.blend_hline(x, y, (unsigned)(x - span->len - 1), + ren_color, + *(span->covers)); + } + if(--num_spans == 0) break; + ++span; + } + } + } + } + + //==============================================renderer_scanline_aa_solid + template class renderer_scanline_aa_solid + { + public: + typedef BaseRenderer base_ren_type; + typedef typename base_ren_type::color_type color_type; + + //-------------------------------------------------------------------- + renderer_scanline_aa_solid() : m_ren(0) {} + explicit renderer_scanline_aa_solid(base_ren_type& ren) : m_ren(&ren) {} + void attach(base_ren_type& ren) + { + m_ren = &ren; + } + + //-------------------------------------------------------------------- + void color(const color_type& c) { m_color = c; } + const color_type& color() const { return m_color; } + + //-------------------------------------------------------------------- + void prepare() {} + + //-------------------------------------------------------------------- + template void render(const Scanline& sl) + { + render_scanline_aa_solid(sl, *m_ren, m_color); + } + + private: + base_ren_type* m_ren; + color_type m_color; + }; + + + + + + + + + + + + + + //======================================================render_scanline_aa + template + void render_scanline_aa(const Scanline& sl, BaseRenderer& ren, + SpanAllocator& alloc, SpanGenerator& span_gen) + { + int y = sl.y(); + + unsigned num_spans = sl.num_spans(); + typename Scanline::const_iterator span = sl.begin(); + for(;;) + { + int x = span->x; + int len = span->len; + const typename Scanline::cover_type* covers = span->covers; + + if(len < 0) len = -len; + typename BaseRenderer::color_type* colors = alloc.allocate(len); + span_gen.generate(colors, x, y, len); + ren.blend_color_hspan(x, y, len, colors, + (span->len < 0) ? 0 : covers, *covers); + + if(--num_spans == 0) break; + ++span; + } + } + + //=====================================================render_scanlines_aa + template + void render_scanlines_aa(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, + SpanAllocator& alloc, SpanGenerator& span_gen) + { + if(ras.rewind_scanlines()) + { + sl.reset(ras.min_x(), ras.max_x()); + span_gen.prepare(); + while(ras.sweep_scanline(sl)) + { + render_scanline_aa(sl, ren, alloc, span_gen); + } + } + } + + //====================================================renderer_scanline_aa + template + class renderer_scanline_aa + { + public: + typedef BaseRenderer base_ren_type; + typedef SpanAllocator alloc_type; + typedef SpanGenerator span_gen_type; + + //-------------------------------------------------------------------- + renderer_scanline_aa() : m_ren(0), m_alloc(0), m_span_gen(0) {} + renderer_scanline_aa(base_ren_type& ren, + alloc_type& alloc, + span_gen_type& span_gen) : + m_ren(&ren), + m_alloc(&alloc), + m_span_gen(&span_gen) + {} + void attach(base_ren_type& ren, + alloc_type& alloc, + span_gen_type& span_gen) + { + m_ren = &ren; + m_alloc = &alloc; + m_span_gen = &span_gen; + } + + //-------------------------------------------------------------------- + void prepare() { m_span_gen->prepare(); } + + //-------------------------------------------------------------------- + template void render(const Scanline& sl) + { + render_scanline_aa(sl, *m_ren, *m_alloc, *m_span_gen); + } + + private: + base_ren_type* m_ren; + alloc_type* m_alloc; + span_gen_type* m_span_gen; + }; + + + + + + + //===============================================render_scanline_bin_solid + template + void render_scanline_bin_solid(const Scanline& sl, + BaseRenderer& ren, + const ColorT& color) + { + unsigned num_spans = sl.num_spans(); + typename Scanline::const_iterator span = sl.begin(); + for(;;) + { + ren.blend_hline(span->x, + sl.y(), + span->x - 1 + ((span->len < 0) ? + -span->len : + span->len), + color, + cover_full); + if(--num_spans == 0) break; + ++span; + } + } + + //==============================================render_scanlines_bin_solid + template + void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl, + BaseRenderer& ren, const ColorT& color) + { + if(ras.rewind_scanlines()) + { + // Explicitly convert "color" to the BaseRenderer color type. + // For example, it can be called with color type "rgba", while + // "rgba8" is needed. Otherwise it will be implicitly + // converted in the loop many times. + //---------------------- + typename BaseRenderer::color_type ren_color(color); + + sl.reset(ras.min_x(), ras.max_x()); + while(ras.sweep_scanline(sl)) + { + //render_scanline_bin_solid(sl, ren, ren_color); + + // This code is equivalent to the above call (copy/paste). + // It's just a "manual" optimization for old compilers, + // like Microsoft Visual C++ v6.0 + //------------------------------- + unsigned num_spans = sl.num_spans(); + typename Scanline::const_iterator span = sl.begin(); + for(;;) + { + ren.blend_hline(span->x, + sl.y(), + span->x - 1 + ((span->len < 0) ? + -span->len : + span->len), + ren_color, + cover_full); + if(--num_spans == 0) break; + ++span; + } + } + } + } + + //=============================================renderer_scanline_bin_solid + template class renderer_scanline_bin_solid + { + public: + typedef BaseRenderer base_ren_type; + typedef typename base_ren_type::color_type color_type; + + //-------------------------------------------------------------------- + renderer_scanline_bin_solid() : m_ren(0) {} + explicit renderer_scanline_bin_solid(base_ren_type& ren) : m_ren(&ren) {} + void attach(base_ren_type& ren) + { + m_ren = &ren; + } + + //-------------------------------------------------------------------- + void color(const color_type& c) { m_color = c; } + const color_type& color() const { return m_color; } + + //-------------------------------------------------------------------- + void prepare() {} + + //-------------------------------------------------------------------- + template void render(const Scanline& sl) + { + render_scanline_bin_solid(sl, *m_ren, m_color); + } + + private: + base_ren_type* m_ren; + color_type m_color; + }; + + + + + + + + + //======================================================render_scanline_bin + template + void render_scanline_bin(const Scanline& sl, BaseRenderer& ren, + SpanAllocator& alloc, SpanGenerator& span_gen) + { + int y = sl.y(); + + unsigned num_spans = sl.num_spans(); + typename Scanline::const_iterator span = sl.begin(); + for(;;) + { + int x = span->x; + int len = span->len; + if(len < 0) len = -len; + typename BaseRenderer::color_type* colors = alloc.allocate(len); + span_gen.generate(colors, x, y, len); + ren.blend_color_hspan(x, y, len, colors, 0, cover_full); + if(--num_spans == 0) break; + ++span; + } + } + + //=====================================================render_scanlines_bin + template + void render_scanlines_bin(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, + SpanAllocator& alloc, SpanGenerator& span_gen) + { + if(ras.rewind_scanlines()) + { + sl.reset(ras.min_x(), ras.max_x()); + span_gen.prepare(); + while(ras.sweep_scanline(sl)) + { + render_scanline_bin(sl, ren, alloc, span_gen); + } + } + } + + //====================================================renderer_scanline_bin + template + class renderer_scanline_bin + { + public: + typedef BaseRenderer base_ren_type; + typedef SpanAllocator alloc_type; + typedef SpanGenerator span_gen_type; + + //-------------------------------------------------------------------- + renderer_scanline_bin() : m_ren(0), m_alloc(0), m_span_gen(0) {} + renderer_scanline_bin(base_ren_type& ren, + alloc_type& alloc, + span_gen_type& span_gen) : + m_ren(&ren), + m_alloc(&alloc), + m_span_gen(&span_gen) + {} + void attach(base_ren_type& ren, + alloc_type& alloc, + span_gen_type& span_gen) + { + m_ren = &ren; + m_alloc = &alloc; + m_span_gen = &span_gen; + } + + //-------------------------------------------------------------------- + void prepare() { m_span_gen->prepare(); } + + //-------------------------------------------------------------------- + template void render(const Scanline& sl) + { + render_scanline_bin(sl, *m_ren, *m_alloc, *m_span_gen); + } + + private: + base_ren_type* m_ren; + alloc_type* m_alloc; + span_gen_type* m_span_gen; + }; + + + + + + + + + + + //========================================================render_scanlines + template + void render_scanlines(Rasterizer& ras, Scanline& sl, Renderer& ren) + { + if(ras.rewind_scanlines()) + { + sl.reset(ras.min_x(), ras.max_x()); + ren.prepare(); + while(ras.sweep_scanline(sl)) + { + ren.render(sl); + } + } + } + + //========================================================render_all_paths + template + void render_all_paths(Rasterizer& ras, + Scanline& sl, + Renderer& r, + VertexSource& vs, + const ColorStorage& as, + const PathId& path_id, + unsigned num_paths) + { + for(unsigned i = 0; i < num_paths; i++) + { + ras.reset(); + ras.add_path(vs, path_id[i]); + r.color(as[i]); + render_scanlines(ras, sl, r); + } + } + + + + + + + //=============================================render_scanlines_compound + template + void render_scanlines_compound(Rasterizer& ras, + ScanlineAA& sl_aa, + ScanlineBin& sl_bin, + BaseRenderer& ren, + SpanAllocator& alloc, + StyleHandler& sh) + { + if(ras.rewind_scanlines()) + { + int min_x = ras.min_x(); + int len = ras.max_x() - min_x + 2; + sl_aa.reset(min_x, ras.max_x()); + sl_bin.reset(min_x, ras.max_x()); + + typedef typename BaseRenderer::color_type color_type; + color_type* color_span = alloc.allocate(len * 2); + color_type* mix_buffer = color_span + len; + unsigned num_spans; + + unsigned num_styles; + unsigned style; + bool solid; + while((num_styles = ras.sweep_styles()) > 0) + { + typename ScanlineAA::const_iterator span_aa; + if(num_styles == 1) + { + // Optimization for a single style. Happens often + //------------------------- + if(ras.sweep_scanline(sl_aa, 0)) + { + style = ras.style(0); + if(sh.is_solid(style)) + { + // Just solid fill + //----------------------- + render_scanline_aa_solid(sl_aa, ren, sh.color(style)); + } + else + { + // Arbitrary span generator + //----------------------- + span_aa = sl_aa.begin(); + num_spans = sl_aa.num_spans(); + for(;;) + { + len = span_aa->len; + sh.generate_span(color_span, + span_aa->x, + sl_aa.y(), + len, + style); + + ren.blend_color_hspan(span_aa->x, + sl_aa.y(), + span_aa->len, + color_span, + span_aa->covers); + if(--num_spans == 0) break; + ++span_aa; + } + } + } + } + else + { + if(ras.sweep_scanline(sl_bin, -1)) + { + // Clear the spans of the mix_buffer + //-------------------- + typename ScanlineBin::const_iterator span_bin = sl_bin.begin(); + num_spans = sl_bin.num_spans(); + for(;;) + { + memset(mix_buffer + span_bin->x - min_x, + 0, + span_bin->len * sizeof(color_type)); + + if(--num_spans == 0) break; + ++span_bin; + } + + unsigned i; + for(i = 0; i < num_styles; i++) + { + style = ras.style(i); + solid = sh.is_solid(style); + + if(ras.sweep_scanline(sl_aa, i)) + { + color_type* colors; + color_type* cspan; + typename ScanlineAA::cover_type* covers; + span_aa = sl_aa.begin(); + num_spans = sl_aa.num_spans(); + if(solid) + { + // Just solid fill + //----------------------- + for(;;) + { + color_type c = sh.color(style); + len = span_aa->len; + colors = mix_buffer + span_aa->x - min_x; + covers = span_aa->covers; + do + { + if(*covers == cover_full) + { + *colors = c; + } + else + { + colors->add(c, *covers); + } + ++colors; + ++covers; + } + while(--len); + if(--num_spans == 0) break; + ++span_aa; + } + } + else + { + // Arbitrary span generator + //----------------------- + for(;;) + { + len = span_aa->len; + colors = mix_buffer + span_aa->x - min_x; + cspan = color_span; + sh.generate_span(cspan, + span_aa->x, + sl_aa.y(), + len, + style); + covers = span_aa->covers; + do + { + if(*covers == cover_full) + { + *colors = *cspan; + } + else + { + colors->add(*cspan, *covers); + } + ++cspan; + ++colors; + ++covers; + } + while(--len); + if(--num_spans == 0) break; + ++span_aa; + } + } + } + } + + // Emit the blended result as a color hspan + //------------------------- + span_bin = sl_bin.begin(); + num_spans = sl_bin.num_spans(); + for(;;) + { + ren.blend_color_hspan(span_bin->x, + sl_bin.y(), + span_bin->len, + mix_buffer + span_bin->x - min_x, + 0, + cover_full); + if(--num_spans == 0) break; + ++span_bin; + } + } // if(ras.sweep_scanline(sl_bin, -1)) + } // if(num_styles == 1) ... else + } // while((num_styles = ras.sweep_styles()) > 0) + } // if(ras.rewind_scanlines()) + } + + //=======================================render_scanlines_compound_layered + template + void render_scanlines_compound_layered(Rasterizer& ras, + ScanlineAA& sl_aa, + BaseRenderer& ren, + SpanAllocator& alloc, + StyleHandler& sh) + { + if(ras.rewind_scanlines()) + { + int min_x = ras.min_x(); + int len = ras.max_x() - min_x + 2; + sl_aa.reset(min_x, ras.max_x()); + + typedef typename BaseRenderer::color_type color_type; + color_type* color_span = alloc.allocate(len * 2); + color_type* mix_buffer = color_span + len; + cover_type* cover_buffer = ras.allocate_cover_buffer(len); + unsigned num_spans; + + unsigned num_styles; + unsigned style; + bool solid; + while((num_styles = ras.sweep_styles()) > 0) + { + typename ScanlineAA::const_iterator span_aa; + if(num_styles == 1) + { + // Optimization for a single style. Happens often + //------------------------- + if(ras.sweep_scanline(sl_aa, 0)) + { + style = ras.style(0); + if(sh.is_solid(style)) + { + // Just solid fill + //----------------------- + render_scanline_aa_solid(sl_aa, ren, sh.color(style)); + } + else + { + // Arbitrary span generator + //----------------------- + span_aa = sl_aa.begin(); + num_spans = sl_aa.num_spans(); + for(;;) + { + len = span_aa->len; + sh.generate_span(color_span, + span_aa->x, + sl_aa.y(), + len, + style); + + ren.blend_color_hspan(span_aa->x, + sl_aa.y(), + span_aa->len, + color_span, + span_aa->covers); + if(--num_spans == 0) break; + ++span_aa; + } + } + } + } + else + { + int sl_start = ras.scanline_start(); + unsigned sl_len = ras.scanline_length(); + + if(sl_len) + { + memset(mix_buffer + sl_start - min_x, + 0, + sl_len * sizeof(color_type)); + + memset(cover_buffer + sl_start - min_x, + 0, + sl_len * sizeof(cover_type)); + + int sl_y = std::numeric_limits::max(); + unsigned i; + for(i = 0; i < num_styles; i++) + { + style = ras.style(i); + solid = sh.is_solid(style); + + if(ras.sweep_scanline(sl_aa, i)) + { + unsigned cover; + color_type* colors; + color_type* cspan; + cover_type* src_covers; + cover_type* dst_covers; + span_aa = sl_aa.begin(); + num_spans = sl_aa.num_spans(); + sl_y = sl_aa.y(); + if(solid) + { + // Just solid fill + //----------------------- + for(;;) + { + color_type c = sh.color(style); + len = span_aa->len; + colors = mix_buffer + span_aa->x - min_x; + src_covers = span_aa->covers; + dst_covers = cover_buffer + span_aa->x - min_x; + do + { + cover = *src_covers; + if(*dst_covers + cover > cover_full) + { + cover = cover_full - *dst_covers; + } + if(cover) + { + colors->add(c, cover); + *dst_covers += cover; + } + ++colors; + ++src_covers; + ++dst_covers; + } + while(--len); + if(--num_spans == 0) break; + ++span_aa; + } + } + else + { + // Arbitrary span generator + //----------------------- + for(;;) + { + len = span_aa->len; + colors = mix_buffer + span_aa->x - min_x; + cspan = color_span; + sh.generate_span(cspan, + span_aa->x, + sl_aa.y(), + len, + style); + src_covers = span_aa->covers; + dst_covers = cover_buffer + span_aa->x - min_x; + do + { + cover = *src_covers; + if(*dst_covers + cover > cover_full) + { + cover = cover_full - *dst_covers; + } + if(cover) + { + colors->add(*cspan, cover); + *dst_covers += cover; + } + ++cspan; + ++colors; + ++src_covers; + ++dst_covers; + } + while(--len); + if(--num_spans == 0) break; + ++span_aa; + } + } + } + } + ren.blend_color_hspan(sl_start, + sl_y, + sl_len, + mix_buffer + sl_start - min_x, + 0, + cover_full); + } //if(sl_len) + } //if(num_styles == 1) ... else + } //while((num_styles = ras.sweep_styles()) > 0) + } //if(ras.rewind_scanlines()) + } + + +} + +#endif diff --git a/xs/src/agg/agg_rendering_buffer.h b/xs/src/agg/agg_rendering_buffer.h new file mode 100644 index 0000000000..0eff6ff27d --- /dev/null +++ b/xs/src/agg/agg_rendering_buffer.h @@ -0,0 +1,300 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class rendering_buffer +// +//---------------------------------------------------------------------------- + +#ifndef AGG_RENDERING_BUFFER_INCLUDED +#define AGG_RENDERING_BUFFER_INCLUDED + +#include "agg_array.h" + +namespace agg +{ + + //===========================================================row_accessor + template class row_accessor + { + public: + typedef const_row_info row_data; + + //------------------------------------------------------------------- + row_accessor() : + m_buf(0), + m_start(0), + m_width(0), + m_height(0), + m_stride(0) + { + } + + //-------------------------------------------------------------------- + row_accessor(T* buf, unsigned width, unsigned height, int stride) : + m_buf(0), + m_start(0), + m_width(0), + m_height(0), + m_stride(0) + { + attach(buf, width, height, stride); + } + + + //-------------------------------------------------------------------- + void attach(T* buf, unsigned width, unsigned height, int stride) + { + m_buf = m_start = buf; + m_width = width; + m_height = height; + m_stride = stride; + if(stride < 0) + { + m_start = m_buf - int(height - 1) * stride; + } + } + + //-------------------------------------------------------------------- + AGG_INLINE T* buf() { return m_buf; } + AGG_INLINE const T* buf() const { return m_buf; } + AGG_INLINE unsigned width() const { return m_width; } + AGG_INLINE unsigned height() const { return m_height; } + AGG_INLINE int stride() const { return m_stride; } + AGG_INLINE unsigned stride_abs() const + { + return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride); + } + + //-------------------------------------------------------------------- + AGG_INLINE T* row_ptr(int, int y, unsigned) + { + return m_start + y * m_stride; + } + AGG_INLINE T* row_ptr(int y) { return m_start + y * m_stride; } + AGG_INLINE const T* row_ptr(int y) const { return m_start + y * m_stride; } + AGG_INLINE row_data row (int y) const + { + return row_data(0, m_width-1, row_ptr(y)); + } + + //-------------------------------------------------------------------- + template + void copy_from(const RenBuf& src) + { + unsigned h = height(); + if(src.height() < h) h = src.height(); + + unsigned l = stride_abs(); + if(src.stride_abs() < l) l = src.stride_abs(); + + l *= sizeof(T); + + unsigned y; + unsigned w = width(); + for (y = 0; y < h; y++) + { + memcpy(row_ptr(0, y, w), src.row_ptr(y), l); + } + } + + //-------------------------------------------------------------------- + void clear(T value) + { + unsigned y; + unsigned w = width(); + unsigned stride = stride_abs(); + for(y = 0; y < height(); y++) + { + T* p = row_ptr(0, y, w); + unsigned x; + for(x = 0; x < stride; x++) + { + *p++ = value; + } + } + } + + private: + //-------------------------------------------------------------------- + T* m_buf; // Pointer to renrdering buffer + T* m_start; // Pointer to first pixel depending on stride + unsigned m_width; // Width in pixels + unsigned m_height; // Height in pixels + int m_stride; // Number of bytes per row. Can be < 0 + }; + + + + + //==========================================================row_ptr_cache + template class row_ptr_cache + { + public: + typedef const_row_info row_data; + + //------------------------------------------------------------------- + row_ptr_cache() : + m_buf(0), + m_rows(), + m_width(0), + m_height(0), + m_stride(0) + { + } + + //-------------------------------------------------------------------- + row_ptr_cache(T* buf, unsigned width, unsigned height, int stride) : + m_buf(0), + m_rows(), + m_width(0), + m_height(0), + m_stride(0) + { + attach(buf, width, height, stride); + } + + //-------------------------------------------------------------------- + void attach(T* buf, unsigned width, unsigned height, int stride) + { + m_buf = buf; + m_width = width; + m_height = height; + m_stride = stride; + if(height > m_rows.size()) + { + m_rows.resize(height); + } + + T* row_ptr = m_buf; + + if(stride < 0) + { + row_ptr = m_buf - int(height - 1) * stride; + } + + T** rows = &m_rows[0]; + + while(height--) + { + *rows++ = row_ptr; + row_ptr += stride; + } + } + + //-------------------------------------------------------------------- + AGG_INLINE T* buf() { return m_buf; } + AGG_INLINE const T* buf() const { return m_buf; } + AGG_INLINE unsigned width() const { return m_width; } + AGG_INLINE unsigned height() const { return m_height; } + AGG_INLINE int stride() const { return m_stride; } + AGG_INLINE unsigned stride_abs() const + { + return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride); + } + + //-------------------------------------------------------------------- + AGG_INLINE T* row_ptr(int, int y, unsigned) + { + return m_rows[y]; + } + AGG_INLINE T* row_ptr(int y) { return m_rows[y]; } + AGG_INLINE const T* row_ptr(int y) const { return m_rows[y]; } + AGG_INLINE row_data row (int y) const + { + return row_data(0, m_width-1, m_rows[y]); + } + + //-------------------------------------------------------------------- + T const* const* rows() const { return &m_rows[0]; } + + //-------------------------------------------------------------------- + template + void copy_from(const RenBuf& src) + { + unsigned h = height(); + if(src.height() < h) h = src.height(); + + unsigned l = stride_abs(); + if(src.stride_abs() < l) l = src.stride_abs(); + + l *= sizeof(T); + + unsigned y; + unsigned w = width(); + for (y = 0; y < h; y++) + { + memcpy(row_ptr(0, y, w), src.row_ptr(y), l); + } + } + + //-------------------------------------------------------------------- + void clear(T value) + { + unsigned y; + unsigned w = width(); + unsigned stride = stride_abs(); + for(y = 0; y < height(); y++) + { + T* p = row_ptr(0, y, w); + unsigned x; + for(x = 0; x < stride; x++) + { + *p++ = value; + } + } + } + + private: + //-------------------------------------------------------------------- + T* m_buf; // Pointer to renrdering buffer + pod_array m_rows; // Pointers to each row of the buffer + unsigned m_width; // Width in pixels + unsigned m_height; // Height in pixels + int m_stride; // Number of bytes per row. Can be < 0 + }; + + + + + //========================================================rendering_buffer + // + // The definition of the main type for accessing the rows in the frame + // buffer. It provides functionality to navigate to the rows in a + // rectangular matrix, from top to bottom or from bottom to top depending + // on stride. + // + // row_accessor is cheap to create/destroy, but performs one multiplication + // when calling row_ptr(). + // + // row_ptr_cache creates an array of pointers to rows, so, the access + // via row_ptr() may be faster. But it requires memory allocation + // when creating. For example, on typical Intel Pentium hardware + // row_ptr_cache speeds span_image_filter_rgb_nn up to 10% + // + // It's used only in short hand typedefs like pixfmt_rgba32 and can be + // redefined in agg_config.h + // In real applications you can use both, depending on your needs + //------------------------------------------------------------------------ +#ifdef AGG_RENDERING_BUFFER + typedef AGG_RENDERING_BUFFER rendering_buffer; +#else +// typedef row_ptr_cache rendering_buffer; + typedef row_accessor rendering_buffer; +#endif + +} + + +#endif diff --git a/xs/src/agg/agg_rendering_buffer_dynarow.h b/xs/src/agg/agg_rendering_buffer_dynarow.h new file mode 100644 index 0000000000..188746f3d3 --- /dev/null +++ b/xs/src/agg/agg_rendering_buffer_dynarow.h @@ -0,0 +1,137 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// class rendering_buffer_dynarow +// +//---------------------------------------------------------------------------- + +#ifndef AGG_RENDERING_BUFFER_DYNAROW_INCLUDED +#define AGG_RENDERING_BUFFER_DYNAROW_INCLUDED + +#include "agg_array.h" + +namespace agg +{ + + //===============================================rendering_buffer_dynarow + // Rendering buffer class with dynamic allocation of the rows. + // The rows are allocated as needed when requesting for span_ptr(). + // The class automatically calculates min_x and max_x for each row. + // Generally it's more efficient to use this class as a temporary buffer + // for rendering a few lines and then to blend it with another buffer. + // + class rendering_buffer_dynarow + { + public: + typedef row_info row_data; + + //------------------------------------------------------------------- + ~rendering_buffer_dynarow() + { + init(0,0,0); + } + + //------------------------------------------------------------------- + rendering_buffer_dynarow() : + m_rows(), + m_width(0), + m_height(0), + m_byte_width(0) + { + } + + // Allocate and clear the buffer + //-------------------------------------------------------------------- + rendering_buffer_dynarow(unsigned width, unsigned height, + unsigned byte_width) : + m_rows(height), + m_width(width), + m_height(height), + m_byte_width(byte_width) + { + memset(&m_rows[0], 0, sizeof(row_data) * height); + } + + // Allocate and clear the buffer + //-------------------------------------------------------------------- + void init(unsigned width, unsigned height, unsigned byte_width) + { + unsigned i; + for(i = 0; i < m_height; ++i) + { + pod_allocator::deallocate((int8u*)m_rows[i].ptr, m_byte_width); + } + if(width && height) + { + m_width = width; + m_height = height; + m_byte_width = byte_width; + m_rows.resize(height); + memset(&m_rows[0], 0, sizeof(row_data) * height); + } + } + + //-------------------------------------------------------------------- + unsigned width() const { return m_width; } + unsigned height() const { return m_height; } + unsigned byte_width() const { return m_byte_width; } + + // The main function used for rendering. Returns pointer to the + // pre-allocated span. Memory for the row is allocated as needed. + //-------------------------------------------------------------------- + int8u* row_ptr(int x, int y, unsigned len) + { + row_data* r = &m_rows[y]; + int x2 = x + len - 1; + if(r->ptr) + { + if(x < r->x1) { r->x1 = x; } + if(x2 > r->x2) { r->x2 = x2; } + } + else + { + int8u* p = pod_allocator::allocate(m_byte_width); + r->ptr = p; + r->x1 = x; + r->x2 = x2; + memset(p, 0, m_byte_width); + } + return (int8u*)r->ptr; + } + + //-------------------------------------------------------------------- + const int8u* row_ptr(int y) const { return m_rows[y].ptr; } + int8u* row_ptr(int y) { return row_ptr(0, y, m_width); } + row_data row (int y) const { return m_rows[y]; } + + private: + //-------------------------------------------------------------------- + // Prohibit copying + rendering_buffer_dynarow(const rendering_buffer_dynarow&); + const rendering_buffer_dynarow& operator = (const rendering_buffer_dynarow&); + + private: + //-------------------------------------------------------------------- + pod_array m_rows; // Pointers to each row of the buffer + unsigned m_width; // Width in pixels + unsigned m_height; // Height in pixels + unsigned m_byte_width; // Width in bytes + }; + + +} + + +#endif diff --git a/xs/src/agg/agg_rounded_rect.h b/xs/src/agg/agg_rounded_rect.h new file mode 100644 index 0000000000..fe8d26f71b --- /dev/null +++ b/xs/src/agg/agg_rounded_rect.h @@ -0,0 +1,72 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Rounded rectangle vertex generator +// +//---------------------------------------------------------------------------- + +#ifndef AGG_ROUNDED_RECT_INCLUDED +#define AGG_ROUNDED_RECT_INCLUDED + +#include "agg_basics.h" +#include "agg_arc.h" + +namespace agg +{ + //------------------------------------------------------------rounded_rect + // + // See Implemantation agg_rounded_rect.cpp + // + class rounded_rect + { + public: + rounded_rect() {} + rounded_rect(double x1, double y1, double x2, double y2, double r); + + void rect(double x1, double y1, double x2, double y2); + void radius(double r); + void radius(double rx, double ry); + void radius(double rx_bottom, double ry_bottom, double rx_top, double ry_top); + void radius(double rx1, double ry1, double rx2, double ry2, + double rx3, double ry3, double rx4, double ry4); + void normalize_radius(); + + void approximation_scale(double s) { m_arc.approximation_scale(s); } + double approximation_scale() const { return m_arc.approximation_scale(); } + + void rewind(unsigned); + unsigned vertex(double* x, double* y); + + private: + double m_x1; + double m_y1; + double m_x2; + double m_y2; + double m_rx1; + double m_ry1; + double m_rx2; + double m_ry2; + double m_rx3; + double m_ry3; + double m_rx4; + double m_ry4; + unsigned m_status; + arc m_arc; + }; + +} + +#endif + diff --git a/xs/src/agg/agg_scanline_bin.h b/xs/src/agg/agg_scanline_bin.h new file mode 100644 index 0000000000..6f9f41e8e3 --- /dev/null +++ b/xs/src/agg/agg_scanline_bin.h @@ -0,0 +1,264 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Class scanline_bin - binary scanline. +// +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates (scanline32_bin) has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_SCANLINE_BIN_INCLUDED +#define AGG_SCANLINE_BIN_INCLUDED + +#include "agg_array.h" + +namespace agg +{ + + //=============================================================scanline_bin + // + // This is binary scaline container which supports the interface + // used in the rasterizer::render(). See description of agg_scanline_u8 + // for details. + // + //------------------------------------------------------------------------ + class scanline_bin + { + public: + typedef int32 coord_type; + + struct span + { + int16 x; + int16 len; + }; + + typedef const span* const_iterator; + + //-------------------------------------------------------------------- + scanline_bin() : + m_last_x(0x7FFFFFF0), + m_spans(), + m_cur_span(0) + { + } + + //-------------------------------------------------------------------- + void reset(int min_x, int max_x) + { + unsigned max_len = max_x - min_x + 3; + if(max_len > m_spans.size()) + { + m_spans.resize(max_len); + } + m_last_x = 0x7FFFFFF0; + m_cur_span = &m_spans[0]; + } + + //-------------------------------------------------------------------- + void add_cell(int x, unsigned) + { + if(x == m_last_x+1) + { + m_cur_span->len++; + } + else + { + ++m_cur_span; + m_cur_span->x = (int16)x; + m_cur_span->len = 1; + } + m_last_x = x; + } + + //-------------------------------------------------------------------- + void add_span(int x, unsigned len, unsigned) + { + if(x == m_last_x+1) + { + m_cur_span->len = (int16)(m_cur_span->len + len); + } + else + { + ++m_cur_span; + m_cur_span->x = (int16)x; + m_cur_span->len = (int16)len; + } + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void add_cells(int x, unsigned len, const void*) + { + add_span(x, len, 0); + } + + //-------------------------------------------------------------------- + void finalize(int y) + { + m_y = y; + } + + //-------------------------------------------------------------------- + void reset_spans() + { + m_last_x = 0x7FFFFFF0; + m_cur_span = &m_spans[0]; + } + + //-------------------------------------------------------------------- + int y() const { return m_y; } + unsigned num_spans() const { return unsigned(m_cur_span - &m_spans[0]); } + const_iterator begin() const { return &m_spans[1]; } + + private: + scanline_bin(const scanline_bin&); + const scanline_bin operator = (const scanline_bin&); + + int m_last_x; + int m_y; + pod_array m_spans; + span* m_cur_span; + }; + + + + + + + //===========================================================scanline32_bin + class scanline32_bin + { + public: + typedef int32 coord_type; + + //-------------------------------------------------------------------- + struct span + { + span() {} + span(coord_type x_, coord_type len_) : x(x_), len(len_) {} + + coord_type x; + coord_type len; + }; + typedef pod_bvector span_array_type; + + + //-------------------------------------------------------------------- + class const_iterator + { + public: + const_iterator(const span_array_type& spans) : + m_spans(spans), + m_span_idx(0) + {} + + const span& operator*() const { return m_spans[m_span_idx]; } + const span* operator->() const { return &m_spans[m_span_idx]; } + + void operator ++ () { ++m_span_idx; } + + private: + const span_array_type& m_spans; + unsigned m_span_idx; + }; + + + //-------------------------------------------------------------------- + scanline32_bin() : m_max_len(0), m_last_x(0x7FFFFFF0) {} + + //-------------------------------------------------------------------- + void reset(int, int) + { + m_last_x = 0x7FFFFFF0; + m_spans.remove_all(); + } + + //-------------------------------------------------------------------- + void add_cell(int x, unsigned) + { + if(x == m_last_x+1) + { + m_spans.last().len++; + } + else + { + m_spans.add(span(coord_type(x), 1)); + } + m_last_x = x; + } + + //-------------------------------------------------------------------- + void add_span(int x, unsigned len, unsigned) + { + if(x == m_last_x+1) + { + m_spans.last().len += coord_type(len); + } + else + { + m_spans.add(span(coord_type(x), coord_type(len))); + } + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void add_cells(int x, unsigned len, const void*) + { + add_span(x, len, 0); + } + + //-------------------------------------------------------------------- + void finalize(int y) + { + m_y = y; + } + + //-------------------------------------------------------------------- + void reset_spans() + { + m_last_x = 0x7FFFFFF0; + m_spans.remove_all(); + } + + //-------------------------------------------------------------------- + int y() const { return m_y; } + unsigned num_spans() const { return m_spans.size(); } + const_iterator begin() const { return const_iterator(m_spans); } + + private: + scanline32_bin(const scanline32_bin&); + const scanline32_bin operator = (const scanline32_bin&); + + unsigned m_max_len; + int m_last_x; + int m_y; + span_array_type m_spans; + }; + + + + + +} + + +#endif diff --git a/xs/src/agg/agg_scanline_boolean_algebra.h b/xs/src/agg/agg_scanline_boolean_algebra.h new file mode 100644 index 0000000000..bc2e9c9d51 --- /dev/null +++ b/xs/src/agg/agg_scanline_boolean_algebra.h @@ -0,0 +1,1567 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED +#define AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED + +#include +#include +#include "agg_basics.h" + + +namespace agg +{ + + //-----------------------------------------------sbool_combine_spans_bin + // Functor. + // Combine two binary encoded spans, i.e., when we don't have any + // anti-aliasing information, but only X and Length. The function + // is compatible with any type of scanlines. + //---------------- + template + struct sbool_combine_spans_bin + { + void operator () (const typename Scanline1::const_iterator&, + const typename Scanline2::const_iterator&, + int x, unsigned len, + Scanline& sl) const + { + sl.add_span(x, len, cover_full); + } + }; + + + + //---------------------------------------------sbool_combine_spans_empty + // Functor. + // Combine two spans as empty ones. The functor does nothing + // and is used to XOR binary spans. + //---------------- + template + struct sbool_combine_spans_empty + { + void operator () (const typename Scanline1::const_iterator&, + const typename Scanline2::const_iterator&, + int, unsigned, + Scanline&) const + {} + }; + + + + //--------------------------------------------------sbool_add_span_empty + // Functor. + // Add nothing. Used in conbine_shapes_sub + //---------------- + template + struct sbool_add_span_empty + { + void operator () (const typename Scanline1::const_iterator&, + int, unsigned, + Scanline&) const + {} + }; + + + //----------------------------------------------------sbool_add_span_bin + // Functor. + // Add a binary span + //---------------- + template + struct sbool_add_span_bin + { + void operator () (const typename Scanline1::const_iterator&, + int x, unsigned len, + Scanline& sl) const + { + sl.add_span(x, len, cover_full); + } + }; + + + + + //-----------------------------------------------------sbool_add_span_aa + // Functor. + // Add an anti-aliased span + // anti-aliasing information, but only X and Length. The function + // is compatible with any type of scanlines. + //---------------- + template + struct sbool_add_span_aa + { + void operator () (const typename Scanline1::const_iterator& span, + int x, unsigned len, + Scanline& sl) const + { + if(span->len < 0) + { + sl.add_span(x, len, *span->covers); + } + else + if(span->len > 0) + { + const typename Scanline1::cover_type* covers = span->covers; + if(span->x < x) covers += x - span->x; + sl.add_cells(x, len, covers); + } + } + }; + + + + + //----------------------------------------------sbool_intersect_spans_aa + // Functor. + // Intersect two spans preserving the anti-aliasing information. + // The result is added to the "sl" scanline. + //------------------ + template + struct sbool_intersect_spans_aa + { + enum cover_scale_e + { + cover_shift = CoverShift, + cover_size = 1 << cover_shift, + cover_mask = cover_size - 1, + cover_full = cover_mask + }; + + + void operator () (const typename Scanline1::const_iterator& span1, + const typename Scanline2::const_iterator& span2, + int x, unsigned len, + Scanline& sl) const + { + unsigned cover; + const typename Scanline1::cover_type* covers1; + const typename Scanline2::cover_type* covers2; + + // Calculate the operation code and choose the + // proper combination algorithm. + // 0 = Both spans are of AA type + // 1 = span1 is solid, span2 is AA + // 2 = span1 is AA, span2 is solid + // 3 = Both spans are of solid type + //----------------- + switch((span1->len < 0) | ((span2->len < 0) << 1)) + { + case 0: // Both are AA spans + covers1 = span1->covers; + covers2 = span2->covers; + if(span1->x < x) covers1 += x - span1->x; + if(span2->x < x) covers2 += x - span2->x; + do + { + cover = *covers1++ * *covers2++; + sl.add_cell(x++, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + while(--len); + break; + + case 1: // span1 is solid, span2 is AA + covers2 = span2->covers; + if(span2->x < x) covers2 += x - span2->x; + if(*(span1->covers) == cover_full) + { + sl.add_cells(x, len, covers2); + } + else + { + do + { + cover = *(span1->covers) * *covers2++; + sl.add_cell(x++, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + while(--len); + } + break; + + case 2: // span1 is AA, span2 is solid + covers1 = span1->covers; + if(span1->x < x) covers1 += x - span1->x; + if(*(span2->covers) == cover_full) + { + sl.add_cells(x, len, covers1); + } + else + { + do + { + cover = *covers1++ * *(span2->covers); + sl.add_cell(x++, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + while(--len); + } + break; + + case 3: // Both are solid spans + cover = *(span1->covers) * *(span2->covers); + sl.add_span(x, len, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + break; + } + } + }; + + + + + + + //--------------------------------------------------sbool_unite_spans_aa + // Functor. + // Unite two spans preserving the anti-aliasing information. + // The result is added to the "sl" scanline. + //------------------ + template + struct sbool_unite_spans_aa + { + enum cover_scale_e + { + cover_shift = CoverShift, + cover_size = 1 << cover_shift, + cover_mask = cover_size - 1, + cover_full = cover_mask + }; + + + void operator () (const typename Scanline1::const_iterator& span1, + const typename Scanline2::const_iterator& span2, + int x, unsigned len, + Scanline& sl) const + { + unsigned cover; + const typename Scanline1::cover_type* covers1; + const typename Scanline2::cover_type* covers2; + + // Calculate the operation code and choose the + // proper combination algorithm. + // 0 = Both spans are of AA type + // 1 = span1 is solid, span2 is AA + // 2 = span1 is AA, span2 is solid + // 3 = Both spans are of solid type + //----------------- + switch((span1->len < 0) | ((span2->len < 0) << 1)) + { + case 0: // Both are AA spans + covers1 = span1->covers; + covers2 = span2->covers; + if(span1->x < x) covers1 += x - span1->x; + if(span2->x < x) covers2 += x - span2->x; + do + { + cover = cover_mask * cover_mask - + (cover_mask - *covers1++) * + (cover_mask - *covers2++); + sl.add_cell(x++, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + while(--len); + break; + + case 1: // span1 is solid, span2 is AA + covers2 = span2->covers; + if(span2->x < x) covers2 += x - span2->x; + if(*(span1->covers) == cover_full) + { + sl.add_span(x, len, cover_full); + } + else + { + do + { + cover = cover_mask * cover_mask - + (cover_mask - *(span1->covers)) * + (cover_mask - *covers2++); + sl.add_cell(x++, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + while(--len); + } + break; + + case 2: // span1 is AA, span2 is solid + covers1 = span1->covers; + if(span1->x < x) covers1 += x - span1->x; + if(*(span2->covers) == cover_full) + { + sl.add_span(x, len, cover_full); + } + else + { + do + { + cover = cover_mask * cover_mask - + (cover_mask - *covers1++) * + (cover_mask - *(span2->covers)); + sl.add_cell(x++, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + while(--len); + } + break; + + case 3: // Both are solid spans + cover = cover_mask * cover_mask - + (cover_mask - *(span1->covers)) * + (cover_mask - *(span2->covers)); + sl.add_span(x, len, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + break; + } + } + }; + + + //---------------------------------------------sbool_xor_formula_linear + template + struct sbool_xor_formula_linear + { + enum cover_scale_e + { + cover_shift = CoverShift, + cover_size = 1 << cover_shift, + cover_mask = cover_size - 1 + }; + + static AGG_INLINE unsigned calculate(unsigned a, unsigned b) + { + unsigned cover = a + b; + if(cover > cover_mask) cover = cover_mask + cover_mask - cover; + return cover; + } + }; + + + //---------------------------------------------sbool_xor_formula_saddle + template + struct sbool_xor_formula_saddle + { + enum cover_scale_e + { + cover_shift = CoverShift, + cover_size = 1 << cover_shift, + cover_mask = cover_size - 1 + }; + + static AGG_INLINE unsigned calculate(unsigned a, unsigned b) + { + unsigned k = a * b; + if(k == cover_mask * cover_mask) return 0; + + a = (cover_mask * cover_mask - (a << cover_shift) + k) >> cover_shift; + b = (cover_mask * cover_mask - (b << cover_shift) + k) >> cover_shift; + return cover_mask - ((a * b) >> cover_shift); + } + }; + + + //-------------------------------------------sbool_xor_formula_abs_diff + struct sbool_xor_formula_abs_diff + { + static AGG_INLINE unsigned calculate(unsigned a, unsigned b) + { + return unsigned(abs(int(a) - int(b))); + } + }; + + + + //----------------------------------------------------sbool_xor_spans_aa + // Functor. + // XOR two spans preserving the anti-aliasing information. + // The result is added to the "sl" scanline. + //------------------ + template + struct sbool_xor_spans_aa + { + enum cover_scale_e + { + cover_shift = CoverShift, + cover_size = 1 << cover_shift, + cover_mask = cover_size - 1, + cover_full = cover_mask + }; + + + void operator () (const typename Scanline1::const_iterator& span1, + const typename Scanline2::const_iterator& span2, + int x, unsigned len, + Scanline& sl) const + { + unsigned cover; + const typename Scanline1::cover_type* covers1; + const typename Scanline2::cover_type* covers2; + + // Calculate the operation code and choose the + // proper combination algorithm. + // 0 = Both spans are of AA type + // 1 = span1 is solid, span2 is AA + // 2 = span1 is AA, span2 is solid + // 3 = Both spans are of solid type + //----------------- + switch((span1->len < 0) | ((span2->len < 0) << 1)) + { + case 0: // Both are AA spans + covers1 = span1->covers; + covers2 = span2->covers; + if(span1->x < x) covers1 += x - span1->x; + if(span2->x < x) covers2 += x - span2->x; + do + { + cover = XorFormula::calculate(*covers1++, *covers2++); + if(cover) sl.add_cell(x, cover); + ++x; + } + while(--len); + break; + + case 1: // span1 is solid, span2 is AA + covers2 = span2->covers; + if(span2->x < x) covers2 += x - span2->x; + do + { + cover = XorFormula::calculate(*(span1->covers), *covers2++); + if(cover) sl.add_cell(x, cover); + ++x; + } + while(--len); + break; + + case 2: // span1 is AA, span2 is solid + covers1 = span1->covers; + if(span1->x < x) covers1 += x - span1->x; + do + { + cover = XorFormula::calculate(*covers1++, *(span2->covers)); + if(cover) sl.add_cell(x, cover); + ++x; + } + while(--len); + break; + + case 3: // Both are solid spans + cover = XorFormula::calculate(*(span1->covers), *(span2->covers)); + if(cover) sl.add_span(x, len, cover); + break; + + } + } + }; + + + + + + //-----------------------------------------------sbool_subtract_spans_aa + // Functor. + // Unite two spans preserving the anti-aliasing information. + // The result is added to the "sl" scanline. + //------------------ + template + struct sbool_subtract_spans_aa + { + enum cover_scale_e + { + cover_shift = CoverShift, + cover_size = 1 << cover_shift, + cover_mask = cover_size - 1, + cover_full = cover_mask + }; + + + void operator () (const typename Scanline1::const_iterator& span1, + const typename Scanline2::const_iterator& span2, + int x, unsigned len, + Scanline& sl) const + { + unsigned cover; + const typename Scanline1::cover_type* covers1; + const typename Scanline2::cover_type* covers2; + + // Calculate the operation code and choose the + // proper combination algorithm. + // 0 = Both spans are of AA type + // 1 = span1 is solid, span2 is AA + // 2 = span1 is AA, span2 is solid + // 3 = Both spans are of solid type + //----------------- + switch((span1->len < 0) | ((span2->len < 0) << 1)) + { + case 0: // Both are AA spans + covers1 = span1->covers; + covers2 = span2->covers; + if(span1->x < x) covers1 += x - span1->x; + if(span2->x < x) covers2 += x - span2->x; + do + { + cover = *covers1++ * (cover_mask - *covers2++); + if(cover) + { + sl.add_cell(x, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + ++x; + } + while(--len); + break; + + case 1: // span1 is solid, span2 is AA + covers2 = span2->covers; + if(span2->x < x) covers2 += x - span2->x; + do + { + cover = *(span1->covers) * (cover_mask - *covers2++); + if(cover) + { + sl.add_cell(x, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + ++x; + } + while(--len); + break; + + case 2: // span1 is AA, span2 is solid + covers1 = span1->covers; + if(span1->x < x) covers1 += x - span1->x; + if(*(span2->covers) != cover_full) + { + do + { + cover = *covers1++ * (cover_mask - *(span2->covers)); + if(cover) + { + sl.add_cell(x, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + ++x; + } + while(--len); + } + break; + + case 3: // Both are solid spans + cover = *(span1->covers) * (cover_mask - *(span2->covers)); + if(cover) + { + sl.add_span(x, len, + (cover == cover_full * cover_full) ? + cover_full : + (cover >> cover_shift)); + } + break; + } + } + }; + + + + + + + //--------------------------------------------sbool_add_spans_and_render + template + void sbool_add_spans_and_render(const Scanline1& sl1, + Scanline& sl, + Renderer& ren, + AddSpanFunctor add_span) + { + sl.reset_spans(); + typename Scanline1::const_iterator span = sl1.begin(); + unsigned num_spans = sl1.num_spans(); + for(;;) + { + add_span(span, span->x, abs((int)span->len), sl); + if(--num_spans == 0) break; + ++span; + } + sl.finalize(sl1.y()); + ren.render(sl); + } + + + + + + + + //---------------------------------------------sbool_intersect_scanlines + // Intersect two scanlines, "sl1" and "sl2" and generate a new "sl" one. + // The combine_spans functor can be of type sbool_combine_spans_bin or + // sbool_intersect_spans_aa. First is a general functor to combine + // two spans without Anti-Aliasing, the second preserves the AA + // information, but works slower + // + template + void sbool_intersect_scanlines(const Scanline1& sl1, + const Scanline2& sl2, + Scanline& sl, + CombineSpansFunctor combine_spans) + { + sl.reset_spans(); + + unsigned num1 = sl1.num_spans(); + if(num1 == 0) return; + + unsigned num2 = sl2.num_spans(); + if(num2 == 0) return; + + typename Scanline1::const_iterator span1 = sl1.begin(); + typename Scanline2::const_iterator span2 = sl2.begin(); + + while(num1 && num2) + { + int xb1 = span1->x; + int xb2 = span2->x; + int xe1 = xb1 + abs((int)span1->len) - 1; + int xe2 = xb2 + abs((int)span2->len) - 1; + + // Determine what spans we should advance in the next step + // The span with the least ending X should be advanced + // advance_both is just an optimization when we ending + // coordinates are the same and we can advance both + //-------------- + bool advance_span1 = xe1 < xe2; + bool advance_both = xe1 == xe2; + + // Find the intersection of the spans + // and check if they intersect + //-------------- + if(xb1 < xb2) xb1 = xb2; + if(xe1 > xe2) xe1 = xe2; + if(xb1 <= xe1) + { + combine_spans(span1, span2, xb1, xe1 - xb1 + 1, sl); + } + + // Advance the spans + //-------------- + if(advance_both) + { + --num1; + --num2; + if(num1) ++span1; + if(num2) ++span2; + } + else + { + if(advance_span1) + { + --num1; + if(num1) ++span1; + } + else + { + --num2; + if(num2) ++span2; + } + } + } + } + + + + + + + + + //------------------------------------------------sbool_intersect_shapes + // Intersect the scanline shapes. Here the "Scanline Generator" + // abstraction is used. ScanlineGen1 and ScanlineGen2 are + // the generators, and can be of type rasterizer_scanline_aa<>. + // There function requires three scanline containers that can be of + // different types. + // "sl1" and "sl2" are used to retrieve scanlines from the generators, + // "sl" is ised as the resulting scanline to render it. + // The external "sl1" and "sl2" are used only for the sake of + // optimization and reusing of the scanline objects. + // the function calls sbool_intersect_scanlines with CombineSpansFunctor + // as the last argument. See sbool_intersect_scanlines for details. + //---------- + template + void sbool_intersect_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren, + CombineSpansFunctor combine_spans) + { + // Prepare the scanline generators. + // If anyone of them doesn't contain + // any scanlines, then return. + //----------------- + if(!sg1.rewind_scanlines()) return; + if(!sg2.rewind_scanlines()) return; + + // Get the bounding boxes + //---------------- + rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); + rect_i r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y()); + + // Calculate the intersection of the bounding + // boxes and return if they don't intersect. + //----------------- + rect_i ir = intersect_rectangles(r1, r2); + if(!ir.is_valid()) return; + + // Reset the scanlines and get two first ones + //----------------- + sl.reset(ir.x1, ir.x2); + sl1.reset(sg1.min_x(), sg1.max_x()); + sl2.reset(sg2.min_x(), sg2.max_x()); + if(!sg1.sweep_scanline(sl1)) return; + if(!sg2.sweep_scanline(sl2)) return; + + ren.prepare(); + + // The main loop + // Here we synchronize the scanlines with + // the same Y coordinate, ignoring all other ones. + // Only scanlines having the same Y-coordinate + // are to be combined. + //----------------- + for(;;) + { + while(sl1.y() < sl2.y()) + { + if(!sg1.sweep_scanline(sl1)) return; + } + while(sl2.y() < sl1.y()) + { + if(!sg2.sweep_scanline(sl2)) return; + } + + if(sl1.y() == sl2.y()) + { + // The Y coordinates are the same. + // Combine the scanlines, render if they contain any spans, + // and advance both generators to the next scanlines + //---------------------- + sbool_intersect_scanlines(sl1, sl2, sl, combine_spans); + if(sl.num_spans()) + { + sl.finalize(sl1.y()); + ren.render(sl); + } + if(!sg1.sweep_scanline(sl1)) return; + if(!sg2.sweep_scanline(sl2)) return; + } + } + } + + + + + + + + //-------------------------------------------------sbool_unite_scanlines + // Unite two scanlines, "sl1" and "sl2" and generate a new "sl" one. + // The combine_spans functor can be of type sbool_combine_spans_bin or + // sbool_intersect_spans_aa. First is a general functor to combine + // two spans without Anti-Aliasing, the second preserves the AA + // information, but works slower + // + template + void sbool_unite_scanlines(const Scanline1& sl1, + const Scanline2& sl2, + Scanline& sl, + AddSpanFunctor1 add_span1, + AddSpanFunctor2 add_span2, + CombineSpansFunctor combine_spans) + { + sl.reset_spans(); + + unsigned num1 = sl1.num_spans(); + unsigned num2 = sl2.num_spans(); + + typename Scanline1::const_iterator span1;// = sl1.begin(); + typename Scanline2::const_iterator span2;// = sl2.begin(); + + enum invalidation_e + { + invalid_b = 0xFFFFFFF, + invalid_e = invalid_b - 1 + }; + + // Initialize the spans as invalid + //--------------- + int xb1 = invalid_b; + int xb2 = invalid_b; + int xe1 = invalid_e; + int xe2 = invalid_e; + + // Initialize span1 if there are spans + //--------------- + if(num1) + { + span1 = sl1.begin(); + xb1 = span1->x; + xe1 = xb1 + abs((int)span1->len) - 1; + --num1; + } + + // Initialize span2 if there are spans + //--------------- + if(num2) + { + span2 = sl2.begin(); + xb2 = span2->x; + xe2 = xb2 + abs((int)span2->len) - 1; + --num2; + } + + + for(;;) + { + // Retrieve a new span1 if it's invalid + //---------------- + if(num1 && xb1 > xe1) + { + --num1; + ++span1; + xb1 = span1->x; + xe1 = xb1 + abs((int)span1->len) - 1; + } + + // Retrieve a new span2 if it's invalid + //---------------- + if(num2 && xb2 > xe2) + { + --num2; + ++span2; + xb2 = span2->x; + xe2 = xb2 + abs((int)span2->len) - 1; + } + + if(xb1 > xe1 && xb2 > xe2) break; + + // Calculate the intersection + //---------------- + int xb = xb1; + int xe = xe1; + if(xb < xb2) xb = xb2; + if(xe > xe2) xe = xe2; + int len = xe - xb + 1; // The length of the intersection + if(len > 0) + { + // The spans intersect, + // add the beginning of the span + //---------------- + if(xb1 < xb2) + { + add_span1(span1, xb1, xb2 - xb1, sl); + xb1 = xb2; + } + else + if(xb2 < xb1) + { + add_span2(span2, xb2, xb1 - xb2, sl); + xb2 = xb1; + } + + // Add the combination part of the spans + //---------------- + combine_spans(span1, span2, xb, len, sl); + + + // Invalidate the fully processed span or both + //---------------- + if(xe1 < xe2) + { + // Invalidate span1 and eat + // the processed part of span2 + //-------------- + xb1 = invalid_b; + xe1 = invalid_e; + xb2 += len; + } + else + if(xe2 < xe1) + { + // Invalidate span2 and eat + // the processed part of span1 + //-------------- + xb2 = invalid_b; + xe2 = invalid_e; + xb1 += len; + } + else + { + xb1 = invalid_b; // Invalidate both + xb2 = invalid_b; + xe1 = invalid_e; + xe2 = invalid_e; + } + } + else + { + // The spans do not intersect + //-------------- + if(xb1 < xb2) + { + // Advance span1 + //--------------- + if(xb1 <= xe1) + { + add_span1(span1, xb1, xe1 - xb1 + 1, sl); + } + xb1 = invalid_b; // Invalidate + xe1 = invalid_e; + } + else + { + // Advance span2 + //--------------- + if(xb2 <= xe2) + { + add_span2(span2, xb2, xe2 - xb2 + 1, sl); + } + xb2 = invalid_b; // Invalidate + xe2 = invalid_e; + } + } + } + } + + + + + //----------------------------------------------------sbool_unite_shapes + // Unite the scanline shapes. Here the "Scanline Generator" + // abstraction is used. ScanlineGen1 and ScanlineGen2 are + // the generators, and can be of type rasterizer_scanline_aa<>. + // There function requires three scanline containers that can be + // of different type. + // "sl1" and "sl2" are used to retrieve scanlines from the generators, + // "sl" is ised as the resulting scanline to render it. + // The external "sl1" and "sl2" are used only for the sake of + // optimization and reusing of the scanline objects. + // the function calls sbool_unite_scanlines with CombineSpansFunctor + // as the last argument. See sbool_unite_scanlines for details. + //---------- + template + void sbool_unite_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren, + AddSpanFunctor1 add_span1, + AddSpanFunctor2 add_span2, + CombineSpansFunctor combine_spans) + { + // Prepare the scanline generators. + // If anyone of them doesn't contain + // any scanlines, then return. + //----------------- + bool flag1 = sg1.rewind_scanlines(); + bool flag2 = sg2.rewind_scanlines(); + if(!flag1 && !flag2) return; + + // Get the bounding boxes + //---------------- + rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); + rect_i r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y()); + + // Calculate the union of the bounding boxes + //----------------- + rect_i ur(1,1,0,0); + if(flag1 && flag2) ur = unite_rectangles(r1, r2); + else if(flag1) ur = r1; + else if(flag2) ur = r2; + + if(!ur.is_valid()) return; + + ren.prepare(); + + // Reset the scanlines and get two first ones + //----------------- + sl.reset(ur.x1, ur.x2); + if(flag1) + { + sl1.reset(sg1.min_x(), sg1.max_x()); + flag1 = sg1.sweep_scanline(sl1); + } + + if(flag2) + { + sl2.reset(sg2.min_x(), sg2.max_x()); + flag2 = sg2.sweep_scanline(sl2); + } + + // The main loop + // Here we synchronize the scanlines with + // the same Y coordinate. + //----------------- + while(flag1 || flag2) + { + if(flag1 && flag2) + { + if(sl1.y() == sl2.y()) + { + // The Y coordinates are the same. + // Combine the scanlines, render if they contain any spans, + // and advance both generators to the next scanlines + //---------------------- + sbool_unite_scanlines(sl1, sl2, sl, + add_span1, add_span2, combine_spans); + if(sl.num_spans()) + { + sl.finalize(sl1.y()); + ren.render(sl); + } + flag1 = sg1.sweep_scanline(sl1); + flag2 = sg2.sweep_scanline(sl2); + } + else + { + if(sl1.y() < sl2.y()) + { + sbool_add_spans_and_render(sl1, sl, ren, add_span1); + flag1 = sg1.sweep_scanline(sl1); + } + else + { + sbool_add_spans_and_render(sl2, sl, ren, add_span2); + flag2 = sg2.sweep_scanline(sl2); + } + } + } + else + { + if(flag1) + { + sbool_add_spans_and_render(sl1, sl, ren, add_span1); + flag1 = sg1.sweep_scanline(sl1); + } + if(flag2) + { + sbool_add_spans_and_render(sl2, sl, ren, add_span2); + flag2 = sg2.sweep_scanline(sl2); + } + } + } + } + + + + + + + + + //-------------------------------------------------sbool_subtract_shapes + // Subtract the scanline shapes, "sg1-sg2". Here the "Scanline Generator" + // abstraction is used. ScanlineGen1 and ScanlineGen2 are + // the generators, and can be of type rasterizer_scanline_aa<>. + // There function requires three scanline containers that can be of + // different types. + // "sl1" and "sl2" are used to retrieve scanlines from the generators, + // "sl" is ised as the resulting scanline to render it. + // The external "sl1" and "sl2" are used only for the sake of + // optimization and reusing of the scanline objects. + // the function calls sbool_intersect_scanlines with CombineSpansFunctor + // as the last argument. See combine_scanlines_sub for details. + //---------- + template + void sbool_subtract_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren, + AddSpanFunctor1 add_span1, + CombineSpansFunctor combine_spans) + { + // Prepare the scanline generators. + // Here "sg1" is master, "sg2" is slave. + //----------------- + if(!sg1.rewind_scanlines()) return; + bool flag2 = sg2.rewind_scanlines(); + + // Get the bounding box + //---------------- + rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); + + // Reset the scanlines and get two first ones + //----------------- + sl.reset(sg1.min_x(), sg1.max_x()); + sl1.reset(sg1.min_x(), sg1.max_x()); + sl2.reset(sg2.min_x(), sg2.max_x()); + if(!sg1.sweep_scanline(sl1)) return; + + if(flag2) flag2 = sg2.sweep_scanline(sl2); + + ren.prepare(); + + // A fake span2 processor + sbool_add_span_empty add_span2; + + // The main loop + // Here we synchronize the scanlines with + // the same Y coordinate, ignoring all other ones. + // Only scanlines having the same Y-coordinate + // are to be combined. + //----------------- + bool flag1 = true; + do + { + // Synchronize "slave" with "master" + //----------------- + while(flag2 && sl2.y() < sl1.y()) + { + flag2 = sg2.sweep_scanline(sl2); + } + + + if(flag2 && sl2.y() == sl1.y()) + { + // The Y coordinates are the same. + // Combine the scanlines and render if they contain any spans. + //---------------------- + sbool_unite_scanlines(sl1, sl2, sl, add_span1, add_span2, combine_spans); + if(sl.num_spans()) + { + sl.finalize(sl1.y()); + ren.render(sl); + } + } + else + { + sbool_add_spans_and_render(sl1, sl, ren, add_span1); + } + + // Advance the "master" + flag1 = sg1.sweep_scanline(sl1); + } + while(flag1); + } + + + + + + + + //---------------------------------------------sbool_intersect_shapes_aa + // Intersect two anti-aliased scanline shapes. + // Here the "Scanline Generator" abstraction is used. + // ScanlineGen1 and ScanlineGen2 are the generators, and can be of + // type rasterizer_scanline_aa<>. There function requires three + // scanline containers that can be of different types. + // "sl1" and "sl2" are used to retrieve scanlines from the generators, + // "sl" is ised as the resulting scanline to render it. + // The external "sl1" and "sl2" are used only for the sake of + // optimization and reusing of the scanline objects. + //---------- + template + void sbool_intersect_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_intersect_spans_aa combine_functor; + sbool_intersect_shapes(sg1, sg2, sl1, sl2, sl, ren, combine_functor); + } + + + + + + //--------------------------------------------sbool_intersect_shapes_bin + // Intersect two binary scanline shapes (without anti-aliasing). + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_intersect_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_combine_spans_bin combine_functor; + sbool_intersect_shapes(sg1, sg2, sl1, sl2, sl, ren, combine_functor); + } + + + + + + //-------------------------------------------------sbool_unite_shapes_aa + // Unite two anti-aliased scanline shapes + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_unite_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_add_span_aa add_functor1; + sbool_add_span_aa add_functor2; + sbool_unite_spans_aa combine_functor; + sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, + add_functor1, add_functor2, combine_functor); + } + + + + + + //------------------------------------------------sbool_unite_shapes_bin + // Unite two binary scanline shapes (without anti-aliasing). + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_unite_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_add_span_bin add_functor1; + sbool_add_span_bin add_functor2; + sbool_combine_spans_bin combine_functor; + sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, + add_functor1, add_functor2, combine_functor); + } + + + + + + + + + + //---------------------------------------------------sbool_xor_shapes_aa + // Apply eXclusive OR to two anti-aliased scanline shapes. There's + // a modified "Linear" XOR used instead of classical "Saddle" one. + // The reason is to have the result absolutely conststent with what + // the scanline rasterizer produces. + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_xor_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_add_span_aa add_functor1; + sbool_add_span_aa add_functor2; + sbool_xor_spans_aa > combine_functor; + sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, + add_functor1, add_functor2, combine_functor); + } + + + + //------------------------------------------sbool_xor_shapes_saddle_aa + // Apply eXclusive OR to two anti-aliased scanline shapes. + // There's the classical "Saddle" used to calculate the + // Anti-Aliasing values, that is: + // a XOR b : 1-((1-a+a*b)*(1-b+a*b)) + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_xor_shapes_saddle_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_add_span_aa add_functor1; + sbool_add_span_aa add_functor2; + sbool_xor_spans_aa > combine_functor; + sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, + add_functor1, add_functor2, combine_functor); + } + + + //--------------------------------------sbool_xor_shapes_abs_diff_aa + // Apply eXclusive OR to two anti-aliased scanline shapes. + // There's the absolute difference used to calculate + // Anti-Aliasing values, that is: + // a XOR b : abs(a-b) + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_xor_shapes_abs_diff_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_add_span_aa add_functor1; + sbool_add_span_aa add_functor2; + sbool_xor_spans_aa combine_functor; + sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, + add_functor1, add_functor2, combine_functor); + } + + + + //--------------------------------------------------sbool_xor_shapes_bin + // Apply eXclusive OR to two binary scanline shapes (without anti-aliasing). + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_xor_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_add_span_bin add_functor1; + sbool_add_span_bin add_functor2; + sbool_combine_spans_empty combine_functor; + sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, + add_functor1, add_functor2, combine_functor); + } + + + + + + + //----------------------------------------------sbool_subtract_shapes_aa + // Subtract shapes "sg1-sg2" with anti-aliasing + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_subtract_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_add_span_aa add_functor; + sbool_subtract_spans_aa combine_functor; + sbool_subtract_shapes(sg1, sg2, sl1, sl2, sl, ren, + add_functor, combine_functor); + } + + + + + + //---------------------------------------------sbool_subtract_shapes_bin + // Subtract binary shapes "sg1-sg2" without anti-aliasing + // See intersect_shapes_aa for more comments + //---------- + template + void sbool_subtract_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + sbool_add_span_bin add_functor; + sbool_combine_spans_empty combine_functor; + sbool_subtract_shapes(sg1, sg2, sl1, sl2, sl, ren, + add_functor, combine_functor); + } + + + + + + + //------------------------------------------------------------sbool_op_e + enum sbool_op_e + { + sbool_or, //----sbool_or + sbool_and, //----sbool_and + sbool_xor, //----sbool_xor + sbool_xor_saddle, //----sbool_xor_saddle + sbool_xor_abs_diff, //----sbool_xor_abs_diff + sbool_a_minus_b, //----sbool_a_minus_b + sbool_b_minus_a //----sbool_b_minus_a + }; + + + + + + + //----------------------------------------------sbool_combine_shapes_bin + template + void sbool_combine_shapes_bin(sbool_op_e op, + ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + switch(op) + { + case sbool_or : sbool_unite_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_and : sbool_intersect_shapes_bin(sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_xor : + case sbool_xor_saddle : + case sbool_xor_abs_diff: sbool_xor_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_a_minus_b : sbool_subtract_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_b_minus_a : sbool_subtract_shapes_bin (sg2, sg1, sl2, sl1, sl, ren); break; + } + } + + + + + //-----------------------------------------------sbool_combine_shapes_aa + template + void sbool_combine_shapes_aa(sbool_op_e op, + ScanlineGen1& sg1, ScanlineGen2& sg2, + Scanline1& sl1, Scanline2& sl2, + Scanline& sl, Renderer& ren) + { + switch(op) + { + case sbool_or : sbool_unite_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_and : sbool_intersect_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_xor : sbool_xor_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_xor_saddle : sbool_xor_shapes_saddle_aa (sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_xor_abs_diff: sbool_xor_shapes_abs_diff_aa(sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_a_minus_b : sbool_subtract_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; + case sbool_b_minus_a : sbool_subtract_shapes_aa (sg2, sg1, sl2, sl1, sl, ren); break; + } + } + +} + + +#endif + diff --git a/xs/src/agg/agg_scanline_p.h b/xs/src/agg/agg_scanline_p.h new file mode 100644 index 0000000000..1d1cbe72f1 --- /dev/null +++ b/xs/src/agg/agg_scanline_p.h @@ -0,0 +1,329 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Class scanline_p - a general purpose scanline container with packed spans. +// +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates (scanline32_p) has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +#ifndef AGG_SCANLINE_P_INCLUDED +#define AGG_SCANLINE_P_INCLUDED + +#include "agg_array.h" + +namespace agg +{ + + //=============================================================scanline_p8 + // + // This is a general purpose scaline container which supports the interface + // used in the rasterizer::render(). See description of scanline_u8 + // for details. + // + //------------------------------------------------------------------------ + class scanline_p8 + { + public: + typedef scanline_p8 self_type; + typedef int8u cover_type; + typedef int16 coord_type; + + //-------------------------------------------------------------------- + struct span + { + coord_type x; + coord_type len; // If negative, it's a solid span, covers is valid + const cover_type* covers; + }; + + typedef span* iterator; + typedef const span* const_iterator; + + scanline_p8() : + m_last_x(0x7FFFFFF0), + m_covers(), + m_cover_ptr(0), + m_spans(), + m_cur_span(0) + { + } + + //-------------------------------------------------------------------- + void reset(int min_x, int max_x) + { + unsigned max_len = max_x - min_x + 3; + if(max_len > m_spans.size()) + { + m_spans.resize(max_len); + m_covers.resize(max_len); + } + m_last_x = 0x7FFFFFF0; + m_cover_ptr = &m_covers[0]; + m_cur_span = &m_spans[0]; + m_cur_span->len = 0; + } + + //-------------------------------------------------------------------- + void add_cell(int x, unsigned cover) + { + *m_cover_ptr = (cover_type)cover; + if(x == m_last_x+1 && m_cur_span->len > 0) + { + m_cur_span->len++; + } + else + { + m_cur_span++; + m_cur_span->covers = m_cover_ptr; + m_cur_span->x = (int16)x; + m_cur_span->len = 1; + } + m_last_x = x; + m_cover_ptr++; + } + + //-------------------------------------------------------------------- + void add_cells(int x, unsigned len, const cover_type* covers) + { + memcpy(m_cover_ptr, covers, len * sizeof(cover_type)); + if(x == m_last_x+1 && m_cur_span->len > 0) + { + m_cur_span->len += (int16)len; + } + else + { + m_cur_span++; + m_cur_span->covers = m_cover_ptr; + m_cur_span->x = (int16)x; + m_cur_span->len = (int16)len; + } + m_cover_ptr += len; + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void add_span(int x, unsigned len, unsigned cover) + { + if(x == m_last_x+1 && + m_cur_span->len < 0 && + cover == *m_cur_span->covers) + { + m_cur_span->len -= (int16)len; + } + else + { + *m_cover_ptr = (cover_type)cover; + m_cur_span++; + m_cur_span->covers = m_cover_ptr++; + m_cur_span->x = (int16)x; + m_cur_span->len = (int16)(-int(len)); + } + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void finalize(int y) + { + m_y = y; + } + + //-------------------------------------------------------------------- + void reset_spans() + { + m_last_x = 0x7FFFFFF0; + m_cover_ptr = &m_covers[0]; + m_cur_span = &m_spans[0]; + m_cur_span->len = 0; + } + + //-------------------------------------------------------------------- + int y() const { return m_y; } + unsigned num_spans() const { return unsigned(m_cur_span - &m_spans[0]); } + const_iterator begin() const { return &m_spans[1]; } + + private: + scanline_p8(const self_type&); + const self_type& operator = (const self_type&); + + int m_last_x; + int m_y; + pod_array m_covers; + cover_type* m_cover_ptr; + pod_array m_spans; + span* m_cur_span; + }; + + + + + + + + + //==========================================================scanline32_p8 + class scanline32_p8 + { + public: + typedef scanline32_p8 self_type; + typedef int8u cover_type; + typedef int32 coord_type; + + struct span + { + span() {} + span(coord_type x_, coord_type len_, const cover_type* covers_) : + x(x_), len(len_), covers(covers_) {} + + coord_type x; + coord_type len; // If negative, it's a solid span, covers is valid + const cover_type* covers; + }; + typedef pod_bvector span_array_type; + + + //-------------------------------------------------------------------- + class const_iterator + { + public: + const_iterator(const span_array_type& spans) : + m_spans(spans), + m_span_idx(0) + {} + + const span& operator*() const { return m_spans[m_span_idx]; } + const span* operator->() const { return &m_spans[m_span_idx]; } + + void operator ++ () { ++m_span_idx; } + + private: + const span_array_type& m_spans; + unsigned m_span_idx; + }; + + //-------------------------------------------------------------------- + scanline32_p8() : + m_max_len(0), + m_last_x(0x7FFFFFF0), + m_covers(), + m_cover_ptr(0) + { + } + + //-------------------------------------------------------------------- + void reset(int min_x, int max_x) + { + unsigned max_len = max_x - min_x + 3; + if(max_len > m_covers.size()) + { + m_covers.resize(max_len); + } + m_last_x = 0x7FFFFFF0; + m_cover_ptr = &m_covers[0]; + m_spans.remove_all(); + } + + //-------------------------------------------------------------------- + void add_cell(int x, unsigned cover) + { + *m_cover_ptr = cover_type(cover); + if(x == m_last_x+1 && m_spans.size() && m_spans.last().len > 0) + { + m_spans.last().len++; + } + else + { + m_spans.add(span(coord_type(x), 1, m_cover_ptr)); + } + m_last_x = x; + m_cover_ptr++; + } + + //-------------------------------------------------------------------- + void add_cells(int x, unsigned len, const cover_type* covers) + { + memcpy(m_cover_ptr, covers, len * sizeof(cover_type)); + if(x == m_last_x+1 && m_spans.size() && m_spans.last().len > 0) + { + m_spans.last().len += coord_type(len); + } + else + { + m_spans.add(span(coord_type(x), coord_type(len), m_cover_ptr)); + } + m_cover_ptr += len; + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void add_span(int x, unsigned len, unsigned cover) + { + if(x == m_last_x+1 && + m_spans.size() && + m_spans.last().len < 0 && + cover == *m_spans.last().covers) + { + m_spans.last().len -= coord_type(len); + } + else + { + *m_cover_ptr = cover_type(cover); + m_spans.add(span(coord_type(x), -coord_type(len), m_cover_ptr++)); + } + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void finalize(int y) + { + m_y = y; + } + + //-------------------------------------------------------------------- + void reset_spans() + { + m_last_x = 0x7FFFFFF0; + m_cover_ptr = &m_covers[0]; + m_spans.remove_all(); + } + + //-------------------------------------------------------------------- + int y() const { return m_y; } + unsigned num_spans() const { return m_spans.size(); } + const_iterator begin() const { return const_iterator(m_spans); } + + private: + scanline32_p8(const self_type&); + const self_type& operator = (const self_type&); + + unsigned m_max_len; + int m_last_x; + int m_y; + pod_array m_covers; + cover_type* m_cover_ptr; + span_array_type m_spans; + }; + + +} + + +#endif + diff --git a/xs/src/agg/agg_scanline_storage_aa.h b/xs/src/agg/agg_scanline_storage_aa.h new file mode 100644 index 0000000000..4c6ed5708f --- /dev/null +++ b/xs/src/agg/agg_scanline_storage_aa.h @@ -0,0 +1,816 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_SCANLINE_STORAGE_AA_INCLUDED +#define AGG_SCANLINE_STORAGE_AA_INCLUDED + +#include +#include +#include +#include +#include "agg_array.h" + + +namespace agg +{ + + //----------------------------------------------scanline_cell_storage + template class scanline_cell_storage + { + struct extra_span + { + unsigned len; + T* ptr; + }; + + public: + typedef T value_type; + + //--------------------------------------------------------------- + ~scanline_cell_storage() + { + remove_all(); + } + + //--------------------------------------------------------------- + scanline_cell_storage() : + m_cells(128-2), + m_extra_storage() + {} + + + // Copying + //--------------------------------------------------------------- + scanline_cell_storage(const scanline_cell_storage& v) : + m_cells(v.m_cells), + m_extra_storage() + { + copy_extra_storage(v); + } + + //--------------------------------------------------------------- + const scanline_cell_storage& + operator = (const scanline_cell_storage& v) + { + remove_all(); + m_cells = v.m_cells; + copy_extra_storage(v); + return *this; + } + + //--------------------------------------------------------------- + void remove_all() + { + int i; + for(i = m_extra_storage.size()-1; i >= 0; --i) + { + pod_allocator::deallocate(m_extra_storage[i].ptr, + m_extra_storage[i].len); + } + m_extra_storage.remove_all(); + m_cells.remove_all(); + } + + //--------------------------------------------------------------- + int add_cells(const T* cells, unsigned num_cells) + { + int idx = m_cells.allocate_continuous_block(num_cells); + if(idx >= 0) + { + T* ptr = &m_cells[idx]; + memcpy(ptr, cells, sizeof(T) * num_cells); + return idx; + } + extra_span s; + s.len = num_cells; + s.ptr = pod_allocator::allocate(num_cells); + memcpy(s.ptr, cells, sizeof(T) * num_cells); + m_extra_storage.add(s); + return -int(m_extra_storage.size()); + } + + //--------------------------------------------------------------- + const T* operator [] (int idx) const + { + if(idx >= 0) + { + if((unsigned)idx >= m_cells.size()) return 0; + return &m_cells[(unsigned)idx]; + } + unsigned i = unsigned(-idx - 1); + if(i >= m_extra_storage.size()) return 0; + return m_extra_storage[i].ptr; + } + + //--------------------------------------------------------------- + T* operator [] (int idx) + { + if(idx >= 0) + { + if((unsigned)idx >= m_cells.size()) return 0; + return &m_cells[(unsigned)idx]; + } + unsigned i = unsigned(-idx - 1); + if(i >= m_extra_storage.size()) return 0; + return m_extra_storage[i].ptr; + } + + private: + void copy_extra_storage(const scanline_cell_storage& v) + { + unsigned i; + for(i = 0; i < v.m_extra_storage.size(); ++i) + { + const extra_span& src = v.m_extra_storage[i]; + extra_span dst; + dst.len = src.len; + dst.ptr = pod_allocator::allocate(dst.len); + memcpy(dst.ptr, src.ptr, dst.len * sizeof(T)); + m_extra_storage.add(dst); + } + } + + pod_bvector m_cells; + pod_bvector m_extra_storage; + }; + + + + + + + //-----------------------------------------------scanline_storage_aa + template class scanline_storage_aa + { + public: + typedef T cover_type; + + //--------------------------------------------------------------- + struct span_data + { + int32 x; + int32 len; // If negative, it's a solid span, covers is valid + int covers_id; // The index of the cells in the scanline_cell_storage + }; + + //--------------------------------------------------------------- + struct scanline_data + { + int y; + unsigned num_spans; + unsigned start_span; + }; + + + //--------------------------------------------------------------- + class embedded_scanline + { + public: + + //----------------------------------------------------------- + class const_iterator + { + public: + struct span + { + int32 x; + int32 len; // If negative, it's a solid span, covers is valid + const T* covers; + }; + + const_iterator() : m_storage(0) {} + const_iterator(embedded_scanline& sl) : + m_storage(sl.m_storage), + m_span_idx(sl.m_scanline.start_span) + { + init_span(); + } + + const span& operator*() const { return m_span; } + const span* operator->() const { return &m_span; } + + void operator ++ () + { + ++m_span_idx; + init_span(); + } + + private: + void init_span() + { + const span_data& s = m_storage->span_by_index(m_span_idx); + m_span.x = s.x; + m_span.len = s.len; + m_span.covers = m_storage->covers_by_index(s.covers_id); + } + + scanline_storage_aa* m_storage; + unsigned m_span_idx; + span m_span; + }; + + friend class const_iterator; + + + //----------------------------------------------------------- + embedded_scanline(const scanline_storage_aa& storage) : + m_storage(&storage) + { + init(0); + } + + //----------------------------------------------------------- + void reset(int, int) {} + unsigned num_spans() const { return m_scanline.num_spans; } + int y() const { return m_scanline.y; } + const_iterator begin() const { return const_iterator(*this); } + + //----------------------------------------------------------- + void init(unsigned scanline_idx) + { + m_scanline_idx = scanline_idx; + m_scanline = m_storage->scanline_by_index(m_scanline_idx); + } + + private: + const scanline_storage_aa* m_storage; + scanline_data m_scanline; + unsigned m_scanline_idx; + }; + + + //--------------------------------------------------------------- + scanline_storage_aa() : + m_covers(), + m_spans(256-2), // Block increment size + m_scanlines(), + m_min_x(std::numeric_limits::max()), + m_min_y(std::numeric_limits::max()), + m_max_x(std::numeric_limits::min()), + m_max_y(std::numeric_limits::min()), + m_cur_scanline(0) + { + m_fake_scanline.y = 0; + m_fake_scanline.num_spans = 0; + m_fake_scanline.start_span = 0; + m_fake_span.x = 0; + m_fake_span.len = 0; + m_fake_span.covers_id = 0; + } + + // Renderer Interface + //--------------------------------------------------------------- + void prepare() + { + m_covers.remove_all(); + m_scanlines.remove_all(); + m_spans.remove_all(); + m_min_x = std::numeric_limits::max(); + m_min_y = std::numeric_limits::max(); + m_max_x = std::numeric_limits::min(); + m_max_y = std::numeric_limits::min(); + m_cur_scanline = 0; + } + + //--------------------------------------------------------------- + template void render(const Scanline& sl) + { + scanline_data sl_this; + + int y = sl.y(); + if(y < m_min_y) m_min_y = y; + if(y > m_max_y) m_max_y = y; + + sl_this.y = y; + sl_this.num_spans = sl.num_spans(); + sl_this.start_span = m_spans.size(); + typename Scanline::const_iterator span_iterator = sl.begin(); + + unsigned num_spans = sl_this.num_spans; + for(;;) + { + span_data sp; + + sp.x = span_iterator->x; + sp.len = span_iterator->len; + int len = abs(int(sp.len)); + sp.covers_id = + m_covers.add_cells(span_iterator->covers, + unsigned(len)); + m_spans.add(sp); + int x1 = sp.x; + int x2 = sp.x + len - 1; + if(x1 < m_min_x) m_min_x = x1; + if(x2 > m_max_x) m_max_x = x2; + if(--num_spans == 0) break; + ++span_iterator; + } + m_scanlines.add(sl_this); + } + + + //--------------------------------------------------------------- + // Iterate scanlines interface + int min_x() const { return m_min_x; } + int min_y() const { return m_min_y; } + int max_x() const { return m_max_x; } + int max_y() const { return m_max_y; } + + //--------------------------------------------------------------- + bool rewind_scanlines() + { + m_cur_scanline = 0; + return m_scanlines.size() > 0; + } + + + //--------------------------------------------------------------- + template bool sweep_scanline(Scanline& sl) + { + sl.reset_spans(); + for(;;) + { + if(m_cur_scanline >= m_scanlines.size()) return false; + const scanline_data& sl_this = m_scanlines[m_cur_scanline]; + + unsigned num_spans = sl_this.num_spans; + unsigned span_idx = sl_this.start_span; + do + { + const span_data& sp = m_spans[span_idx++]; + const T* covers = covers_by_index(sp.covers_id); + if(sp.len < 0) + { + sl.add_span(sp.x, unsigned(-sp.len), *covers); + } + else + { + sl.add_cells(sp.x, sp.len, covers); + } + } + while(--num_spans); + ++m_cur_scanline; + if(sl.num_spans()) + { + sl.finalize(sl_this.y); + break; + } + } + return true; + } + + + //--------------------------------------------------------------- + // Specialization for embedded_scanline + bool sweep_scanline(embedded_scanline& sl) + { + do + { + if(m_cur_scanline >= m_scanlines.size()) return false; + sl.init(m_cur_scanline); + ++m_cur_scanline; + } + while(sl.num_spans() == 0); + return true; + } + + //--------------------------------------------------------------- + unsigned byte_size() const + { + unsigned i; + unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y + + for(i = 0; i < m_scanlines.size(); ++i) + { + size += sizeof(int32) * 3; // scanline size in bytes, Y, num_spans + + const scanline_data& sl_this = m_scanlines[i]; + + unsigned num_spans = sl_this.num_spans; + unsigned span_idx = sl_this.start_span; + do + { + const span_data& sp = m_spans[span_idx++]; + + size += sizeof(int32) * 2; // X, span_len + if(sp.len < 0) + { + size += sizeof(T); // cover + } + else + { + size += sizeof(T) * unsigned(sp.len); // covers + } + } + while(--num_spans); + } + return size; + } + + + //--------------------------------------------------------------- + static void write_int32(int8u* dst, int32 val) + { + dst[0] = ((const int8u*)&val)[0]; + dst[1] = ((const int8u*)&val)[1]; + dst[2] = ((const int8u*)&val)[2]; + dst[3] = ((const int8u*)&val)[3]; + } + + + //--------------------------------------------------------------- + void serialize(int8u* data) const + { + unsigned i; + + write_int32(data, min_x()); // min_x + data += sizeof(int32); + write_int32(data, min_y()); // min_y + data += sizeof(int32); + write_int32(data, max_x()); // max_x + data += sizeof(int32); + write_int32(data, max_y()); // max_y + data += sizeof(int32); + + for(i = 0; i < m_scanlines.size(); ++i) + { + const scanline_data& sl_this = m_scanlines[i]; + + int8u* size_ptr = data; + data += sizeof(int32); // Reserve space for scanline size in bytes + + write_int32(data, sl_this.y); // Y + data += sizeof(int32); + + write_int32(data, sl_this.num_spans); // num_spans + data += sizeof(int32); + + unsigned num_spans = sl_this.num_spans; + unsigned span_idx = sl_this.start_span; + do + { + const span_data& sp = m_spans[span_idx++]; + const T* covers = covers_by_index(sp.covers_id); + + write_int32(data, sp.x); // X + data += sizeof(int32); + + write_int32(data, sp.len); // span_len + data += sizeof(int32); + + if(sp.len < 0) + { + memcpy(data, covers, sizeof(T)); + data += sizeof(T); + } + else + { + memcpy(data, covers, unsigned(sp.len) * sizeof(T)); + data += sizeof(T) * unsigned(sp.len); + } + } + while(--num_spans); + write_int32(size_ptr, int32(unsigned(data - size_ptr))); + } + } + + + //--------------------------------------------------------------- + const scanline_data& scanline_by_index(unsigned i) const + { + return (i < m_scanlines.size()) ? m_scanlines[i] : m_fake_scanline; + } + + //--------------------------------------------------------------- + const span_data& span_by_index(unsigned i) const + { + return (i < m_spans.size()) ? m_spans[i] : m_fake_span; + } + + //--------------------------------------------------------------- + const T* covers_by_index(int i) const + { + return m_covers[i]; + } + + private: + scanline_cell_storage m_covers; + pod_bvector m_spans; + pod_bvector m_scanlines; + span_data m_fake_span; + scanline_data m_fake_scanline; + int m_min_x; + int m_min_y; + int m_max_x; + int m_max_y; + unsigned m_cur_scanline; + }; + + + typedef scanline_storage_aa scanline_storage_aa8; //--------scanline_storage_aa8 + typedef scanline_storage_aa scanline_storage_aa16; //--------scanline_storage_aa16 + typedef scanline_storage_aa scanline_storage_aa32; //--------scanline_storage_aa32 + + + + + //------------------------------------------serialized_scanlines_adaptor_aa + template class serialized_scanlines_adaptor_aa + { + public: + typedef T cover_type; + + //--------------------------------------------------------------------- + class embedded_scanline + { + public: + typedef T cover_type; + + //----------------------------------------------------------------- + class const_iterator + { + public: + struct span + { + int32 x; + int32 len; // If negative, it's a solid span, "covers" is valid + const T* covers; + }; + + const_iterator() : m_ptr(0) {} + const_iterator(const embedded_scanline* sl) : + m_ptr(sl->m_ptr), + m_dx(sl->m_dx) + { + init_span(); + } + + const span& operator*() const { return m_span; } + const span* operator->() const { return &m_span; } + + void operator ++ () + { + if(m_span.len < 0) + { + m_ptr += sizeof(T); + } + else + { + m_ptr += m_span.len * sizeof(T); + } + init_span(); + } + + private: + int read_int32() + { + int32 val; + ((int8u*)&val)[0] = *m_ptr++; + ((int8u*)&val)[1] = *m_ptr++; + ((int8u*)&val)[2] = *m_ptr++; + ((int8u*)&val)[3] = *m_ptr++; + return val; + } + + void init_span() + { + m_span.x = read_int32() + m_dx; + m_span.len = read_int32(); + m_span.covers = m_ptr; + } + + const int8u* m_ptr; + span m_span; + int m_dx; + }; + + friend class const_iterator; + + + //----------------------------------------------------------------- + embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {} + + //----------------------------------------------------------------- + void reset(int, int) {} + unsigned num_spans() const { return m_num_spans; } + int y() const { return m_y; } + const_iterator begin() const { return const_iterator(this); } + + + private: + //----------------------------------------------------------------- + int read_int32() + { + int32 val; + ((int8u*)&val)[0] = *m_ptr++; + ((int8u*)&val)[1] = *m_ptr++; + ((int8u*)&val)[2] = *m_ptr++; + ((int8u*)&val)[3] = *m_ptr++; + return val; + } + + public: + //----------------------------------------------------------------- + void init(const int8u* ptr, int dx, int dy) + { + m_ptr = ptr; + m_y = read_int32() + dy; + m_num_spans = unsigned(read_int32()); + m_dx = dx; + } + + private: + const int8u* m_ptr; + int m_y; + unsigned m_num_spans; + int m_dx; + }; + + + + public: + //-------------------------------------------------------------------- + serialized_scanlines_adaptor_aa() : + m_data(0), + m_end(0), + m_ptr(0), + m_dx(0), + m_dy(0), + m_min_x(std::numeric_limits::max()), + m_min_y(std::numeric_limits::max()), + m_max_x(std::numeric_limits::min()), + m_max_y(std::numeric_limits::min()) + {} + + //-------------------------------------------------------------------- + serialized_scanlines_adaptor_aa(const int8u* data, unsigned size, + double dx, double dy) : + m_data(data), + m_end(data + size), + m_ptr(data), + m_dx(iround(dx)), + m_dy(iround(dy)), + m_min_x(std::numeric_limits::max()), + m_min_y(std::numeric_limits::max()), + m_max_x(std::numeric_limits::min()), + m_max_y(std::numeric_limits::min()) + {} + + //-------------------------------------------------------------------- + void init(const int8u* data, unsigned size, double dx, double dy) + { + m_data = data; + m_end = data + size; + m_ptr = data; + m_dx = iround(dx); + m_dy = iround(dy); + m_min_x = std::numeric_limits::max(); + m_min_y = std::numeric_limits::max(); + m_max_x = std::numeric_limits::min(); + m_max_y = std::numeric_limits::min(); + } + + private: + //-------------------------------------------------------------------- + int read_int32() + { + int32 val; + ((int8u*)&val)[0] = *m_ptr++; + ((int8u*)&val)[1] = *m_ptr++; + ((int8u*)&val)[2] = *m_ptr++; + ((int8u*)&val)[3] = *m_ptr++; + return val; + } + + //-------------------------------------------------------------------- + unsigned read_int32u() + { + int32u val; + ((int8u*)&val)[0] = *m_ptr++; + ((int8u*)&val)[1] = *m_ptr++; + ((int8u*)&val)[2] = *m_ptr++; + ((int8u*)&val)[3] = *m_ptr++; + return val; + } + + public: + // Iterate scanlines interface + //-------------------------------------------------------------------- + bool rewind_scanlines() + { + m_ptr = m_data; + if(m_ptr < m_end) + { + m_min_x = read_int32() + m_dx; + m_min_y = read_int32() + m_dy; + m_max_x = read_int32() + m_dx; + m_max_y = read_int32() + m_dy; + } + return m_ptr < m_end; + } + + //-------------------------------------------------------------------- + int min_x() const { return m_min_x; } + int min_y() const { return m_min_y; } + int max_x() const { return m_max_x; } + int max_y() const { return m_max_y; } + + //-------------------------------------------------------------------- + template bool sweep_scanline(Scanline& sl) + { + sl.reset_spans(); + for(;;) + { + if(m_ptr >= m_end) return false; + + read_int32(); // Skip scanline size in bytes + int y = read_int32() + m_dy; + unsigned num_spans = read_int32(); + + do + { + int x = read_int32() + m_dx; + int len = read_int32(); + + if(len < 0) + { + sl.add_span(x, unsigned(-len), *m_ptr); + m_ptr += sizeof(T); + } + else + { + sl.add_cells(x, len, m_ptr); + m_ptr += len * sizeof(T); + } + } + while(--num_spans); + + if(sl.num_spans()) + { + sl.finalize(y); + break; + } + } + return true; + } + + + //-------------------------------------------------------------------- + // Specialization for embedded_scanline + bool sweep_scanline(embedded_scanline& sl) + { + do + { + if(m_ptr >= m_end) return false; + + unsigned byte_size = read_int32u(); + sl.init(m_ptr, m_dx, m_dy); + m_ptr += byte_size - sizeof(int32); + } + while(sl.num_spans() == 0); + return true; + } + + private: + const int8u* m_data; + const int8u* m_end; + const int8u* m_ptr; + int m_dx; + int m_dy; + int m_min_x; + int m_min_y; + int m_max_x; + int m_max_y; + }; + + + + typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa8; //----serialized_scanlines_adaptor_aa8 + typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa16; //----serialized_scanlines_adaptor_aa16 + typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa32; //----serialized_scanlines_adaptor_aa32 + +} + + +#endif + diff --git a/xs/src/agg/agg_scanline_storage_bin.h b/xs/src/agg/agg_scanline_storage_bin.h new file mode 100644 index 0000000000..0018d4ba60 --- /dev/null +++ b/xs/src/agg/agg_scanline_storage_bin.h @@ -0,0 +1,587 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + + +#ifndef AGG_SCANLINE_STORAGE_BIN_INCLUDED +#define AGG_SCANLINE_STORAGE_BIN_INCLUDED + +#include +#include +#include +#include +#include "agg_array.h" + + +namespace agg +{ + + //-----------------------------------------------scanline_storage_bin + class scanline_storage_bin + { + public: + //--------------------------------------------------------------- + struct span_data + { + int32 x; + int32 len; + }; + + //--------------------------------------------------------------- + struct scanline_data + { + int y; + unsigned num_spans; + unsigned start_span; + }; + + + //--------------------------------------------------------------- + class embedded_scanline + { + public: + + //----------------------------------------------------------- + class const_iterator + { + public: + const_iterator() : m_storage(0) {} + const_iterator(const embedded_scanline* sl) : + m_storage(sl->m_storage), + m_span_idx(sl->m_scanline.start_span) + { + m_span = m_storage->span_by_index(m_span_idx); + } + + const span_data& operator*() const { return m_span; } + const span_data* operator->() const { return &m_span; } + + void operator ++ () + { + ++m_span_idx; + m_span = m_storage->span_by_index(m_span_idx); + } + + private: + const scanline_storage_bin* m_storage; + unsigned m_span_idx; + span_data m_span; + }; + + friend class const_iterator; + + + //----------------------------------------------------------- + embedded_scanline(scanline_storage_bin& storage) : + m_storage(&storage) + { + setup(0); + } + + //----------------------------------------------------------- + void reset(int, int) {} + unsigned num_spans() const { return m_scanline.num_spans; } + int y() const { return m_scanline.y; } + const_iterator begin() const { return const_iterator(this); } + + //----------------------------------------------------------- + void setup(unsigned scanline_idx) + { + m_scanline_idx = scanline_idx; + m_scanline = m_storage->scanline_by_index(m_scanline_idx); + } + + private: + scanline_storage_bin* m_storage; + scanline_data m_scanline; + unsigned m_scanline_idx; + }; + + + //--------------------------------------------------------------- + scanline_storage_bin() : + m_spans(256-2), // Block increment size + m_scanlines(), + m_min_x(std::numeric_limits::max()), + m_min_y(std::numeric_limits::max()), + m_max_x(std::numeric_limits::min()), + m_max_y(std::numeric_limits::min()), + m_cur_scanline(0) + { + m_fake_scanline.y = 0; + m_fake_scanline.num_spans = 0; + m_fake_scanline.start_span = 0; + m_fake_span.x = 0; + m_fake_span.len = 0; + } + + // Renderer Interface + //--------------------------------------------------------------- + void prepare() + { + m_scanlines.remove_all(); + m_spans.remove_all(); + m_min_x = std::numeric_limits::max(); + m_min_y = std::numeric_limits::max(); + m_max_x = std::numeric_limits::min(); + m_max_y = std::numeric_limits::min(); + m_cur_scanline = 0; + } + + //--------------------------------------------------------------- + template void render(const Scanline& sl) + { + scanline_data sl_this; + + int y = sl.y(); + if(y < m_min_y) m_min_y = y; + if(y > m_max_y) m_max_y = y; + + sl_this.y = y; + sl_this.num_spans = sl.num_spans(); + sl_this.start_span = m_spans.size(); + typename Scanline::const_iterator span_iterator = sl.begin(); + + unsigned num_spans = sl_this.num_spans; + for(;;) + { + span_data sp; + sp.x = span_iterator->x; + sp.len = (int32)abs((int)(span_iterator->len)); + m_spans.add(sp); + int x1 = sp.x; + int x2 = sp.x + sp.len - 1; + if(x1 < m_min_x) m_min_x = x1; + if(x2 > m_max_x) m_max_x = x2; + if(--num_spans == 0) break; + ++span_iterator; + } + m_scanlines.add(sl_this); + } + + + //--------------------------------------------------------------- + // Iterate scanlines interface + int min_x() const { return m_min_x; } + int min_y() const { return m_min_y; } + int max_x() const { return m_max_x; } + int max_y() const { return m_max_y; } + + //--------------------------------------------------------------- + bool rewind_scanlines() + { + m_cur_scanline = 0; + return m_scanlines.size() > 0; + } + + + //--------------------------------------------------------------- + template bool sweep_scanline(Scanline& sl) + { + sl.reset_spans(); + for(;;) + { + if(m_cur_scanline >= m_scanlines.size()) return false; + const scanline_data& sl_this = m_scanlines[m_cur_scanline]; + + unsigned num_spans = sl_this.num_spans; + unsigned span_idx = sl_this.start_span; + do + { + const span_data& sp = m_spans[span_idx++]; + sl.add_span(sp.x, sp.len, cover_full); + } + while(--num_spans); + + ++m_cur_scanline; + if(sl.num_spans()) + { + sl.finalize(sl_this.y); + break; + } + } + return true; + } + + + //--------------------------------------------------------------- + // Specialization for embedded_scanline + bool sweep_scanline(embedded_scanline& sl) + { + do + { + if(m_cur_scanline >= m_scanlines.size()) return false; + sl.setup(m_cur_scanline); + ++m_cur_scanline; + } + while(sl.num_spans() == 0); + return true; + } + + + //--------------------------------------------------------------- + unsigned byte_size() const + { + unsigned i; + unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y + + for(i = 0; i < m_scanlines.size(); ++i) + { + size += sizeof(int32) * 2 + // Y, num_spans + unsigned(m_scanlines[i].num_spans) * sizeof(int32) * 2; // X, span_len + } + return size; + } + + + //--------------------------------------------------------------- + static void write_int32(int8u* dst, int32 val) + { + dst[0] = ((const int8u*)&val)[0]; + dst[1] = ((const int8u*)&val)[1]; + dst[2] = ((const int8u*)&val)[2]; + dst[3] = ((const int8u*)&val)[3]; + } + + + //--------------------------------------------------------------- + void serialize(int8u* data) const + { + unsigned i; + + write_int32(data, min_x()); // min_x + data += sizeof(int32); + write_int32(data, min_y()); // min_y + data += sizeof(int32); + write_int32(data, max_x()); // max_x + data += sizeof(int32); + write_int32(data, max_y()); // max_y + data += sizeof(int32); + + for(i = 0; i < m_scanlines.size(); ++i) + { + const scanline_data& sl_this = m_scanlines[i]; + + write_int32(data, sl_this.y); // Y + data += sizeof(int32); + + write_int32(data, sl_this.num_spans); // num_spans + data += sizeof(int32); + + unsigned num_spans = sl_this.num_spans; + unsigned span_idx = sl_this.start_span; + do + { + const span_data& sp = m_spans[span_idx++]; + + write_int32(data, sp.x); // X + data += sizeof(int32); + + write_int32(data, sp.len); // len + data += sizeof(int32); + } + while(--num_spans); + } + } + + + //--------------------------------------------------------------- + const scanline_data& scanline_by_index(unsigned i) const + { + return (i < m_scanlines.size()) ? m_scanlines[i] : m_fake_scanline; + } + + //--------------------------------------------------------------- + const span_data& span_by_index(unsigned i) const + { + return (i < m_spans.size()) ? m_spans[i] : m_fake_span; + } + + + private: + pod_bvector m_spans; + pod_bvector m_scanlines; + span_data m_fake_span; + scanline_data m_fake_scanline; + int m_min_x; + int m_min_y; + int m_max_x; + int m_max_y; + unsigned m_cur_scanline; + }; + + + + + + + + + + + + + + //---------------------------------------serialized_scanlines_adaptor_bin + class serialized_scanlines_adaptor_bin + { + public: + typedef bool cover_type; + + //-------------------------------------------------------------------- + class embedded_scanline + { + public: + + //---------------------------------------------------------------- + class const_iterator + { + public: + struct span + { + int32 x; + int32 len; + }; + + const_iterator() : m_ptr(0) {} + const_iterator(const embedded_scanline* sl) : + m_ptr(sl->m_ptr), + m_dx(sl->m_dx) + { + m_span.x = read_int32() + m_dx; + m_span.len = read_int32(); + } + + const span& operator*() const { return m_span; } + const span* operator->() const { return &m_span; } + + void operator ++ () + { + m_span.x = read_int32() + m_dx; + m_span.len = read_int32(); + } + + private: + int read_int32() + { + int32 val; + ((int8u*)&val)[0] = *m_ptr++; + ((int8u*)&val)[1] = *m_ptr++; + ((int8u*)&val)[2] = *m_ptr++; + ((int8u*)&val)[3] = *m_ptr++; + return val; + } + + const int8u* m_ptr; + span m_span; + int m_dx; + }; + + friend class const_iterator; + + + //---------------------------------------------------------------- + embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {} + + //---------------------------------------------------------------- + void reset(int, int) {} + unsigned num_spans() const { return m_num_spans; } + int y() const { return m_y; } + const_iterator begin() const { return const_iterator(this); } + + + private: + //---------------------------------------------------------------- + int read_int32() + { + int32 val; + ((int8u*)&val)[0] = *m_ptr++; + ((int8u*)&val)[1] = *m_ptr++; + ((int8u*)&val)[2] = *m_ptr++; + ((int8u*)&val)[3] = *m_ptr++; + return val; + } + + public: + //---------------------------------------------------------------- + void init(const int8u* ptr, int dx, int dy) + { + m_ptr = ptr; + m_y = read_int32() + dy; + m_num_spans = unsigned(read_int32()); + m_dx = dx; + } + + private: + const int8u* m_ptr; + int m_y; + unsigned m_num_spans; + int m_dx; + }; + + + + public: + //-------------------------------------------------------------------- + serialized_scanlines_adaptor_bin() : + m_data(0), + m_end(0), + m_ptr(0), + m_dx(0), + m_dy(0), + m_min_x(std::numeric_limits::max()), + m_min_y(std::numeric_limits::max()), + m_max_x(std::numeric_limits::min()), + m_max_y(std::numeric_limits::min()) + {} + + //-------------------------------------------------------------------- + serialized_scanlines_adaptor_bin(const int8u* data, unsigned size, + double dx, double dy) : + m_data(data), + m_end(data + size), + m_ptr(data), + m_dx(iround(dx)), + m_dy(iround(dy)), + m_min_x(std::numeric_limits::max()), + m_min_y(std::numeric_limits::max()), + m_max_x(std::numeric_limits::min()), + m_max_y(std::numeric_limits::min()) + {} + + //-------------------------------------------------------------------- + void init(const int8u* data, unsigned size, double dx, double dy) + { + m_data = data; + m_end = data + size; + m_ptr = data; + m_dx = iround(dx); + m_dy = iround(dy); + m_min_x = std::numeric_limits::max(); + m_min_y = std::numeric_limits::max(); + m_max_x = std::numeric_limits::min(); + m_max_y = std::numeric_limits::min(); + } + + private: + //-------------------------------------------------------------------- + int read_int32() + { + int32 val; + ((int8u*)&val)[0] = *m_ptr++; + ((int8u*)&val)[1] = *m_ptr++; + ((int8u*)&val)[2] = *m_ptr++; + ((int8u*)&val)[3] = *m_ptr++; + return val; + } + + public: + // Iterate scanlines interface + //-------------------------------------------------------------------- + bool rewind_scanlines() + { + m_ptr = m_data; + if(m_ptr < m_end) + { + m_min_x = read_int32() + m_dx; + m_min_y = read_int32() + m_dy; + m_max_x = read_int32() + m_dx; + m_max_y = read_int32() + m_dy; + } + return m_ptr < m_end; + } + + //-------------------------------------------------------------------- + int min_x() const { return m_min_x; } + int min_y() const { return m_min_y; } + int max_x() const { return m_max_x; } + int max_y() const { return m_max_y; } + + //-------------------------------------------------------------------- + template bool sweep_scanline(Scanline& sl) + { + sl.reset_spans(); + for(;;) + { + if(m_ptr >= m_end) return false; + + int y = read_int32() + m_dy; + unsigned num_spans = read_int32(); + + do + { + int x = read_int32() + m_dx; + int len = read_int32(); + + if(len < 0) len = -len; + sl.add_span(x, unsigned(len), cover_full); + } + while(--num_spans); + + if(sl.num_spans()) + { + sl.finalize(y); + break; + } + } + return true; + } + + + //-------------------------------------------------------------------- + // Specialization for embedded_scanline + bool sweep_scanline(embedded_scanline& sl) + { + do + { + if(m_ptr >= m_end) return false; + + sl.init(m_ptr, m_dx, m_dy); + + // Jump to the next scanline + //-------------------------- + read_int32(); // Y + int num_spans = read_int32(); // num_spans + m_ptr += num_spans * sizeof(int32) * 2; + } + while(sl.num_spans() == 0); + return true; + } + + private: + const int8u* m_data; + const int8u* m_end; + const int8u* m_ptr; + int m_dx; + int m_dy; + int m_min_x; + int m_min_y; + int m_max_x; + int m_max_y; + }; + + + +} + +#endif + diff --git a/xs/src/agg/agg_scanline_u.h b/xs/src/agg/agg_scanline_u.h new file mode 100644 index 0000000000..630eb9deac --- /dev/null +++ b/xs/src/agg/agg_scanline_u.h @@ -0,0 +1,499 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for 32-bit screen coordinates (scanline32_u) has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_SCANLINE_U_INCLUDED +#define AGG_SCANLINE_U_INCLUDED + +#include "agg_array.h" + +namespace agg +{ + //=============================================================scanline_u8 + // + // Unpacked scanline container class + // + // This class is used to transfer data from a scanline rasterizer + // to the rendering buffer. It's organized very simple. The class stores + // information of horizontal spans to render it into a pixel-map buffer. + // Each span has staring X, length, and an array of bytes that determine the + // cover-values for each pixel. + // Before using this class you should know the minimal and maximal pixel + // coordinates of your scanline. The protocol of using is: + // 1. reset(min_x, max_x) + // 2. add_cell() / add_span() - accumulate scanline. + // When forming one scanline the next X coordinate must be always greater + // than the last stored one, i.e. it works only with ordered coordinates. + // 3. Call finalize(y) and render the scanline. + // 3. Call reset_spans() to prepare for the new scanline. + // + // 4. Rendering: + // + // Scanline provides an iterator class that allows you to extract + // the spans and the cover values for each pixel. Be aware that clipping + // has not been done yet, so you should perform it yourself. + // Use scanline_u8::iterator to render spans: + //------------------------------------------------------------------------- + // + // int y = sl.y(); // Y-coordinate of the scanline + // + // ************************************ + // ...Perform vertical clipping here... + // ************************************ + // + // scanline_u8::const_iterator span = sl.begin(); + // + // unsigned char* row = m_rbuf->row(y); // The the address of the beginning + // // of the current row + // + // unsigned num_spans = sl.num_spans(); // Number of spans. It's guaranteed that + // // num_spans is always greater than 0. + // + // do + // { + // const scanline_u8::cover_type* covers = + // span->covers; // The array of the cover values + // + // int num_pix = span->len; // Number of pixels of the span. + // // Always greater than 0, still it's + // // better to use "int" instead of + // // "unsigned" because it's more + // // convenient for clipping + // int x = span->x; + // + // ************************************** + // ...Perform horizontal clipping here... + // ...you have x, covers, and pix_count.. + // ************************************** + // + // unsigned char* dst = row + x; // Calculate the start address of the row. + // // In this case we assume a simple + // // grayscale image 1-byte per pixel. + // do + // { + // *dst++ = *covers++; // Hypotetical rendering. + // } + // while(--num_pix); + // + // ++span; + // } + // while(--num_spans); // num_spans cannot be 0, so this loop is quite safe + //------------------------------------------------------------------------ + // + // The question is: why should we accumulate the whole scanline when we + // could render just separate spans when they're ready? + // That's because using the scanline is generally faster. When is consists + // of more than one span the conditions for the processor cash system + // are better, because switching between two different areas of memory + // (that can be very large) occurs less frequently. + //------------------------------------------------------------------------ + class scanline_u8 + { + public: + typedef scanline_u8 self_type; + typedef int8u cover_type; + typedef int16 coord_type; + + //-------------------------------------------------------------------- + struct span + { + coord_type x; + coord_type len; + cover_type* covers; + }; + + typedef span* iterator; + typedef const span* const_iterator; + + //-------------------------------------------------------------------- + scanline_u8() : + m_min_x(0), + m_last_x(0x7FFFFFF0), + m_cur_span(0) + {} + + //-------------------------------------------------------------------- + void reset(int min_x, int max_x) + { + unsigned max_len = max_x - min_x + 2; + if(max_len > m_spans.size()) + { + m_spans.resize(max_len); + m_covers.resize(max_len); + } + m_last_x = 0x7FFFFFF0; + m_min_x = min_x; + m_cur_span = &m_spans[0]; + } + + //-------------------------------------------------------------------- + void add_cell(int x, unsigned cover) + { + x -= m_min_x; + m_covers[x] = (cover_type)cover; + if(x == m_last_x+1) + { + m_cur_span->len++; + } + else + { + m_cur_span++; + m_cur_span->x = (coord_type)(x + m_min_x); + m_cur_span->len = 1; + m_cur_span->covers = &m_covers[x]; + } + m_last_x = x; + } + + //-------------------------------------------------------------------- + void add_cells(int x, unsigned len, const cover_type* covers) + { + x -= m_min_x; + memcpy(&m_covers[x], covers, len * sizeof(cover_type)); + if(x == m_last_x+1) + { + m_cur_span->len += (coord_type)len; + } + else + { + m_cur_span++; + m_cur_span->x = (coord_type)(x + m_min_x); + m_cur_span->len = (coord_type)len; + m_cur_span->covers = &m_covers[x]; + } + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void add_span(int x, unsigned len, unsigned cover) + { + x -= m_min_x; + memset(&m_covers[x], cover, len); + if(x == m_last_x+1) + { + m_cur_span->len += (coord_type)len; + } + else + { + m_cur_span++; + m_cur_span->x = (coord_type)(x + m_min_x); + m_cur_span->len = (coord_type)len; + m_cur_span->covers = &m_covers[x]; + } + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void finalize(int y) + { + m_y = y; + } + + //-------------------------------------------------------------------- + void reset_spans() + { + m_last_x = 0x7FFFFFF0; + m_cur_span = &m_spans[0]; + } + + //-------------------------------------------------------------------- + int y() const { return m_y; } + unsigned num_spans() const { return unsigned(m_cur_span - &m_spans[0]); } + const_iterator begin() const { return &m_spans[1]; } + iterator begin() { return &m_spans[1]; } + + private: + scanline_u8(const self_type&); + const self_type& operator = (const self_type&); + + private: + int m_min_x; + int m_last_x; + int m_y; + pod_array m_covers; + pod_array m_spans; + span* m_cur_span; + }; + + + + + //==========================================================scanline_u8_am + // + // The scanline container with alpha-masking + // + //------------------------------------------------------------------------ + template + class scanline_u8_am : public scanline_u8 + { + public: + typedef scanline_u8 base_type; + typedef AlphaMask alpha_mask_type; + typedef base_type::cover_type cover_type; + typedef base_type::coord_type coord_type; + + scanline_u8_am() : base_type(), m_alpha_mask(0) {} + scanline_u8_am(AlphaMask& am) : base_type(), m_alpha_mask(&am) {} + + //-------------------------------------------------------------------- + void finalize(int span_y) + { + base_type::finalize(span_y); + if(m_alpha_mask) + { + typename base_type::iterator span = base_type::begin(); + unsigned count = base_type::num_spans(); + do + { + m_alpha_mask->combine_hspan(span->x, + base_type::y(), + span->covers, + span->len); + ++span; + } + while(--count); + } + } + + private: + AlphaMask* m_alpha_mask; + }; + + + + + //===========================================================scanline32_u8 + class scanline32_u8 + { + public: + typedef scanline32_u8 self_type; + typedef int8u cover_type; + typedef int32 coord_type; + + //-------------------------------------------------------------------- + struct span + { + span() {} + span(coord_type x_, coord_type len_, cover_type* covers_) : + x(x_), len(len_), covers(covers_) {} + + coord_type x; + coord_type len; + cover_type* covers; + }; + + typedef pod_bvector span_array_type; + + //-------------------------------------------------------------------- + class const_iterator + { + public: + const_iterator(const span_array_type& spans) : + m_spans(spans), + m_span_idx(0) + {} + + const span& operator*() const { return m_spans[m_span_idx]; } + const span* operator->() const { return &m_spans[m_span_idx]; } + + void operator ++ () { ++m_span_idx; } + + private: + const span_array_type& m_spans; + unsigned m_span_idx; + }; + + //-------------------------------------------------------------------- + class iterator + { + public: + iterator(span_array_type& spans) : + m_spans(spans), + m_span_idx(0) + {} + + span& operator*() { return m_spans[m_span_idx]; } + span* operator->() { return &m_spans[m_span_idx]; } + + void operator ++ () { ++m_span_idx; } + + private: + span_array_type& m_spans; + unsigned m_span_idx; + }; + + + + //-------------------------------------------------------------------- + scanline32_u8() : + m_min_x(0), + m_last_x(0x7FFFFFF0), + m_covers() + {} + + //-------------------------------------------------------------------- + void reset(int min_x, int max_x) + { + unsigned max_len = max_x - min_x + 2; + if(max_len > m_covers.size()) + { + m_covers.resize(max_len); + } + m_last_x = 0x7FFFFFF0; + m_min_x = min_x; + m_spans.remove_all(); + } + + //-------------------------------------------------------------------- + void add_cell(int x, unsigned cover) + { + x -= m_min_x; + m_covers[x] = cover_type(cover); + if(x == m_last_x+1) + { + m_spans.last().len++; + } + else + { + m_spans.add(span(coord_type(x + m_min_x), 1, &m_covers[x])); + } + m_last_x = x; + } + + //-------------------------------------------------------------------- + void add_cells(int x, unsigned len, const cover_type* covers) + { + x -= m_min_x; + memcpy(&m_covers[x], covers, len * sizeof(cover_type)); + if(x == m_last_x+1) + { + m_spans.last().len += coord_type(len); + } + else + { + m_spans.add(span(coord_type(x + m_min_x), + coord_type(len), + &m_covers[x])); + } + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void add_span(int x, unsigned len, unsigned cover) + { + x -= m_min_x; + memset(&m_covers[x], cover, len); + if(x == m_last_x+1) + { + m_spans.last().len += coord_type(len); + } + else + { + m_spans.add(span(coord_type(x + m_min_x), + coord_type(len), + &m_covers[x])); + } + m_last_x = x + len - 1; + } + + //-------------------------------------------------------------------- + void finalize(int y) + { + m_y = y; + } + + //-------------------------------------------------------------------- + void reset_spans() + { + m_last_x = 0x7FFFFFF0; + m_spans.remove_all(); + } + + //-------------------------------------------------------------------- + int y() const { return m_y; } + unsigned num_spans() const { return m_spans.size(); } + const_iterator begin() const { return const_iterator(m_spans); } + iterator begin() { return iterator(m_spans); } + + private: + scanline32_u8(const self_type&); + const self_type& operator = (const self_type&); + + private: + int m_min_x; + int m_last_x; + int m_y; + pod_array m_covers; + span_array_type m_spans; + }; + + + + + //========================================================scanline32_u8_am + // + // The scanline container with alpha-masking + // + //------------------------------------------------------------------------ + template + class scanline32_u8_am : public scanline32_u8 + { + public: + typedef scanline32_u8 base_type; + typedef AlphaMask alpha_mask_type; + typedef base_type::cover_type cover_type; + typedef base_type::coord_type coord_type; + + + scanline32_u8_am() : base_type(), m_alpha_mask(0) {} + scanline32_u8_am(AlphaMask& am) : base_type(), m_alpha_mask(&am) {} + + //-------------------------------------------------------------------- + void finalize(int span_y) + { + base_type::finalize(span_y); + if(m_alpha_mask) + { + typename base_type::iterator span = base_type::begin(); + unsigned count = base_type::num_spans(); + do + { + m_alpha_mask->combine_hspan(span->x, + base_type::y(), + span->covers, + span->len); + ++span; + } + while(--count); + } + } + + private: + AlphaMask* m_alpha_mask; + }; + + + +} + +#endif + diff --git a/xs/src/agg/agg_shorten_path.h b/xs/src/agg/agg_shorten_path.h new file mode 100644 index 0000000000..dd9929ff97 --- /dev/null +++ b/xs/src/agg/agg_shorten_path.h @@ -0,0 +1,66 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SHORTEN_PATH_INCLUDED +#define AGG_SHORTEN_PATH_INCLUDED + +#include "agg_basics.h" +#include "agg_vertex_sequence.h" + +namespace agg +{ + + //===========================================================shorten_path + template + void shorten_path(VertexSequence& vs, double s, unsigned closed = 0) + { + typedef typename VertexSequence::value_type vertex_type; + + if(s > 0.0 && vs.size() > 1) + { + double d; + int n = int(vs.size() - 2); + while(n) + { + d = vs[n].dist; + if(d > s) break; + vs.remove_last(); + s -= d; + --n; + } + if(vs.size() < 2) + { + vs.remove_all(); + } + else + { + n = vs.size() - 1; + vertex_type& prev = vs[n-1]; + vertex_type& last = vs[n]; + d = (prev.dist - s) / prev.dist; + double x = prev.x + (last.x - prev.x) * d; + double y = prev.y + (last.y - prev.y) * d; + last.x = x; + last.y = y; + if(!prev(last)) vs.remove_last(); + vs.close(closed != 0); + } + } + } + + +} + +#endif diff --git a/xs/src/agg/agg_simul_eq.h b/xs/src/agg/agg_simul_eq.h new file mode 100644 index 0000000000..3d0dce4b44 --- /dev/null +++ b/xs/src/agg/agg_simul_eq.h @@ -0,0 +1,147 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Solving simultaneous equations +// +//---------------------------------------------------------------------------- +#ifndef AGG_SIMUL_EQ_INCLUDED +#define AGG_SIMUL_EQ_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + + //=============================================================swap_arrays + template void swap_arrays(T* a1, T* a2, unsigned n) + { + unsigned i; + for(i = 0; i < n; i++) + { + T tmp = *a1; + *a1++ = *a2; + *a2++ = tmp; + } + } + + + //============================================================matrix_pivot + template + struct matrix_pivot + { + static int pivot(double m[Rows][Cols], unsigned row) + { + int k = int(row); + double max_val, tmp; + + max_val = -1.0; + unsigned i; + for(i = row; i < Rows; i++) + { + if((tmp = fabs(m[i][row])) > max_val && tmp != 0.0) + { + max_val = tmp; + k = i; + } + } + + if(m[k][row] == 0.0) + { + return -1; + } + + if(k != int(row)) + { + swap_arrays(m[k], m[row], Cols); + return k; + } + return 0; + } + }; + + + + //===============================================================simul_eq + template + struct simul_eq + { + static bool solve(const double left[Size][Size], + const double right[Size][RightCols], + double result[Size][RightCols]) + { + unsigned i, j, k; + double a1; + + double tmp[Size][Size + RightCols]; + + for(i = 0; i < Size; i++) + { + for(j = 0; j < Size; j++) + { + tmp[i][j] = left[i][j]; + } + for(j = 0; j < RightCols; j++) + { + tmp[i][Size + j] = right[i][j]; + } + } + + for(k = 0; k < Size; k++) + { + if(matrix_pivot::pivot(tmp, k) < 0) + { + return false; // Singularity.... + } + + a1 = tmp[k][k]; + + for(j = k; j < Size + RightCols; j++) + { + tmp[k][j] /= a1; + } + + for(i = k + 1; i < Size; i++) + { + a1 = tmp[i][k]; + for (j = k; j < Size + RightCols; j++) + { + tmp[i][j] -= a1 * tmp[k][j]; + } + } + } + + + for(k = 0; k < RightCols; k++) + { + int m; + for(m = int(Size - 1); m >= 0; m--) + { + result[m][k] = tmp[m][Size + k]; + for(j = m + 1; j < Size; j++) + { + result[m][k] -= tmp[m][j] * result[j][k]; + } + } + } + return true; + } + + }; + + +} + +#endif diff --git a/xs/src/agg/agg_span_allocator.h b/xs/src/agg/agg_span_allocator.h new file mode 100644 index 0000000000..201b69bb01 --- /dev/null +++ b/xs/src/agg/agg_span_allocator.h @@ -0,0 +1,54 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_ALLOCATOR_INCLUDED +#define AGG_SPAN_ALLOCATOR_INCLUDED + +#include "agg_array.h" + +namespace agg +{ + //----------------------------------------------------------span_allocator + template class span_allocator + { + public: + typedef ColorT color_type; + + //-------------------------------------------------------------------- + AGG_INLINE color_type* allocate(unsigned span_len) + { + if(span_len > m_span.size()) + { + // To reduce the number of reallocs we align the + // span_len to 256 color elements. + // Well, I just like this number and it looks reasonable. + //----------------------- + m_span.resize(((span_len + 255) >> 8) << 8); + } + return &m_span[0]; + } + + AGG_INLINE color_type* span() { return &m_span[0]; } + AGG_INLINE unsigned max_span_len() const { return m_span.size(); } + + private: + pod_array m_span; + }; +} + + +#endif + + diff --git a/xs/src/agg/agg_span_converter.h b/xs/src/agg/agg_span_converter.h new file mode 100644 index 0000000000..91d0f87c25 --- /dev/null +++ b/xs/src/agg/agg_span_converter.h @@ -0,0 +1,56 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_CONVERTER_INCLUDED +#define AGG_SPAN_CONVERTER_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + //----------------------------------------------------------span_converter + template class span_converter + { + public: + typedef typename SpanGenerator::color_type color_type; + + span_converter(SpanGenerator& span_gen, SpanConverter& span_cnv) : + m_span_gen(&span_gen), m_span_cnv(&span_cnv) {} + + void attach_generator(SpanGenerator& span_gen) { m_span_gen = &span_gen; } + void attach_converter(SpanConverter& span_cnv) { m_span_cnv = &span_cnv; } + + //-------------------------------------------------------------------- + void prepare() + { + m_span_gen->prepare(); + m_span_cnv->prepare(); + } + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + m_span_gen->generate(span, x, y, len); + m_span_cnv->generate(span, x, y, len); + } + + private: + SpanGenerator* m_span_gen; + SpanConverter* m_span_cnv; + }; + +} + +#endif diff --git a/xs/src/agg/agg_span_gouraud.h b/xs/src/agg/agg_span_gouraud.h new file mode 100644 index 0000000000..2986c88fee --- /dev/null +++ b/xs/src/agg/agg_span_gouraud.h @@ -0,0 +1,172 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_GOURAUD_INCLUDED +#define AGG_SPAN_GOURAUD_INCLUDED + +#include "agg_basics.h" +#include "agg_math.h" + +namespace agg +{ + + //============================================================span_gouraud + template class span_gouraud + { + public: + typedef ColorT color_type; + + struct coord_type + { + double x; + double y; + color_type color; + }; + + //-------------------------------------------------------------------- + span_gouraud() : + m_vertex(0) + { + m_cmd[0] = path_cmd_stop; + } + + //-------------------------------------------------------------------- + span_gouraud(const color_type& c1, + const color_type& c2, + const color_type& c3, + double x1, double y1, + double x2, double y2, + double x3, double y3, + double d) : + m_vertex(0) + { + colors(c1, c2, c3); + triangle(x1, y1, x2, y2, x3, y3, d); + } + + //-------------------------------------------------------------------- + void colors(ColorT c1, ColorT c2, ColorT c3) + { + m_coord[0].color = c1; + m_coord[1].color = c2; + m_coord[2].color = c3; + } + + //-------------------------------------------------------------------- + // Sets the triangle and dilates it if needed. + // The trick here is to calculate beveled joins in the vertices of the + // triangle and render it as a 6-vertex polygon. + // It's necessary to achieve numerical stability. + // However, the coordinates to interpolate colors are calculated + // as miter joins (calc_intersection). + void triangle(double x1, double y1, + double x2, double y2, + double x3, double y3, + double d) + { + m_coord[0].x = m_x[0] = x1; + m_coord[0].y = m_y[0] = y1; + m_coord[1].x = m_x[1] = x2; + m_coord[1].y = m_y[1] = y2; + m_coord[2].x = m_x[2] = x3; + m_coord[2].y = m_y[2] = y3; + m_cmd[0] = path_cmd_move_to; + m_cmd[1] = path_cmd_line_to; + m_cmd[2] = path_cmd_line_to; + m_cmd[3] = path_cmd_stop; + + if(d != 0.0) + { + dilate_triangle(m_coord[0].x, m_coord[0].y, + m_coord[1].x, m_coord[1].y, + m_coord[2].x, m_coord[2].y, + m_x, m_y, d); + + calc_intersection(m_x[4], m_y[4], m_x[5], m_y[5], + m_x[0], m_y[0], m_x[1], m_y[1], + &m_coord[0].x, &m_coord[0].y); + + calc_intersection(m_x[0], m_y[0], m_x[1], m_y[1], + m_x[2], m_y[2], m_x[3], m_y[3], + &m_coord[1].x, &m_coord[1].y); + + calc_intersection(m_x[2], m_y[2], m_x[3], m_y[3], + m_x[4], m_y[4], m_x[5], m_y[5], + &m_coord[2].x, &m_coord[2].y); + m_cmd[3] = path_cmd_line_to; + m_cmd[4] = path_cmd_line_to; + m_cmd[5] = path_cmd_line_to; + m_cmd[6] = path_cmd_stop; + } + } + + //-------------------------------------------------------------------- + // Vertex Source Interface to feed the coordinates to the rasterizer + void rewind(unsigned) + { + m_vertex = 0; + } + + //-------------------------------------------------------------------- + unsigned vertex(double* x, double* y) + { + *x = m_x[m_vertex]; + *y = m_y[m_vertex]; + return m_cmd[m_vertex++]; + } + + protected: + //-------------------------------------------------------------------- + void arrange_vertices(coord_type* coord) const + { + coord[0] = m_coord[0]; + coord[1] = m_coord[1]; + coord[2] = m_coord[2]; + + if(m_coord[0].y > m_coord[2].y) + { + coord[0] = m_coord[2]; + coord[2] = m_coord[0]; + } + + coord_type tmp; + if(coord[0].y > coord[1].y) + { + tmp = coord[1]; + coord[1] = coord[0]; + coord[0] = tmp; + } + + if(coord[1].y > coord[2].y) + { + tmp = coord[2]; + coord[2] = coord[1]; + coord[1] = tmp; + } + } + + private: + //-------------------------------------------------------------------- + coord_type m_coord[3]; + double m_x[8]; + double m_y[8]; + unsigned m_cmd[8]; + unsigned m_vertex; + }; + +} + +#endif + diff --git a/xs/src/agg/agg_span_gouraud_gray.h b/xs/src/agg/agg_span_gouraud_gray.h new file mode 100644 index 0000000000..d5fc39d102 --- /dev/null +++ b/xs/src/agg/agg_span_gouraud_gray.h @@ -0,0 +1,241 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_GOURAUD_GRAY_INCLUDED +#define AGG_SPAN_GOURAUD_GRAY_INCLUDED + +#include "agg_basics.h" +#include "agg_color_gray.h" +#include "agg_dda_line.h" +#include "agg_span_gouraud.h" + +namespace agg +{ + + //=======================================================span_gouraud_gray + template class span_gouraud_gray : public span_gouraud + { + public: + typedef ColorT color_type; + typedef typename color_type::value_type value_type; + typedef span_gouraud base_type; + typedef typename base_type::coord_type coord_type; + enum subpixel_scale_e + { + subpixel_shift = 4, + subpixel_scale = 1 << subpixel_shift + }; + + private: + //-------------------------------------------------------------------- + struct gray_calc + { + void init(const coord_type& c1, const coord_type& c2) + { + m_x1 = c1.x - 0.5; + m_y1 = c1.y - 0.5; + m_dx = c2.x - c1.x; + double dy = c2.y - c1.y; + m_1dy = (fabs(dy) < 1e-10) ? 1e10 : 1.0 / dy; + m_v1 = c1.color.v; + m_a1 = c1.color.a; + m_dv = c2.color.v - m_v1; + m_da = c2.color.a - m_a1; + } + + void calc(double y) + { + double k = (y - m_y1) * m_1dy; + if(k < 0.0) k = 0.0; + if(k > 1.0) k = 1.0; + m_v = m_v1 + iround(m_dv * k); + m_a = m_a1 + iround(m_da * k); + m_x = iround((m_x1 + m_dx * k) * subpixel_scale); + } + + double m_x1; + double m_y1; + double m_dx; + double m_1dy; + int m_v1; + int m_a1; + int m_dv; + int m_da; + int m_v; + int m_a; + int m_x; + }; + + + public: + //-------------------------------------------------------------------- + span_gouraud_gray() {} + span_gouraud_gray(const color_type& c1, + const color_type& c2, + const color_type& c3, + double x1, double y1, + double x2, double y2, + double x3, double y3, + double d = 0) : + base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d) + {} + + //-------------------------------------------------------------------- + void prepare() + { + coord_type coord[3]; + base_type::arrange_vertices(coord); + + m_y2 = int(coord[1].y); + + m_swap = cross_product(coord[0].x, coord[0].y, + coord[2].x, coord[2].y, + coord[1].x, coord[1].y) < 0.0; + + m_c1.init(coord[0], coord[2]); + m_c2.init(coord[0], coord[1]); + m_c3.init(coord[1], coord[2]); + } + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + m_c1.calc(y); + const gray_calc* pc1 = &m_c1; + const gray_calc* pc2 = &m_c2; + + if(y < m_y2) + { + // Bottom part of the triangle (first subtriangle) + //------------------------- + m_c2.calc(y + m_c2.m_1dy); + } + else + { + // Upper part (second subtriangle) + //------------------------- + m_c3.calc(y - m_c3.m_1dy); + pc2 = &m_c3; + } + + if(m_swap) + { + // It means that the triangle is oriented clockwise, + // so that we need to swap the controlling structures + //------------------------- + const gray_calc* t = pc2; + pc2 = pc1; + pc1 = t; + } + + // Get the horizontal length with subpixel accuracy + // and protect it from division by zero + //------------------------- + int nlen = abs(pc2->m_x - pc1->m_x); + if(nlen <= 0) nlen = 1; + + dda_line_interpolator<14> v(pc1->m_v, pc2->m_v, nlen); + dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen); + + // Calculate the starting point of the gradient with subpixel + // accuracy and correct (roll back) the interpolators. + // This operation will also clip the beginning of the span + // if necessary. + //------------------------- + int start = pc1->m_x - (x << subpixel_shift); + v -= start; + a -= start; + nlen += start; + + int vv, va; + enum lim_e { lim = color_type::base_mask }; + + // Beginning part of the span. Since we rolled back the + // interpolators, the color values may have overflow. + // So that, we render the beginning part with checking + // for overflow. It lasts until "start" is positive; + // typically it's 1-2 pixels, but may be more in some cases. + //------------------------- + while(len && start > 0) + { + vv = v.y(); + va = a.y(); + if(vv < 0) vv = 0; if(vv > lim) vv = lim; + if(va < 0) va = 0; if(va > lim) va = lim; + span->v = (value_type)vv; + span->a = (value_type)va; + v += subpixel_scale; + a += subpixel_scale; + nlen -= subpixel_scale; + start -= subpixel_scale; + ++span; + --len; + } + + // Middle part, no checking for overflow. + // Actual spans can be longer than the calculated length + // because of anti-aliasing, thus, the interpolators can + // overflow. But while "nlen" is positive we are safe. + //------------------------- + while(len && nlen > 0) + { + span->v = (value_type)v.y(); + span->a = (value_type)a.y(); + v += subpixel_scale; + a += subpixel_scale; + nlen -= subpixel_scale; + ++span; + --len; + } + + // Ending part; checking for overflow. + // Typically it's 1-2 pixels, but may be more in some cases. + //------------------------- + while(len) + { + vv = v.y(); + va = a.y(); + if(vv < 0) vv = 0; if(vv > lim) vv = lim; + if(va < 0) va = 0; if(va > lim) va = lim; + span->v = (value_type)vv; + span->a = (value_type)va; + v += subpixel_scale; + a += subpixel_scale; + ++span; + --len; + } + } + + + private: + bool m_swap; + int m_y2; + gray_calc m_c1; + gray_calc m_c2; + gray_calc m_c3; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_span_gouraud_rgba.h b/xs/src/agg/agg_span_gouraud_rgba.h new file mode 100644 index 0000000000..89192d227b --- /dev/null +++ b/xs/src/agg/agg_span_gouraud_rgba.h @@ -0,0 +1,277 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_GOURAUD_RGBA_INCLUDED +#define AGG_SPAN_GOURAUD_RGBA_INCLUDED + +#include "agg_basics.h" +#include "agg_color_rgba.h" +#include "agg_dda_line.h" +#include "agg_span_gouraud.h" + +namespace agg +{ + + //=======================================================span_gouraud_rgba + template class span_gouraud_rgba : public span_gouraud + { + public: + typedef ColorT color_type; + typedef typename ColorT::value_type value_type; + typedef span_gouraud base_type; + typedef typename base_type::coord_type coord_type; + enum subpixel_scale_e + { + subpixel_shift = 4, + subpixel_scale = 1 << subpixel_shift + }; + + private: + //-------------------------------------------------------------------- + struct rgba_calc + { + void init(const coord_type& c1, const coord_type& c2) + { + m_x1 = c1.x - 0.5; + m_y1 = c1.y - 0.5; + m_dx = c2.x - c1.x; + double dy = c2.y - c1.y; + m_1dy = (dy < 1e-5) ? 1e5 : 1.0 / dy; + m_r1 = c1.color.r; + m_g1 = c1.color.g; + m_b1 = c1.color.b; + m_a1 = c1.color.a; + m_dr = c2.color.r - m_r1; + m_dg = c2.color.g - m_g1; + m_db = c2.color.b - m_b1; + m_da = c2.color.a - m_a1; + } + + void calc(double y) + { + double k = (y - m_y1) * m_1dy; + if(k < 0.0) k = 0.0; + if(k > 1.0) k = 1.0; + m_r = m_r1 + iround(m_dr * k); + m_g = m_g1 + iround(m_dg * k); + m_b = m_b1 + iround(m_db * k); + m_a = m_a1 + iround(m_da * k); + m_x = iround((m_x1 + m_dx * k) * subpixel_scale); + } + + double m_x1; + double m_y1; + double m_dx; + double m_1dy; + int m_r1; + int m_g1; + int m_b1; + int m_a1; + int m_dr; + int m_dg; + int m_db; + int m_da; + int m_r; + int m_g; + int m_b; + int m_a; + int m_x; + }; + + public: + + //-------------------------------------------------------------------- + span_gouraud_rgba() {} + span_gouraud_rgba(const color_type& c1, + const color_type& c2, + const color_type& c3, + double x1, double y1, + double x2, double y2, + double x3, double y3, + double d = 0) : + base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d) + {} + + //-------------------------------------------------------------------- + void prepare() + { + coord_type coord[3]; + base_type::arrange_vertices(coord); + + m_y2 = int(coord[1].y); + + m_swap = cross_product(coord[0].x, coord[0].y, + coord[2].x, coord[2].y, + coord[1].x, coord[1].y) < 0.0; + + m_rgba1.init(coord[0], coord[2]); + m_rgba2.init(coord[0], coord[1]); + m_rgba3.init(coord[1], coord[2]); + } + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + m_rgba1.calc(y);//(m_rgba1.m_1dy > 2) ? m_rgba1.m_y1 : y); + const rgba_calc* pc1 = &m_rgba1; + const rgba_calc* pc2 = &m_rgba2; + + if(y <= m_y2) + { + // Bottom part of the triangle (first subtriangle) + //------------------------- + m_rgba2.calc(y + m_rgba2.m_1dy); + } + else + { + // Upper part (second subtriangle) + m_rgba3.calc(y - m_rgba3.m_1dy); + //------------------------- + pc2 = &m_rgba3; + } + + if(m_swap) + { + // It means that the triangle is oriented clockwise, + // so that we need to swap the controlling structures + //------------------------- + const rgba_calc* t = pc2; + pc2 = pc1; + pc1 = t; + } + + // Get the horizontal length with subpixel accuracy + // and protect it from division by zero + //------------------------- + int nlen = abs(pc2->m_x - pc1->m_x); + if(nlen <= 0) nlen = 1; + + dda_line_interpolator<14> r(pc1->m_r, pc2->m_r, nlen); + dda_line_interpolator<14> g(pc1->m_g, pc2->m_g, nlen); + dda_line_interpolator<14> b(pc1->m_b, pc2->m_b, nlen); + dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen); + + // Calculate the starting point of the gradient with subpixel + // accuracy and correct (roll back) the interpolators. + // This operation will also clip the beginning of the span + // if necessary. + //------------------------- + int start = pc1->m_x - (x << subpixel_shift); + r -= start; + g -= start; + b -= start; + a -= start; + nlen += start; + + int vr, vg, vb, va; + enum lim_e { lim = color_type::base_mask }; + + // Beginning part of the span. Since we rolled back the + // interpolators, the color values may have overflow. + // So that, we render the beginning part with checking + // for overflow. It lasts until "start" is positive; + // typically it's 1-2 pixels, but may be more in some cases. + //------------------------- + while(len && start > 0) + { + vr = r.y(); + vg = g.y(); + vb = b.y(); + va = a.y(); + if(vr < 0) vr = 0; if(vr > lim) vr = lim; + if(vg < 0) vg = 0; if(vg > lim) vg = lim; + if(vb < 0) vb = 0; if(vb > lim) vb = lim; + if(va < 0) va = 0; if(va > lim) va = lim; + span->r = (value_type)vr; + span->g = (value_type)vg; + span->b = (value_type)vb; + span->a = (value_type)va; + r += subpixel_scale; + g += subpixel_scale; + b += subpixel_scale; + a += subpixel_scale; + nlen -= subpixel_scale; + start -= subpixel_scale; + ++span; + --len; + } + + // Middle part, no checking for overflow. + // Actual spans can be longer than the calculated length + // because of anti-aliasing, thus, the interpolators can + // overflow. But while "nlen" is positive we are safe. + //------------------------- + while(len && nlen > 0) + { + span->r = (value_type)r.y(); + span->g = (value_type)g.y(); + span->b = (value_type)b.y(); + span->a = (value_type)a.y(); + r += subpixel_scale; + g += subpixel_scale; + b += subpixel_scale; + a += subpixel_scale; + nlen -= subpixel_scale; + ++span; + --len; + } + + // Ending part; checking for overflow. + // Typically it's 1-2 pixels, but may be more in some cases. + //------------------------- + while(len) + { + vr = r.y(); + vg = g.y(); + vb = b.y(); + va = a.y(); + if(vr < 0) vr = 0; if(vr > lim) vr = lim; + if(vg < 0) vg = 0; if(vg > lim) vg = lim; + if(vb < 0) vb = 0; if(vb > lim) vb = lim; + if(va < 0) va = 0; if(va > lim) va = lim; + span->r = (value_type)vr; + span->g = (value_type)vg; + span->b = (value_type)vb; + span->a = (value_type)va; + r += subpixel_scale; + g += subpixel_scale; + b += subpixel_scale; + a += subpixel_scale; + ++span; + --len; + } + } + + private: + bool m_swap; + int m_y2; + rgba_calc m_rgba1; + rgba_calc m_rgba2; + rgba_calc m_rgba3; + }; + + + +} + +#endif diff --git a/xs/src/agg/agg_span_gradient.h b/xs/src/agg/agg_span_gradient.h new file mode 100644 index 0000000000..58b506dcfe --- /dev/null +++ b/xs/src/agg/agg_span_gradient.h @@ -0,0 +1,377 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_GRADIENT_INCLUDED +#define AGG_SPAN_GRADIENT_INCLUDED + +#include +#include +#include +#include "agg_basics.h" +#include "agg_math.h" +#include "agg_array.h" + + +namespace agg +{ + + enum gradient_subpixel_scale_e + { + gradient_subpixel_shift = 4, //-----gradient_subpixel_shift + gradient_subpixel_scale = 1 << gradient_subpixel_shift, //-----gradient_subpixel_scale + gradient_subpixel_mask = gradient_subpixel_scale - 1 //-----gradient_subpixel_mask + }; + + + + //==========================================================span_gradient + template + class span_gradient + { + public: + typedef Interpolator interpolator_type; + typedef ColorT color_type; + + enum downscale_shift_e + { + downscale_shift = interpolator_type::subpixel_shift - + gradient_subpixel_shift + }; + + //-------------------------------------------------------------------- + span_gradient() {} + + //-------------------------------------------------------------------- + span_gradient(interpolator_type& inter, + GradientF& gradient_function, + ColorF& color_function, + double d1, double d2) : + m_interpolator(&inter), + m_gradient_function(&gradient_function), + m_color_function(&color_function), + m_d1(iround(d1 * gradient_subpixel_scale)), + m_d2(iround(d2 * gradient_subpixel_scale)) + {} + + //-------------------------------------------------------------------- + interpolator_type& interpolator() { return *m_interpolator; } + const GradientF& gradient_function() const { return *m_gradient_function; } + const ColorF& color_function() const { return *m_color_function; } + double d1() const { return double(m_d1) / gradient_subpixel_scale; } + double d2() const { return double(m_d2) / gradient_subpixel_scale; } + + //-------------------------------------------------------------------- + void interpolator(interpolator_type& i) { m_interpolator = &i; } + void gradient_function(GradientF& gf) { m_gradient_function = &gf; } + void color_function(ColorF& cf) { m_color_function = &cf; } + void d1(double v) { m_d1 = iround(v * gradient_subpixel_scale); } + void d2(double v) { m_d2 = iround(v * gradient_subpixel_scale); } + + //-------------------------------------------------------------------- + void prepare() {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + int dd = m_d2 - m_d1; + if(dd < 1) dd = 1; + m_interpolator->begin(x+0.5, y+0.5, len); + do + { + m_interpolator->coordinates(&x, &y); + int d = m_gradient_function->calculate(x >> downscale_shift, + y >> downscale_shift, m_d2); + d = ((d - m_d1) * (int)m_color_function->size()) / dd; + if(d < 0) d = 0; + if(d >= (int)m_color_function->size()) d = m_color_function->size() - 1; + *span++ = (*m_color_function)[d]; + ++(*m_interpolator); + } + while(--len); + } + + private: + interpolator_type* m_interpolator; + GradientF* m_gradient_function; + ColorF* m_color_function; + int m_d1; + int m_d2; + }; + + + + + //=====================================================gradient_linear_color + template + struct gradient_linear_color + { + typedef ColorT color_type; + + gradient_linear_color() {} + gradient_linear_color(const color_type& c1, const color_type& c2, + unsigned size = 256) : + m_c1(c1), m_c2(c2), m_size(size) + // VFALCO 4/28/09 + ,m_mult(1/(double(size)-1)) + // VFALCO + {} + + unsigned size() const { return m_size; } + color_type operator [] (unsigned v) const + { + // VFALCO 4/28/09 + //return m_c1.gradient(m_c2, double(v) / double(m_size - 1)); + return m_c1.gradient(m_c2, double(v) * m_mult ); + // VFALCO + } + + void colors(const color_type& c1, const color_type& c2, unsigned size = 256) + { + m_c1 = c1; + m_c2 = c2; + m_size = size; + // VFALCO 4/28/09 + m_mult=1/(double(size)-1); + // VFALCO + } + + color_type m_c1; + color_type m_c2; + unsigned m_size; + // VFALCO 4/28/09 + double m_mult; + // VFALCO + }; + + + + + + + //==========================================================gradient_circle + class gradient_circle + { + // Actually the same as radial. Just for compatibility + public: + static AGG_INLINE int calculate(int x, int y, int) + { + return int(fast_sqrt(x*x + y*y)); + } + }; + + + //==========================================================gradient_radial + class gradient_radial + { + public: + static AGG_INLINE int calculate(int x, int y, int) + { + return int(fast_sqrt(x*x + y*y)); + } + }; + + //========================================================gradient_radial_d + class gradient_radial_d + { + public: + static AGG_INLINE int calculate(int x, int y, int) + { + return uround(sqrt(double(x)*double(x) + double(y)*double(y))); + } + }; + + //====================================================gradient_radial_focus + class gradient_radial_focus + { + public: + //--------------------------------------------------------------------- + gradient_radial_focus() : + m_r(100 * gradient_subpixel_scale), + m_fx(0), + m_fy(0) + { + update_values(); + } + + //--------------------------------------------------------------------- + gradient_radial_focus(double r, double fx, double fy) : + m_r (iround(r * gradient_subpixel_scale)), + m_fx(iround(fx * gradient_subpixel_scale)), + m_fy(iround(fy * gradient_subpixel_scale)) + { + update_values(); + } + + //--------------------------------------------------------------------- + void init(double r, double fx, double fy) + { + m_r = iround(r * gradient_subpixel_scale); + m_fx = iround(fx * gradient_subpixel_scale); + m_fy = iround(fy * gradient_subpixel_scale); + update_values(); + } + + //--------------------------------------------------------------------- + double radius() const { return double(m_r) / gradient_subpixel_scale; } + double focus_x() const { return double(m_fx) / gradient_subpixel_scale; } + double focus_y() const { return double(m_fy) / gradient_subpixel_scale; } + + //--------------------------------------------------------------------- + int calculate(int x, int y, int) const + { + double dx = x - m_fx; + double dy = y - m_fy; + double d2 = dx * m_fy - dy * m_fx; + double d3 = m_r2 * (dx * dx + dy * dy) - d2 * d2; + return iround((dx * m_fx + dy * m_fy + sqrt(fabs(d3))) * m_mul); + } + + private: + //--------------------------------------------------------------------- + void update_values() + { + // Calculate the invariant values. In case the focal center + // lies exactly on the gradient circle the divisor degenerates + // into zero. In this case we just move the focal center by + // one subpixel unit possibly in the direction to the origin (0,0) + // and calculate the values again. + //------------------------- + m_r2 = double(m_r) * double(m_r); + m_fx2 = double(m_fx) * double(m_fx); + m_fy2 = double(m_fy) * double(m_fy); + double d = (m_r2 - (m_fx2 + m_fy2)); + if(d == 0) + { + if(m_fx) { if(m_fx < 0) ++m_fx; else --m_fx; } + if(m_fy) { if(m_fy < 0) ++m_fy; else --m_fy; } + m_fx2 = double(m_fx) * double(m_fx); + m_fy2 = double(m_fy) * double(m_fy); + d = (m_r2 - (m_fx2 + m_fy2)); + } + m_mul = m_r / d; + } + + int m_r; + int m_fx; + int m_fy; + double m_r2; + double m_fx2; + double m_fy2; + double m_mul; + }; + + + //==============================================================gradient_x + class gradient_x + { + public: + static int calculate(int x, int, int) { return x; } + }; + + + //==============================================================gradient_y + class gradient_y + { + public: + static int calculate(int, int y, int) { return y; } + }; + + //========================================================gradient_diamond + class gradient_diamond + { + public: + static AGG_INLINE int calculate(int x, int y, int) + { + int ax = abs(x); + int ay = abs(y); + return ax > ay ? ax : ay; + } + }; + + //=============================================================gradient_xy + class gradient_xy + { + public: + static AGG_INLINE int calculate(int x, int y, int d) + { + return abs(x) * abs(y) / d; + } + }; + + //========================================================gradient_sqrt_xy + class gradient_sqrt_xy + { + public: + static AGG_INLINE int calculate(int x, int y, int) + { + return fast_sqrt(abs(x) * abs(y)); + } + }; + + //==========================================================gradient_conic + class gradient_conic + { + public: + static AGG_INLINE int calculate(int x, int y, int d) + { + return uround(fabs(atan2(double(y), double(x))) * double(d) / pi); + } + }; + + //=================================================gradient_repeat_adaptor + template class gradient_repeat_adaptor + { + public: + gradient_repeat_adaptor(const GradientF& gradient) : + m_gradient(&gradient) {} + + AGG_INLINE int calculate(int x, int y, int d) const + { + int ret = m_gradient->calculate(x, y, d) % d; + if(ret < 0) ret += d; + return ret; + } + + private: + const GradientF* m_gradient; + }; + + //================================================gradient_reflect_adaptor + template class gradient_reflect_adaptor + { + public: + gradient_reflect_adaptor(const GradientF& gradient) : + m_gradient(&gradient) {} + + AGG_INLINE int calculate(int x, int y, int d) const + { + int d2 = d << 1; + int ret = m_gradient->calculate(x, y, d) % d2; + if(ret < 0) ret += d2; + if(ret >= d) ret = d2 - ret; + return ret; + } + + private: + const GradientF* m_gradient; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_span_gradient_alpha.h b/xs/src/agg/agg_span_gradient_alpha.h new file mode 100644 index 0000000000..2ec040e3b9 --- /dev/null +++ b/xs/src/agg/agg_span_gradient_alpha.h @@ -0,0 +1,126 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_GRADIENT_ALPHA_INCLUDED +#define AGG_SPAN_GRADIENT_ALPHA_INCLUDED + +#include "agg_span_gradient.h" + +namespace agg +{ + //======================================================span_gradient_alpha + template + class span_gradient_alpha + { + public: + typedef Interpolator interpolator_type; + typedef ColorT color_type; + typedef typename color_type::value_type alpha_type; + + enum downscale_shift_e + { + downscale_shift = interpolator_type::subpixel_shift - gradient_subpixel_shift + }; + + + //-------------------------------------------------------------------- + span_gradient_alpha() {} + + //-------------------------------------------------------------------- + span_gradient_alpha(interpolator_type& inter, + GradientF& gradient_function, + AlphaF& alpha_function, + double d1, double d2) : + m_interpolator(&inter), + m_gradient_function(&gradient_function), + m_alpha_function(&alpha_function), + m_d1(iround(d1 * gradient_subpixel_scale)), + m_d2(iround(d2 * gradient_subpixel_scale)) + {} + + //-------------------------------------------------------------------- + interpolator_type& interpolator() { return *m_interpolator; } + const GradientF& gradient_function() const { return *m_gradient_function; } + const AlphaF& alpha_function() const { return *m_alpha_function; } + double d1() const { return double(m_d1) / gradient_subpixel_scale; } + double d2() const { return double(m_d2) / gradient_subpixel_scale; } + + //-------------------------------------------------------------------- + void interpolator(interpolator_type& i) { m_interpolator = &i; } + void gradient_function(const GradientF& gf) { m_gradient_function = &gf; } + void alpha_function(const AlphaF& af) { m_alpha_function = ⁡ } + void d1(double v) { m_d1 = iround(v * gradient_subpixel_scale); } + void d2(double v) { m_d2 = iround(v * gradient_subpixel_scale); } + + //-------------------------------------------------------------------- + void prepare() {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + int dd = m_d2 - m_d1; + if(dd < 1) dd = 1; + m_interpolator->begin(x+0.5, y+0.5, len); + do + { + m_interpolator->coordinates(&x, &y); + int d = m_gradient_function->calculate(x >> downscale_shift, + y >> downscale_shift, m_d2); + d = ((d - m_d1) * (int)m_alpha_function->size()) / dd; + if(d < 0) d = 0; + if(d >= (int)m_alpha_function->size()) d = m_alpha_function->size() - 1; + span->a = (*m_alpha_function)[d]; + ++span; + ++(*m_interpolator); + } + while(--len); + } + + private: + interpolator_type* m_interpolator; + GradientF* m_gradient_function; + AlphaF* m_alpha_function; + int m_d1; + int m_d2; + }; + + + //=======================================================gradient_alpha_x + template struct gradient_alpha_x + { + typedef typename ColorT::value_type alpha_type; + alpha_type operator [] (alpha_type x) const { return x; } + }; + + //====================================================gradient_alpha_x_u8 + struct gradient_alpha_x_u8 + { + typedef int8u alpha_type; + alpha_type operator [] (alpha_type x) const { return x; } + }; + + //==========================================gradient_alpha_one_munus_x_u8 + struct gradient_alpha_one_munus_x_u8 + { + typedef int8u alpha_type; + alpha_type operator [] (alpha_type x) const { return 255-x; } + }; + +} + +#endif diff --git a/xs/src/agg/agg_span_gradient_contour.h b/xs/src/agg/agg_span_gradient_contour.h new file mode 100644 index 0000000000..a1c4ca3773 --- /dev/null +++ b/xs/src/agg/agg_span_gradient_contour.h @@ -0,0 +1,362 @@ +//---------------------------------------------------------------------------- +// AGG Contribution Pack - Gradients 1 (AGG CP - Gradients 1) +// http://milan.marusinec.sk/aggcp +// +// For Anti-Grain Geometry - Version 2.4 +// http://www.antigrain.org +// +// Contribution Created By: +// Milan Marusinec alias Milano +// milan@marusinec.sk +// Copyright (c) 2007-2008 +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// [History] ----------------------------------------------------------------- +// +// 02.02.2008-Milano: Ported from Object Pascal code of AggPas +// +#ifndef AGG_SPAN_GRADIENT_CONTOUR_INCLUDED +#define AGG_SPAN_GRADIENT_CONTOUR_INCLUDED + +#include "agg_basics.h" +#include "agg_trans_affine.h" +#include "agg_path_storage.h" +#include "agg_pixfmt_gray.h" +#include "agg_conv_transform.h" +#include "agg_conv_curve.h" +#include "agg_bounding_rect.h" +#include "agg_renderer_base.h" +#include "agg_renderer_primitives.h" +#include "agg_rasterizer_outline.h" +#include "agg_span_gradient.h" + +#include + +namespace agg +{ + + //==========================================================gradient_contour + class gradient_contour + { + private: + int8u* m_buffer; + int m_width; + int m_height; + int m_frame; + + double m_d1; + double m_d2; + + public: + gradient_contour() : + m_buffer(NULL), + m_width(0), + m_height(0), + m_frame(10), + m_d1(0), + m_d2(100) + { + } + + gradient_contour(double d1, double d2) : + m_buffer(NULL), + m_width(0), + m_height(0), + m_frame(10), + m_d1(d1), + m_d2(d2) + { + } + + ~gradient_contour() + { + if (m_buffer) + { + delete [] m_buffer; + } + } + + int8u* contour_create(path_storage* ps ); + + int contour_width() { return m_width; } + int contour_height() { return m_height; } + + void d1(double d ) { m_d1 = d; } + void d2(double d ) { m_d2 = d; } + + void frame(int f ) { m_frame = f; } + int frame() { return m_frame; } + + int calculate(int x, int y, int d) const + { + if (m_buffer) + { + int px = x >> agg::gradient_subpixel_shift; + int py = y >> agg::gradient_subpixel_shift; + + px %= m_width; + + if (px < 0) + { + px += m_width; + } + + py %= m_height; + + if (py < 0 ) + { + py += m_height; + } + + return iround(m_buffer[py * m_width + px ] * (m_d2 / 256 ) + m_d1 ) << gradient_subpixel_shift; + + } + else + { + return 0; + } + } + + }; + + static AGG_INLINE int square(int x ) { return x * x; } + + // DT algorithm by: Pedro Felzenszwalb + void dt(float* spanf, float* spang, float* spanr, int* spann ,int length ) + { + int k = 0; + float s; + + spann[0 ] = 0; + spang[0 ] = -FLT_MAX; + spang[1 ] = FLT_MAX; + + for (int q = 1; q <= length - 1; q++) + { + s = ((spanf[q ] + square(q ) ) - (spanf[spann[k ] ] + square(spann[k ] ) ) ) / (2 * q - 2 * spann[k ] ); + + while (s <= spang[k ]) + { + k--; + s = ((spanf[q ] + square(q ) ) - (spanf[spann[k ] ] + square(spann[k ] ) ) ) / (2 * q - 2 * spann[k ] ); + } + + k++; + spann[k ] = q; + spang[k ] = s; + spang[k + 1 ] = FLT_MAX; + + } + + k = 0; + + for (int q = 0; q <= length - 1; q++) + { + while (spang[k + 1 ] < q ) + { + k++; + } + + spanr[q ] = square(q - spann[k ] ) + spanf[spann[k ] ]; + } + } + + // DT algorithm by: Pedro Felzenszwalb + int8u* gradient_contour::contour_create(path_storage* ps ) + { + int8u* result = NULL; + + if (ps) + { + // I. Render Black And White NonAA Stroke of the Path + // Path Bounding Box + Some Frame Space Around [configurable] + agg::conv_curve conv(*ps); + + double x1, y1, x2, y2; + + if (agg::bounding_rect_single(conv ,0 ,&x1 ,&y1 ,&x2 ,&y2 )) + { + // Create BW Rendering Surface + int width = int(ceil(x2 - x1 ) ) + m_frame * 2 + 1; + int height = int(ceil(y2 - y1 ) ) + m_frame * 2 + 1; + + int8u* buffer = new int8u[width * height]; + + if (buffer) + { + memset(buffer ,255 ,width * height ); + + // Setup VG Engine & Render + agg::rendering_buffer rb; + rb.attach(buffer ,width ,height ,width ); + + agg::pixfmt_gray8 pf(rb); + agg::renderer_base renb(pf ); + + agg::renderer_primitives > prim(renb ); + agg::rasterizer_outline > > ras(prim ); + + agg::trans_affine mtx; + mtx *= agg::trans_affine_translation(-x1 + m_frame, -y1 + m_frame ); + + agg::conv_transform > trans(conv ,mtx ); + + prim.line_color(agg::rgba8(0 ,0 ,0 ,255 ) ); + ras.add_path(trans ); + + // II. Distance Transform + // Create Float Buffer + 0 vs infinity assignment + float* image = new float[width * height]; + + if (image) + { + for (int y = 0, l = 0; y < height; y++ ) + { + for (int x = 0; x < width; x++, l++ ) + { + if (buffer[l ] == 0) + { + image[l ] = 0.0; + } + else + { + image[l ] = FLT_MAX; + } + } + + } + + // DT of 2d + // SubBuff max width,height + int length = width; + + if (height > length) + { + length = height; + } + + float* spanf = new float[length]; + float* spang = new float[length + 1]; + float* spanr = new float[length]; + int* spann = new int[length]; + + if ((spanf) && (spang) && (spanr) && (spann)) + { + // Transform along columns + for (int x = 0; x < width; x++ ) + { + for (int y = 0; y < height; y++ ) + { + spanf[y] = image[y * width + x]; + } + + // DT of 1d + dt(spanf ,spang ,spanr ,spann ,height ); + + for (int y = 0; y < height; y++ ) + { + image[y * width + x] = spanr[y]; + } + } + + // Transform along rows + for (int y = 0; y < height; y++ ) + { + for (int x = 0; x < width; x++ ) + { + spanf[x] = image[y * width + x]; + } + + // DT of 1d + dt(spanf ,spang ,spanr ,spann ,width ); + + for (int x = 0; x < width; x++ ) + { + image[y * width + x] = spanr[x]; + } + } + + // Take Square Roots, Min & Max + float min = sqrt(image[0] ); + float max = min; + + for (int y = 0, l = 0; y < height; y++ ) + { + for (int x = 0; x < width; x++, l++ ) + { + image[l] = sqrt(image[l]); + + if (min > image[l]) + { + min = image[l]; + } + + if (max < image[l]) + { + max = image[l]; + } + + } + } + + // III. Convert To Grayscale + if (min == max) + { + memset(buffer ,0 ,width * height ); + } + else + { + float scale = 255 / (max - min ); + + for (int y = 0, l = 0; y < height; y++ ) + { + for (int x = 0; x < width; x++ ,l++ ) + { + buffer[l] = int8u(int((image[l] - min ) * scale )); + } + } + } + + // OK + if (m_buffer) + { + delete [] m_buffer; + } + + m_buffer = buffer; + m_width = width; + m_height = height; + + buffer = NULL; + result = m_buffer; + + } + + if (spanf) { delete [] spanf; } + if (spang) { delete [] spang; } + if (spanr) { delete [] spanr; } + if (spann) { delete [] spann; } + + delete [] image; + + } + } + + if (buffer) + { + delete [] buffer; + } + + } + + } + return result; + } + +} + +#endif diff --git a/xs/src/agg/agg_span_gradient_image.h b/xs/src/agg/agg_span_gradient_image.h new file mode 100644 index 0000000000..c99eaca166 --- /dev/null +++ b/xs/src/agg/agg_span_gradient_image.h @@ -0,0 +1,188 @@ +//---------------------------------------------------------------------------- +// AGG Contribution Pack - Gradients 1 (AGG CP - Gradients 1) +// http://milan.marusinec.sk/aggcp +// +// For Anti-Grain Geometry - Version 2.4 +// http://www.antigrain.org +// +// Contribution Created By: +// Milan Marusinec alias Milano +// milan@marusinec.sk +// Copyright (c) 2007-2008 +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// [History] ----------------------------------------------------------------- +// +// 03.02.2008-Milano: Ported from Object Pascal code of AggPas +// +#ifndef AGG_SPAN_GRADIENT_IMAGE_INCLUDED +#define AGG_SPAN_GRADIENT_IMAGE_INCLUDED + +#include "agg_basics.h" +#include "agg_span_gradient.h" +#include "agg_color_rgba.h" +#include "agg_rendering_buffer.h" +#include "agg_pixfmt_rgba.h" + +namespace agg +{ + + //==========================================================one_color_function + template class one_color_function + { + public: + typedef ColorT color_type; + + color_type m_color; + + one_color_function() : + m_color() + { + } + + static unsigned size() { return 1; } + + const color_type& operator [] (unsigned i) const + { + return m_color; + } + + color_type* operator [] (unsigned i) + { + return &m_color; + } + }; + + //==========================================================gradient_image + template class gradient_image + { + private: + //------------ fields + typedef ColorT color_type; + typedef agg::pixfmt_rgba32 pixfmt_type; + + agg::rgba8* m_buffer; + + int m_alocdx; + int m_alocdy; + int m_width; + int m_height; + + color_type* m_color; + + one_color_function m_color_function; + + public: + gradient_image() : + m_color_function(), + m_buffer(NULL), + m_alocdx(0), + m_alocdy(0), + m_width(0), + m_height(0) + { + m_color = m_color_function[0 ]; + } + + ~gradient_image() + { + if (m_buffer) { delete [] m_buffer; } + } + + void* image_create(int width, int height ) + { + void* result = NULL; + + if (width > m_alocdx || height > m_alocdy) + { + if (m_buffer) { delete [] m_buffer; } + + m_buffer = NULL; + m_buffer = new agg::rgba8[width * height]; + + if (m_buffer) + { + m_alocdx = width; + m_alocdy = height; + } + else + { + m_alocdx = 0; + m_alocdy = 0; + }; + }; + + if (m_buffer) + { + m_width = width; + m_height = height; + + for (int rows = 0; rows < height; rows++) + { + agg::rgba8* row = &m_buffer[rows * m_alocdx ]; + memset(row ,0 ,m_width * 4 ); + }; + + result = m_buffer; + }; + return result; + } + + void* image_buffer() { return m_buffer; } + int image_width() { return m_width; } + int image_height() { return m_height; } + int image_stride() { return m_alocdx * 4; } + + int calculate(int x, int y, int d) const + { + if (m_buffer) + { + int px = x >> agg::gradient_subpixel_shift; + int py = y >> agg::gradient_subpixel_shift; + + px %= m_width; + + if (px < 0) + { + px += m_width; + } + + py %= m_height; + + if (py < 0 ) + { + py += m_height; + } + + rgba8* pixel = &m_buffer[py * m_alocdx + px ]; + + m_color->r = pixel->r; + m_color->g = pixel->g; + m_color->b = pixel->b; + m_color->a = pixel->a; + + } + else + { + m_color->r = 0; + m_color->g = 0; + m_color->b = 0; + m_color->a = 0; + } + return 0; + } + + const one_color_function& color_function() const + { + return m_color_function; + } + + }; + +} + +#endif diff --git a/xs/src/agg/agg_span_image_filter.h b/xs/src/agg/agg_span_image_filter.h new file mode 100644 index 0000000000..9d0a10a52c --- /dev/null +++ b/xs/src/agg/agg_span_image_filter.h @@ -0,0 +1,247 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Image transformations with filtering. Span generator base class +// +//---------------------------------------------------------------------------- +#ifndef AGG_SPAN_IMAGE_FILTER_INCLUDED +#define AGG_SPAN_IMAGE_FILTER_INCLUDED + +#include "agg_basics.h" +#include "agg_image_filters.h" +#include "agg_span_interpolator_linear.h" + +namespace agg +{ + + //-------------------------------------------------------span_image_filter + template class span_image_filter + { + public: + typedef Source source_type; + typedef Interpolator interpolator_type; + + //-------------------------------------------------------------------- + span_image_filter() {} + span_image_filter(source_type& src, + interpolator_type& interpolator, + image_filter_lut* filter) : + m_src(&src), + m_interpolator(&interpolator), + m_filter(filter), + m_dx_dbl(0.5), + m_dy_dbl(0.5), + m_dx_int(image_subpixel_scale / 2), + m_dy_int(image_subpixel_scale / 2) + {} + void attach(source_type& v) { m_src = &v; } + + //-------------------------------------------------------------------- + source_type& source() { return *m_src; } + const source_type& source() const { return *m_src; } + const image_filter_lut& filter() const { return *m_filter; } + int filter_dx_int() const { return m_dx_int; } + int filter_dy_int() const { return m_dy_int; } + double filter_dx_dbl() const { return m_dx_dbl; } + double filter_dy_dbl() const { return m_dy_dbl; } + + //-------------------------------------------------------------------- + void interpolator(interpolator_type& v) { m_interpolator = &v; } + void filter(image_filter_lut& v) { m_filter = &v; } + void filter_offset(double dx, double dy) + { + m_dx_dbl = dx; + m_dy_dbl = dy; + m_dx_int = iround(dx * image_subpixel_scale); + m_dy_int = iround(dy * image_subpixel_scale); + } + void filter_offset(double d) { filter_offset(d, d); } + + //-------------------------------------------------------------------- + interpolator_type& interpolator() { return *m_interpolator; } + + //-------------------------------------------------------------------- + void prepare() {} + + //-------------------------------------------------------------------- + private: + source_type* m_src; + interpolator_type* m_interpolator; + image_filter_lut* m_filter; + double m_dx_dbl; + double m_dy_dbl; + unsigned m_dx_int; + unsigned m_dy_int; + }; + + + + + //==============================================span_image_resample_affine + template + class span_image_resample_affine : + public span_image_filter > + { + public: + typedef Source source_type; + typedef span_interpolator_linear interpolator_type; + typedef span_image_filter base_type; + + //-------------------------------------------------------------------- + span_image_resample_affine() : + m_scale_limit(200.0), + m_blur_x(1.0), + m_blur_y(1.0) + {} + + //-------------------------------------------------------------------- + span_image_resample_affine(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, &filter), + m_scale_limit(200.0), + m_blur_x(1.0), + m_blur_y(1.0) + {} + + + //-------------------------------------------------------------------- + int scale_limit() const { return uround(m_scale_limit); } + void scale_limit(int v) { m_scale_limit = v; } + + //-------------------------------------------------------------------- + double blur_x() const { return m_blur_x; } + double blur_y() const { return m_blur_y; } + void blur_x(double v) { m_blur_x = v; } + void blur_y(double v) { m_blur_y = v; } + void blur(double v) { m_blur_x = m_blur_y = v; } + + //-------------------------------------------------------------------- + void prepare() + { + double scale_x; + double scale_y; + + base_type::interpolator().transformer().scaling_abs(&scale_x, &scale_y); + + double scale_xy = scale_x * scale_y; + if (scale_xy > m_scale_limit) + { + scale_x = scale_x * m_scale_limit / scale_xy; + scale_y = scale_y * m_scale_limit / scale_xy; + } + + if(scale_x < 1) scale_x = 1; + if(scale_y < 1) scale_y = 1; + + if(scale_x > m_scale_limit) scale_x = m_scale_limit; + if(scale_y > m_scale_limit) scale_y = m_scale_limit; + + scale_x *= m_blur_x; + scale_y *= m_blur_y; + + if(scale_x < 1) scale_x = 1; + if(scale_y < 1) scale_y = 1; + + m_rx = uround( scale_x * double(image_subpixel_scale)); + m_rx_inv = uround(1.0/scale_x * double(image_subpixel_scale)); + + m_ry = uround( scale_y * double(image_subpixel_scale)); + m_ry_inv = uround(1.0/scale_y * double(image_subpixel_scale)); + } + + protected: + int m_rx; + int m_ry; + int m_rx_inv; + int m_ry_inv; + + private: + double m_scale_limit; + double m_blur_x; + double m_blur_y; + }; + + + + //=====================================================span_image_resample + template + class span_image_resample : + public span_image_filter + { + public: + typedef Source source_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + + //-------------------------------------------------------------------- + span_image_resample() : + m_scale_limit(20), + m_blur_x(image_subpixel_scale), + m_blur_y(image_subpixel_scale) + {} + + //-------------------------------------------------------------------- + span_image_resample(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, &filter), + m_scale_limit(20), + m_blur_x(image_subpixel_scale), + m_blur_y(image_subpixel_scale) + {} + + //-------------------------------------------------------------------- + int scale_limit() const { return m_scale_limit; } + void scale_limit(int v) { m_scale_limit = v; } + + //-------------------------------------------------------------------- + double blur_x() const { return double(m_blur_x) / double(image_subpixel_scale); } + double blur_y() const { return double(m_blur_y) / double(image_subpixel_scale); } + void blur_x(double v) { m_blur_x = uround(v * double(image_subpixel_scale)); } + void blur_y(double v) { m_blur_y = uround(v * double(image_subpixel_scale)); } + void blur(double v) { m_blur_x = + m_blur_y = uround(v * double(image_subpixel_scale)); } + + protected: + AGG_INLINE void adjust_scale(int* rx, int* ry) + { + if(*rx < image_subpixel_scale) *rx = image_subpixel_scale; + if(*ry < image_subpixel_scale) *ry = image_subpixel_scale; + if(*rx > image_subpixel_scale * m_scale_limit) + { + *rx = image_subpixel_scale * m_scale_limit; + } + if(*ry > image_subpixel_scale * m_scale_limit) + { + *ry = image_subpixel_scale * m_scale_limit; + } + *rx = (*rx * m_blur_x) >> image_subpixel_shift; + *ry = (*ry * m_blur_y) >> image_subpixel_shift; + if(*rx < image_subpixel_scale) *rx = image_subpixel_scale; + if(*ry < image_subpixel_scale) *ry = image_subpixel_scale; + } + + int m_scale_limit; + int m_blur_x; + int m_blur_y; + }; + + + + +} + +#endif diff --git a/xs/src/agg/agg_span_image_filter_gray.h b/xs/src/agg/agg_span_image_filter_gray.h new file mode 100644 index 0000000000..4bc9c00be6 --- /dev/null +++ b/xs/src/agg/agg_span_image_filter_gray.h @@ -0,0 +1,723 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +#ifndef AGG_SPAN_IMAGE_FILTER_GRAY_INCLUDED +#define AGG_SPAN_IMAGE_FILTER_GRAY_INCLUDED + +#include "agg_basics.h" +#include "agg_color_gray.h" +#include "agg_span_image_filter.h" + + +namespace agg +{ + + //==============================================span_image_filter_gray_nn + template + class span_image_filter_gray_nn : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_gray_nn() {} + span_image_filter_gray_nn(source_type& src, + interpolator_type& inter) : + base_type(src, inter, 0) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + do + { + base_type::interpolator().coordinates(&x, &y); + span->v = *(const value_type*) + base_type::source().span(x >> image_subpixel_shift, + y >> image_subpixel_shift, + 1); + span->a = color_type::full_value(); + ++span; + ++base_type::interpolator(); + } while(--len); + } + }; + + + + //=========================================span_image_filter_gray_bilinear + template + class span_image_filter_gray_bilinear : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_gray_bilinear() {} + span_image_filter_gray_bilinear(source_type& src, + interpolator_type& inter) : + base_type(src, inter, 0) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + long_type fg; + const value_type *fg_ptr; + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + fg = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); + fg += *fg_ptr * (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); + + fg_ptr = (const value_type*)base_type::source().next_x(); + fg += *fg_ptr * x_hr * (image_subpixel_scale - y_hr); + + fg_ptr = (const value_type*)base_type::source().next_y(); + fg += *fg_ptr * (image_subpixel_scale - x_hr) * y_hr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + fg += *fg_ptr * x_hr * y_hr; + + span->v = color_type::downshift(fg, image_subpixel_shift * 2); + span->a = color_type::full_value(); + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + //====================================span_image_filter_gray_bilinear_clip + template + class span_image_filter_gray_bilinear_clip : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_gray_bilinear_clip() {} + span_image_filter_gray_bilinear_clip(source_type& src, + const color_type& back_color, + interpolator_type& inter) : + base_type(src, inter, 0), + m_back_color(back_color) + {} + const color_type& background_color() const { return m_back_color; } + void background_color(const color_type& v) { m_back_color = v; } + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + long_type fg; + long_type src_alpha; + value_type back_v = m_back_color.v; + value_type back_a = m_back_color.a; + + const value_type *fg_ptr; + + int maxx = base_type::source().width() - 1; + int maxy = base_type::source().height() - 1; + + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + if(x_lr >= 0 && y_lr >= 0 && + x_lr < maxx && y_lr < maxy) + { + fg = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + fg_ptr = (const value_type*)base_type::source().row_ptr(y_lr) + x_lr; + + fg += *fg_ptr++ * (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); + fg += *fg_ptr++ * (image_subpixel_scale - y_hr) * x_hr; + + ++y_lr; + fg_ptr = (const value_type*)base_type::source().row_ptr(y_lr) + x_lr; + + fg += *fg_ptr++ * (image_subpixel_scale - x_hr) * y_hr; + fg += *fg_ptr++ * x_hr * y_hr; + + fg = color_type::downshift(fg, image_subpixel_shift * 2); + src_alpha = color_type::full_value(); + } + else + { + unsigned weight; + if(x_lr < -1 || y_lr < -1 || + x_lr > maxx || y_lr > maxy) + { + fg = back_v; + src_alpha = back_a; + } + else + { + fg = src_alpha = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + weight = (image_subpixel_scale - x_hr) * + (image_subpixel_scale - y_hr); + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg += weight * + *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); + src_alpha += weight * color_type::full_value(); + } + else + { + fg += back_v * weight; + src_alpha += back_a * weight; + } + + x_lr++; + + weight = x_hr * (image_subpixel_scale - y_hr); + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg += weight * + *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); + src_alpha += weight * color_type::full_value(); + } + else + { + fg += back_v * weight; + src_alpha += back_a * weight; + } + + x_lr--; + y_lr++; + + weight = (image_subpixel_scale - x_hr) * y_hr; + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg += weight * + *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); + src_alpha += weight * color_type::full_value(); + } + else + { + fg += back_v * weight; + src_alpha += back_a * weight; + } + + x_lr++; + + weight = x_hr * y_hr; + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg += weight * + *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); + src_alpha += weight * color_type::full_value(); + } + else + { + fg += back_v * weight; + src_alpha += back_a * weight; + } + + fg = color_type::downshift(fg, image_subpixel_shift * 2); + src_alpha = color_type::downshift(src_alpha, image_subpixel_shift * 2); + } + } + + span->v = (value_type)fg; + span->a = (value_type)src_alpha; + ++span; + ++base_type::interpolator(); + + } while(--len); + } + private: + color_type m_back_color; + }; + + + + //==============================================span_image_filter_gray_2x2 + template + class span_image_filter_gray_2x2 : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_gray_2x2() {} + span_image_filter_gray_2x2(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, &filter) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg; + + const value_type *fg_ptr; + const int16* weight_array = base_type::filter().weight_array() + + ((base_type::filter().diameter()/2 - 1) << + image_subpixel_shift); + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + unsigned weight; + fg = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); + weight = (weight_array[x_hr + image_subpixel_scale] * + weight_array[y_hr + image_subpixel_scale] + + image_filter_scale / 2) >> + image_filter_shift; + fg += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = (weight_array[x_hr] * + weight_array[y_hr + image_subpixel_scale] + + image_filter_scale / 2) >> + image_filter_shift; + fg += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_y(); + weight = (weight_array[x_hr + image_subpixel_scale] * + weight_array[y_hr] + + image_filter_scale / 2) >> + image_filter_shift; + fg += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = (weight_array[x_hr] * + weight_array[y_hr] + + image_filter_scale / 2) >> + image_filter_shift; + fg += weight * *fg_ptr; + + fg >>= image_filter_shift; + if(fg > color_type::full_value()) fg = color_type::full_value(); + + span->v = (value_type)fg; + span->a = color_type::full_value(); + ++span; + ++base_type::interpolator(); + } while(--len); + } + }; + + + + //==================================================span_image_filter_gray + template + class span_image_filter_gray : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_gray() {} + span_image_filter_gray(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, &filter) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg; + const value_type *fg_ptr; + + unsigned diameter = base_type::filter().diameter(); + int start = base_type::filter().start(); + const int16* weight_array = base_type::filter().weight_array(); + + int x_count; + int weight_y; + + do + { + base_type::interpolator().coordinates(&x, &y); + + x -= base_type::filter_dx_int(); + y -= base_type::filter_dy_int(); + + int x_hr = x; + int y_hr = y; + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + fg = 0; + + int x_fract = x_hr & image_subpixel_mask; + unsigned y_count = diameter; + + y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); + fg_ptr = (const value_type*)base_type::source().span(x_lr + start, + y_lr + start, + diameter); + for(;;) + { + x_count = diameter; + weight_y = weight_array[y_hr]; + x_hr = image_subpixel_mask - x_fract; + for(;;) + { + fg += *fg_ptr * + ((weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + image_filter_shift); + if(--x_count == 0) break; + x_hr += image_subpixel_scale; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + + if(--y_count == 0) break; + y_hr += image_subpixel_scale; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg >>= image_filter_shift; + if(fg < 0) fg = 0; + if(fg > color_type::full_value()) fg = color_type::full_value(); + span->v = (value_type)fg; + span->a = color_type::full_value(); + + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + + //=========================================span_image_resample_gray_affine + template + class span_image_resample_gray_affine : + public span_image_resample_affine + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef span_image_resample_affine base_type; + typedef typename base_type::interpolator_type interpolator_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + downscale_shift = image_filter_shift + }; + + //-------------------------------------------------------------------- + span_image_resample_gray_affine() {} + span_image_resample_gray_affine(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, filter) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg; + + int diameter = base_type::filter().diameter(); + int filter_scale = diameter << image_subpixel_shift; + int radius_x = (diameter * base_type::m_rx) >> 1; + int radius_y = (diameter * base_type::m_ry) >> 1; + int len_x_lr = + (diameter * base_type::m_rx + image_subpixel_mask) >> + image_subpixel_shift; + + const int16* weight_array = base_type::filter().weight_array(); + + do + { + base_type::interpolator().coordinates(&x, &y); + + x += base_type::filter_dx_int() - radius_x; + y += base_type::filter_dy_int() - radius_y; + + fg = 0; + + int y_lr = y >> image_subpixel_shift; + int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * + base_type::m_ry_inv) >> + image_subpixel_shift; + int total_weight = 0; + int x_lr = x >> image_subpixel_shift; + int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * + base_type::m_rx_inv) >> + image_subpixel_shift; + + int x_hr2 = x_hr; + const value_type* fg_ptr = + (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); + for(;;) + { + int weight_y = weight_array[y_hr]; + x_hr = x_hr2; + for(;;) + { + int weight = (weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + downscale_shift; + + fg += *fg_ptr * weight; + total_weight += weight; + x_hr += base_type::m_rx_inv; + if(x_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + y_hr += base_type::m_ry_inv; + if(y_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg /= total_weight; + if(fg < 0) fg = 0; + if(fg > color_type::full_value()) fg = color_type::full_value(); + + span->v = (value_type)fg; + span->a = color_type::full_value(); + + ++span; + ++base_type::interpolator(); + } while(--len); + } + }; + + + + //================================================span_image_resample_gray + template + class span_image_resample_gray : + public span_image_resample + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef Interpolator interpolator_type; + typedef span_image_resample base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + downscale_shift = image_filter_shift + }; + + //-------------------------------------------------------------------- + span_image_resample_gray() {} + span_image_resample_gray(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, filter) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + long_type fg; + + int diameter = base_type::filter().diameter(); + int filter_scale = diameter << image_subpixel_shift; + + const int16* weight_array = base_type::filter().weight_array(); + do + { + int rx; + int ry; + int rx_inv = image_subpixel_scale; + int ry_inv = image_subpixel_scale; + base_type::interpolator().coordinates(&x, &y); + base_type::interpolator().local_scale(&rx, &ry); + base_type::adjust_scale(&rx, &ry); + + rx_inv = image_subpixel_scale * image_subpixel_scale / rx; + ry_inv = image_subpixel_scale * image_subpixel_scale / ry; + + int radius_x = (diameter * rx) >> 1; + int radius_y = (diameter * ry) >> 1; + int len_x_lr = + (diameter * rx + image_subpixel_mask) >> + image_subpixel_shift; + + x += base_type::filter_dx_int() - radius_x; + y += base_type::filter_dy_int() - radius_y; + + fg = 0; + + int y_lr = y >> image_subpixel_shift; + int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * + ry_inv) >> + image_subpixel_shift; + int total_weight = 0; + int x_lr = x >> image_subpixel_shift; + int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * + rx_inv) >> + image_subpixel_shift; + int x_hr2 = x_hr; + const value_type* fg_ptr = + (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); + + for(;;) + { + int weight_y = weight_array[y_hr]; + x_hr = x_hr2; + for(;;) + { + int weight = (weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + downscale_shift; + fg += *fg_ptr * weight; + total_weight += weight; + x_hr += rx_inv; + if(x_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + y_hr += ry_inv; + if(y_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg /= total_weight; + if(fg < 0) fg = 0; + if(fg > color_type::full_value()) fg = color_type::full_value(); + + span->v = (value_type)fg; + span->a = color_type::full_value(); + + ++span; + ++base_type::interpolator(); + } while(--len); + } + }; + + +} + + +#endif + + + diff --git a/xs/src/agg/agg_span_image_filter_rgb.h b/xs/src/agg/agg_span_image_filter_rgb.h new file mode 100644 index 0000000000..f78ae19c1b --- /dev/null +++ b/xs/src/agg/agg_span_image_filter_rgb.h @@ -0,0 +1,861 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +#ifndef AGG_SPAN_IMAGE_FILTER_RGB_INCLUDED +#define AGG_SPAN_IMAGE_FILTER_RGB_INCLUDED + +#include "agg_basics.h" +#include "agg_color_rgba.h" +#include "agg_span_image_filter.h" + + +namespace agg +{ + + //===============================================span_image_filter_rgb_nn + template + class span_image_filter_rgb_nn : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgb_nn() {} + span_image_filter_rgb_nn(source_type& src, + interpolator_type& inter) : + base_type(src, inter, 0) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + do + { + base_type::interpolator().coordinates(&x, &y); + const value_type* fg_ptr = (const value_type*) + base_type::source().span(x >> image_subpixel_shift, + y >> image_subpixel_shift, + 1); + span->r = fg_ptr[order_type::R]; + span->g = fg_ptr[order_type::G]; + span->b = fg_ptr[order_type::B]; + span->a = color_type::full_value(); + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + + //==========================================span_image_filter_rgb_bilinear + template + class span_image_filter_rgb_bilinear : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgb_bilinear() {} + span_image_filter_rgb_bilinear(source_type& src, + interpolator_type& inter) : + base_type(src, inter, 0) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + long_type fg[3]; + const value_type *fg_ptr; + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + unsigned weight; + + fg[0] = fg[1] = fg[2] = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); + weight = (image_subpixel_scale - x_hr) * + (image_subpixel_scale - y_hr); + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = x_hr * (image_subpixel_scale - y_hr); + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_y(); + weight = (image_subpixel_scale - x_hr) * y_hr; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = x_hr * y_hr; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + span->r = color_type::downshift(fg[order_type::R], image_subpixel_shift * 2); + span->g = color_type::downshift(fg[order_type::G], image_subpixel_shift * 2); + span->b = color_type::downshift(fg[order_type::B], image_subpixel_shift * 2); + span->a = color_type::full_value(); + + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + + //=====================================span_image_filter_rgb_bilinear_clip + template + class span_image_filter_rgb_bilinear_clip : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgb_bilinear_clip() {} + span_image_filter_rgb_bilinear_clip(source_type& src, + const color_type& back_color, + interpolator_type& inter) : + base_type(src, inter, 0), + m_back_color(back_color) + {} + const color_type& background_color() const { return m_back_color; } + void background_color(const color_type& v) { m_back_color = v; } + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + long_type fg[3]; + long_type src_alpha; + value_type back_r = m_back_color.r; + value_type back_g = m_back_color.g; + value_type back_b = m_back_color.b; + value_type back_a = m_back_color.a; + + const value_type *fg_ptr; + + int maxx = base_type::source().width() - 1; + int maxy = base_type::source().height() - 1; + + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + unsigned weight; + + if(x_lr >= 0 && y_lr >= 0 && + x_lr < maxx && y_lr < maxy) + { + fg[0] = fg[1] = fg[2] = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; + + weight = (image_subpixel_scale - x_hr) * + (image_subpixel_scale - y_hr); + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + + weight = x_hr * (image_subpixel_scale - y_hr); + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + + ++y_lr; + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; + + weight = (image_subpixel_scale - x_hr) * y_hr; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + + weight = x_hr * y_hr; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + + fg[0] = color_type::downshift(fg[0], image_subpixel_shift * 2); + fg[1] = color_type::downshift(fg[1], image_subpixel_shift * 2); + fg[2] = color_type::downshift(fg[2], image_subpixel_shift * 2); + src_alpha = color_type::full_value(); + } + else + { + if(x_lr < -1 || y_lr < -1 || + x_lr > maxx || y_lr > maxy) + { + fg[order_type::R] = back_r; + fg[order_type::G] = back_g; + fg[order_type::B] = back_b; + src_alpha = back_a; + } + else + { + fg[0] = fg[1] = fg[2] = src_alpha = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + weight = (image_subpixel_scale - x_hr) * + (image_subpixel_scale - y_hr); + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + src_alpha += weight * color_type::full_value(); + } + else + { + fg[order_type::R] += back_r * weight; + fg[order_type::G] += back_g * weight; + fg[order_type::B] += back_b * weight; + src_alpha += back_a * weight; + } + + x_lr++; + + weight = x_hr * (image_subpixel_scale - y_hr); + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + src_alpha += weight * color_type::full_value(); + } + else + { + fg[order_type::R] += back_r * weight; + fg[order_type::G] += back_g * weight; + fg[order_type::B] += back_b * weight; + src_alpha += back_a * weight; + } + + x_lr--; + y_lr++; + + weight = (image_subpixel_scale - x_hr) * y_hr; + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + src_alpha += weight * color_type::full_value(); + } + else + { + fg[order_type::R] += back_r * weight; + fg[order_type::G] += back_g * weight; + fg[order_type::B] += back_b * weight; + src_alpha += back_a * weight; + } + + x_lr++; + + weight = x_hr * y_hr; + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + src_alpha += weight * color_type::full_value(); + } + else + { + fg[order_type::R] += back_r * weight; + fg[order_type::G] += back_g * weight; + fg[order_type::B] += back_b * weight; + src_alpha += back_a * weight; + } + + fg[0] = color_type::downshift(fg[0], image_subpixel_shift * 2); + fg[1] = color_type::downshift(fg[1], image_subpixel_shift * 2); + fg[2] = color_type::downshift(fg[2], image_subpixel_shift * 2); + src_alpha = color_type::downshift(src_alpha, image_subpixel_shift * 2); + } + } + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = (value_type)src_alpha; + ++span; + ++base_type::interpolator(); + + } while(--len); + } + private: + color_type m_back_color; + }; + + + + //===============================================span_image_filter_rgb_2x2 + template + class span_image_filter_rgb_2x2 : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgb_2x2() {} + span_image_filter_rgb_2x2(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, &filter) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg[3]; + + const value_type *fg_ptr; + const int16* weight_array = base_type::filter().weight_array() + + ((base_type::filter().diameter()/2 - 1) << + image_subpixel_shift); + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + unsigned weight; + fg[0] = fg[1] = fg[2] = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); + weight = (weight_array[x_hr + image_subpixel_scale] * + weight_array[y_hr + image_subpixel_scale] + + image_filter_scale / 2) >> + image_filter_shift; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = (weight_array[x_hr] * + weight_array[y_hr + image_subpixel_scale] + + image_filter_scale / 2) >> + image_filter_shift; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_y(); + weight = (weight_array[x_hr + image_subpixel_scale] * + weight_array[y_hr] + + image_filter_scale / 2) >> + image_filter_shift; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = (weight_array[x_hr] * + weight_array[y_hr] + + image_filter_scale / 2) >> + image_filter_shift; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + fg[0] = color_type::downshift(fg[0], image_filter_shift); + fg[1] = color_type::downshift(fg[1], image_filter_shift); + fg[2] = color_type::downshift(fg[2], image_filter_shift); + + if(fg[order_type::R] > color_type::full_value()) fg[order_type::R] = color_type::full_value(); + if(fg[order_type::G] > color_type::full_value()) fg[order_type::G] = color_type::full_value(); + if(fg[order_type::B] > color_type::full_value()) fg[order_type::B] = color_type::full_value(); + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = color_type::full_value(); + + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + + //===================================================span_image_filter_rgb + template + class span_image_filter_rgb : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgb() {} + span_image_filter_rgb(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, &filter) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg[3]; + const value_type *fg_ptr; + + unsigned diameter = base_type::filter().diameter(); + int start = base_type::filter().start(); + const int16* weight_array = base_type::filter().weight_array(); + + int x_count; + int weight_y; + + do + { + base_type::interpolator().coordinates(&x, &y); + + x -= base_type::filter_dx_int(); + y -= base_type::filter_dy_int(); + + int x_hr = x; + int y_hr = y; + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + fg[0] = fg[1] = fg[2] = 0; + + int x_fract = x_hr & image_subpixel_mask; + unsigned y_count = diameter; + + y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); + fg_ptr = (const value_type*)base_type::source().span(x_lr + start, + y_lr + start, + diameter); + for(;;) + { + x_count = diameter; + weight_y = weight_array[y_hr]; + x_hr = image_subpixel_mask - x_fract; + for(;;) + { + int weight = (weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + image_filter_shift; + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr; + + if(--x_count == 0) break; + x_hr += image_subpixel_scale; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + + if(--y_count == 0) break; + y_hr += image_subpixel_scale; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg[0] = color_type::downshift(fg[0], image_filter_shift); + fg[1] = color_type::downshift(fg[1], image_filter_shift); + fg[2] = color_type::downshift(fg[2], image_filter_shift); + + if(fg[0] < 0) fg[0] = 0; + if(fg[1] < 0) fg[1] = 0; + if(fg[2] < 0) fg[2] = 0; + + if(fg[order_type::R] > color_type::full_value()) fg[order_type::R] = color_type::full_value(); + if(fg[order_type::G] > color_type::full_value()) fg[order_type::G] = color_type::full_value(); + if(fg[order_type::B] > color_type::full_value()) fg[order_type::B] = color_type::full_value(); + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = color_type::full_value(); + + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + + //==========================================span_image_resample_rgb_affine + template + class span_image_resample_rgb_affine : + public span_image_resample_affine + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef span_image_resample_affine base_type; + typedef typename base_type::interpolator_type interpolator_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + downscale_shift = image_filter_shift + }; + + //-------------------------------------------------------------------- + span_image_resample_rgb_affine() {} + span_image_resample_rgb_affine(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, filter) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg[3]; + + int diameter = base_type::filter().diameter(); + int filter_scale = diameter << image_subpixel_shift; + int radius_x = (diameter * base_type::m_rx) >> 1; + int radius_y = (diameter * base_type::m_ry) >> 1; + int len_x_lr = + (diameter * base_type::m_rx + image_subpixel_mask) >> + image_subpixel_shift; + + const int16* weight_array = base_type::filter().weight_array(); + + do + { + base_type::interpolator().coordinates(&x, &y); + + x += base_type::filter_dx_int() - radius_x; + y += base_type::filter_dy_int() - radius_y; + + fg[0] = fg[1] = fg[2] = 0; + + int y_lr = y >> image_subpixel_shift; + int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * + base_type::m_ry_inv) >> + image_subpixel_shift; + int total_weight = 0; + int x_lr = x >> image_subpixel_shift; + int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * + base_type::m_rx_inv) >> + image_subpixel_shift; + + int x_hr2 = x_hr; + const value_type* fg_ptr = + (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); + for(;;) + { + int weight_y = weight_array[y_hr]; + x_hr = x_hr2; + for(;;) + { + int weight = (weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + downscale_shift; + + fg[0] += *fg_ptr++ * weight; + fg[1] += *fg_ptr++ * weight; + fg[2] += *fg_ptr * weight; + total_weight += weight; + x_hr += base_type::m_rx_inv; + if(x_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + y_hr += base_type::m_ry_inv; + if(y_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg[0] /= total_weight; + fg[1] /= total_weight; + fg[2] /= total_weight; + + if(fg[0] < 0) fg[0] = 0; + if(fg[1] < 0) fg[1] = 0; + if(fg[2] < 0) fg[2] = 0; + + if(fg[order_type::R] > color_type::full_value()) fg[order_type::R] = color_type::full_value(); + if(fg[order_type::G] > color_type::full_value()) fg[order_type::G] = color_type::full_value(); + if(fg[order_type::B] > color_type::full_value()) fg[order_type::B] = color_type::full_value(); + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = color_type::full_value(); + + ++span; + ++base_type::interpolator(); + } while(--len); + } + }; + + + + //=================================================span_image_resample_rgb + template + class span_image_resample_rgb : + public span_image_resample + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_resample base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + downscale_shift = image_filter_shift + }; + + //-------------------------------------------------------------------- + span_image_resample_rgb() {} + span_image_resample_rgb(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, filter) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + long_type fg[3]; + + int diameter = base_type::filter().diameter(); + int filter_scale = diameter << image_subpixel_shift; + + const int16* weight_array = base_type::filter().weight_array(); + do + { + int rx; + int ry; + int rx_inv = image_subpixel_scale; + int ry_inv = image_subpixel_scale; + base_type::interpolator().coordinates(&x, &y); + base_type::interpolator().local_scale(&rx, &ry); + base_type::adjust_scale(&rx, &ry); + + rx_inv = image_subpixel_scale * image_subpixel_scale / rx; + ry_inv = image_subpixel_scale * image_subpixel_scale / ry; + + int radius_x = (diameter * rx) >> 1; + int radius_y = (diameter * ry) >> 1; + int len_x_lr = + (diameter * rx + image_subpixel_mask) >> + image_subpixel_shift; + + x += base_type::filter_dx_int() - radius_x; + y += base_type::filter_dy_int() - radius_y; + + fg[0] = fg[1] = fg[2] = 0; + + int y_lr = y >> image_subpixel_shift; + int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * + ry_inv) >> + image_subpixel_shift; + int total_weight = 0; + int x_lr = x >> image_subpixel_shift; + int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * + rx_inv) >> + image_subpixel_shift; + int x_hr2 = x_hr; + const value_type* fg_ptr = + (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); + + for(;;) + { + int weight_y = weight_array[y_hr]; + x_hr = x_hr2; + for(;;) + { + int weight = (weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + downscale_shift; + fg[0] += *fg_ptr++ * weight; + fg[1] += *fg_ptr++ * weight; + fg[2] += *fg_ptr * weight; + total_weight += weight; + x_hr += rx_inv; + if(x_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + y_hr += ry_inv; + if(y_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg[0] /= total_weight; + fg[1] /= total_weight; + fg[2] /= total_weight; + + if(fg[0] < 0) fg[0] = 0; + if(fg[1] < 0) fg[1] = 0; + if(fg[2] < 0) fg[2] = 0; + + if(fg[order_type::R] > color_type::full_value()) fg[order_type::R] = color_type::full_value(); + if(fg[order_type::G] > color_type::full_value()) fg[order_type::G] = color_type::full_value(); + if(fg[order_type::B] > color_type::full_value()) fg[order_type::B] = color_type::full_value(); + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = color_type::full_value(); + + ++span; + ++base_type::interpolator(); + } while(--len); + } + }; + + +} + + +#endif + + + diff --git a/xs/src/agg/agg_span_image_filter_rgba.h b/xs/src/agg/agg_span_image_filter_rgba.h new file mode 100644 index 0000000000..af7a1a2ef0 --- /dev/null +++ b/xs/src/agg/agg_span_image_filter_rgba.h @@ -0,0 +1,890 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- +#ifndef AGG_SPAN_IMAGE_FILTER_RGBA_INCLUDED +#define AGG_SPAN_IMAGE_FILTER_RGBA_INCLUDED + +#include "agg_basics.h" +#include "agg_color_rgba.h" +#include "agg_span_image_filter.h" + + +namespace agg +{ + + //==============================================span_image_filter_rgba_nn + template + class span_image_filter_rgba_nn : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgba_nn() {} + span_image_filter_rgba_nn(source_type& src, + interpolator_type& inter) : + base_type(src, inter, 0) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + do + { + base_type::interpolator().coordinates(&x, &y); + const value_type* fg_ptr = (const value_type*) + base_type::source().span(x >> image_subpixel_shift, + y >> image_subpixel_shift, + 1); + span->r = fg_ptr[order_type::R]; + span->g = fg_ptr[order_type::G]; + span->b = fg_ptr[order_type::B]; + span->a = fg_ptr[order_type::A]; + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + + //=========================================span_image_filter_rgba_bilinear + template + class span_image_filter_rgba_bilinear : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgba_bilinear() {} + span_image_filter_rgba_bilinear(source_type& src, + interpolator_type& inter) : + base_type(src, inter, 0) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg[4]; + const value_type *fg_ptr; + + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + unsigned weight; + + fg[0] = + fg[1] = + fg[2] = + fg[3] = image_subpixel_scale * image_subpixel_scale / 2; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); + weight = (image_subpixel_scale - x_hr) * + (image_subpixel_scale - y_hr); + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = x_hr * (image_subpixel_scale - y_hr); + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_y(); + weight = (image_subpixel_scale - x_hr) * y_hr; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = x_hr * y_hr; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + span->r = value_type(color_type::downshift(fg[order_type::R], image_subpixel_shift * 2)); + span->g = value_type(color_type::downshift(fg[order_type::G], image_subpixel_shift * 2)); + span->b = value_type(color_type::downshift(fg[order_type::B], image_subpixel_shift * 2)); + span->a = value_type(color_type::downshift(fg[order_type::A], image_subpixel_shift * 2)); + + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + //====================================span_image_filter_rgba_bilinear_clip + template + class span_image_filter_rgba_bilinear_clip : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgba_bilinear_clip() {} + span_image_filter_rgba_bilinear_clip(source_type& src, + const color_type& back_color, + interpolator_type& inter) : + base_type(src, inter, 0), + m_back_color(back_color) + {} + const color_type& background_color() const { return m_back_color; } + void background_color(const color_type& v) { m_back_color = v; } + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg[4]; + value_type back_r = m_back_color.r; + value_type back_g = m_back_color.g; + value_type back_b = m_back_color.b; + value_type back_a = m_back_color.a; + + const value_type *fg_ptr; + int maxx = base_type::source().width() - 1; + int maxy = base_type::source().height() - 1; + + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + unsigned weight; + + if(x_lr >= 0 && y_lr >= 0 && + x_lr < maxx && y_lr < maxy) + { + fg[0] = fg[1] = fg[2] = fg[3] = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + (x_lr << 2); + + weight = (image_subpixel_scale - x_hr) * + (image_subpixel_scale - y_hr); + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr++; + + weight = x_hr * (image_subpixel_scale - y_hr); + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr++; + + ++y_lr; + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + (x_lr << 2); + + weight = (image_subpixel_scale - x_hr) * y_hr; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr++; + + weight = x_hr * y_hr; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr++; + + fg[0] = color_type::downshift(fg[0], image_subpixel_shift * 2); + fg[1] = color_type::downshift(fg[1], image_subpixel_shift * 2); + fg[2] = color_type::downshift(fg[2], image_subpixel_shift * 2); + fg[3] = color_type::downshift(fg[3], image_subpixel_shift * 2); + } + else + { + if(x_lr < -1 || y_lr < -1 || + x_lr > maxx || y_lr > maxy) + { + fg[order_type::R] = back_r; + fg[order_type::G] = back_g; + fg[order_type::B] = back_b; + fg[order_type::A] = back_a; + } + else + { + fg[0] = fg[1] = fg[2] = fg[3] = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + weight = (image_subpixel_scale - x_hr) * + (image_subpixel_scale - y_hr); + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + (x_lr << 2); + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr++; + } + else + { + fg[order_type::R] += back_r * weight; + fg[order_type::G] += back_g * weight; + fg[order_type::B] += back_b * weight; + fg[order_type::A] += back_a * weight; + } + + x_lr++; + + weight = x_hr * (image_subpixel_scale - y_hr); + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + (x_lr << 2); + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr++; + } + else + { + fg[order_type::R] += back_r * weight; + fg[order_type::G] += back_g * weight; + fg[order_type::B] += back_b * weight; + fg[order_type::A] += back_a * weight; + } + + x_lr--; + y_lr++; + + weight = (image_subpixel_scale - x_hr) * y_hr; + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + (x_lr << 2); + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr++; + } + else + { + fg[order_type::R] += back_r * weight; + fg[order_type::G] += back_g * weight; + fg[order_type::B] += back_b * weight; + fg[order_type::A] += back_a * weight; + } + + x_lr++; + + weight = x_hr * y_hr; + if(x_lr >= 0 && y_lr >= 0 && + x_lr <= maxx && y_lr <= maxy) + { + fg_ptr = (const value_type*) + base_type::source().row_ptr(y_lr) + (x_lr << 2); + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr++; + } + else + { + fg[order_type::R] += back_r * weight; + fg[order_type::G] += back_g * weight; + fg[order_type::B] += back_b * weight; + fg[order_type::A] += back_a * weight; + } + + fg[0] = color_type::downshift(fg[0], image_subpixel_shift * 2); + fg[1] = color_type::downshift(fg[1], image_subpixel_shift * 2); + fg[2] = color_type::downshift(fg[2], image_subpixel_shift * 2); + fg[3] = color_type::downshift(fg[3], image_subpixel_shift * 2); + } + } + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = (value_type)fg[order_type::A]; + ++span; + ++base_type::interpolator(); + + } while(--len); + } + private: + color_type m_back_color; + }; + + + //==============================================span_image_filter_rgba_2x2 + template + class span_image_filter_rgba_2x2 : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgba_2x2() {} + span_image_filter_rgba_2x2(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, &filter) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg[4]; + + const value_type *fg_ptr; + const int16* weight_array = base_type::filter().weight_array() + + ((base_type::filter().diameter()/2 - 1) << + image_subpixel_shift); + + do + { + int x_hr; + int y_hr; + + base_type::interpolator().coordinates(&x_hr, &y_hr); + + x_hr -= base_type::filter_dx_int(); + y_hr -= base_type::filter_dy_int(); + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + unsigned weight; + fg[0] = fg[1] = fg[2] = fg[3] = 0; + + x_hr &= image_subpixel_mask; + y_hr &= image_subpixel_mask; + + fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); + weight = (weight_array[x_hr + image_subpixel_scale] * + weight_array[y_hr + image_subpixel_scale] + + image_filter_scale / 2) >> + image_filter_shift; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = (weight_array[x_hr] * + weight_array[y_hr + image_subpixel_scale] + + image_filter_scale / 2) >> + image_filter_shift; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_y(); + weight = (weight_array[x_hr + image_subpixel_scale] * + weight_array[y_hr] + + image_filter_scale / 2) >> + image_filter_shift; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + fg_ptr = (const value_type*)base_type::source().next_x(); + weight = (weight_array[x_hr] * + weight_array[y_hr] + + image_filter_scale / 2) >> + image_filter_shift; + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + fg[0] = color_type::downshift(fg[0], image_filter_shift); + fg[1] = color_type::downshift(fg[1], image_filter_shift); + fg[2] = color_type::downshift(fg[2], image_filter_shift); + fg[3] = color_type::downshift(fg[3], image_filter_shift); + + if(fg[order_type::A] > color_type::full_value()) fg[order_type::A] = color_type::full_value(); + if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; + if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; + if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = (value_type)fg[order_type::A]; + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + + //==================================================span_image_filter_rgba + template + class span_image_filter_rgba : + public span_image_filter + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_filter base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + typedef typename color_type::long_type long_type; + + //-------------------------------------------------------------------- + span_image_filter_rgba() {} + span_image_filter_rgba(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, &filter) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg[4]; + const value_type *fg_ptr; + + unsigned diameter = base_type::filter().diameter(); + int start = base_type::filter().start(); + const int16* weight_array = base_type::filter().weight_array(); + + int x_count; + int weight_y; + + do + { + base_type::interpolator().coordinates(&x, &y); + + x -= base_type::filter_dx_int(); + y -= base_type::filter_dy_int(); + + int x_hr = x; + int y_hr = y; + + int x_lr = x_hr >> image_subpixel_shift; + int y_lr = y_hr >> image_subpixel_shift; + + fg[0] = fg[1] = fg[2] = fg[3] = 0; + + int x_fract = x_hr & image_subpixel_mask; + unsigned y_count = diameter; + + y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); + fg_ptr = (const value_type*)base_type::source().span(x_lr + start, + y_lr + start, + diameter); + for(;;) + { + x_count = diameter; + weight_y = weight_array[y_hr]; + x_hr = image_subpixel_mask - x_fract; + for(;;) + { + int weight = (weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + image_filter_shift; + + fg[0] += weight * *fg_ptr++; + fg[1] += weight * *fg_ptr++; + fg[2] += weight * *fg_ptr++; + fg[3] += weight * *fg_ptr; + + if(--x_count == 0) break; + x_hr += image_subpixel_scale; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + + if(--y_count == 0) break; + y_hr += image_subpixel_scale; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg[0] = color_type::downshift(fg[0], image_filter_shift); + fg[1] = color_type::downshift(fg[1], image_filter_shift); + fg[2] = color_type::downshift(fg[2], image_filter_shift); + fg[3] = color_type::downshift(fg[3], image_filter_shift); + + if(fg[0] < 0) fg[0] = 0; + if(fg[1] < 0) fg[1] = 0; + if(fg[2] < 0) fg[2] = 0; + if(fg[3] < 0) fg[3] = 0; + + if(fg[order_type::A] > color_type::full_value()) fg[order_type::A] = color_type::full_value(); + if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; + if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; + if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = (value_type)fg[order_type::A]; + ++span; + ++base_type::interpolator(); + + } while(--len); + } + }; + + + + //========================================span_image_resample_rgba_affine + template + class span_image_resample_rgba_affine : + public span_image_resample_affine + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef span_image_resample_affine base_type; + typedef typename base_type::interpolator_type interpolator_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + downscale_shift = image_filter_shift + }; + + //-------------------------------------------------------------------- + span_image_resample_rgba_affine() {} + span_image_resample_rgba_affine(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, filter) + {} + + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + + long_type fg[4]; + + int diameter = base_type::filter().diameter(); + int filter_scale = diameter << image_subpixel_shift; + int radius_x = (diameter * base_type::m_rx) >> 1; + int radius_y = (diameter * base_type::m_ry) >> 1; + int len_x_lr = + (diameter * base_type::m_rx + image_subpixel_mask) >> + image_subpixel_shift; + + const int16* weight_array = base_type::filter().weight_array(); + + do + { + base_type::interpolator().coordinates(&x, &y); + + x += base_type::filter_dx_int() - radius_x; + y += base_type::filter_dy_int() - radius_y; + + fg[0] = fg[1] = fg[2] = fg[3] = 0; + + int y_lr = y >> image_subpixel_shift; + int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * + base_type::m_ry_inv) >> + image_subpixel_shift; + int total_weight = 0; + int x_lr = x >> image_subpixel_shift; + int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * + base_type::m_rx_inv) >> + image_subpixel_shift; + + int x_hr2 = x_hr; + const value_type* fg_ptr = + (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); + for(;;) + { + int weight_y = weight_array[y_hr]; + x_hr = x_hr2; + for(;;) + { + int weight = (weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + downscale_shift; + + fg[0] += *fg_ptr++ * weight; + fg[1] += *fg_ptr++ * weight; + fg[2] += *fg_ptr++ * weight; + fg[3] += *fg_ptr++ * weight; + total_weight += weight; + x_hr += base_type::m_rx_inv; + if(x_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + y_hr += base_type::m_ry_inv; + if(y_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg[0] /= total_weight; + fg[1] /= total_weight; + fg[2] /= total_weight; + fg[3] /= total_weight; + + if(fg[0] < 0) fg[0] = 0; + if(fg[1] < 0) fg[1] = 0; + if(fg[2] < 0) fg[2] = 0; + if(fg[3] < 0) fg[3] = 0; + + if(fg[order_type::A] > color_type::full_value()) fg[order_type::A] = color_type::full_value(); + if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; + if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; + if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = (value_type)fg[order_type::A]; + + ++span; + ++base_type::interpolator(); + } while(--len); + } + }; + + + + //==============================================span_image_resample_rgba + template + class span_image_resample_rgba : + public span_image_resample + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef Interpolator interpolator_type; + typedef span_image_resample base_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::long_type long_type; + enum base_scale_e + { + downscale_shift = image_filter_shift + }; + + //-------------------------------------------------------------------- + span_image_resample_rgba() {} + span_image_resample_rgba(source_type& src, + interpolator_type& inter, + image_filter_lut& filter) : + base_type(src, inter, filter) + {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + base_type::interpolator().begin(x + base_type::filter_dx_dbl(), + y + base_type::filter_dy_dbl(), len); + long_type fg[4]; + + int diameter = base_type::filter().diameter(); + int filter_scale = diameter << image_subpixel_shift; + + const int16* weight_array = base_type::filter().weight_array(); + do + { + int rx; + int ry; + int rx_inv = image_subpixel_scale; + int ry_inv = image_subpixel_scale; + base_type::interpolator().coordinates(&x, &y); + base_type::interpolator().local_scale(&rx, &ry); + base_type::adjust_scale(&rx, &ry); + + rx_inv = image_subpixel_scale * image_subpixel_scale / rx; + ry_inv = image_subpixel_scale * image_subpixel_scale / ry; + + int radius_x = (diameter * rx) >> 1; + int radius_y = (diameter * ry) >> 1; + int len_x_lr = + (diameter * rx + image_subpixel_mask) >> + image_subpixel_shift; + + x += base_type::filter_dx_int() - radius_x; + y += base_type::filter_dy_int() - radius_y; + + fg[0] = fg[1] = fg[2] = fg[3] = 0; + + int y_lr = y >> image_subpixel_shift; + int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * + ry_inv) >> + image_subpixel_shift; + int total_weight = 0; + int x_lr = x >> image_subpixel_shift; + int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * + rx_inv) >> + image_subpixel_shift; + int x_hr2 = x_hr; + const value_type* fg_ptr = + (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); + + for(;;) + { + int weight_y = weight_array[y_hr]; + x_hr = x_hr2; + for(;;) + { + int weight = (weight_y * weight_array[x_hr] + + image_filter_scale / 2) >> + downscale_shift; + fg[0] += *fg_ptr++ * weight; + fg[1] += *fg_ptr++ * weight; + fg[2] += *fg_ptr++ * weight; + fg[3] += *fg_ptr++ * weight; + total_weight += weight; + x_hr += rx_inv; + if(x_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_x(); + } + y_hr += ry_inv; + if(y_hr >= filter_scale) break; + fg_ptr = (const value_type*)base_type::source().next_y(); + } + + fg[0] /= total_weight; + fg[1] /= total_weight; + fg[2] /= total_weight; + fg[3] /= total_weight; + + if(fg[0] < 0) fg[0] = 0; + if(fg[1] < 0) fg[1] = 0; + if(fg[2] < 0) fg[2] = 0; + if(fg[3] < 0) fg[3] = 0; + + if(fg[order_type::A] > color_type::full_value()) fg[order_type::A] = color_type::full_value(); + if(fg[order_type::R] > fg[order_type::R]) fg[order_type::R] = fg[order_type::R]; + if(fg[order_type::G] > fg[order_type::G]) fg[order_type::G] = fg[order_type::G]; + if(fg[order_type::B] > fg[order_type::B]) fg[order_type::B] = fg[order_type::B]; + + span->r = (value_type)fg[order_type::R]; + span->g = (value_type)fg[order_type::G]; + span->b = (value_type)fg[order_type::B]; + span->a = (value_type)fg[order_type::A]; + + ++span; + ++base_type::interpolator(); + } while(--len); + } + }; + + +} + + +#endif + + + diff --git a/xs/src/agg/agg_span_interpolator_adaptor.h b/xs/src/agg/agg_span_interpolator_adaptor.h new file mode 100644 index 0000000000..0fdfa77479 --- /dev/null +++ b/xs/src/agg/agg_span_interpolator_adaptor.h @@ -0,0 +1,77 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED +#define AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //===============================================span_interpolator_adaptor + template + class span_interpolator_adaptor : public Interpolator + { + public: + typedef Interpolator base_type; + typedef typename base_type::trans_type trans_type; + typedef Distortion distortion_type; + + //-------------------------------------------------------------------- + span_interpolator_adaptor() {} + span_interpolator_adaptor(trans_type& trans, + distortion_type& dist) : + base_type(trans), + m_distortion(&dist) + { + } + + //-------------------------------------------------------------------- + span_interpolator_adaptor(trans_type& trans, + distortion_type& dist, + double x, double y, unsigned len) : + base_type(trans, x, y, len), + m_distortion(&dist) + { + } + + //-------------------------------------------------------------------- + distortion_type& distortion() const + { + return *m_distortion; + } + + //-------------------------------------------------------------------- + void distortion(distortion_type& dist) + { + m_distortion = dist; + } + + //-------------------------------------------------------------------- + void coordinates(int* x, int* y) const + { + base_type::coordinates(x, y); + m_distortion->calculate(x, y); + } + + private: + //-------------------------------------------------------------------- + distortion_type* m_distortion; + }; +} + + +#endif diff --git a/xs/src/agg/agg_span_interpolator_linear.h b/xs/src/agg/agg_span_interpolator_linear.h new file mode 100644 index 0000000000..ef10505ce1 --- /dev/null +++ b/xs/src/agg/agg_span_interpolator_linear.h @@ -0,0 +1,232 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_INTERPOLATOR_LINEAR_INCLUDED +#define AGG_SPAN_INTERPOLATOR_LINEAR_INCLUDED + +#include "agg_basics.h" +#include "agg_dda_line.h" +#include "agg_trans_affine.h" + +namespace agg +{ + + //================================================span_interpolator_linear + template + class span_interpolator_linear + { + public: + typedef Transformer trans_type; + + enum subpixel_scale_e + { + subpixel_shift = SubpixelShift, + subpixel_scale = 1 << subpixel_shift + }; + + //-------------------------------------------------------------------- + span_interpolator_linear() {} + span_interpolator_linear(trans_type& trans) : m_trans(&trans) {} + span_interpolator_linear(trans_type& trans, + double x, double y, unsigned len) : + m_trans(&trans) + { + begin(x, y, len); + } + + //---------------------------------------------------------------- + const trans_type& transformer() const { return *m_trans; } + void transformer(trans_type& trans) { m_trans = &trans; } + + //---------------------------------------------------------------- + void begin(double x, double y, unsigned len) + { + double tx; + double ty; + + tx = x; + ty = y; + m_trans->transform(&tx, &ty); + int x1 = iround(tx * subpixel_scale); + int y1 = iround(ty * subpixel_scale); + + tx = x + len; + ty = y; + m_trans->transform(&tx, &ty); + int x2 = iround(tx * subpixel_scale); + int y2 = iround(ty * subpixel_scale); + + m_li_x = dda2_line_interpolator(x1, x2, len); + m_li_y = dda2_line_interpolator(y1, y2, len); + } + + //---------------------------------------------------------------- + void resynchronize(double xe, double ye, unsigned len) + { + m_trans->transform(&xe, &ye); + m_li_x = dda2_line_interpolator(m_li_x.y(), iround(xe * subpixel_scale), len); + m_li_y = dda2_line_interpolator(m_li_y.y(), iround(ye * subpixel_scale), len); + } + + //---------------------------------------------------------------- + void operator++() + { + ++m_li_x; + ++m_li_y; + } + + //---------------------------------------------------------------- + void coordinates(int* x, int* y) const + { + *x = m_li_x.y(); + *y = m_li_y.y(); + } + + private: + trans_type* m_trans; + dda2_line_interpolator m_li_x; + dda2_line_interpolator m_li_y; + }; + + + + + + + //=====================================span_interpolator_linear_subdiv + template + class span_interpolator_linear_subdiv + { + public: + typedef Transformer trans_type; + + enum subpixel_scale_e + { + subpixel_shift = SubpixelShift, + subpixel_scale = 1 << subpixel_shift + }; + + + //---------------------------------------------------------------- + span_interpolator_linear_subdiv() : + m_subdiv_shift(4), + m_subdiv_size(1 << m_subdiv_shift), + m_subdiv_mask(m_subdiv_size - 1) {} + + span_interpolator_linear_subdiv(trans_type& trans, + unsigned subdiv_shift = 4) : + m_subdiv_shift(subdiv_shift), + m_subdiv_size(1 << m_subdiv_shift), + m_subdiv_mask(m_subdiv_size - 1), + m_trans(&trans) {} + + span_interpolator_linear_subdiv(trans_type& trans, + double x, double y, unsigned len, + unsigned subdiv_shift = 4) : + m_subdiv_shift(subdiv_shift), + m_subdiv_size(1 << m_subdiv_shift), + m_subdiv_mask(m_subdiv_size - 1), + m_trans(&trans) + { + begin(x, y, len); + } + + //---------------------------------------------------------------- + const trans_type& transformer() const { return *m_trans; } + void transformer(const trans_type& trans) { m_trans = &trans; } + + //---------------------------------------------------------------- + unsigned subdiv_shift() const { return m_subdiv_shift; } + void subdiv_shift(unsigned shift) + { + m_subdiv_shift = shift; + m_subdiv_size = 1 << m_subdiv_shift; + m_subdiv_mask = m_subdiv_size - 1; + } + + //---------------------------------------------------------------- + void begin(double x, double y, unsigned len) + { + double tx; + double ty; + m_pos = 1; + m_src_x = iround(x * subpixel_scale) + subpixel_scale; + m_src_y = y; + m_len = len; + + if(len > m_subdiv_size) len = m_subdiv_size; + tx = x; + ty = y; + m_trans->transform(&tx, &ty); + int x1 = iround(tx * subpixel_scale); + int y1 = iround(ty * subpixel_scale); + + tx = x + len; + ty = y; + m_trans->transform(&tx, &ty); + + m_li_x = dda2_line_interpolator(x1, iround(tx * subpixel_scale), len); + m_li_y = dda2_line_interpolator(y1, iround(ty * subpixel_scale), len); + } + + //---------------------------------------------------------------- + void operator++() + { + ++m_li_x; + ++m_li_y; + if(m_pos >= m_subdiv_size) + { + unsigned len = m_len; + if(len > m_subdiv_size) len = m_subdiv_size; + double tx = double(m_src_x) / double(subpixel_scale) + len; + double ty = m_src_y; + m_trans->transform(&tx, &ty); + m_li_x = dda2_line_interpolator(m_li_x.y(), iround(tx * subpixel_scale), len); + m_li_y = dda2_line_interpolator(m_li_y.y(), iround(ty * subpixel_scale), len); + m_pos = 0; + } + m_src_x += subpixel_scale; + ++m_pos; + --m_len; + } + + //---------------------------------------------------------------- + void coordinates(int* x, int* y) const + { + *x = m_li_x.y(); + *y = m_li_y.y(); + } + + private: + unsigned m_subdiv_shift; + unsigned m_subdiv_size; + unsigned m_subdiv_mask; + trans_type* m_trans; + dda2_line_interpolator m_li_x; + dda2_line_interpolator m_li_y; + int m_src_x; + double m_src_y; + unsigned m_pos; + unsigned m_len; + }; + + +} + + + +#endif + + diff --git a/xs/src/agg/agg_span_interpolator_persp.h b/xs/src/agg/agg_span_interpolator_persp.h new file mode 100644 index 0000000000..cad437e04f --- /dev/null +++ b/xs/src/agg/agg_span_interpolator_persp.h @@ -0,0 +1,462 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_SPAN_INTERPOLATOR_PERSP_INCLUDED +#define AGG_SPAN_INTERPOLATOR_PERSP_INCLUDED + +#include "agg_trans_perspective.h" +#include "agg_dda_line.h" + +namespace agg +{ + + + + //===========================================span_interpolator_persp_exact + template + class span_interpolator_persp_exact + { + public: + typedef trans_perspective trans_type; + typedef trans_perspective::iterator_x iterator_type; + enum subpixel_scale_e + { + subpixel_shift = SubpixelShift, + subpixel_scale = 1 << subpixel_shift + }; + + //-------------------------------------------------------------------- + span_interpolator_persp_exact() {} + + //-------------------------------------------------------------------- + // Arbitrary quadrangle transformations + span_interpolator_persp_exact(const double* src, const double* dst) + { + quad_to_quad(src, dst); + } + + //-------------------------------------------------------------------- + // Direct transformations + span_interpolator_persp_exact(double x1, double y1, + double x2, double y2, + const double* quad) + { + rect_to_quad(x1, y1, x2, y2, quad); + } + + //-------------------------------------------------------------------- + // Reverse transformations + span_interpolator_persp_exact(const double* quad, + double x1, double y1, + double x2, double y2) + { + quad_to_rect(quad, x1, y1, x2, y2); + } + + //-------------------------------------------------------------------- + // Set the transformations using two arbitrary quadrangles. + void quad_to_quad(const double* src, const double* dst) + { + m_trans_dir.quad_to_quad(src, dst); + m_trans_inv.quad_to_quad(dst, src); + } + + //-------------------------------------------------------------------- + // Set the direct transformations, i.e., rectangle -> quadrangle + void rect_to_quad(double x1, double y1, double x2, double y2, + const double* quad) + { + double src[8]; + src[0] = src[6] = x1; + src[2] = src[4] = x2; + src[1] = src[3] = y1; + src[5] = src[7] = y2; + quad_to_quad(src, quad); + } + + + //-------------------------------------------------------------------- + // Set the reverse transformations, i.e., quadrangle -> rectangle + void quad_to_rect(const double* quad, + double x1, double y1, double x2, double y2) + { + double dst[8]; + dst[0] = dst[6] = x1; + dst[2] = dst[4] = x2; + dst[1] = dst[3] = y1; + dst[5] = dst[7] = y2; + quad_to_quad(quad, dst); + } + + //-------------------------------------------------------------------- + // Check if the equations were solved successfully + bool is_valid() const { return m_trans_dir.is_valid(); } + + //---------------------------------------------------------------- + void begin(double x, double y, unsigned len) + { + m_iterator = m_trans_dir.begin(x, y, 1.0); + double xt = m_iterator.x; + double yt = m_iterator.y; + + double dx; + double dy; + const double delta = 1/double(subpixel_scale); + dx = xt + delta; + dy = yt; + m_trans_inv.transform(&dx, &dy); + dx -= x; + dy -= y; + int sx1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + dx = xt; + dy = yt + delta; + m_trans_inv.transform(&dx, &dy); + dx -= x; + dy -= y; + int sy1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + x += len; + xt = x; + yt = y; + m_trans_dir.transform(&xt, &yt); + + dx = xt + delta; + dy = yt; + m_trans_inv.transform(&dx, &dy); + dx -= x; + dy -= y; + int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + dx = xt; + dy = yt + delta; + m_trans_inv.transform(&dx, &dy); + dx -= x; + dy -= y; + int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + m_scale_x = dda2_line_interpolator(sx1, sx2, len); + m_scale_y = dda2_line_interpolator(sy1, sy2, len); + } + + + //---------------------------------------------------------------- + void resynchronize(double xe, double ye, unsigned len) + { + // Assume x1,y1 are equal to the ones at the previous end point + int sx1 = m_scale_x.y(); + int sy1 = m_scale_y.y(); + + // Calculate transformed coordinates at x2,y2 + double xt = xe; + double yt = ye; + m_trans_dir.transform(&xt, &yt); + + const double delta = 1/double(subpixel_scale); + double dx; + double dy; + + // Calculate scale by X at x2,y2 + dx = xt + delta; + dy = yt; + m_trans_inv.transform(&dx, &dy); + dx -= xe; + dy -= ye; + int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + // Calculate scale by Y at x2,y2 + dx = xt; + dy = yt + delta; + m_trans_inv.transform(&dx, &dy); + dx -= xe; + dy -= ye; + int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + // Initialize the interpolators + m_scale_x = dda2_line_interpolator(sx1, sx2, len); + m_scale_y = dda2_line_interpolator(sy1, sy2, len); + } + + + + //---------------------------------------------------------------- + void operator++() + { + ++m_iterator; + ++m_scale_x; + ++m_scale_y; + } + + //---------------------------------------------------------------- + void coordinates(int* x, int* y) const + { + *x = iround(m_iterator.x * subpixel_scale); + *y = iround(m_iterator.y * subpixel_scale); + } + + //---------------------------------------------------------------- + void local_scale(int* x, int* y) + { + *x = m_scale_x.y(); + *y = m_scale_y.y(); + } + + //---------------------------------------------------------------- + void transform(double* x, double* y) const + { + m_trans_dir.transform(x, y); + } + + private: + trans_type m_trans_dir; + trans_type m_trans_inv; + iterator_type m_iterator; + dda2_line_interpolator m_scale_x; + dda2_line_interpolator m_scale_y; + }; + + + + + + + + + + + + //============================================span_interpolator_persp_lerp + template + class span_interpolator_persp_lerp + { + public: + typedef trans_perspective trans_type; + enum subpixel_scale_e + { + subpixel_shift = SubpixelShift, + subpixel_scale = 1 << subpixel_shift + }; + + //-------------------------------------------------------------------- + span_interpolator_persp_lerp() {} + + //-------------------------------------------------------------------- + // Arbitrary quadrangle transformations + span_interpolator_persp_lerp(const double* src, const double* dst) + { + quad_to_quad(src, dst); + } + + //-------------------------------------------------------------------- + // Direct transformations + span_interpolator_persp_lerp(double x1, double y1, + double x2, double y2, + const double* quad) + { + rect_to_quad(x1, y1, x2, y2, quad); + } + + //-------------------------------------------------------------------- + // Reverse transformations + span_interpolator_persp_lerp(const double* quad, + double x1, double y1, + double x2, double y2) + { + quad_to_rect(quad, x1, y1, x2, y2); + } + + //-------------------------------------------------------------------- + // Set the transformations using two arbitrary quadrangles. + void quad_to_quad(const double* src, const double* dst) + { + m_trans_dir.quad_to_quad(src, dst); + m_trans_inv.quad_to_quad(dst, src); + } + + //-------------------------------------------------------------------- + // Set the direct transformations, i.e., rectangle -> quadrangle + void rect_to_quad(double x1, double y1, double x2, double y2, + const double* quad) + { + double src[8]; + src[0] = src[6] = x1; + src[2] = src[4] = x2; + src[1] = src[3] = y1; + src[5] = src[7] = y2; + quad_to_quad(src, quad); + } + + + //-------------------------------------------------------------------- + // Set the reverse transformations, i.e., quadrangle -> rectangle + void quad_to_rect(const double* quad, + double x1, double y1, double x2, double y2) + { + double dst[8]; + dst[0] = dst[6] = x1; + dst[2] = dst[4] = x2; + dst[1] = dst[3] = y1; + dst[5] = dst[7] = y2; + quad_to_quad(quad, dst); + } + + //-------------------------------------------------------------------- + // Check if the equations were solved successfully + bool is_valid() const { return m_trans_dir.is_valid(); } + + //---------------------------------------------------------------- + void begin(double x, double y, unsigned len) + { + // Calculate transformed coordinates at x1,y1 + double xt = x; + double yt = y; + m_trans_dir.transform(&xt, &yt); + int x1 = iround(xt * subpixel_scale); + int y1 = iround(yt * subpixel_scale); + + double dx; + double dy; + const double delta = 1/double(subpixel_scale); + + // Calculate scale by X at x1,y1 + dx = xt + delta; + dy = yt; + m_trans_inv.transform(&dx, &dy); + dx -= x; + dy -= y; + int sx1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + // Calculate scale by Y at x1,y1 + dx = xt; + dy = yt + delta; + m_trans_inv.transform(&dx, &dy); + dx -= x; + dy -= y; + int sy1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + // Calculate transformed coordinates at x2,y2 + x += len; + xt = x; + yt = y; + m_trans_dir.transform(&xt, &yt); + int x2 = iround(xt * subpixel_scale); + int y2 = iround(yt * subpixel_scale); + + // Calculate scale by X at x2,y2 + dx = xt + delta; + dy = yt; + m_trans_inv.transform(&dx, &dy); + dx -= x; + dy -= y; + int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + // Calculate scale by Y at x2,y2 + dx = xt; + dy = yt + delta; + m_trans_inv.transform(&dx, &dy); + dx -= x; + dy -= y; + int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + // Initialize the interpolators + m_coord_x = dda2_line_interpolator(x1, x2, len); + m_coord_y = dda2_line_interpolator(y1, y2, len); + m_scale_x = dda2_line_interpolator(sx1, sx2, len); + m_scale_y = dda2_line_interpolator(sy1, sy2, len); + } + + + //---------------------------------------------------------------- + void resynchronize(double xe, double ye, unsigned len) + { + // Assume x1,y1 are equal to the ones at the previous end point + int x1 = m_coord_x.y(); + int y1 = m_coord_y.y(); + int sx1 = m_scale_x.y(); + int sy1 = m_scale_y.y(); + + // Calculate transformed coordinates at x2,y2 + double xt = xe; + double yt = ye; + m_trans_dir.transform(&xt, &yt); + int x2 = iround(xt * subpixel_scale); + int y2 = iround(yt * subpixel_scale); + + const double delta = 1/double(subpixel_scale); + double dx; + double dy; + + // Calculate scale by X at x2,y2 + dx = xt + delta; + dy = yt; + m_trans_inv.transform(&dx, &dy); + dx -= xe; + dy -= ye; + int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + // Calculate scale by Y at x2,y2 + dx = xt; + dy = yt + delta; + m_trans_inv.transform(&dx, &dy); + dx -= xe; + dy -= ye; + int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; + + // Initialize the interpolators + m_coord_x = dda2_line_interpolator(x1, x2, len); + m_coord_y = dda2_line_interpolator(y1, y2, len); + m_scale_x = dda2_line_interpolator(sx1, sx2, len); + m_scale_y = dda2_line_interpolator(sy1, sy2, len); + } + + + //---------------------------------------------------------------- + void operator++() + { + ++m_coord_x; + ++m_coord_y; + ++m_scale_x; + ++m_scale_y; + } + + //---------------------------------------------------------------- + void coordinates(int* x, int* y) const + { + *x = m_coord_x.y(); + *y = m_coord_y.y(); + } + + //---------------------------------------------------------------- + void local_scale(int* x, int* y) + { + *x = m_scale_x.y(); + *y = m_scale_y.y(); + } + + //---------------------------------------------------------------- + void transform(double* x, double* y) const + { + m_trans_dir.transform(x, y); + } + + private: + trans_type m_trans_dir; + trans_type m_trans_inv; + dda2_line_interpolator m_coord_x; + dda2_line_interpolator m_coord_y; + dda2_line_interpolator m_scale_x; + dda2_line_interpolator m_scale_y; + }; + +} + +#endif diff --git a/xs/src/agg/agg_span_interpolator_trans.h b/xs/src/agg/agg_span_interpolator_trans.h new file mode 100644 index 0000000000..32bc678a8e --- /dev/null +++ b/xs/src/agg/agg_span_interpolator_trans.h @@ -0,0 +1,92 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Horizontal span interpolator for use with an arbitrary transformer +// The efficiency highly depends on the operations done in the transformer +// +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_INTERPOLATOR_TRANS_INCLUDED +#define AGG_SPAN_INTERPOLATOR_TRANS_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + //=================================================span_interpolator_trans + template + class span_interpolator_trans + { + public: + typedef Transformer trans_type; + enum subpixel_scale_e + { + subpixel_shift = SubpixelShift, + subpixel_scale = 1 << subpixel_shift + }; + + //-------------------------------------------------------------------- + span_interpolator_trans() {} + span_interpolator_trans(trans_type& trans) : m_trans(&trans) {} + span_interpolator_trans(trans_type& trans, + double x, double y, unsigned) : + m_trans(&trans) + { + begin(x, y, 0); + } + + //---------------------------------------------------------------- + const trans_type& transformer() const { return *m_trans; } + void transformer(const trans_type& trans) { m_trans = &trans; } + + //---------------------------------------------------------------- + void begin(double x, double y, unsigned) + { + m_x = x; + m_y = y; + m_trans->transform(&x, &y); + m_ix = iround(x * subpixel_scale); + m_iy = iround(y * subpixel_scale); + } + + //---------------------------------------------------------------- + void operator++() + { + m_x += 1.0; + double x = m_x; + double y = m_y; + m_trans->transform(&x, &y); + m_ix = iround(x * subpixel_scale); + m_iy = iround(y * subpixel_scale); + } + + //---------------------------------------------------------------- + void coordinates(int* x, int* y) const + { + *x = m_ix; + *y = m_iy; + } + + private: + trans_type* m_trans; + double m_x; + double m_y; + int m_ix; + int m_iy; + }; + +} + +#endif diff --git a/xs/src/agg/agg_span_pattern_gray.h b/xs/src/agg/agg_span_pattern_gray.h new file mode 100644 index 0000000000..ae1a49f879 --- /dev/null +++ b/xs/src/agg/agg_span_pattern_gray.h @@ -0,0 +1,93 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + + +#ifndef AGG_SPAN_PATTERN_GRAY_INCLUDED +#define AGG_SPAN_PATTERN_GRAY_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //=======================================================span_pattern_gray + template class span_pattern_gray + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + + //-------------------------------------------------------------------- + span_pattern_gray() {} + span_pattern_gray(source_type& src, + unsigned offset_x, unsigned offset_y) : + m_src(&src), + m_offset_x(offset_x), + m_offset_y(offset_y), + m_alpha(color_type::base_mask) + {} + + //-------------------------------------------------------------------- + void attach(source_type& v) { m_src = &v; } + source_type& source() { return *m_src; } + const source_type& source() const { return *m_src; } + + //-------------------------------------------------------------------- + void offset_x(unsigned v) { m_offset_x = v; } + void offset_y(unsigned v) { m_offset_y = v; } + unsigned offset_x() const { return m_offset_x; } + unsigned offset_y() const { return m_offset_y; } + void alpha(value_type v) { m_alpha = v; } + value_type alpha() const { return m_alpha; } + + //-------------------------------------------------------------------- + void prepare() {} + void generate(color_type* span, int x, int y, unsigned len) + { + x += m_offset_x; + y += m_offset_y; + const value_type* p = (const value_type*)m_src->span(x, y, len); + do + { + span->v = *p; + span->a = m_alpha; + p = m_src->next_x(); + ++span; + } + while(--len); + } + + private: + source_type* m_src; + unsigned m_offset_x; + unsigned m_offset_y; + value_type m_alpha; + + }; + +} + +#endif + diff --git a/xs/src/agg/agg_span_pattern_rgb.h b/xs/src/agg/agg_span_pattern_rgb.h new file mode 100644 index 0000000000..4850508af1 --- /dev/null +++ b/xs/src/agg/agg_span_pattern_rgb.h @@ -0,0 +1,96 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + + +#ifndef AGG_SPAN_PATTERN_RGB_INCLUDED +#define AGG_SPAN_PATTERN_RGB_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //========================================================span_pattern_rgb + template class span_pattern_rgb + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + + //-------------------------------------------------------------------- + span_pattern_rgb() {} + span_pattern_rgb(source_type& src, + unsigned offset_x, unsigned offset_y) : + m_src(&src), + m_offset_x(offset_x), + m_offset_y(offset_y), + m_alpha(color_type::base_mask) + {} + + //-------------------------------------------------------------------- + void attach(source_type& v) { m_src = &v; } + source_type& source() { return *m_src; } + const source_type& source() const { return *m_src; } + + //-------------------------------------------------------------------- + void offset_x(unsigned v) { m_offset_x = v; } + void offset_y(unsigned v) { m_offset_y = v; } + unsigned offset_x() const { return m_offset_x; } + unsigned offset_y() const { return m_offset_y; } + void alpha(value_type v) { m_alpha = v; } + value_type alpha() const { return m_alpha; } + + //-------------------------------------------------------------------- + void prepare() {} + void generate(color_type* span, int x, int y, unsigned len) + { + x += m_offset_x; + y += m_offset_y; + const value_type* p = (const value_type*)m_src->span(x, y, len); + do + { + span->r = p[order_type::R]; + span->g = p[order_type::G]; + span->b = p[order_type::B]; + span->a = m_alpha; + p = m_src->next_x(); + ++span; + } + while(--len); + } + + private: + source_type* m_src; + unsigned m_offset_x; + unsigned m_offset_y; + value_type m_alpha; + + }; + +} + +#endif + diff --git a/xs/src/agg/agg_span_pattern_rgba.h b/xs/src/agg/agg_span_pattern_rgba.h new file mode 100644 index 0000000000..d47d2a6c02 --- /dev/null +++ b/xs/src/agg/agg_span_pattern_rgba.h @@ -0,0 +1,94 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Adaptation for high precision colors has been sponsored by +// Liberty Technology Systems, Inc., visit http://lib-sys.com +// +// Liberty Technology Systems, Inc. is the provider of +// PostScript and PDF technology for software developers. +// +//---------------------------------------------------------------------------- + + +#ifndef AGG_SPAN_PATTERN_RGBA_INCLUDED +#define AGG_SPAN_PATTERN_RGBA_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //======================================================span_pattern_rgba + template class span_pattern_rgba + { + public: + typedef Source source_type; + typedef typename source_type::color_type color_type; + typedef typename source_type::order_type order_type; + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + + //-------------------------------------------------------------------- + span_pattern_rgba() {} + span_pattern_rgba(source_type& src, + unsigned offset_x, unsigned offset_y) : + m_src(&src), + m_offset_x(offset_x), + m_offset_y(offset_y) + {} + + //-------------------------------------------------------------------- + void attach(source_type& v) { m_src = &v; } + source_type& source() { return *m_src; } + const source_type& source() const { return *m_src; } + + //-------------------------------------------------------------------- + void offset_x(unsigned v) { m_offset_x = v; } + void offset_y(unsigned v) { m_offset_y = v; } + unsigned offset_x() const { return m_offset_x; } + unsigned offset_y() const { return m_offset_y; } + void alpha(value_type) {} + value_type alpha() const { return 0; } + + //-------------------------------------------------------------------- + void prepare() {} + void generate(color_type* span, int x, int y, unsigned len) + { + x += m_offset_x; + y += m_offset_y; + const value_type* p = (const value_type*)m_src->span(x, y, len); + do + { + span->r = p[order_type::R]; + span->g = p[order_type::G]; + span->b = p[order_type::B]; + span->a = p[order_type::A]; + p = (const value_type*)m_src->next_x(); + ++span; + } + while(--len); + } + + private: + source_type* m_src; + unsigned m_offset_x; + unsigned m_offset_y; + + }; + +} + +#endif + diff --git a/xs/src/agg/agg_span_solid.h b/xs/src/agg/agg_span_solid.h new file mode 100644 index 0000000000..ee46df9991 --- /dev/null +++ b/xs/src/agg/agg_span_solid.h @@ -0,0 +1,53 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// span_solid_rgba8 +// +//---------------------------------------------------------------------------- + +#ifndef AGG_SPAN_SOLID_INCLUDED +#define AGG_SPAN_SOLID_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + //--------------------------------------------------------------span_solid + template class span_solid + { + public: + typedef ColorT color_type; + + //-------------------------------------------------------------------- + void color(const color_type& c) { m_color = c; } + const color_type& color() const { return m_color; } + + //-------------------------------------------------------------------- + void prepare() {} + + //-------------------------------------------------------------------- + void generate(color_type* span, int x, int y, unsigned len) + { + do { *span++ = m_color; } while(--len); + } + + private: + color_type m_color; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_span_subdiv_adaptor.h b/xs/src/agg/agg_span_subdiv_adaptor.h new file mode 100644 index 0000000000..b5b855ec97 --- /dev/null +++ b/xs/src/agg/agg_span_subdiv_adaptor.h @@ -0,0 +1,141 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_SPAN_SUBDIV_ADAPTOR_INCLUDED +#define AGG_SPAN_SUBDIV_ADAPTOR_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //=================================================span_subdiv_adaptor + template + class span_subdiv_adaptor + { + public: + typedef Interpolator interpolator_type; + typedef typename interpolator_type::trans_type trans_type; + + enum sublixel_scale_e + { + subpixel_shift = SubpixelShift, + subpixel_scale = 1 << subpixel_shift + }; + + + //---------------------------------------------------------------- + span_subdiv_adaptor() : + m_subdiv_shift(4), + m_subdiv_size(1 << m_subdiv_shift), + m_subdiv_mask(m_subdiv_size - 1) {} + + span_subdiv_adaptor(interpolator_type& interpolator, + unsigned subdiv_shift = 4) : + m_subdiv_shift(subdiv_shift), + m_subdiv_size(1 << m_subdiv_shift), + m_subdiv_mask(m_subdiv_size - 1), + m_interpolator(&interpolator) {} + + span_subdiv_adaptor(interpolator_type& interpolator, + double x, double y, unsigned len, + unsigned subdiv_shift = 4) : + m_subdiv_shift(subdiv_shift), + m_subdiv_size(1 << m_subdiv_shift), + m_subdiv_mask(m_subdiv_size - 1), + m_interpolator(&interpolator) + { + begin(x, y, len); + } + + + //---------------------------------------------------------------- + const interpolator_type& interpolator() const { return *m_interpolator; } + void interpolator(interpolator_type& intr) { m_interpolator = &intr; } + + //---------------------------------------------------------------- + const trans_type& transformer() const + { + return *m_interpolator->transformer(); + } + void transformer(const trans_type& trans) + { + m_interpolator->transformer(trans); + } + + //---------------------------------------------------------------- + unsigned subdiv_shift() const { return m_subdiv_shift; } + void subdiv_shift(unsigned shift) + { + m_subdiv_shift = shift; + m_subdiv_size = 1 << m_subdiv_shift; + m_subdiv_mask = m_subdiv_size - 1; + } + + //---------------------------------------------------------------- + void begin(double x, double y, unsigned len) + { + m_pos = 1; + m_src_x = iround(x * subpixel_scale) + subpixel_scale; + m_src_y = y; + m_len = len; + if(len > m_subdiv_size) len = m_subdiv_size; + m_interpolator->begin(x, y, len); + } + + //---------------------------------------------------------------- + void operator++() + { + ++(*m_interpolator); + if(m_pos >= m_subdiv_size) + { + unsigned len = m_len; + if(len > m_subdiv_size) len = m_subdiv_size; + m_interpolator->resynchronize(double(m_src_x) / double(subpixel_scale) + len, + m_src_y, + len); + m_pos = 0; + } + m_src_x += subpixel_scale; + ++m_pos; + --m_len; + } + + //---------------------------------------------------------------- + void coordinates(int* x, int* y) const + { + m_interpolator->coordinates(x, y); + } + + //---------------------------------------------------------------- + void local_scale(int* x, int* y) const + { + m_interpolator->local_scale(x, y); + } + + + private: + unsigned m_subdiv_shift; + unsigned m_subdiv_size; + unsigned m_subdiv_mask; + interpolator_type* m_interpolator; + int m_src_x; + double m_src_y; + unsigned m_pos; + unsigned m_len; + }; + +} + +#endif diff --git a/xs/src/agg/agg_trans_affine.h b/xs/src/agg/agg_trans_affine.h new file mode 100644 index 0000000000..1a61163883 --- /dev/null +++ b/xs/src/agg/agg_trans_affine.h @@ -0,0 +1,518 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Affine transformation classes. +// +//---------------------------------------------------------------------------- +#ifndef AGG_TRANS_AFFINE_INCLUDED +#define AGG_TRANS_AFFINE_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + const double affine_epsilon = 1e-14; + + //============================================================trans_affine + // + // See Implementation agg_trans_affine.cpp + // + // Affine transformation are linear transformations in Cartesian coordinates + // (strictly speaking not only in Cartesian, but for the beginning we will + // think so). They are rotation, scaling, translation and skewing. + // After any affine transformation a line segment remains a line segment + // and it will never become a curve. + // + // There will be no math about matrix calculations, since it has been + // described many times. Ask yourself a very simple question: + // "why do we need to understand and use some matrix stuff instead of just + // rotating, scaling and so on". The answers are: + // + // 1. Any combination of transformations can be done by only 4 multiplications + // and 4 additions in floating point. + // 2. One matrix transformation is equivalent to the number of consecutive + // discrete transformations, i.e. the matrix "accumulates" all transformations + // in the order of their settings. Suppose we have 4 transformations: + // * rotate by 30 degrees, + // * scale X to 2.0, + // * scale Y to 1.5, + // * move to (100, 100). + // The result will depend on the order of these transformations, + // and the advantage of matrix is that the sequence of discret calls: + // rotate(30), scaleX(2.0), scaleY(1.5), move(100,100) + // will have exactly the same result as the following matrix transformations: + // + // affine_matrix m; + // m *= rotate_matrix(30); + // m *= scaleX_matrix(2.0); + // m *= scaleY_matrix(1.5); + // m *= move_matrix(100,100); + // + // m.transform_my_point_at_last(x, y); + // + // What is the good of it? In real life we will set-up the matrix only once + // and then transform many points, let alone the convenience to set any + // combination of transformations. + // + // So, how to use it? Very easy - literally as it's shown above. Not quite, + // let us write a correct example: + // + // agg::trans_affine m; + // m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0); + // m *= agg::trans_affine_scaling(2.0, 1.5); + // m *= agg::trans_affine_translation(100.0, 100.0); + // m.transform(&x, &y); + // + // The affine matrix is all you need to perform any linear transformation, + // but all transformations have origin point (0,0). It means that we need to + // use 2 translations if we want to rotate someting around (100,100): + // + // m *= agg::trans_affine_translation(-100.0, -100.0); // move to (0,0) + // m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0); // rotate + // m *= agg::trans_affine_translation(100.0, 100.0); // move back to (100,100) + //---------------------------------------------------------------------- + struct trans_affine + { + double sx, shy, shx, sy, tx, ty; + + //------------------------------------------ Construction + // Identity matrix + trans_affine() : + sx(1.0), shy(0.0), shx(0.0), sy(1.0), tx(0.0), ty(0.0) + {} + + // Custom matrix. Usually used in derived classes + trans_affine(double v0, double v1, double v2, + double v3, double v4, double v5) : + sx(v0), shy(v1), shx(v2), sy(v3), tx(v4), ty(v5) + {} + + // Custom matrix from m[6] + explicit trans_affine(const double* m) : + sx(m[0]), shy(m[1]), shx(m[2]), sy(m[3]), tx(m[4]), ty(m[5]) + {} + + // Rectangle to a parallelogram. + trans_affine(double x1, double y1, double x2, double y2, + const double* parl) + { + rect_to_parl(x1, y1, x2, y2, parl); + } + + // Parallelogram to a rectangle. + trans_affine(const double* parl, + double x1, double y1, double x2, double y2) + { + parl_to_rect(parl, x1, y1, x2, y2); + } + + // Arbitrary parallelogram transformation. + trans_affine(const double* src, const double* dst) + { + parl_to_parl(src, dst); + } + + //---------------------------------- Parellelogram transformations + // transform a parallelogram to another one. Src and dst are + // pointers to arrays of three points (double[6], x1,y1,...) that + // identify three corners of the parallelograms assuming implicit + // fourth point. The arguments are arrays of double[6] mapped + // to x1,y1, x2,y2, x3,y3 where the coordinates are: + // *-----------------* + // / (x3,y3)/ + // / / + // /(x1,y1) (x2,y2)/ + // *-----------------* + const trans_affine& parl_to_parl(const double* src, + const double* dst); + + const trans_affine& rect_to_parl(double x1, double y1, + double x2, double y2, + const double* parl); + + const trans_affine& parl_to_rect(const double* parl, + double x1, double y1, + double x2, double y2); + + + //------------------------------------------ Operations + // Reset - load an identity matrix + const trans_affine& reset(); + + // Direct transformations operations + const trans_affine& translate(double x, double y); + const trans_affine& rotate(double a); + const trans_affine& scale(double s); + const trans_affine& scale(double x, double y); + + // Multiply matrix to another one + const trans_affine& multiply(const trans_affine& m); + + // Multiply "m" to "this" and assign the result to "this" + const trans_affine& premultiply(const trans_affine& m); + + // Multiply matrix to inverse of another one + const trans_affine& multiply_inv(const trans_affine& m); + + // Multiply inverse of "m" to "this" and assign the result to "this" + const trans_affine& premultiply_inv(const trans_affine& m); + + // Invert matrix. Do not try to invert degenerate matrices, + // there's no check for validity. If you set scale to 0 and + // then try to invert matrix, expect unpredictable result. + const trans_affine& invert(); + + // Mirroring around X + const trans_affine& flip_x(); + + // Mirroring around Y + const trans_affine& flip_y(); + + //------------------------------------------- Load/Store + // Store matrix to an array [6] of double + void store_to(double* m) const + { + *m++ = sx; *m++ = shy; *m++ = shx; *m++ = sy; *m++ = tx; *m++ = ty; + } + + // Load matrix from an array [6] of double + const trans_affine& load_from(const double* m) + { + sx = *m++; shy = *m++; shx = *m++; sy = *m++; tx = *m++; ty = *m++; + return *this; + } + + //------------------------------------------- Operators + + // Multiply the matrix by another one + const trans_affine& operator *= (const trans_affine& m) + { + return multiply(m); + } + + // Multiply the matrix by inverse of another one + const trans_affine& operator /= (const trans_affine& m) + { + return multiply_inv(m); + } + + // Multiply the matrix by another one and return + // the result in a separete matrix. + trans_affine operator * (const trans_affine& m) const + { + return trans_affine(*this).multiply(m); + } + + // Multiply the matrix by inverse of another one + // and return the result in a separete matrix. + trans_affine operator / (const trans_affine& m) const + { + return trans_affine(*this).multiply_inv(m); + } + + // Calculate and return the inverse matrix + trans_affine operator ~ () const + { + trans_affine ret = *this; + return ret.invert(); + } + + // Equal operator with default epsilon + bool operator == (const trans_affine& m) const + { + return is_equal(m, affine_epsilon); + } + + // Not Equal operator with default epsilon + bool operator != (const trans_affine& m) const + { + return !is_equal(m, affine_epsilon); + } + + //-------------------------------------------- Transformations + // Direct transformation of x and y + void transform(double* x, double* y) const; + + // Direct transformation of x and y, 2x2 matrix only, no translation + void transform_2x2(double* x, double* y) const; + + // Inverse transformation of x and y. It works slower than the + // direct transformation. For massive operations it's better to + // invert() the matrix and then use direct transformations. + void inverse_transform(double* x, double* y) const; + + //-------------------------------------------- Auxiliary + // Calculate the determinant of matrix + double determinant() const + { + return sx * sy - shy * shx; + } + + // Calculate the reciprocal of the determinant + double determinant_reciprocal() const + { + return 1.0 / (sx * sy - shy * shx); + } + + // Get the average scale (by X and Y). + // Basically used to calculate the approximation_scale when + // decomposinting curves into line segments. + double scale() const; + + // Check to see if the matrix is not degenerate + bool is_valid(double epsilon = affine_epsilon) const; + + // Check to see if it's an identity matrix + bool is_identity(double epsilon = affine_epsilon) const; + + // Check to see if two matrices are equal + bool is_equal(const trans_affine& m, double epsilon = affine_epsilon) const; + + // Determine the major parameters. Use with caution considering + // possible degenerate cases. + double rotation() const; + void translation(double* dx, double* dy) const; + void scaling(double* x, double* y) const; + void scaling_abs(double* x, double* y) const; + }; + + //------------------------------------------------------------------------ + inline void trans_affine::transform(double* x, double* y) const + { + double tmp = *x; + *x = tmp * sx + *y * shx + tx; + *y = tmp * shy + *y * sy + ty; + } + + //------------------------------------------------------------------------ + inline void trans_affine::transform_2x2(double* x, double* y) const + { + double tmp = *x; + *x = tmp * sx + *y * shx; + *y = tmp * shy + *y * sy; + } + + //------------------------------------------------------------------------ + inline void trans_affine::inverse_transform(double* x, double* y) const + { + double d = determinant_reciprocal(); + double a = (*x - tx) * d; + double b = (*y - ty) * d; + *x = a * sy - b * shx; + *y = b * sx - a * shy; + } + + //------------------------------------------------------------------------ + inline double trans_affine::scale() const + { + double x = 0.707106781 * sx + 0.707106781 * shx; + double y = 0.707106781 * shy + 0.707106781 * sy; + return sqrt(x*x + y*y); + } + + //------------------------------------------------------------------------ + inline const trans_affine& trans_affine::translate(double x, double y) + { + tx += x; + ty += y; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_affine& trans_affine::rotate(double a) + { + double ca = cos(a); + double sa = sin(a); + double t0 = sx * ca - shy * sa; + double t2 = shx * ca - sy * sa; + double t4 = tx * ca - ty * sa; + shy = sx * sa + shy * ca; + sy = shx * sa + sy * ca; + ty = tx * sa + ty * ca; + sx = t0; + shx = t2; + tx = t4; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_affine& trans_affine::scale(double x, double y) + { + double mm0 = x; // Possible hint for the optimizer + double mm3 = y; + sx *= mm0; + shx *= mm0; + tx *= mm0; + shy *= mm3; + sy *= mm3; + ty *= mm3; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_affine& trans_affine::scale(double s) + { + double m = s; // Possible hint for the optimizer + sx *= m; + shx *= m; + tx *= m; + shy *= m; + sy *= m; + ty *= m; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_affine& trans_affine::premultiply(const trans_affine& m) + { + trans_affine t = m; + return *this = t.multiply(*this); + } + + //------------------------------------------------------------------------ + inline const trans_affine& trans_affine::multiply_inv(const trans_affine& m) + { + trans_affine t = m; + t.invert(); + return multiply(t); + } + + //------------------------------------------------------------------------ + inline const trans_affine& trans_affine::premultiply_inv(const trans_affine& m) + { + trans_affine t = m; + t.invert(); + return *this = t.multiply(*this); + } + + //------------------------------------------------------------------------ + inline void trans_affine::scaling_abs(double* x, double* y) const + { + // Used to calculate scaling coefficients in image resampling. + // When there is considerable shear this method gives us much + // better estimation than just sx, sy. + *x = sqrt(sx * sx + shx * shx); + *y = sqrt(shy * shy + sy * sy); + } + + //====================================================trans_affine_rotation + // Rotation matrix. sin() and cos() are calculated twice for the same angle. + // There's no harm because the performance of sin()/cos() is very good on all + // modern processors. Besides, this operation is not going to be invoked too + // often. + class trans_affine_rotation : public trans_affine + { + public: + trans_affine_rotation(double a) : + trans_affine(cos(a), sin(a), -sin(a), cos(a), 0.0, 0.0) + {} + }; + + //====================================================trans_affine_scaling + // Scaling matrix. x, y - scale coefficients by X and Y respectively + class trans_affine_scaling : public trans_affine + { + public: + trans_affine_scaling(double x, double y) : + trans_affine(x, 0.0, 0.0, y, 0.0, 0.0) + {} + + trans_affine_scaling(double s) : + trans_affine(s, 0.0, 0.0, s, 0.0, 0.0) + {} + }; + + //================================================trans_affine_translation + // Translation matrix + class trans_affine_translation : public trans_affine + { + public: + trans_affine_translation(double x, double y) : + trans_affine(1.0, 0.0, 0.0, 1.0, x, y) + {} + }; + + //====================================================trans_affine_skewing + // Sckewing (shear) matrix + class trans_affine_skewing : public trans_affine + { + public: + trans_affine_skewing(double x, double y) : + trans_affine(1.0, tan(y), tan(x), 1.0, 0.0, 0.0) + {} + }; + + + //===============================================trans_affine_line_segment + // Rotate, Scale and Translate, associating 0...dist with line segment + // x1,y1,x2,y2 + class trans_affine_line_segment : public trans_affine + { + public: + trans_affine_line_segment(double x1, double y1, double x2, double y2, + double dist) + { + double dx = x2 - x1; + double dy = y2 - y1; + if(dist > 0.0) + { + multiply(trans_affine_scaling(sqrt(dx * dx + dy * dy) / dist)); + } + multiply(trans_affine_rotation(atan2(dy, dx))); + multiply(trans_affine_translation(x1, y1)); + } + }; + + + //============================================trans_affine_reflection_unit + // Reflection matrix. Reflect coordinates across the line through + // the origin containing the unit vector (ux, uy). + // Contributed by John Horigan + class trans_affine_reflection_unit : public trans_affine + { + public: + trans_affine_reflection_unit(double ux, double uy) : + trans_affine(2.0 * ux * ux - 1.0, + 2.0 * ux * uy, + 2.0 * ux * uy, + 2.0 * uy * uy - 1.0, + 0.0, 0.0) + {} + }; + + + //=================================================trans_affine_reflection + // Reflection matrix. Reflect coordinates across the line through + // the origin at the angle a or containing the non-unit vector (x, y). + // Contributed by John Horigan + class trans_affine_reflection : public trans_affine_reflection_unit + { + public: + trans_affine_reflection(double a) : + trans_affine_reflection_unit(cos(a), sin(a)) + {} + + + trans_affine_reflection(double x, double y) : + trans_affine_reflection_unit(x / sqrt(x * x + y * y), y / sqrt(x * x + y * y)) + {} + }; + +} + + +#endif + diff --git a/xs/src/agg/agg_trans_bilinear.h b/xs/src/agg/agg_trans_bilinear.h new file mode 100644 index 0000000000..f3ab596472 --- /dev/null +++ b/xs/src/agg/agg_trans_bilinear.h @@ -0,0 +1,166 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Bilinear 2D transformations +// +//---------------------------------------------------------------------------- +#ifndef AGG_TRANS_BILINEAR_INCLUDED +#define AGG_TRANS_BILINEAR_INCLUDED + +#include "agg_basics.h" +#include "agg_simul_eq.h" + +namespace agg +{ + + //==========================================================trans_bilinear + class trans_bilinear + { + public: + //-------------------------------------------------------------------- + trans_bilinear() : m_valid(false) {} + + //-------------------------------------------------------------------- + // Arbitrary quadrangle transformations + trans_bilinear(const double* src, const double* dst) + { + quad_to_quad(src, dst); + } + + + //-------------------------------------------------------------------- + // Direct transformations + trans_bilinear(double x1, double y1, double x2, double y2, + const double* quad) + { + rect_to_quad(x1, y1, x2, y2, quad); + } + + + //-------------------------------------------------------------------- + // Reverse transformations + trans_bilinear(const double* quad, + double x1, double y1, double x2, double y2) + { + quad_to_rect(quad, x1, y1, x2, y2); + } + + + //-------------------------------------------------------------------- + // Set the transformations using two arbitrary quadrangles. + void quad_to_quad(const double* src, const double* dst) + { + double left[4][4]; + double right[4][2]; + + unsigned i; + for(i = 0; i < 4; i++) + { + unsigned ix = i * 2; + unsigned iy = ix + 1; + left[i][0] = 1.0; + left[i][1] = src[ix] * src[iy]; + left[i][2] = src[ix]; + left[i][3] = src[iy]; + + right[i][0] = dst[ix]; + right[i][1] = dst[iy]; + } + m_valid = simul_eq<4, 2>::solve(left, right, m_mtx); + } + + + //-------------------------------------------------------------------- + // Set the direct transformations, i.e., rectangle -> quadrangle + void rect_to_quad(double x1, double y1, double x2, double y2, + const double* quad) + { + double src[8]; + src[0] = src[6] = x1; + src[2] = src[4] = x2; + src[1] = src[3] = y1; + src[5] = src[7] = y2; + quad_to_quad(src, quad); + } + + + //-------------------------------------------------------------------- + // Set the reverse transformations, i.e., quadrangle -> rectangle + void quad_to_rect(const double* quad, + double x1, double y1, double x2, double y2) + { + double dst[8]; + dst[0] = dst[6] = x1; + dst[2] = dst[4] = x2; + dst[1] = dst[3] = y1; + dst[5] = dst[7] = y2; + quad_to_quad(quad, dst); + } + + //-------------------------------------------------------------------- + // Check if the equations were solved successfully + bool is_valid() const { return m_valid; } + + //-------------------------------------------------------------------- + // Transform a point (x, y) + void transform(double* x, double* y) const + { + double tx = *x; + double ty = *y; + double xy = tx * ty; + *x = m_mtx[0][0] + m_mtx[1][0] * xy + m_mtx[2][0] * tx + m_mtx[3][0] * ty; + *y = m_mtx[0][1] + m_mtx[1][1] * xy + m_mtx[2][1] * tx + m_mtx[3][1] * ty; + } + + + //-------------------------------------------------------------------- + class iterator_x + { + double inc_x; + double inc_y; + + public: + double x; + double y; + + iterator_x() {} + iterator_x(double tx, double ty, double step, const double m[4][2]) : + inc_x(m[1][0] * step * ty + m[2][0] * step), + inc_y(m[1][1] * step * ty + m[2][1] * step), + x(m[0][0] + m[1][0] * tx * ty + m[2][0] * tx + m[3][0] * ty), + y(m[0][1] + m[1][1] * tx * ty + m[2][1] * tx + m[3][1] * ty) + { + } + + void operator ++ () + { + x += inc_x; + y += inc_y; + } + }; + + iterator_x begin(double x, double y, double step) const + { + return iterator_x(x, y, step, m_mtx); + } + + private: + double m_mtx[4][2]; + bool m_valid; + }; + +} + +#endif diff --git a/xs/src/agg/agg_trans_double_path.h b/xs/src/agg/agg_trans_double_path.h new file mode 100644 index 0000000000..c645a7f869 --- /dev/null +++ b/xs/src/agg/agg_trans_double_path.h @@ -0,0 +1,131 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_TRANS_DOUBLE_PATH_INCLUDED +#define AGG_TRANS_DOUBLE_PATH_INCLUDED + +#include "agg_basics.h" +#include "agg_vertex_sequence.h" + +namespace agg +{ + + // See also: agg_trans_double_path.cpp + // + //-------------------------------------------------------trans_double_path + class trans_double_path + { + enum status_e + { + initial, + making_path, + ready + }; + + public: + typedef vertex_sequence vertex_storage; + + trans_double_path(); + + //-------------------------------------------------------------------- + void base_length(double v) { m_base_length = v; } + double base_length() const { return m_base_length; } + + //-------------------------------------------------------------------- + void base_height(double v) { m_base_height = v; } + double base_height() const { return m_base_height; } + + //-------------------------------------------------------------------- + void preserve_x_scale(bool f) { m_preserve_x_scale = f; } + bool preserve_x_scale() const { return m_preserve_x_scale; } + + //-------------------------------------------------------------------- + void reset(); + void move_to1(double x, double y); + void line_to1(double x, double y); + void move_to2(double x, double y); + void line_to2(double x, double y); + void finalize_paths(); + + //-------------------------------------------------------------------- + template + void add_paths(VertexSource1& vs1, VertexSource2& vs2, + unsigned path1_id=0, unsigned path2_id=0) + { + double x; + double y; + + unsigned cmd; + + vs1.rewind(path1_id); + while(!is_stop(cmd = vs1.vertex(&x, &y))) + { + if(is_move_to(cmd)) + { + move_to1(x, y); + } + else + { + if(is_vertex(cmd)) + { + line_to1(x, y); + } + } + } + + vs2.rewind(path2_id); + while(!is_stop(cmd = vs2.vertex(&x, &y))) + { + if(is_move_to(cmd)) + { + move_to2(x, y); + } + else + { + if(is_vertex(cmd)) + { + line_to2(x, y); + } + } + } + finalize_paths(); + } + + //-------------------------------------------------------------------- + double total_length1() const; + double total_length2() const; + void transform(double *x, double *y) const; + + private: + double finalize_path(vertex_storage& vertices); + void transform1(const vertex_storage& vertices, + double kindex, double kx, + double *x, double* y) const; + + vertex_storage m_src_vertices1; + vertex_storage m_src_vertices2; + double m_base_length; + double m_base_height; + double m_kindex1; + double m_kindex2; + status_e m_status1; + status_e m_status2; + bool m_preserve_x_scale; + }; + +} + + +#endif diff --git a/xs/src/agg/agg_trans_perspective.h b/xs/src/agg/agg_trans_perspective.h new file mode 100644 index 0000000000..7d4aa26c79 --- /dev/null +++ b/xs/src/agg/agg_trans_perspective.h @@ -0,0 +1,731 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Perspective 2D transformations +// +//---------------------------------------------------------------------------- +#ifndef AGG_TRANS_PERSPECTIVE_INCLUDED +#define AGG_TRANS_PERSPECTIVE_INCLUDED + +#include "agg_trans_affine.h" + +namespace agg +{ + //=======================================================trans_perspective + struct trans_perspective + { + double sx, shy, w0, shx, sy, w1, tx, ty, w2; + + //------------------------------------------------------- Construction + // Identity matrix + trans_perspective() : + sx (1), shy(0), w0(0), + shx(0), sy (1), w1(0), + tx (0), ty (0), w2(1) {} + + // Custom matrix + trans_perspective(double v0, double v1, double v2, + double v3, double v4, double v5, + double v6, double v7, double v8) : + sx (v0), shy(v1), w0(v2), + shx(v3), sy (v4), w1(v5), + tx (v6), ty (v7), w2(v8) {} + + // Custom matrix from m[9] + explicit trans_perspective(const double* m) : + sx (m[0]), shy(m[1]), w0(m[2]), + shx(m[3]), sy (m[4]), w1(m[5]), + tx (m[6]), ty (m[7]), w2(m[8]) {} + + // From affine + explicit trans_perspective(const trans_affine& a) : + sx (a.sx ), shy(a.shy), w0(0), + shx(a.shx), sy (a.sy ), w1(0), + tx (a.tx ), ty (a.ty ), w2(1) {} + + // Rectangle to quadrilateral + trans_perspective(double x1, double y1, double x2, double y2, + const double* quad); + + // Quadrilateral to rectangle + trans_perspective(const double* quad, + double x1, double y1, double x2, double y2); + + // Arbitrary quadrilateral transformations + trans_perspective(const double* src, const double* dst); + + //-------------------------------------- Quadrilateral transformations + // The arguments are double[8] that are mapped to quadrilaterals: + // x1,y1, x2,y2, x3,y3, x4,y4 + bool quad_to_quad(const double* qs, const double* qd); + + bool rect_to_quad(double x1, double y1, + double x2, double y2, + const double* q); + + bool quad_to_rect(const double* q, + double x1, double y1, + double x2, double y2); + + // Map square (0,0,1,1) to the quadrilateral and vice versa + bool square_to_quad(const double* q); + bool quad_to_square(const double* q); + + + //--------------------------------------------------------- Operations + // Reset - load an identity matrix + const trans_perspective& reset(); + + // Invert matrix. Returns false in degenerate case + bool invert(); + + // Direct transformations operations + const trans_perspective& translate(double x, double y); + const trans_perspective& rotate(double a); + const trans_perspective& scale(double s); + const trans_perspective& scale(double x, double y); + + // Multiply the matrix by another one + const trans_perspective& multiply(const trans_perspective& m); + + // Multiply "m" by "this" and assign the result to "this" + const trans_perspective& premultiply(const trans_perspective& m); + + // Multiply matrix to inverse of another one + const trans_perspective& multiply_inv(const trans_perspective& m); + + // Multiply inverse of "m" by "this" and assign the result to "this" + const trans_perspective& premultiply_inv(const trans_perspective& m); + + // Multiply the matrix by another one + const trans_perspective& multiply(const trans_affine& m); + + // Multiply "m" by "this" and assign the result to "this" + const trans_perspective& premultiply(const trans_affine& m); + + // Multiply the matrix by inverse of another one + const trans_perspective& multiply_inv(const trans_affine& m); + + // Multiply inverse of "m" by "this" and assign the result to "this" + const trans_perspective& premultiply_inv(const trans_affine& m); + + //--------------------------------------------------------- Load/Store + void store_to(double* m) const; + const trans_perspective& load_from(const double* m); + + //---------------------------------------------------------- Operators + // Multiply the matrix by another one + const trans_perspective& operator *= (const trans_perspective& m) + { + return multiply(m); + } + const trans_perspective& operator *= (const trans_affine& m) + { + return multiply(m); + } + + // Multiply the matrix by inverse of another one + const trans_perspective& operator /= (const trans_perspective& m) + { + return multiply_inv(m); + } + const trans_perspective& operator /= (const trans_affine& m) + { + return multiply_inv(m); + } + + // Multiply the matrix by another one and return + // the result in a separete matrix. + trans_perspective operator * (const trans_perspective& m) const + { + return trans_perspective(*this).multiply(m); + } + trans_perspective operator * (const trans_affine& m) const + { + return trans_perspective(*this).multiply(m); + } + + // Multiply the matrix by inverse of another one + // and return the result in a separete matrix. + trans_perspective operator / (const trans_perspective& m) const + { + return trans_perspective(*this).multiply_inv(m); + } + trans_perspective operator / (const trans_affine& m) const + { + return trans_perspective(*this).multiply_inv(m); + } + + // Calculate and return the inverse matrix + trans_perspective operator ~ () const + { + trans_perspective ret = *this; + ret.invert(); + return ret; + } + + // Equal operator with default epsilon + bool operator == (const trans_perspective& m) const + { + return is_equal(m, affine_epsilon); + } + + // Not Equal operator with default epsilon + bool operator != (const trans_perspective& m) const + { + return !is_equal(m, affine_epsilon); + } + + //---------------------------------------------------- Transformations + // Direct transformation of x and y + void transform(double* x, double* y) const; + + // Direct transformation of x and y, affine part only + void transform_affine(double* x, double* y) const; + + // Direct transformation of x and y, 2x2 matrix only, no translation + void transform_2x2(double* x, double* y) const; + + // Inverse transformation of x and y. It works slow because + // it explicitly inverts the matrix on every call. For massive + // operations it's better to invert() the matrix and then use + // direct transformations. + void inverse_transform(double* x, double* y) const; + + + //---------------------------------------------------------- Auxiliary + const trans_perspective& from_affine(const trans_affine& a); + double determinant() const; + double determinant_reciprocal() const; + + bool is_valid(double epsilon = affine_epsilon) const; + bool is_identity(double epsilon = affine_epsilon) const; + bool is_equal(const trans_perspective& m, + double epsilon = affine_epsilon) const; + + // Determine the major affine parameters. Use with caution + // considering possible degenerate cases. + double scale() const; + double rotation() const; + void translation(double* dx, double* dy) const; + void scaling(double* x, double* y) const; + void scaling_abs(double* x, double* y) const; + + + + //-------------------------------------------------------------------- + class iterator_x + { + double den; + double den_step; + double nom_x; + double nom_x_step; + double nom_y; + double nom_y_step; + + public: + double x; + double y; + + iterator_x() {} + iterator_x(double px, double py, double step, const trans_perspective& m) : + den(px * m.w0 + py * m.w1 + m.w2), + den_step(m.w0 * step), + nom_x(px * m.sx + py * m.shx + m.tx), + nom_x_step(step * m.sx), + nom_y(px * m.shy + py * m.sy + m.ty), + nom_y_step(step * m.shy), + x(nom_x / den), + y(nom_y / den) + {} + + void operator ++ () + { + den += den_step; + nom_x += nom_x_step; + nom_y += nom_y_step; + double d = 1.0 / den; + x = nom_x * d; + y = nom_y * d; + } + }; + + //-------------------------------------------------------------------- + iterator_x begin(double x, double y, double step) const + { + return iterator_x(x, y, step, *this); + } + }; + + + + + + + + + + + + + + + //------------------------------------------------------------------------ + inline bool trans_perspective::square_to_quad(const double* q) + { + double dx = q[0] - q[2] + q[4] - q[6]; + double dy = q[1] - q[3] + q[5] - q[7]; + if(dx == 0.0 && dy == 0.0) + { + // Affine case (parallelogram) + //--------------- + sx = q[2] - q[0]; + shy = q[3] - q[1]; + w0 = 0.0; + shx = q[4] - q[2]; + sy = q[5] - q[3]; + w1 = 0.0; + tx = q[0]; + ty = q[1]; + w2 = 1.0; + } + else + { + double dx1 = q[2] - q[4]; + double dy1 = q[3] - q[5]; + double dx2 = q[6] - q[4]; + double dy2 = q[7] - q[5]; + double den = dx1 * dy2 - dx2 * dy1; + if(den == 0.0) + { + // Singular case + //--------------- + sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0; + return false; + } + // General case + //--------------- + double u = (dx * dy2 - dy * dx2) / den; + double v = (dy * dx1 - dx * dy1) / den; + sx = q[2] - q[0] + u * q[2]; + shy = q[3] - q[1] + u * q[3]; + w0 = u; + shx = q[6] - q[0] + v * q[6]; + sy = q[7] - q[1] + v * q[7]; + w1 = v; + tx = q[0]; + ty = q[1]; + w2 = 1.0; + } + return true; + } + + //------------------------------------------------------------------------ + inline bool trans_perspective::invert() + { + double d0 = sy * w2 - w1 * ty; + double d1 = w0 * ty - shy * w2; + double d2 = shy * w1 - w0 * sy; + double d = sx * d0 + shx * d1 + tx * d2; + if(d == 0.0) + { + sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0; + return false; + } + d = 1.0 / d; + trans_perspective a = *this; + sx = d * d0; + shy = d * d1; + w0 = d * d2; + shx = d * (a.w1 *a.tx - a.shx*a.w2); + sy = d * (a.sx *a.w2 - a.w0 *a.tx); + w1 = d * (a.w0 *a.shx - a.sx *a.w1); + tx = d * (a.shx*a.ty - a.sy *a.tx); + ty = d * (a.shy*a.tx - a.sx *a.ty); + w2 = d * (a.sx *a.sy - a.shy*a.shx); + return true; + } + + //------------------------------------------------------------------------ + inline bool trans_perspective::quad_to_square(const double* q) + { + if(!square_to_quad(q)) return false; + invert(); + return true; + } + + //------------------------------------------------------------------------ + inline bool trans_perspective::quad_to_quad(const double* qs, + const double* qd) + { + trans_perspective p; + if(! quad_to_square(qs)) return false; + if(!p.square_to_quad(qd)) return false; + multiply(p); + return true; + } + + //------------------------------------------------------------------------ + inline bool trans_perspective::rect_to_quad(double x1, double y1, + double x2, double y2, + const double* q) + { + double r[8]; + r[0] = r[6] = x1; + r[2] = r[4] = x2; + r[1] = r[3] = y1; + r[5] = r[7] = y2; + return quad_to_quad(r, q); + } + + //------------------------------------------------------------------------ + inline bool trans_perspective::quad_to_rect(const double* q, + double x1, double y1, + double x2, double y2) + { + double r[8]; + r[0] = r[6] = x1; + r[2] = r[4] = x2; + r[1] = r[3] = y1; + r[5] = r[7] = y2; + return quad_to_quad(q, r); + } + + //------------------------------------------------------------------------ + inline trans_perspective::trans_perspective(double x1, double y1, + double x2, double y2, + const double* quad) + { + rect_to_quad(x1, y1, x2, y2, quad); + } + + //------------------------------------------------------------------------ + inline trans_perspective::trans_perspective(const double* quad, + double x1, double y1, + double x2, double y2) + { + quad_to_rect(quad, x1, y1, x2, y2); + } + + //------------------------------------------------------------------------ + inline trans_perspective::trans_perspective(const double* src, + const double* dst) + { + quad_to_quad(src, dst); + } + + //------------------------------------------------------------------------ + inline const trans_perspective& trans_perspective::reset() + { + sx = 1; shy = 0; w0 = 0; + shx = 0; sy = 1; w1 = 0; + tx = 0; ty = 0; w2 = 1; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& + trans_perspective::multiply(const trans_perspective& a) + { + trans_perspective b = *this; + sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0; + shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1; + tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2; + shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0; + sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1; + ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2; + w0 = a.w0 *b.sx + a.w1 *b.shy + a.w2*b.w0; + w1 = a.w0 *b.shx + a.w1 *b.sy + a.w2*b.w1; + w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2*b.w2; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& + trans_perspective::multiply(const trans_affine& a) + { + trans_perspective b = *this; + sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0; + shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1; + tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2; + shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0; + sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1; + ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& + trans_perspective::premultiply(const trans_perspective& b) + { + trans_perspective a = *this; + sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0; + shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1; + tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2; + shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0; + sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1; + ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2; + w0 = a.w0 *b.sx + a.w1 *b.shy + a.w2*b.w0; + w1 = a.w0 *b.shx + a.w1 *b.sy + a.w2*b.w1; + w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2*b.w2; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& + trans_perspective::premultiply(const trans_affine& b) + { + trans_perspective a = *this; + sx = a.sx *b.sx + a.shx*b.shy; + shx = a.sx *b.shx + a.shx*b.sy; + tx = a.sx *b.tx + a.shx*b.ty + a.tx; + shy = a.shy*b.sx + a.sy *b.shy; + sy = a.shy*b.shx + a.sy *b.sy; + ty = a.shy*b.tx + a.sy *b.ty + a.ty; + w0 = a.w0 *b.sx + a.w1 *b.shy; + w1 = a.w0 *b.shx + a.w1 *b.sy; + w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2; + return *this; + } + + //------------------------------------------------------------------------ + const trans_perspective& + trans_perspective::multiply_inv(const trans_perspective& m) + { + trans_perspective t = m; + t.invert(); + return multiply(t); + } + + //------------------------------------------------------------------------ + const trans_perspective& + trans_perspective::multiply_inv(const trans_affine& m) + { + trans_affine t = m; + t.invert(); + return multiply(t); + } + + //------------------------------------------------------------------------ + const trans_perspective& + trans_perspective::premultiply_inv(const trans_perspective& m) + { + trans_perspective t = m; + t.invert(); + return *this = t.multiply(*this); + } + + //------------------------------------------------------------------------ + const trans_perspective& + trans_perspective::premultiply_inv(const trans_affine& m) + { + trans_perspective t(m); + t.invert(); + return *this = t.multiply(*this); + } + + //------------------------------------------------------------------------ + inline const trans_perspective& + trans_perspective::translate(double x, double y) + { + tx += x; + ty += y; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& trans_perspective::rotate(double a) + { + multiply(trans_affine_rotation(a)); + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& trans_perspective::scale(double s) + { + multiply(trans_affine_scaling(s)); + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& trans_perspective::scale(double x, double y) + { + multiply(trans_affine_scaling(x, y)); + return *this; + } + + //------------------------------------------------------------------------ + inline void trans_perspective::transform(double* px, double* py) const + { + double x = *px; + double y = *py; + double m = 1.0 / (x*w0 + y*w1 + w2); + *px = m * (x*sx + y*shx + tx); + *py = m * (x*shy + y*sy + ty); + } + + //------------------------------------------------------------------------ + inline void trans_perspective::transform_affine(double* x, double* y) const + { + double tmp = *x; + *x = tmp * sx + *y * shx + tx; + *y = tmp * shy + *y * sy + ty; + } + + //------------------------------------------------------------------------ + inline void trans_perspective::transform_2x2(double* x, double* y) const + { + double tmp = *x; + *x = tmp * sx + *y * shx; + *y = tmp * shy + *y * sy; + } + + //------------------------------------------------------------------------ + inline void trans_perspective::inverse_transform(double* x, double* y) const + { + trans_perspective t(*this); + if(t.invert()) t.transform(x, y); + } + + //------------------------------------------------------------------------ + inline void trans_perspective::store_to(double* m) const + { + *m++ = sx; *m++ = shy; *m++ = w0; + *m++ = shx; *m++ = sy; *m++ = w1; + *m++ = tx; *m++ = ty; *m++ = w2; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& trans_perspective::load_from(const double* m) + { + sx = *m++; shy = *m++; w0 = *m++; + shx = *m++; sy = *m++; w1 = *m++; + tx = *m++; ty = *m++; w2 = *m++; + return *this; + } + + //------------------------------------------------------------------------ + inline const trans_perspective& + trans_perspective::from_affine(const trans_affine& a) + { + sx = a.sx; shy = a.shy; w0 = 0; + shx = a.shx; sy = a.sy; w1 = 0; + tx = a.tx; ty = a.ty; w2 = 1; + return *this; + } + + //------------------------------------------------------------------------ + inline double trans_perspective::determinant() const + { + return sx * (sy * w2 - ty * w1) + + shx * (ty * w0 - shy * w2) + + tx * (shy * w1 - sy * w0); + } + + //------------------------------------------------------------------------ + inline double trans_perspective::determinant_reciprocal() const + { + return 1.0 / determinant(); + } + + //------------------------------------------------------------------------ + inline bool trans_perspective::is_valid(double epsilon) const + { + return fabs(sx) > epsilon && fabs(sy) > epsilon && fabs(w2) > epsilon; + } + + //------------------------------------------------------------------------ + inline bool trans_perspective::is_identity(double epsilon) const + { + return is_equal_eps(sx, 1.0, epsilon) && + is_equal_eps(shy, 0.0, epsilon) && + is_equal_eps(w0, 0.0, epsilon) && + is_equal_eps(shx, 0.0, epsilon) && + is_equal_eps(sy, 1.0, epsilon) && + is_equal_eps(w1, 0.0, epsilon) && + is_equal_eps(tx, 0.0, epsilon) && + is_equal_eps(ty, 0.0, epsilon) && + is_equal_eps(w2, 1.0, epsilon); + } + + //------------------------------------------------------------------------ + inline bool trans_perspective::is_equal(const trans_perspective& m, + double epsilon) const + { + return is_equal_eps(sx, m.sx, epsilon) && + is_equal_eps(shy, m.shy, epsilon) && + is_equal_eps(w0, m.w0, epsilon) && + is_equal_eps(shx, m.shx, epsilon) && + is_equal_eps(sy, m.sy, epsilon) && + is_equal_eps(w1, m.w1, epsilon) && + is_equal_eps(tx, m.tx, epsilon) && + is_equal_eps(ty, m.ty, epsilon) && + is_equal_eps(w2, m.w2, epsilon); + } + + //------------------------------------------------------------------------ + inline double trans_perspective::scale() const + { + double x = 0.707106781 * sx + 0.707106781 * shx; + double y = 0.707106781 * shy + 0.707106781 * sy; + return sqrt(x*x + y*y); + } + + //------------------------------------------------------------------------ + inline double trans_perspective::rotation() const + { + double x1 = 0.0; + double y1 = 0.0; + double x2 = 1.0; + double y2 = 0.0; + transform(&x1, &y1); + transform(&x2, &y2); + return atan2(y2-y1, x2-x1); + } + + //------------------------------------------------------------------------ + void trans_perspective::translation(double* dx, double* dy) const + { + *dx = tx; + *dy = ty; + } + + //------------------------------------------------------------------------ + void trans_perspective::scaling(double* x, double* y) const + { + double x1 = 0.0; + double y1 = 0.0; + double x2 = 1.0; + double y2 = 1.0; + trans_perspective t(*this); + t *= trans_affine_rotation(-rotation()); + t.transform(&x1, &y1); + t.transform(&x2, &y2); + *x = x2 - x1; + *y = y2 - y1; + } + + //------------------------------------------------------------------------ + void trans_perspective::scaling_abs(double* x, double* y) const + { + *x = sqrt(sx * sx + shx * shx); + *y = sqrt(shy * shy + sy * sy); + } + + +} + +#endif + diff --git a/xs/src/agg/agg_trans_single_path.h b/xs/src/agg/agg_trans_single_path.h new file mode 100644 index 0000000000..9f4bf53bdb --- /dev/null +++ b/xs/src/agg/agg_trans_single_path.h @@ -0,0 +1,97 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_TRANS_SINGLE_PATH_INCLUDED +#define AGG_TRANS_SINGLE_PATH_INCLUDED + +#include "agg_basics.h" +#include "agg_vertex_sequence.h" + +namespace agg +{ + + // See also: agg_trans_single_path.cpp + // + //-------------------------------------------------------trans_single_path + class trans_single_path + { + enum status_e + { + initial, + making_path, + ready + }; + + public: + typedef vertex_sequence vertex_storage; + + trans_single_path(); + + //-------------------------------------------------------------------- + void base_length(double v) { m_base_length = v; } + double base_length() const { return m_base_length; } + + //-------------------------------------------------------------------- + void preserve_x_scale(bool f) { m_preserve_x_scale = f; } + bool preserve_x_scale() const { return m_preserve_x_scale; } + + //-------------------------------------------------------------------- + void reset(); + void move_to(double x, double y); + void line_to(double x, double y); + void finalize_path(); + + //-------------------------------------------------------------------- + template + void add_path(VertexSource& vs, unsigned path_id=0) + { + double x; + double y; + + unsigned cmd; + vs.rewind(path_id); + while(!is_stop(cmd = vs.vertex(&x, &y))) + { + if(is_move_to(cmd)) + { + move_to(x, y); + } + else + { + if(is_vertex(cmd)) + { + line_to(x, y); + } + } + } + finalize_path(); + } + + //-------------------------------------------------------------------- + double total_length() const; + void transform(double *x, double *y) const; + + private: + vertex_storage m_src_vertices; + double m_base_length; + double m_kindex; + status_e m_status; + bool m_preserve_x_scale; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_trans_viewport.h b/xs/src/agg/agg_trans_viewport.h new file mode 100644 index 0000000000..7088f99078 --- /dev/null +++ b/xs/src/agg/agg_trans_viewport.h @@ -0,0 +1,303 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Viewport transformer - simple orthogonal conversions from world coordinates +// to screen (device) ones. +// +//---------------------------------------------------------------------------- + +#ifndef AGG_TRANS_VIEWPORT_INCLUDED +#define AGG_TRANS_VIEWPORT_INCLUDED + +#include +#include "agg_trans_affine.h" + + +namespace agg +{ + + enum aspect_ratio_e + { + aspect_ratio_stretch, + aspect_ratio_meet, + aspect_ratio_slice + }; + + + //----------------------------------------------------------trans_viewport + class trans_viewport + { + public: + //------------------------------------------------------------------- + trans_viewport() : + m_world_x1(0.0), + m_world_y1(0.0), + m_world_x2(1.0), + m_world_y2(1.0), + m_device_x1(0.0), + m_device_y1(0.0), + m_device_x2(1.0), + m_device_y2(1.0), + m_aspect(aspect_ratio_stretch), + m_is_valid(true), + m_align_x(0.5), + m_align_y(0.5), + m_wx1(0.0), + m_wy1(0.0), + m_wx2(1.0), + m_wy2(1.0), + m_dx1(0.0), + m_dy1(0.0), + m_kx(1.0), + m_ky(1.0) + {} + + //------------------------------------------------------------------- + void preserve_aspect_ratio(double alignx, + double aligny, + aspect_ratio_e aspect) + { + m_align_x = alignx; + m_align_y = aligny; + m_aspect = aspect; + update(); + } + + //------------------------------------------------------------------- + void device_viewport(double x1, double y1, double x2, double y2) + { + m_device_x1 = x1; + m_device_y1 = y1; + m_device_x2 = x2; + m_device_y2 = y2; + update(); + } + + //------------------------------------------------------------------- + void world_viewport(double x1, double y1, double x2, double y2) + { + m_world_x1 = x1; + m_world_y1 = y1; + m_world_x2 = x2; + m_world_y2 = y2; + update(); + } + + //------------------------------------------------------------------- + void device_viewport(double* x1, double* y1, double* x2, double* y2) const + { + *x1 = m_device_x1; + *y1 = m_device_y1; + *x2 = m_device_x2; + *y2 = m_device_y2; + } + + //------------------------------------------------------------------- + void world_viewport(double* x1, double* y1, double* x2, double* y2) const + { + *x1 = m_world_x1; + *y1 = m_world_y1; + *x2 = m_world_x2; + *y2 = m_world_y2; + } + + //------------------------------------------------------------------- + void world_viewport_actual(double* x1, double* y1, + double* x2, double* y2) const + { + *x1 = m_wx1; + *y1 = m_wy1; + *x2 = m_wx2; + *y2 = m_wy2; + } + + //------------------------------------------------------------------- + bool is_valid() const { return m_is_valid; } + double align_x() const { return m_align_x; } + double align_y() const { return m_align_y; } + aspect_ratio_e aspect_ratio() const { return m_aspect; } + + //------------------------------------------------------------------- + void transform(double* x, double* y) const + { + *x = (*x - m_wx1) * m_kx + m_dx1; + *y = (*y - m_wy1) * m_ky + m_dy1; + } + + //------------------------------------------------------------------- + void transform_scale_only(double* x, double* y) const + { + *x *= m_kx; + *y *= m_ky; + } + + //------------------------------------------------------------------- + void inverse_transform(double* x, double* y) const + { + *x = (*x - m_dx1) / m_kx + m_wx1; + *y = (*y - m_dy1) / m_ky + m_wy1; + } + + //------------------------------------------------------------------- + void inverse_transform_scale_only(double* x, double* y) const + { + *x /= m_kx; + *y /= m_ky; + } + + //------------------------------------------------------------------- + double device_dx() const { return m_dx1 - m_wx1 * m_kx; } + double device_dy() const { return m_dy1 - m_wy1 * m_ky; } + + //------------------------------------------------------------------- + double scale_x() const + { + return m_kx; + } + + //------------------------------------------------------------------- + double scale_y() const + { + return m_ky; + } + + //------------------------------------------------------------------- + double scale() const + { + return (m_kx + m_ky) * 0.5; + } + + //------------------------------------------------------------------- + trans_affine to_affine() const + { + trans_affine mtx = trans_affine_translation(-m_wx1, -m_wy1); + mtx *= trans_affine_scaling(m_kx, m_ky); + mtx *= trans_affine_translation(m_dx1, m_dy1); + return mtx; + } + + //------------------------------------------------------------------- + trans_affine to_affine_scale_only() const + { + return trans_affine_scaling(m_kx, m_ky); + } + + //------------------------------------------------------------------- + unsigned byte_size() const + { + return sizeof(*this); + } + + void serialize(int8u* ptr) const + { + memcpy(ptr, this, sizeof(*this)); + } + + void deserialize(const int8u* ptr) + { + memcpy(this, ptr, sizeof(*this)); + } + + private: + void update(); + + double m_world_x1; + double m_world_y1; + double m_world_x2; + double m_world_y2; + double m_device_x1; + double m_device_y1; + double m_device_x2; + double m_device_y2; + aspect_ratio_e m_aspect; + bool m_is_valid; + double m_align_x; + double m_align_y; + double m_wx1; + double m_wy1; + double m_wx2; + double m_wy2; + double m_dx1; + double m_dy1; + double m_kx; + double m_ky; + }; + + + + //----------------------------------------------------------------------- + inline void trans_viewport::update() + { + const double epsilon = 1e-30; + if(fabs(m_world_x1 - m_world_x2) < epsilon || + fabs(m_world_y1 - m_world_y2) < epsilon || + fabs(m_device_x1 - m_device_x2) < epsilon || + fabs(m_device_y1 - m_device_y2) < epsilon) + { + m_wx1 = m_world_x1; + m_wy1 = m_world_y1; + m_wx2 = m_world_x1 + 1.0; + m_wy2 = m_world_y2 + 1.0; + m_dx1 = m_device_x1; + m_dy1 = m_device_y1; + m_kx = 1.0; + m_ky = 1.0; + m_is_valid = false; + return; + } + + double world_x1 = m_world_x1; + double world_y1 = m_world_y1; + double world_x2 = m_world_x2; + double world_y2 = m_world_y2; + double device_x1 = m_device_x1; + double device_y1 = m_device_y1; + double device_x2 = m_device_x2; + double device_y2 = m_device_y2; + if(m_aspect != aspect_ratio_stretch) + { + double d; + m_kx = (device_x2 - device_x1) / (world_x2 - world_x1); + m_ky = (device_y2 - device_y1) / (world_y2 - world_y1); + + if((m_aspect == aspect_ratio_meet) == (m_kx < m_ky)) + { + d = (world_y2 - world_y1) * m_ky / m_kx; + world_y1 += (world_y2 - world_y1 - d) * m_align_y; + world_y2 = world_y1 + d; + } + else + { + d = (world_x2 - world_x1) * m_kx / m_ky; + world_x1 += (world_x2 - world_x1 - d) * m_align_x; + world_x2 = world_x1 + d; + } + } + m_wx1 = world_x1; + m_wy1 = world_y1; + m_wx2 = world_x2; + m_wy2 = world_y2; + m_dx1 = device_x1; + m_dy1 = device_y1; + m_kx = (device_x2 - device_x1) / (world_x2 - world_x1); + m_ky = (device_y2 - device_y1) / (world_y2 - world_y1); + m_is_valid = true; + } + + +} + + +#endif diff --git a/xs/src/agg/agg_trans_warp_magnifier.h b/xs/src/agg/agg_trans_warp_magnifier.h new file mode 100644 index 0000000000..38a92dbec8 --- /dev/null +++ b/xs/src/agg/agg_trans_warp_magnifier.h @@ -0,0 +1,56 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_WARP_MAGNIFIER_INCLUDED +#define AGG_WARP_MAGNIFIER_INCLUDED + + +namespace agg +{ + + //----------------------------------------------------trans_warp_magnifier + // + // See Inmplementation agg_trans_warp_magnifier.cpp + // + class trans_warp_magnifier + { + public: + trans_warp_magnifier() : m_xc(0.0), m_yc(0.0), m_magn(1.0), m_radius(1.0) {} + + void center(double x, double y) { m_xc = x; m_yc = y; } + void magnification(double m) { m_magn = m; } + void radius(double r) { m_radius = r; } + + double xc() const { return m_xc; } + double yc() const { return m_yc; } + double magnification() const { return m_magn; } + double radius() const { return m_radius; } + + void transform(double* x, double* y) const; + void inverse_transform(double* x, double* y) const; + + private: + double m_xc; + double m_yc; + double m_magn; + double m_radius; + }; + + +} + + +#endif + diff --git a/xs/src/agg/agg_vcgen_bspline.h b/xs/src/agg/agg_vcgen_bspline.h new file mode 100644 index 0000000000..a2944548c0 --- /dev/null +++ b/xs/src/agg/agg_vcgen_bspline.h @@ -0,0 +1,74 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VCGEN_BSPLINE_INCLUDED +#define AGG_VCGEN_BSPLINE_INCLUDED + +#include "agg_basics.h" +#include "agg_array.h" +#include "agg_bspline.h" + + +namespace agg +{ + + //==========================================================vcgen_bspline + class vcgen_bspline + { + enum status_e + { + initial, + ready, + polygon, + end_poly, + stop + }; + + public: + typedef pod_bvector vertex_storage; + + vcgen_bspline(); + + void interpolation_step(double v) { m_interpolation_step = v; } + double interpolation_step() const { return m_interpolation_step; } + + // Vertex Generator Interface + void remove_all(); + void add_vertex(double x, double y, unsigned cmd); + + // Vertex Source Interface + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + vcgen_bspline(const vcgen_bspline&); + const vcgen_bspline& operator = (const vcgen_bspline&); + + vertex_storage m_src_vertices; + bspline m_spline_x; + bspline m_spline_y; + double m_interpolation_step; + unsigned m_closed; + status_e m_status; + unsigned m_src_vertex; + double m_cur_abscissa; + double m_max_abscissa; + }; + +} + + +#endif + diff --git a/xs/src/agg/agg_vcgen_contour.h b/xs/src/agg/agg_vcgen_contour.h new file mode 100644 index 0000000000..8c25da13f5 --- /dev/null +++ b/xs/src/agg/agg_vcgen_contour.h @@ -0,0 +1,94 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VCGEN_CONTOUR_INCLUDED +#define AGG_VCGEN_CONTOUR_INCLUDED + +#include "agg_math_stroke.h" + +namespace agg +{ + + //----------------------------------------------------------vcgen_contour + // + // See Implementation agg_vcgen_contour.cpp + // + class vcgen_contour + { + enum status_e + { + initial, + ready, + outline, + out_vertices, + end_poly, + stop + }; + + public: + typedef vertex_sequence vertex_storage; + typedef pod_bvector coord_storage; + + vcgen_contour(); + + void line_cap(line_cap_e lc) { m_stroker.line_cap(lc); } + void line_join(line_join_e lj) { m_stroker.line_join(lj); } + void inner_join(inner_join_e ij) { m_stroker.inner_join(ij); } + + line_cap_e line_cap() const { return m_stroker.line_cap(); } + line_join_e line_join() const { return m_stroker.line_join(); } + inner_join_e inner_join() const { return m_stroker.inner_join(); } + + void width(double w) { m_stroker.width(m_width = w); } + void miter_limit(double ml) { m_stroker.miter_limit(ml); } + void miter_limit_theta(double t) { m_stroker.miter_limit_theta(t); } + void inner_miter_limit(double ml) { m_stroker.inner_miter_limit(ml); } + void approximation_scale(double as) { m_stroker.approximation_scale(as); } + + double width() const { return m_width; } + double miter_limit() const { return m_stroker.miter_limit(); } + double inner_miter_limit() const { return m_stroker.inner_miter_limit(); } + double approximation_scale() const { return m_stroker.approximation_scale(); } + + void auto_detect_orientation(bool v) { m_auto_detect = v; } + bool auto_detect_orientation() const { return m_auto_detect; } + + // Generator interface + void remove_all(); + void add_vertex(double x, double y, unsigned cmd); + + // Vertex Source Interface + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + vcgen_contour(const vcgen_contour&); + const vcgen_contour& operator = (const vcgen_contour&); + + math_stroke m_stroker; + double m_width; + vertex_storage m_src_vertices; + coord_storage m_out_vertices; + status_e m_status; + unsigned m_src_vertex; + unsigned m_out_vertex; + unsigned m_closed; + unsigned m_orientation; + bool m_auto_detect; + }; + +} + +#endif diff --git a/xs/src/agg/agg_vcgen_dash.h b/xs/src/agg/agg_vcgen_dash.h new file mode 100644 index 0000000000..c87dce4c81 --- /dev/null +++ b/xs/src/agg/agg_vcgen_dash.h @@ -0,0 +1,93 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Line dash generator +// +//---------------------------------------------------------------------------- +#ifndef AGG_VCGEN_DASH_INCLUDED +#define AGG_VCGEN_DASH_INCLUDED + +#include "agg_basics.h" +#include "agg_vertex_sequence.h" + +namespace agg +{ + + //---------------------------------------------------------------vcgen_dash + // + // See Implementation agg_vcgen_dash.cpp + // + class vcgen_dash + { + enum max_dashes_e + { + max_dashes = 32 + }; + + enum status_e + { + initial, + ready, + polyline, + stop + }; + + public: + typedef vertex_sequence vertex_storage; + + vcgen_dash(); + + void remove_all_dashes(); + void add_dash(double dash_len, double gap_len); + void dash_start(double ds); + + void shorten(double s) { m_shorten = s; } + double shorten() const { return m_shorten; } + + // Vertex Generator Interface + void remove_all(); + void add_vertex(double x, double y, unsigned cmd); + + // Vertex Source Interface + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + vcgen_dash(const vcgen_dash&); + const vcgen_dash& operator = (const vcgen_dash&); + + void calc_dash_start(double ds); + + double m_dashes[max_dashes]; + double m_total_dash_len; + unsigned m_num_dashes; + double m_dash_start; + double m_shorten; + double m_curr_dash_start; + unsigned m_curr_dash; + double m_curr_rest; + const vertex_dist* m_v1; + const vertex_dist* m_v2; + + vertex_storage m_src_vertices; + unsigned m_closed; + status_e m_status; + unsigned m_src_vertex; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_vcgen_markers_term.h b/xs/src/agg/agg_vcgen_markers_term.h new file mode 100644 index 0000000000..ee1e74e3eb --- /dev/null +++ b/xs/src/agg/agg_vcgen_markers_term.h @@ -0,0 +1,66 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VCGEN_MARKERS_TERM_INCLUDED +#define AGG_VCGEN_MARKERS_TERM_INCLUDED + +#include "agg_basics.h" +#include "agg_vertex_sequence.h" + +namespace agg +{ + + //======================================================vcgen_markers_term + // + // See Implemantation agg_vcgen_markers_term.cpp + // Terminal markers generator (arrowhead/arrowtail) + // + //------------------------------------------------------------------------ + class vcgen_markers_term + { + public: + vcgen_markers_term() : m_curr_id(0), m_curr_idx(0) {} + + // Vertex Generator Interface + void remove_all(); + void add_vertex(double x, double y, unsigned cmd); + + // Vertex Source Interface + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + vcgen_markers_term(const vcgen_markers_term&); + const vcgen_markers_term& operator = (const vcgen_markers_term&); + + struct coord_type + { + double x, y; + + coord_type() {} + coord_type(double x_, double y_) : x(x_), y(y_) {} + }; + + typedef pod_bvector coord_storage; + + coord_storage m_markers; + unsigned m_curr_id; + unsigned m_curr_idx; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_vcgen_smooth_poly1.h b/xs/src/agg/agg_vcgen_smooth_poly1.h new file mode 100644 index 0000000000..80fc0fb796 --- /dev/null +++ b/xs/src/agg/agg_vcgen_smooth_poly1.h @@ -0,0 +1,87 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VCGEN_SMOOTH_POLY1_INCLUDED +#define AGG_VCGEN_SMOOTH_POLY1_INCLUDED + +#include "agg_basics.h" +#include "agg_vertex_sequence.h" + + +namespace agg +{ + + //======================================================vcgen_smooth_poly1 + // + // See Implementation agg_vcgen_smooth_poly1.cpp + // Smooth polygon generator + // + //------------------------------------------------------------------------ + class vcgen_smooth_poly1 + { + enum status_e + { + initial, + ready, + polygon, + ctrl_b, + ctrl_e, + ctrl1, + ctrl2, + end_poly, + stop + }; + + public: + typedef vertex_sequence vertex_storage; + + vcgen_smooth_poly1(); + + void smooth_value(double v) { m_smooth_value = v * 0.5; } + double smooth_value() const { return m_smooth_value * 2.0; } + + // Vertex Generator Interface + void remove_all(); + void add_vertex(double x, double y, unsigned cmd); + + // Vertex Source Interface + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + vcgen_smooth_poly1(const vcgen_smooth_poly1&); + const vcgen_smooth_poly1& operator = (const vcgen_smooth_poly1&); + + void calculate(const vertex_dist& v0, + const vertex_dist& v1, + const vertex_dist& v2, + const vertex_dist& v3); + + vertex_storage m_src_vertices; + double m_smooth_value; + unsigned m_closed; + status_e m_status; + unsigned m_src_vertex; + double m_ctrl1_x; + double m_ctrl1_y; + double m_ctrl2_x; + double m_ctrl2_y; + }; + +} + + +#endif + diff --git a/xs/src/agg/agg_vcgen_stroke.h b/xs/src/agg/agg_vcgen_stroke.h new file mode 100644 index 0000000000..778223fe40 --- /dev/null +++ b/xs/src/agg/agg_vcgen_stroke.h @@ -0,0 +1,102 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VCGEN_STROKE_INCLUDED +#define AGG_VCGEN_STROKE_INCLUDED + +#include "agg_math_stroke.h" + + +namespace agg +{ + + //============================================================vcgen_stroke + // + // See Implementation agg_vcgen_stroke.cpp + // Stroke generator + // + //------------------------------------------------------------------------ + class vcgen_stroke + { + enum status_e + { + initial, + ready, + cap1, + cap2, + outline1, + close_first, + outline2, + out_vertices, + end_poly1, + end_poly2, + stop + }; + + public: + typedef vertex_sequence vertex_storage; + typedef pod_bvector coord_storage; + + vcgen_stroke(); + + void line_cap(line_cap_e lc) { m_stroker.line_cap(lc); } + void line_join(line_join_e lj) { m_stroker.line_join(lj); } + void inner_join(inner_join_e ij) { m_stroker.inner_join(ij); } + + line_cap_e line_cap() const { return m_stroker.line_cap(); } + line_join_e line_join() const { return m_stroker.line_join(); } + inner_join_e inner_join() const { return m_stroker.inner_join(); } + + void width(double w) { m_stroker.width(w); } + void miter_limit(double ml) { m_stroker.miter_limit(ml); } + void miter_limit_theta(double t) { m_stroker.miter_limit_theta(t); } + void inner_miter_limit(double ml) { m_stroker.inner_miter_limit(ml); } + void approximation_scale(double as) { m_stroker.approximation_scale(as); } + + double width() const { return m_stroker.width(); } + double miter_limit() const { return m_stroker.miter_limit(); } + double inner_miter_limit() const { return m_stroker.inner_miter_limit(); } + double approximation_scale() const { return m_stroker.approximation_scale(); } + + void shorten(double s) { m_shorten = s; } + double shorten() const { return m_shorten; } + + // Vertex Generator Interface + void remove_all(); + void add_vertex(double x, double y, unsigned cmd); + + // Vertex Source Interface + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + private: + vcgen_stroke(const vcgen_stroke&); + const vcgen_stroke& operator = (const vcgen_stroke&); + + math_stroke m_stroker; + vertex_storage m_src_vertices; + coord_storage m_out_vertices; + double m_shorten; + unsigned m_closed; + status_e m_status; + status_e m_prev_status; + unsigned m_src_vertex; + unsigned m_out_vertex; + }; + + +} + +#endif diff --git a/xs/src/agg/agg_vcgen_vertex_sequence.h b/xs/src/agg/agg_vcgen_vertex_sequence.h new file mode 100644 index 0000000000..5adc671597 --- /dev/null +++ b/xs/src/agg/agg_vcgen_vertex_sequence.h @@ -0,0 +1,135 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VCGEN_VERTEX_SEQUENCE_INCLUDED +#define AGG_VCGEN_VERTEX_SEQUENCE_INCLUDED + +#include "agg_basics.h" +#include "agg_vertex_sequence.h" +#include "agg_shorten_path.h" + +namespace agg +{ + + //===================================================vcgen_vertex_sequence + class vcgen_vertex_sequence + { + public: + typedef vertex_dist_cmd vertex_type; + typedef vertex_sequence vertex_storage; + + vcgen_vertex_sequence() : + m_flags(0), + m_cur_vertex(0), + m_shorten(0.0), + m_ready(false) + { + } + + // Vertex Generator Interface + void remove_all(); + void add_vertex(double x, double y, unsigned cmd); + + // Vertex Source Interface + void rewind(unsigned path_id); + unsigned vertex(double* x, double* y); + + void shorten(double s) { m_shorten = s; } + double shorten() const { return m_shorten; } + + private: + vcgen_vertex_sequence(const vcgen_vertex_sequence&); + const vcgen_vertex_sequence& operator = (const vcgen_vertex_sequence&); + + vertex_storage m_src_vertices; + unsigned m_flags; + unsigned m_cur_vertex; + double m_shorten; + bool m_ready; + }; + + + //------------------------------------------------------------------------ + inline void vcgen_vertex_sequence::remove_all() + { + m_ready = false; + m_src_vertices.remove_all(); + m_cur_vertex = 0; + m_flags = 0; + } + + //------------------------------------------------------------------------ + inline void vcgen_vertex_sequence::add_vertex(double x, double y, unsigned cmd) + { + m_ready = false; + if(is_move_to(cmd)) + { + m_src_vertices.modify_last(vertex_dist_cmd(x, y, cmd)); + } + else + { + if(is_vertex(cmd)) + { + m_src_vertices.add(vertex_dist_cmd(x, y, cmd)); + } + else + { + m_flags = cmd & path_flags_mask; + } + } + } + + + //------------------------------------------------------------------------ + inline void vcgen_vertex_sequence::rewind(unsigned) + { + if(!m_ready) + { + m_src_vertices.close(is_closed(m_flags)); + shorten_path(m_src_vertices, m_shorten, get_close_flag(m_flags)); + } + m_ready = true; + m_cur_vertex = 0; + } + + //------------------------------------------------------------------------ + inline unsigned vcgen_vertex_sequence::vertex(double* x, double* y) + { + if(!m_ready) + { + rewind(0); + } + + if(m_cur_vertex == m_src_vertices.size()) + { + ++m_cur_vertex; + return path_cmd_end_poly | m_flags; + } + + if(m_cur_vertex > m_src_vertices.size()) + { + return path_cmd_stop; + } + + vertex_type& v = m_src_vertices[m_cur_vertex++]; + *x = v.x; + *y = v.y; + return v.cmd; + } + + +} + +#endif diff --git a/xs/src/agg/agg_vertex_sequence.h b/xs/src/agg/agg_vertex_sequence.h new file mode 100644 index 0000000000..2ad0701b37 --- /dev/null +++ b/xs/src/agg/agg_vertex_sequence.h @@ -0,0 +1,172 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// vertex_sequence container and vertex_dist struct +// +//---------------------------------------------------------------------------- +#ifndef AGG_VERTEX_SEQUENCE_INCLUDED +#define AGG_VERTEX_SEQUENCE_INCLUDED + +#include "agg_basics.h" +#include "agg_array.h" +#include "agg_math.h" + +namespace agg +{ + + //----------------------------------------------------------vertex_sequence + // Modified agg::pod_bvector. The data is interpreted as a sequence + // of vertices. It means that the type T must expose: + // + // bool T::operator() (const T& val) + // + // that is called every time new vertex is being added. The main purpose + // of this operator is the possibility to calculate some values during + // adding and to return true if the vertex fits some criteria or false if + // it doesn't. In the last case the new vertex is not added. + // + // The simple example is filtering coinciding vertices with calculation + // of the distance between the current and previous ones: + // + // struct vertex_dist + // { + // double x; + // double y; + // double dist; + // + // vertex_dist() {} + // vertex_dist(double x_, double y_) : + // x(x_), + // y(y_), + // dist(0.0) + // { + // } + // + // bool operator () (const vertex_dist& val) + // { + // return (dist = calc_distance(x, y, val.x, val.y)) > EPSILON; + // } + // }; + // + // Function close() calls this operator and removes the last vertex if + // necessary. + //------------------------------------------------------------------------ + template + class vertex_sequence : public pod_bvector + { + public: + typedef pod_bvector base_type; + + void add(const T& val); + void modify_last(const T& val); + void close(bool remove_flag); + }; + + + + //------------------------------------------------------------------------ + template + void vertex_sequence::add(const T& val) + { + if(base_type::size() > 1) + { + if(!(*this)[base_type::size() - 2]((*this)[base_type::size() - 1])) + { + base_type::remove_last(); + } + } + base_type::add(val); + } + + + //------------------------------------------------------------------------ + template + void vertex_sequence::modify_last(const T& val) + { + base_type::remove_last(); + add(val); + } + + + + //------------------------------------------------------------------------ + template + void vertex_sequence::close(bool closed) + { + while(base_type::size() > 1) + { + if((*this)[base_type::size() - 2]((*this)[base_type::size() - 1])) break; + T t = (*this)[base_type::size() - 1]; + base_type::remove_last(); + modify_last(t); + } + + if(closed) + { + while(base_type::size() > 1) + { + if((*this)[base_type::size() - 1]((*this)[0])) break; + base_type::remove_last(); + } + } + } + + + //-------------------------------------------------------------vertex_dist + // Vertex (x, y) with the distance to the next one. The last vertex has + // distance between the last and the first points if the polygon is closed + // and 0.0 if it's a polyline. + struct vertex_dist + { + double x; + double y; + double dist; + + vertex_dist() {} + vertex_dist(double x_, double y_) : + x(x_), + y(y_), + dist(0.0) + { + } + + bool operator () (const vertex_dist& val) + { + bool ret = (dist = calc_distance(x, y, val.x, val.y)) > vertex_dist_epsilon; + if(!ret) dist = 1.0 / vertex_dist_epsilon; + return ret; + } + }; + + + + //--------------------------------------------------------vertex_dist_cmd + // Save as the above but with additional "command" value + struct vertex_dist_cmd : public vertex_dist + { + unsigned cmd; + + vertex_dist_cmd() {} + vertex_dist_cmd(double x_, double y_, unsigned cmd_) : + vertex_dist(x_, y_), + cmd(cmd_) + { + } + }; + + +} + +#endif diff --git a/xs/src/agg/agg_vpgen_clip_polygon.h b/xs/src/agg/agg_vpgen_clip_polygon.h new file mode 100644 index 0000000000..ded754e211 --- /dev/null +++ b/xs/src/agg/agg_vpgen_clip_polygon.h @@ -0,0 +1,83 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VPGEN_CLIP_POLYGON_INCLUDED +#define AGG_VPGEN_CLIP_POLYGON_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //======================================================vpgen_clip_polygon + // + // See Implementation agg_vpgen_clip_polygon.cpp + // + class vpgen_clip_polygon + { + public: + vpgen_clip_polygon() : + m_clip_box(0, 0, 1, 1), + m_x1(0), + m_y1(0), + m_clip_flags(0), + m_num_vertices(0), + m_vertex(0), + m_cmd(path_cmd_move_to) + { + } + + void clip_box(double x1, double y1, double x2, double y2) + { + m_clip_box.x1 = x1; + m_clip_box.y1 = y1; + m_clip_box.x2 = x2; + m_clip_box.y2 = y2; + m_clip_box.normalize(); + } + + + double x1() const { return m_clip_box.x1; } + double y1() const { return m_clip_box.y1; } + double x2() const { return m_clip_box.x2; } + double y2() const { return m_clip_box.y2; } + + static bool auto_close() { return true; } + static bool auto_unclose() { return false; } + + void reset(); + void move_to(double x, double y); + void line_to(double x, double y); + unsigned vertex(double* x, double* y); + + private: + unsigned clipping_flags(double x, double y); + + private: + rect_d m_clip_box; + double m_x1; + double m_y1; + unsigned m_clip_flags; + double m_x[4]; + double m_y[4]; + unsigned m_num_vertices; + unsigned m_vertex; + unsigned m_cmd; + }; + +} + + +#endif diff --git a/xs/src/agg/agg_vpgen_clip_polyline.h b/xs/src/agg/agg_vpgen_clip_polyline.h new file mode 100644 index 0000000000..b070a7759e --- /dev/null +++ b/xs/src/agg/agg_vpgen_clip_polyline.h @@ -0,0 +1,78 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VPGEN_CLIP_POLYLINE_INCLUDED +#define AGG_VPGEN_CLIP_POLYLINE_INCLUDED + +#include "agg_basics.h" + +namespace agg +{ + + //======================================================vpgen_clip_polyline + // + // See Implementation agg_vpgen_clip_polyline.cpp + // + class vpgen_clip_polyline + { + public: + vpgen_clip_polyline() : + m_clip_box(0, 0, 1, 1), + m_x1(0), + m_y1(0), + m_num_vertices(0), + m_vertex(0), + m_move_to(false) + { + } + + void clip_box(double x1, double y1, double x2, double y2) + { + m_clip_box.x1 = x1; + m_clip_box.y1 = y1; + m_clip_box.x2 = x2; + m_clip_box.y2 = y2; + m_clip_box.normalize(); + } + + double x1() const { return m_clip_box.x1; } + double y1() const { return m_clip_box.y1; } + double x2() const { return m_clip_box.x2; } + double y2() const { return m_clip_box.y2; } + + static bool auto_close() { return false; } + static bool auto_unclose() { return true; } + + void reset(); + void move_to(double x, double y); + void line_to(double x, double y); + unsigned vertex(double* x, double* y); + + private: + rect_d m_clip_box; + double m_x1; + double m_y1; + double m_x[2]; + double m_y[2]; + unsigned m_cmd[2]; + unsigned m_num_vertices; + unsigned m_vertex; + bool m_move_to; + }; + +} + + +#endif diff --git a/xs/src/agg/agg_vpgen_segmentator.h b/xs/src/agg/agg_vpgen_segmentator.h new file mode 100644 index 0000000000..29b3c9fa6f --- /dev/null +++ b/xs/src/agg/agg_vpgen_segmentator.h @@ -0,0 +1,61 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +#ifndef AGG_VPGEN_SEGMENTATOR_INCLUDED +#define AGG_VPGEN_SEGMENTATOR_INCLUDED + +#include +#include "agg_basics.h" + +namespace agg +{ + + //=======================================================vpgen_segmentator + // + // See Implementation agg_vpgen_segmentator.cpp + // + class vpgen_segmentator + { + public: + vpgen_segmentator() : m_approximation_scale(1.0) {} + + void approximation_scale(double s) { m_approximation_scale = s; } + double approximation_scale() const { return m_approximation_scale; } + + static bool auto_close() { return false; } + static bool auto_unclose() { return false; } + + void reset() { m_cmd = path_cmd_stop; } + void move_to(double x, double y); + void line_to(double x, double y); + unsigned vertex(double* x, double* y); + + private: + double m_approximation_scale; + double m_x1; + double m_y1; + double m_dx; + double m_dy; + double m_dl; + double m_ddl; + unsigned m_cmd; + }; + + + +} + +#endif + diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 05d635afeb..a4366a717a 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -12,11 +12,14 @@ #include // For png export of the sliced model +#include #include #include #include #include +#include "Rasterizer/Rasterizer.hpp" + #include namespace Slic3r { @@ -1260,55 +1263,88 @@ public: template<> class FilePrinter { - wxBitmap bitmap_; - std::unique_ptr dc_; - std::unique_ptr gc_; - double pxw_; - double pxh_; + std::unique_ptr rst_; + Raster::Resolution res_; + Raster::PixelDim pxdim_; public: inline FilePrinter(unsigned width_px, unsigned height_px, - double width_mm, double height_mm): - bitmap_(width_px, height_px), - dc_(new wxMemoryDC(bitmap_)), - gc_(wxGraphicsContext::Create(*dc_)), - pxw_(width_mm/width_px), - pxh_(height_mm/width_px) - { - gc_->SetAntialiasMode(wxANTIALIAS_DEFAULT); - } + double width_mm, double height_mm): + res_(width_px, height_px), + pxdim_(width_mm/width_px, height_mm/height_px) {} FilePrinter(const FilePrinter& ) = delete; FilePrinter(FilePrinter&& m): - bitmap_(std::move(m.bitmap_)), dc_(std::move(m.dc_)), - gc_(std::move(m.gc_)), pxw_(m.pxw_), pxh_(m.pxh_) {} + rst_(std::move(m.rst_)), + res_(m.res_), + pxdim_(m.pxdim_) {} - void drawPolygon(const Polygon& p) { - - gc_->SetPen(*wxWHITE_PEN); - std::vector points; - points.reserve(p.points.size()); - - for(auto pp : p.points) { - points.emplace_back( - std::round(pp.x * SCALING_FACTOR/pxw_), - std::round(pp.y * SCALING_FACTOR/pxh_) - ); - } - - gc_->DrawLines(points.size(), points.data()); + inline void drawPolygon(const Polygon& p) { + if(!rst_) rst_.reset(new Raster(res_, pxdim_)); + rst_->draw(p); } - void finish() { - + inline void finish() { + rst_.reset(); } - void save(const std::string& path) { - if(!bitmap_.SaveFile(path, wxBITMAP_TYPE_PNG)) { - std::cout << "fail for " << path << std::endl; - } + inline void save(const std::string& path) { + std::fstream out(path, std::fstream::out | std::fstream::binary); + rst_->save(out); + out.close(); } }; +//template<> +//class FilePrinter { +// wxBitmap bitmap_; +// std::unique_ptr dc_; +// std::unique_ptr gc_; +// double pxw_; +// double pxh_; +//public: +// inline FilePrinter(unsigned width_px, unsigned height_px, +// double width_mm, double height_mm): +// bitmap_(width_px, height_px), +// dc_(new wxMemoryDC(bitmap_)), +// gc_(wxGraphicsContext::Create(*dc_)), +// pxw_(width_mm/width_px), +// pxh_(height_mm/width_px) +// { +// gc_->SetAntialiasMode(wxANTIALIAS_DEFAULT); +// } + +// FilePrinter(const FilePrinter& ) = delete; +// FilePrinter(FilePrinter&& m): +// bitmap_(std::move(m.bitmap_)), dc_(std::move(m.dc_)), +// gc_(std::move(m.gc_)), pxw_(m.pxw_), pxh_(m.pxh_) {} + +// void drawPolygon(const Polygon& p) { + +// gc_->SetPen(*wxWHITE_PEN); +// std::vector points; +// points.reserve(p.points.size()); + +// for(auto pp : p.points) { +// points.emplace_back( +// std::round(pp.x * SCALING_FACTOR/pxw_), +// std::round(pp.y * SCALING_FACTOR/pxh_) +// ); +// } + +// gc_->DrawLines(points.size(), points.data()); +// } + +// void finish() { + +// } + +// void save(const std::string& path) { +// if(!bitmap_.SaveFile(path, wxBITMAP_TYPE_PNG)) { +// std::cout << "fail for " << path << std::endl; +// } +// } +//}; + template void Print::print_to(std::string dirpath, Args...args) { @@ -1338,8 +1374,10 @@ void Print::print_to(std::string dirpath, Args...args) std::vector> printers; printers.reserve(layers.size()); - for(unsigned i = 0; i < layers.size(); i++) + + for(unsigned i = 0; i < layers.size(); i++) { printers.emplace_back(std::forward(args)...); + } #pragma omp parallel for for(int layer_id = 0; layer_id < layers.size(); layer_id++) { @@ -1378,54 +1416,10 @@ void Print::print_to(std::string dirpath, Args...args) }); }); + printers[layer_id].save(dir + "layer" + std::to_string(layer_id) + ".ppm"); printer.finish(); - // layer_id++; - // if ($layer->slice_z == -1) { - // printf $fh qq{ \n}, $layer_id; - // } else { - // printf $fh qq{ \n}, $layer_id, unscale($layer->slice_z); - // } - - // my @current_layer_slices = (); - // # sort slices so that the outermost ones come first - // my @slices = sort { $a->contour->contains_point($b->contour->first_point) ? 0 : 1 } @{$layer->slices}; - // foreach my $copy (@{$layer->object->_shifted_copies}) { - // foreach my $slice (@slices) { - // my $expolygon = $slice->clone; - // $expolygon->translate(@$copy); - // $expolygon->translate(-$print_bb->x_min, -$print_bb->y_min); - // $print_polygon->($expolygon->contour, 'contour'); - // $print_polygon->($_, 'hole') for @{$expolygon->holes}; - // push @current_layer_slices, $expolygon; - // } - // } -// # generate support material -// if ($self->has_support_material && $layer->id > 0) { -// my (@supported_slices, @unsupported_slices) = (); -// foreach my $expolygon (@current_layer_slices) { -// my $intersection = intersection_ex( -// [ map @$_, @previous_layer_slices ], -// [ @$expolygon ], -// ); -// @$intersection -// ? push @supported_slices, $expolygon -// : push @unsupported_slices, $expolygon; -// } -// my @supported_points = map @$_, @$_, @supported_slices; -// foreach my $expolygon (@unsupported_slices) { -// # look for the nearest point to this island among all -// # supported points -// my $contour = $expolygon->contour; -// my $support_point = $contour->first_point->nearest_point(\@supported_points) -// or next; -// my $anchor_point = $support_point->nearest_point([ @$contour ]); -// printf $fh qq{ \n}, -// map @$_, $support_point, $anchor_point; -// } -// } -// print $fh qq{ \n}; -// @previous_layer_slices = @current_layer_slices; +// std::cout << "processed layers: " << layer_id + 1 << std::endl; previous_layer_slices = current_layer_slices; } @@ -1434,8 +1428,9 @@ void Print::print_to(std::string dirpath, Args...args) } void Print::print_to_png(std::string dirpath, long width_px, long height_px, - Pointf pixel_size_mm) { - print_to(dirpath, 2560, 1440, 700, 400); + double width_mm, double height_mm) { + print_to(dirpath, width_px, height_px, + width_mm, height_mm); } } diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index 48cb0898af..fc2cf2b202 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -319,11 +319,11 @@ public: void print_to(std::string dirpath, Args...args); void print_to_png(std::string dirpath, long width_px, long height_px, - Pointf pixel_size_mm); + double width_mm, double height_mm); void print_to_png(std::string dirpath) { // Where should this be specified? - print_to_png(dirpath, 2560, 1440, Pointf{2560/700.0, 2560/400.0}); + print_to_png(dirpath, 2560, 1440, 70.0, 40.0); } private: diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index 99d3968b26..d4af2a6ca8 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -1,40 +1,156 @@ #include "Rasterizer.hpp" -#include +#include +// For rasterizing +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// For compression +#include namespace Slic3r { class Raster::Impl { +public: + using TBuffer = std::vector>; + using TPixelRenderer = agg::pixfmt_rgb24; + using TRawRenderer = agg::renderer_base; + using TRenderer = agg::renderer_primitives; + using TPixel = TPixelRenderer::color_type; + using TRawBuffer = agg::rendering_buffer; + using TRendererAA = agg::renderer_scanline_aa_solid; + + static const TPixel ColorWhite; + static const TPixel ColorBlack; + +private: + Raster::Resolution resolution_; + Raster::PixelDim pxdim_; + TBuffer buf_; + TRawBuffer rbuf_; + TPixelRenderer pixfmt_; + TRawRenderer raw_renderer_; +public: + inline Impl(const Raster::Resolution& res, const Raster::PixelDim &pd): + resolution_(res), pxdim_(pd), + buf_(res.pixels()), + rbuf_(reinterpret_cast(buf_.data()), + res.width_px, res.height_px, res.width_px*sizeof(TBuffer::value_type)), + pixfmt_(rbuf_), + raw_renderer_(pixfmt_) + { + clear(); + } + + void draw(const Polygon &p) { + TRendererAA ren_aa(raw_renderer_); + agg::rasterizer_scanline_aa<> ras; + agg::scanline_p8 scanlines; + + agg::path_storage paths; + +// ras.gamma(agg::gamma_power(1.0)); + + auto it = p.points.begin(); + auto itnext = std::next(it); + + { + double xf = std::round(it->x * SCALING_FACTOR/pxdim_.w_mm); + double yf = std::round(it->y * SCALING_FACTOR/pxdim_.h_mm); + double nxf = std::round(itnext->x * SCALING_FACTOR/pxdim_.w_mm); + double nyf = std::round(itnext->y * SCALING_FACTOR/pxdim_.h_mm); + + paths.move_to(xf, yf); + paths.line_to(nxf, nyf); + + ++it, ++itnext; + } + while(itnext != p.points.end() ) { +// double xf = std::round(it->x * SCALING_FACTOR/pxdim_.w_mm); +// double yf = std::round(it->y * SCALING_FACTOR/pxdim_.h_mm); +// auto x = renderer_.coord(xf); +// auto y = renderer_.coord(yf); + + double nxf = std::round(itnext->x * SCALING_FACTOR/pxdim_.w_mm); + double nyf = std::round(itnext->y * SCALING_FACTOR/pxdim_.h_mm); +// auto nx = renderer_.coord(nxf); +// auto ny = renderer_.coord(nyf); + +// renderer_.move_to(x, y); +// renderer_.line_to(nx, ny); + +// paths.move_to(xf, yf); + paths.line_to(nxf, nyf); + + /*++it,*/ ++itnext; + } + + paths.close_polygon(); + ras.add_path(paths); + + ren_aa.color(ColorWhite); + agg::render_scanlines(ras, scanlines, ren_aa); + } + + inline void clear() { + raw_renderer_.clear(ColorBlack); + } + + inline const TBuffer& buffer() const { return buf_; } + + inline const Raster::Resolution resolution() { return resolution_; } }; -Raster::Raster(const Raster::Resolution &r, const Raster::PixelDim &pd): - impl_(new Impl), resolution_(r), pxdim_(pd) {} +const Raster::Impl::TPixel Raster::Impl::ColorWhite = Raster::Impl::TPixel(255, 255, 255); +const Raster::Impl::TPixel Raster::Impl::ColorBlack = Raster::Impl::TPixel(0, 0, 0); + +Raster::Raster(const Resolution &r, const PixelDim &pd): + impl_(new Impl(r, pd)) {} Raster::~Raster() {} -Raster::Raster(const Raster &cpy): resolution_(cpy.resolution_), - pxdim_(cpy.pxdim_) { +Raster::Raster(const Raster &cpy) { *impl_ = *(cpy.impl_); } Raster::Raster(Raster &&m): - impl_(std::move(m.impl_)), resolution_(m.resolution_), pxdim_(m.pxdim_) {} + impl_(std::move(m.impl_)) {} void Raster::clear() { - + impl_->clear(); } void Raster::draw(const Polygon &poly) { - png_image ifo; + impl_->draw(poly); } -void Raster::finish() +void Raster::save(std::ostream& stream, Compression comp) { + switch(comp) { + case Compression::RAW: + case Compression::PNG: + stream << "P6 " + << impl_->resolution().width_px << " " + << impl_->resolution().height_px << " " + << "255 "; + stream.write(reinterpret_cast(impl_->buffer().data()), + impl_->buffer().size()*sizeof(Impl::TBuffer::value_type)); + break; + } } } diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp index db4ee02f33..d6b27ea82f 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp @@ -1,6 +1,7 @@ #ifndef RASTERIZER_HPP #define RASTERIZER_HPP +#include #include namespace Slic3r { @@ -10,10 +11,18 @@ class Raster { std::unique_ptr impl_; public: + enum class Compression { + RAW, + PNG + }; + struct Resolution { unsigned width_px; unsigned height_px; inline Resolution(unsigned w, unsigned h): width_px(w), height_px(h) {} + inline unsigned pixels() const /*noexcept*/ { + return width_px * height_px; + } }; struct PixelDim { @@ -23,7 +32,7 @@ public: w_mm(px_width_mm), h_mm(px_height_mm) {} }; - inline explicit Raster(const Resolution& r, const PixelDim& pd ); + explicit Raster(const Resolution& r, const PixelDim& pd ); ~Raster(); Raster(const Raster& cpy); Raster(Raster&& m); @@ -32,11 +41,7 @@ public: void draw(const Polygon& poly); - void finish(); - -private: - Resolution resolution_; - PixelDim pxdim_; + void save(std::ostream& stream, Compression comp = Compression::RAW); }; } From 19221b749cf820aa40b99548c1340c346b73e597 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 18 May 2018 08:21:24 +0200 Subject: [PATCH 0369/1150] Fix of https://github.com/prusa3d/Slic3r/issues/869 --- xs/src/libslic3r/PrintConfig.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index dcfc3ffe74..9333132ff4 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1933,7 +1933,10 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va "support_material_tool", "acceleration", "adjust_overhang_flow", "standby_temperature", "scale", "rotate", "duplicate", "duplicate_grid", "start_perimeters_at_concave_points", "start_perimeters_at_non_overhang", "randomize_start", - "seal_position", "vibration_limit", "bed_size", "octoprint_host", + "seal_position", "vibration_limit", "bed_size", + // Maybe one day we will rename octoprint_host to print_host as it has been done in the upstream Slic3r. + // Commenting this out fixes github issue #869 for now. + // "octoprint_host", "print_center", "g0", "threads", "pressure_advance", "wipe_tower_per_color_wipe" }; From 651c4ab0ae9cf533d470c891a615364a0539c2de Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 18 May 2018 08:46:33 +0200 Subject: [PATCH 0370/1150] Fixed a typo in AppConfig --- xs/src/libslic3r/PerimeterGenerator.hpp | 5 ++--- xs/src/libslic3r/PrintObject.cpp | 1 - xs/src/slic3r/GUI/AppConfig.hpp | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/xs/src/libslic3r/PerimeterGenerator.hpp b/xs/src/libslic3r/PerimeterGenerator.hpp index 04557a2c0b..c0f449908d 100644 --- a/xs/src/libslic3r/PerimeterGenerator.hpp +++ b/xs/src/libslic3r/PerimeterGenerator.hpp @@ -24,9 +24,8 @@ public: // Children contour, may be both CCW and CW oriented (outer contours or holes). std::vector children; - PerimeterGeneratorLoop(Polygon polygon, unsigned short depth) - : polygon(polygon), is_contour(false), depth(depth) - {}; + PerimeterGeneratorLoop(Polygon polygon, unsigned short depth, bool is_contour) : + polygon(polygon), is_contour(is_contour), depth(depth) {} // External perimeter. It may be CCW or CW oriented (outer contour or hole contour). bool is_external() const { return this->depth == 0; } // An island, which may have holes, but it does not have another internal island. diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index c61fc102b9..b0341db16e 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -1459,7 +1459,6 @@ void PrintObject::_make_perimeters() size_t region_id = region_it - this->_print->regions.begin(); const PrintRegion ®ion = **region_it; - if (!region.config.extra_perimeters || region.config.perimeters == 0 || region.config.fill_density == 0 diff --git a/xs/src/slic3r/GUI/AppConfig.hpp b/xs/src/slic3r/GUI/AppConfig.hpp index 08741e1e4b..b742176ed3 100644 --- a/xs/src/slic3r/GUI/AppConfig.hpp +++ b/xs/src/slic3r/GUI/AppConfig.hpp @@ -101,7 +101,7 @@ public: // Returns true if the user's data directory comes from before Slic3r 1.40.0 (no updating) bool legacy_datadir() const { return m_legacy_datadir; } - bool set_legacy_datadir(bool value) { m_legacy_datadir = value; } + void set_legacy_datadir(bool value) { m_legacy_datadir = value; } // Get the Slic3r version check url. // This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file. From 3f08ef70f1db16a1971822d41a047a1cc43bb7ce Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 18 May 2018 09:52:09 +0200 Subject: [PATCH 0371/1150] Fix of extraneous infill over thin walls. Fixes https://github.com/prusa3d/Slic3r/issues/670 and some of https://github.com/prusa3d/Slic3r/issues/895 PerimeterGenerator was using an unsafe clipper offset function, which performed offset for both a contour and its holes together. With this commit the offsets were replaced with their safe counterparts, though these safe counterparts may be somehow slower (performing offset on ExPolygon or ExPolygons, piece by piece). Also there was a bug, where if the infill & gap fill consumed everything of the polygon, a polygon one onion shell above was still used for infill. --- xs/src/libslic3r/ClipperUtils.cpp | 29 ++- xs/src/libslic3r/ClipperUtils.hpp | 3 + xs/src/libslic3r/ExPolygon.cpp | 30 +-- xs/src/libslic3r/PerimeterGenerator.cpp | 277 +++++++++--------------- 4 files changed, 138 insertions(+), 201 deletions(-) diff --git a/xs/src/libslic3r/ClipperUtils.cpp b/xs/src/libslic3r/ClipperUtils.cpp index 86123b23c3..31a12aa77a 100644 --- a/xs/src/libslic3r/ClipperUtils.cpp +++ b/xs/src/libslic3r/ClipperUtils.cpp @@ -458,6 +458,19 @@ offset2_ex(const Polygons &polygons, const float delta1, const float delta2, return ClipperPaths_to_Slic3rExPolygons(output); } +//FIXME Vojtech: This functon may likely be optimized to avoid some of the Slic3r to Clipper +// conversions and unnecessary Clipper calls. +ExPolygons offset2_ex(const ExPolygons &expolygons, const float delta1, + const float delta2, ClipperLib::JoinType joinType, double miterLimit) +{ + Polygons polys; + for (const ExPolygon &expoly : expolygons) + append(polys, + offset(offset_ex(expoly, delta1, joinType, miterLimit), + delta2, joinType, miterLimit)); + return union_ex(polys); +} + template T _clipper_do(const ClipperLib::ClipType clipType, const Polygons &subject, @@ -650,8 +663,7 @@ union_pt_chained(const Polygons &subject, bool safety_offset_) return retval; } -void -traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval) +void traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval) { /* use a nearest neighbor search to order these children TODO: supply start_near to chained_path() too? */ @@ -677,8 +689,7 @@ traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval) } } -Polygons -simplify_polygons(const Polygons &subject, bool preserve_collinear) +Polygons simplify_polygons(const Polygons &subject, bool preserve_collinear) { // convert into Clipper polygons ClipperLib::Paths input_subject = Slic3rMultiPoints_to_ClipperPaths(subject); @@ -698,13 +709,11 @@ simplify_polygons(const Polygons &subject, bool preserve_collinear) return ClipperPaths_to_Slic3rPolygons(output); } -ExPolygons -simplify_polygons_ex(const Polygons &subject, bool preserve_collinear) +ExPolygons simplify_polygons_ex(const Polygons &subject, bool preserve_collinear) { - if (!preserve_collinear) { - return union_ex(simplify_polygons(subject, preserve_collinear)); - } - + if (! preserve_collinear) + return union_ex(simplify_polygons(subject, false)); + // convert into Clipper polygons ClipperLib::Paths input_subject = Slic3rMultiPoints_to_ClipperPaths(subject); diff --git a/xs/src/libslic3r/ClipperUtils.hpp b/xs/src/libslic3r/ClipperUtils.hpp index eb83c31a34..b065cfe07b 100644 --- a/xs/src/libslic3r/ClipperUtils.hpp +++ b/xs/src/libslic3r/ClipperUtils.hpp @@ -80,6 +80,9 @@ Slic3r::Polygons offset2(const Slic3r::Polygons &polygons, const float delta1, Slic3r::ExPolygons offset2_ex(const Slic3r::Polygons &polygons, const float delta1, const float delta2, ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3); +Slic3r::ExPolygons offset2_ex(const Slic3r::ExPolygons &expolygons, const float delta1, + const float delta2, ClipperLib::JoinType joinType = ClipperLib::jtMiter, + double miterLimit = 3); Slic3r::Polygons _clipper(ClipperLib::ClipType clipType, const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, bool safety_offset_ = false); diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp index 1d4bac50b1..cd57fd7b0d 100644 --- a/xs/src/libslic3r/ExPolygon.cpp +++ b/xs/src/libslic3r/ExPolygon.cpp @@ -168,52 +168,42 @@ ExPolygon::overlaps(const ExPolygon &other) const return ! other.contour.points.empty() && this->contains_b(other.contour.points.front()); } -void -ExPolygon::simplify_p(double tolerance, Polygons* polygons) const +void ExPolygon::simplify_p(double tolerance, Polygons* polygons) const { Polygons pp = this->simplify_p(tolerance); polygons->insert(polygons->end(), pp.begin(), pp.end()); } -Polygons -ExPolygon::simplify_p(double tolerance) const +Polygons ExPolygon::simplify_p(double tolerance) const { Polygons pp; pp.reserve(this->holes.size() + 1); - // contour { Polygon p = this->contour; p.points.push_back(p.points.front()); p.points = MultiPoint::_douglas_peucker(p.points, tolerance); p.points.pop_back(); - pp.push_back(p); + pp.emplace_back(std::move(p)); } - // holes - for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) { - Polygon p = *it; + for (Polygon p : this->holes) { p.points.push_back(p.points.front()); p.points = MultiPoint::_douglas_peucker(p.points, tolerance); p.points.pop_back(); - pp.push_back(p); + pp.emplace_back(std::move(p)); } - pp = simplify_polygons(pp); - return pp; + return simplify_polygons(pp); } -ExPolygons -ExPolygon::simplify(double tolerance) const +ExPolygons ExPolygon::simplify(double tolerance) const { - Polygons pp = this->simplify_p(tolerance); - return union_ex(pp); + return union_ex(this->simplify_p(tolerance)); } -void -ExPolygon::simplify(double tolerance, ExPolygons* expolygons) const +void ExPolygon::simplify(double tolerance, ExPolygons* expolygons) const { - ExPolygons ep = this->simplify(tolerance); - expolygons->insert(expolygons->end(), ep.begin(), ep.end()); + append(*expolygons, this->simplify(tolerance)); } void diff --git a/xs/src/libslic3r/PerimeterGenerator.cpp b/xs/src/libslic3r/PerimeterGenerator.cpp index ea9c73fa4f..c2284aad4d 100644 --- a/xs/src/libslic3r/PerimeterGenerator.cpp +++ b/xs/src/libslic3r/PerimeterGenerator.cpp @@ -6,8 +6,7 @@ namespace Slic3r { -void -PerimeterGenerator::process() +void PerimeterGenerator::process() { // other perimeters this->_mm3_per_mm = this->perimeter_flow.mm3_per_mm(); @@ -45,7 +44,6 @@ PerimeterGenerator::process() // lower layer, so we take lower slices and offset them by half the nozzle diameter used // in the current layer double nozzle_diameter = this->print_config->nozzle_diameter.get_at(this->config->perimeter_extruder-1); - this->_lower_slices_p = offset(*this->lower_slices, float(scale_(+nozzle_diameter/2))); } @@ -53,149 +51,115 @@ PerimeterGenerator::process() // extra perimeters for each one for (const Surface &surface : this->slices->surfaces) { // detect how many perimeters must be generated for this island - const int loop_number = this->config->perimeters + surface.extra_perimeters -1; // 0-indexed loops - - Polygons gaps; - - Polygons last = surface.expolygon.simplify_p(SCALED_RESOLUTION); - if (loop_number >= 0) { // no loops = -1 - + int loop_number = this->config->perimeters + surface.extra_perimeters - 1; // 0-indexed loops + ExPolygons last = union_ex(surface.expolygon.simplify_p(SCALED_RESOLUTION)); + ExPolygons gaps; + if (loop_number >= 0) { + // In case no perimeters are to be generated, loop_number will equal to -1. std::vector contours(loop_number+1); // depth => loops std::vector holes(loop_number+1); // depth => loops ThickPolylines thin_walls; - // we loop one time more than needed in order to find gaps after the last perimeter was applied - for (int i = 0; i <= loop_number+1; ++i) { // outer loop is 0 - Polygons offsets; + for (int i = 0;; ++ i) { // outer loop is 0 + // Calculate next onion shell of perimeters. + ExPolygons offsets; if (i == 0) { // the minimum thickness of a single loop is: // ext_width/2 + ext_spacing/2 + spacing/2 + width/2 - if (this->config->thin_walls) { - offsets = offset2( + offsets = this->config->thin_walls ? + offset2_ex( last, -(ext_perimeter_width / 2 + ext_min_spacing / 2 - 1), - +(ext_min_spacing/2 - 1) - ); - } else { - offsets = offset(last, - ext_perimeter_width / 2); - } - + +(ext_min_spacing / 2 - 1)) : + offset_ex(last, - ext_perimeter_width / 2); // look for thin walls if (this->config->thin_walls) { - Polygons diffpp = diff( - last, - offset(offsets, ext_perimeter_width / 2), - true // medial axis requires non-overlapping geometry - ); - // the following offset2 ensures almost nothing in @thin_walls is narrower than $min_width // (actually, something larger than that still may exist due to mitering or other causes) coord_t min_width = scale_(this->ext_perimeter_flow.nozzle_diameter / 3); - ExPolygons expp = offset2_ex(diffpp, -min_width/2, +min_width/2); - + ExPolygons expp = offset2_ex( + // medial axis requires non-overlapping geometry + diff_ex(to_polygons(last), + offset(offsets, ext_perimeter_width / 2), + true), + - min_width / 2, min_width / 2); // the maximum thickness of our thin wall area is equal to the minimum thickness of a single loop - for (ExPolygons::const_iterator ex = expp.begin(); ex != expp.end(); ++ex) - ex->medial_axis(ext_perimeter_width + ext_perimeter_spacing2, min_width, &thin_walls); - - #ifdef DEBUG - printf(" " PRINTF_ZU " thin walls detected\n", thin_walls.size()); - #endif - - /* - if (false) { - require "Slic3r/SVG.pm"; - Slic3r::SVG::output( - "medial_axis.svg", - no_arrows => 1, - #expolygons => \@expp, - polylines => \@thin_walls, - ); - } - */ + for (ExPolygon &ex : expp) + ex.medial_axis(ext_perimeter_width + ext_perimeter_spacing2, min_width, &thin_walls); } } else { //FIXME Is this offset correct if the line width of the inner perimeters differs // from the line width of the infill? coord_t distance = (i == 1) ? ext_perimeter_spacing2 : perimeter_spacing; - - if (this->config->thin_walls) { + offsets = this->config->thin_walls ? // This path will ensure, that the perimeters do not overfill, as in // prusa3d/Slic3r GH #32, but with the cost of rounding the perimeters // excessively, creating gaps, which then need to be filled in by the not very // reliable gap fill algorithm. // Also the offset2(perimeter, -x, x) may sometimes lead to a perimeter, which is larger than // the original. - offsets = offset2( - last, - -(distance + min_spacing/2 - 1), - +(min_spacing/2 - 1) - ); - } else { + offset2_ex(last, + - (distance + min_spacing / 2 - 1), + min_spacing / 2 - 1) : // If "detect thin walls" is not enabled, this paths will be entered, which // leads to overflows, as in prusa3d/Slic3r GH #32 - offsets = offset( - last, - -distance - ); - } - + offset_ex(last, - distance); // look for gaps - if (this->config->gap_fill_speed.value > 0 && this->config->fill_density.value > 0) { + if (this->config->gap_fill_speed.value > 0 && this->config->fill_density.value > 0) // not using safety offset here would "detect" very narrow gaps // (but still long enough to escape the area threshold) that gap fill // won't be able to fill but we'd still remove from infill area - Polygons diff_pp = diff( - offset(last, -0.5*distance), - offset(offsets, +0.5*distance + 10) // safety offset - ); - gaps.insert(gaps.end(), diff_pp.begin(), diff_pp.end()); - } - } - - if (offsets.empty()) break; - if (i > loop_number) break; // we were only looking for gaps this time - - last = offsets; - for (Polygons::const_iterator polygon = offsets.begin(); polygon != offsets.end(); ++polygon) { - PerimeterGeneratorLoop loop(*polygon, i); - loop.is_contour = polygon->is_counter_clockwise(); - if (loop.is_contour) { - contours[i].push_back(loop); - } else { - holes[i].push_back(loop); + append(gaps, diff_ex( + offset(last, -0.5 * distance), + offset(offsets, 0.5 * distance + 10))); // safety offset + } + if (offsets.empty()) { + // Store the number of loops actually generated. + loop_number = i - 1; + // No region left to be filled in. + last.clear(); + break; + } else if (i > loop_number) { + // If i > loop_number, we were looking just for gaps. + break; + } + for (const ExPolygon &expolygon : offsets) { + contours[i].emplace_back(PerimeterGeneratorLoop(expolygon.contour, i, true)); + if (! expolygon.holes.empty()) { + holes[i].reserve(holes[i].size() + expolygon.holes.size()); + for (const Polygon &hole : expolygon.holes) + holes[i].emplace_back(PerimeterGeneratorLoop(hole, i, false)); } } + last = std::move(offsets); } - + // nest loops: holes first - for (int d = 0; d <= loop_number; ++d) { + for (int d = 0; d <= loop_number; ++ d) { PerimeterGeneratorLoops &holes_d = holes[d]; - // loop through all holes having depth == d - for (int i = 0; i < (int)holes_d.size(); ++i) { + for (int i = 0; i < (int)holes_d.size(); ++ i) { const PerimeterGeneratorLoop &loop = holes_d[i]; - // find the hole loop that contains this one, if any - for (int t = d+1; t <= loop_number; ++t) { - for (int j = 0; j < (int)holes[t].size(); ++j) { + for (int t = d + 1; t <= loop_number; ++ t) { + for (int j = 0; j < (int)holes[t].size(); ++ j) { PerimeterGeneratorLoop &candidate_parent = holes[t][j]; if (candidate_parent.polygon.contains(loop.polygon.first_point())) { candidate_parent.children.push_back(loop); holes_d.erase(holes_d.begin() + i); - --i; + -- i; goto NEXT_LOOP; } } } - // if no hole contains this hole, find the contour loop that contains it - for (int t = loop_number; t >= 0; --t) { - for (int j = 0; j < (int)contours[t].size(); ++j) { + for (int t = loop_number; t >= 0; -- t) { + for (int j = 0; j < (int)contours[t].size(); ++ j) { PerimeterGeneratorLoop &candidate_parent = contours[t][j]; if (candidate_parent.polygon.contains(loop.polygon.first_point())) { candidate_parent.children.push_back(loop); holes_d.erase(holes_d.begin() + i); - --i; + -- i; goto NEXT_LOOP; } } @@ -203,75 +167,57 @@ PerimeterGenerator::process() NEXT_LOOP: ; } } - // nest contour loops - for (int d = loop_number; d >= 1; --d) { + for (int d = loop_number; d >= 1; -- d) { PerimeterGeneratorLoops &contours_d = contours[d]; - // loop through all contours having depth == d - for (int i = 0; i < (int)contours_d.size(); ++i) { + for (int i = 0; i < (int)contours_d.size(); ++ i) { const PerimeterGeneratorLoop &loop = contours_d[i]; - // find the contour loop that contains it - for (int t = d-1; t >= 0; --t) { - for (int j = 0; j < contours[t].size(); ++j) { + for (int t = d - 1; t >= 0; -- t) { + for (int j = 0; j < contours[t].size(); ++ j) { PerimeterGeneratorLoop &candidate_parent = contours[t][j]; if (candidate_parent.polygon.contains(loop.polygon.first_point())) { candidate_parent.children.push_back(loop); contours_d.erase(contours_d.begin() + i); - --i; + -- i; goto NEXT_CONTOUR; } } } - NEXT_CONTOUR: ; } } - // at this point, all loops should be in contours[0] - ExtrusionEntityCollection entities = this->_traverse_loops(contours.front(), thin_walls); - // if brim will be printed, reverse the order of perimeters so that // we continue inwards after having finished the brim // TODO: add test for perimeter order - if (this->config->external_perimeters_first - || (this->layer_id == 0 && this->print_config->brim_width.value > 0)) - entities.reverse(); - + if (this->config->external_perimeters_first || + (this->layer_id == 0 && this->print_config->brim_width.value > 0)) + entities.reverse(); // append perimeters for this slice as a collection - if (!entities.empty()) + if (! entities.empty()) this->loops->append(entities); } // for each loop of an island // fill gaps - if (!gaps.empty()) { - /* - SVG svg("gaps.svg"); - svg.draw(union_ex(gaps)); - svg.Close(); - */ - + if (! gaps.empty()) { // collapse double min = 0.2 * perimeter_width * (1 - INSET_OVERLAP_TOLERANCE); double max = 2. * perimeter_spacing; ExPolygons gaps_ex = diff_ex( - offset2(gaps, -min/2, +min/2), - offset2(gaps, -max/2, +max/2), - true - ); - + //FIXME offset2 would be enough and cheaper. + offset2_ex(gaps, -min/2, +min/2), + offset2_ex(gaps, -max/2, +max/2), + true); ThickPolylines polylines; - for (ExPolygons::const_iterator ex = gaps_ex.begin(); ex != gaps_ex.end(); ++ex) - ex->medial_axis(max, min, &polylines); - - if (!polylines.empty()) { + for (const ExPolygon &ex : gaps_ex) + ex.medial_axis(max, min, &polylines); + if (! polylines.empty()) { ExtrusionEntityCollection gap_fill = this->_variable_width(polylines, erGapFill, this->solid_infill_flow); - this->gap_fill->append(gap_fill.entities); - /* Make sure we don't infill narrow parts that are already gap-filled (we only consider this surface's gaps to reduce the diff() complexity). Growing actual extrusions ensures that gaps not filled by medial axis @@ -280,7 +226,7 @@ PerimeterGenerator::process() and use zigzag). */ //FIXME Vojtech: This grows by a rounded extrusion width, not by line spacing, // therefore it may cover the area, but no the volume. - last = diff(last, gap_fill.polygons_covered_by_width(10.f)); + last = diff_ex(to_polygons(last), gap_fill.polygons_covered_by_width(10.f)); } } @@ -288,36 +234,34 @@ PerimeterGenerator::process() // we offset by half the perimeter spacing (to get to the actual infill boundary) // and then we offset back and forth by half the infill spacing to only consider the // non-collapsing regions - coord_t inset = 0; - if (loop_number == 0) { - // one loop - inset += ext_perimeter_spacing / 2; - } else if (loop_number > 0) { - // two or more loops - inset += perimeter_spacing / 2; - } + coord_t inset = + (loop_number < 0) ? 0 : + (loop_number == 0) ? + // one loop + ext_perimeter_spacing / 2 : + // two or more loops? + perimeter_spacing / 2; // only apply infill overlap if we actually have one perimeter if (inset > 0) inset -= this->config->get_abs_value("infill_overlap", inset + solid_infill_spacing / 2); // simplify infill contours according to resolution Polygons pp; - for (ExPolygon &ex : union_ex(last)) + for (ExPolygon &ex : last) ex.simplify_p(SCALED_RESOLUTION, &pp); // collapse too narrow infill areas - coord_t min_perimeter_infill_spacing = solid_infill_spacing * (1 - INSET_OVERLAP_TOLERANCE); + coord_t min_perimeter_infill_spacing = solid_infill_spacing * (1. - INSET_OVERLAP_TOLERANCE); // append infill areas to fill_surfaces this->fill_surfaces->append( offset2_ex( - pp, - -inset -min_perimeter_infill_spacing/2, - +min_perimeter_infill_spacing/2), + union_ex(pp), + - inset - min_perimeter_infill_spacing / 2, + min_perimeter_infill_spacing / 2), stInternal); } // for each island } -ExtrusionEntityCollection -PerimeterGenerator::_traverse_loops(const PerimeterGeneratorLoops &loops, - ThickPolylines &thin_walls) const +ExtrusionEntityCollection PerimeterGenerator::_traverse_loops( + const PerimeterGeneratorLoops &loops, ThickPolylines &thin_walls) const { // loops is an arrayref of ::Loop objects // turn each one into an ExtrusionLoop object @@ -422,8 +366,7 @@ PerimeterGenerator::_traverse_loops(const PerimeterGeneratorLoops &loops, return entities; } -ExtrusionEntityCollection -PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow) const +ExtrusionEntityCollection PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow) const { // this value determines granularity of adaptive width, as G-code does not allow // variable extrusion within a single move; this value shall only affect the amount @@ -431,10 +374,10 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo const double tolerance = scale_(0.05); ExtrusionEntityCollection coll; - for (ThickPolylines::const_iterator p = polylines.begin(); p != polylines.end(); ++p) { + for (const ThickPolyline &p : polylines) { ExtrusionPaths paths; ExtrusionPath path(role); - ThickLines lines = p->thicklines(); + ThickLines lines = p.thicklines(); for (int i = 0; i < (int)lines.size(); ++i) { const ThickLine& line = lines[i]; @@ -474,12 +417,11 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo lines.insert(lines.begin() + i + j, new_line); } - --i; + -- i; continue; } const double w = fmax(line.a_width, line.b_width); - if (path.polyline.points.empty()) { path.polyline.append(line.a); path.polyline.append(line.b); @@ -497,21 +439,19 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo if (thickness_delta <= tolerance) { // the width difference between this line and the current flow width is // within the accepted tolerance - path.polyline.append(line.b); } else { // we need to initialize a new line - paths.push_back(path); + paths.emplace_back(std::move(path)); path = ExtrusionPath(role); - --i; + -- i; } } } if (path.polyline.is_valid()) - paths.push_back(path); - - // append paths to collection - if (!paths.empty()) { + paths.emplace_back(std::move(path)); + // Append paths to collection. + if (! paths.empty()) { if (paths.front().first_point().coincides_with(paths.back().last_point())) coll.append(ExtrusionLoop(paths)); else @@ -522,20 +462,15 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo return coll; } -bool -PerimeterGeneratorLoop::is_internal_contour() const +bool PerimeterGeneratorLoop::is_internal_contour() const { - if (this->is_contour) { - // an internal contour is a contour containing no other contours - for (std::vector::const_iterator loop = this->children.begin(); - loop != this->children.end(); ++loop) { - if (loop->is_contour) { - return false; - } - } - return true; - } - return false; + // An internal contour is a contour containing no other contours + if (! this->is_contour) + return false; + for (const PerimeterGeneratorLoop &loop : this->children) + if (loop.is_contour) + return false; + return true; } } From 0584990b65ccc9304c3511f30f3ceb44331f2f91 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 18 May 2018 10:14:47 +0200 Subject: [PATCH 0372/1150] Fixed z layers indices under 3D preview sliders --- lib/Slic3r/GUI/3DScene.pm | 6 ++---- lib/Slic3r/GUI/Plater/3DPreview.pm | 21 ++++++++++++++++----- xs/src/slic3r/GUI/3DScene.cpp | 4 ++-- xs/src/slic3r/GUI/3DScene.hpp | 2 +- xs/xsp/GUI_3DScene.xsp | 5 ++--- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 3bfb6f7597..33c0e8d37b 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -2192,10 +2192,8 @@ sub reset_legend_texture { } sub get_current_print_zs { - my ($self) = @_; - - my $count = $self->volumes->get_current_print_zs(); - return $count; + my ($self, $active_only) = @_; + return $self->volumes->get_current_print_zs($active_only); } 1; diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index fec463682b..de6c6e8180 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -380,7 +380,7 @@ sub load_print { $self->show_hide_ui_elements('full'); # recalculates zs and update sliders accordingly - $self->{layers_z} = $self->canvas->get_current_print_zs(); + $self->{layers_z} = $self->canvas->get_current_print_zs(1); $n_layers = scalar(@{$self->{layers_z}}); if ($n_layers == 0) { # all layers filtered out @@ -465,10 +465,21 @@ sub set_z_range $self->{z_high} = $z_high; $self->{z_label_low}->SetLabel(sprintf '%.2f', $z_low); $self->{z_label_high}->SetLabel(sprintf '%.2f', $z_high); - my $z_idx_low = 1 + $self->slider_low->GetValue; - my $z_idx_high = 1 + $self->slider_high->GetValue; - $self->{z_label_low_idx}->SetLabel(sprintf '%d', $z_idx_low); - $self->{z_label_high_idx}->SetLabel(sprintf '%d', $z_idx_high); + + my $layers_z = $self->canvas->get_current_print_zs(0); + for (my $i = 0; $i < scalar(@{$layers_z}); $i += 1) { + if (($z_low - 1e-6 < @{$layers_z}[$i]) && (@{$layers_z}[$i] < $z_low + 1e-6)) { + $self->{z_label_low_idx}->SetLabel(sprintf '%d', $i + 1); + last; + } + } + for (my $i = 0; $i < scalar(@{$layers_z}); $i += 1) { + if (($z_high - 1e-6 < @{$layers_z}[$i]) && (@{$layers_z}[$i] < $z_high + 1e-6)) { + $self->{z_label_high_idx}->SetLabel(sprintf '%d', $i + 1); + last; + } + } + $self->canvas->set_toolpaths_range($z_low - 1e-6, $z_high + 1e-6); $self->canvas->Refresh if $self->IsShown; } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 0ead76b885..db1737e149 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -760,13 +760,13 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con } } -std::vector GLVolumeCollection::get_current_print_zs() const +std::vector GLVolumeCollection::get_current_print_zs(bool active_only) const { // Collect layer top positions of all volumes. std::vector print_zs; for (GLVolume *vol : this->volumes) { - if (vol->is_active) + if (!active_only || vol->is_active) append(print_zs, vol->print_zs); } std::sort(print_zs.begin(), print_zs.end()); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index fb5d9f14b2..a417f5f9df 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -428,7 +428,7 @@ public: void update_colors_by_extruder(const DynamicPrintConfig* config); // Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection - std::vector get_current_print_zs() const; + std::vector get_current_print_zs(bool active_only) const; private: GLVolumeCollection(const GLVolumeCollection &other); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index ee5a82ba1f..6a907291e2 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -92,10 +92,9 @@ int count() %code{% RETVAL = THIS->volumes.size(); %}; - std::vector get_current_print_zs() - %code{% RETVAL = THIS->get_current_print_zs(); %}; + std::vector 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; From 1e0a8de5b162bac0e79a8a5b595cd253a045205d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 18 May 2018 11:05:48 +0200 Subject: [PATCH 0373/1150] 3DScene cutting plane moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 92 +++++++++++++------------ xs/src/slic3r/GUI/3DScene.cpp | 14 +++- xs/src/slic3r/GUI/3DScene.hpp | 5 +- xs/src/slic3r/GUI/GLCanvas3D.cpp | 79 +++++++++++++++++++-- xs/src/slic3r/GUI/GLCanvas3D.hpp | 21 +++++- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 18 ++++- xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 7 +- xs/xsp/GUI_3DScene.xsp | 18 ++++- 8 files changed, 196 insertions(+), 58 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index a654f6554f..e2fdcaacaa 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -46,8 +46,6 @@ __PACKAGE__->mk_accessors( qw(_quat init on_move on_model_update volumes - cutting_plane_z - cut_lines_vertices background _mouse_pos _hover_volume_idx @@ -1071,19 +1069,23 @@ sub select_volume { sub SetCuttingPlane { my ($self, $z, $expolygons) = @_; - $self->cutting_plane_z($z); - - # grow slices in order to display them better - $expolygons = offset_ex([ map @$_, @$expolygons ], scale 0.1); - - my @verts = (); - foreach my $line (map @{$_->lines}, map @$_, @$expolygons) { - push @verts, ( - unscale($line->a->x), unscale($line->a->y), $z, #)) - unscale($line->b->x), unscale($line->b->y), $z, #)) - ); - } - $self->cut_lines_vertices(OpenGL::Array->new_list(GL_FLOAT, @verts)); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_cutting_plane($self, $z, $expolygons); + +# $self->cutting_plane_z($z); +# +# # grow slices in order to display them better +# $expolygons = offset_ex([ map @$_, @$expolygons ], scale 0.1); +# +# my @verts = (); +# foreach my $line (map @{$_->lines}, map @$_, @$expolygons) { +# push @verts, ( +# unscale($line->a->x), unscale($line->a->y), $z, #)) +# unscale($line->b->x), unscale($line->b->y), $z, #)) +# ); +# } +# $self->cut_lines_vertices(OpenGL::Array->new_list(GL_FLOAT, @verts)); +#============================================================================================================================== } # Given an axis and angle, compute quaternion. @@ -1516,7 +1518,7 @@ sub Render { # draw ground my $ground_z = GROUND_Z; #============================================================================================================================== - Slic3r::GUI::_3DScene::render($self); + Slic3r::GUI::_3DScene::render_bed($self); # if ($self->bed_triangles) { # glDisable(GL_DEPTH_TEST); @@ -1603,33 +1605,37 @@ sub Render { glEnable(GL_CULL_FACE) if ($self->enable_picking); } - if (defined $self->cutting_plane_z) { - # draw cutting plane - my $plane_z = $self->cutting_plane_z; - my $bb = $volumes_bb; - glDisable(GL_CULL_FACE); - glDisable(GL_LIGHTING); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBegin(GL_QUADS); - glColor4f(0.8, 0.8, 0.8, 0.5); - glVertex3f($bb->x_min-20, $bb->y_min-20, $plane_z); - glVertex3f($bb->x_max+20, $bb->y_min-20, $plane_z); - glVertex3f($bb->x_max+20, $bb->y_max+20, $plane_z); - glVertex3f($bb->x_min-20, $bb->y_max+20, $plane_z); - glEnd(); - glEnable(GL_CULL_FACE); - glDisable(GL_BLEND); - - # draw cutting contours - glEnableClientState(GL_VERTEX_ARRAY); - glLineWidth(2); - glColor3f(0, 0, 0); - glVertexPointer_c(3, GL_FLOAT, 0, $self->cut_lines_vertices->ptr()); - glDrawArrays(GL_LINES, 0, $self->cut_lines_vertices->elements / 3); - glVertexPointer_c(3, GL_FLOAT, 0, 0); - glDisableClientState(GL_VERTEX_ARRAY); - } +#============================================================================================================================== + Slic3r::GUI::_3DScene::render_cutting_plane($self); + +# if (defined $self->cutting_plane_z) { +# # draw cutting plane +# my $plane_z = $self->cutting_plane_z; +# my $bb = $volumes_bb; +# glDisable(GL_CULL_FACE); +# glDisable(GL_LIGHTING); +# glEnable(GL_BLEND); +# glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +# glBegin(GL_QUADS); +# glColor4f(0.8, 0.8, 0.8, 0.5); +# glVertex3f($bb->x_min-20, $bb->y_min-20, $plane_z); +# glVertex3f($bb->x_max+20, $bb->y_min-20, $plane_z); +# glVertex3f($bb->x_max+20, $bb->y_max+20, $plane_z); +# glVertex3f($bb->x_min-20, $bb->y_max+20, $plane_z); +# glEnd(); +# glEnable(GL_CULL_FACE); +# glDisable(GL_BLEND); +# +# # draw cutting contours +# glEnableClientState(GL_VERTEX_ARRAY); +# glLineWidth(2); +# glColor3f(0, 0, 0); +# glVertexPointer_c(3, GL_FLOAT, 0, $self->cut_lines_vertices->ptr()); +# glDrawArrays(GL_LINES, 0, $self->cut_lines_vertices->elements / 3); +# glVertexPointer_c(3, GL_FLOAT, 0, 0); +# glDisableClientState(GL_VERTEX_ARRAY); +# } +#============================================================================================================================== # draw warning message $self->draw_warning; diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index d2e778ac61..9babd8bc61 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1808,6 +1808,11 @@ BoundingBoxf3 _3DScene::get_max_bounding_box(wxGLCanvas* canvas) return s_canvas_mgr.get_max_bounding_box(canvas); } +void _3DScene::set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons) +{ + return s_canvas_mgr.set_cutting_plane(canvas, z, polygons); +} + unsigned int _3DScene::get_camera_type(wxGLCanvas* canvas) { return s_canvas_mgr.get_camera_type(canvas); @@ -1888,9 +1893,14 @@ void _3DScene::select_view(wxGLCanvas* canvas, const std::string& direction) s_canvas_mgr.select_view(canvas, direction); } -void _3DScene::render(wxGLCanvas* canvas) +void _3DScene::render_bed(wxGLCanvas* canvas) { - s_canvas_mgr.render(canvas); + s_canvas_mgr.render_bed(canvas); +} + +void _3DScene::render_cutting_plane(wxGLCanvas* canvas) +{ + s_canvas_mgr.render_cutting_plane(canvas); } void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 8d6345f971..eb03a53137 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -562,6 +562,8 @@ public: static BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas); static BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); + static void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons); + static unsigned int get_camera_type(wxGLCanvas* canvas); static void set_camera_type(wxGLCanvas* canvas, unsigned int type); static std::string get_camera_type_as_string(wxGLCanvas* canvas); @@ -585,7 +587,8 @@ public: static void zoom_to_volumes(wxGLCanvas* canvas); static void select_view(wxGLCanvas* canvas, const std::string& direction); - static void render(wxGLCanvas* canvas); + static void render_bed(wxGLCanvas* canvas); + static void render_cutting_plane(wxGLCanvas* canvas); static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 4a5a97c95e..9631f7996b 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -230,8 +230,7 @@ void GLCanvas3D::Bed::render() ::glColor4f(0.8f, 0.6f, 0.5f, 0.4f); ::glNormal3d(0.0f, 0.0f, 1.0f); ::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_triangles.get_data()); - ::glDrawArrays(GL_TRIANGLES, 0, triangles_vcount); -// ::glDisableClientState(GL_VERTEX_ARRAY); + ::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount); // we need depth test for grid, otherwise it would disappear when looking // the object from below @@ -242,9 +241,8 @@ void GLCanvas3D::Bed::render() ::glLineWidth(3.0f); ::glColor4f(0.2f, 0.2f, 0.2f, 0.4f); -// ::glEnableClientState(GL_VERTEX_ARRAY); ::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_gridlines.get_data()); - ::glDrawArrays(GL_LINES, 0, gridlines_vcount); + ::glDrawArrays(GL_LINES, 0, (GLsizei)gridlines_vcount); ::glDisableClientState(GL_VERTEX_ARRAY); @@ -299,6 +297,66 @@ void GLCanvas3D::Bed::_calc_gridlines(const ExPolygon& poly, const BoundingBox& printf("Unable to create bed grid lines\n"); } +GLCanvas3D::CuttingPlane::CuttingPlane() + : m_z(-1.0f) +{ +} + +bool GLCanvas3D::CuttingPlane::set(float z, const ExPolygons& polygons) +{ + m_z = z; + + // grow slices in order to display them better + ExPolygons expolygons = offset_ex(polygons, scale_(0.1)); + Lines lines = to_lines(expolygons); + return m_lines.set_from_lines(lines, m_z); +} + +void GLCanvas3D::CuttingPlane::render_plane(const BoundingBoxf3& bb) +{ + if (m_z >= 0.0f) + { + ::glDisable(GL_CULL_FACE); + ::glDisable(GL_LIGHTING); + ::glEnable(GL_BLEND); + ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + float margin = 20.0f; + float min_x = bb.min.x - margin; + float max_x = bb.max.x + margin; + float min_y = bb.min.y - margin; + float max_y = bb.max.y + margin; + + ::glBegin(GL_QUADS); + ::glColor4f(0.8f, 0.8f, 0.8f, 0.5f); + ::glVertex3f(min_x, min_y, m_z); + ::glVertex3f(max_x, min_y, m_z); + ::glVertex3f(max_x, max_y, m_z); + ::glVertex3f(min_x, max_y, m_z); + ::glEnd(); + + ::glEnable(GL_CULL_FACE); + ::glDisable(GL_BLEND); + } +} + +void GLCanvas3D::CuttingPlane::render_contour() +{ + ::glEnableClientState(GL_VERTEX_ARRAY); + + if (m_z >= 0.0f) + { + unsigned int lines_vcount = m_lines.get_data_size() / 3; + + ::glLineWidth(2.0f); + ::glColor3f(0.0f, 0.0f, 0.0f); + ::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_lines.get_data()); + ::glDrawArrays(GL_LINES, 0, (GLsizei)lines_vcount); + } + + ::glDisableClientState(GL_VERTEX_ARRAY); +} + GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) : m_canvas(canvas) , m_context(context) @@ -446,6 +504,11 @@ void GLCanvas3D::set_bed_origin(const Pointf& origin) m_bed.set_origin(origin); } +void GLCanvas3D::set_cutting_plane(float z, const ExPolygons& polygons) +{ + m_cutting_plane.set(z, polygons); +} + GLCanvas3D::Camera::EType GLCanvas3D::get_camera_type() const { return m_camera.get_type(); @@ -580,11 +643,17 @@ void GLCanvas3D::select_view(const std::string& direction) } } -void GLCanvas3D::render() +void GLCanvas3D::render_bed() { m_bed.render(); } +void GLCanvas3D::render_cutting_plane() +{ + m_cutting_plane.render_plane(volumes_bounding_box()); + m_cutting_plane.render_contour(); +} + void GLCanvas3D::register_on_viewport_changed_callback(void* callback) { if (callback != nullptr) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 507964136e..a7e9dbfb00 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -3,6 +3,7 @@ #include "../../libslic3r/BoundingBox.hpp" #include "../../libslic3r/Utils.hpp" +#include "../../libslic3r/ExPolygon.hpp" class wxGLCanvas; class wxGLContext; @@ -100,11 +101,26 @@ public: void _calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); }; + class CuttingPlane + { + float m_z; + GeometryBuffer m_lines; + + public: + CuttingPlane(); + + bool set(float z, const ExPolygons& polygons); + + void render_plane(const BoundingBoxf3& bb); + void render_contour(); + }; + private: wxGLCanvas* m_canvas; wxGLContext* m_context; Camera m_camera; Bed m_bed; + CuttingPlane m_cutting_plane; GLVolumeCollection* m_volumes; @@ -140,6 +156,8 @@ public: const Pointf& get_bed_origin() const; void set_bed_origin(const Pointf& origin); + void set_cutting_plane(float z, const ExPolygons& polygons); + Camera::EType get_camera_type() const; void set_camera_type(Camera::EType type); std::string get_camera_type_as_string() const; @@ -167,7 +185,8 @@ public: void zoom_to_volumes(); void select_view(const std::string& direction); - void render(); + void render_bed(); + void render_cutting_plane(); void register_on_viewport_changed_callback(void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 61867c61ca..911fb2f0ef 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -232,6 +232,13 @@ BoundingBoxf3 GLCanvas3DManager::get_max_bounding_box(wxGLCanvas* canvas) return (it != m_canvases.end()) ? it->second->max_bounding_box() : BoundingBoxf3(); } +void GLCanvas3DManager::set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_cutting_plane(z, polygons); +} + unsigned int GLCanvas3DManager::get_camera_type(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); @@ -343,11 +350,18 @@ void GLCanvas3DManager::select_view(wxGLCanvas* canvas, const std::string& direc it->second->select_view(direction); } -void GLCanvas3DManager::render(wxGLCanvas* canvas) +void GLCanvas3DManager::render_bed(wxGLCanvas* canvas) { CanvasesMap::iterator it = _get_canvas(canvas); if (it != m_canvases.end()) - it->second->render(); + it->second->render_bed(); +} + +void GLCanvas3DManager::render_cutting_plane(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->render_cutting_plane(); } void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index bf0b9c0668..4d8066597c 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -1,7 +1,7 @@ #ifndef slic3r_GLCanvas3DManager_hpp_ #define slic3r_GLCanvas3DManager_hpp_ -#include "GLCanvas3D.hpp" +#include "../../slic3r/GUI/GLCanvas3D.hpp" #include @@ -72,6 +72,8 @@ public: BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas); BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); + void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons); + unsigned int get_camera_type(wxGLCanvas* canvas) const; void set_camera_type(wxGLCanvas* canvas, unsigned int type); std::string get_camera_type_as_string(wxGLCanvas* canvas) const; @@ -95,7 +97,8 @@ public: void zoom_to_volumes(wxGLCanvas* canvas); void select_view(wxGLCanvas* canvas, const std::string& direction); - void render(wxGLCanvas* canvas); + void render_bed(wxGLCanvas* canvas); + void render_cutting_plane(wxGLCanvas* canvas); void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index c62c7e9581..2efe8f11b6 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -283,6 +283,14 @@ is_shown_on_screen(canvas) OUTPUT: RETVAL +void +set_cutting_plane(canvas, z, polygons) + SV *canvas; + float z; + ExPolygons polygons; + CODE: + _3DScene::set_cutting_plane((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), z, polygons); + unsigned int get_camera_type(canvas) SV *canvas; @@ -401,10 +409,16 @@ select_view(canvas, direction) _3DScene::select_view((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), direction); void -render(canvas) +render_bed(canvas) SV *canvas; CODE: - _3DScene::render((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + _3DScene::render_bed((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + +void +render_cutting_plane(canvas) + SV *canvas; + CODE: + _3DScene::render_cutting_plane((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); void register_on_viewport_changed_callback(canvas, callback) From 876cf9aa8bb89ce977d6d4a6463a783fcb79d079 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 18 May 2018 11:39:49 +0200 Subject: [PATCH 0374/1150] Show/hide warning icon according to the view mode --- lib/Slic3r/GUI/Plater.pm | 34 +++++++++++++++++++++++++--------- xs/src/slic3r/GUI/GUI.cpp | 12 +++++++++++- xs/src/slic3r/GUI/GUI.hpp | 5 ++++- xs/xsp/GUI.xsp | 9 +++++++-- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index ebb561a9e5..5a3c1bb9f1 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -442,7 +442,16 @@ sub new { $self->{"object_info_$field"}->SetFont($Slic3r::GUI::small_font); if ($field eq 'manifold') { $self->{object_info_manifold_warning_icon} = Wx::StaticBitmap->new($scrolled_window_panel, -1, Wx::Bitmap->new(Slic3r::var("error.png"), wxBITMAP_TYPE_PNG)); - $self->{object_info_manifold_warning_icon}->Hide; + #$self->{object_info_manifold_warning_icon}->Hide; + $self->{"object_info_manifold_warning_icon_show"} = sub { + if ($self->{object_info_manifold_warning_icon}->IsShown() != $_[0]) { + Slic3r::GUI::set_show_manifold_warning_icon($_[0]); + return if (wxTheApp->{app_config}->get("view_mode") eq "simple"); + $self->{object_info_manifold_warning_icon}->Show($_[0]); + $self->Layout + } + }; + $self->{"object_info_manifold_warning_icon_show"}->(0); my $h_sizer = Wx::BoxSizer->new(wxHORIZONTAL); $h_sizer->Add($self->{object_info_manifold_warning_icon}, 0); @@ -511,10 +520,7 @@ sub new { # } if ($scrolled_window_sizer->IsShown(2) != $_[0]) { Slic3r::GUI::set_show_print_info($_[0]); - my $mode = wxTheApp->{app_config}->get("view_mode"); - printf $mode."\n"; - return if ($mode eq "simple"); - print "non-simple\n"; + return if (wxTheApp->{app_config}->get("view_mode") eq "simple"); $scrolled_window_sizer->Show(2, $_[0]); $scrolled_window_panel->Layout } @@ -542,7 +548,8 @@ sub new { $self->{btn_export_stl}, $self->{btn_reslice}, $self->{btn_print}, - $self->{btn_send_gcode} ); + $self->{btn_send_gcode}, + $self->{object_info_manifold_warning_icon} ); } # Last correct selected item for each preset @@ -881,6 +888,9 @@ sub remove { $self->select_object(undef); $self->update; $self->schedule_background_process; + + # Hide the slicing results if the current slicing status is no more valid. + $self->{"print_info_box_show"}->(0); } sub reset { @@ -900,6 +910,9 @@ sub reset { $self->select_object(undef); $self->update; + + # Hide the slicing results if the current slicing status is no more valid. + $self->{"print_info_box_show"}->(0); } sub increase { @@ -2017,7 +2030,8 @@ sub selection_changed { $self->{object_info_facets}->SetLabel(sprintf(L('%d (%d shells)'), $model_object->facets_count, $stats->{number_of_parts})); if (my $errors = sum(@$stats{qw(degenerate_facets edges_fixed facets_removed facets_added facets_reversed backwards_edges)})) { $self->{object_info_manifold}->SetLabel(sprintf(L("Auto-repaired (%d errors)"), $errors)); - $self->{object_info_manifold_warning_icon}->Show; + #$self->{object_info_manifold_warning_icon}->Show; + $self->{"object_info_manifold_warning_icon_show"}->(1); # we don't show normals_fixed because we never provide normals # to admesh, so it generates normals for all facets @@ -2027,14 +2041,16 @@ sub selection_changed { $self->{object_info_manifold_warning_icon}->SetToolTipString($message); } else { $self->{object_info_manifold}->SetLabel(L("Yes")); - $self->{object_info_manifold_warning_icon}->Hide; + #$self->{object_info_manifold_warning_icon}->Hide; + $self->{"object_info_manifold_warning_icon_show"}->(0); } } else { $self->{object_info_facets}->SetLabel($object->facets); } } else { $self->{"object_info_$_"}->SetLabel("") for qw(size volume facets materials manifold); - $self->{object_info_manifold_warning_icon}->Hide; + #$self->{object_info_manifold_warning_icon}->Hide; + $self->{"object_info_manifold_warning_icon_show"}->(0); $self->{object_info_manifold}->SetToolTipString(""); } $self->Layout; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 09ede75beb..abdeb6c72e 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -210,7 +210,9 @@ wxButton *g_btn_export_stl = nullptr; wxButton *g_btn_reslice = nullptr; wxButton *g_btn_print = nullptr; wxButton *g_btn_send_gcode = nullptr; +wxStaticBitmap *g_manifold_warning_icon = nullptr; bool g_show_print_info = false; +bool g_show_manifold_warning_icon = false; static void init_label_colours() { @@ -274,7 +276,8 @@ void set_preset_updater(PresetUpdater *updater) void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_parameters_sizer, wxBoxSizer *expert_mode_part_sizer, wxBoxSizer *scrolled_window_sizer, wxButton *btn_export_stl, wxButton *btn_reslice, - wxButton *btn_print, wxButton *btn_send_gcode) + wxButton *btn_print, wxButton *btn_send_gcode, + wxStaticBitmap *manifold_warning_icon) { g_plater = parent; g_frequently_changed_parameters_sizer = frequently_changed_parameters_sizer; @@ -284,6 +287,7 @@ void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_par g_btn_reslice = btn_reslice; g_btn_print = btn_print; g_btn_send_gcode = btn_send_gcode; + g_manifold_warning_icon = manifold_warning_icon; } void set_show_print_info(bool show) @@ -291,6 +295,11 @@ void set_show_print_info(bool show) g_show_print_info = show; } +void set_show_manifold_warning_icon(bool show) +{ + g_show_manifold_warning_icon = show; +} + std::vector& get_tabs_list() { return g_tabs_list; @@ -1122,6 +1131,7 @@ void show_scrolled_window_sizer(bool show) g_scrolled_window_sizer->Show(static_cast(0), show); g_scrolled_window_sizer->Show(1, show); g_scrolled_window_sizer->Show(2, show && g_show_print_info); + g_manifold_warning_icon->Show(show && g_show_manifold_warning_icon); } void update_mode() diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 1cca993197..4fd8b800ab 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -20,6 +20,7 @@ class wxBoxSizer; class wxFlexGridSizer; class wxButton; class wxFileDialog; +class wxStaticBitmap; namespace Slic3r { @@ -86,8 +87,10 @@ void set_objects_from_perl( wxWindow* parent, wxButton *btn_export_stl, wxButton *btn_reslice, wxButton *btn_print, - wxButton *btn_send_gcode); + wxButton *btn_send_gcode, + wxStaticBitmap *manifold_warning_icon); void set_show_print_info(bool show); +void set_show_manifold_warning_icon(bool show); AppConfig* get_app_config(); wxApp* get_app(); diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index b402ab656e..6dcb4a6ab3 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -97,7 +97,8 @@ void set_objects_from_perl( SV *ui_parent, SV *btn_export_stl, SV *btn_reslice, SV *btn_print, - SV *btn_send_gcode) + SV *btn_send_gcode, + SV *manifold_warning_icon) %code%{ Slic3r::GUI::set_objects_from_perl( (wxWindow *)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), (wxBoxSizer *)wxPli_sv_2_object(aTHX_ frequently_changed_parameters_sizer, "Wx::BoxSizer"), @@ -106,11 +107,15 @@ void set_objects_from_perl( SV *ui_parent, (wxButton *)wxPli_sv_2_object(aTHX_ btn_export_stl, "Wx::Button"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_reslice, "Wx::Button"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_print, "Wx::Button"), - (wxButton *)wxPli_sv_2_object(aTHX_ btn_send_gcode, "Wx::Button")); %}; + (wxButton *)wxPli_sv_2_object(aTHX_ btn_send_gcode, "Wx::Button"), + (wxStaticBitmap *)wxPli_sv_2_object(aTHX_ manifold_warning_icon, "Wx::StaticBitmap")); %}; void set_show_print_info(bool show) %code%{ Slic3r::GUI::set_show_print_info(show); %}; +void set_show_manifold_warning_icon(bool show) + %code%{ Slic3r::GUI::set_show_manifold_warning_icon(show); %}; + std::string fold_utf8_to_ascii(const char *src) %code%{ RETVAL = Slic3r::fold_utf8_to_ascii(src); %}; From bd2371cb03ff69a0d2fc87e9c9653d91c07caf5f Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 18 May 2018 12:16:15 +0200 Subject: [PATCH 0375/1150] Right column of the Plater is passed to own panel to be able be updated separately from whole Plater panel --- lib/Slic3r/GUI/Plater.pm | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 5a3c1bb9f1..e57c2267aa 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -225,9 +225,12 @@ sub new { $self->{btoolbar}->Add($self->{"btn_layer_editing"}); } + ### Panel for right column + $self->{right_panel} = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + ### Scrolled Window for info boxes my $scrolled_window_sizer = Wx::BoxSizer->new(wxVERTICAL); - my $scrolled_window_panel = Wx::ScrolledWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + my $scrolled_window_panel = Wx::ScrolledWindow->new($self->{right_panel}, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); $scrolled_window_panel->SetSizer($scrolled_window_sizer); $scrolled_window_panel->SetScrollbars(1, 1, 1, 1); @@ -249,11 +252,11 @@ sub new { }); # right pane buttons - $self->{btn_export_gcode} = Wx::Button->new($self, -1, L("Export G-code…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_reslice} = Wx::Button->new($self, -1, L("Slice now"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_print} = Wx::Button->new($self, -1, L("Print…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_send_gcode} = Wx::Button->new($self, -1, L("Send to printer"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_export_stl} = Wx::Button->new($self, -1, L("Export STL…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_export_gcode} = Wx::Button->new($self->{right_panel}, -1, L("Export G-code…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_reslice} = Wx::Button->new($self->{right_panel}, -1, L("Slice now"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_print} = Wx::Button->new($self->{right_panel}, -1, L("Print…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_send_gcode} = Wx::Button->new($self->{right_panel}, -1, L("Send to printer"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_export_stl} = Wx::Button->new($self->{right_panel}, -1, L("Export STL…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); #$self->{btn_export_gcode}->SetFont($Slic3r::GUI::small_font); #$self->{btn_export_stl}->SetFont($Slic3r::GUI::small_font); $self->{btn_print}->Hide; @@ -390,9 +393,9 @@ sub new { # $self->{preset_choosers}{$group}[$idx] $self->{preset_choosers} = {}; for my $group (qw(print filament printer)) { - my $text = Wx::StaticText->new($self, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + my $text = Wx::StaticText->new($self->{right_panel}, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); $text->SetFont($Slic3r::GUI::small_font); - my $choice = Wx::BitmapComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, [], wxCB_READONLY); + my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [], wxCB_READONLY); if ($group eq 'filament') { EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down(0, @_); } ); } @@ -410,9 +413,9 @@ sub new { } my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxVERTICAL); - Slic3r::GUI::add_frequently_changed_parameters($self, $frequently_changed_parameters_sizer, $presets); + Slic3r::GUI::add_frequently_changed_parameters($self->{right_panel}, $frequently_changed_parameters_sizer, $presets); my $expert_mode_part_sizer = Wx::BoxSizer->new(wxVERTICAL); - Slic3r::GUI::add_expert_mode_part($self, $expert_mode_part_sizer); + Slic3r::GUI::add_expert_mode_part($self->{right_panel}, $expert_mode_part_sizer); my $object_info_sizer; { @@ -528,9 +531,13 @@ sub new { # Show the box initially, let it be shown after the slicing is finished. $self->{"print_info_box_show"}->(0); + $right_sizer->SetSizeHints($self->{right_panel}); + $self->{right_panel}->SetSizer($right_sizer); + my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); $hsizer->Add($self->{preview_notebook}, 1, wxEXPAND | wxTOP, 1); - $hsizer->Add($right_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, 3); + $hsizer->Add($self->{right_panel}, 0, wxEXPAND | wxLEFT | wxRIGHT, 3); + #$hsizer->Add($right_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, 3); my $sizer = Wx::BoxSizer->new(wxVERTICAL); $sizer->Add($self->{htoolbar}, 0, wxEXPAND, 0) if $self->{htoolbar}; @@ -2004,7 +2011,7 @@ sub selection_changed { my ($obj_idx, $object) = $self->selected_object; my $have_sel = defined $obj_idx; - $self->Freeze; + $self->{right_panel}->Freeze; if ($self->{htoolbar}) { # On OSX or Linux $self->{htoolbar}->EnableTool($_, $have_sel) @@ -2058,7 +2065,7 @@ sub selection_changed { # prepagate the event to the frame (a custom Wx event would be cleaner) $self->GetFrame->on_plater_selection_changed($have_sel); - $self->Thaw; + $self->{right_panel}->Thaw; } sub select_object { From 99293011e674caa62e872a4ad2c1c9db8dbed3ad Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 18 May 2018 12:19:54 +0200 Subject: [PATCH 0376/1150] Corrected brim generation (width), enabling continuity with skirt --- xs/src/libslic3r/Print.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 80f68c51b6..756fe08f9d 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -923,13 +923,15 @@ void Print::_make_skirt() // Initial offset of the brim inner edge from the object (possible with a support & raft). // The skirt will touch the brim if the brim is extruded. - coord_t distance = scale_(std::max(this->config.skirt_distance.value, this->config.brim_width.value)); + Flow brim_flow = this->brim_flow(); + double actual_brim_width = brim_flow.spacing() * floor(this->config.brim_width.value / brim_flow.spacing()); + coord_t distance = scale_(std::max(this->config.skirt_distance.value, actual_brim_width)); // Draw outlines from outside to inside. // Loop while we have less skirts than required or any extruder hasn't reached the min length if any. std::vector extruded_length(extruders.size(), 0.); for (int i = n_skirts, extruder_idx = 0; i > 0; -- i) { // Offset the skirt outside. - distance += coord_t(scale_(spacing)); + distance += coord_t(scale_(spacing/2.)); // Generate the skirt centerline. Polygon loop; { @@ -989,7 +991,7 @@ void Print::_make_brim() } } Polygons loops; - size_t num_loops = size_t(floor(this->config.brim_width.value / flow.width)); + size_t num_loops = size_t(floor(this->config.brim_width.value / flow.spacing())); for (size_t i = 0; i < num_loops; ++ i) { islands = offset(islands, float(flow.scaled_spacing()), jtSquare); for (Polygon &poly : islands) { From 5fc8fdee112808b03baf651da17d4c826893336f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 18 May 2018 13:02:47 +0200 Subject: [PATCH 0377/1150] 3DScene axes moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 53 ++++++------- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 4 + lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 4 + xs/src/slic3r/GUI/3DScene.cpp | 37 ++++++--- xs/src/slic3r/GUI/3DScene.hpp | 10 ++- xs/src/slic3r/GUI/GLCanvas3D.cpp | 93 ++++++++++++++++++----- xs/src/slic3r/GUI/GLCanvas3D.hpp | 30 ++++++-- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 46 +++++++---- xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 10 ++- xs/xsp/GUI_3DScene.xsp | 51 +++++++++---- 10 files changed, 244 insertions(+), 94 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index e2fdcaacaa..23b87d6610 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1551,35 +1551,36 @@ sub Render { my $volumes_bb = $self->volumes_bounding_box; - { - # draw axes - # disable depth testing so that axes are not covered by ground - glDisable(GL_DEPTH_TEST); #============================================================================================================================== - my $origin = Slic3r::GUI::_3DScene::get_bed_origin($self); + Slic3r::GUI::_3DScene::render_axes($self); + +# { +# # draw axes +# # disable depth testing so that axes are not covered by ground +# glDisable(GL_DEPTH_TEST); # my $origin = $self->origin; +# my $axis_len = $self->use_plain_shader ? 0.3 * max(@{ $self->bed_bounding_box->size }) : 2 * max(@{ $volumes_bb->size }); +# glLineWidth(2); +# glBegin(GL_LINES); +# # draw line for x axis +# glColor3f(1, 0, 0); +# glVertex3f(@$origin, $ground_z); +# glVertex3f($origin->x + $axis_len, $origin->y, $ground_z); #,, +# # draw line for y axis +# glColor3f(0, 1, 0); +# glVertex3f(@$origin, $ground_z); +# glVertex3f($origin->x, $origin->y + $axis_len, $ground_z); #++ +# glEnd(); +# # draw line for Z axis +# # (re-enable depth test so that axis is correctly shown when objects are behind it) +# glEnable(GL_DEPTH_TEST); +# glBegin(GL_LINES); +# glColor3f(0, 0, 1); +# glVertex3f(@$origin, $ground_z); +# glVertex3f(@$origin, $ground_z+$axis_len); +# glEnd(); +# } #============================================================================================================================== - my $axis_len = $self->use_plain_shader ? 0.3 * max(@{ $self->bed_bounding_box->size }) : 2 * max(@{ $volumes_bb->size }); - glLineWidth(2); - glBegin(GL_LINES); - # draw line for x axis - glColor3f(1, 0, 0); - glVertex3f(@$origin, $ground_z); - glVertex3f($origin->x + $axis_len, $origin->y, $ground_z); #,, - # draw line for y axis - glColor3f(0, 1, 0); - glVertex3f(@$origin, $ground_z); - glVertex3f($origin->x, $origin->y + $axis_len, $ground_z); #++ - glEnd(); - # draw line for Z axis - # (re-enable depth test so that axis is correctly shown when objects are behind it) - glEnable(GL_DEPTH_TEST); - glBegin(GL_LINES); - glColor3f(0, 0, 1); - glVertex3f(@$origin, $ground_z); - glVertex3f(@$origin, $ground_z+$axis_len); - glEnd(); - } glEnable(GL_LIGHTING); diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 6d3234ff3f..80ba4db506 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -9,6 +9,9 @@ use utf8; use Slic3r::Geometry qw(PI X); use Wx qw(wxTheApp :dialog :id :misc :sizer wxTAB_TRAVERSAL); use Wx::Event qw(EVT_CLOSE EVT_BUTTON); +#============================================================================================================================== +use List::Util qw(max); +#============================================================================================================================== use base 'Wx::Dialog'; sub new { @@ -115,6 +118,7 @@ sub new { $canvas->load_object($self->{model_object}, undef, undef, [0]); #============================================================================================================================== Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas); + Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ $canvas->volumes_bounding_box->size })); # $canvas->set_auto_bed_shape; #============================================================================================================================== $canvas->SetSize([500,500]); diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index ee1bf22d10..9320e66664 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -10,6 +10,9 @@ use File::Basename qw(basename); use Wx qw(:misc :sizer :treectrl :button :keycode wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG wxID_CANCEL wxMOD_CONTROL wxTheApp); use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED EVT_TREE_KEY_DOWN EVT_KEY_DOWN); +#============================================================================================================================== +use List::Util qw(max); +#============================================================================================================================== use base 'Wx::Panel'; use constant ICON_OBJECT => 0; @@ -162,6 +165,7 @@ sub new { $canvas->load_object($self->{model_object}, undef, undef, [0]); #============================================================================================================================== Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas); + Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ $canvas->volumes_bounding_box->size })); # $canvas->set_auto_bed_shape; #============================================================================================================================== $canvas->SetSize([500,700]); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 9babd8bc61..02dfd18aef 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1782,17 +1782,6 @@ void _3DScene::set_auto_bed_shape(wxGLCanvas* canvas) return s_canvas_mgr.set_auto_bed_shape(canvas); } -Pointf _3DScene::get_bed_origin(wxGLCanvas* canvas) -{ - return s_canvas_mgr.get_bed_origin(canvas); -} - -void _3DScene::set_bed_origin(wxGLCanvas* canvas, const Pointf* origin) -{ - if (origin != nullptr) - s_canvas_mgr.set_bed_origin(canvas, *origin); -} - BoundingBoxf3 _3DScene::get_bed_bounding_box(wxGLCanvas* canvas) { return s_canvas_mgr.get_bed_bounding_box(canvas); @@ -1808,6 +1797,27 @@ BoundingBoxf3 _3DScene::get_max_bounding_box(wxGLCanvas* canvas) return s_canvas_mgr.get_max_bounding_box(canvas); } +Pointf3 _3DScene::get_axes_origin(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_axes_origin(canvas); +} + +void _3DScene::set_axes_origin(wxGLCanvas* canvas, const Pointf3* origin) +{ + if (origin != nullptr) + s_canvas_mgr.set_axes_origin(canvas, *origin); +} + +float _3DScene::get_axes_length(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_axes_length(canvas); +} + +void _3DScene::set_axes_length(wxGLCanvas* canvas, float length) +{ + s_canvas_mgr.set_axes_length(canvas, length); +} + void _3DScene::set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons) { return s_canvas_mgr.set_cutting_plane(canvas, z, polygons); @@ -1898,6 +1908,11 @@ void _3DScene::render_bed(wxGLCanvas* canvas) s_canvas_mgr.render_bed(canvas); } +void _3DScene::render_axes(wxGLCanvas* canvas) +{ + s_canvas_mgr.render_axes(canvas); +} + void _3DScene::render_cutting_plane(wxGLCanvas* canvas) { s_canvas_mgr.render_cutting_plane(canvas); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index eb03a53137..2ae07d858d 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -555,13 +555,16 @@ public: static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); static void set_auto_bed_shape(wxGLCanvas* canvas); - static Pointf get_bed_origin(wxGLCanvas* canvas); - static void set_bed_origin(wxGLCanvas* canvas, const Pointf* origin); - static BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas); static BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas); static BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); + static Pointf3 get_axes_origin(wxGLCanvas* canvas); + static void set_axes_origin(wxGLCanvas* canvas, const Pointf3* origin); + + static float get_axes_length(wxGLCanvas* canvas); + static void set_axes_length(wxGLCanvas* canvas, float length); + static void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons); static unsigned int get_camera_type(wxGLCanvas* canvas); @@ -588,6 +591,7 @@ public: static void select_view(wxGLCanvas* canvas, const std::string& direction); static void render_bed(wxGLCanvas* canvas); + static void render_axes(wxGLCanvas* canvas); static void render_cutting_plane(wxGLCanvas* canvas); static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 9631f7996b..de875841cc 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -196,8 +196,6 @@ void GLCanvas3D::Bed::set_shape(const Pointfs& shape) _calc_gridlines(poly, bed_bbox); m_polygon = offset_ex(poly.contour, bed_bbox.radius() * 1.7, jtRound, scale_(0.5))[0].contour; - - set_origin(Pointf(0.0, 0.0)); } const BoundingBoxf3& GLCanvas3D::Bed::get_bounding_box() const @@ -205,16 +203,6 @@ const BoundingBoxf3& GLCanvas3D::Bed::get_bounding_box() const return m_bounding_box; } -const Pointf& GLCanvas3D::Bed::get_origin() const -{ - return m_origin; -} - -void GLCanvas3D::Bed::set_origin(const Pointf& origin) -{ - m_origin = origin; -} - void GLCanvas3D::Bed::render() { unsigned int triangles_vcount = m_triangles.get_data_size() / 3; @@ -297,6 +285,56 @@ void GLCanvas3D::Bed::_calc_gridlines(const ExPolygon& poly, const BoundingBox& printf("Unable to create bed grid lines\n"); } +GLCanvas3D::Axes::Axes() + : m_length(0.0f) +{ +} + +const Pointf3& GLCanvas3D::Axes::get_origin() const +{ + return m_origin; +} + +void GLCanvas3D::Axes::set_origin(const Pointf3& origin) +{ + m_origin = origin; +} + +float GLCanvas3D::Axes::get_length() const +{ + return m_length; +} + +void GLCanvas3D::Axes::set_length(float length) +{ + m_length = length; +} + +void GLCanvas3D::Axes::render() +{ + // disable depth testing so that axes are not covered by ground + ::glDisable(GL_DEPTH_TEST); + ::glLineWidth(2.0f); + ::glBegin(GL_LINES); + // draw line for x axis + ::glColor3f(1.0f, 0.0f, 0.0f); + ::glVertex3f((float)m_origin.x, (float)m_origin.y, (float)m_origin.z); + ::glVertex3f((float)m_origin.x + m_length, (float)m_origin.y, (float)m_origin.z); + // draw line for y axis + ::glColor3f(0.0f, 1.0f, 0.0f); + ::glVertex3f((float)m_origin.x, (float)m_origin.y, (float)m_origin.z); + ::glVertex3f((float)m_origin.x, (float)m_origin.y + m_length, (float)m_origin.z); + ::glEnd(); + // draw line for Z axis + // (re-enable depth test so that axis is correctly shown when objects are behind it) + ::glEnable(GL_DEPTH_TEST); + ::glBegin(GL_LINES); + ::glColor3f(0.0f, 0.0f, 1.0f); + ::glVertex3f((float)m_origin.x, (float)m_origin.y, (float)m_origin.z); + ::glVertex3f((float)m_origin.x, (float)m_origin.y, (float)m_origin.z + m_length); + ::glEnd(); +} + GLCanvas3D::CuttingPlane::CuttingPlane() : m_z(-1.0f) { @@ -472,6 +510,10 @@ void GLCanvas3D::set_volumes(GLVolumeCollection* volumes) void GLCanvas3D::set_bed_shape(const Pointfs& shape) { m_bed.set_shape(shape); + + // Set the origin and size for painting of the coordinate system axes. + set_axes_origin(Pointf3(0.0, 0.0, (coordf_t)GROUND_Z)); + set_axes_length(0.3f * (float)bed_bounding_box().max_size()); } void GLCanvas3D::set_auto_bed_shape() @@ -491,17 +533,27 @@ void GLCanvas3D::set_auto_bed_shape() set_bed_shape(bed_shape); // Set the origin for painting of the coordinate system axes. - set_bed_origin(Pointf(center.x, center.y)); + set_axes_origin(Pointf3(center.x, center.y, (coordf_t)GROUND_Z)); } -const Pointf& GLCanvas3D::get_bed_origin() const +const Pointf3& GLCanvas3D::get_axes_origin() const { - return m_bed.get_origin(); + return m_axes.get_origin(); } -void GLCanvas3D::set_bed_origin(const Pointf& origin) +void GLCanvas3D::set_axes_origin(const Pointf3& origin) { - m_bed.set_origin(origin); + m_axes.set_origin(origin); +} + +float GLCanvas3D::get_axes_length() const +{ + return m_axes.get_length(); +} + +void GLCanvas3D::set_axes_length(float length) +{ + return m_axes.set_length(length); } void GLCanvas3D::set_cutting_plane(float z, const ExPolygons& polygons) @@ -645,9 +697,16 @@ void GLCanvas3D::select_view(const std::string& direction) void GLCanvas3D::render_bed() { + ::glDisable(GL_LIGHTING); m_bed.render(); } +void GLCanvas3D::render_axes() +{ + ::glDisable(GL_LIGHTING); + m_axes.render(); +} + void GLCanvas3D::render_cutting_plane() { m_cutting_plane.render_plane(volumes_bounding_box()); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index a7e9dbfb00..201a840bed 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -79,7 +79,6 @@ public: { Pointfs m_shape; BoundingBoxf3 m_bounding_box; - Pointf m_origin; Polygon m_polygon; GeometryBuffer m_triangles; GeometryBuffer m_gridlines; @@ -90,9 +89,6 @@ public: const BoundingBoxf3& get_bounding_box() const; - const Pointf& get_origin() const; - void set_origin(const Pointf& origin); - void render(); private: @@ -101,6 +97,23 @@ public: void _calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); }; + class Axes + { + Pointf3 m_origin; + float m_length; + + public: + Axes(); + + const Pointf3& get_origin() const; + void set_origin(const Pointf3& origin); + + float get_length() const; + void set_length(float length); + + void render(); + }; + class CuttingPlane { float m_z; @@ -120,6 +133,7 @@ private: wxGLContext* m_context; Camera m_camera; Bed m_bed; + Axes m_axes; CuttingPlane m_cutting_plane; GLVolumeCollection* m_volumes; @@ -153,8 +167,11 @@ public: // Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane to support the scene objects. void set_auto_bed_shape(); - const Pointf& get_bed_origin() const; - void set_bed_origin(const Pointf& origin); + const Pointf3& get_axes_origin() const; + void set_axes_origin(const Pointf3& origin); + + float get_axes_length() const; + void set_axes_length(float length); void set_cutting_plane(float z, const ExPolygons& polygons); @@ -186,6 +203,7 @@ public: void select_view(const std::string& direction); void render_bed(); + void render_axes(); void render_cutting_plane(); void register_on_viewport_changed_callback(void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 911fb2f0ef..48241dafb1 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -201,19 +201,6 @@ void GLCanvas3DManager::set_auto_bed_shape(wxGLCanvas* canvas) it->second->set_auto_bed_shape(); } -Pointf GLCanvas3DManager::get_bed_origin(wxGLCanvas* canvas) const -{ - CanvasesMap::const_iterator it = _get_canvas(canvas); - return (it != m_canvases.end()) ? it->second->get_bed_origin() : Pointf(); -} - -void GLCanvas3DManager::set_bed_origin(wxGLCanvas* canvas, const Pointf& origin) -{ - CanvasesMap::iterator it = _get_canvas(canvas); - if (it != m_canvases.end()) - it->second->set_bed_origin(origin); -} - BoundingBoxf3 GLCanvas3DManager::get_bed_bounding_box(wxGLCanvas* canvas) { CanvasesMap::const_iterator it = _get_canvas(canvas); @@ -232,6 +219,32 @@ BoundingBoxf3 GLCanvas3DManager::get_max_bounding_box(wxGLCanvas* canvas) return (it != m_canvases.end()) ? it->second->max_bounding_box() : BoundingBoxf3(); } +Pointf3 GLCanvas3DManager::get_axes_origin(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_axes_origin() : Pointf3(); +} + +void GLCanvas3DManager::set_axes_origin(wxGLCanvas* canvas, const Pointf3& origin) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_axes_origin(origin); +} + +float GLCanvas3DManager::get_axes_length(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_axes_length() : 0.0f; +} + +void GLCanvas3DManager::set_axes_length(wxGLCanvas* canvas, float length) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_axes_length(length); +} + void GLCanvas3DManager::set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons) { CanvasesMap::iterator it = _get_canvas(canvas); @@ -357,6 +370,13 @@ void GLCanvas3DManager::render_bed(wxGLCanvas* canvas) it->second->render_bed(); } +void GLCanvas3DManager::render_axes(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->render_axes(); +} + void GLCanvas3DManager::render_cutting_plane(wxGLCanvas* canvas) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 4d8066597c..4877618f00 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -65,13 +65,16 @@ public: void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); void set_auto_bed_shape(wxGLCanvas* canvas); - Pointf get_bed_origin(wxGLCanvas* canvas) const; - void set_bed_origin(wxGLCanvas* canvas, const Pointf& origin); - BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas); BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas); BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas); + Pointf3 get_axes_origin(wxGLCanvas* canvas) const; + void set_axes_origin(wxGLCanvas* canvas, const Pointf3& origin); + + float get_axes_length(wxGLCanvas* canvas) const; + void set_axes_length(wxGLCanvas* canvas, float length); + void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons); unsigned int get_camera_type(wxGLCanvas* canvas) const; @@ -98,6 +101,7 @@ public: void select_view(wxGLCanvas* canvas, const std::string& direction); void render_bed(wxGLCanvas* canvas); + void render_axes(wxGLCanvas* canvas); void render_cutting_plane(wxGLCanvas* canvas); void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 2efe8f11b6..55679ba16b 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -221,21 +221,6 @@ set_auto_bed_shape(canvas) CODE: _3DScene::set_auto_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); -Clone -get_bed_origin(canvas) - SV *canvas; - CODE: - RETVAL = _3DScene::get_bed_origin((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); - OUTPUT: - RETVAL - -void -set_bed_origin(canvas, origin) - SV *canvas; - Pointf *origin - CODE: - _3DScene::set_bed_origin((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), origin); - Clone get_bed_bounding_box(canvas) SV *canvas; @@ -283,6 +268,36 @@ is_shown_on_screen(canvas) OUTPUT: RETVAL +Clone +get_axes_origin(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_axes_origin((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_axes_origin(canvas, origin) + SV *canvas; + Pointf3 *origin; + CODE: + _3DScene::set_axes_origin((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), origin); + +float +get_axes_length(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_axes_length((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_axes_length(canvas, length) + SV *canvas; + float length; + CODE: + _3DScene::set_axes_length((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), length); + void set_cutting_plane(canvas, z, polygons) SV *canvas; @@ -414,6 +429,12 @@ render_bed(canvas) CODE: _3DScene::render_bed((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); +void +render_axes(canvas) + SV *canvas; + CODE: + _3DScene::render_axes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + void render_cutting_plane(canvas) SV *canvas; From 5e1e43f47842314b2785956a99d5b344ef7229af Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 18 May 2018 13:56:51 +0200 Subject: [PATCH 0378/1150] Resolved problem with Flickering. Right column of the Plater is passed to own panel to be able be updated separately from whole Plater panel --- lib/Slic3r/GUI/Plater.pm | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index be1e020214..e141c77326 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -225,9 +225,12 @@ sub new { $self->{btoolbar}->Add($self->{"btn_layer_editing"}); } + ### Panel for right column + $self->{right_panel} = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + ### Scrolled Window for info boxes my $scrolled_window_sizer = Wx::BoxSizer->new(wxVERTICAL); - my $scrolled_window_panel = Wx::ScrolledWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + my $scrolled_window_panel = Wx::ScrolledWindow->new($self->{right_panel}, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); $scrolled_window_panel->SetSizer($scrolled_window_sizer); $scrolled_window_panel->SetScrollbars(1, 1, 1, 1); @@ -249,11 +252,11 @@ sub new { }); # right pane buttons - $self->{btn_export_gcode} = Wx::Button->new($self, -1, L("Export G-code…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_reslice} = Wx::Button->new($self, -1, L("Slice now"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_print} = Wx::Button->new($self, -1, L("Print…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_send_gcode} = Wx::Button->new($self, -1, L("Send to printer"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_export_stl} = Wx::Button->new($self, -1, L("Export STL…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_export_gcode} = Wx::Button->new($self->{right_panel}, -1, L("Export G-code…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_reslice} = Wx::Button->new($self->{right_panel}, -1, L("Slice now"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_print} = Wx::Button->new($self->{right_panel}, -1, L("Print…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_send_gcode} = Wx::Button->new($self->{right_panel}, -1, L("Send to printer"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_export_stl} = Wx::Button->new($self->{right_panel}, -1, L("Export STL…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); #$self->{btn_export_gcode}->SetFont($Slic3r::GUI::small_font); #$self->{btn_export_stl}->SetFont($Slic3r::GUI::small_font); $self->{btn_print}->Hide; @@ -390,9 +393,9 @@ sub new { # $self->{preset_choosers}{$group}[$idx] $self->{preset_choosers} = {}; for my $group (qw(print filament printer)) { - my $text = Wx::StaticText->new($self, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + my $text = Wx::StaticText->new($self->{right_panel}, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); $text->SetFont($Slic3r::GUI::small_font); - my $choice = Wx::BitmapComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, [], wxCB_READONLY); + my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [], wxCB_READONLY); if ($group eq 'filament') { EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down(0, @_); } ); } @@ -410,7 +413,7 @@ sub new { } my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxHORIZONTAL); - Slic3r::GUI::add_frequently_changed_parameters($self, $frequently_changed_parameters_sizer, $presets); + Slic3r::GUI::add_frequently_changed_parameters($self->{right_panel}, $frequently_changed_parameters_sizer, $presets); my $object_info_sizer; { @@ -514,9 +517,12 @@ sub new { # Show the box initially, let it be shown after the slicing is finished. $self->{"print_info_box_show"}->(0); + $right_sizer->SetSizeHints($self->{right_panel}); + $self->{right_panel}->SetSizer($right_sizer); + my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); $hsizer->Add($self->{preview_notebook}, 1, wxEXPAND | wxTOP, 1); - $hsizer->Add($right_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, 3); + $hsizer->Add($self->{right_panel}, 0, wxEXPAND | wxLEFT | wxRIGHT, 3); my $sizer = Wx::BoxSizer->new(wxVERTICAL); $sizer->Add($self->{htoolbar}, 0, wxEXPAND, 0) if $self->{htoolbar}; @@ -1976,7 +1982,7 @@ sub selection_changed { my ($obj_idx, $object) = $self->selected_object; my $have_sel = defined $obj_idx; - $self->Freeze; + $self->{right_panel}->Freeze; if ($self->{htoolbar}) { # On OSX or Linux $self->{htoolbar}->EnableTool($_, $have_sel) @@ -2030,7 +2036,7 @@ sub selection_changed { # prepagate the event to the frame (a custom Wx event would be cleaner) $self->GetFrame->on_plater_selection_changed($have_sel); - $self->Thaw; + $self->{right_panel}->Thaw; } sub select_object { From a7fc57a176e1cb8f8f2d3b070563b2dc5a5e1f16 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 18 May 2018 14:08:59 +0200 Subject: [PATCH 0379/1150] 3DScene reset_object method moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 46 ++++++++++++----------- lib/Slic3r/GUI/Plater/3D.pm | 5 ++- lib/Slic3r/GUI/Plater/3DPreview.pm | 7 +++- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 7 +++- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 15 ++++++-- xs/src/slic3r/GUI/3DScene.cpp | 10 +++++ xs/src/slic3r/GUI/3DScene.hpp | 4 ++ xs/src/slic3r/GUI/GLCanvas3D.cpp | 32 +++++++++++++++- xs/src/slic3r/GUI/GLCanvas3D.hpp | 17 ++++++++- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 13 +++++++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 4 ++ xs/xsp/GUI_3DScene.xsp | 6 +++ 12 files changed, 135 insertions(+), 31 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 23b87d6610..17e2e63775 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -110,7 +110,9 @@ __PACKAGE__->mk_accessors( qw(_quat init use constant TRACKBALLSIZE => 0.8; use constant TURNTABLE_MODE => 1; -use constant GROUND_Z => -0.02; +#============================================================================================================================== +#use constant GROUND_Z => -0.02; +#============================================================================================================================== # For mesh selection: Not selected - bright yellow. use constant DEFAULT_COLOR => [1,1,0]; # For mesh selection: Selected - bright green. @@ -127,13 +129,11 @@ use constant HOVER_COLOR => [0.4,0.9,0,1]; #use constant VIEW_BOTTOM => [0.0,180.0]; #use constant VIEW_FRONT => [0.0,90.0]; #use constant VIEW_REAR => [180.0,90.0]; -#============================================================================================================================== - -use constant MANIPULATION_IDLE => 0; -use constant MANIPULATION_DRAGGING => 1; -use constant MANIPULATION_LAYER_HEIGHT => 2; - -#============================================================================================================================== +# +#use constant MANIPULATION_IDLE => 0; +#use constant MANIPULATION_DRAGGING => 1; +#use constant MANIPULATION_LAYER_HEIGHT => 2; +# #use constant GIMBALL_LOCK_THETA_MAX => 180; #============================================================================================================================== @@ -223,7 +223,10 @@ sub new { $self->{layer_height_edit_last_z} = 0.; $self->{layer_height_edit_last_action} = 0; - $self->reset_objects; +#============================================================================================================================== + Slic3r::GUI::_3DScene::reset_volumes($self); +# $self->reset_objects; +#============================================================================================================================== EVT_PAINT($self, sub { my $dc = Wx::PaintDC->new($self); @@ -723,19 +726,18 @@ sub mouse_wheel_event { $self->Refresh; } -# Reset selection. -sub reset_objects { - my ($self) = @_; - if ($self->GetContext) { - $self->SetCurrent($self->GetContext); - $self->volumes->release_geometry; - } - $self->volumes->erase; #============================================================================================================================== - Slic3r::GUI::_3DScene::set_dirty($self, 1); +## Reset selection. +#sub reset_objects { +# my ($self) = @_; +# if ($self->GetContext) { +# $self->SetCurrent($self->GetContext); +# $self->volumes->release_geometry; +# } +# $self->volumes->erase; # $self->_dirty(1); +#} #============================================================================================================================== -} # Setup camera to view all objects. sub set_viewport_from_scene { @@ -1515,8 +1517,10 @@ sub Render { # draw ground and axes glDisable(GL_LIGHTING); - # draw ground - my $ground_z = GROUND_Z; +#============================================================================================================================== +# # draw ground +# my $ground_z = GROUND_Z; +#============================================================================================================================== #============================================================================================================================== Slic3r::GUI::_3DScene::render_bed($self); diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index 2706df509f..6c3e02e09b 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -197,7 +197,10 @@ sub update_volumes_selection { sub reload_scene { my ($self, $force) = @_; - $self->reset_objects; +#============================================================================================================================== + Slic3r::GUI::_3DScene::reset_volumes($self); +# $self->reset_objects; +#============================================================================================================================== $self->update_bed_size; if (! $self->IsShown && ! $force) { diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index 96c28fee5b..0aff64310c 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -277,8 +277,11 @@ sub new { sub reload_print { my ($self, $force) = @_; - - $self->canvas->reset_objects; + +#============================================================================================================================== + Slic3r::GUI::_3DScene::reset_volumes($self->canvas); +# $self->canvas->reset_objects; +#============================================================================================================================== $self->_loaded(0); if (! $self->IsShown && ! $force) { diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 80ba4db506..b379ba8ef7 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -254,8 +254,11 @@ sub _update { for @$expolygon; $expolygon->translate(map Slic3r::Geometry::scale($_), @{ $self->{model_object}->instances->[0]->offset }); } - - $self->{canvas}->reset_objects; + +#============================================================================================================================== + Slic3r::GUI::_3DScene::reset_volumes($self->{canvas}); +# $self->{canvas}->reset_objects; +#============================================================================================================================== $self->{canvas}->load_object($_, undef, undef, [0]) for @objects; $self->{canvas}->SetCuttingPlane( $self->{cut_options}{z}, diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 9320e66664..a2b779a0ab 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -494,7 +494,10 @@ sub _parts_changed { $self->reload_tree; if ($self->{canvas}) { - $self->{canvas}->reset_objects; +#============================================================================================================================== + Slic3r::GUI::_3DScene::reset_volumes($self->{canvas}); +# $self->{canvas}->reset_objects; +#============================================================================================================================== $self->{canvas}->load_object($self->{model_object}); $self->{canvas}->zoom_to_volumes; $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); @@ -539,7 +542,10 @@ sub _update_canvas { my ($self) = @_; if ($self->{canvas}) { - $self->{canvas}->reset_objects; +#============================================================================================================================== + Slic3r::GUI::_3DScene::reset_volumes($self->{canvas}); +# $self->{canvas}->reset_objects; +#============================================================================================================================== $self->{canvas}->load_object($self->{model_object}); # restore selection, if any @@ -572,7 +578,10 @@ sub _update { $self->{parts_changed} = 1; my @objects = (); push @objects, $self->{model_object}; - $self->{canvas}->reset_objects; +#============================================================================================================================== + Slic3r::GUI::_3DScene::reset_volumes($self->{canvas}); +# $self->{canvas}->reset_objects; +#============================================================================================================================== $self->{canvas}->load_object($_, undef, [0]) for @objects; $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); $self->{canvas}->Render; diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 02dfd18aef..bb1527f8da 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1772,6 +1772,11 @@ void _3DScene::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes) s_canvas_mgr.set_volumes(canvas, volumes); } +void _3DScene::reset_volumes(wxGLCanvas* canvas) +{ + s_canvas_mgr.reset_volumes(canvas); +} + void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape) { return s_canvas_mgr.set_bed_shape(canvas, shape); @@ -1887,6 +1892,11 @@ void _3DScene::set_camera_target(wxGLCanvas* canvas, const Pointf3* target) { s_canvas_mgr.set_camera_target(canvas, target); } + +bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas) +{ + return s_canvas_mgr.is_layers_editing_enabled(canvas); +} void _3DScene::zoom_to_bed(wxGLCanvas* canvas) { diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 2ae07d858d..3f4ecc6376 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -552,6 +552,8 @@ public: static GLVolumeCollection* get_volumes(wxGLCanvas* canvas); static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes); + static void reset_volumes(wxGLCanvas* canvas); + static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); static void set_auto_bed_shape(wxGLCanvas* canvas); @@ -586,6 +588,8 @@ public: static Pointf3 get_camera_target(wxGLCanvas* canvas); static void set_camera_target(wxGLCanvas* canvas, const Pointf3* target); + static bool is_layers_editing_enabled(wxGLCanvas* canvas); + static void zoom_to_bed(wxGLCanvas* canvas); static void zoom_to_volumes(wxGLCanvas* canvas); static void select_view(wxGLCanvas* canvas, const std::string& direction); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index de875841cc..7a47028809 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -395,6 +395,16 @@ void GLCanvas3D::CuttingPlane::render_contour() ::glDisableClientState(GL_VERTEX_ARRAY); } +GLCanvas3D::LayersEditing::LayersEditing() + : m_enabled(false) +{ +} + +bool GLCanvas3D::LayersEditing::is_enabled() const +{ + return m_enabled; +} + GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) : m_canvas(canvas) , m_context(context) @@ -409,10 +419,15 @@ GLCanvas3D::~GLCanvas3D() _deregister_callbacks(); } -void GLCanvas3D::set_current() +bool GLCanvas3D::set_current() { if ((m_canvas != nullptr) && (m_context != nullptr)) + { m_canvas->SetCurrent(*m_context); + return true; + } + + return false; } bool GLCanvas3D::is_dirty() const @@ -507,6 +522,16 @@ void GLCanvas3D::set_volumes(GLVolumeCollection* volumes) m_volumes = volumes; } +void GLCanvas3D::reset_volumes() +{ + if (set_current() && (m_volumes != nullptr)) + { + m_volumes->release_geometry(); + m_volumes->clear(); + set_dirty(true); + } +} + void GLCanvas3D::set_bed_shape(const Pointfs& shape) { m_bed.set_shape(shape); @@ -652,6 +677,11 @@ BoundingBoxf3 GLCanvas3D::max_bounding_box() const return bb; } +bool GLCanvas3D::is_layers_editing_enabled() const +{ + return m_layers_editing.is_enabled(); +} + void GLCanvas3D::zoom_to_bed() { _zoom_to_bounding_box(bed_bounding_box()); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 201a840bed..558e6c350e 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -128,6 +128,16 @@ public: void render_contour(); }; + class LayersEditing + { + bool m_enabled; + + public: + LayersEditing(); + + bool is_enabled() const; + }; + private: wxGLCanvas* m_canvas; wxGLContext* m_context; @@ -135,6 +145,7 @@ private: Bed m_bed; Axes m_axes; CuttingPlane m_cutting_plane; + LayersEditing m_layers_editing; GLVolumeCollection* m_volumes; @@ -147,7 +158,7 @@ public: GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context); ~GLCanvas3D(); - void set_current(); + bool set_current(); bool is_dirty() const; void set_dirty(bool dirty); @@ -159,6 +170,8 @@ public: GLVolumeCollection* get_volumes(); void set_volumes(GLVolumeCollection* volumes); + void reset_volumes(); + // Set the bed shape to a single closed 2D polygon(array of two element arrays), // triangulate the bed and store the triangles into m_bed.m_triangles, // fills the m_bed.m_grid_lines and sets m_bed.m_origin. @@ -198,6 +211,8 @@ public: BoundingBoxf3 volumes_bounding_box() const; BoundingBoxf3 max_bounding_box() const; + bool is_layers_editing_enabled() const; + void zoom_to_bed(); void zoom_to_volumes(); void select_view(const std::string& direction); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 48241dafb1..f4cf4235ed 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -187,6 +187,13 @@ void GLCanvas3DManager::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volu it->second->set_volumes(volumes); } +void GLCanvas3DManager::reset_volumes(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->reset_volumes(); +} + void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape) { CanvasesMap::iterator it = _get_canvas(canvas); @@ -342,6 +349,12 @@ void GLCanvas3DManager::set_camera_target(wxGLCanvas* canvas, const Pointf3* tar it->second->set_camera_target(*target); } +bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->is_layers_editing_enabled() : false; +} + void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 4877618f00..6abe1bbf72 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -62,6 +62,8 @@ public: GLVolumeCollection* get_volumes(wxGLCanvas* canvas); void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes); + void reset_volumes(wxGLCanvas* canvas); + void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape); void set_auto_bed_shape(wxGLCanvas* canvas); @@ -96,6 +98,8 @@ public: Pointf3 get_camera_target(wxGLCanvas* canvas) const; void set_camera_target(wxGLCanvas* canvas, const Pointf3* target); + bool is_layers_editing_enabled(wxGLCanvas* canvas) const; + void zoom_to_bed(wxGLCanvas* canvas); void zoom_to_volumes(wxGLCanvas* canvas); void select_view(wxGLCanvas* canvas, const std::string& direction); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 55679ba16b..c55ee8fbdc 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -207,6 +207,12 @@ set_volumes(canvas, volumes) GLVolumeCollection *volumes; CODE: _3DScene::set_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), volumes); + +void +reset_volumes(canvas) + SV *canvas; + CODE: + _3DScene::reset_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); void set_bed_shape(canvas, shape) From fd43e53aeb67b6ad0b3e25b25af2702694b45917 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 18 May 2018 14:58:24 +0200 Subject: [PATCH 0380/1150] PresetUpdater: Add some more logging --- xs/src/slic3r/Utils/PresetUpdater.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index a5208e3c26..9a4d1048f0 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -402,7 +402,11 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons PresetBundle bundle; bundle.load_configbundle(update.target.string(), PresetBundle::LOAD_CFGBNDLE_SYSTEM); + BOOST_LOG_TRIVIAL(info) << boost::format("Deleting %1% conflicting presets") + % (bundle.prints.size() + bundle.filaments.size() + bundle.printers.size()); + auto preset_remover = [](const Preset &preset) { + BOOST_LOG_TRIVIAL(info) << '\t' << preset.file; fs::remove(preset.file); }; @@ -411,9 +415,14 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons for (const auto &preset : bundle.printers) { preset_remover(preset); } // Also apply the `obsolete_presets` property, removing obsolete ini files + + BOOST_LOG_TRIVIAL(info) << boost::format("Deleting %1% obsolete presets") + % (bundle.obsolete_presets.prints.size() + bundle.obsolete_presets.filaments.size() + bundle.obsolete_presets.printers.size()); + auto obsolete_remover = [](const char *subdir, const std::string &preset) { auto path = fs::path(Slic3r::data_dir()) / subdir / preset; path += ".ini"; + BOOST_LOG_TRIVIAL(info) << '\t' << path.string(); fs::remove(path); }; From d97939c01280c03864694e813138c18eb95cb792 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 18 May 2018 15:08:18 +0200 Subject: [PATCH 0381/1150] Holes now printed correctly. export changed to pgm which is grayscale. --- xs/src/libslic3r/Print.cpp | 100 ++++++++++------ xs/src/libslic3r/Rasterizer/Rasterizer.cpp | 128 +++++++++++---------- xs/src/libslic3r/Rasterizer/Rasterizer.hpp | 11 +- 3 files changed, 147 insertions(+), 92 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index a4366a717a..7477a97362 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -13,6 +13,7 @@ // For png export of the sliced model #include +#include #include #include #include @@ -1256,41 +1257,79 @@ void Print::set_status(int percent, const std::string &message) template class FilePrinter { public: - void drawPolygon(const ExPolygon& p); - void finish(); + void drawPolygon(const ExPolygon& p, unsigned lyr); + void layers(unsigned layernum); + unsigned layers() const; + void beginLayer(unsigned layer); + void beginLayer(); + void finishLayer(unsigned layer); + void finishLayer(); void save(const std::string& path); }; template<> class FilePrinter { - std::unique_ptr rst_; + std::vector> layers_rst_; Raster::Resolution res_; Raster::PixelDim pxdim_; public: inline FilePrinter(unsigned width_px, unsigned height_px, - double width_mm, double height_mm): + double width_mm, double height_mm, + unsigned layer_cnt = 0): res_(width_px, height_px), - pxdim_(width_mm/width_px, height_mm/height_px) {} + pxdim_(width_mm/width_px, height_mm/height_px) { + layers(layer_cnt); + } FilePrinter(const FilePrinter& ) = delete; FilePrinter(FilePrinter&& m): - rst_(std::move(m.rst_)), + layers_rst_(std::move(m.layers_rst_)), res_(m.res_), pxdim_(m.pxdim_) {} - inline void drawPolygon(const Polygon& p) { - if(!rst_) rst_.reset(new Raster(res_, pxdim_)); - rst_->draw(p); + inline void layers(unsigned cnt) { if(cnt > 0) layers_rst_.resize(cnt); } + inline unsigned layers() const { return layers_rst_.size(); } + + inline void drawPolygon(const ExPolygon& p, unsigned lyr) { + assert(lyr_id < layers_rst_.size()); + layers_rst_[lyr].first.draw(p); } - inline void finish() { - rst_.reset(); + inline void beginLayer(unsigned lyr) { + if(layers_rst_.size() <= lyr) layers_rst_.resize(lyr+1); + layers_rst_[lyr].first.reset(res_, pxdim_); + } + + inline void beginLayer() { + layers_rst_.emplace_back(Raster(res_, pxdim_), std::stringstream()); + } + + inline void finishLayer(unsigned lyr_id) { + assert(lyr_id < layers_rst_.size()); + layers_rst_[lyr_id].first.save(layers_rst_[lyr_id].second); + layers_rst_[lyr_id].first.reset(); + } + + inline void finishLayer() { + if(!layers_rst_.empty()) { + layers_rst_.back().first.save(layers_rst_.back().second); + layers_rst_.back().first.reset(); + } } inline void save(const std::string& path) { - std::fstream out(path, std::fstream::out | std::fstream::binary); - rst_->save(out); - out.close(); + for(unsigned i = 0; i < layers_rst_.size(); i++) { + if(layers_rst_[i].second.rdbuf()->in_avail() > 0) { + std::string loc = path + "layer" + std::to_string(i) + ".pgm"; + std::fstream out(loc, std::fstream::out | std::fstream::binary); + if(out.good()) { + out << layers_rst_[i].second.rdbuf(); + } + out.close(); + layers_rst_[i].first.reset(); + layers_rst_[i].second.str(""); + } + } } }; @@ -1372,14 +1411,10 @@ void Print::print_to(std::string dirpath, Args...args) ExPolygons previous_layer_slices; auto print_bb = bounding_box(); - std::vector> printers; - printers.reserve(layers.size()); + FilePrinter printer(std::forward(args)...); + printer.layers(layers.size()); - for(unsigned i = 0; i < layers.size(); i++) { - printers.emplace_back(std::forward(args)...); - } - -#pragma omp parallel for +#pragma omp parallel for /*num_threads(8)*/ for(int layer_id = 0; layer_id < layers.size(); layer_id++) { Layer& l = *(layers[layer_id]); @@ -1393,7 +1428,12 @@ void Print::print_to(std::string dirpath, Args...args) ExPolygons current_layer_slices; - auto& printer = printers[layer_id]; + try { + printer.beginLayer(layer_id); + } catch(std::bad_alloc& ) { + printer.save(dir); + printer.beginLayer(layer_id); + } std::for_each(l.object()->_shifted_copies.begin(), l.object()->_shifted_copies.end(), @@ -1406,25 +1446,21 @@ void Print::print_to(std::string dirpath, Args...args) slice.translate(d.x, d.y); slice.translate(-print_bb.min.x, -print_bb.min.y); - printer.drawPolygon(slice.contour); - std::for_each(slice.holes.begin(), slice.holes.end(), - [&printer](const Polygon& hole){ - printer.drawPolygon(hole); - }); + printer.drawPolygon(slice, layer_id); current_layer_slices.push_back(slice); }); }); - printers[layer_id].save(dir + "layer" + std::to_string(layer_id) + ".ppm"); - printer.finish(); + printer.finishLayer(layer_id); + + std::cout << "processed layer: " << layer_id << " by thread: " + << omp_get_thread_num() << std::endl; -// std::cout << "processed layers: " << layer_id + 1 << std::endl; previous_layer_slices = current_layer_slices; } -// for(unsigned i = 0; i < printers.size(); i++) -// printers[i].save(dir + "layer" + std::to_string(i) + ".png"); + printer.save(dir); } void Print::print_to_png(std::string dirpath, long width_px, long height_px, diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index d4af2a6ca8..bd27278ed6 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -22,13 +22,13 @@ namespace Slic3r { class Raster::Impl { public: - using TBuffer = std::vector>; - using TPixelRenderer = agg::pixfmt_rgb24; + using TPixelRenderer = agg::pixfmt_gray8; // agg::pixfmt_rgb24; using TRawRenderer = agg::renderer_base; - using TRenderer = agg::renderer_primitives; using TPixel = TPixelRenderer::color_type; using TRawBuffer = agg::rendering_buffer; + using TBuffer = std::vector; + using TRendererAA = agg::renderer_scanline_aa_solid; static const TPixel ColorWhite; @@ -41,66 +41,36 @@ private: TRawBuffer rbuf_; TPixelRenderer pixfmt_; TRawRenderer raw_renderer_; + TRendererAA renderer_; public: inline Impl(const Raster::Resolution& res, const Raster::PixelDim &pd): resolution_(res), pxdim_(pd), buf_(res.pixels()), - rbuf_(reinterpret_cast(buf_.data()), - res.width_px, res.height_px, res.width_px*sizeof(TBuffer::value_type)), + rbuf_(reinterpret_cast(buf_.data()), + res.width_px, res.height_px, + res.width_px*TPixelRenderer::num_components), pixfmt_(rbuf_), - raw_renderer_(pixfmt_) + raw_renderer_(pixfmt_), + renderer_(raw_renderer_) { + renderer_.color(ColorWhite); + + // If we would like to play around with gamma + // ras.gamma(agg::gamma_power(1.0)); + clear(); } - void draw(const Polygon &p) { - TRendererAA ren_aa(raw_renderer_); + void draw(const ExPolygon &poly) { agg::rasterizer_scanline_aa<> ras; agg::scanline_p8 scanlines; - agg::path_storage paths; - -// ras.gamma(agg::gamma_power(1.0)); - - auto it = p.points.begin(); - auto itnext = std::next(it); - - { - double xf = std::round(it->x * SCALING_FACTOR/pxdim_.w_mm); - double yf = std::round(it->y * SCALING_FACTOR/pxdim_.h_mm); - double nxf = std::round(itnext->x * SCALING_FACTOR/pxdim_.w_mm); - double nyf = std::round(itnext->y * SCALING_FACTOR/pxdim_.h_mm); - - paths.move_to(xf, yf); - paths.line_to(nxf, nyf); - - ++it, ++itnext; - } - while(itnext != p.points.end() ) { -// double xf = std::round(it->x * SCALING_FACTOR/pxdim_.w_mm); -// double yf = std::round(it->y * SCALING_FACTOR/pxdim_.h_mm); -// auto x = renderer_.coord(xf); -// auto y = renderer_.coord(yf); - - double nxf = std::round(itnext->x * SCALING_FACTOR/pxdim_.w_mm); - double nyf = std::round(itnext->y * SCALING_FACTOR/pxdim_.h_mm); -// auto nx = renderer_.coord(nxf); -// auto ny = renderer_.coord(nyf); - -// renderer_.move_to(x, y); -// renderer_.line_to(nx, ny); - -// paths.move_to(xf, yf); - paths.line_to(nxf, nyf); - - /*++it,*/ ++itnext; + ras.add_path(to_path(poly.contour)); + for(auto h : poly.holes) { + ras.add_path(to_path(h)); } - paths.close_polygon(); - ras.add_path(paths); - - ren_aa.color(ColorWhite); - agg::render_scanlines(ras, scanlines, ren_aa); + agg::render_scanlines(ras, scanlines, renderer_); } inline void clear() { @@ -110,14 +80,37 @@ public: inline const TBuffer& buffer() const { return buf_; } inline const Raster::Resolution resolution() { return resolution_; } + +private: + double getPx(const Point& p) { + return p.x * SCALING_FACTOR/pxdim_.w_mm; + } + + double getPy(const Point& p) { + return p.y * SCALING_FACTOR/pxdim_.h_mm; + } + + agg::path_storage to_path(const Polygon& poly) { + agg::path_storage path; + auto it = poly.points.begin(); + path.move_to(getPx(*it), getPy(*it)); + while(++it != poly.points.end()) + path.line_to(getPx(*it), getPy(*it)); + + path.line_to(getPx(poly.points.front()), getPy(poly.points.front())); + return path; + } + }; -const Raster::Impl::TPixel Raster::Impl::ColorWhite = Raster::Impl::TPixel(255, 255, 255); -const Raster::Impl::TPixel Raster::Impl::ColorBlack = Raster::Impl::TPixel(0, 0, 0); +const Raster::Impl::TPixel Raster::Impl::ColorWhite = Raster::Impl::TPixel(255); +const Raster::Impl::TPixel Raster::Impl::ColorBlack = Raster::Impl::TPixel(0); Raster::Raster(const Resolution &r, const PixelDim &pd): impl_(new Impl(r, pd)) {} +Raster::Raster() {} + Raster::~Raster() {} Raster::Raster(const Raster &cpy) { @@ -127,30 +120,49 @@ Raster::Raster(const Raster &cpy) { Raster::Raster(Raster &&m): impl_(std::move(m.impl_)) {} +void Raster::reset(const Raster::Resolution &r, const Raster::PixelDim &pd) +{ + impl_.reset(new Impl(r, pd)); +} + +void Raster::reset() +{ + impl_.reset(); +} + +Raster::Resolution Raster::resolution() const +{ + if(impl_) return impl_->resolution(); + + return Resolution(0, 0); +} + void Raster::clear() { + assert(impl_); impl_->clear(); } -void Raster::draw(const Polygon &poly) +void Raster::draw(const ExPolygon &poly) { + assert(impl_); impl_->draw(poly); } void Raster::save(std::ostream& stream, Compression comp) { + assert(impl_); switch(comp) { - case Compression::RAW: case Compression::PNG: - stream << "P6 " + case Compression::RAW: + stream << "P5 " << impl_->resolution().width_px << " " << impl_->resolution().height_px << " " << "255 "; - - stream.write(reinterpret_cast(impl_->buffer().data()), - impl_->buffer().size()*sizeof(Impl::TBuffer::value_type)); - break; } + + stream.write(reinterpret_cast(impl_->buffer().data()), + impl_->buffer().size()*sizeof(Impl::TBuffer::value_type)); } } diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp index d6b27ea82f..31a1244ec8 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp @@ -2,7 +2,7 @@ #define RASTERIZER_HPP #include -#include +#include namespace Slic3r { @@ -33,13 +33,20 @@ public: }; explicit Raster(const Resolution& r, const PixelDim& pd ); + Raster(); ~Raster(); Raster(const Raster& cpy); Raster(Raster&& m); + void reset(const Resolution& r, const PixelDim& pd); + + void reset(); + + Resolution resolution() const; + void clear(); - void draw(const Polygon& poly); + void draw(const ExPolygon& poly); void save(std::ostream& stream, Compression comp = Compression::RAW); }; From 0f552832da24a826c671bb335884c7e08e29dc48 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 18 May 2018 18:11:29 +0200 Subject: [PATCH 0382/1150] PNG conversion and parallel execution working. --- xs/src/agg/copying | 65 +++ xs/src/libslic3r/Print.cpp | 58 +-- xs/src/libslic3r/Print.hpp | 2 +- xs/src/libslic3r/Rasterizer/Rasterizer.cpp | 43 +- xs/src/png/COPYING | 25 ++ xs/src/png/color.hpp | 65 +++ xs/src/png/end_info.hpp | 74 ++++ xs/src/png/error.hpp | 118 ++++++ xs/src/png/image_info.hpp | 215 ++++++++++ xs/src/png/info.hpp | 186 ++++++++ xs/src/png/info_base.hpp | 77 ++++ xs/src/png/io_base.hpp | 467 +++++++++++++++++++++ xs/src/png/palette.hpp | 48 +++ xs/src/png/pixel_traits.hpp | 103 +++++ xs/src/png/tRNS.hpp | 48 +++ xs/src/png/types.hpp | 120 ++++++ xs/src/png/writer.hpp | 199 +++++++++ 17 files changed, 1876 insertions(+), 37 deletions(-) create mode 100644 xs/src/agg/copying create mode 100644 xs/src/png/COPYING create mode 100644 xs/src/png/color.hpp create mode 100644 xs/src/png/end_info.hpp create mode 100644 xs/src/png/error.hpp create mode 100644 xs/src/png/image_info.hpp create mode 100644 xs/src/png/info.hpp create mode 100644 xs/src/png/info_base.hpp create mode 100644 xs/src/png/io_base.hpp create mode 100644 xs/src/png/palette.hpp create mode 100644 xs/src/png/pixel_traits.hpp create mode 100644 xs/src/png/tRNS.hpp create mode 100644 xs/src/png/types.hpp create mode 100644 xs/src/png/writer.hpp diff --git a/xs/src/agg/copying b/xs/src/agg/copying new file mode 100644 index 0000000000..b6028e5195 --- /dev/null +++ b/xs/src/agg/copying @@ -0,0 +1,65 @@ +The Anti-Grain Geometry Project +A high quality rendering engine for C++ +http://antigrain.com + +Anti-Grain Geometry has dual licensing model. The Modified BSD +License was first added in version v2.4 just for convenience. +It is a simple, permissive non-copyleft free software license, +compatible with the GNU GPL. It's well proven and recognizable. +See http://www.fsf.org/licensing/licenses/index_html#ModifiedBSD +for details. + +Note that the Modified BSD license DOES NOT restrict your rights +if you choose the Anti-Grain Geometry Public License. + + + + +Anti-Grain Geometry Public License +==================================================== + +Anti-Grain Geometry - Version 2.4 +Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) + +Permission to copy, use, modify, sell and distribute this software +is granted provided this copyright notice appears in all copies. +This software is provided "as is" without express or implied +warranty, and with no claim as to its suitability for any purpose. + + + + + +Modified BSD License +==================================================== +Anti-Grain Geometry - Version 2.4 +Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 7477a97362..5d596f9e6d 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -11,17 +11,17 @@ #include #include + // For png export of the sliced model #include #include -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include "Rasterizer/Rasterizer.hpp" - -#include +#include "tbb/parallel_for.h" namespace Slic3r { @@ -1265,6 +1265,7 @@ public: void finishLayer(unsigned layer); void finishLayer(); void save(const std::string& path); + void saveLayer(unsigned lyr, const std::string& path); }; template<> @@ -1306,13 +1307,15 @@ public: inline void finishLayer(unsigned lyr_id) { assert(lyr_id < layers_rst_.size()); - layers_rst_[lyr_id].first.save(layers_rst_[lyr_id].second); + layers_rst_[lyr_id].first.save(layers_rst_[lyr_id].second, + Raster::Compression::PNG); layers_rst_[lyr_id].first.reset(); } inline void finishLayer() { if(!layers_rst_.empty()) { - layers_rst_.back().first.save(layers_rst_.back().second); + layers_rst_.back().first.save(layers_rst_.back().second, + Raster::Compression::PNG); layers_rst_.back().first.reset(); } } @@ -1320,17 +1323,28 @@ public: inline void save(const std::string& path) { for(unsigned i = 0; i < layers_rst_.size(); i++) { if(layers_rst_[i].second.rdbuf()->in_avail() > 0) { - std::string loc = path + "layer" + std::to_string(i) + ".pgm"; + std::string loc = path + "layer" + std::to_string(i) + ".png"; std::fstream out(loc, std::fstream::out | std::fstream::binary); if(out.good()) { out << layers_rst_[i].second.rdbuf(); } out.close(); - layers_rst_[i].first.reset(); layers_rst_[i].second.str(""); } } } + + void saveLayer(unsigned lyr, const std::string& path) { + unsigned i = lyr; + assert(i < layers_rst_.size()); + std::string loc = path + "layer" + std::to_string(i) + ".png"; + std::fstream out(loc, std::fstream::out | std::fstream::binary); + if(out.good()) { + layers_rst_[i].first.save(out, Raster::Compression::PNG); + } + out.close(); + layers_rst_[i].first.reset(); + } }; //template<> @@ -1408,17 +1422,15 @@ void Print::print_to(std::string dirpath, Args...args) return l1->print_z < l2->print_z; }); - ExPolygons previous_layer_slices; auto print_bb = bounding_box(); FilePrinter printer(std::forward(args)...); printer.layers(layers.size()); -#pragma omp parallel for /*num_threads(8)*/ - for(int layer_id = 0; layer_id < layers.size(); layer_id++) { + auto process_layer = [&layers, &printer, print_bb, dir] (unsigned layer_id) { Layer& l = *(layers[layer_id]); - auto slices = l.slices; + ExPolygonCollection slices = l.slices; using Sl = ExPolygons::value_type; std::sort(slices.expolygons.begin(), slices.expolygons.end(), @@ -1426,14 +1438,7 @@ void Print::print_to(std::string dirpath, Args...args) return a.contains(b.contour.first_point()) ? false : true; }); - ExPolygons current_layer_slices; - - try { - printer.beginLayer(layer_id); - } catch(std::bad_alloc& ) { - printer.save(dir); - printer.beginLayer(layer_id); - } + printer.beginLayer(layer_id); std::for_each(l.object()->_shifted_copies.begin(), l.object()->_shifted_copies.end(), @@ -1447,18 +1452,15 @@ void Print::print_to(std::string dirpath, Args...args) slice.translate(-print_bb.min.x, -print_bb.min.y); printer.drawPolygon(slice, layer_id); - - current_layer_slices.push_back(slice); }); }); printer.finishLayer(layer_id); +// printer.saveLayer(layer_id, dir); - std::cout << "processed layer: " << layer_id << " by thread: " - << omp_get_thread_num() << std::endl; + }; - previous_layer_slices = current_layer_slices; - } + tbb::parallel_for(0, layers.size(), process_layer); printer.save(dir); } diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index fc2cf2b202..2409b6f4fc 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -323,7 +323,7 @@ public: void print_to_png(std::string dirpath) { // Where should this be specified? - print_to_png(dirpath, 2560, 1440, 70.0, 40.0); + print_to_png(dirpath, 1440, 2560, 40.0, 72.0); } private: diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index bd27278ed6..5b0719ecfd 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -1,5 +1,4 @@ #include "Rasterizer.hpp" - #include // For rasterizing @@ -16,7 +15,13 @@ #include // For compression -#include +#ifdef WIN32 +inline char *strerror_r(int errnum, char *buf, size_t buflen) { + strerror_s(buf, buflen, errnum); + return buf; +} +#endif +#include namespace Slic3r { @@ -77,7 +82,7 @@ public: raw_renderer_.clear(ColorBlack); } - inline const TBuffer& buffer() const { return buf_; } + inline TBuffer& buffer() { return buf_; } inline const Raster::Resolution resolution() { return resolution_; } @@ -153,16 +158,38 @@ void Raster::save(std::ostream& stream, Compression comp) { assert(impl_); switch(comp) { - case Compression::PNG: - case Compression::RAW: + case Compression::PNG: { + + png::writer wr(stream); + + wr.set_bit_depth(8); + wr.set_color_type(png::color_type_gray); + wr.set_width(resolution().width_px); + wr.set_height(resolution().height_px); + wr.set_compression_type(png::compression_type_default); + + wr.write_info(); + + auto& b = impl_->buffer(); + auto ptr = reinterpret_cast( b.data() ); + unsigned stride = + sizeof(Impl::TBuffer::value_type) * resolution().width_px; + + for(unsigned r = 0; r < resolution().height_px; r++, ptr+=stride) { + wr.write_row(ptr); + } + + break; + } + case Compression::RAW: { stream << "P5 " << impl_->resolution().width_px << " " << impl_->resolution().height_px << " " << "255 "; + stream.write(reinterpret_cast(impl_->buffer().data()), + impl_->buffer().size()*sizeof(Impl::TBuffer::value_type)); + } } - - stream.write(reinterpret_cast(impl_->buffer().data()), - impl_->buffer().size()*sizeof(Impl::TBuffer::value_type)); } } diff --git a/xs/src/png/COPYING b/xs/src/png/COPYING new file mode 100644 index 0000000000..04889ba11d --- /dev/null +++ b/xs/src/png/COPYING @@ -0,0 +1,25 @@ +Copying png++ is subject to the following license: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/xs/src/png/color.hpp b/xs/src/png/color.hpp new file mode 100644 index 0000000000..b5ffde2c4e --- /dev/null +++ b/xs/src/png/color.hpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_COLOR_HPP_INCLUDED +#define PNGPP_COLOR_HPP_INCLUDED + +#include "types.hpp" + +namespace png +{ + + /** + * \brief PNG color struct extension. Adds constructors. + */ + struct color + : png_color + { + explicit color(byte r = 0, byte g = 0, byte b = 0) + { + this->red = r; + this->green = g; + this->blue = b; + } + + /** + * \brief Initializes color with a copy of png_color object. + */ + color(png_color const& other) + { + this->red = other.red; + this->green = other.green; + this->blue = other.blue; + } + }; + +} // namespace png + +#endif // PNGPP_COLOR_HPP_INCLUDED diff --git a/xs/src/png/end_info.hpp b/xs/src/png/end_info.hpp new file mode 100644 index 0000000000..09590596df --- /dev/null +++ b/xs/src/png/end_info.hpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_END_INFO_HPP_INCLUDED +#define PNGPP_END_INFO_HPP_INCLUDED + +#include "info_base.hpp" + +namespace png +{ + + /** + * \brief Internal class to hold PNG ending %info. + * + * \see info, info_base + */ + class end_info + : public info_base + { + public: + end_info(io_base& io, png_struct* png) + : info_base(io, png) + { + } + + void destroy() + { + assert(m_info); + png_destroy_info_struct(m_png, & m_info); + } + + void read() + { + png_read_end(m_png, m_info); + } + + void write() const + { + png_write_end(m_png, m_info); + } + + // TODO: add methods to read/write text comments etc. + }; + +} // namespace png + +#endif // PNGPP_END_INFO_HPP_INCLUDED diff --git a/xs/src/png/error.hpp b/xs/src/png/error.hpp new file mode 100644 index 0000000000..834cf1b3a9 --- /dev/null +++ b/xs/src/png/error.hpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_ERROR_HPP_INCLUDED +#define PNGPP_ERROR_HPP_INCLUDED + +/* check if we have strerror_s or strerror_r, prefer the former which is C11 std */ +#ifdef __STDC_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 +#include + +#define HAVE_STRERROR_S 1 +#else +#undef HAVE_STRERROR_S +#endif + +#include +#include +#include +#include +#include + +namespace png +{ + + /** + * \brief Exception class to represent runtime errors related to + * png++ operation. + */ + class error + : public std::runtime_error + { + public: + /** + * \param message error description + */ + explicit error(std::string const& message) + : std::runtime_error(message) + { + } + }; + + /** + * \brief Exception class to represent standard library errors + * (generally IO). + * + * \see reader, writer + */ + class std_error + : public std::runtime_error + { + public: + /** + * Constructs an std_error object. The \a message string is + * appended with ": " and the error description as + * returned by \c strerror(\a error). + * + * \param message error description + * \param error error number + */ + explicit std_error(std::string const& message, int errnum = errno) + : std::runtime_error((message + ": ") + thread_safe_strerror(errnum)) + { + } + + protected: + static std::string thread_safe_strerror(int errnum) + { +#define ERRBUF_SIZE 512 + char buf[ERRBUF_SIZE] = { 0 }; + +#ifdef HAVE_STRERROR_S + strerror_s(buf, ERRBUF_SIZE, errnum); + return std::string(buf); +#else +#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE + strerror_r(errnum, buf, ERRBUF_SIZE); + return std::string(buf); +#else + /* GNU variant can return a pointer to static buffer instead of buf */ + return std::string(strerror_r(errnum, buf, ERRBUF_SIZE)); +#endif +#endif + +#undef ERRBUF_SIZE + } + }; + +} // namespace png + +#endif // PNGPP_ERROR_HPP_INCLUDED diff --git a/xs/src/png/image_info.hpp b/xs/src/png/image_info.hpp new file mode 100644 index 0000000000..8407bc18b8 --- /dev/null +++ b/xs/src/png/image_info.hpp @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_IMAGE_INFO_HPP_INCLUDED +#define PNGPP_IMAGE_INFO_HPP_INCLUDED + +#include "types.hpp" +#include "palette.hpp" +#include "tRNS.hpp" +#include "pixel_traits.hpp" + +namespace png +{ + + /** + * \brief Holds information about PNG image. + * + * \see image, generator, consumer + */ + class image_info + { + public: + /** + * \brief Constructs the image_info object with default values + * for color_type, interlace_type, compression_method and + * filter_type. + */ + image_info() + : m_width(0), + m_height(0), + m_bit_depth(0), + m_color_type(color_type_none), + m_interlace_type(interlace_none), + m_compression_type(compression_type_default), + m_filter_type(filter_type_default), + m_gamma(0.0) + { + } + + uint_32 get_width() const + { + return m_width; + } + + void set_width(uint_32 width) + { + m_width = width; + } + + uint_32 get_height() const + { + return m_height; + } + + void set_height(uint_32 height) + { + m_height = height; + } + + color_type get_color_type() const + { + return m_color_type; + } + + void set_color_type(color_type color_space) + { + m_color_type = color_space; + } + + int get_bit_depth() const + { + return m_bit_depth; + } + + void set_bit_depth(int bit_depth) + { + m_bit_depth = bit_depth; + } + + interlace_type get_interlace_type() const + { + return m_interlace_type; + } + + void set_interlace_type(interlace_type interlace) + { + m_interlace_type = interlace; + } + + compression_type get_compression_type() const + { + return m_compression_type; + } + + void set_compression_type(compression_type compression) + { + m_compression_type = compression; + } + + filter_type get_filter_type() const + { + return m_filter_type; + } + + void set_filter_type(filter_type filter) + { + m_filter_type = filter; + } + + palette const& get_palette() const + { + return m_palette; + } + + palette& get_palette() + { + return m_palette; + } + + void set_palette(palette const& plte) + { + m_palette = plte; + } + + /** + * \brief Removes all entries from the palette. + */ + void drop_palette() + { + m_palette.clear(); + } + + tRNS const& get_tRNS() const + { + return m_tRNS; + } + + tRNS& get_tRNS() + { + return m_tRNS; + } + + void set_tRNS(tRNS const& trns) + { + m_tRNS = trns; + } + + double get_gamma() const + { + return m_gamma; + } + + void set_gamma(double gamma) + { + m_gamma = gamma; + } + + protected: + uint_32 m_width; + uint_32 m_height; + int m_bit_depth; + color_type m_color_type; + interlace_type m_interlace_type; + compression_type m_compression_type; + filter_type m_filter_type; + palette m_palette; + tRNS m_tRNS; + double m_gamma; + }; + + /** + * \brief Returns an image_info object with color_type and + * bit_depth fields setup appropriate for the \c pixel type. + */ + template< typename pixel > + image_info + make_image_info() + { + typedef pixel_traits< pixel > traits; + image_info info; + info.set_color_type(traits::get_color_type()); + info.set_bit_depth(traits::get_bit_depth()); + return info; + } + +} // namespace png + +#endif // PNGPP_IMAGE_INFO_HPP_INCLUDED diff --git a/xs/src/png/info.hpp b/xs/src/png/info.hpp new file mode 100644 index 0000000000..3f3cf09c31 --- /dev/null +++ b/xs/src/png/info.hpp @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_INFO_HPP_INCLUDED +#define PNGPP_INFO_HPP_INCLUDED + +#include +#include "info_base.hpp" +#include "image_info.hpp" + +namespace png +{ + + /** + * \brief Holds information about PNG image. Adapter class for IO + * image operations. + */ + class info + : public info_base, + public image_info + { + public: + info(io_base& io, png_struct* png) + : info_base(io, png) + { + } + + void read() + { + assert(m_png); + assert(m_info); + + png_read_info(m_png, m_info); + png_get_IHDR(m_png, + m_info, + & m_width, + & m_height, + reinterpret_cast< int* >(& m_bit_depth), + reinterpret_cast< int* >(& m_color_type), + reinterpret_cast< int* >(& m_interlace_type), + reinterpret_cast< int* >(& m_compression_type), + reinterpret_cast< int* >(& m_filter_type)); + + if (png_get_valid(m_png, m_info, chunk_PLTE) == chunk_PLTE) + { + png_color* colors = 0; + int count = 0; + png_get_PLTE(m_png, m_info, & colors, & count); + m_palette.assign(colors, colors + count); + } + +#ifdef PNG_tRNS_SUPPORTED + if (png_get_valid(m_png, m_info, chunk_tRNS) == chunk_tRNS) + { + if (m_color_type == color_type_palette) + { + int count; + byte* values; + if (png_get_tRNS(m_png, m_info, & values, & count, NULL) + != PNG_INFO_tRNS) + { + throw error("png_get_tRNS() failed"); + } + m_tRNS.assign(values, values + count); + } + } +#endif + +#ifdef PNG_gAMA_SUPPORTED + if (png_get_valid(m_png, m_info, chunk_gAMA) == chunk_gAMA) + { +#ifdef PNG_FLOATING_POINT_SUPPORTED + if (png_get_gAMA(m_png, m_info, &m_gamma) != PNG_INFO_gAMA) + { + throw error("png_get_gAMA() failed"); + } +#else + png_fixed_point gamma = 0; + if (png_get_gAMA_fixed(m_png, m_info, &gamma) != PNG_INFO_gAMA) + { + throw error("png_get_gAMA_fixed() failed"); + } + m_gamma = gamma / 100000.0; +#endif + } +#endif + } + + void write() const + { + assert(m_png); + assert(m_info); + + sync_ihdr(); + if (m_color_type == color_type_palette) + { + if (! m_palette.empty()) + { + png_set_PLTE(m_png, m_info, + const_cast< color* >(& m_palette[0]), + (int) m_palette.size()); + } + if (! m_tRNS.empty()) + { +#ifdef PNG_tRNS_SUPPORTED + png_set_tRNS(m_png, m_info, + const_cast< byte* >(& m_tRNS[0]), + m_tRNS.size(), + NULL); +#else + throw error("attempted to write tRNS chunk; recompile with PNG_tRNS_SUPPORTED"); +#endif + } + } + + if (m_gamma > 0) + { +#ifdef PNG_gAMA_SUPPORTED +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_gAMA(m_png, m_info, m_gamma); +#else + png_set_gAMA_fixed(m_png, m_info, + (png_fixed_point)(m_gamma * 100000)); +#endif +#else + throw error("attempted to write gAMA chunk; recompile with PNG_gAMA_SUPPORTED"); +#endif + } + + png_write_info(m_png, m_info); + } + + void update() + { + assert(m_png); + assert(m_info); + + sync_ihdr(); + png_read_update_info(m_png, m_info); + } + + protected: + void sync_ihdr(void) const + { + png_set_IHDR(m_png, + m_info, + m_width, + m_height, + m_bit_depth, + m_color_type, + m_interlace_type, + m_compression_type, + m_filter_type); + } + }; + +} // namespace png + +#endif // PNGPP_INFO_HPP_INCLUDED diff --git a/xs/src/png/info_base.hpp b/xs/src/png/info_base.hpp new file mode 100644 index 0000000000..45e1542963 --- /dev/null +++ b/xs/src/png/info_base.hpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_INFO_BASE_HPP_INCLUDED +#define PNGPP_INFO_BASE_HPP_INCLUDED + +#include +#include "error.hpp" +#include "types.hpp" + +namespace png +{ + + class io_base; + + /** + * \brief Internal class to hold PNG info or end_info. + */ + class info_base + { + info_base(info_base const&); + info_base& operator=(info_base const&); + + public: + info_base(io_base& io, png_struct* png) + : m_io(io), + m_png(png), + m_info(png_create_info_struct(m_png)) + { + } + + png_info* get_png_info() const + { + return m_info; + } + + png_info** get_png_info_ptr() + { + return & m_info; + } + + protected: + io_base& m_io; + png_struct* m_png; + png_info* m_info; + }; + +} // namespace png + +#endif // PNGPP_INFO_BASE_HPP_INCLUDED diff --git a/xs/src/png/io_base.hpp b/xs/src/png/io_base.hpp new file mode 100644 index 0000000000..3c2d830435 --- /dev/null +++ b/xs/src/png/io_base.hpp @@ -0,0 +1,467 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_IO_BASE_HPP_INCLUDED +#define PNGPP_IO_BASE_HPP_INCLUDED + +#include +#include +#include +#include "error.hpp" +#include "info.hpp" +#include "end_info.hpp" + +static void +trace_io_transform(char const* fmt, ...) +{ +#ifdef DEBUG_IO_TRANSFORM + va_list va; + va_start(va, fmt); + fprintf(stderr, "TRANSFORM_IO: "); + vfprintf(stderr, fmt, va); + va_end(va); +#endif +} +#define TRACE_IO_TRANSFORM trace_io_transform + +namespace png +{ + + /** + * \brief Base class for PNG reader/writer classes. + * + * \see reader, writer + */ + class io_base + { + io_base(io_base const&); + io_base& operator=(io_base const&); + + public: + explicit io_base(png_struct* png) + : m_png(png), + m_info(*this, m_png), + m_end_info(*this, m_png) + { + } + + ~io_base() + { + assert(! m_png); + assert(! m_info.get_png_info()); + assert(! m_end_info.get_png_info()); + } + + png_struct* get_png_struct() const + { + return m_png; + } + + info& get_info() + { + return m_info; + } + + info const& get_info() const + { + return m_info; + } + + image_info const& get_image_info() const + { + return m_info; + } + + void set_image_info(image_info const& info) + { + static_cast< image_info& >(m_info) = info; // slice it + } + + end_info& get_end_info() + { + return m_end_info; + } + + end_info const& get_end_info() const + { + return m_end_info; + } + + ////////////////////////////////////////////////////////////////////// + // info accessors + // + uint_32 get_width() const + { + return m_info.get_width(); + } + + void set_width(uint_32 width) + { + m_info.set_width(width); + } + + uint_32 get_height() const + { + return m_info.get_height(); + } + + void set_height(uint_32 height) + { + m_info.set_height(height); + } + + color_type get_color_type() const + { + return m_info.get_color_type(); + } + + void set_color_type(color_type color_space) + { + m_info.set_color_type(color_space); + } + + int get_bit_depth() const + { + return m_info.get_bit_depth(); + } + + void set_bit_depth(int bit_depth) + { + m_info.set_bit_depth(bit_depth); + } + + interlace_type get_interlace_type() const + { + return m_info.get_interlace_type(); + } + + void set_interlace_type(interlace_type interlace) + { + m_info.set_interlace_type(interlace); + } + + compression_type get_compression_type() const + { + return m_info.get_compression_type(); + } + + void set_compression_type(compression_type compression) + { + m_info.set_compression_type(compression); + } + + filter_type get_filter_type() const + { + return m_info.get_filter_type(); + } + + void set_filter_type(filter_type filter) + { + m_info.set_filter_type(filter); + } + + ////////////////////////////////////////////////////////////////////// + + bool has_chunk(chunk id) + { + return png_get_valid(m_png, + m_info.get_png_info(), + uint_32(id)) == uint_32(id); + } + +#if defined(PNG_READ_EXPAND_SUPPORTED) + void set_gray_1_2_4_to_8() const + { + TRACE_IO_TRANSFORM("png_set_expand_gray_1_2_4_to_8\n"); + png_set_expand_gray_1_2_4_to_8(m_png); + } + + void set_palette_to_rgb() const + { + TRACE_IO_TRANSFORM("png_set_palette_to_rgb\n"); + png_set_palette_to_rgb(m_png); + } + + void set_tRNS_to_alpha() const + { + TRACE_IO_TRANSFORM("png_set_tRNS_to_alpha\n"); + png_set_tRNS_to_alpha(m_png); + } +#endif // defined(PNG_READ_EXPAND_SUPPORTED) + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) + void set_bgr() const + { + TRACE_IO_TRANSFORM("png_set_bgr\n"); + png_set_bgr(m_png); + } +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + void set_gray_to_rgb() const + { + TRACE_IO_TRANSFORM("png_set_gray_to_rgb\n"); + png_set_gray_to_rgb(m_png); + } +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED + void set_rgb_to_gray(rgb_to_gray_error_action error_action + = rgb_to_gray_silent, + double red_weight = -1.0, + double green_weight = -1.0) const + { + TRACE_IO_TRANSFORM("png_set_rgb_to_gray: error_action=%d," + " red_weight=%lf, green_weight=%lf\n", + error_action, red_weight, green_weight); + + png_set_rgb_to_gray(m_png, error_action, red_weight, green_weight); + } +#else + void set_rgb_to_gray(rgb_to_gray_error_action error_action + = rgb_to_gray_silent, + fixed_point red_weight = -1, + fixed_point green_weight = -1) const + { + TRACE_IO_TRANSFORM("png_set_rgb_to_gray_fixed: error_action=%d," + " red_weight=%d, green_weight=%d\n", + error_action, red_weight, green_weight); + + png_set_rgb_to_gray_fixed(m_png, error_action, + red_weight, green_weight); + } +#endif // PNG_FLOATING_POINT_SUPPORTED + + ////////////////////////////////////////////////////////////////////// + // alpha channel transformations + // +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) + void set_strip_alpha() const + { + TRACE_IO_TRANSFORM("png_set_strip_alpha\n"); + png_set_strip_alpha(m_png); + } +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) \ + || defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) + void set_swap_alpha() const + { + TRACE_IO_TRANSFORM("png_set_swap_alpha\n"); + png_set_swap_alpha(m_png); + } +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) \ + || defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) + void set_invert_alpha() const + { + TRACE_IO_TRANSFORM("png_set_invert_alpha\n"); + png_set_invert_alpha(m_png); + } +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) + void set_filler(uint_32 filler, filler_type type) const + { + TRACE_IO_TRANSFORM("png_set_filler: filler=%08x, type=%d\n", + filler, type); + + png_set_filler(m_png, filler, type); + } + +#if !defined(PNG_1_0_X) + void set_add_alpha(uint_32 filler, filler_type type) const + { + TRACE_IO_TRANSFORM("png_set_add_alpha: filler=%08x, type=%d\n", + filler, type); + + png_set_add_alpha(m_png, filler, type); + } +#endif +#endif // PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) + void set_swap() const + { + TRACE_IO_TRANSFORM("png_set_swap\n"); + png_set_swap(m_png); + } +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) + void set_packing() const + { + TRACE_IO_TRANSFORM("png_set_packing\n"); + png_set_packing(m_png); + } +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) \ + || defined(PNG_WRITE_PACKSWAP_SUPPORTED) + void set_packswap() const + { + TRACE_IO_TRANSFORM("png_set_packswap\n"); + png_set_packswap(m_png); + } +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + void set_shift(byte red_bits, byte green_bits, byte blue_bits, + byte alpha_bits = 0) const + { + TRACE_IO_TRANSFORM("png_set_shift: red_bits=%d, green_bits=%d," + " blue_bits=%d, alpha_bits=%d\n", + red_bits, green_bits, blue_bits, alpha_bits); + + if (get_color_type() != color_type_rgb + || get_color_type() != color_type_rgb_alpha) + { + throw error("set_shift: expected RGB or RGBA color type"); + } + color_info bits; + bits.red = red_bits; + bits.green = green_bits; + bits.blue = blue_bits; + bits.alpha = alpha_bits; + png_set_shift(m_png, & bits); + } + + void set_shift(byte gray_bits, byte alpha_bits = 0) const + { + TRACE_IO_TRANSFORM("png_set_shift: gray_bits=%d, alpha_bits=%d\n", + gray_bits, alpha_bits); + + if (get_color_type() != color_type_gray + || get_color_type() != color_type_gray_alpha) + { + throw error("set_shift: expected Gray or Gray+Alpha color type"); + } + color_info bits; + bits.gray = gray_bits; + bits.alpha = alpha_bits; + png_set_shift(m_png, & bits); + } +#endif // PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED + +#if defined(PNG_READ_INTERLACING_SUPPORTED) \ + || defined(PNG_WRITE_INTERLACING_SUPPORTED) + int set_interlace_handling() const + { + TRACE_IO_TRANSFORM("png_set_interlace_handling\n"); + return png_set_interlace_handling(m_png); + } +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) + void set_invert_mono() const + { + TRACE_IO_TRANSFORM("png_set_invert_mono\n"); + png_set_invert_mono(m_png); + } +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) + void set_strip_16() const + { + TRACE_IO_TRANSFORM("png_set_strip_16\n"); + png_set_strip_16(m_png); + } +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + void set_read_user_transform(png_user_transform_ptr transform_fn) + { + TRACE_IO_TRANSFORM("png_set_read_user_transform_fn\n"); + png_set_read_user_transform_fn(m_png, transform_fn); + } +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) \ + || defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + void set_user_transform_info(void* info, int bit_depth, int channels) + { + TRACE_IO_TRANSFORM("png_set_user_transform_info: bit_depth=%d," + " channels=%d\n", bit_depth, channels); + + png_set_user_transform_info(m_png, info, bit_depth, channels); + } +#endif + + protected: + void* get_io_ptr() const + { + return png_get_io_ptr(m_png); + } + + void set_error(char const* message) + { + assert(message); + m_error = message; + } + + void reset_error() + { + m_error.clear(); + } + +/* + std::string const& get_error() const + { + return m_error; + } +*/ + + bool is_error() const + { + return !m_error.empty(); + } + + void raise_error() + { + longjmp(png_jmpbuf(m_png), -1); + } + + static void raise_error(png_struct* png, char const* message) + { + io_base* io = static_cast< io_base* >(png_get_error_ptr(png)); + io->set_error(message); + io->raise_error(); + } + + png_struct* m_png; + info m_info; + end_info m_end_info; + std::string m_error; + }; + +} // namespace png + +#endif // PNGPP_IO_BASE_HPP_INCLUDED diff --git a/xs/src/png/palette.hpp b/xs/src/png/palette.hpp new file mode 100644 index 0000000000..917f280075 --- /dev/null +++ b/xs/src/png/palette.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_PALETTE_HPP_INCLUDED +#define PNGPP_PALETTE_HPP_INCLUDED + +#include +#include "color.hpp" + +namespace png +{ + + /** + * \brief The palette type. Currently implemented as \c std::vector + * of png::color. + */ + typedef std::vector< color > palette; + +} // namespace png + +#endif // PNGPP_PALETTE_HPP_INCLUDED diff --git a/xs/src/png/pixel_traits.hpp b/xs/src/png/pixel_traits.hpp new file mode 100644 index 0000000000..8ffdfeedb4 --- /dev/null +++ b/xs/src/png/pixel_traits.hpp @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_PIXEL_TRAITS_HPP_INCLUDED +#define PNGPP_PIXEL_TRAITS_HPP_INCLUDED + +#include +#include "types.hpp" + +namespace png +{ + + /** + * \brief Pixel traits class template. + * + * Provides information about pixel color type and components bit depth. + * Not implemented--see specializations. + * + * \see pixel_traits, pixel_traits + */ + template< typename pixel > struct pixel_traits; + + /** + * \brief Basic pixel traits class template. + * + * Provides common implementation for various pixel_traits<> + * specializations. + */ + template< typename pixel, + typename component, + color_type pixel_color_type, + int channels_value = sizeof(pixel) / sizeof(component), + int bit_depth_value = std::numeric_limits< component >::digits > + struct basic_pixel_traits + { + typedef pixel pixel_type; + typedef component component_type; + + static color_type get_color_type() + { + return pixel_color_type; + } + + static const int channels = channels_value; + static int get_channels() + { + return channels; + } + + static const int bit_depth = bit_depth_value; + static int get_bit_depth() + { + return bit_depth; + } + }; + + /** + * \brief Basic pixel traits class template for pixels with alpha + * channel. + */ + template< typename component > + struct basic_alpha_pixel_traits + { + /** + * \brief Returns the default alpha channel filler for full + * opacity. + */ + static component get_alpha_filler() + { + return std::numeric_limits< component >::max(); + } + }; + +} // namespace png + +#endif // PNGPP_PIXEL_TRAITS_HPP_INCLUDED diff --git a/xs/src/png/tRNS.hpp b/xs/src/png/tRNS.hpp new file mode 100644 index 0000000000..ff01816433 --- /dev/null +++ b/xs/src/png/tRNS.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_TRNS_HPP_INCLUDED +#define PNGPP_TRNS_HPP_INCLUDED + +#include +#include "color.hpp" + +namespace png +{ + + /** + * \brief The palette transparency map type. Currently + * implemented as \c std::vector of png::byte. + */ + typedef std::vector< byte > tRNS; + +} // namespace png + +#endif // PNGPP_TRNS_HPP_INCLUDED diff --git a/xs/src/png/types.hpp b/xs/src/png/types.hpp new file mode 100644 index 0000000000..1538d6bd28 --- /dev/null +++ b/xs/src/png/types.hpp @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_TYPES_HPP_INCLUDED +#define PNGPP_TYPES_HPP_INCLUDED + +#include + +namespace png +{ + + typedef png_byte byte; + typedef png_uint_16 uint_16; + typedef png_uint_32 uint_32; + typedef png_fixed_point fixed_point; + typedef png_color_8 color_info; + typedef png_color_16 color_info_16; + + enum color_type + { + color_type_none = -1, + color_type_gray = PNG_COLOR_TYPE_GRAY, + color_type_palette = PNG_COLOR_TYPE_PALETTE, + color_type_rgb = PNG_COLOR_TYPE_RGB, + color_type_rgb_alpha = PNG_COLOR_TYPE_RGB_ALPHA, + color_type_gray_alpha = PNG_COLOR_TYPE_GRAY_ALPHA, + color_type_rgba = PNG_COLOR_TYPE_RGBA, + color_type_ga = PNG_COLOR_TYPE_GA + }; + + enum color_mask + { + color_mask_palette = PNG_COLOR_MASK_PALETTE, + color_mask_color = PNG_COLOR_MASK_COLOR, + color_mask_rgb = color_mask_color, + color_mask_alpha = PNG_COLOR_MASK_ALPHA + }; + + enum filler_type + { + filler_before = PNG_FILLER_BEFORE, + filler_after = PNG_FILLER_AFTER + }; + + enum rgb_to_gray_error_action + { + rgb_to_gray_silent = 1, + rgb_to_gray_warning = 2, + rgb_to_gray_error = 3 + }; + + enum interlace_type + { + interlace_none = PNG_INTERLACE_NONE, + interlace_adam7 = PNG_INTERLACE_ADAM7 + }; + + enum compression_type + { + compression_type_base = PNG_COMPRESSION_TYPE_BASE, + compression_type_default = PNG_COMPRESSION_TYPE_DEFAULT + }; + + enum filter_type + { + filter_type_base = PNG_FILTER_TYPE_BASE, + intrapixel_differencing = PNG_INTRAPIXEL_DIFFERENCING, + filter_type_default = PNG_FILTER_TYPE_DEFAULT + }; + + enum chunk + { + chunk_gAMA = PNG_INFO_gAMA, + chunk_sBIT = PNG_INFO_sBIT, + chunk_cHRM = PNG_INFO_cHRM, + chunk_PLTE = PNG_INFO_PLTE, + chunk_tRNS = PNG_INFO_tRNS, + chunk_bKGD = PNG_INFO_bKGD, + chunk_hIST = PNG_INFO_hIST, + chunk_pHYs = PNG_INFO_pHYs, + chunk_oFFs = PNG_INFO_oFFs, + chunk_tIME = PNG_INFO_tIME, + chunk_pCAL = PNG_INFO_pCAL, + chunk_sRGB = PNG_INFO_sRGB, + chunk_iCCP = PNG_INFO_iCCP, + chunk_sPLT = PNG_INFO_sPLT, + chunk_sCAL = PNG_INFO_sCAL, + chunk_IDAT = PNG_INFO_IDAT + }; + +} // namespace png + +#endif // PNGPP_TYPES_HPP_INCLUDED diff --git a/xs/src/png/writer.hpp b/xs/src/png/writer.hpp new file mode 100644 index 0000000000..448dfd50b1 --- /dev/null +++ b/xs/src/png/writer.hpp @@ -0,0 +1,199 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_WRITER_HPP_INCLUDED +#define PNGPP_WRITER_HPP_INCLUDED + +#include +#include "io_base.hpp" + +namespace png +{ + + /** + * \brief PNG writer class template. This is the low-level + * writing interface--use image class or generator class to + * actually write images. + * + * The \c ostream template parameter specifies the type of output + * stream to work with. The \c ostream class should implement the + * minimum of the following interface: + * + * \code + * class my_ostream + * { + * public: + * void write(char const*, size_t); + * void flush(); + * bool good(); + * }; + * \endcode + * + * With the semantics similar to the \c std::ostream. Naturally, + * \c std::ostream fits this requirement and can be used with the + * writer class as is. + * + * \see image, reader, generator, io_base + */ + template< class ostream > + class writer + : public io_base + { + public: + /** + * \brief Constructs a writer prepared to write PNG image into + * a \a stream. + */ + explicit writer(ostream& stream) + : io_base(png_create_write_struct(PNG_LIBPNG_VER_STRING, + static_cast< io_base* >(this), + raise_error, + 0)) + { + png_set_write_fn(m_png, & stream, write_data, flush_data); + } + + ~writer() + { + m_end_info.destroy(); + png_destroy_write_struct(& m_png, m_info.get_png_info_ptr()); + } + + void write_png() const + { + if (setjmp(png_jmpbuf(m_png))) + { + throw error(m_error); + } + png_write_png(m_png, + m_info.get_png_info(), + /* transforms = */ 0, + /* params = */ 0); + } + + /** + * \brief Write info about PNG image. + */ + void write_info() const + { + if (setjmp(png_jmpbuf(m_png))) + { + throw error(m_error); + } + m_info.write(); + } + + /** + * \brief Writes a row of image data at a time. + */ + void write_row(byte* bytes) + { + if (setjmp(png_jmpbuf(m_png))) + { + throw error(m_error); + } + png_write_row(m_png, bytes); + } + + /** + * \brief Reads ending info about PNG image. + */ + void write_end_info() const + { + if (setjmp(png_jmpbuf(m_png))) + { + throw error(m_error); + } + m_end_info.write(); + } + + private: + static void write_data(png_struct* png, byte* data, png_size_t length) + { + io_base* io = static_cast< io_base* >(png_get_error_ptr(png)); + writer* wr = static_cast< writer* >(io); + wr->reset_error(); + ostream* stream = reinterpret_cast< ostream* >(png_get_io_ptr(png)); + try + { + stream->write(reinterpret_cast< char* >(data), length); + if (!stream->good()) + { + wr->set_error("ostream::write() failed"); + } + } + catch (std::exception const& error) + { + wr->set_error(error.what()); + } + catch (...) + { + assert(!"caught something wrong"); + wr->set_error("write_data: caught something wrong"); + } + if (wr->is_error()) + { + wr->raise_error(); + } + } + + static void flush_data(png_struct* png) + { + io_base* io = static_cast< io_base* >(png_get_error_ptr(png)); + writer* wr = static_cast< writer* >(io); + wr->reset_error(); + ostream* stream = reinterpret_cast< ostream* >(png_get_io_ptr(png)); + try + { + stream->flush(); + if (!stream->good()) + { + wr->set_error("ostream::flush() failed"); + } + } + catch (std::exception const& error) + { + wr->set_error(error.what()); + } + catch (...) + { + assert(!"caught something wrong"); + wr->set_error("flush_data: caught something wrong"); + } + if (wr->is_error()) + { + wr->raise_error(); + } + } + }; + +} // namespace png + +#endif // PNGPP_WRITER_HPP_INCLUDED From deabeaaa7fc48691c9b778e11a725f7bd93a0458 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Sun, 20 May 2018 23:39:52 +0200 Subject: [PATCH 0383/1150] Aligned frequently changing parameters according to presets settings on the Plater tab. Fixed missing adding of the Filaments preset settings(for multy material case) to the right_panel --- lib/Slic3r/GUI/Plater.pm | 3 ++- xs/src/slic3r/GUI/GUI.cpp | 4 ++-- xs/src/slic3r/GUI/OptionsGroup.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index e141c77326..a2c3b094e9 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -410,6 +410,7 @@ sub new { $presets->Add($text, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 4); $presets->Add($choice, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxBOTTOM, 1); } + $presets->Layout; } my $frequently_changed_parameters_sizer = Wx::BoxSizer->new(wxHORIZONTAL); @@ -1738,7 +1739,7 @@ sub on_extruders_change { my @presets = $choices->[0]->GetStrings; # initialize new choice - my $choice = Wx::BitmapComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); + my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); my $extruder_idx = scalar @$choices; EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down($extruder_idx, @_); } ); push @$choices, $choice; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 4789f4590b..a744bb09d5 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -809,8 +809,8 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl { DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; m_optgroup = std::make_shared(parent, "", config); -// const wxArrayInt& ar = preset_sizer->GetColWidths(); -// m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front(); // doesn't work + const wxArrayInt& ar = preset_sizer->GetColWidths(); + m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front()-4; // doesn't work m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ TabPrint* tab_print = nullptr; for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 657ad03c03..57659d03dd 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -150,11 +150,11 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* // Build a label if we have it wxStaticText* label=nullptr; if (label_width != 0) { - label = new wxStaticText(parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ": "), - wxDefaultPosition, staticbox ? wxSize(label_width, -1) : wxDefaultSize); + label = new wxStaticText(parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ":"), + wxDefaultPosition, wxSize(label_width, -1), staticbox ? 0 : wxALIGN_RIGHT); label->SetFont(label_font); label->Wrap(label_width); // avoid a Linux/GTK bug - grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT) | wxALIGN_CENTER_VERTICAL, 0); + grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5); if (line.label_tooltip.compare("") != 0) label->SetToolTip(line.label_tooltip); } @@ -170,7 +170,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* // if we have a single option with no sidetext just add it directly to the grid sizer auto sizer = new wxBoxSizer(wxHORIZONTAL); - grid_sizer->Add(sizer, 0, wxEXPAND | wxALL, 0); + grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM|wxTOP|wxLEFT), staticbox ? 0 : 1); if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) { const auto& option = option_set.front(); @@ -180,7 +180,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL); if (is_window_field(field)) sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, (option.opt.full_width ? wxEXPAND : 0) | - wxBOTTOM | wxTOP | wxALIGN_CENTER_VERTICAL, wxOSX ? 0 : 2); + wxBOTTOM | wxTOP | wxALIGN_CENTER_VERTICAL, (wxOSX||!staticbox) ? 0 : 2); if (is_sizer_field(field)) sizer->Add(field->getSizer(), 0, (option.opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0); return; From 53ddf724e1c3040b894af3e5d875fedeb387ced8 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 21 May 2018 10:51:47 +0200 Subject: [PATCH 0384/1150] Fixed object setting dialog on NVIDIA cards --- lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm index 908d5eff77..61a8f2a01e 100644 --- a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm @@ -46,6 +46,8 @@ sub new { $self->SetSizer($sizer); $self->SetMinSize($self->GetSize); + $self->Layout; + wxTheApp->restore_window_pos($self, "object_settings"); return $self; From 3291cbfdad7f1172016147befb3ec4c2b89d5ffb Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 21 May 2018 11:19:03 +0200 Subject: [PATCH 0385/1150] Fix of #889 --- xs/src/slic3r/GUI/3DScene.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index db1737e149..cb2e08e1ff 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -2457,7 +2457,7 @@ bool _3DScene::_travel_paths_by_type(const GCodePreviewData& preview_data, GLVol TypesList::iterator type = std::find(types.begin(), types.end(), Type(polyline.type)); if (type != types.end()) { - type->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().max.z)); + type->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z)); type->volume->offsets.push_back(type->volume->indexed_vertex_array.quad_indices.size()); type->volume->offsets.push_back(type->volume->indexed_vertex_array.triangle_indices.size()); @@ -2523,7 +2523,7 @@ bool _3DScene::_travel_paths_by_feedrate(const GCodePreviewData& preview_data, G FeedratesList::iterator feedrate = std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate)); if (feedrate != feedrates.end()) { - feedrate->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().max.z)); + feedrate->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z)); feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.quad_indices.size()); feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.triangle_indices.size()); @@ -2589,7 +2589,7 @@ bool _3DScene::_travel_paths_by_tool(const GCodePreviewData& preview_data, GLVol ToolsList::iterator tool = std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id)); if (tool != tools.end()) { - tool->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().max.z)); + tool->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z)); tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.quad_indices.size()); tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.triangle_indices.size()); @@ -2613,7 +2613,10 @@ void _3DScene::_load_gcode_retractions(const GCodePreviewData& preview_data, GLV { volumes.volumes.emplace_back(volume); - for (const GCodePreviewData::Retraction::Position& position : preview_data.retraction.positions) + GCodePreviewData::Retraction::PositionsList copy(preview_data.retraction.positions); + std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position.z < p2.position.z; }); + + for (const GCodePreviewData::Retraction::Position& position : copy) { volume->print_zs.push_back(unscale(position.position.z)); volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size()); @@ -2641,7 +2644,10 @@ void _3DScene::_load_gcode_unretractions(const GCodePreviewData& preview_data, G { volumes.volumes.emplace_back(volume); - for (const GCodePreviewData::Retraction::Position& position : preview_data.unretraction.positions) + GCodePreviewData::Retraction::PositionsList copy(preview_data.unretraction.positions); + std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position.z < p2.position.z; }); + + for (const GCodePreviewData::Retraction::Position& position : copy) { volume->print_zs.push_back(unscale(position.position.z)); volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size()); From 308a0b5709086350e423afa258f7e2b1ad3bb440 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 21 May 2018 11:50:48 +0200 Subject: [PATCH 0386/1150] Remember output directory default value set to true --- xs/src/slic3r/GUI/Preferences.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xs/src/slic3r/GUI/Preferences.cpp b/xs/src/slic3r/GUI/Preferences.cpp index cb7ac92a69..2500afa136 100644 --- a/xs/src/slic3r/GUI/Preferences.cpp +++ b/xs/src/slic3r/GUI/Preferences.cpp @@ -35,8 +35,8 @@ void PreferencesDialog::build() def.type = coBool; def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory " "instead of the one containing the input files."); - def.default_value = new ConfigOptionBool{ app_config->get("remember_output_path")[0] == '1' }; // 1; - Option option(def, "remember_output_path"); + def.default_value = new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path")[0] == '1' : true }; // 1; + Option option(def, "remember_output_path"); m_optgroup->append_single_option_line(option); def.label = L("Auto-center parts"); From 64b905820d00bad48b43f7d5ba36848462814976 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 21 May 2018 12:34:31 +0200 Subject: [PATCH 0387/1150] Fixed bugs with non-correct update of buttons enable. Set minimum size for the scrolled_window_panel. --- lib/Slic3r/GUI/Plater.pm | 1 + lib/Slic3r/GUI/Plater/3D.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a2c3b094e9..0fa651b192 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -230,6 +230,7 @@ sub new { ### Scrolled Window for info boxes my $scrolled_window_sizer = Wx::BoxSizer->new(wxVERTICAL); + $scrolled_window_sizer->SetMinSize([310, -1]); my $scrolled_window_panel = Wx::ScrolledWindow->new($self->{right_panel}, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); $scrolled_window_panel->SetSizer($scrolled_window_sizer); $scrolled_window_panel->SetScrollbars(1, 1, 1, 1); diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index c9c9542762..c3521a4dad 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -245,7 +245,7 @@ sub reload_scene { $self->set_warning_enabled(0); $self->volumes->update_outside_state($self->{config}, 1); Slic3r::GUI::_3DScene::reset_warning_texture(); - $self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons); + $self->on_enable_action_buttons->(scalar @{$self->{model}->objects} > 0) if ($self->on_enable_action_buttons); } } else { $self->set_warning_enabled(0); From 7cff6ef6dba33055179ab30c12016a1ab25eec99 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 21 May 2018 13:08:02 +0200 Subject: [PATCH 0388/1150] Shaders loaded from files --- lib/Slic3r/GUI/3DScene.pm | 547 +++++++++++---------- resources/shaders/gouraud.fs | 18 + resources/shaders/gouraud.vs | 70 +++ resources/shaders/variable_layer_height.fs | 40 ++ resources/shaders/variable_layer_height.vs | 46 ++ xs/src/slic3r/GUI/GLShader.cpp | 47 +- xs/src/slic3r/GUI/GLShader.hpp | 6 +- xs/xsp/GUI_3DScene.xsp | 3 +- 8 files changed, 504 insertions(+), 273 deletions(-) create mode 100644 resources/shaders/gouraud.fs create mode 100644 resources/shaders/gouraud.vs create mode 100644 resources/shaders/variable_layer_height.fs create mode 100644 resources/shaders/variable_layer_height.vs diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 17e2e63775..72fdd6d6af 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -321,7 +321,10 @@ sub layer_editing_enabled { $self->SetCurrent($self->GetContext); my $shader = new Slic3r::GUI::_3DScene::GLShader; my $error_message; - if (! $shader->load($self->_fragment_shader_variable_layer_height, $self->_vertex_shader_variable_layer_height)) { +#============================================================================================================================== + if (! $shader->load_from_file("variable_layer_height.fs", "variable_layer_height.vs")) { +# if (! $shader->load_from_text($self->_fragment_shader_variable_layer_height, $self->_vertex_shader_variable_layer_height)) { +#============================================================================================================================== # Compilation or linking of the shaders failed. $error_message = "Cannot compile an OpenGL Shader, therefore the Variable Layer Editing will be disabled.\n\n" . $shader->last_error; @@ -1375,8 +1378,10 @@ sub InitGL { if ($self->UseVBOs) { my $shader = new Slic3r::GUI::_3DScene::GLShader; - if (! $shader->load($self->_fragment_shader_Gouraud, $self->_vertex_shader_Gouraud)) { -# if (! $shader->load($self->_fragment_shader_Phong, $self->_vertex_shader_Phong)) { +#=================================================================================================================================== + if (! $shader->load_from_file("gouraud.fs", "gouraud.vs")) { +## if (! $shader->load($self->_fragment_shader_Phong, $self->_vertex_shader_Phong)) { +#=================================================================================================================================== print "Compilaton of path shader failed: \n" . $shader->last_error . "\n"; $shader = undef; } else { @@ -2051,273 +2056,275 @@ sub _report_opengl_state } } -sub _vertex_shader_Gouraud { - return <<'VERTEX'; -#version 110 - -#define INTENSITY_CORRECTION 0.6 - -// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31) -const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); -#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SHININESS 20.0 - -// normalized values for (1./1.43, 0.2/1.43, 1./1.43) -const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); -#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) -//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) -//#define LIGHT_FRONT_SHININESS 5.0 - -#define INTENSITY_AMBIENT 0.3 - -const vec3 ZERO = vec3(0.0, 0.0, 0.0); - -struct PrintBoxDetection -{ - vec3 min; - vec3 max; - // xyz contains the offset, if w == 1.0 detection needs to be performed - vec4 volume_origin; -}; - -uniform PrintBoxDetection print_box; - -// x = tainted, y = specular; -varying vec2 intensity; - -varying vec3 delta_box_min; -varying vec3 delta_box_max; - -void main() -{ - // First transform the normal into camera space and normalize the result. - vec3 normal = normalize(gl_NormalMatrix * gl_Normal); - - // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. - // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. - float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); - - intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; - intensity.y = 0.0; - - if (NdotL > 0.0) - intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); - - // Perform the same lighting calculation for the 2nd light source (no specular applied). - NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); - intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; - - // compute deltas for out of print volume detection (world coordinates) - if (print_box.volume_origin.w == 1.0) - { - vec3 v = gl_Vertex.xyz + print_box.volume_origin.xyz; - delta_box_min = v - print_box.min; - delta_box_max = v - print_box.max; - } - else - { - delta_box_min = ZERO; - delta_box_max = ZERO; - } - - gl_Position = ftransform(); -} - -VERTEX -} - -sub _fragment_shader_Gouraud { - return <<'FRAGMENT'; -#version 110 - -const vec3 ZERO = vec3(0.0, 0.0, 0.0); - -// x = tainted, y = specular; -varying vec2 intensity; - -varying vec3 delta_box_min; -varying vec3 delta_box_max; - -uniform vec4 uniform_color; - -void main() -{ - // if the fragment is outside the print volume -> use darker color - vec3 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(uniform_color.rgb, ZERO, 0.3333) : uniform_color.rgb; - gl_FragColor = vec4(vec3(intensity.y, intensity.y, intensity.y) + color * intensity.x, uniform_color.a); -} - -FRAGMENT -} - -sub _vertex_shader_Phong { - return <<'VERTEX'; -#version 110 - -varying vec3 normal; -varying vec3 eye; -void main(void) -{ - eye = normalize(vec3(gl_ModelViewMatrix * gl_Vertex)); - normal = normalize(gl_NormalMatrix * gl_Normal); - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; -} -VERTEX -} - -sub _fragment_shader_Phong { - return <<'FRAGMENT'; -#version 110 - -#define INTENSITY_CORRECTION 0.7 - -#define LIGHT_TOP_DIR -0.6/1.31, 0.6/1.31, 1./1.31 -#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SPECULAR (0.5 * INTENSITY_CORRECTION) -//#define LIGHT_TOP_SHININESS 50. -#define LIGHT_TOP_SHININESS 10. - -#define LIGHT_FRONT_DIR 1./1.43, 0.2/1.43, 1./1.43 -#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) -#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) -#define LIGHT_FRONT_SHININESS 50. - -#define INTENSITY_AMBIENT 0.0 - -varying vec3 normal; -varying vec3 eye; -uniform vec4 uniform_color; -void main() { - - float intensity_specular = 0.; - float intensity_tainted = 0.; - float intensity = max(dot(normal,vec3(LIGHT_TOP_DIR)), 0.0); - // if the vertex is lit compute the specular color - if (intensity > 0.0) { - intensity_tainted = LIGHT_TOP_DIFFUSE * intensity; - // compute the half vector - vec3 h = normalize(vec3(LIGHT_TOP_DIR) + eye); - // compute the specular term into spec - intensity_specular = LIGHT_TOP_SPECULAR * pow(max(dot(h, normal), 0.0), LIGHT_TOP_SHININESS); - } - intensity = max(dot(normal,vec3(LIGHT_FRONT_DIR)), 0.0); - // if the vertex is lit compute the specular color - if (intensity > 0.0) { - intensity_tainted += LIGHT_FRONT_DIFFUSE * intensity; - // compute the half vector -// vec3 h = normalize(vec3(LIGHT_FRONT_DIR) + eye); - // compute the specular term into spec -// intensity_specular += LIGHT_FRONT_SPECULAR * pow(max(dot(h,normal), 0.0), LIGHT_FRONT_SHININESS); - } - - gl_FragColor = max( - vec4(intensity_specular, intensity_specular, intensity_specular, 0.) + uniform_color * intensity_tainted, - INTENSITY_AMBIENT * uniform_color); - gl_FragColor.a = uniform_color.a; -} -FRAGMENT -} - -sub _vertex_shader_variable_layer_height { - return <<'VERTEX'; -#version 110 - -#define INTENSITY_CORRECTION 0.6 - -const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); -#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SHININESS 20.0 - -const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); -#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) -//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) -//#define LIGHT_FRONT_SHININESS 5.0 - -#define INTENSITY_AMBIENT 0.3 - -// x = tainted, y = specular; -varying vec2 intensity; - -varying float object_z; - -void main() -{ - // First transform the normal into camera space and normalize the result. - vec3 normal = normalize(gl_NormalMatrix * gl_Normal); - - // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. - // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. - float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); - - intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; - intensity.y = 0.0; - - if (NdotL > 0.0) - intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); - - // Perform the same lighting calculation for the 2nd light source (no specular) - NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); - - intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; - - // Scaled to widths of the Z texture. - object_z = gl_Vertex.z; - - gl_Position = ftransform(); -} - -VERTEX -} - -sub _fragment_shader_variable_layer_height { - return <<'FRAGMENT'; -#version 110 - -#define M_PI 3.1415926535897932384626433832795 - -// 2D texture (1D texture split by the rows) of color along the object Z axis. -uniform sampler2D z_texture; -// Scaling from the Z texture rows coordinate to the normalized texture row coordinate. -uniform float z_to_texture_row; -uniform float z_texture_row_to_normalized; -uniform float z_cursor; -uniform float z_cursor_band_width; - -// x = tainted, y = specular; -varying vec2 intensity; - -varying float object_z; - -void main() -{ - float object_z_row = z_to_texture_row * object_z; - // Index of the row in the texture. - float z_texture_row = floor(object_z_row); - // Normalized coordinate from 0. to 1. - float z_texture_col = object_z_row - z_texture_row; - float z_blend = 0.25 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) * 1.8 / z_cursor_band_width))) + 0.25; - // Calculate level of detail from the object Z coordinate. - // This makes the slowly sloping surfaces to be show with high detail (with stripes), - // and the vertical surfaces to be shown with low detail (no stripes) - float z_in_cells = object_z_row * 190.; - // Gradient of Z projected on the screen. - float dx_vtc = dFdx(z_in_cells); - float dy_vtc = dFdy(z_in_cells); - float lod = clamp(0.5 * log2(max(dx_vtc*dx_vtc, dy_vtc*dy_vtc)), 0., 1.); - // Sample the Z texture. Texture coordinates are normalized to <0, 1>. - vec4 color = - mix(texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.), - texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.), lod); - - // Mix the final color. - gl_FragColor = - vec4(intensity.y, intensity.y, intensity.y, 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend); -} - -FRAGMENT -} +#=================================================================================================================================== +#sub _vertex_shader_Gouraud { +# return <<'VERTEX'; +##version 110 +# +##define INTENSITY_CORRECTION 0.6 +# +#// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31) +#const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); +##define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) +##define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) +##define LIGHT_TOP_SHININESS 20.0 +# +#// normalized values for (1./1.43, 0.2/1.43, 1./1.43) +#const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); +##define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) +#//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) +#//#define LIGHT_FRONT_SHININESS 5.0 +# +##define INTENSITY_AMBIENT 0.3 +# +#const vec3 ZERO = vec3(0.0, 0.0, 0.0); +# +#struct PrintBoxDetection +#{ +# vec3 min; +# vec3 max; +# // xyz contains the offset, if w == 1.0 detection needs to be performed +# vec4 volume_origin; +#}; +# +#uniform PrintBoxDetection print_box; +# +#// x = tainted, y = specular; +#varying vec2 intensity; +# +#varying vec3 delta_box_min; +#varying vec3 delta_box_max; +# +#void main() +#{ +# // First transform the normal into camera space and normalize the result. +# vec3 normal = normalize(gl_NormalMatrix * gl_Normal); +# +# // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. +# // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. +# float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); +# +# intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; +# intensity.y = 0.0; +# +# if (NdotL > 0.0) +# intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); +# +# // Perform the same lighting calculation for the 2nd light source (no specular applied). +# NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); +# intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; +# +# // compute deltas for out of print volume detection (world coordinates) +# if (print_box.volume_origin.w == 1.0) +# { +# vec3 v = gl_Vertex.xyz + print_box.volume_origin.xyz; +# delta_box_min = v - print_box.min; +# delta_box_max = v - print_box.max; +# } +# else +# { +# delta_box_min = ZERO; +# delta_box_max = ZERO; +# } +# +# gl_Position = ftransform(); +#} +# +#VERTEX +#} +# +#sub _fragment_shader_Gouraud { +# return <<'FRAGMENT'; +##version 110 +# +#const vec3 ZERO = vec3(0.0, 0.0, 0.0); +# +#// x = tainted, y = specular; +#varying vec2 intensity; +# +#varying vec3 delta_box_min; +#varying vec3 delta_box_max; +# +#uniform vec4 uniform_color; +# +#void main() +#{ +# // if the fragment is outside the print volume -> use darker color +# vec3 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(uniform_color.rgb, ZERO, 0.3333) : uniform_color.rgb; +# gl_FragColor = vec4(vec3(intensity.y, intensity.y, intensity.y) + color * intensity.x, uniform_color.a); +#} +# +#FRAGMENT +#} +# +#sub _vertex_shader_Phong { +# return <<'VERTEX'; +##version 110 +# +#varying vec3 normal; +#varying vec3 eye; +#void main(void) +#{ +# eye = normalize(vec3(gl_ModelViewMatrix * gl_Vertex)); +# normal = normalize(gl_NormalMatrix * gl_Normal); +# gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +#} +#VERTEX +#} +# +#sub _fragment_shader_Phong { +# return <<'FRAGMENT'; +##version 110 +# +##define INTENSITY_CORRECTION 0.7 +# +##define LIGHT_TOP_DIR -0.6/1.31, 0.6/1.31, 1./1.31 +##define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) +##define LIGHT_TOP_SPECULAR (0.5 * INTENSITY_CORRECTION) +#//#define LIGHT_TOP_SHININESS 50. +##define LIGHT_TOP_SHININESS 10. +# +##define LIGHT_FRONT_DIR 1./1.43, 0.2/1.43, 1./1.43 +##define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) +##define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) +##define LIGHT_FRONT_SHININESS 50. +# +##define INTENSITY_AMBIENT 0.0 +# +#varying vec3 normal; +#varying vec3 eye; +#uniform vec4 uniform_color; +#void main() { +# +# float intensity_specular = 0.; +# float intensity_tainted = 0.; +# float intensity = max(dot(normal,vec3(LIGHT_TOP_DIR)), 0.0); +# // if the vertex is lit compute the specular color +# if (intensity > 0.0) { +# intensity_tainted = LIGHT_TOP_DIFFUSE * intensity; +# // compute the half vector +# vec3 h = normalize(vec3(LIGHT_TOP_DIR) + eye); +# // compute the specular term into spec +# intensity_specular = LIGHT_TOP_SPECULAR * pow(max(dot(h, normal), 0.0), LIGHT_TOP_SHININESS); +# } +# intensity = max(dot(normal,vec3(LIGHT_FRONT_DIR)), 0.0); +# // if the vertex is lit compute the specular color +# if (intensity > 0.0) { +# intensity_tainted += LIGHT_FRONT_DIFFUSE * intensity; +# // compute the half vector +#// vec3 h = normalize(vec3(LIGHT_FRONT_DIR) + eye); +# // compute the specular term into spec +#// intensity_specular += LIGHT_FRONT_SPECULAR * pow(max(dot(h,normal), 0.0), LIGHT_FRONT_SHININESS); +# } +# +# gl_FragColor = max( +# vec4(intensity_specular, intensity_specular, intensity_specular, 0.) + uniform_color * intensity_tainted, +# INTENSITY_AMBIENT * uniform_color); +# gl_FragColor.a = uniform_color.a; +#} +#FRAGMENT +#} +# +#sub _vertex_shader_variable_layer_height { +# return <<'VERTEX'; +##version 110 +# +##define INTENSITY_CORRECTION 0.6 +# +#const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); +##define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) +##define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) +##define LIGHT_TOP_SHININESS 20.0 +# +#const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); +##define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) +#//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) +#//#define LIGHT_FRONT_SHININESS 5.0 +# +##define INTENSITY_AMBIENT 0.3 +# +#// x = tainted, y = specular; +#varying vec2 intensity; +# +#varying float object_z; +# +#void main() +#{ +# // First transform the normal into camera space and normalize the result. +# vec3 normal = normalize(gl_NormalMatrix * gl_Normal); +# +# // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. +# // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. +# float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); +# +# intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; +# intensity.y = 0.0; +# +# if (NdotL > 0.0) +# intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); +# +# // Perform the same lighting calculation for the 2nd light source (no specular) +# NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); +# +# intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; +# +# // Scaled to widths of the Z texture. +# object_z = gl_Vertex.z; +# +# gl_Position = ftransform(); +#} +# +#VERTEX +#} +# +#sub _fragment_shader_variable_layer_height { +# return <<'FRAGMENT'; +##version 110 +# +##define M_PI 3.1415926535897932384626433832795 +# +#// 2D texture (1D texture split by the rows) of color along the object Z axis. +#uniform sampler2D z_texture; +#// Scaling from the Z texture rows coordinate to the normalized texture row coordinate. +#uniform float z_to_texture_row; +#uniform float z_texture_row_to_normalized; +#uniform float z_cursor; +#uniform float z_cursor_band_width; +# +#// x = tainted, y = specular; +#varying vec2 intensity; +# +#varying float object_z; +# +#void main() +#{ +# float object_z_row = z_to_texture_row * object_z; +# // Index of the row in the texture. +# float z_texture_row = floor(object_z_row); +# // Normalized coordinate from 0. to 1. +# float z_texture_col = object_z_row - z_texture_row; +# float z_blend = 0.25 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) * 1.8 / z_cursor_band_width))) + 0.25; +# // Calculate level of detail from the object Z coordinate. +# // This makes the slowly sloping surfaces to be show with high detail (with stripes), +# // and the vertical surfaces to be shown with low detail (no stripes) +# float z_in_cells = object_z_row * 190.; +# // Gradient of Z projected on the screen. +# float dx_vtc = dFdx(z_in_cells); +# float dy_vtc = dFdy(z_in_cells); +# float lod = clamp(0.5 * log2(max(dx_vtc*dx_vtc, dy_vtc*dy_vtc)), 0., 1.); +# // Sample the Z texture. Texture coordinates are normalized to <0, 1>. +# vec4 color = +# mix(texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.), +# texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.), lod); +# +# // Mix the final color. +# gl_FragColor = +# vec4(intensity.y, intensity.y, intensity.y, 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend); +#} +# +#FRAGMENT +#} +#=================================================================================================================================== # The 3D canvas to display objects and tool paths. package Slic3r::GUI::3DScene; diff --git a/resources/shaders/gouraud.fs b/resources/shaders/gouraud.fs new file mode 100644 index 0000000000..9edc8fa769 --- /dev/null +++ b/resources/shaders/gouraud.fs @@ -0,0 +1,18 @@ +#version 110 + +const vec3 ZERO = vec3(0.0, 0.0, 0.0); + +// x = tainted, y = specular; +varying vec2 intensity; + +varying vec3 delta_box_min; +varying vec3 delta_box_max; + +uniform vec4 uniform_color; + +void main() +{ + // if the fragment is outside the print volume -> use darker color + vec3 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(uniform_color.rgb, ZERO, 0.3333) : uniform_color.rgb; + gl_FragColor = vec4(vec3(intensity.y, intensity.y, intensity.y) + color * intensity.x, uniform_color.a); +} diff --git a/resources/shaders/gouraud.vs b/resources/shaders/gouraud.vs new file mode 100644 index 0000000000..22ba91a934 --- /dev/null +++ b/resources/shaders/gouraud.vs @@ -0,0 +1,70 @@ +#version 110 + +#define INTENSITY_CORRECTION 0.6 + +// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31) +const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); +#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) +#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) +#define LIGHT_TOP_SHININESS 20.0 + +// normalized values for (1./1.43, 0.2/1.43, 1./1.43) +const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); +#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) +//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) +//#define LIGHT_FRONT_SHININESS 5.0 + +#define INTENSITY_AMBIENT 0.3 + +const vec3 ZERO = vec3(0.0, 0.0, 0.0); + +struct PrintBoxDetection +{ + vec3 min; + vec3 max; + // xyz contains the offset, if w == 1.0 detection needs to be performed + vec4 volume_origin; +}; + +uniform PrintBoxDetection print_box; + +// x = tainted, y = specular; +varying vec2 intensity; + +varying vec3 delta_box_min; +varying vec3 delta_box_max; + +void main() +{ + // First transform the normal into camera space and normalize the result. + vec3 normal = normalize(gl_NormalMatrix * gl_Normal); + + // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. + // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. + float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); + + intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; + intensity.y = 0.0; + + if (NdotL > 0.0) + intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); + + // Perform the same lighting calculation for the 2nd light source (no specular applied). + NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); + intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; + + // compute deltas for out of print volume detection (world coordinates) + if (print_box.volume_origin.w == 1.0) + { + vec3 v = gl_Vertex.xyz + print_box.volume_origin.xyz; + delta_box_min = v - print_box.min; + delta_box_max = v - print_box.max; + } + else + { + delta_box_min = ZERO; + delta_box_max = ZERO; + } + + gl_Position = ftransform(); +} diff --git a/resources/shaders/variable_layer_height.fs b/resources/shaders/variable_layer_height.fs new file mode 100644 index 0000000000..f87e6627e4 --- /dev/null +++ b/resources/shaders/variable_layer_height.fs @@ -0,0 +1,40 @@ +#version 110 + +#define M_PI 3.1415926535897932384626433832795 + +// 2D texture (1D texture split by the rows) of color along the object Z axis. +uniform sampler2D z_texture; +// Scaling from the Z texture rows coordinate to the normalized texture row coordinate. +uniform float z_to_texture_row; +uniform float z_texture_row_to_normalized; +uniform float z_cursor; +uniform float z_cursor_band_width; + +// x = tainted, y = specular; +varying vec2 intensity; + +varying float object_z; + +void main() +{ + float object_z_row = z_to_texture_row * object_z; + // Index of the row in the texture. + float z_texture_row = floor(object_z_row); + // Normalized coordinate from 0. to 1. + float z_texture_col = object_z_row - z_texture_row; + float z_blend = 0.25 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) * 1.8 / z_cursor_band_width))) + 0.25; + // Calculate level of detail from the object Z coordinate. + // This makes the slowly sloping surfaces to be show with high detail (with stripes), + // and the vertical surfaces to be shown with low detail (no stripes) + float z_in_cells = object_z_row * 190.; + // Gradient of Z projected on the screen. + float dx_vtc = dFdx(z_in_cells); + float dy_vtc = dFdy(z_in_cells); + float lod = clamp(0.5 * log2(max(dx_vtc * dx_vtc, dy_vtc * dy_vtc)), 0., 1.); + // Sample the Z texture. Texture coordinates are normalized to <0, 1>. + vec4 color = mix(texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.), + texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.), lod); + + // Mix the final color. + gl_FragColor = vec4(intensity.y, intensity.y, intensity.y, 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend); +} diff --git a/resources/shaders/variable_layer_height.vs b/resources/shaders/variable_layer_height.vs new file mode 100644 index 0000000000..2c918c0d49 --- /dev/null +++ b/resources/shaders/variable_layer_height.vs @@ -0,0 +1,46 @@ +#version 110 + +#define INTENSITY_CORRECTION 0.6 + +const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); +#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) +#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) +#define LIGHT_TOP_SHININESS 20.0 + +const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); +#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) +//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) +//#define LIGHT_FRONT_SHININESS 5.0 + +#define INTENSITY_AMBIENT 0.3 + +// x = tainted, y = specular; +varying vec2 intensity; + +varying float object_z; + +void main() +{ + // First transform the normal into camera space and normalize the result. + vec3 normal = normalize(gl_NormalMatrix * gl_Normal); + + // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. + // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. + float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0); + + intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; + intensity.y = 0.0; + + if (NdotL > 0.0) + intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); + + // Perform the same lighting calculation for the 2nd light source (no specular) + NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); + + intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; + + // Scaled to widths of the Z texture. + object_z = gl_Vertex.z; + + gl_Position = ftransform(); +} diff --git a/xs/src/slic3r/GUI/GLShader.cpp b/xs/src/slic3r/GUI/GLShader.cpp index ce9a80f059..a888110d61 100644 --- a/xs/src/slic3r/GUI/GLShader.cpp +++ b/xs/src/slic3r/GUI/GLShader.cpp @@ -2,6 +2,11 @@ #include "GLShader.hpp" +//############################################################################################################################################ +#include "../../libslic3r/Utils.hpp" +#include +//############################################################################################################################################ + #include #include #include @@ -22,7 +27,10 @@ inline std::string gl_get_string_safe(GLenum param) return std::string(value ? value : "N/A"); } -bool GLShader::load(const char *fragment_shader, const char *vertex_shader) +//############################################################################################################################################ +bool GLShader::load_from_text(const char *fragment_shader, const char *vertex_shader) +//bool GLShader::load(const char *fragment_shader, const char *vertex_shader) +//############################################################################################################################################ { std::string gl_version = gl_get_string_safe(GL_VERSION); int major = atoi(gl_version.c_str()); @@ -123,6 +131,43 @@ bool GLShader::load(const char *fragment_shader, const char *vertex_shader) return true; } +//############################################################################################################################################ +bool GLShader::load_from_file(const char* fragment_shader_filename, const char* vertex_shader_filename) +{ + const std::string& path = resources_dir() + "/shaders/"; + + boost::nowide::ifstream vs(path + std::string(vertex_shader_filename), boost::nowide::ifstream::binary); + if (!vs.good()) + return false; + + vs.seekg(0, vs.end); + int file_length = vs.tellg(); + vs.seekg(0, vs.beg); + std::string vertex_shader(file_length, '\0'); + vs.read(const_cast(vertex_shader.data()), file_length); + if (!vs.good()) + return false; + + vs.close(); + + boost::nowide::ifstream fs(path + std::string(fragment_shader_filename), boost::nowide::ifstream::binary); + if (!fs.good()) + return false; + + fs.seekg(0, fs.end); + file_length = fs.tellg(); + fs.seekg(0, fs.beg); + std::string fragment_shader(file_length, '\0'); + fs.read(const_cast(fragment_shader.data()), file_length); + if (!fs.good()) + return false; + + fs.close(); + + return load_from_text(fragment_shader.c_str(), vertex_shader.c_str()); +} +//############################################################################################################################################ + void GLShader::release() { if (this->shader_program_id) { diff --git a/xs/src/slic3r/GUI/GLShader.hpp b/xs/src/slic3r/GUI/GLShader.hpp index d91463f195..7d52d879df 100644 --- a/xs/src/slic3r/GUI/GLShader.hpp +++ b/xs/src/slic3r/GUI/GLShader.hpp @@ -16,7 +16,11 @@ public: {} ~GLShader(); - bool load(const char *fragment_shader, const char *vertex_shader); +//############################################################################################################################################ + bool load_from_text(const char *fragment_shader, const char *vertex_shader); + bool load_from_file(const char* fragment_shader_filename, const char* vertex_shader_filename); +// bool load(const char *fragment_shader, const char *vertex_shader); +//############################################################################################################################################ void release(); int get_attrib_location(const char *name) const; diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index c55ee8fbdc..240e62dbac 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -8,7 +8,8 @@ GLShader(); ~GLShader(); - bool load(const char *fragment_shader, const char *vertex_shader); + bool load_from_text(const char *fragment_shader, const char *vertex_shader); + bool load_from_file(const char *fragment_shader, const char *vertex_shader); void release(); int get_attrib_location(const char *name) const; From 6b5c0073a7e067008abe63570476939706853204 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 21 May 2018 13:46:41 +0200 Subject: [PATCH 0389/1150] Model centered when exporting to png. Added some comments to the rasterization. --- xs/src/libslic3r/Print.cpp | 152 +++++++++++---------- xs/src/libslic3r/Print.hpp | 9 +- xs/src/libslic3r/Rasterizer/Rasterizer.cpp | 11 +- xs/src/libslic3r/Rasterizer/Rasterizer.hpp | 31 ++++- 4 files changed, 122 insertions(+), 81 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 5d596f9e6d..1da3d9ce23 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -15,10 +15,6 @@ // For png export of the sliced model #include #include -//#include -//#include -//#include -//#include #include "Rasterizer/Rasterizer.hpp" #include "tbb/parallel_for.h" @@ -1254,22 +1250,57 @@ void Print::set_status(int percent, const std::string &message) printf("Print::status %d => %s\n", percent, message.c_str()); } +/* + * Interface for a file printer of the slices. Implementation can be an SVG + * or PNG printer or any other format. + * + * The format argument spefies the output format of the printer and it enables + * different implementations of this class template for each supported format. + * + */ template class FilePrinter { public: + + // Draw an ExPolygon which is a polygon inside a slice on the specified layer. void drawPolygon(const ExPolygon& p, unsigned lyr); + + // Tell the printer how many layers should it consider. void layers(unsigned layernum); + + // Get the number of layers in the print. unsigned layers() const; + + /* Switch the a particular layer. If there where less layers then the + * specified layer number than an appripriate number of layers will be + * allocated in the printer. + */ void beginLayer(unsigned layer); + + // Allocate a new layer on top of the last and switch to it. void beginLayer(); + + /* + * Finish the selected layer. It means that no drawing is allowed on that + * layer anymore. This fact can be used to prepare the file system output + * data like png conmprimation and so on. + */ void finishLayer(unsigned layer); + + // Finish the top layer. void finishLayer(); + + // Save all the layers into the file (or dir) specified in the path argument void save(const std::string& path); + + // Save only the selected layer to the file specified in path argument. void saveLayer(unsigned lyr, const std::string& path); }; -template<> +template<> // Implementation for PNG raster output class FilePrinter { + // We will save the compressed PNG data into stringstreams which can be done + // in parallel. Later we can write every layer to the disk sequentially. std::vector> layers_rst_; Raster::Resolution res_; Raster::PixelDim pxdim_; @@ -1341,70 +1372,24 @@ public: std::fstream out(loc, std::fstream::out | std::fstream::binary); if(out.good()) { layers_rst_[i].first.save(out, Raster::Compression::PNG); - } + } /*else { + some logging should be done here... + }*/ out.close(); layers_rst_[i].first.reset(); } }; -//template<> -//class FilePrinter { -// wxBitmap bitmap_; -// std::unique_ptr dc_; -// std::unique_ptr gc_; -// double pxw_; -// double pxh_; -//public: -// inline FilePrinter(unsigned width_px, unsigned height_px, -// double width_mm, double height_mm): -// bitmap_(width_px, height_px), -// dc_(new wxMemoryDC(bitmap_)), -// gc_(wxGraphicsContext::Create(*dc_)), -// pxw_(width_mm/width_px), -// pxh_(height_mm/width_px) -// { -// gc_->SetAntialiasMode(wxANTIALIAS_DEFAULT); -// } - -// FilePrinter(const FilePrinter& ) = delete; -// FilePrinter(FilePrinter&& m): -// bitmap_(std::move(m.bitmap_)), dc_(std::move(m.dc_)), -// gc_(std::move(m.gc_)), pxw_(m.pxw_), pxh_(m.pxh_) {} - -// void drawPolygon(const Polygon& p) { - -// gc_->SetPen(*wxWHITE_PEN); -// std::vector points; -// points.reserve(p.points.size()); - -// for(auto pp : p.points) { -// points.emplace_back( -// std::round(pp.x * SCALING_FACTOR/pxw_), -// std::round(pp.y * SCALING_FACTOR/pxh_) -// ); -// } - -// gc_->DrawLines(points.size(), points.data()); -// } - -// void finish() { - -// } - -// void save(const std::string& path) { -// if(!bitmap_.SaveFile(path, wxBITMAP_TYPE_PNG)) { -// std::cout << "fail for " << path << std::endl; -// } -// } -//}; - template -void Print::print_to(std::string dirpath, Args...args) +void Print::print_to(std::string dirpath, + double width_mm, + double height_mm, + Args...args) { std::string dir = dirpath; -#ifdef WIN32 +#ifdef WIN32 // Making dirpath end with a directory separator on all platforms if(dir.back() != '\\') dir.push_back('\\'); #else if(dir.back() != '/') dir.push_back('/'); @@ -1412,34 +1397,50 @@ void Print::print_to(std::string dirpath, Args...args) LayerPtrs layers; + // Merge the sliced layers wit hthe support layers std::for_each(objects.begin(), objects.end(), [&layers](PrintObject *o){ layers.insert(layers.end(), o->layers.begin(), o->layers.end()); layers.insert(layers.end(), o->support_layers.begin(), o->support_layers.end()); }); + // Sort layers by z coord std::sort(layers.begin(), layers.end(), [](Layer *l1, Layer *l2){ return l1->print_z < l2->print_z; }); auto print_bb = bounding_box(); - FilePrinter printer(std::forward(args)...); - printer.layers(layers.size()); + // If the print does not fit into the print area we should cry about it. + assert(unscale(print_bb.size().x) <= width_mm || + unscale(print_bb.size().y) <= height_mm); - auto process_layer = [&layers, &printer, print_bb, dir] (unsigned layer_id) { + // Offset for centering the print onto the print area + auto cx = scale_(width_mm)/2 - (print_bb.center().x - print_bb.min.x); + auto cy = scale_(height_mm)/2 - (print_bb.center().y - print_bb.min.y); + + // Create the actual printer, forward any additional arguments to it. + FilePrinter printer(std::forward(args)...); + printer.layers(layers.size()); // Allocate space for all the layers + + // Method that prints one layer + auto process_layer = [this, &layers, &printer, print_bb, dir, cx, cy] + (unsigned layer_id) + { Layer& l = *(layers[layer_id]); - ExPolygonCollection slices = l.slices; - using Sl = ExPolygons::value_type; + ExPolygonCollection slices = l.slices; // Copy the layer slices + + // Sort the polygons in the layer std::sort(slices.expolygons.begin(), slices.expolygons.end(), - [](Sl a, Sl b){ + [](const ExPolygon& a, const ExPolygon& b){ return a.contains(b.contour.first_point()) ? false : true; }); - printer.beginLayer(layer_id); + printer.beginLayer(layer_id); // Switch to the appropriate layer + // Draw all the polygons in the slice to the actual layer. std::for_each(l.object()->_shifted_copies.begin(), l.object()->_shifted_copies.end(), [&] (Point d) @@ -1449,25 +1450,34 @@ void Print::print_to(std::string dirpath, Args...args) [&] (ExPolygon slice) { slice.translate(d.x, d.y); - slice.translate(-print_bb.min.x, -print_bb.min.y); + slice.translate(-print_bb.min.x + cx, -print_bb.min.y + cy); printer.drawPolygon(slice, layer_id); }); }); - printer.finishLayer(layer_id); -// printer.saveLayer(layer_id, dir); + if(has_support_material() && layer_id > 0) { + std::cout << "support layer " << layer_id << "\n"; + } + + printer.finishLayer(layer_id); // Finish the layer for later saving it. + // printer.saveLayer(layer_id, dir); We could save the layer immediately }; - tbb::parallel_for(0, layers.size(), process_layer); + // Print all the layers in parallel + tbb::parallel_for(0, + layers.size(), + process_layer); + // Save the print into the file system. printer.save(dir); } void Print::print_to_png(std::string dirpath, long width_px, long height_px, double width_mm, double height_mm) { - print_to(dirpath, width_px, height_px, + print_to(dirpath, width_mm, height_mm, + width_px, height_px, width_mm, height_mm); } diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index 2409b6f4fc..8fd8f832da 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -316,14 +316,17 @@ public: }; template - void print_to(std::string dirpath, Args...args); + void print_to(std::string dirpath, + double width_mm, + double height_mm, + Args...args); void print_to_png(std::string dirpath, long width_px, long height_px, double width_mm, double height_mm); void print_to_png(std::string dirpath) { - // Where should this be specified? - print_to_png(dirpath, 1440, 2560, 40.0, 72.0); + // Will need some GUI dialogue perhaps for these to be specified. + print_to_png(dirpath, 1440, 2560, 68.0, 120.0); } private: diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index 5b0719ecfd..adf4fa2c86 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -1,4 +1,6 @@ #include "Rasterizer.hpp" +#include + #include // For rasterizing @@ -14,7 +16,7 @@ #include #include -// For compression +// For png compression #ifdef WIN32 inline char *strerror_r(int errnum, char *buf, size_t buflen) { strerror_s(buf, buflen, errnum); @@ -70,9 +72,12 @@ public: agg::rasterizer_scanline_aa<> ras; agg::scanline_p8 scanlines; - ras.add_path(to_path(poly.contour)); + auto&& path = to_path(poly.contour); + ras.add_path(path); + for(auto h : poly.holes) { - ras.add_path(to_path(h)); + auto&& holepath = to_path(h); + ras.add_path(holepath); } agg::render_scanlines(ras, scanlines, renderer_); diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp index 31a1244ec8..5fc927d517 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp @@ -2,20 +2,32 @@ #define RASTERIZER_HPP #include -#include +#include namespace Slic3r { +class ExPolygon; + +/** + * @brief Raster captures an antialiased monochrome canvas where vectorial + * polygons can be rasterized. Fill color is always white and the background is + * black. Countours are antialiased. + * + * It also supports saving the raster data into a standard output stream in raw + * or PNG format. + */ class Raster { class Impl; std::unique_ptr impl_; public: + /// Supported compression types enum class Compression { - RAW, - PNG + RAW, //!> Uncompressed pixel data + PNG //!> PNG compression }; + /// Type that represents a resolution in pixels. struct Resolution { unsigned width_px; unsigned height_px; @@ -25,6 +37,7 @@ public: } }; + /// Types that represents the dimension of a pixel in millimeters. struct PixelDim { double w_mm; double h_mm; @@ -32,22 +45,32 @@ public: w_mm(px_width_mm), h_mm(px_height_mm) {} }; + /// Constructor taking the resolution and the pixel dimension. explicit Raster(const Resolution& r, const PixelDim& pd ); Raster(); - ~Raster(); Raster(const Raster& cpy); Raster(Raster&& m); + ~Raster(); + /// Reallocated everything for the given resolution and pixel dimension. void reset(const Resolution& r, const PixelDim& pd); + /** + * Release the allocated resources. Drawing in this state ends in + * unspecified behaviour. + */ void reset(); + /// Get the resolution of the raster. Resolution resolution() const; + /// Clear the raster with black color. void clear(); + /// Draw a polygon with holes. void draw(const ExPolygon& poly); + /// Save the raster on the specified stream. void save(std::ostream& stream, Compression comp = Compression::RAW); }; From c4478ccffaed4a6ca3ffff324df90f523bec2152 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 21 May 2018 14:36:09 +0200 Subject: [PATCH 0390/1150] Fixed wrong updating of the options group tree --- xs/src/slic3r/GUI/Tab.cpp | 24 ++++++++++++++---------- xs/src/slic3r/GUI/Tab.hpp | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 5a47dd1e7b..38c97f25e7 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1709,7 +1709,8 @@ void TabPrinter::build_extruder_pages(){ size_t n_before_extruders = 2; // Count of pages before Extruder pages size_t n_after_single_extruder_MM = 2; // Count of pages after single_extruder_multi_material page - if (m_extruders_count_old == m_extruders_count || m_extruders_count <= 2) + if (m_extruders_count_old == m_extruders_count || + (m_has_single_extruder_MM_page && m_extruders_count == 1)) { // if we have a single extruder MM setup, add a page with configuration options: for (int i = 0; i < m_pages.size(); ++i) // first make sure it's not there already @@ -1717,16 +1718,19 @@ void TabPrinter::build_extruder_pages(){ m_pages.erase(m_pages.begin() + i); break; } - if (m_extruders_count > 1 && m_config->opt_bool("single_extruder_multi_material")) { - // create a page, but pretend it's an extruder page, so we can add it to m_pages ourselves - auto page = add_options_page(_(L("Single extruder MM setup")), "printer_empty.png", true); - auto optgroup = page->new_optgroup(_(L("Single extruder multimaterial parameters"))); - optgroup->append_single_option_line("cooling_tube_retraction"); - optgroup->append_single_option_line("cooling_tube_length"); - optgroup->append_single_option_line("parking_pos_retraction"); - m_pages.insert(m_pages.end() - n_after_single_extruder_MM, page); - } + m_has_single_extruder_MM_page = false; } + if (m_extruders_count > 1 && m_config->opt_bool("single_extruder_multi_material") && !m_has_single_extruder_MM_page) { + // create a page, but pretend it's an extruder page, so we can add it to m_pages ourselves + auto page = add_options_page(_(L("Single extruder MM setup")), "printer_empty.png", true); + auto optgroup = page->new_optgroup(_(L("Single extruder multimaterial parameters"))); + optgroup->append_single_option_line("cooling_tube_retraction"); + optgroup->append_single_option_line("cooling_tube_length"); + optgroup->append_single_option_line("parking_pos_retraction"); + m_pages.insert(m_pages.end() - n_after_single_extruder_MM, page); + m_has_single_extruder_MM_page = true; + } + for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx){ //# build page diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 62030bce34..d6bf2cf43e 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -312,6 +312,7 @@ public: //Slic3r::GUI::Tab::Printer; class TabPrinter : public Tab { + bool m_has_single_extruder_MM_page = false; public: wxButton* m_serial_test_btn; wxButton* m_octoprint_host_test_btn; From 3fdc5e20a7b7455e73dde0033daca20155b63b69 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 21 May 2018 14:40:09 +0200 Subject: [PATCH 0391/1150] Warning texture moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 149 ++++++++++++------------ lib/Slic3r/GUI/Plater/3D.pm | 15 ++- xs/src/slic3r/GUI/3DScene.cpp | 15 +++ xs/src/slic3r/GUI/3DScene.hpp | 5 + xs/src/slic3r/GUI/GLCanvas3D.cpp | 64 ++++++++++ xs/src/slic3r/GUI/GLCanvas3D.hpp | 6 + xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 21 ++++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 5 + xs/xsp/GUI_3DScene.xsp | 26 ++++- 9 files changed, 230 insertions(+), 76 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 72fdd6d6af..e3dd848dbf 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -59,7 +59,6 @@ __PACKAGE__->mk_accessors( qw(_quat init _layer_height_edited _legend_enabled - _warning_enabled _mouse_dragging ) ); @@ -193,7 +192,9 @@ sub new { # $self->_zoom(1); #============================================================================================================================== $self->_legend_enabled(0); - $self->_warning_enabled(0); +#============================================================================================================================== +# $self->_warning_enabled(0); +#============================================================================================================================== $self->use_plain_shader(0); #============================================================================================================================== # $self->_apply_zoom_to_volumes_filter(0); @@ -295,10 +296,12 @@ sub set_legend_enabled { $self->_legend_enabled($value); } -sub set_warning_enabled { - my ($self, $value) = @_; - $self->_warning_enabled($value); -} +#============================================================================================================================== +#sub set_warning_enabled { +# my ($self, $value) = @_; +# $self->_warning_enabled($value); +#} +#============================================================================================================================== sub Destroy { my ($self) = @_; @@ -1617,6 +1620,7 @@ sub Render { #============================================================================================================================== Slic3r::GUI::_3DScene::render_cutting_plane($self); + Slic3r::GUI::_3DScene::render_warning_texture($self); # if (defined $self->cutting_plane_z) { # # draw cutting plane @@ -1645,10 +1649,10 @@ sub Render { # glVertexPointer_c(3, GL_FLOAT, 0, 0); # glDisableClientState(GL_VERTEX_ARRAY); # } +# +# # draw warning message +# $self->draw_warning; #============================================================================================================================== - - # draw warning message - $self->draw_warning; # draw gcode preview legend $self->draw_legend; @@ -1762,32 +1766,34 @@ sub _variable_layer_thickness_load_reset_image { return $self->{layer_preview_reset_image}->{valid}; } -# Paint the tooltip. -sub _render_image { - my ($self, $image, $l, $r, $b, $t) = @_; - $self->_render_texture($image->{texture_id}, $l, $r, $b, $t); -} - -sub _render_texture { - my ($self, $tex_id, $l, $r, $b, $t) = @_; - - glColor4f(1.,1.,1.,1.); - glDisable(GL_LIGHTING); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, $tex_id); - glBegin(GL_QUADS); - glTexCoord2d(0.,1.); glVertex3f($l, $b, 0); - glTexCoord2d(1.,1.); glVertex3f($r, $b, 0); - glTexCoord2d(1.,0.); glVertex3f($r, $t, 0); - glTexCoord2d(0.,0.); glVertex3f($l, $t, 0); - glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - glEnable(GL_LIGHTING); -} +#============================================================================================================================== +## Paint the tooltip. +#sub _render_image { +# my ($self, $image, $l, $r, $b, $t) = @_; +# $self->_render_texture($image->{texture_id}, $l, $r, $b, $t); +#} +# +#sub _render_texture { +# my ($self, $tex_id, $l, $r, $b, $t) = @_; +# +# glColor4f(1.,1.,1.,1.); +# glDisable(GL_LIGHTING); +# glEnable(GL_BLEND); +# glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +# glEnable(GL_TEXTURE_2D); +# glBindTexture(GL_TEXTURE_2D, $tex_id); +# glBegin(GL_QUADS); +# glTexCoord2d(0.,1.); glVertex3f($l, $b, 0); +# glTexCoord2d(1.,1.); glVertex3f($r, $b, 0); +# glTexCoord2d(1.,0.); glVertex3f($r, $t, 0); +# glTexCoord2d(0.,0.); glVertex3f($l, $t, 0); +# glEnd(); +# glBindTexture(GL_TEXTURE_2D, 0); +# glDisable(GL_TEXTURE_2D); +# glDisable(GL_BLEND); +# glEnable(GL_LIGHTING); +#} +#============================================================================================================================== sub draw_active_object_annotations { # $fakecolor is a boolean indicating, that the objects shall be rendered in a color coding the object index for picking. @@ -1857,16 +1863,20 @@ sub draw_active_object_annotations { my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); my $gap = 10/$zoom; my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$zoom + $gap, $reset_bottom + $gap); + Slic3r::GUI::_3DScene::render_texture($self, $self->{layer_preview_annotation}->{texture_id}, $l, $r, $t, $b); # my $gap = 10/$self->_zoom; # my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$self->_zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$self->_zoom + $gap, $reset_bottom + $gap); +# $self->_render_image($self->{layer_preview_annotation}, $l, $r, $t, $b); #============================================================================================================================== - $self->_render_image($self->{layer_preview_annotation}, $l, $r, $t, $b); } # Paint the reset button. if ($self->_variable_layer_thickness_load_reset_image) { - $self->_render_image($self->{layer_preview_reset_image}, $reset_left, $reset_right, $reset_bottom, $reset_top); +#============================================================================================================================== + Slic3r::GUI::_3DScene::render_texture($self, $self->{layer_preview_reset_image}->{texture_id}, $reset_left, $reset_right, $reset_bottom, $reset_top); +# $self->_render_image($self->{layer_preview_reset_image}, $reset_left, $reset_right, $reset_bottom, $reset_top); +#============================================================================================================================== } # Paint the graph. @@ -1936,13 +1946,14 @@ sub draw_legend { my $t = (0.5 * $ch) / $zoom; my $r = $l + $tex_w / $zoom; my $b = $t - $tex_h / $zoom; + Slic3r::GUI::_3DScene::render_texture($self, $tex_id, $l, $r, $b, $t); # my $l = (-0.5 * $cw) / $self->_zoom; # my $t = (0.5 * $ch) / $self->_zoom; # my $r = $l + $tex_w / $self->_zoom; # my $b = $t - $tex_h / $self->_zoom; +# $self->_render_texture($tex_id, $l, $r, $b, $t); #============================================================================================================================== - $self->_render_texture($tex_id, $l, $r, $b, $t); glPopMatrix(); glEnable(GL_DEPTH_TEST); @@ -1950,46 +1961,40 @@ sub draw_legend { } } -sub draw_warning { - my ($self) = @_; - - if (!$self->_warning_enabled) { - return; - } - - # If the warning texture has not been loaded into the GPU, do it now. - my $tex_id = Slic3r::GUI::_3DScene::finalize_warning_texture; - if ($tex_id > 0) - { - my $tex_w = Slic3r::GUI::_3DScene::get_warning_texture_width; - my $tex_h = Slic3r::GUI::_3DScene::get_warning_texture_height; - if (($tex_w > 0) && ($tex_h > 0)) - { - glDisable(GL_DEPTH_TEST); - glPushMatrix(); - glLoadIdentity(); - - my ($cw, $ch) = $self->GetSizeWH; - #============================================================================================================================== - my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); - my $l = (-0.5 * $tex_w) / $zoom; - my $t = (-0.5 * $ch + $tex_h) / $zoom; - my $r = $l + $tex_w / $zoom; - my $b = $t - $tex_h / $zoom; - +#sub draw_warning { +# my ($self) = @_; +# +# if (!$self->_warning_enabled) { +# return; +# } +# +# # If the warning texture has not been loaded into the GPU, do it now. +# my $tex_id = Slic3r::GUI::_3DScene::finalize_warning_texture; +# if ($tex_id > 0) +# { +# my $tex_w = Slic3r::GUI::_3DScene::get_warning_texture_width; +# my $tex_h = Slic3r::GUI::_3DScene::get_warning_texture_height; +# if (($tex_w > 0) && ($tex_h > 0)) +# { +# glDisable(GL_DEPTH_TEST); +# glPushMatrix(); +# glLoadIdentity(); +# +# my ($cw, $ch) = $self->GetSizeWH; +# # my $l = (-0.5 * $tex_w) / $self->_zoom; # my $t = (-0.5 * $ch + $tex_h) / $self->_zoom; # my $r = $l + $tex_w / $self->_zoom; # my $b = $t - $tex_h / $self->_zoom; +# $self->_render_texture($tex_id, $l, $r, $b, $t); +# +# glPopMatrix(); +# glEnable(GL_DEPTH_TEST); +# } +# } +#} #============================================================================================================================== - $self->_render_texture($tex_id, $l, $r, $b, $t); - - glPopMatrix(); - glEnable(GL_DEPTH_TEST); - } - } -} sub update_volumes_colors_by_extruder { my ($self, $config) = @_; diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index a678be67a6..ecf841b27e 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -241,17 +241,26 @@ sub reload_scene { if (scalar @{$self->volumes} > 0) { if (!$self->{model}->fits_print_volume($self->{config})) { - $self->set_warning_enabled(1); +#============================================================================================================================== + Slic3r::GUI::_3DScene::enable_warning_texture($self, 1); +# $self->set_warning_enabled(1); +#============================================================================================================================== Slic3r::GUI::_3DScene::generate_warning_texture(L("Detected object outside print volume")); $self->on_enable_action_buttons->(0) if ($self->on_enable_action_buttons); } else { - $self->set_warning_enabled(0); +#============================================================================================================================== + Slic3r::GUI::_3DScene::enable_warning_texture($self, 0); +# $self->set_warning_enabled(0); +#============================================================================================================================== $self->volumes->update_outside_state($self->{config}, 1); Slic3r::GUI::_3DScene::reset_warning_texture(); $self->on_enable_action_buttons->(scalar @{$self->{model}->objects} > 0) if ($self->on_enable_action_buttons); } } else { - $self->set_warning_enabled(0); +#============================================================================================================================== + Slic3r::GUI::_3DScene::enable_warning_texture($self, 0); +# $self->set_warning_enabled(0); +#============================================================================================================================== Slic3r::GUI::_3DScene::reset_warning_texture(); } } diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index bb1527f8da..be170a2820 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1898,6 +1898,11 @@ bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas) return s_canvas_mgr.is_layers_editing_enabled(canvas); } +void _3DScene::enable_warning_texture(wxGLCanvas* canvas, bool enable) +{ + s_canvas_mgr.enable_warning_texture(canvas, enable); +} + void _3DScene::zoom_to_bed(wxGLCanvas* canvas) { s_canvas_mgr.zoom_to_bed(canvas); @@ -1928,6 +1933,16 @@ void _3DScene::render_cutting_plane(wxGLCanvas* canvas) s_canvas_mgr.render_cutting_plane(canvas); } +void _3DScene::render_warning_texture(wxGLCanvas* canvas) +{ + s_canvas_mgr.render_warning_texture(canvas); +} + +void _3DScene::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) +{ + s_canvas_mgr.render_texture(canvas, tex_id, left, right, bottom, top); +} + void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) { s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 3f4ecc6376..a984823961 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -590,6 +590,8 @@ public: static bool is_layers_editing_enabled(wxGLCanvas* canvas); + static void enable_warning_texture(wxGLCanvas* canvas, bool enable); + static void zoom_to_bed(wxGLCanvas* canvas); static void zoom_to_volumes(wxGLCanvas* canvas); static void select_view(wxGLCanvas* canvas, const std::string& direction); @@ -597,6 +599,9 @@ public: static void render_bed(wxGLCanvas* canvas); static void render_axes(wxGLCanvas* canvas); static void render_cutting_plane(wxGLCanvas* canvas); + static void render_warning_texture(wxGLCanvas* canvas); + + static void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top); static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 7a47028809..c97a9566c3 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -411,6 +411,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) , m_volumes(nullptr) , m_dirty(true) , m_apply_zoom_to_volumes_filter(false) + , m_warning_texture_enabled(false) { } @@ -682,6 +683,11 @@ bool GLCanvas3D::is_layers_editing_enabled() const return m_layers_editing.is_enabled(); } +void GLCanvas3D::enable_warning_texture(bool enable) +{ + m_warning_texture_enabled = enable; +} + void GLCanvas3D::zoom_to_bed() { _zoom_to_bounding_box(bed_bounding_box()); @@ -743,6 +749,64 @@ void GLCanvas3D::render_cutting_plane() m_cutting_plane.render_contour(); } +void GLCanvas3D::render_warning_texture() +{ + if (!m_warning_texture_enabled) + return; + + // If the warning texture has not been loaded into the GPU, do it now. + unsigned int tex_id = _3DScene::finalize_warning_texture(); + if (tex_id > 0) + { + unsigned int w = _3DScene::get_warning_texture_width(); + unsigned int h = _3DScene::get_warning_texture_height(); + if ((w > 0) && (h > 0)) + { + ::glDisable(GL_DEPTH_TEST); + ::glPushMatrix(); + ::glLoadIdentity(); + + std::pair cnv_size = _get_canvas_size(); + float zoom = get_camera_zoom(); + float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; + float l = (-0.5f * (float)w) * inv_zoom; + float t = (-0.5f * cnv_size.second + (float)h) * inv_zoom; + float r = l + (float)w * inv_zoom; + float b = t - (float)h * inv_zoom; + + render_texture(tex_id, l, r, b, t); + + ::glPopMatrix(); + ::glEnable(GL_DEPTH_TEST); + } + } +} + +void GLCanvas3D::render_texture(unsigned int tex_id, float left, float right, float bottom, float top) +{ + ::glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + ::glDisable(GL_LIGHTING); + ::glEnable(GL_BLEND); + ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + ::glEnable(GL_TEXTURE_2D); + + ::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id); + + ::glBegin(GL_QUADS); + ::glTexCoord2d(0.0f, 1.0f); glVertex3f(left, bottom, 0.0f); + ::glTexCoord2d(1.0f, 1.0f); glVertex3f(right, bottom, 0.0f); + ::glTexCoord2d(1.0f, 0.0f); glVertex3f(right, top, 0.0f); + ::glTexCoord2d(0.0f, 0.0f); glVertex3f(left, top, 0.0f); + ::glEnd(); + + ::glBindTexture(GL_TEXTURE_2D, 0); + + ::glDisable(GL_TEXTURE_2D); + ::glDisable(GL_BLEND); + ::glEnable(GL_LIGHTING); +} + void GLCanvas3D::register_on_viewport_changed_callback(void* callback) { if (callback != nullptr) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 558e6c350e..d7614d4e46 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -151,6 +151,7 @@ private: bool m_dirty; bool m_apply_zoom_to_volumes_filter; + bool m_warning_texture_enabled; PerlCallback m_on_viewport_changed_callback; @@ -213,6 +214,8 @@ public: bool is_layers_editing_enabled() const; + void enable_warning_texture(bool enable); + void zoom_to_bed(); void zoom_to_volumes(); void select_view(const std::string& direction); @@ -220,6 +223,9 @@ public: void render_bed(); void render_axes(); void render_cutting_plane(); + void render_warning_texture(); + + void render_texture(unsigned int tex_id, float left, float right, float bottom, float top); void register_on_viewport_changed_callback(void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index f4cf4235ed..22eff5a01e 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -355,6 +355,13 @@ bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const return (it != m_canvases.end()) ? it->second->is_layers_editing_enabled() : false; } +void GLCanvas3DManager::enable_warning_texture(wxGLCanvas* canvas, bool enable) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->enable_warning_texture(enable); +} + void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas) { CanvasesMap::iterator it = _get_canvas(canvas); @@ -397,6 +404,20 @@ void GLCanvas3DManager::render_cutting_plane(wxGLCanvas* canvas) it->second->render_cutting_plane(); } +void GLCanvas3DManager::render_warning_texture(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->render_warning_texture(); +} + +void GLCanvas3DManager::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->render_texture(tex_id, left, right, bottom, top); +} + void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 6abe1bbf72..d0d2bb609d 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -100,6 +100,8 @@ public: bool is_layers_editing_enabled(wxGLCanvas* canvas) const; + void enable_warning_texture(wxGLCanvas* canvas, bool enable); + void zoom_to_bed(wxGLCanvas* canvas); void zoom_to_volumes(wxGLCanvas* canvas); void select_view(wxGLCanvas* canvas, const std::string& direction); @@ -107,6 +109,9 @@ public: void render_bed(wxGLCanvas* canvas); void render_axes(wxGLCanvas* canvas); void render_cutting_plane(wxGLCanvas* canvas); + void render_warning_texture(wxGLCanvas* canvas); + + void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top); void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 240e62dbac..aa4c98d155 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -411,6 +411,13 @@ set_camera_target(canvas, target) CODE: _3DScene::set_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), target); +void +enable_warning_texture(canvas, enable) + SV *canvas; + bool enable; + CODE: + _3DScene::enable_warning_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), enable); + void zoom_to_bed(canvas) SV *canvas; @@ -447,7 +454,24 @@ render_cutting_plane(canvas) SV *canvas; CODE: _3DScene::render_cutting_plane((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); - + +void +render_warning_texture(canvas) + SV *canvas; + CODE: + _3DScene::render_warning_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + +void +render_texture(canvas, tex_id, left, right, bottom, top) + SV *canvas; + unsigned int tex_id; + float left; + float right; + float bottom; + float top; + CODE: + _3DScene::render_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), tex_id, left, right, bottom, top); + void register_on_viewport_changed_callback(canvas, callback) SV *canvas; From 622c613b410fd0f8ac82b78ae577194f9e1c3607 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 21 May 2018 14:49:31 +0200 Subject: [PATCH 0392/1150] Update of the view mode works correctly --- lib/Slic3r/GUI/MainFrame.pm | 2 ++ lib/Slic3r/GUI/Plater.pm | 7 ++++--- lib/Slic3r/GUI/Plater/3D.pm | 2 +- xs/src/slic3r/GUI/GUI.cpp | 9 ++++----- xs/src/slic3r/GUI/GUI.hpp | 2 ++ xs/src/slic3r/GUI/Tab.cpp | 16 ++++++++++------ xs/xsp/GUI.xsp | 3 +++ 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index fbcd34a3f6..51f5911f01 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -96,6 +96,8 @@ sub new { $self->update_ui_from_settings; + Slic3r::GUI::update_mode(); + return $self; } diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index e57c2267aa..5bd4587bbe 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -449,7 +449,8 @@ sub new { $self->{"object_info_manifold_warning_icon_show"} = sub { if ($self->{object_info_manifold_warning_icon}->IsShown() != $_[0]) { Slic3r::GUI::set_show_manifold_warning_icon($_[0]); - return if (wxTheApp->{app_config}->get("view_mode") eq "simple"); + my $mode = wxTheApp->{app_config}->get("view_mode"); + return if ($mode eq "" || $mode eq "simple"); $self->{object_info_manifold_warning_icon}->Show($_[0]); $self->Layout } @@ -548,7 +549,7 @@ sub new { $self->SetSizer($sizer); # Send sizers/buttons to C++ - Slic3r::GUI::set_objects_from_perl( $self, + Slic3r::GUI::set_objects_from_perl( $self->{right_panel}, $frequently_changed_parameters_sizer, $expert_mode_part_sizer, $scrolled_window_sizer, @@ -1767,7 +1768,7 @@ sub on_extruders_change { my @presets = $choices->[0]->GetStrings; # initialize new choice - my $choice = Wx::BitmapComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); + my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); my $extruder_idx = scalar @$choices; EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down($extruder_idx, @_); } ); push @$choices, $choice; diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index c9c9542762..c3521a4dad 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -245,7 +245,7 @@ sub reload_scene { $self->set_warning_enabled(0); $self->volumes->update_outside_state($self->{config}, 1); Slic3r::GUI::_3DScene::reset_warning_texture(); - $self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons); + $self->on_enable_action_buttons->(scalar @{$self->{model}->objects} > 0) if ($self->on_enable_action_buttons); } } else { $self->set_warning_enabled(0); diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index abdeb6c72e..1fc02ed1f5 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -202,7 +202,7 @@ double m_brim_width = 0.0; wxButton* g_wiping_dialog_button = nullptr; //showed/hided controls according to the view mode -wxWindow *g_plater = nullptr; +wxWindow *g_right_panel = nullptr; wxBoxSizer *g_frequently_changed_parameters_sizer = nullptr; wxBoxSizer *g_expert_mode_part_sizer = nullptr; wxBoxSizer *g_scrolled_window_sizer = nullptr; @@ -279,7 +279,7 @@ void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_par wxButton *btn_print, wxButton *btn_send_gcode, wxStaticBitmap *manifold_warning_icon) { - g_plater = parent; + g_right_panel = parent; g_frequently_changed_parameters_sizer = frequently_changed_parameters_sizer; g_expert_mode_part_sizer = expert_mode_part_sizer; g_scrolled_window_sizer = scrolled_window_sizer; @@ -616,7 +616,6 @@ void create_preset_tabs(bool no_controller, int event_value_change, int event_pr tab->set_event_value_change(wxEventType(event_value_change)); tab->set_event_presets_changed(wxEventType(event_presets_changed)); } - update_mode();// TODO change place of call this function } TabIface* get_preset_tab_iface(char *name) @@ -1136,14 +1135,14 @@ void show_scrolled_window_sizer(bool show) void update_mode() { - wxWindowUpdateLocker noUpdates(g_plater); + wxWindowUpdateLocker noUpdates(g_right_panel); ConfigMenuIDs mode = get_view_mode(); show_frequently_changed_parameters(mode >= ConfigMenuModeRegular); g_expert_mode_part_sizer->Show(mode == ConfigMenuModeExpert); show_scrolled_window_sizer(mode >= ConfigMenuModeRegular); show_buttons(mode >= ConfigMenuModeRegular); - g_plater->Layout(); + g_right_panel->Layout(); } ConfigOptionsGroup* get_optgroup() diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 4fd8b800ab..5f89d8b661 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -142,6 +142,8 @@ void save_language(); void get_installed_languages(wxArrayString & names, wxArrayLong & identifiers); // select language from the list of installed languages bool select_language(wxArrayString & names, wxArrayLong & identifiers); +// update right panel of the Plater according to view mode +void update_mode(); std::vector& get_tabs_list(); bool checked_tab(Tab* tab); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 5a47dd1e7b..21c85925d8 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -705,13 +705,17 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) // Show/hide the 'purging volumes' button void Tab::update_wiping_button_visibility() { - bool wipe_tower_enabled = dynamic_cast( (m_preset_bundle->prints.get_edited_preset().config ).option("wipe_tower"))->value; - bool multiple_extruders = dynamic_cast((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1; - bool single_extruder_mm = dynamic_cast( (m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value; + if (!get_app_config()->has("view_mode") || get_app_config()->get("view_mode") == "simple") + get_wiping_dialog_button()->Hide(); + else { + bool wipe_tower_enabled = dynamic_cast((m_preset_bundle->prints.get_edited_preset().config).option("wipe_tower"))->value; + bool multiple_extruders = dynamic_cast((m_preset_bundle->printers.get_edited_preset().config).option("nozzle_diameter"))->values.size() > 1; + bool single_extruder_mm = dynamic_cast((m_preset_bundle->printers.get_edited_preset().config).option("single_extruder_multi_material"))->value; - if (wipe_tower_enabled && multiple_extruders && single_extruder_mm) - get_wiping_dialog_button()->Show(); - else get_wiping_dialog_button()->Hide(); + if (wipe_tower_enabled && multiple_extruders && single_extruder_mm) + get_wiping_dialog_button()->Show(); + else get_wiping_dialog_button()->Hide(); + } (get_wiping_dialog_button()->GetParent())->Layout(); } diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 6dcb4a6ab3..aca60d0f87 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -116,6 +116,9 @@ void set_show_print_info(bool show) void set_show_manifold_warning_icon(bool show) %code%{ Slic3r::GUI::set_show_manifold_warning_icon(show); %}; +void update_mode() + %code%{ Slic3r::GUI::update_mode(); %}; + std::string fold_utf8_to_ascii(const char *src) %code%{ RETVAL = Slic3r::fold_utf8_to_ascii(src); %}; From bf7b9eb3e7d5a2fcd74a23f9b7362e76abfb97c1 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 21 May 2018 14:57:43 +0200 Subject: [PATCH 0393/1150] Legend texture moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 87 +++++++++++-------------- lib/Slic3r/GUI/Plater.pm | 10 ++- xs/src/slic3r/GUI/3DScene.cpp | 10 +++ xs/src/slic3r/GUI/3DScene.hpp | 2 + xs/src/slic3r/GUI/GLCanvas3D.cpp | 40 +++++++++++- xs/src/slic3r/GUI/GLCanvas3D.hpp | 3 + xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 14 ++++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 2 + xs/xsp/GUI_3DScene.xsp | 13 ++++ 9 files changed, 129 insertions(+), 52 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index e3dd848dbf..31982f6a95 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -58,7 +58,6 @@ __PACKAGE__->mk_accessors( qw(_quat init _layer_height_edited - _legend_enabled _mouse_dragging ) ); @@ -190,9 +189,7 @@ sub new { # $self->_stheta(45); # $self->_sphi(45); # $self->_zoom(1); -#============================================================================================================================== - $self->_legend_enabled(0); -#============================================================================================================================== +# $self->_legend_enabled(0); # $self->_warning_enabled(0); #============================================================================================================================== $self->use_plain_shader(0); @@ -291,12 +288,12 @@ sub new { return $self; } -sub set_legend_enabled { - my ($self, $value) = @_; - $self->_legend_enabled($value); -} - #============================================================================================================================== +#sub set_legend_enabled { +# my ($self, $value) = @_; +# $self->_legend_enabled($value); +#} +# #sub set_warning_enabled { # my ($self, $value) = @_; # $self->_warning_enabled($value); @@ -1621,6 +1618,7 @@ sub Render { #============================================================================================================================== Slic3r::GUI::_3DScene::render_cutting_plane($self); Slic3r::GUI::_3DScene::render_warning_texture($self); + Slic3r::GUI::_3DScene::render_legend_texture($self); # if (defined $self->cutting_plane_z) { # # draw cutting plane @@ -1652,11 +1650,11 @@ sub Render { # # # draw warning message # $self->draw_warning; +# +# # draw gcode preview legend +# $self->draw_legend; #============================================================================================================================== - # draw gcode preview legend - $self->draw_legend; - $self->draw_active_object_annotations; $self->SwapBuffers(); @@ -1919,49 +1917,40 @@ sub draw_active_object_annotations { glEnable(GL_DEPTH_TEST); } -sub draw_legend { - my ($self) = @_; - - if (!$self->_legend_enabled) { - return; - } - - # If the legend texture has not been loaded into the GPU, do it now. - my $tex_id = Slic3r::GUI::_3DScene::finalize_legend_texture; - if ($tex_id > 0) - { - my $tex_w = Slic3r::GUI::_3DScene::get_legend_texture_width; - my $tex_h = Slic3r::GUI::_3DScene::get_legend_texture_height; - if (($tex_w > 0) && ($tex_h > 0)) - { - glDisable(GL_DEPTH_TEST); - glPushMatrix(); - glLoadIdentity(); - - my ($cw, $ch) = $self->GetSizeWH; - #============================================================================================================================== - my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self); - my $l = (-0.5 * $cw) / $zoom; - my $t = (0.5 * $ch) / $zoom; - my $r = $l + $tex_w / $zoom; - my $b = $t - $tex_h / $zoom; - Slic3r::GUI::_3DScene::render_texture($self, $tex_id, $l, $r, $b, $t); - +#sub draw_legend { +# my ($self) = @_; +# +# if (!$self->_legend_enabled) { +# return; +# } +# +# # If the legend texture has not been loaded into the GPU, do it now. +# my $tex_id = Slic3r::GUI::_3DScene::finalize_legend_texture; +# if ($tex_id > 0) +# { +# my $tex_w = Slic3r::GUI::_3DScene::get_legend_texture_width; +# my $tex_h = Slic3r::GUI::_3DScene::get_legend_texture_height; +# if (($tex_w > 0) && ($tex_h > 0)) +# { +# glDisable(GL_DEPTH_TEST); +# glPushMatrix(); +# glLoadIdentity(); +# +# my ($cw, $ch) = $self->GetSizeWH; +# # my $l = (-0.5 * $cw) / $self->_zoom; # my $t = (0.5 * $ch) / $self->_zoom; # my $r = $l + $tex_w / $self->_zoom; # my $b = $t - $tex_h / $self->_zoom; # $self->_render_texture($tex_id, $l, $r, $b, $t); -#============================================================================================================================== - - glPopMatrix(); - glEnable(GL_DEPTH_TEST); - } - } -} - -#============================================================================================================================== +# +# glPopMatrix(); +# glEnable(GL_DEPTH_TEST); +# } +# } +#} +# #sub draw_warning { # my ($self) = @_; # diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 9f80b1e25a..b136d89a1b 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -177,10 +177,16 @@ sub new { my $preview = $self->{preview_notebook}->GetCurrentPage; if ($preview == $self->{preview3D}) { - $self->{preview3D}->canvas->set_legend_enabled(1); +#============================================================================================================================== + Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 1); +# $self->{preview3D}->canvas->set_legend_enabled(1); +#============================================================================================================================== $self->{preview3D}->load_print(1); } else { - $self->{preview3D}->canvas->set_legend_enabled(0); +#============================================================================================================================== + Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 0); +# $self->{preview3D}->canvas->set_legend_enabled(0); +#============================================================================================================================== } $preview->OnActivate if $preview->can('OnActivate'); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index be170a2820..87a3c9aad6 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1903,6 +1903,11 @@ void _3DScene::enable_warning_texture(wxGLCanvas* canvas, bool enable) s_canvas_mgr.enable_warning_texture(canvas, enable); } +void _3DScene::enable_legend_texture(wxGLCanvas* canvas, bool enable) +{ + s_canvas_mgr.enable_legend_texture(canvas, enable); +} + void _3DScene::zoom_to_bed(wxGLCanvas* canvas) { s_canvas_mgr.zoom_to_bed(canvas); @@ -1938,6 +1943,11 @@ void _3DScene::render_warning_texture(wxGLCanvas* canvas) s_canvas_mgr.render_warning_texture(canvas); } +void _3DScene::render_legend_texture(wxGLCanvas* canvas) +{ + s_canvas_mgr.render_legend_texture(canvas); +} + void _3DScene::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) { s_canvas_mgr.render_texture(canvas, tex_id, left, right, bottom, top); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index a984823961..a3d976018d 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -591,6 +591,7 @@ public: static bool is_layers_editing_enabled(wxGLCanvas* canvas); static void enable_warning_texture(wxGLCanvas* canvas, bool enable); + static void enable_legend_texture(wxGLCanvas* canvas, bool enable); static void zoom_to_bed(wxGLCanvas* canvas); static void zoom_to_volumes(wxGLCanvas* canvas); @@ -600,6 +601,7 @@ public: static void render_axes(wxGLCanvas* canvas); static void render_cutting_plane(wxGLCanvas* canvas); static void render_warning_texture(wxGLCanvas* canvas); + static void render_legend_texture(wxGLCanvas* canvas); static void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index c97a9566c3..fce0459061 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -412,6 +412,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) , m_dirty(true) , m_apply_zoom_to_volumes_filter(false) , m_warning_texture_enabled(false) + , m_legend_texture_enabled(false) { } @@ -688,6 +689,11 @@ void GLCanvas3D::enable_warning_texture(bool enable) m_warning_texture_enabled = enable; } +void GLCanvas3D::enable_legend_texture(bool enable) +{ + m_legend_texture_enabled = enable; +} + void GLCanvas3D::zoom_to_bed() { _zoom_to_bounding_box(bed_bounding_box()); @@ -770,7 +776,7 @@ void GLCanvas3D::render_warning_texture() float zoom = get_camera_zoom(); float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; float l = (-0.5f * (float)w) * inv_zoom; - float t = (-0.5f * cnv_size.second + (float)h) * inv_zoom; + float t = (-0.5f * (float)cnv_size.second + (float)h) * inv_zoom; float r = l + (float)w * inv_zoom; float b = t - (float)h * inv_zoom; @@ -782,6 +788,38 @@ void GLCanvas3D::render_warning_texture() } } +void GLCanvas3D::render_legend_texture() +{ + if (!m_legend_texture_enabled) + return; + + // If the legend texture has not been loaded into the GPU, do it now. + unsigned int tex_id = _3DScene::finalize_legend_texture(); + if (tex_id > 0) + { + unsigned int w = _3DScene::get_legend_texture_width(); + unsigned int h = _3DScene::get_legend_texture_height(); + if ((w > 0) && (h > 0)) + { + ::glDisable(GL_DEPTH_TEST); + ::glPushMatrix(); + ::glLoadIdentity(); + + std::pair cnv_size = _get_canvas_size(); + float zoom = get_camera_zoom(); + float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; + float l = (-0.5f * (float)cnv_size.first) * inv_zoom; + float t = (0.5f * (float)cnv_size.second) * inv_zoom; + float r = l + (float)w * inv_zoom; + float b = t - (float)h * inv_zoom; + render_texture(tex_id, l, r, b, t); + + ::glPopMatrix(); + ::glEnable(GL_DEPTH_TEST); + } + } +} + void GLCanvas3D::render_texture(unsigned int tex_id, float left, float right, float bottom, float top) { ::glColor4f(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index d7614d4e46..e1ce33fad4 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -152,6 +152,7 @@ private: bool m_dirty; bool m_apply_zoom_to_volumes_filter; bool m_warning_texture_enabled; + bool m_legend_texture_enabled; PerlCallback m_on_viewport_changed_callback; @@ -215,6 +216,7 @@ public: bool is_layers_editing_enabled() const; void enable_warning_texture(bool enable); + void enable_legend_texture(bool enable); void zoom_to_bed(); void zoom_to_volumes(); @@ -224,6 +226,7 @@ public: void render_axes(); void render_cutting_plane(); void render_warning_texture(); + void render_legend_texture(); void render_texture(unsigned int tex_id, float left, float right, float bottom, float top); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 22eff5a01e..7647e3525e 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -362,6 +362,13 @@ void GLCanvas3DManager::enable_warning_texture(wxGLCanvas* canvas, bool enable) it->second->enable_warning_texture(enable); } +void GLCanvas3DManager::enable_legend_texture(wxGLCanvas* canvas, bool enable) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->enable_legend_texture(enable); +} + void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas) { CanvasesMap::iterator it = _get_canvas(canvas); @@ -411,6 +418,13 @@ void GLCanvas3DManager::render_warning_texture(wxGLCanvas* canvas) it->second->render_warning_texture(); } +void GLCanvas3DManager::render_legend_texture(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->render_legend_texture(); +} + void GLCanvas3DManager::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index d0d2bb609d..d79152f43b 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -101,6 +101,7 @@ public: bool is_layers_editing_enabled(wxGLCanvas* canvas) const; void enable_warning_texture(wxGLCanvas* canvas, bool enable); + void enable_legend_texture(wxGLCanvas* canvas, bool enable); void zoom_to_bed(wxGLCanvas* canvas); void zoom_to_volumes(wxGLCanvas* canvas); @@ -110,6 +111,7 @@ public: void render_axes(wxGLCanvas* canvas); void render_cutting_plane(wxGLCanvas* canvas); void render_warning_texture(wxGLCanvas* canvas); + void render_legend_texture(wxGLCanvas* canvas); void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index aa4c98d155..32500b3eb6 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -418,6 +418,13 @@ enable_warning_texture(canvas, enable) CODE: _3DScene::enable_warning_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), enable); +void +enable_legend_texture(canvas, enable) + SV *canvas; + bool enable; + CODE: + _3DScene::enable_legend_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), enable); + void zoom_to_bed(canvas) SV *canvas; @@ -461,6 +468,12 @@ render_warning_texture(canvas) CODE: _3DScene::render_warning_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); +void +render_legend_texture(canvas) + SV *canvas; + CODE: + _3DScene::render_legend_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + void render_texture(canvas, tex_id, left, right, bottom, top) SV *canvas; From 0f035d0bae758338a46951b26f089b611f6c3bac Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 21 May 2018 15:24:52 +0200 Subject: [PATCH 0394/1150] Background rendering moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 69 +++++++++++++------------ xs/src/slic3r/GUI/3DScene.cpp | 5 ++ xs/src/slic3r/GUI/3DScene.hpp | 1 + xs/src/slic3r/GUI/GLCanvas3D.cpp | 50 +++++++++++++++--- xs/src/slic3r/GUI/GLCanvas3D.hpp | 8 ++- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 7 +++ xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 1 + xs/xsp/GUI_3DScene.xsp | 6 +++ 8 files changed, 105 insertions(+), 42 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 31982f6a95..dcd8e31106 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -46,7 +46,6 @@ __PACKAGE__->mk_accessors( qw(_quat init on_move on_model_update volumes - background _mouse_pos _hover_volume_idx @@ -183,7 +182,9 @@ sub new { #============================================================================================================================== $self->{can_multisample} = $can_multisample; - $self->background(1); +#============================================================================================================================== +# $self->background(1); +#============================================================================================================================== $self->_quat((0, 0, 0, 1)); #============================================================================================================================== # $self->_stheta(45); @@ -1491,38 +1492,40 @@ sub Render { } } - # draw fixed background - if ($self->background) { - glDisable(GL_LIGHTING); - glPushMatrix(); - glLoadIdentity(); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - - # Draws a bluish bottom to top gradient over the complete screen. - glDisable(GL_DEPTH_TEST); - glBegin(GL_QUADS); - glColor3f(0.0,0.0,0.0); - glVertex3f(-1.0,-1.0, 1.0); - glVertex3f( 1.0,-1.0, 1.0); - glColor3f(10/255,98/255,144/255); - glVertex3f( 1.0, 1.0, 1.0); - glVertex3f(-1.0, 1.0, 1.0); - glEnd(); - glPopMatrix(); - glEnable(GL_DEPTH_TEST); - - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - glEnable(GL_LIGHTING); - } - - # draw ground and axes - glDisable(GL_LIGHTING); - #============================================================================================================================== + Slic3r::GUI::_3DScene::render_background($self); + +# # draw fixed background +# if ($self->background) { +# glDisable(GL_LIGHTING); +# glPushMatrix(); +# glLoadIdentity(); +# +# glMatrixMode(GL_PROJECTION); +# glPushMatrix(); +# glLoadIdentity(); +# +# # Draws a bluish bottom to top gradient over the complete screen. +# glDisable(GL_DEPTH_TEST); +# glBegin(GL_QUADS); +# glColor3f(0.0,0.0,0.0); +# glVertex3f(-1.0,-1.0, 1.0); +# glVertex3f( 1.0,-1.0, 1.0); +# glColor3f(10/255,98/255,144/255); +# glVertex3f( 1.0, 1.0, 1.0); +# glVertex3f(-1.0, 1.0, 1.0); +# glEnd(); +# glPopMatrix(); +# glEnable(GL_DEPTH_TEST); +# +# glMatrixMode(GL_MODELVIEW); +# glPopMatrix(); +# glEnable(GL_LIGHTING); +# } +# +# # draw ground and axes +# glDisable(GL_LIGHTING); +# # # draw ground # my $ground_z = GROUND_Z; #============================================================================================================================== diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 87a3c9aad6..40e6f18518 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1923,6 +1923,11 @@ void _3DScene::select_view(wxGLCanvas* canvas, const std::string& direction) s_canvas_mgr.select_view(canvas, direction); } +void _3DScene::render_background(wxGLCanvas* canvas) +{ + s_canvas_mgr.render_background(canvas); +} + void _3DScene::render_bed(wxGLCanvas* canvas) { s_canvas_mgr.render_bed(canvas); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index a3d976018d..22b8695632 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -597,6 +597,7 @@ public: static void zoom_to_volumes(wxGLCanvas* canvas); static void select_view(wxGLCanvas* canvas, const std::string& direction); + static void render_background(wxGLCanvas* canvas); static void render_bed(wxGLCanvas* canvas); static void render_axes(wxGLCanvas* canvas); static void render_cutting_plane(wxGLCanvas* canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index fce0459061..f55563f7ae 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -208,6 +208,7 @@ void GLCanvas3D::Bed::render() unsigned int triangles_vcount = m_triangles.get_data_size() / 3; if (triangles_vcount > 0) { + ::glDisable(GL_LIGHTING); ::glDisable(GL_DEPTH_TEST); ::glEnable(GL_BLEND); @@ -312,6 +313,7 @@ void GLCanvas3D::Axes::set_length(float length) void GLCanvas3D::Axes::render() { + ::glDisable(GL_LIGHTING); // disable depth testing so that axes are not covered by ground ::glDisable(GL_DEPTH_TEST); ::glLineWidth(2.0f); @@ -350,12 +352,18 @@ bool GLCanvas3D::CuttingPlane::set(float z, const ExPolygons& polygons) return m_lines.set_from_lines(lines, m_z); } -void GLCanvas3D::CuttingPlane::render_plane(const BoundingBoxf3& bb) +void GLCanvas3D::CuttingPlane::render(const BoundingBoxf3& bb) +{ + ::glDisable(GL_LIGHTING); + _render_plane(bb); + _render_contour(); +} + +void GLCanvas3D::CuttingPlane::_render_plane(const BoundingBoxf3& bb) { if (m_z >= 0.0f) { ::glDisable(GL_CULL_FACE); - ::glDisable(GL_LIGHTING); ::glEnable(GL_BLEND); ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -378,7 +386,7 @@ void GLCanvas3D::CuttingPlane::render_plane(const BoundingBoxf3& bb) } } -void GLCanvas3D::CuttingPlane::render_contour() +void GLCanvas3D::CuttingPlane::_render_contour() { ::glEnableClientState(GL_VERTEX_ARRAY); @@ -737,22 +745,50 @@ void GLCanvas3D::select_view(const std::string& direction) } } +void GLCanvas3D::render_background() +{ + static const float COLOR[3] = { 10.0f / 255.0f, 98.0f / 255.0f, 144.0f / 255.0f }; + + ::glDisable(GL_LIGHTING); + + ::glPushMatrix(); + ::glLoadIdentity(); + ::glMatrixMode(GL_PROJECTION); + ::glPushMatrix(); + ::glLoadIdentity(); + + // Draws a bluish bottom to top gradient over the complete screen. + ::glDisable(GL_DEPTH_TEST); + + ::glBegin(GL_QUADS); + ::glColor3f(0.0f, 0.0f, 0.0f); + ::glVertex3f(-1.0f, -1.0f, 1.0f); + ::glVertex3f(1.0f, -1.0f, 1.0f); + ::glColor3f(COLOR[0], COLOR[1], COLOR[2]); + ::glVertex3f(1.0f, 1.0f, 1.0f); + ::glVertex3f(-1.0f, 1.0f, 1.0f); + ::glEnd(); + + ::glEnable(GL_DEPTH_TEST); + + ::glPopMatrix(); + ::glMatrixMode(GL_MODELVIEW); + ::glPopMatrix(); +} + void GLCanvas3D::render_bed() { - ::glDisable(GL_LIGHTING); m_bed.render(); } void GLCanvas3D::render_axes() { - ::glDisable(GL_LIGHTING); m_axes.render(); } void GLCanvas3D::render_cutting_plane() { - m_cutting_plane.render_plane(volumes_bounding_box()); - m_cutting_plane.render_contour(); + m_cutting_plane.render(volumes_bounding_box()); } void GLCanvas3D::render_warning_texture() diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index e1ce33fad4..de244511a7 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -124,8 +124,11 @@ public: bool set(float z, const ExPolygons& polygons); - void render_plane(const BoundingBoxf3& bb); - void render_contour(); + void render(const BoundingBoxf3& bb); + + private: + void _render_plane(const BoundingBoxf3& bb); + void _render_contour(); }; class LayersEditing @@ -222,6 +225,7 @@ public: void zoom_to_volumes(); void select_view(const std::string& direction); + void render_background(); void render_bed(); void render_axes(); void render_cutting_plane(); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 7647e3525e..4ff07b782d 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -390,6 +390,13 @@ void GLCanvas3DManager::select_view(wxGLCanvas* canvas, const std::string& direc it->second->select_view(direction); } +void GLCanvas3DManager::render_background(wxGLCanvas* canvas) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->render_background(); +} + void GLCanvas3DManager::render_bed(wxGLCanvas* canvas) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index d79152f43b..f7293049ee 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -107,6 +107,7 @@ public: void zoom_to_volumes(wxGLCanvas* canvas); void select_view(wxGLCanvas* canvas, const std::string& direction); + void render_background(wxGLCanvas* canvas); void render_bed(wxGLCanvas* canvas); void render_axes(wxGLCanvas* canvas); void render_cutting_plane(wxGLCanvas* canvas); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 32500b3eb6..6fd23a2f08 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -444,6 +444,12 @@ select_view(canvas, direction) CODE: _3DScene::select_view((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), direction); +void +render_background(canvas) + SV *canvas; + CODE: + _3DScene::render_background((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + void render_bed(canvas) SV *canvas; From ae53c7cb2ede95bdb7eb1b8e52c95b52b309c3eb Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 21 May 2018 15:57:03 +0200 Subject: [PATCH 0395/1150] Volumes rendering moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 88 ++++++++++++++----------- xs/src/slic3r/GUI/3DScene.cpp | 5 ++ xs/src/slic3r/GUI/3DScene.hpp | 1 + xs/src/slic3r/GUI/GLCanvas3D.cpp | 67 +++++++++++++++---- xs/src/slic3r/GUI/GLCanvas3D.hpp | 25 +++---- xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 35 ++++++---- xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 15 +++-- xs/xsp/GUI_3DScene.xsp | 9 ++- 8 files changed, 159 insertions(+), 86 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index dcd8e31106..d720b40609 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1470,7 +1470,10 @@ sub Render { glDisable(GL_MULTISAMPLE) if ($self->{can_multisample}); glDisable(GL_LIGHTING); glDisable(GL_BLEND); - $self->draw_volumes(1); +#============================================================================================================================== + Slic3r::GUI::_3DScene::render_volumes($self, 1); +# $self->draw_volumes(1); +#============================================================================================================================== glPopAttrib(); glFlush(); my $col = [ glReadPixels_p($pos->x, $self->GetSize->GetHeight - $pos->y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE) ]; @@ -1598,7 +1601,10 @@ sub Render { # draw objects if (! $self->use_plain_shader) { - $self->draw_volumes; +#============================================================================================================================== + Slic3r::GUI::_3DScene::render_volumes($self, 0); +# $self->draw_volumes; +#============================================================================================================================== } elsif ($self->UseVBOs) { if ($self->enable_picking) { $self->mark_volumes_for_layer_height; @@ -1663,44 +1669,46 @@ sub Render { $self->SwapBuffers(); } -sub draw_volumes { - # $fakecolor is a boolean indicating, that the objects shall be rendered in a color coding the object index for picking. - my ($self, $fakecolor) = @_; - - # do not cull backfaces to show broken geometry, if any - glDisable(GL_CULL_FACE); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - - foreach my $volume_idx (0..$#{$self->volumes}) { - my $volume = $self->volumes->[$volume_idx]; - - if ($fakecolor) { - # Object picking mode. Render the object with a color encoding the object index. - my $r = ($volume_idx & 0x000000FF) >> 0; - my $g = ($volume_idx & 0x0000FF00) >> 8; - my $b = ($volume_idx & 0x00FF0000) >> 16; - glColor4f($r/255.0, $g/255.0, $b/255.0, 1); - } elsif ($volume->selected) { - glColor4f(@{ &SELECTED_COLOR }); - } elsif ($volume->hover) { - glColor4f(@{ &HOVER_COLOR }); - } else { - glColor4f(@{ $volume->color }); - } - - $volume->render; - } - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - - glDisable(GL_BLEND); - glEnable(GL_CULL_FACE); -} +#============================================================================================================================== +#sub draw_volumes { +# # $fakecolor is a boolean indicating, that the objects shall be rendered in a color coding the object index for picking. +# my ($self, $fakecolor) = @_; +# +# # do not cull backfaces to show broken geometry, if any +# glDisable(GL_CULL_FACE); +# +# glEnable(GL_BLEND); +# glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +# +# glEnableClientState(GL_VERTEX_ARRAY); +# glEnableClientState(GL_NORMAL_ARRAY); +# +# foreach my $volume_idx (0..$#{$self->volumes}) { +# my $volume = $self->volumes->[$volume_idx]; +# +# if ($fakecolor) { +# # Object picking mode. Render the object with a color encoding the object index. +# my $r = ($volume_idx & 0x000000FF) >> 0; +# my $g = ($volume_idx & 0x0000FF00) >> 8; +# my $b = ($volume_idx & 0x00FF0000) >> 16; +# glColor4f($r/255.0, $g/255.0, $b/255.0, 1); +# } elsif ($volume->selected) { +# glColor4f(@{ &SELECTED_COLOR }); +# } elsif ($volume->hover) { +# glColor4f(@{ &HOVER_COLOR }); +# } else { +# glColor4f(@{ $volume->color }); +# } +# +# $volume->render; +# } +# glDisableClientState(GL_NORMAL_ARRAY); +# glDisableClientState(GL_VERTEX_ARRAY); +# +# glDisable(GL_BLEND); +# glEnable(GL_CULL_FACE); +#} +#============================================================================================================================== sub mark_volumes_for_layer_height { my ($self) = @_; diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 40e6f18518..a7f5bd89e5 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1938,6 +1938,11 @@ void _3DScene::render_axes(wxGLCanvas* canvas) s_canvas_mgr.render_axes(canvas); } +void _3DScene::render_volumes(wxGLCanvas* canvas, bool fake_colors) +{ + s_canvas_mgr.render_volumes(canvas, fake_colors); +} + void _3DScene::render_cutting_plane(wxGLCanvas* canvas) { s_canvas_mgr.render_cutting_plane(canvas); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 22b8695632..24223b6b64 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -600,6 +600,7 @@ public: static void render_background(wxGLCanvas* canvas); static void render_bed(wxGLCanvas* canvas); static void render_axes(wxGLCanvas* canvas); + static void render_volumes(wxGLCanvas* canvas, bool fake_colors); static void render_cutting_plane(wxGLCanvas* canvas); static void render_warning_texture(wxGLCanvas* canvas); static void render_legend_texture(wxGLCanvas* canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index f55563f7ae..80eea86f0d 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -203,7 +203,7 @@ const BoundingBoxf3& GLCanvas3D::Bed::get_bounding_box() const return m_bounding_box; } -void GLCanvas3D::Bed::render() +void GLCanvas3D::Bed::render() const { unsigned int triangles_vcount = m_triangles.get_data_size() / 3; if (triangles_vcount > 0) @@ -311,7 +311,7 @@ void GLCanvas3D::Axes::set_length(float length) m_length = length; } -void GLCanvas3D::Axes::render() +void GLCanvas3D::Axes::render() const { ::glDisable(GL_LIGHTING); // disable depth testing so that axes are not covered by ground @@ -352,14 +352,14 @@ bool GLCanvas3D::CuttingPlane::set(float z, const ExPolygons& polygons) return m_lines.set_from_lines(lines, m_z); } -void GLCanvas3D::CuttingPlane::render(const BoundingBoxf3& bb) +void GLCanvas3D::CuttingPlane::render(const BoundingBoxf3& bb) const { ::glDisable(GL_LIGHTING); _render_plane(bb); _render_contour(); } -void GLCanvas3D::CuttingPlane::_render_plane(const BoundingBoxf3& bb) +void GLCanvas3D::CuttingPlane::_render_plane(const BoundingBoxf3& bb) const { if (m_z >= 0.0f) { @@ -386,7 +386,7 @@ void GLCanvas3D::CuttingPlane::_render_plane(const BoundingBoxf3& bb) } } -void GLCanvas3D::CuttingPlane::_render_contour() +void GLCanvas3D::CuttingPlane::_render_contour() const { ::glEnableClientState(GL_VERTEX_ARRAY); @@ -745,7 +745,7 @@ void GLCanvas3D::select_view(const std::string& direction) } } -void GLCanvas3D::render_background() +void GLCanvas3D::render_background() const { static const float COLOR[3] = { 10.0f / 255.0f, 98.0f / 255.0f, 144.0f / 255.0f }; @@ -776,22 +776,65 @@ void GLCanvas3D::render_background() ::glPopMatrix(); } -void GLCanvas3D::render_bed() +void GLCanvas3D::render_bed() const { m_bed.render(); } -void GLCanvas3D::render_axes() +void GLCanvas3D::render_axes() const { m_axes.render(); } -void GLCanvas3D::render_cutting_plane() +void GLCanvas3D::render_volumes(bool fake_colors) const +{ + static const float INV_255 = 1.0f / 255.0f; + + if (m_volumes == nullptr) + return; + + ::glEnable(GL_LIGHTING); + + // do not cull backfaces to show broken geometry, if any + ::glDisable(GL_CULL_FACE); + + ::glEnable(GL_BLEND); + ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + ::glEnableClientState(GL_VERTEX_ARRAY); + ::glEnableClientState(GL_NORMAL_ARRAY); + + unsigned int volume_id = 0; + for (const GLVolume* vol : m_volumes->volumes) + { + if (fake_colors) + { + // Object picking mode. Render the object with a color encoding the object index. + unsigned int r = (volume_id & 0x000000FF) >> 0; + unsigned int g = (volume_id & 0x0000FF00) >> 8; + unsigned int b = (volume_id & 0x00FF0000) >> 16; + ::glColor4f((float)r * INV_255, (float)g * INV_255, (float)b * INV_255, 1.0f); + } + else + ::glColor4f(vol->render_color[0], vol->render_color[1], vol->render_color[2], vol->render_color[3]); + + vol->render(); + ++volume_id; + } + + ::glDisableClientState(GL_NORMAL_ARRAY); + ::glDisableClientState(GL_VERTEX_ARRAY); + ::glDisable(GL_BLEND); + + ::glEnable(GL_CULL_FACE); +} + +void GLCanvas3D::render_cutting_plane() const { m_cutting_plane.render(volumes_bounding_box()); } -void GLCanvas3D::render_warning_texture() +void GLCanvas3D::render_warning_texture() const { if (!m_warning_texture_enabled) return; @@ -824,7 +867,7 @@ void GLCanvas3D::render_warning_texture() } } -void GLCanvas3D::render_legend_texture() +void GLCanvas3D::render_legend_texture() const { if (!m_legend_texture_enabled) return; @@ -856,7 +899,7 @@ void GLCanvas3D::render_legend_texture() } } -void GLCanvas3D::render_texture(unsigned int tex_id, float left, float right, float bottom, float top) +void GLCanvas3D::render_texture(unsigned int tex_id, float left, float right, float bottom, float top) const { ::glColor4f(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index de244511a7..29be074903 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -89,7 +89,7 @@ public: const BoundingBoxf3& get_bounding_box() const; - void render(); + void render() const; private: void _calc_bounding_box(); @@ -111,7 +111,7 @@ public: float get_length() const; void set_length(float length); - void render(); + void render() const; }; class CuttingPlane @@ -124,11 +124,11 @@ public: bool set(float z, const ExPolygons& polygons); - void render(const BoundingBoxf3& bb); + void render(const BoundingBoxf3& bb) const; private: - void _render_plane(const BoundingBoxf3& bb); - void _render_contour(); + void _render_plane(const BoundingBoxf3& bb) const; + void _render_contour() const; }; class LayersEditing @@ -225,14 +225,15 @@ public: void zoom_to_volumes(); void select_view(const std::string& direction); - void render_background(); - void render_bed(); - void render_axes(); - void render_cutting_plane(); - void render_warning_texture(); - void render_legend_texture(); + void render_background() const; + void render_bed() const; + void render_axes() const; + void render_volumes(bool fake_colors) const; + void render_cutting_plane() const; + void render_warning_texture() const; + void render_legend_texture() const; - void render_texture(unsigned int tex_id, float left, float right, float bottom, float top); + void render_texture(unsigned int tex_id, float left, float right, float bottom, float top) const; void register_on_viewport_changed_callback(void* callback); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index 4ff07b782d..7e8cf913f7 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -390,51 +390,58 @@ void GLCanvas3DManager::select_view(wxGLCanvas* canvas, const std::string& direc it->second->select_view(direction); } -void GLCanvas3DManager::render_background(wxGLCanvas* canvas) +void GLCanvas3DManager::render_background(wxGLCanvas* canvas) const { - CanvasesMap::iterator it = _get_canvas(canvas); + CanvasesMap::const_iterator it = _get_canvas(canvas); if (it != m_canvases.end()) it->second->render_background(); } -void GLCanvas3DManager::render_bed(wxGLCanvas* canvas) +void GLCanvas3DManager::render_bed(wxGLCanvas* canvas) const { - CanvasesMap::iterator it = _get_canvas(canvas); + CanvasesMap::const_iterator it = _get_canvas(canvas); if (it != m_canvases.end()) it->second->render_bed(); } -void GLCanvas3DManager::render_axes(wxGLCanvas* canvas) +void GLCanvas3DManager::render_axes(wxGLCanvas* canvas) const { - CanvasesMap::iterator it = _get_canvas(canvas); + CanvasesMap::const_iterator it = _get_canvas(canvas); if (it != m_canvases.end()) it->second->render_axes(); } -void GLCanvas3DManager::render_cutting_plane(wxGLCanvas* canvas) +void GLCanvas3DManager::render_volumes(wxGLCanvas* canvas, bool fake_colors) const { - CanvasesMap::iterator it = _get_canvas(canvas); + CanvasesMap::const_iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->render_volumes(fake_colors); +} + +void GLCanvas3DManager::render_cutting_plane(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); if (it != m_canvases.end()) it->second->render_cutting_plane(); } -void GLCanvas3DManager::render_warning_texture(wxGLCanvas* canvas) +void GLCanvas3DManager::render_warning_texture(wxGLCanvas* canvas) const { - CanvasesMap::iterator it = _get_canvas(canvas); + CanvasesMap::const_iterator it = _get_canvas(canvas); if (it != m_canvases.end()) it->second->render_warning_texture(); } -void GLCanvas3DManager::render_legend_texture(wxGLCanvas* canvas) +void GLCanvas3DManager::render_legend_texture(wxGLCanvas* canvas) const { - CanvasesMap::iterator it = _get_canvas(canvas); + CanvasesMap::const_iterator it = _get_canvas(canvas); if (it != m_canvases.end()) it->second->render_legend_texture(); } -void GLCanvas3DManager::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) +void GLCanvas3DManager::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) const { - CanvasesMap::iterator it = _get_canvas(canvas); + CanvasesMap::const_iterator it = _get_canvas(canvas); if (it != m_canvases.end()) it->second->render_texture(tex_id, left, right, bottom, top); } diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index f7293049ee..f2ff8a112f 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -107,14 +107,15 @@ public: void zoom_to_volumes(wxGLCanvas* canvas); void select_view(wxGLCanvas* canvas, const std::string& direction); - void render_background(wxGLCanvas* canvas); - void render_bed(wxGLCanvas* canvas); - void render_axes(wxGLCanvas* canvas); - void render_cutting_plane(wxGLCanvas* canvas); - void render_warning_texture(wxGLCanvas* canvas); - void render_legend_texture(wxGLCanvas* canvas); + void render_background(wxGLCanvas* canvas) const; + void render_bed(wxGLCanvas* canvas) const; + void render_axes(wxGLCanvas* canvas) const; + void render_volumes(wxGLCanvas* canvas, bool fake_colors) const; + void render_cutting_plane(wxGLCanvas* canvas) const; + void render_warning_texture(wxGLCanvas* canvas) const; + void render_legend_texture(wxGLCanvas* canvas) const; - void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top); + void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) const; void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 6fd23a2f08..40332e7ec1 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -461,7 +461,14 @@ render_axes(canvas) SV *canvas; CODE: _3DScene::render_axes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); - + +void +render_volumes(canvas, fake_colors) + SV *canvas; + bool fake_colors; + CODE: + _3DScene::render_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), fake_colors); + void render_cutting_plane(canvas) SV *canvas; From e6e078cbf7651834d1d026c22eccd0425194b8f4 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 21 May 2018 15:56:35 +0200 Subject: [PATCH 0396/1150] Unneccessary AGG sources removed. Added libpng and zlib sources and static build in cmake. --- xs/CMakeLists.txt | 31 +- xs/src/agg/AUTHORS | 2 + xs/src/agg/agg_alpha_mask_u8.h | 499 -- xs/src/agg/agg_arc.h | 74 - xs/src/agg/agg_arrowhead.h | 82 - xs/src/agg/agg_bitset_iterator.h | 54 - xs/src/agg/agg_blur.h | 1503 ----- xs/src/agg/agg_bounding_rect.h | 116 - xs/src/agg/agg_bspline.h | 76 - xs/src/agg/agg_conv_adaptor_vcgen.h | 157 - xs/src/agg/agg_conv_adaptor_vpgen.h | 159 - xs/src/agg/agg_conv_bspline.h | 48 - xs/src/agg/agg_conv_clip_polygon.h | 63 - xs/src/agg/agg_conv_clip_polyline.h | 63 - xs/src/agg/agg_conv_close_polygon.h | 125 - xs/src/agg/agg_conv_concat.h | 73 - xs/src/agg/agg_conv_contour.h | 65 - xs/src/agg/agg_conv_curve.h | 201 - xs/src/agg/agg_conv_dash.h | 68 - xs/src/agg/agg_conv_gpc.h | 432 -- xs/src/agg/agg_conv_marker.h | 148 - xs/src/agg/agg_conv_marker_adaptor.h | 51 - xs/src/agg/agg_conv_segmentator.h | 48 - xs/src/agg/agg_conv_shorten_path.h | 50 - xs/src/agg/agg_conv_smooth_poly1.h | 80 - xs/src/agg/agg_conv_stroke.h | 73 - xs/src/agg/agg_conv_unclose_polygon.h | 52 - xs/src/agg/agg_curves.h | 693 --- xs/src/agg/agg_dda_line.h | 290 - xs/src/agg/agg_ellipse.h | 123 - xs/src/agg/agg_ellipse_bresenham.h | 113 - xs/src/agg/agg_embedded_raster_fonts.h | 59 - xs/src/agg/agg_font_cache_manager.h | 409 -- xs/src/agg/agg_font_cache_manager2.h | 311 - xs/src/agg/agg_glyph_raster_bin.h | 155 - xs/src/agg/agg_gradient_lut.h | 244 - xs/src/agg/agg_gsv_text.h | 153 - xs/src/agg/agg_image_accessors.h | 481 -- xs/src/agg/agg_image_filters.h | 449 -- xs/src/agg/agg_line_aa_basics.h | 189 - xs/src/agg/agg_math_stroke.h | 526 -- xs/src/agg/agg_path_length.h | 65 - xs/src/agg/agg_path_storage_integer.h | 295 - xs/src/agg/agg_pattern_filters_rgba.h | 123 - xs/src/agg/agg_pixfmt_amask_adaptor.h | 240 - xs/src/agg/agg_pixfmt_rgb_packed.h | 1311 ----- xs/src/agg/agg_pixfmt_rgba.h | 2803 --------- xs/src/agg/agg_pixfmt_transposer.h | 157 - xs/src/agg/agg_rasterizer_compound_aa.h | 665 --- xs/src/agg/agg_rasterizer_outline.h | 147 - xs/src/agg/agg_rasterizer_outline_aa.h | 599 -- xs/src/agg/agg_renderer_markers.h | 711 --- xs/src/agg/agg_renderer_mclip.h | 349 -- xs/src/agg/agg_renderer_outline_aa.h | 1836 ------ xs/src/agg/agg_renderer_outline_image.h | 1036 ---- xs/src/agg/agg_renderer_primitives.h | 224 - xs/src/agg/agg_renderer_raster_text.h | 264 - xs/src/agg/agg_rendering_buffer_dynarow.h | 137 - xs/src/agg/agg_rounded_rect.h | 72 - xs/src/agg/agg_scanline_bin.h | 264 - xs/src/agg/agg_scanline_boolean_algebra.h | 1567 ------ xs/src/agg/agg_scanline_storage_aa.h | 816 --- xs/src/agg/agg_scanline_storage_bin.h | 587 -- xs/src/agg/agg_scanline_u.h | 499 -- xs/src/agg/agg_shorten_path.h | 66 - xs/src/agg/agg_simul_eq.h | 147 - xs/src/agg/agg_span_allocator.h | 54 - xs/src/agg/agg_span_converter.h | 56 - xs/src/agg/agg_span_gouraud.h | 172 - xs/src/agg/agg_span_gouraud_gray.h | 241 - xs/src/agg/agg_span_gouraud_rgba.h | 277 - xs/src/agg/agg_span_gradient.h | 377 -- xs/src/agg/agg_span_gradient_alpha.h | 126 - xs/src/agg/agg_span_gradient_contour.h | 362 -- xs/src/agg/agg_span_gradient_image.h | 188 - xs/src/agg/agg_span_image_filter.h | 247 - xs/src/agg/agg_span_image_filter_gray.h | 723 --- xs/src/agg/agg_span_image_filter_rgb.h | 861 --- xs/src/agg/agg_span_image_filter_rgba.h | 890 --- xs/src/agg/agg_span_interpolator_adaptor.h | 77 - xs/src/agg/agg_span_interpolator_linear.h | 232 - xs/src/agg/agg_span_interpolator_persp.h | 462 -- xs/src/agg/agg_span_interpolator_trans.h | 92 - xs/src/agg/agg_span_pattern_gray.h | 93 - xs/src/agg/agg_span_pattern_rgb.h | 96 - xs/src/agg/agg_span_pattern_rgba.h | 94 - xs/src/agg/agg_span_solid.h | 53 - xs/src/agg/agg_span_subdiv_adaptor.h | 141 - xs/src/agg/agg_trans_bilinear.h | 166 - xs/src/agg/agg_trans_double_path.h | 131 - xs/src/agg/agg_trans_perspective.h | 731 --- xs/src/agg/agg_trans_single_path.h | 97 - xs/src/agg/agg_trans_viewport.h | 303 - xs/src/agg/agg_trans_warp_magnifier.h | 56 - xs/src/agg/agg_vcgen_bspline.h | 74 - xs/src/agg/agg_vcgen_contour.h | 94 - xs/src/agg/agg_vcgen_dash.h | 93 - xs/src/agg/agg_vcgen_markers_term.h | 66 - xs/src/agg/agg_vcgen_smooth_poly1.h | 87 - xs/src/agg/agg_vcgen_stroke.h | 102 - xs/src/agg/agg_vcgen_vertex_sequence.h | 135 - xs/src/agg/agg_vertex_sequence.h | 172 - xs/src/agg/agg_vpgen_clip_polygon.h | 83 - xs/src/agg/agg_vpgen_clip_polyline.h | 78 - xs/src/agg/agg_vpgen_segmentator.h | 61 - xs/src/libslic3r/Rasterizer/Rasterizer.cpp | 1 - xs/src/png/AUTHORS | 4 + xs/src/png/NEWS | 60 + xs/src/png/libpng/ANNOUNCE | 35 + xs/src/png/libpng/CMakeLists.txt | 937 +++ xs/src/png/libpng/LICENSE | 133 + xs/src/png/libpng/libpng-config.in | 127 + xs/src/png/libpng/libpng.pc.in | 12 + xs/src/png/libpng/png.c | 4614 +++++++++++++++ xs/src/png/libpng/png.h | 3278 +++++++++++ xs/src/png/libpng/pngconf.h | 622 ++ xs/src/png/libpng/pngdebug.h | 153 + xs/src/png/libpng/pngerror.c | 963 ++++ xs/src/png/libpng/pngget.c | 1248 ++++ xs/src/png/libpng/pnginfo.h | 267 + xs/src/png/libpng/pngmem.c | 284 + xs/src/png/libpng/pngpread.c | 1096 ++++ xs/src/png/libpng/pngpriv.h | 2120 +++++++ xs/src/png/libpng/pngread.c | 4219 ++++++++++++++ xs/src/png/libpng/pngrio.c | 120 + xs/src/png/libpng/pngrtran.c | 5010 +++++++++++++++++ xs/src/png/libpng/pngrutil.c | 4661 +++++++++++++++ xs/src/png/libpng/pngset.c | 1802 ++++++ xs/src/png/libpng/pngstruct.h | 483 ++ xs/src/png/libpng/pngtest.c | 2156 +++++++ xs/src/png/libpng/pngtrans.c | 864 +++ xs/src/png/libpng/pngwio.c | 168 + xs/src/png/libpng/pngwrite.c | 2396 ++++++++ xs/src/png/libpng/pngwtran.c | 576 ++ xs/src/png/libpng/pngwutil.c | 2784 +++++++++ xs/src/png/libpng/scripts/genchk.cmake.in | 37 + xs/src/png/libpng/scripts/genout.cmake.in | 93 + xs/src/png/libpng/scripts/gensrc.cmake.in | 138 + .../png/libpng/scripts/libpng-config-body.in | 96 + .../png/libpng/scripts/libpng-config-head.in | 24 + xs/src/png/libpng/scripts/libpng.pc.in | 10 + .../png/libpng/scripts/pnglibconf.h.prebuilt | 220 + xs/src/png/libpng/scripts/test.cmake.in | 31 + xs/src/png/zlib/CMakeLists.txt | 251 + xs/src/png/zlib/ChangeLog | 1515 +++++ xs/src/png/zlib/FAQ | 368 ++ xs/src/png/zlib/INDEX | 68 + xs/src/png/zlib/Makefile | 5 + xs/src/png/zlib/Makefile.in | 410 ++ xs/src/png/zlib/README | 115 + xs/src/png/zlib/adler32.c | 186 + xs/src/png/zlib/amiga/Makefile.pup | 69 + xs/src/png/zlib/amiga/Makefile.sas | 68 + xs/src/png/zlib/compress.c | 86 + xs/src/png/zlib/configure | 921 +++ xs/src/png/zlib/contrib/README.contrib | 78 + xs/src/png/zlib/contrib/ada/buffer_demo.adb | 106 + xs/src/png/zlib/contrib/ada/mtest.adb | 156 + xs/src/png/zlib/contrib/ada/read.adb | 156 + xs/src/png/zlib/contrib/ada/readme.txt | 65 + xs/src/png/zlib/contrib/ada/test.adb | 463 ++ xs/src/png/zlib/contrib/ada/zlib-streams.adb | 225 + xs/src/png/zlib/contrib/ada/zlib-streams.ads | 114 + xs/src/png/zlib/contrib/ada/zlib-thin.adb | 141 + xs/src/png/zlib/contrib/ada/zlib-thin.ads | 450 ++ xs/src/png/zlib/contrib/ada/zlib.adb | 701 +++ xs/src/png/zlib/contrib/ada/zlib.ads | 328 ++ xs/src/png/zlib/contrib/ada/zlib.gpr | 20 + xs/src/png/zlib/contrib/amd64/amd64-match.S | 452 ++ xs/src/png/zlib/contrib/asm686/README.686 | 51 + xs/src/png/zlib/contrib/asm686/match.S | 357 ++ xs/src/png/zlib/contrib/blast/Makefile | 8 + xs/src/png/zlib/contrib/blast/README | 4 + xs/src/png/zlib/contrib/blast/blast.c | 466 ++ xs/src/png/zlib/contrib/blast/blast.h | 83 + xs/src/png/zlib/contrib/blast/test.pk | Bin 0 -> 8 bytes xs/src/png/zlib/contrib/blast/test.txt | 1 + xs/src/png/zlib/contrib/delphi/ZLib.pas | 557 ++ xs/src/png/zlib/contrib/delphi/ZLibConst.pas | 11 + xs/src/png/zlib/contrib/delphi/readme.txt | 76 + xs/src/png/zlib/contrib/delphi/zlibd32.mak | 99 + xs/src/png/zlib/contrib/dotzlib/DotZLib.build | 33 + xs/src/png/zlib/contrib/dotzlib/DotZLib.chm | Bin 0 -> 72726 bytes xs/src/png/zlib/contrib/dotzlib/DotZLib.sln | 21 + .../contrib/dotzlib/DotZLib/AssemblyInfo.cs | 58 + .../contrib/dotzlib/DotZLib/ChecksumImpl.cs | 202 + .../contrib/dotzlib/DotZLib/CircularBuffer.cs | 83 + .../zlib/contrib/dotzlib/DotZLib/CodecBase.cs | 198 + .../zlib/contrib/dotzlib/DotZLib/Deflater.cs | 106 + .../zlib/contrib/dotzlib/DotZLib/DotZLib.cs | 288 + .../contrib/dotzlib/DotZLib/DotZLib.csproj | 141 + .../contrib/dotzlib/DotZLib/GZipStream.cs | 301 + .../zlib/contrib/dotzlib/DotZLib/Inflater.cs | 105 + .../zlib/contrib/dotzlib/DotZLib/UnitTests.cs | 274 + .../png/zlib/contrib/dotzlib/LICENSE_1_0.txt | 23 + xs/src/png/zlib/contrib/dotzlib/readme.txt | 58 + xs/src/png/zlib/contrib/gcc_gvmat64/gvmat64.S | 574 ++ xs/src/png/zlib/contrib/infback9/README | 1 + xs/src/png/zlib/contrib/infback9/infback9.c | 615 ++ xs/src/png/zlib/contrib/infback9/infback9.h | 37 + xs/src/png/zlib/contrib/infback9/inffix9.h | 107 + xs/src/png/zlib/contrib/infback9/inflate9.h | 47 + xs/src/png/zlib/contrib/infback9/inftree9.c | 324 ++ xs/src/png/zlib/contrib/infback9/inftree9.h | 61 + xs/src/png/zlib/contrib/inflate86/inffas86.c | 1157 ++++ xs/src/png/zlib/contrib/inflate86/inffast.S | 1368 +++++ xs/src/png/zlib/contrib/iostream/test.cpp | 24 + xs/src/png/zlib/contrib/iostream/zfstream.cpp | 329 ++ xs/src/png/zlib/contrib/iostream/zfstream.h | 128 + xs/src/png/zlib/contrib/iostream2/zstream.h | 307 + .../zlib/contrib/iostream2/zstream_test.cpp | 25 + xs/src/png/zlib/contrib/iostream3/README | 35 + xs/src/png/zlib/contrib/iostream3/TODO | 17 + xs/src/png/zlib/contrib/iostream3/test.cc | 50 + xs/src/png/zlib/contrib/iostream3/zfstream.cc | 479 ++ xs/src/png/zlib/contrib/iostream3/zfstream.h | 466 ++ xs/src/png/zlib/contrib/masmx64/bld_ml64.bat | 2 + xs/src/png/zlib/contrib/masmx64/gvmat64.asm | 553 ++ xs/src/png/zlib/contrib/masmx64/inffas8664.c | 186 + xs/src/png/zlib/contrib/masmx64/inffasx64.asm | 396 ++ xs/src/png/zlib/contrib/masmx64/readme.txt | 31 + xs/src/png/zlib/contrib/masmx86/bld_ml32.bat | 2 + xs/src/png/zlib/contrib/masmx86/inffas32.asm | 1080 ++++ xs/src/png/zlib/contrib/masmx86/match686.asm | 479 ++ xs/src/png/zlib/contrib/masmx86/readme.txt | 27 + xs/src/png/zlib/contrib/minizip/Makefile | 25 + xs/src/png/zlib/contrib/minizip/Makefile.am | 45 + .../contrib/minizip/MiniZip64_Changes.txt | 6 + .../zlib/contrib/minizip/MiniZip64_info.txt | 74 + xs/src/png/zlib/contrib/minizip/configure.ac | 32 + xs/src/png/zlib/contrib/minizip/crypt.h | 131 + xs/src/png/zlib/contrib/minizip/ioapi.c | 247 + xs/src/png/zlib/contrib/minizip/ioapi.h | 208 + xs/src/png/zlib/contrib/minizip/iowin32.c | 462 ++ xs/src/png/zlib/contrib/minizip/iowin32.h | 28 + xs/src/png/zlib/contrib/minizip/make_vms.com | 25 + xs/src/png/zlib/contrib/minizip/miniunz.c | 660 +++ xs/src/png/zlib/contrib/minizip/miniunzip.1 | 63 + xs/src/png/zlib/contrib/minizip/minizip.1 | 46 + xs/src/png/zlib/contrib/minizip/minizip.c | 520 ++ xs/src/png/zlib/contrib/minizip/minizip.pc.in | 12 + xs/src/png/zlib/contrib/minizip/mztools.c | 291 + xs/src/png/zlib/contrib/minizip/mztools.h | 37 + xs/src/png/zlib/contrib/minizip/unzip.c | 2125 +++++++ xs/src/png/zlib/contrib/minizip/unzip.h | 437 ++ xs/src/png/zlib/contrib/minizip/zip.c | 2007 +++++++ xs/src/png/zlib/contrib/minizip/zip.h | 362 ++ xs/src/png/zlib/contrib/pascal/example.pas | 599 ++ xs/src/png/zlib/contrib/pascal/readme.txt | 76 + xs/src/png/zlib/contrib/pascal/zlibd32.mak | 99 + xs/src/png/zlib/contrib/pascal/zlibpas.pas | 276 + xs/src/png/zlib/contrib/puff/Makefile | 42 + xs/src/png/zlib/contrib/puff/README | 63 + xs/src/png/zlib/contrib/puff/puff.c | 840 +++ xs/src/png/zlib/contrib/puff/puff.h | 35 + xs/src/png/zlib/contrib/puff/pufftest.c | 165 + xs/src/png/zlib/contrib/puff/zeros.raw | Bin 0 -> 2517 bytes xs/src/png/zlib/contrib/testzlib/testzlib.c | 275 + xs/src/png/zlib/contrib/testzlib/testzlib.txt | 10 + xs/src/png/zlib/contrib/untgz/Makefile | 14 + xs/src/png/zlib/contrib/untgz/Makefile.msc | 17 + xs/src/png/zlib/contrib/untgz/untgz.c | 674 +++ xs/src/png/zlib/contrib/vstudio/readme.txt | 78 + .../zlib/contrib/vstudio/vc10/miniunz.vcxproj | 310 + .../vstudio/vc10/miniunz.vcxproj.filters | 22 + .../zlib/contrib/vstudio/vc10/minizip.vcxproj | 307 + .../vstudio/vc10/minizip.vcxproj.filters | 22 + .../contrib/vstudio/vc10/testzlib.vcxproj | 420 ++ .../vstudio/vc10/testzlib.vcxproj.filters | 58 + .../contrib/vstudio/vc10/testzlibdll.vcxproj | 310 + .../vstudio/vc10/testzlibdll.vcxproj.filters | 22 + xs/src/png/zlib/contrib/vstudio/vc10/zlib.rc | 32 + .../contrib/vstudio/vc10/zlibstat.vcxproj | 473 ++ .../vstudio/vc10/zlibstat.vcxproj.filters | 77 + .../png/zlib/contrib/vstudio/vc10/zlibvc.def | 153 + .../png/zlib/contrib/vstudio/vc10/zlibvc.sln | 135 + .../zlib/contrib/vstudio/vc10/zlibvc.vcxproj | 657 +++ .../vstudio/vc10/zlibvc.vcxproj.filters | 118 + .../zlib/contrib/vstudio/vc11/miniunz.vcxproj | 314 ++ .../zlib/contrib/vstudio/vc11/minizip.vcxproj | 311 + .../contrib/vstudio/vc11/testzlib.vcxproj | 426 ++ .../contrib/vstudio/vc11/testzlibdll.vcxproj | 314 ++ xs/src/png/zlib/contrib/vstudio/vc11/zlib.rc | 32 + .../contrib/vstudio/vc11/zlibstat.vcxproj | 464 ++ .../png/zlib/contrib/vstudio/vc11/zlibvc.def | 153 + .../png/zlib/contrib/vstudio/vc11/zlibvc.sln | 117 + .../zlib/contrib/vstudio/vc11/zlibvc.vcxproj | 688 +++ .../zlib/contrib/vstudio/vc12/miniunz.vcxproj | 316 ++ .../zlib/contrib/vstudio/vc12/minizip.vcxproj | 313 + .../contrib/vstudio/vc12/testzlib.vcxproj | 430 ++ .../contrib/vstudio/vc12/testzlibdll.vcxproj | 316 ++ xs/src/png/zlib/contrib/vstudio/vc12/zlib.rc | 32 + .../contrib/vstudio/vc12/zlibstat.vcxproj | 467 ++ .../png/zlib/contrib/vstudio/vc12/zlibvc.def | 153 + .../png/zlib/contrib/vstudio/vc12/zlibvc.sln | 119 + .../zlib/contrib/vstudio/vc12/zlibvc.vcxproj | 692 +++ .../zlib/contrib/vstudio/vc14/miniunz.vcxproj | 316 ++ .../zlib/contrib/vstudio/vc14/minizip.vcxproj | 313 + .../contrib/vstudio/vc14/testzlib.vcxproj | 430 ++ .../contrib/vstudio/vc14/testzlibdll.vcxproj | 316 ++ xs/src/png/zlib/contrib/vstudio/vc14/zlib.rc | 32 + .../contrib/vstudio/vc14/zlibstat.vcxproj | 467 ++ .../png/zlib/contrib/vstudio/vc14/zlibvc.def | 153 + .../png/zlib/contrib/vstudio/vc14/zlibvc.sln | 119 + .../zlib/contrib/vstudio/vc14/zlibvc.vcxproj | 692 +++ .../zlib/contrib/vstudio/vc9/miniunz.vcproj | 565 ++ .../zlib/contrib/vstudio/vc9/minizip.vcproj | 562 ++ .../zlib/contrib/vstudio/vc9/testzlib.vcproj | 852 +++ .../contrib/vstudio/vc9/testzlibdll.vcproj | 565 ++ xs/src/png/zlib/contrib/vstudio/vc9/zlib.rc | 32 + .../zlib/contrib/vstudio/vc9/zlibstat.vcproj | 835 +++ .../png/zlib/contrib/vstudio/vc9/zlibvc.def | 153 + .../png/zlib/contrib/vstudio/vc9/zlibvc.sln | 144 + .../zlib/contrib/vstudio/vc9/zlibvc.vcproj | 1156 ++++ xs/src/png/zlib/crc32.c | 442 ++ xs/src/png/zlib/crc32.h | 441 ++ xs/src/png/zlib/deflate.c | 2163 +++++++ xs/src/png/zlib/deflate.h | 349 ++ xs/src/png/zlib/gzclose.c | 25 + xs/src/png/zlib/gzguts.h | 218 + xs/src/png/zlib/gzlib.c | 637 +++ xs/src/png/zlib/gzread.c | 654 +++ xs/src/png/zlib/gzwrite.c | 665 +++ xs/src/png/zlib/infback.c | 640 +++ xs/src/png/zlib/inffast.c | 323 ++ xs/src/png/zlib/inffast.h | 11 + xs/src/png/zlib/inffixed.h | 94 + xs/src/png/zlib/inflate.c | 1561 +++++ xs/src/png/zlib/inflate.h | 125 + xs/src/png/zlib/inftrees.c | 304 + xs/src/png/zlib/inftrees.h | 62 + xs/src/png/zlib/make_vms.com | 867 +++ xs/src/png/zlib/msdos/Makefile.bor | 115 + xs/src/png/zlib/msdos/Makefile.dj2 | 104 + xs/src/png/zlib/msdos/Makefile.emx | 69 + xs/src/png/zlib/msdos/Makefile.msc | 112 + xs/src/png/zlib/msdos/Makefile.tc | 100 + xs/src/png/zlib/nintendods/Makefile | 126 + xs/src/png/zlib/nintendods/README | 5 + xs/src/png/zlib/old/Makefile.emx | 69 + xs/src/png/zlib/old/Makefile.riscos | 151 + xs/src/png/zlib/old/README | 3 + xs/src/png/zlib/old/descrip.mms | 48 + xs/src/png/zlib/old/os2/Makefile.os2 | 136 + xs/src/png/zlib/old/os2/zlib.def | 51 + xs/src/png/zlib/old/visual-basic.txt | 160 + xs/src/png/zlib/os400/README400 | 48 + xs/src/png/zlib/os400/bndsrc | 119 + xs/src/png/zlib/os400/make.sh | 366 ++ xs/src/png/zlib/os400/zlib.inc | 527 ++ xs/src/png/zlib/qnx/package.qpg | 141 + xs/src/png/zlib/treebuild.xml | 116 + xs/src/png/zlib/trees.c | 1203 ++++ xs/src/png/zlib/trees.h | 128 + xs/src/png/zlib/uncompr.c | 93 + xs/src/png/zlib/watcom/watcom_f.mak | 43 + xs/src/png/zlib/watcom/watcom_l.mak | 43 + xs/src/png/zlib/win32/DLL_FAQ.txt | 397 ++ xs/src/png/zlib/win32/Makefile.bor | 110 + xs/src/png/zlib/win32/Makefile.gcc | 182 + xs/src/png/zlib/win32/Makefile.msc | 163 + xs/src/png/zlib/win32/README-WIN32.txt | 103 + xs/src/png/zlib/win32/VisualC.txt | 3 + xs/src/png/zlib/win32/zlib.def | 94 + xs/src/png/zlib/win32/zlib1.rc | 40 + xs/src/png/zlib/zconf.h.cmakein | 536 ++ xs/src/png/zlib/zconf.h.in | 534 ++ xs/src/png/zlib/zconf.h.included | 534 ++ xs/src/png/zlib/zlib.3 | 149 + xs/src/png/zlib/zlib.3.pdf | Bin 0 -> 19318 bytes xs/src/png/zlib/zlib.h | 1912 +++++++ xs/src/png/zlib/zlib.map | 94 + xs/src/png/zlib/zlib.pc.cmakein | 13 + xs/src/png/zlib/zlib.pc.in | 13 + xs/src/png/zlib/zlib2ansi | 152 + xs/src/png/zlib/zutil.c | 325 ++ xs/src/png/zlib/zutil.h | 271 + 377 files changed, 108760 insertions(+), 31984 deletions(-) create mode 100644 xs/src/agg/AUTHORS delete mode 100644 xs/src/agg/agg_alpha_mask_u8.h delete mode 100644 xs/src/agg/agg_arc.h delete mode 100644 xs/src/agg/agg_arrowhead.h delete mode 100644 xs/src/agg/agg_bitset_iterator.h delete mode 100644 xs/src/agg/agg_blur.h delete mode 100644 xs/src/agg/agg_bounding_rect.h delete mode 100644 xs/src/agg/agg_bspline.h delete mode 100644 xs/src/agg/agg_conv_adaptor_vcgen.h delete mode 100644 xs/src/agg/agg_conv_adaptor_vpgen.h delete mode 100644 xs/src/agg/agg_conv_bspline.h delete mode 100644 xs/src/agg/agg_conv_clip_polygon.h delete mode 100644 xs/src/agg/agg_conv_clip_polyline.h delete mode 100644 xs/src/agg/agg_conv_close_polygon.h delete mode 100644 xs/src/agg/agg_conv_concat.h delete mode 100644 xs/src/agg/agg_conv_contour.h delete mode 100644 xs/src/agg/agg_conv_curve.h delete mode 100644 xs/src/agg/agg_conv_dash.h delete mode 100644 xs/src/agg/agg_conv_gpc.h delete mode 100644 xs/src/agg/agg_conv_marker.h delete mode 100644 xs/src/agg/agg_conv_marker_adaptor.h delete mode 100644 xs/src/agg/agg_conv_segmentator.h delete mode 100644 xs/src/agg/agg_conv_shorten_path.h delete mode 100644 xs/src/agg/agg_conv_smooth_poly1.h delete mode 100644 xs/src/agg/agg_conv_stroke.h delete mode 100644 xs/src/agg/agg_conv_unclose_polygon.h delete mode 100644 xs/src/agg/agg_curves.h delete mode 100644 xs/src/agg/agg_dda_line.h delete mode 100644 xs/src/agg/agg_ellipse.h delete mode 100644 xs/src/agg/agg_ellipse_bresenham.h delete mode 100644 xs/src/agg/agg_embedded_raster_fonts.h delete mode 100644 xs/src/agg/agg_font_cache_manager.h delete mode 100644 xs/src/agg/agg_font_cache_manager2.h delete mode 100644 xs/src/agg/agg_glyph_raster_bin.h delete mode 100644 xs/src/agg/agg_gradient_lut.h delete mode 100644 xs/src/agg/agg_gsv_text.h delete mode 100644 xs/src/agg/agg_image_accessors.h delete mode 100644 xs/src/agg/agg_image_filters.h delete mode 100644 xs/src/agg/agg_line_aa_basics.h delete mode 100644 xs/src/agg/agg_math_stroke.h delete mode 100644 xs/src/agg/agg_path_length.h delete mode 100644 xs/src/agg/agg_path_storage_integer.h delete mode 100644 xs/src/agg/agg_pattern_filters_rgba.h delete mode 100644 xs/src/agg/agg_pixfmt_amask_adaptor.h delete mode 100644 xs/src/agg/agg_pixfmt_rgb_packed.h delete mode 100644 xs/src/agg/agg_pixfmt_rgba.h delete mode 100644 xs/src/agg/agg_pixfmt_transposer.h delete mode 100644 xs/src/agg/agg_rasterizer_compound_aa.h delete mode 100644 xs/src/agg/agg_rasterizer_outline.h delete mode 100644 xs/src/agg/agg_rasterizer_outline_aa.h delete mode 100644 xs/src/agg/agg_renderer_markers.h delete mode 100644 xs/src/agg/agg_renderer_mclip.h delete mode 100644 xs/src/agg/agg_renderer_outline_aa.h delete mode 100644 xs/src/agg/agg_renderer_outline_image.h delete mode 100644 xs/src/agg/agg_renderer_primitives.h delete mode 100644 xs/src/agg/agg_renderer_raster_text.h delete mode 100644 xs/src/agg/agg_rendering_buffer_dynarow.h delete mode 100644 xs/src/agg/agg_rounded_rect.h delete mode 100644 xs/src/agg/agg_scanline_bin.h delete mode 100644 xs/src/agg/agg_scanline_boolean_algebra.h delete mode 100644 xs/src/agg/agg_scanline_storage_aa.h delete mode 100644 xs/src/agg/agg_scanline_storage_bin.h delete mode 100644 xs/src/agg/agg_scanline_u.h delete mode 100644 xs/src/agg/agg_shorten_path.h delete mode 100644 xs/src/agg/agg_simul_eq.h delete mode 100644 xs/src/agg/agg_span_allocator.h delete mode 100644 xs/src/agg/agg_span_converter.h delete mode 100644 xs/src/agg/agg_span_gouraud.h delete mode 100644 xs/src/agg/agg_span_gouraud_gray.h delete mode 100644 xs/src/agg/agg_span_gouraud_rgba.h delete mode 100644 xs/src/agg/agg_span_gradient.h delete mode 100644 xs/src/agg/agg_span_gradient_alpha.h delete mode 100644 xs/src/agg/agg_span_gradient_contour.h delete mode 100644 xs/src/agg/agg_span_gradient_image.h delete mode 100644 xs/src/agg/agg_span_image_filter.h delete mode 100644 xs/src/agg/agg_span_image_filter_gray.h delete mode 100644 xs/src/agg/agg_span_image_filter_rgb.h delete mode 100644 xs/src/agg/agg_span_image_filter_rgba.h delete mode 100644 xs/src/agg/agg_span_interpolator_adaptor.h delete mode 100644 xs/src/agg/agg_span_interpolator_linear.h delete mode 100644 xs/src/agg/agg_span_interpolator_persp.h delete mode 100644 xs/src/agg/agg_span_interpolator_trans.h delete mode 100644 xs/src/agg/agg_span_pattern_gray.h delete mode 100644 xs/src/agg/agg_span_pattern_rgb.h delete mode 100644 xs/src/agg/agg_span_pattern_rgba.h delete mode 100644 xs/src/agg/agg_span_solid.h delete mode 100644 xs/src/agg/agg_span_subdiv_adaptor.h delete mode 100644 xs/src/agg/agg_trans_bilinear.h delete mode 100644 xs/src/agg/agg_trans_double_path.h delete mode 100644 xs/src/agg/agg_trans_perspective.h delete mode 100644 xs/src/agg/agg_trans_single_path.h delete mode 100644 xs/src/agg/agg_trans_viewport.h delete mode 100644 xs/src/agg/agg_trans_warp_magnifier.h delete mode 100644 xs/src/agg/agg_vcgen_bspline.h delete mode 100644 xs/src/agg/agg_vcgen_contour.h delete mode 100644 xs/src/agg/agg_vcgen_dash.h delete mode 100644 xs/src/agg/agg_vcgen_markers_term.h delete mode 100644 xs/src/agg/agg_vcgen_smooth_poly1.h delete mode 100644 xs/src/agg/agg_vcgen_stroke.h delete mode 100644 xs/src/agg/agg_vcgen_vertex_sequence.h delete mode 100644 xs/src/agg/agg_vertex_sequence.h delete mode 100644 xs/src/agg/agg_vpgen_clip_polygon.h delete mode 100644 xs/src/agg/agg_vpgen_clip_polyline.h delete mode 100644 xs/src/agg/agg_vpgen_segmentator.h create mode 100644 xs/src/png/AUTHORS create mode 100644 xs/src/png/NEWS create mode 100644 xs/src/png/libpng/ANNOUNCE create mode 100644 xs/src/png/libpng/CMakeLists.txt create mode 100644 xs/src/png/libpng/LICENSE create mode 100644 xs/src/png/libpng/libpng-config.in create mode 100644 xs/src/png/libpng/libpng.pc.in create mode 100644 xs/src/png/libpng/png.c create mode 100644 xs/src/png/libpng/png.h create mode 100644 xs/src/png/libpng/pngconf.h create mode 100644 xs/src/png/libpng/pngdebug.h create mode 100644 xs/src/png/libpng/pngerror.c create mode 100644 xs/src/png/libpng/pngget.c create mode 100644 xs/src/png/libpng/pnginfo.h create mode 100644 xs/src/png/libpng/pngmem.c create mode 100644 xs/src/png/libpng/pngpread.c create mode 100644 xs/src/png/libpng/pngpriv.h create mode 100644 xs/src/png/libpng/pngread.c create mode 100644 xs/src/png/libpng/pngrio.c create mode 100644 xs/src/png/libpng/pngrtran.c create mode 100644 xs/src/png/libpng/pngrutil.c create mode 100644 xs/src/png/libpng/pngset.c create mode 100644 xs/src/png/libpng/pngstruct.h create mode 100644 xs/src/png/libpng/pngtest.c create mode 100644 xs/src/png/libpng/pngtrans.c create mode 100644 xs/src/png/libpng/pngwio.c create mode 100644 xs/src/png/libpng/pngwrite.c create mode 100644 xs/src/png/libpng/pngwtran.c create mode 100644 xs/src/png/libpng/pngwutil.c create mode 100644 xs/src/png/libpng/scripts/genchk.cmake.in create mode 100644 xs/src/png/libpng/scripts/genout.cmake.in create mode 100644 xs/src/png/libpng/scripts/gensrc.cmake.in create mode 100644 xs/src/png/libpng/scripts/libpng-config-body.in create mode 100644 xs/src/png/libpng/scripts/libpng-config-head.in create mode 100644 xs/src/png/libpng/scripts/libpng.pc.in create mode 100644 xs/src/png/libpng/scripts/pnglibconf.h.prebuilt create mode 100644 xs/src/png/libpng/scripts/test.cmake.in create mode 100644 xs/src/png/zlib/CMakeLists.txt create mode 100644 xs/src/png/zlib/ChangeLog create mode 100644 xs/src/png/zlib/FAQ create mode 100644 xs/src/png/zlib/INDEX create mode 100644 xs/src/png/zlib/Makefile create mode 100644 xs/src/png/zlib/Makefile.in create mode 100644 xs/src/png/zlib/README create mode 100644 xs/src/png/zlib/adler32.c create mode 100644 xs/src/png/zlib/amiga/Makefile.pup create mode 100644 xs/src/png/zlib/amiga/Makefile.sas create mode 100644 xs/src/png/zlib/compress.c create mode 100644 xs/src/png/zlib/configure create mode 100644 xs/src/png/zlib/contrib/README.contrib create mode 100644 xs/src/png/zlib/contrib/ada/buffer_demo.adb create mode 100644 xs/src/png/zlib/contrib/ada/mtest.adb create mode 100644 xs/src/png/zlib/contrib/ada/read.adb create mode 100644 xs/src/png/zlib/contrib/ada/readme.txt create mode 100644 xs/src/png/zlib/contrib/ada/test.adb create mode 100644 xs/src/png/zlib/contrib/ada/zlib-streams.adb create mode 100644 xs/src/png/zlib/contrib/ada/zlib-streams.ads create mode 100644 xs/src/png/zlib/contrib/ada/zlib-thin.adb create mode 100644 xs/src/png/zlib/contrib/ada/zlib-thin.ads create mode 100644 xs/src/png/zlib/contrib/ada/zlib.adb create mode 100644 xs/src/png/zlib/contrib/ada/zlib.ads create mode 100644 xs/src/png/zlib/contrib/ada/zlib.gpr create mode 100644 xs/src/png/zlib/contrib/amd64/amd64-match.S create mode 100644 xs/src/png/zlib/contrib/asm686/README.686 create mode 100644 xs/src/png/zlib/contrib/asm686/match.S create mode 100644 xs/src/png/zlib/contrib/blast/Makefile create mode 100644 xs/src/png/zlib/contrib/blast/README create mode 100644 xs/src/png/zlib/contrib/blast/blast.c create mode 100644 xs/src/png/zlib/contrib/blast/blast.h create mode 100644 xs/src/png/zlib/contrib/blast/test.pk create mode 100644 xs/src/png/zlib/contrib/blast/test.txt create mode 100644 xs/src/png/zlib/contrib/delphi/ZLib.pas create mode 100644 xs/src/png/zlib/contrib/delphi/ZLibConst.pas create mode 100644 xs/src/png/zlib/contrib/delphi/readme.txt create mode 100644 xs/src/png/zlib/contrib/delphi/zlibd32.mak create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib.build create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib.chm create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib.sln create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/CodecBase.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/Deflater.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/DotZLib.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/GZipStream.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/Inflater.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/DotZLib/UnitTests.cs create mode 100644 xs/src/png/zlib/contrib/dotzlib/LICENSE_1_0.txt create mode 100644 xs/src/png/zlib/contrib/dotzlib/readme.txt create mode 100644 xs/src/png/zlib/contrib/gcc_gvmat64/gvmat64.S create mode 100644 xs/src/png/zlib/contrib/infback9/README create mode 100644 xs/src/png/zlib/contrib/infback9/infback9.c create mode 100644 xs/src/png/zlib/contrib/infback9/infback9.h create mode 100644 xs/src/png/zlib/contrib/infback9/inffix9.h create mode 100644 xs/src/png/zlib/contrib/infback9/inflate9.h create mode 100644 xs/src/png/zlib/contrib/infback9/inftree9.c create mode 100644 xs/src/png/zlib/contrib/infback9/inftree9.h create mode 100644 xs/src/png/zlib/contrib/inflate86/inffas86.c create mode 100644 xs/src/png/zlib/contrib/inflate86/inffast.S create mode 100644 xs/src/png/zlib/contrib/iostream/test.cpp create mode 100644 xs/src/png/zlib/contrib/iostream/zfstream.cpp create mode 100644 xs/src/png/zlib/contrib/iostream/zfstream.h create mode 100644 xs/src/png/zlib/contrib/iostream2/zstream.h create mode 100644 xs/src/png/zlib/contrib/iostream2/zstream_test.cpp create mode 100644 xs/src/png/zlib/contrib/iostream3/README create mode 100644 xs/src/png/zlib/contrib/iostream3/TODO create mode 100644 xs/src/png/zlib/contrib/iostream3/test.cc create mode 100644 xs/src/png/zlib/contrib/iostream3/zfstream.cc create mode 100644 xs/src/png/zlib/contrib/iostream3/zfstream.h create mode 100644 xs/src/png/zlib/contrib/masmx64/bld_ml64.bat create mode 100644 xs/src/png/zlib/contrib/masmx64/gvmat64.asm create mode 100644 xs/src/png/zlib/contrib/masmx64/inffas8664.c create mode 100644 xs/src/png/zlib/contrib/masmx64/inffasx64.asm create mode 100644 xs/src/png/zlib/contrib/masmx64/readme.txt create mode 100644 xs/src/png/zlib/contrib/masmx86/bld_ml32.bat create mode 100644 xs/src/png/zlib/contrib/masmx86/inffas32.asm create mode 100644 xs/src/png/zlib/contrib/masmx86/match686.asm create mode 100644 xs/src/png/zlib/contrib/masmx86/readme.txt create mode 100644 xs/src/png/zlib/contrib/minizip/Makefile create mode 100644 xs/src/png/zlib/contrib/minizip/Makefile.am create mode 100644 xs/src/png/zlib/contrib/minizip/MiniZip64_Changes.txt create mode 100644 xs/src/png/zlib/contrib/minizip/MiniZip64_info.txt create mode 100644 xs/src/png/zlib/contrib/minizip/configure.ac create mode 100644 xs/src/png/zlib/contrib/minizip/crypt.h create mode 100644 xs/src/png/zlib/contrib/minizip/ioapi.c create mode 100644 xs/src/png/zlib/contrib/minizip/ioapi.h create mode 100644 xs/src/png/zlib/contrib/minizip/iowin32.c create mode 100644 xs/src/png/zlib/contrib/minizip/iowin32.h create mode 100644 xs/src/png/zlib/contrib/minizip/make_vms.com create mode 100644 xs/src/png/zlib/contrib/minizip/miniunz.c create mode 100644 xs/src/png/zlib/contrib/minizip/miniunzip.1 create mode 100644 xs/src/png/zlib/contrib/minizip/minizip.1 create mode 100644 xs/src/png/zlib/contrib/minizip/minizip.c create mode 100644 xs/src/png/zlib/contrib/minizip/minizip.pc.in create mode 100644 xs/src/png/zlib/contrib/minizip/mztools.c create mode 100644 xs/src/png/zlib/contrib/minizip/mztools.h create mode 100644 xs/src/png/zlib/contrib/minizip/unzip.c create mode 100644 xs/src/png/zlib/contrib/minizip/unzip.h create mode 100644 xs/src/png/zlib/contrib/minizip/zip.c create mode 100644 xs/src/png/zlib/contrib/minizip/zip.h create mode 100644 xs/src/png/zlib/contrib/pascal/example.pas create mode 100644 xs/src/png/zlib/contrib/pascal/readme.txt create mode 100644 xs/src/png/zlib/contrib/pascal/zlibd32.mak create mode 100644 xs/src/png/zlib/contrib/pascal/zlibpas.pas create mode 100644 xs/src/png/zlib/contrib/puff/Makefile create mode 100644 xs/src/png/zlib/contrib/puff/README create mode 100644 xs/src/png/zlib/contrib/puff/puff.c create mode 100644 xs/src/png/zlib/contrib/puff/puff.h create mode 100644 xs/src/png/zlib/contrib/puff/pufftest.c create mode 100644 xs/src/png/zlib/contrib/puff/zeros.raw create mode 100644 xs/src/png/zlib/contrib/testzlib/testzlib.c create mode 100644 xs/src/png/zlib/contrib/testzlib/testzlib.txt create mode 100644 xs/src/png/zlib/contrib/untgz/Makefile create mode 100644 xs/src/png/zlib/contrib/untgz/Makefile.msc create mode 100644 xs/src/png/zlib/contrib/untgz/untgz.c create mode 100644 xs/src/png/zlib/contrib/vstudio/readme.txt create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/miniunz.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/minizip.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/testzlib.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/zlib.rc create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/zlibstat.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.def create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.sln create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/miniunz.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/minizip.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/testzlib.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/zlib.rc create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/zlibstat.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.def create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.sln create mode 100644 xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/miniunz.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/minizip.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/testzlib.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/zlib.rc create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/zlibstat.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.def create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.sln create mode 100644 xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/miniunz.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/minizip.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/testzlib.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/zlib.rc create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/zlibstat.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.def create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.sln create mode 100644 xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.vcxproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/miniunz.vcproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/minizip.vcproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/testzlib.vcproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/testzlibdll.vcproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/zlib.rc create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/zlibstat.vcproj create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.def create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.sln create mode 100644 xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.vcproj create mode 100644 xs/src/png/zlib/crc32.c create mode 100644 xs/src/png/zlib/crc32.h create mode 100644 xs/src/png/zlib/deflate.c create mode 100644 xs/src/png/zlib/deflate.h create mode 100644 xs/src/png/zlib/gzclose.c create mode 100644 xs/src/png/zlib/gzguts.h create mode 100644 xs/src/png/zlib/gzlib.c create mode 100644 xs/src/png/zlib/gzread.c create mode 100644 xs/src/png/zlib/gzwrite.c create mode 100644 xs/src/png/zlib/infback.c create mode 100644 xs/src/png/zlib/inffast.c create mode 100644 xs/src/png/zlib/inffast.h create mode 100644 xs/src/png/zlib/inffixed.h create mode 100644 xs/src/png/zlib/inflate.c create mode 100644 xs/src/png/zlib/inflate.h create mode 100644 xs/src/png/zlib/inftrees.c create mode 100644 xs/src/png/zlib/inftrees.h create mode 100644 xs/src/png/zlib/make_vms.com create mode 100644 xs/src/png/zlib/msdos/Makefile.bor create mode 100644 xs/src/png/zlib/msdos/Makefile.dj2 create mode 100644 xs/src/png/zlib/msdos/Makefile.emx create mode 100644 xs/src/png/zlib/msdos/Makefile.msc create mode 100644 xs/src/png/zlib/msdos/Makefile.tc create mode 100644 xs/src/png/zlib/nintendods/Makefile create mode 100644 xs/src/png/zlib/nintendods/README create mode 100644 xs/src/png/zlib/old/Makefile.emx create mode 100644 xs/src/png/zlib/old/Makefile.riscos create mode 100644 xs/src/png/zlib/old/README create mode 100644 xs/src/png/zlib/old/descrip.mms create mode 100644 xs/src/png/zlib/old/os2/Makefile.os2 create mode 100644 xs/src/png/zlib/old/os2/zlib.def create mode 100644 xs/src/png/zlib/old/visual-basic.txt create mode 100644 xs/src/png/zlib/os400/README400 create mode 100644 xs/src/png/zlib/os400/bndsrc create mode 100644 xs/src/png/zlib/os400/make.sh create mode 100644 xs/src/png/zlib/os400/zlib.inc create mode 100644 xs/src/png/zlib/qnx/package.qpg create mode 100644 xs/src/png/zlib/treebuild.xml create mode 100644 xs/src/png/zlib/trees.c create mode 100644 xs/src/png/zlib/trees.h create mode 100644 xs/src/png/zlib/uncompr.c create mode 100644 xs/src/png/zlib/watcom/watcom_f.mak create mode 100644 xs/src/png/zlib/watcom/watcom_l.mak create mode 100644 xs/src/png/zlib/win32/DLL_FAQ.txt create mode 100644 xs/src/png/zlib/win32/Makefile.bor create mode 100644 xs/src/png/zlib/win32/Makefile.gcc create mode 100644 xs/src/png/zlib/win32/Makefile.msc create mode 100644 xs/src/png/zlib/win32/README-WIN32.txt create mode 100644 xs/src/png/zlib/win32/VisualC.txt create mode 100644 xs/src/png/zlib/win32/zlib.def create mode 100644 xs/src/png/zlib/win32/zlib1.rc create mode 100644 xs/src/png/zlib/zconf.h.cmakein create mode 100644 xs/src/png/zlib/zconf.h.in create mode 100644 xs/src/png/zlib/zconf.h.included create mode 100644 xs/src/png/zlib/zlib.3 create mode 100644 xs/src/png/zlib/zlib.3.pdf create mode 100644 xs/src/png/zlib/zlib.h create mode 100644 xs/src/png/zlib/zlib.map create mode 100644 xs/src/png/zlib/zlib.pc.cmakein create mode 100644 xs/src/png/zlib/zlib.pc.in create mode 100644 xs/src/png/zlib/zlib2ansi create mode 100644 xs/src/png/zlib/zutil.c create mode 100644 xs/src/png/zlib/zutil.h diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index f2c44dde84..73b7cae37a 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -332,18 +332,39 @@ add_library(semver STATIC ${LIBDIR}/semver/semver.c ) +# ############################################################################## +# Configure rasterizer target +# ############################################################################## -find_package(PNG REQUIRED) +option(RASTERIZER_USE_SYSTEM_LIBPNG "Use the libpng present in system instead of + the provided copy." OFF) add_library(rasterizer STATIC ${LIBDIR}/libslic3r/Rasterizer/Rasterizer.hpp ${LIBDIR}/libslic3r/Rasterizer/Rasterizer.cpp ) -target_link_libraries(rasterizer ${PNG_LIBRARIES}) -target_include_directories(rasterizer PRIVATE ${PNG_INCLUDE_DIRS}) -target_compile_definitions(rasterizer PRIVATE ${PNG_DEFINITIONS}) -target_link_libraries(libslic3r rasterizer) +if(RASTERIZER_USE_SYSTEM_LIBPNG) + find_package(PNG REQUIRED) + target_link_libraries(rasterizer PRIVATE ${PNG_LIBRARIES}) + target_include_directories(rasterizer PRIVATE ${PNG_INCLUDE_DIRS}) + target_compile_definitions(rasterizer PRIVATE ${PNG_DEFINITIONS}) +else() + add_subdirectory( ${LIBDIR}/png/zlib) + add_subdirectory( ${LIBDIR}/png/libpng ) + + target_include_directories( png_static PRIVATE + ${LIBDIR}/png/zlib + ${CMAKE_CURRENT_BINARY_DIR}/src/png/zlib + ) + + target_link_libraries(rasterizer PRIVATE png_static zlibstatic) +endif() + +target_link_libraries(libslic3r rasterizer ) + +# ############################################################################## + # Generate the Slic3r Perl module (XS) typemap file. set(MyTypemap ${CMAKE_CURRENT_BINARY_DIR}/typemap) diff --git a/xs/src/agg/AUTHORS b/xs/src/agg/AUTHORS new file mode 100644 index 0000000000..2bb6518ec0 --- /dev/null +++ b/xs/src/agg/AUTHORS @@ -0,0 +1,2 @@ +Anti-Grain Geometry - Version 2.4 +Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) diff --git a/xs/src/agg/agg_alpha_mask_u8.h b/xs/src/agg/agg_alpha_mask_u8.h deleted file mode 100644 index e301c10088..0000000000 --- a/xs/src/agg/agg_alpha_mask_u8.h +++ /dev/null @@ -1,499 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// scanline_u8 class -// -//---------------------------------------------------------------------------- -#ifndef AGG_ALPHA_MASK_U8_INCLUDED -#define AGG_ALPHA_MASK_U8_INCLUDED - -#include -#include "agg_basics.h" -#include "agg_rendering_buffer.h" - -namespace agg -{ - //===================================================one_component_mask_u8 - struct one_component_mask_u8 - { - static unsigned calculate(const int8u* p) { return *p; } - }; - - - //=====================================================rgb_to_gray_mask_u8 - template - struct rgb_to_gray_mask_u8 - { - static unsigned calculate(const int8u* p) - { - return (p[R]*77 + p[G]*150 + p[B]*29) >> 8; - } - }; - - //==========================================================alpha_mask_u8 - template - class alpha_mask_u8 - { - public: - typedef int8u cover_type; - typedef alpha_mask_u8 self_type; - enum cover_scale_e - { - cover_shift = 8, - cover_none = 0, - cover_full = 255 - }; - - alpha_mask_u8() : m_rbuf(0) {} - explicit alpha_mask_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {} - - void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; } - - MaskF& mask_function() { return m_mask_function; } - const MaskF& mask_function() const { return m_mask_function; } - - - //-------------------------------------------------------------------- - cover_type pixel(int x, int y) const - { - if(x >= 0 && y >= 0 && - x < (int)m_rbuf->width() && - y < (int)m_rbuf->height()) - { - return (cover_type)m_mask_function.calculate( - m_rbuf->row_ptr(y) + x * Step + Offset); - } - return 0; - } - - //-------------------------------------------------------------------- - cover_type combine_pixel(int x, int y, cover_type val) const - { - if(x >= 0 && y >= 0 && - x < (int)m_rbuf->width() && - y < (int)m_rbuf->height()) - { - return (cover_type)((cover_full + val * - m_mask_function.calculate( - m_rbuf->row_ptr(y) + x * Step + Offset)) >> - cover_shift); - } - return 0; - } - - - //-------------------------------------------------------------------- - void fill_hspan(int x, int y, cover_type* dst, int num_pix) const - { - int xmax = m_rbuf->width() - 1; - int ymax = m_rbuf->height() - 1; - - int count = num_pix; - cover_type* covers = dst; - - if(y < 0 || y > ymax) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - - if(x < 0) - { - count += x; - if(count <= 0) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - memset(covers, 0, -x * sizeof(cover_type)); - covers -= x; - x = 0; - } - - if(x + count > xmax) - { - int rest = x + count - xmax - 1; - count -= rest; - if(count <= 0) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - memset(covers + count, 0, rest * sizeof(cover_type)); - } - - const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - do - { - *covers++ = (cover_type)m_mask_function.calculate(mask); - mask += Step; - } - while(--count); - } - - - //-------------------------------------------------------------------- - void combine_hspan(int x, int y, cover_type* dst, int num_pix) const - { - int xmax = m_rbuf->width() - 1; - int ymax = m_rbuf->height() - 1; - - int count = num_pix; - cover_type* covers = dst; - - if(y < 0 || y > ymax) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - - if(x < 0) - { - count += x; - if(count <= 0) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - memset(covers, 0, -x * sizeof(cover_type)); - covers -= x; - x = 0; - } - - if(x + count > xmax) - { - int rest = x + count - xmax - 1; - count -= rest; - if(count <= 0) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - memset(covers + count, 0, rest * sizeof(cover_type)); - } - - const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - do - { - *covers = (cover_type)((cover_full + (*covers) * - m_mask_function.calculate(mask)) >> - cover_shift); - ++covers; - mask += Step; - } - while(--count); - } - - //-------------------------------------------------------------------- - void fill_vspan(int x, int y, cover_type* dst, int num_pix) const - { - int xmax = m_rbuf->width() - 1; - int ymax = m_rbuf->height() - 1; - - int count = num_pix; - cover_type* covers = dst; - - if(x < 0 || x > xmax) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - - if(y < 0) - { - count += y; - if(count <= 0) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - memset(covers, 0, -y * sizeof(cover_type)); - covers -= y; - y = 0; - } - - if(y + count > ymax) - { - int rest = y + count - ymax - 1; - count -= rest; - if(count <= 0) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - memset(covers + count, 0, rest * sizeof(cover_type)); - } - - const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - do - { - *covers++ = (cover_type)m_mask_function.calculate(mask); - mask += m_rbuf->stride(); - } - while(--count); - } - - //-------------------------------------------------------------------- - void combine_vspan(int x, int y, cover_type* dst, int num_pix) const - { - int xmax = m_rbuf->width() - 1; - int ymax = m_rbuf->height() - 1; - - int count = num_pix; - cover_type* covers = dst; - - if(x < 0 || x > xmax) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - - if(y < 0) - { - count += y; - if(count <= 0) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - memset(covers, 0, -y * sizeof(cover_type)); - covers -= y; - y = 0; - } - - if(y + count > ymax) - { - int rest = y + count - ymax - 1; - count -= rest; - if(count <= 0) - { - memset(dst, 0, num_pix * sizeof(cover_type)); - return; - } - memset(covers + count, 0, rest * sizeof(cover_type)); - } - - const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - do - { - *covers = (cover_type)((cover_full + (*covers) * - m_mask_function.calculate(mask)) >> - cover_shift); - ++covers; - mask += m_rbuf->stride(); - } - while(--count); - } - - - private: - alpha_mask_u8(const self_type&); - const self_type& operator = (const self_type&); - - rendering_buffer* m_rbuf; - MaskF m_mask_function; - }; - - - typedef alpha_mask_u8<1, 0> alpha_mask_gray8; //----alpha_mask_gray8 - - typedef alpha_mask_u8<3, 0> alpha_mask_rgb24r; //----alpha_mask_rgb24r - typedef alpha_mask_u8<3, 1> alpha_mask_rgb24g; //----alpha_mask_rgb24g - typedef alpha_mask_u8<3, 2> alpha_mask_rgb24b; //----alpha_mask_rgb24b - - typedef alpha_mask_u8<3, 2> alpha_mask_bgr24r; //----alpha_mask_bgr24r - typedef alpha_mask_u8<3, 1> alpha_mask_bgr24g; //----alpha_mask_bgr24g - typedef alpha_mask_u8<3, 0> alpha_mask_bgr24b; //----alpha_mask_bgr24b - - typedef alpha_mask_u8<4, 0> alpha_mask_rgba32r; //----alpha_mask_rgba32r - typedef alpha_mask_u8<4, 1> alpha_mask_rgba32g; //----alpha_mask_rgba32g - typedef alpha_mask_u8<4, 2> alpha_mask_rgba32b; //----alpha_mask_rgba32b - typedef alpha_mask_u8<4, 3> alpha_mask_rgba32a; //----alpha_mask_rgba32a - - typedef alpha_mask_u8<4, 1> alpha_mask_argb32r; //----alpha_mask_argb32r - typedef alpha_mask_u8<4, 2> alpha_mask_argb32g; //----alpha_mask_argb32g - typedef alpha_mask_u8<4, 3> alpha_mask_argb32b; //----alpha_mask_argb32b - typedef alpha_mask_u8<4, 0> alpha_mask_argb32a; //----alpha_mask_argb32a - - typedef alpha_mask_u8<4, 2> alpha_mask_bgra32r; //----alpha_mask_bgra32r - typedef alpha_mask_u8<4, 1> alpha_mask_bgra32g; //----alpha_mask_bgra32g - typedef alpha_mask_u8<4, 0> alpha_mask_bgra32b; //----alpha_mask_bgra32b - typedef alpha_mask_u8<4, 3> alpha_mask_bgra32a; //----alpha_mask_bgra32a - - typedef alpha_mask_u8<4, 3> alpha_mask_abgr32r; //----alpha_mask_abgr32r - typedef alpha_mask_u8<4, 2> alpha_mask_abgr32g; //----alpha_mask_abgr32g - typedef alpha_mask_u8<4, 1> alpha_mask_abgr32b; //----alpha_mask_abgr32b - typedef alpha_mask_u8<4, 0> alpha_mask_abgr32a; //----alpha_mask_abgr32a - - typedef alpha_mask_u8<3, 0, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_rgb24gray; //----alpha_mask_rgb24gray - typedef alpha_mask_u8<3, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgr24gray; //----alpha_mask_bgr24gray - typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_rgba32gray; //----alpha_mask_rgba32gray - typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_argb32gray; //----alpha_mask_argb32gray - typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgra32gray; //----alpha_mask_bgra32gray - typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_abgr32gray; //----alpha_mask_abgr32gray - - - - //==========================================================amask_no_clip_u8 - template - class amask_no_clip_u8 - { - public: - typedef int8u cover_type; - typedef amask_no_clip_u8 self_type; - enum cover_scale_e - { - cover_shift = 8, - cover_none = 0, - cover_full = 255 - }; - - amask_no_clip_u8() : m_rbuf(0) {} - explicit amask_no_clip_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {} - - void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; } - - MaskF& mask_function() { return m_mask_function; } - const MaskF& mask_function() const { return m_mask_function; } - - - //-------------------------------------------------------------------- - cover_type pixel(int x, int y) const - { - return (cover_type)m_mask_function.calculate( - m_rbuf->row_ptr(y) + x * Step + Offset); - } - - - //-------------------------------------------------------------------- - cover_type combine_pixel(int x, int y, cover_type val) const - { - return (cover_type)((cover_full + val * - m_mask_function.calculate( - m_rbuf->row_ptr(y) + x * Step + Offset)) >> - cover_shift); - } - - - //-------------------------------------------------------------------- - void fill_hspan(int x, int y, cover_type* dst, int num_pix) const - { - const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - do - { - *dst++ = (cover_type)m_mask_function.calculate(mask); - mask += Step; - } - while(--num_pix); - } - - - - //-------------------------------------------------------------------- - void combine_hspan(int x, int y, cover_type* dst, int num_pix) const - { - const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - do - { - *dst = (cover_type)((cover_full + (*dst) * - m_mask_function.calculate(mask)) >> - cover_shift); - ++dst; - mask += Step; - } - while(--num_pix); - } - - - //-------------------------------------------------------------------- - void fill_vspan(int x, int y, cover_type* dst, int num_pix) const - { - const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - do - { - *dst++ = (cover_type)m_mask_function.calculate(mask); - mask += m_rbuf->stride(); - } - while(--num_pix); - } - - - //-------------------------------------------------------------------- - void combine_vspan(int x, int y, cover_type* dst, int num_pix) const - { - const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; - do - { - *dst = (cover_type)((cover_full + (*dst) * - m_mask_function.calculate(mask)) >> - cover_shift); - ++dst; - mask += m_rbuf->stride(); - } - while(--num_pix); - } - - private: - amask_no_clip_u8(const self_type&); - const self_type& operator = (const self_type&); - - rendering_buffer* m_rbuf; - MaskF m_mask_function; - }; - - - typedef amask_no_clip_u8<1, 0> amask_no_clip_gray8; //----amask_no_clip_gray8 - - typedef amask_no_clip_u8<3, 0> amask_no_clip_rgb24r; //----amask_no_clip_rgb24r - typedef amask_no_clip_u8<3, 1> amask_no_clip_rgb24g; //----amask_no_clip_rgb24g - typedef amask_no_clip_u8<3, 2> amask_no_clip_rgb24b; //----amask_no_clip_rgb24b - - typedef amask_no_clip_u8<3, 2> amask_no_clip_bgr24r; //----amask_no_clip_bgr24r - typedef amask_no_clip_u8<3, 1> amask_no_clip_bgr24g; //----amask_no_clip_bgr24g - typedef amask_no_clip_u8<3, 0> amask_no_clip_bgr24b; //----amask_no_clip_bgr24b - - typedef amask_no_clip_u8<4, 0> amask_no_clip_rgba32r; //----amask_no_clip_rgba32r - typedef amask_no_clip_u8<4, 1> amask_no_clip_rgba32g; //----amask_no_clip_rgba32g - typedef amask_no_clip_u8<4, 2> amask_no_clip_rgba32b; //----amask_no_clip_rgba32b - typedef amask_no_clip_u8<4, 3> amask_no_clip_rgba32a; //----amask_no_clip_rgba32a - - typedef amask_no_clip_u8<4, 1> amask_no_clip_argb32r; //----amask_no_clip_argb32r - typedef amask_no_clip_u8<4, 2> amask_no_clip_argb32g; //----amask_no_clip_argb32g - typedef amask_no_clip_u8<4, 3> amask_no_clip_argb32b; //----amask_no_clip_argb32b - typedef amask_no_clip_u8<4, 0> amask_no_clip_argb32a; //----amask_no_clip_argb32a - - typedef amask_no_clip_u8<4, 2> amask_no_clip_bgra32r; //----amask_no_clip_bgra32r - typedef amask_no_clip_u8<4, 1> amask_no_clip_bgra32g; //----amask_no_clip_bgra32g - typedef amask_no_clip_u8<4, 0> amask_no_clip_bgra32b; //----amask_no_clip_bgra32b - typedef amask_no_clip_u8<4, 3> amask_no_clip_bgra32a; //----amask_no_clip_bgra32a - - typedef amask_no_clip_u8<4, 3> amask_no_clip_abgr32r; //----amask_no_clip_abgr32r - typedef amask_no_clip_u8<4, 2> amask_no_clip_abgr32g; //----amask_no_clip_abgr32g - typedef amask_no_clip_u8<4, 1> amask_no_clip_abgr32b; //----amask_no_clip_abgr32b - typedef amask_no_clip_u8<4, 0> amask_no_clip_abgr32a; //----amask_no_clip_abgr32a - - typedef amask_no_clip_u8<3, 0, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_rgb24gray; //----amask_no_clip_rgb24gray - typedef amask_no_clip_u8<3, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgr24gray; //----amask_no_clip_bgr24gray - typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_rgba32gray; //----amask_no_clip_rgba32gray - typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_argb32gray; //----amask_no_clip_argb32gray - typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgra32gray; //----amask_no_clip_bgra32gray - typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_abgr32gray; //----amask_no_clip_abgr32gray - - -} - - - -#endif diff --git a/xs/src/agg/agg_arc.h b/xs/src/agg/agg_arc.h deleted file mode 100644 index 17e1d43473..0000000000 --- a/xs/src/agg/agg_arc.h +++ /dev/null @@ -1,74 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Arc vertex generator -// -//---------------------------------------------------------------------------- - -#ifndef AGG_ARC_INCLUDED -#define AGG_ARC_INCLUDED - -#include -#include "agg_basics.h" - -namespace agg -{ - - //=====================================================================arc - // - // See Implementation agg_arc.cpp - // - class arc - { - public: - arc() : m_scale(1.0), m_initialized(false) {} - arc(double x, double y, - double rx, double ry, - double a1, double a2, - bool ccw=true); - - void init(double x, double y, - double rx, double ry, - double a1, double a2, - bool ccw=true); - - void approximation_scale(double s); - double approximation_scale() const { return m_scale; } - - void rewind(unsigned); - unsigned vertex(double* x, double* y); - - private: - void normalize(double a1, double a2, bool ccw); - - double m_x; - double m_y; - double m_rx; - double m_ry; - double m_angle; - double m_start; - double m_end; - double m_scale; - double m_da; - bool m_ccw; - bool m_initialized; - unsigned m_path_cmd; - }; - - -} - - -#endif diff --git a/xs/src/agg/agg_arrowhead.h b/xs/src/agg/agg_arrowhead.h deleted file mode 100644 index 5e029ddee0..0000000000 --- a/xs/src/agg/agg_arrowhead.h +++ /dev/null @@ -1,82 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Simple arrowhead/arrowtail generator -// -//---------------------------------------------------------------------------- -#ifndef AGG_ARROWHEAD_INCLUDED -#define AGG_ARROWHEAD_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //===============================================================arrowhead - // - // See implementation agg_arrowhead.cpp - // - class arrowhead - { - public: - arrowhead(); - - void head(double d1, double d2, double d3, double d4) - { - m_head_d1 = d1; - m_head_d2 = d2; - m_head_d3 = d3; - m_head_d4 = d4; - m_head_flag = true; - } - - void head() { m_head_flag = true; } - void no_head() { m_head_flag = false; } - - void tail(double d1, double d2, double d3, double d4) - { - m_tail_d1 = d1; - m_tail_d2 = d2; - m_tail_d3 = d3; - m_tail_d4 = d4; - m_tail_flag = true; - } - - void tail() { m_tail_flag = true; } - void no_tail() { m_tail_flag = false; } - - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - double m_head_d1; - double m_head_d2; - double m_head_d3; - double m_head_d4; - double m_tail_d1; - double m_tail_d2; - double m_tail_d3; - double m_tail_d4; - bool m_head_flag; - bool m_tail_flag; - double m_coord[16]; - unsigned m_cmd[8]; - unsigned m_curr_id; - unsigned m_curr_coord; - }; - -} - -#endif diff --git a/xs/src/agg/agg_bitset_iterator.h b/xs/src/agg/agg_bitset_iterator.h deleted file mode 100644 index 7382d5c335..0000000000 --- a/xs/src/agg/agg_bitset_iterator.h +++ /dev/null @@ -1,54 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_BITSET_ITERATOR_INCLUDED -#define AGG_BITSET_ITERATOR_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - class bitset_iterator - { - public: - bitset_iterator(const int8u* bits, unsigned offset = 0) : - m_bits(bits + (offset >> 3)), - m_mask(0x80 >> (offset & 7)) - {} - - void operator ++ () - { - m_mask >>= 1; - if(m_mask == 0) - { - ++m_bits; - m_mask = 0x80; - } - } - - unsigned bit() const - { - return (*m_bits) & m_mask; - } - - private: - const int8u* m_bits; - int8u m_mask; - }; - -} - -#endif diff --git a/xs/src/agg/agg_blur.h b/xs/src/agg/agg_blur.h deleted file mode 100644 index cd5713f314..0000000000 --- a/xs/src/agg/agg_blur.h +++ /dev/null @@ -1,1503 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// The Stack Blur Algorithm was invented by Mario Klingemann, -// mario@quasimondo.com and described here: -// http://incubator.quasimondo.com/processing/fast_blur_deluxe.php -// (search phrase "Stackblur: Fast But Goodlooking"). -// The major improvement is that there's no more division table -// that was very expensive to create for large blur radii. Insted, -// for 8-bit per channel and radius not exceeding 254 the division is -// replaced by multiplication and shift. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_BLUR_INCLUDED -#define AGG_BLUR_INCLUDED - -#include "agg_array.h" -#include "agg_pixfmt_base.h" -#include "agg_pixfmt_transposer.h" - -namespace agg -{ - - template struct stack_blur_tables - { - static int16u const g_stack_blur8_mul[255]; - static int8u const g_stack_blur8_shr[255]; - }; - - //------------------------------------------------------------------------ - template - int16u const stack_blur_tables::g_stack_blur8_mul[255] = - { - 512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512, - 454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512, - 482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456, - 437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512, - 497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328, - 320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456, - 446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335, - 329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512, - 505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405, - 399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328, - 324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271, - 268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456, - 451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388, - 385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335, - 332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292, - 289,287,285,282,280,278,275,273,271,269,267,265,263,261,259 - }; - - //------------------------------------------------------------------------ - template - int8u const stack_blur_tables::g_stack_blur8_shr[255] = - { - 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, - 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 - }; - - - - //==============================================================stack_blur - template class stack_blur - { - public: - typedef ColorT color_type; - typedef CalculatorT calculator_type; - - //-------------------------------------------------------------------- - template void blur_x(Img& img, unsigned radius) - { - if(radius < 1) return; - - unsigned x, y, xp, i; - unsigned stack_ptr; - unsigned stack_start; - - color_type pix; - color_type* stack_pix; - calculator_type sum; - calculator_type sum_in; - calculator_type sum_out; - - unsigned w = img.width(); - unsigned h = img.height(); - unsigned wm = w - 1; - unsigned div = radius * 2 + 1; - - unsigned div_sum = (radius + 1) * (radius + 1); - unsigned mul_sum = 0; - unsigned shr_sum = 0; - unsigned max_val = color_type::base_mask; - - if(max_val <= 255 && radius < 255) - { - mul_sum = stack_blur_tables::g_stack_blur8_mul[radius]; - shr_sum = stack_blur_tables::g_stack_blur8_shr[radius]; - } - - m_buf.allocate(w, 128); - m_stack.allocate(div, 32); - - for(y = 0; y < h; y++) - { - sum.clear(); - sum_in.clear(); - sum_out.clear(); - - pix = img.pixel(0, y); - for(i = 0; i <= radius; i++) - { - m_stack[i] = pix; - sum.add(pix, i + 1); - sum_out.add(pix); - } - for(i = 1; i <= radius; i++) - { - pix = img.pixel((i > wm) ? wm : i, y); - m_stack[i + radius] = pix; - sum.add(pix, radius + 1 - i); - sum_in.add(pix); - } - - stack_ptr = radius; - for(x = 0; x < w; x++) - { - if(mul_sum) sum.calc_pix(m_buf[x], mul_sum, shr_sum); - else sum.calc_pix(m_buf[x], div_sum); - - sum.sub(sum_out); - - stack_start = stack_ptr + div - radius; - if(stack_start >= div) stack_start -= div; - stack_pix = &m_stack[stack_start]; - - sum_out.sub(*stack_pix); - - xp = x + radius + 1; - if(xp > wm) xp = wm; - pix = img.pixel(xp, y); - - *stack_pix = pix; - - sum_in.add(pix); - sum.add(sum_in); - - ++stack_ptr; - if(stack_ptr >= div) stack_ptr = 0; - stack_pix = &m_stack[stack_ptr]; - - sum_out.add(*stack_pix); - sum_in.sub(*stack_pix); - } - img.copy_color_hspan(0, y, w, &m_buf[0]); - } - } - - //-------------------------------------------------------------------- - template void blur_y(Img& img, unsigned radius) - { - pixfmt_transposer img2(img); - blur_x(img2, radius); - } - - //-------------------------------------------------------------------- - template void blur(Img& img, unsigned radius) - { - blur_x(img, radius); - pixfmt_transposer img2(img); - blur_x(img2, radius); - } - - private: - pod_vector m_buf; - pod_vector m_stack; - }; - - //====================================================stack_blur_calc_rgba - template struct stack_blur_calc_rgba - { - typedef T value_type; - value_type r,g,b,a; - - AGG_INLINE void clear() - { - r = g = b = a = 0; - } - - template AGG_INLINE void add(const ArgT& v) - { - r += v.r; - g += v.g; - b += v.b; - a += v.a; - } - - template AGG_INLINE void add(const ArgT& v, unsigned k) - { - r += v.r * k; - g += v.g * k; - b += v.b * k; - a += v.a * k; - } - - template AGG_INLINE void sub(const ArgT& v) - { - r -= v.r; - g -= v.g; - b -= v.b; - a -= v.a; - } - - template AGG_INLINE void calc_pix(ArgT& v, unsigned div) - { - typedef typename ArgT::value_type value_type; - v.r = value_type(r / div); - v.g = value_type(g / div); - v.b = value_type(b / div); - v.a = value_type(a / div); - } - - template - AGG_INLINE void calc_pix(ArgT& v, unsigned mul, unsigned shr) - { - typedef typename ArgT::value_type value_type; - v.r = value_type((r * mul) >> shr); - v.g = value_type((g * mul) >> shr); - v.b = value_type((b * mul) >> shr); - v.a = value_type((a * mul) >> shr); - } - }; - - - //=====================================================stack_blur_calc_rgb - template struct stack_blur_calc_rgb - { - typedef T value_type; - value_type r,g,b; - - AGG_INLINE void clear() - { - r = g = b = 0; - } - - template AGG_INLINE void add(const ArgT& v) - { - r += v.r; - g += v.g; - b += v.b; - } - - template AGG_INLINE void add(const ArgT& v, unsigned k) - { - r += v.r * k; - g += v.g * k; - b += v.b * k; - } - - template AGG_INLINE void sub(const ArgT& v) - { - r -= v.r; - g -= v.g; - b -= v.b; - } - - template AGG_INLINE void calc_pix(ArgT& v, unsigned div) - { - typedef typename ArgT::value_type value_type; - v.r = value_type(r / div); - v.g = value_type(g / div); - v.b = value_type(b / div); - } - - template - AGG_INLINE void calc_pix(ArgT& v, unsigned mul, unsigned shr) - { - typedef typename ArgT::value_type value_type; - v.r = value_type((r * mul) >> shr); - v.g = value_type((g * mul) >> shr); - v.b = value_type((b * mul) >> shr); - } - }; - - - //====================================================stack_blur_calc_gray - template struct stack_blur_calc_gray - { - typedef T value_type; - value_type v; - - AGG_INLINE void clear() - { - v = 0; - } - - template AGG_INLINE void add(const ArgT& a) - { - v += a.v; - } - - template AGG_INLINE void add(const ArgT& a, unsigned k) - { - v += a.v * k; - } - - template AGG_INLINE void sub(const ArgT& a) - { - v -= a.v; - } - - template AGG_INLINE void calc_pix(ArgT& a, unsigned div) - { - typedef typename ArgT::value_type value_type; - a.v = value_type(v / div); - } - - template - AGG_INLINE void calc_pix(ArgT& a, unsigned mul, unsigned shr) - { - typedef typename ArgT::value_type value_type; - a.v = value_type((v * mul) >> shr); - } - }; - - - - //========================================================stack_blur_gray8 - template - void stack_blur_gray8(Img& img, unsigned rx, unsigned ry) - { - unsigned x, y, xp, yp, i; - unsigned stack_ptr; - unsigned stack_start; - - const int8u* src_pix_ptr; - int8u* dst_pix_ptr; - unsigned pix; - unsigned stack_pix; - unsigned sum; - unsigned sum_in; - unsigned sum_out; - - unsigned w = img.width(); - unsigned h = img.height(); - unsigned wm = w - 1; - unsigned hm = h - 1; - - unsigned div; - unsigned mul_sum; - unsigned shr_sum; - - pod_vector stack; - - if(rx > 0) - { - if(rx > 254) rx = 254; - div = rx * 2 + 1; - mul_sum = stack_blur_tables::g_stack_blur8_mul[rx]; - shr_sum = stack_blur_tables::g_stack_blur8_shr[rx]; - stack.allocate(div); - - for(y = 0; y < h; y++) - { - sum = sum_in = sum_out = 0; - - src_pix_ptr = img.pix_ptr(0, y); - pix = *src_pix_ptr; - for(i = 0; i <= rx; i++) - { - stack[i] = pix; - sum += pix * (i + 1); - sum_out += pix; - } - for(i = 1; i <= rx; i++) - { - if(i <= wm) src_pix_ptr += Img::pix_width; - pix = *src_pix_ptr; - stack[i + rx] = pix; - sum += pix * (rx + 1 - i); - sum_in += pix; - } - - stack_ptr = rx; - xp = rx; - if(xp > wm) xp = wm; - src_pix_ptr = img.pix_ptr(xp, y); - dst_pix_ptr = img.pix_ptr(0, y); - for(x = 0; x < w; x++) - { - *dst_pix_ptr = (sum * mul_sum) >> shr_sum; - dst_pix_ptr += Img::pix_width; - - sum -= sum_out; - - stack_start = stack_ptr + div - rx; - if(stack_start >= div) stack_start -= div; - sum_out -= stack[stack_start]; - - if(xp < wm) - { - src_pix_ptr += Img::pix_width; - pix = *src_pix_ptr; - ++xp; - } - - stack[stack_start] = pix; - - sum_in += pix; - sum += sum_in; - - ++stack_ptr; - if(stack_ptr >= div) stack_ptr = 0; - stack_pix = stack[stack_ptr]; - - sum_out += stack_pix; - sum_in -= stack_pix; - } - } - } - - if(ry > 0) - { - if(ry > 254) ry = 254; - div = ry * 2 + 1; - mul_sum = stack_blur_tables::g_stack_blur8_mul[ry]; - shr_sum = stack_blur_tables::g_stack_blur8_shr[ry]; - stack.allocate(div); - - int stride = img.stride(); - for(x = 0; x < w; x++) - { - sum = sum_in = sum_out = 0; - - src_pix_ptr = img.pix_ptr(x, 0); - pix = *src_pix_ptr; - for(i = 0; i <= ry; i++) - { - stack[i] = pix; - sum += pix * (i + 1); - sum_out += pix; - } - for(i = 1; i <= ry; i++) - { - if(i <= hm) src_pix_ptr += stride; - pix = *src_pix_ptr; - stack[i + ry] = pix; - sum += pix * (ry + 1 - i); - sum_in += pix; - } - - stack_ptr = ry; - yp = ry; - if(yp > hm) yp = hm; - src_pix_ptr = img.pix_ptr(x, yp); - dst_pix_ptr = img.pix_ptr(x, 0); - for(y = 0; y < h; y++) - { - *dst_pix_ptr = (sum * mul_sum) >> shr_sum; - dst_pix_ptr += stride; - - sum -= sum_out; - - stack_start = stack_ptr + div - ry; - if(stack_start >= div) stack_start -= div; - sum_out -= stack[stack_start]; - - if(yp < hm) - { - src_pix_ptr += stride; - pix = *src_pix_ptr; - ++yp; - } - - stack[stack_start] = pix; - - sum_in += pix; - sum += sum_in; - - ++stack_ptr; - if(stack_ptr >= div) stack_ptr = 0; - stack_pix = stack[stack_ptr]; - - sum_out += stack_pix; - sum_in -= stack_pix; - } - } - } - } - - - - //========================================================stack_blur_rgb24 - template - void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry) - { - typedef typename Img::color_type color_type; - typedef typename Img::order_type order_type; - enum order_e - { - R = order_type::R, - G = order_type::G, - B = order_type::B - }; - - unsigned x, y, xp, yp, i; - unsigned stack_ptr; - unsigned stack_start; - - const int8u* src_pix_ptr; - int8u* dst_pix_ptr; - color_type* stack_pix_ptr; - - unsigned sum_r; - unsigned sum_g; - unsigned sum_b; - unsigned sum_in_r; - unsigned sum_in_g; - unsigned sum_in_b; - unsigned sum_out_r; - unsigned sum_out_g; - unsigned sum_out_b; - - unsigned w = img.width(); - unsigned h = img.height(); - unsigned wm = w - 1; - unsigned hm = h - 1; - - unsigned div; - unsigned mul_sum; - unsigned shr_sum; - - pod_vector stack; - - if(rx > 0) - { - if(rx > 254) rx = 254; - div = rx * 2 + 1; - mul_sum = stack_blur_tables::g_stack_blur8_mul[rx]; - shr_sum = stack_blur_tables::g_stack_blur8_shr[rx]; - stack.allocate(div); - - for(y = 0; y < h; y++) - { - sum_r = - sum_g = - sum_b = - sum_in_r = - sum_in_g = - sum_in_b = - sum_out_r = - sum_out_g = - sum_out_b = 0; - - src_pix_ptr = img.pix_ptr(0, y); - for(i = 0; i <= rx; i++) - { - stack_pix_ptr = &stack[i]; - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - sum_r += src_pix_ptr[R] * (i + 1); - sum_g += src_pix_ptr[G] * (i + 1); - sum_b += src_pix_ptr[B] * (i + 1); - sum_out_r += src_pix_ptr[R]; - sum_out_g += src_pix_ptr[G]; - sum_out_b += src_pix_ptr[B]; - } - for(i = 1; i <= rx; i++) - { - if(i <= wm) src_pix_ptr += Img::pix_width; - stack_pix_ptr = &stack[i + rx]; - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - sum_r += src_pix_ptr[R] * (rx + 1 - i); - sum_g += src_pix_ptr[G] * (rx + 1 - i); - sum_b += src_pix_ptr[B] * (rx + 1 - i); - sum_in_r += src_pix_ptr[R]; - sum_in_g += src_pix_ptr[G]; - sum_in_b += src_pix_ptr[B]; - } - - stack_ptr = rx; - xp = rx; - if(xp > wm) xp = wm; - src_pix_ptr = img.pix_ptr(xp, y); - dst_pix_ptr = img.pix_ptr(0, y); - for(x = 0; x < w; x++) - { - dst_pix_ptr[R] = (sum_r * mul_sum) >> shr_sum; - dst_pix_ptr[G] = (sum_g * mul_sum) >> shr_sum; - dst_pix_ptr[B] = (sum_b * mul_sum) >> shr_sum; - dst_pix_ptr += Img::pix_width; - - sum_r -= sum_out_r; - sum_g -= sum_out_g; - sum_b -= sum_out_b; - - stack_start = stack_ptr + div - rx; - if(stack_start >= div) stack_start -= div; - stack_pix_ptr = &stack[stack_start]; - - sum_out_r -= stack_pix_ptr->r; - sum_out_g -= stack_pix_ptr->g; - sum_out_b -= stack_pix_ptr->b; - - if(xp < wm) - { - src_pix_ptr += Img::pix_width; - ++xp; - } - - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - - sum_in_r += src_pix_ptr[R]; - sum_in_g += src_pix_ptr[G]; - sum_in_b += src_pix_ptr[B]; - sum_r += sum_in_r; - sum_g += sum_in_g; - sum_b += sum_in_b; - - ++stack_ptr; - if(stack_ptr >= div) stack_ptr = 0; - stack_pix_ptr = &stack[stack_ptr]; - - sum_out_r += stack_pix_ptr->r; - sum_out_g += stack_pix_ptr->g; - sum_out_b += stack_pix_ptr->b; - sum_in_r -= stack_pix_ptr->r; - sum_in_g -= stack_pix_ptr->g; - sum_in_b -= stack_pix_ptr->b; - } - } - } - - if(ry > 0) - { - if(ry > 254) ry = 254; - div = ry * 2 + 1; - mul_sum = stack_blur_tables::g_stack_blur8_mul[ry]; - shr_sum = stack_blur_tables::g_stack_blur8_shr[ry]; - stack.allocate(div); - - int stride = img.stride(); - for(x = 0; x < w; x++) - { - sum_r = - sum_g = - sum_b = - sum_in_r = - sum_in_g = - sum_in_b = - sum_out_r = - sum_out_g = - sum_out_b = 0; - - src_pix_ptr = img.pix_ptr(x, 0); - for(i = 0; i <= ry; i++) - { - stack_pix_ptr = &stack[i]; - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - sum_r += src_pix_ptr[R] * (i + 1); - sum_g += src_pix_ptr[G] * (i + 1); - sum_b += src_pix_ptr[B] * (i + 1); - sum_out_r += src_pix_ptr[R]; - sum_out_g += src_pix_ptr[G]; - sum_out_b += src_pix_ptr[B]; - } - for(i = 1; i <= ry; i++) - { - if(i <= hm) src_pix_ptr += stride; - stack_pix_ptr = &stack[i + ry]; - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - sum_r += src_pix_ptr[R] * (ry + 1 - i); - sum_g += src_pix_ptr[G] * (ry + 1 - i); - sum_b += src_pix_ptr[B] * (ry + 1 - i); - sum_in_r += src_pix_ptr[R]; - sum_in_g += src_pix_ptr[G]; - sum_in_b += src_pix_ptr[B]; - } - - stack_ptr = ry; - yp = ry; - if(yp > hm) yp = hm; - src_pix_ptr = img.pix_ptr(x, yp); - dst_pix_ptr = img.pix_ptr(x, 0); - for(y = 0; y < h; y++) - { - dst_pix_ptr[R] = (sum_r * mul_sum) >> shr_sum; - dst_pix_ptr[G] = (sum_g * mul_sum) >> shr_sum; - dst_pix_ptr[B] = (sum_b * mul_sum) >> shr_sum; - dst_pix_ptr += stride; - - sum_r -= sum_out_r; - sum_g -= sum_out_g; - sum_b -= sum_out_b; - - stack_start = stack_ptr + div - ry; - if(stack_start >= div) stack_start -= div; - - stack_pix_ptr = &stack[stack_start]; - sum_out_r -= stack_pix_ptr->r; - sum_out_g -= stack_pix_ptr->g; - sum_out_b -= stack_pix_ptr->b; - - if(yp < hm) - { - src_pix_ptr += stride; - ++yp; - } - - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - - sum_in_r += src_pix_ptr[R]; - sum_in_g += src_pix_ptr[G]; - sum_in_b += src_pix_ptr[B]; - sum_r += sum_in_r; - sum_g += sum_in_g; - sum_b += sum_in_b; - - ++stack_ptr; - if(stack_ptr >= div) stack_ptr = 0; - stack_pix_ptr = &stack[stack_ptr]; - - sum_out_r += stack_pix_ptr->r; - sum_out_g += stack_pix_ptr->g; - sum_out_b += stack_pix_ptr->b; - sum_in_r -= stack_pix_ptr->r; - sum_in_g -= stack_pix_ptr->g; - sum_in_b -= stack_pix_ptr->b; - } - } - } - } - - - - //=======================================================stack_blur_rgba32 - template - void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry) - { - typedef typename Img::color_type color_type; - typedef typename Img::order_type order_type; - enum order_e - { - R = order_type::R, - G = order_type::G, - B = order_type::B, - A = order_type::A - }; - - unsigned x, y, xp, yp, i; - unsigned stack_ptr; - unsigned stack_start; - - const int8u* src_pix_ptr; - int8u* dst_pix_ptr; - color_type* stack_pix_ptr; - - unsigned sum_r; - unsigned sum_g; - unsigned sum_b; - unsigned sum_a; - unsigned sum_in_r; - unsigned sum_in_g; - unsigned sum_in_b; - unsigned sum_in_a; - unsigned sum_out_r; - unsigned sum_out_g; - unsigned sum_out_b; - unsigned sum_out_a; - - unsigned w = img.width(); - unsigned h = img.height(); - unsigned wm = w - 1; - unsigned hm = h - 1; - - unsigned div; - unsigned mul_sum; - unsigned shr_sum; - - pod_vector stack; - - if(rx > 0) - { - if(rx > 254) rx = 254; - div = rx * 2 + 1; - mul_sum = stack_blur_tables::g_stack_blur8_mul[rx]; - shr_sum = stack_blur_tables::g_stack_blur8_shr[rx]; - stack.allocate(div); - - for(y = 0; y < h; y++) - { - sum_r = - sum_g = - sum_b = - sum_a = - sum_in_r = - sum_in_g = - sum_in_b = - sum_in_a = - sum_out_r = - sum_out_g = - sum_out_b = - sum_out_a = 0; - - src_pix_ptr = img.pix_ptr(0, y); - for(i = 0; i <= rx; i++) - { - stack_pix_ptr = &stack[i]; - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - stack_pix_ptr->a = src_pix_ptr[A]; - sum_r += src_pix_ptr[R] * (i + 1); - sum_g += src_pix_ptr[G] * (i + 1); - sum_b += src_pix_ptr[B] * (i + 1); - sum_a += src_pix_ptr[A] * (i + 1); - sum_out_r += src_pix_ptr[R]; - sum_out_g += src_pix_ptr[G]; - sum_out_b += src_pix_ptr[B]; - sum_out_a += src_pix_ptr[A]; - } - for(i = 1; i <= rx; i++) - { - if(i <= wm) src_pix_ptr += Img::pix_width; - stack_pix_ptr = &stack[i + rx]; - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - stack_pix_ptr->a = src_pix_ptr[A]; - sum_r += src_pix_ptr[R] * (rx + 1 - i); - sum_g += src_pix_ptr[G] * (rx + 1 - i); - sum_b += src_pix_ptr[B] * (rx + 1 - i); - sum_a += src_pix_ptr[A] * (rx + 1 - i); - sum_in_r += src_pix_ptr[R]; - sum_in_g += src_pix_ptr[G]; - sum_in_b += src_pix_ptr[B]; - sum_in_a += src_pix_ptr[A]; - } - - stack_ptr = rx; - xp = rx; - if(xp > wm) xp = wm; - src_pix_ptr = img.pix_ptr(xp, y); - dst_pix_ptr = img.pix_ptr(0, y); - for(x = 0; x < w; x++) - { - dst_pix_ptr[R] = (sum_r * mul_sum) >> shr_sum; - dst_pix_ptr[G] = (sum_g * mul_sum) >> shr_sum; - dst_pix_ptr[B] = (sum_b * mul_sum) >> shr_sum; - dst_pix_ptr[A] = (sum_a * mul_sum) >> shr_sum; - dst_pix_ptr += Img::pix_width; - - sum_r -= sum_out_r; - sum_g -= sum_out_g; - sum_b -= sum_out_b; - sum_a -= sum_out_a; - - stack_start = stack_ptr + div - rx; - if(stack_start >= div) stack_start -= div; - stack_pix_ptr = &stack[stack_start]; - - sum_out_r -= stack_pix_ptr->r; - sum_out_g -= stack_pix_ptr->g; - sum_out_b -= stack_pix_ptr->b; - sum_out_a -= stack_pix_ptr->a; - - if(xp < wm) - { - src_pix_ptr += Img::pix_width; - ++xp; - } - - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - stack_pix_ptr->a = src_pix_ptr[A]; - - sum_in_r += src_pix_ptr[R]; - sum_in_g += src_pix_ptr[G]; - sum_in_b += src_pix_ptr[B]; - sum_in_a += src_pix_ptr[A]; - sum_r += sum_in_r; - sum_g += sum_in_g; - sum_b += sum_in_b; - sum_a += sum_in_a; - - ++stack_ptr; - if(stack_ptr >= div) stack_ptr = 0; - stack_pix_ptr = &stack[stack_ptr]; - - sum_out_r += stack_pix_ptr->r; - sum_out_g += stack_pix_ptr->g; - sum_out_b += stack_pix_ptr->b; - sum_out_a += stack_pix_ptr->a; - sum_in_r -= stack_pix_ptr->r; - sum_in_g -= stack_pix_ptr->g; - sum_in_b -= stack_pix_ptr->b; - sum_in_a -= stack_pix_ptr->a; - } - } - } - - if(ry > 0) - { - if(ry > 254) ry = 254; - div = ry * 2 + 1; - mul_sum = stack_blur_tables::g_stack_blur8_mul[ry]; - shr_sum = stack_blur_tables::g_stack_blur8_shr[ry]; - stack.allocate(div); - - int stride = img.stride(); - for(x = 0; x < w; x++) - { - sum_r = - sum_g = - sum_b = - sum_a = - sum_in_r = - sum_in_g = - sum_in_b = - sum_in_a = - sum_out_r = - sum_out_g = - sum_out_b = - sum_out_a = 0; - - src_pix_ptr = img.pix_ptr(x, 0); - for(i = 0; i <= ry; i++) - { - stack_pix_ptr = &stack[i]; - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - stack_pix_ptr->a = src_pix_ptr[A]; - sum_r += src_pix_ptr[R] * (i + 1); - sum_g += src_pix_ptr[G] * (i + 1); - sum_b += src_pix_ptr[B] * (i + 1); - sum_a += src_pix_ptr[A] * (i + 1); - sum_out_r += src_pix_ptr[R]; - sum_out_g += src_pix_ptr[G]; - sum_out_b += src_pix_ptr[B]; - sum_out_a += src_pix_ptr[A]; - } - for(i = 1; i <= ry; i++) - { - if(i <= hm) src_pix_ptr += stride; - stack_pix_ptr = &stack[i + ry]; - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - stack_pix_ptr->a = src_pix_ptr[A]; - sum_r += src_pix_ptr[R] * (ry + 1 - i); - sum_g += src_pix_ptr[G] * (ry + 1 - i); - sum_b += src_pix_ptr[B] * (ry + 1 - i); - sum_a += src_pix_ptr[A] * (ry + 1 - i); - sum_in_r += src_pix_ptr[R]; - sum_in_g += src_pix_ptr[G]; - sum_in_b += src_pix_ptr[B]; - sum_in_a += src_pix_ptr[A]; - } - - stack_ptr = ry; - yp = ry; - if(yp > hm) yp = hm; - src_pix_ptr = img.pix_ptr(x, yp); - dst_pix_ptr = img.pix_ptr(x, 0); - for(y = 0; y < h; y++) - { - dst_pix_ptr[R] = (sum_r * mul_sum) >> shr_sum; - dst_pix_ptr[G] = (sum_g * mul_sum) >> shr_sum; - dst_pix_ptr[B] = (sum_b * mul_sum) >> shr_sum; - dst_pix_ptr[A] = (sum_a * mul_sum) >> shr_sum; - dst_pix_ptr += stride; - - sum_r -= sum_out_r; - sum_g -= sum_out_g; - sum_b -= sum_out_b; - sum_a -= sum_out_a; - - stack_start = stack_ptr + div - ry; - if(stack_start >= div) stack_start -= div; - - stack_pix_ptr = &stack[stack_start]; - sum_out_r -= stack_pix_ptr->r; - sum_out_g -= stack_pix_ptr->g; - sum_out_b -= stack_pix_ptr->b; - sum_out_a -= stack_pix_ptr->a; - - if(yp < hm) - { - src_pix_ptr += stride; - ++yp; - } - - stack_pix_ptr->r = src_pix_ptr[R]; - stack_pix_ptr->g = src_pix_ptr[G]; - stack_pix_ptr->b = src_pix_ptr[B]; - stack_pix_ptr->a = src_pix_ptr[A]; - - sum_in_r += src_pix_ptr[R]; - sum_in_g += src_pix_ptr[G]; - sum_in_b += src_pix_ptr[B]; - sum_in_a += src_pix_ptr[A]; - sum_r += sum_in_r; - sum_g += sum_in_g; - sum_b += sum_in_b; - sum_a += sum_in_a; - - ++stack_ptr; - if(stack_ptr >= div) stack_ptr = 0; - stack_pix_ptr = &stack[stack_ptr]; - - sum_out_r += stack_pix_ptr->r; - sum_out_g += stack_pix_ptr->g; - sum_out_b += stack_pix_ptr->b; - sum_out_a += stack_pix_ptr->a; - sum_in_r -= stack_pix_ptr->r; - sum_in_g -= stack_pix_ptr->g; - sum_in_b -= stack_pix_ptr->b; - sum_in_a -= stack_pix_ptr->a; - } - } - } - } - - - - //===========================================================recursive_blur - template class recursive_blur - { - public: - typedef ColorT color_type; - typedef CalculatorT calculator_type; - typedef typename color_type::value_type value_type; - typedef typename calculator_type::value_type calc_type; - - //-------------------------------------------------------------------- - template void blur_x(Img& img, double radius) - { - if(radius < 0.62) return; - if(img.width() < 3) return; - - calc_type s = calc_type(radius * 0.5); - calc_type q = calc_type((s < 2.5) ? - 3.97156 - 4.14554 * sqrt(1 - 0.26891 * s) : - 0.98711 * s - 0.96330); - - calc_type q2 = calc_type(q * q); - calc_type q3 = calc_type(q2 * q); - - calc_type b0 = calc_type(1.0 / (1.578250 + - 2.444130 * q + - 1.428100 * q2 + - 0.422205 * q3)); - - calc_type b1 = calc_type( 2.44413 * q + - 2.85619 * q2 + - 1.26661 * q3); - - calc_type b2 = calc_type(-1.42810 * q2 + - -1.26661 * q3); - - calc_type b3 = calc_type(0.422205 * q3); - - calc_type b = calc_type(1 - (b1 + b2 + b3) * b0); - - b1 *= b0; - b2 *= b0; - b3 *= b0; - - int w = img.width(); - int h = img.height(); - int wm = w-1; - int x, y; - - m_sum1.allocate(w); - m_sum2.allocate(w); - m_buf.allocate(w); - - for(y = 0; y < h; y++) - { - calculator_type c; - c.from_pix(img.pixel(0, y)); - m_sum1[0].calc(b, b1, b2, b3, c, c, c, c); - c.from_pix(img.pixel(1, y)); - m_sum1[1].calc(b, b1, b2, b3, c, m_sum1[0], m_sum1[0], m_sum1[0]); - c.from_pix(img.pixel(2, y)); - m_sum1[2].calc(b, b1, b2, b3, c, m_sum1[1], m_sum1[0], m_sum1[0]); - - for(x = 3; x < w; ++x) - { - c.from_pix(img.pixel(x, y)); - m_sum1[x].calc(b, b1, b2, b3, c, m_sum1[x-1], m_sum1[x-2], m_sum1[x-3]); - } - - m_sum2[wm ].calc(b, b1, b2, b3, m_sum1[wm ], m_sum1[wm ], m_sum1[wm], m_sum1[wm]); - m_sum2[wm-1].calc(b, b1, b2, b3, m_sum1[wm-1], m_sum2[wm ], m_sum2[wm], m_sum2[wm]); - m_sum2[wm-2].calc(b, b1, b2, b3, m_sum1[wm-2], m_sum2[wm-1], m_sum2[wm], m_sum2[wm]); - m_sum2[wm ].to_pix(m_buf[wm ]); - m_sum2[wm-1].to_pix(m_buf[wm-1]); - m_sum2[wm-2].to_pix(m_buf[wm-2]); - - for(x = wm-3; x >= 0; --x) - { - m_sum2[x].calc(b, b1, b2, b3, m_sum1[x], m_sum2[x+1], m_sum2[x+2], m_sum2[x+3]); - m_sum2[x].to_pix(m_buf[x]); - } - img.copy_color_hspan(0, y, w, &m_buf[0]); - } - } - - //-------------------------------------------------------------------- - template void blur_y(Img& img, double radius) - { - pixfmt_transposer img2(img); - blur_x(img2, radius); - } - - //-------------------------------------------------------------------- - template void blur(Img& img, double radius) - { - blur_x(img, radius); - pixfmt_transposer img2(img); - blur_x(img2, radius); - } - - private: - agg::pod_vector m_sum1; - agg::pod_vector m_sum2; - agg::pod_vector m_buf; - }; - - - //=================================================recursive_blur_calc_rgba - template struct recursive_blur_calc_rgba - { - typedef T value_type; - typedef recursive_blur_calc_rgba self_type; - - value_type r,g,b,a; - - template - AGG_INLINE void from_pix(const ColorT& c) - { - r = c.r; - g = c.g; - b = c.b; - a = c.a; - } - - AGG_INLINE void calc(value_type b1, - value_type b2, - value_type b3, - value_type b4, - const self_type& c1, - const self_type& c2, - const self_type& c3, - const self_type& c4) - { - r = b1*c1.r + b2*c2.r + b3*c3.r + b4*c4.r; - g = b1*c1.g + b2*c2.g + b3*c3.g + b4*c4.g; - b = b1*c1.b + b2*c2.b + b3*c3.b + b4*c4.b; - a = b1*c1.a + b2*c2.a + b3*c3.a + b4*c4.a; - } - - template - AGG_INLINE void to_pix(ColorT& c) const - { - typedef typename ColorT::value_type cv_type; - c.r = cv_type(r); - c.g = cv_type(g); - c.b = cv_type(b); - c.a = cv_type(a); - } - }; - - - //=================================================recursive_blur_calc_rgb - template struct recursive_blur_calc_rgb - { - typedef T value_type; - typedef recursive_blur_calc_rgb self_type; - - value_type r,g,b; - - template - AGG_INLINE void from_pix(const ColorT& c) - { - r = c.r; - g = c.g; - b = c.b; - } - - AGG_INLINE void calc(value_type b1, - value_type b2, - value_type b3, - value_type b4, - const self_type& c1, - const self_type& c2, - const self_type& c3, - const self_type& c4) - { - r = b1*c1.r + b2*c2.r + b3*c3.r + b4*c4.r; - g = b1*c1.g + b2*c2.g + b3*c3.g + b4*c4.g; - b = b1*c1.b + b2*c2.b + b3*c3.b + b4*c4.b; - } - - template - AGG_INLINE void to_pix(ColorT& c) const - { - typedef typename ColorT::value_type cv_type; - c.r = cv_type(r); - c.g = cv_type(g); - c.b = cv_type(b); - } - }; - - - //================================================recursive_blur_calc_gray - template struct recursive_blur_calc_gray - { - typedef T value_type; - typedef recursive_blur_calc_gray self_type; - - value_type v; - - template - AGG_INLINE void from_pix(const ColorT& c) - { - v = c.v; - } - - AGG_INLINE void calc(value_type b1, - value_type b2, - value_type b3, - value_type b4, - const self_type& c1, - const self_type& c2, - const self_type& c3, - const self_type& c4) - { - v = b1*c1.v + b2*c2.v + b3*c3.v + b4*c4.v; - } - - template - AGG_INLINE void to_pix(ColorT& c) const - { - typedef typename ColorT::value_type cv_type; - c.v = cv_type(v); - } - }; - - //================================================slight_blur - // Special-purpose filter for applying a Gaussian blur with a radius small enough - // that the blur only affects adjacent pixels. A Gaussian curve with a standard - // deviation of r/2 is used, as per the HTML/CSS spec. At 3 standard deviations, - // the contribution drops to less than 0.005, i.e. less than half a percent, - // therefore the radius can be at least 1.33 before errors become significant. - // This filter is useful for smoothing artifacts caused by detail rendered - // at the pixel scale, e.g. single-pixel lines. Note that the filter should - // only be used with premultiplied pixel formats (or those without alpha). - // See the "line_thickness" example for a demonstration. - template - class slight_blur - { - public: - typedef typename PixFmt::pixel_type pixel_type; - typedef typename PixFmt::value_type value_type; - typedef typename PixFmt::order_type order_type; - - slight_blur(double r = 1.33) - { - radius(r); - } - - void radius(double r) - { - if (r > 0) - { - // Sample the gaussian curve at 0 and r/2 standard deviations. - // At 3 standard deviations, the response is < 0.005. - double pi = 3.14159; - double n = 2 / r; - m_g0 = 1 / sqrt(2 * pi); - m_g1 = m_g0 * exp(-n * n); - - // Normalize. - double sum = m_g0 + 2 * m_g1; - m_g0 /= sum; - m_g1 /= sum; - } - else - { - m_g0 = 1; - m_g1 = 0; - } - } - - void blur(PixFmt& img, rect_i bounds) - { - // Make sure we stay within the image area. - bounds.clip(rect_i(0, 0, img.width() - 1, img.height() - 1)); - - int w = bounds.x2 - bounds.x1 + 1; - int h = bounds.y2 - bounds.y1 + 1; - - if (w < 3 || h < 3) return; - - // Allocate 3 rows of buffer space. - m_buf.allocate(w * 3); - - // Set up row pointers - pixel_type * begin = &m_buf[0]; - pixel_type * r0 = begin; - pixel_type * r1 = r0 + w; - pixel_type * r2 = r1 + w; - pixel_type * end = r2 + w; - - // Horizontally blur the first two input rows. - calc_row(img, bounds.x1, bounds.y1, w, r0); - memcpy(r1, r0, w * sizeof(pixel_type)); - - for (int y = 0; ; ) - { - // Get pointer to first pixel. - pixel_type* p = img.pix_value_ptr(bounds.x1, bounds.y1 + y, bounds.x1 + w); - - // Horizontally blur the row below. - if (y + 1 < h) - { - calc_row(img, bounds.x1, bounds.y1 + y + 1, w, r2); - } - else - { - memcpy(r2, r1, w * sizeof(pixel_type)); // duplicate bottom row - } - - // Combine blurred rows into destination. - for (int x = 0; x < w; ++x) - { - calc_pixel(*r0++, *r1++, *r2++, *p++); - } - - if (++y >= h) break; - - // Wrap bottom row pointer around to top of buffer. - if (r2 == end) r2 = begin; - else if (r1 == end) r1 = begin; - else if (r0 == end) r0 = begin; - } - } - - private: - void calc_row(PixFmt& img, int x, int y, int w, pixel_type* row) - { - const int wm = w - 1; - - pixel_type* p = img.pix_value_ptr(x, y, w); - - pixel_type c[3]; - pixel_type* p0 = c; - pixel_type* p1 = c + 1; - pixel_type* p2 = c + 2; - pixel_type* end = c + 3; - *p0 = *p1 = *p; - - for (int x = 0; x < wm; ++x) - { - *p2 = *(p = p->next()); - - calc_pixel(*p0++, *p1++, *p2++, *row++); - - if (p0 == end) p0 = c; - else if (p1 == end) p1 = c; - else if (p2 == end) p2 = c; - } - - calc_pixel(*p0, *p1, *p1, *row); - } - - void calc_pixel( - pixel_type const & c1, - pixel_type const & c2, - pixel_type const & c3, - pixel_type & x) - { - calc_pixel(c1, c2, c3, x, PixFmt::pixfmt_category()); - } - - void calc_pixel( - pixel_type const & c1, - pixel_type const & c2, - pixel_type const & c3, - pixel_type & x, - pixfmt_gray_tag) - { - x.c[0] = calc_value(c1.c[0], c2.c[0], c3.c[0]); - } - - void calc_pixel( - pixel_type const & c1, - pixel_type const & c2, - pixel_type const & c3, - pixel_type & x, - pixfmt_rgb_tag) - { - enum { R = order_type::R, G = order_type::G, B = order_type::B }; - x.c[R] = calc_value(c1.c[R], c2.c[R], c3.c[R]); - x.c[G] = calc_value(c1.c[G], c2.c[G], c3.c[G]); - x.c[B] = calc_value(c1.c[B], c2.c[B], c3.c[B]); - } - - void calc_pixel( - pixel_type const & c1, - pixel_type const & c2, - pixel_type const & c3, - pixel_type & x, - pixfmt_rgba_tag) - { - enum { R = order_type::R, G = order_type::G, B = order_type::B, A = order_type::A }; - x.c[R] = calc_value(c1.c[R], c2.c[R], c3.c[R]); - x.c[G] = calc_value(c1.c[G], c2.c[G], c3.c[G]); - x.c[B] = calc_value(c1.c[B], c2.c[B], c3.c[B]); - x.c[A] = calc_value(c1.c[A], c2.c[A], c3.c[A]); - } - - value_type calc_value(value_type v1, value_type v2, value_type v3) - { - return value_type(m_g1 * v1 + m_g0 * v2 + m_g1 * v3); - } - - double m_g0, m_g1; - pod_vector m_buf; - }; - - // Helper functions for applying blur to a surface without having to create an intermediate object. - - template - void apply_slight_blur(PixFmt& img, const rect_i& bounds, double r = 1) - { - if (r > 0) slight_blur(r).blur(img, bounds); - } - - template - void apply_slight_blur(PixFmt& img, double r = 1) - { - if (r > 0) slight_blur(r).blur(img, rect_i(0, 0, img.width() - 1, img.height() - 1)); - } - - template - void apply_slight_blur(renderer_base& img, const rect_i& bounds, double r = 1) - { - if (r > 0) slight_blur(r).blur(img.ren(), bounds); - } - - template - void apply_slight_blur(renderer_base& img, double r = 1) - { - if (r > 0) slight_blur(r).blur(img.ren(), img.clip_box()); - } -} - - - - -#endif diff --git a/xs/src/agg/agg_bounding_rect.h b/xs/src/agg/agg_bounding_rect.h deleted file mode 100644 index f13b863f0f..0000000000 --- a/xs/src/agg/agg_bounding_rect.h +++ /dev/null @@ -1,116 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// bounding_rect function template -// -//---------------------------------------------------------------------------- -#ifndef AGG_BOUNDING_RECT_INCLUDED -#define AGG_BOUNDING_RECT_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //-----------------------------------------------------------bounding_rect - template - bool bounding_rect(VertexSource& vs, GetId& gi, - unsigned start, unsigned num, - CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2) - { - unsigned i; - double x; - double y; - bool first = true; - - *x1 = CoordT(1); - *y1 = CoordT(1); - *x2 = CoordT(0); - *y2 = CoordT(0); - - for(i = 0; i < num; i++) - { - vs.rewind(gi[start + i]); - unsigned cmd; - while(!is_stop(cmd = vs.vertex(&x, &y))) - { - if(is_vertex(cmd)) - { - if(first) - { - *x1 = CoordT(x); - *y1 = CoordT(y); - *x2 = CoordT(x); - *y2 = CoordT(y); - first = false; - } - else - { - if(CoordT(x) < *x1) *x1 = CoordT(x); - if(CoordT(y) < *y1) *y1 = CoordT(y); - if(CoordT(x) > *x2) *x2 = CoordT(x); - if(CoordT(y) > *y2) *y2 = CoordT(y); - } - } - } - } - return *x1 <= *x2 && *y1 <= *y2; - } - - - //-----------------------------------------------------bounding_rect_single - template - bool bounding_rect_single(VertexSource& vs, unsigned path_id, - CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2) - { - double x; - double y; - bool first = true; - - *x1 = CoordT(1); - *y1 = CoordT(1); - *x2 = CoordT(0); - *y2 = CoordT(0); - - vs.rewind(path_id); - unsigned cmd; - while(!is_stop(cmd = vs.vertex(&x, &y))) - { - if(is_vertex(cmd)) - { - if(first) - { - *x1 = CoordT(x); - *y1 = CoordT(y); - *x2 = CoordT(x); - *y2 = CoordT(y); - first = false; - } - else - { - if(CoordT(x) < *x1) *x1 = CoordT(x); - if(CoordT(y) < *y1) *y1 = CoordT(y); - if(CoordT(x) > *x2) *x2 = CoordT(x); - if(CoordT(y) > *y2) *y2 = CoordT(y); - } - } - } - return *x1 <= *x2 && *y1 <= *y2; - } - - -} - -#endif diff --git a/xs/src/agg/agg_bspline.h b/xs/src/agg/agg_bspline.h deleted file mode 100644 index 2c1ed9a38c..0000000000 --- a/xs/src/agg/agg_bspline.h +++ /dev/null @@ -1,76 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// class bspline -// -//---------------------------------------------------------------------------- - -#ifndef AGG_BSPLINE_INCLUDED -#define AGG_BSPLINE_INCLUDED - -#include "agg_array.h" - -namespace agg -{ - //----------------------------------------------------------------bspline - // A very simple class of Bi-cubic Spline interpolation. - // First call init(num, x[], y[]) where num - number of source points, - // x, y - arrays of X and Y values respectively. Here Y must be a function - // of X. It means that all the X-coordinates must be arranged in the ascending - // order. - // Then call get(x) that calculates a value Y for the respective X. - // The class supports extrapolation, i.e. you can call get(x) where x is - // outside the given with init() X-range. Extrapolation is a simple linear - // function. - // - // See Implementation agg_bspline.cpp - //------------------------------------------------------------------------ - class bspline - { - public: - bspline(); - bspline(int num); - bspline(int num, const double* x, const double* y); - - void init(int num); - void add_point(double x, double y); - void prepare(); - - void init(int num, const double* x, const double* y); - - double get(double x) const; - double get_stateful(double x) const; - - private: - bspline(const bspline&); - const bspline& operator = (const bspline&); - - static void bsearch(int n, const double *x, double x0, int *i); - double extrapolation_left(double x) const; - double extrapolation_right(double x) const; - double interpolation(double x, int i) const; - - int m_max; - int m_num; - double* m_x; - double* m_y; - pod_array m_am; - mutable int m_last_idx; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_conv_adaptor_vcgen.h b/xs/src/agg/agg_conv_adaptor_vcgen.h deleted file mode 100644 index a79f2208c6..0000000000 --- a/xs/src/agg/agg_conv_adaptor_vcgen.h +++ /dev/null @@ -1,157 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_ADAPTOR_VCGEN_INCLUDED -#define AGG_CONV_ADAPTOR_VCGEN_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - //------------------------------------------------------------null_markers - struct null_markers - { - void remove_all() {} - void add_vertex(double, double, unsigned) {} - void prepare_src() {} - - void rewind(unsigned) {} - unsigned vertex(double*, double*) { return path_cmd_stop; } - }; - - - //------------------------------------------------------conv_adaptor_vcgen - template class conv_adaptor_vcgen - { - enum status - { - initial, - accumulate, - generate - }; - - public: - explicit conv_adaptor_vcgen(VertexSource& source) : - m_source(&source), - m_status(initial) - {} - void attach(VertexSource& source) { m_source = &source; } - - Generator& generator() { return m_generator; } - const Generator& generator() const { return m_generator; } - - Markers& markers() { return m_markers; } - const Markers& markers() const { return m_markers; } - - void rewind(unsigned path_id) - { - m_source->rewind(path_id); - m_status = initial; - } - - unsigned vertex(double* x, double* y); - - private: - // Prohibit copying - conv_adaptor_vcgen(const conv_adaptor_vcgen&); - const conv_adaptor_vcgen& - operator = (const conv_adaptor_vcgen&); - - VertexSource* m_source; - Generator m_generator; - Markers m_markers; - status m_status; - unsigned m_last_cmd; - double m_start_x; - double m_start_y; - }; - - - - - - //------------------------------------------------------------------------ - template - unsigned conv_adaptor_vcgen::vertex(double* x, double* y) - { - unsigned cmd = path_cmd_stop; - bool done = false; - while(!done) - { - switch(m_status) - { - case initial: - m_markers.remove_all(); - m_last_cmd = m_source->vertex(&m_start_x, &m_start_y); - m_status = accumulate; - - case accumulate: - if(is_stop(m_last_cmd)) return path_cmd_stop; - - m_generator.remove_all(); - m_generator.add_vertex(m_start_x, m_start_y, path_cmd_move_to); - m_markers.add_vertex(m_start_x, m_start_y, path_cmd_move_to); - - for(;;) - { - cmd = m_source->vertex(x, y); - if(is_vertex(cmd)) - { - m_last_cmd = cmd; - if(is_move_to(cmd)) - { - m_start_x = *x; - m_start_y = *y; - break; - } - m_generator.add_vertex(*x, *y, cmd); - m_markers.add_vertex(*x, *y, path_cmd_line_to); - } - else - { - if(is_stop(cmd)) - { - m_last_cmd = path_cmd_stop; - break; - } - if(is_end_poly(cmd)) - { - m_generator.add_vertex(*x, *y, cmd); - break; - } - } - } - m_generator.rewind(0); - m_status = generate; - - case generate: - cmd = m_generator.vertex(x, y); - if(is_stop(cmd)) - { - m_status = accumulate; - break; - } - done = true; - break; - } - } - return cmd; - } - -} - -#endif diff --git a/xs/src/agg/agg_conv_adaptor_vpgen.h b/xs/src/agg/agg_conv_adaptor_vpgen.h deleted file mode 100644 index d6b545ef1f..0000000000 --- a/xs/src/agg/agg_conv_adaptor_vpgen.h +++ /dev/null @@ -1,159 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_ADAPTOR_VPGEN_INCLUDED -#define AGG_CONV_ADAPTOR_VPGEN_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //======================================================conv_adaptor_vpgen - template class conv_adaptor_vpgen - { - public: - explicit conv_adaptor_vpgen(VertexSource& source) : m_source(&source) {} - void attach(VertexSource& source) { m_source = &source; } - - VPGen& vpgen() { return m_vpgen; } - const VPGen& vpgen() const { return m_vpgen; } - - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - conv_adaptor_vpgen(const conv_adaptor_vpgen&); - const conv_adaptor_vpgen& - operator = (const conv_adaptor_vpgen&); - - VertexSource* m_source; - VPGen m_vpgen; - double m_start_x; - double m_start_y; - unsigned m_poly_flags; - int m_vertices; - }; - - - - //------------------------------------------------------------------------ - template - void conv_adaptor_vpgen::rewind(unsigned path_id) - { - m_source->rewind(path_id); - m_vpgen.reset(); - m_start_x = 0; - m_start_y = 0; - m_poly_flags = 0; - m_vertices = 0; - } - - - //------------------------------------------------------------------------ - template - unsigned conv_adaptor_vpgen::vertex(double* x, double* y) - { - unsigned cmd = path_cmd_stop; - for(;;) - { - cmd = m_vpgen.vertex(x, y); - if(!is_stop(cmd)) break; - - if(m_poly_flags && !m_vpgen.auto_unclose()) - { - *x = 0.0; - *y = 0.0; - cmd = m_poly_flags; - m_poly_flags = 0; - break; - } - - if(m_vertices < 0) - { - if(m_vertices < -1) - { - m_vertices = 0; - return path_cmd_stop; - } - m_vpgen.move_to(m_start_x, m_start_y); - m_vertices = 1; - continue; - } - - double tx, ty; - cmd = m_source->vertex(&tx, &ty); - if(is_vertex(cmd)) - { - if(is_move_to(cmd)) - { - if(m_vpgen.auto_close() && m_vertices > 2) - { - m_vpgen.line_to(m_start_x, m_start_y); - m_poly_flags = path_cmd_end_poly | path_flags_close; - m_start_x = tx; - m_start_y = ty; - m_vertices = -1; - continue; - } - m_vpgen.move_to(tx, ty); - m_start_x = tx; - m_start_y = ty; - m_vertices = 1; - } - else - { - m_vpgen.line_to(tx, ty); - ++m_vertices; - } - } - else - { - if(is_end_poly(cmd)) - { - m_poly_flags = cmd; - if(is_closed(cmd) || m_vpgen.auto_close()) - { - if(m_vpgen.auto_close()) m_poly_flags |= path_flags_close; - if(m_vertices > 2) - { - m_vpgen.line_to(m_start_x, m_start_y); - } - m_vertices = 0; - } - } - else - { - // path_cmd_stop - if(m_vpgen.auto_close() && m_vertices > 2) - { - m_vpgen.line_to(m_start_x, m_start_y); - m_poly_flags = path_cmd_end_poly | path_flags_close; - m_vertices = -2; - continue; - } - break; - } - } - } - return cmd; - } - - -} - - -#endif - diff --git a/xs/src/agg/agg_conv_bspline.h b/xs/src/agg/agg_conv_bspline.h deleted file mode 100644 index 13d22d9297..0000000000 --- a/xs/src/agg/agg_conv_bspline.h +++ /dev/null @@ -1,48 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_CONV_BSPLINE_INCLUDED -#define AGG_CONV_BSPLINE_INCLUDED - -#include "agg_basics.h" -#include "agg_vcgen_bspline.h" -#include "agg_conv_adaptor_vcgen.h" - - -namespace agg -{ - - //---------------------------------------------------------conv_bspline - template - struct conv_bspline : public conv_adaptor_vcgen - { - typedef conv_adaptor_vcgen base_type; - - conv_bspline(VertexSource& vs) : - conv_adaptor_vcgen(vs) {} - - void interpolation_step(double v) { base_type::generator().interpolation_step(v); } - double interpolation_step() const { return base_type::generator().interpolation_step(); } - - private: - conv_bspline(const conv_bspline&); - const conv_bspline& - operator = (const conv_bspline&); - }; - -} - - -#endif - diff --git a/xs/src/agg/agg_conv_clip_polygon.h b/xs/src/agg/agg_conv_clip_polygon.h deleted file mode 100644 index 87537638dc..0000000000 --- a/xs/src/agg/agg_conv_clip_polygon.h +++ /dev/null @@ -1,63 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Polygon clipping converter -// There an optimized Liang-Basky algorithm is used. -// The algorithm doesn't optimize the degenerate edges, i.e. it will never -// break a closed polygon into two or more ones, instead, there will be -// degenerate edges coinciding with the respective clipping boundaries. -// This is a sub-optimal solution, because that optimization would require -// extra, rather expensive math while the rasterizer tolerates it quite well, -// without any considerable overhead. -// -//---------------------------------------------------------------------------- -#ifndef AGG_CONV_CLIP_POLYGON_INCLUDED -#define AGG_CONV_CLIP_POLYGON_INCLUDED - -#include "agg_basics.h" -#include "agg_conv_adaptor_vpgen.h" -#include "agg_vpgen_clip_polygon.h" - -namespace agg -{ - - //=======================================================conv_clip_polygon - template - struct conv_clip_polygon : public conv_adaptor_vpgen - { - typedef conv_adaptor_vpgen base_type; - - conv_clip_polygon(VertexSource& vs) : - conv_adaptor_vpgen(vs) {} - - void clip_box(double x1, double y1, double x2, double y2) - { - base_type::vpgen().clip_box(x1, y1, x2, y2); - } - - double x1() const { return base_type::vpgen().x1(); } - double y1() const { return base_type::vpgen().y1(); } - double x2() const { return base_type::vpgen().x2(); } - double y2() const { return base_type::vpgen().y2(); } - - private: - conv_clip_polygon(const conv_clip_polygon&); - const conv_clip_polygon& - operator = (const conv_clip_polygon&); - }; - -} - -#endif diff --git a/xs/src/agg/agg_conv_clip_polyline.h b/xs/src/agg/agg_conv_clip_polyline.h deleted file mode 100644 index f3fc2888c2..0000000000 --- a/xs/src/agg/agg_conv_clip_polyline.h +++ /dev/null @@ -1,63 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// polyline clipping converter -// There an optimized Liang-Basky algorithm is used. -// The algorithm doesn't optimize the degenerate edges, i.e. it will never -// break a closed polyline into two or more ones, instead, there will be -// degenerate edges coinciding with the respective clipping boundaries. -// This is a sub-optimal solution, because that optimization would require -// extra, rather expensive math while the rasterizer tolerates it quite well, -// without any considerable overhead. -// -//---------------------------------------------------------------------------- -#ifndef AGG_CONV_CLIP_polyline_INCLUDED -#define AGG_CONV_CLIP_polyline_INCLUDED - -#include "agg_basics.h" -#include "agg_conv_adaptor_vpgen.h" -#include "agg_vpgen_clip_polyline.h" - -namespace agg -{ - - //=======================================================conv_clip_polyline - template - struct conv_clip_polyline : public conv_adaptor_vpgen - { - typedef conv_adaptor_vpgen base_type; - - conv_clip_polyline(VertexSource& vs) : - conv_adaptor_vpgen(vs) {} - - void clip_box(double x1, double y1, double x2, double y2) - { - base_type::vpgen().clip_box(x1, y1, x2, y2); - } - - double x1() const { return base_type::vpgen().x1(); } - double y1() const { return base_type::vpgen().y1(); } - double x2() const { return base_type::vpgen().x2(); } - double y2() const { return base_type::vpgen().y2(); } - - private: - conv_clip_polyline(const conv_clip_polyline&); - const conv_clip_polyline& - operator = (const conv_clip_polyline&); - }; - -} - -#endif diff --git a/xs/src/agg/agg_conv_close_polygon.h b/xs/src/agg/agg_conv_close_polygon.h deleted file mode 100644 index c46594fdfb..0000000000 --- a/xs/src/agg/agg_conv_close_polygon.h +++ /dev/null @@ -1,125 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_CLOSE_POLYGON_INCLUDED -#define AGG_CONV_CLOSE_POLYGON_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //======================================================conv_close_polygon - template class conv_close_polygon - { - public: - explicit conv_close_polygon(VertexSource& vs) : m_source(&vs) {} - void attach(VertexSource& source) { m_source = &source; } - - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - conv_close_polygon(const conv_close_polygon&); - const conv_close_polygon& - operator = (const conv_close_polygon&); - - VertexSource* m_source; - unsigned m_cmd[2]; - double m_x[2]; - double m_y[2]; - unsigned m_vertex; - bool m_line_to; - }; - - - - //------------------------------------------------------------------------ - template - void conv_close_polygon::rewind(unsigned path_id) - { - m_source->rewind(path_id); - m_vertex = 2; - m_line_to = false; - } - - - - //------------------------------------------------------------------------ - template - unsigned conv_close_polygon::vertex(double* x, double* y) - { - unsigned cmd = path_cmd_stop; - for(;;) - { - if(m_vertex < 2) - { - *x = m_x[m_vertex]; - *y = m_y[m_vertex]; - cmd = m_cmd[m_vertex]; - ++m_vertex; - break; - } - - cmd = m_source->vertex(x, y); - - if(is_end_poly(cmd)) - { - cmd |= path_flags_close; - break; - } - - if(is_stop(cmd)) - { - if(m_line_to) - { - m_cmd[0] = path_cmd_end_poly | path_flags_close; - m_cmd[1] = path_cmd_stop; - m_vertex = 0; - m_line_to = false; - continue; - } - break; - } - - if(is_move_to(cmd)) - { - if(m_line_to) - { - m_x[0] = 0.0; - m_y[0] = 0.0; - m_cmd[0] = path_cmd_end_poly | path_flags_close; - m_x[1] = *x; - m_y[1] = *y; - m_cmd[1] = cmd; - m_vertex = 0; - m_line_to = false; - continue; - } - break; - } - - if(is_vertex(cmd)) - { - m_line_to = true; - break; - } - } - return cmd; - } - -} - -#endif diff --git a/xs/src/agg/agg_conv_concat.h b/xs/src/agg/agg_conv_concat.h deleted file mode 100644 index 745d349c6f..0000000000 --- a/xs/src/agg/agg_conv_concat.h +++ /dev/null @@ -1,73 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_CONCAT_INCLUDED -#define AGG_CONV_CONCAT_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - //=============================================================conv_concat - // Concatenation of two paths. Usually used to combine lines or curves - // with markers such as arrowheads - template class conv_concat - { - public: - conv_concat(VS1& source1, VS2& source2) : - m_source1(&source1), m_source2(&source2), m_status(2) {} - void attach1(VS1& source) { m_source1 = &source; } - void attach2(VS2& source) { m_source2 = &source; } - - - void rewind(unsigned path_id) - { - m_source1->rewind(path_id); - m_source2->rewind(0); - m_status = 0; - } - - unsigned vertex(double* x, double* y) - { - unsigned cmd; - if(m_status == 0) - { - cmd = m_source1->vertex(x, y); - if(!is_stop(cmd)) return cmd; - m_status = 1; - } - if(m_status == 1) - { - cmd = m_source2->vertex(x, y); - if(!is_stop(cmd)) return cmd; - m_status = 2; - } - return path_cmd_stop; - } - - private: - conv_concat(const conv_concat&); - const conv_concat& - operator = (const conv_concat&); - - VS1* m_source1; - VS2* m_source2; - int m_status; - - }; -} - - -#endif diff --git a/xs/src/agg/agg_conv_contour.h b/xs/src/agg/agg_conv_contour.h deleted file mode 100644 index b4b5a9047e..0000000000 --- a/xs/src/agg/agg_conv_contour.h +++ /dev/null @@ -1,65 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// conv_stroke -// -//---------------------------------------------------------------------------- -#ifndef AGG_CONV_CONTOUR_INCLUDED -#define AGG_CONV_CONTOUR_INCLUDED - -#include "agg_basics.h" -#include "agg_vcgen_contour.h" -#include "agg_conv_adaptor_vcgen.h" - -namespace agg -{ - - //-----------------------------------------------------------conv_contour - template - struct conv_contour : public conv_adaptor_vcgen - { - typedef conv_adaptor_vcgen base_type; - - conv_contour(VertexSource& vs) : - conv_adaptor_vcgen(vs) - { - } - - void line_join(line_join_e lj) { base_type::generator().line_join(lj); } - void inner_join(inner_join_e ij) { base_type::generator().inner_join(ij); } - void width(double w) { base_type::generator().width(w); } - void miter_limit(double ml) { base_type::generator().miter_limit(ml); } - void miter_limit_theta(double t) { base_type::generator().miter_limit_theta(t); } - void inner_miter_limit(double ml) { base_type::generator().inner_miter_limit(ml); } - void approximation_scale(double as) { base_type::generator().approximation_scale(as); } - void auto_detect_orientation(bool v) { base_type::generator().auto_detect_orientation(v); } - - line_join_e line_join() const { return base_type::generator().line_join(); } - inner_join_e inner_join() const { return base_type::generator().inner_join(); } - double width() const { return base_type::generator().width(); } - double miter_limit() const { return base_type::generator().miter_limit(); } - double inner_miter_limit() const { return base_type::generator().inner_miter_limit(); } - double approximation_scale() const { return base_type::generator().approximation_scale(); } - bool auto_detect_orientation() const { return base_type::generator().auto_detect_orientation(); } - - private: - conv_contour(const conv_contour&); - const conv_contour& - operator = (const conv_contour&); - }; - -} - -#endif diff --git a/xs/src/agg/agg_conv_curve.h b/xs/src/agg/agg_conv_curve.h deleted file mode 100644 index 0be3b6fd74..0000000000 --- a/xs/src/agg/agg_conv_curve.h +++ /dev/null @@ -1,201 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// classes conv_curve -// -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_CURVE_INCLUDED -#define AGG_CONV_CURVE_INCLUDED - -#include "agg_basics.h" -#include "agg_curves.h" - -namespace agg -{ - - - //---------------------------------------------------------------conv_curve - // Curve converter class. Any path storage can have Bezier curves defined - // by their control points. There're two types of curves supported: curve3 - // and curve4. Curve3 is a conic Bezier curve with 2 endpoints and 1 control - // point. Curve4 has 2 control points (4 points in total) and can be used - // to interpolate more complicated curves. Curve4, unlike curve3 can be used - // to approximate arcs, both circular and elliptical. Curves are approximated - // with straight lines and one of the approaches is just to store the whole - // sequence of vertices that approximate our curve. It takes additional - // memory, and at the same time the consecutive vertices can be calculated - // on demand. - // - // Initially, path storages are not suppose to keep all the vertices of the - // curves (although, nothing prevents us from doing so). Instead, path_storage - // keeps only vertices, needed to calculate a curve on demand. Those vertices - // are marked with special commands. So, if the path_storage contains curves - // (which are not real curves yet), and we render this storage directly, - // all we will see is only 2 or 3 straight line segments (for curve3 and - // curve4 respectively). If we need to see real curves drawn we need to - // include this class into the conversion pipeline. - // - // Class conv_curve recognizes commands path_cmd_curve3 and path_cmd_curve4 - // and converts these vertices into a move_to/line_to sequence. - //----------------------------------------------------------------------- - template class conv_curve - { - public: - typedef Curve3 curve3_type; - typedef Curve4 curve4_type; - typedef conv_curve self_type; - - explicit conv_curve(VertexSource& source) : - m_source(&source), m_last_x(0.0), m_last_y(0.0) {} - void attach(VertexSource& source) { m_source = &source; } - - void approximation_method(curve_approximation_method_e v) - { - m_curve3.approximation_method(v); - m_curve4.approximation_method(v); - } - - curve_approximation_method_e approximation_method() const - { - return m_curve4.approximation_method(); - } - - void approximation_scale(double s) - { - m_curve3.approximation_scale(s); - m_curve4.approximation_scale(s); - } - - double approximation_scale() const - { - return m_curve4.approximation_scale(); - } - - void angle_tolerance(double v) - { - m_curve3.angle_tolerance(v); - m_curve4.angle_tolerance(v); - } - - double angle_tolerance() const - { - return m_curve4.angle_tolerance(); - } - - void cusp_limit(double v) - { - m_curve3.cusp_limit(v); - m_curve4.cusp_limit(v); - } - - double cusp_limit() const - { - return m_curve4.cusp_limit(); - } - - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - conv_curve(const self_type&); - const self_type& operator = (const self_type&); - - VertexSource* m_source; - double m_last_x; - double m_last_y; - curve3_type m_curve3; - curve4_type m_curve4; - }; - - - - //------------------------------------------------------------------------ - template - void conv_curve::rewind(unsigned path_id) - { - m_source->rewind(path_id); - m_last_x = 0.0; - m_last_y = 0.0; - m_curve3.reset(); - m_curve4.reset(); - } - - - //------------------------------------------------------------------------ - template - unsigned conv_curve::vertex(double* x, double* y) - { - if(!is_stop(m_curve3.vertex(x, y))) - { - m_last_x = *x; - m_last_y = *y; - return path_cmd_line_to; - } - - if(!is_stop(m_curve4.vertex(x, y))) - { - m_last_x = *x; - m_last_y = *y; - return path_cmd_line_to; - } - - double ct2_x = 0; - double ct2_y = 0; - double end_x = 0; - double end_y = 0; - - unsigned cmd = m_source->vertex(x, y); - switch(cmd) - { - case path_cmd_curve3: - m_source->vertex(&end_x, &end_y); - - m_curve3.init(m_last_x, m_last_y, - *x, *y, - end_x, end_y); - - m_curve3.vertex(x, y); // First call returns path_cmd_move_to - m_curve3.vertex(x, y); // This is the first vertex of the curve - cmd = path_cmd_line_to; - break; - - case path_cmd_curve4: - m_source->vertex(&ct2_x, &ct2_y); - m_source->vertex(&end_x, &end_y); - - m_curve4.init(m_last_x, m_last_y, - *x, *y, - ct2_x, ct2_y, - end_x, end_y); - - m_curve4.vertex(x, y); // First call returns path_cmd_move_to - m_curve4.vertex(x, y); // This is the first vertex of the curve - cmd = path_cmd_line_to; - break; - } - m_last_x = *x; - m_last_y = *y; - return cmd; - } - - -} - - - -#endif diff --git a/xs/src/agg/agg_conv_dash.h b/xs/src/agg/agg_conv_dash.h deleted file mode 100644 index 23c13ad0ab..0000000000 --- a/xs/src/agg/agg_conv_dash.h +++ /dev/null @@ -1,68 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// conv_dash -// -//---------------------------------------------------------------------------- -#ifndef AGG_CONV_DASH_INCLUDED -#define AGG_CONV_DASH_INCLUDED - -#include "agg_basics.h" -#include "agg_vcgen_dash.h" -#include "agg_conv_adaptor_vcgen.h" - -namespace agg -{ - - //---------------------------------------------------------------conv_dash - template - struct conv_dash : public conv_adaptor_vcgen - { - typedef Markers marker_type; - typedef conv_adaptor_vcgen base_type; - - conv_dash(VertexSource& vs) : - conv_adaptor_vcgen(vs) - { - } - - void remove_all_dashes() - { - base_type::generator().remove_all_dashes(); - } - - void add_dash(double dash_len, double gap_len) - { - base_type::generator().add_dash(dash_len, gap_len); - } - - void dash_start(double ds) - { - base_type::generator().dash_start(ds); - } - - void shorten(double s) { base_type::generator().shorten(s); } - double shorten() const { return base_type::generator().shorten(); } - - private: - conv_dash(const conv_dash&); - const conv_dash& - operator = (const conv_dash&); - }; - - -} - -#endif diff --git a/xs/src/agg/agg_conv_gpc.h b/xs/src/agg/agg_conv_gpc.h deleted file mode 100644 index 698ae900f4..0000000000 --- a/xs/src/agg/agg_conv_gpc.h +++ /dev/null @@ -1,432 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// General Polygon Clipper based on the GPC library by Alan Murta -// Union, Intersection, XOR, A-B, B-A -// Contact the author if you intend to use it in commercial applications! -// http://www.cs.man.ac.uk/aig/staff/alan/software/ -// Alan Murta (email: gpc@cs.man.ac.uk) -// -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_GPC_INCLUDED -#define AGG_CONV_GPC_INCLUDED - -#include -#include "agg_basics.h" -#include "agg_array.h" - -extern "C" -{ -#include "gpc.h" -} - -namespace agg -{ - enum gpc_op_e - { - gpc_or, - gpc_and, - gpc_xor, - gpc_a_minus_b, - gpc_b_minus_a - }; - - - //================================================================conv_gpc - template class conv_gpc - { - enum status - { - status_move_to, - status_line_to, - status_stop - }; - - struct contour_header_type - { - int num_vertices; - int hole_flag; - gpc_vertex* vertices; - }; - - typedef pod_bvector vertex_array_type; - typedef pod_bvector contour_header_array_type; - - - public: - typedef VSA source_a_type; - typedef VSB source_b_type; - typedef conv_gpc self_type; - - ~conv_gpc() - { - free_gpc_data(); - } - - conv_gpc(source_a_type& a, source_b_type& b, gpc_op_e op = gpc_or) : - m_src_a(&a), - m_src_b(&b), - m_status(status_move_to), - m_vertex(-1), - m_contour(-1), - m_operation(op) - { - memset(&m_poly_a, 0, sizeof(m_poly_a)); - memset(&m_poly_b, 0, sizeof(m_poly_b)); - memset(&m_result, 0, sizeof(m_result)); - } - - void attach1(VSA& source) { m_src_a = &source; } - void attach2(VSB& source) { m_src_b = &source; } - - void operation(gpc_op_e v) { m_operation = v; } - - // Vertex Source Interface - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - conv_gpc(const conv_gpc&); - const conv_gpc& operator = (const conv_gpc&); - - //-------------------------------------------------------------------- - void free_polygon(gpc_polygon& p); - void free_result(); - void free_gpc_data(); - void start_contour(); - void add_vertex(double x, double y); - void end_contour(unsigned orientation); - void make_polygon(gpc_polygon& p); - void start_extracting(); - bool next_contour(); - bool next_vertex(double* x, double* y); - - - //-------------------------------------------------------------------- - template void add(VS& src, gpc_polygon& p) - { - unsigned cmd; - double x, y; - double start_x = 0.0; - double start_y = 0.0; - bool line_to = false; - unsigned orientation = 0; - - m_contour_accumulator.remove_all(); - - while(!is_stop(cmd = src.vertex(&x, &y))) - { - if(is_vertex(cmd)) - { - if(is_move_to(cmd)) - { - if(line_to) - { - end_contour(orientation); - orientation = 0; - } - start_contour(); - start_x = x; - start_y = y; - } - add_vertex(x, y); - line_to = true; - } - else - { - if(is_end_poly(cmd)) - { - orientation = get_orientation(cmd); - if(line_to && is_closed(cmd)) - { - add_vertex(start_x, start_y); - } - } - } - } - if(line_to) - { - end_contour(orientation); - } - make_polygon(p); - } - - - private: - //-------------------------------------------------------------------- - source_a_type* m_src_a; - source_b_type* m_src_b; - status m_status; - int m_vertex; - int m_contour; - gpc_op_e m_operation; - vertex_array_type m_vertex_accumulator; - contour_header_array_type m_contour_accumulator; - gpc_polygon m_poly_a; - gpc_polygon m_poly_b; - gpc_polygon m_result; - }; - - - - - - //------------------------------------------------------------------------ - template - void conv_gpc::free_polygon(gpc_polygon& p) - { - int i; - for(i = 0; i < p.num_contours; i++) - { - pod_allocator::deallocate(p.contour[i].vertex, - p.contour[i].num_vertices); - } - pod_allocator::deallocate(p.contour, p.num_contours); - memset(&p, 0, sizeof(gpc_polygon)); - } - - - //------------------------------------------------------------------------ - template - void conv_gpc::free_result() - { - if(m_result.contour) - { - gpc_free_polygon(&m_result); - } - memset(&m_result, 0, sizeof(m_result)); - } - - - //------------------------------------------------------------------------ - template - void conv_gpc::free_gpc_data() - { - free_polygon(m_poly_a); - free_polygon(m_poly_b); - free_result(); - } - - - //------------------------------------------------------------------------ - template - void conv_gpc::start_contour() - { - contour_header_type h; - memset(&h, 0, sizeof(h)); - m_contour_accumulator.add(h); - m_vertex_accumulator.remove_all(); - } - - - //------------------------------------------------------------------------ - template - inline void conv_gpc::add_vertex(double x, double y) - { - gpc_vertex v; - v.x = x; - v.y = y; - m_vertex_accumulator.add(v); - } - - - //------------------------------------------------------------------------ - template - void conv_gpc::end_contour(unsigned /*orientation*/) - { - if(m_contour_accumulator.size()) - { - if(m_vertex_accumulator.size() > 2) - { - contour_header_type& h = - m_contour_accumulator[m_contour_accumulator.size() - 1]; - - h.num_vertices = m_vertex_accumulator.size(); - h.hole_flag = 0; - - // TO DO: Clarify the "holes" - //if(is_cw(orientation)) h.hole_flag = 1; - - h.vertices = pod_allocator::allocate(h.num_vertices); - gpc_vertex* d = h.vertices; - int i; - for(i = 0; i < h.num_vertices; i++) - { - const gpc_vertex& s = m_vertex_accumulator[i]; - d->x = s.x; - d->y = s.y; - ++d; - } - } - else - { - m_vertex_accumulator.remove_last(); - } - } - } - - - //------------------------------------------------------------------------ - template - void conv_gpc::make_polygon(gpc_polygon& p) - { - free_polygon(p); - if(m_contour_accumulator.size()) - { - p.num_contours = m_contour_accumulator.size(); - - p.hole = 0; - p.contour = pod_allocator::allocate(p.num_contours); - - int i; - gpc_vertex_list* pv = p.contour; - for(i = 0; i < p.num_contours; i++) - { - const contour_header_type& h = m_contour_accumulator[i]; - pv->num_vertices = h.num_vertices; - pv->vertex = h.vertices; - ++pv; - } - } - } - - - //------------------------------------------------------------------------ - template - void conv_gpc::start_extracting() - { - m_status = status_move_to; - m_contour = -1; - m_vertex = -1; - } - - - //------------------------------------------------------------------------ - template - bool conv_gpc::next_contour() - { - if(++m_contour < m_result.num_contours) - { - m_vertex = -1; - return true; - } - return false; - } - - - //------------------------------------------------------------------------ - template - inline bool conv_gpc::next_vertex(double* x, double* y) - { - const gpc_vertex_list& vlist = m_result.contour[m_contour]; - if(++m_vertex < vlist.num_vertices) - { - const gpc_vertex& v = vlist.vertex[m_vertex]; - *x = v.x; - *y = v.y; - return true; - } - return false; - } - - - //------------------------------------------------------------------------ - template - void conv_gpc::rewind(unsigned path_id) - { - free_result(); - m_src_a->rewind(path_id); - m_src_b->rewind(path_id); - add(*m_src_a, m_poly_a); - add(*m_src_b, m_poly_b); - switch(m_operation) - { - case gpc_or: - gpc_polygon_clip(GPC_UNION, - &m_poly_a, - &m_poly_b, - &m_result); - break; - - case gpc_and: - gpc_polygon_clip(GPC_INT, - &m_poly_a, - &m_poly_b, - &m_result); - break; - - case gpc_xor: - gpc_polygon_clip(GPC_XOR, - &m_poly_a, - &m_poly_b, - &m_result); - break; - - case gpc_a_minus_b: - gpc_polygon_clip(GPC_DIFF, - &m_poly_a, - &m_poly_b, - &m_result); - break; - - case gpc_b_minus_a: - gpc_polygon_clip(GPC_DIFF, - &m_poly_b, - &m_poly_a, - &m_result); - break; - } - start_extracting(); - } - - - //------------------------------------------------------------------------ - template - unsigned conv_gpc::vertex(double* x, double* y) - { - if(m_status == status_move_to) - { - if(next_contour()) - { - if(next_vertex(x, y)) - { - m_status = status_line_to; - return path_cmd_move_to; - } - m_status = status_stop; - return path_cmd_end_poly | path_flags_close; - } - } - else - { - if(next_vertex(x, y)) - { - return path_cmd_line_to; - } - else - { - m_status = status_move_to; - } - return path_cmd_end_poly | path_flags_close; - } - return path_cmd_stop; - } - - -} - - -#endif diff --git a/xs/src/agg/agg_conv_marker.h b/xs/src/agg/agg_conv_marker.h deleted file mode 100644 index 2cd3cb403f..0000000000 --- a/xs/src/agg/agg_conv_marker.h +++ /dev/null @@ -1,148 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// conv_marker -// -//---------------------------------------------------------------------------- -#ifndef AGG_CONV_MARKER_INCLUDED -#define AGG_CONV_MARKER_INCLUDED - -#include "agg_basics.h" -#include "agg_trans_affine.h" - -namespace agg -{ - //-------------------------------------------------------------conv_marker - template - class conv_marker - { - public: - conv_marker(MarkerLocator& ml, MarkerShapes& ms); - - trans_affine& transform() { return m_transform; } - const trans_affine& transform() const { return m_transform; } - - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - conv_marker(const conv_marker&); - const conv_marker& - operator = (const conv_marker&); - - enum status_e - { - initial, - markers, - polygon, - stop - }; - - MarkerLocator* m_marker_locator; - MarkerShapes* m_marker_shapes; - trans_affine m_transform; - trans_affine m_mtx; - status_e m_status; - unsigned m_marker; - unsigned m_num_markers; - }; - - - //------------------------------------------------------------------------ - template - conv_marker::conv_marker(MarkerLocator& ml, MarkerShapes& ms) : - m_marker_locator(&ml), - m_marker_shapes(&ms), - m_status(initial), - m_marker(0), - m_num_markers(1) - { - } - - - //------------------------------------------------------------------------ - template - void conv_marker::rewind(unsigned) - { - m_status = initial; - m_marker = 0; - m_num_markers = 1; - } - - - //------------------------------------------------------------------------ - template - unsigned conv_marker::vertex(double* x, double* y) - { - unsigned cmd = path_cmd_move_to; - double x1, y1, x2, y2; - - while(!is_stop(cmd)) - { - switch(m_status) - { - case initial: - if(m_num_markers == 0) - { - cmd = path_cmd_stop; - break; - } - m_marker_locator->rewind(m_marker); - ++m_marker; - m_num_markers = 0; - m_status = markers; - - case markers: - if(is_stop(m_marker_locator->vertex(&x1, &y1))) - { - m_status = initial; - break; - } - if(is_stop(m_marker_locator->vertex(&x2, &y2))) - { - m_status = initial; - break; - } - ++m_num_markers; - m_mtx = m_transform; - m_mtx *= trans_affine_rotation(atan2(y2 - y1, x2 - x1)); - m_mtx *= trans_affine_translation(x1, y1); - m_marker_shapes->rewind(m_marker - 1); - m_status = polygon; - - case polygon: - cmd = m_marker_shapes->vertex(x, y); - if(is_stop(cmd)) - { - cmd = path_cmd_move_to; - m_status = markers; - break; - } - m_mtx.transform(x, y); - return cmd; - - case stop: - cmd = path_cmd_stop; - break; - } - } - return cmd; - } - -} - - -#endif - diff --git a/xs/src/agg/agg_conv_marker_adaptor.h b/xs/src/agg/agg_conv_marker_adaptor.h deleted file mode 100644 index 4486d6ace9..0000000000 --- a/xs/src/agg/agg_conv_marker_adaptor.h +++ /dev/null @@ -1,51 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_MARKER_ADAPTOR_INCLUDED -#define AGG_CONV_MARKER_ADAPTOR_INCLUDED - -#include "agg_basics.h" -#include "agg_conv_adaptor_vcgen.h" -#include "agg_vcgen_vertex_sequence.h" - -namespace agg -{ - - //=====================================================conv_marker_adaptor - template - struct conv_marker_adaptor : - public conv_adaptor_vcgen - { - typedef Markers marker_type; - typedef conv_adaptor_vcgen base_type; - - conv_marker_adaptor(VertexSource& vs) : - conv_adaptor_vcgen(vs) - { - } - - void shorten(double s) { base_type::generator().shorten(s); } - double shorten() const { return base_type::generator().shorten(); } - - private: - conv_marker_adaptor(const conv_marker_adaptor&); - const conv_marker_adaptor& - operator = (const conv_marker_adaptor&); - }; - - -} - -#endif diff --git a/xs/src/agg/agg_conv_segmentator.h b/xs/src/agg/agg_conv_segmentator.h deleted file mode 100644 index e69a9e7d7d..0000000000 --- a/xs/src/agg/agg_conv_segmentator.h +++ /dev/null @@ -1,48 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_SEGMENTATOR_INCLUDED -#define AGG_CONV_SEGMENTATOR_INCLUDED - -#include "agg_basics.h" -#include "agg_conv_adaptor_vpgen.h" -#include "agg_vpgen_segmentator.h" - -namespace agg -{ - - //========================================================conv_segmentator - template - struct conv_segmentator : public conv_adaptor_vpgen - { - typedef conv_adaptor_vpgen base_type; - - conv_segmentator(VertexSource& vs) : - conv_adaptor_vpgen(vs) {} - - void approximation_scale(double s) { base_type::vpgen().approximation_scale(s); } - double approximation_scale() const { return base_type::vpgen().approximation_scale(); } - - private: - conv_segmentator(const conv_segmentator&); - const conv_segmentator& - operator = (const conv_segmentator&); - }; - - -} - -#endif - diff --git a/xs/src/agg/agg_conv_shorten_path.h b/xs/src/agg/agg_conv_shorten_path.h deleted file mode 100644 index 5617e51d17..0000000000 --- a/xs/src/agg/agg_conv_shorten_path.h +++ /dev/null @@ -1,50 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_SHORTEN_PATH_INCLUDED -#define AGG_CONV_SHORTEN_PATH_INCLUDED - -#include "agg_basics.h" -#include "agg_conv_adaptor_vcgen.h" -#include "agg_vcgen_vertex_sequence.h" - -namespace agg -{ - - //=======================================================conv_shorten_path - template class conv_shorten_path : - public conv_adaptor_vcgen - { - public: - typedef conv_adaptor_vcgen base_type; - - conv_shorten_path(VertexSource& vs) : - conv_adaptor_vcgen(vs) - { - } - - void shorten(double s) { base_type::generator().shorten(s); } - double shorten() const { return base_type::generator().shorten(); } - - private: - conv_shorten_path(const conv_shorten_path&); - const conv_shorten_path& - operator = (const conv_shorten_path&); - }; - - -} - -#endif diff --git a/xs/src/agg/agg_conv_smooth_poly1.h b/xs/src/agg/agg_conv_smooth_poly1.h deleted file mode 100644 index 4ac4e3d6e2..0000000000 --- a/xs/src/agg/agg_conv_smooth_poly1.h +++ /dev/null @@ -1,80 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Smooth polygon generator -// -//---------------------------------------------------------------------------- -#ifndef AGG_CONV_SMOOTH_POLY1_INCLUDED -#define AGG_CONV_SMOOTH_POLY1_INCLUDED - -#include "agg_basics.h" -#include "agg_vcgen_smooth_poly1.h" -#include "agg_conv_adaptor_vcgen.h" -#include "agg_conv_curve.h" - - -namespace agg -{ - - //-------------------------------------------------------conv_smooth_poly1 - template - struct conv_smooth_poly1 : - public conv_adaptor_vcgen - { - typedef conv_adaptor_vcgen base_type; - - conv_smooth_poly1(VertexSource& vs) : - conv_adaptor_vcgen(vs) - { - } - - void smooth_value(double v) { base_type::generator().smooth_value(v); } - double smooth_value() const { return base_type::generator().smooth_value(); } - - private: - conv_smooth_poly1(const conv_smooth_poly1&); - const conv_smooth_poly1& - operator = (const conv_smooth_poly1&); - }; - - - - //-------------------------------------------------conv_smooth_poly1_curve - template - struct conv_smooth_poly1_curve : - public conv_curve > - { - conv_smooth_poly1_curve(VertexSource& vs) : - conv_curve >(m_smooth), - m_smooth(vs) - { - } - - void smooth_value(double v) { m_smooth.generator().smooth_value(v); } - double smooth_value() const { return m_smooth.generator().smooth_value(); } - - private: - conv_smooth_poly1_curve(const conv_smooth_poly1_curve&); - const conv_smooth_poly1_curve& - operator = (const conv_smooth_poly1_curve&); - - conv_smooth_poly1 m_smooth; - }; - -} - - -#endif - diff --git a/xs/src/agg/agg_conv_stroke.h b/xs/src/agg/agg_conv_stroke.h deleted file mode 100644 index e19a6b61f4..0000000000 --- a/xs/src/agg/agg_conv_stroke.h +++ /dev/null @@ -1,73 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// conv_stroke -// -//---------------------------------------------------------------------------- -#ifndef AGG_CONV_STROKE_INCLUDED -#define AGG_CONV_STROKE_INCLUDED - -#include "agg_basics.h" -#include "agg_vcgen_stroke.h" -#include "agg_conv_adaptor_vcgen.h" - -namespace agg -{ - - //-------------------------------------------------------------conv_stroke - template - struct conv_stroke : - public conv_adaptor_vcgen - { - typedef Markers marker_type; - typedef conv_adaptor_vcgen base_type; - - conv_stroke(VertexSource& vs) : - conv_adaptor_vcgen(vs) - { - } - - void line_cap(line_cap_e lc) { base_type::generator().line_cap(lc); } - void line_join(line_join_e lj) { base_type::generator().line_join(lj); } - void inner_join(inner_join_e ij) { base_type::generator().inner_join(ij); } - - line_cap_e line_cap() const { return base_type::generator().line_cap(); } - line_join_e line_join() const { return base_type::generator().line_join(); } - inner_join_e inner_join() const { return base_type::generator().inner_join(); } - - void width(double w) { base_type::generator().width(w); } - void miter_limit(double ml) { base_type::generator().miter_limit(ml); } - void miter_limit_theta(double t) { base_type::generator().miter_limit_theta(t); } - void inner_miter_limit(double ml) { base_type::generator().inner_miter_limit(ml); } - void approximation_scale(double as) { base_type::generator().approximation_scale(as); } - - double width() const { return base_type::generator().width(); } - double miter_limit() const { return base_type::generator().miter_limit(); } - double inner_miter_limit() const { return base_type::generator().inner_miter_limit(); } - double approximation_scale() const { return base_type::generator().approximation_scale(); } - - void shorten(double s) { base_type::generator().shorten(s); } - double shorten() const { return base_type::generator().shorten(); } - - private: - conv_stroke(const conv_stroke&); - const conv_stroke& - operator = (const conv_stroke&); - - }; - -} - -#endif diff --git a/xs/src/agg/agg_conv_unclose_polygon.h b/xs/src/agg/agg_conv_unclose_polygon.h deleted file mode 100644 index fe5c263810..0000000000 --- a/xs/src/agg/agg_conv_unclose_polygon.h +++ /dev/null @@ -1,52 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CONV_UNCLOSE_POLYGON_INCLUDED -#define AGG_CONV_UNCLOSE_POLYGON_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - //====================================================conv_unclose_polygon - template class conv_unclose_polygon - { - public: - explicit conv_unclose_polygon(VertexSource& vs) : m_source(&vs) {} - void attach(VertexSource& source) { m_source = &source; } - - void rewind(unsigned path_id) - { - m_source->rewind(path_id); - } - - unsigned vertex(double* x, double* y) - { - unsigned cmd = m_source->vertex(x, y); - if(is_end_poly(cmd)) cmd &= ~path_flags_close; - return cmd; - } - - private: - conv_unclose_polygon(const conv_unclose_polygon&); - const conv_unclose_polygon& - operator = (const conv_unclose_polygon&); - - VertexSource* m_source; - }; - -} - -#endif diff --git a/xs/src/agg/agg_curves.h b/xs/src/agg/agg_curves.h deleted file mode 100644 index 1ef02e8783..0000000000 --- a/xs/src/agg/agg_curves.h +++ /dev/null @@ -1,693 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// Copyright (C) 2005 Tony Juricic (tonygeek@yahoo.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_CURVES_INCLUDED -#define AGG_CURVES_INCLUDED - -#include "agg_array.h" - -namespace agg -{ - - // See Implementation agg_curves.cpp - - //--------------------------------------------curve_approximation_method_e - enum curve_approximation_method_e - { - curve_inc, - curve_div - }; - - //--------------------------------------------------------------curve3_inc - class curve3_inc - { - public: - curve3_inc() : - m_num_steps(0), m_step(0), m_scale(1.0) { } - - curve3_inc(double x1, double y1, - double x2, double y2, - double x3, double y3) : - m_num_steps(0), m_step(0), m_scale(1.0) - { - init(x1, y1, x2, y2, x3, y3); - } - - void reset() { m_num_steps = 0; m_step = -1; } - void init(double x1, double y1, - double x2, double y2, - double x3, double y3); - - void approximation_method(curve_approximation_method_e) {} - curve_approximation_method_e approximation_method() const { return curve_inc; } - - void approximation_scale(double s); - double approximation_scale() const; - - void angle_tolerance(double) {} - double angle_tolerance() const { return 0.0; } - - void cusp_limit(double) {} - double cusp_limit() const { return 0.0; } - - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - int m_num_steps; - int m_step; - double m_scale; - double m_start_x; - double m_start_y; - double m_end_x; - double m_end_y; - double m_fx; - double m_fy; - double m_dfx; - double m_dfy; - double m_ddfx; - double m_ddfy; - double m_saved_fx; - double m_saved_fy; - double m_saved_dfx; - double m_saved_dfy; - }; - - - - - - //-------------------------------------------------------------curve3_div - class curve3_div - { - public: - curve3_div() : - m_approximation_scale(1.0), - m_angle_tolerance(0.0), - m_count(0) - {} - - curve3_div(double x1, double y1, - double x2, double y2, - double x3, double y3) : - m_approximation_scale(1.0), - m_angle_tolerance(0.0), - m_count(0) - { - init(x1, y1, x2, y2, x3, y3); - } - - void reset() { m_points.remove_all(); m_count = 0; } - void init(double x1, double y1, - double x2, double y2, - double x3, double y3); - - void approximation_method(curve_approximation_method_e) {} - curve_approximation_method_e approximation_method() const { return curve_div; } - - void approximation_scale(double s) { m_approximation_scale = s; } - double approximation_scale() const { return m_approximation_scale; } - - void angle_tolerance(double a) { m_angle_tolerance = a; } - double angle_tolerance() const { return m_angle_tolerance; } - - void cusp_limit(double) {} - double cusp_limit() const { return 0.0; } - - void rewind(unsigned) - { - m_count = 0; - } - - unsigned vertex(double* x, double* y) - { - if(m_count >= m_points.size()) return path_cmd_stop; - const point_d& p = m_points[m_count++]; - *x = p.x; - *y = p.y; - return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; - } - - private: - void bezier(double x1, double y1, - double x2, double y2, - double x3, double y3); - void recursive_bezier(double x1, double y1, - double x2, double y2, - double x3, double y3, - unsigned level); - - double m_approximation_scale; - double m_distance_tolerance_square; - double m_angle_tolerance; - unsigned m_count; - pod_bvector m_points; - }; - - - - - - - - //-------------------------------------------------------------curve4_points - struct curve4_points - { - double cp[8]; - curve4_points() {} - curve4_points(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) - { - cp[0] = x1; cp[1] = y1; cp[2] = x2; cp[3] = y2; - cp[4] = x3; cp[5] = y3; cp[6] = x4; cp[7] = y4; - } - void init(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) - { - cp[0] = x1; cp[1] = y1; cp[2] = x2; cp[3] = y2; - cp[4] = x3; cp[5] = y3; cp[6] = x4; cp[7] = y4; - } - double operator [] (unsigned i) const { return cp[i]; } - double& operator [] (unsigned i) { return cp[i]; } - }; - - - - //-------------------------------------------------------------curve4_inc - class curve4_inc - { - public: - curve4_inc() : - m_num_steps(0), m_step(0), m_scale(1.0) { } - - curve4_inc(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) : - m_num_steps(0), m_step(0), m_scale(1.0) - { - init(x1, y1, x2, y2, x3, y3, x4, y4); - } - - curve4_inc(const curve4_points& cp) : - m_num_steps(0), m_step(0), m_scale(1.0) - { - init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); - } - - void reset() { m_num_steps = 0; m_step = -1; } - void init(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4); - - void init(const curve4_points& cp) - { - init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); - } - - void approximation_method(curve_approximation_method_e) {} - curve_approximation_method_e approximation_method() const { return curve_inc; } - - void approximation_scale(double s); - double approximation_scale() const; - - void angle_tolerance(double) {} - double angle_tolerance() const { return 0.0; } - - void cusp_limit(double) {} - double cusp_limit() const { return 0.0; } - - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - int m_num_steps; - int m_step; - double m_scale; - double m_start_x; - double m_start_y; - double m_end_x; - double m_end_y; - double m_fx; - double m_fy; - double m_dfx; - double m_dfy; - double m_ddfx; - double m_ddfy; - double m_dddfx; - double m_dddfy; - double m_saved_fx; - double m_saved_fy; - double m_saved_dfx; - double m_saved_dfy; - double m_saved_ddfx; - double m_saved_ddfy; - }; - - - - //-------------------------------------------------------catrom_to_bezier - inline curve4_points catrom_to_bezier(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) - { - // Trans. matrix Catmull-Rom to Bezier - // - // 0 1 0 0 - // -1/6 1 1/6 0 - // 0 1/6 1 -1/6 - // 0 0 1 0 - // - return curve4_points( - x2, - y2, - (-x1 + 6*x2 + x3) / 6, - (-y1 + 6*y2 + y3) / 6, - ( x2 + 6*x3 - x4) / 6, - ( y2 + 6*y3 - y4) / 6, - x3, - y3); - } - - - //----------------------------------------------------------------------- - inline curve4_points - catrom_to_bezier(const curve4_points& cp) - { - return catrom_to_bezier(cp[0], cp[1], cp[2], cp[3], - cp[4], cp[5], cp[6], cp[7]); - } - - - - //-----------------------------------------------------ubspline_to_bezier - inline curve4_points ubspline_to_bezier(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) - { - // Trans. matrix Uniform BSpline to Bezier - // - // 1/6 4/6 1/6 0 - // 0 4/6 2/6 0 - // 0 2/6 4/6 0 - // 0 1/6 4/6 1/6 - // - return curve4_points( - (x1 + 4*x2 + x3) / 6, - (y1 + 4*y2 + y3) / 6, - (4*x2 + 2*x3) / 6, - (4*y2 + 2*y3) / 6, - (2*x2 + 4*x3) / 6, - (2*y2 + 4*y3) / 6, - (x2 + 4*x3 + x4) / 6, - (y2 + 4*y3 + y4) / 6); - } - - - //----------------------------------------------------------------------- - inline curve4_points - ubspline_to_bezier(const curve4_points& cp) - { - return ubspline_to_bezier(cp[0], cp[1], cp[2], cp[3], - cp[4], cp[5], cp[6], cp[7]); - } - - - - - //------------------------------------------------------hermite_to_bezier - inline curve4_points hermite_to_bezier(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) - { - // Trans. matrix Hermite to Bezier - // - // 1 0 0 0 - // 1 0 1/3 0 - // 0 1 0 -1/3 - // 0 1 0 0 - // - return curve4_points( - x1, - y1, - (3*x1 + x3) / 3, - (3*y1 + y3) / 3, - (3*x2 - x4) / 3, - (3*y2 - y4) / 3, - x2, - y2); - } - - - - //----------------------------------------------------------------------- - inline curve4_points - hermite_to_bezier(const curve4_points& cp) - { - return hermite_to_bezier(cp[0], cp[1], cp[2], cp[3], - cp[4], cp[5], cp[6], cp[7]); - } - - - //-------------------------------------------------------------curve4_div - class curve4_div - { - public: - curve4_div() : - m_approximation_scale(1.0), - m_angle_tolerance(0.0), - m_cusp_limit(0.0), - m_count(0) - {} - - curve4_div(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) : - m_approximation_scale(1.0), - m_angle_tolerance(0.0), - m_cusp_limit(0.0), - m_count(0) - { - init(x1, y1, x2, y2, x3, y3, x4, y4); - } - - curve4_div(const curve4_points& cp) : - m_approximation_scale(1.0), - m_angle_tolerance(0.0), - m_count(0) - { - init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); - } - - void reset() { m_points.remove_all(); m_count = 0; } - void init(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4); - - void init(const curve4_points& cp) - { - init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); - } - - void approximation_method(curve_approximation_method_e) {} - - curve_approximation_method_e approximation_method() const - { - return curve_div; - } - - void approximation_scale(double s) { m_approximation_scale = s; } - double approximation_scale() const { return m_approximation_scale; } - - void angle_tolerance(double a) { m_angle_tolerance = a; } - double angle_tolerance() const { return m_angle_tolerance; } - - void cusp_limit(double v) - { - m_cusp_limit = (v == 0.0) ? 0.0 : pi - v; - } - - double cusp_limit() const - { - return (m_cusp_limit == 0.0) ? 0.0 : pi - m_cusp_limit; - } - - void rewind(unsigned) - { - m_count = 0; - } - - unsigned vertex(double* x, double* y) - { - if(m_count >= m_points.size()) return path_cmd_stop; - const point_d& p = m_points[m_count++]; - *x = p.x; - *y = p.y; - return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; - } - - private: - void bezier(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4); - - void recursive_bezier(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4, - unsigned level); - - double m_approximation_scale; - double m_distance_tolerance_square; - double m_angle_tolerance; - double m_cusp_limit; - unsigned m_count; - pod_bvector m_points; - }; - - - //-----------------------------------------------------------------curve3 - class curve3 - { - public: - curve3() : m_approximation_method(curve_div) {} - curve3(double x1, double y1, - double x2, double y2, - double x3, double y3) : - m_approximation_method(curve_div) - { - init(x1, y1, x2, y2, x3, y3); - } - - void reset() - { - m_curve_inc.reset(); - m_curve_div.reset(); - } - - void init(double x1, double y1, - double x2, double y2, - double x3, double y3) - { - if(m_approximation_method == curve_inc) - { - m_curve_inc.init(x1, y1, x2, y2, x3, y3); - } - else - { - m_curve_div.init(x1, y1, x2, y2, x3, y3); - } - } - - void approximation_method(curve_approximation_method_e v) - { - m_approximation_method = v; - } - - curve_approximation_method_e approximation_method() const - { - return m_approximation_method; - } - - void approximation_scale(double s) - { - m_curve_inc.approximation_scale(s); - m_curve_div.approximation_scale(s); - } - - double approximation_scale() const - { - return m_curve_inc.approximation_scale(); - } - - void angle_tolerance(double a) - { - m_curve_div.angle_tolerance(a); - } - - double angle_tolerance() const - { - return m_curve_div.angle_tolerance(); - } - - void cusp_limit(double v) - { - m_curve_div.cusp_limit(v); - } - - double cusp_limit() const - { - return m_curve_div.cusp_limit(); - } - - void rewind(unsigned path_id) - { - if(m_approximation_method == curve_inc) - { - m_curve_inc.rewind(path_id); - } - else - { - m_curve_div.rewind(path_id); - } - } - - unsigned vertex(double* x, double* y) - { - if(m_approximation_method == curve_inc) - { - return m_curve_inc.vertex(x, y); - } - return m_curve_div.vertex(x, y); - } - - private: - curve3_inc m_curve_inc; - curve3_div m_curve_div; - curve_approximation_method_e m_approximation_method; - }; - - - - - - //-----------------------------------------------------------------curve4 - class curve4 - { - public: - curve4() : m_approximation_method(curve_div) {} - curve4(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) : - m_approximation_method(curve_div) - { - init(x1, y1, x2, y2, x3, y3, x4, y4); - } - - curve4(const curve4_points& cp) : - m_approximation_method(curve_div) - { - init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); - } - - void reset() - { - m_curve_inc.reset(); - m_curve_div.reset(); - } - - void init(double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4) - { - if(m_approximation_method == curve_inc) - { - m_curve_inc.init(x1, y1, x2, y2, x3, y3, x4, y4); - } - else - { - m_curve_div.init(x1, y1, x2, y2, x3, y3, x4, y4); - } - } - - void init(const curve4_points& cp) - { - init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); - } - - void approximation_method(curve_approximation_method_e v) - { - m_approximation_method = v; - } - - curve_approximation_method_e approximation_method() const - { - return m_approximation_method; - } - - void approximation_scale(double s) - { - m_curve_inc.approximation_scale(s); - m_curve_div.approximation_scale(s); - } - double approximation_scale() const { return m_curve_inc.approximation_scale(); } - - void angle_tolerance(double v) - { - m_curve_div.angle_tolerance(v); - } - - double angle_tolerance() const - { - return m_curve_div.angle_tolerance(); - } - - void cusp_limit(double v) - { - m_curve_div.cusp_limit(v); - } - - double cusp_limit() const - { - return m_curve_div.cusp_limit(); - } - - void rewind(unsigned path_id) - { - if(m_approximation_method == curve_inc) - { - m_curve_inc.rewind(path_id); - } - else - { - m_curve_div.rewind(path_id); - } - } - - unsigned vertex(double* x, double* y) - { - if(m_approximation_method == curve_inc) - { - return m_curve_inc.vertex(x, y); - } - return m_curve_div.vertex(x, y); - } - - private: - curve4_inc m_curve_inc; - curve4_div m_curve_div; - curve_approximation_method_e m_approximation_method; - }; - - - - -} - -#endif diff --git a/xs/src/agg/agg_dda_line.h b/xs/src/agg/agg_dda_line.h deleted file mode 100644 index f589e76b83..0000000000 --- a/xs/src/agg/agg_dda_line.h +++ /dev/null @@ -1,290 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// classes dda_line_interpolator, dda2_line_interpolator -// -//---------------------------------------------------------------------------- - -#ifndef AGG_DDA_LINE_INCLUDED -#define AGG_DDA_LINE_INCLUDED - -#include -#include "agg_basics.h" - -namespace agg -{ - - //===================================================dda_line_interpolator - template class dda_line_interpolator - { - public: - //-------------------------------------------------------------------- - dda_line_interpolator() {} - - //-------------------------------------------------------------------- - dda_line_interpolator(int y1, int y2, unsigned count) : - m_y(y1), - m_inc(((y2 - y1) << FractionShift) / int(count)), - m_dy(0) - { - } - - //-------------------------------------------------------------------- - void operator ++ () - { - m_dy += m_inc; - } - - //-------------------------------------------------------------------- - void operator -- () - { - m_dy -= m_inc; - } - - //-------------------------------------------------------------------- - void operator += (unsigned n) - { - m_dy += m_inc * n; - } - - //-------------------------------------------------------------------- - void operator -= (unsigned n) - { - m_dy -= m_inc * n; - } - - - //-------------------------------------------------------------------- - int y() const { return m_y + (m_dy >> (FractionShift-YShift)); } - int dy() const { return m_dy; } - - - private: - int m_y; - int m_inc; - int m_dy; - }; - - - - - - //=================================================dda2_line_interpolator - class dda2_line_interpolator - { - public: - typedef int save_data_type; - enum save_size_e { save_size = 2 }; - - //-------------------------------------------------------------------- - dda2_line_interpolator() {} - - //-------------------------------------------- Forward-adjusted line - dda2_line_interpolator(int y1, int y2, int count) : - m_cnt(count <= 0 ? 1 : count), - m_lft((y2 - y1) / m_cnt), - m_rem((y2 - y1) % m_cnt), - m_mod(m_rem), - m_y(y1) - { - if(m_mod <= 0) - { - m_mod += count; - m_rem += count; - m_lft--; - } - m_mod -= count; - } - - //-------------------------------------------- Backward-adjusted line - dda2_line_interpolator(int y1, int y2, int count, int) : - m_cnt(count <= 0 ? 1 : count), - m_lft((y2 - y1) / m_cnt), - m_rem((y2 - y1) % m_cnt), - m_mod(m_rem), - m_y(y1) - { - if(m_mod <= 0) - { - m_mod += count; - m_rem += count; - m_lft--; - } - } - - //-------------------------------------------- Backward-adjusted line - dda2_line_interpolator(int y, int count) : - m_cnt(count <= 0 ? 1 : count), - m_lft(y / m_cnt), - m_rem(y % m_cnt), - m_mod(m_rem), - m_y(0) - { - if(m_mod <= 0) - { - m_mod += count; - m_rem += count; - m_lft--; - } - } - - - //-------------------------------------------------------------------- - void save(save_data_type* data) const - { - data[0] = m_mod; - data[1] = m_y; - } - - //-------------------------------------------------------------------- - void load(const save_data_type* data) - { - m_mod = data[0]; - m_y = data[1]; - } - - //-------------------------------------------------------------------- - void operator++() - { - m_mod += m_rem; - m_y += m_lft; - if(m_mod > 0) - { - m_mod -= m_cnt; - m_y++; - } - } - - //-------------------------------------------------------------------- - void operator--() - { - if(m_mod <= m_rem) - { - m_mod += m_cnt; - m_y--; - } - m_mod -= m_rem; - m_y -= m_lft; - } - - //-------------------------------------------------------------------- - void adjust_forward() - { - m_mod -= m_cnt; - } - - //-------------------------------------------------------------------- - void adjust_backward() - { - m_mod += m_cnt; - } - - //-------------------------------------------------------------------- - int mod() const { return m_mod; } - int rem() const { return m_rem; } - int lft() const { return m_lft; } - - //-------------------------------------------------------------------- - int y() const { return m_y; } - - private: - int m_cnt; - int m_lft; - int m_rem; - int m_mod; - int m_y; - }; - - - - - - - - //---------------------------------------------line_bresenham_interpolator - class line_bresenham_interpolator - { - public: - enum subpixel_scale_e - { - subpixel_shift = 8, - subpixel_scale = 1 << subpixel_shift, - subpixel_mask = subpixel_scale - 1 - }; - - //-------------------------------------------------------------------- - static int line_lr(int v) { return v >> subpixel_shift; } - - //-------------------------------------------------------------------- - line_bresenham_interpolator(int x1, int y1, int x2, int y2) : - m_x1_lr(line_lr(x1)), - m_y1_lr(line_lr(y1)), - m_x2_lr(line_lr(x2)), - m_y2_lr(line_lr(y2)), - m_ver(abs(m_x2_lr - m_x1_lr) < abs(m_y2_lr - m_y1_lr)), - m_len(m_ver ? abs(m_y2_lr - m_y1_lr) : - abs(m_x2_lr - m_x1_lr)), - m_inc(m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1)), - m_interpolator(m_ver ? x1 : y1, - m_ver ? x2 : y2, - m_len) - { - } - - //-------------------------------------------------------------------- - bool is_ver() const { return m_ver; } - unsigned len() const { return m_len; } - int inc() const { return m_inc; } - - //-------------------------------------------------------------------- - void hstep() - { - ++m_interpolator; - m_x1_lr += m_inc; - } - - //-------------------------------------------------------------------- - void vstep() - { - ++m_interpolator; - m_y1_lr += m_inc; - } - - //-------------------------------------------------------------------- - int x1() const { return m_x1_lr; } - int y1() const { return m_y1_lr; } - int x2() const { return line_lr(m_interpolator.y()); } - int y2() const { return line_lr(m_interpolator.y()); } - int x2_hr() const { return m_interpolator.y(); } - int y2_hr() const { return m_interpolator.y(); } - - private: - int m_x1_lr; - int m_y1_lr; - int m_x2_lr; - int m_y2_lr; - bool m_ver; - unsigned m_len; - int m_inc; - dda2_line_interpolator m_interpolator; - - }; - - -} - - - -#endif diff --git a/xs/src/agg/agg_ellipse.h b/xs/src/agg/agg_ellipse.h deleted file mode 100644 index e78ce27dd9..0000000000 --- a/xs/src/agg/agg_ellipse.h +++ /dev/null @@ -1,123 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// class ellipse -// -//---------------------------------------------------------------------------- - -#ifndef AGG_ELLIPSE_INCLUDED -#define AGG_ELLIPSE_INCLUDED - -#include "agg_basics.h" -#include - -namespace agg -{ - - //----------------------------------------------------------------ellipse - class ellipse - { - public: - ellipse() : - m_x(0.0), m_y(0.0), m_rx(1.0), m_ry(1.0), m_scale(1.0), - m_num(4), m_step(0), m_cw(false) {} - - ellipse(double x, double y, double rx, double ry, - unsigned num_steps=0, bool cw=false) : - m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0), - m_num(num_steps), m_step(0), m_cw(cw) - { - if(m_num == 0) calc_num_steps(); - } - - void init(double x, double y, double rx, double ry, - unsigned num_steps=0, bool cw=false); - - void approximation_scale(double scale); - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - void calc_num_steps(); - - double m_x; - double m_y; - double m_rx; - double m_ry; - double m_scale; - unsigned m_num; - unsigned m_step; - bool m_cw; - }; - - //------------------------------------------------------------------------ - inline void ellipse::init(double x, double y, double rx, double ry, - unsigned num_steps, bool cw) - { - m_x = x; - m_y = y; - m_rx = rx; - m_ry = ry; - m_num = num_steps; - m_step = 0; - m_cw = cw; - if(m_num == 0) calc_num_steps(); - } - - //------------------------------------------------------------------------ - inline void ellipse::approximation_scale(double scale) - { - m_scale = scale; - calc_num_steps(); - } - - //------------------------------------------------------------------------ - inline void ellipse::calc_num_steps() - { - double ra = (fabs(m_rx) + fabs(m_ry)) / 2; - double da = acos(ra / (ra + 0.125 / m_scale)) * 2; - m_num = uround(2*pi / da); - } - - //------------------------------------------------------------------------ - inline void ellipse::rewind(unsigned) - { - m_step = 0; - } - - //------------------------------------------------------------------------ - inline unsigned ellipse::vertex(double* x, double* y) - { - if(m_step == m_num) - { - ++m_step; - return path_cmd_end_poly | path_flags_close | path_flags_ccw; - } - if(m_step > m_num) return path_cmd_stop; - double angle = double(m_step) / double(m_num) * 2.0 * pi; - if(m_cw) angle = 2.0 * pi - angle; - *x = m_x + cos(angle) * m_rx; - *y = m_y + sin(angle) * m_ry; - m_step++; - return ((m_step == 1) ? path_cmd_move_to : path_cmd_line_to); - } - -} - - - -#endif - - diff --git a/xs/src/agg/agg_ellipse_bresenham.h b/xs/src/agg/agg_ellipse_bresenham.h deleted file mode 100644 index ee3b9c4638..0000000000 --- a/xs/src/agg/agg_ellipse_bresenham.h +++ /dev/null @@ -1,113 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Simple Bresenham interpolator for ellipsees -// -//---------------------------------------------------------------------------- - -#ifndef AGG_ELLIPSE_BRESENHAM_INCLUDED -#define AGG_ELLIPSE_BRESENHAM_INCLUDED - - -#include "agg_basics.h" - - -namespace agg -{ - - //------------------------------------------ellipse_bresenham_interpolator - class ellipse_bresenham_interpolator - { - public: - ellipse_bresenham_interpolator(int rx, int ry) : - m_rx2(rx * rx), - m_ry2(ry * ry), - m_two_rx2(m_rx2 << 1), - m_two_ry2(m_ry2 << 1), - m_dx(0), - m_dy(0), - m_inc_x(0), - m_inc_y(-ry * m_two_rx2), - m_cur_f(0) - {} - - int dx() const { return m_dx; } - int dy() const { return m_dy; } - - void operator++ () - { - int mx, my, mxy, min_m; - int fx, fy, fxy; - - mx = fx = m_cur_f + m_inc_x + m_ry2; - if(mx < 0) mx = -mx; - - my = fy = m_cur_f + m_inc_y + m_rx2; - if(my < 0) my = -my; - - mxy = fxy = m_cur_f + m_inc_x + m_ry2 + m_inc_y + m_rx2; - if(mxy < 0) mxy = -mxy; - - min_m = mx; - bool flag = true; - - if(min_m > my) - { - min_m = my; - flag = false; - } - - m_dx = m_dy = 0; - - if(min_m > mxy) - { - m_inc_x += m_two_ry2; - m_inc_y += m_two_rx2; - m_cur_f = fxy; - m_dx = 1; - m_dy = 1; - return; - } - - if(flag) - { - m_inc_x += m_two_ry2; - m_cur_f = fx; - m_dx = 1; - return; - } - - m_inc_y += m_two_rx2; - m_cur_f = fy; - m_dy = 1; - } - - private: - int m_rx2; - int m_ry2; - int m_two_rx2; - int m_two_ry2; - int m_dx; - int m_dy; - int m_inc_x; - int m_inc_y; - int m_cur_f; - - }; - -} - -#endif - diff --git a/xs/src/agg/agg_embedded_raster_fonts.h b/xs/src/agg/agg_embedded_raster_fonts.h deleted file mode 100644 index 9d522d671c..0000000000 --- a/xs/src/agg/agg_embedded_raster_fonts.h +++ /dev/null @@ -1,59 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_EMBEDDED_RASTER_FONTS_INCLUDED -#define AGG_EMBEDDED_RASTER_FONTS_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - extern const int8u gse4x6[]; - extern const int8u gse4x8[]; - extern const int8u gse5x7[]; - extern const int8u gse5x9[]; - extern const int8u gse6x12[]; - extern const int8u gse6x9[]; - extern const int8u gse7x11[]; - extern const int8u gse7x11_bold[]; - extern const int8u gse7x15[]; - extern const int8u gse7x15_bold[]; - extern const int8u gse8x16[]; - extern const int8u gse8x16_bold[]; - extern const int8u mcs11_prop[]; - extern const int8u mcs11_prop_condensed[]; - extern const int8u mcs12_prop[]; - extern const int8u mcs13_prop[]; - extern const int8u mcs5x10_mono[]; - extern const int8u mcs5x11_mono[]; - extern const int8u mcs6x10_mono[]; - extern const int8u mcs6x11_mono[]; - extern const int8u mcs7x12_mono_high[]; - extern const int8u mcs7x12_mono_low[]; - extern const int8u verdana12[]; - extern const int8u verdana12_bold[]; - extern const int8u verdana13[]; - extern const int8u verdana13_bold[]; - extern const int8u verdana14[]; - extern const int8u verdana14_bold[]; - extern const int8u verdana16[]; - extern const int8u verdana16_bold[]; - extern const int8u verdana17[]; - extern const int8u verdana17_bold[]; - extern const int8u verdana18[]; - extern const int8u verdana18_bold[]; -} - -#endif diff --git a/xs/src/agg/agg_font_cache_manager.h b/xs/src/agg/agg_font_cache_manager.h deleted file mode 100644 index fe9a9280fa..0000000000 --- a/xs/src/agg/agg_font_cache_manager.h +++ /dev/null @@ -1,409 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_FONT_CACHE_MANAGER_INCLUDED -#define AGG_FONT_CACHE_MANAGER_INCLUDED - -#include -#include "agg_array.h" - -namespace agg -{ - - //---------------------------------------------------------glyph_data_type - enum glyph_data_type - { - glyph_data_invalid = 0, - glyph_data_mono = 1, - glyph_data_gray8 = 2, - glyph_data_outline = 3 - }; - - - //-------------------------------------------------------------glyph_cache - struct glyph_cache - { - unsigned glyph_index; - int8u* data; - unsigned data_size; - glyph_data_type data_type; - rect_i bounds; - double advance_x; - double advance_y; - }; - - - //--------------------------------------------------------------font_cache - class font_cache - { - public: - enum block_size_e { block_size = 16384-16 }; - - //-------------------------------------------------------------------- - font_cache() : - m_allocator(block_size), - m_font_signature(0) - {} - - //-------------------------------------------------------------------- - void signature(const char* font_signature) - { - m_font_signature = (char*)m_allocator.allocate(strlen(font_signature) + 1); - strcpy(m_font_signature, font_signature); - memset(m_glyphs, 0, sizeof(m_glyphs)); - } - - //-------------------------------------------------------------------- - bool font_is(const char* font_signature) const - { - return strcmp(font_signature, m_font_signature) == 0; - } - - //-------------------------------------------------------------------- - const glyph_cache* find_glyph(unsigned glyph_code) const - { - unsigned msb = (glyph_code >> 8) & 0xFF; - if(m_glyphs[msb]) - { - return m_glyphs[msb][glyph_code & 0xFF]; - } - return 0; - } - - //-------------------------------------------------------------------- - glyph_cache* cache_glyph(unsigned glyph_code, - unsigned glyph_index, - unsigned data_size, - glyph_data_type data_type, - const rect_i& bounds, - double advance_x, - double advance_y) - { - unsigned msb = (glyph_code >> 8) & 0xFF; - if(m_glyphs[msb] == 0) - { - m_glyphs[msb] = - (glyph_cache**)m_allocator.allocate(sizeof(glyph_cache*) * 256, - sizeof(glyph_cache*)); - memset(m_glyphs[msb], 0, sizeof(glyph_cache*) * 256); - } - - unsigned lsb = glyph_code & 0xFF; - if(m_glyphs[msb][lsb]) return 0; // Already exists, do not overwrite - - glyph_cache* glyph = - (glyph_cache*)m_allocator.allocate(sizeof(glyph_cache), - sizeof(double)); - - glyph->glyph_index = glyph_index; - glyph->data = m_allocator.allocate(data_size); - glyph->data_size = data_size; - glyph->data_type = data_type; - glyph->bounds = bounds; - glyph->advance_x = advance_x; - glyph->advance_y = advance_y; - return m_glyphs[msb][lsb] = glyph; - } - - private: - block_allocator m_allocator; - glyph_cache** m_glyphs[256]; - char* m_font_signature; - }; - - - - - - - - //---------------------------------------------------------font_cache_pool - class font_cache_pool - { - public: - //-------------------------------------------------------------------- - ~font_cache_pool() - { - unsigned i; - for(i = 0; i < m_num_fonts; ++i) - { - obj_allocator::deallocate(m_fonts[i]); - } - pod_allocator::deallocate(m_fonts, m_max_fonts); - } - - //-------------------------------------------------------------------- - font_cache_pool(unsigned max_fonts=32) : - m_fonts(pod_allocator::allocate(max_fonts)), - m_max_fonts(max_fonts), - m_num_fonts(0), - m_cur_font(0) - {} - - - //-------------------------------------------------------------------- - void font(const char* font_signature, bool reset_cache = false) - { - int idx = find_font(font_signature); - if(idx >= 0) - { - if(reset_cache) - { - obj_allocator::deallocate(m_fonts[idx]); - m_fonts[idx] = obj_allocator::allocate(); - m_fonts[idx]->signature(font_signature); - } - m_cur_font = m_fonts[idx]; - } - else - { - if(m_num_fonts >= m_max_fonts) - { - obj_allocator::deallocate(m_fonts[0]); - memcpy(m_fonts, - m_fonts + 1, - (m_max_fonts - 1) * sizeof(font_cache*)); - m_num_fonts = m_max_fonts - 1; - } - m_fonts[m_num_fonts] = obj_allocator::allocate(); - m_fonts[m_num_fonts]->signature(font_signature); - m_cur_font = m_fonts[m_num_fonts]; - ++m_num_fonts; - } - } - - //-------------------------------------------------------------------- - const font_cache* font() const - { - return m_cur_font; - } - - //-------------------------------------------------------------------- - const glyph_cache* find_glyph(unsigned glyph_code) const - { - if(m_cur_font) return m_cur_font->find_glyph(glyph_code); - return 0; - } - - //-------------------------------------------------------------------- - glyph_cache* cache_glyph(unsigned glyph_code, - unsigned glyph_index, - unsigned data_size, - glyph_data_type data_type, - const rect_i& bounds, - double advance_x, - double advance_y) - { - if(m_cur_font) - { - return m_cur_font->cache_glyph(glyph_code, - glyph_index, - data_size, - data_type, - bounds, - advance_x, - advance_y); - } - return 0; - } - - - //-------------------------------------------------------------------- - int find_font(const char* font_signature) - { - unsigned i; - for(i = 0; i < m_num_fonts; i++) - { - if(m_fonts[i]->font_is(font_signature)) return int(i); - } - return -1; - } - - private: - font_cache** m_fonts; - unsigned m_max_fonts; - unsigned m_num_fonts; - font_cache* m_cur_font; - }; - - - - - //------------------------------------------------------------------------ - enum glyph_rendering - { - glyph_ren_native_mono, - glyph_ren_native_gray8, - glyph_ren_outline, - glyph_ren_agg_mono, - glyph_ren_agg_gray8 - }; - - - - - //------------------------------------------------------font_cache_manager - template class font_cache_manager - { - public: - typedef FontEngine font_engine_type; - typedef font_cache_manager self_type; - typedef typename font_engine_type::path_adaptor_type path_adaptor_type; - typedef typename font_engine_type::gray8_adaptor_type gray8_adaptor_type; - typedef typename gray8_adaptor_type::embedded_scanline gray8_scanline_type; - typedef typename font_engine_type::mono_adaptor_type mono_adaptor_type; - typedef typename mono_adaptor_type::embedded_scanline mono_scanline_type; - - //-------------------------------------------------------------------- - font_cache_manager(font_engine_type& engine, unsigned max_fonts=32) : - m_fonts(max_fonts), - m_engine(engine), - m_change_stamp(-1), - m_prev_glyph(0), - m_last_glyph(0) - {} - - //-------------------------------------------------------------------- - void reset_last_glyph() - { - m_prev_glyph = m_last_glyph = 0; - } - - //-------------------------------------------------------------------- - const glyph_cache* glyph(unsigned glyph_code) - { - synchronize(); - const glyph_cache* gl = m_fonts.find_glyph(glyph_code); - if(gl) - { - m_prev_glyph = m_last_glyph; - return m_last_glyph = gl; - } - else - { - if(m_engine.prepare_glyph(glyph_code)) - { - m_prev_glyph = m_last_glyph; - m_last_glyph = m_fonts.cache_glyph(glyph_code, - m_engine.glyph_index(), - m_engine.data_size(), - m_engine.data_type(), - m_engine.bounds(), - m_engine.advance_x(), - m_engine.advance_y()); - m_engine.write_glyph_to(m_last_glyph->data); - return m_last_glyph; - } - } - return 0; - } - - //-------------------------------------------------------------------- - void init_embedded_adaptors(const glyph_cache* gl, - double x, double y, - double scale=1.0) - { - if(gl) - { - switch(gl->data_type) - { - default: return; - case glyph_data_mono: - m_mono_adaptor.init(gl->data, gl->data_size, x, y); - break; - - case glyph_data_gray8: - m_gray8_adaptor.init(gl->data, gl->data_size, x, y); - break; - - case glyph_data_outline: - m_path_adaptor.init(gl->data, gl->data_size, x, y, scale); - break; - } - } - } - - - //-------------------------------------------------------------------- - path_adaptor_type& path_adaptor() { return m_path_adaptor; } - gray8_adaptor_type& gray8_adaptor() { return m_gray8_adaptor; } - gray8_scanline_type& gray8_scanline() { return m_gray8_scanline; } - mono_adaptor_type& mono_adaptor() { return m_mono_adaptor; } - mono_scanline_type& mono_scanline() { return m_mono_scanline; } - - //-------------------------------------------------------------------- - const glyph_cache* perv_glyph() const { return m_prev_glyph; } - const glyph_cache* last_glyph() const { return m_last_glyph; } - - //-------------------------------------------------------------------- - bool add_kerning(double* x, double* y) - { - if(m_prev_glyph && m_last_glyph) - { - return m_engine.add_kerning(m_prev_glyph->glyph_index, - m_last_glyph->glyph_index, - x, y); - } - return false; - } - - //-------------------------------------------------------------------- - void precache(unsigned from, unsigned to) - { - for(; from <= to; ++from) glyph(from); - } - - //-------------------------------------------------------------------- - void reset_cache() - { - m_fonts.font(m_engine.font_signature(), true); - m_change_stamp = m_engine.change_stamp(); - m_prev_glyph = m_last_glyph = 0; - } - - private: - //-------------------------------------------------------------------- - font_cache_manager(const self_type&); - const self_type& operator = (const self_type&); - - //-------------------------------------------------------------------- - void synchronize() - { - if(m_change_stamp != m_engine.change_stamp()) - { - m_fonts.font(m_engine.font_signature()); - m_change_stamp = m_engine.change_stamp(); - m_prev_glyph = m_last_glyph = 0; - } - } - - font_cache_pool m_fonts; - font_engine_type& m_engine; - int m_change_stamp; - double m_dx; - double m_dy; - const glyph_cache* m_prev_glyph; - const glyph_cache* m_last_glyph; - path_adaptor_type m_path_adaptor; - gray8_adaptor_type m_gray8_adaptor; - gray8_scanline_type m_gray8_scanline; - mono_adaptor_type m_mono_adaptor; - mono_scanline_type m_mono_scanline; - }; - -} - -#endif - diff --git a/xs/src/agg/agg_font_cache_manager2.h b/xs/src/agg/agg_font_cache_manager2.h deleted file mode 100644 index 75d311eff7..0000000000 --- a/xs/src/agg/agg_font_cache_manager2.h +++ /dev/null @@ -1,311 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_FONT_CACHE_MANAGER2_INCLUDED -#define AGG_FONT_CACHE_MANAGER2_INCLUDED - -#include -#include -#include -#include "agg_array.h" - -namespace agg { - -namespace fman { - //---------------------------------------------------------glyph_data_type - enum glyph_data_type - { - glyph_data_invalid = 0, - glyph_data_mono = 1, - glyph_data_gray8 = 2, - glyph_data_outline = 3 - }; - - - //-------------------------------------------------------------cached_glyph - struct cached_glyph - { - void * cached_font; - unsigned glyph_code; - unsigned glyph_index; - int8u* data; - unsigned data_size; - glyph_data_type data_type; - rect_i bounds; - double advance_x; - double advance_y; - }; - - - //--------------------------------------------------------------cached_glyphs - class cached_glyphs - { - public: - enum block_size_e { block_size = 16384-16 }; - - //-------------------------------------------------------------------- - cached_glyphs() - : m_allocator(block_size) - { memset(m_glyphs, 0, sizeof(m_glyphs)); } - - //-------------------------------------------------------------------- - const cached_glyph* find_glyph(unsigned glyph_code) const - { - unsigned msb = (glyph_code >> 8) & 0xFF; - if(m_glyphs[msb]) - { - return m_glyphs[msb][glyph_code & 0xFF]; - } - return 0; - } - - //-------------------------------------------------------------------- - cached_glyph* cache_glyph( - void * cached_font, - unsigned glyph_code, - unsigned glyph_index, - unsigned data_size, - glyph_data_type data_type, - const rect_i& bounds, - double advance_x, - double advance_y) - { - unsigned msb = (glyph_code >> 8) & 0xFF; - if(m_glyphs[msb] == 0) - { - m_glyphs[msb] = - (cached_glyph**)m_allocator.allocate(sizeof(cached_glyph*) * 256, - sizeof(cached_glyph*)); - memset(m_glyphs[msb], 0, sizeof(cached_glyph*) * 256); - } - - unsigned lsb = glyph_code & 0xFF; - if(m_glyphs[msb][lsb]) return 0; // Already exists, do not overwrite - - cached_glyph* glyph = - (cached_glyph*)m_allocator.allocate(sizeof(cached_glyph), - sizeof(double)); - - glyph->cached_font = cached_font; - glyph->glyph_code = glyph_code; - glyph->glyph_index = glyph_index; - glyph->data = m_allocator.allocate(data_size); - glyph->data_size = data_size; - glyph->data_type = data_type; - glyph->bounds = bounds; - glyph->advance_x = advance_x; - glyph->advance_y = advance_y; - return m_glyphs[msb][lsb] = glyph; - } - - private: - block_allocator m_allocator; - cached_glyph** m_glyphs[256]; - }; - - - - //------------------------------------------------------------------------ - enum glyph_rendering - { - glyph_ren_native_mono, - glyph_ren_native_gray8, - glyph_ren_outline, - glyph_ren_agg_mono, - glyph_ren_agg_gray8 - }; - - - - - //------------------------------------------------------font_cache_manager - template class font_cache_manager - { - public: - typedef FontEngine font_engine_type; - typedef font_cache_manager self_type; - typedef typename font_engine_type::path_adaptor_type path_adaptor_type; - typedef typename font_engine_type::gray8_adaptor_type gray8_adaptor_type; - typedef typename gray8_adaptor_type::embedded_scanline gray8_scanline_type; - typedef typename font_engine_type::mono_adaptor_type mono_adaptor_type; - typedef typename mono_adaptor_type::embedded_scanline mono_scanline_type; - - struct cached_font - { - cached_font( - font_engine_type& engine, - typename FontEngine::loaded_face *face, - double height, - double width, - bool hinting, - glyph_rendering rendering ) - : m_engine( engine ) - , m_face( face ) - , m_height( height ) - , m_width( width ) - , m_hinting( hinting ) - , m_rendering( rendering ) - { - select_face(); - m_face_height=m_face->height(); - m_face_width=m_face->width(); - m_face_ascent=m_face->ascent(); - m_face_descent=m_face->descent(); - m_face_ascent_b=m_face->ascent_b(); - m_face_descent_b=m_face->descent_b(); - } - - double height() const - { - return m_face_height; - } - - double width() const - { - return m_face_width; - } - - double ascent() const - { - return m_face_ascent; - } - - double descent() const - { - return m_face_descent; - } - - double ascent_b() const - { - return m_face_ascent_b; - } - - double descent_b() const - { - return m_face_descent_b; - } - - bool add_kerning( const cached_glyph *first, const cached_glyph *second, double* x, double* y) - { - if( !first || !second ) - return false; - select_face(); - return m_face->add_kerning( - first->glyph_index, second->glyph_index, x, y ); - } - - void select_face() - { - m_face->select_instance( m_height, m_width, m_hinting, m_rendering ); - } - - const cached_glyph *get_glyph(unsigned cp) - { - const cached_glyph *glyph=m_glyphs.find_glyph(cp); - if( glyph==0 ) - { - typename FontEngine::prepared_glyph prepared; - select_face(); - bool success=m_face->prepare_glyph(cp, &prepared); - if( success ) - { - glyph=m_glyphs.cache_glyph( - this, - prepared.glyph_code, - prepared.glyph_index, - prepared.data_size, - prepared.data_type, - prepared.bounds, - prepared.advance_x, - prepared.advance_y ); - assert( glyph!=0 ); - m_face->write_glyph_to(&prepared,glyph->data); - } - } - return glyph; - } - - font_engine_type& m_engine; - typename FontEngine::loaded_face *m_face; - double m_height; - double m_width; - bool m_hinting; - glyph_rendering m_rendering; - double m_face_height; - double m_face_width; - double m_face_ascent; - double m_face_descent; - double m_face_ascent_b; - double m_face_descent_b; - cached_glyphs m_glyphs; - }; - - //-------------------------------------------------------------------- - font_cache_manager(font_engine_type& engine, unsigned max_fonts=32) - :m_engine(engine) - { } - - //-------------------------------------------------------------------- - void init_embedded_adaptors(const cached_glyph* gl, - double x, double y, - double scale=1.0) - { - if(gl) - { - switch(gl->data_type) - { - default: return; - case glyph_data_mono: - m_mono_adaptor.init(gl->data, gl->data_size, x, y); - break; - - case glyph_data_gray8: - m_gray8_adaptor.init(gl->data, gl->data_size, x, y); - break; - - case glyph_data_outline: - m_path_adaptor.init(gl->data, gl->data_size, x, y, scale); - break; - } - } - } - - - //-------------------------------------------------------------------- - path_adaptor_type& path_adaptor() { return m_path_adaptor; } - gray8_adaptor_type& gray8_adaptor() { return m_gray8_adaptor; } - gray8_scanline_type& gray8_scanline() { return m_gray8_scanline; } - mono_adaptor_type& mono_adaptor() { return m_mono_adaptor; } - mono_scanline_type& mono_scanline() { return m_mono_scanline; } - - - private: - //-------------------------------------------------------------------- - font_cache_manager(const self_type&); - const self_type& operator = (const self_type&); - - font_engine_type& m_engine; - path_adaptor_type m_path_adaptor; - gray8_adaptor_type m_gray8_adaptor; - gray8_scanline_type m_gray8_scanline; - mono_adaptor_type m_mono_adaptor; - mono_scanline_type m_mono_scanline; - }; - -} -} - -#endif - diff --git a/xs/src/agg/agg_glyph_raster_bin.h b/xs/src/agg/agg_glyph_raster_bin.h deleted file mode 100644 index b0bf858efd..0000000000 --- a/xs/src/agg/agg_glyph_raster_bin.h +++ /dev/null @@ -1,155 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_GLYPH_RASTER_BIN_INCLUDED -#define AGG_GLYPH_RASTER_BIN_INCLUDED - -#include -#include "agg_basics.h" - -namespace agg -{ - - //========================================================glyph_raster_bin - template class glyph_raster_bin - { - public: - typedef ColorT color_type; - - //-------------------------------------------------------------------- - struct glyph_rect - { - int x1,y1,x2,y2; - double dx, dy; - }; - - //-------------------------------------------------------------------- - glyph_raster_bin(const int8u* font) : - m_font(font), - m_big_endian(false) - { - int t = 1; - if(*(char*)&t == 0) m_big_endian = true; - memset(m_span, 0, sizeof(m_span)); - } - - //-------------------------------------------------------------------- - const int8u* font() const { return m_font; } - void font(const int8u* f) { m_font = f; } - - //-------------------------------------------------------------------- - double height() const { return m_font[0]; } - double base_line() const { return m_font[1]; } - - //-------------------------------------------------------------------- - template - double width(const CharT* str) const - { - unsigned start_char = m_font[2]; - unsigned num_chars = m_font[3]; - - unsigned w = 0; - while(*str) - { - unsigned glyph = *str; - const int8u* bits = m_font + 4 + num_chars * 2 + - value(m_font + 4 + (glyph - start_char) * 2); - w += *bits; - ++str; - } - return w; - } - - //-------------------------------------------------------------------- - void prepare(glyph_rect* r, double x, double y, unsigned glyph, bool flip) - { - unsigned start_char = m_font[2]; - unsigned num_chars = m_font[3]; - - m_bits = m_font + 4 + num_chars * 2 + - value(m_font + 4 + (glyph - start_char) * 2); - - m_glyph_width = *m_bits++; - m_glyph_byte_width = (m_glyph_width + 7) >> 3; - - r->x1 = int(x); - r->x2 = r->x1 + m_glyph_width - 1; - if(flip) - { - r->y1 = int(y) - m_font[0] + m_font[1]; - r->y2 = r->y1 + m_font[0] - 1; - } - else - { - r->y1 = int(y) - m_font[1] + 1; - r->y2 = r->y1 + m_font[0] - 1; - } - r->dx = m_glyph_width; - r->dy = 0; - } - - //-------------------------------------------------------------------- - const cover_type* span(unsigned i) - { - i = m_font[0] - i - 1; - const int8u* bits = m_bits + i * m_glyph_byte_width; - unsigned j; - unsigned val = *bits; - unsigned nb = 0; - for(j = 0; j < m_glyph_width; ++j) - { - m_span[j] = (cover_type)((val & 0x80) ? cover_full : cover_none); - val <<= 1; - if(++nb >= 8) - { - val = *++bits; - nb = 0; - } - } - return m_span; - } - - private: - //-------------------------------------------------------------------- - int16u value(const int8u* p) const - { - int16u v; - if(m_big_endian) - { - *(int8u*)&v = p[1]; - *((int8u*)&v + 1) = p[0]; - } - else - { - *(int8u*)&v = p[0]; - *((int8u*)&v + 1) = p[1]; - } - return v; - } - - - //-------------------------------------------------------------------- - const int8u* m_font; - bool m_big_endian; - cover_type m_span[32]; - const int8u* m_bits; - unsigned m_glyph_width; - unsigned m_glyph_byte_width; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_gradient_lut.h b/xs/src/agg/agg_gradient_lut.h deleted file mode 100644 index 9aaa426815..0000000000 --- a/xs/src/agg/agg_gradient_lut.h +++ /dev/null @@ -1,244 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_GRADIENT_LUT_INCLUDED -#define AGG_GRADIENT_LUT_INCLUDED - -#include "agg_array.h" -#include "agg_dda_line.h" -#include "agg_color_rgba.h" -#include "agg_color_gray.h" - -namespace agg -{ - - //======================================================color_interpolator - template struct color_interpolator - { - public: - typedef ColorT color_type; - - color_interpolator(const color_type& c1, - const color_type& c2, - unsigned len) : - m_c1(c1), - m_c2(c2), - m_len(len), - m_count(0) - {} - - void operator ++ () - { - ++m_count; - } - - color_type color() const - { - return m_c1.gradient(m_c2, double(m_count) / m_len); - } - - private: - color_type m_c1; - color_type m_c2; - unsigned m_len; - unsigned m_count; - }; - - //======================================================================== - // Fast specialization for rgba8 - template<> struct color_interpolator - { - public: - typedef rgba8 color_type; - - color_interpolator(const color_type& c1, - const color_type& c2, - unsigned len) : - r(c1.r, c2.r, len), - g(c1.g, c2.g, len), - b(c1.b, c2.b, len), - a(c1.a, c2.a, len) - {} - - void operator ++ () - { - ++r; ++g; ++b; ++a; - } - - color_type color() const - { - return color_type(r.y(), g.y(), b.y(), a.y()); - } - - private: - agg::dda_line_interpolator<14> r, g, b, a; - }; - - //======================================================================== - // Fast specialization for gray8 - template<> struct color_interpolator - { - public: - typedef gray8 color_type; - - color_interpolator(const color_type& c1, - const color_type& c2, - unsigned len) : - v(c1.v, c2.v, len), - a(c1.a, c2.a, len) - {} - - void operator ++ () - { - ++v; ++a; - } - - color_type color() const - { - return color_type(v.y(), a.y()); - } - - private: - agg::dda_line_interpolator<14> v,a; - }; - - //============================================================gradient_lut - template class gradient_lut - { - public: - typedef ColorInterpolator interpolator_type; - typedef typename interpolator_type::color_type color_type; - enum { color_lut_size = ColorLutSize }; - - //-------------------------------------------------------------------- - gradient_lut() : m_color_lut(color_lut_size) {} - - // Build Gradient Lut - // First, call remove_all(), then add_color() at least twice, - // then build_lut(). Argument "offset" in add_color must be - // in range [0...1] and defines a color stop as it is described - // in SVG specification, section Gradients and Patterns. - // The simplest linear gradient is: - // gradient_lut.add_color(0.0, start_color); - // gradient_lut.add_color(1.0, end_color); - //-------------------------------------------------------------------- - void remove_all(); - void add_color(double offset, const color_type& color); - void build_lut(); - - // Size-index Interface. This class can be used directly as the - // ColorF in span_gradient. All it needs is two access methods - // size() and operator []. - //-------------------------------------------------------------------- - static unsigned size() - { - return color_lut_size; - } - const color_type& operator [] (unsigned i) const - { - return m_color_lut[i]; - } - - private: - //-------------------------------------------------------------------- - struct color_point - { - double offset; - color_type color; - - color_point() {} - color_point(double off, const color_type& c) : - offset(off), color(c) - { - if(offset < 0.0) offset = 0.0; - if(offset > 1.0) offset = 1.0; - } - }; - typedef agg::pod_bvector color_profile_type; - typedef agg::pod_array color_lut_type; - - static bool offset_less(const color_point& a, const color_point& b) - { - return a.offset < b.offset; - } - static bool offset_equal(const color_point& a, const color_point& b) - { - return a.offset == b.offset; - } - - //-------------------------------------------------------------------- - color_profile_type m_color_profile; - color_lut_type m_color_lut; - }; - - - - //------------------------------------------------------------------------ - template - void gradient_lut::remove_all() - { - m_color_profile.remove_all(); - } - - //------------------------------------------------------------------------ - template - void gradient_lut::add_color(double offset, const color_type& color) - { - m_color_profile.add(color_point(offset, color)); - } - - //------------------------------------------------------------------------ - template - void gradient_lut::build_lut() - { - quick_sort(m_color_profile, offset_less); - m_color_profile.cut_at(remove_duplicates(m_color_profile, offset_equal)); - if(m_color_profile.size() >= 2) - { - unsigned i; - unsigned start = uround(m_color_profile[0].offset * color_lut_size); - unsigned end; - color_type c = m_color_profile[0].color; - for(i = 0; i < start; i++) - { - m_color_lut[i] = c; - } - for(i = 1; i < m_color_profile.size(); i++) - { - end = uround(m_color_profile[i].offset * color_lut_size); - interpolator_type ci(m_color_profile[i-1].color, - m_color_profile[i ].color, - end - start + 1); - while(start < end) - { - m_color_lut[start] = ci.color(); - ++ci; - ++start; - } - } - c = m_color_profile.last().color; - for(; end < m_color_lut.size(); end++) - { - m_color_lut[end] = c; - } - } - } -} - - - - -#endif diff --git a/xs/src/agg/agg_gsv_text.h b/xs/src/agg/agg_gsv_text.h deleted file mode 100644 index 16b3aeb33d..0000000000 --- a/xs/src/agg/agg_gsv_text.h +++ /dev/null @@ -1,153 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Class gsv_text -// -//---------------------------------------------------------------------------- - -#ifndef AGG_GSV_TEXT_INCLUDED -#define AGG_GSV_TEXT_INCLUDED - -#include "agg_array.h" -#include "agg_conv_stroke.h" -#include "agg_conv_transform.h" - -namespace agg -{ - - - //---------------------------------------------------------------gsv_text - // - // See Implementation agg_gsv_text.cpp - // - class gsv_text - { - enum status - { - initial, - next_char, - start_glyph, - glyph - }; - - public: - gsv_text(); - - void font(const void* font); - void flip(bool flip_y) { m_flip = flip_y; } - void load_font(const char* file); - void size(double height, double width=0.0); - void space(double space); - void line_space(double line_space); - void start_point(double x, double y); - void text(const char* text); - - double text_width(); - - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - // not supposed to be copied - gsv_text(const gsv_text&); - const gsv_text& operator = (const gsv_text&); - - int16u value(const int8u* p) const - { - int16u v; - if(m_big_endian) - { - *(int8u*)&v = p[1]; - *((int8u*)&v + 1) = p[0]; - } - else - { - *(int8u*)&v = p[0]; - *((int8u*)&v + 1) = p[1]; - } - return v; - } - - private: - double m_x; - double m_y; - double m_start_x; - double m_width; - double m_height; - double m_space; - double m_line_space; - char m_chr[2]; - char* m_text; - pod_array m_text_buf; - char* m_cur_chr; - const void* m_font; - pod_array m_loaded_font; - status m_status; - bool m_big_endian; - bool m_flip; - int8u* m_indices; - int8* m_glyphs; - int8* m_bglyph; - int8* m_eglyph; - double m_w; - double m_h; - }; - - - - - //--------------------------------------------------------gsv_text_outline - template class gsv_text_outline - { - public: - gsv_text_outline(gsv_text& text, Transformer& trans) : - m_polyline(text), - m_trans(m_polyline, trans) - { - } - - void width(double w) - { - m_polyline.width(w); - } - - void transformer(const Transformer* trans) - { - m_trans->transformer(trans); - } - - void rewind(unsigned path_id) - { - m_trans.rewind(path_id); - m_polyline.line_join(round_join); - m_polyline.line_cap(round_cap); - } - - unsigned vertex(double* x, double* y) - { - return m_trans.vertex(x, y); - } - - private: - conv_stroke m_polyline; - conv_transform, Transformer> m_trans; - }; - - - -} - - -#endif diff --git a/xs/src/agg/agg_image_accessors.h b/xs/src/agg/agg_image_accessors.h deleted file mode 100644 index c651d6d2e8..0000000000 --- a/xs/src/agg/agg_image_accessors.h +++ /dev/null @@ -1,481 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_IMAGE_ACCESSORS_INCLUDED -#define AGG_IMAGE_ACCESSORS_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //-----------------------------------------------------image_accessor_clip - template class image_accessor_clip - { - public: - typedef PixFmt pixfmt_type; - typedef typename pixfmt_type::color_type color_type; - typedef typename pixfmt_type::order_type order_type; - typedef typename pixfmt_type::value_type value_type; - enum pix_width_e { pix_width = pixfmt_type::pix_width }; - - image_accessor_clip() {} - explicit image_accessor_clip(pixfmt_type& pixf, - const color_type& bk) : - m_pixf(&pixf) - { - pixfmt_type::make_pix(m_bk_buf, bk); - } - - void attach(pixfmt_type& pixf) - { - m_pixf = &pixf; - } - - void background_color(const color_type& bk) - { - pixfmt_type::make_pix(m_bk_buf, bk); - } - - private: - AGG_INLINE const int8u* pixel() const - { - if(m_y >= 0 && m_y < (int)m_pixf->height() && - m_x >= 0 && m_x < (int)m_pixf->width()) - { - return m_pixf->pix_ptr(m_x, m_y); - } - return m_bk_buf; - } - - public: - AGG_INLINE const int8u* span(int x, int y, unsigned len) - { - m_x = m_x0 = x; - m_y = y; - if(y >= 0 && y < (int)m_pixf->height() && - x >= 0 && x+(int)len <= (int)m_pixf->width()) - { - return m_pix_ptr = m_pixf->pix_ptr(x, y); - } - m_pix_ptr = 0; - return pixel(); - } - - AGG_INLINE const int8u* next_x() - { - if(m_pix_ptr) return m_pix_ptr += pix_width; - ++m_x; - return pixel(); - } - - AGG_INLINE const int8u* next_y() - { - ++m_y; - m_x = m_x0; - if(m_pix_ptr && - m_y >= 0 && m_y < (int)m_pixf->height()) - { - return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); - } - m_pix_ptr = 0; - return pixel(); - } - - private: - const pixfmt_type* m_pixf; - int8u m_bk_buf[pix_width]; - int m_x, m_x0, m_y; - const int8u* m_pix_ptr; - }; - - - - - //--------------------------------------------------image_accessor_no_clip - template class image_accessor_no_clip - { - public: - typedef PixFmt pixfmt_type; - typedef typename pixfmt_type::color_type color_type; - typedef typename pixfmt_type::order_type order_type; - typedef typename pixfmt_type::value_type value_type; - enum pix_width_e { pix_width = pixfmt_type::pix_width }; - - image_accessor_no_clip() {} - explicit image_accessor_no_clip(pixfmt_type& pixf) : - m_pixf(&pixf) - {} - - void attach(pixfmt_type& pixf) - { - m_pixf = &pixf; - } - - AGG_INLINE const int8u* span(int x, int y, unsigned) - { - m_x = x; - m_y = y; - return m_pix_ptr = m_pixf->pix_ptr(x, y); - } - - AGG_INLINE const int8u* next_x() - { - return m_pix_ptr += pix_width; - } - - AGG_INLINE const int8u* next_y() - { - ++m_y; - return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); - } - - private: - const pixfmt_type* m_pixf; - int m_x, m_y; - const int8u* m_pix_ptr; - }; - - - - - //----------------------------------------------------image_accessor_clone - template class image_accessor_clone - { - public: - typedef PixFmt pixfmt_type; - typedef typename pixfmt_type::color_type color_type; - typedef typename pixfmt_type::order_type order_type; - typedef typename pixfmt_type::value_type value_type; - enum pix_width_e { pix_width = pixfmt_type::pix_width }; - - image_accessor_clone() {} - explicit image_accessor_clone(pixfmt_type& pixf) : - m_pixf(&pixf) - {} - - void attach(pixfmt_type& pixf) - { - m_pixf = &pixf; - } - - private: - AGG_INLINE const int8u* pixel() const - { - int x = m_x; - int y = m_y; - if(x < 0) x = 0; - if(y < 0) y = 0; - if(x >= (int)m_pixf->width()) x = m_pixf->width() - 1; - if(y >= (int)m_pixf->height()) y = m_pixf->height() - 1; - return m_pixf->pix_ptr(x, y); - } - - public: - AGG_INLINE const int8u* span(int x, int y, unsigned len) - { - m_x = m_x0 = x; - m_y = y; - if(y >= 0 && y < (int)m_pixf->height() && - x >= 0 && x+len <= (int)m_pixf->width()) - { - return m_pix_ptr = m_pixf->pix_ptr(x, y); - } - m_pix_ptr = 0; - return pixel(); - } - - AGG_INLINE const int8u* next_x() - { - if(m_pix_ptr) return m_pix_ptr += pix_width; - ++m_x; - return pixel(); - } - - AGG_INLINE const int8u* next_y() - { - ++m_y; - m_x = m_x0; - if(m_pix_ptr && - m_y >= 0 && m_y < (int)m_pixf->height()) - { - return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); - } - m_pix_ptr = 0; - return pixel(); - } - - private: - const pixfmt_type* m_pixf; - int m_x, m_x0, m_y; - const int8u* m_pix_ptr; - }; - - - - - - //-----------------------------------------------------image_accessor_wrap - template class image_accessor_wrap - { - public: - typedef PixFmt pixfmt_type; - typedef typename pixfmt_type::color_type color_type; - typedef typename pixfmt_type::order_type order_type; - typedef typename pixfmt_type::value_type value_type; - enum pix_width_e { pix_width = pixfmt_type::pix_width }; - - image_accessor_wrap() {} - explicit image_accessor_wrap(pixfmt_type& pixf) : - m_pixf(&pixf), - m_wrap_x(pixf.width()), - m_wrap_y(pixf.height()) - {} - - void attach(pixfmt_type& pixf) - { - m_pixf = &pixf; - } - - AGG_INLINE const int8u* span(int x, int y, unsigned) - { - m_x = x; - m_row_ptr = m_pixf->pix_ptr(0, m_wrap_y(y)); - return m_row_ptr + m_wrap_x(x) * pix_width; - } - - AGG_INLINE const int8u* next_x() - { - int x = ++m_wrap_x; - return m_row_ptr + x * pix_width; - } - - AGG_INLINE const int8u* next_y() - { - m_row_ptr = m_pixf->pix_ptr(0, ++m_wrap_y); - return m_row_ptr + m_wrap_x(m_x) * pix_width; - } - - private: - const pixfmt_type* m_pixf; - const int8u* m_row_ptr; - int m_x; - WrapX m_wrap_x; - WrapY m_wrap_y; - }; - - - - - //--------------------------------------------------------wrap_mode_repeat - class wrap_mode_repeat - { - public: - wrap_mode_repeat() {} - wrap_mode_repeat(unsigned size) : - m_size(size), - m_add(size * (0x3FFFFFFF / size)), - m_value(0) - {} - - AGG_INLINE unsigned operator() (int v) - { - return m_value = (unsigned(v) + m_add) % m_size; - } - - AGG_INLINE unsigned operator++ () - { - ++m_value; - if(m_value >= m_size) m_value = 0; - return m_value; - } - private: - unsigned m_size; - unsigned m_add; - unsigned m_value; - }; - - - //---------------------------------------------------wrap_mode_repeat_pow2 - class wrap_mode_repeat_pow2 - { - public: - wrap_mode_repeat_pow2() {} - wrap_mode_repeat_pow2(unsigned size) : m_value(0) - { - m_mask = 1; - while(m_mask < size) m_mask = (m_mask << 1) | 1; - m_mask >>= 1; - } - AGG_INLINE unsigned operator() (int v) - { - return m_value = unsigned(v) & m_mask; - } - AGG_INLINE unsigned operator++ () - { - ++m_value; - if(m_value > m_mask) m_value = 0; - return m_value; - } - private: - unsigned m_mask; - unsigned m_value; - }; - - - //----------------------------------------------wrap_mode_repeat_auto_pow2 - class wrap_mode_repeat_auto_pow2 - { - public: - wrap_mode_repeat_auto_pow2() {} - wrap_mode_repeat_auto_pow2(unsigned size) : - m_size(size), - m_add(size * (0x3FFFFFFF / size)), - m_mask((m_size & (m_size-1)) ? 0 : m_size-1), - m_value(0) - {} - - AGG_INLINE unsigned operator() (int v) - { - if(m_mask) return m_value = unsigned(v) & m_mask; - return m_value = (unsigned(v) + m_add) % m_size; - } - AGG_INLINE unsigned operator++ () - { - ++m_value; - if(m_value >= m_size) m_value = 0; - return m_value; - } - - private: - unsigned m_size; - unsigned m_add; - unsigned m_mask; - unsigned m_value; - }; - - - //-------------------------------------------------------wrap_mode_reflect - class wrap_mode_reflect - { - public: - wrap_mode_reflect() {} - wrap_mode_reflect(unsigned size) : - m_size(size), - m_size2(size * 2), - m_add(m_size2 * (0x3FFFFFFF / m_size2)), - m_value(0) - {} - - AGG_INLINE unsigned operator() (int v) - { - m_value = (unsigned(v) + m_add) % m_size2; - if(m_value >= m_size) return m_size2 - m_value - 1; - return m_value; - } - - AGG_INLINE unsigned operator++ () - { - ++m_value; - if(m_value >= m_size2) m_value = 0; - if(m_value >= m_size) return m_size2 - m_value - 1; - return m_value; - } - private: - unsigned m_size; - unsigned m_size2; - unsigned m_add; - unsigned m_value; - }; - - - - //--------------------------------------------------wrap_mode_reflect_pow2 - class wrap_mode_reflect_pow2 - { - public: - wrap_mode_reflect_pow2() {} - wrap_mode_reflect_pow2(unsigned size) : m_value(0) - { - m_mask = 1; - m_size = 1; - while(m_mask < size) - { - m_mask = (m_mask << 1) | 1; - m_size <<= 1; - } - } - AGG_INLINE unsigned operator() (int v) - { - m_value = unsigned(v) & m_mask; - if(m_value >= m_size) return m_mask - m_value; - return m_value; - } - AGG_INLINE unsigned operator++ () - { - ++m_value; - m_value &= m_mask; - if(m_value >= m_size) return m_mask - m_value; - return m_value; - } - private: - unsigned m_size; - unsigned m_mask; - unsigned m_value; - }; - - - - //---------------------------------------------wrap_mode_reflect_auto_pow2 - class wrap_mode_reflect_auto_pow2 - { - public: - wrap_mode_reflect_auto_pow2() {} - wrap_mode_reflect_auto_pow2(unsigned size) : - m_size(size), - m_size2(size * 2), - m_add(m_size2 * (0x3FFFFFFF / m_size2)), - m_mask((m_size2 & (m_size2-1)) ? 0 : m_size2-1), - m_value(0) - {} - - AGG_INLINE unsigned operator() (int v) - { - m_value = m_mask ? unsigned(v) & m_mask : - (unsigned(v) + m_add) % m_size2; - if(m_value >= m_size) return m_size2 - m_value - 1; - return m_value; - } - AGG_INLINE unsigned operator++ () - { - ++m_value; - if(m_value >= m_size2) m_value = 0; - if(m_value >= m_size) return m_size2 - m_value - 1; - return m_value; - } - - private: - unsigned m_size; - unsigned m_size2; - unsigned m_add; - unsigned m_mask; - unsigned m_value; - }; - - -} - - -#endif diff --git a/xs/src/agg/agg_image_filters.h b/xs/src/agg/agg_image_filters.h deleted file mode 100644 index 0e7c598daf..0000000000 --- a/xs/src/agg/agg_image_filters.h +++ /dev/null @@ -1,449 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Image transformation filters, -// Filtering classes (image_filter_lut, image_filter), -// Basic filter shape classes -//---------------------------------------------------------------------------- -#ifndef AGG_IMAGE_FILTERS_INCLUDED -#define AGG_IMAGE_FILTERS_INCLUDED - -#include "agg_array.h" -#include "agg_math.h" - -namespace agg -{ - - // See Implementation agg_image_filters.cpp - - enum image_filter_scale_e - { - image_filter_shift = 14, //----image_filter_shift - image_filter_scale = 1 << image_filter_shift, //----image_filter_scale - image_filter_mask = image_filter_scale - 1 //----image_filter_mask - }; - - enum image_subpixel_scale_e - { - image_subpixel_shift = 8, //----image_subpixel_shift - image_subpixel_scale = 1 << image_subpixel_shift, //----image_subpixel_scale - image_subpixel_mask = image_subpixel_scale - 1 //----image_subpixel_mask - }; - - - //-----------------------------------------------------image_filter_lut - class image_filter_lut - { - public: - template void calculate(const FilterF& filter, - bool normalization=true) - { - filter; // prevent erroneous C4100 in MSVC - double r = filter.radius(); - realloc_lut(r); - unsigned i; - unsigned pivot = diameter() << (image_subpixel_shift - 1); - for(i = 0; i < pivot; i++) - { - double x = double(i) / double(image_subpixel_scale); - double y = filter.calc_weight(x); - m_weight_array[pivot + i] = - m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale); - } - unsigned end = (diameter() << image_subpixel_shift) - 1; - m_weight_array[0] = m_weight_array[end]; - if(normalization) - { - normalize(); - } - } - - image_filter_lut() : m_radius(0), m_diameter(0), m_start(0) {} - - template image_filter_lut(const FilterF& filter, - bool normalization=true) - { - calculate(filter, normalization); - } - - double radius() const { return m_radius; } - unsigned diameter() const { return m_diameter; } - int start() const { return m_start; } - const int16* weight_array() const { return &m_weight_array[0]; } - void normalize(); - - private: - void realloc_lut(double radius); - image_filter_lut(const image_filter_lut&); - const image_filter_lut& operator = (const image_filter_lut&); - - double m_radius; - unsigned m_diameter; - int m_start; - pod_array m_weight_array; - }; - - - - //--------------------------------------------------------image_filter - template class image_filter : public image_filter_lut - { - public: - image_filter() - { - calculate(m_filter_function); - } - private: - FilterF m_filter_function; - }; - - - //-----------------------------------------------image_filter_bilinear - struct image_filter_bilinear - { - static double radius() { return 1.0; } - static double calc_weight(double x) - { - return 1.0 - x; - } - }; - - - //-----------------------------------------------image_filter_hanning - struct image_filter_hanning - { - static double radius() { return 1.0; } - static double calc_weight(double x) - { - return 0.5 + 0.5 * cos(pi * x); - } - }; - - - //-----------------------------------------------image_filter_hamming - struct image_filter_hamming - { - static double radius() { return 1.0; } - static double calc_weight(double x) - { - return 0.54 + 0.46 * cos(pi * x); - } - }; - - //-----------------------------------------------image_filter_hermite - struct image_filter_hermite - { - static double radius() { return 1.0; } - static double calc_weight(double x) - { - return (2.0 * x - 3.0) * x * x + 1.0; - } - }; - - //------------------------------------------------image_filter_quadric - struct image_filter_quadric - { - static double radius() { return 1.5; } - static double calc_weight(double x) - { - double t; - if(x < 0.5) return 0.75 - x * x; - if(x < 1.5) {t = x - 1.5; return 0.5 * t * t;} - return 0.0; - } - }; - - //------------------------------------------------image_filter_bicubic - class image_filter_bicubic - { - static double pow3(double x) - { - return (x <= 0.0) ? 0.0 : x * x * x; - } - - public: - static double radius() { return 2.0; } - static double calc_weight(double x) - { - return - (1.0/6.0) * - (pow3(x + 2) - 4 * pow3(x + 1) + 6 * pow3(x) - 4 * pow3(x - 1)); - } - }; - - //-------------------------------------------------image_filter_kaiser - class image_filter_kaiser - { - double a; - double i0a; - double epsilon; - - public: - image_filter_kaiser(double b = 6.33) : - a(b), epsilon(1e-12) - { - i0a = 1.0 / bessel_i0(b); - } - - static double radius() { return 1.0; } - double calc_weight(double x) const - { - return bessel_i0(a * sqrt(1. - x * x)) * i0a; - } - - private: - double bessel_i0(double x) const - { - int i; - double sum, y, t; - - sum = 1.; - y = x * x / 4.; - t = y; - - for(i = 2; t > epsilon; i++) - { - sum += t; - t *= (double)y / (i * i); - } - return sum; - } - }; - - //----------------------------------------------image_filter_catrom - struct image_filter_catrom - { - static double radius() { return 2.0; } - static double calc_weight(double x) - { - if(x < 1.0) return 0.5 * (2.0 + x * x * (-5.0 + x * 3.0)); - if(x < 2.0) return 0.5 * (4.0 + x * (-8.0 + x * (5.0 - x))); - return 0.; - } - }; - - //---------------------------------------------image_filter_mitchell - class image_filter_mitchell - { - double p0, p2, p3; - double q0, q1, q2, q3; - - public: - image_filter_mitchell(double b = 1.0/3.0, double c = 1.0/3.0) : - p0((6.0 - 2.0 * b) / 6.0), - p2((-18.0 + 12.0 * b + 6.0 * c) / 6.0), - p3((12.0 - 9.0 * b - 6.0 * c) / 6.0), - q0((8.0 * b + 24.0 * c) / 6.0), - q1((-12.0 * b - 48.0 * c) / 6.0), - q2((6.0 * b + 30.0 * c) / 6.0), - q3((-b - 6.0 * c) / 6.0) - {} - - static double radius() { return 2.0; } - double calc_weight(double x) const - { - if(x < 1.0) return p0 + x * x * (p2 + x * p3); - if(x < 2.0) return q0 + x * (q1 + x * (q2 + x * q3)); - return 0.0; - } - }; - - - //----------------------------------------------image_filter_spline16 - struct image_filter_spline16 - { - static double radius() { return 2.0; } - static double calc_weight(double x) - { - if(x < 1.0) - { - return ((x - 9.0/5.0 ) * x - 1.0/5.0 ) * x + 1.0; - } - return ((-1.0/3.0 * (x-1) + 4.0/5.0) * (x-1) - 7.0/15.0 ) * (x-1); - } - }; - - - //---------------------------------------------image_filter_spline36 - struct image_filter_spline36 - { - static double radius() { return 3.0; } - static double calc_weight(double x) - { - if(x < 1.0) - { - return ((13.0/11.0 * x - 453.0/209.0) * x - 3.0/209.0) * x + 1.0; - } - if(x < 2.0) - { - return ((-6.0/11.0 * (x-1) + 270.0/209.0) * (x-1) - 156.0/ 209.0) * (x-1); - } - return ((1.0/11.0 * (x-2) - 45.0/209.0) * (x-2) + 26.0/209.0) * (x-2); - } - }; - - - //----------------------------------------------image_filter_gaussian - struct image_filter_gaussian - { - static double radius() { return 2.0; } - static double calc_weight(double x) - { - return exp(-2.0 * x * x) * sqrt(2.0 / pi); - } - }; - - - //------------------------------------------------image_filter_bessel - struct image_filter_bessel - { - static double radius() { return 3.2383; } - static double calc_weight(double x) - { - return (x == 0.0) ? pi / 4.0 : besj(pi * x, 1) / (2.0 * x); - } - }; - - - //-------------------------------------------------image_filter_sinc - class image_filter_sinc - { - public: - image_filter_sinc(double r) : m_radius(r < 2.0 ? 2.0 : r) {} - double radius() const { return m_radius; } - double calc_weight(double x) const - { - if(x == 0.0) return 1.0; - x *= pi; - return sin(x) / x; - } - private: - double m_radius; - }; - - - //-----------------------------------------------image_filter_lanczos - class image_filter_lanczos - { - public: - image_filter_lanczos(double r) : m_radius(r < 2.0 ? 2.0 : r) {} - double radius() const { return m_radius; } - double calc_weight(double x) const - { - if(x == 0.0) return 1.0; - if(x > m_radius) return 0.0; - x *= pi; - double xr = x / m_radius; - return (sin(x) / x) * (sin(xr) / xr); - } - private: - double m_radius; - }; - - - //----------------------------------------------image_filter_blackman - class image_filter_blackman - { - public: - image_filter_blackman(double r) : m_radius(r < 2.0 ? 2.0 : r) {} - double radius() const { return m_radius; } - double calc_weight(double x) const - { - if(x == 0.0) return 1.0; - if(x > m_radius) return 0.0; - x *= pi; - double xr = x / m_radius; - return (sin(x) / x) * (0.42 + 0.5*cos(xr) + 0.08*cos(2*xr)); - } - private: - double m_radius; - }; - - //------------------------------------------------image_filter_sinc36 - class image_filter_sinc36 : public image_filter_sinc - { public: image_filter_sinc36() : image_filter_sinc(3.0){} }; - - //------------------------------------------------image_filter_sinc64 - class image_filter_sinc64 : public image_filter_sinc - { public: image_filter_sinc64() : image_filter_sinc(4.0){} }; - - //-----------------------------------------------image_filter_sinc100 - class image_filter_sinc100 : public image_filter_sinc - { public: image_filter_sinc100() : image_filter_sinc(5.0){} }; - - //-----------------------------------------------image_filter_sinc144 - class image_filter_sinc144 : public image_filter_sinc - { public: image_filter_sinc144() : image_filter_sinc(6.0){} }; - - //-----------------------------------------------image_filter_sinc196 - class image_filter_sinc196 : public image_filter_sinc - { public: image_filter_sinc196() : image_filter_sinc(7.0){} }; - - //-----------------------------------------------image_filter_sinc256 - class image_filter_sinc256 : public image_filter_sinc - { public: image_filter_sinc256() : image_filter_sinc(8.0){} }; - - //---------------------------------------------image_filter_lanczos36 - class image_filter_lanczos36 : public image_filter_lanczos - { public: image_filter_lanczos36() : image_filter_lanczos(3.0){} }; - - //---------------------------------------------image_filter_lanczos64 - class image_filter_lanczos64 : public image_filter_lanczos - { public: image_filter_lanczos64() : image_filter_lanczos(4.0){} }; - - //--------------------------------------------image_filter_lanczos100 - class image_filter_lanczos100 : public image_filter_lanczos - { public: image_filter_lanczos100() : image_filter_lanczos(5.0){} }; - - //--------------------------------------------image_filter_lanczos144 - class image_filter_lanczos144 : public image_filter_lanczos - { public: image_filter_lanczos144() : image_filter_lanczos(6.0){} }; - - //--------------------------------------------image_filter_lanczos196 - class image_filter_lanczos196 : public image_filter_lanczos - { public: image_filter_lanczos196() : image_filter_lanczos(7.0){} }; - - //--------------------------------------------image_filter_lanczos256 - class image_filter_lanczos256 : public image_filter_lanczos - { public: image_filter_lanczos256() : image_filter_lanczos(8.0){} }; - - //--------------------------------------------image_filter_blackman36 - class image_filter_blackman36 : public image_filter_blackman - { public: image_filter_blackman36() : image_filter_blackman(3.0){} }; - - //--------------------------------------------image_filter_blackman64 - class image_filter_blackman64 : public image_filter_blackman - { public: image_filter_blackman64() : image_filter_blackman(4.0){} }; - - //-------------------------------------------image_filter_blackman100 - class image_filter_blackman100 : public image_filter_blackman - { public: image_filter_blackman100() : image_filter_blackman(5.0){} }; - - //-------------------------------------------image_filter_blackman144 - class image_filter_blackman144 : public image_filter_blackman - { public: image_filter_blackman144() : image_filter_blackman(6.0){} }; - - //-------------------------------------------image_filter_blackman196 - class image_filter_blackman196 : public image_filter_blackman - { public: image_filter_blackman196() : image_filter_blackman(7.0){} }; - - //-------------------------------------------image_filter_blackman256 - class image_filter_blackman256 : public image_filter_blackman - { public: image_filter_blackman256() : image_filter_blackman(8.0){} }; - - -} - -#endif diff --git a/xs/src/agg/agg_line_aa_basics.h b/xs/src/agg/agg_line_aa_basics.h deleted file mode 100644 index c5acb18e79..0000000000 --- a/xs/src/agg/agg_line_aa_basics.h +++ /dev/null @@ -1,189 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_LINE_AA_BASICS_INCLUDED -#define AGG_LINE_AA_BASICS_INCLUDED - -#include -#include "agg_basics.h" - -namespace agg -{ - - // See Implementation agg_line_aa_basics.cpp - - //------------------------------------------------------------------------- - enum line_subpixel_scale_e - { - line_subpixel_shift = 8, //----line_subpixel_shift - line_subpixel_scale = 1 << line_subpixel_shift, //----line_subpixel_scale - line_subpixel_mask = line_subpixel_scale - 1, //----line_subpixel_mask - line_max_coord = (1 << 28) - 1, //----line_max_coord - line_max_length = 1 << (line_subpixel_shift + 10) //----line_max_length - }; - - //------------------------------------------------------------------------- - enum line_mr_subpixel_scale_e - { - line_mr_subpixel_shift = 4, //----line_mr_subpixel_shift - line_mr_subpixel_scale = 1 << line_mr_subpixel_shift, //----line_mr_subpixel_scale - line_mr_subpixel_mask = line_mr_subpixel_scale - 1 //----line_mr_subpixel_mask - }; - - //------------------------------------------------------------------line_mr - AGG_INLINE int line_mr(int x) - { - return x >> (line_subpixel_shift - line_mr_subpixel_shift); - } - - //-------------------------------------------------------------------line_hr - AGG_INLINE int line_hr(int x) - { - return x << (line_subpixel_shift - line_mr_subpixel_shift); - } - - //---------------------------------------------------------------line_dbl_hr - AGG_INLINE int line_dbl_hr(int x) - { - return x << line_subpixel_shift; - } - - //---------------------------------------------------------------line_coord - struct line_coord - { - AGG_INLINE static int conv(double x) - { - return iround(x * line_subpixel_scale); - } - }; - - //-----------------------------------------------------------line_coord_sat - struct line_coord_sat - { - AGG_INLINE static int conv(double x) - { - return saturation::iround(x * line_subpixel_scale); - } - }; - - //==========================================================line_parameters - struct line_parameters - { - //--------------------------------------------------------------------- - line_parameters() {} - line_parameters(int x1_, int y1_, int x2_, int y2_, int len_) : - x1(x1_), y1(y1_), x2(x2_), y2(y2_), - dx(abs(x2_ - x1_)), - dy(abs(y2_ - y1_)), - sx((x2_ > x1_) ? 1 : -1), - sy((y2_ > y1_) ? 1 : -1), - vertical(dy >= dx), - inc(vertical ? sy : sx), - len(len_), - octant((sy & 4) | (sx & 2) | int(vertical)) - { - } - - //--------------------------------------------------------------------- - unsigned orthogonal_quadrant() const { return s_orthogonal_quadrant[octant]; } - unsigned diagonal_quadrant() const { return s_diagonal_quadrant[octant]; } - - //--------------------------------------------------------------------- - bool same_orthogonal_quadrant(const line_parameters& lp) const - { - return s_orthogonal_quadrant[octant] == s_orthogonal_quadrant[lp.octant]; - } - - //--------------------------------------------------------------------- - bool same_diagonal_quadrant(const line_parameters& lp) const - { - return s_diagonal_quadrant[octant] == s_diagonal_quadrant[lp.octant]; - } - - //--------------------------------------------------------------------- - void divide(line_parameters& lp1, line_parameters& lp2) const - { - int xmid = (x1 + x2) >> 1; - int ymid = (y1 + y2) >> 1; - int len2 = len >> 1; - - lp1 = *this; - lp2 = *this; - - lp1.x2 = xmid; - lp1.y2 = ymid; - lp1.len = len2; - lp1.dx = abs(lp1.x2 - lp1.x1); - lp1.dy = abs(lp1.y2 - lp1.y1); - - lp2.x1 = xmid; - lp2.y1 = ymid; - lp2.len = len2; - lp2.dx = abs(lp2.x2 - lp2.x1); - lp2.dy = abs(lp2.y2 - lp2.y1); - } - - //--------------------------------------------------------------------- - int x1, y1, x2, y2, dx, dy, sx, sy; - bool vertical; - int inc; - int len; - int octant; - - //--------------------------------------------------------------------- - static const int8u s_orthogonal_quadrant[8]; - static const int8u s_diagonal_quadrant[8]; - }; - - - - // See Implementation agg_line_aa_basics.cpp - - //----------------------------------------------------------------bisectrix - void bisectrix(const line_parameters& l1, - const line_parameters& l2, - int* x, int* y); - - - //-------------------------------------------fix_degenerate_bisectrix_start - void inline fix_degenerate_bisectrix_start(const line_parameters& lp, - int* x, int* y) - { - int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - - double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len); - if(d < line_subpixel_scale/2) - { - *x = lp.x1 + (lp.y2 - lp.y1); - *y = lp.y1 - (lp.x2 - lp.x1); - } - } - - - //---------------------------------------------fix_degenerate_bisectrix_end - void inline fix_degenerate_bisectrix_end(const line_parameters& lp, - int* x, int* y) - { - int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - - double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len); - if(d < line_subpixel_scale/2) - { - *x = lp.x2 + (lp.y2 - lp.y1); - *y = lp.y2 - (lp.x2 - lp.x1); - } - } - - -} - -#endif diff --git a/xs/src/agg/agg_math_stroke.h b/xs/src/agg/agg_math_stroke.h deleted file mode 100644 index 4806dcd4bf..0000000000 --- a/xs/src/agg/agg_math_stroke.h +++ /dev/null @@ -1,526 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Stroke math -// -//---------------------------------------------------------------------------- - -#ifndef AGG_STROKE_MATH_INCLUDED -#define AGG_STROKE_MATH_INCLUDED - -#include "agg_math.h" -#include "agg_vertex_sequence.h" - -namespace agg -{ - //-------------------------------------------------------------line_cap_e - enum line_cap_e - { - butt_cap, - square_cap, - round_cap - }; - - //------------------------------------------------------------line_join_e - enum line_join_e - { - miter_join = 0, - miter_join_revert = 1, - round_join = 2, - bevel_join = 3, - miter_join_round = 4 - }; - - - //-----------------------------------------------------------inner_join_e - enum inner_join_e - { - inner_bevel, - inner_miter, - inner_jag, - inner_round - }; - - //------------------------------------------------------------math_stroke - template class math_stroke - { - public: - typedef typename VertexConsumer::value_type coord_type; - - math_stroke(); - - void line_cap(line_cap_e lc) { m_line_cap = lc; } - void line_join(line_join_e lj) { m_line_join = lj; } - void inner_join(inner_join_e ij) { m_inner_join = ij; } - - line_cap_e line_cap() const { return m_line_cap; } - line_join_e line_join() const { return m_line_join; } - inner_join_e inner_join() const { return m_inner_join; } - - void width(double w); - void miter_limit(double ml) { m_miter_limit = ml; } - void miter_limit_theta(double t); - void inner_miter_limit(double ml) { m_inner_miter_limit = ml; } - void approximation_scale(double as) { m_approx_scale = as; } - - double width() const { return m_width * 2.0; } - double miter_limit() const { return m_miter_limit; } - double inner_miter_limit() const { return m_inner_miter_limit; } - double approximation_scale() const { return m_approx_scale; } - - void calc_cap(VertexConsumer& vc, - const vertex_dist& v0, - const vertex_dist& v1, - double len); - - void calc_join(VertexConsumer& vc, - const vertex_dist& v0, - const vertex_dist& v1, - const vertex_dist& v2, - double len1, - double len2); - - private: - AGG_INLINE void add_vertex(VertexConsumer& vc, double x, double y) - { - vc.add(coord_type(x, y)); - } - - void calc_arc(VertexConsumer& vc, - double x, double y, - double dx1, double dy1, - double dx2, double dy2); - - void calc_miter(VertexConsumer& vc, - const vertex_dist& v0, - const vertex_dist& v1, - const vertex_dist& v2, - double dx1, double dy1, - double dx2, double dy2, - line_join_e lj, - double mlimit, - double dbevel); - - double m_width; - double m_width_abs; - double m_width_eps; - int m_width_sign; - double m_miter_limit; - double m_inner_miter_limit; - double m_approx_scale; - line_cap_e m_line_cap; - line_join_e m_line_join; - inner_join_e m_inner_join; - }; - - //----------------------------------------------------------------------- - template math_stroke::math_stroke() : - m_width(0.5), - m_width_abs(0.5), - m_width_eps(0.5/1024.0), - m_width_sign(1), - m_miter_limit(4.0), - m_inner_miter_limit(1.01), - m_approx_scale(1.0), - m_line_cap(butt_cap), - m_line_join(miter_join), - m_inner_join(inner_miter) - { - } - - //----------------------------------------------------------------------- - template void math_stroke::width(double w) - { - m_width = w * 0.5; - if(m_width < 0) - { - m_width_abs = -m_width; - m_width_sign = -1; - } - else - { - m_width_abs = m_width; - m_width_sign = 1; - } - m_width_eps = m_width / 1024.0; - } - - //----------------------------------------------------------------------- - template void math_stroke::miter_limit_theta(double t) - { - m_miter_limit = 1.0 / sin(t * 0.5) ; - } - - //----------------------------------------------------------------------- - template - void math_stroke::calc_arc(VC& vc, - double x, double y, - double dx1, double dy1, - double dx2, double dy2) - { - double a1 = atan2(dy1 * m_width_sign, dx1 * m_width_sign); - double a2 = atan2(dy2 * m_width_sign, dx2 * m_width_sign); - double da = a1 - a2; - int i, n; - - da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2; - - add_vertex(vc, x + dx1, y + dy1); - if(m_width_sign > 0) - { - if(a1 > a2) a2 += 2 * pi; - n = int((a2 - a1) / da); - da = (a2 - a1) / (n + 1); - a1 += da; - for(i = 0; i < n; i++) - { - add_vertex(vc, x + cos(a1) * m_width, y + sin(a1) * m_width); - a1 += da; - } - } - else - { - if(a1 < a2) a2 -= 2 * pi; - n = int((a1 - a2) / da); - da = (a1 - a2) / (n + 1); - a1 -= da; - for(i = 0; i < n; i++) - { - add_vertex(vc, x + cos(a1) * m_width, y + sin(a1) * m_width); - a1 -= da; - } - } - add_vertex(vc, x + dx2, y + dy2); - } - - //----------------------------------------------------------------------- - template - void math_stroke::calc_miter(VC& vc, - const vertex_dist& v0, - const vertex_dist& v1, - const vertex_dist& v2, - double dx1, double dy1, - double dx2, double dy2, - line_join_e lj, - double mlimit, - double dbevel) - { - double xi = v1.x; - double yi = v1.y; - double di = 1; - double lim = m_width_abs * mlimit; - bool miter_limit_exceeded = true; // Assume the worst - bool intersection_failed = true; // Assume the worst - - if(calc_intersection(v0.x + dx1, v0.y - dy1, - v1.x + dx1, v1.y - dy1, - v1.x + dx2, v1.y - dy2, - v2.x + dx2, v2.y - dy2, - &xi, &yi)) - { - // Calculation of the intersection succeeded - //--------------------- - di = calc_distance(v1.x, v1.y, xi, yi); - if(di <= lim) - { - // Inside the miter limit - //--------------------- - add_vertex(vc, xi, yi); - miter_limit_exceeded = false; - } - intersection_failed = false; - } - else - { - // Calculation of the intersection failed, most probably - // the three points lie one straight line. - // First check if v0 and v2 lie on the opposite sides of vector: - // (v1.x, v1.y) -> (v1.x+dx1, v1.y-dy1), that is, the perpendicular - // to the line determined by vertices v0 and v1. - // This condition determines whether the next line segments continues - // the previous one or goes back. - //---------------- - double x2 = v1.x + dx1; - double y2 = v1.y - dy1; - if((cross_product(v0.x, v0.y, v1.x, v1.y, x2, y2) < 0.0) == - (cross_product(v1.x, v1.y, v2.x, v2.y, x2, y2) < 0.0)) - { - // This case means that the next segment continues - // the previous one (straight line) - //----------------- - add_vertex(vc, v1.x + dx1, v1.y - dy1); - miter_limit_exceeded = false; - } - } - - if(miter_limit_exceeded) - { - // Miter limit exceeded - //------------------------ - switch(lj) - { - case miter_join_revert: - // For the compatibility with SVG, PDF, etc, - // we use a simple bevel join instead of - // "smart" bevel - //------------------- - add_vertex(vc, v1.x + dx1, v1.y - dy1); - add_vertex(vc, v1.x + dx2, v1.y - dy2); - break; - - case miter_join_round: - calc_arc(vc, v1.x, v1.y, dx1, -dy1, dx2, -dy2); - break; - - default: - // If no miter-revert, calculate new dx1, dy1, dx2, dy2 - //---------------- - if(intersection_failed) - { - mlimit *= m_width_sign; - add_vertex(vc, v1.x + dx1 + dy1 * mlimit, - v1.y - dy1 + dx1 * mlimit); - add_vertex(vc, v1.x + dx2 - dy2 * mlimit, - v1.y - dy2 - dx2 * mlimit); - } - else - { - double x1 = v1.x + dx1; - double y1 = v1.y - dy1; - double x2 = v1.x + dx2; - double y2 = v1.y - dy2; - di = (lim - dbevel) / (di - dbevel); - add_vertex(vc, x1 + (xi - x1) * di, - y1 + (yi - y1) * di); - add_vertex(vc, x2 + (xi - x2) * di, - y2 + (yi - y2) * di); - } - break; - } - } - } - - //--------------------------------------------------------stroke_calc_cap - template - void math_stroke::calc_cap(VC& vc, - const vertex_dist& v0, - const vertex_dist& v1, - double len) - { - vc.remove_all(); - - double dx1 = (v1.y - v0.y) / len; - double dy1 = (v1.x - v0.x) / len; - double dx2 = 0; - double dy2 = 0; - - dx1 *= m_width; - dy1 *= m_width; - - if(m_line_cap != round_cap) - { - if(m_line_cap == square_cap) - { - dx2 = dy1 * m_width_sign; - dy2 = dx1 * m_width_sign; - } - add_vertex(vc, v0.x - dx1 - dx2, v0.y + dy1 - dy2); - add_vertex(vc, v0.x + dx1 - dx2, v0.y - dy1 - dy2); - } - else - { - double da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2; - double a1; - int i; - int n = int(pi / da); - - da = pi / (n + 1); - add_vertex(vc, v0.x - dx1, v0.y + dy1); - if(m_width_sign > 0) - { - a1 = atan2(dy1, -dx1); - a1 += da; - for(i = 0; i < n; i++) - { - add_vertex(vc, v0.x + cos(a1) * m_width, - v0.y + sin(a1) * m_width); - a1 += da; - } - } - else - { - a1 = atan2(-dy1, dx1); - a1 -= da; - for(i = 0; i < n; i++) - { - add_vertex(vc, v0.x + cos(a1) * m_width, - v0.y + sin(a1) * m_width); - a1 -= da; - } - } - add_vertex(vc, v0.x + dx1, v0.y - dy1); - } - } - - //----------------------------------------------------------------------- - template - void math_stroke::calc_join(VC& vc, - const vertex_dist& v0, - const vertex_dist& v1, - const vertex_dist& v2, - double len1, - double len2) - { - double dx1 = m_width * (v1.y - v0.y) / len1; - double dy1 = m_width * (v1.x - v0.x) / len1; - double dx2 = m_width * (v2.y - v1.y) / len2; - double dy2 = m_width * (v2.x - v1.x) / len2; - - vc.remove_all(); - - double cp = cross_product(v0.x, v0.y, v1.x, v1.y, v2.x, v2.y); - if(cp != 0 && (cp > 0) == (m_width > 0)) - { - // Inner join - //--------------- - double limit = ((len1 < len2) ? len1 : len2) / m_width_abs; - if(limit < m_inner_miter_limit) - { - limit = m_inner_miter_limit; - } - - switch(m_inner_join) - { - default: // inner_bevel - add_vertex(vc, v1.x + dx1, v1.y - dy1); - add_vertex(vc, v1.x + dx2, v1.y - dy2); - break; - - case inner_miter: - calc_miter(vc, - v0, v1, v2, dx1, dy1, dx2, dy2, - miter_join_revert, - limit, 0); - break; - - case inner_jag: - case inner_round: - cp = (dx1-dx2) * (dx1-dx2) + (dy1-dy2) * (dy1-dy2); - if(cp < len1 * len1 && cp < len2 * len2) - { - calc_miter(vc, - v0, v1, v2, dx1, dy1, dx2, dy2, - miter_join_revert, - limit, 0); - } - else - { - if(m_inner_join == inner_jag) - { - add_vertex(vc, v1.x + dx1, v1.y - dy1); - add_vertex(vc, v1.x, v1.y ); - add_vertex(vc, v1.x + dx2, v1.y - dy2); - } - else - { - add_vertex(vc, v1.x + dx1, v1.y - dy1); - add_vertex(vc, v1.x, v1.y ); - calc_arc(vc, v1.x, v1.y, dx2, -dy2, dx1, -dy1); - add_vertex(vc, v1.x, v1.y ); - add_vertex(vc, v1.x + dx2, v1.y - dy2); - } - } - break; - } - } - else - { - // Outer join - //--------------- - - // Calculate the distance between v1 and - // the central point of the bevel line segment - //--------------- - double dx = (dx1 + dx2) / 2; - double dy = (dy1 + dy2) / 2; - double dbevel = sqrt(dx * dx + dy * dy); - - if(m_line_join == round_join || m_line_join == bevel_join) - { - // This is an optimization that reduces the number of points - // in cases of almost collinear segments. If there's no - // visible difference between bevel and miter joins we'd rather - // use miter join because it adds only one point instead of two. - // - // Here we calculate the middle point between the bevel points - // and then, the distance between v1 and this middle point. - // At outer joins this distance always less than stroke width, - // because it's actually the height of an isosceles triangle of - // v1 and its two bevel points. If the difference between this - // width and this value is small (no visible bevel) we can - // add just one point. - // - // The constant in the expression makes the result approximately - // the same as in round joins and caps. You can safely comment - // out this entire "if". - //------------------- - if(m_approx_scale * (m_width_abs - dbevel) < m_width_eps) - { - if(calc_intersection(v0.x + dx1, v0.y - dy1, - v1.x + dx1, v1.y - dy1, - v1.x + dx2, v1.y - dy2, - v2.x + dx2, v2.y - dy2, - &dx, &dy)) - { - add_vertex(vc, dx, dy); - } - else - { - add_vertex(vc, v1.x + dx1, v1.y - dy1); - } - return; - } - } - - switch(m_line_join) - { - case miter_join: - case miter_join_revert: - case miter_join_round: - calc_miter(vc, - v0, v1, v2, dx1, dy1, dx2, dy2, - m_line_join, - m_miter_limit, - dbevel); - break; - - case round_join: - calc_arc(vc, v1.x, v1.y, dx1, -dy1, dx2, -dy2); - break; - - default: // Bevel join - add_vertex(vc, v1.x + dx1, v1.y - dy1); - add_vertex(vc, v1.x + dx2, v1.y - dy2); - break; - } - } - } - - - - -} - -#endif diff --git a/xs/src/agg/agg_path_length.h b/xs/src/agg/agg_path_length.h deleted file mode 100644 index 740ba31df2..0000000000 --- a/xs/src/agg/agg_path_length.h +++ /dev/null @@ -1,65 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_PATH_LENGTH_INCLUDED -#define AGG_PATH_LENGTH_INCLUDED - -#include "agg_math.h" - -namespace agg -{ - template - double path_length(VertexSource& vs, unsigned path_id = 0) - { - double len = 0.0; - double start_x = 0.0; - double start_y = 0.0; - double x1 = 0.0; - double y1 = 0.0; - double x2 = 0.0; - double y2 = 0.0; - bool first = true; - - unsigned cmd; - vs.rewind(path_id); - while(!is_stop(cmd = vs.vertex(&x2, &y2))) - { - if(is_vertex(cmd)) - { - if(first || is_move_to(cmd)) - { - start_x = x2; - start_y = y2; - } - else - { - len += calc_distance(x1, y1, x2, y2); - } - x1 = x2; - y1 = y2; - first = false; - } - else - { - if(is_close(cmd) && !first) - { - len += calc_distance(x1, y1, start_x, start_y); - } - } - } - return len; - } -} - -#endif diff --git a/xs/src/agg/agg_path_storage_integer.h b/xs/src/agg/agg_path_storage_integer.h deleted file mode 100644 index 7c48355993..0000000000 --- a/xs/src/agg/agg_path_storage_integer.h +++ /dev/null @@ -1,295 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_PATH_STORAGE_INTEGER_INCLUDED -#define AGG_PATH_STORAGE_INTEGER_INCLUDED - -#include -#include "agg_array.h" - -namespace agg -{ - //---------------------------------------------------------vertex_integer - template struct vertex_integer - { - enum path_cmd - { - cmd_move_to = 0, - cmd_line_to = 1, - cmd_curve3 = 2, - cmd_curve4 = 3 - }; - - enum coord_scale_e - { - coord_shift = CoordShift, - coord_scale = 1 << coord_shift - }; - - T x,y; - vertex_integer() {} - vertex_integer(T x_, T y_, unsigned flag) : - x(((x_ << 1) & ~1) | (flag & 1)), - y(((y_ << 1) & ~1) | (flag >> 1)) {} - - unsigned vertex(double* x_, double* y_, - double dx=0, double dy=0, - double scale=1.0) const - { - *x_ = dx + (double(x >> 1) / coord_scale) * scale; - *y_ = dy + (double(y >> 1) / coord_scale) * scale; - switch(((y & 1) << 1) | (x & 1)) - { - case cmd_move_to: return path_cmd_move_to; - case cmd_line_to: return path_cmd_line_to; - case cmd_curve3: return path_cmd_curve3; - case cmd_curve4: return path_cmd_curve4; - } - return path_cmd_stop; - } - }; - - - //---------------------------------------------------path_storage_integer - template class path_storage_integer - { - public: - typedef T value_type; - typedef vertex_integer vertex_integer_type; - - //-------------------------------------------------------------------- - path_storage_integer() : m_storage(), m_vertex_idx(0), m_closed(true) {} - - //-------------------------------------------------------------------- - void remove_all() { m_storage.remove_all(); } - - //-------------------------------------------------------------------- - void move_to(T x, T y) - { - m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_move_to)); - } - - //-------------------------------------------------------------------- - void line_to(T x, T y) - { - m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_line_to)); - } - - //-------------------------------------------------------------------- - void curve3(T x_ctrl, T y_ctrl, - T x_to, T y_to) - { - m_storage.add(vertex_integer_type(x_ctrl, y_ctrl, vertex_integer_type::cmd_curve3)); - m_storage.add(vertex_integer_type(x_to, y_to, vertex_integer_type::cmd_curve3)); - } - - //-------------------------------------------------------------------- - void curve4(T x_ctrl1, T y_ctrl1, - T x_ctrl2, T y_ctrl2, - T x_to, T y_to) - { - m_storage.add(vertex_integer_type(x_ctrl1, y_ctrl1, vertex_integer_type::cmd_curve4)); - m_storage.add(vertex_integer_type(x_ctrl2, y_ctrl2, vertex_integer_type::cmd_curve4)); - m_storage.add(vertex_integer_type(x_to, y_to, vertex_integer_type::cmd_curve4)); - } - - //-------------------------------------------------------------------- - void close_polygon() {} - - //-------------------------------------------------------------------- - unsigned size() const { return m_storage.size(); } - unsigned vertex(unsigned idx, double* x, double* y) const - { - return m_storage[idx].vertex(x, y); - } - - //-------------------------------------------------------------------- - unsigned byte_size() const { return m_storage.size() * sizeof(vertex_integer_type); } - void serialize(int8u* ptr) const - { - unsigned i; - for(i = 0; i < m_storage.size(); i++) - { - memcpy(ptr, &m_storage[i], sizeof(vertex_integer_type)); - ptr += sizeof(vertex_integer_type); - } - } - - //-------------------------------------------------------------------- - void rewind(unsigned) - { - m_vertex_idx = 0; - m_closed = true; - } - - //-------------------------------------------------------------------- - unsigned vertex(double* x, double* y) - { - if(m_storage.size() < 2 || m_vertex_idx > m_storage.size()) - { - *x = 0; - *y = 0; - return path_cmd_stop; - } - if(m_vertex_idx == m_storage.size()) - { - *x = 0; - *y = 0; - ++m_vertex_idx; - return path_cmd_end_poly | path_flags_close; - } - unsigned cmd = m_storage[m_vertex_idx].vertex(x, y); - if(is_move_to(cmd) && !m_closed) - { - *x = 0; - *y = 0; - m_closed = true; - return path_cmd_end_poly | path_flags_close; - } - m_closed = false; - ++m_vertex_idx; - return cmd; - } - - //-------------------------------------------------------------------- - rect_d bounding_rect() const - { - rect_d bounds(1e100, 1e100, -1e100, -1e100); - if(m_storage.size() == 0) - { - bounds.x1 = bounds.y1 = bounds.x2 = bounds.y2 = 0.0; - } - else - { - unsigned i; - for(i = 0; i < m_storage.size(); i++) - { - double x, y; - m_storage[i].vertex(&x, &y); - if(x < bounds.x1) bounds.x1 = x; - if(y < bounds.y1) bounds.y1 = y; - if(x > bounds.x2) bounds.x2 = x; - if(y > bounds.y2) bounds.y2 = y; - } - } - return bounds; - } - - private: - pod_bvector m_storage; - unsigned m_vertex_idx; - bool m_closed; - }; - - - - - //-----------------------------------------serialized_integer_path_adaptor - template class serialized_integer_path_adaptor - { - public: - typedef vertex_integer vertex_integer_type; - - //-------------------------------------------------------------------- - serialized_integer_path_adaptor() : - m_data(0), - m_end(0), - m_ptr(0), - m_dx(0.0), - m_dy(0.0), - m_scale(1.0), - m_vertices(0) - {} - - //-------------------------------------------------------------------- - serialized_integer_path_adaptor(const int8u* data, unsigned size, - double dx, double dy) : - m_data(data), - m_end(data + size), - m_ptr(data), - m_dx(dx), - m_dy(dy), - m_vertices(0) - {} - - //-------------------------------------------------------------------- - void init(const int8u* data, unsigned size, - double dx, double dy, double scale=1.0) - { - m_data = data; - m_end = data + size; - m_ptr = data; - m_dx = dx; - m_dy = dy; - m_scale = scale; - m_vertices = 0; - } - - - //-------------------------------------------------------------------- - void rewind(unsigned) - { - m_ptr = m_data; - m_vertices = 0; - } - - //-------------------------------------------------------------------- - unsigned vertex(double* x, double* y) - { - if(m_data == 0 || m_ptr > m_end) - { - *x = 0; - *y = 0; - return path_cmd_stop; - } - - if(m_ptr == m_end) - { - *x = 0; - *y = 0; - m_ptr += sizeof(vertex_integer_type); - return path_cmd_end_poly | path_flags_close; - } - - vertex_integer_type v; - memcpy(&v, m_ptr, sizeof(vertex_integer_type)); - unsigned cmd = v.vertex(x, y, m_dx, m_dy, m_scale); - if(is_move_to(cmd) && m_vertices > 2) - { - *x = 0; - *y = 0; - m_vertices = 0; - return path_cmd_end_poly | path_flags_close; - } - ++m_vertices; - m_ptr += sizeof(vertex_integer_type); - return cmd; - } - - private: - const int8u* m_data; - const int8u* m_end; - const int8u* m_ptr; - double m_dx; - double m_dy; - double m_scale; - unsigned m_vertices; - }; - -} - - -#endif - diff --git a/xs/src/agg/agg_pattern_filters_rgba.h b/xs/src/agg/agg_pattern_filters_rgba.h deleted file mode 100644 index c1d174cacb..0000000000 --- a/xs/src/agg/agg_pattern_filters_rgba.h +++ /dev/null @@ -1,123 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_PATTERN_FILTERS_RGBA8_INCLUDED -#define AGG_PATTERN_FILTERS_RGBA8_INCLUDED - -#include "agg_basics.h" -#include "agg_line_aa_basics.h" -#include "agg_color_rgba.h" - - -namespace agg -{ - - //=======================================================pattern_filter_nn - template struct pattern_filter_nn - { - typedef ColorT color_type; - static unsigned dilation() { return 0; } - - static void AGG_INLINE pixel_low_res(color_type const* const* buf, - color_type* p, int x, int y) - { - *p = buf[y][x]; - } - - static void AGG_INLINE pixel_high_res(color_type const* const* buf, - color_type* p, int x, int y) - { - *p = buf[y >> line_subpixel_shift] - [x >> line_subpixel_shift]; - } - }; - - typedef pattern_filter_nn pattern_filter_nn_rgba8; - typedef pattern_filter_nn pattern_filter_nn_rgba16; - - - //===========================================pattern_filter_bilinear_rgba - template struct pattern_filter_bilinear_rgba - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - - - static unsigned dilation() { return 1; } - - static AGG_INLINE void pixel_low_res(color_type const* const* buf, - color_type* p, int x, int y) - { - *p = buf[y][x]; - } - - static AGG_INLINE void pixel_high_res(color_type const* const* buf, - color_type* p, int x, int y) - { - calc_type r, g, b, a; - r = g = b = a = 0; - - calc_type weight; - int x_lr = x >> line_subpixel_shift; - int y_lr = y >> line_subpixel_shift; - - x &= line_subpixel_mask; - y &= line_subpixel_mask; - const color_type* ptr = buf[y_lr] + x_lr; - - weight = (line_subpixel_scale - x) * - (line_subpixel_scale - y); - r += weight * ptr->r; - g += weight * ptr->g; - b += weight * ptr->b; - a += weight * ptr->a; - - ++ptr; - - weight = x * (line_subpixel_scale - y); - r += weight * ptr->r; - g += weight * ptr->g; - b += weight * ptr->b; - a += weight * ptr->a; - - ptr = buf[y_lr + 1] + x_lr; - - weight = (line_subpixel_scale - x) * y; - r += weight * ptr->r; - g += weight * ptr->g; - b += weight * ptr->b; - a += weight * ptr->a; - - ++ptr; - - weight = x * y; - r += weight * ptr->r; - g += weight * ptr->g; - b += weight * ptr->b; - a += weight * ptr->a; - - p->r = (value_type)color_type::downshift(r, line_subpixel_shift * 2); - p->g = (value_type)color_type::downshift(g, line_subpixel_shift * 2); - p->b = (value_type)color_type::downshift(b, line_subpixel_shift * 2); - p->a = (value_type)color_type::downshift(a, line_subpixel_shift * 2); - } - }; - - typedef pattern_filter_bilinear_rgba pattern_filter_bilinear_rgba8; - typedef pattern_filter_bilinear_rgba pattern_filter_bilinear_rgba16; - typedef pattern_filter_bilinear_rgba pattern_filter_bilinear_rgba32; -} - -#endif diff --git a/xs/src/agg/agg_pixfmt_amask_adaptor.h b/xs/src/agg/agg_pixfmt_amask_adaptor.h deleted file mode 100644 index 568a74dac9..0000000000 --- a/xs/src/agg/agg_pixfmt_amask_adaptor.h +++ /dev/null @@ -1,240 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED -#define AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED - - -#include -#include "agg_array.h" -#include "agg_rendering_buffer.h" - - -namespace agg -{ - //==================================================pixfmt_amask_adaptor - template class pixfmt_amask_adaptor - { - public: - typedef PixFmt pixfmt_type; - typedef typename pixfmt_type::color_type color_type; - typedef typename pixfmt_type::row_data row_data; - typedef AlphaMask amask_type; - typedef typename amask_type::cover_type cover_type; - - private: - enum span_extra_tail_e { span_extra_tail = 256 }; - - void realloc_span(unsigned len) - { - if(len > m_span.size()) - { - m_span.resize(len + span_extra_tail); - } - } - - void init_span(unsigned len) - { - realloc_span(len); - memset(&m_span[0], amask_type::cover_full, len * sizeof(cover_type)); - } - - void init_span(unsigned len, const cover_type* covers) - { - realloc_span(len); - memcpy(&m_span[0], covers, len * sizeof(cover_type)); - } - - - public: - pixfmt_amask_adaptor(pixfmt_type& pixf, amask_type& mask) : - m_pixf(&pixf), m_mask(&mask), m_span() - {} - - void attach_pixfmt(pixfmt_type& pixf) { m_pixf = &pixf; } - void attach_alpha_mask(amask_type& mask) { m_mask = &mask; } - - //-------------------------------------------------------------------- - template - bool attach_pixfmt(PixFmt2& pixf, int x1, int y1, int x2, int y2) - { - return m_pixf->attach(pixf, x1, y1, x2, y2); - } - - //-------------------------------------------------------------------- - unsigned width() const { return m_pixf->width(); } - unsigned height() const { return m_pixf->height(); } - - //-------------------------------------------------------------------- - color_type pixel(int x, int y) - { - return m_pixf->pixel(x, y); - } - - //-------------------------------------------------------------------- - void copy_pixel(int x, int y, const color_type& c) - { - m_pixf->blend_pixel(x, y, c, m_mask->pixel(x, y)); - } - - //-------------------------------------------------------------------- - void blend_pixel(int x, int y, const color_type& c, cover_type cover) - { - m_pixf->blend_pixel(x, y, c, m_mask->combine_pixel(x, y, cover)); - } - - //-------------------------------------------------------------------- - void copy_hline(int x, int y, - unsigned len, - const color_type& c) - { - realloc_span(len); - m_mask->fill_hspan(x, y, &m_span[0], len); - m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); - } - - //-------------------------------------------------------------------- - void blend_hline(int x, int y, - unsigned len, - const color_type& c, - cover_type) - { - init_span(len); - m_mask->combine_hspan(x, y, &m_span[0], len); - m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); - } - - //-------------------------------------------------------------------- - void copy_vline(int x, int y, - unsigned len, - const color_type& c) - { - realloc_span(len); - m_mask->fill_vspan(x, y, &m_span[0], len); - m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); - } - - //-------------------------------------------------------------------- - void blend_vline(int x, int y, - unsigned len, - const color_type& c, - cover_type) - { - init_span(len); - m_mask->combine_vspan(x, y, &m_span[0], len); - m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); - } - - //-------------------------------------------------------------------- - void copy_from(const rendering_buffer& from, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len) - { - m_pixf->copy_from(from, xdst, ydst, xsrc, ysrc, len); - } - - - //-------------------------------------------------------------------- - void blend_solid_hspan(int x, int y, - unsigned len, - const color_type& c, - const cover_type* covers) - { - init_span(len, covers); - m_mask->combine_hspan(x, y, &m_span[0], len); - m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); - } - - - //-------------------------------------------------------------------- - void blend_solid_vspan(int x, int y, - unsigned len, - const color_type& c, - const cover_type* covers) - { - init_span(len, covers); - m_mask->combine_vspan(x, y, &m_span[0], len); - m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); - } - - - //-------------------------------------------------------------------- - void copy_color_hspan(int x, int y, unsigned len, const color_type* colors) - { - realloc_span(len); - m_mask->fill_hspan(x, y, &m_span[0], len); - m_pixf->blend_color_hspan(x, y, len, colors, &m_span[0], cover_full); - } - - //-------------------------------------------------------------------- - void copy_color_vspan(int x, int y, unsigned len, const color_type* colors) - { - realloc_span(len); - m_mask->fill_vspan(x, y, &m_span[0], len); - m_pixf->blend_color_vspan(x, y, len, colors, &m_span[0], cover_full); - } - - //-------------------------------------------------------------------- - void blend_color_hspan(int x, int y, - unsigned len, - const color_type* colors, - const cover_type* covers, - cover_type cover = cover_full) - { - if(covers) - { - init_span(len, covers); - m_mask->combine_hspan(x, y, &m_span[0], len); - } - else - { - realloc_span(len); - m_mask->fill_hspan(x, y, &m_span[0], len); - } - m_pixf->blend_color_hspan(x, y, len, colors, &m_span[0], cover); - } - - - //-------------------------------------------------------------------- - void blend_color_vspan(int x, int y, - unsigned len, - const color_type* colors, - const cover_type* covers, - cover_type cover = cover_full) - { - if(covers) - { - init_span(len, covers); - m_mask->combine_vspan(x, y, &m_span[0], len); - } - else - { - realloc_span(len); - m_mask->fill_vspan(x, y, &m_span[0], len); - } - m_pixf->blend_color_vspan(x, y, len, colors, &m_span[0], cover); - } - - private: - pixfmt_type* m_pixf; - const amask_type* m_mask; - pod_array m_span; - }; - -} - -#endif - diff --git a/xs/src/agg/agg_pixfmt_rgb_packed.h b/xs/src/agg/agg_pixfmt_rgb_packed.h deleted file mode 100644 index 9152cf060f..0000000000 --- a/xs/src/agg/agg_pixfmt_rgb_packed.h +++ /dev/null @@ -1,1311 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_PIXFMT_RGB_PACKED_INCLUDED -#define AGG_PIXFMT_RGB_PACKED_INCLUDED - -#include -#include "agg_basics.h" -#include "agg_color_rgba.h" -#include "agg_rendering_buffer.h" - -namespace agg -{ - //=========================================================blender_rgb555 - struct blender_rgb555 - { - typedef rgba8 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int16u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type rgb = *p; - calc_type r = (rgb >> 7) & 0xF8; - calc_type g = (rgb >> 2) & 0xF8; - calc_type b = (rgb << 3) & 0xF8; - *p = (pixel_type) - (((((cr - r) * alpha + (r << 8)) >> 1) & 0x7C00) | - ((((cg - g) * alpha + (g << 8)) >> 6) & 0x03E0) | - (((cb - b) * alpha + (b << 8)) >> 11) | 0x8000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xF8) << 7) | - ((g & 0xF8) << 2) | - (b >> 3) | 0x8000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 7) & 0xF8, - (p >> 2) & 0xF8, - (p << 3) & 0xF8); - } - }; - - - //=====================================================blender_rgb555_pre - struct blender_rgb555_pre - { - typedef rgba8 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int16u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned cover) - { - alpha = color_type::base_mask - alpha; - pixel_type rgb = *p; - calc_type r = (rgb >> 7) & 0xF8; - calc_type g = (rgb >> 2) & 0xF8; - calc_type b = (rgb << 3) & 0xF8; - *p = (pixel_type) - ((((r * alpha + cr * cover) >> 1) & 0x7C00) | - (((g * alpha + cg * cover) >> 6) & 0x03E0) | - ((b * alpha + cb * cover) >> 11) | 0x8000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xF8) << 7) | - ((g & 0xF8) << 2) | - (b >> 3) | 0x8000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 7) & 0xF8, - (p >> 2) & 0xF8, - (p << 3) & 0xF8); - } - }; - - - - - //=====================================================blender_rgb555_gamma - template class blender_rgb555_gamma - { - public: - typedef rgba8 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int16u pixel_type; - typedef Gamma gamma_type; - - blender_rgb555_gamma() : m_gamma(0) {} - void gamma(const gamma_type& g) { m_gamma = &g; } - - AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type rgb = *p; - calc_type r = m_gamma->dir((rgb >> 7) & 0xF8); - calc_type g = m_gamma->dir((rgb >> 2) & 0xF8); - calc_type b = m_gamma->dir((rgb << 3) & 0xF8); - *p = (pixel_type) - (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 8)) >> 8) << 7) & 0x7C00) | - ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 8)) >> 8) << 2) & 0x03E0) | - (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 8)) >> 8) >> 3) | 0x8000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xF8) << 7) | - ((g & 0xF8) << 2) | - (b >> 3) | 0x8000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 7) & 0xF8, - (p >> 2) & 0xF8, - (p << 3) & 0xF8); - } - - private: - const Gamma* m_gamma; - }; - - - - - - //=========================================================blender_rgb565 - struct blender_rgb565 - { - typedef rgba8 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int16u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type rgb = *p; - calc_type r = (rgb >> 8) & 0xF8; - calc_type g = (rgb >> 3) & 0xFC; - calc_type b = (rgb << 3) & 0xF8; - *p = (pixel_type) - (((((cr - r) * alpha + (r << 8)) ) & 0xF800) | - ((((cg - g) * alpha + (g << 8)) >> 5) & 0x07E0) | - (((cb - b) * alpha + (b << 8)) >> 11)); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 8) & 0xF8, - (p >> 3) & 0xFC, - (p << 3) & 0xF8); - } - }; - - - - //=====================================================blender_rgb565_pre - struct blender_rgb565_pre - { - typedef rgba8 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int16u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned cover) - { - alpha = color_type::base_mask - alpha; - pixel_type rgb = *p; - calc_type r = (rgb >> 8) & 0xF8; - calc_type g = (rgb >> 3) & 0xFC; - calc_type b = (rgb << 3) & 0xF8; - *p = (pixel_type) - ((((r * alpha + cr * cover) ) & 0xF800) | - (((g * alpha + cg * cover) >> 5 ) & 0x07E0) | - ((b * alpha + cb * cover) >> 11)); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 8) & 0xF8, - (p >> 3) & 0xFC, - (p << 3) & 0xF8); - } - }; - - - - //=====================================================blender_rgb565_gamma - template class blender_rgb565_gamma - { - public: - typedef rgba8 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int16u pixel_type; - typedef Gamma gamma_type; - - blender_rgb565_gamma() : m_gamma(0) {} - void gamma(const gamma_type& g) { m_gamma = &g; } - - AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type rgb = *p; - calc_type r = m_gamma->dir((rgb >> 8) & 0xF8); - calc_type g = m_gamma->dir((rgb >> 3) & 0xFC); - calc_type b = m_gamma->dir((rgb << 3) & 0xF8); - *p = (pixel_type) - (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 8)) >> 8) << 8) & 0xF800) | - ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 8)) >> 8) << 3) & 0x07E0) | - (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 8)) >> 8) >> 3)); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 8) & 0xF8, - (p >> 3) & 0xFC, - (p << 3) & 0xF8); - } - - private: - const Gamma* m_gamma; - }; - - - - //=====================================================blender_rgbAAA - struct blender_rgbAAA - { - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type rgb = *p; - calc_type r = (rgb >> 14) & 0xFFC0; - calc_type g = (rgb >> 4) & 0xFFC0; - calc_type b = (rgb << 6) & 0xFFC0; - *p = (pixel_type) - (((((cr - r) * alpha + (r << 16)) >> 2) & 0x3FF00000) | - ((((cg - g) * alpha + (g << 16)) >> 12) & 0x000FFC00) | - (((cb - b) * alpha + (b << 16)) >> 22) | 0xC0000000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xFFC0) << 14) | - ((g & 0xFFC0) << 4) | - (b >> 6) | 0xC0000000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 14) & 0xFFC0, - (p >> 4) & 0xFFC0, - (p << 6) & 0xFFC0); - } - }; - - - - //==================================================blender_rgbAAA_pre - struct blender_rgbAAA_pre - { - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned cover) - { - alpha = color_type::base_mask - alpha; - cover = (cover + 1) << (color_type::base_shift - 8); - pixel_type rgb = *p; - calc_type r = (rgb >> 14) & 0xFFC0; - calc_type g = (rgb >> 4) & 0xFFC0; - calc_type b = (rgb << 6) & 0xFFC0; - *p = (pixel_type) - ((((r * alpha + cr * cover) >> 2) & 0x3FF00000) | - (((g * alpha + cg * cover) >> 12) & 0x000FFC00) | - ((b * alpha + cb * cover) >> 22) | 0xC0000000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xFFC0) << 14) | - ((g & 0xFFC0) << 4) | - (b >> 6) | 0xC0000000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 14) & 0xFFC0, - (p >> 4) & 0xFFC0, - (p << 6) & 0xFFC0); - } - }; - - - - //=================================================blender_rgbAAA_gamma - template class blender_rgbAAA_gamma - { - public: - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - typedef Gamma gamma_type; - - blender_rgbAAA_gamma() : m_gamma(0) {} - void gamma(const gamma_type& g) { m_gamma = &g; } - - AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type rgb = *p; - calc_type r = m_gamma->dir((rgb >> 14) & 0xFFC0); - calc_type g = m_gamma->dir((rgb >> 4) & 0xFFC0); - calc_type b = m_gamma->dir((rgb << 6) & 0xFFC0); - *p = (pixel_type) - (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) << 14) & 0x3FF00000) | - ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 4 ) & 0x000FFC00) | - (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) >> 6 ) | 0xC0000000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xFFC0) << 14) | - ((g & 0xFFC0) << 4) | - (b >> 6) | 0xC0000000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 14) & 0xFFC0, - (p >> 4) & 0xFFC0, - (p << 6) & 0xFFC0); - } - private: - const Gamma* m_gamma; - }; - - - //=====================================================blender_bgrAAA - struct blender_bgrAAA - { - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type bgr = *p; - calc_type b = (bgr >> 14) & 0xFFC0; - calc_type g = (bgr >> 4) & 0xFFC0; - calc_type r = (bgr << 6) & 0xFFC0; - *p = (pixel_type) - (((((cb - b) * alpha + (b << 16)) >> 2) & 0x3FF00000) | - ((((cg - g) * alpha + (g << 16)) >> 12) & 0x000FFC00) | - (((cr - r) * alpha + (r << 16)) >> 22) | 0xC0000000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((b & 0xFFC0) << 14) | - ((g & 0xFFC0) << 4) | - (r >> 6) | 0xC0000000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p << 6) & 0xFFC0, - (p >> 4) & 0xFFC0, - (p >> 14) & 0xFFC0); - } - }; - - - - //=================================================blender_bgrAAA_pre - struct blender_bgrAAA_pre - { - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned cover) - { - alpha = color_type::base_mask - alpha; - cover = (cover + 1) << (color_type::base_shift - 8); - pixel_type bgr = *p; - calc_type b = (bgr >> 14) & 0xFFC0; - calc_type g = (bgr >> 4) & 0xFFC0; - calc_type r = (bgr << 6) & 0xFFC0; - *p = (pixel_type) - ((((b * alpha + cb * cover) >> 2) & 0x3FF00000) | - (((g * alpha + cg * cover) >> 12) & 0x000FFC00) | - ((r * alpha + cr * cover) >> 22) | 0xC0000000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((b & 0xFFC0) << 14) | - ((g & 0xFFC0) << 4) | - (r >> 6) | 0xC0000000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p << 6) & 0xFFC0, - (p >> 4) & 0xFFC0, - (p >> 14) & 0xFFC0); - } - }; - - - - //=================================================blender_bgrAAA_gamma - template class blender_bgrAAA_gamma - { - public: - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - typedef Gamma gamma_type; - - blender_bgrAAA_gamma() : m_gamma(0) {} - void gamma(const gamma_type& g) { m_gamma = &g; } - - AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type bgr = *p; - calc_type b = m_gamma->dir((bgr >> 14) & 0xFFC0); - calc_type g = m_gamma->dir((bgr >> 4) & 0xFFC0); - calc_type r = m_gamma->dir((bgr << 6) & 0xFFC0); - *p = (pixel_type) - (((m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) << 14) & 0x3FF00000) | - ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 4 ) & 0x000FFC00) | - (m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) >> 6 ) | 0xC0000000); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((b & 0xFFC0) << 14) | - ((g & 0xFFC0) << 4) | - (r >> 6) | 0xC0000000); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p << 6) & 0xFFC0, - (p >> 4) & 0xFFC0, - (p >> 14) & 0xFFC0); - } - - private: - const Gamma* m_gamma; - }; - - - - //=====================================================blender_rgbBBA - struct blender_rgbBBA - { - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type rgb = *p; - calc_type r = (rgb >> 16) & 0xFFE0; - calc_type g = (rgb >> 5) & 0xFFE0; - calc_type b = (rgb << 6) & 0xFFC0; - *p = (pixel_type) - (((((cr - r) * alpha + (r << 16)) ) & 0xFFE00000) | - ((((cg - g) * alpha + (g << 16)) >> 11) & 0x001FFC00) | - (((cb - b) * alpha + (b << 16)) >> 22)); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 16) & 0xFFE0, - (p >> 5) & 0xFFE0, - (p << 6) & 0xFFC0); - } - }; - - - //=================================================blender_rgbBBA_pre - struct blender_rgbBBA_pre - { - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned cover) - { - alpha = color_type::base_mask - alpha; - cover = (cover + 1) << (color_type::base_shift - 8); - pixel_type rgb = *p; - calc_type r = (rgb >> 16) & 0xFFE0; - calc_type g = (rgb >> 5) & 0xFFE0; - calc_type b = (rgb << 6) & 0xFFC0; - *p = (pixel_type) - ((((r * alpha + cr * cover) ) & 0xFFE00000) | - (((g * alpha + cg * cover) >> 11) & 0x001FFC00) | - ((b * alpha + cb * cover) >> 22)); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 16) & 0xFFE0, - (p >> 5) & 0xFFE0, - (p << 6) & 0xFFC0); - } - }; - - - - //=================================================blender_rgbBBA_gamma - template class blender_rgbBBA_gamma - { - public: - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - typedef Gamma gamma_type; - - blender_rgbBBA_gamma() : m_gamma(0) {} - void gamma(const gamma_type& g) { m_gamma = &g; } - - AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type rgb = *p; - calc_type r = m_gamma->dir((rgb >> 16) & 0xFFE0); - calc_type g = m_gamma->dir((rgb >> 5) & 0xFFE0); - calc_type b = m_gamma->dir((rgb << 6) & 0xFFC0); - *p = (pixel_type) - (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) << 16) & 0xFFE00000) | - ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 5 ) & 0x001FFC00) | - (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) >> 6 )); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p >> 16) & 0xFFE0, - (p >> 5) & 0xFFE0, - (p << 6) & 0xFFC0); - } - - private: - const Gamma* m_gamma; - }; - - - //=====================================================blender_bgrABB - struct blender_bgrABB - { - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type bgr = *p; - calc_type b = (bgr >> 16) & 0xFFC0; - calc_type g = (bgr >> 6) & 0xFFE0; - calc_type r = (bgr << 5) & 0xFFE0; - *p = (pixel_type) - (((((cb - b) * alpha + (b << 16)) ) & 0xFFC00000) | - ((((cg - g) * alpha + (g << 16)) >> 10) & 0x003FF800) | - (((cr - r) * alpha + (r << 16)) >> 21)); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p << 5) & 0xFFE0, - (p >> 6) & 0xFFE0, - (p >> 16) & 0xFFC0); - } - }; - - - //=================================================blender_bgrABB_pre - struct blender_bgrABB_pre - { - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - - static AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned cover) - { - alpha = color_type::base_mask - alpha; - cover = (cover + 1) << (color_type::base_shift - 8); - pixel_type bgr = *p; - calc_type b = (bgr >> 16) & 0xFFC0; - calc_type g = (bgr >> 6) & 0xFFE0; - calc_type r = (bgr << 5) & 0xFFE0; - *p = (pixel_type) - ((((b * alpha + cb * cover) ) & 0xFFC00000) | - (((g * alpha + cg * cover) >> 10) & 0x003FF800) | - ((r * alpha + cr * cover) >> 21)); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p << 5) & 0xFFE0, - (p >> 6) & 0xFFE0, - (p >> 16) & 0xFFC0); - } - }; - - - - //=================================================blender_bgrABB_gamma - template class blender_bgrABB_gamma - { - public: - typedef rgba16 color_type; - typedef color_type::value_type value_type; - typedef color_type::calc_type calc_type; - typedef int32u pixel_type; - typedef Gamma gamma_type; - - blender_bgrABB_gamma() : m_gamma(0) {} - void gamma(const gamma_type& g) { m_gamma = &g; } - - AGG_INLINE void blend_pix(pixel_type* p, - unsigned cr, unsigned cg, unsigned cb, - unsigned alpha, - unsigned) - { - pixel_type bgr = *p; - calc_type b = m_gamma->dir((bgr >> 16) & 0xFFC0); - calc_type g = m_gamma->dir((bgr >> 6) & 0xFFE0); - calc_type r = m_gamma->dir((bgr << 5) & 0xFFE0); - *p = (pixel_type) - (((m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) << 16) & 0xFFC00000) | - ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 6 ) & 0x003FF800) | - (m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) >> 5 )); - } - - static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) - { - return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); - } - - static AGG_INLINE color_type make_color(pixel_type p) - { - return color_type((p << 5) & 0xFFE0, - (p >> 6) & 0xFFE0, - (p >> 16) & 0xFFC0); - } - - private: - const Gamma* m_gamma; - }; - - - - //===========================================pixfmt_alpha_blend_rgb_packed - template class pixfmt_alpha_blend_rgb_packed - { - public: - typedef RenBuf rbuf_type; - typedef typename rbuf_type::row_data row_data; - typedef Blender blender_type; - typedef typename blender_type::color_type color_type; - typedef typename blender_type::pixel_type pixel_type; - typedef int order_type; // A fake one - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - enum base_scale_e - { - base_shift = color_type::base_shift, - base_scale = color_type::base_scale, - base_mask = color_type::base_mask, - pix_width = sizeof(pixel_type), - }; - - private: - //-------------------------------------------------------------------- - AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover) - { - if (c.a) - { - calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; - if(alpha == base_mask) - { - *p = m_blender.make_pix(c.r, c.g, c.b); - } - else - { - m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); - } - } - } - - public: - //-------------------------------------------------------------------- - explicit pixfmt_alpha_blend_rgb_packed(rbuf_type& rb) : m_rbuf(&rb) {} - void attach(rbuf_type& rb) { m_rbuf = &rb; } - - //-------------------------------------------------------------------- - template - bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) - { - rect_i r(x1, y1, x2, y2); - if(r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) - { - int stride = pixf.stride(); - m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), - (r.x2 - r.x1) + 1, - (r.y2 - r.y1) + 1, - stride); - return true; - } - return false; - } - - Blender& blender() { return m_blender; } - - //-------------------------------------------------------------------- - AGG_INLINE unsigned width() const { return m_rbuf->width(); } - AGG_INLINE unsigned height() const { return m_rbuf->height(); } - AGG_INLINE int stride() const { return m_rbuf->stride(); } - - //-------------------------------------------------------------------- - AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } - AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } - AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); } - - //-------------------------------------------------------------------- - AGG_INLINE int8u* pix_ptr(int x, int y) - { - return m_rbuf->row_ptr(y) + x * pix_width; - } - - AGG_INLINE const int8u* pix_ptr(int x, int y) const - { - return m_rbuf->row_ptr(y) + x * pix_width; - } - - //-------------------------------------------------------------------- - AGG_INLINE void make_pix(int8u* p, const color_type& c) - { - *(pixel_type*)p = m_blender.make_pix(c.r, c.g, c.b); - } - - //-------------------------------------------------------------------- - AGG_INLINE color_type pixel(int x, int y) const - { - return m_blender.make_color(((pixel_type*)m_rbuf->row_ptr(y))[x]); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_pixel(int x, int y, const color_type& c) - { - ((pixel_type*) - m_rbuf->row_ptr(x, y, 1))[x] = - m_blender.make_pix(c.r, c.g, c.b); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) - { - copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y, 1) + x, c, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_hline(int x, int y, - unsigned len, - const color_type& c) - { - pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; - pixel_type v = m_blender.make_pix(c.r, c.g, c.b); - do - { - *p++ = v; - } - while(--len); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_vline(int x, int y, - unsigned len, - const color_type& c) - { - pixel_type v = m_blender.make_pix(c.r, c.g, c.b); - do - { - pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x; - *p = v; - } - while(--len); - } - - //-------------------------------------------------------------------- - void blend_hline(int x, int y, - unsigned len, - const color_type& c, - int8u cover) - { - if (c.a) - { - pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; - calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; - if(alpha == base_mask) - { - pixel_type v = m_blender.make_pix(c.r, c.g, c.b); - do - { - *p++ = v; - } - while(--len); - } - else - { - do - { - m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); - ++p; - } - while(--len); - } - } - } - - //-------------------------------------------------------------------- - void blend_vline(int x, int y, - unsigned len, - const color_type& c, - int8u cover) - { - if (c.a) - { - calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; - if(alpha == base_mask) - { - pixel_type v = m_blender.make_pix(c.r, c.g, c.b); - do - { - ((pixel_type*)m_rbuf->row_ptr(x, y++, 1))[x] = v; - } - while(--len); - } - else - { - do - { - m_blender.blend_pix( - (pixel_type*)m_rbuf->row_ptr(x, y++, 1), - c.r, c.g, c.b, alpha, cover); - } - while(--len); - } - } - } - - //-------------------------------------------------------------------- - void blend_solid_hspan(int x, int y, - unsigned len, - const color_type& c, - const int8u* covers) - { - pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; - do - { - copy_or_blend_pix(p, c, *covers++); - ++p; - } - while(--len); - } - - //-------------------------------------------------------------------- - void blend_solid_vspan(int x, int y, - unsigned len, - const color_type& c, - const int8u* covers) - { - do - { - copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x, - c, *covers++); - } - while(--len); - } - - //-------------------------------------------------------------------- - void copy_color_hspan(int x, int y, - unsigned len, - const color_type* colors) - { - pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; - do - { - *p++ = m_blender.make_pix(colors->r, colors->g, colors->b); - ++colors; - } - while(--len); - } - - //-------------------------------------------------------------------- - void copy_color_vspan(int x, int y, - unsigned len, - const color_type* colors) - { - do - { - pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x; - *p = m_blender.make_pix(colors->r, colors->g, colors->b); - ++colors; - } - while(--len); - } - - //-------------------------------------------------------------------- - void blend_color_hspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; - do - { - copy_or_blend_pix(p++, *colors++, covers ? *covers++ : cover); - } - while(--len); - } - - //-------------------------------------------------------------------- - void blend_color_vspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - do - { - copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x, - *colors++, covers ? *covers++ : cover); - } - while(--len); - } - - //-------------------------------------------------------------------- - template - void copy_from(const RenBuf2& from, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len) - { - const int8u* p = from.row_ptr(ysrc); - if(p) - { - memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, - p + xsrc * pix_width, - len * pix_width); - } - } - - //-------------------------------------------------------------------- - template - void blend_from(const SrcPixelFormatRenderer& from, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::order_type src_order; - - const value_type* psrc = (const value_type*)from.row_ptr(ysrc); - if(psrc) - { - psrc += xsrc * 4; - pixel_type* pdst = - (pixel_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; - do - { - value_type alpha = psrc[src_order::A]; - if(alpha) - { - if(alpha == base_mask && cover == 255) - { - *pdst = m_blender.make_pix(psrc[src_order::R], - psrc[src_order::G], - psrc[src_order::B]); - } - else - { - m_blender.blend_pix(pdst, - psrc[src_order::R], - psrc[src_order::G], - psrc[src_order::B], - alpha, - cover); - } - } - psrc += 4; - ++pdst; - } - while(--len); - } - } - - //-------------------------------------------------------------------- - template - void blend_from_color(const SrcPixelFormatRenderer& from, - const color_type& color, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::value_type src_value_type; - const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc); - if(psrc) - { - psrc += xsrc * SrcPixelFormatRenderer::pix_step + SrcPixelFormatRenderer::pix_offset; - pixel_type* pdst = - (pixel_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; - - do - { - m_blender.blend_pix(pdst, - color.r, color.g, color.b, color.a, - cover); - psrc += SrcPixelFormatRenderer::pix_step; - ++pdst; - } - while(--len); - } - } - - //-------------------------------------------------------------------- - template - void blend_from_lut(const SrcPixelFormatRenderer& from, - const color_type* color_lut, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::value_type src_value_type; - const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc); - if(psrc) - { - psrc += xsrc * SrcPixelFormatRenderer::pix_step + SrcPixelFormatRenderer::pix_offset; - pixel_type* pdst = - (pixel_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; - - do - { - const color_type& color = color_lut[*psrc]; - m_blender.blend_pix(pdst, - color.r, color.g, color.b, color.a, - cover); - psrc += SrcPixelFormatRenderer::pix_step; - ++pdst; - } - while(--len); - } - } - - - - private: - rbuf_type* m_rbuf; - Blender m_blender; - }; - - typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb555; //----pixfmt_rgb555 - typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb565; //----pixfmt_rgb565 - - typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb555_pre; //----pixfmt_rgb555_pre - typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb565_pre; //----pixfmt_rgb565_pre - - typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbAAA; //----pixfmt_rgbAAA - typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrAAA; //----pixfmt_bgrAAA - typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbBBA; //----pixfmt_rgbBBA - typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrABB; //----pixfmt_bgrABB - - typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbAAA_pre; //----pixfmt_rgbAAA_pre - typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrAAA_pre; //----pixfmt_bgrAAA_pre - typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbBBA_pre; //----pixfmt_rgbBBA_pre - typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrABB_pre; //----pixfmt_bgrABB_pre - - - //-----------------------------------------------------pixfmt_rgb555_gamma - template class pixfmt_rgb555_gamma : - public pixfmt_alpha_blend_rgb_packed, - rendering_buffer> - { - public: - pixfmt_rgb555_gamma(rendering_buffer& rb, const Gamma& g) : - pixfmt_alpha_blend_rgb_packed, - rendering_buffer>(rb) - { - this->blender().gamma(g); - } - }; - - - //-----------------------------------------------------pixfmt_rgb565_gamma - template class pixfmt_rgb565_gamma : - public pixfmt_alpha_blend_rgb_packed, rendering_buffer> - { - public: - pixfmt_rgb565_gamma(rendering_buffer& rb, const Gamma& g) : - pixfmt_alpha_blend_rgb_packed, rendering_buffer>(rb) - { - this->blender().gamma(g); - } - }; - - - //-----------------------------------------------------pixfmt_rgbAAA_gamma - template class pixfmt_rgbAAA_gamma : - public pixfmt_alpha_blend_rgb_packed, - rendering_buffer> - { - public: - pixfmt_rgbAAA_gamma(rendering_buffer& rb, const Gamma& g) : - pixfmt_alpha_blend_rgb_packed, - rendering_buffer>(rb) - { - this->blender().gamma(g); - } - }; - - - //-----------------------------------------------------pixfmt_bgrAAA_gamma - template class pixfmt_bgrAAA_gamma : - public pixfmt_alpha_blend_rgb_packed, - rendering_buffer> - { - public: - pixfmt_bgrAAA_gamma(rendering_buffer& rb, const Gamma& g) : - pixfmt_alpha_blend_rgb_packed, - rendering_buffer>(rb) - { - this->blender().gamma(g); - } - }; - - - //-----------------------------------------------------pixfmt_rgbBBA_gamma - template class pixfmt_rgbBBA_gamma : - public pixfmt_alpha_blend_rgb_packed, - rendering_buffer> - { - public: - pixfmt_rgbBBA_gamma(rendering_buffer& rb, const Gamma& g) : - pixfmt_alpha_blend_rgb_packed, - rendering_buffer>(rb) - { - this->blender().gamma(g); - } - }; - - - //-----------------------------------------------------pixfmt_bgrABB_gamma - template class pixfmt_bgrABB_gamma : - public pixfmt_alpha_blend_rgb_packed, - rendering_buffer> - { - public: - pixfmt_bgrABB_gamma(rendering_buffer& rb, const Gamma& g) : - pixfmt_alpha_blend_rgb_packed, - rendering_buffer>(rb) - { - this->blender().gamma(g); - } - }; - - -} - -#endif - diff --git a/xs/src/agg/agg_pixfmt_rgba.h b/xs/src/agg/agg_pixfmt_rgba.h deleted file mode 100644 index 9c4ab449ac..0000000000 --- a/xs/src/agg/agg_pixfmt_rgba.h +++ /dev/null @@ -1,2803 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_PIXFMT_RGBA_INCLUDED -#define AGG_PIXFMT_RGBA_INCLUDED - -#include -#include -#include "agg_pixfmt_base.h" -#include "agg_rendering_buffer.h" - -namespace agg -{ - template inline T sd_min(T a, T b) { return (a < b) ? a : b; } - template inline T sd_max(T a, T b) { return (a > b) ? a : b; } - - inline rgba & clip(rgba & c) - { - if (c.a > 1) c.a = 1; else if (c.a < 0) c.a = 0; - if (c.r > c.a) c.r = c.a; else if (c.r < 0) c.r = 0; - if (c.g > c.a) c.g = c.a; else if (c.g < 0) c.g = 0; - if (c.b > c.a) c.b = c.a; else if (c.b < 0) c.b = 0; - return c; - } - - //=========================================================multiplier_rgba - template - struct multiplier_rgba - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - - //-------------------------------------------------------------------- - static AGG_INLINE void premultiply(value_type* p) - { - value_type a = p[Order::A]; - p[Order::R] = color_type::multiply(p[Order::R], a); - p[Order::G] = color_type::multiply(p[Order::G], a); - p[Order::B] = color_type::multiply(p[Order::B], a); - } - - - //-------------------------------------------------------------------- - static AGG_INLINE void demultiply(value_type* p) - { - value_type a = p[Order::A]; - p[Order::R] = color_type::demultiply(p[Order::R], a); - p[Order::G] = color_type::demultiply(p[Order::G], a); - p[Order::B] = color_type::demultiply(p[Order::B], a); - } - }; - - //=====================================================apply_gamma_dir_rgba - template - class apply_gamma_dir_rgba - { - public: - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - - apply_gamma_dir_rgba(const GammaLut& gamma) : m_gamma(gamma) {} - - AGG_INLINE void operator () (value_type* p) - { - p[Order::R] = m_gamma.dir(p[Order::R]); - p[Order::G] = m_gamma.dir(p[Order::G]); - p[Order::B] = m_gamma.dir(p[Order::B]); - } - - private: - const GammaLut& m_gamma; - }; - - //=====================================================apply_gamma_inv_rgba - template class apply_gamma_inv_rgba - { - public: - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - - apply_gamma_inv_rgba(const GammaLut& gamma) : m_gamma(gamma) {} - - AGG_INLINE void operator () (value_type* p) - { - p[Order::R] = m_gamma.inv(p[Order::R]); - p[Order::G] = m_gamma.inv(p[Order::G]); - p[Order::B] = m_gamma.inv(p[Order::B]); - } - - private: - const GammaLut& m_gamma; - }; - - - template - struct conv_rgba_pre - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - - //-------------------------------------------------------------------- - static AGG_INLINE void set_plain_color(value_type* p, color_type c) - { - c.premultiply(); - p[Order::R] = c.r; - p[Order::G] = c.g; - p[Order::B] = c.b; - p[Order::A] = c.a; - } - - //-------------------------------------------------------------------- - static AGG_INLINE color_type get_plain_color(const value_type* p) - { - return color_type( - p[Order::R], - p[Order::G], - p[Order::B], - p[Order::A]).demultiply(); - } - }; - - template - struct conv_rgba_plain - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - - //-------------------------------------------------------------------- - static AGG_INLINE void set_plain_color(value_type* p, color_type c) - { - p[Order::R] = c.r; - p[Order::G] = c.g; - p[Order::B] = c.b; - p[Order::A] = c.a; - } - - //-------------------------------------------------------------------- - static AGG_INLINE color_type get_plain_color(const value_type* p) - { - return color_type( - p[Order::R], - p[Order::G], - p[Order::B], - p[Order::A]); - } - }; - - //=============================================================blender_rgba - // Blends "plain" (i.e. non-premultiplied) colors into a premultiplied buffer. - template - struct blender_rgba : conv_rgba_pre - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - // Blend pixels using the non-premultiplied form of Alvy-Ray Smith's - // compositing function. Since the render buffer is in fact premultiplied - // we omit the initial premultiplication and final demultiplication. - - //-------------------------------------------------------------------- - static AGG_INLINE void blend_pix(value_type* p, - value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) - { - blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover)); - } - - //-------------------------------------------------------------------- - static AGG_INLINE void blend_pix(value_type* p, - value_type cr, value_type cg, value_type cb, value_type alpha) - { - p[Order::R] = color_type::lerp(p[Order::R], cr, alpha); - p[Order::G] = color_type::lerp(p[Order::G], cg, alpha); - p[Order::B] = color_type::lerp(p[Order::B], cb, alpha); - p[Order::A] = color_type::prelerp(p[Order::A], alpha, alpha); - } - }; - - - //========================================================blender_rgba_pre - // Blends premultiplied colors into a premultiplied buffer. - template - struct blender_rgba_pre : conv_rgba_pre - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - // Blend pixels using the premultiplied form of Alvy-Ray Smith's - // compositing function. - - //-------------------------------------------------------------------- - static AGG_INLINE void blend_pix(value_type* p, - value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) - { - blend_pix(p, - color_type::mult_cover(cr, cover), - color_type::mult_cover(cg, cover), - color_type::mult_cover(cb, cover), - color_type::mult_cover(alpha, cover)); - } - - //-------------------------------------------------------------------- - static AGG_INLINE void blend_pix(value_type* p, - value_type cr, value_type cg, value_type cb, value_type alpha) - { - p[Order::R] = color_type::prelerp(p[Order::R], cr, alpha); - p[Order::G] = color_type::prelerp(p[Order::G], cg, alpha); - p[Order::B] = color_type::prelerp(p[Order::B], cb, alpha); - p[Order::A] = color_type::prelerp(p[Order::A], alpha, alpha); - } - }; - - //======================================================blender_rgba_plain - // Blends "plain" (non-premultiplied) colors into a plain (non-premultiplied) buffer. - template - struct blender_rgba_plain : conv_rgba_plain - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - // Blend pixels using the non-premultiplied form of Alvy-Ray Smith's - // compositing function. - - //-------------------------------------------------------------------- - static AGG_INLINE void blend_pix(value_type* p, - value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover) - { - blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover)); - } - - //-------------------------------------------------------------------- - static AGG_INLINE void blend_pix(value_type* p, - value_type cr, value_type cg, value_type cb, value_type alpha) - { - if (alpha > color_type::empty_value()) - { - calc_type a = p[Order::A]; - calc_type r = color_type::multiply(p[Order::R], a); - calc_type g = color_type::multiply(p[Order::G], a); - calc_type b = color_type::multiply(p[Order::B], a); - p[Order::R] = color_type::lerp(r, cr, alpha); - p[Order::G] = color_type::lerp(g, cg, alpha); - p[Order::B] = color_type::lerp(b, cb, alpha); - p[Order::A] = color_type::prelerp(a, alpha, alpha); - multiplier_rgba::demultiply(p); - } - } - }; - - // SVG compositing operations. - // For specifications, see http://www.w3.org/TR/SVGCompositing/ - - //=========================================================comp_op_rgba_clear - template - struct comp_op_rgba_clear : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = 0 - // Da' = 0 - static AGG_INLINE void blend_pix(value_type* p, - value_type, value_type, value_type, value_type, cover_type cover) - { - if (cover >= cover_full) - { - p[0] = p[1] = p[2] = p[3] = color_type::empty_value(); - } - else if (cover > cover_none) - { - set(p, get(p, cover_full - cover)); - } - } - }; - - //===========================================================comp_op_rgba_src - template - struct comp_op_rgba_src : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca - // Da' = Sa - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - if (cover >= cover_full) - { - set(p, r, g, b, a); - } - else - { - rgba s = get(r, g, b, a, cover); - rgba d = get(p, cover_full - cover); - d.r += s.r; - d.g += s.g; - d.b += s.b; - d.a += s.a; - set(p, d); - } - } - }; - - //===========================================================comp_op_rgba_dst - template - struct comp_op_rgba_dst : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - - // Dca' = Dca.Sa + Dca.(1 - Sa) = Dca - // Da' = Da.Sa + Da.(1 - Sa) = Da - static AGG_INLINE void blend_pix(value_type*, - value_type, value_type, value_type, value_type, cover_type) - { - // Well, that was easy! - } - }; - - //======================================================comp_op_rgba_src_over - template - struct comp_op_rgba_src_over : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca + Dca.(1 - Sa) = Dca + Sca - Dca.Sa - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { -#if 1 - blender_rgba_pre::blend_pix(p, r, g, b, a, cover); -#else - rgba s = get(r, g, b, a, cover); - rgba d = get(p); - d.r += s.r - d.r * s.a; - d.g += s.g - d.g * s.a; - d.b += s.b - d.b * s.a; - d.a += s.a - d.a * s.a; - set(p, d); -#endif - } - }; - - //======================================================comp_op_rgba_dst_over - template - struct comp_op_rgba_dst_over : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Dca + Sca.(1 - Da) - // Da' = Sa + Da - Sa.Da = Da + Sa.(1 - Da) - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - rgba d = get(p); - double d1a = 1 - d.a; - d.r += s.r * d1a; - d.g += s.g * d1a; - d.b += s.b * d1a; - d.a += s.a * d1a; - set(p, d); - } - }; - - //======================================================comp_op_rgba_src_in - template - struct comp_op_rgba_src_in : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca.Da - // Da' = Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - double da = ColorT::to_double(p[Order::A]); - if (da > 0) - { - rgba s = get(r, g, b, a, cover); - rgba d = get(p, cover_full - cover); - d.r += s.r * da; - d.g += s.g * da; - d.b += s.b * da; - d.a += s.a * da; - set(p, d); - } - } - }; - - //======================================================comp_op_rgba_dst_in - template - struct comp_op_rgba_dst_in : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Dca.Sa - // Da' = Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type, value_type, value_type, value_type a, cover_type cover) - { - double sa = ColorT::to_double(a); - rgba d = get(p, cover_full - cover); - rgba d2 = get(p, cover); - d.r += d2.r * sa; - d.g += d2.g * sa; - d.b += d2.b * sa; - d.a += d2.a * sa; - set(p, d); - } - }; - - //======================================================comp_op_rgba_src_out - template - struct comp_op_rgba_src_out : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca.(1 - Da) - // Da' = Sa.(1 - Da) - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - rgba d = get(p, cover_full - cover); - double d1a = 1 - ColorT::to_double(p[Order::A]); - d.r += s.r * d1a; - d.g += s.g * d1a; - d.b += s.b * d1a; - d.a += s.a * d1a; - set(p, d); - } - }; - - //======================================================comp_op_rgba_dst_out - template - struct comp_op_rgba_dst_out : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Dca.(1 - Sa) - // Da' = Da.(1 - Sa) - static AGG_INLINE void blend_pix(value_type* p, - value_type, value_type, value_type, value_type a, cover_type cover) - { - rgba d = get(p, cover_full - cover); - rgba dc = get(p, cover); - double s1a = 1 - ColorT::to_double(a); - d.r += dc.r * s1a; - d.g += dc.g * s1a; - d.b += dc.b * s1a; - d.a += dc.a * s1a; - set(p, d); - } - }; - - //=====================================================comp_op_rgba_src_atop - template - struct comp_op_rgba_src_atop : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca.Da + Dca.(1 - Sa) - // Da' = Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - rgba d = get(p); - double s1a = 1 - s.a; - d.r = s.r * d.a + d.r * s1a; - d.g = s.g * d.a + d.g * s1a; - d.b = s.b * d.a + d.g * s1a; - set(p, d); - } - }; - - //=====================================================comp_op_rgba_dst_atop - template - struct comp_op_rgba_dst_atop : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Dca.Sa + Sca.(1 - Da) - // Da' = Sa - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba sc = get(r, g, b, a, cover); - rgba dc = get(p, cover); - rgba d = get(p, cover_full - cover); - double sa = ColorT::to_double(a); - double d1a = 1 - ColorT::to_double(p[Order::A]); - d.r += dc.r * sa + sc.r * d1a; - d.g += dc.g * sa + sc.g * d1a; - d.b += dc.b * sa + sc.b * d1a; - d.a += sc.a; - set(p, d); - } - }; - - //=========================================================comp_op_rgba_xor - template - struct comp_op_rgba_xor : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca.(1 - Da) + Dca.(1 - Sa) - // Da' = Sa + Da - 2.Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - rgba d = get(p); - double s1a = 1 - s.a; - double d1a = 1 - ColorT::to_double(p[Order::A]); - d.r = s.r * d1a + d.r * s1a; - d.g = s.g * d1a + d.g * s1a; - d.b = s.b * d1a + d.b * s1a; - d.a = s.a + d.a - 2 * s.a * d.a; - set(p, d); - } - }; - - //=========================================================comp_op_rgba_plus - template - struct comp_op_rgba_plus : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca + Dca - // Da' = Sa + Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - d.a = sd_min(d.a + s.a, 1.0); - d.r = sd_min(d.r + s.r, d.a); - d.g = sd_min(d.g + s.g, d.a); - d.b = sd_min(d.b + s.b, d.a); - set(p, clip(d)); - } - } - }; - - //========================================================comp_op_rgba_minus - // Note: not included in SVG spec. - template - struct comp_op_rgba_minus : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Dca - Sca - // Da' = 1 - (1 - Sa).(1 - Da) = Da + Sa - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - d.a += s.a - s.a * d.a; - d.r = sd_max(d.r - s.r, 0.0); - d.g = sd_max(d.g - s.g, 0.0); - d.b = sd_max(d.b - s.b, 0.0); - set(p, clip(d)); - } - } - }; - - //=====================================================comp_op_rgba_multiply - template - struct comp_op_rgba_multiply : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - double s1a = 1 - s.a; - double d1a = 1 - d.a; - d.r = s.r * d.r + s.r * d1a + d.r * s1a; - d.g = s.g * d.g + s.g * d1a + d.g * s1a; - d.b = s.b * d.b + s.b * d1a + d.b * s1a; - d.a += s.a - s.a * d.a; - set(p, clip(d)); - } - } - }; - - //=====================================================comp_op_rgba_screen - template - struct comp_op_rgba_screen : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca + Dca - Sca.Dca - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - d.r += s.r - s.r * d.r; - d.g += s.g - s.g * d.g; - d.b += s.b - s.b * d.b; - d.a += s.a - s.a * d.a; - set(p, clip(d)); - } - } - }; - - //=====================================================comp_op_rgba_overlay - template - struct comp_op_rgba_overlay : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // if 2.Dca <= Da - // Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) - // otherwise - // Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) - // - // Da' = Sa + Da - Sa.Da - static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) - { - return (2 * dca <= da) ? - 2 * sca * dca + sca * d1a + dca * s1a : - sada - 2 * (da - dca) * (sa - sca) + sca * d1a + dca * s1a; - } - - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - double d1a = 1 - d.a; - double s1a = 1 - s.a; - double sada = s.a * d.a; - d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); - d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); - d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); - d.a += s.a - s.a * d.a; - set(p, clip(d)); - } - } - }; - - //=====================================================comp_op_rgba_darken - template - struct comp_op_rgba_darken : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = min(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - double d1a = 1 - d.a; - double s1a = 1 - s.a; - d.r = sd_min(s.r * d.a, d.r * s.a) + s.r * d1a + d.r * s1a; - d.g = sd_min(s.g * d.a, d.g * s.a) + s.g * d1a + d.g * s1a; - d.b = sd_min(s.b * d.a, d.b * s.a) + s.b * d1a + d.b * s1a; - d.a += s.a - s.a * d.a; - set(p, clip(d)); - } - } - }; - - //=====================================================comp_op_rgba_lighten - template - struct comp_op_rgba_lighten : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = max(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - double d1a = 1 - d.a; - double s1a = 1 - s.a; - d.r = sd_max(s.r * d.a, d.r * s.a) + s.r * d1a + d.r * s1a; - d.g = sd_max(s.g * d.a, d.g * s.a) + s.g * d1a + d.g * s1a; - d.b = sd_max(s.b * d.a, d.b * s.a) + s.b * d1a + d.b * s1a; - d.a += s.a - s.a * d.a; - set(p, clip(d)); - } - } - }; - - //=====================================================comp_op_rgba_color_dodge - template - struct comp_op_rgba_color_dodge : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // if Sca == Sa and Dca == 0 - // Dca' = Sca.(1 - Da) + Dca.(1 - Sa) = Sca.(1 - Da) - // otherwise if Sca == Sa - // Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa) - // otherwise if Sca < Sa - // Dca' = Sa.Da.min(1, Dca/Da.Sa/(Sa - Sca)) + Sca.(1 - Da) + Dca.(1 - Sa) - // - // Da' = Sa + Da - Sa.Da - static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) - { - if (sca < sa) return sada * sd_min(1.0, (dca / da) * sa / (sa - sca)) + sca * d1a + dca * s1a; - if (dca > 0) return sada + sca * d1a + dca * s1a; - return sca * d1a; - } - - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - if (d.a > 0) - { - double sada = s.a * d.a; - double s1a = 1 - s.a; - double d1a = 1 - d.a; - d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); - d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); - d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); - d.a += s.a - s.a * d.a; - set(p, clip(d)); - } - else set(p, s); - } - } - }; - - //=====================================================comp_op_rgba_color_burn - template - struct comp_op_rgba_color_burn : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // if Sca == 0 and Dca == Da - // Dca' = Sa.Da + Dca.(1 - Sa) - // otherwise if Sca == 0 - // Dca' = Dca.(1 - Sa) - // otherwise if Sca > 0 - // Dca' = Sa.Da.(1 - min(1, (1 - Dca/Da).Sa/Sca)) + Sca.(1 - Da) + Dca.(1 - Sa) - static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) - { - if (sca > 0) return sada * (1 - sd_min(1.0, (1 - dca / da) * sa / sca)) + sca * d1a + dca * s1a; - if (dca > da) return sada + dca * s1a; - return dca * s1a; - } - - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - if (d.a > 0) - { - double sada = s.a * d.a; - double s1a = 1 - s.a; - double d1a = 1 - d.a; - d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); - d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); - d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); - d.a += s.a - sada; - set(p, clip(d)); - } - else set(p, s); - } - } - }; - - //=====================================================comp_op_rgba_hard_light - template - struct comp_op_rgba_hard_light : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // if 2.Sca < Sa - // Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) - // otherwise - // Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) - // - // Da' = Sa + Da - Sa.Da - static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) - { - return (2 * sca < sa) ? - 2 * sca * dca + sca * d1a + dca * s1a : - sada - 2 * (da - dca) * (sa - sca) + sca * d1a + dca * s1a; - } - - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - double d1a = 1 - d.a; - double s1a = 1 - s.a; - double sada = s.a * d.a; - d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); - d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); - d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); - d.a += s.a - sada; - set(p, clip(d)); - } - } - }; - - //=====================================================comp_op_rgba_soft_light - template - struct comp_op_rgba_soft_light : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // if 2.Sca <= Sa - // Dca' = Dca.Sa - (Sa.Da - 2.Sca.Da).Dca.Sa.(Sa.Da - Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) - // otherwise if 2.Sca > Sa and 4.Dca <= Da - // Dca' = Dca.Sa + (2.Sca.Da - Sa.Da).((((16.Dsa.Sa - 12).Dsa.Sa + 4).Dsa.Da) - Dsa.Da) + Sca.(1 - Da) + Dca.(1 - Sa) - // otherwise if 2.Sca > Sa and 4.Dca > Da - // Dca' = Dca.Sa + (2.Sca.Da - Sa.Da).((Dca.Sa)^0.5 - Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) - // - // Da' = Sa + Da - Sa.Da - static AGG_INLINE double calc(double dca, double sca, double da, double sa, double sada, double d1a, double s1a) - { - double dcasa = dca * sa; - if (2 * sca <= sa) return dcasa - (sada - 2 * sca * da) * dcasa * (sada - dcasa) + sca * d1a + dca * s1a; - if (4 * dca <= da) return dcasa + (2 * sca * da - sada) * ((((16 * dcasa - 12) * dcasa + 4) * dca * da) - dca * da) + sca * d1a + dca * s1a; - return dcasa + (2 * sca * da - sada) * (sqrt(dcasa) - dcasa) + sca * d1a + dca * s1a; - } - - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - if (d.a > 0) - { - double sada = s.a * d.a; - double s1a = 1 - s.a; - double d1a = 1 - d.a; - d.r = calc(d.r, s.r, d.a, s.a, sada, d1a, s1a); - d.g = calc(d.g, s.g, d.a, s.a, sada, d1a, s1a); - d.b = calc(d.b, s.b, d.a, s.a, sada, d1a, s1a); - d.a += s.a - sada; - set(p, clip(d)); - } - else set(p, s); - } - } - }; - - //=====================================================comp_op_rgba_difference - template - struct comp_op_rgba_difference : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = Sca + Dca - 2.min(Sca.Da, Dca.Sa) - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - d.r += s.r - 2 * sd_min(s.r * d.a, d.r * s.a); - d.g += s.g - 2 * sd_min(s.g * d.a, d.g * s.a); - d.b += s.b - 2 * sd_min(s.b * d.a, d.b * s.a); - d.a += s.a - s.a * d.a; - set(p, clip(d)); - } - } - }; - - //=====================================================comp_op_rgba_exclusion - template - struct comp_op_rgba_exclusion : blender_base - { - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - using blender_base::get; - using blender_base::set; - - // Dca' = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - rgba s = get(r, g, b, a, cover); - if (s.a > 0) - { - rgba d = get(p); - double d1a = 1 - d.a; - double s1a = 1 - s.a; - d.r = (s.r * d.a + d.r * s.a - 2 * s.r * d.r) + s.r * d1a + d.r * s1a; - d.g = (s.g * d.a + d.g * s.a - 2 * s.g * d.g) + s.g * d1a + d.g * s1a; - d.b = (s.b * d.a + d.b * s.a - 2 * s.b * d.b) + s.b * d1a + d.b * s1a; - d.a += s.a - s.a * d.a; - set(p, clip(d)); - } - } - }; - -#if 0 - //=====================================================comp_op_rgba_contrast - template struct comp_op_rgba_contrast - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - base_shift = color_type::base_shift, - base_mask = color_type::base_mask - }; - - - static AGG_INLINE void blend_pix(value_type* p, - unsigned sr, unsigned sg, unsigned sb, - unsigned sa, unsigned cover) - { - if (cover < 255) - { - sr = (sr * cover + 255) >> 8; - sg = (sg * cover + 255) >> 8; - sb = (sb * cover + 255) >> 8; - sa = (sa * cover + 255) >> 8; - } - long_type dr = p[Order::R]; - long_type dg = p[Order::G]; - long_type db = p[Order::B]; - int da = p[Order::A]; - long_type d2a = da >> 1; - unsigned s2a = sa >> 1; - - int r = (int)((((dr - d2a) * int((sr - s2a)*2 + base_mask)) >> base_shift) + d2a); - int g = (int)((((dg - d2a) * int((sg - s2a)*2 + base_mask)) >> base_shift) + d2a); - int b = (int)((((db - d2a) * int((sb - s2a)*2 + base_mask)) >> base_shift) + d2a); - - r = (r < 0) ? 0 : r; - g = (g < 0) ? 0 : g; - b = (b < 0) ? 0 : b; - - p[Order::R] = (value_type)((r > da) ? da : r); - p[Order::G] = (value_type)((g > da) ? da : g); - p[Order::B] = (value_type)((b > da) ? da : b); - } - }; - - //=====================================================comp_op_rgba_invert - template struct comp_op_rgba_invert - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - base_shift = color_type::base_shift, - base_mask = color_type::base_mask - }; - - // Dca' = (Da - Dca) * Sa + Dca.(1 - Sa) - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - unsigned sr, unsigned sg, unsigned sb, - unsigned sa, unsigned cover) - { - sa = (sa * cover + 255) >> 8; - if (sa) - { - calc_type da = p[Order::A]; - calc_type dr = ((da - p[Order::R]) * sa + base_mask) >> base_shift; - calc_type dg = ((da - p[Order::G]) * sa + base_mask) >> base_shift; - calc_type db = ((da - p[Order::B]) * sa + base_mask) >> base_shift; - calc_type s1a = base_mask - sa; - p[Order::R] = (value_type)(dr + ((p[Order::R] * s1a + base_mask) >> base_shift)); - p[Order::G] = (value_type)(dg + ((p[Order::G] * s1a + base_mask) >> base_shift)); - p[Order::B] = (value_type)(db + ((p[Order::B] * s1a + base_mask) >> base_shift)); - p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); - } - } - }; - - //=================================================comp_op_rgba_invert_rgb - template struct comp_op_rgba_invert_rgb - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - base_shift = color_type::base_shift, - base_mask = color_type::base_mask - }; - - // Dca' = (Da - Dca) * Sca + Dca.(1 - Sa) - // Da' = Sa + Da - Sa.Da - static AGG_INLINE void blend_pix(value_type* p, - unsigned sr, unsigned sg, unsigned sb, - unsigned sa, unsigned cover) - { - if (cover < 255) - { - sr = (sr * cover + 255) >> 8; - sg = (sg * cover + 255) >> 8; - sb = (sb * cover + 255) >> 8; - sa = (sa * cover + 255) >> 8; - } - if (sa) - { - calc_type da = p[Order::A]; - calc_type dr = ((da - p[Order::R]) * sr + base_mask) >> base_shift; - calc_type dg = ((da - p[Order::G]) * sg + base_mask) >> base_shift; - calc_type db = ((da - p[Order::B]) * sb + base_mask) >> base_shift; - calc_type s1a = base_mask - sa; - p[Order::R] = (value_type)(dr + ((p[Order::R] * s1a + base_mask) >> base_shift)); - p[Order::G] = (value_type)(dg + ((p[Order::G] * s1a + base_mask) >> base_shift)); - p[Order::B] = (value_type)(db + ((p[Order::B] * s1a + base_mask) >> base_shift)); - p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); - } - } - }; -#endif - - - //======================================================comp_op_table_rgba - template struct comp_op_table_rgba - { - typedef typename ColorT::value_type value_type; - typedef typename ColorT::calc_type calc_type; - typedef void (*comp_op_func_type)(value_type* p, - value_type cr, - value_type cg, - value_type cb, - value_type ca, - cover_type cover); - static comp_op_func_type g_comp_op_func[]; - }; - - //==========================================================g_comp_op_func - template - typename comp_op_table_rgba::comp_op_func_type - comp_op_table_rgba::g_comp_op_func[] = - { - comp_op_rgba_clear ::blend_pix, - comp_op_rgba_src ::blend_pix, - comp_op_rgba_dst ::blend_pix, - comp_op_rgba_src_over ::blend_pix, - comp_op_rgba_dst_over ::blend_pix, - comp_op_rgba_src_in ::blend_pix, - comp_op_rgba_dst_in ::blend_pix, - comp_op_rgba_src_out ::blend_pix, - comp_op_rgba_dst_out ::blend_pix, - comp_op_rgba_src_atop ::blend_pix, - comp_op_rgba_dst_atop ::blend_pix, - comp_op_rgba_xor ::blend_pix, - comp_op_rgba_plus ::blend_pix, - //comp_op_rgba_minus ::blend_pix, - comp_op_rgba_multiply ::blend_pix, - comp_op_rgba_screen ::blend_pix, - comp_op_rgba_overlay ::blend_pix, - comp_op_rgba_darken ::blend_pix, - comp_op_rgba_lighten ::blend_pix, - comp_op_rgba_color_dodge::blend_pix, - comp_op_rgba_color_burn ::blend_pix, - comp_op_rgba_hard_light ::blend_pix, - comp_op_rgba_soft_light ::blend_pix, - comp_op_rgba_difference ::blend_pix, - comp_op_rgba_exclusion ::blend_pix, - //comp_op_rgba_contrast ::blend_pix, - //comp_op_rgba_invert ::blend_pix, - //comp_op_rgba_invert_rgb ::blend_pix, - 0 - }; - - - //==============================================================comp_op_e - enum comp_op_e - { - comp_op_clear, //----comp_op_clear - comp_op_src, //----comp_op_src - comp_op_dst, //----comp_op_dst - comp_op_src_over, //----comp_op_src_over - comp_op_dst_over, //----comp_op_dst_over - comp_op_src_in, //----comp_op_src_in - comp_op_dst_in, //----comp_op_dst_in - comp_op_src_out, //----comp_op_src_out - comp_op_dst_out, //----comp_op_dst_out - comp_op_src_atop, //----comp_op_src_atop - comp_op_dst_atop, //----comp_op_dst_atop - comp_op_xor, //----comp_op_xor - comp_op_plus, //----comp_op_plus - //comp_op_minus, //----comp_op_minus - comp_op_multiply, //----comp_op_multiply - comp_op_screen, //----comp_op_screen - comp_op_overlay, //----comp_op_overlay - comp_op_darken, //----comp_op_darken - comp_op_lighten, //----comp_op_lighten - comp_op_color_dodge, //----comp_op_color_dodge - comp_op_color_burn, //----comp_op_color_burn - comp_op_hard_light, //----comp_op_hard_light - comp_op_soft_light, //----comp_op_soft_light - comp_op_difference, //----comp_op_difference - comp_op_exclusion, //----comp_op_exclusion - //comp_op_contrast, //----comp_op_contrast - //comp_op_invert, //----comp_op_invert - //comp_op_invert_rgb, //----comp_op_invert_rgb - - end_of_comp_op_e - }; - - - - - - - - //====================================================comp_op_adaptor_rgba - template - struct comp_op_adaptor_rgba - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned op, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - comp_op_table_rgba::g_comp_op_func[op](p, - color_type::multiply(r, a), - color_type::multiply(g, a), - color_type::multiply(b, a), - a, cover); - } - }; - - //=========================================comp_op_adaptor_clip_to_dst_rgba - template - struct comp_op_adaptor_clip_to_dst_rgba - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned op, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - r = color_type::multiply(r, a); - g = color_type::multiply(g, a); - b = color_type::multiply(b, a); - value_type da = p[Order::A]; - comp_op_table_rgba::g_comp_op_func[op](p, - color_type::multiply(r, da), - color_type::multiply(g, da), - color_type::multiply(b, da), - color_type::multiply(a, da), cover); - } - }; - - //================================================comp_op_adaptor_rgba_pre - template - struct comp_op_adaptor_rgba_pre - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned op, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - comp_op_table_rgba::g_comp_op_func[op](p, r, g, b, a, cover); - } - }; - - //=====================================comp_op_adaptor_clip_to_dst_rgba_pre - template - struct comp_op_adaptor_clip_to_dst_rgba_pre - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned op, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - value_type da = p[Order::A]; - comp_op_table_rgba::g_comp_op_func[op](p, - color_type::multiply(r, da), - color_type::multiply(g, da), - color_type::multiply(b, da), - color_type::multiply(a, da), cover); - } - }; - - //====================================================comp_op_adaptor_rgba_plain - template - struct comp_op_adaptor_rgba_plain - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned op, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - multiplier_rgba::premultiply(p); - comp_op_adaptor_rgba::blend_pix(op, p, r, g, b, a, cover); - multiplier_rgba::demultiply(p); - } - }; - - //=========================================comp_op_adaptor_clip_to_dst_rgba_plain - template - struct comp_op_adaptor_clip_to_dst_rgba_plain - { - typedef ColorT color_type; - typedef Order order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned op, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - multiplier_rgba::premultiply(p); - comp_op_adaptor_clip_to_dst_rgba::blend_pix(op, p, r, g, b, a, cover); - multiplier_rgba::demultiply(p); - } - }; - - //=======================================================comp_adaptor_rgba - template - struct comp_adaptor_rgba - { - typedef typename BlenderPre::color_type color_type; - typedef typename BlenderPre::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - BlenderPre::blend_pix(p, - color_type::multiply(r, a), - color_type::multiply(g, a), - color_type::multiply(b, a), - a, cover); - } - }; - - //==========================================comp_adaptor_clip_to_dst_rgba - template - struct comp_adaptor_clip_to_dst_rgba - { - typedef typename BlenderPre::color_type color_type; - typedef typename BlenderPre::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - r = color_type::multiply(r, a); - g = color_type::multiply(g, a); - b = color_type::multiply(b, a); - value_type da = p[order_type::A]; - BlenderPre::blend_pix(p, - color_type::multiply(r, da), - color_type::multiply(g, da), - color_type::multiply(b, da), - color_type::multiply(a, da), cover); - } - }; - - //=======================================================comp_adaptor_rgba_pre - template - struct comp_adaptor_rgba_pre - { - typedef typename BlenderPre::color_type color_type; - typedef typename BlenderPre::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - BlenderPre::blend_pix(p, r, g, b, a, cover); - } - }; - - //======================================comp_adaptor_clip_to_dst_rgba_pre - template - struct comp_adaptor_clip_to_dst_rgba_pre - { - typedef typename BlenderPre::color_type color_type; - typedef typename BlenderPre::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - unsigned da = p[order_type::A]; - BlenderPre::blend_pix(p, - color_type::multiply(r, da), - color_type::multiply(g, da), - color_type::multiply(b, da), - color_type::multiply(a, da), - cover); - } - }; - - //=======================================================comp_adaptor_rgba_plain - template - struct comp_adaptor_rgba_plain - { - typedef typename BlenderPre::color_type color_type; - typedef typename BlenderPre::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned op, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - multiplier_rgba::premultiply(p); - comp_adaptor_rgba::blend_pix(op, p, r, g, b, a, cover); - multiplier_rgba::demultiply(p); - } - }; - - //==========================================comp_adaptor_clip_to_dst_rgba_plain - template - struct comp_adaptor_clip_to_dst_rgba_plain - { - typedef typename BlenderPre::color_type color_type; - typedef typename BlenderPre::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - static AGG_INLINE void blend_pix(unsigned op, value_type* p, - value_type r, value_type g, value_type b, value_type a, cover_type cover) - { - multiplier_rgba::premultiply(p); - comp_adaptor_clip_to_dst_rgba::blend_pix(op, p, r, g, b, a, cover); - multiplier_rgba::demultiply(p); - } - }; - - - //=================================================pixfmt_alpha_blend_rgba - template - class pixfmt_alpha_blend_rgba - { - public: - typedef pixfmt_rgba_tag pixfmt_category; - typedef RenBuf rbuf_type; - typedef typename rbuf_type::row_data row_data; - typedef Blender blender_type; - typedef typename blender_type::color_type color_type; - typedef typename blender_type::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - enum - { - num_components = 4, - pix_step = 4, - pix_width = sizeof(value_type) * pix_step, - }; - struct pixel_type - { - value_type c[num_components]; - - void set(value_type r, value_type g, value_type b, value_type a) - { - c[order_type::R] = r; - c[order_type::G] = g; - c[order_type::B] = b; - c[order_type::A] = a; - } - - void set(const color_type& color) - { - set(color.r, color.g, color.b, color.a); - } - - void get(value_type& r, value_type& g, value_type& b, value_type& a) const - { - r = c[order_type::R]; - g = c[order_type::G]; - b = c[order_type::B]; - a = c[order_type::A]; - } - - color_type get() const - { - return color_type( - c[order_type::R], - c[order_type::G], - c[order_type::B], - c[order_type::A]); - } - - pixel_type* next() - { - return (pixel_type*)(c + pix_step); - } - - const pixel_type* next() const - { - return (const pixel_type*)(c + pix_step); - } - - pixel_type* advance(int n) - { - return (pixel_type*)(c + n * pix_step); - } - - const pixel_type* advance(int n) const - { - return (const pixel_type*)(c + n * pix_step); - } - }; - - private: - //-------------------------------------------------------------------- - AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover) - { - m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_pix(pixel_type* p, const color_type& c) - { - m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover) - { - if (!c.is_transparent()) - { - if (c.is_opaque() && cover == cover_mask) - { - p->set(c.r, c.g, c.b, c.a); - } - else - { - m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a, cover); - } - } - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c) - { - if (!c.is_transparent()) - { - if (c.is_opaque()) - { - p->set(c.r, c.g, c.b, c.a); - } - else - { - m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a); - } - } - } - - public: - //-------------------------------------------------------------------- - pixfmt_alpha_blend_rgba() : m_rbuf(0) {} - explicit pixfmt_alpha_blend_rgba(rbuf_type& rb) : m_rbuf(&rb) {} - void attach(rbuf_type& rb) { m_rbuf = &rb; } - - //-------------------------------------------------------------------- - template - bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) - { - rect_i r(x1, y1, x2, y2); - if (r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) - { - int stride = pixf.stride(); - m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), - (r.x2 - r.x1) + 1, - (r.y2 - r.y1) + 1, - stride); - return true; - } - return false; - } - - //-------------------------------------------------------------------- - AGG_INLINE unsigned width() const { return m_rbuf->width(); } - AGG_INLINE unsigned height() const { return m_rbuf->height(); } - AGG_INLINE int stride() const { return m_rbuf->stride(); } - - //-------------------------------------------------------------------- - AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } - AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } - AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); } - - //-------------------------------------------------------------------- - AGG_INLINE int8u* pix_ptr(int x, int y) - { - return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step); - } - - AGG_INLINE const int8u* pix_ptr(int x, int y) const - { - return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step); - } - - // Return pointer to pixel value, forcing row to be allocated. - AGG_INLINE pixel_type* pix_value_ptr(int x, int y, unsigned len) - { - return (pixel_type*)(m_rbuf->row_ptr(x, y, len) + sizeof(value_type) * (x * pix_step)); - } - - // Return pointer to pixel value, or null if row not allocated. - AGG_INLINE const pixel_type* pix_value_ptr(int x, int y) const - { - int8u* p = m_rbuf->row_ptr(y); - return p ? (pixel_type*)(p + sizeof(value_type) * (x * pix_step)) : 0; - } - - // Get pixel pointer from raw buffer pointer. - AGG_INLINE static pixel_type* pix_value_ptr(void* p) - { - return (pixel_type*)p; - } - - // Get pixel pointer from raw buffer pointer. - AGG_INLINE static const pixel_type* pix_value_ptr(const void* p) - { - return (const pixel_type*)p; - } - - //-------------------------------------------------------------------- - AGG_INLINE static void write_plain_color(void* p, color_type c) - { - blender_type::set_plain_color(pix_value_ptr(p)->c, c); - } - - //-------------------------------------------------------------------- - AGG_INLINE static color_type read_plain_color(const void* p) - { - return blender_type::get_plain_color(pix_value_ptr(p)->c); - } - - //-------------------------------------------------------------------- - AGG_INLINE static void make_pix(int8u* p, const color_type& c) - { - ((pixel_type*)p)->set(c); - } - - //-------------------------------------------------------------------- - AGG_INLINE color_type pixel(int x, int y) const - { - if (const pixel_type* p = pix_value_ptr(x, y)) - { - return p->get(); - } - return color_type::no_color(); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_pixel(int x, int y, const color_type& c) - { - pix_value_ptr(x, y, 1)->set(c); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) - { - copy_or_blend_pix(pix_value_ptr(x, y, 1), c, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_hline(int x, int y, - unsigned len, - const color_type& c) - { - pixel_type v; - v.set(c); - pixel_type* p = pix_value_ptr(x, y, len); - do - { - *p = v; - p = p->next(); - } - while (--len); - } - - - //-------------------------------------------------------------------- - AGG_INLINE void copy_vline(int x, int y, - unsigned len, - const color_type& c) - { - pixel_type v; - v.set(c); - do - { - *pix_value_ptr(x, y++, 1) = v; - } - while (--len); - } - - //-------------------------------------------------------------------- - void blend_hline(int x, int y, - unsigned len, - const color_type& c, - int8u cover) - { - if (!c.is_transparent()) - { - pixel_type* p = pix_value_ptr(x, y, len); - if (c.is_opaque() && cover == cover_mask) - { - pixel_type v; - v.set(c); - do - { - *p = v; - p = p->next(); - } - while (--len); - } - else - { - if (cover == cover_mask) - { - do - { - blend_pix(p, c); - p = p->next(); - } - while (--len); - } - else - { - do - { - blend_pix(p, c, cover); - p = p->next(); - } - while (--len); - } - } - } - } - - - //-------------------------------------------------------------------- - void blend_vline(int x, int y, - unsigned len, - const color_type& c, - int8u cover) - { - if (!c.is_transparent()) - { - if (c.is_opaque() && cover == cover_mask) - { - pixel_type v; - v.set(c); - do - { - *pix_value_ptr(x, y++, 1) = v; - } - while (--len); - } - else - { - if (cover == cover_mask) - { - do - { - blend_pix(pix_value_ptr(x, y++, 1), c, c.a); - } - while (--len); - } - else - { - do - { - blend_pix(pix_value_ptr(x, y++, 1), c, cover); - } - while (--len); - } - } - } - } - - - //-------------------------------------------------------------------- - void blend_solid_hspan(int x, int y, - unsigned len, - const color_type& c, - const int8u* covers) - { - if (!c.is_transparent()) - { - pixel_type* p = pix_value_ptr(x, y, len); - do - { - if (c.is_opaque() && *covers == cover_mask) - { - p->set(c); - } - else - { - blend_pix(p, c, *covers); - } - p = p->next(); - ++covers; - } - while (--len); - } - } - - - //-------------------------------------------------------------------- - void blend_solid_vspan(int x, int y, - unsigned len, - const color_type& c, - const int8u* covers) - { - if (!c.is_transparent()) - { - do - { - pixel_type* p = pix_value_ptr(x, y++, 1); - if (c.is_opaque() && *covers == cover_mask) - { - p->set(c); - } - else - { - blend_pix(p, c, *covers); - } - ++covers; - } - while (--len); - } - } - - //-------------------------------------------------------------------- - void copy_color_hspan(int x, int y, - unsigned len, - const color_type* colors) - { - pixel_type* p = pix_value_ptr(x, y, len); - do - { - p->set(*colors++); - p = p->next(); - } - while (--len); - } - - - //-------------------------------------------------------------------- - void copy_color_vspan(int x, int y, - unsigned len, - const color_type* colors) - { - do - { - pix_value_ptr(x, y++, 1)->set(*colors++); - } - while (--len); - } - - //-------------------------------------------------------------------- - void blend_color_hspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - pixel_type* p = pix_value_ptr(x, y, len); - if (covers) - { - do - { - copy_or_blend_pix(p, *colors++, *covers++); - p = p->next(); - } - while (--len); - } - else - { - if (cover == cover_mask) - { - do - { - copy_or_blend_pix(p, *colors++); - p = p->next(); - } - while (--len); - } - else - { - do - { - copy_or_blend_pix(p, *colors++, cover); - p = p->next(); - } - while (--len); - } - } - } - - //-------------------------------------------------------------------- - void blend_color_vspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - if (covers) - { - do - { - copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, *covers++); - } - while (--len); - } - else - { - if (cover == cover_mask) - { - do - { - copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++); - } - while (--len); - } - else - { - do - { - copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, cover); - } - while (--len); - } - } - } - - //-------------------------------------------------------------------- - template void for_each_pixel(Function f) - { - for (unsigned y = 0; y < height(); ++y) - { - row_data r = m_rbuf->row(y); - if (r.ptr) - { - unsigned len = r.x2 - r.x1 + 1; - pixel_type* p = pix_value_ptr(r.x1, y, len); - do - { - f(p->c); - p = p->next(); - } - while (--len); - } - } - } - - //-------------------------------------------------------------------- - void premultiply() - { - for_each_pixel(multiplier_rgba::premultiply); - } - - //-------------------------------------------------------------------- - void demultiply() - { - for_each_pixel(multiplier_rgba::demultiply); - } - - //-------------------------------------------------------------------- - template void apply_gamma_dir(const GammaLut& g) - { - for_each_pixel(apply_gamma_dir_rgba(g)); - } - - //-------------------------------------------------------------------- - template void apply_gamma_inv(const GammaLut& g) - { - for_each_pixel(apply_gamma_inv_rgba(g)); - } - - //-------------------------------------------------------------------- - template void copy_from(const RenBuf2& from, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len) - { - if (const int8u* p = from.row_ptr(ysrc)) - { - memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, - p + xsrc * pix_width, - len * pix_width); - } - } - - //-------------------------------------------------------------------- - // Blend from another RGBA surface. - template - void blend_from(const SrcPixelFormatRenderer& from, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; - - if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) - { - pixel_type* pdst = pix_value_ptr(xdst, ydst, len); - int srcinc = 1; - int dstinc = 1; - - if (xdst > xsrc) - { - psrc = psrc->advance(len - 1); - pdst = pdst->advance(len - 1); - srcinc = -1; - dstinc = -1; - } - - if (cover == cover_mask) - { - do - { - copy_or_blend_pix(pdst, psrc->get()); - psrc = psrc->advance(srcinc); - pdst = pdst->advance(dstinc); - } - while (--len); - } - else - { - do - { - copy_or_blend_pix(pdst, psrc->get(), cover); - psrc = psrc->advance(srcinc); - pdst = pdst->advance(dstinc); - } - while (--len); - } - } - } - - //-------------------------------------------------------------------- - // Combine single color with grayscale surface and blend. - template - void blend_from_color(const SrcPixelFormatRenderer& from, - const color_type& color, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; - typedef typename SrcPixelFormatRenderer::color_type src_color_type; - - if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) - { - pixel_type* pdst = pix_value_ptr(xdst, ydst, len); - - do - { - copy_or_blend_pix(pdst, color, - src_color_type::scale_cover(cover, psrc->c[0])); - psrc = psrc->next(); - pdst = pdst->next(); - } - while (--len); - } - } - - //-------------------------------------------------------------------- - // Blend from color table, using grayscale surface as indexes into table. - // Obviously, this only works for integer value types. - template - void blend_from_lut(const SrcPixelFormatRenderer& from, - const color_type* color_lut, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; - - if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) - { - pixel_type* pdst = pix_value_ptr(xdst, ydst, len); - - if (cover == cover_mask) - { - do - { - copy_or_blend_pix(pdst, color_lut[psrc->c[0]]); - psrc = psrc->next(); - pdst = pdst->next(); - } - while (--len); - } - else - { - do - { - copy_or_blend_pix(pdst, color_lut[psrc->c[0]], cover); - psrc = psrc->next(); - pdst = pdst->next(); - } - while (--len); - } - } - } - - private: - rbuf_type* m_rbuf; - Blender m_blender; - }; - - //================================================pixfmt_custom_blend_rgba - template class pixfmt_custom_blend_rgba - { - public: - typedef pixfmt_rgba_tag pixfmt_category; - typedef RenBuf rbuf_type; - typedef typename rbuf_type::row_data row_data; - typedef Blender blender_type; - typedef typename blender_type::color_type color_type; - typedef typename blender_type::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - enum - { - num_components = 4, - pix_step = 4, - pix_width = sizeof(value_type) * pix_step, - }; - struct pixel_type - { - value_type c[num_components]; - - void set(value_type r, value_type g, value_type b, value_type a) - { - c[order_type::R] = r; - c[order_type::G] = g; - c[order_type::B] = b; - c[order_type::A] = a; - } - - void set(const color_type& color) - { - set(color.r, color.g, color.b, color.a); - } - - void get(value_type& r, value_type& g, value_type& b, value_type& a) const - { - r = c[order_type::R]; - g = c[order_type::G]; - b = c[order_type::B]; - a = c[order_type::A]; - } - - color_type get() const - { - return color_type( - c[order_type::R], - c[order_type::G], - c[order_type::B], - c[order_type::A]); - } - - pixel_type* next() - { - return (pixel_type*)(c + pix_step); - } - - const pixel_type* next() const - { - return (const pixel_type*)(c + pix_step); - } - - pixel_type* advance(int n) - { - return (pixel_type*)(c + n * pix_step); - } - - const pixel_type* advance(int n) const - { - return (const pixel_type*)(c + n * pix_step); - } - }; - - - private: - //-------------------------------------------------------------------- - AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover = cover_full) - { - m_blender.blend_pix(m_comp_op, p->c, c.r, c.g, c.b, c.a, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover = cover_full) - { - if (!c.is_transparent()) - { - if (c.is_opaque() && cover == cover_mask) - { - p->set(c.r, c.g, c.b, c.a); - } - else - { - blend_pix(p, c, cover); - } - } - } - - public: - //-------------------------------------------------------------------- - pixfmt_custom_blend_rgba() : m_rbuf(0), m_comp_op(3) {} - explicit pixfmt_custom_blend_rgba(rbuf_type& rb, unsigned comp_op=3) : - m_rbuf(&rb), - m_comp_op(comp_op) - {} - void attach(rbuf_type& rb) { m_rbuf = &rb; } - - //-------------------------------------------------------------------- - template - bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) - { - rect_i r(x1, y1, x2, y2); - if (r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) - { - int stride = pixf.stride(); - m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), - (r.x2 - r.x1) + 1, - (r.y2 - r.y1) + 1, - stride); - return true; - } - return false; - } - - //-------------------------------------------------------------------- - void comp_op(unsigned op) { m_comp_op = op; } - unsigned comp_op() const { return m_comp_op; } - - //-------------------------------------------------------------------- - AGG_INLINE unsigned width() const { return m_rbuf->width(); } - AGG_INLINE unsigned height() const { return m_rbuf->height(); } - AGG_INLINE int stride() const { return m_rbuf->stride(); } - - //-------------------------------------------------------------------- - AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } - AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } - AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); } - - //-------------------------------------------------------------------- - AGG_INLINE int8u* pix_ptr(int x, int y) - { - return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step); - } - - AGG_INLINE const int8u* pix_ptr(int x, int y) const - { - return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step); - } - - // Return pointer to pixel value, forcing row to be allocated. - AGG_INLINE pixel_type* pix_value_ptr(int x, int y, unsigned len) - { - return (pixel_type*)(m_rbuf->row_ptr(x, y, len) + sizeof(value_type) * (x * pix_step)); - } - - // Return pointer to pixel value, or null if row not allocated. - AGG_INLINE const pixel_type* pix_value_ptr(int x, int y) const - { - int8u* p = m_rbuf->row_ptr(y); - return p ? (pixel_type*)(p + sizeof(value_type) * (x * pix_step)) : 0; - } - - // Get pixel pointer from raw buffer pointer. - AGG_INLINE static pixel_type* pix_value_ptr(void* p) - { - return (pixel_type*)p; - } - - // Get pixel pointer from raw buffer pointer. - AGG_INLINE static const pixel_type* pix_value_ptr(const void* p) - { - return (const pixel_type*)p; - } - - //-------------------------------------------------------------------- - AGG_INLINE static void make_pix(int8u* p, const color_type& c) - { - ((pixel_type*)p)->set(c); - } - - //-------------------------------------------------------------------- - AGG_INLINE color_type pixel(int x, int y) const - { - if (const pixel_type* p = pix_value_ptr(x, y)) - { - return p->get(); - } - return color_type::no_color(); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_pixel(int x, int y, const color_type& c) - { - make_pix(pix_value_ptr(x, y, 1), c); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) - { - blend_pix(pix_value_ptr(x, y, 1), c, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_hline(int x, int y, - unsigned len, - const color_type& c) - { - pixel_type v; - v.set(c); - pixel_type* p = pix_value_ptr(x, y, len); - do - { - *p = v; - p = p->next(); - } - while (--len); - } - - - //-------------------------------------------------------------------- - AGG_INLINE void copy_vline(int x, int y, - unsigned len, - const color_type& c) - { - pixel_type v; - v.set(c); - do - { - *pix_value_ptr(x, y++, 1) = v; - } - while (--len); - } - - //-------------------------------------------------------------------- - void blend_hline(int x, int y, unsigned len, - const color_type& c, int8u cover) - { - - pixel_type* p = pix_value_ptr(x, y, len); - do - { - blend_pix(p, c, cover); - p = p->next(); - } - while (--len); - } - - //-------------------------------------------------------------------- - void blend_vline(int x, int y, unsigned len, - const color_type& c, int8u cover) - { - do - { - blend_pix(pix_value_ptr(x, y++, 1), c, cover); - } - while (--len); - } - - //-------------------------------------------------------------------- - void blend_solid_hspan(int x, int y, unsigned len, - const color_type& c, const int8u* covers) - { - pixel_type* p = pix_value_ptr(x, y, len); - - do - { - blend_pix(p, c, *covers++); - p = p->next(); - } - while (--len); - } - - //-------------------------------------------------------------------- - void blend_solid_vspan(int x, int y, unsigned len, - const color_type& c, const int8u* covers) - { - do - { - blend_pix(pix_value_ptr(x, y++, 1), c, *covers++); - } - while (--len); - } - - //-------------------------------------------------------------------- - void copy_color_hspan(int x, int y, - unsigned len, - const color_type* colors) - { - pixel_type* p = pix_value_ptr(x, y, len); - - do - { - p->set(*colors++); - p = p->next(); - } - while (--len); - } - - //-------------------------------------------------------------------- - void copy_color_vspan(int x, int y, - unsigned len, - const color_type* colors) - { - do - { - pix_value_ptr(x, y++, 1)->set(*colors++); - } - while (--len); - } - - //-------------------------------------------------------------------- - void blend_color_hspan(int x, int y, unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - pixel_type* p = pix_value_ptr(x, y, len); - - do - { - blend_pix(p, *colors++, covers ? *covers++ : cover); - p = p->next(); - } - while (--len); - } - - //-------------------------------------------------------------------- - void blend_color_vspan(int x, int y, unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - do - { - blend_pix(pix_value_ptr(x, y++, 1), *colors++, covers ? *covers++ : cover); - } - while (--len); - - } - - //-------------------------------------------------------------------- - template void for_each_pixel(Function f) - { - unsigned y; - for (y = 0; y < height(); ++y) - { - row_data r = m_rbuf->row(y); - if (r.ptr) - { - unsigned len = r.x2 - r.x1 + 1; - pixel_type* p = pix_value_ptr(r.x1, y, len); - do - { - f(p->c); - p = p->next(); - } - while (--len); - } - } - } - - //-------------------------------------------------------------------- - void premultiply() - { - for_each_pixel(multiplier_rgba::premultiply); - } - - //-------------------------------------------------------------------- - void demultiply() - { - for_each_pixel(multiplier_rgba::demultiply); - } - - //-------------------------------------------------------------------- - template void apply_gamma_dir(const GammaLut& g) - { - for_each_pixel(apply_gamma_dir_rgba(g)); - } - - //-------------------------------------------------------------------- - template void apply_gamma_inv(const GammaLut& g) - { - for_each_pixel(apply_gamma_inv_rgba(g)); - } - - //-------------------------------------------------------------------- - template void copy_from(const RenBuf2& from, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len) - { - if (const int8u* p = from.row_ptr(ysrc)) - { - memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, - p + xsrc * pix_width, - len * pix_width); - } - } - - //-------------------------------------------------------------------- - // Blend from another RGBA surface. - template - void blend_from(const SrcPixelFormatRenderer& from, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; - - if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) - { - pixel_type* pdst = pix_value_ptr(xdst, ydst, len); - int srcinc = 1; - int dstinc = 1; - - if (xdst > xsrc) - { - psrc = psrc->advance(len - 1); - pdst = pdst->advance(len - 1); - srcinc = -1; - dstinc = -1; - } - - do - { - blend_pix(pdst, psrc->get(), cover); - psrc = psrc->advance(srcinc); - pdst = pdst->advance(dstinc); - } - while (--len); - } - } - - //-------------------------------------------------------------------- - // Blend from single color, using grayscale surface as alpha channel. - template - void blend_from_color(const SrcPixelFormatRenderer& from, - const color_type& color, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; - typedef typename SrcPixelFormatRenderer::color_type src_color_type; - - if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) - { - pixel_type* pdst = pix_value_ptr(xdst, ydst, len); - - do - { - blend_pix(pdst, color, - src_color_type::scale_cover(cover, psrc->c[0])); - psrc = psrc->next(); - pdst = pdst->next(); - } - while (--len); - } - } - - //-------------------------------------------------------------------- - // Blend from color table, using grayscale surface as indexes into table. - // Obviously, this only works for integer value types. - template - void blend_from_lut(const SrcPixelFormatRenderer& from, - const color_type* color_lut, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len, - int8u cover) - { - typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type; - - if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc)) - { - pixel_type* pdst = pix_value_ptr(xdst, ydst, len); - - do - { - blend_pix(pdst, color_lut[psrc->c[0]], cover); - psrc = psrc->next(); - pdst = pdst->next(); - } - while (--len); - } - } - - private: - rbuf_type* m_rbuf; - Blender m_blender; - unsigned m_comp_op; - }; - - - //----------------------------------------------------------------------- - typedef blender_rgba blender_rgba32; - typedef blender_rgba blender_argb32; - typedef blender_rgba blender_abgr32; - typedef blender_rgba blender_bgra32; - - typedef blender_rgba blender_srgba32; - typedef blender_rgba blender_sargb32; - typedef blender_rgba blender_sabgr32; - typedef blender_rgba blender_sbgra32; - - typedef blender_rgba_pre blender_rgba32_pre; - typedef blender_rgba_pre blender_argb32_pre; - typedef blender_rgba_pre blender_abgr32_pre; - typedef blender_rgba_pre blender_bgra32_pre; - - typedef blender_rgba_pre blender_srgba32_pre; - typedef blender_rgba_pre blender_sargb32_pre; - typedef blender_rgba_pre blender_sabgr32_pre; - typedef blender_rgba_pre blender_sbgra32_pre; - - typedef blender_rgba_plain blender_rgba32_plain; - typedef blender_rgba_plain blender_argb32_plain; - typedef blender_rgba_plain blender_abgr32_plain; - typedef blender_rgba_plain blender_bgra32_plain; - - typedef blender_rgba_plain blender_srgba32_plain; - typedef blender_rgba_plain blender_sargb32_plain; - typedef blender_rgba_plain blender_sabgr32_plain; - typedef blender_rgba_plain blender_sbgra32_plain; - - typedef blender_rgba blender_rgba64; - typedef blender_rgba blender_argb64; - typedef blender_rgba blender_abgr64; - typedef blender_rgba blender_bgra64; - - typedef blender_rgba_pre blender_rgba64_pre; - typedef blender_rgba_pre blender_argb64_pre; - typedef blender_rgba_pre blender_abgr64_pre; - typedef blender_rgba_pre blender_bgra64_pre; - - typedef blender_rgba_plain blender_rgba64_plain; - typedef blender_rgba_plain blender_argb64_plain; - typedef blender_rgba_plain blender_abgr64_plain; - typedef blender_rgba_plain blender_bgra64_plain; - - typedef blender_rgba blender_rgba128; - typedef blender_rgba blender_argb128; - typedef blender_rgba blender_abgr128; - typedef blender_rgba blender_bgra128; - - typedef blender_rgba_pre blender_rgba128_pre; - typedef blender_rgba_pre blender_argb128_pre; - typedef blender_rgba_pre blender_abgr128_pre; - typedef blender_rgba_pre blender_bgra128_pre; - - typedef blender_rgba_plain blender_rgba128_plain; - typedef blender_rgba_plain blender_argb128_plain; - typedef blender_rgba_plain blender_abgr128_plain; - typedef blender_rgba_plain blender_bgra128_plain; - - - //----------------------------------------------------------------------- - typedef pixfmt_alpha_blend_rgba pixfmt_rgba32; - typedef pixfmt_alpha_blend_rgba pixfmt_argb32; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr32; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra32; - - typedef pixfmt_alpha_blend_rgba pixfmt_srgba32; - typedef pixfmt_alpha_blend_rgba pixfmt_sargb32; - typedef pixfmt_alpha_blend_rgba pixfmt_sabgr32; - typedef pixfmt_alpha_blend_rgba pixfmt_sbgra32; - - typedef pixfmt_alpha_blend_rgba pixfmt_rgba32_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_argb32_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr32_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra32_pre; - - typedef pixfmt_alpha_blend_rgba pixfmt_srgba32_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_sargb32_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_sabgr32_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_sbgra32_pre; - - typedef pixfmt_alpha_blend_rgba pixfmt_rgba32_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_argb32_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr32_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra32_plain; - - typedef pixfmt_alpha_blend_rgba pixfmt_srgba32_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_sargb32_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_sabgr32_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_sbgra32_plain; - - typedef pixfmt_alpha_blend_rgba pixfmt_rgba64; - typedef pixfmt_alpha_blend_rgba pixfmt_argb64; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr64; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra64; - - typedef pixfmt_alpha_blend_rgba pixfmt_rgba64_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_argb64_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr64_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra64_pre; - - typedef pixfmt_alpha_blend_rgba pixfmt_rgba64_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_argb64_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr64_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra64_plain; - - typedef pixfmt_alpha_blend_rgba pixfmt_rgba128; - typedef pixfmt_alpha_blend_rgba pixfmt_argb128; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr128; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra128; - - typedef pixfmt_alpha_blend_rgba pixfmt_rgba128_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_argb128_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr128_pre; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra128_pre; - - typedef pixfmt_alpha_blend_rgba pixfmt_rgba128_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_argb128_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_abgr128_plain; - typedef pixfmt_alpha_blend_rgba pixfmt_bgra128_plain; - -} - -#endif - diff --git a/xs/src/agg/agg_pixfmt_transposer.h b/xs/src/agg/agg_pixfmt_transposer.h deleted file mode 100644 index 64738b6c75..0000000000 --- a/xs/src/agg/agg_pixfmt_transposer.h +++ /dev/null @@ -1,157 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_PIXFMT_TRANSPOSER_INCLUDED -#define AGG_PIXFMT_TRANSPOSER_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - //=======================================================pixfmt_transposer - template class pixfmt_transposer - { - public: - typedef PixFmt pixfmt_type; - typedef typename pixfmt_type::color_type color_type; - typedef typename pixfmt_type::row_data row_data; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - - //-------------------------------------------------------------------- - pixfmt_transposer() : m_pixf(0) {} - explicit pixfmt_transposer(pixfmt_type& pixf) : m_pixf(&pixf) {} - void attach(pixfmt_type& pixf) { m_pixf = &pixf; } - - //-------------------------------------------------------------------- - AGG_INLINE unsigned width() const { return m_pixf->height(); } - AGG_INLINE unsigned height() const { return m_pixf->width(); } - - //-------------------------------------------------------------------- - AGG_INLINE color_type pixel(int x, int y) const - { - return m_pixf->pixel(y, x); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_pixel(int x, int y, const color_type& c) - { - m_pixf->copy_pixel(y, x, c); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_pixel(int x, int y, - const color_type& c, - int8u cover) - { - m_pixf->blend_pixel(y, x, c, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_hline(int x, int y, - unsigned len, - const color_type& c) - { - m_pixf->copy_vline(y, x, len, c); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_vline(int x, int y, - unsigned len, - const color_type& c) - { - m_pixf->copy_hline(y, x, len, c); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_hline(int x, int y, - unsigned len, - const color_type& c, - int8u cover) - { - m_pixf->blend_vline(y, x, len, c, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_vline(int x, int y, - unsigned len, - const color_type& c, - int8u cover) - { - m_pixf->blend_hline(y, x, len, c, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_solid_hspan(int x, int y, - unsigned len, - const color_type& c, - const int8u* covers) - { - m_pixf->blend_solid_vspan(y, x, len, c, covers); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_solid_vspan(int x, int y, - unsigned len, - const color_type& c, - const int8u* covers) - { - m_pixf->blend_solid_hspan(y, x, len, c, covers); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_color_hspan(int x, int y, - unsigned len, - const color_type* colors) - { - m_pixf->copy_color_vspan(y, x, len, colors); - } - - //-------------------------------------------------------------------- - AGG_INLINE void copy_color_vspan(int x, int y, - unsigned len, - const color_type* colors) - { - m_pixf->copy_color_hspan(y, x, len, colors); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_color_hspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - m_pixf->blend_color_vspan(y, x, len, colors, covers, cover); - } - - //-------------------------------------------------------------------- - AGG_INLINE void blend_color_vspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - m_pixf->blend_color_hspan(y, x, len, colors, covers, cover); - } - - private: - pixfmt_type* m_pixf; - }; -} - -#endif - - diff --git a/xs/src/agg/agg_rasterizer_compound_aa.h b/xs/src/agg/agg_rasterizer_compound_aa.h deleted file mode 100644 index 72d811be0f..0000000000 --- a/xs/src/agg/agg_rasterizer_compound_aa.h +++ /dev/null @@ -1,665 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.3 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// -// The author gratefully acknowleges the support of David Turner, -// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType -// libray - in producing this work. See http://www.freetype.org for details. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for 32-bit screen coordinates has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- -#ifndef AGG_RASTERIZER_COMPOUND_AA_INCLUDED -#define AGG_RASTERIZER_COMPOUND_AA_INCLUDED - -#include -#include "agg_rasterizer_cells_aa.h" -#include "agg_rasterizer_sl_clip.h" - -namespace agg -{ - - //-----------------------------------------------------------cell_style_aa - // A pixel cell. There're no constructors defined and it was done - // intentionally in order to avoid extra overhead when allocating an - // array of cells. - struct cell_style_aa - { - int x; - int y; - int cover; - int area; - int16 left, right; - - void initial() - { - x = std::numeric_limits::max(); - y = std::numeric_limits::max(); - cover = 0; - area = 0; - left = -1; - right = -1; - } - - void style(const cell_style_aa& c) - { - left = c.left; - right = c.right; - } - - int not_equal(int ex, int ey, const cell_style_aa& c) const - { - return ((unsigned)ex - (unsigned)x) | ((unsigned)ey - (unsigned)y) | - ((unsigned)left - (unsigned)c.left) | ((unsigned)right - (unsigned)c.right); - } - }; - - - //===========================================================layer_order_e - enum layer_order_e - { - layer_unsorted, //------layer_unsorted - layer_direct, //------layer_direct - layer_inverse //------layer_inverse - }; - - - //==================================================rasterizer_compound_aa - template class rasterizer_compound_aa - { - struct style_info - { - unsigned start_cell; - unsigned num_cells; - int last_x; - }; - - struct cell_info - { - int x, area, cover; - }; - - public: - typedef Clip clip_type; - typedef typename Clip::conv_type conv_type; - typedef typename Clip::coord_type coord_type; - - enum aa_scale_e - { - aa_shift = 8, - aa_scale = 1 << aa_shift, - aa_mask = aa_scale - 1, - aa_scale2 = aa_scale * 2, - aa_mask2 = aa_scale2 - 1 - }; - - //-------------------------------------------------------------------- - rasterizer_compound_aa() : - m_outline(), - m_clipper(), - m_filling_rule(fill_non_zero), - m_layer_order(layer_direct), - m_styles(), // Active Styles - m_ast(), // Active Style Table (unique values) - m_asm(), // Active Style Mask - m_cells(), - m_cover_buf(), - m_min_style(std::numeric_limits::max()), - m_max_style(std::numeric_limits::min()), - m_start_x(0), - m_start_y(0), - m_scan_y(std::numeric_limits::max()), - m_sl_start(0), - m_sl_len(0) - {} - - //-------------------------------------------------------------------- - void reset(); - void reset_clipping(); - void clip_box(double x1, double y1, double x2, double y2); - void filling_rule(filling_rule_e filling_rule); - void layer_order(layer_order_e order); - - //-------------------------------------------------------------------- - void styles(int left, int right); - void move_to(int x, int y); - void line_to(int x, int y); - void move_to_d(double x, double y); - void line_to_d(double x, double y); - void add_vertex(double x, double y, unsigned cmd); - - void edge(int x1, int y1, int x2, int y2); - void edge_d(double x1, double y1, double x2, double y2); - - //------------------------------------------------------------------- - template - void add_path(VertexSource& vs, unsigned path_id=0) - { - double x; - double y; - - unsigned cmd; - vs.rewind(path_id); - if(m_outline.sorted()) reset(); - while(!is_stop(cmd = vs.vertex(&x, &y))) - { - add_vertex(x, y, cmd); - } - } - - - //-------------------------------------------------------------------- - int min_x() const { return m_outline.min_x(); } - int min_y() const { return m_outline.min_y(); } - int max_x() const { return m_outline.max_x(); } - int max_y() const { return m_outline.max_y(); } - int min_style() const { return m_min_style; } - int max_style() const { return m_max_style; } - - //-------------------------------------------------------------------- - void sort(); - bool rewind_scanlines(); - unsigned sweep_styles(); - int scanline_start() const { return m_sl_start; } - unsigned scanline_length() const { return m_sl_len; } - unsigned style(unsigned style_idx) const; - - cover_type* allocate_cover_buffer(unsigned len); - - //-------------------------------------------------------------------- - bool navigate_scanline(int y); - bool hit_test(int tx, int ty); - - //-------------------------------------------------------------------- - AGG_INLINE unsigned calculate_alpha(int area) const - { - int cover = area >> (poly_subpixel_shift*2 + 1 - aa_shift); - if(cover < 0) cover = -cover; - if(m_filling_rule == fill_even_odd) - { - cover &= aa_mask2; - if(cover > aa_scale) - { - cover = aa_scale2 - cover; - } - } - if(cover > aa_mask) cover = aa_mask; - return cover; - } - - //-------------------------------------------------------------------- - // Sweeps one scanline with one style index. The style ID can be - // determined by calling style(). - template bool sweep_scanline(Scanline& sl, int style_idx) - { - int scan_y = m_scan_y - 1; - if(scan_y > m_outline.max_y()) return false; - - sl.reset_spans(); - - if(style_idx < 0) - { - style_idx = 0; - } - else - { - style_idx++; - } - - const style_info& st = m_styles[m_ast[style_idx]]; - - unsigned num_cells = st.num_cells; - cell_info* cell = &m_cells[st.start_cell]; - - int cover = 0; - while(num_cells--) - { - unsigned alpha; - int x = cell->x; - int area = cell->area; - - cover += cell->cover; - - ++cell; - - if(area) - { - alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area); - sl.add_cell(x, alpha); - x++; - } - - if(num_cells && cell->x > x) - { - alpha = calculate_alpha(cover << (poly_subpixel_shift + 1)); - if(alpha) - { - sl.add_span(x, cell->x - x, alpha); - } - } - } - - if(sl.num_spans() == 0) return false; - sl.finalize(scan_y); - return true; - } - - private: - void add_style(int style_id); - - //-------------------------------------------------------------------- - // Disable copying - rasterizer_compound_aa(const rasterizer_compound_aa&); - const rasterizer_compound_aa& - operator = (const rasterizer_compound_aa&); - - private: - rasterizer_cells_aa m_outline; - clip_type m_clipper; - filling_rule_e m_filling_rule; - layer_order_e m_layer_order; - pod_vector m_styles; // Active Styles - pod_vector m_ast; // Active Style Table (unique values) - pod_vector m_asm; // Active Style Mask - pod_vector m_cells; - pod_vector m_cover_buf; - - int m_min_style; - int m_max_style; - coord_type m_start_x; - coord_type m_start_y; - int m_scan_y; - int m_sl_start; - unsigned m_sl_len; - }; - - - - - - - - - - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::reset() - { - m_outline.reset(); - m_min_style = std::numeric_limits::max(); - m_max_style = std::numeric_limits::min(); - m_scan_y = std::numeric_limits::max(); - m_sl_start = 0; - m_sl_len = 0; - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::filling_rule(filling_rule_e filling_rule) - { - m_filling_rule = filling_rule; - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::layer_order(layer_order_e order) - { - m_layer_order = order; - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::clip_box(double x1, double y1, - double x2, double y2) - { - reset(); - m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1), - conv_type::upscale(x2), conv_type::upscale(y2)); - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::reset_clipping() - { - reset(); - m_clipper.reset_clipping(); - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::styles(int left, int right) - { - cell_style_aa cell; - cell.initial(); - cell.left = (int16)left; - cell.right = (int16)right; - m_outline.style(cell); - if(left >= 0 && left < m_min_style) m_min_style = left; - if(left >= 0 && left > m_max_style) m_max_style = left; - if(right >= 0 && right < m_min_style) m_min_style = right; - if(right >= 0 && right > m_max_style) m_max_style = right; - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::move_to(int x, int y) - { - if(m_outline.sorted()) reset(); - m_clipper.move_to(m_start_x = conv_type::downscale(x), - m_start_y = conv_type::downscale(y)); - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::line_to(int x, int y) - { - m_clipper.line_to(m_outline, - conv_type::downscale(x), - conv_type::downscale(y)); - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::move_to_d(double x, double y) - { - if(m_outline.sorted()) reset(); - m_clipper.move_to(m_start_x = conv_type::upscale(x), - m_start_y = conv_type::upscale(y)); - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::line_to_d(double x, double y) - { - m_clipper.line_to(m_outline, - conv_type::upscale(x), - conv_type::upscale(y)); - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::add_vertex(double x, double y, unsigned cmd) - { - if(is_move_to(cmd)) - { - move_to_d(x, y); - } - else - if(is_vertex(cmd)) - { - line_to_d(x, y); - } - else - if(is_close(cmd)) - { - m_clipper.line_to(m_outline, m_start_x, m_start_y); - } - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::edge(int x1, int y1, int x2, int y2) - { - if(m_outline.sorted()) reset(); - m_clipper.move_to(conv_type::downscale(x1), conv_type::downscale(y1)); - m_clipper.line_to(m_outline, - conv_type::downscale(x2), - conv_type::downscale(y2)); - } - - //------------------------------------------------------------------------ - template - void rasterizer_compound_aa::edge_d(double x1, double y1, - double x2, double y2) - { - if(m_outline.sorted()) reset(); - m_clipper.move_to(conv_type::upscale(x1), conv_type::upscale(y1)); - m_clipper.line_to(m_outline, - conv_type::upscale(x2), - conv_type::upscale(y2)); - } - - //------------------------------------------------------------------------ - template - AGG_INLINE void rasterizer_compound_aa::sort() - { - m_outline.sort_cells(); - } - - //------------------------------------------------------------------------ - template - AGG_INLINE bool rasterizer_compound_aa::rewind_scanlines() - { - m_outline.sort_cells(); - if(m_outline.total_cells() == 0) - { - return false; - } - if(m_max_style < m_min_style) - { - return false; - } - m_scan_y = m_outline.min_y(); - m_styles.allocate(m_max_style - m_min_style + 2, 128); - return true; - } - - //------------------------------------------------------------------------ - template - AGG_INLINE void rasterizer_compound_aa::add_style(int style_id) - { - if(style_id < 0) style_id = 0; - else style_id -= m_min_style - 1; - - unsigned nbyte = style_id >> 3; - unsigned mask = 1 << (style_id & 7); - - style_info* style = &m_styles[style_id]; - if((m_asm[nbyte] & mask) == 0) - { - m_ast.add(style_id); - m_asm[nbyte] |= mask; - style->start_cell = 0; - style->num_cells = 0; - style->last_x = std::numeric_limits::min(); - } - ++style->start_cell; - } - - //------------------------------------------------------------------------ - // Returns the number of styles - template - unsigned rasterizer_compound_aa::sweep_styles() - { - for(;;) - { - if(m_scan_y > m_outline.max_y()) return 0; - unsigned num_cells = m_outline.scanline_num_cells(m_scan_y); - const cell_style_aa* const* cells = m_outline.scanline_cells(m_scan_y); - unsigned num_styles = m_max_style - m_min_style + 2; - const cell_style_aa* curr_cell; - unsigned style_id; - style_info* style; - cell_info* cell; - - m_cells.allocate(num_cells * 2, 256); // Each cell can have two styles - m_ast.capacity(num_styles, 64); - m_asm.allocate((num_styles + 7) >> 3, 8); - m_asm.zero(); - - if(num_cells) - { - // Pre-add zero (for no-fill style, that is, -1). - // We need that to ensure that the "-1 style" would go first. - m_asm[0] |= 1; - m_ast.add(0); - style = &m_styles[0]; - style->start_cell = 0; - style->num_cells = 0; - style->last_x = std::numeric_limits::min(); - - m_sl_start = cells[0]->x; - m_sl_len = cells[num_cells-1]->x - m_sl_start + 1; - while(num_cells--) - { - curr_cell = *cells++; - add_style(curr_cell->left); - add_style(curr_cell->right); - } - - // Convert the Y-histogram into the array of starting indexes - unsigned i; - unsigned start_cell = 0; - for(i = 0; i < m_ast.size(); i++) - { - style_info& st = m_styles[m_ast[i]]; - unsigned v = st.start_cell; - st.start_cell = start_cell; - start_cell += v; - } - - cells = m_outline.scanline_cells(m_scan_y); - num_cells = m_outline.scanline_num_cells(m_scan_y); - - while(num_cells--) - { - curr_cell = *cells++; - style_id = (curr_cell->left < 0) ? 0 : - curr_cell->left - m_min_style + 1; - - style = &m_styles[style_id]; - if(curr_cell->x == style->last_x) - { - cell = &m_cells[style->start_cell + style->num_cells - 1]; - cell->area += curr_cell->area; - cell->cover += curr_cell->cover; - } - else - { - cell = &m_cells[style->start_cell + style->num_cells]; - cell->x = curr_cell->x; - cell->area = curr_cell->area; - cell->cover = curr_cell->cover; - style->last_x = curr_cell->x; - style->num_cells++; - } - - style_id = (curr_cell->right < 0) ? 0 : - curr_cell->right - m_min_style + 1; - - style = &m_styles[style_id]; - if(curr_cell->x == style->last_x) - { - cell = &m_cells[style->start_cell + style->num_cells - 1]; - cell->area -= curr_cell->area; - cell->cover -= curr_cell->cover; - } - else - { - cell = &m_cells[style->start_cell + style->num_cells]; - cell->x = curr_cell->x; - cell->area = -curr_cell->area; - cell->cover = -curr_cell->cover; - style->last_x = curr_cell->x; - style->num_cells++; - } - } - } - if(m_ast.size() > 1) break; - ++m_scan_y; - } - ++m_scan_y; - - if(m_layer_order != layer_unsorted) - { - range_adaptor > ra(m_ast, 1, m_ast.size() - 1); - if(m_layer_order == layer_direct) quick_sort(ra, unsigned_greater); - else quick_sort(ra, unsigned_less); - } - - return m_ast.size() - 1; - } - - //------------------------------------------------------------------------ - // Returns style ID depending of the existing style index - template - AGG_INLINE - unsigned rasterizer_compound_aa::style(unsigned style_idx) const - { - return m_ast[style_idx + 1] + m_min_style - 1; - } - - //------------------------------------------------------------------------ - template - AGG_INLINE bool rasterizer_compound_aa::navigate_scanline(int y) - { - m_outline.sort_cells(); - if(m_outline.total_cells() == 0) - { - return false; - } - if(m_max_style < m_min_style) - { - return false; - } - if(y < m_outline.min_y() || y > m_outline.max_y()) - { - return false; - } - m_scan_y = y; - m_styles.allocate(m_max_style - m_min_style + 2, 128); - return true; - } - - //------------------------------------------------------------------------ - template - bool rasterizer_compound_aa::hit_test(int tx, int ty) - { - if(!navigate_scanline(ty)) - { - return false; - } - - unsigned num_styles = sweep_styles(); - if(num_styles <= 0) - { - return false; - } - - scanline_hit_test sl(tx); - sweep_scanline(sl, -1); - return sl.hit(); - } - - //------------------------------------------------------------------------ - template - cover_type* rasterizer_compound_aa::allocate_cover_buffer(unsigned len) - { - m_cover_buf.allocate(len, 256); - return &m_cover_buf[0]; - } - -} - - - -#endif - diff --git a/xs/src/agg/agg_rasterizer_outline.h b/xs/src/agg/agg_rasterizer_outline.h deleted file mode 100644 index 65203e34c5..0000000000 --- a/xs/src/agg/agg_rasterizer_outline.h +++ /dev/null @@ -1,147 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_RASTERIZER_OUTLINE_INCLUDED -#define AGG_RASTERIZER_OUTLINE_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - //======================================================rasterizer_outline - template class rasterizer_outline - { - public: - explicit rasterizer_outline(Renderer& ren) : - m_ren(&ren), - m_start_x(0), - m_start_y(0), - m_vertices(0) - {} - void attach(Renderer& ren) { m_ren = &ren; } - - - //-------------------------------------------------------------------- - void move_to(int x, int y) - { - m_vertices = 1; - m_ren->move_to(m_start_x = x, m_start_y = y); - } - - //-------------------------------------------------------------------- - void line_to(int x, int y) - { - ++m_vertices; - m_ren->line_to(x, y); - } - - //-------------------------------------------------------------------- - void move_to_d(double x, double y) - { - move_to(m_ren->coord(x), m_ren->coord(y)); - } - - //-------------------------------------------------------------------- - void line_to_d(double x, double y) - { - line_to(m_ren->coord(x), m_ren->coord(y)); - } - - //-------------------------------------------------------------------- - void close() - { - if(m_vertices > 2) - { - line_to(m_start_x, m_start_y); - } - m_vertices = 0; - } - - //-------------------------------------------------------------------- - void add_vertex(double x, double y, unsigned cmd) - { - if(is_move_to(cmd)) - { - move_to_d(x, y); - } - else - { - if(is_end_poly(cmd)) - { - if(is_closed(cmd)) close(); - } - else - { - line_to_d(x, y); - } - } - } - - - //-------------------------------------------------------------------- - template - void add_path(VertexSource& vs, unsigned path_id=0) - { - double x; - double y; - - unsigned cmd; - vs.rewind(path_id); - while(!is_stop(cmd = vs.vertex(&x, &y))) - { - add_vertex(x, y, cmd); - } - } - - - //-------------------------------------------------------------------- - template - void render_all_paths(VertexSource& vs, - const ColorStorage& colors, - const PathId& path_id, - unsigned num_paths) - { - for(unsigned i = 0; i < num_paths; i++) - { - m_ren->line_color(colors[i]); - add_path(vs, path_id[i]); - } - } - - - //-------------------------------------------------------------------- - template void render_ctrl(Ctrl& c) - { - unsigned i; - for(i = 0; i < c.num_paths(); i++) - { - m_ren->line_color(c.color(i)); - add_path(c, i); - } - } - - - private: - Renderer* m_ren; - int m_start_x; - int m_start_y; - unsigned m_vertices; - }; - - -} - - -#endif - diff --git a/xs/src/agg/agg_rasterizer_outline_aa.h b/xs/src/agg/agg_rasterizer_outline_aa.h deleted file mode 100644 index a06bd1e843..0000000000 --- a/xs/src/agg/agg_rasterizer_outline_aa.h +++ /dev/null @@ -1,599 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_RASTERIZER_OUTLINE_AA_INCLUDED -#define AGG_RASTERIZER_OUTLINE_AA_INCLUDED - -#include "agg_basics.h" -#include "agg_line_aa_basics.h" -#include "agg_vertex_sequence.h" - -namespace agg -{ - - //------------------------------------------------------------------------- - inline bool cmp_dist_start(int d) { return d > 0; } - inline bool cmp_dist_end(int d) { return d <= 0; } - - - - //-----------------------------------------------------------line_aa_vertex - // Vertex (x, y) with the distance to the next one. The last vertex has - // the distance between the last and the first points - struct line_aa_vertex - { - int x; - int y; - int len; - - line_aa_vertex() {} - line_aa_vertex(int x_, int y_) : - x(x_), - y(y_), - len(0) - { - } - - bool operator () (const line_aa_vertex& val) - { - double dx = val.x - x; - double dy = val.y - y; - return (len = uround(sqrt(dx * dx + dy * dy))) > - (line_subpixel_scale + line_subpixel_scale / 2); - } - }; - - - //----------------------------------------------------------outline_aa_join_e - enum outline_aa_join_e - { - outline_no_join, //-----outline_no_join - outline_miter_join, //-----outline_miter_join - outline_round_join, //-----outline_round_join - outline_miter_accurate_join //-----outline_accurate_join - }; - - //=======================================================rasterizer_outline_aa - template class rasterizer_outline_aa - { - private: - //------------------------------------------------------------------------ - struct draw_vars - { - unsigned idx; - int x1, y1, x2, y2; - line_parameters curr, next; - int lcurr, lnext; - int xb1, yb1, xb2, yb2; - unsigned flags; - }; - - void draw(draw_vars& dv, unsigned start, unsigned end); - - public: - typedef line_aa_vertex vertex_type; - typedef vertex_sequence vertex_storage_type; - - explicit rasterizer_outline_aa(Renderer& ren) : - m_ren(&ren), - m_line_join(ren.accurate_join_only() ? - outline_miter_accurate_join : - outline_round_join), - m_round_cap(false), - m_start_x(0), - m_start_y(0) - {} - void attach(Renderer& ren) { m_ren = &ren; } - - //------------------------------------------------------------------------ - void line_join(outline_aa_join_e join) - { - m_line_join = m_ren->accurate_join_only() ? - outline_miter_accurate_join : - join; - } - bool line_join() const { return m_line_join; } - - //------------------------------------------------------------------------ - void round_cap(bool v) { m_round_cap = v; } - bool round_cap() const { return m_round_cap; } - - //------------------------------------------------------------------------ - void move_to(int x, int y) - { - m_src_vertices.modify_last(vertex_type(m_start_x = x, m_start_y = y)); - } - - //------------------------------------------------------------------------ - void line_to(int x, int y) - { - m_src_vertices.add(vertex_type(x, y)); - } - - //------------------------------------------------------------------------ - void move_to_d(double x, double y) - { - move_to(Coord::conv(x), Coord::conv(y)); - } - - //------------------------------------------------------------------------ - void line_to_d(double x, double y) - { - line_to(Coord::conv(x), Coord::conv(y)); - } - - //------------------------------------------------------------------------ - void render(bool close_polygon); - - //------------------------------------------------------------------------ - void add_vertex(double x, double y, unsigned cmd) - { - if(is_move_to(cmd)) - { - render(false); - move_to_d(x, y); - } - else - { - if(is_end_poly(cmd)) - { - render(is_closed(cmd)); - if(is_closed(cmd)) - { - move_to(m_start_x, m_start_y); - } - } - else - { - line_to_d(x, y); - } - } - } - - //------------------------------------------------------------------------ - template - void add_path(VertexSource& vs, unsigned path_id=0) - { - double x; - double y; - - unsigned cmd; - vs.rewind(path_id); - while(!is_stop(cmd = vs.vertex(&x, &y))) - { - add_vertex(x, y, cmd); - } - render(false); - } - - - //------------------------------------------------------------------------ - template - void render_all_paths(VertexSource& vs, - const ColorStorage& colors, - const PathId& path_id, - unsigned num_paths) - { - for(unsigned i = 0; i < num_paths; i++) - { - m_ren->color(colors[i]); - add_path(vs, path_id[i]); - } - } - - - //------------------------------------------------------------------------ - template void render_ctrl(Ctrl& c) - { - unsigned i; - for(i = 0; i < c.num_paths(); i++) - { - m_ren->color(c.color(i)); - add_path(c, i); - } - } - - private: - rasterizer_outline_aa(const rasterizer_outline_aa&); - const rasterizer_outline_aa& operator = - (const rasterizer_outline_aa&); - - Renderer* m_ren; - vertex_storage_type m_src_vertices; - outline_aa_join_e m_line_join; - bool m_round_cap; - int m_start_x; - int m_start_y; - }; - - - - - - - - - //---------------------------------------------------------------------------- - template - void rasterizer_outline_aa::draw(draw_vars& dv, - unsigned start, - unsigned end) - { - unsigned i; - const vertex_storage_type::value_type* v; - - for(i = start; i < end; i++) - { - if(m_line_join == outline_round_join) - { - dv.xb1 = dv.curr.x1 + (dv.curr.y2 - dv.curr.y1); - dv.yb1 = dv.curr.y1 - (dv.curr.x2 - dv.curr.x1); - dv.xb2 = dv.curr.x2 + (dv.curr.y2 - dv.curr.y1); - dv.yb2 = dv.curr.y2 - (dv.curr.x2 - dv.curr.x1); - } - - switch(dv.flags) - { - case 0: m_ren->line3(dv.curr, dv.xb1, dv.yb1, dv.xb2, dv.yb2); break; - case 1: m_ren->line2(dv.curr, dv.xb2, dv.yb2); break; - case 2: m_ren->line1(dv.curr, dv.xb1, dv.yb1); break; - case 3: m_ren->line0(dv.curr); break; - } - - if(m_line_join == outline_round_join && (dv.flags & 2) == 0) - { - m_ren->pie(dv.curr.x2, dv.curr.y2, - dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), - dv.curr.y2 - (dv.curr.x2 - dv.curr.x1), - dv.curr.x2 + (dv.next.y2 - dv.next.y1), - dv.curr.y2 - (dv.next.x2 - dv.next.x1)); - } - - dv.x1 = dv.x2; - dv.y1 = dv.y2; - dv.lcurr = dv.lnext; - dv.lnext = m_src_vertices[dv.idx].len; - - ++dv.idx; - if(dv.idx >= m_src_vertices.size()) dv.idx = 0; - - v = &m_src_vertices[dv.idx]; - dv.x2 = v->x; - dv.y2 = v->y; - - dv.curr = dv.next; - dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); - dv.xb1 = dv.xb2; - dv.yb1 = dv.yb2; - - switch(m_line_join) - { - case outline_no_join: - dv.flags = 3; - break; - - case outline_miter_join: - dv.flags >>= 1; - dv.flags |= ((dv.curr.diagonal_quadrant() == - dv.next.diagonal_quadrant()) << 1); - if((dv.flags & 2) == 0) - { - bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); - } - break; - - case outline_round_join: - dv.flags >>= 1; - dv.flags |= ((dv.curr.diagonal_quadrant() == - dv.next.diagonal_quadrant()) << 1); - break; - - case outline_miter_accurate_join: - dv.flags = 0; - bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); - break; - } - } - } - - - - - //---------------------------------------------------------------------------- - template - void rasterizer_outline_aa::render(bool close_polygon) - { - m_src_vertices.close(close_polygon); - draw_vars dv; - const vertex_storage_type::value_type* v; - int x1; - int y1; - int x2; - int y2; - int lprev; - - if(close_polygon) - { - if(m_src_vertices.size() >= 3) - { - dv.idx = 2; - - v = &m_src_vertices[m_src_vertices.size() - 1]; - x1 = v->x; - y1 = v->y; - lprev = v->len; - - v = &m_src_vertices[0]; - x2 = v->x; - y2 = v->y; - dv.lcurr = v->len; - line_parameters prev(x1, y1, x2, y2, lprev); - - v = &m_src_vertices[1]; - dv.x1 = v->x; - dv.y1 = v->y; - dv.lnext = v->len; - dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr); - - v = &m_src_vertices[dv.idx]; - dv.x2 = v->x; - dv.y2 = v->y; - dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); - - dv.xb1 = 0; - dv.yb1 = 0; - dv.xb2 = 0; - dv.yb2 = 0; - - switch(m_line_join) - { - case outline_no_join: - dv.flags = 3; - break; - - case outline_miter_join: - case outline_round_join: - dv.flags = - (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) | - ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1); - break; - - case outline_miter_accurate_join: - dv.flags = 0; - break; - } - - if((dv.flags & 1) == 0 && m_line_join != outline_round_join) - { - bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1); - } - - if((dv.flags & 2) == 0 && m_line_join != outline_round_join) - { - bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); - } - draw(dv, 0, m_src_vertices.size()); - } - } - else - { - switch(m_src_vertices.size()) - { - case 0: - case 1: - break; - - case 2: - { - v = &m_src_vertices[0]; - x1 = v->x; - y1 = v->y; - lprev = v->len; - v = &m_src_vertices[1]; - x2 = v->x; - y2 = v->y; - line_parameters lp(x1, y1, x2, y2, lprev); - if(m_round_cap) - { - m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); - } - m_ren->line3(lp, - x1 + (y2 - y1), - y1 - (x2 - x1), - x2 + (y2 - y1), - y2 - (x2 - x1)); - if(m_round_cap) - { - m_ren->semidot(cmp_dist_end, x2, y2, x2 + (y2 - y1), y2 - (x2 - x1)); - } - } - break; - - case 3: - { - int x3, y3; - int lnext; - v = &m_src_vertices[0]; - x1 = v->x; - y1 = v->y; - lprev = v->len; - v = &m_src_vertices[1]; - x2 = v->x; - y2 = v->y; - lnext = v->len; - v = &m_src_vertices[2]; - x3 = v->x; - y3 = v->y; - line_parameters lp1(x1, y1, x2, y2, lprev); - line_parameters lp2(x2, y2, x3, y3, lnext); - - if(m_round_cap) - { - m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); - } - - if(m_line_join == outline_round_join) - { - m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), - x2 + (y2 - y1), y2 - (x2 - x1)); - - m_ren->pie(x2, y2, x2 + (y2 - y1), y2 - (x2 - x1), - x2 + (y3 - y2), y2 - (x3 - x2)); - - m_ren->line3(lp2, x2 + (y3 - y2), y2 - (x3 - x2), - x3 + (y3 - y2), y3 - (x3 - x2)); - } - else - { - bisectrix(lp1, lp2, &dv.xb1, &dv.yb1); - m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), - dv.xb1, dv.yb1); - - m_ren->line3(lp2, dv.xb1, dv.yb1, - x3 + (y3 - y2), y3 - (x3 - x2)); - } - if(m_round_cap) - { - m_ren->semidot(cmp_dist_end, x3, y3, x3 + (y3 - y2), y3 - (x3 - x2)); - } - } - break; - - default: - { - dv.idx = 3; - - v = &m_src_vertices[0]; - x1 = v->x; - y1 = v->y; - lprev = v->len; - - v = &m_src_vertices[1]; - x2 = v->x; - y2 = v->y; - dv.lcurr = v->len; - line_parameters prev(x1, y1, x2, y2, lprev); - - v = &m_src_vertices[2]; - dv.x1 = v->x; - dv.y1 = v->y; - dv.lnext = v->len; - dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr); - - v = &m_src_vertices[dv.idx]; - dv.x2 = v->x; - dv.y2 = v->y; - dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); - - dv.xb1 = 0; - dv.yb1 = 0; - dv.xb2 = 0; - dv.yb2 = 0; - - switch(m_line_join) - { - case outline_no_join: - dv.flags = 3; - break; - - case outline_miter_join: - case outline_round_join: - dv.flags = - (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) | - ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1); - break; - - case outline_miter_accurate_join: - dv.flags = 0; - break; - } - - if(m_round_cap) - { - m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); - } - if((dv.flags & 1) == 0) - { - if(m_line_join == outline_round_join) - { - m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), - x2 + (y2 - y1), y2 - (x2 - x1)); - m_ren->pie(prev.x2, prev.y2, - x2 + (y2 - y1), y2 - (x2 - x1), - dv.curr.x1 + (dv.curr.y2 - dv.curr.y1), - dv.curr.y1 - (dv.curr.x2 - dv.curr.x1)); - } - else - { - bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1); - m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), - dv.xb1, dv.yb1); - } - } - else - { - m_ren->line1(prev, - x1 + (y2 - y1), - y1 - (x2 - x1)); - } - if((dv.flags & 2) == 0 && m_line_join != outline_round_join) - { - bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); - } - - draw(dv, 1, m_src_vertices.size() - 2); - - if((dv.flags & 1) == 0) - { - if(m_line_join == outline_round_join) - { - m_ren->line3(dv.curr, - dv.curr.x1 + (dv.curr.y2 - dv.curr.y1), - dv.curr.y1 - (dv.curr.x2 - dv.curr.x1), - dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), - dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); - } - else - { - m_ren->line3(dv.curr, dv.xb1, dv.yb1, - dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), - dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); - } - } - else - { - m_ren->line2(dv.curr, - dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), - dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); - } - if(m_round_cap) - { - m_ren->semidot(cmp_dist_end, dv.curr.x2, dv.curr.y2, - dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), - dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); - } - - } - break; - } - } - m_src_vertices.remove_all(); - } - - -} - - -#endif - diff --git a/xs/src/agg/agg_renderer_markers.h b/xs/src/agg/agg_renderer_markers.h deleted file mode 100644 index 6ff0534943..0000000000 --- a/xs/src/agg/agg_renderer_markers.h +++ /dev/null @@ -1,711 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// class renderer_markers -// -//---------------------------------------------------------------------------- - -#ifndef AGG_RENDERER_MARKERS_INCLUDED -#define AGG_RENDERER_MARKERS_INCLUDED - -#include "agg_basics.h" -#include "agg_renderer_primitives.h" - -namespace agg -{ - - //---------------------------------------------------------------marker_e - enum marker_e - { - marker_square, - marker_diamond, - marker_circle, - marker_crossed_circle, - marker_semiellipse_left, - marker_semiellipse_right, - marker_semiellipse_up, - marker_semiellipse_down, - marker_triangle_left, - marker_triangle_right, - marker_triangle_up, - marker_triangle_down, - marker_four_rays, - marker_cross, - marker_x, - marker_dash, - marker_dot, - marker_pixel, - - end_of_markers - }; - - - - //--------------------------------------------------------renderer_markers - template class renderer_markers : - public renderer_primitives - { - public: - typedef renderer_primitives base_type; - typedef BaseRenderer base_ren_type; - typedef typename base_ren_type::color_type color_type; - - //-------------------------------------------------------------------- - renderer_markers(base_ren_type& rbuf) : - base_type(rbuf) - {} - - //-------------------------------------------------------------------- - bool visible(int x, int y, int r) const - { - rect_i rc(x-r, y-r, x+y, y+r); - return rc.clip(base_type::ren().bounding_clip_box()); - } - - //-------------------------------------------------------------------- - void square(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) base_type::outlined_rectangle(x-r, y-r, x+r, y+r); - else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - - //-------------------------------------------------------------------- - void diamond(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int dy = -r; - int dx = 0; - do - { - base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); - - if(dx) - { - base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); - base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); - } - ++dy; - ++dx; - } - while(dy <= 0); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - //-------------------------------------------------------------------- - void circle(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) base_type::outlined_ellipse(x, y, r, r); - else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - - - - //-------------------------------------------------------------------- - void crossed_circle(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - base_type::outlined_ellipse(x, y, r, r); - int r6 = r + (r >> 1); - if(r <= 2) r6++; - r >>= 1; - base_type::ren().blend_hline(x-r6, y, x-r, base_type::line_color(), cover_full); - base_type::ren().blend_hline(x+r, y, x+r6, base_type::line_color(), cover_full); - base_type::ren().blend_vline(x, y-r6, y-r, base_type::line_color(), cover_full); - base_type::ren().blend_vline(x, y+r, y+r6, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //------------------------------------------------------------------------ - void semiellipse_left(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int r8 = r * 4 / 5; - int dy = -r; - int dx = 0; - ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); - do - { - dx += ei.dx(); - dy += ei.dy(); - - base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); - - if(ei.dy() && dx) - { - base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); - } - ++ei; - } - while(dy < r8); - base_type::ren().blend_vline(x+dy, y-dx, y+dx, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void semiellipse_right(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int r8 = r * 4 / 5; - int dy = -r; - int dx = 0; - ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); - do - { - dx += ei.dx(); - dy += ei.dy(); - - base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); - - if(ei.dy() && dx) - { - base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); - } - ++ei; - } - while(dy < r8); - base_type::ren().blend_vline(x-dy, y-dx, y+dx, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void semiellipse_up(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int r8 = r * 4 / 5; - int dy = -r; - int dx = 0; - ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); - do - { - dx += ei.dx(); - dy += ei.dy(); - - base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); - - if(ei.dy() && dx) - { - base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); - } - ++ei; - } - while(dy < r8); - base_type::ren().blend_hline(x-dx, y-dy-1, x+dx, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void semiellipse_down(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int r8 = r * 4 / 5; - int dy = -r; - int dx = 0; - ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); - do - { - dx += ei.dx(); - dy += ei.dy(); - - base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); - - if(ei.dy() && dx) - { - base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); - } - ++ei; - } - while(dy < r8); - base_type::ren().blend_hline(x-dx, y+dy+1, x+dx, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void triangle_left(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int dy = -r; - int dx = 0; - int flip = 0; - int r6 = r * 3 / 5; - do - { - base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); - - if(dx) - { - base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); - } - ++dy; - dx += flip; - flip ^= 1; - } - while(dy < r6); - base_type::ren().blend_vline(x+dy, y-dx, y+dx, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void triangle_right(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int dy = -r; - int dx = 0; - int flip = 0; - int r6 = r * 3 / 5; - do - { - base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); - - if(dx) - { - base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); - } - ++dy; - dx += flip; - flip ^= 1; - } - while(dy < r6); - base_type::ren().blend_vline(x-dy, y-dx, y+dx, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void triangle_up(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int dy = -r; - int dx = 0; - int flip = 0; - int r6 = r * 3 / 5; - do - { - base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); - - if(dx) - { - base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); - } - ++dy; - dx += flip; - flip ^= 1; - } - while(dy < r6); - base_type::ren().blend_hline(x-dx, y-dy, x+dx, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void triangle_down(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int dy = -r; - int dx = 0; - int flip = 0; - int r6 = r * 3 / 5; - do - { - base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); - - if(dx) - { - base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); - } - ++dy; - dx += flip; - flip ^= 1; - } - while(dy < r6); - base_type::ren().blend_hline(x-dx, y+dy, x+dx, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void four_rays(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int dy = -r; - int dx = 0; - int flip = 0; - int r3 = -(r / 3); - do - { - base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); - - if(dx) - { - base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); - base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); - base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); - base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); - } - ++dy; - dx += flip; - flip ^= 1; - } - while(dy <= r3); - base_type::solid_rectangle(x+r3+1, y+r3+1, x-r3-1, y-r3-1); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void cross(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - base_type::ren().blend_vline(x, y-r, y+r, base_type::line_color(), cover_full); - base_type::ren().blend_hline(x-r, y, x+r, base_type::line_color(), cover_full); - } - else - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - } - - - //-------------------------------------------------------------------- - void xing(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) - { - int dy = -r * 7 / 10; - do - { - base_type::ren().blend_pixel(x + dy, y + dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dy, y + dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x + dy, y - dy, base_type::line_color(), cover_full); - base_type::ren().blend_pixel(x - dy, y - dy, base_type::line_color(), cover_full); - ++dy; - } - while(dy < 0); - } - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - - - //-------------------------------------------------------------------- - void dash(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) base_type::ren().blend_hline(x-r, y, x+r, base_type::line_color(), cover_full); - else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - - - //-------------------------------------------------------------------- - void dot(int x, int y, int r) - { - if(visible(x, y, r)) - { - if(r) base_type::solid_ellipse(x, y, r, r); - else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - } - - //-------------------------------------------------------------------- - void pixel(int x, int y, int) - { - base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); - } - - //-------------------------------------------------------------------- - void marker(int x, int y, int r, marker_e type) - { - switch(type) - { - case marker_square: square(x, y, r); break; - case marker_diamond: diamond(x, y, r); break; - case marker_circle: circle(x, y, r); break; - case marker_crossed_circle: crossed_circle(x, y, r); break; - case marker_semiellipse_left: semiellipse_left(x, y, r); break; - case marker_semiellipse_right: semiellipse_right(x, y, r); break; - case marker_semiellipse_up: semiellipse_up(x, y, r); break; - case marker_semiellipse_down: semiellipse_down(x, y, r); break; - case marker_triangle_left: triangle_left(x, y, r); break; - case marker_triangle_right: triangle_right(x, y, r); break; - case marker_triangle_up: triangle_up(x, y, r); break; - case marker_triangle_down: triangle_down(x, y, r); break; - case marker_four_rays: four_rays(x, y, r); break; - case marker_cross: cross(x, y, r); break; - case marker_x: xing(x, y, r); break; - case marker_dash: dash(x, y, r); break; - case marker_dot: dot(x, y, r); break; - case marker_pixel: pixel(x, y, r); break; - case end_of_markers: break; - } - } - - - //-------------------------------------------------------------------- - template - void markers(int n, const T* x, const T* y, T r, marker_e type) - { - if(n <= 0) return; - if(r == 0) - { - do - { - base_type::ren().blend_pixel(int(*x), int(*y), base_type::fill_color(), cover_full); - ++x; - ++y; - } - while(--n); - return; - } - - switch(type) - { - case marker_square: do { square (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_diamond: do { diamond (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_circle: do { circle (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_crossed_circle: do { crossed_circle (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_semiellipse_left: do { semiellipse_left (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_semiellipse_right: do { semiellipse_right(int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_semiellipse_up: do { semiellipse_up (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_semiellipse_down: do { semiellipse_down (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_triangle_left: do { triangle_left (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_triangle_right: do { triangle_right (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_triangle_up: do { triangle_up (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_triangle_down: do { triangle_down (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_four_rays: do { four_rays (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_cross: do { cross (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_x: do { xing (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_dash: do { dash (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_dot: do { dot (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case marker_pixel: do { pixel (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; - case end_of_markers: break; - } - } - - //-------------------------------------------------------------------- - template - void markers(int n, const T* x, const T* y, const T* r, marker_e type) - { - if(n <= 0) return; - switch(type) - { - case marker_square: do { square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_diamond: do { diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_circle: do { circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_crossed_circle: do { crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_semiellipse_left: do { semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_semiellipse_right: do { semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_semiellipse_up: do { semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_semiellipse_down: do { semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_triangle_left: do { triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_triangle_right: do { triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_triangle_up: do { triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_triangle_down: do { triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_four_rays: do { four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_cross: do { cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_x: do { xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_dash: do { dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_dot: do { dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case marker_pixel: do { pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; - case end_of_markers: break; - } - } - - //-------------------------------------------------------------------- - template - void markers(int n, const T* x, const T* y, const T* r, const color_type* fc, marker_e type) - { - if(n <= 0) return; - switch(type) - { - case marker_square: do { base_type::fill_color(*fc); square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_diamond: do { base_type::fill_color(*fc); diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_circle: do { base_type::fill_color(*fc); circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_crossed_circle: do { base_type::fill_color(*fc); crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_semiellipse_left: do { base_type::fill_color(*fc); semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_semiellipse_right: do { base_type::fill_color(*fc); semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_semiellipse_up: do { base_type::fill_color(*fc); semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_semiellipse_down: do { base_type::fill_color(*fc); semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_triangle_left: do { base_type::fill_color(*fc); triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_triangle_right: do { base_type::fill_color(*fc); triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_triangle_up: do { base_type::fill_color(*fc); triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_triangle_down: do { base_type::fill_color(*fc); triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_four_rays: do { base_type::fill_color(*fc); four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_cross: do { base_type::fill_color(*fc); cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_x: do { base_type::fill_color(*fc); xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_dash: do { base_type::fill_color(*fc); dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_dot: do { base_type::fill_color(*fc); dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case marker_pixel: do { base_type::fill_color(*fc); pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; - case end_of_markers: break; - } - } - - //-------------------------------------------------------------------- - template - void markers(int n, const T* x, const T* y, const T* r, const color_type* fc, const color_type* lc, marker_e type) - { - if(n <= 0) return; - switch(type) - { - case marker_square: do { base_type::fill_color(*fc); base_type::line_color(*lc); square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_diamond: do { base_type::fill_color(*fc); base_type::line_color(*lc); diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_circle: do { base_type::fill_color(*fc); base_type::line_color(*lc); circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_crossed_circle: do { base_type::fill_color(*fc); base_type::line_color(*lc); crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_semiellipse_left: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_semiellipse_right: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_semiellipse_up: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_semiellipse_down: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_triangle_left: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_triangle_right: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_triangle_up: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_triangle_down: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_four_rays: do { base_type::fill_color(*fc); base_type::line_color(*lc); four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_cross: do { base_type::fill_color(*fc); base_type::line_color(*lc); cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_x: do { base_type::fill_color(*fc); base_type::line_color(*lc); xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_dash: do { base_type::fill_color(*fc); base_type::line_color(*lc); dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_dot: do { base_type::fill_color(*fc); base_type::line_color(*lc); dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case marker_pixel: do { base_type::fill_color(*fc); base_type::line_color(*lc); pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; - case end_of_markers: break; - } - } - }; - -} - -#endif diff --git a/xs/src/agg/agg_renderer_mclip.h b/xs/src/agg/agg_renderer_mclip.h deleted file mode 100644 index 96a7d4e094..0000000000 --- a/xs/src/agg/agg_renderer_mclip.h +++ /dev/null @@ -1,349 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// class renderer_mclip -// -//---------------------------------------------------------------------------- - -#ifndef AGG_RENDERER_MCLIP_INCLUDED -#define AGG_RENDERER_MCLIP_INCLUDED - -#include "agg_basics.h" -#include "agg_array.h" -#include "agg_renderer_base.h" - -namespace agg -{ - - //----------------------------------------------------------renderer_mclip - template class renderer_mclip - { - public: - typedef PixelFormat pixfmt_type; - typedef typename pixfmt_type::color_type color_type; - typedef typename pixfmt_type::row_data row_data; - typedef renderer_base base_ren_type; - - //-------------------------------------------------------------------- - explicit renderer_mclip(pixfmt_type& pixf) : - m_ren(pixf), - m_curr_cb(0), - m_bounds(m_ren.xmin(), m_ren.ymin(), m_ren.xmax(), m_ren.ymax()) - {} - void attach(pixfmt_type& pixf) - { - m_ren.attach(pixf); - reset_clipping(true); - } - - //-------------------------------------------------------------------- - const pixfmt_type& ren() const { return m_ren.ren(); } - pixfmt_type& ren() { return m_ren.ren(); } - - //-------------------------------------------------------------------- - unsigned width() const { return m_ren.width(); } - unsigned height() const { return m_ren.height(); } - - //-------------------------------------------------------------------- - const rect_i& clip_box() const { return m_ren.clip_box(); } - int xmin() const { return m_ren.xmin(); } - int ymin() const { return m_ren.ymin(); } - int xmax() const { return m_ren.xmax(); } - int ymax() const { return m_ren.ymax(); } - - //-------------------------------------------------------------------- - const rect_i& bounding_clip_box() const { return m_bounds; } - int bounding_xmin() const { return m_bounds.x1; } - int bounding_ymin() const { return m_bounds.y1; } - int bounding_xmax() const { return m_bounds.x2; } - int bounding_ymax() const { return m_bounds.y2; } - - //-------------------------------------------------------------------- - void first_clip_box() - { - m_curr_cb = 0; - if(m_clip.size()) - { - const rect_i& cb = m_clip[0]; - m_ren.clip_box_naked(cb.x1, cb.y1, cb.x2, cb.y2); - } - } - - //-------------------------------------------------------------------- - bool next_clip_box() - { - if(++m_curr_cb < m_clip.size()) - { - const rect_i& cb = m_clip[m_curr_cb]; - m_ren.clip_box_naked(cb.x1, cb.y1, cb.x2, cb.y2); - return true; - } - return false; - } - - //-------------------------------------------------------------------- - void reset_clipping(bool visibility) - { - m_ren.reset_clipping(visibility); - m_clip.remove_all(); - m_curr_cb = 0; - m_bounds = m_ren.clip_box(); - } - - //-------------------------------------------------------------------- - void add_clip_box(int x1, int y1, int x2, int y2) - { - rect_i cb(x1, y1, x2, y2); - cb.normalize(); - if(cb.clip(rect_i(0, 0, width() - 1, height() - 1))) - { - m_clip.add(cb); - if(cb.x1 < m_bounds.x1) m_bounds.x1 = cb.x1; - if(cb.y1 < m_bounds.y1) m_bounds.y1 = cb.y1; - if(cb.x2 > m_bounds.x2) m_bounds.x2 = cb.x2; - if(cb.y2 > m_bounds.y2) m_bounds.y2 = cb.y2; - } - } - - //-------------------------------------------------------------------- - void clear(const color_type& c) - { - m_ren.clear(c); - } - - //-------------------------------------------------------------------- - void copy_pixel(int x, int y, const color_type& c) - { - first_clip_box(); - do - { - if(m_ren.inbox(x, y)) - { - m_ren.ren().copy_pixel(x, y, c); - break; - } - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void blend_pixel(int x, int y, const color_type& c, cover_type cover) - { - first_clip_box(); - do - { - if(m_ren.inbox(x, y)) - { - m_ren.ren().blend_pixel(x, y, c, cover); - break; - } - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - color_type pixel(int x, int y) const - { - first_clip_box(); - do - { - if(m_ren.inbox(x, y)) - { - return m_ren.ren().pixel(x, y); - } - } - while(next_clip_box()); - return color_type::no_color(); - } - - //-------------------------------------------------------------------- - void copy_hline(int x1, int y, int x2, const color_type& c) - { - first_clip_box(); - do - { - m_ren.copy_hline(x1, y, x2, c); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void copy_vline(int x, int y1, int y2, const color_type& c) - { - first_clip_box(); - do - { - m_ren.copy_vline(x, y1, y2, c); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void blend_hline(int x1, int y, int x2, - const color_type& c, cover_type cover) - { - first_clip_box(); - do - { - m_ren.blend_hline(x1, y, x2, c, cover); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void blend_vline(int x, int y1, int y2, - const color_type& c, cover_type cover) - { - first_clip_box(); - do - { - m_ren.blend_vline(x, y1, y2, c, cover); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void copy_bar(int x1, int y1, int x2, int y2, const color_type& c) - { - first_clip_box(); - do - { - m_ren.copy_bar(x1, y1, x2, y2, c); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void blend_bar(int x1, int y1, int x2, int y2, - const color_type& c, cover_type cover) - { - first_clip_box(); - do - { - m_ren.blend_bar(x1, y1, x2, y2, c, cover); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void blend_solid_hspan(int x, int y, int len, - const color_type& c, const cover_type* covers) - { - first_clip_box(); - do - { - m_ren.blend_solid_hspan(x, y, len, c, covers); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void blend_solid_vspan(int x, int y, int len, - const color_type& c, const cover_type* covers) - { - first_clip_box(); - do - { - m_ren.blend_solid_vspan(x, y, len, c, covers); - } - while(next_clip_box()); - } - - - //-------------------------------------------------------------------- - void copy_color_hspan(int x, int y, int len, const color_type* colors) - { - first_clip_box(); - do - { - m_ren.copy_color_hspan(x, y, len, colors); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void blend_color_hspan(int x, int y, int len, - const color_type* colors, - const cover_type* covers, - cover_type cover = cover_full) - { - first_clip_box(); - do - { - m_ren.blend_color_hspan(x, y, len, colors, covers, cover); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void blend_color_vspan(int x, int y, int len, - const color_type* colors, - const cover_type* covers, - cover_type cover = cover_full) - { - first_clip_box(); - do - { - m_ren.blend_color_vspan(x, y, len, colors, covers, cover); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - void copy_from(const rendering_buffer& from, - const rect_i* rc=0, - int x_to=0, - int y_to=0) - { - first_clip_box(); - do - { - m_ren.copy_from(from, rc, x_to, y_to); - } - while(next_clip_box()); - } - - //-------------------------------------------------------------------- - template - void blend_from(const SrcPixelFormatRenderer& src, - const rect_i* rect_src_ptr = 0, - int dx = 0, - int dy = 0, - cover_type cover = cover_full) - { - first_clip_box(); - do - { - m_ren.blend_from(src, rect_src_ptr, dx, dy, cover); - } - while(next_clip_box()); - } - - - private: - renderer_mclip(const renderer_mclip&); - const renderer_mclip& - operator = (const renderer_mclip&); - - base_ren_type m_ren; - pod_bvector m_clip; - unsigned m_curr_cb; - rect_i m_bounds; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_renderer_outline_aa.h b/xs/src/agg/agg_renderer_outline_aa.h deleted file mode 100644 index 394c58ca69..0000000000 --- a/xs/src/agg/agg_renderer_outline_aa.h +++ /dev/null @@ -1,1836 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_RENDERER_OUTLINE_AA_INCLUDED -#define AGG_RENDERER_OUTLINE_AA_INCLUDED - -#include "agg_array.h" -#include "agg_math.h" -#include "agg_line_aa_basics.h" -#include "agg_dda_line.h" -#include "agg_ellipse_bresenham.h" -#include "agg_renderer_base.h" -#include "agg_gamma_functions.h" -#include "agg_clip_liang_barsky.h" - -namespace agg -{ - - //===================================================distance_interpolator0 - class distance_interpolator0 - { - public: - //--------------------------------------------------------------------- - distance_interpolator0() {} - distance_interpolator0(int x1, int y1, int x2, int y2, int x, int y) : - m_dx(line_mr(x2) - line_mr(x1)), - m_dy(line_mr(y2) - line_mr(y1)), - m_dist((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy - - (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx) - { - m_dx <<= line_mr_subpixel_shift; - m_dy <<= line_mr_subpixel_shift; - } - - //--------------------------------------------------------------------- - void inc_x() { m_dist += m_dy; } - int dist() const { return m_dist; } - - private: - //--------------------------------------------------------------------- - int m_dx; - int m_dy; - int m_dist; - }; - - //==================================================distance_interpolator00 - class distance_interpolator00 - { - public: - //--------------------------------------------------------------------- - distance_interpolator00() {} - distance_interpolator00(int xc, int yc, - int x1, int y1, int x2, int y2, - int x, int y) : - m_dx1(line_mr(x1) - line_mr(xc)), - m_dy1(line_mr(y1) - line_mr(yc)), - m_dx2(line_mr(x2) - line_mr(xc)), - m_dy2(line_mr(y2) - line_mr(yc)), - m_dist1((line_mr(x + line_subpixel_scale/2) - line_mr(x1)) * m_dy1 - - (line_mr(y + line_subpixel_scale/2) - line_mr(y1)) * m_dx1), - m_dist2((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy2 - - (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx2) - { - m_dx1 <<= line_mr_subpixel_shift; - m_dy1 <<= line_mr_subpixel_shift; - m_dx2 <<= line_mr_subpixel_shift; - m_dy2 <<= line_mr_subpixel_shift; - } - - //--------------------------------------------------------------------- - void inc_x() { m_dist1 += m_dy1; m_dist2 += m_dy2; } - int dist1() const { return m_dist1; } - int dist2() const { return m_dist2; } - - private: - //--------------------------------------------------------------------- - int m_dx1; - int m_dy1; - int m_dx2; - int m_dy2; - int m_dist1; - int m_dist2; - }; - - //===================================================distance_interpolator1 - class distance_interpolator1 - { - public: - //--------------------------------------------------------------------- - distance_interpolator1() {} - distance_interpolator1(int x1, int y1, int x2, int y2, int x, int y) : - m_dx(x2 - x1), - m_dy(y2 - y1), - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - - double(y + line_subpixel_scale/2 - y2) * double(m_dx))) - { - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - } - - //--------------------------------------------------------------------- - void inc_x() { m_dist += m_dy; } - void dec_x() { m_dist -= m_dy; } - void inc_y() { m_dist -= m_dx; } - void dec_y() { m_dist += m_dx; } - - //--------------------------------------------------------------------- - void inc_x(int dy) - { - m_dist += m_dy; - if(dy > 0) m_dist -= m_dx; - if(dy < 0) m_dist += m_dx; - } - - //--------------------------------------------------------------------- - void dec_x(int dy) - { - m_dist -= m_dy; - if(dy > 0) m_dist -= m_dx; - if(dy < 0) m_dist += m_dx; - } - - //--------------------------------------------------------------------- - void inc_y(int dx) - { - m_dist -= m_dx; - if(dx > 0) m_dist += m_dy; - if(dx < 0) m_dist -= m_dy; - } - - void dec_y(int dx) - //--------------------------------------------------------------------- - { - m_dist += m_dx; - if(dx > 0) m_dist += m_dy; - if(dx < 0) m_dist -= m_dy; - } - - //--------------------------------------------------------------------- - int dist() const { return m_dist; } - int dx() const { return m_dx; } - int dy() const { return m_dy; } - - private: - //--------------------------------------------------------------------- - int m_dx; - int m_dy; - int m_dist; - }; - - - - - - //===================================================distance_interpolator2 - class distance_interpolator2 - { - public: - //--------------------------------------------------------------------- - distance_interpolator2() {} - distance_interpolator2(int x1, int y1, int x2, int y2, - int sx, int sy, int x, int y) : - m_dx(x2 - x1), - m_dy(y2 - y1), - m_dx_start(line_mr(sx) - line_mr(x1)), - m_dy_start(line_mr(sy) - line_mr(y1)), - - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), - - m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start) - { - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - m_dx_start <<= line_mr_subpixel_shift; - m_dy_start <<= line_mr_subpixel_shift; - } - - distance_interpolator2(int x1, int y1, int x2, int y2, - int ex, int ey, int x, int y, int) : - m_dx(x2 - x1), - m_dy(y2 - y1), - m_dx_start(line_mr(ex) - line_mr(x2)), - m_dy_start(line_mr(ey) - line_mr(y2)), - - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), - - m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_start - - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_start) - { - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - m_dx_start <<= line_mr_subpixel_shift; - m_dy_start <<= line_mr_subpixel_shift; - } - - - //--------------------------------------------------------------------- - void inc_x() { m_dist += m_dy; m_dist_start += m_dy_start; } - void dec_x() { m_dist -= m_dy; m_dist_start -= m_dy_start; } - void inc_y() { m_dist -= m_dx; m_dist_start -= m_dx_start; } - void dec_y() { m_dist += m_dx; m_dist_start += m_dx_start; } - - //--------------------------------------------------------------------- - void inc_x(int dy) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - if(dy > 0) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - } - if(dy < 0) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - } - } - - //--------------------------------------------------------------------- - void dec_x(int dy) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - if(dy > 0) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - } - if(dy < 0) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - } - } - - //--------------------------------------------------------------------- - void inc_y(int dx) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - if(dx > 0) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - } - if(dx < 0) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - } - } - - //--------------------------------------------------------------------- - void dec_y(int dx) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - if(dx > 0) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - } - if(dx < 0) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - } - } - - //--------------------------------------------------------------------- - int dist() const { return m_dist; } - int dist_start() const { return m_dist_start; } - int dist_end() const { return m_dist_start; } - - //--------------------------------------------------------------------- - int dx() const { return m_dx; } - int dy() const { return m_dy; } - int dx_start() const { return m_dx_start; } - int dy_start() const { return m_dy_start; } - int dx_end() const { return m_dx_start; } - int dy_end() const { return m_dy_start; } - - private: - //--------------------------------------------------------------------- - int m_dx; - int m_dy; - int m_dx_start; - int m_dy_start; - - int m_dist; - int m_dist_start; - }; - - - - - - //===================================================distance_interpolator3 - class distance_interpolator3 - { - public: - //--------------------------------------------------------------------- - distance_interpolator3() {} - distance_interpolator3(int x1, int y1, int x2, int y2, - int sx, int sy, int ex, int ey, - int x, int y) : - m_dx(x2 - x1), - m_dy(y2 - y1), - m_dx_start(line_mr(sx) - line_mr(x1)), - m_dy_start(line_mr(sy) - line_mr(y1)), - m_dx_end(line_mr(ex) - line_mr(x2)), - m_dy_end(line_mr(ey) - line_mr(y2)), - - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), - - m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start), - - m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end) - { - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - m_dx_start <<= line_mr_subpixel_shift; - m_dy_start <<= line_mr_subpixel_shift; - m_dx_end <<= line_mr_subpixel_shift; - m_dy_end <<= line_mr_subpixel_shift; - } - - //--------------------------------------------------------------------- - void inc_x() { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_end += m_dy_end; } - void dec_x() { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; } - void inc_y() { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; } - void dec_y() { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_end += m_dx_end; } - - //--------------------------------------------------------------------- - void inc_x(int dy) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_end += m_dy_end; - if(dy > 0) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_end -= m_dx_end; - } - if(dy < 0) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_end += m_dx_end; - } - } - - //--------------------------------------------------------------------- - void dec_x(int dy) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_end -= m_dy_end; - if(dy > 0) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_end -= m_dx_end; - } - if(dy < 0) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_end += m_dx_end; - } - } - - //--------------------------------------------------------------------- - void inc_y(int dx) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_end -= m_dx_end; - if(dx > 0) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_end += m_dy_end; - } - if(dx < 0) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_end -= m_dy_end; - } - } - - //--------------------------------------------------------------------- - void dec_y(int dx) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_end += m_dx_end; - if(dx > 0) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_end += m_dy_end; - } - if(dx < 0) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_end -= m_dy_end; - } - } - - //--------------------------------------------------------------------- - int dist() const { return m_dist; } - int dist_start() const { return m_dist_start; } - int dist_end() const { return m_dist_end; } - - //--------------------------------------------------------------------- - int dx() const { return m_dx; } - int dy() const { return m_dy; } - int dx_start() const { return m_dx_start; } - int dy_start() const { return m_dy_start; } - int dx_end() const { return m_dx_end; } - int dy_end() const { return m_dy_end; } - - private: - //--------------------------------------------------------------------- - int m_dx; - int m_dy; - int m_dx_start; - int m_dy_start; - int m_dx_end; - int m_dy_end; - - int m_dist; - int m_dist_start; - int m_dist_end; - }; - - - - - - //================================================line_interpolator_aa_base - template class line_interpolator_aa_base - { - public: - typedef Renderer renderer_type; - typedef typename Renderer::color_type color_type; - - //--------------------------------------------------------------------- - enum max_half_width_e - { - max_half_width = 64 - }; - - //--------------------------------------------------------------------- - line_interpolator_aa_base(renderer_type& ren, line_parameters& lp) : - m_lp(&lp), - m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : - line_dbl_hr(lp.y2 - lp.y1), - lp.vertical ? abs(lp.y2 - lp.y1) : - abs(lp.x2 - lp.x1) + 1), - m_ren(ren), - m_len((lp.vertical == (lp.inc > 0)) ? -lp.len : lp.len), - m_x(lp.x1 >> line_subpixel_shift), - m_y(lp.y1 >> line_subpixel_shift), - m_old_x(m_x), - m_old_y(m_y), - m_count((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) : - abs((lp.x2 >> line_subpixel_shift) - m_x))), - m_width(ren.subpixel_width()), - //m_max_extent(m_width >> (line_subpixel_shift - 2)), - m_max_extent((m_width + line_subpixel_mask) >> line_subpixel_shift), - m_step(0) - { - agg::dda2_line_interpolator li(0, lp.vertical ? - (lp.dy << agg::line_subpixel_shift) : - (lp.dx << agg::line_subpixel_shift), - lp.len); - - unsigned i; - int stop = m_width + line_subpixel_scale * 2; - for(i = 0; i < max_half_width; ++i) - { - m_dist[i] = li.y(); - if(m_dist[i] >= stop) break; - ++li; - } - m_dist[i++] = 0x7FFF0000; - } - - //--------------------------------------------------------------------- - template int step_hor_base(DI& di) - { - ++m_li; - m_x += m_lp->inc; - m_y = (m_lp->y1 + m_li.y()) >> line_subpixel_shift; - - if(m_lp->inc > 0) di.inc_x(m_y - m_old_y); - else di.dec_x(m_y - m_old_y); - - m_old_y = m_y; - - return di.dist() / m_len; - } - - //--------------------------------------------------------------------- - template int step_ver_base(DI& di) - { - ++m_li; - m_y += m_lp->inc; - m_x = (m_lp->x1 + m_li.y()) >> line_subpixel_shift; - - if(m_lp->inc > 0) di.inc_y(m_x - m_old_x); - else di.dec_y(m_x - m_old_x); - - m_old_x = m_x; - - return di.dist() / m_len; - } - - //--------------------------------------------------------------------- - bool vertical() const { return m_lp->vertical; } - int width() const { return m_width; } - int count() const { return m_count; } - - private: - line_interpolator_aa_base(const line_interpolator_aa_base&); - const line_interpolator_aa_base& - operator = (const line_interpolator_aa_base&); - - protected: - line_parameters* m_lp; - dda2_line_interpolator m_li; - renderer_type& m_ren; - int m_len; - int m_x; - int m_y; - int m_old_x; - int m_old_y; - int m_count; - int m_width; - int m_max_extent; - int m_step; - int m_dist[max_half_width + 1]; - cover_type m_covers[max_half_width * 2 + 4]; - }; - - - - - - - - //====================================================line_interpolator_aa0 - template class line_interpolator_aa0 : - public line_interpolator_aa_base - { - public: - typedef Renderer renderer_type; - typedef typename Renderer::color_type color_type; - typedef line_interpolator_aa_base base_type; - - //--------------------------------------------------------------------- - line_interpolator_aa0(renderer_type& ren, line_parameters& lp) : - line_interpolator_aa_base(ren, lp), - m_di(lp.x1, lp.y1, lp.x2, lp.y2, - lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) - { - base_type::m_li.adjust_forward(); - } - - //--------------------------------------------------------------------- - bool step_hor() - { - int dist; - int dy; - int s1 = base_type::step_hor_base(m_di); - cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; - cover_type* p1 = p0; - - *p1++ = (cover_type)base_type::m_ren.cover(s1); - - dy = 1; - while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) - { - *p1++ = (cover_type)base_type::m_ren.cover(dist); - ++dy; - } - - dy = 1; - while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) - { - *--p0 = (cover_type)base_type::m_ren.cover(dist); - ++dy; - } - base_type::m_ren.blend_solid_vspan(base_type::m_x, - base_type::m_y - dy + 1, - unsigned(p1 - p0), - p0); - return ++base_type::m_step < base_type::m_count; - } - - //--------------------------------------------------------------------- - bool step_ver() - { - int dist; - int dx; - int s1 = base_type::step_ver_base(m_di); - cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; - cover_type* p1 = p0; - - *p1++ = (cover_type)base_type::m_ren.cover(s1); - - dx = 1; - while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) - { - *p1++ = (cover_type)base_type::m_ren.cover(dist); - ++dx; - } - - dx = 1; - while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) - { - *--p0 = (cover_type)base_type::m_ren.cover(dist); - ++dx; - } - base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, - base_type::m_y, - unsigned(p1 - p0), - p0); - return ++base_type::m_step < base_type::m_count; - } - - private: - line_interpolator_aa0(const line_interpolator_aa0&); - const line_interpolator_aa0& - operator = (const line_interpolator_aa0&); - - //--------------------------------------------------------------------- - distance_interpolator1 m_di; - }; - - - - - - - //====================================================line_interpolator_aa1 - template class line_interpolator_aa1 : - public line_interpolator_aa_base - { - public: - typedef Renderer renderer_type; - typedef typename Renderer::color_type color_type; - typedef line_interpolator_aa_base base_type; - - //--------------------------------------------------------------------- - line_interpolator_aa1(renderer_type& ren, line_parameters& lp, - int sx, int sy) : - line_interpolator_aa_base(ren, lp), - m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, - lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) - { - int dist1_start; - int dist2_start; - - int npix = 1; - - if(lp.vertical) - { - do - { - --base_type::m_li; - base_type::m_y -= lp.inc; - base_type::m_x = (base_type::m_lp->x1 + base_type::m_li.y()) >> line_subpixel_shift; - - if(lp.inc > 0) m_di.dec_y(base_type::m_x - base_type::m_old_x); - else m_di.inc_y(base_type::m_x - base_type::m_old_x); - - base_type::m_old_x = base_type::m_x; - - dist1_start = dist2_start = m_di.dist_start(); - - int dx = 0; - if(dist1_start < 0) ++npix; - do - { - dist1_start += m_di.dy_start(); - dist2_start -= m_di.dy_start(); - if(dist1_start < 0) ++npix; - if(dist2_start < 0) ++npix; - ++dx; - } - while(base_type::m_dist[dx] <= base_type::m_width); - --base_type::m_step; - if(npix == 0) break; - npix = 0; - } - while(base_type::m_step >= -base_type::m_max_extent); - } - else - { - do - { - --base_type::m_li; - base_type::m_x -= lp.inc; - base_type::m_y = (base_type::m_lp->y1 + base_type::m_li.y()) >> line_subpixel_shift; - - if(lp.inc > 0) m_di.dec_x(base_type::m_y - base_type::m_old_y); - else m_di.inc_x(base_type::m_y - base_type::m_old_y); - - base_type::m_old_y = base_type::m_y; - - dist1_start = dist2_start = m_di.dist_start(); - - int dy = 0; - if(dist1_start < 0) ++npix; - do - { - dist1_start -= m_di.dx_start(); - dist2_start += m_di.dx_start(); - if(dist1_start < 0) ++npix; - if(dist2_start < 0) ++npix; - ++dy; - } - while(base_type::m_dist[dy] <= base_type::m_width); - --base_type::m_step; - if(npix == 0) break; - npix = 0; - } - while(base_type::m_step >= -base_type::m_max_extent); - } - base_type::m_li.adjust_forward(); - } - - //--------------------------------------------------------------------- - bool step_hor() - { - int dist_start; - int dist; - int dy; - int s1 = base_type::step_hor_base(m_di); - - dist_start = m_di.dist_start(); - cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; - cover_type* p1 = p0; - - *p1 = 0; - if(dist_start <= 0) - { - *p1 = (cover_type)base_type::m_ren.cover(s1); - } - ++p1; - - dy = 1; - while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) - { - dist_start -= m_di.dx_start(); - *p1 = 0; - if(dist_start <= 0) - { - *p1 = (cover_type)base_type::m_ren.cover(dist); - } - ++p1; - ++dy; - } - - dy = 1; - dist_start = m_di.dist_start(); - while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) - { - dist_start += m_di.dx_start(); - *--p0 = 0; - if(dist_start <= 0) - { - *p0 = (cover_type)base_type::m_ren.cover(dist); - } - ++dy; - } - - base_type::m_ren.blend_solid_vspan(base_type::m_x, - base_type::m_y - dy + 1, - unsigned(p1 - p0), - p0); - return ++base_type::m_step < base_type::m_count; - } - - //--------------------------------------------------------------------- - bool step_ver() - { - int dist_start; - int dist; - int dx; - int s1 = base_type::step_ver_base(m_di); - cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; - cover_type* p1 = p0; - - dist_start = m_di.dist_start(); - - *p1 = 0; - if(dist_start <= 0) - { - *p1 = (cover_type)base_type::m_ren.cover(s1); - } - ++p1; - - dx = 1; - while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) - { - dist_start += m_di.dy_start(); - *p1 = 0; - if(dist_start <= 0) - { - *p1 = (cover_type)base_type::m_ren.cover(dist); - } - ++p1; - ++dx; - } - - dx = 1; - dist_start = m_di.dist_start(); - while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) - { - dist_start -= m_di.dy_start(); - *--p0 = 0; - if(dist_start <= 0) - { - *p0 = (cover_type)base_type::m_ren.cover(dist); - } - ++dx; - } - base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, - base_type::m_y, - unsigned(p1 - p0), - p0); - return ++base_type::m_step < base_type::m_count; - } - - private: - line_interpolator_aa1(const line_interpolator_aa1&); - const line_interpolator_aa1& - operator = (const line_interpolator_aa1&); - - //--------------------------------------------------------------------- - distance_interpolator2 m_di; - }; - - - - - - - - - - - - - //====================================================line_interpolator_aa2 - template class line_interpolator_aa2 : - public line_interpolator_aa_base - { - public: - typedef Renderer renderer_type; - typedef typename Renderer::color_type color_type; - typedef line_interpolator_aa_base base_type; - - //--------------------------------------------------------------------- - line_interpolator_aa2(renderer_type& ren, line_parameters& lp, - int ex, int ey) : - line_interpolator_aa_base(ren, lp), - m_di(lp.x1, lp.y1, lp.x2, lp.y2, ex, ey, - lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask, - 0) - { - base_type::m_li.adjust_forward(); - base_type::m_step -= base_type::m_max_extent; - } - - //--------------------------------------------------------------------- - bool step_hor() - { - int dist_end; - int dist; - int dy; - int s1 = base_type::step_hor_base(m_di); - cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; - cover_type* p1 = p0; - - dist_end = m_di.dist_end(); - - int npix = 0; - *p1 = 0; - if(dist_end > 0) - { - *p1 = (cover_type)base_type::m_ren.cover(s1); - ++npix; - } - ++p1; - - dy = 1; - while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) - { - dist_end -= m_di.dx_end(); - *p1 = 0; - if(dist_end > 0) - { - *p1 = (cover_type)base_type::m_ren.cover(dist); - ++npix; - } - ++p1; - ++dy; - } - - dy = 1; - dist_end = m_di.dist_end(); - while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) - { - dist_end += m_di.dx_end(); - *--p0 = 0; - if(dist_end > 0) - { - *p0 = (cover_type)base_type::m_ren.cover(dist); - ++npix; - } - ++dy; - } - base_type::m_ren.blend_solid_vspan(base_type::m_x, - base_type::m_y - dy + 1, - unsigned(p1 - p0), - p0); - return npix && ++base_type::m_step < base_type::m_count; - } - - //--------------------------------------------------------------------- - bool step_ver() - { - int dist_end; - int dist; - int dx; - int s1 = base_type::step_ver_base(m_di); - cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; - cover_type* p1 = p0; - - dist_end = m_di.dist_end(); - - int npix = 0; - *p1 = 0; - if(dist_end > 0) - { - *p1 = (cover_type)base_type::m_ren.cover(s1); - ++npix; - } - ++p1; - - dx = 1; - while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) - { - dist_end += m_di.dy_end(); - *p1 = 0; - if(dist_end > 0) - { - *p1 = (cover_type)base_type::m_ren.cover(dist); - ++npix; - } - ++p1; - ++dx; - } - - dx = 1; - dist_end = m_di.dist_end(); - while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) - { - dist_end -= m_di.dy_end(); - *--p0 = 0; - if(dist_end > 0) - { - *p0 = (cover_type)base_type::m_ren.cover(dist); - ++npix; - } - ++dx; - } - base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, - base_type::m_y, - unsigned(p1 - p0), - p0); - return npix && ++base_type::m_step < base_type::m_count; - } - - private: - line_interpolator_aa2(const line_interpolator_aa2&); - const line_interpolator_aa2& - operator = (const line_interpolator_aa2&); - - //--------------------------------------------------------------------- - distance_interpolator2 m_di; - }; - - - - - - - - - - - //====================================================line_interpolator_aa3 - template class line_interpolator_aa3 : - public line_interpolator_aa_base - { - public: - typedef Renderer renderer_type; - typedef typename Renderer::color_type color_type; - typedef line_interpolator_aa_base base_type; - - //--------------------------------------------------------------------- - line_interpolator_aa3(renderer_type& ren, line_parameters& lp, - int sx, int sy, int ex, int ey) : - line_interpolator_aa_base(ren, lp), - m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, - lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) - { - int dist1_start; - int dist2_start; - int npix = 1; - if(lp.vertical) - { - do - { - --base_type::m_li; - base_type::m_y -= lp.inc; - base_type::m_x = (base_type::m_lp->x1 + base_type::m_li.y()) >> line_subpixel_shift; - - if(lp.inc > 0) m_di.dec_y(base_type::m_x - base_type::m_old_x); - else m_di.inc_y(base_type::m_x - base_type::m_old_x); - - base_type::m_old_x = base_type::m_x; - - dist1_start = dist2_start = m_di.dist_start(); - - int dx = 0; - if(dist1_start < 0) ++npix; - do - { - dist1_start += m_di.dy_start(); - dist2_start -= m_di.dy_start(); - if(dist1_start < 0) ++npix; - if(dist2_start < 0) ++npix; - ++dx; - } - while(base_type::m_dist[dx] <= base_type::m_width); - if(npix == 0) break; - npix = 0; - } - while(--base_type::m_step >= -base_type::m_max_extent); - } - else - { - do - { - --base_type::m_li; - base_type::m_x -= lp.inc; - base_type::m_y = (base_type::m_lp->y1 + base_type::m_li.y()) >> line_subpixel_shift; - - if(lp.inc > 0) m_di.dec_x(base_type::m_y - base_type::m_old_y); - else m_di.inc_x(base_type::m_y - base_type::m_old_y); - - base_type::m_old_y = base_type::m_y; - - dist1_start = dist2_start = m_di.dist_start(); - - int dy = 0; - if(dist1_start < 0) ++npix; - do - { - dist1_start -= m_di.dx_start(); - dist2_start += m_di.dx_start(); - if(dist1_start < 0) ++npix; - if(dist2_start < 0) ++npix; - ++dy; - } - while(base_type::m_dist[dy] <= base_type::m_width); - if(npix == 0) break; - npix = 0; - } - while(--base_type::m_step >= -base_type::m_max_extent); - } - base_type::m_li.adjust_forward(); - base_type::m_step -= base_type::m_max_extent; - } - - - //--------------------------------------------------------------------- - bool step_hor() - { - int dist_start; - int dist_end; - int dist; - int dy; - int s1 = base_type::step_hor_base(m_di); - cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; - cover_type* p1 = p0; - - dist_start = m_di.dist_start(); - dist_end = m_di.dist_end(); - - int npix = 0; - *p1 = 0; - if(dist_end > 0) - { - if(dist_start <= 0) - { - *p1 = (cover_type)base_type::m_ren.cover(s1); - } - ++npix; - } - ++p1; - - dy = 1; - while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) - { - dist_start -= m_di.dx_start(); - dist_end -= m_di.dx_end(); - *p1 = 0; - if(dist_end > 0 && dist_start <= 0) - { - *p1 = (cover_type)base_type::m_ren.cover(dist); - ++npix; - } - ++p1; - ++dy; - } - - dy = 1; - dist_start = m_di.dist_start(); - dist_end = m_di.dist_end(); - while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) - { - dist_start += m_di.dx_start(); - dist_end += m_di.dx_end(); - *--p0 = 0; - if(dist_end > 0 && dist_start <= 0) - { - *p0 = (cover_type)base_type::m_ren.cover(dist); - ++npix; - } - ++dy; - } - base_type::m_ren.blend_solid_vspan(base_type::m_x, - base_type::m_y - dy + 1, - unsigned(p1 - p0), - p0); - return npix && ++base_type::m_step < base_type::m_count; - } - - //--------------------------------------------------------------------- - bool step_ver() - { - int dist_start; - int dist_end; - int dist; - int dx; - int s1 = base_type::step_ver_base(m_di); - cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; - cover_type* p1 = p0; - - dist_start = m_di.dist_start(); - dist_end = m_di.dist_end(); - - int npix = 0; - *p1 = 0; - if(dist_end > 0) - { - if(dist_start <= 0) - { - *p1 = (cover_type)base_type::m_ren.cover(s1); - } - ++npix; - } - ++p1; - - dx = 1; - while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) - { - dist_start += m_di.dy_start(); - dist_end += m_di.dy_end(); - *p1 = 0; - if(dist_end > 0 && dist_start <= 0) - { - *p1 = (cover_type)base_type::m_ren.cover(dist); - ++npix; - } - ++p1; - ++dx; - } - - dx = 1; - dist_start = m_di.dist_start(); - dist_end = m_di.dist_end(); - while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) - { - dist_start -= m_di.dy_start(); - dist_end -= m_di.dy_end(); - *--p0 = 0; - if(dist_end > 0 && dist_start <= 0) - { - *p0 = (cover_type)base_type::m_ren.cover(dist); - ++npix; - } - ++dx; - } - base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, - base_type::m_y, - unsigned(p1 - p0), - p0); - return npix && ++base_type::m_step < base_type::m_count; - } - - private: - line_interpolator_aa3(const line_interpolator_aa3&); - const line_interpolator_aa3& - operator = (const line_interpolator_aa3&); - - //--------------------------------------------------------------------- - distance_interpolator3 m_di; - }; - - - - - //==========================================================line_profile_aa - // - // See Implementation agg_line_profile_aa.cpp - // - class line_profile_aa - { - public: - //--------------------------------------------------------------------- - typedef int8u value_type; - enum subpixel_scale_e - { - subpixel_shift = line_subpixel_shift, - subpixel_scale = 1 << subpixel_shift, - subpixel_mask = subpixel_scale - 1 - }; - - enum aa_scale_e - { - aa_shift = 8, - aa_scale = 1 << aa_shift, - aa_mask = aa_scale - 1 - }; - - //--------------------------------------------------------------------- - line_profile_aa() : - m_subpixel_width(0), - m_min_width(1.0), - m_smoother_width(1.0) - { - int i; - for(i = 0; i < aa_scale; i++) m_gamma[i] = (value_type)i; - } - - //--------------------------------------------------------------------- - template - line_profile_aa(double w, const GammaF& gamma_function) : - m_subpixel_width(0), - m_min_width(1.0), - m_smoother_width(1.0) - { - gamma(gamma_function); - width(w); - } - - //--------------------------------------------------------------------- - void min_width(double w) { m_min_width = w; } - void smoother_width(double w) { m_smoother_width = w; } - - //--------------------------------------------------------------------- - template void gamma(const GammaF& gamma_function) - { - int i; - for(i = 0; i < aa_scale; i++) - { - m_gamma[i] = value_type( - uround(gamma_function(double(i) / aa_mask) * aa_mask)); - } - } - - void width(double w); - - unsigned profile_size() const { return m_profile.size(); } - int subpixel_width() const { return m_subpixel_width; } - - //--------------------------------------------------------------------- - double min_width() const { return m_min_width; } - double smoother_width() const { return m_smoother_width; } - - //--------------------------------------------------------------------- - value_type value(int dist) const - { - return m_profile[dist + subpixel_scale*2]; - } - - private: - line_profile_aa(const line_profile_aa&); - const line_profile_aa& operator = (const line_profile_aa&); - - value_type* profile(double w); - void set(double center_width, double smoother_width); - - //--------------------------------------------------------------------- - pod_array m_profile; - value_type m_gamma[aa_scale]; - int m_subpixel_width; - double m_min_width; - double m_smoother_width; - }; - - - //======================================================renderer_outline_aa - template class renderer_outline_aa - { - public: - //--------------------------------------------------------------------- - typedef BaseRenderer base_ren_type; - typedef renderer_outline_aa self_type; - typedef typename base_ren_type::color_type color_type; - - //--------------------------------------------------------------------- - renderer_outline_aa(base_ren_type& ren, line_profile_aa& prof) : - m_ren(&ren), - m_profile(&prof), - m_clip_box(0,0,0,0), - m_clipping(false) - {} - void attach(base_ren_type& ren) { m_ren = &ren; } - - //--------------------------------------------------------------------- - void color(const color_type& c) { m_color = c; } - const color_type& color() const { return m_color; } - - //--------------------------------------------------------------------- - void profile(line_profile_aa& prof) { m_profile = &prof; } - line_profile_aa& profile() const { return *m_profile; } - - //--------------------------------------------------------------------- - int subpixel_width() const { return m_profile->subpixel_width(); } - - //--------------------------------------------------------------------- - void reset_clipping() { m_clipping = false; } - void clip_box(double x1, double y1, double x2, double y2) - { - m_clip_box.x1 = line_coord_sat::conv(x1); - m_clip_box.y1 = line_coord_sat::conv(y1); - m_clip_box.x2 = line_coord_sat::conv(x2); - m_clip_box.y2 = line_coord_sat::conv(y2); - m_clipping = true; - } - - //--------------------------------------------------------------------- - int cover(int d) const - { - return m_profile->value(d); - } - - //------------------------------------------------------------------------- - void blend_solid_hspan(int x, int y, unsigned len, const cover_type* covers) - { - m_ren->blend_solid_hspan(x, y, len, m_color, covers); - } - - //------------------------------------------------------------------------- - void blend_solid_vspan(int x, int y, unsigned len, const cover_type* covers) - { - m_ren->blend_solid_vspan(x, y, len, m_color, covers); - } - - //------------------------------------------------------------------------- - static bool accurate_join_only() { return false; } - - //------------------------------------------------------------------------- - template - void semidot_hline(Cmp cmp, - int xc1, int yc1, int xc2, int yc2, - int x1, int y1, int x2) - { - cover_type covers[line_interpolator_aa_base::max_half_width * 2 + 4]; - cover_type* p0 = covers; - cover_type* p1 = covers; - int x = x1 << line_subpixel_shift; - int y = y1 << line_subpixel_shift; - int w = subpixel_width(); - distance_interpolator0 di(xc1, yc1, xc2, yc2, x, y); - x += line_subpixel_scale/2; - y += line_subpixel_scale/2; - - int x0 = x1; - int dx = x - xc1; - int dy = y - yc1; - do - { - int d = int(fast_sqrt(dx*dx + dy*dy)); - *p1 = 0; - if(cmp(di.dist()) && d <= w) - { - *p1 = (cover_type)cover(d); - } - ++p1; - dx += line_subpixel_scale; - di.inc_x(); - } - while(++x1 <= x2); - m_ren->blend_solid_hspan(x0, y1, - unsigned(p1 - p0), - color(), - p0); - } - - //------------------------------------------------------------------------- - template - void semidot(Cmp cmp, int xc1, int yc1, int xc2, int yc2) - { - if(m_clipping && clipping_flags(xc1, yc1, m_clip_box)) return; - - int r = ((subpixel_width() + line_subpixel_mask) >> line_subpixel_shift); - if(r < 1) r = 1; - ellipse_bresenham_interpolator ei(r, r); - int dx = 0; - int dy = -r; - int dy0 = dy; - int dx0 = dx; - int x = xc1 >> line_subpixel_shift; - int y = yc1 >> line_subpixel_shift; - - do - { - dx += ei.dx(); - dy += ei.dy(); - - if(dy != dy0) - { - semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y+dy0, x+dx0); - semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y-dy0, x+dx0); - } - dx0 = dx; - dy0 = dy; - ++ei; - } - while(dy < 0); - semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y+dy0, x+dx0); - } - - //------------------------------------------------------------------------- - void pie_hline(int xc, int yc, int xp1, int yp1, int xp2, int yp2, - int xh1, int yh1, int xh2) - { - if(m_clipping && clipping_flags(xc, yc, m_clip_box)) return; - - cover_type covers[line_interpolator_aa_base::max_half_width * 2 + 4]; - cover_type* p0 = covers; - cover_type* p1 = covers; - int x = xh1 << line_subpixel_shift; - int y = yh1 << line_subpixel_shift; - int w = subpixel_width(); - - distance_interpolator00 di(xc, yc, xp1, yp1, xp2, yp2, x, y); - x += line_subpixel_scale/2; - y += line_subpixel_scale/2; - - int xh0 = xh1; - int dx = x - xc; - int dy = y - yc; - do - { - int d = int(fast_sqrt(dx*dx + dy*dy)); - *p1 = 0; - if(di.dist1() <= 0 && di.dist2() > 0 && d <= w) - { - *p1 = (cover_type)cover(d); - } - ++p1; - dx += line_subpixel_scale; - di.inc_x(); - } - while(++xh1 <= xh2); - m_ren->blend_solid_hspan(xh0, yh1, - unsigned(p1 - p0), - color(), - p0); - } - - - //------------------------------------------------------------------------- - void pie(int xc, int yc, int x1, int y1, int x2, int y2) - { - int r = ((subpixel_width() + line_subpixel_mask) >> line_subpixel_shift); - if(r < 1) r = 1; - ellipse_bresenham_interpolator ei(r, r); - int dx = 0; - int dy = -r; - int dy0 = dy; - int dx0 = dx; - int x = xc >> line_subpixel_shift; - int y = yc >> line_subpixel_shift; - - do - { - dx += ei.dx(); - dy += ei.dy(); - - if(dy != dy0) - { - pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y+dy0, x+dx0); - pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y-dy0, x+dx0); - } - dx0 = dx; - dy0 = dy; - ++ei; - } - while(dy < 0); - pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y+dy0, x+dx0); - } - - //------------------------------------------------------------------------- - void line0_no_clip(line_parameters& lp) - { - if(lp.len > line_max_length) - { - line_parameters lp1, lp2; - lp.divide(lp1, lp2); - line0_no_clip(lp1); - line0_no_clip(lp2); - return; - } - - line_interpolator_aa0 li(*this, lp); - if(li.count()) - { - if(li.vertical()) - { - while(li.step_ver()); - } - else - { - while(li.step_hor()); - } - } - } - - //------------------------------------------------------------------------- - void line0(line_parameters& lp) - { - if(m_clipping) - { - int x1 = lp.x1; - int y1 = lp.y1; - int x2 = lp.x2; - int y2 = lp.y2; - unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); - if((flags & 4) == 0) - { - if(flags) - { - line_parameters lp2(x1, y1, x2, y2, - uround(calc_distance(x1, y1, x2, y2))); - line0_no_clip(lp2); - } - else - { - line0_no_clip(lp); - } - } - } - else - { - line0_no_clip(lp); - } - } - - //------------------------------------------------------------------------- - void line1_no_clip(line_parameters& lp, int sx, int sy) - { - if(lp.len > line_max_length) - { - line_parameters lp1, lp2; - lp.divide(lp1, lp2); - line1_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1); - line1_no_clip(lp2, lp1.x2 + (lp1.y2 - lp1.y1), lp1.y2 - (lp1.x2 - lp1.x1)); - return; - } - - fix_degenerate_bisectrix_start(lp, &sx, &sy); - line_interpolator_aa1 li(*this, lp, sx, sy); - if(li.vertical()) - { - while(li.step_ver()); - } - else - { - while(li.step_hor()); - } - } - - - //------------------------------------------------------------------------- - void line1(line_parameters& lp, int sx, int sy) - { - if(m_clipping) - { - int x1 = lp.x1; - int y1 = lp.y1; - int x2 = lp.x2; - int y2 = lp.y2; - unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); - if((flags & 4) == 0) - { - if(flags) - { - line_parameters lp2(x1, y1, x2, y2, - uround(calc_distance(x1, y1, x2, y2))); - if(flags & 1) - { - sx = x1 + (y2 - y1); - sy = y1 - (x2 - x1); - } - else - { - while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) - { - sx = (lp.x1 + sx) >> 1; - sy = (lp.y1 + sy) >> 1; - } - } - line1_no_clip(lp2, sx, sy); - } - else - { - line1_no_clip(lp, sx, sy); - } - } - } - else - { - line1_no_clip(lp, sx, sy); - } - } - - //------------------------------------------------------------------------- - void line2_no_clip(line_parameters& lp, int ex, int ey) - { - if(lp.len > line_max_length) - { - line_parameters lp1, lp2; - lp.divide(lp1, lp2); - line2_no_clip(lp1, lp1.x2 + (lp1.y2 - lp1.y1), lp1.y2 - (lp1.x2 - lp1.x1)); - line2_no_clip(lp2, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); - return; - } - - fix_degenerate_bisectrix_end(lp, &ex, &ey); - line_interpolator_aa2 li(*this, lp, ex, ey); - if(li.vertical()) - { - while(li.step_ver()); - } - else - { - while(li.step_hor()); - } - } - - //------------------------------------------------------------------------- - void line2(line_parameters& lp, int ex, int ey) - { - if(m_clipping) - { - int x1 = lp.x1; - int y1 = lp.y1; - int x2 = lp.x2; - int y2 = lp.y2; - unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); - if((flags & 4) == 0) - { - if(flags) - { - line_parameters lp2(x1, y1, x2, y2, - uround(calc_distance(x1, y1, x2, y2))); - if(flags & 2) - { - ex = x2 + (y2 - y1); - ey = y2 - (x2 - x1); - } - else - { - while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) - { - ex = (lp.x2 + ex) >> 1; - ey = (lp.y2 + ey) >> 1; - } - } - line2_no_clip(lp2, ex, ey); - } - else - { - line2_no_clip(lp, ex, ey); - } - } - } - else - { - line2_no_clip(lp, ex, ey); - } - } - - //------------------------------------------------------------------------- - void line3_no_clip(line_parameters& lp, - int sx, int sy, int ex, int ey) - { - if(lp.len > line_max_length) - { - line_parameters lp1, lp2; - lp.divide(lp1, lp2); - int mx = lp1.x2 + (lp1.y2 - lp1.y1); - int my = lp1.y2 - (lp1.x2 - lp1.x1); - line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my); - line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); - return; - } - - fix_degenerate_bisectrix_start(lp, &sx, &sy); - fix_degenerate_bisectrix_end(lp, &ex, &ey); - line_interpolator_aa3 li(*this, lp, sx, sy, ex, ey); - if(li.vertical()) - { - while(li.step_ver()); - } - else - { - while(li.step_hor()); - } - } - - //------------------------------------------------------------------------- - void line3(line_parameters& lp, - int sx, int sy, int ex, int ey) - { - if(m_clipping) - { - int x1 = lp.x1; - int y1 = lp.y1; - int x2 = lp.x2; - int y2 = lp.y2; - unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); - if((flags & 4) == 0) - { - if(flags) - { - line_parameters lp2(x1, y1, x2, y2, - uround(calc_distance(x1, y1, x2, y2))); - if(flags & 1) - { - sx = x1 + (y2 - y1); - sy = y1 - (x2 - x1); - } - else - { - while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) - { - sx = (lp.x1 + sx) >> 1; - sy = (lp.y1 + sy) >> 1; - } - } - if(flags & 2) - { - ex = x2 + (y2 - y1); - ey = y2 - (x2 - x1); - } - else - { - while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) - { - ex = (lp.x2 + ex) >> 1; - ey = (lp.y2 + ey) >> 1; - } - } - line3_no_clip(lp2, sx, sy, ex, ey); - } - else - { - line3_no_clip(lp, sx, sy, ex, ey); - } - } - } - else - { - line3_no_clip(lp, sx, sy, ex, ey); - } - } - - - private: - base_ren_type* m_ren; - line_profile_aa* m_profile; - color_type m_color; - rect_i m_clip_box; - bool m_clipping; - }; - - - -} - -#endif diff --git a/xs/src/agg/agg_renderer_outline_image.h b/xs/src/agg/agg_renderer_outline_image.h deleted file mode 100644 index 2ccc5beddf..0000000000 --- a/xs/src/agg/agg_renderer_outline_image.h +++ /dev/null @@ -1,1036 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_RENDERER_OUTLINE_IMAGE_INCLUDED -#define AGG_RENDERER_OUTLINE_IMAGE_INCLUDED - -#include "agg_array.h" -#include "agg_math.h" -#include "agg_line_aa_basics.h" -#include "agg_dda_line.h" -#include "agg_rendering_buffer.h" -#include "agg_clip_liang_barsky.h" - - -namespace agg -{ - //========================================================line_image_scale - template class line_image_scale - { - public: - typedef typename Source::color_type color_type; - - line_image_scale(const Source& src, double height) : - m_source(src), - m_height(height), - m_scale(src.height() / height), - m_scale_inv(height / src.height()) - { - } - - double width() const { return m_source.width(); } - double height() const { return m_height; } - - color_type pixel(int x, int y) const - { - if (m_scale < 1.0) - { - // Interpolate between nearest source pixels. - double src_y = (y + 0.5) * m_scale - 0.5; - int h = m_source.height() - 1; - int y1 = ifloor(src_y); - int y2 = y1 + 1; - rgba pix1 = (y1 < 0) ? rgba::no_color() : rgba(m_source.pixel(x, y1)); - rgba pix2 = (y2 > h) ? rgba::no_color() : rgba(m_source.pixel(x, y2)); - return pix1.gradient(pix2, src_y - y1); - } - else - { - // Average source pixels between y and y+1. - double src_y1 = (y + 0.5) * m_scale - 0.5; - double src_y2 = src_y1 + m_scale; - int h = m_source.height() - 1; - int y1 = ifloor(src_y1); - int y2 = ifloor(src_y2); - rgba c = rgba::no_color(); - if (y1 >= 0) c += rgba(m_source.pixel(x, y1)) *= y1 + 1 - src_y1; - while (++y1 < y2) - { - if (y1 <= h) c += m_source.pixel(x, y1); - } - if (y2 <= h) c += rgba(m_source.pixel(x, y2)) *= src_y2 - y2; - return c *= m_scale_inv; - } - } - - private: - line_image_scale(const line_image_scale&); - const line_image_scale& operator = (const line_image_scale&); - - const Source& m_source; - double m_height; - double m_scale; - double m_scale_inv; - }; - - - - //======================================================line_image_pattern - template class line_image_pattern - { - public: - typedef Filter filter_type; - typedef typename filter_type::color_type color_type; - - //-------------------------------------------------------------------- - line_image_pattern(Filter& filter) : - m_filter(&filter), - m_dilation(filter.dilation() + 1), - m_dilation_hr(m_dilation << line_subpixel_shift), - m_data(), - m_width(0), - m_height(0), - m_width_hr(0), - m_half_height_hr(0), - m_offset_y_hr(0) - { - } - - // Create - //-------------------------------------------------------------------- - template - line_image_pattern(Filter& filter, const Source& src) : - m_filter(&filter), - m_dilation(filter.dilation() + 1), - m_dilation_hr(m_dilation << line_subpixel_shift), - m_data(), - m_width(0), - m_height(0), - m_width_hr(0), - m_half_height_hr(0), - m_offset_y_hr(0) - { - create(src); - } - - // Create - //-------------------------------------------------------------------- - template void create(const Source& src) - { - m_height = uceil(src.height()); - m_width = uceil(src.width()); - m_width_hr = uround(src.width() * line_subpixel_scale); - m_half_height_hr = uround(src.height() * line_subpixel_scale/2); - m_offset_y_hr = m_dilation_hr + m_half_height_hr - line_subpixel_scale/2; - m_half_height_hr += line_subpixel_scale/2; - - m_data.resize((m_width + m_dilation * 2) * (m_height + m_dilation * 2)); - - m_buf.attach(&m_data[0], m_width + m_dilation * 2, - m_height + m_dilation * 2, - m_width + m_dilation * 2); - unsigned x, y; - color_type* d1; - color_type* d2; - for(y = 0; y < m_height; y++) - { - d1 = m_buf.row_ptr(y + m_dilation) + m_dilation; - for(x = 0; x < m_width; x++) - { - *d1++ = src.pixel(x, y); - } - } - - const color_type* s1; - const color_type* s2; - for(y = 0; y < m_dilation; y++) - { - //s1 = m_buf.row_ptr(m_height + m_dilation - 1) + m_dilation; - //s2 = m_buf.row_ptr(m_dilation) + m_dilation; - d1 = m_buf.row_ptr(m_dilation + m_height + y) + m_dilation; - d2 = m_buf.row_ptr(m_dilation - y - 1) + m_dilation; - for(x = 0; x < m_width; x++) - { - //*d1++ = color_type(*s1++, 0); - //*d2++ = color_type(*s2++, 0); - *d1++ = color_type::no_color(); - *d2++ = color_type::no_color(); - } - } - - unsigned h = m_height + m_dilation * 2; - for(y = 0; y < h; y++) - { - s1 = m_buf.row_ptr(y) + m_dilation; - s2 = m_buf.row_ptr(y) + m_dilation + m_width; - d1 = m_buf.row_ptr(y) + m_dilation + m_width; - d2 = m_buf.row_ptr(y) + m_dilation; - - for(x = 0; x < m_dilation; x++) - { - *d1++ = *s1++; - *--d2 = *--s2; - } - } - } - - //-------------------------------------------------------------------- - int pattern_width() const { return m_width_hr; } - int line_width() const { return m_half_height_hr; } - double width() const { return m_height; } - - //-------------------------------------------------------------------- - void pixel(color_type* p, int x, int y) const - { - m_filter->pixel_high_res(m_buf.rows(), - p, - x % m_width_hr + m_dilation_hr, - y + m_offset_y_hr); - } - - //-------------------------------------------------------------------- - const filter_type& filter() const { return *m_filter; } - - private: - line_image_pattern(const line_image_pattern&); - const line_image_pattern& - operator = (const line_image_pattern&); - - protected: - row_ptr_cache m_buf; - const filter_type* m_filter; - unsigned m_dilation; - int m_dilation_hr; - pod_array m_data; - unsigned m_width; - unsigned m_height; - int m_width_hr; - int m_half_height_hr; - int m_offset_y_hr; - }; - - - - - - - //=================================================line_image_pattern_pow2 - template class line_image_pattern_pow2 : - public line_image_pattern - { - public: - typedef Filter filter_type; - typedef typename filter_type::color_type color_type; - typedef line_image_pattern base_type; - - //-------------------------------------------------------------------- - line_image_pattern_pow2(Filter& filter) : - line_image_pattern(filter), m_mask(line_subpixel_mask) {} - - //-------------------------------------------------------------------- - template - line_image_pattern_pow2(Filter& filter, const Source& src) : - line_image_pattern(filter), m_mask(line_subpixel_mask) - { - create(src); - } - - //-------------------------------------------------------------------- - template void create(const Source& src) - { - line_image_pattern::create(src); - m_mask = 1; - while(m_mask < base_type::m_width) - { - m_mask <<= 1; - m_mask |= 1; - } - m_mask <<= line_subpixel_shift - 1; - m_mask |= line_subpixel_mask; - base_type::m_width_hr = m_mask + 1; - } - - //-------------------------------------------------------------------- - void pixel(color_type* p, int x, int y) const - { - base_type::m_filter->pixel_high_res( - base_type::m_buf.rows(), - p, - (x & m_mask) + base_type::m_dilation_hr, - y + base_type::m_offset_y_hr); - } - private: - unsigned m_mask; - }; - - - - - - - - //===================================================distance_interpolator4 - class distance_interpolator4 - { - public: - //--------------------------------------------------------------------- - distance_interpolator4() {} - distance_interpolator4(int x1, int y1, int x2, int y2, - int sx, int sy, int ex, int ey, - int len, double scale, int x, int y) : - m_dx(x2 - x1), - m_dy(y2 - y1), - m_dx_start(line_mr(sx) - line_mr(x1)), - m_dy_start(line_mr(sy) - line_mr(y1)), - m_dx_end(line_mr(ex) - line_mr(x2)), - m_dy_end(line_mr(ey) - line_mr(y2)), - - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), - - m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start), - - m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end), - m_len(uround(len / scale)) - { - double d = len * scale; - int dx = iround(((x2 - x1) << line_subpixel_shift) / d); - int dy = iround(((y2 - y1) << line_subpixel_shift) / d); - m_dx_pict = -dy; - m_dy_pict = dx; - m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict - - (y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >> - line_subpixel_shift; - - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - m_dx_start <<= line_mr_subpixel_shift; - m_dy_start <<= line_mr_subpixel_shift; - m_dx_end <<= line_mr_subpixel_shift; - m_dy_end <<= line_mr_subpixel_shift; - } - - //--------------------------------------------------------------------- - void inc_x() - { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_pict += m_dy_pict; - m_dist_end += m_dy_end; - } - - //--------------------------------------------------------------------- - void dec_x() - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_pict -= m_dy_pict; - m_dist_end -= m_dy_end; - } - - //--------------------------------------------------------------------- - void inc_y() - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_pict -= m_dx_pict; - m_dist_end -= m_dx_end; - } - - //--------------------------------------------------------------------- - void dec_y() - { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_pict += m_dx_pict; - m_dist_end += m_dx_end; - } - - //--------------------------------------------------------------------- - void inc_x(int dy) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_pict += m_dy_pict; - m_dist_end += m_dy_end; - if(dy > 0) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_pict -= m_dx_pict; - m_dist_end -= m_dx_end; - } - if(dy < 0) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_pict += m_dx_pict; - m_dist_end += m_dx_end; - } - } - - //--------------------------------------------------------------------- - void dec_x(int dy) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_pict -= m_dy_pict; - m_dist_end -= m_dy_end; - if(dy > 0) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_pict -= m_dx_pict; - m_dist_end -= m_dx_end; - } - if(dy < 0) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_pict += m_dx_pict; - m_dist_end += m_dx_end; - } - } - - //--------------------------------------------------------------------- - void inc_y(int dx) - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_pict -= m_dx_pict; - m_dist_end -= m_dx_end; - if(dx > 0) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_pict += m_dy_pict; - m_dist_end += m_dy_end; - } - if(dx < 0) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_pict -= m_dy_pict; - m_dist_end -= m_dy_end; - } - } - - //--------------------------------------------------------------------- - void dec_y(int dx) - { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_pict += m_dx_pict; - m_dist_end += m_dx_end; - if(dx > 0) - { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_pict += m_dy_pict; - m_dist_end += m_dy_end; - } - if(dx < 0) - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_pict -= m_dy_pict; - m_dist_end -= m_dy_end; - } - } - - //--------------------------------------------------------------------- - int dist() const { return m_dist; } - int dist_start() const { return m_dist_start; } - int dist_pict() const { return m_dist_pict; } - int dist_end() const { return m_dist_end; } - - //--------------------------------------------------------------------- - int dx() const { return m_dx; } - int dy() const { return m_dy; } - int dx_start() const { return m_dx_start; } - int dy_start() const { return m_dy_start; } - int dx_pict() const { return m_dx_pict; } - int dy_pict() const { return m_dy_pict; } - int dx_end() const { return m_dx_end; } - int dy_end() const { return m_dy_end; } - int len() const { return m_len; } - - private: - //--------------------------------------------------------------------- - int m_dx; - int m_dy; - int m_dx_start; - int m_dy_start; - int m_dx_pict; - int m_dy_pict; - int m_dx_end; - int m_dy_end; - - int m_dist; - int m_dist_start; - int m_dist_pict; - int m_dist_end; - int m_len; - }; - - - - - - //==================================================line_interpolator_image - template class line_interpolator_image - { - public: - typedef Renderer renderer_type; - typedef typename Renderer::color_type color_type; - - //--------------------------------------------------------------------- - enum max_half_width_e - { - max_half_width = 64 - }; - - //--------------------------------------------------------------------- - line_interpolator_image(renderer_type& ren, const line_parameters& lp, - int sx, int sy, int ex, int ey, - int pattern_start, - double scale_x) : - m_lp(lp), - m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : - line_dbl_hr(lp.y2 - lp.y1), - lp.vertical ? abs(lp.y2 - lp.y1) : - abs(lp.x2 - lp.x1) + 1), - m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x, - lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask), - m_ren(ren), - m_x(lp.x1 >> line_subpixel_shift), - m_y(lp.y1 >> line_subpixel_shift), - m_old_x(m_x), - m_old_y(m_y), - m_count((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) : - abs((lp.x2 >> line_subpixel_shift) - m_x))), - m_width(ren.subpixel_width()), - //m_max_extent(m_width >> (line_subpixel_shift - 2)), - m_max_extent((m_width + line_subpixel_scale) >> line_subpixel_shift), - m_start(pattern_start + (m_max_extent + 2) * ren.pattern_width()), - m_step(0) - { - agg::dda2_line_interpolator li(0, lp.vertical ? - (lp.dy << agg::line_subpixel_shift) : - (lp.dx << agg::line_subpixel_shift), - lp.len); - - unsigned i; - int stop = m_width + line_subpixel_scale * 2; - for(i = 0; i < max_half_width; ++i) - { - m_dist_pos[i] = li.y(); - if(m_dist_pos[i] >= stop) break; - ++li; - } - m_dist_pos[i] = 0x7FFF0000; - - int dist1_start; - int dist2_start; - int npix = 1; - - if(lp.vertical) - { - do - { - --m_li; - m_y -= lp.inc; - m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift; - - if(lp.inc > 0) m_di.dec_y(m_x - m_old_x); - else m_di.inc_y(m_x - m_old_x); - - m_old_x = m_x; - - dist1_start = dist2_start = m_di.dist_start(); - - int dx = 0; - if(dist1_start < 0) ++npix; - do - { - dist1_start += m_di.dy_start(); - dist2_start -= m_di.dy_start(); - if(dist1_start < 0) ++npix; - if(dist2_start < 0) ++npix; - ++dx; - } - while(m_dist_pos[dx] <= m_width); - if(npix == 0) break; - - npix = 0; - } - while(--m_step >= -m_max_extent); - } - else - { - do - { - --m_li; - - m_x -= lp.inc; - m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift; - - if(lp.inc > 0) m_di.dec_x(m_y - m_old_y); - else m_di.inc_x(m_y - m_old_y); - - m_old_y = m_y; - - dist1_start = dist2_start = m_di.dist_start(); - - int dy = 0; - if(dist1_start < 0) ++npix; - do - { - dist1_start -= m_di.dx_start(); - dist2_start += m_di.dx_start(); - if(dist1_start < 0) ++npix; - if(dist2_start < 0) ++npix; - ++dy; - } - while(m_dist_pos[dy] <= m_width); - if(npix == 0) break; - - npix = 0; - } - while(--m_step >= -m_max_extent); - } - m_li.adjust_forward(); - m_step -= m_max_extent; - } - - //--------------------------------------------------------------------- - bool step_hor() - { - ++m_li; - m_x += m_lp.inc; - m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift; - - if(m_lp.inc > 0) m_di.inc_x(m_y - m_old_y); - else m_di.dec_x(m_y - m_old_y); - - m_old_y = m_y; - - int s1 = m_di.dist() / m_lp.len; - int s2 = -s1; - - if(m_lp.inc < 0) s1 = -s1; - - int dist_start; - int dist_pict; - int dist_end; - int dy; - int dist; - - dist_start = m_di.dist_start(); - dist_pict = m_di.dist_pict() + m_start; - dist_end = m_di.dist_end(); - color_type* p0 = m_colors + max_half_width + 2; - color_type* p1 = p0; - - int npix = 0; - p1->clear(); - if(dist_end > 0) - { - if(dist_start <= 0) - { - m_ren.pixel(p1, dist_pict, s2); - } - ++npix; - } - ++p1; - - dy = 1; - while((dist = m_dist_pos[dy]) - s1 <= m_width) - { - dist_start -= m_di.dx_start(); - dist_pict -= m_di.dx_pict(); - dist_end -= m_di.dx_end(); - p1->clear(); - if(dist_end > 0 && dist_start <= 0) - { - if(m_lp.inc > 0) dist = -dist; - m_ren.pixel(p1, dist_pict, s2 - dist); - ++npix; - } - ++p1; - ++dy; - } - - dy = 1; - dist_start = m_di.dist_start(); - dist_pict = m_di.dist_pict() + m_start; - dist_end = m_di.dist_end(); - while((dist = m_dist_pos[dy]) + s1 <= m_width) - { - dist_start += m_di.dx_start(); - dist_pict += m_di.dx_pict(); - dist_end += m_di.dx_end(); - --p0; - p0->clear(); - if(dist_end > 0 && dist_start <= 0) - { - if(m_lp.inc > 0) dist = -dist; - m_ren.pixel(p0, dist_pict, s2 + dist); - ++npix; - } - ++dy; - } - m_ren.blend_color_vspan(m_x, - m_y - dy + 1, - unsigned(p1 - p0), - p0); - return npix && ++m_step < m_count; - } - - - - //--------------------------------------------------------------------- - bool step_ver() - { - ++m_li; - m_y += m_lp.inc; - m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift; - - if(m_lp.inc > 0) m_di.inc_y(m_x - m_old_x); - else m_di.dec_y(m_x - m_old_x); - - m_old_x = m_x; - - int s1 = m_di.dist() / m_lp.len; - int s2 = -s1; - - if(m_lp.inc > 0) s1 = -s1; - - int dist_start; - int dist_pict; - int dist_end; - int dist; - int dx; - - dist_start = m_di.dist_start(); - dist_pict = m_di.dist_pict() + m_start; - dist_end = m_di.dist_end(); - color_type* p0 = m_colors + max_half_width + 2; - color_type* p1 = p0; - - int npix = 0; - p1->clear(); - if(dist_end > 0) - { - if(dist_start <= 0) - { - m_ren.pixel(p1, dist_pict, s2); - } - ++npix; - } - ++p1; - - dx = 1; - while((dist = m_dist_pos[dx]) - s1 <= m_width) - { - dist_start += m_di.dy_start(); - dist_pict += m_di.dy_pict(); - dist_end += m_di.dy_end(); - p1->clear(); - if(dist_end > 0 && dist_start <= 0) - { - if(m_lp.inc > 0) dist = -dist; - m_ren.pixel(p1, dist_pict, s2 + dist); - ++npix; - } - ++p1; - ++dx; - } - - dx = 1; - dist_start = m_di.dist_start(); - dist_pict = m_di.dist_pict() + m_start; - dist_end = m_di.dist_end(); - while((dist = m_dist_pos[dx]) + s1 <= m_width) - { - dist_start -= m_di.dy_start(); - dist_pict -= m_di.dy_pict(); - dist_end -= m_di.dy_end(); - --p0; - p0->clear(); - if(dist_end > 0 && dist_start <= 0) - { - if(m_lp.inc > 0) dist = -dist; - m_ren.pixel(p0, dist_pict, s2 - dist); - ++npix; - } - ++dx; - } - m_ren.blend_color_hspan(m_x - dx + 1, - m_y, - unsigned(p1 - p0), - p0); - return npix && ++m_step < m_count; - } - - - //--------------------------------------------------------------------- - int pattern_end() const { return m_start + m_di.len(); } - - //--------------------------------------------------------------------- - bool vertical() const { return m_lp.vertical; } - int width() const { return m_width; } - int count() const { return m_count; } - - private: - line_interpolator_image(const line_interpolator_image&); - const line_interpolator_image& - operator = (const line_interpolator_image&); - - protected: - const line_parameters& m_lp; - dda2_line_interpolator m_li; - distance_interpolator4 m_di; - renderer_type& m_ren; - int m_plen; - int m_x; - int m_y; - int m_old_x; - int m_old_y; - int m_count; - int m_width; - int m_max_extent; - int m_start; - int m_step; - int m_dist_pos[max_half_width + 1]; - color_type m_colors[max_half_width * 2 + 4]; - }; - - - - - - - - - //===================================================renderer_outline_image - template - class renderer_outline_image - { - public: - //--------------------------------------------------------------------- - typedef BaseRenderer base_ren_type; - typedef renderer_outline_image self_type; - typedef typename base_ren_type::color_type color_type; - typedef ImagePattern pattern_type; - - - //--------------------------------------------------------------------- - renderer_outline_image(base_ren_type& ren, pattern_type& patt) : - m_ren(&ren), - m_pattern(&patt), - m_start(0), - m_scale_x(1.0), - m_clip_box(0,0,0,0), - m_clipping(false) - {} - void attach(base_ren_type& ren) { m_ren = &ren; } - - //--------------------------------------------------------------------- - void pattern(pattern_type& p) { m_pattern = &p; } - pattern_type& pattern() const { return *m_pattern; } - - //--------------------------------------------------------------------- - void reset_clipping() { m_clipping = false; } - void clip_box(double x1, double y1, double x2, double y2) - { - m_clip_box.x1 = line_coord_sat::conv(x1); - m_clip_box.y1 = line_coord_sat::conv(y1); - m_clip_box.x2 = line_coord_sat::conv(x2); - m_clip_box.y2 = line_coord_sat::conv(y2); - m_clipping = true; - } - - //--------------------------------------------------------------------- - void scale_x(double s) { m_scale_x = s; } - double scale_x() const { return m_scale_x; } - - //--------------------------------------------------------------------- - void start_x(double s) { m_start = iround(s * line_subpixel_scale); } - double start_x() const { return double(m_start) / line_subpixel_scale; } - - //--------------------------------------------------------------------- - int subpixel_width() const { return m_pattern->line_width(); } - int pattern_width() const { return m_pattern->pattern_width(); } - double width() const { return double(subpixel_width()) / line_subpixel_scale; } - - //------------------------------------------------------------------------- - void pixel(color_type* p, int x, int y) const - { - m_pattern->pixel(p, x, y); - } - - //------------------------------------------------------------------------- - void blend_color_hspan(int x, int y, unsigned len, const color_type* colors) - { - m_ren->blend_color_hspan(x, y, len, colors, 0); - } - - //------------------------------------------------------------------------- - void blend_color_vspan(int x, int y, unsigned len, const color_type* colors) - { - m_ren->blend_color_vspan(x, y, len, colors, 0); - } - - //------------------------------------------------------------------------- - static bool accurate_join_only() { return true; } - - //------------------------------------------------------------------------- - template - void semidot(Cmp, int, int, int, int) - { - } - - //------------------------------------------------------------------------- - void pie(int, int, int, int, int, int) - { - } - - //------------------------------------------------------------------------- - void line0(const line_parameters&) - { - } - - //------------------------------------------------------------------------- - void line1(const line_parameters&, int, int) - { - } - - //------------------------------------------------------------------------- - void line2(const line_parameters&, int, int) - { - } - - //------------------------------------------------------------------------- - void line3_no_clip(const line_parameters& lp, - int sx, int sy, int ex, int ey) - { - if(lp.len > line_max_length) - { - line_parameters lp1, lp2; - lp.divide(lp1, lp2); - int mx = lp1.x2 + (lp1.y2 - lp1.y1); - int my = lp1.y2 - (lp1.x2 - lp1.x1); - line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my); - line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); - return; - } - - fix_degenerate_bisectrix_start(lp, &sx, &sy); - fix_degenerate_bisectrix_end(lp, &ex, &ey); - line_interpolator_image li(*this, lp, - sx, sy, - ex, ey, - m_start, m_scale_x); - if(li.vertical()) - { - while(li.step_ver()); - } - else - { - while(li.step_hor()); - } - m_start += uround(lp.len / m_scale_x); - } - - //------------------------------------------------------------------------- - void line3(const line_parameters& lp, - int sx, int sy, int ex, int ey) - { - if(m_clipping) - { - int x1 = lp.x1; - int y1 = lp.y1; - int x2 = lp.x2; - int y2 = lp.y2; - unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); - int start = m_start; - if((flags & 4) == 0) - { - if(flags) - { - line_parameters lp2(x1, y1, x2, y2, - uround(calc_distance(x1, y1, x2, y2))); - if(flags & 1) - { - m_start += uround(calc_distance(lp.x1, lp.y1, x1, y1) / m_scale_x); - sx = x1 + (y2 - y1); - sy = y1 - (x2 - x1); - } - else - { - while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) - { - sx = (lp.x1 + sx) >> 1; - sy = (lp.y1 + sy) >> 1; - } - } - if(flags & 2) - { - ex = x2 + (y2 - y1); - ey = y2 - (x2 - x1); - } - else - { - while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) - { - ex = (lp.x2 + ex) >> 1; - ey = (lp.y2 + ey) >> 1; - } - } - line3_no_clip(lp2, sx, sy, ex, ey); - } - else - { - line3_no_clip(lp, sx, sy, ex, ey); - } - } - m_start = start + uround(lp.len / m_scale_x); - } - else - { - line3_no_clip(lp, sx, sy, ex, ey); - } - } - - private: - base_ren_type* m_ren; - pattern_type* m_pattern; - int m_start; - double m_scale_x; - rect_i m_clip_box; - bool m_clipping; - }; - - - - - -} - - - -#endif diff --git a/xs/src/agg/agg_renderer_primitives.h b/xs/src/agg/agg_renderer_primitives.h deleted file mode 100644 index f008db7c94..0000000000 --- a/xs/src/agg/agg_renderer_primitives.h +++ /dev/null @@ -1,224 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// class renderer_primitives -// -//---------------------------------------------------------------------------- - -#ifndef AGG_RENDERER_PRIMITIVES_INCLUDED -#define AGG_RENDERER_PRIMITIVES_INCLUDED - -#include "agg_basics.h" -#include "agg_renderer_base.h" -#include "agg_dda_line.h" -#include "agg_ellipse_bresenham.h" - -namespace agg -{ - //-----------------------------------------------------renderer_primitives - template class renderer_primitives - { - public: - typedef BaseRenderer base_ren_type; - typedef typename base_ren_type::color_type color_type; - - //-------------------------------------------------------------------- - explicit renderer_primitives(base_ren_type& ren) : - m_ren(&ren), - m_fill_color(), - m_line_color(), - m_curr_x(0), - m_curr_y(0) - {} - void attach(base_ren_type& ren) { m_ren = &ren; } - - //-------------------------------------------------------------------- - static int coord(double c) - { - return iround(c * line_bresenham_interpolator::subpixel_scale); - } - - //-------------------------------------------------------------------- - void fill_color(const color_type& c) { m_fill_color = c; } - void line_color(const color_type& c) { m_line_color = c; } - const color_type& fill_color() const { return m_fill_color; } - const color_type& line_color() const { return m_line_color; } - - //-------------------------------------------------------------------- - void rectangle(int x1, int y1, int x2, int y2) - { - m_ren->blend_hline(x1, y1, x2-1, m_line_color, cover_full); - m_ren->blend_vline(x2, y1, y2-1, m_line_color, cover_full); - m_ren->blend_hline(x1+1, y2, x2, m_line_color, cover_full); - m_ren->blend_vline(x1, y1+1, y2, m_line_color, cover_full); - } - - //-------------------------------------------------------------------- - void solid_rectangle(int x1, int y1, int x2, int y2) - { - m_ren->blend_bar(x1, y1, x2, y2, m_fill_color, cover_full); - } - - //-------------------------------------------------------------------- - void outlined_rectangle(int x1, int y1, int x2, int y2) - { - rectangle(x1, y1, x2, y2); - m_ren->blend_bar(x1+1, y1+1, x2-1, y2-1, m_fill_color, cover_full); - } - - //-------------------------------------------------------------------- - void ellipse(int x, int y, int rx, int ry) - { - ellipse_bresenham_interpolator ei(rx, ry); - int dx = 0; - int dy = -ry; - do - { - dx += ei.dx(); - dy += ei.dy(); - m_ren->blend_pixel(x + dx, y + dy, m_line_color, cover_full); - m_ren->blend_pixel(x + dx, y - dy, m_line_color, cover_full); - m_ren->blend_pixel(x - dx, y - dy, m_line_color, cover_full); - m_ren->blend_pixel(x - dx, y + dy, m_line_color, cover_full); - ++ei; - } - while(dy < 0); - } - - //-------------------------------------------------------------------- - void solid_ellipse(int x, int y, int rx, int ry) - { - ellipse_bresenham_interpolator ei(rx, ry); - int dx = 0; - int dy = -ry; - int dy0 = dy; - int dx0 = dx; - - do - { - dx += ei.dx(); - dy += ei.dy(); - - if(dy != dy0) - { - m_ren->blend_hline(x-dx0, y+dy0, x+dx0, m_fill_color, cover_full); - m_ren->blend_hline(x-dx0, y-dy0, x+dx0, m_fill_color, cover_full); - } - dx0 = dx; - dy0 = dy; - ++ei; - } - while(dy < 0); - m_ren->blend_hline(x-dx0, y+dy0, x+dx0, m_fill_color, cover_full); - } - - //-------------------------------------------------------------------- - void outlined_ellipse(int x, int y, int rx, int ry) - { - ellipse_bresenham_interpolator ei(rx, ry); - int dx = 0; - int dy = -ry; - - do - { - dx += ei.dx(); - dy += ei.dy(); - - m_ren->blend_pixel(x + dx, y + dy, m_line_color, cover_full); - m_ren->blend_pixel(x + dx, y - dy, m_line_color, cover_full); - m_ren->blend_pixel(x - dx, y - dy, m_line_color, cover_full); - m_ren->blend_pixel(x - dx, y + dy, m_line_color, cover_full); - - if(ei.dy() && dx) - { - m_ren->blend_hline(x-dx+1, y+dy, x+dx-1, m_fill_color, cover_full); - m_ren->blend_hline(x-dx+1, y-dy, x+dx-1, m_fill_color, cover_full); - } - ++ei; - } - while(dy < 0); - } - - //-------------------------------------------------------------------- - void line(int x1, int y1, int x2, int y2, bool last=false) - { - line_bresenham_interpolator li(x1, y1, x2, y2); - - unsigned len = li.len(); - if(len == 0) - { - if(last) - { - m_ren->blend_pixel(li.line_lr(x1), li.line_lr(y1), m_line_color, cover_full); - } - return; - } - - if(last) ++len; - - if(li.is_ver()) - { - do - { - m_ren->blend_pixel(li.x2(), li.y1(), m_line_color, cover_full); - li.vstep(); - } - while(--len); - } - else - { - do - { - m_ren->blend_pixel(li.x1(), li.y2(), m_line_color, cover_full); - li.hstep(); - } - while(--len); - } - } - - //-------------------------------------------------------------------- - void move_to(int x, int y) - { - m_curr_x = x; - m_curr_y = y; - } - - //-------------------------------------------------------------------- - void line_to(int x, int y, bool last=false) - { - line(m_curr_x, m_curr_y, x, y, last); - m_curr_x = x; - m_curr_y = y; - } - - //-------------------------------------------------------------------- - const base_ren_type& ren() const { return *m_ren; } - base_ren_type& ren() { return *m_ren; } - - //-------------------------------------------------------------------- - const rendering_buffer& rbuf() const { return m_ren->rbuf(); } - rendering_buffer& rbuf() { return m_ren->rbuf(); } - - private: - base_ren_type* m_ren; - color_type m_fill_color; - color_type m_line_color; - int m_curr_x; - int m_curr_y; - }; - -} - -#endif diff --git a/xs/src/agg/agg_renderer_raster_text.h b/xs/src/agg/agg_renderer_raster_text.h deleted file mode 100644 index 87b43f9600..0000000000 --- a/xs/src/agg/agg_renderer_raster_text.h +++ /dev/null @@ -1,264 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_RENDERER_RASTER_TEXT_INCLUDED -#define AGG_RENDERER_RASTER_TEXT_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //==============================================renderer_raster_htext_solid - template - class renderer_raster_htext_solid - { - public: - typedef BaseRenderer ren_type; - typedef GlyphGenerator glyph_gen_type; - typedef typename glyph_gen_type::glyph_rect glyph_rect; - typedef typename ren_type::color_type color_type; - - renderer_raster_htext_solid(ren_type& ren, glyph_gen_type& glyph) : - m_ren(&ren), - m_glyph(&glyph) - {} - void attach(ren_type& ren) { m_ren = &ren; } - - //-------------------------------------------------------------------- - void color(const color_type& c) { m_color = c; } - const color_type& color() const { return m_color; } - - //-------------------------------------------------------------------- - template - void render_text(double x, double y, const CharT* str, bool flip=false) - { - glyph_rect r; - while(*str) - { - m_glyph->prepare(&r, x, y, *str, flip); - if(r.x2 >= r.x1) - { - int i; - if(flip) - { - for(i = r.y1; i <= r.y2; i++) - { - m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1), - m_color, - m_glyph->span(r.y2 - i)); - } - } - else - { - for(i = r.y1; i <= r.y2; i++) - { - m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1), - m_color, - m_glyph->span(i - r.y1)); - } - } - } - x += r.dx; - y += r.dy; - ++str; - } - } - - private: - ren_type* m_ren; - glyph_gen_type* m_glyph; - color_type m_color; - }; - - - - //=============================================renderer_raster_vtext_solid - template - class renderer_raster_vtext_solid - { - public: - typedef BaseRenderer ren_type; - typedef GlyphGenerator glyph_gen_type; - typedef typename glyph_gen_type::glyph_rect glyph_rect; - typedef typename ren_type::color_type color_type; - - renderer_raster_vtext_solid(ren_type& ren, glyph_gen_type& glyph) : - m_ren(&ren), - m_glyph(&glyph) - { - } - - //-------------------------------------------------------------------- - void color(const color_type& c) { m_color = c; } - const color_type& color() const { return m_color; } - - //-------------------------------------------------------------------- - template - void render_text(double x, double y, const CharT* str, bool flip=false) - { - glyph_rect r; - while(*str) - { - m_glyph->prepare(&r, x, y, *str, !flip); - if(r.x2 >= r.x1) - { - int i; - if(flip) - { - for(i = r.y1; i <= r.y2; i++) - { - m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1), - m_color, - m_glyph->span(i - r.y1)); - } - } - else - { - for(i = r.y1; i <= r.y2; i++) - { - m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1), - m_color, - m_glyph->span(r.y2 - i)); - } - } - } - x += r.dx; - y += r.dy; - ++str; - } - } - - private: - ren_type* m_ren; - glyph_gen_type* m_glyph; - color_type m_color; - }; - - - - - - - //===================================================renderer_raster_htext - template - class renderer_raster_htext - { - public: - typedef ScanlineRenderer ren_type; - typedef GlyphGenerator glyph_gen_type; - typedef typename glyph_gen_type::glyph_rect glyph_rect; - - class scanline_single_span - { - public: - typedef agg::cover_type cover_type; - - //---------------------------------------------------------------- - struct const_span - { - int x; - unsigned len; - const cover_type* covers; - - const_span() {} - const_span(int x_, unsigned len_, const cover_type* covers_) : - x(x_), len(len_), covers(covers_) - {} - }; - - typedef const const_span* const_iterator; - - //---------------------------------------------------------------- - scanline_single_span(int x, int y, unsigned len, - const cover_type* covers) : - m_y(y), - m_span(x, len, covers) - {} - - //---------------------------------------------------------------- - int y() const { return m_y; } - unsigned num_spans() const { return 1; } - const_iterator begin() const { return &m_span; } - - private: - //---------------------------------------------------------------- - int m_y; - const_span m_span; - }; - - - - //-------------------------------------------------------------------- - renderer_raster_htext(ren_type& ren, glyph_gen_type& glyph) : - m_ren(&ren), - m_glyph(&glyph) - { - } - - - //-------------------------------------------------------------------- - template - void render_text(double x, double y, const CharT* str, bool flip=false) - { - glyph_rect r; - while(*str) - { - m_glyph->prepare(&r, x, y, *str, flip); - if(r.x2 >= r.x1) - { - m_ren->prepare(); - int i; - if(flip) - { - for(i = r.y1; i <= r.y2; i++) - { - m_ren->render( - scanline_single_span(r.x1, - i, - (r.x2 - r.x1 + 1), - m_glyph->span(r.y2 - i))); - } - } - else - { - for(i = r.y1; i <= r.y2; i++) - { - m_ren->render( - scanline_single_span(r.x1, - i, - (r.x2 - r.x1 + 1), - m_glyph->span(i - r.y1))); - } - } - } - x += r.dx; - y += r.dy; - ++str; - } - } - - private: - ren_type* m_ren; - glyph_gen_type* m_glyph; - }; - - - - -} - -#endif - diff --git a/xs/src/agg/agg_rendering_buffer_dynarow.h b/xs/src/agg/agg_rendering_buffer_dynarow.h deleted file mode 100644 index 188746f3d3..0000000000 --- a/xs/src/agg/agg_rendering_buffer_dynarow.h +++ /dev/null @@ -1,137 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// class rendering_buffer_dynarow -// -//---------------------------------------------------------------------------- - -#ifndef AGG_RENDERING_BUFFER_DYNAROW_INCLUDED -#define AGG_RENDERING_BUFFER_DYNAROW_INCLUDED - -#include "agg_array.h" - -namespace agg -{ - - //===============================================rendering_buffer_dynarow - // Rendering buffer class with dynamic allocation of the rows. - // The rows are allocated as needed when requesting for span_ptr(). - // The class automatically calculates min_x and max_x for each row. - // Generally it's more efficient to use this class as a temporary buffer - // for rendering a few lines and then to blend it with another buffer. - // - class rendering_buffer_dynarow - { - public: - typedef row_info row_data; - - //------------------------------------------------------------------- - ~rendering_buffer_dynarow() - { - init(0,0,0); - } - - //------------------------------------------------------------------- - rendering_buffer_dynarow() : - m_rows(), - m_width(0), - m_height(0), - m_byte_width(0) - { - } - - // Allocate and clear the buffer - //-------------------------------------------------------------------- - rendering_buffer_dynarow(unsigned width, unsigned height, - unsigned byte_width) : - m_rows(height), - m_width(width), - m_height(height), - m_byte_width(byte_width) - { - memset(&m_rows[0], 0, sizeof(row_data) * height); - } - - // Allocate and clear the buffer - //-------------------------------------------------------------------- - void init(unsigned width, unsigned height, unsigned byte_width) - { - unsigned i; - for(i = 0; i < m_height; ++i) - { - pod_allocator::deallocate((int8u*)m_rows[i].ptr, m_byte_width); - } - if(width && height) - { - m_width = width; - m_height = height; - m_byte_width = byte_width; - m_rows.resize(height); - memset(&m_rows[0], 0, sizeof(row_data) * height); - } - } - - //-------------------------------------------------------------------- - unsigned width() const { return m_width; } - unsigned height() const { return m_height; } - unsigned byte_width() const { return m_byte_width; } - - // The main function used for rendering. Returns pointer to the - // pre-allocated span. Memory for the row is allocated as needed. - //-------------------------------------------------------------------- - int8u* row_ptr(int x, int y, unsigned len) - { - row_data* r = &m_rows[y]; - int x2 = x + len - 1; - if(r->ptr) - { - if(x < r->x1) { r->x1 = x; } - if(x2 > r->x2) { r->x2 = x2; } - } - else - { - int8u* p = pod_allocator::allocate(m_byte_width); - r->ptr = p; - r->x1 = x; - r->x2 = x2; - memset(p, 0, m_byte_width); - } - return (int8u*)r->ptr; - } - - //-------------------------------------------------------------------- - const int8u* row_ptr(int y) const { return m_rows[y].ptr; } - int8u* row_ptr(int y) { return row_ptr(0, y, m_width); } - row_data row (int y) const { return m_rows[y]; } - - private: - //-------------------------------------------------------------------- - // Prohibit copying - rendering_buffer_dynarow(const rendering_buffer_dynarow&); - const rendering_buffer_dynarow& operator = (const rendering_buffer_dynarow&); - - private: - //-------------------------------------------------------------------- - pod_array m_rows; // Pointers to each row of the buffer - unsigned m_width; // Width in pixels - unsigned m_height; // Height in pixels - unsigned m_byte_width; // Width in bytes - }; - - -} - - -#endif diff --git a/xs/src/agg/agg_rounded_rect.h b/xs/src/agg/agg_rounded_rect.h deleted file mode 100644 index fe8d26f71b..0000000000 --- a/xs/src/agg/agg_rounded_rect.h +++ /dev/null @@ -1,72 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Rounded rectangle vertex generator -// -//---------------------------------------------------------------------------- - -#ifndef AGG_ROUNDED_RECT_INCLUDED -#define AGG_ROUNDED_RECT_INCLUDED - -#include "agg_basics.h" -#include "agg_arc.h" - -namespace agg -{ - //------------------------------------------------------------rounded_rect - // - // See Implemantation agg_rounded_rect.cpp - // - class rounded_rect - { - public: - rounded_rect() {} - rounded_rect(double x1, double y1, double x2, double y2, double r); - - void rect(double x1, double y1, double x2, double y2); - void radius(double r); - void radius(double rx, double ry); - void radius(double rx_bottom, double ry_bottom, double rx_top, double ry_top); - void radius(double rx1, double ry1, double rx2, double ry2, - double rx3, double ry3, double rx4, double ry4); - void normalize_radius(); - - void approximation_scale(double s) { m_arc.approximation_scale(s); } - double approximation_scale() const { return m_arc.approximation_scale(); } - - void rewind(unsigned); - unsigned vertex(double* x, double* y); - - private: - double m_x1; - double m_y1; - double m_x2; - double m_y2; - double m_rx1; - double m_ry1; - double m_rx2; - double m_ry2; - double m_rx3; - double m_ry3; - double m_rx4; - double m_ry4; - unsigned m_status; - arc m_arc; - }; - -} - -#endif - diff --git a/xs/src/agg/agg_scanline_bin.h b/xs/src/agg/agg_scanline_bin.h deleted file mode 100644 index 6f9f41e8e3..0000000000 --- a/xs/src/agg/agg_scanline_bin.h +++ /dev/null @@ -1,264 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Class scanline_bin - binary scanline. -// -//---------------------------------------------------------------------------- -// -// Adaptation for 32-bit screen coordinates (scanline32_bin) has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_SCANLINE_BIN_INCLUDED -#define AGG_SCANLINE_BIN_INCLUDED - -#include "agg_array.h" - -namespace agg -{ - - //=============================================================scanline_bin - // - // This is binary scaline container which supports the interface - // used in the rasterizer::render(). See description of agg_scanline_u8 - // for details. - // - //------------------------------------------------------------------------ - class scanline_bin - { - public: - typedef int32 coord_type; - - struct span - { - int16 x; - int16 len; - }; - - typedef const span* const_iterator; - - //-------------------------------------------------------------------- - scanline_bin() : - m_last_x(0x7FFFFFF0), - m_spans(), - m_cur_span(0) - { - } - - //-------------------------------------------------------------------- - void reset(int min_x, int max_x) - { - unsigned max_len = max_x - min_x + 3; - if(max_len > m_spans.size()) - { - m_spans.resize(max_len); - } - m_last_x = 0x7FFFFFF0; - m_cur_span = &m_spans[0]; - } - - //-------------------------------------------------------------------- - void add_cell(int x, unsigned) - { - if(x == m_last_x+1) - { - m_cur_span->len++; - } - else - { - ++m_cur_span; - m_cur_span->x = (int16)x; - m_cur_span->len = 1; - } - m_last_x = x; - } - - //-------------------------------------------------------------------- - void add_span(int x, unsigned len, unsigned) - { - if(x == m_last_x+1) - { - m_cur_span->len = (int16)(m_cur_span->len + len); - } - else - { - ++m_cur_span; - m_cur_span->x = (int16)x; - m_cur_span->len = (int16)len; - } - m_last_x = x + len - 1; - } - - //-------------------------------------------------------------------- - void add_cells(int x, unsigned len, const void*) - { - add_span(x, len, 0); - } - - //-------------------------------------------------------------------- - void finalize(int y) - { - m_y = y; - } - - //-------------------------------------------------------------------- - void reset_spans() - { - m_last_x = 0x7FFFFFF0; - m_cur_span = &m_spans[0]; - } - - //-------------------------------------------------------------------- - int y() const { return m_y; } - unsigned num_spans() const { return unsigned(m_cur_span - &m_spans[0]); } - const_iterator begin() const { return &m_spans[1]; } - - private: - scanline_bin(const scanline_bin&); - const scanline_bin operator = (const scanline_bin&); - - int m_last_x; - int m_y; - pod_array m_spans; - span* m_cur_span; - }; - - - - - - - //===========================================================scanline32_bin - class scanline32_bin - { - public: - typedef int32 coord_type; - - //-------------------------------------------------------------------- - struct span - { - span() {} - span(coord_type x_, coord_type len_) : x(x_), len(len_) {} - - coord_type x; - coord_type len; - }; - typedef pod_bvector span_array_type; - - - //-------------------------------------------------------------------- - class const_iterator - { - public: - const_iterator(const span_array_type& spans) : - m_spans(spans), - m_span_idx(0) - {} - - const span& operator*() const { return m_spans[m_span_idx]; } - const span* operator->() const { return &m_spans[m_span_idx]; } - - void operator ++ () { ++m_span_idx; } - - private: - const span_array_type& m_spans; - unsigned m_span_idx; - }; - - - //-------------------------------------------------------------------- - scanline32_bin() : m_max_len(0), m_last_x(0x7FFFFFF0) {} - - //-------------------------------------------------------------------- - void reset(int, int) - { - m_last_x = 0x7FFFFFF0; - m_spans.remove_all(); - } - - //-------------------------------------------------------------------- - void add_cell(int x, unsigned) - { - if(x == m_last_x+1) - { - m_spans.last().len++; - } - else - { - m_spans.add(span(coord_type(x), 1)); - } - m_last_x = x; - } - - //-------------------------------------------------------------------- - void add_span(int x, unsigned len, unsigned) - { - if(x == m_last_x+1) - { - m_spans.last().len += coord_type(len); - } - else - { - m_spans.add(span(coord_type(x), coord_type(len))); - } - m_last_x = x + len - 1; - } - - //-------------------------------------------------------------------- - void add_cells(int x, unsigned len, const void*) - { - add_span(x, len, 0); - } - - //-------------------------------------------------------------------- - void finalize(int y) - { - m_y = y; - } - - //-------------------------------------------------------------------- - void reset_spans() - { - m_last_x = 0x7FFFFFF0; - m_spans.remove_all(); - } - - //-------------------------------------------------------------------- - int y() const { return m_y; } - unsigned num_spans() const { return m_spans.size(); } - const_iterator begin() const { return const_iterator(m_spans); } - - private: - scanline32_bin(const scanline32_bin&); - const scanline32_bin operator = (const scanline32_bin&); - - unsigned m_max_len; - int m_last_x; - int m_y; - span_array_type m_spans; - }; - - - - - -} - - -#endif diff --git a/xs/src/agg/agg_scanline_boolean_algebra.h b/xs/src/agg/agg_scanline_boolean_algebra.h deleted file mode 100644 index bc2e9c9d51..0000000000 --- a/xs/src/agg/agg_scanline_boolean_algebra.h +++ /dev/null @@ -1,1567 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED -#define AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED - -#include -#include -#include "agg_basics.h" - - -namespace agg -{ - - //-----------------------------------------------sbool_combine_spans_bin - // Functor. - // Combine two binary encoded spans, i.e., when we don't have any - // anti-aliasing information, but only X and Length. The function - // is compatible with any type of scanlines. - //---------------- - template - struct sbool_combine_spans_bin - { - void operator () (const typename Scanline1::const_iterator&, - const typename Scanline2::const_iterator&, - int x, unsigned len, - Scanline& sl) const - { - sl.add_span(x, len, cover_full); - } - }; - - - - //---------------------------------------------sbool_combine_spans_empty - // Functor. - // Combine two spans as empty ones. The functor does nothing - // and is used to XOR binary spans. - //---------------- - template - struct sbool_combine_spans_empty - { - void operator () (const typename Scanline1::const_iterator&, - const typename Scanline2::const_iterator&, - int, unsigned, - Scanline&) const - {} - }; - - - - //--------------------------------------------------sbool_add_span_empty - // Functor. - // Add nothing. Used in conbine_shapes_sub - //---------------- - template - struct sbool_add_span_empty - { - void operator () (const typename Scanline1::const_iterator&, - int, unsigned, - Scanline&) const - {} - }; - - - //----------------------------------------------------sbool_add_span_bin - // Functor. - // Add a binary span - //---------------- - template - struct sbool_add_span_bin - { - void operator () (const typename Scanline1::const_iterator&, - int x, unsigned len, - Scanline& sl) const - { - sl.add_span(x, len, cover_full); - } - }; - - - - - //-----------------------------------------------------sbool_add_span_aa - // Functor. - // Add an anti-aliased span - // anti-aliasing information, but only X and Length. The function - // is compatible with any type of scanlines. - //---------------- - template - struct sbool_add_span_aa - { - void operator () (const typename Scanline1::const_iterator& span, - int x, unsigned len, - Scanline& sl) const - { - if(span->len < 0) - { - sl.add_span(x, len, *span->covers); - } - else - if(span->len > 0) - { - const typename Scanline1::cover_type* covers = span->covers; - if(span->x < x) covers += x - span->x; - sl.add_cells(x, len, covers); - } - } - }; - - - - - //----------------------------------------------sbool_intersect_spans_aa - // Functor. - // Intersect two spans preserving the anti-aliasing information. - // The result is added to the "sl" scanline. - //------------------ - template - struct sbool_intersect_spans_aa - { - enum cover_scale_e - { - cover_shift = CoverShift, - cover_size = 1 << cover_shift, - cover_mask = cover_size - 1, - cover_full = cover_mask - }; - - - void operator () (const typename Scanline1::const_iterator& span1, - const typename Scanline2::const_iterator& span2, - int x, unsigned len, - Scanline& sl) const - { - unsigned cover; - const typename Scanline1::cover_type* covers1; - const typename Scanline2::cover_type* covers2; - - // Calculate the operation code and choose the - // proper combination algorithm. - // 0 = Both spans are of AA type - // 1 = span1 is solid, span2 is AA - // 2 = span1 is AA, span2 is solid - // 3 = Both spans are of solid type - //----------------- - switch((span1->len < 0) | ((span2->len < 0) << 1)) - { - case 0: // Both are AA spans - covers1 = span1->covers; - covers2 = span2->covers; - if(span1->x < x) covers1 += x - span1->x; - if(span2->x < x) covers2 += x - span2->x; - do - { - cover = *covers1++ * *covers2++; - sl.add_cell(x++, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - while(--len); - break; - - case 1: // span1 is solid, span2 is AA - covers2 = span2->covers; - if(span2->x < x) covers2 += x - span2->x; - if(*(span1->covers) == cover_full) - { - sl.add_cells(x, len, covers2); - } - else - { - do - { - cover = *(span1->covers) * *covers2++; - sl.add_cell(x++, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - while(--len); - } - break; - - case 2: // span1 is AA, span2 is solid - covers1 = span1->covers; - if(span1->x < x) covers1 += x - span1->x; - if(*(span2->covers) == cover_full) - { - sl.add_cells(x, len, covers1); - } - else - { - do - { - cover = *covers1++ * *(span2->covers); - sl.add_cell(x++, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - while(--len); - } - break; - - case 3: // Both are solid spans - cover = *(span1->covers) * *(span2->covers); - sl.add_span(x, len, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - break; - } - } - }; - - - - - - - //--------------------------------------------------sbool_unite_spans_aa - // Functor. - // Unite two spans preserving the anti-aliasing information. - // The result is added to the "sl" scanline. - //------------------ - template - struct sbool_unite_spans_aa - { - enum cover_scale_e - { - cover_shift = CoverShift, - cover_size = 1 << cover_shift, - cover_mask = cover_size - 1, - cover_full = cover_mask - }; - - - void operator () (const typename Scanline1::const_iterator& span1, - const typename Scanline2::const_iterator& span2, - int x, unsigned len, - Scanline& sl) const - { - unsigned cover; - const typename Scanline1::cover_type* covers1; - const typename Scanline2::cover_type* covers2; - - // Calculate the operation code and choose the - // proper combination algorithm. - // 0 = Both spans are of AA type - // 1 = span1 is solid, span2 is AA - // 2 = span1 is AA, span2 is solid - // 3 = Both spans are of solid type - //----------------- - switch((span1->len < 0) | ((span2->len < 0) << 1)) - { - case 0: // Both are AA spans - covers1 = span1->covers; - covers2 = span2->covers; - if(span1->x < x) covers1 += x - span1->x; - if(span2->x < x) covers2 += x - span2->x; - do - { - cover = cover_mask * cover_mask - - (cover_mask - *covers1++) * - (cover_mask - *covers2++); - sl.add_cell(x++, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - while(--len); - break; - - case 1: // span1 is solid, span2 is AA - covers2 = span2->covers; - if(span2->x < x) covers2 += x - span2->x; - if(*(span1->covers) == cover_full) - { - sl.add_span(x, len, cover_full); - } - else - { - do - { - cover = cover_mask * cover_mask - - (cover_mask - *(span1->covers)) * - (cover_mask - *covers2++); - sl.add_cell(x++, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - while(--len); - } - break; - - case 2: // span1 is AA, span2 is solid - covers1 = span1->covers; - if(span1->x < x) covers1 += x - span1->x; - if(*(span2->covers) == cover_full) - { - sl.add_span(x, len, cover_full); - } - else - { - do - { - cover = cover_mask * cover_mask - - (cover_mask - *covers1++) * - (cover_mask - *(span2->covers)); - sl.add_cell(x++, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - while(--len); - } - break; - - case 3: // Both are solid spans - cover = cover_mask * cover_mask - - (cover_mask - *(span1->covers)) * - (cover_mask - *(span2->covers)); - sl.add_span(x, len, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - break; - } - } - }; - - - //---------------------------------------------sbool_xor_formula_linear - template - struct sbool_xor_formula_linear - { - enum cover_scale_e - { - cover_shift = CoverShift, - cover_size = 1 << cover_shift, - cover_mask = cover_size - 1 - }; - - static AGG_INLINE unsigned calculate(unsigned a, unsigned b) - { - unsigned cover = a + b; - if(cover > cover_mask) cover = cover_mask + cover_mask - cover; - return cover; - } - }; - - - //---------------------------------------------sbool_xor_formula_saddle - template - struct sbool_xor_formula_saddle - { - enum cover_scale_e - { - cover_shift = CoverShift, - cover_size = 1 << cover_shift, - cover_mask = cover_size - 1 - }; - - static AGG_INLINE unsigned calculate(unsigned a, unsigned b) - { - unsigned k = a * b; - if(k == cover_mask * cover_mask) return 0; - - a = (cover_mask * cover_mask - (a << cover_shift) + k) >> cover_shift; - b = (cover_mask * cover_mask - (b << cover_shift) + k) >> cover_shift; - return cover_mask - ((a * b) >> cover_shift); - } - }; - - - //-------------------------------------------sbool_xor_formula_abs_diff - struct sbool_xor_formula_abs_diff - { - static AGG_INLINE unsigned calculate(unsigned a, unsigned b) - { - return unsigned(abs(int(a) - int(b))); - } - }; - - - - //----------------------------------------------------sbool_xor_spans_aa - // Functor. - // XOR two spans preserving the anti-aliasing information. - // The result is added to the "sl" scanline. - //------------------ - template - struct sbool_xor_spans_aa - { - enum cover_scale_e - { - cover_shift = CoverShift, - cover_size = 1 << cover_shift, - cover_mask = cover_size - 1, - cover_full = cover_mask - }; - - - void operator () (const typename Scanline1::const_iterator& span1, - const typename Scanline2::const_iterator& span2, - int x, unsigned len, - Scanline& sl) const - { - unsigned cover; - const typename Scanline1::cover_type* covers1; - const typename Scanline2::cover_type* covers2; - - // Calculate the operation code and choose the - // proper combination algorithm. - // 0 = Both spans are of AA type - // 1 = span1 is solid, span2 is AA - // 2 = span1 is AA, span2 is solid - // 3 = Both spans are of solid type - //----------------- - switch((span1->len < 0) | ((span2->len < 0) << 1)) - { - case 0: // Both are AA spans - covers1 = span1->covers; - covers2 = span2->covers; - if(span1->x < x) covers1 += x - span1->x; - if(span2->x < x) covers2 += x - span2->x; - do - { - cover = XorFormula::calculate(*covers1++, *covers2++); - if(cover) sl.add_cell(x, cover); - ++x; - } - while(--len); - break; - - case 1: // span1 is solid, span2 is AA - covers2 = span2->covers; - if(span2->x < x) covers2 += x - span2->x; - do - { - cover = XorFormula::calculate(*(span1->covers), *covers2++); - if(cover) sl.add_cell(x, cover); - ++x; - } - while(--len); - break; - - case 2: // span1 is AA, span2 is solid - covers1 = span1->covers; - if(span1->x < x) covers1 += x - span1->x; - do - { - cover = XorFormula::calculate(*covers1++, *(span2->covers)); - if(cover) sl.add_cell(x, cover); - ++x; - } - while(--len); - break; - - case 3: // Both are solid spans - cover = XorFormula::calculate(*(span1->covers), *(span2->covers)); - if(cover) sl.add_span(x, len, cover); - break; - - } - } - }; - - - - - - //-----------------------------------------------sbool_subtract_spans_aa - // Functor. - // Unite two spans preserving the anti-aliasing information. - // The result is added to the "sl" scanline. - //------------------ - template - struct sbool_subtract_spans_aa - { - enum cover_scale_e - { - cover_shift = CoverShift, - cover_size = 1 << cover_shift, - cover_mask = cover_size - 1, - cover_full = cover_mask - }; - - - void operator () (const typename Scanline1::const_iterator& span1, - const typename Scanline2::const_iterator& span2, - int x, unsigned len, - Scanline& sl) const - { - unsigned cover; - const typename Scanline1::cover_type* covers1; - const typename Scanline2::cover_type* covers2; - - // Calculate the operation code and choose the - // proper combination algorithm. - // 0 = Both spans are of AA type - // 1 = span1 is solid, span2 is AA - // 2 = span1 is AA, span2 is solid - // 3 = Both spans are of solid type - //----------------- - switch((span1->len < 0) | ((span2->len < 0) << 1)) - { - case 0: // Both are AA spans - covers1 = span1->covers; - covers2 = span2->covers; - if(span1->x < x) covers1 += x - span1->x; - if(span2->x < x) covers2 += x - span2->x; - do - { - cover = *covers1++ * (cover_mask - *covers2++); - if(cover) - { - sl.add_cell(x, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - ++x; - } - while(--len); - break; - - case 1: // span1 is solid, span2 is AA - covers2 = span2->covers; - if(span2->x < x) covers2 += x - span2->x; - do - { - cover = *(span1->covers) * (cover_mask - *covers2++); - if(cover) - { - sl.add_cell(x, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - ++x; - } - while(--len); - break; - - case 2: // span1 is AA, span2 is solid - covers1 = span1->covers; - if(span1->x < x) covers1 += x - span1->x; - if(*(span2->covers) != cover_full) - { - do - { - cover = *covers1++ * (cover_mask - *(span2->covers)); - if(cover) - { - sl.add_cell(x, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - ++x; - } - while(--len); - } - break; - - case 3: // Both are solid spans - cover = *(span1->covers) * (cover_mask - *(span2->covers)); - if(cover) - { - sl.add_span(x, len, - (cover == cover_full * cover_full) ? - cover_full : - (cover >> cover_shift)); - } - break; - } - } - }; - - - - - - - //--------------------------------------------sbool_add_spans_and_render - template - void sbool_add_spans_and_render(const Scanline1& sl1, - Scanline& sl, - Renderer& ren, - AddSpanFunctor add_span) - { - sl.reset_spans(); - typename Scanline1::const_iterator span = sl1.begin(); - unsigned num_spans = sl1.num_spans(); - for(;;) - { - add_span(span, span->x, abs((int)span->len), sl); - if(--num_spans == 0) break; - ++span; - } - sl.finalize(sl1.y()); - ren.render(sl); - } - - - - - - - - //---------------------------------------------sbool_intersect_scanlines - // Intersect two scanlines, "sl1" and "sl2" and generate a new "sl" one. - // The combine_spans functor can be of type sbool_combine_spans_bin or - // sbool_intersect_spans_aa. First is a general functor to combine - // two spans without Anti-Aliasing, the second preserves the AA - // information, but works slower - // - template - void sbool_intersect_scanlines(const Scanline1& sl1, - const Scanline2& sl2, - Scanline& sl, - CombineSpansFunctor combine_spans) - { - sl.reset_spans(); - - unsigned num1 = sl1.num_spans(); - if(num1 == 0) return; - - unsigned num2 = sl2.num_spans(); - if(num2 == 0) return; - - typename Scanline1::const_iterator span1 = sl1.begin(); - typename Scanline2::const_iterator span2 = sl2.begin(); - - while(num1 && num2) - { - int xb1 = span1->x; - int xb2 = span2->x; - int xe1 = xb1 + abs((int)span1->len) - 1; - int xe2 = xb2 + abs((int)span2->len) - 1; - - // Determine what spans we should advance in the next step - // The span with the least ending X should be advanced - // advance_both is just an optimization when we ending - // coordinates are the same and we can advance both - //-------------- - bool advance_span1 = xe1 < xe2; - bool advance_both = xe1 == xe2; - - // Find the intersection of the spans - // and check if they intersect - //-------------- - if(xb1 < xb2) xb1 = xb2; - if(xe1 > xe2) xe1 = xe2; - if(xb1 <= xe1) - { - combine_spans(span1, span2, xb1, xe1 - xb1 + 1, sl); - } - - // Advance the spans - //-------------- - if(advance_both) - { - --num1; - --num2; - if(num1) ++span1; - if(num2) ++span2; - } - else - { - if(advance_span1) - { - --num1; - if(num1) ++span1; - } - else - { - --num2; - if(num2) ++span2; - } - } - } - } - - - - - - - - - //------------------------------------------------sbool_intersect_shapes - // Intersect the scanline shapes. Here the "Scanline Generator" - // abstraction is used. ScanlineGen1 and ScanlineGen2 are - // the generators, and can be of type rasterizer_scanline_aa<>. - // There function requires three scanline containers that can be of - // different types. - // "sl1" and "sl2" are used to retrieve scanlines from the generators, - // "sl" is ised as the resulting scanline to render it. - // The external "sl1" and "sl2" are used only for the sake of - // optimization and reusing of the scanline objects. - // the function calls sbool_intersect_scanlines with CombineSpansFunctor - // as the last argument. See sbool_intersect_scanlines for details. - //---------- - template - void sbool_intersect_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren, - CombineSpansFunctor combine_spans) - { - // Prepare the scanline generators. - // If anyone of them doesn't contain - // any scanlines, then return. - //----------------- - if(!sg1.rewind_scanlines()) return; - if(!sg2.rewind_scanlines()) return; - - // Get the bounding boxes - //---------------- - rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); - rect_i r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y()); - - // Calculate the intersection of the bounding - // boxes and return if they don't intersect. - //----------------- - rect_i ir = intersect_rectangles(r1, r2); - if(!ir.is_valid()) return; - - // Reset the scanlines and get two first ones - //----------------- - sl.reset(ir.x1, ir.x2); - sl1.reset(sg1.min_x(), sg1.max_x()); - sl2.reset(sg2.min_x(), sg2.max_x()); - if(!sg1.sweep_scanline(sl1)) return; - if(!sg2.sweep_scanline(sl2)) return; - - ren.prepare(); - - // The main loop - // Here we synchronize the scanlines with - // the same Y coordinate, ignoring all other ones. - // Only scanlines having the same Y-coordinate - // are to be combined. - //----------------- - for(;;) - { - while(sl1.y() < sl2.y()) - { - if(!sg1.sweep_scanline(sl1)) return; - } - while(sl2.y() < sl1.y()) - { - if(!sg2.sweep_scanline(sl2)) return; - } - - if(sl1.y() == sl2.y()) - { - // The Y coordinates are the same. - // Combine the scanlines, render if they contain any spans, - // and advance both generators to the next scanlines - //---------------------- - sbool_intersect_scanlines(sl1, sl2, sl, combine_spans); - if(sl.num_spans()) - { - sl.finalize(sl1.y()); - ren.render(sl); - } - if(!sg1.sweep_scanline(sl1)) return; - if(!sg2.sweep_scanline(sl2)) return; - } - } - } - - - - - - - - //-------------------------------------------------sbool_unite_scanlines - // Unite two scanlines, "sl1" and "sl2" and generate a new "sl" one. - // The combine_spans functor can be of type sbool_combine_spans_bin or - // sbool_intersect_spans_aa. First is a general functor to combine - // two spans without Anti-Aliasing, the second preserves the AA - // information, but works slower - // - template - void sbool_unite_scanlines(const Scanline1& sl1, - const Scanline2& sl2, - Scanline& sl, - AddSpanFunctor1 add_span1, - AddSpanFunctor2 add_span2, - CombineSpansFunctor combine_spans) - { - sl.reset_spans(); - - unsigned num1 = sl1.num_spans(); - unsigned num2 = sl2.num_spans(); - - typename Scanline1::const_iterator span1;// = sl1.begin(); - typename Scanline2::const_iterator span2;// = sl2.begin(); - - enum invalidation_e - { - invalid_b = 0xFFFFFFF, - invalid_e = invalid_b - 1 - }; - - // Initialize the spans as invalid - //--------------- - int xb1 = invalid_b; - int xb2 = invalid_b; - int xe1 = invalid_e; - int xe2 = invalid_e; - - // Initialize span1 if there are spans - //--------------- - if(num1) - { - span1 = sl1.begin(); - xb1 = span1->x; - xe1 = xb1 + abs((int)span1->len) - 1; - --num1; - } - - // Initialize span2 if there are spans - //--------------- - if(num2) - { - span2 = sl2.begin(); - xb2 = span2->x; - xe2 = xb2 + abs((int)span2->len) - 1; - --num2; - } - - - for(;;) - { - // Retrieve a new span1 if it's invalid - //---------------- - if(num1 && xb1 > xe1) - { - --num1; - ++span1; - xb1 = span1->x; - xe1 = xb1 + abs((int)span1->len) - 1; - } - - // Retrieve a new span2 if it's invalid - //---------------- - if(num2 && xb2 > xe2) - { - --num2; - ++span2; - xb2 = span2->x; - xe2 = xb2 + abs((int)span2->len) - 1; - } - - if(xb1 > xe1 && xb2 > xe2) break; - - // Calculate the intersection - //---------------- - int xb = xb1; - int xe = xe1; - if(xb < xb2) xb = xb2; - if(xe > xe2) xe = xe2; - int len = xe - xb + 1; // The length of the intersection - if(len > 0) - { - // The spans intersect, - // add the beginning of the span - //---------------- - if(xb1 < xb2) - { - add_span1(span1, xb1, xb2 - xb1, sl); - xb1 = xb2; - } - else - if(xb2 < xb1) - { - add_span2(span2, xb2, xb1 - xb2, sl); - xb2 = xb1; - } - - // Add the combination part of the spans - //---------------- - combine_spans(span1, span2, xb, len, sl); - - - // Invalidate the fully processed span or both - //---------------- - if(xe1 < xe2) - { - // Invalidate span1 and eat - // the processed part of span2 - //-------------- - xb1 = invalid_b; - xe1 = invalid_e; - xb2 += len; - } - else - if(xe2 < xe1) - { - // Invalidate span2 and eat - // the processed part of span1 - //-------------- - xb2 = invalid_b; - xe2 = invalid_e; - xb1 += len; - } - else - { - xb1 = invalid_b; // Invalidate both - xb2 = invalid_b; - xe1 = invalid_e; - xe2 = invalid_e; - } - } - else - { - // The spans do not intersect - //-------------- - if(xb1 < xb2) - { - // Advance span1 - //--------------- - if(xb1 <= xe1) - { - add_span1(span1, xb1, xe1 - xb1 + 1, sl); - } - xb1 = invalid_b; // Invalidate - xe1 = invalid_e; - } - else - { - // Advance span2 - //--------------- - if(xb2 <= xe2) - { - add_span2(span2, xb2, xe2 - xb2 + 1, sl); - } - xb2 = invalid_b; // Invalidate - xe2 = invalid_e; - } - } - } - } - - - - - //----------------------------------------------------sbool_unite_shapes - // Unite the scanline shapes. Here the "Scanline Generator" - // abstraction is used. ScanlineGen1 and ScanlineGen2 are - // the generators, and can be of type rasterizer_scanline_aa<>. - // There function requires three scanline containers that can be - // of different type. - // "sl1" and "sl2" are used to retrieve scanlines from the generators, - // "sl" is ised as the resulting scanline to render it. - // The external "sl1" and "sl2" are used only for the sake of - // optimization and reusing of the scanline objects. - // the function calls sbool_unite_scanlines with CombineSpansFunctor - // as the last argument. See sbool_unite_scanlines for details. - //---------- - template - void sbool_unite_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren, - AddSpanFunctor1 add_span1, - AddSpanFunctor2 add_span2, - CombineSpansFunctor combine_spans) - { - // Prepare the scanline generators. - // If anyone of them doesn't contain - // any scanlines, then return. - //----------------- - bool flag1 = sg1.rewind_scanlines(); - bool flag2 = sg2.rewind_scanlines(); - if(!flag1 && !flag2) return; - - // Get the bounding boxes - //---------------- - rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); - rect_i r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y()); - - // Calculate the union of the bounding boxes - //----------------- - rect_i ur(1,1,0,0); - if(flag1 && flag2) ur = unite_rectangles(r1, r2); - else if(flag1) ur = r1; - else if(flag2) ur = r2; - - if(!ur.is_valid()) return; - - ren.prepare(); - - // Reset the scanlines and get two first ones - //----------------- - sl.reset(ur.x1, ur.x2); - if(flag1) - { - sl1.reset(sg1.min_x(), sg1.max_x()); - flag1 = sg1.sweep_scanline(sl1); - } - - if(flag2) - { - sl2.reset(sg2.min_x(), sg2.max_x()); - flag2 = sg2.sweep_scanline(sl2); - } - - // The main loop - // Here we synchronize the scanlines with - // the same Y coordinate. - //----------------- - while(flag1 || flag2) - { - if(flag1 && flag2) - { - if(sl1.y() == sl2.y()) - { - // The Y coordinates are the same. - // Combine the scanlines, render if they contain any spans, - // and advance both generators to the next scanlines - //---------------------- - sbool_unite_scanlines(sl1, sl2, sl, - add_span1, add_span2, combine_spans); - if(sl.num_spans()) - { - sl.finalize(sl1.y()); - ren.render(sl); - } - flag1 = sg1.sweep_scanline(sl1); - flag2 = sg2.sweep_scanline(sl2); - } - else - { - if(sl1.y() < sl2.y()) - { - sbool_add_spans_and_render(sl1, sl, ren, add_span1); - flag1 = sg1.sweep_scanline(sl1); - } - else - { - sbool_add_spans_and_render(sl2, sl, ren, add_span2); - flag2 = sg2.sweep_scanline(sl2); - } - } - } - else - { - if(flag1) - { - sbool_add_spans_and_render(sl1, sl, ren, add_span1); - flag1 = sg1.sweep_scanline(sl1); - } - if(flag2) - { - sbool_add_spans_and_render(sl2, sl, ren, add_span2); - flag2 = sg2.sweep_scanline(sl2); - } - } - } - } - - - - - - - - - //-------------------------------------------------sbool_subtract_shapes - // Subtract the scanline shapes, "sg1-sg2". Here the "Scanline Generator" - // abstraction is used. ScanlineGen1 and ScanlineGen2 are - // the generators, and can be of type rasterizer_scanline_aa<>. - // There function requires three scanline containers that can be of - // different types. - // "sl1" and "sl2" are used to retrieve scanlines from the generators, - // "sl" is ised as the resulting scanline to render it. - // The external "sl1" and "sl2" are used only for the sake of - // optimization and reusing of the scanline objects. - // the function calls sbool_intersect_scanlines with CombineSpansFunctor - // as the last argument. See combine_scanlines_sub for details. - //---------- - template - void sbool_subtract_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren, - AddSpanFunctor1 add_span1, - CombineSpansFunctor combine_spans) - { - // Prepare the scanline generators. - // Here "sg1" is master, "sg2" is slave. - //----------------- - if(!sg1.rewind_scanlines()) return; - bool flag2 = sg2.rewind_scanlines(); - - // Get the bounding box - //---------------- - rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); - - // Reset the scanlines and get two first ones - //----------------- - sl.reset(sg1.min_x(), sg1.max_x()); - sl1.reset(sg1.min_x(), sg1.max_x()); - sl2.reset(sg2.min_x(), sg2.max_x()); - if(!sg1.sweep_scanline(sl1)) return; - - if(flag2) flag2 = sg2.sweep_scanline(sl2); - - ren.prepare(); - - // A fake span2 processor - sbool_add_span_empty add_span2; - - // The main loop - // Here we synchronize the scanlines with - // the same Y coordinate, ignoring all other ones. - // Only scanlines having the same Y-coordinate - // are to be combined. - //----------------- - bool flag1 = true; - do - { - // Synchronize "slave" with "master" - //----------------- - while(flag2 && sl2.y() < sl1.y()) - { - flag2 = sg2.sweep_scanline(sl2); - } - - - if(flag2 && sl2.y() == sl1.y()) - { - // The Y coordinates are the same. - // Combine the scanlines and render if they contain any spans. - //---------------------- - sbool_unite_scanlines(sl1, sl2, sl, add_span1, add_span2, combine_spans); - if(sl.num_spans()) - { - sl.finalize(sl1.y()); - ren.render(sl); - } - } - else - { - sbool_add_spans_and_render(sl1, sl, ren, add_span1); - } - - // Advance the "master" - flag1 = sg1.sweep_scanline(sl1); - } - while(flag1); - } - - - - - - - - //---------------------------------------------sbool_intersect_shapes_aa - // Intersect two anti-aliased scanline shapes. - // Here the "Scanline Generator" abstraction is used. - // ScanlineGen1 and ScanlineGen2 are the generators, and can be of - // type rasterizer_scanline_aa<>. There function requires three - // scanline containers that can be of different types. - // "sl1" and "sl2" are used to retrieve scanlines from the generators, - // "sl" is ised as the resulting scanline to render it. - // The external "sl1" and "sl2" are used only for the sake of - // optimization and reusing of the scanline objects. - //---------- - template - void sbool_intersect_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_intersect_spans_aa combine_functor; - sbool_intersect_shapes(sg1, sg2, sl1, sl2, sl, ren, combine_functor); - } - - - - - - //--------------------------------------------sbool_intersect_shapes_bin - // Intersect two binary scanline shapes (without anti-aliasing). - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_intersect_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_combine_spans_bin combine_functor; - sbool_intersect_shapes(sg1, sg2, sl1, sl2, sl, ren, combine_functor); - } - - - - - - //-------------------------------------------------sbool_unite_shapes_aa - // Unite two anti-aliased scanline shapes - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_unite_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_add_span_aa add_functor1; - sbool_add_span_aa add_functor2; - sbool_unite_spans_aa combine_functor; - sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, - add_functor1, add_functor2, combine_functor); - } - - - - - - //------------------------------------------------sbool_unite_shapes_bin - // Unite two binary scanline shapes (without anti-aliasing). - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_unite_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_add_span_bin add_functor1; - sbool_add_span_bin add_functor2; - sbool_combine_spans_bin combine_functor; - sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, - add_functor1, add_functor2, combine_functor); - } - - - - - - - - - - //---------------------------------------------------sbool_xor_shapes_aa - // Apply eXclusive OR to two anti-aliased scanline shapes. There's - // a modified "Linear" XOR used instead of classical "Saddle" one. - // The reason is to have the result absolutely conststent with what - // the scanline rasterizer produces. - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_xor_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_add_span_aa add_functor1; - sbool_add_span_aa add_functor2; - sbool_xor_spans_aa > combine_functor; - sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, - add_functor1, add_functor2, combine_functor); - } - - - - //------------------------------------------sbool_xor_shapes_saddle_aa - // Apply eXclusive OR to two anti-aliased scanline shapes. - // There's the classical "Saddle" used to calculate the - // Anti-Aliasing values, that is: - // a XOR b : 1-((1-a+a*b)*(1-b+a*b)) - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_xor_shapes_saddle_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_add_span_aa add_functor1; - sbool_add_span_aa add_functor2; - sbool_xor_spans_aa > combine_functor; - sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, - add_functor1, add_functor2, combine_functor); - } - - - //--------------------------------------sbool_xor_shapes_abs_diff_aa - // Apply eXclusive OR to two anti-aliased scanline shapes. - // There's the absolute difference used to calculate - // Anti-Aliasing values, that is: - // a XOR b : abs(a-b) - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_xor_shapes_abs_diff_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_add_span_aa add_functor1; - sbool_add_span_aa add_functor2; - sbool_xor_spans_aa combine_functor; - sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, - add_functor1, add_functor2, combine_functor); - } - - - - //--------------------------------------------------sbool_xor_shapes_bin - // Apply eXclusive OR to two binary scanline shapes (without anti-aliasing). - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_xor_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_add_span_bin add_functor1; - sbool_add_span_bin add_functor2; - sbool_combine_spans_empty combine_functor; - sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, - add_functor1, add_functor2, combine_functor); - } - - - - - - - //----------------------------------------------sbool_subtract_shapes_aa - // Subtract shapes "sg1-sg2" with anti-aliasing - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_subtract_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_add_span_aa add_functor; - sbool_subtract_spans_aa combine_functor; - sbool_subtract_shapes(sg1, sg2, sl1, sl2, sl, ren, - add_functor, combine_functor); - } - - - - - - //---------------------------------------------sbool_subtract_shapes_bin - // Subtract binary shapes "sg1-sg2" without anti-aliasing - // See intersect_shapes_aa for more comments - //---------- - template - void sbool_subtract_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - sbool_add_span_bin add_functor; - sbool_combine_spans_empty combine_functor; - sbool_subtract_shapes(sg1, sg2, sl1, sl2, sl, ren, - add_functor, combine_functor); - } - - - - - - - //------------------------------------------------------------sbool_op_e - enum sbool_op_e - { - sbool_or, //----sbool_or - sbool_and, //----sbool_and - sbool_xor, //----sbool_xor - sbool_xor_saddle, //----sbool_xor_saddle - sbool_xor_abs_diff, //----sbool_xor_abs_diff - sbool_a_minus_b, //----sbool_a_minus_b - sbool_b_minus_a //----sbool_b_minus_a - }; - - - - - - - //----------------------------------------------sbool_combine_shapes_bin - template - void sbool_combine_shapes_bin(sbool_op_e op, - ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - switch(op) - { - case sbool_or : sbool_unite_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_and : sbool_intersect_shapes_bin(sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_xor : - case sbool_xor_saddle : - case sbool_xor_abs_diff: sbool_xor_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_a_minus_b : sbool_subtract_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_b_minus_a : sbool_subtract_shapes_bin (sg2, sg1, sl2, sl1, sl, ren); break; - } - } - - - - - //-----------------------------------------------sbool_combine_shapes_aa - template - void sbool_combine_shapes_aa(sbool_op_e op, - ScanlineGen1& sg1, ScanlineGen2& sg2, - Scanline1& sl1, Scanline2& sl2, - Scanline& sl, Renderer& ren) - { - switch(op) - { - case sbool_or : sbool_unite_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_and : sbool_intersect_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_xor : sbool_xor_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_xor_saddle : sbool_xor_shapes_saddle_aa (sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_xor_abs_diff: sbool_xor_shapes_abs_diff_aa(sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_a_minus_b : sbool_subtract_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; - case sbool_b_minus_a : sbool_subtract_shapes_aa (sg2, sg1, sl2, sl1, sl, ren); break; - } - } - -} - - -#endif - diff --git a/xs/src/agg/agg_scanline_storage_aa.h b/xs/src/agg/agg_scanline_storage_aa.h deleted file mode 100644 index 4c6ed5708f..0000000000 --- a/xs/src/agg/agg_scanline_storage_aa.h +++ /dev/null @@ -1,816 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for 32-bit screen coordinates has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_SCANLINE_STORAGE_AA_INCLUDED -#define AGG_SCANLINE_STORAGE_AA_INCLUDED - -#include -#include -#include -#include -#include "agg_array.h" - - -namespace agg -{ - - //----------------------------------------------scanline_cell_storage - template class scanline_cell_storage - { - struct extra_span - { - unsigned len; - T* ptr; - }; - - public: - typedef T value_type; - - //--------------------------------------------------------------- - ~scanline_cell_storage() - { - remove_all(); - } - - //--------------------------------------------------------------- - scanline_cell_storage() : - m_cells(128-2), - m_extra_storage() - {} - - - // Copying - //--------------------------------------------------------------- - scanline_cell_storage(const scanline_cell_storage& v) : - m_cells(v.m_cells), - m_extra_storage() - { - copy_extra_storage(v); - } - - //--------------------------------------------------------------- - const scanline_cell_storage& - operator = (const scanline_cell_storage& v) - { - remove_all(); - m_cells = v.m_cells; - copy_extra_storage(v); - return *this; - } - - //--------------------------------------------------------------- - void remove_all() - { - int i; - for(i = m_extra_storage.size()-1; i >= 0; --i) - { - pod_allocator::deallocate(m_extra_storage[i].ptr, - m_extra_storage[i].len); - } - m_extra_storage.remove_all(); - m_cells.remove_all(); - } - - //--------------------------------------------------------------- - int add_cells(const T* cells, unsigned num_cells) - { - int idx = m_cells.allocate_continuous_block(num_cells); - if(idx >= 0) - { - T* ptr = &m_cells[idx]; - memcpy(ptr, cells, sizeof(T) * num_cells); - return idx; - } - extra_span s; - s.len = num_cells; - s.ptr = pod_allocator::allocate(num_cells); - memcpy(s.ptr, cells, sizeof(T) * num_cells); - m_extra_storage.add(s); - return -int(m_extra_storage.size()); - } - - //--------------------------------------------------------------- - const T* operator [] (int idx) const - { - if(idx >= 0) - { - if((unsigned)idx >= m_cells.size()) return 0; - return &m_cells[(unsigned)idx]; - } - unsigned i = unsigned(-idx - 1); - if(i >= m_extra_storage.size()) return 0; - return m_extra_storage[i].ptr; - } - - //--------------------------------------------------------------- - T* operator [] (int idx) - { - if(idx >= 0) - { - if((unsigned)idx >= m_cells.size()) return 0; - return &m_cells[(unsigned)idx]; - } - unsigned i = unsigned(-idx - 1); - if(i >= m_extra_storage.size()) return 0; - return m_extra_storage[i].ptr; - } - - private: - void copy_extra_storage(const scanline_cell_storage& v) - { - unsigned i; - for(i = 0; i < v.m_extra_storage.size(); ++i) - { - const extra_span& src = v.m_extra_storage[i]; - extra_span dst; - dst.len = src.len; - dst.ptr = pod_allocator::allocate(dst.len); - memcpy(dst.ptr, src.ptr, dst.len * sizeof(T)); - m_extra_storage.add(dst); - } - } - - pod_bvector m_cells; - pod_bvector m_extra_storage; - }; - - - - - - - //-----------------------------------------------scanline_storage_aa - template class scanline_storage_aa - { - public: - typedef T cover_type; - - //--------------------------------------------------------------- - struct span_data - { - int32 x; - int32 len; // If negative, it's a solid span, covers is valid - int covers_id; // The index of the cells in the scanline_cell_storage - }; - - //--------------------------------------------------------------- - struct scanline_data - { - int y; - unsigned num_spans; - unsigned start_span; - }; - - - //--------------------------------------------------------------- - class embedded_scanline - { - public: - - //----------------------------------------------------------- - class const_iterator - { - public: - struct span - { - int32 x; - int32 len; // If negative, it's a solid span, covers is valid - const T* covers; - }; - - const_iterator() : m_storage(0) {} - const_iterator(embedded_scanline& sl) : - m_storage(sl.m_storage), - m_span_idx(sl.m_scanline.start_span) - { - init_span(); - } - - const span& operator*() const { return m_span; } - const span* operator->() const { return &m_span; } - - void operator ++ () - { - ++m_span_idx; - init_span(); - } - - private: - void init_span() - { - const span_data& s = m_storage->span_by_index(m_span_idx); - m_span.x = s.x; - m_span.len = s.len; - m_span.covers = m_storage->covers_by_index(s.covers_id); - } - - scanline_storage_aa* m_storage; - unsigned m_span_idx; - span m_span; - }; - - friend class const_iterator; - - - //----------------------------------------------------------- - embedded_scanline(const scanline_storage_aa& storage) : - m_storage(&storage) - { - init(0); - } - - //----------------------------------------------------------- - void reset(int, int) {} - unsigned num_spans() const { return m_scanline.num_spans; } - int y() const { return m_scanline.y; } - const_iterator begin() const { return const_iterator(*this); } - - //----------------------------------------------------------- - void init(unsigned scanline_idx) - { - m_scanline_idx = scanline_idx; - m_scanline = m_storage->scanline_by_index(m_scanline_idx); - } - - private: - const scanline_storage_aa* m_storage; - scanline_data m_scanline; - unsigned m_scanline_idx; - }; - - - //--------------------------------------------------------------- - scanline_storage_aa() : - m_covers(), - m_spans(256-2), // Block increment size - m_scanlines(), - m_min_x(std::numeric_limits::max()), - m_min_y(std::numeric_limits::max()), - m_max_x(std::numeric_limits::min()), - m_max_y(std::numeric_limits::min()), - m_cur_scanline(0) - { - m_fake_scanline.y = 0; - m_fake_scanline.num_spans = 0; - m_fake_scanline.start_span = 0; - m_fake_span.x = 0; - m_fake_span.len = 0; - m_fake_span.covers_id = 0; - } - - // Renderer Interface - //--------------------------------------------------------------- - void prepare() - { - m_covers.remove_all(); - m_scanlines.remove_all(); - m_spans.remove_all(); - m_min_x = std::numeric_limits::max(); - m_min_y = std::numeric_limits::max(); - m_max_x = std::numeric_limits::min(); - m_max_y = std::numeric_limits::min(); - m_cur_scanline = 0; - } - - //--------------------------------------------------------------- - template void render(const Scanline& sl) - { - scanline_data sl_this; - - int y = sl.y(); - if(y < m_min_y) m_min_y = y; - if(y > m_max_y) m_max_y = y; - - sl_this.y = y; - sl_this.num_spans = sl.num_spans(); - sl_this.start_span = m_spans.size(); - typename Scanline::const_iterator span_iterator = sl.begin(); - - unsigned num_spans = sl_this.num_spans; - for(;;) - { - span_data sp; - - sp.x = span_iterator->x; - sp.len = span_iterator->len; - int len = abs(int(sp.len)); - sp.covers_id = - m_covers.add_cells(span_iterator->covers, - unsigned(len)); - m_spans.add(sp); - int x1 = sp.x; - int x2 = sp.x + len - 1; - if(x1 < m_min_x) m_min_x = x1; - if(x2 > m_max_x) m_max_x = x2; - if(--num_spans == 0) break; - ++span_iterator; - } - m_scanlines.add(sl_this); - } - - - //--------------------------------------------------------------- - // Iterate scanlines interface - int min_x() const { return m_min_x; } - int min_y() const { return m_min_y; } - int max_x() const { return m_max_x; } - int max_y() const { return m_max_y; } - - //--------------------------------------------------------------- - bool rewind_scanlines() - { - m_cur_scanline = 0; - return m_scanlines.size() > 0; - } - - - //--------------------------------------------------------------- - template bool sweep_scanline(Scanline& sl) - { - sl.reset_spans(); - for(;;) - { - if(m_cur_scanline >= m_scanlines.size()) return false; - const scanline_data& sl_this = m_scanlines[m_cur_scanline]; - - unsigned num_spans = sl_this.num_spans; - unsigned span_idx = sl_this.start_span; - do - { - const span_data& sp = m_spans[span_idx++]; - const T* covers = covers_by_index(sp.covers_id); - if(sp.len < 0) - { - sl.add_span(sp.x, unsigned(-sp.len), *covers); - } - else - { - sl.add_cells(sp.x, sp.len, covers); - } - } - while(--num_spans); - ++m_cur_scanline; - if(sl.num_spans()) - { - sl.finalize(sl_this.y); - break; - } - } - return true; - } - - - //--------------------------------------------------------------- - // Specialization for embedded_scanline - bool sweep_scanline(embedded_scanline& sl) - { - do - { - if(m_cur_scanline >= m_scanlines.size()) return false; - sl.init(m_cur_scanline); - ++m_cur_scanline; - } - while(sl.num_spans() == 0); - return true; - } - - //--------------------------------------------------------------- - unsigned byte_size() const - { - unsigned i; - unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y - - for(i = 0; i < m_scanlines.size(); ++i) - { - size += sizeof(int32) * 3; // scanline size in bytes, Y, num_spans - - const scanline_data& sl_this = m_scanlines[i]; - - unsigned num_spans = sl_this.num_spans; - unsigned span_idx = sl_this.start_span; - do - { - const span_data& sp = m_spans[span_idx++]; - - size += sizeof(int32) * 2; // X, span_len - if(sp.len < 0) - { - size += sizeof(T); // cover - } - else - { - size += sizeof(T) * unsigned(sp.len); // covers - } - } - while(--num_spans); - } - return size; - } - - - //--------------------------------------------------------------- - static void write_int32(int8u* dst, int32 val) - { - dst[0] = ((const int8u*)&val)[0]; - dst[1] = ((const int8u*)&val)[1]; - dst[2] = ((const int8u*)&val)[2]; - dst[3] = ((const int8u*)&val)[3]; - } - - - //--------------------------------------------------------------- - void serialize(int8u* data) const - { - unsigned i; - - write_int32(data, min_x()); // min_x - data += sizeof(int32); - write_int32(data, min_y()); // min_y - data += sizeof(int32); - write_int32(data, max_x()); // max_x - data += sizeof(int32); - write_int32(data, max_y()); // max_y - data += sizeof(int32); - - for(i = 0; i < m_scanlines.size(); ++i) - { - const scanline_data& sl_this = m_scanlines[i]; - - int8u* size_ptr = data; - data += sizeof(int32); // Reserve space for scanline size in bytes - - write_int32(data, sl_this.y); // Y - data += sizeof(int32); - - write_int32(data, sl_this.num_spans); // num_spans - data += sizeof(int32); - - unsigned num_spans = sl_this.num_spans; - unsigned span_idx = sl_this.start_span; - do - { - const span_data& sp = m_spans[span_idx++]; - const T* covers = covers_by_index(sp.covers_id); - - write_int32(data, sp.x); // X - data += sizeof(int32); - - write_int32(data, sp.len); // span_len - data += sizeof(int32); - - if(sp.len < 0) - { - memcpy(data, covers, sizeof(T)); - data += sizeof(T); - } - else - { - memcpy(data, covers, unsigned(sp.len) * sizeof(T)); - data += sizeof(T) * unsigned(sp.len); - } - } - while(--num_spans); - write_int32(size_ptr, int32(unsigned(data - size_ptr))); - } - } - - - //--------------------------------------------------------------- - const scanline_data& scanline_by_index(unsigned i) const - { - return (i < m_scanlines.size()) ? m_scanlines[i] : m_fake_scanline; - } - - //--------------------------------------------------------------- - const span_data& span_by_index(unsigned i) const - { - return (i < m_spans.size()) ? m_spans[i] : m_fake_span; - } - - //--------------------------------------------------------------- - const T* covers_by_index(int i) const - { - return m_covers[i]; - } - - private: - scanline_cell_storage m_covers; - pod_bvector m_spans; - pod_bvector m_scanlines; - span_data m_fake_span; - scanline_data m_fake_scanline; - int m_min_x; - int m_min_y; - int m_max_x; - int m_max_y; - unsigned m_cur_scanline; - }; - - - typedef scanline_storage_aa scanline_storage_aa8; //--------scanline_storage_aa8 - typedef scanline_storage_aa scanline_storage_aa16; //--------scanline_storage_aa16 - typedef scanline_storage_aa scanline_storage_aa32; //--------scanline_storage_aa32 - - - - - //------------------------------------------serialized_scanlines_adaptor_aa - template class serialized_scanlines_adaptor_aa - { - public: - typedef T cover_type; - - //--------------------------------------------------------------------- - class embedded_scanline - { - public: - typedef T cover_type; - - //----------------------------------------------------------------- - class const_iterator - { - public: - struct span - { - int32 x; - int32 len; // If negative, it's a solid span, "covers" is valid - const T* covers; - }; - - const_iterator() : m_ptr(0) {} - const_iterator(const embedded_scanline* sl) : - m_ptr(sl->m_ptr), - m_dx(sl->m_dx) - { - init_span(); - } - - const span& operator*() const { return m_span; } - const span* operator->() const { return &m_span; } - - void operator ++ () - { - if(m_span.len < 0) - { - m_ptr += sizeof(T); - } - else - { - m_ptr += m_span.len * sizeof(T); - } - init_span(); - } - - private: - int read_int32() - { - int32 val; - ((int8u*)&val)[0] = *m_ptr++; - ((int8u*)&val)[1] = *m_ptr++; - ((int8u*)&val)[2] = *m_ptr++; - ((int8u*)&val)[3] = *m_ptr++; - return val; - } - - void init_span() - { - m_span.x = read_int32() + m_dx; - m_span.len = read_int32(); - m_span.covers = m_ptr; - } - - const int8u* m_ptr; - span m_span; - int m_dx; - }; - - friend class const_iterator; - - - //----------------------------------------------------------------- - embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {} - - //----------------------------------------------------------------- - void reset(int, int) {} - unsigned num_spans() const { return m_num_spans; } - int y() const { return m_y; } - const_iterator begin() const { return const_iterator(this); } - - - private: - //----------------------------------------------------------------- - int read_int32() - { - int32 val; - ((int8u*)&val)[0] = *m_ptr++; - ((int8u*)&val)[1] = *m_ptr++; - ((int8u*)&val)[2] = *m_ptr++; - ((int8u*)&val)[3] = *m_ptr++; - return val; - } - - public: - //----------------------------------------------------------------- - void init(const int8u* ptr, int dx, int dy) - { - m_ptr = ptr; - m_y = read_int32() + dy; - m_num_spans = unsigned(read_int32()); - m_dx = dx; - } - - private: - const int8u* m_ptr; - int m_y; - unsigned m_num_spans; - int m_dx; - }; - - - - public: - //-------------------------------------------------------------------- - serialized_scanlines_adaptor_aa() : - m_data(0), - m_end(0), - m_ptr(0), - m_dx(0), - m_dy(0), - m_min_x(std::numeric_limits::max()), - m_min_y(std::numeric_limits::max()), - m_max_x(std::numeric_limits::min()), - m_max_y(std::numeric_limits::min()) - {} - - //-------------------------------------------------------------------- - serialized_scanlines_adaptor_aa(const int8u* data, unsigned size, - double dx, double dy) : - m_data(data), - m_end(data + size), - m_ptr(data), - m_dx(iround(dx)), - m_dy(iround(dy)), - m_min_x(std::numeric_limits::max()), - m_min_y(std::numeric_limits::max()), - m_max_x(std::numeric_limits::min()), - m_max_y(std::numeric_limits::min()) - {} - - //-------------------------------------------------------------------- - void init(const int8u* data, unsigned size, double dx, double dy) - { - m_data = data; - m_end = data + size; - m_ptr = data; - m_dx = iround(dx); - m_dy = iround(dy); - m_min_x = std::numeric_limits::max(); - m_min_y = std::numeric_limits::max(); - m_max_x = std::numeric_limits::min(); - m_max_y = std::numeric_limits::min(); - } - - private: - //-------------------------------------------------------------------- - int read_int32() - { - int32 val; - ((int8u*)&val)[0] = *m_ptr++; - ((int8u*)&val)[1] = *m_ptr++; - ((int8u*)&val)[2] = *m_ptr++; - ((int8u*)&val)[3] = *m_ptr++; - return val; - } - - //-------------------------------------------------------------------- - unsigned read_int32u() - { - int32u val; - ((int8u*)&val)[0] = *m_ptr++; - ((int8u*)&val)[1] = *m_ptr++; - ((int8u*)&val)[2] = *m_ptr++; - ((int8u*)&val)[3] = *m_ptr++; - return val; - } - - public: - // Iterate scanlines interface - //-------------------------------------------------------------------- - bool rewind_scanlines() - { - m_ptr = m_data; - if(m_ptr < m_end) - { - m_min_x = read_int32() + m_dx; - m_min_y = read_int32() + m_dy; - m_max_x = read_int32() + m_dx; - m_max_y = read_int32() + m_dy; - } - return m_ptr < m_end; - } - - //-------------------------------------------------------------------- - int min_x() const { return m_min_x; } - int min_y() const { return m_min_y; } - int max_x() const { return m_max_x; } - int max_y() const { return m_max_y; } - - //-------------------------------------------------------------------- - template bool sweep_scanline(Scanline& sl) - { - sl.reset_spans(); - for(;;) - { - if(m_ptr >= m_end) return false; - - read_int32(); // Skip scanline size in bytes - int y = read_int32() + m_dy; - unsigned num_spans = read_int32(); - - do - { - int x = read_int32() + m_dx; - int len = read_int32(); - - if(len < 0) - { - sl.add_span(x, unsigned(-len), *m_ptr); - m_ptr += sizeof(T); - } - else - { - sl.add_cells(x, len, m_ptr); - m_ptr += len * sizeof(T); - } - } - while(--num_spans); - - if(sl.num_spans()) - { - sl.finalize(y); - break; - } - } - return true; - } - - - //-------------------------------------------------------------------- - // Specialization for embedded_scanline - bool sweep_scanline(embedded_scanline& sl) - { - do - { - if(m_ptr >= m_end) return false; - - unsigned byte_size = read_int32u(); - sl.init(m_ptr, m_dx, m_dy); - m_ptr += byte_size - sizeof(int32); - } - while(sl.num_spans() == 0); - return true; - } - - private: - const int8u* m_data; - const int8u* m_end; - const int8u* m_ptr; - int m_dx; - int m_dy; - int m_min_x; - int m_min_y; - int m_max_x; - int m_max_y; - }; - - - - typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa8; //----serialized_scanlines_adaptor_aa8 - typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa16; //----serialized_scanlines_adaptor_aa16 - typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa32; //----serialized_scanlines_adaptor_aa32 - -} - - -#endif - diff --git a/xs/src/agg/agg_scanline_storage_bin.h b/xs/src/agg/agg_scanline_storage_bin.h deleted file mode 100644 index 0018d4ba60..0000000000 --- a/xs/src/agg/agg_scanline_storage_bin.h +++ /dev/null @@ -1,587 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for 32-bit screen coordinates has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - - -#ifndef AGG_SCANLINE_STORAGE_BIN_INCLUDED -#define AGG_SCANLINE_STORAGE_BIN_INCLUDED - -#include -#include -#include -#include -#include "agg_array.h" - - -namespace agg -{ - - //-----------------------------------------------scanline_storage_bin - class scanline_storage_bin - { - public: - //--------------------------------------------------------------- - struct span_data - { - int32 x; - int32 len; - }; - - //--------------------------------------------------------------- - struct scanline_data - { - int y; - unsigned num_spans; - unsigned start_span; - }; - - - //--------------------------------------------------------------- - class embedded_scanline - { - public: - - //----------------------------------------------------------- - class const_iterator - { - public: - const_iterator() : m_storage(0) {} - const_iterator(const embedded_scanline* sl) : - m_storage(sl->m_storage), - m_span_idx(sl->m_scanline.start_span) - { - m_span = m_storage->span_by_index(m_span_idx); - } - - const span_data& operator*() const { return m_span; } - const span_data* operator->() const { return &m_span; } - - void operator ++ () - { - ++m_span_idx; - m_span = m_storage->span_by_index(m_span_idx); - } - - private: - const scanline_storage_bin* m_storage; - unsigned m_span_idx; - span_data m_span; - }; - - friend class const_iterator; - - - //----------------------------------------------------------- - embedded_scanline(scanline_storage_bin& storage) : - m_storage(&storage) - { - setup(0); - } - - //----------------------------------------------------------- - void reset(int, int) {} - unsigned num_spans() const { return m_scanline.num_spans; } - int y() const { return m_scanline.y; } - const_iterator begin() const { return const_iterator(this); } - - //----------------------------------------------------------- - void setup(unsigned scanline_idx) - { - m_scanline_idx = scanline_idx; - m_scanline = m_storage->scanline_by_index(m_scanline_idx); - } - - private: - scanline_storage_bin* m_storage; - scanline_data m_scanline; - unsigned m_scanline_idx; - }; - - - //--------------------------------------------------------------- - scanline_storage_bin() : - m_spans(256-2), // Block increment size - m_scanlines(), - m_min_x(std::numeric_limits::max()), - m_min_y(std::numeric_limits::max()), - m_max_x(std::numeric_limits::min()), - m_max_y(std::numeric_limits::min()), - m_cur_scanline(0) - { - m_fake_scanline.y = 0; - m_fake_scanline.num_spans = 0; - m_fake_scanline.start_span = 0; - m_fake_span.x = 0; - m_fake_span.len = 0; - } - - // Renderer Interface - //--------------------------------------------------------------- - void prepare() - { - m_scanlines.remove_all(); - m_spans.remove_all(); - m_min_x = std::numeric_limits::max(); - m_min_y = std::numeric_limits::max(); - m_max_x = std::numeric_limits::min(); - m_max_y = std::numeric_limits::min(); - m_cur_scanline = 0; - } - - //--------------------------------------------------------------- - template void render(const Scanline& sl) - { - scanline_data sl_this; - - int y = sl.y(); - if(y < m_min_y) m_min_y = y; - if(y > m_max_y) m_max_y = y; - - sl_this.y = y; - sl_this.num_spans = sl.num_spans(); - sl_this.start_span = m_spans.size(); - typename Scanline::const_iterator span_iterator = sl.begin(); - - unsigned num_spans = sl_this.num_spans; - for(;;) - { - span_data sp; - sp.x = span_iterator->x; - sp.len = (int32)abs((int)(span_iterator->len)); - m_spans.add(sp); - int x1 = sp.x; - int x2 = sp.x + sp.len - 1; - if(x1 < m_min_x) m_min_x = x1; - if(x2 > m_max_x) m_max_x = x2; - if(--num_spans == 0) break; - ++span_iterator; - } - m_scanlines.add(sl_this); - } - - - //--------------------------------------------------------------- - // Iterate scanlines interface - int min_x() const { return m_min_x; } - int min_y() const { return m_min_y; } - int max_x() const { return m_max_x; } - int max_y() const { return m_max_y; } - - //--------------------------------------------------------------- - bool rewind_scanlines() - { - m_cur_scanline = 0; - return m_scanlines.size() > 0; - } - - - //--------------------------------------------------------------- - template bool sweep_scanline(Scanline& sl) - { - sl.reset_spans(); - for(;;) - { - if(m_cur_scanline >= m_scanlines.size()) return false; - const scanline_data& sl_this = m_scanlines[m_cur_scanline]; - - unsigned num_spans = sl_this.num_spans; - unsigned span_idx = sl_this.start_span; - do - { - const span_data& sp = m_spans[span_idx++]; - sl.add_span(sp.x, sp.len, cover_full); - } - while(--num_spans); - - ++m_cur_scanline; - if(sl.num_spans()) - { - sl.finalize(sl_this.y); - break; - } - } - return true; - } - - - //--------------------------------------------------------------- - // Specialization for embedded_scanline - bool sweep_scanline(embedded_scanline& sl) - { - do - { - if(m_cur_scanline >= m_scanlines.size()) return false; - sl.setup(m_cur_scanline); - ++m_cur_scanline; - } - while(sl.num_spans() == 0); - return true; - } - - - //--------------------------------------------------------------- - unsigned byte_size() const - { - unsigned i; - unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y - - for(i = 0; i < m_scanlines.size(); ++i) - { - size += sizeof(int32) * 2 + // Y, num_spans - unsigned(m_scanlines[i].num_spans) * sizeof(int32) * 2; // X, span_len - } - return size; - } - - - //--------------------------------------------------------------- - static void write_int32(int8u* dst, int32 val) - { - dst[0] = ((const int8u*)&val)[0]; - dst[1] = ((const int8u*)&val)[1]; - dst[2] = ((const int8u*)&val)[2]; - dst[3] = ((const int8u*)&val)[3]; - } - - - //--------------------------------------------------------------- - void serialize(int8u* data) const - { - unsigned i; - - write_int32(data, min_x()); // min_x - data += sizeof(int32); - write_int32(data, min_y()); // min_y - data += sizeof(int32); - write_int32(data, max_x()); // max_x - data += sizeof(int32); - write_int32(data, max_y()); // max_y - data += sizeof(int32); - - for(i = 0; i < m_scanlines.size(); ++i) - { - const scanline_data& sl_this = m_scanlines[i]; - - write_int32(data, sl_this.y); // Y - data += sizeof(int32); - - write_int32(data, sl_this.num_spans); // num_spans - data += sizeof(int32); - - unsigned num_spans = sl_this.num_spans; - unsigned span_idx = sl_this.start_span; - do - { - const span_data& sp = m_spans[span_idx++]; - - write_int32(data, sp.x); // X - data += sizeof(int32); - - write_int32(data, sp.len); // len - data += sizeof(int32); - } - while(--num_spans); - } - } - - - //--------------------------------------------------------------- - const scanline_data& scanline_by_index(unsigned i) const - { - return (i < m_scanlines.size()) ? m_scanlines[i] : m_fake_scanline; - } - - //--------------------------------------------------------------- - const span_data& span_by_index(unsigned i) const - { - return (i < m_spans.size()) ? m_spans[i] : m_fake_span; - } - - - private: - pod_bvector m_spans; - pod_bvector m_scanlines; - span_data m_fake_span; - scanline_data m_fake_scanline; - int m_min_x; - int m_min_y; - int m_max_x; - int m_max_y; - unsigned m_cur_scanline; - }; - - - - - - - - - - - - - - //---------------------------------------serialized_scanlines_adaptor_bin - class serialized_scanlines_adaptor_bin - { - public: - typedef bool cover_type; - - //-------------------------------------------------------------------- - class embedded_scanline - { - public: - - //---------------------------------------------------------------- - class const_iterator - { - public: - struct span - { - int32 x; - int32 len; - }; - - const_iterator() : m_ptr(0) {} - const_iterator(const embedded_scanline* sl) : - m_ptr(sl->m_ptr), - m_dx(sl->m_dx) - { - m_span.x = read_int32() + m_dx; - m_span.len = read_int32(); - } - - const span& operator*() const { return m_span; } - const span* operator->() const { return &m_span; } - - void operator ++ () - { - m_span.x = read_int32() + m_dx; - m_span.len = read_int32(); - } - - private: - int read_int32() - { - int32 val; - ((int8u*)&val)[0] = *m_ptr++; - ((int8u*)&val)[1] = *m_ptr++; - ((int8u*)&val)[2] = *m_ptr++; - ((int8u*)&val)[3] = *m_ptr++; - return val; - } - - const int8u* m_ptr; - span m_span; - int m_dx; - }; - - friend class const_iterator; - - - //---------------------------------------------------------------- - embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {} - - //---------------------------------------------------------------- - void reset(int, int) {} - unsigned num_spans() const { return m_num_spans; } - int y() const { return m_y; } - const_iterator begin() const { return const_iterator(this); } - - - private: - //---------------------------------------------------------------- - int read_int32() - { - int32 val; - ((int8u*)&val)[0] = *m_ptr++; - ((int8u*)&val)[1] = *m_ptr++; - ((int8u*)&val)[2] = *m_ptr++; - ((int8u*)&val)[3] = *m_ptr++; - return val; - } - - public: - //---------------------------------------------------------------- - void init(const int8u* ptr, int dx, int dy) - { - m_ptr = ptr; - m_y = read_int32() + dy; - m_num_spans = unsigned(read_int32()); - m_dx = dx; - } - - private: - const int8u* m_ptr; - int m_y; - unsigned m_num_spans; - int m_dx; - }; - - - - public: - //-------------------------------------------------------------------- - serialized_scanlines_adaptor_bin() : - m_data(0), - m_end(0), - m_ptr(0), - m_dx(0), - m_dy(0), - m_min_x(std::numeric_limits::max()), - m_min_y(std::numeric_limits::max()), - m_max_x(std::numeric_limits::min()), - m_max_y(std::numeric_limits::min()) - {} - - //-------------------------------------------------------------------- - serialized_scanlines_adaptor_bin(const int8u* data, unsigned size, - double dx, double dy) : - m_data(data), - m_end(data + size), - m_ptr(data), - m_dx(iround(dx)), - m_dy(iround(dy)), - m_min_x(std::numeric_limits::max()), - m_min_y(std::numeric_limits::max()), - m_max_x(std::numeric_limits::min()), - m_max_y(std::numeric_limits::min()) - {} - - //-------------------------------------------------------------------- - void init(const int8u* data, unsigned size, double dx, double dy) - { - m_data = data; - m_end = data + size; - m_ptr = data; - m_dx = iround(dx); - m_dy = iround(dy); - m_min_x = std::numeric_limits::max(); - m_min_y = std::numeric_limits::max(); - m_max_x = std::numeric_limits::min(); - m_max_y = std::numeric_limits::min(); - } - - private: - //-------------------------------------------------------------------- - int read_int32() - { - int32 val; - ((int8u*)&val)[0] = *m_ptr++; - ((int8u*)&val)[1] = *m_ptr++; - ((int8u*)&val)[2] = *m_ptr++; - ((int8u*)&val)[3] = *m_ptr++; - return val; - } - - public: - // Iterate scanlines interface - //-------------------------------------------------------------------- - bool rewind_scanlines() - { - m_ptr = m_data; - if(m_ptr < m_end) - { - m_min_x = read_int32() + m_dx; - m_min_y = read_int32() + m_dy; - m_max_x = read_int32() + m_dx; - m_max_y = read_int32() + m_dy; - } - return m_ptr < m_end; - } - - //-------------------------------------------------------------------- - int min_x() const { return m_min_x; } - int min_y() const { return m_min_y; } - int max_x() const { return m_max_x; } - int max_y() const { return m_max_y; } - - //-------------------------------------------------------------------- - template bool sweep_scanline(Scanline& sl) - { - sl.reset_spans(); - for(;;) - { - if(m_ptr >= m_end) return false; - - int y = read_int32() + m_dy; - unsigned num_spans = read_int32(); - - do - { - int x = read_int32() + m_dx; - int len = read_int32(); - - if(len < 0) len = -len; - sl.add_span(x, unsigned(len), cover_full); - } - while(--num_spans); - - if(sl.num_spans()) - { - sl.finalize(y); - break; - } - } - return true; - } - - - //-------------------------------------------------------------------- - // Specialization for embedded_scanline - bool sweep_scanline(embedded_scanline& sl) - { - do - { - if(m_ptr >= m_end) return false; - - sl.init(m_ptr, m_dx, m_dy); - - // Jump to the next scanline - //-------------------------- - read_int32(); // Y - int num_spans = read_int32(); // num_spans - m_ptr += num_spans * sizeof(int32) * 2; - } - while(sl.num_spans() == 0); - return true; - } - - private: - const int8u* m_data; - const int8u* m_end; - const int8u* m_ptr; - int m_dx; - int m_dy; - int m_min_x; - int m_min_y; - int m_max_x; - int m_max_y; - }; - - - -} - -#endif - diff --git a/xs/src/agg/agg_scanline_u.h b/xs/src/agg/agg_scanline_u.h deleted file mode 100644 index 630eb9deac..0000000000 --- a/xs/src/agg/agg_scanline_u.h +++ /dev/null @@ -1,499 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for 32-bit screen coordinates (scanline32_u) has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_SCANLINE_U_INCLUDED -#define AGG_SCANLINE_U_INCLUDED - -#include "agg_array.h" - -namespace agg -{ - //=============================================================scanline_u8 - // - // Unpacked scanline container class - // - // This class is used to transfer data from a scanline rasterizer - // to the rendering buffer. It's organized very simple. The class stores - // information of horizontal spans to render it into a pixel-map buffer. - // Each span has staring X, length, and an array of bytes that determine the - // cover-values for each pixel. - // Before using this class you should know the minimal and maximal pixel - // coordinates of your scanline. The protocol of using is: - // 1. reset(min_x, max_x) - // 2. add_cell() / add_span() - accumulate scanline. - // When forming one scanline the next X coordinate must be always greater - // than the last stored one, i.e. it works only with ordered coordinates. - // 3. Call finalize(y) and render the scanline. - // 3. Call reset_spans() to prepare for the new scanline. - // - // 4. Rendering: - // - // Scanline provides an iterator class that allows you to extract - // the spans and the cover values for each pixel. Be aware that clipping - // has not been done yet, so you should perform it yourself. - // Use scanline_u8::iterator to render spans: - //------------------------------------------------------------------------- - // - // int y = sl.y(); // Y-coordinate of the scanline - // - // ************************************ - // ...Perform vertical clipping here... - // ************************************ - // - // scanline_u8::const_iterator span = sl.begin(); - // - // unsigned char* row = m_rbuf->row(y); // The the address of the beginning - // // of the current row - // - // unsigned num_spans = sl.num_spans(); // Number of spans. It's guaranteed that - // // num_spans is always greater than 0. - // - // do - // { - // const scanline_u8::cover_type* covers = - // span->covers; // The array of the cover values - // - // int num_pix = span->len; // Number of pixels of the span. - // // Always greater than 0, still it's - // // better to use "int" instead of - // // "unsigned" because it's more - // // convenient for clipping - // int x = span->x; - // - // ************************************** - // ...Perform horizontal clipping here... - // ...you have x, covers, and pix_count.. - // ************************************** - // - // unsigned char* dst = row + x; // Calculate the start address of the row. - // // In this case we assume a simple - // // grayscale image 1-byte per pixel. - // do - // { - // *dst++ = *covers++; // Hypotetical rendering. - // } - // while(--num_pix); - // - // ++span; - // } - // while(--num_spans); // num_spans cannot be 0, so this loop is quite safe - //------------------------------------------------------------------------ - // - // The question is: why should we accumulate the whole scanline when we - // could render just separate spans when they're ready? - // That's because using the scanline is generally faster. When is consists - // of more than one span the conditions for the processor cash system - // are better, because switching between two different areas of memory - // (that can be very large) occurs less frequently. - //------------------------------------------------------------------------ - class scanline_u8 - { - public: - typedef scanline_u8 self_type; - typedef int8u cover_type; - typedef int16 coord_type; - - //-------------------------------------------------------------------- - struct span - { - coord_type x; - coord_type len; - cover_type* covers; - }; - - typedef span* iterator; - typedef const span* const_iterator; - - //-------------------------------------------------------------------- - scanline_u8() : - m_min_x(0), - m_last_x(0x7FFFFFF0), - m_cur_span(0) - {} - - //-------------------------------------------------------------------- - void reset(int min_x, int max_x) - { - unsigned max_len = max_x - min_x + 2; - if(max_len > m_spans.size()) - { - m_spans.resize(max_len); - m_covers.resize(max_len); - } - m_last_x = 0x7FFFFFF0; - m_min_x = min_x; - m_cur_span = &m_spans[0]; - } - - //-------------------------------------------------------------------- - void add_cell(int x, unsigned cover) - { - x -= m_min_x; - m_covers[x] = (cover_type)cover; - if(x == m_last_x+1) - { - m_cur_span->len++; - } - else - { - m_cur_span++; - m_cur_span->x = (coord_type)(x + m_min_x); - m_cur_span->len = 1; - m_cur_span->covers = &m_covers[x]; - } - m_last_x = x; - } - - //-------------------------------------------------------------------- - void add_cells(int x, unsigned len, const cover_type* covers) - { - x -= m_min_x; - memcpy(&m_covers[x], covers, len * sizeof(cover_type)); - if(x == m_last_x+1) - { - m_cur_span->len += (coord_type)len; - } - else - { - m_cur_span++; - m_cur_span->x = (coord_type)(x + m_min_x); - m_cur_span->len = (coord_type)len; - m_cur_span->covers = &m_covers[x]; - } - m_last_x = x + len - 1; - } - - //-------------------------------------------------------------------- - void add_span(int x, unsigned len, unsigned cover) - { - x -= m_min_x; - memset(&m_covers[x], cover, len); - if(x == m_last_x+1) - { - m_cur_span->len += (coord_type)len; - } - else - { - m_cur_span++; - m_cur_span->x = (coord_type)(x + m_min_x); - m_cur_span->len = (coord_type)len; - m_cur_span->covers = &m_covers[x]; - } - m_last_x = x + len - 1; - } - - //-------------------------------------------------------------------- - void finalize(int y) - { - m_y = y; - } - - //-------------------------------------------------------------------- - void reset_spans() - { - m_last_x = 0x7FFFFFF0; - m_cur_span = &m_spans[0]; - } - - //-------------------------------------------------------------------- - int y() const { return m_y; } - unsigned num_spans() const { return unsigned(m_cur_span - &m_spans[0]); } - const_iterator begin() const { return &m_spans[1]; } - iterator begin() { return &m_spans[1]; } - - private: - scanline_u8(const self_type&); - const self_type& operator = (const self_type&); - - private: - int m_min_x; - int m_last_x; - int m_y; - pod_array m_covers; - pod_array m_spans; - span* m_cur_span; - }; - - - - - //==========================================================scanline_u8_am - // - // The scanline container with alpha-masking - // - //------------------------------------------------------------------------ - template - class scanline_u8_am : public scanline_u8 - { - public: - typedef scanline_u8 base_type; - typedef AlphaMask alpha_mask_type; - typedef base_type::cover_type cover_type; - typedef base_type::coord_type coord_type; - - scanline_u8_am() : base_type(), m_alpha_mask(0) {} - scanline_u8_am(AlphaMask& am) : base_type(), m_alpha_mask(&am) {} - - //-------------------------------------------------------------------- - void finalize(int span_y) - { - base_type::finalize(span_y); - if(m_alpha_mask) - { - typename base_type::iterator span = base_type::begin(); - unsigned count = base_type::num_spans(); - do - { - m_alpha_mask->combine_hspan(span->x, - base_type::y(), - span->covers, - span->len); - ++span; - } - while(--count); - } - } - - private: - AlphaMask* m_alpha_mask; - }; - - - - - //===========================================================scanline32_u8 - class scanline32_u8 - { - public: - typedef scanline32_u8 self_type; - typedef int8u cover_type; - typedef int32 coord_type; - - //-------------------------------------------------------------------- - struct span - { - span() {} - span(coord_type x_, coord_type len_, cover_type* covers_) : - x(x_), len(len_), covers(covers_) {} - - coord_type x; - coord_type len; - cover_type* covers; - }; - - typedef pod_bvector span_array_type; - - //-------------------------------------------------------------------- - class const_iterator - { - public: - const_iterator(const span_array_type& spans) : - m_spans(spans), - m_span_idx(0) - {} - - const span& operator*() const { return m_spans[m_span_idx]; } - const span* operator->() const { return &m_spans[m_span_idx]; } - - void operator ++ () { ++m_span_idx; } - - private: - const span_array_type& m_spans; - unsigned m_span_idx; - }; - - //-------------------------------------------------------------------- - class iterator - { - public: - iterator(span_array_type& spans) : - m_spans(spans), - m_span_idx(0) - {} - - span& operator*() { return m_spans[m_span_idx]; } - span* operator->() { return &m_spans[m_span_idx]; } - - void operator ++ () { ++m_span_idx; } - - private: - span_array_type& m_spans; - unsigned m_span_idx; - }; - - - - //-------------------------------------------------------------------- - scanline32_u8() : - m_min_x(0), - m_last_x(0x7FFFFFF0), - m_covers() - {} - - //-------------------------------------------------------------------- - void reset(int min_x, int max_x) - { - unsigned max_len = max_x - min_x + 2; - if(max_len > m_covers.size()) - { - m_covers.resize(max_len); - } - m_last_x = 0x7FFFFFF0; - m_min_x = min_x; - m_spans.remove_all(); - } - - //-------------------------------------------------------------------- - void add_cell(int x, unsigned cover) - { - x -= m_min_x; - m_covers[x] = cover_type(cover); - if(x == m_last_x+1) - { - m_spans.last().len++; - } - else - { - m_spans.add(span(coord_type(x + m_min_x), 1, &m_covers[x])); - } - m_last_x = x; - } - - //-------------------------------------------------------------------- - void add_cells(int x, unsigned len, const cover_type* covers) - { - x -= m_min_x; - memcpy(&m_covers[x], covers, len * sizeof(cover_type)); - if(x == m_last_x+1) - { - m_spans.last().len += coord_type(len); - } - else - { - m_spans.add(span(coord_type(x + m_min_x), - coord_type(len), - &m_covers[x])); - } - m_last_x = x + len - 1; - } - - //-------------------------------------------------------------------- - void add_span(int x, unsigned len, unsigned cover) - { - x -= m_min_x; - memset(&m_covers[x], cover, len); - if(x == m_last_x+1) - { - m_spans.last().len += coord_type(len); - } - else - { - m_spans.add(span(coord_type(x + m_min_x), - coord_type(len), - &m_covers[x])); - } - m_last_x = x + len - 1; - } - - //-------------------------------------------------------------------- - void finalize(int y) - { - m_y = y; - } - - //-------------------------------------------------------------------- - void reset_spans() - { - m_last_x = 0x7FFFFFF0; - m_spans.remove_all(); - } - - //-------------------------------------------------------------------- - int y() const { return m_y; } - unsigned num_spans() const { return m_spans.size(); } - const_iterator begin() const { return const_iterator(m_spans); } - iterator begin() { return iterator(m_spans); } - - private: - scanline32_u8(const self_type&); - const self_type& operator = (const self_type&); - - private: - int m_min_x; - int m_last_x; - int m_y; - pod_array m_covers; - span_array_type m_spans; - }; - - - - - //========================================================scanline32_u8_am - // - // The scanline container with alpha-masking - // - //------------------------------------------------------------------------ - template - class scanline32_u8_am : public scanline32_u8 - { - public: - typedef scanline32_u8 base_type; - typedef AlphaMask alpha_mask_type; - typedef base_type::cover_type cover_type; - typedef base_type::coord_type coord_type; - - - scanline32_u8_am() : base_type(), m_alpha_mask(0) {} - scanline32_u8_am(AlphaMask& am) : base_type(), m_alpha_mask(&am) {} - - //-------------------------------------------------------------------- - void finalize(int span_y) - { - base_type::finalize(span_y); - if(m_alpha_mask) - { - typename base_type::iterator span = base_type::begin(); - unsigned count = base_type::num_spans(); - do - { - m_alpha_mask->combine_hspan(span->x, - base_type::y(), - span->covers, - span->len); - ++span; - } - while(--count); - } - } - - private: - AlphaMask* m_alpha_mask; - }; - - - -} - -#endif - diff --git a/xs/src/agg/agg_shorten_path.h b/xs/src/agg/agg_shorten_path.h deleted file mode 100644 index dd9929ff97..0000000000 --- a/xs/src/agg/agg_shorten_path.h +++ /dev/null @@ -1,66 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SHORTEN_PATH_INCLUDED -#define AGG_SHORTEN_PATH_INCLUDED - -#include "agg_basics.h" -#include "agg_vertex_sequence.h" - -namespace agg -{ - - //===========================================================shorten_path - template - void shorten_path(VertexSequence& vs, double s, unsigned closed = 0) - { - typedef typename VertexSequence::value_type vertex_type; - - if(s > 0.0 && vs.size() > 1) - { - double d; - int n = int(vs.size() - 2); - while(n) - { - d = vs[n].dist; - if(d > s) break; - vs.remove_last(); - s -= d; - --n; - } - if(vs.size() < 2) - { - vs.remove_all(); - } - else - { - n = vs.size() - 1; - vertex_type& prev = vs[n-1]; - vertex_type& last = vs[n]; - d = (prev.dist - s) / prev.dist; - double x = prev.x + (last.x - prev.x) * d; - double y = prev.y + (last.y - prev.y) * d; - last.x = x; - last.y = y; - if(!prev(last)) vs.remove_last(); - vs.close(closed != 0); - } - } - } - - -} - -#endif diff --git a/xs/src/agg/agg_simul_eq.h b/xs/src/agg/agg_simul_eq.h deleted file mode 100644 index 3d0dce4b44..0000000000 --- a/xs/src/agg/agg_simul_eq.h +++ /dev/null @@ -1,147 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Solving simultaneous equations -// -//---------------------------------------------------------------------------- -#ifndef AGG_SIMUL_EQ_INCLUDED -#define AGG_SIMUL_EQ_INCLUDED - -#include -#include "agg_basics.h" - -namespace agg -{ - - //=============================================================swap_arrays - template void swap_arrays(T* a1, T* a2, unsigned n) - { - unsigned i; - for(i = 0; i < n; i++) - { - T tmp = *a1; - *a1++ = *a2; - *a2++ = tmp; - } - } - - - //============================================================matrix_pivot - template - struct matrix_pivot - { - static int pivot(double m[Rows][Cols], unsigned row) - { - int k = int(row); - double max_val, tmp; - - max_val = -1.0; - unsigned i; - for(i = row; i < Rows; i++) - { - if((tmp = fabs(m[i][row])) > max_val && tmp != 0.0) - { - max_val = tmp; - k = i; - } - } - - if(m[k][row] == 0.0) - { - return -1; - } - - if(k != int(row)) - { - swap_arrays(m[k], m[row], Cols); - return k; - } - return 0; - } - }; - - - - //===============================================================simul_eq - template - struct simul_eq - { - static bool solve(const double left[Size][Size], - const double right[Size][RightCols], - double result[Size][RightCols]) - { - unsigned i, j, k; - double a1; - - double tmp[Size][Size + RightCols]; - - for(i = 0; i < Size; i++) - { - for(j = 0; j < Size; j++) - { - tmp[i][j] = left[i][j]; - } - for(j = 0; j < RightCols; j++) - { - tmp[i][Size + j] = right[i][j]; - } - } - - for(k = 0; k < Size; k++) - { - if(matrix_pivot::pivot(tmp, k) < 0) - { - return false; // Singularity.... - } - - a1 = tmp[k][k]; - - for(j = k; j < Size + RightCols; j++) - { - tmp[k][j] /= a1; - } - - for(i = k + 1; i < Size; i++) - { - a1 = tmp[i][k]; - for (j = k; j < Size + RightCols; j++) - { - tmp[i][j] -= a1 * tmp[k][j]; - } - } - } - - - for(k = 0; k < RightCols; k++) - { - int m; - for(m = int(Size - 1); m >= 0; m--) - { - result[m][k] = tmp[m][Size + k]; - for(j = m + 1; j < Size; j++) - { - result[m][k] -= tmp[m][j] * result[j][k]; - } - } - } - return true; - } - - }; - - -} - -#endif diff --git a/xs/src/agg/agg_span_allocator.h b/xs/src/agg/agg_span_allocator.h deleted file mode 100644 index 201b69bb01..0000000000 --- a/xs/src/agg/agg_span_allocator.h +++ /dev/null @@ -1,54 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_ALLOCATOR_INCLUDED -#define AGG_SPAN_ALLOCATOR_INCLUDED - -#include "agg_array.h" - -namespace agg -{ - //----------------------------------------------------------span_allocator - template class span_allocator - { - public: - typedef ColorT color_type; - - //-------------------------------------------------------------------- - AGG_INLINE color_type* allocate(unsigned span_len) - { - if(span_len > m_span.size()) - { - // To reduce the number of reallocs we align the - // span_len to 256 color elements. - // Well, I just like this number and it looks reasonable. - //----------------------- - m_span.resize(((span_len + 255) >> 8) << 8); - } - return &m_span[0]; - } - - AGG_INLINE color_type* span() { return &m_span[0]; } - AGG_INLINE unsigned max_span_len() const { return m_span.size(); } - - private: - pod_array m_span; - }; -} - - -#endif - - diff --git a/xs/src/agg/agg_span_converter.h b/xs/src/agg/agg_span_converter.h deleted file mode 100644 index 91d0f87c25..0000000000 --- a/xs/src/agg/agg_span_converter.h +++ /dev/null @@ -1,56 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_CONVERTER_INCLUDED -#define AGG_SPAN_CONVERTER_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - //----------------------------------------------------------span_converter - template class span_converter - { - public: - typedef typename SpanGenerator::color_type color_type; - - span_converter(SpanGenerator& span_gen, SpanConverter& span_cnv) : - m_span_gen(&span_gen), m_span_cnv(&span_cnv) {} - - void attach_generator(SpanGenerator& span_gen) { m_span_gen = &span_gen; } - void attach_converter(SpanConverter& span_cnv) { m_span_cnv = &span_cnv; } - - //-------------------------------------------------------------------- - void prepare() - { - m_span_gen->prepare(); - m_span_cnv->prepare(); - } - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - m_span_gen->generate(span, x, y, len); - m_span_cnv->generate(span, x, y, len); - } - - private: - SpanGenerator* m_span_gen; - SpanConverter* m_span_cnv; - }; - -} - -#endif diff --git a/xs/src/agg/agg_span_gouraud.h b/xs/src/agg/agg_span_gouraud.h deleted file mode 100644 index 2986c88fee..0000000000 --- a/xs/src/agg/agg_span_gouraud.h +++ /dev/null @@ -1,172 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_GOURAUD_INCLUDED -#define AGG_SPAN_GOURAUD_INCLUDED - -#include "agg_basics.h" -#include "agg_math.h" - -namespace agg -{ - - //============================================================span_gouraud - template class span_gouraud - { - public: - typedef ColorT color_type; - - struct coord_type - { - double x; - double y; - color_type color; - }; - - //-------------------------------------------------------------------- - span_gouraud() : - m_vertex(0) - { - m_cmd[0] = path_cmd_stop; - } - - //-------------------------------------------------------------------- - span_gouraud(const color_type& c1, - const color_type& c2, - const color_type& c3, - double x1, double y1, - double x2, double y2, - double x3, double y3, - double d) : - m_vertex(0) - { - colors(c1, c2, c3); - triangle(x1, y1, x2, y2, x3, y3, d); - } - - //-------------------------------------------------------------------- - void colors(ColorT c1, ColorT c2, ColorT c3) - { - m_coord[0].color = c1; - m_coord[1].color = c2; - m_coord[2].color = c3; - } - - //-------------------------------------------------------------------- - // Sets the triangle and dilates it if needed. - // The trick here is to calculate beveled joins in the vertices of the - // triangle and render it as a 6-vertex polygon. - // It's necessary to achieve numerical stability. - // However, the coordinates to interpolate colors are calculated - // as miter joins (calc_intersection). - void triangle(double x1, double y1, - double x2, double y2, - double x3, double y3, - double d) - { - m_coord[0].x = m_x[0] = x1; - m_coord[0].y = m_y[0] = y1; - m_coord[1].x = m_x[1] = x2; - m_coord[1].y = m_y[1] = y2; - m_coord[2].x = m_x[2] = x3; - m_coord[2].y = m_y[2] = y3; - m_cmd[0] = path_cmd_move_to; - m_cmd[1] = path_cmd_line_to; - m_cmd[2] = path_cmd_line_to; - m_cmd[3] = path_cmd_stop; - - if(d != 0.0) - { - dilate_triangle(m_coord[0].x, m_coord[0].y, - m_coord[1].x, m_coord[1].y, - m_coord[2].x, m_coord[2].y, - m_x, m_y, d); - - calc_intersection(m_x[4], m_y[4], m_x[5], m_y[5], - m_x[0], m_y[0], m_x[1], m_y[1], - &m_coord[0].x, &m_coord[0].y); - - calc_intersection(m_x[0], m_y[0], m_x[1], m_y[1], - m_x[2], m_y[2], m_x[3], m_y[3], - &m_coord[1].x, &m_coord[1].y); - - calc_intersection(m_x[2], m_y[2], m_x[3], m_y[3], - m_x[4], m_y[4], m_x[5], m_y[5], - &m_coord[2].x, &m_coord[2].y); - m_cmd[3] = path_cmd_line_to; - m_cmd[4] = path_cmd_line_to; - m_cmd[5] = path_cmd_line_to; - m_cmd[6] = path_cmd_stop; - } - } - - //-------------------------------------------------------------------- - // Vertex Source Interface to feed the coordinates to the rasterizer - void rewind(unsigned) - { - m_vertex = 0; - } - - //-------------------------------------------------------------------- - unsigned vertex(double* x, double* y) - { - *x = m_x[m_vertex]; - *y = m_y[m_vertex]; - return m_cmd[m_vertex++]; - } - - protected: - //-------------------------------------------------------------------- - void arrange_vertices(coord_type* coord) const - { - coord[0] = m_coord[0]; - coord[1] = m_coord[1]; - coord[2] = m_coord[2]; - - if(m_coord[0].y > m_coord[2].y) - { - coord[0] = m_coord[2]; - coord[2] = m_coord[0]; - } - - coord_type tmp; - if(coord[0].y > coord[1].y) - { - tmp = coord[1]; - coord[1] = coord[0]; - coord[0] = tmp; - } - - if(coord[1].y > coord[2].y) - { - tmp = coord[2]; - coord[2] = coord[1]; - coord[1] = tmp; - } - } - - private: - //-------------------------------------------------------------------- - coord_type m_coord[3]; - double m_x[8]; - double m_y[8]; - unsigned m_cmd[8]; - unsigned m_vertex; - }; - -} - -#endif - diff --git a/xs/src/agg/agg_span_gouraud_gray.h b/xs/src/agg/agg_span_gouraud_gray.h deleted file mode 100644 index d5fc39d102..0000000000 --- a/xs/src/agg/agg_span_gouraud_gray.h +++ /dev/null @@ -1,241 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_GOURAUD_GRAY_INCLUDED -#define AGG_SPAN_GOURAUD_GRAY_INCLUDED - -#include "agg_basics.h" -#include "agg_color_gray.h" -#include "agg_dda_line.h" -#include "agg_span_gouraud.h" - -namespace agg -{ - - //=======================================================span_gouraud_gray - template class span_gouraud_gray : public span_gouraud - { - public: - typedef ColorT color_type; - typedef typename color_type::value_type value_type; - typedef span_gouraud base_type; - typedef typename base_type::coord_type coord_type; - enum subpixel_scale_e - { - subpixel_shift = 4, - subpixel_scale = 1 << subpixel_shift - }; - - private: - //-------------------------------------------------------------------- - struct gray_calc - { - void init(const coord_type& c1, const coord_type& c2) - { - m_x1 = c1.x - 0.5; - m_y1 = c1.y - 0.5; - m_dx = c2.x - c1.x; - double dy = c2.y - c1.y; - m_1dy = (fabs(dy) < 1e-10) ? 1e10 : 1.0 / dy; - m_v1 = c1.color.v; - m_a1 = c1.color.a; - m_dv = c2.color.v - m_v1; - m_da = c2.color.a - m_a1; - } - - void calc(double y) - { - double k = (y - m_y1) * m_1dy; - if(k < 0.0) k = 0.0; - if(k > 1.0) k = 1.0; - m_v = m_v1 + iround(m_dv * k); - m_a = m_a1 + iround(m_da * k); - m_x = iround((m_x1 + m_dx * k) * subpixel_scale); - } - - double m_x1; - double m_y1; - double m_dx; - double m_1dy; - int m_v1; - int m_a1; - int m_dv; - int m_da; - int m_v; - int m_a; - int m_x; - }; - - - public: - //-------------------------------------------------------------------- - span_gouraud_gray() {} - span_gouraud_gray(const color_type& c1, - const color_type& c2, - const color_type& c3, - double x1, double y1, - double x2, double y2, - double x3, double y3, - double d = 0) : - base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d) - {} - - //-------------------------------------------------------------------- - void prepare() - { - coord_type coord[3]; - base_type::arrange_vertices(coord); - - m_y2 = int(coord[1].y); - - m_swap = cross_product(coord[0].x, coord[0].y, - coord[2].x, coord[2].y, - coord[1].x, coord[1].y) < 0.0; - - m_c1.init(coord[0], coord[2]); - m_c2.init(coord[0], coord[1]); - m_c3.init(coord[1], coord[2]); - } - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - m_c1.calc(y); - const gray_calc* pc1 = &m_c1; - const gray_calc* pc2 = &m_c2; - - if(y < m_y2) - { - // Bottom part of the triangle (first subtriangle) - //------------------------- - m_c2.calc(y + m_c2.m_1dy); - } - else - { - // Upper part (second subtriangle) - //------------------------- - m_c3.calc(y - m_c3.m_1dy); - pc2 = &m_c3; - } - - if(m_swap) - { - // It means that the triangle is oriented clockwise, - // so that we need to swap the controlling structures - //------------------------- - const gray_calc* t = pc2; - pc2 = pc1; - pc1 = t; - } - - // Get the horizontal length with subpixel accuracy - // and protect it from division by zero - //------------------------- - int nlen = abs(pc2->m_x - pc1->m_x); - if(nlen <= 0) nlen = 1; - - dda_line_interpolator<14> v(pc1->m_v, pc2->m_v, nlen); - dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen); - - // Calculate the starting point of the gradient with subpixel - // accuracy and correct (roll back) the interpolators. - // This operation will also clip the beginning of the span - // if necessary. - //------------------------- - int start = pc1->m_x - (x << subpixel_shift); - v -= start; - a -= start; - nlen += start; - - int vv, va; - enum lim_e { lim = color_type::base_mask }; - - // Beginning part of the span. Since we rolled back the - // interpolators, the color values may have overflow. - // So that, we render the beginning part with checking - // for overflow. It lasts until "start" is positive; - // typically it's 1-2 pixels, but may be more in some cases. - //------------------------- - while(len && start > 0) - { - vv = v.y(); - va = a.y(); - if(vv < 0) vv = 0; if(vv > lim) vv = lim; - if(va < 0) va = 0; if(va > lim) va = lim; - span->v = (value_type)vv; - span->a = (value_type)va; - v += subpixel_scale; - a += subpixel_scale; - nlen -= subpixel_scale; - start -= subpixel_scale; - ++span; - --len; - } - - // Middle part, no checking for overflow. - // Actual spans can be longer than the calculated length - // because of anti-aliasing, thus, the interpolators can - // overflow. But while "nlen" is positive we are safe. - //------------------------- - while(len && nlen > 0) - { - span->v = (value_type)v.y(); - span->a = (value_type)a.y(); - v += subpixel_scale; - a += subpixel_scale; - nlen -= subpixel_scale; - ++span; - --len; - } - - // Ending part; checking for overflow. - // Typically it's 1-2 pixels, but may be more in some cases. - //------------------------- - while(len) - { - vv = v.y(); - va = a.y(); - if(vv < 0) vv = 0; if(vv > lim) vv = lim; - if(va < 0) va = 0; if(va > lim) va = lim; - span->v = (value_type)vv; - span->a = (value_type)va; - v += subpixel_scale; - a += subpixel_scale; - ++span; - --len; - } - } - - - private: - bool m_swap; - int m_y2; - gray_calc m_c1; - gray_calc m_c2; - gray_calc m_c3; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_span_gouraud_rgba.h b/xs/src/agg/agg_span_gouraud_rgba.h deleted file mode 100644 index 89192d227b..0000000000 --- a/xs/src/agg/agg_span_gouraud_rgba.h +++ /dev/null @@ -1,277 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_GOURAUD_RGBA_INCLUDED -#define AGG_SPAN_GOURAUD_RGBA_INCLUDED - -#include "agg_basics.h" -#include "agg_color_rgba.h" -#include "agg_dda_line.h" -#include "agg_span_gouraud.h" - -namespace agg -{ - - //=======================================================span_gouraud_rgba - template class span_gouraud_rgba : public span_gouraud - { - public: - typedef ColorT color_type; - typedef typename ColorT::value_type value_type; - typedef span_gouraud base_type; - typedef typename base_type::coord_type coord_type; - enum subpixel_scale_e - { - subpixel_shift = 4, - subpixel_scale = 1 << subpixel_shift - }; - - private: - //-------------------------------------------------------------------- - struct rgba_calc - { - void init(const coord_type& c1, const coord_type& c2) - { - m_x1 = c1.x - 0.5; - m_y1 = c1.y - 0.5; - m_dx = c2.x - c1.x; - double dy = c2.y - c1.y; - m_1dy = (dy < 1e-5) ? 1e5 : 1.0 / dy; - m_r1 = c1.color.r; - m_g1 = c1.color.g; - m_b1 = c1.color.b; - m_a1 = c1.color.a; - m_dr = c2.color.r - m_r1; - m_dg = c2.color.g - m_g1; - m_db = c2.color.b - m_b1; - m_da = c2.color.a - m_a1; - } - - void calc(double y) - { - double k = (y - m_y1) * m_1dy; - if(k < 0.0) k = 0.0; - if(k > 1.0) k = 1.0; - m_r = m_r1 + iround(m_dr * k); - m_g = m_g1 + iround(m_dg * k); - m_b = m_b1 + iround(m_db * k); - m_a = m_a1 + iround(m_da * k); - m_x = iround((m_x1 + m_dx * k) * subpixel_scale); - } - - double m_x1; - double m_y1; - double m_dx; - double m_1dy; - int m_r1; - int m_g1; - int m_b1; - int m_a1; - int m_dr; - int m_dg; - int m_db; - int m_da; - int m_r; - int m_g; - int m_b; - int m_a; - int m_x; - }; - - public: - - //-------------------------------------------------------------------- - span_gouraud_rgba() {} - span_gouraud_rgba(const color_type& c1, - const color_type& c2, - const color_type& c3, - double x1, double y1, - double x2, double y2, - double x3, double y3, - double d = 0) : - base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d) - {} - - //-------------------------------------------------------------------- - void prepare() - { - coord_type coord[3]; - base_type::arrange_vertices(coord); - - m_y2 = int(coord[1].y); - - m_swap = cross_product(coord[0].x, coord[0].y, - coord[2].x, coord[2].y, - coord[1].x, coord[1].y) < 0.0; - - m_rgba1.init(coord[0], coord[2]); - m_rgba2.init(coord[0], coord[1]); - m_rgba3.init(coord[1], coord[2]); - } - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - m_rgba1.calc(y);//(m_rgba1.m_1dy > 2) ? m_rgba1.m_y1 : y); - const rgba_calc* pc1 = &m_rgba1; - const rgba_calc* pc2 = &m_rgba2; - - if(y <= m_y2) - { - // Bottom part of the triangle (first subtriangle) - //------------------------- - m_rgba2.calc(y + m_rgba2.m_1dy); - } - else - { - // Upper part (second subtriangle) - m_rgba3.calc(y - m_rgba3.m_1dy); - //------------------------- - pc2 = &m_rgba3; - } - - if(m_swap) - { - // It means that the triangle is oriented clockwise, - // so that we need to swap the controlling structures - //------------------------- - const rgba_calc* t = pc2; - pc2 = pc1; - pc1 = t; - } - - // Get the horizontal length with subpixel accuracy - // and protect it from division by zero - //------------------------- - int nlen = abs(pc2->m_x - pc1->m_x); - if(nlen <= 0) nlen = 1; - - dda_line_interpolator<14> r(pc1->m_r, pc2->m_r, nlen); - dda_line_interpolator<14> g(pc1->m_g, pc2->m_g, nlen); - dda_line_interpolator<14> b(pc1->m_b, pc2->m_b, nlen); - dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen); - - // Calculate the starting point of the gradient with subpixel - // accuracy and correct (roll back) the interpolators. - // This operation will also clip the beginning of the span - // if necessary. - //------------------------- - int start = pc1->m_x - (x << subpixel_shift); - r -= start; - g -= start; - b -= start; - a -= start; - nlen += start; - - int vr, vg, vb, va; - enum lim_e { lim = color_type::base_mask }; - - // Beginning part of the span. Since we rolled back the - // interpolators, the color values may have overflow. - // So that, we render the beginning part with checking - // for overflow. It lasts until "start" is positive; - // typically it's 1-2 pixels, but may be more in some cases. - //------------------------- - while(len && start > 0) - { - vr = r.y(); - vg = g.y(); - vb = b.y(); - va = a.y(); - if(vr < 0) vr = 0; if(vr > lim) vr = lim; - if(vg < 0) vg = 0; if(vg > lim) vg = lim; - if(vb < 0) vb = 0; if(vb > lim) vb = lim; - if(va < 0) va = 0; if(va > lim) va = lim; - span->r = (value_type)vr; - span->g = (value_type)vg; - span->b = (value_type)vb; - span->a = (value_type)va; - r += subpixel_scale; - g += subpixel_scale; - b += subpixel_scale; - a += subpixel_scale; - nlen -= subpixel_scale; - start -= subpixel_scale; - ++span; - --len; - } - - // Middle part, no checking for overflow. - // Actual spans can be longer than the calculated length - // because of anti-aliasing, thus, the interpolators can - // overflow. But while "nlen" is positive we are safe. - //------------------------- - while(len && nlen > 0) - { - span->r = (value_type)r.y(); - span->g = (value_type)g.y(); - span->b = (value_type)b.y(); - span->a = (value_type)a.y(); - r += subpixel_scale; - g += subpixel_scale; - b += subpixel_scale; - a += subpixel_scale; - nlen -= subpixel_scale; - ++span; - --len; - } - - // Ending part; checking for overflow. - // Typically it's 1-2 pixels, but may be more in some cases. - //------------------------- - while(len) - { - vr = r.y(); - vg = g.y(); - vb = b.y(); - va = a.y(); - if(vr < 0) vr = 0; if(vr > lim) vr = lim; - if(vg < 0) vg = 0; if(vg > lim) vg = lim; - if(vb < 0) vb = 0; if(vb > lim) vb = lim; - if(va < 0) va = 0; if(va > lim) va = lim; - span->r = (value_type)vr; - span->g = (value_type)vg; - span->b = (value_type)vb; - span->a = (value_type)va; - r += subpixel_scale; - g += subpixel_scale; - b += subpixel_scale; - a += subpixel_scale; - ++span; - --len; - } - } - - private: - bool m_swap; - int m_y2; - rgba_calc m_rgba1; - rgba_calc m_rgba2; - rgba_calc m_rgba3; - }; - - - -} - -#endif diff --git a/xs/src/agg/agg_span_gradient.h b/xs/src/agg/agg_span_gradient.h deleted file mode 100644 index 58b506dcfe..0000000000 --- a/xs/src/agg/agg_span_gradient.h +++ /dev/null @@ -1,377 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_GRADIENT_INCLUDED -#define AGG_SPAN_GRADIENT_INCLUDED - -#include -#include -#include -#include "agg_basics.h" -#include "agg_math.h" -#include "agg_array.h" - - -namespace agg -{ - - enum gradient_subpixel_scale_e - { - gradient_subpixel_shift = 4, //-----gradient_subpixel_shift - gradient_subpixel_scale = 1 << gradient_subpixel_shift, //-----gradient_subpixel_scale - gradient_subpixel_mask = gradient_subpixel_scale - 1 //-----gradient_subpixel_mask - }; - - - - //==========================================================span_gradient - template - class span_gradient - { - public: - typedef Interpolator interpolator_type; - typedef ColorT color_type; - - enum downscale_shift_e - { - downscale_shift = interpolator_type::subpixel_shift - - gradient_subpixel_shift - }; - - //-------------------------------------------------------------------- - span_gradient() {} - - //-------------------------------------------------------------------- - span_gradient(interpolator_type& inter, - GradientF& gradient_function, - ColorF& color_function, - double d1, double d2) : - m_interpolator(&inter), - m_gradient_function(&gradient_function), - m_color_function(&color_function), - m_d1(iround(d1 * gradient_subpixel_scale)), - m_d2(iround(d2 * gradient_subpixel_scale)) - {} - - //-------------------------------------------------------------------- - interpolator_type& interpolator() { return *m_interpolator; } - const GradientF& gradient_function() const { return *m_gradient_function; } - const ColorF& color_function() const { return *m_color_function; } - double d1() const { return double(m_d1) / gradient_subpixel_scale; } - double d2() const { return double(m_d2) / gradient_subpixel_scale; } - - //-------------------------------------------------------------------- - void interpolator(interpolator_type& i) { m_interpolator = &i; } - void gradient_function(GradientF& gf) { m_gradient_function = &gf; } - void color_function(ColorF& cf) { m_color_function = &cf; } - void d1(double v) { m_d1 = iround(v * gradient_subpixel_scale); } - void d2(double v) { m_d2 = iround(v * gradient_subpixel_scale); } - - //-------------------------------------------------------------------- - void prepare() {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - int dd = m_d2 - m_d1; - if(dd < 1) dd = 1; - m_interpolator->begin(x+0.5, y+0.5, len); - do - { - m_interpolator->coordinates(&x, &y); - int d = m_gradient_function->calculate(x >> downscale_shift, - y >> downscale_shift, m_d2); - d = ((d - m_d1) * (int)m_color_function->size()) / dd; - if(d < 0) d = 0; - if(d >= (int)m_color_function->size()) d = m_color_function->size() - 1; - *span++ = (*m_color_function)[d]; - ++(*m_interpolator); - } - while(--len); - } - - private: - interpolator_type* m_interpolator; - GradientF* m_gradient_function; - ColorF* m_color_function; - int m_d1; - int m_d2; - }; - - - - - //=====================================================gradient_linear_color - template - struct gradient_linear_color - { - typedef ColorT color_type; - - gradient_linear_color() {} - gradient_linear_color(const color_type& c1, const color_type& c2, - unsigned size = 256) : - m_c1(c1), m_c2(c2), m_size(size) - // VFALCO 4/28/09 - ,m_mult(1/(double(size)-1)) - // VFALCO - {} - - unsigned size() const { return m_size; } - color_type operator [] (unsigned v) const - { - // VFALCO 4/28/09 - //return m_c1.gradient(m_c2, double(v) / double(m_size - 1)); - return m_c1.gradient(m_c2, double(v) * m_mult ); - // VFALCO - } - - void colors(const color_type& c1, const color_type& c2, unsigned size = 256) - { - m_c1 = c1; - m_c2 = c2; - m_size = size; - // VFALCO 4/28/09 - m_mult=1/(double(size)-1); - // VFALCO - } - - color_type m_c1; - color_type m_c2; - unsigned m_size; - // VFALCO 4/28/09 - double m_mult; - // VFALCO - }; - - - - - - - //==========================================================gradient_circle - class gradient_circle - { - // Actually the same as radial. Just for compatibility - public: - static AGG_INLINE int calculate(int x, int y, int) - { - return int(fast_sqrt(x*x + y*y)); - } - }; - - - //==========================================================gradient_radial - class gradient_radial - { - public: - static AGG_INLINE int calculate(int x, int y, int) - { - return int(fast_sqrt(x*x + y*y)); - } - }; - - //========================================================gradient_radial_d - class gradient_radial_d - { - public: - static AGG_INLINE int calculate(int x, int y, int) - { - return uround(sqrt(double(x)*double(x) + double(y)*double(y))); - } - }; - - //====================================================gradient_radial_focus - class gradient_radial_focus - { - public: - //--------------------------------------------------------------------- - gradient_radial_focus() : - m_r(100 * gradient_subpixel_scale), - m_fx(0), - m_fy(0) - { - update_values(); - } - - //--------------------------------------------------------------------- - gradient_radial_focus(double r, double fx, double fy) : - m_r (iround(r * gradient_subpixel_scale)), - m_fx(iround(fx * gradient_subpixel_scale)), - m_fy(iround(fy * gradient_subpixel_scale)) - { - update_values(); - } - - //--------------------------------------------------------------------- - void init(double r, double fx, double fy) - { - m_r = iround(r * gradient_subpixel_scale); - m_fx = iround(fx * gradient_subpixel_scale); - m_fy = iround(fy * gradient_subpixel_scale); - update_values(); - } - - //--------------------------------------------------------------------- - double radius() const { return double(m_r) / gradient_subpixel_scale; } - double focus_x() const { return double(m_fx) / gradient_subpixel_scale; } - double focus_y() const { return double(m_fy) / gradient_subpixel_scale; } - - //--------------------------------------------------------------------- - int calculate(int x, int y, int) const - { - double dx = x - m_fx; - double dy = y - m_fy; - double d2 = dx * m_fy - dy * m_fx; - double d3 = m_r2 * (dx * dx + dy * dy) - d2 * d2; - return iround((dx * m_fx + dy * m_fy + sqrt(fabs(d3))) * m_mul); - } - - private: - //--------------------------------------------------------------------- - void update_values() - { - // Calculate the invariant values. In case the focal center - // lies exactly on the gradient circle the divisor degenerates - // into zero. In this case we just move the focal center by - // one subpixel unit possibly in the direction to the origin (0,0) - // and calculate the values again. - //------------------------- - m_r2 = double(m_r) * double(m_r); - m_fx2 = double(m_fx) * double(m_fx); - m_fy2 = double(m_fy) * double(m_fy); - double d = (m_r2 - (m_fx2 + m_fy2)); - if(d == 0) - { - if(m_fx) { if(m_fx < 0) ++m_fx; else --m_fx; } - if(m_fy) { if(m_fy < 0) ++m_fy; else --m_fy; } - m_fx2 = double(m_fx) * double(m_fx); - m_fy2 = double(m_fy) * double(m_fy); - d = (m_r2 - (m_fx2 + m_fy2)); - } - m_mul = m_r / d; - } - - int m_r; - int m_fx; - int m_fy; - double m_r2; - double m_fx2; - double m_fy2; - double m_mul; - }; - - - //==============================================================gradient_x - class gradient_x - { - public: - static int calculate(int x, int, int) { return x; } - }; - - - //==============================================================gradient_y - class gradient_y - { - public: - static int calculate(int, int y, int) { return y; } - }; - - //========================================================gradient_diamond - class gradient_diamond - { - public: - static AGG_INLINE int calculate(int x, int y, int) - { - int ax = abs(x); - int ay = abs(y); - return ax > ay ? ax : ay; - } - }; - - //=============================================================gradient_xy - class gradient_xy - { - public: - static AGG_INLINE int calculate(int x, int y, int d) - { - return abs(x) * abs(y) / d; - } - }; - - //========================================================gradient_sqrt_xy - class gradient_sqrt_xy - { - public: - static AGG_INLINE int calculate(int x, int y, int) - { - return fast_sqrt(abs(x) * abs(y)); - } - }; - - //==========================================================gradient_conic - class gradient_conic - { - public: - static AGG_INLINE int calculate(int x, int y, int d) - { - return uround(fabs(atan2(double(y), double(x))) * double(d) / pi); - } - }; - - //=================================================gradient_repeat_adaptor - template class gradient_repeat_adaptor - { - public: - gradient_repeat_adaptor(const GradientF& gradient) : - m_gradient(&gradient) {} - - AGG_INLINE int calculate(int x, int y, int d) const - { - int ret = m_gradient->calculate(x, y, d) % d; - if(ret < 0) ret += d; - return ret; - } - - private: - const GradientF* m_gradient; - }; - - //================================================gradient_reflect_adaptor - template class gradient_reflect_adaptor - { - public: - gradient_reflect_adaptor(const GradientF& gradient) : - m_gradient(&gradient) {} - - AGG_INLINE int calculate(int x, int y, int d) const - { - int d2 = d << 1; - int ret = m_gradient->calculate(x, y, d) % d2; - if(ret < 0) ret += d2; - if(ret >= d) ret = d2 - ret; - return ret; - } - - private: - const GradientF* m_gradient; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_span_gradient_alpha.h b/xs/src/agg/agg_span_gradient_alpha.h deleted file mode 100644 index 2ec040e3b9..0000000000 --- a/xs/src/agg/agg_span_gradient_alpha.h +++ /dev/null @@ -1,126 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_GRADIENT_ALPHA_INCLUDED -#define AGG_SPAN_GRADIENT_ALPHA_INCLUDED - -#include "agg_span_gradient.h" - -namespace agg -{ - //======================================================span_gradient_alpha - template - class span_gradient_alpha - { - public: - typedef Interpolator interpolator_type; - typedef ColorT color_type; - typedef typename color_type::value_type alpha_type; - - enum downscale_shift_e - { - downscale_shift = interpolator_type::subpixel_shift - gradient_subpixel_shift - }; - - - //-------------------------------------------------------------------- - span_gradient_alpha() {} - - //-------------------------------------------------------------------- - span_gradient_alpha(interpolator_type& inter, - GradientF& gradient_function, - AlphaF& alpha_function, - double d1, double d2) : - m_interpolator(&inter), - m_gradient_function(&gradient_function), - m_alpha_function(&alpha_function), - m_d1(iround(d1 * gradient_subpixel_scale)), - m_d2(iround(d2 * gradient_subpixel_scale)) - {} - - //-------------------------------------------------------------------- - interpolator_type& interpolator() { return *m_interpolator; } - const GradientF& gradient_function() const { return *m_gradient_function; } - const AlphaF& alpha_function() const { return *m_alpha_function; } - double d1() const { return double(m_d1) / gradient_subpixel_scale; } - double d2() const { return double(m_d2) / gradient_subpixel_scale; } - - //-------------------------------------------------------------------- - void interpolator(interpolator_type& i) { m_interpolator = &i; } - void gradient_function(const GradientF& gf) { m_gradient_function = &gf; } - void alpha_function(const AlphaF& af) { m_alpha_function = ⁡ } - void d1(double v) { m_d1 = iround(v * gradient_subpixel_scale); } - void d2(double v) { m_d2 = iround(v * gradient_subpixel_scale); } - - //-------------------------------------------------------------------- - void prepare() {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - int dd = m_d2 - m_d1; - if(dd < 1) dd = 1; - m_interpolator->begin(x+0.5, y+0.5, len); - do - { - m_interpolator->coordinates(&x, &y); - int d = m_gradient_function->calculate(x >> downscale_shift, - y >> downscale_shift, m_d2); - d = ((d - m_d1) * (int)m_alpha_function->size()) / dd; - if(d < 0) d = 0; - if(d >= (int)m_alpha_function->size()) d = m_alpha_function->size() - 1; - span->a = (*m_alpha_function)[d]; - ++span; - ++(*m_interpolator); - } - while(--len); - } - - private: - interpolator_type* m_interpolator; - GradientF* m_gradient_function; - AlphaF* m_alpha_function; - int m_d1; - int m_d2; - }; - - - //=======================================================gradient_alpha_x - template struct gradient_alpha_x - { - typedef typename ColorT::value_type alpha_type; - alpha_type operator [] (alpha_type x) const { return x; } - }; - - //====================================================gradient_alpha_x_u8 - struct gradient_alpha_x_u8 - { - typedef int8u alpha_type; - alpha_type operator [] (alpha_type x) const { return x; } - }; - - //==========================================gradient_alpha_one_munus_x_u8 - struct gradient_alpha_one_munus_x_u8 - { - typedef int8u alpha_type; - alpha_type operator [] (alpha_type x) const { return 255-x; } - }; - -} - -#endif diff --git a/xs/src/agg/agg_span_gradient_contour.h b/xs/src/agg/agg_span_gradient_contour.h deleted file mode 100644 index a1c4ca3773..0000000000 --- a/xs/src/agg/agg_span_gradient_contour.h +++ /dev/null @@ -1,362 +0,0 @@ -//---------------------------------------------------------------------------- -// AGG Contribution Pack - Gradients 1 (AGG CP - Gradients 1) -// http://milan.marusinec.sk/aggcp -// -// For Anti-Grain Geometry - Version 2.4 -// http://www.antigrain.org -// -// Contribution Created By: -// Milan Marusinec alias Milano -// milan@marusinec.sk -// Copyright (c) 2007-2008 -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -// [History] ----------------------------------------------------------------- -// -// 02.02.2008-Milano: Ported from Object Pascal code of AggPas -// -#ifndef AGG_SPAN_GRADIENT_CONTOUR_INCLUDED -#define AGG_SPAN_GRADIENT_CONTOUR_INCLUDED - -#include "agg_basics.h" -#include "agg_trans_affine.h" -#include "agg_path_storage.h" -#include "agg_pixfmt_gray.h" -#include "agg_conv_transform.h" -#include "agg_conv_curve.h" -#include "agg_bounding_rect.h" -#include "agg_renderer_base.h" -#include "agg_renderer_primitives.h" -#include "agg_rasterizer_outline.h" -#include "agg_span_gradient.h" - -#include - -namespace agg -{ - - //==========================================================gradient_contour - class gradient_contour - { - private: - int8u* m_buffer; - int m_width; - int m_height; - int m_frame; - - double m_d1; - double m_d2; - - public: - gradient_contour() : - m_buffer(NULL), - m_width(0), - m_height(0), - m_frame(10), - m_d1(0), - m_d2(100) - { - } - - gradient_contour(double d1, double d2) : - m_buffer(NULL), - m_width(0), - m_height(0), - m_frame(10), - m_d1(d1), - m_d2(d2) - { - } - - ~gradient_contour() - { - if (m_buffer) - { - delete [] m_buffer; - } - } - - int8u* contour_create(path_storage* ps ); - - int contour_width() { return m_width; } - int contour_height() { return m_height; } - - void d1(double d ) { m_d1 = d; } - void d2(double d ) { m_d2 = d; } - - void frame(int f ) { m_frame = f; } - int frame() { return m_frame; } - - int calculate(int x, int y, int d) const - { - if (m_buffer) - { - int px = x >> agg::gradient_subpixel_shift; - int py = y >> agg::gradient_subpixel_shift; - - px %= m_width; - - if (px < 0) - { - px += m_width; - } - - py %= m_height; - - if (py < 0 ) - { - py += m_height; - } - - return iround(m_buffer[py * m_width + px ] * (m_d2 / 256 ) + m_d1 ) << gradient_subpixel_shift; - - } - else - { - return 0; - } - } - - }; - - static AGG_INLINE int square(int x ) { return x * x; } - - // DT algorithm by: Pedro Felzenszwalb - void dt(float* spanf, float* spang, float* spanr, int* spann ,int length ) - { - int k = 0; - float s; - - spann[0 ] = 0; - spang[0 ] = -FLT_MAX; - spang[1 ] = FLT_MAX; - - for (int q = 1; q <= length - 1; q++) - { - s = ((spanf[q ] + square(q ) ) - (spanf[spann[k ] ] + square(spann[k ] ) ) ) / (2 * q - 2 * spann[k ] ); - - while (s <= spang[k ]) - { - k--; - s = ((spanf[q ] + square(q ) ) - (spanf[spann[k ] ] + square(spann[k ] ) ) ) / (2 * q - 2 * spann[k ] ); - } - - k++; - spann[k ] = q; - spang[k ] = s; - spang[k + 1 ] = FLT_MAX; - - } - - k = 0; - - for (int q = 0; q <= length - 1; q++) - { - while (spang[k + 1 ] < q ) - { - k++; - } - - spanr[q ] = square(q - spann[k ] ) + spanf[spann[k ] ]; - } - } - - // DT algorithm by: Pedro Felzenszwalb - int8u* gradient_contour::contour_create(path_storage* ps ) - { - int8u* result = NULL; - - if (ps) - { - // I. Render Black And White NonAA Stroke of the Path - // Path Bounding Box + Some Frame Space Around [configurable] - agg::conv_curve conv(*ps); - - double x1, y1, x2, y2; - - if (agg::bounding_rect_single(conv ,0 ,&x1 ,&y1 ,&x2 ,&y2 )) - { - // Create BW Rendering Surface - int width = int(ceil(x2 - x1 ) ) + m_frame * 2 + 1; - int height = int(ceil(y2 - y1 ) ) + m_frame * 2 + 1; - - int8u* buffer = new int8u[width * height]; - - if (buffer) - { - memset(buffer ,255 ,width * height ); - - // Setup VG Engine & Render - agg::rendering_buffer rb; - rb.attach(buffer ,width ,height ,width ); - - agg::pixfmt_gray8 pf(rb); - agg::renderer_base renb(pf ); - - agg::renderer_primitives > prim(renb ); - agg::rasterizer_outline > > ras(prim ); - - agg::trans_affine mtx; - mtx *= agg::trans_affine_translation(-x1 + m_frame, -y1 + m_frame ); - - agg::conv_transform > trans(conv ,mtx ); - - prim.line_color(agg::rgba8(0 ,0 ,0 ,255 ) ); - ras.add_path(trans ); - - // II. Distance Transform - // Create Float Buffer + 0 vs infinity assignment - float* image = new float[width * height]; - - if (image) - { - for (int y = 0, l = 0; y < height; y++ ) - { - for (int x = 0; x < width; x++, l++ ) - { - if (buffer[l ] == 0) - { - image[l ] = 0.0; - } - else - { - image[l ] = FLT_MAX; - } - } - - } - - // DT of 2d - // SubBuff max width,height - int length = width; - - if (height > length) - { - length = height; - } - - float* spanf = new float[length]; - float* spang = new float[length + 1]; - float* spanr = new float[length]; - int* spann = new int[length]; - - if ((spanf) && (spang) && (spanr) && (spann)) - { - // Transform along columns - for (int x = 0; x < width; x++ ) - { - for (int y = 0; y < height; y++ ) - { - spanf[y] = image[y * width + x]; - } - - // DT of 1d - dt(spanf ,spang ,spanr ,spann ,height ); - - for (int y = 0; y < height; y++ ) - { - image[y * width + x] = spanr[y]; - } - } - - // Transform along rows - for (int y = 0; y < height; y++ ) - { - for (int x = 0; x < width; x++ ) - { - spanf[x] = image[y * width + x]; - } - - // DT of 1d - dt(spanf ,spang ,spanr ,spann ,width ); - - for (int x = 0; x < width; x++ ) - { - image[y * width + x] = spanr[x]; - } - } - - // Take Square Roots, Min & Max - float min = sqrt(image[0] ); - float max = min; - - for (int y = 0, l = 0; y < height; y++ ) - { - for (int x = 0; x < width; x++, l++ ) - { - image[l] = sqrt(image[l]); - - if (min > image[l]) - { - min = image[l]; - } - - if (max < image[l]) - { - max = image[l]; - } - - } - } - - // III. Convert To Grayscale - if (min == max) - { - memset(buffer ,0 ,width * height ); - } - else - { - float scale = 255 / (max - min ); - - for (int y = 0, l = 0; y < height; y++ ) - { - for (int x = 0; x < width; x++ ,l++ ) - { - buffer[l] = int8u(int((image[l] - min ) * scale )); - } - } - } - - // OK - if (m_buffer) - { - delete [] m_buffer; - } - - m_buffer = buffer; - m_width = width; - m_height = height; - - buffer = NULL; - result = m_buffer; - - } - - if (spanf) { delete [] spanf; } - if (spang) { delete [] spang; } - if (spanr) { delete [] spanr; } - if (spann) { delete [] spann; } - - delete [] image; - - } - } - - if (buffer) - { - delete [] buffer; - } - - } - - } - return result; - } - -} - -#endif diff --git a/xs/src/agg/agg_span_gradient_image.h b/xs/src/agg/agg_span_gradient_image.h deleted file mode 100644 index c99eaca166..0000000000 --- a/xs/src/agg/agg_span_gradient_image.h +++ /dev/null @@ -1,188 +0,0 @@ -//---------------------------------------------------------------------------- -// AGG Contribution Pack - Gradients 1 (AGG CP - Gradients 1) -// http://milan.marusinec.sk/aggcp -// -// For Anti-Grain Geometry - Version 2.4 -// http://www.antigrain.org -// -// Contribution Created By: -// Milan Marusinec alias Milano -// milan@marusinec.sk -// Copyright (c) 2007-2008 -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -// [History] ----------------------------------------------------------------- -// -// 03.02.2008-Milano: Ported from Object Pascal code of AggPas -// -#ifndef AGG_SPAN_GRADIENT_IMAGE_INCLUDED -#define AGG_SPAN_GRADIENT_IMAGE_INCLUDED - -#include "agg_basics.h" -#include "agg_span_gradient.h" -#include "agg_color_rgba.h" -#include "agg_rendering_buffer.h" -#include "agg_pixfmt_rgba.h" - -namespace agg -{ - - //==========================================================one_color_function - template class one_color_function - { - public: - typedef ColorT color_type; - - color_type m_color; - - one_color_function() : - m_color() - { - } - - static unsigned size() { return 1; } - - const color_type& operator [] (unsigned i) const - { - return m_color; - } - - color_type* operator [] (unsigned i) - { - return &m_color; - } - }; - - //==========================================================gradient_image - template class gradient_image - { - private: - //------------ fields - typedef ColorT color_type; - typedef agg::pixfmt_rgba32 pixfmt_type; - - agg::rgba8* m_buffer; - - int m_alocdx; - int m_alocdy; - int m_width; - int m_height; - - color_type* m_color; - - one_color_function m_color_function; - - public: - gradient_image() : - m_color_function(), - m_buffer(NULL), - m_alocdx(0), - m_alocdy(0), - m_width(0), - m_height(0) - { - m_color = m_color_function[0 ]; - } - - ~gradient_image() - { - if (m_buffer) { delete [] m_buffer; } - } - - void* image_create(int width, int height ) - { - void* result = NULL; - - if (width > m_alocdx || height > m_alocdy) - { - if (m_buffer) { delete [] m_buffer; } - - m_buffer = NULL; - m_buffer = new agg::rgba8[width * height]; - - if (m_buffer) - { - m_alocdx = width; - m_alocdy = height; - } - else - { - m_alocdx = 0; - m_alocdy = 0; - }; - }; - - if (m_buffer) - { - m_width = width; - m_height = height; - - for (int rows = 0; rows < height; rows++) - { - agg::rgba8* row = &m_buffer[rows * m_alocdx ]; - memset(row ,0 ,m_width * 4 ); - }; - - result = m_buffer; - }; - return result; - } - - void* image_buffer() { return m_buffer; } - int image_width() { return m_width; } - int image_height() { return m_height; } - int image_stride() { return m_alocdx * 4; } - - int calculate(int x, int y, int d) const - { - if (m_buffer) - { - int px = x >> agg::gradient_subpixel_shift; - int py = y >> agg::gradient_subpixel_shift; - - px %= m_width; - - if (px < 0) - { - px += m_width; - } - - py %= m_height; - - if (py < 0 ) - { - py += m_height; - } - - rgba8* pixel = &m_buffer[py * m_alocdx + px ]; - - m_color->r = pixel->r; - m_color->g = pixel->g; - m_color->b = pixel->b; - m_color->a = pixel->a; - - } - else - { - m_color->r = 0; - m_color->g = 0; - m_color->b = 0; - m_color->a = 0; - } - return 0; - } - - const one_color_function& color_function() const - { - return m_color_function; - } - - }; - -} - -#endif diff --git a/xs/src/agg/agg_span_image_filter.h b/xs/src/agg/agg_span_image_filter.h deleted file mode 100644 index 9d0a10a52c..0000000000 --- a/xs/src/agg/agg_span_image_filter.h +++ /dev/null @@ -1,247 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Image transformations with filtering. Span generator base class -// -//---------------------------------------------------------------------------- -#ifndef AGG_SPAN_IMAGE_FILTER_INCLUDED -#define AGG_SPAN_IMAGE_FILTER_INCLUDED - -#include "agg_basics.h" -#include "agg_image_filters.h" -#include "agg_span_interpolator_linear.h" - -namespace agg -{ - - //-------------------------------------------------------span_image_filter - template class span_image_filter - { - public: - typedef Source source_type; - typedef Interpolator interpolator_type; - - //-------------------------------------------------------------------- - span_image_filter() {} - span_image_filter(source_type& src, - interpolator_type& interpolator, - image_filter_lut* filter) : - m_src(&src), - m_interpolator(&interpolator), - m_filter(filter), - m_dx_dbl(0.5), - m_dy_dbl(0.5), - m_dx_int(image_subpixel_scale / 2), - m_dy_int(image_subpixel_scale / 2) - {} - void attach(source_type& v) { m_src = &v; } - - //-------------------------------------------------------------------- - source_type& source() { return *m_src; } - const source_type& source() const { return *m_src; } - const image_filter_lut& filter() const { return *m_filter; } - int filter_dx_int() const { return m_dx_int; } - int filter_dy_int() const { return m_dy_int; } - double filter_dx_dbl() const { return m_dx_dbl; } - double filter_dy_dbl() const { return m_dy_dbl; } - - //-------------------------------------------------------------------- - void interpolator(interpolator_type& v) { m_interpolator = &v; } - void filter(image_filter_lut& v) { m_filter = &v; } - void filter_offset(double dx, double dy) - { - m_dx_dbl = dx; - m_dy_dbl = dy; - m_dx_int = iround(dx * image_subpixel_scale); - m_dy_int = iround(dy * image_subpixel_scale); - } - void filter_offset(double d) { filter_offset(d, d); } - - //-------------------------------------------------------------------- - interpolator_type& interpolator() { return *m_interpolator; } - - //-------------------------------------------------------------------- - void prepare() {} - - //-------------------------------------------------------------------- - private: - source_type* m_src; - interpolator_type* m_interpolator; - image_filter_lut* m_filter; - double m_dx_dbl; - double m_dy_dbl; - unsigned m_dx_int; - unsigned m_dy_int; - }; - - - - - //==============================================span_image_resample_affine - template - class span_image_resample_affine : - public span_image_filter > - { - public: - typedef Source source_type; - typedef span_interpolator_linear interpolator_type; - typedef span_image_filter base_type; - - //-------------------------------------------------------------------- - span_image_resample_affine() : - m_scale_limit(200.0), - m_blur_x(1.0), - m_blur_y(1.0) - {} - - //-------------------------------------------------------------------- - span_image_resample_affine(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, &filter), - m_scale_limit(200.0), - m_blur_x(1.0), - m_blur_y(1.0) - {} - - - //-------------------------------------------------------------------- - int scale_limit() const { return uround(m_scale_limit); } - void scale_limit(int v) { m_scale_limit = v; } - - //-------------------------------------------------------------------- - double blur_x() const { return m_blur_x; } - double blur_y() const { return m_blur_y; } - void blur_x(double v) { m_blur_x = v; } - void blur_y(double v) { m_blur_y = v; } - void blur(double v) { m_blur_x = m_blur_y = v; } - - //-------------------------------------------------------------------- - void prepare() - { - double scale_x; - double scale_y; - - base_type::interpolator().transformer().scaling_abs(&scale_x, &scale_y); - - double scale_xy = scale_x * scale_y; - if (scale_xy > m_scale_limit) - { - scale_x = scale_x * m_scale_limit / scale_xy; - scale_y = scale_y * m_scale_limit / scale_xy; - } - - if(scale_x < 1) scale_x = 1; - if(scale_y < 1) scale_y = 1; - - if(scale_x > m_scale_limit) scale_x = m_scale_limit; - if(scale_y > m_scale_limit) scale_y = m_scale_limit; - - scale_x *= m_blur_x; - scale_y *= m_blur_y; - - if(scale_x < 1) scale_x = 1; - if(scale_y < 1) scale_y = 1; - - m_rx = uround( scale_x * double(image_subpixel_scale)); - m_rx_inv = uround(1.0/scale_x * double(image_subpixel_scale)); - - m_ry = uround( scale_y * double(image_subpixel_scale)); - m_ry_inv = uround(1.0/scale_y * double(image_subpixel_scale)); - } - - protected: - int m_rx; - int m_ry; - int m_rx_inv; - int m_ry_inv; - - private: - double m_scale_limit; - double m_blur_x; - double m_blur_y; - }; - - - - //=====================================================span_image_resample - template - class span_image_resample : - public span_image_filter - { - public: - typedef Source source_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - - //-------------------------------------------------------------------- - span_image_resample() : - m_scale_limit(20), - m_blur_x(image_subpixel_scale), - m_blur_y(image_subpixel_scale) - {} - - //-------------------------------------------------------------------- - span_image_resample(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, &filter), - m_scale_limit(20), - m_blur_x(image_subpixel_scale), - m_blur_y(image_subpixel_scale) - {} - - //-------------------------------------------------------------------- - int scale_limit() const { return m_scale_limit; } - void scale_limit(int v) { m_scale_limit = v; } - - //-------------------------------------------------------------------- - double blur_x() const { return double(m_blur_x) / double(image_subpixel_scale); } - double blur_y() const { return double(m_blur_y) / double(image_subpixel_scale); } - void blur_x(double v) { m_blur_x = uround(v * double(image_subpixel_scale)); } - void blur_y(double v) { m_blur_y = uround(v * double(image_subpixel_scale)); } - void blur(double v) { m_blur_x = - m_blur_y = uround(v * double(image_subpixel_scale)); } - - protected: - AGG_INLINE void adjust_scale(int* rx, int* ry) - { - if(*rx < image_subpixel_scale) *rx = image_subpixel_scale; - if(*ry < image_subpixel_scale) *ry = image_subpixel_scale; - if(*rx > image_subpixel_scale * m_scale_limit) - { - *rx = image_subpixel_scale * m_scale_limit; - } - if(*ry > image_subpixel_scale * m_scale_limit) - { - *ry = image_subpixel_scale * m_scale_limit; - } - *rx = (*rx * m_blur_x) >> image_subpixel_shift; - *ry = (*ry * m_blur_y) >> image_subpixel_shift; - if(*rx < image_subpixel_scale) *rx = image_subpixel_scale; - if(*ry < image_subpixel_scale) *ry = image_subpixel_scale; - } - - int m_scale_limit; - int m_blur_x; - int m_blur_y; - }; - - - - -} - -#endif diff --git a/xs/src/agg/agg_span_image_filter_gray.h b/xs/src/agg/agg_span_image_filter_gray.h deleted file mode 100644 index 4bc9c00be6..0000000000 --- a/xs/src/agg/agg_span_image_filter_gray.h +++ /dev/null @@ -1,723 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- -#ifndef AGG_SPAN_IMAGE_FILTER_GRAY_INCLUDED -#define AGG_SPAN_IMAGE_FILTER_GRAY_INCLUDED - -#include "agg_basics.h" -#include "agg_color_gray.h" -#include "agg_span_image_filter.h" - - -namespace agg -{ - - //==============================================span_image_filter_gray_nn - template - class span_image_filter_gray_nn : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_gray_nn() {} - span_image_filter_gray_nn(source_type& src, - interpolator_type& inter) : - base_type(src, inter, 0) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - do - { - base_type::interpolator().coordinates(&x, &y); - span->v = *(const value_type*) - base_type::source().span(x >> image_subpixel_shift, - y >> image_subpixel_shift, - 1); - span->a = color_type::full_value(); - ++span; - ++base_type::interpolator(); - } while(--len); - } - }; - - - - //=========================================span_image_filter_gray_bilinear - template - class span_image_filter_gray_bilinear : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_gray_bilinear() {} - span_image_filter_gray_bilinear(source_type& src, - interpolator_type& inter) : - base_type(src, inter, 0) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - long_type fg; - const value_type *fg_ptr; - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - fg = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); - fg += *fg_ptr * (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); - - fg_ptr = (const value_type*)base_type::source().next_x(); - fg += *fg_ptr * x_hr * (image_subpixel_scale - y_hr); - - fg_ptr = (const value_type*)base_type::source().next_y(); - fg += *fg_ptr * (image_subpixel_scale - x_hr) * y_hr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - fg += *fg_ptr * x_hr * y_hr; - - span->v = color_type::downshift(fg, image_subpixel_shift * 2); - span->a = color_type::full_value(); - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - //====================================span_image_filter_gray_bilinear_clip - template - class span_image_filter_gray_bilinear_clip : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_gray_bilinear_clip() {} - span_image_filter_gray_bilinear_clip(source_type& src, - const color_type& back_color, - interpolator_type& inter) : - base_type(src, inter, 0), - m_back_color(back_color) - {} - const color_type& background_color() const { return m_back_color; } - void background_color(const color_type& v) { m_back_color = v; } - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - long_type fg; - long_type src_alpha; - value_type back_v = m_back_color.v; - value_type back_a = m_back_color.a; - - const value_type *fg_ptr; - - int maxx = base_type::source().width() - 1; - int maxy = base_type::source().height() - 1; - - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - if(x_lr >= 0 && y_lr >= 0 && - x_lr < maxx && y_lr < maxy) - { - fg = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - fg_ptr = (const value_type*)base_type::source().row_ptr(y_lr) + x_lr; - - fg += *fg_ptr++ * (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); - fg += *fg_ptr++ * (image_subpixel_scale - y_hr) * x_hr; - - ++y_lr; - fg_ptr = (const value_type*)base_type::source().row_ptr(y_lr) + x_lr; - - fg += *fg_ptr++ * (image_subpixel_scale - x_hr) * y_hr; - fg += *fg_ptr++ * x_hr * y_hr; - - fg = color_type::downshift(fg, image_subpixel_shift * 2); - src_alpha = color_type::full_value(); - } - else - { - unsigned weight; - if(x_lr < -1 || y_lr < -1 || - x_lr > maxx || y_lr > maxy) - { - fg = back_v; - src_alpha = back_a; - } - else - { - fg = src_alpha = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - weight = (image_subpixel_scale - x_hr) * - (image_subpixel_scale - y_hr); - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg += weight * - *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); - src_alpha += weight * color_type::full_value(); - } - else - { - fg += back_v * weight; - src_alpha += back_a * weight; - } - - x_lr++; - - weight = x_hr * (image_subpixel_scale - y_hr); - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg += weight * - *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); - src_alpha += weight * color_type::full_value(); - } - else - { - fg += back_v * weight; - src_alpha += back_a * weight; - } - - x_lr--; - y_lr++; - - weight = (image_subpixel_scale - x_hr) * y_hr; - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg += weight * - *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); - src_alpha += weight * color_type::full_value(); - } - else - { - fg += back_v * weight; - src_alpha += back_a * weight; - } - - x_lr++; - - weight = x_hr * y_hr; - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg += weight * - *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); - src_alpha += weight * color_type::full_value(); - } - else - { - fg += back_v * weight; - src_alpha += back_a * weight; - } - - fg = color_type::downshift(fg, image_subpixel_shift * 2); - src_alpha = color_type::downshift(src_alpha, image_subpixel_shift * 2); - } - } - - span->v = (value_type)fg; - span->a = (value_type)src_alpha; - ++span; - ++base_type::interpolator(); - - } while(--len); - } - private: - color_type m_back_color; - }; - - - - //==============================================span_image_filter_gray_2x2 - template - class span_image_filter_gray_2x2 : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_gray_2x2() {} - span_image_filter_gray_2x2(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, &filter) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg; - - const value_type *fg_ptr; - const int16* weight_array = base_type::filter().weight_array() + - ((base_type::filter().diameter()/2 - 1) << - image_subpixel_shift); - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - unsigned weight; - fg = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); - weight = (weight_array[x_hr + image_subpixel_scale] * - weight_array[y_hr + image_subpixel_scale] + - image_filter_scale / 2) >> - image_filter_shift; - fg += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = (weight_array[x_hr] * - weight_array[y_hr + image_subpixel_scale] + - image_filter_scale / 2) >> - image_filter_shift; - fg += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_y(); - weight = (weight_array[x_hr + image_subpixel_scale] * - weight_array[y_hr] + - image_filter_scale / 2) >> - image_filter_shift; - fg += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = (weight_array[x_hr] * - weight_array[y_hr] + - image_filter_scale / 2) >> - image_filter_shift; - fg += weight * *fg_ptr; - - fg >>= image_filter_shift; - if(fg > color_type::full_value()) fg = color_type::full_value(); - - span->v = (value_type)fg; - span->a = color_type::full_value(); - ++span; - ++base_type::interpolator(); - } while(--len); - } - }; - - - - //==================================================span_image_filter_gray - template - class span_image_filter_gray : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_gray() {} - span_image_filter_gray(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, &filter) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg; - const value_type *fg_ptr; - - unsigned diameter = base_type::filter().diameter(); - int start = base_type::filter().start(); - const int16* weight_array = base_type::filter().weight_array(); - - int x_count; - int weight_y; - - do - { - base_type::interpolator().coordinates(&x, &y); - - x -= base_type::filter_dx_int(); - y -= base_type::filter_dy_int(); - - int x_hr = x; - int y_hr = y; - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - fg = 0; - - int x_fract = x_hr & image_subpixel_mask; - unsigned y_count = diameter; - - y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); - fg_ptr = (const value_type*)base_type::source().span(x_lr + start, - y_lr + start, - diameter); - for(;;) - { - x_count = diameter; - weight_y = weight_array[y_hr]; - x_hr = image_subpixel_mask - x_fract; - for(;;) - { - fg += *fg_ptr * - ((weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - image_filter_shift); - if(--x_count == 0) break; - x_hr += image_subpixel_scale; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - - if(--y_count == 0) break; - y_hr += image_subpixel_scale; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg >>= image_filter_shift; - if(fg < 0) fg = 0; - if(fg > color_type::full_value()) fg = color_type::full_value(); - span->v = (value_type)fg; - span->a = color_type::full_value(); - - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - - //=========================================span_image_resample_gray_affine - template - class span_image_resample_gray_affine : - public span_image_resample_affine - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef span_image_resample_affine base_type; - typedef typename base_type::interpolator_type interpolator_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - downscale_shift = image_filter_shift - }; - - //-------------------------------------------------------------------- - span_image_resample_gray_affine() {} - span_image_resample_gray_affine(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, filter) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg; - - int diameter = base_type::filter().diameter(); - int filter_scale = diameter << image_subpixel_shift; - int radius_x = (diameter * base_type::m_rx) >> 1; - int radius_y = (diameter * base_type::m_ry) >> 1; - int len_x_lr = - (diameter * base_type::m_rx + image_subpixel_mask) >> - image_subpixel_shift; - - const int16* weight_array = base_type::filter().weight_array(); - - do - { - base_type::interpolator().coordinates(&x, &y); - - x += base_type::filter_dx_int() - radius_x; - y += base_type::filter_dy_int() - radius_y; - - fg = 0; - - int y_lr = y >> image_subpixel_shift; - int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * - base_type::m_ry_inv) >> - image_subpixel_shift; - int total_weight = 0; - int x_lr = x >> image_subpixel_shift; - int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * - base_type::m_rx_inv) >> - image_subpixel_shift; - - int x_hr2 = x_hr; - const value_type* fg_ptr = - (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); - for(;;) - { - int weight_y = weight_array[y_hr]; - x_hr = x_hr2; - for(;;) - { - int weight = (weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - downscale_shift; - - fg += *fg_ptr * weight; - total_weight += weight; - x_hr += base_type::m_rx_inv; - if(x_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - y_hr += base_type::m_ry_inv; - if(y_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg /= total_weight; - if(fg < 0) fg = 0; - if(fg > color_type::full_value()) fg = color_type::full_value(); - - span->v = (value_type)fg; - span->a = color_type::full_value(); - - ++span; - ++base_type::interpolator(); - } while(--len); - } - }; - - - - //================================================span_image_resample_gray - template - class span_image_resample_gray : - public span_image_resample - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef Interpolator interpolator_type; - typedef span_image_resample base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - downscale_shift = image_filter_shift - }; - - //-------------------------------------------------------------------- - span_image_resample_gray() {} - span_image_resample_gray(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, filter) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - long_type fg; - - int diameter = base_type::filter().diameter(); - int filter_scale = diameter << image_subpixel_shift; - - const int16* weight_array = base_type::filter().weight_array(); - do - { - int rx; - int ry; - int rx_inv = image_subpixel_scale; - int ry_inv = image_subpixel_scale; - base_type::interpolator().coordinates(&x, &y); - base_type::interpolator().local_scale(&rx, &ry); - base_type::adjust_scale(&rx, &ry); - - rx_inv = image_subpixel_scale * image_subpixel_scale / rx; - ry_inv = image_subpixel_scale * image_subpixel_scale / ry; - - int radius_x = (diameter * rx) >> 1; - int radius_y = (diameter * ry) >> 1; - int len_x_lr = - (diameter * rx + image_subpixel_mask) >> - image_subpixel_shift; - - x += base_type::filter_dx_int() - radius_x; - y += base_type::filter_dy_int() - radius_y; - - fg = 0; - - int y_lr = y >> image_subpixel_shift; - int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * - ry_inv) >> - image_subpixel_shift; - int total_weight = 0; - int x_lr = x >> image_subpixel_shift; - int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * - rx_inv) >> - image_subpixel_shift; - int x_hr2 = x_hr; - const value_type* fg_ptr = - (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); - - for(;;) - { - int weight_y = weight_array[y_hr]; - x_hr = x_hr2; - for(;;) - { - int weight = (weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - downscale_shift; - fg += *fg_ptr * weight; - total_weight += weight; - x_hr += rx_inv; - if(x_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - y_hr += ry_inv; - if(y_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg /= total_weight; - if(fg < 0) fg = 0; - if(fg > color_type::full_value()) fg = color_type::full_value(); - - span->v = (value_type)fg; - span->a = color_type::full_value(); - - ++span; - ++base_type::interpolator(); - } while(--len); - } - }; - - -} - - -#endif - - - diff --git a/xs/src/agg/agg_span_image_filter_rgb.h b/xs/src/agg/agg_span_image_filter_rgb.h deleted file mode 100644 index f78ae19c1b..0000000000 --- a/xs/src/agg/agg_span_image_filter_rgb.h +++ /dev/null @@ -1,861 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- -#ifndef AGG_SPAN_IMAGE_FILTER_RGB_INCLUDED -#define AGG_SPAN_IMAGE_FILTER_RGB_INCLUDED - -#include "agg_basics.h" -#include "agg_color_rgba.h" -#include "agg_span_image_filter.h" - - -namespace agg -{ - - //===============================================span_image_filter_rgb_nn - template - class span_image_filter_rgb_nn : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgb_nn() {} - span_image_filter_rgb_nn(source_type& src, - interpolator_type& inter) : - base_type(src, inter, 0) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - do - { - base_type::interpolator().coordinates(&x, &y); - const value_type* fg_ptr = (const value_type*) - base_type::source().span(x >> image_subpixel_shift, - y >> image_subpixel_shift, - 1); - span->r = fg_ptr[order_type::R]; - span->g = fg_ptr[order_type::G]; - span->b = fg_ptr[order_type::B]; - span->a = color_type::full_value(); - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - - //==========================================span_image_filter_rgb_bilinear - template - class span_image_filter_rgb_bilinear : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgb_bilinear() {} - span_image_filter_rgb_bilinear(source_type& src, - interpolator_type& inter) : - base_type(src, inter, 0) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - long_type fg[3]; - const value_type *fg_ptr; - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - unsigned weight; - - fg[0] = fg[1] = fg[2] = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); - weight = (image_subpixel_scale - x_hr) * - (image_subpixel_scale - y_hr); - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = x_hr * (image_subpixel_scale - y_hr); - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_y(); - weight = (image_subpixel_scale - x_hr) * y_hr; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = x_hr * y_hr; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - span->r = color_type::downshift(fg[order_type::R], image_subpixel_shift * 2); - span->g = color_type::downshift(fg[order_type::G], image_subpixel_shift * 2); - span->b = color_type::downshift(fg[order_type::B], image_subpixel_shift * 2); - span->a = color_type::full_value(); - - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - - //=====================================span_image_filter_rgb_bilinear_clip - template - class span_image_filter_rgb_bilinear_clip : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgb_bilinear_clip() {} - span_image_filter_rgb_bilinear_clip(source_type& src, - const color_type& back_color, - interpolator_type& inter) : - base_type(src, inter, 0), - m_back_color(back_color) - {} - const color_type& background_color() const { return m_back_color; } - void background_color(const color_type& v) { m_back_color = v; } - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - long_type fg[3]; - long_type src_alpha; - value_type back_r = m_back_color.r; - value_type back_g = m_back_color.g; - value_type back_b = m_back_color.b; - value_type back_a = m_back_color.a; - - const value_type *fg_ptr; - - int maxx = base_type::source().width() - 1; - int maxy = base_type::source().height() - 1; - - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - unsigned weight; - - if(x_lr >= 0 && y_lr >= 0 && - x_lr < maxx && y_lr < maxy) - { - fg[0] = fg[1] = fg[2] = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; - - weight = (image_subpixel_scale - x_hr) * - (image_subpixel_scale - y_hr); - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - - weight = x_hr * (image_subpixel_scale - y_hr); - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - - ++y_lr; - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; - - weight = (image_subpixel_scale - x_hr) * y_hr; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - - weight = x_hr * y_hr; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - - fg[0] = color_type::downshift(fg[0], image_subpixel_shift * 2); - fg[1] = color_type::downshift(fg[1], image_subpixel_shift * 2); - fg[2] = color_type::downshift(fg[2], image_subpixel_shift * 2); - src_alpha = color_type::full_value(); - } - else - { - if(x_lr < -1 || y_lr < -1 || - x_lr > maxx || y_lr > maxy) - { - fg[order_type::R] = back_r; - fg[order_type::G] = back_g; - fg[order_type::B] = back_b; - src_alpha = back_a; - } - else - { - fg[0] = fg[1] = fg[2] = src_alpha = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - weight = (image_subpixel_scale - x_hr) * - (image_subpixel_scale - y_hr); - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - src_alpha += weight * color_type::full_value(); - } - else - { - fg[order_type::R] += back_r * weight; - fg[order_type::G] += back_g * weight; - fg[order_type::B] += back_b * weight; - src_alpha += back_a * weight; - } - - x_lr++; - - weight = x_hr * (image_subpixel_scale - y_hr); - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - src_alpha += weight * color_type::full_value(); - } - else - { - fg[order_type::R] += back_r * weight; - fg[order_type::G] += back_g * weight; - fg[order_type::B] += back_b * weight; - src_alpha += back_a * weight; - } - - x_lr--; - y_lr++; - - weight = (image_subpixel_scale - x_hr) * y_hr; - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - src_alpha += weight * color_type::full_value(); - } - else - { - fg[order_type::R] += back_r * weight; - fg[order_type::G] += back_g * weight; - fg[order_type::B] += back_b * weight; - src_alpha += back_a * weight; - } - - x_lr++; - - weight = x_hr * y_hr; - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - src_alpha += weight * color_type::full_value(); - } - else - { - fg[order_type::R] += back_r * weight; - fg[order_type::G] += back_g * weight; - fg[order_type::B] += back_b * weight; - src_alpha += back_a * weight; - } - - fg[0] = color_type::downshift(fg[0], image_subpixel_shift * 2); - fg[1] = color_type::downshift(fg[1], image_subpixel_shift * 2); - fg[2] = color_type::downshift(fg[2], image_subpixel_shift * 2); - src_alpha = color_type::downshift(src_alpha, image_subpixel_shift * 2); - } - } - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = (value_type)src_alpha; - ++span; - ++base_type::interpolator(); - - } while(--len); - } - private: - color_type m_back_color; - }; - - - - //===============================================span_image_filter_rgb_2x2 - template - class span_image_filter_rgb_2x2 : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgb_2x2() {} - span_image_filter_rgb_2x2(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, &filter) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg[3]; - - const value_type *fg_ptr; - const int16* weight_array = base_type::filter().weight_array() + - ((base_type::filter().diameter()/2 - 1) << - image_subpixel_shift); - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - unsigned weight; - fg[0] = fg[1] = fg[2] = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); - weight = (weight_array[x_hr + image_subpixel_scale] * - weight_array[y_hr + image_subpixel_scale] + - image_filter_scale / 2) >> - image_filter_shift; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = (weight_array[x_hr] * - weight_array[y_hr + image_subpixel_scale] + - image_filter_scale / 2) >> - image_filter_shift; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_y(); - weight = (weight_array[x_hr + image_subpixel_scale] * - weight_array[y_hr] + - image_filter_scale / 2) >> - image_filter_shift; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = (weight_array[x_hr] * - weight_array[y_hr] + - image_filter_scale / 2) >> - image_filter_shift; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - fg[0] = color_type::downshift(fg[0], image_filter_shift); - fg[1] = color_type::downshift(fg[1], image_filter_shift); - fg[2] = color_type::downshift(fg[2], image_filter_shift); - - if(fg[order_type::R] > color_type::full_value()) fg[order_type::R] = color_type::full_value(); - if(fg[order_type::G] > color_type::full_value()) fg[order_type::G] = color_type::full_value(); - if(fg[order_type::B] > color_type::full_value()) fg[order_type::B] = color_type::full_value(); - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = color_type::full_value(); - - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - - //===================================================span_image_filter_rgb - template - class span_image_filter_rgb : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgb() {} - span_image_filter_rgb(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, &filter) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg[3]; - const value_type *fg_ptr; - - unsigned diameter = base_type::filter().diameter(); - int start = base_type::filter().start(); - const int16* weight_array = base_type::filter().weight_array(); - - int x_count; - int weight_y; - - do - { - base_type::interpolator().coordinates(&x, &y); - - x -= base_type::filter_dx_int(); - y -= base_type::filter_dy_int(); - - int x_hr = x; - int y_hr = y; - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - fg[0] = fg[1] = fg[2] = 0; - - int x_fract = x_hr & image_subpixel_mask; - unsigned y_count = diameter; - - y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); - fg_ptr = (const value_type*)base_type::source().span(x_lr + start, - y_lr + start, - diameter); - for(;;) - { - x_count = diameter; - weight_y = weight_array[y_hr]; - x_hr = image_subpixel_mask - x_fract; - for(;;) - { - int weight = (weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - image_filter_shift; - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr; - - if(--x_count == 0) break; - x_hr += image_subpixel_scale; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - - if(--y_count == 0) break; - y_hr += image_subpixel_scale; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg[0] = color_type::downshift(fg[0], image_filter_shift); - fg[1] = color_type::downshift(fg[1], image_filter_shift); - fg[2] = color_type::downshift(fg[2], image_filter_shift); - - if(fg[0] < 0) fg[0] = 0; - if(fg[1] < 0) fg[1] = 0; - if(fg[2] < 0) fg[2] = 0; - - if(fg[order_type::R] > color_type::full_value()) fg[order_type::R] = color_type::full_value(); - if(fg[order_type::G] > color_type::full_value()) fg[order_type::G] = color_type::full_value(); - if(fg[order_type::B] > color_type::full_value()) fg[order_type::B] = color_type::full_value(); - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = color_type::full_value(); - - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - - //==========================================span_image_resample_rgb_affine - template - class span_image_resample_rgb_affine : - public span_image_resample_affine - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef span_image_resample_affine base_type; - typedef typename base_type::interpolator_type interpolator_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - downscale_shift = image_filter_shift - }; - - //-------------------------------------------------------------------- - span_image_resample_rgb_affine() {} - span_image_resample_rgb_affine(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, filter) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg[3]; - - int diameter = base_type::filter().diameter(); - int filter_scale = diameter << image_subpixel_shift; - int radius_x = (diameter * base_type::m_rx) >> 1; - int radius_y = (diameter * base_type::m_ry) >> 1; - int len_x_lr = - (diameter * base_type::m_rx + image_subpixel_mask) >> - image_subpixel_shift; - - const int16* weight_array = base_type::filter().weight_array(); - - do - { - base_type::interpolator().coordinates(&x, &y); - - x += base_type::filter_dx_int() - radius_x; - y += base_type::filter_dy_int() - radius_y; - - fg[0] = fg[1] = fg[2] = 0; - - int y_lr = y >> image_subpixel_shift; - int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * - base_type::m_ry_inv) >> - image_subpixel_shift; - int total_weight = 0; - int x_lr = x >> image_subpixel_shift; - int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * - base_type::m_rx_inv) >> - image_subpixel_shift; - - int x_hr2 = x_hr; - const value_type* fg_ptr = - (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); - for(;;) - { - int weight_y = weight_array[y_hr]; - x_hr = x_hr2; - for(;;) - { - int weight = (weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - downscale_shift; - - fg[0] += *fg_ptr++ * weight; - fg[1] += *fg_ptr++ * weight; - fg[2] += *fg_ptr * weight; - total_weight += weight; - x_hr += base_type::m_rx_inv; - if(x_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - y_hr += base_type::m_ry_inv; - if(y_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg[0] /= total_weight; - fg[1] /= total_weight; - fg[2] /= total_weight; - - if(fg[0] < 0) fg[0] = 0; - if(fg[1] < 0) fg[1] = 0; - if(fg[2] < 0) fg[2] = 0; - - if(fg[order_type::R] > color_type::full_value()) fg[order_type::R] = color_type::full_value(); - if(fg[order_type::G] > color_type::full_value()) fg[order_type::G] = color_type::full_value(); - if(fg[order_type::B] > color_type::full_value()) fg[order_type::B] = color_type::full_value(); - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = color_type::full_value(); - - ++span; - ++base_type::interpolator(); - } while(--len); - } - }; - - - - //=================================================span_image_resample_rgb - template - class span_image_resample_rgb : - public span_image_resample - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_resample base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - downscale_shift = image_filter_shift - }; - - //-------------------------------------------------------------------- - span_image_resample_rgb() {} - span_image_resample_rgb(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, filter) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - long_type fg[3]; - - int diameter = base_type::filter().diameter(); - int filter_scale = diameter << image_subpixel_shift; - - const int16* weight_array = base_type::filter().weight_array(); - do - { - int rx; - int ry; - int rx_inv = image_subpixel_scale; - int ry_inv = image_subpixel_scale; - base_type::interpolator().coordinates(&x, &y); - base_type::interpolator().local_scale(&rx, &ry); - base_type::adjust_scale(&rx, &ry); - - rx_inv = image_subpixel_scale * image_subpixel_scale / rx; - ry_inv = image_subpixel_scale * image_subpixel_scale / ry; - - int radius_x = (diameter * rx) >> 1; - int radius_y = (diameter * ry) >> 1; - int len_x_lr = - (diameter * rx + image_subpixel_mask) >> - image_subpixel_shift; - - x += base_type::filter_dx_int() - radius_x; - y += base_type::filter_dy_int() - radius_y; - - fg[0] = fg[1] = fg[2] = 0; - - int y_lr = y >> image_subpixel_shift; - int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * - ry_inv) >> - image_subpixel_shift; - int total_weight = 0; - int x_lr = x >> image_subpixel_shift; - int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * - rx_inv) >> - image_subpixel_shift; - int x_hr2 = x_hr; - const value_type* fg_ptr = - (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); - - for(;;) - { - int weight_y = weight_array[y_hr]; - x_hr = x_hr2; - for(;;) - { - int weight = (weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - downscale_shift; - fg[0] += *fg_ptr++ * weight; - fg[1] += *fg_ptr++ * weight; - fg[2] += *fg_ptr * weight; - total_weight += weight; - x_hr += rx_inv; - if(x_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - y_hr += ry_inv; - if(y_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg[0] /= total_weight; - fg[1] /= total_weight; - fg[2] /= total_weight; - - if(fg[0] < 0) fg[0] = 0; - if(fg[1] < 0) fg[1] = 0; - if(fg[2] < 0) fg[2] = 0; - - if(fg[order_type::R] > color_type::full_value()) fg[order_type::R] = color_type::full_value(); - if(fg[order_type::G] > color_type::full_value()) fg[order_type::G] = color_type::full_value(); - if(fg[order_type::B] > color_type::full_value()) fg[order_type::B] = color_type::full_value(); - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = color_type::full_value(); - - ++span; - ++base_type::interpolator(); - } while(--len); - } - }; - - -} - - -#endif - - - diff --git a/xs/src/agg/agg_span_image_filter_rgba.h b/xs/src/agg/agg_span_image_filter_rgba.h deleted file mode 100644 index af7a1a2ef0..0000000000 --- a/xs/src/agg/agg_span_image_filter_rgba.h +++ /dev/null @@ -1,890 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- -#ifndef AGG_SPAN_IMAGE_FILTER_RGBA_INCLUDED -#define AGG_SPAN_IMAGE_FILTER_RGBA_INCLUDED - -#include "agg_basics.h" -#include "agg_color_rgba.h" -#include "agg_span_image_filter.h" - - -namespace agg -{ - - //==============================================span_image_filter_rgba_nn - template - class span_image_filter_rgba_nn : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgba_nn() {} - span_image_filter_rgba_nn(source_type& src, - interpolator_type& inter) : - base_type(src, inter, 0) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - do - { - base_type::interpolator().coordinates(&x, &y); - const value_type* fg_ptr = (const value_type*) - base_type::source().span(x >> image_subpixel_shift, - y >> image_subpixel_shift, - 1); - span->r = fg_ptr[order_type::R]; - span->g = fg_ptr[order_type::G]; - span->b = fg_ptr[order_type::B]; - span->a = fg_ptr[order_type::A]; - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - - //=========================================span_image_filter_rgba_bilinear - template - class span_image_filter_rgba_bilinear : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgba_bilinear() {} - span_image_filter_rgba_bilinear(source_type& src, - interpolator_type& inter) : - base_type(src, inter, 0) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg[4]; - const value_type *fg_ptr; - - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - unsigned weight; - - fg[0] = - fg[1] = - fg[2] = - fg[3] = image_subpixel_scale * image_subpixel_scale / 2; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); - weight = (image_subpixel_scale - x_hr) * - (image_subpixel_scale - y_hr); - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = x_hr * (image_subpixel_scale - y_hr); - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_y(); - weight = (image_subpixel_scale - x_hr) * y_hr; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = x_hr * y_hr; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - span->r = value_type(color_type::downshift(fg[order_type::R], image_subpixel_shift * 2)); - span->g = value_type(color_type::downshift(fg[order_type::G], image_subpixel_shift * 2)); - span->b = value_type(color_type::downshift(fg[order_type::B], image_subpixel_shift * 2)); - span->a = value_type(color_type::downshift(fg[order_type::A], image_subpixel_shift * 2)); - - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - //====================================span_image_filter_rgba_bilinear_clip - template - class span_image_filter_rgba_bilinear_clip : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgba_bilinear_clip() {} - span_image_filter_rgba_bilinear_clip(source_type& src, - const color_type& back_color, - interpolator_type& inter) : - base_type(src, inter, 0), - m_back_color(back_color) - {} - const color_type& background_color() const { return m_back_color; } - void background_color(const color_type& v) { m_back_color = v; } - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg[4]; - value_type back_r = m_back_color.r; - value_type back_g = m_back_color.g; - value_type back_b = m_back_color.b; - value_type back_a = m_back_color.a; - - const value_type *fg_ptr; - int maxx = base_type::source().width() - 1; - int maxy = base_type::source().height() - 1; - - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - unsigned weight; - - if(x_lr >= 0 && y_lr >= 0 && - x_lr < maxx && y_lr < maxy) - { - fg[0] = fg[1] = fg[2] = fg[3] = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + (x_lr << 2); - - weight = (image_subpixel_scale - x_hr) * - (image_subpixel_scale - y_hr); - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr++; - - weight = x_hr * (image_subpixel_scale - y_hr); - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr++; - - ++y_lr; - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + (x_lr << 2); - - weight = (image_subpixel_scale - x_hr) * y_hr; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr++; - - weight = x_hr * y_hr; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr++; - - fg[0] = color_type::downshift(fg[0], image_subpixel_shift * 2); - fg[1] = color_type::downshift(fg[1], image_subpixel_shift * 2); - fg[2] = color_type::downshift(fg[2], image_subpixel_shift * 2); - fg[3] = color_type::downshift(fg[3], image_subpixel_shift * 2); - } - else - { - if(x_lr < -1 || y_lr < -1 || - x_lr > maxx || y_lr > maxy) - { - fg[order_type::R] = back_r; - fg[order_type::G] = back_g; - fg[order_type::B] = back_b; - fg[order_type::A] = back_a; - } - else - { - fg[0] = fg[1] = fg[2] = fg[3] = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - weight = (image_subpixel_scale - x_hr) * - (image_subpixel_scale - y_hr); - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + (x_lr << 2); - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr++; - } - else - { - fg[order_type::R] += back_r * weight; - fg[order_type::G] += back_g * weight; - fg[order_type::B] += back_b * weight; - fg[order_type::A] += back_a * weight; - } - - x_lr++; - - weight = x_hr * (image_subpixel_scale - y_hr); - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + (x_lr << 2); - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr++; - } - else - { - fg[order_type::R] += back_r * weight; - fg[order_type::G] += back_g * weight; - fg[order_type::B] += back_b * weight; - fg[order_type::A] += back_a * weight; - } - - x_lr--; - y_lr++; - - weight = (image_subpixel_scale - x_hr) * y_hr; - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + (x_lr << 2); - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr++; - } - else - { - fg[order_type::R] += back_r * weight; - fg[order_type::G] += back_g * weight; - fg[order_type::B] += back_b * weight; - fg[order_type::A] += back_a * weight; - } - - x_lr++; - - weight = x_hr * y_hr; - if(x_lr >= 0 && y_lr >= 0 && - x_lr <= maxx && y_lr <= maxy) - { - fg_ptr = (const value_type*) - base_type::source().row_ptr(y_lr) + (x_lr << 2); - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr++; - } - else - { - fg[order_type::R] += back_r * weight; - fg[order_type::G] += back_g * weight; - fg[order_type::B] += back_b * weight; - fg[order_type::A] += back_a * weight; - } - - fg[0] = color_type::downshift(fg[0], image_subpixel_shift * 2); - fg[1] = color_type::downshift(fg[1], image_subpixel_shift * 2); - fg[2] = color_type::downshift(fg[2], image_subpixel_shift * 2); - fg[3] = color_type::downshift(fg[3], image_subpixel_shift * 2); - } - } - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = (value_type)fg[order_type::A]; - ++span; - ++base_type::interpolator(); - - } while(--len); - } - private: - color_type m_back_color; - }; - - - //==============================================span_image_filter_rgba_2x2 - template - class span_image_filter_rgba_2x2 : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgba_2x2() {} - span_image_filter_rgba_2x2(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, &filter) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg[4]; - - const value_type *fg_ptr; - const int16* weight_array = base_type::filter().weight_array() + - ((base_type::filter().diameter()/2 - 1) << - image_subpixel_shift); - - do - { - int x_hr; - int y_hr; - - base_type::interpolator().coordinates(&x_hr, &y_hr); - - x_hr -= base_type::filter_dx_int(); - y_hr -= base_type::filter_dy_int(); - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - unsigned weight; - fg[0] = fg[1] = fg[2] = fg[3] = 0; - - x_hr &= image_subpixel_mask; - y_hr &= image_subpixel_mask; - - fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); - weight = (weight_array[x_hr + image_subpixel_scale] * - weight_array[y_hr + image_subpixel_scale] + - image_filter_scale / 2) >> - image_filter_shift; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = (weight_array[x_hr] * - weight_array[y_hr + image_subpixel_scale] + - image_filter_scale / 2) >> - image_filter_shift; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_y(); - weight = (weight_array[x_hr + image_subpixel_scale] * - weight_array[y_hr] + - image_filter_scale / 2) >> - image_filter_shift; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - fg_ptr = (const value_type*)base_type::source().next_x(); - weight = (weight_array[x_hr] * - weight_array[y_hr] + - image_filter_scale / 2) >> - image_filter_shift; - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - fg[0] = color_type::downshift(fg[0], image_filter_shift); - fg[1] = color_type::downshift(fg[1], image_filter_shift); - fg[2] = color_type::downshift(fg[2], image_filter_shift); - fg[3] = color_type::downshift(fg[3], image_filter_shift); - - if(fg[order_type::A] > color_type::full_value()) fg[order_type::A] = color_type::full_value(); - if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; - if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; - if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = (value_type)fg[order_type::A]; - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - - //==================================================span_image_filter_rgba - template - class span_image_filter_rgba : - public span_image_filter - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_filter base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - typedef typename color_type::long_type long_type; - - //-------------------------------------------------------------------- - span_image_filter_rgba() {} - span_image_filter_rgba(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, &filter) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg[4]; - const value_type *fg_ptr; - - unsigned diameter = base_type::filter().diameter(); - int start = base_type::filter().start(); - const int16* weight_array = base_type::filter().weight_array(); - - int x_count; - int weight_y; - - do - { - base_type::interpolator().coordinates(&x, &y); - - x -= base_type::filter_dx_int(); - y -= base_type::filter_dy_int(); - - int x_hr = x; - int y_hr = y; - - int x_lr = x_hr >> image_subpixel_shift; - int y_lr = y_hr >> image_subpixel_shift; - - fg[0] = fg[1] = fg[2] = fg[3] = 0; - - int x_fract = x_hr & image_subpixel_mask; - unsigned y_count = diameter; - - y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); - fg_ptr = (const value_type*)base_type::source().span(x_lr + start, - y_lr + start, - diameter); - for(;;) - { - x_count = diameter; - weight_y = weight_array[y_hr]; - x_hr = image_subpixel_mask - x_fract; - for(;;) - { - int weight = (weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - image_filter_shift; - - fg[0] += weight * *fg_ptr++; - fg[1] += weight * *fg_ptr++; - fg[2] += weight * *fg_ptr++; - fg[3] += weight * *fg_ptr; - - if(--x_count == 0) break; - x_hr += image_subpixel_scale; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - - if(--y_count == 0) break; - y_hr += image_subpixel_scale; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg[0] = color_type::downshift(fg[0], image_filter_shift); - fg[1] = color_type::downshift(fg[1], image_filter_shift); - fg[2] = color_type::downshift(fg[2], image_filter_shift); - fg[3] = color_type::downshift(fg[3], image_filter_shift); - - if(fg[0] < 0) fg[0] = 0; - if(fg[1] < 0) fg[1] = 0; - if(fg[2] < 0) fg[2] = 0; - if(fg[3] < 0) fg[3] = 0; - - if(fg[order_type::A] > color_type::full_value()) fg[order_type::A] = color_type::full_value(); - if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; - if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; - if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = (value_type)fg[order_type::A]; - ++span; - ++base_type::interpolator(); - - } while(--len); - } - }; - - - - //========================================span_image_resample_rgba_affine - template - class span_image_resample_rgba_affine : - public span_image_resample_affine - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef span_image_resample_affine base_type; - typedef typename base_type::interpolator_type interpolator_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - downscale_shift = image_filter_shift - }; - - //-------------------------------------------------------------------- - span_image_resample_rgba_affine() {} - span_image_resample_rgba_affine(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, filter) - {} - - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - - long_type fg[4]; - - int diameter = base_type::filter().diameter(); - int filter_scale = diameter << image_subpixel_shift; - int radius_x = (diameter * base_type::m_rx) >> 1; - int radius_y = (diameter * base_type::m_ry) >> 1; - int len_x_lr = - (diameter * base_type::m_rx + image_subpixel_mask) >> - image_subpixel_shift; - - const int16* weight_array = base_type::filter().weight_array(); - - do - { - base_type::interpolator().coordinates(&x, &y); - - x += base_type::filter_dx_int() - radius_x; - y += base_type::filter_dy_int() - radius_y; - - fg[0] = fg[1] = fg[2] = fg[3] = 0; - - int y_lr = y >> image_subpixel_shift; - int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * - base_type::m_ry_inv) >> - image_subpixel_shift; - int total_weight = 0; - int x_lr = x >> image_subpixel_shift; - int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * - base_type::m_rx_inv) >> - image_subpixel_shift; - - int x_hr2 = x_hr; - const value_type* fg_ptr = - (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); - for(;;) - { - int weight_y = weight_array[y_hr]; - x_hr = x_hr2; - for(;;) - { - int weight = (weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - downscale_shift; - - fg[0] += *fg_ptr++ * weight; - fg[1] += *fg_ptr++ * weight; - fg[2] += *fg_ptr++ * weight; - fg[3] += *fg_ptr++ * weight; - total_weight += weight; - x_hr += base_type::m_rx_inv; - if(x_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - y_hr += base_type::m_ry_inv; - if(y_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg[0] /= total_weight; - fg[1] /= total_weight; - fg[2] /= total_weight; - fg[3] /= total_weight; - - if(fg[0] < 0) fg[0] = 0; - if(fg[1] < 0) fg[1] = 0; - if(fg[2] < 0) fg[2] = 0; - if(fg[3] < 0) fg[3] = 0; - - if(fg[order_type::A] > color_type::full_value()) fg[order_type::A] = color_type::full_value(); - if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; - if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; - if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = (value_type)fg[order_type::A]; - - ++span; - ++base_type::interpolator(); - } while(--len); - } - }; - - - - //==============================================span_image_resample_rgba - template - class span_image_resample_rgba : - public span_image_resample - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef Interpolator interpolator_type; - typedef span_image_resample base_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::long_type long_type; - enum base_scale_e - { - downscale_shift = image_filter_shift - }; - - //-------------------------------------------------------------------- - span_image_resample_rgba() {} - span_image_resample_rgba(source_type& src, - interpolator_type& inter, - image_filter_lut& filter) : - base_type(src, inter, filter) - {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - base_type::interpolator().begin(x + base_type::filter_dx_dbl(), - y + base_type::filter_dy_dbl(), len); - long_type fg[4]; - - int diameter = base_type::filter().diameter(); - int filter_scale = diameter << image_subpixel_shift; - - const int16* weight_array = base_type::filter().weight_array(); - do - { - int rx; - int ry; - int rx_inv = image_subpixel_scale; - int ry_inv = image_subpixel_scale; - base_type::interpolator().coordinates(&x, &y); - base_type::interpolator().local_scale(&rx, &ry); - base_type::adjust_scale(&rx, &ry); - - rx_inv = image_subpixel_scale * image_subpixel_scale / rx; - ry_inv = image_subpixel_scale * image_subpixel_scale / ry; - - int radius_x = (diameter * rx) >> 1; - int radius_y = (diameter * ry) >> 1; - int len_x_lr = - (diameter * rx + image_subpixel_mask) >> - image_subpixel_shift; - - x += base_type::filter_dx_int() - radius_x; - y += base_type::filter_dy_int() - radius_y; - - fg[0] = fg[1] = fg[2] = fg[3] = 0; - - int y_lr = y >> image_subpixel_shift; - int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * - ry_inv) >> - image_subpixel_shift; - int total_weight = 0; - int x_lr = x >> image_subpixel_shift; - int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * - rx_inv) >> - image_subpixel_shift; - int x_hr2 = x_hr; - const value_type* fg_ptr = - (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); - - for(;;) - { - int weight_y = weight_array[y_hr]; - x_hr = x_hr2; - for(;;) - { - int weight = (weight_y * weight_array[x_hr] + - image_filter_scale / 2) >> - downscale_shift; - fg[0] += *fg_ptr++ * weight; - fg[1] += *fg_ptr++ * weight; - fg[2] += *fg_ptr++ * weight; - fg[3] += *fg_ptr++ * weight; - total_weight += weight; - x_hr += rx_inv; - if(x_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_x(); - } - y_hr += ry_inv; - if(y_hr >= filter_scale) break; - fg_ptr = (const value_type*)base_type::source().next_y(); - } - - fg[0] /= total_weight; - fg[1] /= total_weight; - fg[2] /= total_weight; - fg[3] /= total_weight; - - if(fg[0] < 0) fg[0] = 0; - if(fg[1] < 0) fg[1] = 0; - if(fg[2] < 0) fg[2] = 0; - if(fg[3] < 0) fg[3] = 0; - - if(fg[order_type::A] > color_type::full_value()) fg[order_type::A] = color_type::full_value(); - if(fg[order_type::R] > fg[order_type::R]) fg[order_type::R] = fg[order_type::R]; - if(fg[order_type::G] > fg[order_type::G]) fg[order_type::G] = fg[order_type::G]; - if(fg[order_type::B] > fg[order_type::B]) fg[order_type::B] = fg[order_type::B]; - - span->r = (value_type)fg[order_type::R]; - span->g = (value_type)fg[order_type::G]; - span->b = (value_type)fg[order_type::B]; - span->a = (value_type)fg[order_type::A]; - - ++span; - ++base_type::interpolator(); - } while(--len); - } - }; - - -} - - -#endif - - - diff --git a/xs/src/agg/agg_span_interpolator_adaptor.h b/xs/src/agg/agg_span_interpolator_adaptor.h deleted file mode 100644 index 0fdfa77479..0000000000 --- a/xs/src/agg/agg_span_interpolator_adaptor.h +++ /dev/null @@ -1,77 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED -#define AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //===============================================span_interpolator_adaptor - template - class span_interpolator_adaptor : public Interpolator - { - public: - typedef Interpolator base_type; - typedef typename base_type::trans_type trans_type; - typedef Distortion distortion_type; - - //-------------------------------------------------------------------- - span_interpolator_adaptor() {} - span_interpolator_adaptor(trans_type& trans, - distortion_type& dist) : - base_type(trans), - m_distortion(&dist) - { - } - - //-------------------------------------------------------------------- - span_interpolator_adaptor(trans_type& trans, - distortion_type& dist, - double x, double y, unsigned len) : - base_type(trans, x, y, len), - m_distortion(&dist) - { - } - - //-------------------------------------------------------------------- - distortion_type& distortion() const - { - return *m_distortion; - } - - //-------------------------------------------------------------------- - void distortion(distortion_type& dist) - { - m_distortion = dist; - } - - //-------------------------------------------------------------------- - void coordinates(int* x, int* y) const - { - base_type::coordinates(x, y); - m_distortion->calculate(x, y); - } - - private: - //-------------------------------------------------------------------- - distortion_type* m_distortion; - }; -} - - -#endif diff --git a/xs/src/agg/agg_span_interpolator_linear.h b/xs/src/agg/agg_span_interpolator_linear.h deleted file mode 100644 index ef10505ce1..0000000000 --- a/xs/src/agg/agg_span_interpolator_linear.h +++ /dev/null @@ -1,232 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_INTERPOLATOR_LINEAR_INCLUDED -#define AGG_SPAN_INTERPOLATOR_LINEAR_INCLUDED - -#include "agg_basics.h" -#include "agg_dda_line.h" -#include "agg_trans_affine.h" - -namespace agg -{ - - //================================================span_interpolator_linear - template - class span_interpolator_linear - { - public: - typedef Transformer trans_type; - - enum subpixel_scale_e - { - subpixel_shift = SubpixelShift, - subpixel_scale = 1 << subpixel_shift - }; - - //-------------------------------------------------------------------- - span_interpolator_linear() {} - span_interpolator_linear(trans_type& trans) : m_trans(&trans) {} - span_interpolator_linear(trans_type& trans, - double x, double y, unsigned len) : - m_trans(&trans) - { - begin(x, y, len); - } - - //---------------------------------------------------------------- - const trans_type& transformer() const { return *m_trans; } - void transformer(trans_type& trans) { m_trans = &trans; } - - //---------------------------------------------------------------- - void begin(double x, double y, unsigned len) - { - double tx; - double ty; - - tx = x; - ty = y; - m_trans->transform(&tx, &ty); - int x1 = iround(tx * subpixel_scale); - int y1 = iround(ty * subpixel_scale); - - tx = x + len; - ty = y; - m_trans->transform(&tx, &ty); - int x2 = iround(tx * subpixel_scale); - int y2 = iround(ty * subpixel_scale); - - m_li_x = dda2_line_interpolator(x1, x2, len); - m_li_y = dda2_line_interpolator(y1, y2, len); - } - - //---------------------------------------------------------------- - void resynchronize(double xe, double ye, unsigned len) - { - m_trans->transform(&xe, &ye); - m_li_x = dda2_line_interpolator(m_li_x.y(), iround(xe * subpixel_scale), len); - m_li_y = dda2_line_interpolator(m_li_y.y(), iround(ye * subpixel_scale), len); - } - - //---------------------------------------------------------------- - void operator++() - { - ++m_li_x; - ++m_li_y; - } - - //---------------------------------------------------------------- - void coordinates(int* x, int* y) const - { - *x = m_li_x.y(); - *y = m_li_y.y(); - } - - private: - trans_type* m_trans; - dda2_line_interpolator m_li_x; - dda2_line_interpolator m_li_y; - }; - - - - - - - //=====================================span_interpolator_linear_subdiv - template - class span_interpolator_linear_subdiv - { - public: - typedef Transformer trans_type; - - enum subpixel_scale_e - { - subpixel_shift = SubpixelShift, - subpixel_scale = 1 << subpixel_shift - }; - - - //---------------------------------------------------------------- - span_interpolator_linear_subdiv() : - m_subdiv_shift(4), - m_subdiv_size(1 << m_subdiv_shift), - m_subdiv_mask(m_subdiv_size - 1) {} - - span_interpolator_linear_subdiv(trans_type& trans, - unsigned subdiv_shift = 4) : - m_subdiv_shift(subdiv_shift), - m_subdiv_size(1 << m_subdiv_shift), - m_subdiv_mask(m_subdiv_size - 1), - m_trans(&trans) {} - - span_interpolator_linear_subdiv(trans_type& trans, - double x, double y, unsigned len, - unsigned subdiv_shift = 4) : - m_subdiv_shift(subdiv_shift), - m_subdiv_size(1 << m_subdiv_shift), - m_subdiv_mask(m_subdiv_size - 1), - m_trans(&trans) - { - begin(x, y, len); - } - - //---------------------------------------------------------------- - const trans_type& transformer() const { return *m_trans; } - void transformer(const trans_type& trans) { m_trans = &trans; } - - //---------------------------------------------------------------- - unsigned subdiv_shift() const { return m_subdiv_shift; } - void subdiv_shift(unsigned shift) - { - m_subdiv_shift = shift; - m_subdiv_size = 1 << m_subdiv_shift; - m_subdiv_mask = m_subdiv_size - 1; - } - - //---------------------------------------------------------------- - void begin(double x, double y, unsigned len) - { - double tx; - double ty; - m_pos = 1; - m_src_x = iround(x * subpixel_scale) + subpixel_scale; - m_src_y = y; - m_len = len; - - if(len > m_subdiv_size) len = m_subdiv_size; - tx = x; - ty = y; - m_trans->transform(&tx, &ty); - int x1 = iround(tx * subpixel_scale); - int y1 = iround(ty * subpixel_scale); - - tx = x + len; - ty = y; - m_trans->transform(&tx, &ty); - - m_li_x = dda2_line_interpolator(x1, iround(tx * subpixel_scale), len); - m_li_y = dda2_line_interpolator(y1, iround(ty * subpixel_scale), len); - } - - //---------------------------------------------------------------- - void operator++() - { - ++m_li_x; - ++m_li_y; - if(m_pos >= m_subdiv_size) - { - unsigned len = m_len; - if(len > m_subdiv_size) len = m_subdiv_size; - double tx = double(m_src_x) / double(subpixel_scale) + len; - double ty = m_src_y; - m_trans->transform(&tx, &ty); - m_li_x = dda2_line_interpolator(m_li_x.y(), iround(tx * subpixel_scale), len); - m_li_y = dda2_line_interpolator(m_li_y.y(), iround(ty * subpixel_scale), len); - m_pos = 0; - } - m_src_x += subpixel_scale; - ++m_pos; - --m_len; - } - - //---------------------------------------------------------------- - void coordinates(int* x, int* y) const - { - *x = m_li_x.y(); - *y = m_li_y.y(); - } - - private: - unsigned m_subdiv_shift; - unsigned m_subdiv_size; - unsigned m_subdiv_mask; - trans_type* m_trans; - dda2_line_interpolator m_li_x; - dda2_line_interpolator m_li_y; - int m_src_x; - double m_src_y; - unsigned m_pos; - unsigned m_len; - }; - - -} - - - -#endif - - diff --git a/xs/src/agg/agg_span_interpolator_persp.h b/xs/src/agg/agg_span_interpolator_persp.h deleted file mode 100644 index cad437e04f..0000000000 --- a/xs/src/agg/agg_span_interpolator_persp.h +++ /dev/null @@ -1,462 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_SPAN_INTERPOLATOR_PERSP_INCLUDED -#define AGG_SPAN_INTERPOLATOR_PERSP_INCLUDED - -#include "agg_trans_perspective.h" -#include "agg_dda_line.h" - -namespace agg -{ - - - - //===========================================span_interpolator_persp_exact - template - class span_interpolator_persp_exact - { - public: - typedef trans_perspective trans_type; - typedef trans_perspective::iterator_x iterator_type; - enum subpixel_scale_e - { - subpixel_shift = SubpixelShift, - subpixel_scale = 1 << subpixel_shift - }; - - //-------------------------------------------------------------------- - span_interpolator_persp_exact() {} - - //-------------------------------------------------------------------- - // Arbitrary quadrangle transformations - span_interpolator_persp_exact(const double* src, const double* dst) - { - quad_to_quad(src, dst); - } - - //-------------------------------------------------------------------- - // Direct transformations - span_interpolator_persp_exact(double x1, double y1, - double x2, double y2, - const double* quad) - { - rect_to_quad(x1, y1, x2, y2, quad); - } - - //-------------------------------------------------------------------- - // Reverse transformations - span_interpolator_persp_exact(const double* quad, - double x1, double y1, - double x2, double y2) - { - quad_to_rect(quad, x1, y1, x2, y2); - } - - //-------------------------------------------------------------------- - // Set the transformations using two arbitrary quadrangles. - void quad_to_quad(const double* src, const double* dst) - { - m_trans_dir.quad_to_quad(src, dst); - m_trans_inv.quad_to_quad(dst, src); - } - - //-------------------------------------------------------------------- - // Set the direct transformations, i.e., rectangle -> quadrangle - void rect_to_quad(double x1, double y1, double x2, double y2, - const double* quad) - { - double src[8]; - src[0] = src[6] = x1; - src[2] = src[4] = x2; - src[1] = src[3] = y1; - src[5] = src[7] = y2; - quad_to_quad(src, quad); - } - - - //-------------------------------------------------------------------- - // Set the reverse transformations, i.e., quadrangle -> rectangle - void quad_to_rect(const double* quad, - double x1, double y1, double x2, double y2) - { - double dst[8]; - dst[0] = dst[6] = x1; - dst[2] = dst[4] = x2; - dst[1] = dst[3] = y1; - dst[5] = dst[7] = y2; - quad_to_quad(quad, dst); - } - - //-------------------------------------------------------------------- - // Check if the equations were solved successfully - bool is_valid() const { return m_trans_dir.is_valid(); } - - //---------------------------------------------------------------- - void begin(double x, double y, unsigned len) - { - m_iterator = m_trans_dir.begin(x, y, 1.0); - double xt = m_iterator.x; - double yt = m_iterator.y; - - double dx; - double dy; - const double delta = 1/double(subpixel_scale); - dx = xt + delta; - dy = yt; - m_trans_inv.transform(&dx, &dy); - dx -= x; - dy -= y; - int sx1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - dx = xt; - dy = yt + delta; - m_trans_inv.transform(&dx, &dy); - dx -= x; - dy -= y; - int sy1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - x += len; - xt = x; - yt = y; - m_trans_dir.transform(&xt, &yt); - - dx = xt + delta; - dy = yt; - m_trans_inv.transform(&dx, &dy); - dx -= x; - dy -= y; - int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - dx = xt; - dy = yt + delta; - m_trans_inv.transform(&dx, &dy); - dx -= x; - dy -= y; - int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - m_scale_x = dda2_line_interpolator(sx1, sx2, len); - m_scale_y = dda2_line_interpolator(sy1, sy2, len); - } - - - //---------------------------------------------------------------- - void resynchronize(double xe, double ye, unsigned len) - { - // Assume x1,y1 are equal to the ones at the previous end point - int sx1 = m_scale_x.y(); - int sy1 = m_scale_y.y(); - - // Calculate transformed coordinates at x2,y2 - double xt = xe; - double yt = ye; - m_trans_dir.transform(&xt, &yt); - - const double delta = 1/double(subpixel_scale); - double dx; - double dy; - - // Calculate scale by X at x2,y2 - dx = xt + delta; - dy = yt; - m_trans_inv.transform(&dx, &dy); - dx -= xe; - dy -= ye; - int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - // Calculate scale by Y at x2,y2 - dx = xt; - dy = yt + delta; - m_trans_inv.transform(&dx, &dy); - dx -= xe; - dy -= ye; - int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - // Initialize the interpolators - m_scale_x = dda2_line_interpolator(sx1, sx2, len); - m_scale_y = dda2_line_interpolator(sy1, sy2, len); - } - - - - //---------------------------------------------------------------- - void operator++() - { - ++m_iterator; - ++m_scale_x; - ++m_scale_y; - } - - //---------------------------------------------------------------- - void coordinates(int* x, int* y) const - { - *x = iround(m_iterator.x * subpixel_scale); - *y = iround(m_iterator.y * subpixel_scale); - } - - //---------------------------------------------------------------- - void local_scale(int* x, int* y) - { - *x = m_scale_x.y(); - *y = m_scale_y.y(); - } - - //---------------------------------------------------------------- - void transform(double* x, double* y) const - { - m_trans_dir.transform(x, y); - } - - private: - trans_type m_trans_dir; - trans_type m_trans_inv; - iterator_type m_iterator; - dda2_line_interpolator m_scale_x; - dda2_line_interpolator m_scale_y; - }; - - - - - - - - - - - - //============================================span_interpolator_persp_lerp - template - class span_interpolator_persp_lerp - { - public: - typedef trans_perspective trans_type; - enum subpixel_scale_e - { - subpixel_shift = SubpixelShift, - subpixel_scale = 1 << subpixel_shift - }; - - //-------------------------------------------------------------------- - span_interpolator_persp_lerp() {} - - //-------------------------------------------------------------------- - // Arbitrary quadrangle transformations - span_interpolator_persp_lerp(const double* src, const double* dst) - { - quad_to_quad(src, dst); - } - - //-------------------------------------------------------------------- - // Direct transformations - span_interpolator_persp_lerp(double x1, double y1, - double x2, double y2, - const double* quad) - { - rect_to_quad(x1, y1, x2, y2, quad); - } - - //-------------------------------------------------------------------- - // Reverse transformations - span_interpolator_persp_lerp(const double* quad, - double x1, double y1, - double x2, double y2) - { - quad_to_rect(quad, x1, y1, x2, y2); - } - - //-------------------------------------------------------------------- - // Set the transformations using two arbitrary quadrangles. - void quad_to_quad(const double* src, const double* dst) - { - m_trans_dir.quad_to_quad(src, dst); - m_trans_inv.quad_to_quad(dst, src); - } - - //-------------------------------------------------------------------- - // Set the direct transformations, i.e., rectangle -> quadrangle - void rect_to_quad(double x1, double y1, double x2, double y2, - const double* quad) - { - double src[8]; - src[0] = src[6] = x1; - src[2] = src[4] = x2; - src[1] = src[3] = y1; - src[5] = src[7] = y2; - quad_to_quad(src, quad); - } - - - //-------------------------------------------------------------------- - // Set the reverse transformations, i.e., quadrangle -> rectangle - void quad_to_rect(const double* quad, - double x1, double y1, double x2, double y2) - { - double dst[8]; - dst[0] = dst[6] = x1; - dst[2] = dst[4] = x2; - dst[1] = dst[3] = y1; - dst[5] = dst[7] = y2; - quad_to_quad(quad, dst); - } - - //-------------------------------------------------------------------- - // Check if the equations were solved successfully - bool is_valid() const { return m_trans_dir.is_valid(); } - - //---------------------------------------------------------------- - void begin(double x, double y, unsigned len) - { - // Calculate transformed coordinates at x1,y1 - double xt = x; - double yt = y; - m_trans_dir.transform(&xt, &yt); - int x1 = iround(xt * subpixel_scale); - int y1 = iround(yt * subpixel_scale); - - double dx; - double dy; - const double delta = 1/double(subpixel_scale); - - // Calculate scale by X at x1,y1 - dx = xt + delta; - dy = yt; - m_trans_inv.transform(&dx, &dy); - dx -= x; - dy -= y; - int sx1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - // Calculate scale by Y at x1,y1 - dx = xt; - dy = yt + delta; - m_trans_inv.transform(&dx, &dy); - dx -= x; - dy -= y; - int sy1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - // Calculate transformed coordinates at x2,y2 - x += len; - xt = x; - yt = y; - m_trans_dir.transform(&xt, &yt); - int x2 = iround(xt * subpixel_scale); - int y2 = iround(yt * subpixel_scale); - - // Calculate scale by X at x2,y2 - dx = xt + delta; - dy = yt; - m_trans_inv.transform(&dx, &dy); - dx -= x; - dy -= y; - int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - // Calculate scale by Y at x2,y2 - dx = xt; - dy = yt + delta; - m_trans_inv.transform(&dx, &dy); - dx -= x; - dy -= y; - int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - // Initialize the interpolators - m_coord_x = dda2_line_interpolator(x1, x2, len); - m_coord_y = dda2_line_interpolator(y1, y2, len); - m_scale_x = dda2_line_interpolator(sx1, sx2, len); - m_scale_y = dda2_line_interpolator(sy1, sy2, len); - } - - - //---------------------------------------------------------------- - void resynchronize(double xe, double ye, unsigned len) - { - // Assume x1,y1 are equal to the ones at the previous end point - int x1 = m_coord_x.y(); - int y1 = m_coord_y.y(); - int sx1 = m_scale_x.y(); - int sy1 = m_scale_y.y(); - - // Calculate transformed coordinates at x2,y2 - double xt = xe; - double yt = ye; - m_trans_dir.transform(&xt, &yt); - int x2 = iround(xt * subpixel_scale); - int y2 = iround(yt * subpixel_scale); - - const double delta = 1/double(subpixel_scale); - double dx; - double dy; - - // Calculate scale by X at x2,y2 - dx = xt + delta; - dy = yt; - m_trans_inv.transform(&dx, &dy); - dx -= xe; - dy -= ye; - int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - // Calculate scale by Y at x2,y2 - dx = xt; - dy = yt + delta; - m_trans_inv.transform(&dx, &dy); - dx -= xe; - dy -= ye; - int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; - - // Initialize the interpolators - m_coord_x = dda2_line_interpolator(x1, x2, len); - m_coord_y = dda2_line_interpolator(y1, y2, len); - m_scale_x = dda2_line_interpolator(sx1, sx2, len); - m_scale_y = dda2_line_interpolator(sy1, sy2, len); - } - - - //---------------------------------------------------------------- - void operator++() - { - ++m_coord_x; - ++m_coord_y; - ++m_scale_x; - ++m_scale_y; - } - - //---------------------------------------------------------------- - void coordinates(int* x, int* y) const - { - *x = m_coord_x.y(); - *y = m_coord_y.y(); - } - - //---------------------------------------------------------------- - void local_scale(int* x, int* y) - { - *x = m_scale_x.y(); - *y = m_scale_y.y(); - } - - //---------------------------------------------------------------- - void transform(double* x, double* y) const - { - m_trans_dir.transform(x, y); - } - - private: - trans_type m_trans_dir; - trans_type m_trans_inv; - dda2_line_interpolator m_coord_x; - dda2_line_interpolator m_coord_y; - dda2_line_interpolator m_scale_x; - dda2_line_interpolator m_scale_y; - }; - -} - -#endif diff --git a/xs/src/agg/agg_span_interpolator_trans.h b/xs/src/agg/agg_span_interpolator_trans.h deleted file mode 100644 index 32bc678a8e..0000000000 --- a/xs/src/agg/agg_span_interpolator_trans.h +++ /dev/null @@ -1,92 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Horizontal span interpolator for use with an arbitrary transformer -// The efficiency highly depends on the operations done in the transformer -// -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_INTERPOLATOR_TRANS_INCLUDED -#define AGG_SPAN_INTERPOLATOR_TRANS_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - //=================================================span_interpolator_trans - template - class span_interpolator_trans - { - public: - typedef Transformer trans_type; - enum subpixel_scale_e - { - subpixel_shift = SubpixelShift, - subpixel_scale = 1 << subpixel_shift - }; - - //-------------------------------------------------------------------- - span_interpolator_trans() {} - span_interpolator_trans(trans_type& trans) : m_trans(&trans) {} - span_interpolator_trans(trans_type& trans, - double x, double y, unsigned) : - m_trans(&trans) - { - begin(x, y, 0); - } - - //---------------------------------------------------------------- - const trans_type& transformer() const { return *m_trans; } - void transformer(const trans_type& trans) { m_trans = &trans; } - - //---------------------------------------------------------------- - void begin(double x, double y, unsigned) - { - m_x = x; - m_y = y; - m_trans->transform(&x, &y); - m_ix = iround(x * subpixel_scale); - m_iy = iround(y * subpixel_scale); - } - - //---------------------------------------------------------------- - void operator++() - { - m_x += 1.0; - double x = m_x; - double y = m_y; - m_trans->transform(&x, &y); - m_ix = iround(x * subpixel_scale); - m_iy = iround(y * subpixel_scale); - } - - //---------------------------------------------------------------- - void coordinates(int* x, int* y) const - { - *x = m_ix; - *y = m_iy; - } - - private: - trans_type* m_trans; - double m_x; - double m_y; - int m_ix; - int m_iy; - }; - -} - -#endif diff --git a/xs/src/agg/agg_span_pattern_gray.h b/xs/src/agg/agg_span_pattern_gray.h deleted file mode 100644 index ae1a49f879..0000000000 --- a/xs/src/agg/agg_span_pattern_gray.h +++ /dev/null @@ -1,93 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - - -#ifndef AGG_SPAN_PATTERN_GRAY_INCLUDED -#define AGG_SPAN_PATTERN_GRAY_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //=======================================================span_pattern_gray - template class span_pattern_gray - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - - //-------------------------------------------------------------------- - span_pattern_gray() {} - span_pattern_gray(source_type& src, - unsigned offset_x, unsigned offset_y) : - m_src(&src), - m_offset_x(offset_x), - m_offset_y(offset_y), - m_alpha(color_type::base_mask) - {} - - //-------------------------------------------------------------------- - void attach(source_type& v) { m_src = &v; } - source_type& source() { return *m_src; } - const source_type& source() const { return *m_src; } - - //-------------------------------------------------------------------- - void offset_x(unsigned v) { m_offset_x = v; } - void offset_y(unsigned v) { m_offset_y = v; } - unsigned offset_x() const { return m_offset_x; } - unsigned offset_y() const { return m_offset_y; } - void alpha(value_type v) { m_alpha = v; } - value_type alpha() const { return m_alpha; } - - //-------------------------------------------------------------------- - void prepare() {} - void generate(color_type* span, int x, int y, unsigned len) - { - x += m_offset_x; - y += m_offset_y; - const value_type* p = (const value_type*)m_src->span(x, y, len); - do - { - span->v = *p; - span->a = m_alpha; - p = m_src->next_x(); - ++span; - } - while(--len); - } - - private: - source_type* m_src; - unsigned m_offset_x; - unsigned m_offset_y; - value_type m_alpha; - - }; - -} - -#endif - diff --git a/xs/src/agg/agg_span_pattern_rgb.h b/xs/src/agg/agg_span_pattern_rgb.h deleted file mode 100644 index 4850508af1..0000000000 --- a/xs/src/agg/agg_span_pattern_rgb.h +++ /dev/null @@ -1,96 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - - -#ifndef AGG_SPAN_PATTERN_RGB_INCLUDED -#define AGG_SPAN_PATTERN_RGB_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //========================================================span_pattern_rgb - template class span_pattern_rgb - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - - //-------------------------------------------------------------------- - span_pattern_rgb() {} - span_pattern_rgb(source_type& src, - unsigned offset_x, unsigned offset_y) : - m_src(&src), - m_offset_x(offset_x), - m_offset_y(offset_y), - m_alpha(color_type::base_mask) - {} - - //-------------------------------------------------------------------- - void attach(source_type& v) { m_src = &v; } - source_type& source() { return *m_src; } - const source_type& source() const { return *m_src; } - - //-------------------------------------------------------------------- - void offset_x(unsigned v) { m_offset_x = v; } - void offset_y(unsigned v) { m_offset_y = v; } - unsigned offset_x() const { return m_offset_x; } - unsigned offset_y() const { return m_offset_y; } - void alpha(value_type v) { m_alpha = v; } - value_type alpha() const { return m_alpha; } - - //-------------------------------------------------------------------- - void prepare() {} - void generate(color_type* span, int x, int y, unsigned len) - { - x += m_offset_x; - y += m_offset_y; - const value_type* p = (const value_type*)m_src->span(x, y, len); - do - { - span->r = p[order_type::R]; - span->g = p[order_type::G]; - span->b = p[order_type::B]; - span->a = m_alpha; - p = m_src->next_x(); - ++span; - } - while(--len); - } - - private: - source_type* m_src; - unsigned m_offset_x; - unsigned m_offset_y; - value_type m_alpha; - - }; - -} - -#endif - diff --git a/xs/src/agg/agg_span_pattern_rgba.h b/xs/src/agg/agg_span_pattern_rgba.h deleted file mode 100644 index d47d2a6c02..0000000000 --- a/xs/src/agg/agg_span_pattern_rgba.h +++ /dev/null @@ -1,94 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Adaptation for high precision colors has been sponsored by -// Liberty Technology Systems, Inc., visit http://lib-sys.com -// -// Liberty Technology Systems, Inc. is the provider of -// PostScript and PDF technology for software developers. -// -//---------------------------------------------------------------------------- - - -#ifndef AGG_SPAN_PATTERN_RGBA_INCLUDED -#define AGG_SPAN_PATTERN_RGBA_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //======================================================span_pattern_rgba - template class span_pattern_rgba - { - public: - typedef Source source_type; - typedef typename source_type::color_type color_type; - typedef typename source_type::order_type order_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - - //-------------------------------------------------------------------- - span_pattern_rgba() {} - span_pattern_rgba(source_type& src, - unsigned offset_x, unsigned offset_y) : - m_src(&src), - m_offset_x(offset_x), - m_offset_y(offset_y) - {} - - //-------------------------------------------------------------------- - void attach(source_type& v) { m_src = &v; } - source_type& source() { return *m_src; } - const source_type& source() const { return *m_src; } - - //-------------------------------------------------------------------- - void offset_x(unsigned v) { m_offset_x = v; } - void offset_y(unsigned v) { m_offset_y = v; } - unsigned offset_x() const { return m_offset_x; } - unsigned offset_y() const { return m_offset_y; } - void alpha(value_type) {} - value_type alpha() const { return 0; } - - //-------------------------------------------------------------------- - void prepare() {} - void generate(color_type* span, int x, int y, unsigned len) - { - x += m_offset_x; - y += m_offset_y; - const value_type* p = (const value_type*)m_src->span(x, y, len); - do - { - span->r = p[order_type::R]; - span->g = p[order_type::G]; - span->b = p[order_type::B]; - span->a = p[order_type::A]; - p = (const value_type*)m_src->next_x(); - ++span; - } - while(--len); - } - - private: - source_type* m_src; - unsigned m_offset_x; - unsigned m_offset_y; - - }; - -} - -#endif - diff --git a/xs/src/agg/agg_span_solid.h b/xs/src/agg/agg_span_solid.h deleted file mode 100644 index ee46df9991..0000000000 --- a/xs/src/agg/agg_span_solid.h +++ /dev/null @@ -1,53 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// span_solid_rgba8 -// -//---------------------------------------------------------------------------- - -#ifndef AGG_SPAN_SOLID_INCLUDED -#define AGG_SPAN_SOLID_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - //--------------------------------------------------------------span_solid - template class span_solid - { - public: - typedef ColorT color_type; - - //-------------------------------------------------------------------- - void color(const color_type& c) { m_color = c; } - const color_type& color() const { return m_color; } - - //-------------------------------------------------------------------- - void prepare() {} - - //-------------------------------------------------------------------- - void generate(color_type* span, int x, int y, unsigned len) - { - do { *span++ = m_color; } while(--len); - } - - private: - color_type m_color; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_span_subdiv_adaptor.h b/xs/src/agg/agg_span_subdiv_adaptor.h deleted file mode 100644 index b5b855ec97..0000000000 --- a/xs/src/agg/agg_span_subdiv_adaptor.h +++ /dev/null @@ -1,141 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -#ifndef AGG_SPAN_SUBDIV_ADAPTOR_INCLUDED -#define AGG_SPAN_SUBDIV_ADAPTOR_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //=================================================span_subdiv_adaptor - template - class span_subdiv_adaptor - { - public: - typedef Interpolator interpolator_type; - typedef typename interpolator_type::trans_type trans_type; - - enum sublixel_scale_e - { - subpixel_shift = SubpixelShift, - subpixel_scale = 1 << subpixel_shift - }; - - - //---------------------------------------------------------------- - span_subdiv_adaptor() : - m_subdiv_shift(4), - m_subdiv_size(1 << m_subdiv_shift), - m_subdiv_mask(m_subdiv_size - 1) {} - - span_subdiv_adaptor(interpolator_type& interpolator, - unsigned subdiv_shift = 4) : - m_subdiv_shift(subdiv_shift), - m_subdiv_size(1 << m_subdiv_shift), - m_subdiv_mask(m_subdiv_size - 1), - m_interpolator(&interpolator) {} - - span_subdiv_adaptor(interpolator_type& interpolator, - double x, double y, unsigned len, - unsigned subdiv_shift = 4) : - m_subdiv_shift(subdiv_shift), - m_subdiv_size(1 << m_subdiv_shift), - m_subdiv_mask(m_subdiv_size - 1), - m_interpolator(&interpolator) - { - begin(x, y, len); - } - - - //---------------------------------------------------------------- - const interpolator_type& interpolator() const { return *m_interpolator; } - void interpolator(interpolator_type& intr) { m_interpolator = &intr; } - - //---------------------------------------------------------------- - const trans_type& transformer() const - { - return *m_interpolator->transformer(); - } - void transformer(const trans_type& trans) - { - m_interpolator->transformer(trans); - } - - //---------------------------------------------------------------- - unsigned subdiv_shift() const { return m_subdiv_shift; } - void subdiv_shift(unsigned shift) - { - m_subdiv_shift = shift; - m_subdiv_size = 1 << m_subdiv_shift; - m_subdiv_mask = m_subdiv_size - 1; - } - - //---------------------------------------------------------------- - void begin(double x, double y, unsigned len) - { - m_pos = 1; - m_src_x = iround(x * subpixel_scale) + subpixel_scale; - m_src_y = y; - m_len = len; - if(len > m_subdiv_size) len = m_subdiv_size; - m_interpolator->begin(x, y, len); - } - - //---------------------------------------------------------------- - void operator++() - { - ++(*m_interpolator); - if(m_pos >= m_subdiv_size) - { - unsigned len = m_len; - if(len > m_subdiv_size) len = m_subdiv_size; - m_interpolator->resynchronize(double(m_src_x) / double(subpixel_scale) + len, - m_src_y, - len); - m_pos = 0; - } - m_src_x += subpixel_scale; - ++m_pos; - --m_len; - } - - //---------------------------------------------------------------- - void coordinates(int* x, int* y) const - { - m_interpolator->coordinates(x, y); - } - - //---------------------------------------------------------------- - void local_scale(int* x, int* y) const - { - m_interpolator->local_scale(x, y); - } - - - private: - unsigned m_subdiv_shift; - unsigned m_subdiv_size; - unsigned m_subdiv_mask; - interpolator_type* m_interpolator; - int m_src_x; - double m_src_y; - unsigned m_pos; - unsigned m_len; - }; - -} - -#endif diff --git a/xs/src/agg/agg_trans_bilinear.h b/xs/src/agg/agg_trans_bilinear.h deleted file mode 100644 index f3ab596472..0000000000 --- a/xs/src/agg/agg_trans_bilinear.h +++ /dev/null @@ -1,166 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Bilinear 2D transformations -// -//---------------------------------------------------------------------------- -#ifndef AGG_TRANS_BILINEAR_INCLUDED -#define AGG_TRANS_BILINEAR_INCLUDED - -#include "agg_basics.h" -#include "agg_simul_eq.h" - -namespace agg -{ - - //==========================================================trans_bilinear - class trans_bilinear - { - public: - //-------------------------------------------------------------------- - trans_bilinear() : m_valid(false) {} - - //-------------------------------------------------------------------- - // Arbitrary quadrangle transformations - trans_bilinear(const double* src, const double* dst) - { - quad_to_quad(src, dst); - } - - - //-------------------------------------------------------------------- - // Direct transformations - trans_bilinear(double x1, double y1, double x2, double y2, - const double* quad) - { - rect_to_quad(x1, y1, x2, y2, quad); - } - - - //-------------------------------------------------------------------- - // Reverse transformations - trans_bilinear(const double* quad, - double x1, double y1, double x2, double y2) - { - quad_to_rect(quad, x1, y1, x2, y2); - } - - - //-------------------------------------------------------------------- - // Set the transformations using two arbitrary quadrangles. - void quad_to_quad(const double* src, const double* dst) - { - double left[4][4]; - double right[4][2]; - - unsigned i; - for(i = 0; i < 4; i++) - { - unsigned ix = i * 2; - unsigned iy = ix + 1; - left[i][0] = 1.0; - left[i][1] = src[ix] * src[iy]; - left[i][2] = src[ix]; - left[i][3] = src[iy]; - - right[i][0] = dst[ix]; - right[i][1] = dst[iy]; - } - m_valid = simul_eq<4, 2>::solve(left, right, m_mtx); - } - - - //-------------------------------------------------------------------- - // Set the direct transformations, i.e., rectangle -> quadrangle - void rect_to_quad(double x1, double y1, double x2, double y2, - const double* quad) - { - double src[8]; - src[0] = src[6] = x1; - src[2] = src[4] = x2; - src[1] = src[3] = y1; - src[5] = src[7] = y2; - quad_to_quad(src, quad); - } - - - //-------------------------------------------------------------------- - // Set the reverse transformations, i.e., quadrangle -> rectangle - void quad_to_rect(const double* quad, - double x1, double y1, double x2, double y2) - { - double dst[8]; - dst[0] = dst[6] = x1; - dst[2] = dst[4] = x2; - dst[1] = dst[3] = y1; - dst[5] = dst[7] = y2; - quad_to_quad(quad, dst); - } - - //-------------------------------------------------------------------- - // Check if the equations were solved successfully - bool is_valid() const { return m_valid; } - - //-------------------------------------------------------------------- - // Transform a point (x, y) - void transform(double* x, double* y) const - { - double tx = *x; - double ty = *y; - double xy = tx * ty; - *x = m_mtx[0][0] + m_mtx[1][0] * xy + m_mtx[2][0] * tx + m_mtx[3][0] * ty; - *y = m_mtx[0][1] + m_mtx[1][1] * xy + m_mtx[2][1] * tx + m_mtx[3][1] * ty; - } - - - //-------------------------------------------------------------------- - class iterator_x - { - double inc_x; - double inc_y; - - public: - double x; - double y; - - iterator_x() {} - iterator_x(double tx, double ty, double step, const double m[4][2]) : - inc_x(m[1][0] * step * ty + m[2][0] * step), - inc_y(m[1][1] * step * ty + m[2][1] * step), - x(m[0][0] + m[1][0] * tx * ty + m[2][0] * tx + m[3][0] * ty), - y(m[0][1] + m[1][1] * tx * ty + m[2][1] * tx + m[3][1] * ty) - { - } - - void operator ++ () - { - x += inc_x; - y += inc_y; - } - }; - - iterator_x begin(double x, double y, double step) const - { - return iterator_x(x, y, step, m_mtx); - } - - private: - double m_mtx[4][2]; - bool m_valid; - }; - -} - -#endif diff --git a/xs/src/agg/agg_trans_double_path.h b/xs/src/agg/agg_trans_double_path.h deleted file mode 100644 index c645a7f869..0000000000 --- a/xs/src/agg/agg_trans_double_path.h +++ /dev/null @@ -1,131 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_TRANS_DOUBLE_PATH_INCLUDED -#define AGG_TRANS_DOUBLE_PATH_INCLUDED - -#include "agg_basics.h" -#include "agg_vertex_sequence.h" - -namespace agg -{ - - // See also: agg_trans_double_path.cpp - // - //-------------------------------------------------------trans_double_path - class trans_double_path - { - enum status_e - { - initial, - making_path, - ready - }; - - public: - typedef vertex_sequence vertex_storage; - - trans_double_path(); - - //-------------------------------------------------------------------- - void base_length(double v) { m_base_length = v; } - double base_length() const { return m_base_length; } - - //-------------------------------------------------------------------- - void base_height(double v) { m_base_height = v; } - double base_height() const { return m_base_height; } - - //-------------------------------------------------------------------- - void preserve_x_scale(bool f) { m_preserve_x_scale = f; } - bool preserve_x_scale() const { return m_preserve_x_scale; } - - //-------------------------------------------------------------------- - void reset(); - void move_to1(double x, double y); - void line_to1(double x, double y); - void move_to2(double x, double y); - void line_to2(double x, double y); - void finalize_paths(); - - //-------------------------------------------------------------------- - template - void add_paths(VertexSource1& vs1, VertexSource2& vs2, - unsigned path1_id=0, unsigned path2_id=0) - { - double x; - double y; - - unsigned cmd; - - vs1.rewind(path1_id); - while(!is_stop(cmd = vs1.vertex(&x, &y))) - { - if(is_move_to(cmd)) - { - move_to1(x, y); - } - else - { - if(is_vertex(cmd)) - { - line_to1(x, y); - } - } - } - - vs2.rewind(path2_id); - while(!is_stop(cmd = vs2.vertex(&x, &y))) - { - if(is_move_to(cmd)) - { - move_to2(x, y); - } - else - { - if(is_vertex(cmd)) - { - line_to2(x, y); - } - } - } - finalize_paths(); - } - - //-------------------------------------------------------------------- - double total_length1() const; - double total_length2() const; - void transform(double *x, double *y) const; - - private: - double finalize_path(vertex_storage& vertices); - void transform1(const vertex_storage& vertices, - double kindex, double kx, - double *x, double* y) const; - - vertex_storage m_src_vertices1; - vertex_storage m_src_vertices2; - double m_base_length; - double m_base_height; - double m_kindex1; - double m_kindex2; - status_e m_status1; - status_e m_status2; - bool m_preserve_x_scale; - }; - -} - - -#endif diff --git a/xs/src/agg/agg_trans_perspective.h b/xs/src/agg/agg_trans_perspective.h deleted file mode 100644 index 7d4aa26c79..0000000000 --- a/xs/src/agg/agg_trans_perspective.h +++ /dev/null @@ -1,731 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Perspective 2D transformations -// -//---------------------------------------------------------------------------- -#ifndef AGG_TRANS_PERSPECTIVE_INCLUDED -#define AGG_TRANS_PERSPECTIVE_INCLUDED - -#include "agg_trans_affine.h" - -namespace agg -{ - //=======================================================trans_perspective - struct trans_perspective - { - double sx, shy, w0, shx, sy, w1, tx, ty, w2; - - //------------------------------------------------------- Construction - // Identity matrix - trans_perspective() : - sx (1), shy(0), w0(0), - shx(0), sy (1), w1(0), - tx (0), ty (0), w2(1) {} - - // Custom matrix - trans_perspective(double v0, double v1, double v2, - double v3, double v4, double v5, - double v6, double v7, double v8) : - sx (v0), shy(v1), w0(v2), - shx(v3), sy (v4), w1(v5), - tx (v6), ty (v7), w2(v8) {} - - // Custom matrix from m[9] - explicit trans_perspective(const double* m) : - sx (m[0]), shy(m[1]), w0(m[2]), - shx(m[3]), sy (m[4]), w1(m[5]), - tx (m[6]), ty (m[7]), w2(m[8]) {} - - // From affine - explicit trans_perspective(const trans_affine& a) : - sx (a.sx ), shy(a.shy), w0(0), - shx(a.shx), sy (a.sy ), w1(0), - tx (a.tx ), ty (a.ty ), w2(1) {} - - // Rectangle to quadrilateral - trans_perspective(double x1, double y1, double x2, double y2, - const double* quad); - - // Quadrilateral to rectangle - trans_perspective(const double* quad, - double x1, double y1, double x2, double y2); - - // Arbitrary quadrilateral transformations - trans_perspective(const double* src, const double* dst); - - //-------------------------------------- Quadrilateral transformations - // The arguments are double[8] that are mapped to quadrilaterals: - // x1,y1, x2,y2, x3,y3, x4,y4 - bool quad_to_quad(const double* qs, const double* qd); - - bool rect_to_quad(double x1, double y1, - double x2, double y2, - const double* q); - - bool quad_to_rect(const double* q, - double x1, double y1, - double x2, double y2); - - // Map square (0,0,1,1) to the quadrilateral and vice versa - bool square_to_quad(const double* q); - bool quad_to_square(const double* q); - - - //--------------------------------------------------------- Operations - // Reset - load an identity matrix - const trans_perspective& reset(); - - // Invert matrix. Returns false in degenerate case - bool invert(); - - // Direct transformations operations - const trans_perspective& translate(double x, double y); - const trans_perspective& rotate(double a); - const trans_perspective& scale(double s); - const trans_perspective& scale(double x, double y); - - // Multiply the matrix by another one - const trans_perspective& multiply(const trans_perspective& m); - - // Multiply "m" by "this" and assign the result to "this" - const trans_perspective& premultiply(const trans_perspective& m); - - // Multiply matrix to inverse of another one - const trans_perspective& multiply_inv(const trans_perspective& m); - - // Multiply inverse of "m" by "this" and assign the result to "this" - const trans_perspective& premultiply_inv(const trans_perspective& m); - - // Multiply the matrix by another one - const trans_perspective& multiply(const trans_affine& m); - - // Multiply "m" by "this" and assign the result to "this" - const trans_perspective& premultiply(const trans_affine& m); - - // Multiply the matrix by inverse of another one - const trans_perspective& multiply_inv(const trans_affine& m); - - // Multiply inverse of "m" by "this" and assign the result to "this" - const trans_perspective& premultiply_inv(const trans_affine& m); - - //--------------------------------------------------------- Load/Store - void store_to(double* m) const; - const trans_perspective& load_from(const double* m); - - //---------------------------------------------------------- Operators - // Multiply the matrix by another one - const trans_perspective& operator *= (const trans_perspective& m) - { - return multiply(m); - } - const trans_perspective& operator *= (const trans_affine& m) - { - return multiply(m); - } - - // Multiply the matrix by inverse of another one - const trans_perspective& operator /= (const trans_perspective& m) - { - return multiply_inv(m); - } - const trans_perspective& operator /= (const trans_affine& m) - { - return multiply_inv(m); - } - - // Multiply the matrix by another one and return - // the result in a separete matrix. - trans_perspective operator * (const trans_perspective& m) const - { - return trans_perspective(*this).multiply(m); - } - trans_perspective operator * (const trans_affine& m) const - { - return trans_perspective(*this).multiply(m); - } - - // Multiply the matrix by inverse of another one - // and return the result in a separete matrix. - trans_perspective operator / (const trans_perspective& m) const - { - return trans_perspective(*this).multiply_inv(m); - } - trans_perspective operator / (const trans_affine& m) const - { - return trans_perspective(*this).multiply_inv(m); - } - - // Calculate and return the inverse matrix - trans_perspective operator ~ () const - { - trans_perspective ret = *this; - ret.invert(); - return ret; - } - - // Equal operator with default epsilon - bool operator == (const trans_perspective& m) const - { - return is_equal(m, affine_epsilon); - } - - // Not Equal operator with default epsilon - bool operator != (const trans_perspective& m) const - { - return !is_equal(m, affine_epsilon); - } - - //---------------------------------------------------- Transformations - // Direct transformation of x and y - void transform(double* x, double* y) const; - - // Direct transformation of x and y, affine part only - void transform_affine(double* x, double* y) const; - - // Direct transformation of x and y, 2x2 matrix only, no translation - void transform_2x2(double* x, double* y) const; - - // Inverse transformation of x and y. It works slow because - // it explicitly inverts the matrix on every call. For massive - // operations it's better to invert() the matrix and then use - // direct transformations. - void inverse_transform(double* x, double* y) const; - - - //---------------------------------------------------------- Auxiliary - const trans_perspective& from_affine(const trans_affine& a); - double determinant() const; - double determinant_reciprocal() const; - - bool is_valid(double epsilon = affine_epsilon) const; - bool is_identity(double epsilon = affine_epsilon) const; - bool is_equal(const trans_perspective& m, - double epsilon = affine_epsilon) const; - - // Determine the major affine parameters. Use with caution - // considering possible degenerate cases. - double scale() const; - double rotation() const; - void translation(double* dx, double* dy) const; - void scaling(double* x, double* y) const; - void scaling_abs(double* x, double* y) const; - - - - //-------------------------------------------------------------------- - class iterator_x - { - double den; - double den_step; - double nom_x; - double nom_x_step; - double nom_y; - double nom_y_step; - - public: - double x; - double y; - - iterator_x() {} - iterator_x(double px, double py, double step, const trans_perspective& m) : - den(px * m.w0 + py * m.w1 + m.w2), - den_step(m.w0 * step), - nom_x(px * m.sx + py * m.shx + m.tx), - nom_x_step(step * m.sx), - nom_y(px * m.shy + py * m.sy + m.ty), - nom_y_step(step * m.shy), - x(nom_x / den), - y(nom_y / den) - {} - - void operator ++ () - { - den += den_step; - nom_x += nom_x_step; - nom_y += nom_y_step; - double d = 1.0 / den; - x = nom_x * d; - y = nom_y * d; - } - }; - - //-------------------------------------------------------------------- - iterator_x begin(double x, double y, double step) const - { - return iterator_x(x, y, step, *this); - } - }; - - - - - - - - - - - - - - - //------------------------------------------------------------------------ - inline bool trans_perspective::square_to_quad(const double* q) - { - double dx = q[0] - q[2] + q[4] - q[6]; - double dy = q[1] - q[3] + q[5] - q[7]; - if(dx == 0.0 && dy == 0.0) - { - // Affine case (parallelogram) - //--------------- - sx = q[2] - q[0]; - shy = q[3] - q[1]; - w0 = 0.0; - shx = q[4] - q[2]; - sy = q[5] - q[3]; - w1 = 0.0; - tx = q[0]; - ty = q[1]; - w2 = 1.0; - } - else - { - double dx1 = q[2] - q[4]; - double dy1 = q[3] - q[5]; - double dx2 = q[6] - q[4]; - double dy2 = q[7] - q[5]; - double den = dx1 * dy2 - dx2 * dy1; - if(den == 0.0) - { - // Singular case - //--------------- - sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0; - return false; - } - // General case - //--------------- - double u = (dx * dy2 - dy * dx2) / den; - double v = (dy * dx1 - dx * dy1) / den; - sx = q[2] - q[0] + u * q[2]; - shy = q[3] - q[1] + u * q[3]; - w0 = u; - shx = q[6] - q[0] + v * q[6]; - sy = q[7] - q[1] + v * q[7]; - w1 = v; - tx = q[0]; - ty = q[1]; - w2 = 1.0; - } - return true; - } - - //------------------------------------------------------------------------ - inline bool trans_perspective::invert() - { - double d0 = sy * w2 - w1 * ty; - double d1 = w0 * ty - shy * w2; - double d2 = shy * w1 - w0 * sy; - double d = sx * d0 + shx * d1 + tx * d2; - if(d == 0.0) - { - sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0; - return false; - } - d = 1.0 / d; - trans_perspective a = *this; - sx = d * d0; - shy = d * d1; - w0 = d * d2; - shx = d * (a.w1 *a.tx - a.shx*a.w2); - sy = d * (a.sx *a.w2 - a.w0 *a.tx); - w1 = d * (a.w0 *a.shx - a.sx *a.w1); - tx = d * (a.shx*a.ty - a.sy *a.tx); - ty = d * (a.shy*a.tx - a.sx *a.ty); - w2 = d * (a.sx *a.sy - a.shy*a.shx); - return true; - } - - //------------------------------------------------------------------------ - inline bool trans_perspective::quad_to_square(const double* q) - { - if(!square_to_quad(q)) return false; - invert(); - return true; - } - - //------------------------------------------------------------------------ - inline bool trans_perspective::quad_to_quad(const double* qs, - const double* qd) - { - trans_perspective p; - if(! quad_to_square(qs)) return false; - if(!p.square_to_quad(qd)) return false; - multiply(p); - return true; - } - - //------------------------------------------------------------------------ - inline bool trans_perspective::rect_to_quad(double x1, double y1, - double x2, double y2, - const double* q) - { - double r[8]; - r[0] = r[6] = x1; - r[2] = r[4] = x2; - r[1] = r[3] = y1; - r[5] = r[7] = y2; - return quad_to_quad(r, q); - } - - //------------------------------------------------------------------------ - inline bool trans_perspective::quad_to_rect(const double* q, - double x1, double y1, - double x2, double y2) - { - double r[8]; - r[0] = r[6] = x1; - r[2] = r[4] = x2; - r[1] = r[3] = y1; - r[5] = r[7] = y2; - return quad_to_quad(q, r); - } - - //------------------------------------------------------------------------ - inline trans_perspective::trans_perspective(double x1, double y1, - double x2, double y2, - const double* quad) - { - rect_to_quad(x1, y1, x2, y2, quad); - } - - //------------------------------------------------------------------------ - inline trans_perspective::trans_perspective(const double* quad, - double x1, double y1, - double x2, double y2) - { - quad_to_rect(quad, x1, y1, x2, y2); - } - - //------------------------------------------------------------------------ - inline trans_perspective::trans_perspective(const double* src, - const double* dst) - { - quad_to_quad(src, dst); - } - - //------------------------------------------------------------------------ - inline const trans_perspective& trans_perspective::reset() - { - sx = 1; shy = 0; w0 = 0; - shx = 0; sy = 1; w1 = 0; - tx = 0; ty = 0; w2 = 1; - return *this; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& - trans_perspective::multiply(const trans_perspective& a) - { - trans_perspective b = *this; - sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0; - shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1; - tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2; - shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0; - sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1; - ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2; - w0 = a.w0 *b.sx + a.w1 *b.shy + a.w2*b.w0; - w1 = a.w0 *b.shx + a.w1 *b.sy + a.w2*b.w1; - w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2*b.w2; - return *this; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& - trans_perspective::multiply(const trans_affine& a) - { - trans_perspective b = *this; - sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0; - shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1; - tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2; - shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0; - sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1; - ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2; - return *this; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& - trans_perspective::premultiply(const trans_perspective& b) - { - trans_perspective a = *this; - sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0; - shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1; - tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2; - shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0; - sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1; - ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2; - w0 = a.w0 *b.sx + a.w1 *b.shy + a.w2*b.w0; - w1 = a.w0 *b.shx + a.w1 *b.sy + a.w2*b.w1; - w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2*b.w2; - return *this; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& - trans_perspective::premultiply(const trans_affine& b) - { - trans_perspective a = *this; - sx = a.sx *b.sx + a.shx*b.shy; - shx = a.sx *b.shx + a.shx*b.sy; - tx = a.sx *b.tx + a.shx*b.ty + a.tx; - shy = a.shy*b.sx + a.sy *b.shy; - sy = a.shy*b.shx + a.sy *b.sy; - ty = a.shy*b.tx + a.sy *b.ty + a.ty; - w0 = a.w0 *b.sx + a.w1 *b.shy; - w1 = a.w0 *b.shx + a.w1 *b.sy; - w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2; - return *this; - } - - //------------------------------------------------------------------------ - const trans_perspective& - trans_perspective::multiply_inv(const trans_perspective& m) - { - trans_perspective t = m; - t.invert(); - return multiply(t); - } - - //------------------------------------------------------------------------ - const trans_perspective& - trans_perspective::multiply_inv(const trans_affine& m) - { - trans_affine t = m; - t.invert(); - return multiply(t); - } - - //------------------------------------------------------------------------ - const trans_perspective& - trans_perspective::premultiply_inv(const trans_perspective& m) - { - trans_perspective t = m; - t.invert(); - return *this = t.multiply(*this); - } - - //------------------------------------------------------------------------ - const trans_perspective& - trans_perspective::premultiply_inv(const trans_affine& m) - { - trans_perspective t(m); - t.invert(); - return *this = t.multiply(*this); - } - - //------------------------------------------------------------------------ - inline const trans_perspective& - trans_perspective::translate(double x, double y) - { - tx += x; - ty += y; - return *this; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& trans_perspective::rotate(double a) - { - multiply(trans_affine_rotation(a)); - return *this; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& trans_perspective::scale(double s) - { - multiply(trans_affine_scaling(s)); - return *this; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& trans_perspective::scale(double x, double y) - { - multiply(trans_affine_scaling(x, y)); - return *this; - } - - //------------------------------------------------------------------------ - inline void trans_perspective::transform(double* px, double* py) const - { - double x = *px; - double y = *py; - double m = 1.0 / (x*w0 + y*w1 + w2); - *px = m * (x*sx + y*shx + tx); - *py = m * (x*shy + y*sy + ty); - } - - //------------------------------------------------------------------------ - inline void trans_perspective::transform_affine(double* x, double* y) const - { - double tmp = *x; - *x = tmp * sx + *y * shx + tx; - *y = tmp * shy + *y * sy + ty; - } - - //------------------------------------------------------------------------ - inline void trans_perspective::transform_2x2(double* x, double* y) const - { - double tmp = *x; - *x = tmp * sx + *y * shx; - *y = tmp * shy + *y * sy; - } - - //------------------------------------------------------------------------ - inline void trans_perspective::inverse_transform(double* x, double* y) const - { - trans_perspective t(*this); - if(t.invert()) t.transform(x, y); - } - - //------------------------------------------------------------------------ - inline void trans_perspective::store_to(double* m) const - { - *m++ = sx; *m++ = shy; *m++ = w0; - *m++ = shx; *m++ = sy; *m++ = w1; - *m++ = tx; *m++ = ty; *m++ = w2; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& trans_perspective::load_from(const double* m) - { - sx = *m++; shy = *m++; w0 = *m++; - shx = *m++; sy = *m++; w1 = *m++; - tx = *m++; ty = *m++; w2 = *m++; - return *this; - } - - //------------------------------------------------------------------------ - inline const trans_perspective& - trans_perspective::from_affine(const trans_affine& a) - { - sx = a.sx; shy = a.shy; w0 = 0; - shx = a.shx; sy = a.sy; w1 = 0; - tx = a.tx; ty = a.ty; w2 = 1; - return *this; - } - - //------------------------------------------------------------------------ - inline double trans_perspective::determinant() const - { - return sx * (sy * w2 - ty * w1) + - shx * (ty * w0 - shy * w2) + - tx * (shy * w1 - sy * w0); - } - - //------------------------------------------------------------------------ - inline double trans_perspective::determinant_reciprocal() const - { - return 1.0 / determinant(); - } - - //------------------------------------------------------------------------ - inline bool trans_perspective::is_valid(double epsilon) const - { - return fabs(sx) > epsilon && fabs(sy) > epsilon && fabs(w2) > epsilon; - } - - //------------------------------------------------------------------------ - inline bool trans_perspective::is_identity(double epsilon) const - { - return is_equal_eps(sx, 1.0, epsilon) && - is_equal_eps(shy, 0.0, epsilon) && - is_equal_eps(w0, 0.0, epsilon) && - is_equal_eps(shx, 0.0, epsilon) && - is_equal_eps(sy, 1.0, epsilon) && - is_equal_eps(w1, 0.0, epsilon) && - is_equal_eps(tx, 0.0, epsilon) && - is_equal_eps(ty, 0.0, epsilon) && - is_equal_eps(w2, 1.0, epsilon); - } - - //------------------------------------------------------------------------ - inline bool trans_perspective::is_equal(const trans_perspective& m, - double epsilon) const - { - return is_equal_eps(sx, m.sx, epsilon) && - is_equal_eps(shy, m.shy, epsilon) && - is_equal_eps(w0, m.w0, epsilon) && - is_equal_eps(shx, m.shx, epsilon) && - is_equal_eps(sy, m.sy, epsilon) && - is_equal_eps(w1, m.w1, epsilon) && - is_equal_eps(tx, m.tx, epsilon) && - is_equal_eps(ty, m.ty, epsilon) && - is_equal_eps(w2, m.w2, epsilon); - } - - //------------------------------------------------------------------------ - inline double trans_perspective::scale() const - { - double x = 0.707106781 * sx + 0.707106781 * shx; - double y = 0.707106781 * shy + 0.707106781 * sy; - return sqrt(x*x + y*y); - } - - //------------------------------------------------------------------------ - inline double trans_perspective::rotation() const - { - double x1 = 0.0; - double y1 = 0.0; - double x2 = 1.0; - double y2 = 0.0; - transform(&x1, &y1); - transform(&x2, &y2); - return atan2(y2-y1, x2-x1); - } - - //------------------------------------------------------------------------ - void trans_perspective::translation(double* dx, double* dy) const - { - *dx = tx; - *dy = ty; - } - - //------------------------------------------------------------------------ - void trans_perspective::scaling(double* x, double* y) const - { - double x1 = 0.0; - double y1 = 0.0; - double x2 = 1.0; - double y2 = 1.0; - trans_perspective t(*this); - t *= trans_affine_rotation(-rotation()); - t.transform(&x1, &y1); - t.transform(&x2, &y2); - *x = x2 - x1; - *y = y2 - y1; - } - - //------------------------------------------------------------------------ - void trans_perspective::scaling_abs(double* x, double* y) const - { - *x = sqrt(sx * sx + shx * shx); - *y = sqrt(shy * shy + sy * sy); - } - - -} - -#endif - diff --git a/xs/src/agg/agg_trans_single_path.h b/xs/src/agg/agg_trans_single_path.h deleted file mode 100644 index 9f4bf53bdb..0000000000 --- a/xs/src/agg/agg_trans_single_path.h +++ /dev/null @@ -1,97 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_TRANS_SINGLE_PATH_INCLUDED -#define AGG_TRANS_SINGLE_PATH_INCLUDED - -#include "agg_basics.h" -#include "agg_vertex_sequence.h" - -namespace agg -{ - - // See also: agg_trans_single_path.cpp - // - //-------------------------------------------------------trans_single_path - class trans_single_path - { - enum status_e - { - initial, - making_path, - ready - }; - - public: - typedef vertex_sequence vertex_storage; - - trans_single_path(); - - //-------------------------------------------------------------------- - void base_length(double v) { m_base_length = v; } - double base_length() const { return m_base_length; } - - //-------------------------------------------------------------------- - void preserve_x_scale(bool f) { m_preserve_x_scale = f; } - bool preserve_x_scale() const { return m_preserve_x_scale; } - - //-------------------------------------------------------------------- - void reset(); - void move_to(double x, double y); - void line_to(double x, double y); - void finalize_path(); - - //-------------------------------------------------------------------- - template - void add_path(VertexSource& vs, unsigned path_id=0) - { - double x; - double y; - - unsigned cmd; - vs.rewind(path_id); - while(!is_stop(cmd = vs.vertex(&x, &y))) - { - if(is_move_to(cmd)) - { - move_to(x, y); - } - else - { - if(is_vertex(cmd)) - { - line_to(x, y); - } - } - } - finalize_path(); - } - - //-------------------------------------------------------------------- - double total_length() const; - void transform(double *x, double *y) const; - - private: - vertex_storage m_src_vertices; - double m_base_length; - double m_kindex; - status_e m_status; - bool m_preserve_x_scale; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_trans_viewport.h b/xs/src/agg/agg_trans_viewport.h deleted file mode 100644 index 7088f99078..0000000000 --- a/xs/src/agg/agg_trans_viewport.h +++ /dev/null @@ -1,303 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Viewport transformer - simple orthogonal conversions from world coordinates -// to screen (device) ones. -// -//---------------------------------------------------------------------------- - -#ifndef AGG_TRANS_VIEWPORT_INCLUDED -#define AGG_TRANS_VIEWPORT_INCLUDED - -#include -#include "agg_trans_affine.h" - - -namespace agg -{ - - enum aspect_ratio_e - { - aspect_ratio_stretch, - aspect_ratio_meet, - aspect_ratio_slice - }; - - - //----------------------------------------------------------trans_viewport - class trans_viewport - { - public: - //------------------------------------------------------------------- - trans_viewport() : - m_world_x1(0.0), - m_world_y1(0.0), - m_world_x2(1.0), - m_world_y2(1.0), - m_device_x1(0.0), - m_device_y1(0.0), - m_device_x2(1.0), - m_device_y2(1.0), - m_aspect(aspect_ratio_stretch), - m_is_valid(true), - m_align_x(0.5), - m_align_y(0.5), - m_wx1(0.0), - m_wy1(0.0), - m_wx2(1.0), - m_wy2(1.0), - m_dx1(0.0), - m_dy1(0.0), - m_kx(1.0), - m_ky(1.0) - {} - - //------------------------------------------------------------------- - void preserve_aspect_ratio(double alignx, - double aligny, - aspect_ratio_e aspect) - { - m_align_x = alignx; - m_align_y = aligny; - m_aspect = aspect; - update(); - } - - //------------------------------------------------------------------- - void device_viewport(double x1, double y1, double x2, double y2) - { - m_device_x1 = x1; - m_device_y1 = y1; - m_device_x2 = x2; - m_device_y2 = y2; - update(); - } - - //------------------------------------------------------------------- - void world_viewport(double x1, double y1, double x2, double y2) - { - m_world_x1 = x1; - m_world_y1 = y1; - m_world_x2 = x2; - m_world_y2 = y2; - update(); - } - - //------------------------------------------------------------------- - void device_viewport(double* x1, double* y1, double* x2, double* y2) const - { - *x1 = m_device_x1; - *y1 = m_device_y1; - *x2 = m_device_x2; - *y2 = m_device_y2; - } - - //------------------------------------------------------------------- - void world_viewport(double* x1, double* y1, double* x2, double* y2) const - { - *x1 = m_world_x1; - *y1 = m_world_y1; - *x2 = m_world_x2; - *y2 = m_world_y2; - } - - //------------------------------------------------------------------- - void world_viewport_actual(double* x1, double* y1, - double* x2, double* y2) const - { - *x1 = m_wx1; - *y1 = m_wy1; - *x2 = m_wx2; - *y2 = m_wy2; - } - - //------------------------------------------------------------------- - bool is_valid() const { return m_is_valid; } - double align_x() const { return m_align_x; } - double align_y() const { return m_align_y; } - aspect_ratio_e aspect_ratio() const { return m_aspect; } - - //------------------------------------------------------------------- - void transform(double* x, double* y) const - { - *x = (*x - m_wx1) * m_kx + m_dx1; - *y = (*y - m_wy1) * m_ky + m_dy1; - } - - //------------------------------------------------------------------- - void transform_scale_only(double* x, double* y) const - { - *x *= m_kx; - *y *= m_ky; - } - - //------------------------------------------------------------------- - void inverse_transform(double* x, double* y) const - { - *x = (*x - m_dx1) / m_kx + m_wx1; - *y = (*y - m_dy1) / m_ky + m_wy1; - } - - //------------------------------------------------------------------- - void inverse_transform_scale_only(double* x, double* y) const - { - *x /= m_kx; - *y /= m_ky; - } - - //------------------------------------------------------------------- - double device_dx() const { return m_dx1 - m_wx1 * m_kx; } - double device_dy() const { return m_dy1 - m_wy1 * m_ky; } - - //------------------------------------------------------------------- - double scale_x() const - { - return m_kx; - } - - //------------------------------------------------------------------- - double scale_y() const - { - return m_ky; - } - - //------------------------------------------------------------------- - double scale() const - { - return (m_kx + m_ky) * 0.5; - } - - //------------------------------------------------------------------- - trans_affine to_affine() const - { - trans_affine mtx = trans_affine_translation(-m_wx1, -m_wy1); - mtx *= trans_affine_scaling(m_kx, m_ky); - mtx *= trans_affine_translation(m_dx1, m_dy1); - return mtx; - } - - //------------------------------------------------------------------- - trans_affine to_affine_scale_only() const - { - return trans_affine_scaling(m_kx, m_ky); - } - - //------------------------------------------------------------------- - unsigned byte_size() const - { - return sizeof(*this); - } - - void serialize(int8u* ptr) const - { - memcpy(ptr, this, sizeof(*this)); - } - - void deserialize(const int8u* ptr) - { - memcpy(this, ptr, sizeof(*this)); - } - - private: - void update(); - - double m_world_x1; - double m_world_y1; - double m_world_x2; - double m_world_y2; - double m_device_x1; - double m_device_y1; - double m_device_x2; - double m_device_y2; - aspect_ratio_e m_aspect; - bool m_is_valid; - double m_align_x; - double m_align_y; - double m_wx1; - double m_wy1; - double m_wx2; - double m_wy2; - double m_dx1; - double m_dy1; - double m_kx; - double m_ky; - }; - - - - //----------------------------------------------------------------------- - inline void trans_viewport::update() - { - const double epsilon = 1e-30; - if(fabs(m_world_x1 - m_world_x2) < epsilon || - fabs(m_world_y1 - m_world_y2) < epsilon || - fabs(m_device_x1 - m_device_x2) < epsilon || - fabs(m_device_y1 - m_device_y2) < epsilon) - { - m_wx1 = m_world_x1; - m_wy1 = m_world_y1; - m_wx2 = m_world_x1 + 1.0; - m_wy2 = m_world_y2 + 1.0; - m_dx1 = m_device_x1; - m_dy1 = m_device_y1; - m_kx = 1.0; - m_ky = 1.0; - m_is_valid = false; - return; - } - - double world_x1 = m_world_x1; - double world_y1 = m_world_y1; - double world_x2 = m_world_x2; - double world_y2 = m_world_y2; - double device_x1 = m_device_x1; - double device_y1 = m_device_y1; - double device_x2 = m_device_x2; - double device_y2 = m_device_y2; - if(m_aspect != aspect_ratio_stretch) - { - double d; - m_kx = (device_x2 - device_x1) / (world_x2 - world_x1); - m_ky = (device_y2 - device_y1) / (world_y2 - world_y1); - - if((m_aspect == aspect_ratio_meet) == (m_kx < m_ky)) - { - d = (world_y2 - world_y1) * m_ky / m_kx; - world_y1 += (world_y2 - world_y1 - d) * m_align_y; - world_y2 = world_y1 + d; - } - else - { - d = (world_x2 - world_x1) * m_kx / m_ky; - world_x1 += (world_x2 - world_x1 - d) * m_align_x; - world_x2 = world_x1 + d; - } - } - m_wx1 = world_x1; - m_wy1 = world_y1; - m_wx2 = world_x2; - m_wy2 = world_y2; - m_dx1 = device_x1; - m_dy1 = device_y1; - m_kx = (device_x2 - device_x1) / (world_x2 - world_x1); - m_ky = (device_y2 - device_y1) / (world_y2 - world_y1); - m_is_valid = true; - } - - -} - - -#endif diff --git a/xs/src/agg/agg_trans_warp_magnifier.h b/xs/src/agg/agg_trans_warp_magnifier.h deleted file mode 100644 index 38a92dbec8..0000000000 --- a/xs/src/agg/agg_trans_warp_magnifier.h +++ /dev/null @@ -1,56 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_WARP_MAGNIFIER_INCLUDED -#define AGG_WARP_MAGNIFIER_INCLUDED - - -namespace agg -{ - - //----------------------------------------------------trans_warp_magnifier - // - // See Inmplementation agg_trans_warp_magnifier.cpp - // - class trans_warp_magnifier - { - public: - trans_warp_magnifier() : m_xc(0.0), m_yc(0.0), m_magn(1.0), m_radius(1.0) {} - - void center(double x, double y) { m_xc = x; m_yc = y; } - void magnification(double m) { m_magn = m; } - void radius(double r) { m_radius = r; } - - double xc() const { return m_xc; } - double yc() const { return m_yc; } - double magnification() const { return m_magn; } - double radius() const { return m_radius; } - - void transform(double* x, double* y) const; - void inverse_transform(double* x, double* y) const; - - private: - double m_xc; - double m_yc; - double m_magn; - double m_radius; - }; - - -} - - -#endif - diff --git a/xs/src/agg/agg_vcgen_bspline.h b/xs/src/agg/agg_vcgen_bspline.h deleted file mode 100644 index a2944548c0..0000000000 --- a/xs/src/agg/agg_vcgen_bspline.h +++ /dev/null @@ -1,74 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VCGEN_BSPLINE_INCLUDED -#define AGG_VCGEN_BSPLINE_INCLUDED - -#include "agg_basics.h" -#include "agg_array.h" -#include "agg_bspline.h" - - -namespace agg -{ - - //==========================================================vcgen_bspline - class vcgen_bspline - { - enum status_e - { - initial, - ready, - polygon, - end_poly, - stop - }; - - public: - typedef pod_bvector vertex_storage; - - vcgen_bspline(); - - void interpolation_step(double v) { m_interpolation_step = v; } - double interpolation_step() const { return m_interpolation_step; } - - // Vertex Generator Interface - void remove_all(); - void add_vertex(double x, double y, unsigned cmd); - - // Vertex Source Interface - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - vcgen_bspline(const vcgen_bspline&); - const vcgen_bspline& operator = (const vcgen_bspline&); - - vertex_storage m_src_vertices; - bspline m_spline_x; - bspline m_spline_y; - double m_interpolation_step; - unsigned m_closed; - status_e m_status; - unsigned m_src_vertex; - double m_cur_abscissa; - double m_max_abscissa; - }; - -} - - -#endif - diff --git a/xs/src/agg/agg_vcgen_contour.h b/xs/src/agg/agg_vcgen_contour.h deleted file mode 100644 index 8c25da13f5..0000000000 --- a/xs/src/agg/agg_vcgen_contour.h +++ /dev/null @@ -1,94 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VCGEN_CONTOUR_INCLUDED -#define AGG_VCGEN_CONTOUR_INCLUDED - -#include "agg_math_stroke.h" - -namespace agg -{ - - //----------------------------------------------------------vcgen_contour - // - // See Implementation agg_vcgen_contour.cpp - // - class vcgen_contour - { - enum status_e - { - initial, - ready, - outline, - out_vertices, - end_poly, - stop - }; - - public: - typedef vertex_sequence vertex_storage; - typedef pod_bvector coord_storage; - - vcgen_contour(); - - void line_cap(line_cap_e lc) { m_stroker.line_cap(lc); } - void line_join(line_join_e lj) { m_stroker.line_join(lj); } - void inner_join(inner_join_e ij) { m_stroker.inner_join(ij); } - - line_cap_e line_cap() const { return m_stroker.line_cap(); } - line_join_e line_join() const { return m_stroker.line_join(); } - inner_join_e inner_join() const { return m_stroker.inner_join(); } - - void width(double w) { m_stroker.width(m_width = w); } - void miter_limit(double ml) { m_stroker.miter_limit(ml); } - void miter_limit_theta(double t) { m_stroker.miter_limit_theta(t); } - void inner_miter_limit(double ml) { m_stroker.inner_miter_limit(ml); } - void approximation_scale(double as) { m_stroker.approximation_scale(as); } - - double width() const { return m_width; } - double miter_limit() const { return m_stroker.miter_limit(); } - double inner_miter_limit() const { return m_stroker.inner_miter_limit(); } - double approximation_scale() const { return m_stroker.approximation_scale(); } - - void auto_detect_orientation(bool v) { m_auto_detect = v; } - bool auto_detect_orientation() const { return m_auto_detect; } - - // Generator interface - void remove_all(); - void add_vertex(double x, double y, unsigned cmd); - - // Vertex Source Interface - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - vcgen_contour(const vcgen_contour&); - const vcgen_contour& operator = (const vcgen_contour&); - - math_stroke m_stroker; - double m_width; - vertex_storage m_src_vertices; - coord_storage m_out_vertices; - status_e m_status; - unsigned m_src_vertex; - unsigned m_out_vertex; - unsigned m_closed; - unsigned m_orientation; - bool m_auto_detect; - }; - -} - -#endif diff --git a/xs/src/agg/agg_vcgen_dash.h b/xs/src/agg/agg_vcgen_dash.h deleted file mode 100644 index c87dce4c81..0000000000 --- a/xs/src/agg/agg_vcgen_dash.h +++ /dev/null @@ -1,93 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// Line dash generator -// -//---------------------------------------------------------------------------- -#ifndef AGG_VCGEN_DASH_INCLUDED -#define AGG_VCGEN_DASH_INCLUDED - -#include "agg_basics.h" -#include "agg_vertex_sequence.h" - -namespace agg -{ - - //---------------------------------------------------------------vcgen_dash - // - // See Implementation agg_vcgen_dash.cpp - // - class vcgen_dash - { - enum max_dashes_e - { - max_dashes = 32 - }; - - enum status_e - { - initial, - ready, - polyline, - stop - }; - - public: - typedef vertex_sequence vertex_storage; - - vcgen_dash(); - - void remove_all_dashes(); - void add_dash(double dash_len, double gap_len); - void dash_start(double ds); - - void shorten(double s) { m_shorten = s; } - double shorten() const { return m_shorten; } - - // Vertex Generator Interface - void remove_all(); - void add_vertex(double x, double y, unsigned cmd); - - // Vertex Source Interface - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - vcgen_dash(const vcgen_dash&); - const vcgen_dash& operator = (const vcgen_dash&); - - void calc_dash_start(double ds); - - double m_dashes[max_dashes]; - double m_total_dash_len; - unsigned m_num_dashes; - double m_dash_start; - double m_shorten; - double m_curr_dash_start; - unsigned m_curr_dash; - double m_curr_rest; - const vertex_dist* m_v1; - const vertex_dist* m_v2; - - vertex_storage m_src_vertices; - unsigned m_closed; - status_e m_status; - unsigned m_src_vertex; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_vcgen_markers_term.h b/xs/src/agg/agg_vcgen_markers_term.h deleted file mode 100644 index ee1e74e3eb..0000000000 --- a/xs/src/agg/agg_vcgen_markers_term.h +++ /dev/null @@ -1,66 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VCGEN_MARKERS_TERM_INCLUDED -#define AGG_VCGEN_MARKERS_TERM_INCLUDED - -#include "agg_basics.h" -#include "agg_vertex_sequence.h" - -namespace agg -{ - - //======================================================vcgen_markers_term - // - // See Implemantation agg_vcgen_markers_term.cpp - // Terminal markers generator (arrowhead/arrowtail) - // - //------------------------------------------------------------------------ - class vcgen_markers_term - { - public: - vcgen_markers_term() : m_curr_id(0), m_curr_idx(0) {} - - // Vertex Generator Interface - void remove_all(); - void add_vertex(double x, double y, unsigned cmd); - - // Vertex Source Interface - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - vcgen_markers_term(const vcgen_markers_term&); - const vcgen_markers_term& operator = (const vcgen_markers_term&); - - struct coord_type - { - double x, y; - - coord_type() {} - coord_type(double x_, double y_) : x(x_), y(y_) {} - }; - - typedef pod_bvector coord_storage; - - coord_storage m_markers; - unsigned m_curr_id; - unsigned m_curr_idx; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_vcgen_smooth_poly1.h b/xs/src/agg/agg_vcgen_smooth_poly1.h deleted file mode 100644 index 80fc0fb796..0000000000 --- a/xs/src/agg/agg_vcgen_smooth_poly1.h +++ /dev/null @@ -1,87 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VCGEN_SMOOTH_POLY1_INCLUDED -#define AGG_VCGEN_SMOOTH_POLY1_INCLUDED - -#include "agg_basics.h" -#include "agg_vertex_sequence.h" - - -namespace agg -{ - - //======================================================vcgen_smooth_poly1 - // - // See Implementation agg_vcgen_smooth_poly1.cpp - // Smooth polygon generator - // - //------------------------------------------------------------------------ - class vcgen_smooth_poly1 - { - enum status_e - { - initial, - ready, - polygon, - ctrl_b, - ctrl_e, - ctrl1, - ctrl2, - end_poly, - stop - }; - - public: - typedef vertex_sequence vertex_storage; - - vcgen_smooth_poly1(); - - void smooth_value(double v) { m_smooth_value = v * 0.5; } - double smooth_value() const { return m_smooth_value * 2.0; } - - // Vertex Generator Interface - void remove_all(); - void add_vertex(double x, double y, unsigned cmd); - - // Vertex Source Interface - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - vcgen_smooth_poly1(const vcgen_smooth_poly1&); - const vcgen_smooth_poly1& operator = (const vcgen_smooth_poly1&); - - void calculate(const vertex_dist& v0, - const vertex_dist& v1, - const vertex_dist& v2, - const vertex_dist& v3); - - vertex_storage m_src_vertices; - double m_smooth_value; - unsigned m_closed; - status_e m_status; - unsigned m_src_vertex; - double m_ctrl1_x; - double m_ctrl1_y; - double m_ctrl2_x; - double m_ctrl2_y; - }; - -} - - -#endif - diff --git a/xs/src/agg/agg_vcgen_stroke.h b/xs/src/agg/agg_vcgen_stroke.h deleted file mode 100644 index 778223fe40..0000000000 --- a/xs/src/agg/agg_vcgen_stroke.h +++ /dev/null @@ -1,102 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VCGEN_STROKE_INCLUDED -#define AGG_VCGEN_STROKE_INCLUDED - -#include "agg_math_stroke.h" - - -namespace agg -{ - - //============================================================vcgen_stroke - // - // See Implementation agg_vcgen_stroke.cpp - // Stroke generator - // - //------------------------------------------------------------------------ - class vcgen_stroke - { - enum status_e - { - initial, - ready, - cap1, - cap2, - outline1, - close_first, - outline2, - out_vertices, - end_poly1, - end_poly2, - stop - }; - - public: - typedef vertex_sequence vertex_storage; - typedef pod_bvector coord_storage; - - vcgen_stroke(); - - void line_cap(line_cap_e lc) { m_stroker.line_cap(lc); } - void line_join(line_join_e lj) { m_stroker.line_join(lj); } - void inner_join(inner_join_e ij) { m_stroker.inner_join(ij); } - - line_cap_e line_cap() const { return m_stroker.line_cap(); } - line_join_e line_join() const { return m_stroker.line_join(); } - inner_join_e inner_join() const { return m_stroker.inner_join(); } - - void width(double w) { m_stroker.width(w); } - void miter_limit(double ml) { m_stroker.miter_limit(ml); } - void miter_limit_theta(double t) { m_stroker.miter_limit_theta(t); } - void inner_miter_limit(double ml) { m_stroker.inner_miter_limit(ml); } - void approximation_scale(double as) { m_stroker.approximation_scale(as); } - - double width() const { return m_stroker.width(); } - double miter_limit() const { return m_stroker.miter_limit(); } - double inner_miter_limit() const { return m_stroker.inner_miter_limit(); } - double approximation_scale() const { return m_stroker.approximation_scale(); } - - void shorten(double s) { m_shorten = s; } - double shorten() const { return m_shorten; } - - // Vertex Generator Interface - void remove_all(); - void add_vertex(double x, double y, unsigned cmd); - - // Vertex Source Interface - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - private: - vcgen_stroke(const vcgen_stroke&); - const vcgen_stroke& operator = (const vcgen_stroke&); - - math_stroke m_stroker; - vertex_storage m_src_vertices; - coord_storage m_out_vertices; - double m_shorten; - unsigned m_closed; - status_e m_status; - status_e m_prev_status; - unsigned m_src_vertex; - unsigned m_out_vertex; - }; - - -} - -#endif diff --git a/xs/src/agg/agg_vcgen_vertex_sequence.h b/xs/src/agg/agg_vcgen_vertex_sequence.h deleted file mode 100644 index 5adc671597..0000000000 --- a/xs/src/agg/agg_vcgen_vertex_sequence.h +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VCGEN_VERTEX_SEQUENCE_INCLUDED -#define AGG_VCGEN_VERTEX_SEQUENCE_INCLUDED - -#include "agg_basics.h" -#include "agg_vertex_sequence.h" -#include "agg_shorten_path.h" - -namespace agg -{ - - //===================================================vcgen_vertex_sequence - class vcgen_vertex_sequence - { - public: - typedef vertex_dist_cmd vertex_type; - typedef vertex_sequence vertex_storage; - - vcgen_vertex_sequence() : - m_flags(0), - m_cur_vertex(0), - m_shorten(0.0), - m_ready(false) - { - } - - // Vertex Generator Interface - void remove_all(); - void add_vertex(double x, double y, unsigned cmd); - - // Vertex Source Interface - void rewind(unsigned path_id); - unsigned vertex(double* x, double* y); - - void shorten(double s) { m_shorten = s; } - double shorten() const { return m_shorten; } - - private: - vcgen_vertex_sequence(const vcgen_vertex_sequence&); - const vcgen_vertex_sequence& operator = (const vcgen_vertex_sequence&); - - vertex_storage m_src_vertices; - unsigned m_flags; - unsigned m_cur_vertex; - double m_shorten; - bool m_ready; - }; - - - //------------------------------------------------------------------------ - inline void vcgen_vertex_sequence::remove_all() - { - m_ready = false; - m_src_vertices.remove_all(); - m_cur_vertex = 0; - m_flags = 0; - } - - //------------------------------------------------------------------------ - inline void vcgen_vertex_sequence::add_vertex(double x, double y, unsigned cmd) - { - m_ready = false; - if(is_move_to(cmd)) - { - m_src_vertices.modify_last(vertex_dist_cmd(x, y, cmd)); - } - else - { - if(is_vertex(cmd)) - { - m_src_vertices.add(vertex_dist_cmd(x, y, cmd)); - } - else - { - m_flags = cmd & path_flags_mask; - } - } - } - - - //------------------------------------------------------------------------ - inline void vcgen_vertex_sequence::rewind(unsigned) - { - if(!m_ready) - { - m_src_vertices.close(is_closed(m_flags)); - shorten_path(m_src_vertices, m_shorten, get_close_flag(m_flags)); - } - m_ready = true; - m_cur_vertex = 0; - } - - //------------------------------------------------------------------------ - inline unsigned vcgen_vertex_sequence::vertex(double* x, double* y) - { - if(!m_ready) - { - rewind(0); - } - - if(m_cur_vertex == m_src_vertices.size()) - { - ++m_cur_vertex; - return path_cmd_end_poly | m_flags; - } - - if(m_cur_vertex > m_src_vertices.size()) - { - return path_cmd_stop; - } - - vertex_type& v = m_src_vertices[m_cur_vertex++]; - *x = v.x; - *y = v.y; - return v.cmd; - } - - -} - -#endif diff --git a/xs/src/agg/agg_vertex_sequence.h b/xs/src/agg/agg_vertex_sequence.h deleted file mode 100644 index 2ad0701b37..0000000000 --- a/xs/src/agg/agg_vertex_sequence.h +++ /dev/null @@ -1,172 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- -// -// vertex_sequence container and vertex_dist struct -// -//---------------------------------------------------------------------------- -#ifndef AGG_VERTEX_SEQUENCE_INCLUDED -#define AGG_VERTEX_SEQUENCE_INCLUDED - -#include "agg_basics.h" -#include "agg_array.h" -#include "agg_math.h" - -namespace agg -{ - - //----------------------------------------------------------vertex_sequence - // Modified agg::pod_bvector. The data is interpreted as a sequence - // of vertices. It means that the type T must expose: - // - // bool T::operator() (const T& val) - // - // that is called every time new vertex is being added. The main purpose - // of this operator is the possibility to calculate some values during - // adding and to return true if the vertex fits some criteria or false if - // it doesn't. In the last case the new vertex is not added. - // - // The simple example is filtering coinciding vertices with calculation - // of the distance between the current and previous ones: - // - // struct vertex_dist - // { - // double x; - // double y; - // double dist; - // - // vertex_dist() {} - // vertex_dist(double x_, double y_) : - // x(x_), - // y(y_), - // dist(0.0) - // { - // } - // - // bool operator () (const vertex_dist& val) - // { - // return (dist = calc_distance(x, y, val.x, val.y)) > EPSILON; - // } - // }; - // - // Function close() calls this operator and removes the last vertex if - // necessary. - //------------------------------------------------------------------------ - template - class vertex_sequence : public pod_bvector - { - public: - typedef pod_bvector base_type; - - void add(const T& val); - void modify_last(const T& val); - void close(bool remove_flag); - }; - - - - //------------------------------------------------------------------------ - template - void vertex_sequence::add(const T& val) - { - if(base_type::size() > 1) - { - if(!(*this)[base_type::size() - 2]((*this)[base_type::size() - 1])) - { - base_type::remove_last(); - } - } - base_type::add(val); - } - - - //------------------------------------------------------------------------ - template - void vertex_sequence::modify_last(const T& val) - { - base_type::remove_last(); - add(val); - } - - - - //------------------------------------------------------------------------ - template - void vertex_sequence::close(bool closed) - { - while(base_type::size() > 1) - { - if((*this)[base_type::size() - 2]((*this)[base_type::size() - 1])) break; - T t = (*this)[base_type::size() - 1]; - base_type::remove_last(); - modify_last(t); - } - - if(closed) - { - while(base_type::size() > 1) - { - if((*this)[base_type::size() - 1]((*this)[0])) break; - base_type::remove_last(); - } - } - } - - - //-------------------------------------------------------------vertex_dist - // Vertex (x, y) with the distance to the next one. The last vertex has - // distance between the last and the first points if the polygon is closed - // and 0.0 if it's a polyline. - struct vertex_dist - { - double x; - double y; - double dist; - - vertex_dist() {} - vertex_dist(double x_, double y_) : - x(x_), - y(y_), - dist(0.0) - { - } - - bool operator () (const vertex_dist& val) - { - bool ret = (dist = calc_distance(x, y, val.x, val.y)) > vertex_dist_epsilon; - if(!ret) dist = 1.0 / vertex_dist_epsilon; - return ret; - } - }; - - - - //--------------------------------------------------------vertex_dist_cmd - // Save as the above but with additional "command" value - struct vertex_dist_cmd : public vertex_dist - { - unsigned cmd; - - vertex_dist_cmd() {} - vertex_dist_cmd(double x_, double y_, unsigned cmd_) : - vertex_dist(x_, y_), - cmd(cmd_) - { - } - }; - - -} - -#endif diff --git a/xs/src/agg/agg_vpgen_clip_polygon.h b/xs/src/agg/agg_vpgen_clip_polygon.h deleted file mode 100644 index ded754e211..0000000000 --- a/xs/src/agg/agg_vpgen_clip_polygon.h +++ /dev/null @@ -1,83 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VPGEN_CLIP_POLYGON_INCLUDED -#define AGG_VPGEN_CLIP_POLYGON_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //======================================================vpgen_clip_polygon - // - // See Implementation agg_vpgen_clip_polygon.cpp - // - class vpgen_clip_polygon - { - public: - vpgen_clip_polygon() : - m_clip_box(0, 0, 1, 1), - m_x1(0), - m_y1(0), - m_clip_flags(0), - m_num_vertices(0), - m_vertex(0), - m_cmd(path_cmd_move_to) - { - } - - void clip_box(double x1, double y1, double x2, double y2) - { - m_clip_box.x1 = x1; - m_clip_box.y1 = y1; - m_clip_box.x2 = x2; - m_clip_box.y2 = y2; - m_clip_box.normalize(); - } - - - double x1() const { return m_clip_box.x1; } - double y1() const { return m_clip_box.y1; } - double x2() const { return m_clip_box.x2; } - double y2() const { return m_clip_box.y2; } - - static bool auto_close() { return true; } - static bool auto_unclose() { return false; } - - void reset(); - void move_to(double x, double y); - void line_to(double x, double y); - unsigned vertex(double* x, double* y); - - private: - unsigned clipping_flags(double x, double y); - - private: - rect_d m_clip_box; - double m_x1; - double m_y1; - unsigned m_clip_flags; - double m_x[4]; - double m_y[4]; - unsigned m_num_vertices; - unsigned m_vertex; - unsigned m_cmd; - }; - -} - - -#endif diff --git a/xs/src/agg/agg_vpgen_clip_polyline.h b/xs/src/agg/agg_vpgen_clip_polyline.h deleted file mode 100644 index b070a7759e..0000000000 --- a/xs/src/agg/agg_vpgen_clip_polyline.h +++ /dev/null @@ -1,78 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VPGEN_CLIP_POLYLINE_INCLUDED -#define AGG_VPGEN_CLIP_POLYLINE_INCLUDED - -#include "agg_basics.h" - -namespace agg -{ - - //======================================================vpgen_clip_polyline - // - // See Implementation agg_vpgen_clip_polyline.cpp - // - class vpgen_clip_polyline - { - public: - vpgen_clip_polyline() : - m_clip_box(0, 0, 1, 1), - m_x1(0), - m_y1(0), - m_num_vertices(0), - m_vertex(0), - m_move_to(false) - { - } - - void clip_box(double x1, double y1, double x2, double y2) - { - m_clip_box.x1 = x1; - m_clip_box.y1 = y1; - m_clip_box.x2 = x2; - m_clip_box.y2 = y2; - m_clip_box.normalize(); - } - - double x1() const { return m_clip_box.x1; } - double y1() const { return m_clip_box.y1; } - double x2() const { return m_clip_box.x2; } - double y2() const { return m_clip_box.y2; } - - static bool auto_close() { return false; } - static bool auto_unclose() { return true; } - - void reset(); - void move_to(double x, double y); - void line_to(double x, double y); - unsigned vertex(double* x, double* y); - - private: - rect_d m_clip_box; - double m_x1; - double m_y1; - double m_x[2]; - double m_y[2]; - unsigned m_cmd[2]; - unsigned m_num_vertices; - unsigned m_vertex; - bool m_move_to; - }; - -} - - -#endif diff --git a/xs/src/agg/agg_vpgen_segmentator.h b/xs/src/agg/agg_vpgen_segmentator.h deleted file mode 100644 index 29b3c9fa6f..0000000000 --- a/xs/src/agg/agg_vpgen_segmentator.h +++ /dev/null @@ -1,61 +0,0 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -#ifndef AGG_VPGEN_SEGMENTATOR_INCLUDED -#define AGG_VPGEN_SEGMENTATOR_INCLUDED - -#include -#include "agg_basics.h" - -namespace agg -{ - - //=======================================================vpgen_segmentator - // - // See Implementation agg_vpgen_segmentator.cpp - // - class vpgen_segmentator - { - public: - vpgen_segmentator() : m_approximation_scale(1.0) {} - - void approximation_scale(double s) { m_approximation_scale = s; } - double approximation_scale() const { return m_approximation_scale; } - - static bool auto_close() { return false; } - static bool auto_unclose() { return false; } - - void reset() { m_cmd = path_cmd_stop; } - void move_to(double x, double y); - void line_to(double x, double y); - unsigned vertex(double* x, double* y); - - private: - double m_approximation_scale; - double m_x1; - double m_y1; - double m_dx; - double m_dy; - double m_dl; - double m_ddl; - unsigned m_cmd; - }; - - - -} - -#endif - diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index adf4fa2c86..71d0c8ef35 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/xs/src/png/AUTHORS b/xs/src/png/AUTHORS new file mode 100644 index 0000000000..25aad54dce --- /dev/null +++ b/xs/src/png/AUTHORS @@ -0,0 +1,4 @@ +png++ is written by Alexander Shulgin (alex dot shulgin at gmail dot com) +Copyright (C) 2007,2008 + +When writing to me be sure to put png++: in the subject :-) diff --git a/xs/src/png/NEWS b/xs/src/png/NEWS new file mode 100644 index 0000000000..cc006fbf5e --- /dev/null +++ b/xs/src/png/NEWS @@ -0,0 +1,60 @@ +Version 0.2.7: + + - Added solid_pixel_buffer (patch by Andrey Potapov). + + - Fixed some compilation problems on Win32. + +Version 0.2.5: + + - Fixed compatibility with newer libpng versions (>= 1.4) + + - Fixed compilation on FreeBSD. + + - Fixed tRNS handling with transformations. + + - Added IO transformation debugging facility. + + - Better organized test suite. + +Version 0.2.3: + + - Fixed numerous `already defined' errors due to require_color_space + implementation. + + - Added `config.hpp'. + + - Fixed `strerror' usage. + + - Minor docs fixes. + + +Version 0.2.1: + + - Added support for tRNS chunk. + + - Added non-std IO streams support. + + - Fixed 16-bit endianness problems. + + - Improved test script. + + +Version 0.2.0: + + - Added support for 16-bit data (RGB, RGBA, Grayscale and Gray+Alpha + color types) + + - Added support for packed 1-, 2- or 4-bit pixels (Grayscale and + Indexed colors) + + - Fixed interlace handling code which was severely broken + + - Added possibility to process images without reading the entire + image into memory + + - Internals are refactored while the client interface is mostly + unchanged + + - Added intensive test suite + + - Added documentation diff --git a/xs/src/png/libpng/ANNOUNCE b/xs/src/png/libpng/ANNOUNCE new file mode 100644 index 0000000000..0f66c0d1da --- /dev/null +++ b/xs/src/png/libpng/ANNOUNCE @@ -0,0 +1,35 @@ +Libpng 1.6.34 - September 29, 2017 + +This is a public release of libpng, intended for use in production codes. + +Files available for download: + +Source files with LF line endings (for Unix/Linux) and with a +"configure" script + + libpng-1.6.34.tar.xz (LZMA-compressed, recommended) + libpng-1.6.34.tar.gz + +Source files with CRLF line endings (for Windows), without the +"configure" script + + lpng1634.7z (LZMA-compressed, recommended) + lpng1634.zip + +Other information: + + libpng-1.6.34-README.txt + libpng-1.6.34-LICENSE.txt + libpng-1.6.34-*.asc (armored detached GPG signatures) + +Changes since the last public release (1.6.33): + Removed contrib/pngsuite/i*.png; some of these were incorrect and caused + test failures. + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net +(subscription required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe) +or to glennrp at users.sourceforge.net + +Glenn R-P diff --git a/xs/src/png/libpng/CMakeLists.txt b/xs/src/png/libpng/CMakeLists.txt new file mode 100644 index 0000000000..266b67d0e2 --- /dev/null +++ b/xs/src/png/libpng/CMakeLists.txt @@ -0,0 +1,937 @@ +# CMakeLists.txt + +# Copyright (C) 2007,2009-2017 Glenn Randers-Pehrson +# Written by Christian Ehrlicher, 2007 +# Revised by Roger Lowman, 2009-2010 +# Revised by Clifford Yapp, 2011-2012 +# Revised by Roger Leigh, 2016 +# Revised by Andreas Franek, 2016 + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +cmake_minimum_required(VERSION 3.0.2) +cmake_policy(VERSION 3.0.2) + +# Set MacOSX @rpath usage globally. +if (POLICY CMP0020) + cmake_policy(SET CMP0020 NEW) +endif(POLICY CMP0020) +if (POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif(POLICY CMP0042) +# Use new variable expansion policy. +if (POLICY CMP0053) + cmake_policy(SET CMP0053 NEW) +endif(POLICY CMP0053) +if (POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif(POLICY CMP0054) + +set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo") + +project(libpng ASM C) + +set(PNGLIB_MAJOR 1) +set(PNGLIB_MINOR 6) +set(PNGLIB_RELEASE 34) +set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) +set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) + +# needed packages + +#Allow users to specify location of Zlib, +# Useful if zlib is being built alongside this as a sub-project + +set(PNG_BUILD_ZLIB ${CMAKE_CURRENT_SOURCE_DIR}/zlib) + +if(NOT WIN32) + find_library(M_LIBRARY + NAMES m + PATHS /usr/lib /usr/local/lib + ) + if(NOT M_LIBRARY) + message(STATUS "math lib 'libm' not found; floating point support disabled") + endif() +else() + # not needed on windows + set(M_LIBRARY "") +endif() + +# COMMAND LINE OPTIONS +option(PNG_SHARED "Build shared lib" OFF) +option(PNG_STATIC "Build static lib" ON) +option(PNG_TESTS "Build libpng tests" OFF) + +# Many more configuration options could be added here +option(PNG_FRAMEWORK "Build OS X framework" OFF) +option(PNG_DEBUG "Build with debug output" OFF) +option(PNGARG "Disable ANSI-C prototypes" OFF) + +option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON) + +set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names") +set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") + +if(PNG_HARDWARE_OPTIMIZATIONS) +# set definitions and sources for arm +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") + set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) + set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations: + check: (default) use internal checking code; + off: disable the optimizations; + on: turn on unconditionally.") + set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS + ${PNG_ARM_NEON_POSSIBLE_VALUES}) + list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) + if(index EQUAL -1) + message(FATAL_ERROR + " PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_ARM_NEON} STREQUAL "no") + set(libpng_arm_sources + arm/arm_init.c + arm/filter_neon.S + arm/filter_neon_intrinsics.c) + + if(${PNG_ARM_NEON} STREQUAL "on") + add_definitions(-DPNG_ARM_NEON_OPT=2) + elseif(${PNG_ARM_NEON} STREQUAL "check") + add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED) + endif() + else() + add_definitions(-DPNG_ARM_NEON_OPT=0) + endif() +endif() + +# set definitions and sources for powerpc +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" ) + set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) + set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations: + off: disable the optimizations.") + set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS + ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) + list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) + if(index EQUAL -1) + message(FATAL_ERROR + " PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "no") + set(libpng_powerpc_sources + powerpc/powerpc_init.c + powerpc/filter_vsx_intrinsics.c) + if(${PNG_POWERPC_VSX} STREQUAL "on") + add_definitions(-DPNG_POWERPC_VSX_OPT=2) + endif() + else() + add_definitions(-DPNG_POWERPC_VSX_OPT=0) + endif() +endif() + +# set definitions and sources for intel +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" ) + set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) + set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations: + off: disable the optimizations") + set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS + ${PNG_INTEL_SSE_POSSIBLE_VALUES}) + list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) + if(index EQUAL -1) + message(FATAL_ERROR + " PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_INTEL_SSE} STREQUAL "no") + set(libpng_intel_sources + intel/intel_init.c + intel/filter_sse2_intrinsics.c) + if(${PNG_INTEL_SSE} STREQUAL "on") + add_definitions(-DPNG_INTEL_SSE_OPT=1) + endif() + else() + add_definitions(-DPNG_INTEL_SSE_OPT=0) + endif() +endif() + +# set definitions and sources for MIPS +if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" ) + set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) + set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations: + off: disable the optimizations") + set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS + ${PNG_MIPS_MSA_POSSIBLE_VALUES}) + list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index) + if(index EQUAL -1) + message(FATAL_ERROR + " PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_MIPS_MSA} STREQUAL "no") + set(libpng_mips_sources + mips/mips_init.c + mips/filter_msa_intrinsics.c) + if(${PNG_MIPS_MSA} STREQUAL "on") + add_definitions(-DPNG_MIPS_MSA_OPT=2) + endif() + else() + add_definitions(-DPNG_MIPS_MSA_OPT=0) + endif() +endif() +endif(PNG_HARDWARE_OPTIMIZATIONS) + +# SET LIBNAME +set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) + +# to distinguish between debug and release lib +set(CMAKE_DEBUG_POSTFIX "d") + +include(CheckCSourceCompiles) +option(ld-version-script "Enable linker version script" ON) +if(ld-version-script AND NOT APPLE) + # Check if LD supports linker scripts. + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { + global: sym; + local: *; +}; + +VERS_2 { + global: sym2; + main; +} VERS_1; +") + set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") + check_c_source_compiles("void sym(void) {} +void sym2(void) {} +int main(void) {return 0;} +" HAVE_LD_VERSION_SCRIPT) + if(NOT HAVE_LD_VERSION_SCRIPT) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") + check_c_source_compiles("void sym(void) {} +void sym2(void) {} +int main(void) {return 0;} +" HAVE_SOLARIS_LD_VERSION_SCRIPT) + endif() + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") +endif() + +# Find symbol prefix. Likely obsolete and unnecessary with recent +# toolchains (it's not done in many other projects). +function(symbol_prefix) + set(SYMBOL_PREFIX) + + execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-" + INPUT_FILE /dev/null + OUTPUT_VARIABLE OUT + RESULT_VARIABLE STATUS) + + if(CPP_FAIL) + message(WARNING "Failed to run the C preprocessor") + endif() + + string(REPLACE "\n" ";" OUT "${OUT}") + foreach(line ${OUT}) + string(REGEX MATCH "^PREFIX=" found_match "${line}") + if(found_match) + STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}") + string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}") + if(found_match) + STRING(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}") + endif() + set(SYMBOL_PREFIX "${prefix}") + endif() + endforeach() + + message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}") + set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE) +endfunction() + +if(UNIX) + symbol_prefix() +endif() + +find_program(AWK NAMES gawk awk) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +if(NOT AWK OR ANDROID) + # No awk available to generate sources; use pre-built pnglibconf.h + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt + ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) + add_custom_target(genfiles) # Dummy +else() + include(CMakeParseArguments) + # Generate .chk from .out with awk + # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_chk) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if (NOT _GC_INPUT) + message(FATAL_ERROR "Invalid arguments. generate_out requires input.") + endif() + if (NOT _GC_OUTPUT) + message(FATAL_ERROR "Invalid arguments. generate_out requires output.") + endif() + + add_custom_command(OUTPUT "${_GC_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DINPUT=${_GC_INPUT}" + "-DOUTPUT=${_GC_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake" + DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Generate .out from .c with awk + # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_out) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if (NOT _GO_INPUT) + message(FATAL_ERROR "Invalid arguments. generate_out requires input.") + endif() + if (NOT _GO_OUTPUT) + message(FATAL_ERROR "Invalid arguments. generate_out requires output.") + endif() + + add_custom_command(OUTPUT "${_GO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DINPUT=${_GO_INPUT}" + "-DOUTPUT=${_GO_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake" + DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Generate specific source file with awk + # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_source) + set(options) + set(oneValueArgs OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if (NOT _GSO_OUTPUT) + message(FATAL_ERROR "Invalid arguments. generate_source requires output.") + endif() + + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DOUTPUT=${_GSO_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" + DEPENDS ${_GSO_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Copy file + function(generate_copy source destination) + add_custom_command(OUTPUT "${destination}" + COMMAND "${CMAKE_COMMAND}" -E remove "${destination}" + COMMAND "${CMAKE_COMMAND}" -E copy "${source}" + "${destination}" + DEPENDS "${source}") + endfunction() + + # Generate scripts/pnglibconf.h + generate_source(OUTPUT "scripts/pnglibconf.c" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") + + # Generate pnglibconf.c + generate_source(OUTPUT "pnglibconf.c" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") + + if(PNG_PREFIX) + set(PNGLIBCONF_H_EXTRA_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst") + set(PNGPREFIX_H_EXTRA_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") + endif() + + generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") + + # Generate pnglibconf.h + generate_source(OUTPUT "pnglibconf.h" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + ${PNGLIBCONF_H_EXTRA_DEPENDS}) + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") + + # Generate pngprefix.h + generate_source(OUTPUT "pngprefix.h" + DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS}) + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def") + + add_custom_target(symbol-check DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk") + + generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") + generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") + + add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") + add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") + + add_custom_target("genprebuilt" + COMMAND "${CMAKE_COMMAND}" + "-DOUTPUT=scripts/pnglibconf.h.prebuilt" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + + # A single target handles generation of all generated files. If + # they are dependend upon separately by multiple targets, this + # confuses parallel make (it would require a separate top-level + # target for each file to track the dependencies properly). + add_custom_target(genfiles DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") +endif(NOT AWK OR ANDROID) + +# OUR SOURCES +set(libpng_public_hdrs + png.h + pngconf.h + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" +) +set(libpng_private_hdrs + pngpriv.h + pngdebug.h + pnginfo.h + pngstruct.h +) +if(AWK AND NOT ANDROID) + list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") +endif() +set(libpng_sources + ${libpng_public_hdrs} + ${libpng_private_hdrs} + png.c + pngerror.c + pngget.c + pngmem.c + pngpread.c + pngread.c + pngrio.c + pngrtran.c + pngrutil.c + pngset.c + pngtrans.c + pngwio.c + pngwrite.c + pngwtran.c + pngwutil.c + ${libpng_arm_sources} + ${libpng_intel_sources} + ${libpng_mips_sources} + ${libpng_powerpc_sources} +) +set(pngtest_sources + pngtest.c +) +set(pngvalid_sources + contrib/libtests/pngvalid.c +) +set(pngstest_sources + contrib/libtests/pngstest.c +) +set(pngunknown_sources + contrib/libtests/pngunknown.c +) +set(pngimage_sources + contrib/libtests/pngimage.c +) +set(pngfix_sources + contrib/tools/pngfix.c +) +set(png_fix_itxt_sources + contrib/tools/png-fix-itxt.c +) + +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) +endif(MSVC) + +if(PNG_DEBUG) + add_definitions(-DPNG_DEBUG) +endif() + +# NOW BUILD OUR TARGET +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) + +unset(PNG_LIB_TARGETS) + +if(PNG_SHARED) + add_library(png SHARED ${libpng_sources}) + set(PNG_LIB_TARGETS png) + set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) + add_dependencies(png genfiles) + if(MSVC) + # msvc does not append 'lib' - do it here to have consistent name + set_target_properties(png PROPERTIES PREFIX "lib") + set_target_properties(png PROPERTIES IMPORT_PREFIX "lib") + endif() + target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY}) + + if(UNIX AND AWK) + if(HAVE_LD_VERSION_SCRIPT) + set_target_properties(png PROPERTIES LINK_FLAGS + "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") + elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT) + set_target_properties(png PROPERTIES LINK_FLAGS + "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") + endif() + endif() +endif() + +if(PNG_STATIC) + # does not work without changing name + set(PNG_LIB_NAME_STATIC png_static) + add_library(png_static STATIC ${libpng_sources}) + add_dependencies(png_static genfiles) + # MSVC doesn't use a different file extension for shared vs. static + # libs. We are able to change OUTPUT_NAME to remove the _static + # for all other platforms. + if(NOT MSVC) + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME}" + CLEAN_DIRECT_OUTPUT 1) + else() + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME}_static" + CLEAN_DIRECT_OUTPUT 1) + endif() + list(APPEND PNG_LIB_TARGETS png_static) + if(MSVC) + # msvc does not append 'lib' - do it here to have consistent name + set_target_properties(png_static PROPERTIES PREFIX "lib") + endif() + target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY}) +endif() + +if(PNG_FRAMEWORK) + set(PNG_LIB_NAME_FRAMEWORK png_framework) + add_library(png_framework SHARED ${libpng_sources}) + add_dependencies(png_framework genfiles) + list(APPEND PNG_LIB_TARGETS png_framework) + set_target_properties(png_framework PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION ${PNGLIB_VERSION} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION} + MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + PUBLIC_HEADER "${libpng_public_hdrs}" + OUTPUT_NAME png) + target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY}) +endif() + +if(NOT PNG_LIB_TARGETS) + message(SEND_ERROR + "No library variant selected to build. " + "Please enable at least one of the following options: " + " PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK") +endif() + +if(PNG_SHARED AND WIN32) + set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) +endif() + +function(png_add_test) + set(options) + set(oneValueArgs NAME COMMAND) + set(multiValueArgs OPTIONS FILES) + cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (NOT _PAT_NAME) + message(FATAL_ERROR "Invalid arguments. png_add_test requires name.") + endif() + if (NOT _PAT_COMMAND) + message(FATAL_ERROR "Invalid arguments. png_add_test requires command.") + endif() + + set(TEST_OPTIONS "${_PAT_OPTIONS}") + set(TEST_FILES "${_PAT_FILES}") + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY) + if(CMAKE_MAJOR_VERSION GREATER 2) # have generator expressions + add_test(NAME "${_PAT_NAME}" + COMMAND "${CMAKE_COMMAND}" + "-DLIBPNG=$" + "-DTEST_COMMAND=$" + -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake") + else() # old 2.x add_test; limited and won't work well on Windows + # Note LIBPNG is a dummy value as there are no generator expressions + add_test("${_PAT_NAME}" "${CMAKE_COMMAND}" + "-DLIBPNG=${CMAKE_CURRENT_BINARY_DIR}/libpng.so" + "-DTEST_COMMAND=./${_PAT_COMMAND}" + -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake") + endif() +endfunction() + +if(PNG_TESTS AND PNG_SHARED) + # Find test PNG files by globbing, but sort lists to ensure + # consistency between different filesystems. + file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png") + list(SORT PNGSUITE_PNGS) + file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png") + list(SORT TEST_PNGS) + + set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png") + + add_executable(pngtest ${pngtest_sources}) + target_link_libraries(pngtest png) + + png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}") + + add_executable(pngvalid ${pngvalid_sources}) + target_link_libraries(pngvalid png) + + png_add_test(NAME pngvalid-gamma-16-to-8 + COMMAND pngvalid OPTIONS --gamma-16-to-8) + png_add_test(NAME pngvalid-gamma-alpha-mode + COMMAND pngvalid OPTIONS --gamma-alpha-mode) + png_add_test(NAME pngvalid-gamma-background + COMMAND pngvalid OPTIONS --gamma-background) + png_add_test(NAME pngvalid-gamma-expand16-alpha-mode + COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16) + png_add_test(NAME pngvalid-gamma-expand16-background + COMMAND pngvalid OPTIONS --gamma-background --expand16) + png_add_test(NAME pngvalid-gamma-expand16-transform + COMMAND pngvalid OPTIONS --gamma-transform --expand16) + png_add_test(NAME pngvalid-gamma-sbit + COMMAND pngvalid OPTIONS --gamma-sbit) + png_add_test(NAME pngvalid-gamma-threshold + COMMAND pngvalid OPTIONS --gamma-threshold) + png_add_test(NAME pngvalid-gamma-transform + COMMAND pngvalid OPTIONS --gamma-transform) + png_add_test(NAME pngvalid-progressive-interlace-standard + COMMAND pngvalid OPTIONS --standard --progressive-read --interlace) + png_add_test(NAME pngvalid-progressive-size + COMMAND pngvalid OPTIONS --size --progressive-read) + png_add_test(NAME pngvalid-progressive-standard + COMMAND pngvalid OPTIONS --standard --progressive-read) + png_add_test(NAME pngvalid-standard + COMMAND pngvalid OPTIONS --standard) + png_add_test(NAME pngvalid-transform + COMMAND pngvalid OPTIONS --transform) + + add_executable(pngstest ${pngstest_sources}) + target_link_libraries(pngstest png) + + foreach(gamma_type 1.8 linear none sRGB) + foreach(alpha_type none alpha) + set(PNGSTEST_FILES) + foreach(test_png ${TEST_PNGS}) + string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}") + string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}") + string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}") + string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}") + + set(TEST_PNG_VALID TRUE) + + if(TEST_PNG_ALPHA) + if (NOT "${alpha_type}" STREQUAL "alpha") + set(TEST_PNG_VALID FALSE) + endif() + else() + if ("${alpha_type}" STREQUAL "alpha") + set(TEST_PNG_VALID FALSE) + endif() + endif() + + if(TEST_PNG_LINEAR) + if(NOT "${gamma_type}" STREQUAL "linear") + set(TEST_PNG_VALID FALSE) + endif() + elseif(TEST_PNG_SRGB) + if(NOT "${gamma_type}" STREQUAL "sRGB") + set(TEST_PNG_VALID FALSE) + endif() + elseif(TEST_PNG_G18) + if(NOT "${gamma_type}" STREQUAL "1.8") + set(TEST_PNG_VALID FALSE) + endif() + else() + if(NOT "${gamma_type}" STREQUAL "none") + set(TEST_PNG_VALID FALSE) + endif() + endif() + + if(TEST_PNG_VALID) + list(APPEND PNGSTEST_FILES "${test_png}") + endif() + endforeach() + # Should already be sorted, but sort anyway to be certain. + list(SORT PNGSTEST_FILES) + png_add_test(NAME pngstest-${gamma_type}-${alpha_type} + COMMAND pngstest + OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log + FILES ${PNGSTEST_FILES}) + endforeach() + endforeach() + + add_executable(pngunknown ${pngunknown_sources}) + target_link_libraries(pngunknown png) + + png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}") + + add_executable(pngimage ${pngimage_sources}) + target_link_libraries(pngimage png) + + png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS}) + png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS}) +endif() + +if(PNG_SHARED) + add_executable(pngfix ${pngfix_sources}) + target_link_libraries(pngfix png) + set(PNG_BIN_TARGETS pngfix) + + add_executable(png-fix-itxt ${png_fix_itxt_sources}) + target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY}) + list(APPEND PNG_BIN_TARGETS png-fix-itxt) +endif() + +# Set a variable with CMake code which: +# Creates a symlink from src to dest (if possible) or alternatively +# copies if different. +include(CMakeParseArguments) + +function(CREATE_SYMLINK DEST_FILE) + + cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN}) + + if(NOT S_TARGET AND NOT S_FILE) + message(FATAL_ERROR "Specify either a TARGET or a FILE for CREATE_SYMLINK to link to.") + endif(NOT S_TARGET AND NOT S_FILE) + + if(S_TARGET AND S_FILE) + message(FATAL_ERROR "CREATE_SYMLINK called with both source file ${S_FILE} and build target ${S_TARGET} arguments - can only handle 1 type per call.") + endif(S_TARGET AND S_FILE) + + if(S_FILE) + # If we don't need to symlink something that's coming from a build target, + # we can go ahead and symlink/copy at configure time. + + if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ) + else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS) + execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ) + endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS) + endif(S_FILE) + + if(S_TARGET) + # We need to use generator expressions, which can be a bit tricky, so for + # simplicity make the symlink a POST_BUILD step and use the TARGET + # signature of add_custom_command. + + if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS) + add_custom_command(TARGET ${S_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different $ $/${DEST_FILE} + ) + else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS) + add_custom_command(TARGET ${S_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E create_symlink $ $/${DEST_FILE} + ) + endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS) + + endif(S_TARGET) + +endfunction() + +# Create source generation scripts. +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY) + + +# libpng is a library so default to 'lib' +if(NOT DEFINED CMAKE_INSTALL_LIBDIR) + set(CMAKE_INSTALL_LIBDIR lib) +endif(NOT DEFINED CMAKE_INSTALL_LIBDIR) + +# CREATE PKGCONFIG FILES +# we use the same files like ./configure, so we have to set its vars +# Only do this on Windows for Cygwin - the files don't make much sense outside +# a UNIX look alike +if(NOT WIN32 OR CYGWIN OR MINGW) + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix ${CMAKE_INSTALL_PREFIX}) + set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + set(includedir ${CMAKE_INSTALL_PREFIX}/include) + set(LIBS "-lz -lm") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY) + CREATE_SYMLINK(libpng.pc FILE ${PNGLIB_NAME}.pc) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in + ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY) + CREATE_SYMLINK(libpng-config FILE ${PNGLIB_NAME}-config) +endif(NOT WIN32 OR CYGWIN OR MINGW) + +# SET UP LINKS +if(PNG_SHARED) + set_target_properties(png PROPERTIES +# VERSION 16.${PNGLIB_RELEASE}.1.6.34 + VERSION 16.${PNGLIB_RELEASE}.0 + SOVERSION 16 + CLEAN_DIRECT_OUTPUT 1) +endif() + +# If CMake > 2.4.x, we set a variable used below to export +# targets to an export file. +# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2 +if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4) + set(PNG_EXPORT_RULE EXPORT libpng) +elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof + set(PNG_EXPORT_RULE EXPORT libpng) +endif() + +# INSTALL +if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) + install(TARGETS ${PNG_LIB_TARGETS} + ${PNG_EXPORT_RULE} + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + if(PNG_SHARED) + # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin + if(CYGWIN OR MINGW) + CREATE_SYMLINK(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png) + install(FILES $/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif(CYGWIN OR MINGW) + + if(NOT WIN32) + CREATE_SYMLINK(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png) + install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif(NOT WIN32) + endif(PNG_SHARED) + + if(PNG_STATIC) + if(NOT WIN32 OR CYGWIN OR MINGW) + CREATE_SYMLINK( libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static) + install(FILES $/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif(NOT WIN32 OR CYGWIN OR MINGW) + endif() +endif() + +if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) + install(FILES ${libpng_public_hdrs} DESTINATION include) + install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME}) +endif() +if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL ) + if(NOT WIN32 OR CYGWIN OR MINGW) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config + DESTINATION bin) + endif(NOT WIN32 OR CYGWIN OR MINGW) +endif() + +if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL ) + install(TARGETS ${PNG_BIN_TARGETS} + RUNTIME DESTINATION bin) +endif() + +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + # Install man pages + if(NOT PNG_MAN_DIR) + set(PNG_MAN_DIR "share/man") + endif() + install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3) + install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5) + # Install pkg-config files + if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config + DESTINATION bin) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config + DESTINATION bin) + endif(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) +endif() + +# On versions of CMake that support it, create an export file CMake +# users can include() to import our targets +if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL ) + install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake) +endif() + +# what's with libpng-manual.txt and all the extra files? + +# UNINSTALL +# do we need this? + +# DIST +# do we need this? + +# to create msvc import lib for mingw compiled shared lib +# pexports libpng.dll > libpng.def +# lib /def:libpng.def /machine:x86 diff --git a/xs/src/png/libpng/LICENSE b/xs/src/png/libpng/LICENSE new file mode 100644 index 0000000000..4cda4fa0ad --- /dev/null +++ b/xs/src/png/libpng/LICENSE @@ -0,0 +1,133 @@ + +This copy of the libpng notices is provided for your convenience. In case of +any discrepancy between this copy and the notices in the file png.h that is +included in the libpng distribution, the latter shall prevail. + +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + +If you modify libpng you may insert additional notices immediately following +this sentence. + +This code is released under the libpng license. + +libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are +Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are +derived from libpng-1.0.6, and are distributed according to the same +disclaimer and license as libpng-1.0.6 with the following individuals +added to the list of Contributing Authors: + + Simon-Pierre Cadieux + Eric S. Raymond + Mans Rullgard + Cosmin Truta + Gilles Vollant + James Yu + Mandar Sahastrabuddhe + Google Inc. + Vadim Barkov + +and with the following additions to the disclaimer: + + There is no warranty against interference with your enjoyment of the + library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is with + the user. + +Some files in the "contrib" directory and some configure-generated +files that are distributed with libpng have other copyright owners and +are released under other open source licenses. + +libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are +Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from +libpng-0.96, and are distributed according to the same disclaimer and +license as libpng-0.96, with the following individuals added to the list +of Contributing Authors: + + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik + +libpng versions 0.89, June 1996, through 0.96, May 1997, are +Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, +and are distributed according to the same disclaimer and license as +libpng-0.88, with the following individuals added to the list of +Contributing Authors: + + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +Some files in the "scripts" directory have other copyright owners +but are released under this license. + +libpng versions 0.5, May 1995, through 0.88, January 1996, are +Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + +For the purposes of this copyright and license, "Contributing Authors" +is defined as the following set of individuals: + + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing Authors +and Group 42, Inc. disclaim all warranties, expressed or implied, +including, without limitation, the warranties of merchantability and of +fitness for any purpose. The Contributing Authors and Group 42, Inc. +assume no liability for direct, indirect, incidental, special, exemplary, +or consequential damages, which may result from the use of the PNG +Reference Library, even if advised of the possibility of such damage. + +Permission is hereby granted to use, copy, modify, and distribute this +source code, or portions hereof, for any purpose, without fee, subject +to the following restrictions: + + 1. The origin of this source code must not be misrepresented. + + 2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + +The Contributing Authors and Group 42, Inc. specifically permit, without +fee, and encourage the use of this source code as a component to +supporting the PNG file format in commercial products. If you use this +source code in a product, acknowledgment is not required but would be +appreciated. + +END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. + +TRADEMARK: + +The name "libpng" has not been registered by the Copyright owner +as a trademark in any jurisdiction. However, because libpng has +been distributed and maintained world-wide, continually since 1995, +the Copyright owner claims "common-law trademark protection" in any +jurisdiction where common-law trademark is recognized. + +OSI CERTIFICATION: + +Libpng is OSI Certified Open Source Software. OSI Certified Open Source is +a certification mark of the Open Source Initiative. OSI has not addressed +the additional disclaimers inserted at version 1.0.7. + +EXPORT CONTROL: + +The Copyright owner believes that the Export Control Classification +Number (ECCN) for libpng is EAR99, which means not subject to export +controls or International Traffic in Arms Regulations (ITAR) because +it is open source, publicly available software, that does not contain +any encryption software. See the EAR, paragraphs 734.3(b)(3) and +734.7(b). + +Glenn Randers-Pehrson +glennrp at users.sourceforge.net +September 29, 2017 diff --git a/xs/src/png/libpng/libpng-config.in b/xs/src/png/libpng/libpng-config.in new file mode 100644 index 0000000000..69bf8e33f0 --- /dev/null +++ b/xs/src/png/libpng/libpng-config.in @@ -0,0 +1,127 @@ +#! /bin/sh + +# libpng-config +# provides configuration info for libpng. + +# Copyright (C) 2002, 2004, 2006, 2007 Glenn Randers-Pehrson + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# Modeled after libxml-config. + +version="@PNGLIB_VERSION@" +prefix="@prefix@" +exec_prefix="@exec_prefix@" +libdir="@libdir@" +includedir="@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" +libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" +all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ @LIBS@" +I_opts="-I${includedir}" +L_opts="-L${libdir}" +R_opts="" +cppflags="" +ccopts="" +ldopts="" + +usage() +{ + cat < 8) + png_error(png_ptr, "Too many bytes for PNG signature"); + + png_ptr->sig_bytes = (png_byte)nb; +} + +/* Checks whether the supplied bytes match the PNG signature. We allow + * checking less than the full 8-byte signature so that those apps that + * already read the first few bytes of a file to determine the file type + * can simply check the remaining bytes for extra assurance. Returns + * an integer less than, equal to, or greater than zero if sig is found, + * respectively, to be less than, to match, or be greater than the correct + * PNG signature (this is the same behavior as strcmp, memcmp, etc). + */ +int PNGAPI +png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check) +{ + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + + if (num_to_check > 8) + num_to_check = 8; + + else if (num_to_check < 1) + return (-1); + + if (start > 7) + return (-1); + + if (start + num_to_check > 8) + num_to_check = 8 - start; + + return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check))); +} + +#endif /* READ */ + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +/* Function to allocate memory for zlib */ +PNG_FUNCTION(voidpf /* PRIVATE */, +png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) +{ + png_alloc_size_t num_bytes = size; + + if (png_ptr == NULL) + return NULL; + + if (items >= (~(png_alloc_size_t)0)/size) + { + png_warning (png_voidcast(png_structrp, png_ptr), + "Potential overflow in png_zalloc()"); + return NULL; + } + + num_bytes *= items; + return png_malloc_warn(png_voidcast(png_structrp, png_ptr), num_bytes); +} + +/* Function to free memory for zlib */ +void /* PRIVATE */ +png_zfree(voidpf png_ptr, voidpf ptr) +{ + png_free(png_voidcast(png_const_structrp,png_ptr), ptr); +} + +/* Reset the CRC variable to 32 bits of 1's. Care must be taken + * in case CRC is > 32 bits to leave the top bits 0. + */ +void /* PRIVATE */ +png_reset_crc(png_structrp png_ptr) +{ + /* The cast is safe because the crc is a 32-bit value. */ + png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0); +} + +/* Calculate the CRC over a section of data. We can only pass as + * much data to this routine as the largest single buffer size. We + * also check that this data will actually be used before going to the + * trouble of calculating it. + */ +void /* PRIVATE */ +png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) +{ + int need_crc = 1; + + if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0) + { + if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == + (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) + need_crc = 0; + } + + else /* critical */ + { + if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0) + need_crc = 0; + } + + /* 'uLong' is defined in zlib.h as unsigned long; this means that on some + * systems it is a 64-bit value. crc32, however, returns 32 bits so the + * following cast is safe. 'uInt' may be no more than 16 bits, so it is + * necessary to perform a loop here. + */ + if (need_crc != 0 && length > 0) + { + uLong crc = png_ptr->crc; /* Should never issue a warning */ + + do + { + uInt safe_length = (uInt)length; +#ifndef __COVERITY__ + if (safe_length == 0) + safe_length = (uInt)-1; /* evil, but safe */ +#endif + + crc = crc32(crc, ptr, safe_length); + + /* The following should never issue compiler warnings; if they do the + * target system has characteristics that will probably violate other + * assumptions within the libpng code. + */ + ptr += safe_length; + length -= safe_length; + } + while (length > 0); + + /* And the following is always safe because the crc is only 32 bits. */ + png_ptr->crc = (png_uint_32)crc; + } +} + +/* Check a user supplied version number, called from both read and write + * functions that create a png_struct. + */ +int +png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) +{ + /* Libpng versions 1.0.0 and later are binary compatible if the version + * string matches through the second '.'; we must recompile any + * applications that use any older library version. + */ + + if (user_png_ver != NULL) + { + int i = -1; + int found_dots = 0; + + do + { + i++; + if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i]) + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + if (user_png_ver[i] == '.') + found_dots++; + } while (found_dots < 2 && user_png_ver[i] != 0 && + PNG_LIBPNG_VER_STRING[i] != 0); + } + + else + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + + if ((png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) != 0) + { +#ifdef PNG_WARNINGS_SUPPORTED + size_t pos = 0; + char m[128]; + + pos = png_safecat(m, (sizeof m), pos, + "Application built with libpng-"); + pos = png_safecat(m, (sizeof m), pos, user_png_ver); + pos = png_safecat(m, (sizeof m), pos, " but running with "); + pos = png_safecat(m, (sizeof m), pos, PNG_LIBPNG_VER_STRING); + PNG_UNUSED(pos) + + png_warning(png_ptr, m); +#endif + +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags = 0; +#endif + + return 0; + } + + /* Success return. */ + return 1; +} + +/* Generic function to create a png_struct for either read or write - this + * contains the common initialization. + */ +PNG_FUNCTION(png_structp /* PRIVATE */, +png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) +{ + png_struct create_struct; +# ifdef PNG_SETJMP_SUPPORTED + jmp_buf create_jmp_buf; +# endif + + /* This temporary stack-allocated structure is used to provide a place to + * build enough context to allow the user provided memory allocator (if any) + * to be called. + */ + memset(&create_struct, 0, (sizeof create_struct)); + + /* Added at libpng-1.2.6 */ +# ifdef PNG_USER_LIMITS_SUPPORTED + create_struct.user_width_max = PNG_USER_WIDTH_MAX; + create_struct.user_height_max = PNG_USER_HEIGHT_MAX; + +# ifdef PNG_USER_CHUNK_CACHE_MAX + /* Added at libpng-1.2.43 and 1.4.0 */ + create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; +# endif + +# ifdef PNG_USER_CHUNK_MALLOC_MAX + /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists + * in png_struct regardless. + */ + create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX; +# endif +# endif + + /* The following two API calls simply set fields in png_struct, so it is safe + * to do them now even though error handling is not yet set up. + */ +# ifdef PNG_USER_MEM_SUPPORTED + png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn); +# else + PNG_UNUSED(mem_ptr) + PNG_UNUSED(malloc_fn) + PNG_UNUSED(free_fn) +# endif + + /* (*error_fn) can return control to the caller after the error_ptr is set, + * this will result in a memory leak unless the error_fn does something + * extremely sophisticated. The design lacks merit but is implicit in the + * API. + */ + png_set_error_fn(&create_struct, error_ptr, error_fn, warn_fn); + +# ifdef PNG_SETJMP_SUPPORTED + if (!setjmp(create_jmp_buf)) +# endif + { +# ifdef PNG_SETJMP_SUPPORTED + /* Temporarily fake out the longjmp information until we have + * successfully completed this function. This only works if we have + * setjmp() support compiled in, but it is safe - this stuff should + * never happen. + */ + create_struct.jmp_buf_ptr = &create_jmp_buf; + create_struct.jmp_buf_size = 0; /*stack allocation*/ + create_struct.longjmp_fn = longjmp; +# endif + /* Call the general version checker (shared with read and write code): + */ + if (png_user_version_check(&create_struct, user_png_ver) != 0) + { + png_structrp png_ptr = png_voidcast(png_structrp, + png_malloc_warn(&create_struct, (sizeof *png_ptr))); + + if (png_ptr != NULL) + { + /* png_ptr->zstream holds a back-pointer to the png_struct, so + * this can only be done now: + */ + create_struct.zstream.zalloc = png_zalloc; + create_struct.zstream.zfree = png_zfree; + create_struct.zstream.opaque = png_ptr; + +# ifdef PNG_SETJMP_SUPPORTED + /* Eliminate the local error handling: */ + create_struct.jmp_buf_ptr = NULL; + create_struct.jmp_buf_size = 0; + create_struct.longjmp_fn = 0; +# endif + + *png_ptr = create_struct; + + /* This is the successful return point */ + return png_ptr; + } + } + } + + /* A longjmp because of a bug in the application storage allocator or a + * simple failure to allocate the png_struct. + */ + return NULL; +} + +/* Allocate the memory for an info_struct for the application. */ +PNG_FUNCTION(png_infop,PNGAPI +png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED) +{ + png_inforp info_ptr; + + png_debug(1, "in png_create_info_struct"); + + if (png_ptr == NULL) + return NULL; + + /* Use the internal API that does not (or at least should not) error out, so + * that this call always returns ok. The application typically sets up the + * error handling *after* creating the info_struct because this is the way it + * has always been done in 'example.c'. + */ + info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr, + (sizeof *info_ptr))); + + if (info_ptr != NULL) + memset(info_ptr, 0, (sizeof *info_ptr)); + + return info_ptr; +} + +/* This function frees the memory associated with a single info struct. + * Normally, one would use either png_destroy_read_struct() or + * png_destroy_write_struct() to free an info struct, but this may be + * useful for some applications. From libpng 1.6.0 this function is also used + * internally to implement the png_info release part of the 'struct' destroy + * APIs. This ensures that all possible approaches free the same data (all of + * it). + */ +void PNGAPI +png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr) +{ + png_inforp info_ptr = NULL; + + png_debug(1, "in png_destroy_info_struct"); + + if (png_ptr == NULL) + return; + + if (info_ptr_ptr != NULL) + info_ptr = *info_ptr_ptr; + + if (info_ptr != NULL) + { + /* Do this first in case of an error below; if the app implements its own + * memory management this can lead to png_free calling png_error, which + * will abort this routine and return control to the app error handler. + * An infinite loop may result if it then tries to free the same info + * ptr. + */ + *info_ptr_ptr = NULL; + + png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + memset(info_ptr, 0, (sizeof *info_ptr)); + png_free(png_ptr, info_ptr); + } +} + +/* Initialize the info structure. This is now an internal function (0.89) + * and applications using it are urged to use png_create_info_struct() + * instead. Use deprecated in 1.6.0, internal use removed (used internally it + * is just a memset). + * + * NOTE: it is almost inconceivable that this API is used because it bypasses + * the user-memory mechanism and the user error handling/warning mechanisms in + * those cases where it does anything other than a memset. + */ +PNG_FUNCTION(void,PNGAPI +png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), + PNG_DEPRECATED) +{ + png_inforp info_ptr = *ptr_ptr; + + png_debug(1, "in png_info_init_3"); + + if (info_ptr == NULL) + return; + + if ((sizeof (png_info)) > png_info_struct_size) + { + *ptr_ptr = NULL; + /* The following line is why this API should not be used: */ + free(info_ptr); + info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL, + (sizeof *info_ptr))); + if (info_ptr == NULL) + return; + *ptr_ptr = info_ptr; + } + + /* Set everything to 0 */ + memset(info_ptr, 0, (sizeof *info_ptr)); +} + +/* The following API is not called internally */ +void PNGAPI +png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr, + int freer, png_uint_32 mask) +{ + png_debug(1, "in png_data_freer"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (freer == PNG_DESTROY_WILL_FREE_DATA) + info_ptr->free_me |= mask; + + else if (freer == PNG_USER_WILL_FREE_DATA) + info_ptr->free_me &= ~mask; + + else + png_error(png_ptr, "Unknown freer parameter in png_data_freer"); +} + +void PNGAPI +png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, + int num) +{ + png_debug(1, "in png_free_data"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + +#ifdef PNG_TEXT_SUPPORTED + /* Free text item num or (if num == -1) all text items */ + if (info_ptr->text != NULL && + ((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0) + { + if (num != -1) + { + png_free(png_ptr, info_ptr->text[num].key); + info_ptr->text[num].key = NULL; + } + + else + { + int i; + + for (i = 0; i < info_ptr->num_text; i++) + png_free(png_ptr, info_ptr->text[i].key); + + png_free(png_ptr, info_ptr->text); + info_ptr->text = NULL; + info_ptr->num_text = 0; + info_ptr->max_text = 0; + } + } +#endif + +#ifdef PNG_tRNS_SUPPORTED + /* Free any tRNS entry */ + if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0) + { + info_ptr->valid &= ~PNG_INFO_tRNS; + png_free(png_ptr, info_ptr->trans_alpha); + info_ptr->trans_alpha = NULL; + info_ptr->num_trans = 0; + } +#endif + +#ifdef PNG_sCAL_SUPPORTED + /* Free any sCAL entry */ + if (((mask & PNG_FREE_SCAL) & info_ptr->free_me) != 0) + { + png_free(png_ptr, info_ptr->scal_s_width); + png_free(png_ptr, info_ptr->scal_s_height); + info_ptr->scal_s_width = NULL; + info_ptr->scal_s_height = NULL; + info_ptr->valid &= ~PNG_INFO_sCAL; + } +#endif + +#ifdef PNG_pCAL_SUPPORTED + /* Free any pCAL entry */ + if (((mask & PNG_FREE_PCAL) & info_ptr->free_me) != 0) + { + png_free(png_ptr, info_ptr->pcal_purpose); + png_free(png_ptr, info_ptr->pcal_units); + info_ptr->pcal_purpose = NULL; + info_ptr->pcal_units = NULL; + + if (info_ptr->pcal_params != NULL) + { + int i; + + for (i = 0; i < info_ptr->pcal_nparams; i++) + png_free(png_ptr, info_ptr->pcal_params[i]); + + png_free(png_ptr, info_ptr->pcal_params); + info_ptr->pcal_params = NULL; + } + info_ptr->valid &= ~PNG_INFO_pCAL; + } +#endif + +#ifdef PNG_iCCP_SUPPORTED + /* Free any profile entry */ + if (((mask & PNG_FREE_ICCP) & info_ptr->free_me) != 0) + { + png_free(png_ptr, info_ptr->iccp_name); + png_free(png_ptr, info_ptr->iccp_profile); + info_ptr->iccp_name = NULL; + info_ptr->iccp_profile = NULL; + info_ptr->valid &= ~PNG_INFO_iCCP; + } +#endif + +#ifdef PNG_sPLT_SUPPORTED + /* Free a given sPLT entry, or (if num == -1) all sPLT entries */ + if (info_ptr->splt_palettes != NULL && + ((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0) + { + if (num != -1) + { + png_free(png_ptr, info_ptr->splt_palettes[num].name); + png_free(png_ptr, info_ptr->splt_palettes[num].entries); + info_ptr->splt_palettes[num].name = NULL; + info_ptr->splt_palettes[num].entries = NULL; + } + + else + { + int i; + + for (i = 0; i < info_ptr->splt_palettes_num; i++) + { + png_free(png_ptr, info_ptr->splt_palettes[i].name); + png_free(png_ptr, info_ptr->splt_palettes[i].entries); + } + + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes = NULL; + info_ptr->splt_palettes_num = 0; + info_ptr->valid &= ~PNG_INFO_sPLT; + } + } +#endif + +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED + if (info_ptr->unknown_chunks != NULL && + ((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0) + { + if (num != -1) + { + png_free(png_ptr, info_ptr->unknown_chunks[num].data); + info_ptr->unknown_chunks[num].data = NULL; + } + + else + { + int i; + + for (i = 0; i < info_ptr->unknown_chunks_num; i++) + png_free(png_ptr, info_ptr->unknown_chunks[i].data); + + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks = NULL; + info_ptr->unknown_chunks_num = 0; + } + } +#endif + +#ifdef PNG_eXIf_SUPPORTED + /* Free any eXIf entry */ + if (((mask & PNG_FREE_EXIF) & info_ptr->free_me) != 0) + { +# ifdef PNG_READ_eXIf_SUPPORTED + if (info_ptr->eXIf_buf) + { + png_free(png_ptr, info_ptr->eXIf_buf); + info_ptr->eXIf_buf = NULL; + } +# endif + if (info_ptr->exif) + { + png_free(png_ptr, info_ptr->exif); + info_ptr->exif = NULL; + } + info_ptr->valid &= ~PNG_INFO_eXIf; + } +#endif + +#ifdef PNG_hIST_SUPPORTED + /* Free any hIST entry */ + if (((mask & PNG_FREE_HIST) & info_ptr->free_me) != 0) + { + png_free(png_ptr, info_ptr->hist); + info_ptr->hist = NULL; + info_ptr->valid &= ~PNG_INFO_hIST; + } +#endif + + /* Free any PLTE entry that was internally allocated */ + if (((mask & PNG_FREE_PLTE) & info_ptr->free_me) != 0) + { + png_free(png_ptr, info_ptr->palette); + info_ptr->palette = NULL; + info_ptr->valid &= ~PNG_INFO_PLTE; + info_ptr->num_palette = 0; + } + +#ifdef PNG_INFO_IMAGE_SUPPORTED + /* Free any image bits attached to the info structure */ + if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0) + { + if (info_ptr->row_pointers != NULL) + { + png_uint_32 row; + for (row = 0; row < info_ptr->height; row++) + png_free(png_ptr, info_ptr->row_pointers[row]); + + png_free(png_ptr, info_ptr->row_pointers); + info_ptr->row_pointers = NULL; + } + info_ptr->valid &= ~PNG_INFO_IDAT; + } +#endif + + if (num != -1) + mask &= ~PNG_FREE_MUL; + + info_ptr->free_me &= ~mask; +} +#endif /* READ || WRITE */ + +/* This function returns a pointer to the io_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy() or png_read_destroy() are called. + */ +png_voidp PNGAPI +png_get_io_ptr(png_const_structrp png_ptr) +{ + if (png_ptr == NULL) + return (NULL); + + return (png_ptr->io_ptr); +} + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +# ifdef PNG_STDIO_SUPPORTED +/* Initialize the default input/output functions for the PNG file. If you + * use your own read or write routines, you can call either png_set_read_fn() + * or png_set_write_fn() instead of png_init_io(). If you have defined + * PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a + * function of your own because "FILE *" isn't necessarily available. + */ +void PNGAPI +png_init_io(png_structrp png_ptr, png_FILE_p fp) +{ + png_debug(1, "in png_init_io"); + + if (png_ptr == NULL) + return; + + png_ptr->io_ptr = (png_voidp)fp; +} +# endif + +# ifdef PNG_SAVE_INT_32_SUPPORTED +/* PNG signed integers are saved in 32-bit 2's complement format. ANSI C-90 + * defines a cast of a signed integer to an unsigned integer either to preserve + * the value, if it is positive, or to calculate: + * + * (UNSIGNED_MAX+1) + integer + * + * Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the + * negative integral value is added the result will be an unsigned value + * correspnding to the 2's complement representation. + */ +void PNGAPI +png_save_int_32(png_bytep buf, png_int_32 i) +{ + png_save_uint_32(buf, (png_uint_32)i); +} +# endif + +# ifdef PNG_TIME_RFC1123_SUPPORTED +/* Convert the supplied time into an RFC 1123 string suitable for use in + * a "Creation Time" or other text-based time string. + */ +int PNGAPI +png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime) +{ + static PNG_CONST char short_months[12][4] = + {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + if (out == NULL) + return 0; + + if (ptime->year > 9999 /* RFC1123 limitation */ || + ptime->month == 0 || ptime->month > 12 || + ptime->day == 0 || ptime->day > 31 || + ptime->hour > 23 || ptime->minute > 59 || + ptime->second > 60) + return 0; + + { + size_t pos = 0; + char number_buf[5]; /* enough for a four-digit year */ + +# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string)) +# define APPEND_NUMBER(format, value)\ + APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value))) +# define APPEND(ch) if (pos < 28) out[pos++] = (ch) + + APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day); + APPEND(' '); + APPEND_STRING(short_months[(ptime->month - 1)]); + APPEND(' '); + APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year); + APPEND(' '); + APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour); + APPEND(':'); + APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute); + APPEND(':'); + APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second); + APPEND_STRING(" +0000"); /* This reliably terminates the buffer */ + PNG_UNUSED (pos) + +# undef APPEND +# undef APPEND_NUMBER +# undef APPEND_STRING + } + + return 1; +} + +# if PNG_LIBPNG_VER < 10700 +/* To do: remove the following from libpng-1.7 */ +/* Original API that uses a private buffer in png_struct. + * Deprecated because it causes png_struct to carry a spurious temporary + * buffer (png_struct::time_buffer), better to have the caller pass this in. + */ +png_const_charp PNGAPI +png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime) +{ + if (png_ptr != NULL) + { + /* The only failure above if png_ptr != NULL is from an invalid ptime */ + if (png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime) == 0) + png_warning(png_ptr, "Ignoring invalid time value"); + + else + return png_ptr->time_buffer; + } + + return NULL; +} +# endif /* LIBPNG_VER < 10700 */ +# endif /* TIME_RFC1123 */ + +#endif /* READ || WRITE */ + +png_const_charp PNGAPI +png_get_copyright(png_const_structrp png_ptr) +{ + PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ +#ifdef PNG_STRING_COPYRIGHT + return PNG_STRING_COPYRIGHT +#else +# ifdef __STDC__ + return PNG_STRING_NEWLINE \ + "libpng version 1.6.34 - September 29, 2017" PNG_STRING_NEWLINE \ + "Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \ + PNG_STRING_NEWLINE \ + "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ + "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ + PNG_STRING_NEWLINE; +# else + return "libpng version 1.6.34 - September 29, 2017\ + Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\ + Copyright (c) 1996-1997 Andreas Dilger\ + Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; +# endif +#endif +} + +/* The following return the library version as a short string in the + * format 1.0.0 through 99.99.99zz. To get the version of *.h files + * used with your application, print out PNG_LIBPNG_VER_STRING, which + * is defined in png.h. + * Note: now there is no difference between png_get_libpng_ver() and + * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, + * it is guaranteed that png.c uses the correct version of png.h. + */ +png_const_charp PNGAPI +png_get_libpng_ver(png_const_structrp png_ptr) +{ + /* Version of *.c files used when building libpng */ + return png_get_header_ver(png_ptr); +} + +png_const_charp PNGAPI +png_get_header_ver(png_const_structrp png_ptr) +{ + /* Version of *.h files used when building libpng */ + PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ + return PNG_LIBPNG_VER_STRING; +} + +png_const_charp PNGAPI +png_get_header_version(png_const_structrp png_ptr) +{ + /* Returns longer string containing both version and date */ + PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ +#ifdef __STDC__ + return PNG_HEADER_VERSION_STRING +# ifndef PNG_READ_SUPPORTED + " (NO READ SUPPORT)" +# endif + PNG_STRING_NEWLINE; +#else + return PNG_HEADER_VERSION_STRING; +#endif +} + +#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED +/* NOTE: this routine is not used internally! */ +/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth + * large of png_color. This lets grayscale images be treated as + * paletted. Most useful for gamma correction and simplification + * of code. This API is not used internally. + */ +void PNGAPI +png_build_grayscale_palette(int bit_depth, png_colorp palette) +{ + int num_palette; + int color_inc; + int i; + int v; + + png_debug(1, "in png_do_build_grayscale_palette"); + + if (palette == NULL) + return; + + switch (bit_depth) + { + case 1: + num_palette = 2; + color_inc = 0xff; + break; + + case 2: + num_palette = 4; + color_inc = 0x55; + break; + + case 4: + num_palette = 16; + color_inc = 0x11; + break; + + case 8: + num_palette = 256; + color_inc = 1; + break; + + default: + num_palette = 0; + color_inc = 0; + break; + } + + for (i = 0, v = 0; i < num_palette; i++, v += color_inc) + { + palette[i].red = (png_byte)(v & 0xff); + palette[i].green = (png_byte)(v & 0xff); + palette[i].blue = (png_byte)(v & 0xff); + } +} +#endif + +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED +int PNGAPI +png_handle_as_unknown(png_const_structrp png_ptr, png_const_bytep chunk_name) +{ + /* Check chunk_name and return "keep" value if it's on the list, else 0 */ + png_const_bytep p, p_end; + + if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list == 0) + return PNG_HANDLE_CHUNK_AS_DEFAULT; + + p_end = png_ptr->chunk_list; + p = p_end + png_ptr->num_chunk_list*5; /* beyond end */ + + /* The code is the fifth byte after each four byte string. Historically this + * code was always searched from the end of the list, this is no longer + * necessary because the 'set' routine handles duplicate entries correcty. + */ + do /* num_chunk_list > 0, so at least one */ + { + p -= 5; + + if (memcmp(chunk_name, p, 4) == 0) + return p[4]; + } + while (p > p_end); + + /* This means that known chunks should be processed and unknown chunks should + * be handled according to the value of png_ptr->unknown_default; this can be + * confusing because, as a result, there are two levels of defaulting for + * unknown chunks. + */ + return PNG_HANDLE_CHUNK_AS_DEFAULT; +} + +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\ + defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) +int /* PRIVATE */ +png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name) +{ + png_byte chunk_string[5]; + + PNG_CSTRING_FROM_CHUNK(chunk_string, chunk_name); + return png_handle_as_unknown(png_ptr, chunk_string); +} +#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */ +#endif /* SET_UNKNOWN_CHUNKS */ + +#ifdef PNG_READ_SUPPORTED +/* This function, added to libpng-1.0.6g, is untested. */ +int PNGAPI +png_reset_zstream(png_structrp png_ptr) +{ + if (png_ptr == NULL) + return Z_STREAM_ERROR; + + /* WARNING: this resets the window bits to the maximum! */ + return (inflateReset(&png_ptr->zstream)); +} +#endif /* READ */ + +/* This function was added to libpng-1.0.7 */ +png_uint_32 PNGAPI +png_access_version_number(void) +{ + /* Version of *.c files used when building libpng */ + return((png_uint_32)PNG_LIBPNG_VER); +} + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +/* Ensure that png_ptr->zstream.msg holds some appropriate error message string. + * If it doesn't 'ret' is used to set it to something appropriate, even in cases + * like Z_OK or Z_STREAM_END where the error code is apparently a success code. + */ +void /* PRIVATE */ +png_zstream_error(png_structrp png_ptr, int ret) +{ + /* Translate 'ret' into an appropriate error string, priority is given to the + * one in zstream if set. This always returns a string, even in cases like + * Z_OK or Z_STREAM_END where the error code is a success code. + */ + if (png_ptr->zstream.msg == NULL) switch (ret) + { + default: + case Z_OK: + png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return code"); + break; + + case Z_STREAM_END: + /* Normal exit */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected end of LZ stream"); + break; + + case Z_NEED_DICT: + /* This means the deflate stream did not have a dictionary; this + * indicates a bogus PNG. + */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("missing LZ dictionary"); + break; + + case Z_ERRNO: + /* gz APIs only: should not happen */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("zlib IO error"); + break; + + case Z_STREAM_ERROR: + /* internal libpng error */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("bad parameters to zlib"); + break; + + case Z_DATA_ERROR: + png_ptr->zstream.msg = PNGZ_MSG_CAST("damaged LZ stream"); + break; + + case Z_MEM_ERROR: + png_ptr->zstream.msg = PNGZ_MSG_CAST("insufficient memory"); + break; + + case Z_BUF_ERROR: + /* End of input or output; not a problem if the caller is doing + * incremental read or write. + */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("truncated"); + break; + + case Z_VERSION_ERROR: + png_ptr->zstream.msg = PNGZ_MSG_CAST("unsupported zlib version"); + break; + + case PNG_UNEXPECTED_ZLIB_RETURN: + /* Compile errors here mean that zlib now uses the value co-opted in + * pngpriv.h for PNG_UNEXPECTED_ZLIB_RETURN; update the switch above + * and change pngpriv.h. Note that this message is "... return", + * whereas the default/Z_OK one is "... return code". + */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return"); + break; + } +} + +/* png_convert_size: a PNGAPI but no longer in png.h, so deleted + * at libpng 1.5.5! + */ + +/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ +#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */ +static int +png_colorspace_check_gamma(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_fixed_point gAMA, int from) + /* This is called to check a new gamma value against an existing one. The + * routine returns false if the new gamma value should not be written. + * + * 'from' says where the new gamma value comes from: + * + * 0: the new gamma value is the libpng estimate for an ICC profile + * 1: the new gamma value comes from a gAMA chunk + * 2: the new gamma value comes from an sRGB chunk + */ +{ + png_fixed_point gtest; + + if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && + (png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 || + png_gamma_significant(gtest) != 0)) + { + /* Either this is an sRGB image, in which case the calculated gamma + * approximation should match, or this is an image with a profile and the + * value libpng calculates for the gamma of the profile does not match the + * value recorded in the file. The former, sRGB, case is an error, the + * latter is just a warning. + */ + if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2) + { + png_chunk_report(png_ptr, "gamma value does not match sRGB", + PNG_CHUNK_ERROR); + /* Do not overwrite an sRGB value */ + return from == 2; + } + + else /* sRGB tag not involved */ + { + png_chunk_report(png_ptr, "gamma value does not match libpng estimate", + PNG_CHUNK_WARNING); + return from == 1; + } + } + + return 1; +} + +void /* PRIVATE */ +png_colorspace_set_gamma(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_fixed_point gAMA) +{ + /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't + * occur. Since the fixed point representation is asymetrical it is + * possible for 1/gamma to overflow the limit of 21474 and this means the + * gamma value must be at least 5/100000 and hence at most 20000.0. For + * safety the limits here are a little narrower. The values are 0.00016 to + * 6250.0, which are truly ridiculous gamma values (and will produce + * displays that are all black or all white.) + * + * In 1.6.0 this test replaces the ones in pngrutil.c, in the gAMA chunk + * handling code, which only required the value to be >0. + */ + png_const_charp errmsg; + + if (gAMA < 16 || gAMA > 625000000) + errmsg = "gamma value out of range"; + +# ifdef PNG_READ_gAMA_SUPPORTED + /* Allow the application to set the gamma value more than once */ + else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && + (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0) + errmsg = "duplicate"; +# endif + + /* Do nothing if the colorspace is already invalid */ + else if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) + return; + + else + { + if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA, + 1/*from gAMA*/) != 0) + { + /* Store this gamma value. */ + colorspace->gamma = gAMA; + colorspace->flags |= + (PNG_COLORSPACE_HAVE_GAMMA | PNG_COLORSPACE_FROM_gAMA); + } + + /* At present if the check_gamma test fails the gamma of the colorspace is + * not updated however the colorspace is not invalidated. This + * corresponds to the case where the existing gamma comes from an sRGB + * chunk or profile. An error message has already been output. + */ + return; + } + + /* Error exit - errmsg has been set. */ + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_chunk_report(png_ptr, errmsg, PNG_CHUNK_WRITE_ERROR); +} + +void /* PRIVATE */ +png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr) +{ + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0) + { + /* Everything is invalid */ + info_ptr->valid &= ~(PNG_INFO_gAMA|PNG_INFO_cHRM|PNG_INFO_sRGB| + PNG_INFO_iCCP); + +# ifdef PNG_COLORSPACE_SUPPORTED + /* Clean up the iCCP profile now if it won't be used. */ + png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/); +# else + PNG_UNUSED(png_ptr) +# endif + } + + else + { +# ifdef PNG_COLORSPACE_SUPPORTED + /* Leave the INFO_iCCP flag set if the pngset.c code has already set + * it; this allows a PNG to contain a profile which matches sRGB and + * yet still have that profile retrievable by the application. + */ + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0) + info_ptr->valid |= PNG_INFO_sRGB; + + else + info_ptr->valid &= ~PNG_INFO_sRGB; + + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + info_ptr->valid |= PNG_INFO_cHRM; + + else + info_ptr->valid &= ~PNG_INFO_cHRM; +# endif + + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0) + info_ptr->valid |= PNG_INFO_gAMA; + + else + info_ptr->valid &= ~PNG_INFO_gAMA; + } +} + +#ifdef PNG_READ_SUPPORTED +void /* PRIVATE */ +png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr) +{ + if (info_ptr == NULL) /* reduce code size; check here not in the caller */ + return; + + info_ptr->colorspace = png_ptr->colorspace; + png_colorspace_sync_info(png_ptr, info_ptr); +} +#endif +#endif /* GAMMA */ + +#ifdef PNG_COLORSPACE_SUPPORTED +/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for + * cHRM, as opposed to using chromaticities. These internal APIs return + * non-zero on a parameter error. The X, Y and Z values are required to be + * positive and less than 1.0. + */ +static int +png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) +{ + png_int_32 d, dwhite, whiteX, whiteY; + + d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z; + if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d) == 0) + return 1; + if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d) == 0) + return 1; + dwhite = d; + whiteX = XYZ->red_X; + whiteY = XYZ->red_Y; + + d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z; + if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d) == 0) + return 1; + if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d) == 0) + return 1; + dwhite += d; + whiteX += XYZ->green_X; + whiteY += XYZ->green_Y; + + d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z; + if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d) == 0) + return 1; + if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d) == 0) + return 1; + dwhite += d; + whiteX += XYZ->blue_X; + whiteY += XYZ->blue_Y; + + /* The reference white is simply the sum of the end-point (X,Y,Z) vectors, + * thus: + */ + if (png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite) == 0) + return 1; + if (png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite) == 0) + return 1; + + return 0; +} + +static int +png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) +{ + png_fixed_point red_inverse, green_inverse, blue_scale; + png_fixed_point left, right, denominator; + + /* Check xy and, implicitly, z. Note that wide gamut color spaces typically + * have end points with 0 tristimulus values (these are impossible end + * points, but they are used to cover the possible colors). We check + * xy->whitey against 5, not 0, to avoid a possible integer overflow. + */ + if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1; + if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1; + if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1; + if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1; + if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1; + if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1; + if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1; + if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1; + + /* The reverse calculation is more difficult because the original tristimulus + * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8 + * derived values were recorded in the cHRM chunk; + * (red,green,blue,white)x(x,y). This loses one degree of freedom and + * therefore an arbitrary ninth value has to be introduced to undo the + * original transformations. + * + * Think of the original end-points as points in (X,Y,Z) space. The + * chromaticity values (c) have the property: + * + * C + * c = --------- + * X + Y + Z + * + * For each c (x,y,z) from the corresponding original C (X,Y,Z). Thus the + * three chromaticity values (x,y,z) for each end-point obey the + * relationship: + * + * x + y + z = 1 + * + * This describes the plane in (X,Y,Z) space that intersects each axis at the + * value 1.0; call this the chromaticity plane. Thus the chromaticity + * calculation has scaled each end-point so that it is on the x+y+z=1 plane + * and chromaticity is the intersection of the vector from the origin to the + * (X,Y,Z) value with the chromaticity plane. + * + * To fully invert the chromaticity calculation we would need the three + * end-point scale factors, (red-scale, green-scale, blue-scale), but these + * were not recorded. Instead we calculated the reference white (X,Y,Z) and + * recorded the chromaticity of this. The reference white (X,Y,Z) would have + * given all three of the scale factors since: + * + * color-C = color-c * color-scale + * white-C = red-C + green-C + blue-C + * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale + * + * But cHRM records only white-x and white-y, so we have lost the white scale + * factor: + * + * white-C = white-c*white-scale + * + * To handle this the inverse transformation makes an arbitrary assumption + * about white-scale: + * + * Assume: white-Y = 1.0 + * Hence: white-scale = 1/white-y + * Or: red-Y + green-Y + blue-Y = 1.0 + * + * Notice the last statement of the assumption gives an equation in three of + * the nine values we want to calculate. 8 more equations come from the + * above routine as summarised at the top above (the chromaticity + * calculation): + * + * Given: color-x = color-X / (color-X + color-Y + color-Z) + * Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0 + * + * This is 9 simultaneous equations in the 9 variables "color-C" and can be + * solved by Cramer's rule. Cramer's rule requires calculating 10 9x9 matrix + * determinants, however this is not as bad as it seems because only 28 of + * the total of 90 terms in the various matrices are non-zero. Nevertheless + * Cramer's rule is notoriously numerically unstable because the determinant + * calculation involves the difference of large, but similar, numbers. It is + * difficult to be sure that the calculation is stable for real world values + * and it is certain that it becomes unstable where the end points are close + * together. + * + * So this code uses the perhaps slightly less optimal but more + * understandable and totally obvious approach of calculating color-scale. + * + * This algorithm depends on the precision in white-scale and that is + * (1/white-y), so we can immediately see that as white-y approaches 0 the + * accuracy inherent in the cHRM chunk drops off substantially. + * + * libpng arithmetic: a simple inversion of the above equations + * ------------------------------------------------------------ + * + * white_scale = 1/white-y + * white-X = white-x * white-scale + * white-Y = 1.0 + * white-Z = (1 - white-x - white-y) * white_scale + * + * white-C = red-C + green-C + blue-C + * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale + * + * This gives us three equations in (red-scale,green-scale,blue-scale) where + * all the coefficients are now known: + * + * red-x*red-scale + green-x*green-scale + blue-x*blue-scale + * = white-x/white-y + * red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1 + * red-z*red-scale + green-z*green-scale + blue-z*blue-scale + * = (1 - white-x - white-y)/white-y + * + * In the last equation color-z is (1 - color-x - color-y) so we can add all + * three equations together to get an alternative third: + * + * red-scale + green-scale + blue-scale = 1/white-y = white-scale + * + * So now we have a Cramer's rule solution where the determinants are just + * 3x3 - far more tractible. Unfortunately 3x3 determinants still involve + * multiplication of three coefficients so we can't guarantee to avoid + * overflow in the libpng fixed point representation. Using Cramer's rule in + * floating point is probably a good choice here, but it's not an option for + * fixed point. Instead proceed to simplify the first two equations by + * eliminating what is likely to be the largest value, blue-scale: + * + * blue-scale = white-scale - red-scale - green-scale + * + * Hence: + * + * (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale = + * (white-x - blue-x)*white-scale + * + * (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale = + * 1 - blue-y*white-scale + * + * And now we can trivially solve for (red-scale,green-scale): + * + * green-scale = + * (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale + * ----------------------------------------------------------- + * green-x - blue-x + * + * red-scale = + * 1 - blue-y*white-scale - (green-y - blue-y) * green-scale + * --------------------------------------------------------- + * red-y - blue-y + * + * Hence: + * + * red-scale = + * ( (green-x - blue-x) * (white-y - blue-y) - + * (green-y - blue-y) * (white-x - blue-x) ) / white-y + * ------------------------------------------------------------------------- + * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) + * + * green-scale = + * ( (red-y - blue-y) * (white-x - blue-x) - + * (red-x - blue-x) * (white-y - blue-y) ) / white-y + * ------------------------------------------------------------------------- + * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) + * + * Accuracy: + * The input values have 5 decimal digits of accuracy. The values are all in + * the range 0 < value < 1, so simple products are in the same range but may + * need up to 10 decimal digits to preserve the original precision and avoid + * underflow. Because we are using a 32-bit signed representation we cannot + * match this; the best is a little over 9 decimal digits, less than 10. + * + * The approach used here is to preserve the maximum precision within the + * signed representation. Because the red-scale calculation above uses the + * difference between two products of values that must be in the range -1..+1 + * it is sufficient to divide the product by 7; ceil(100,000/32767*2). The + * factor is irrelevant in the calculation because it is applied to both + * numerator and denominator. + * + * Note that the values of the differences of the products of the + * chromaticities in the above equations tend to be small, for example for + * the sRGB chromaticities they are: + * + * red numerator: -0.04751 + * green numerator: -0.08788 + * denominator: -0.2241 (without white-y multiplication) + * + * The resultant Y coefficients from the chromaticities of some widely used + * color space definitions are (to 15 decimal places): + * + * sRGB + * 0.212639005871510 0.715168678767756 0.072192315360734 + * Kodak ProPhoto + * 0.288071128229293 0.711843217810102 0.000085653960605 + * Adobe RGB + * 0.297344975250536 0.627363566255466 0.075291458493998 + * Adobe Wide Gamut RGB + * 0.258728243040113 0.724682314948566 0.016589442011321 + */ + /* By the argument, above overflow should be impossible here. The return + * value of 2 indicates an internal error to the caller. + */ + if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0) + return 2; + if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0) + return 2; + denominator = left - right; + + /* Now find the red numerator. */ + if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0) + return 2; + if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 0) + return 2; + + /* Overflow is possible here and it indicates an extreme set of PNG cHRM + * chunk values. This calculation actually returns the reciprocal of the + * scale value because this allows us to delay the multiplication of white-y + * into the denominator, which tends to produce a small number. + */ + if (png_muldiv(&red_inverse, xy->whitey, denominator, left-right) == 0 || + red_inverse <= xy->whitey /* r+g+b scales = white scale */) + return 1; + + /* Similarly for green_inverse: */ + if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7) == 0) + return 2; + if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0) + return 2; + if (png_muldiv(&green_inverse, xy->whitey, denominator, left-right) == 0 || + green_inverse <= xy->whitey) + return 1; + + /* And the blue scale, the checks above guarantee this can't overflow but it + * can still produce 0 for extreme cHRM values. + */ + blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) - + png_reciprocal(green_inverse); + if (blue_scale <= 0) + return 1; + + + /* And fill in the png_XYZ: */ + if (png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse) == 0) + return 1; + if (png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse) == 0) + return 1; + if (png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1, + red_inverse) == 0) + return 1; + + if (png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse) == 0) + return 1; + if (png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse) == 0) + return 1; + if (png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1, + green_inverse) == 0) + return 1; + + if (png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1) == 0) + return 1; + if (png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale, PNG_FP_1) == 0) + return 1; + if (png_muldiv(&XYZ->blue_Z, PNG_FP_1 - xy->bluex - xy->bluey, blue_scale, + PNG_FP_1) == 0) + return 1; + + return 0; /*success*/ +} + +static int +png_XYZ_normalize(png_XYZ *XYZ) +{ + png_int_32 Y; + + if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 || + XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 || + XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0) + return 1; + + /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1. + * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore + * relying on addition of two positive values producing a negative one is not + * safe. + */ + Y = XYZ->red_Y; + if (0x7fffffff - Y < XYZ->green_X) + return 1; + Y += XYZ->green_Y; + if (0x7fffffff - Y < XYZ->blue_X) + return 1; + Y += XYZ->blue_Y; + + if (Y != PNG_FP_1) + { + if (png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y) == 0) + return 1; + if (png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y) == 0) + return 1; + if (png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y) == 0) + return 1; + + if (png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y) == 0) + return 1; + if (png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y) == 0) + return 1; + if (png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y) == 0) + return 1; + + if (png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y) == 0) + return 1; + if (png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y) == 0) + return 1; + if (png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y) == 0) + return 1; + } + + return 0; +} + +static int +png_colorspace_endpoints_match(const png_xy *xy1, const png_xy *xy2, int delta) +{ + /* Allow an error of +/-0.01 (absolute value) on each chromaticity */ + if (PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) || + PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) || + PNG_OUT_OF_RANGE(xy1->redx, xy2->redx, delta) || + PNG_OUT_OF_RANGE(xy1->redy, xy2->redy, delta) || + PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) || + PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) || + PNG_OUT_OF_RANGE(xy1->bluex, xy2->bluex, delta) || + PNG_OUT_OF_RANGE(xy1->bluey, xy2->bluey, delta)) + return 0; + return 1; +} + +/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM + * chunk chromaticities. Earlier checks used to simply look for the overflow + * condition (where the determinant of the matrix to solve for XYZ ends up zero + * because the chromaticity values are not all distinct.) Despite this it is + * theoretically possible to produce chromaticities that are apparently valid + * but that rapidly degrade to invalid, potentially crashing, sets because of + * arithmetic inaccuracies when calculations are performed on them. The new + * check is to round-trip xy -> XYZ -> xy and then check that the result is + * within a small percentage of the original. + */ +static int +png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy) +{ + int result; + png_xy xy_test; + + /* As a side-effect this routine also returns the XYZ endpoints. */ + result = png_XYZ_from_xy(XYZ, xy); + if (result != 0) + return result; + + result = png_xy_from_XYZ(&xy_test, XYZ); + if (result != 0) + return result; + + if (png_colorspace_endpoints_match(xy, &xy_test, + 5/*actually, the math is pretty accurate*/) != 0) + return 0; + + /* Too much slip */ + return 1; +} + +/* This is the check going the other way. The XYZ is modified to normalize it + * (another side-effect) and the xy chromaticities are returned. + */ +static int +png_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ) +{ + int result; + png_XYZ XYZtemp; + + result = png_XYZ_normalize(XYZ); + if (result != 0) + return result; + + result = png_xy_from_XYZ(xy, XYZ); + if (result != 0) + return result; + + XYZtemp = *XYZ; + return png_colorspace_check_xy(&XYZtemp, xy); +} + +/* Used to check for an endpoint match against sRGB */ +static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */ +{ + /* color x y */ + /* red */ 64000, 33000, + /* green */ 30000, 60000, + /* blue */ 15000, 6000, + /* white */ 31270, 32900 +}; + +static int +png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, + png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, + int preferred) +{ + if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) + return 0; + + /* The consistency check is performed on the chromaticities; this factors out + * variations because of the normalization (or not) of the end point Y + * values. + */ + if (preferred < 2 && + (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + { + /* The end points must be reasonably close to any we already have. The + * following allows an error of up to +/-.001 + */ + if (png_colorspace_endpoints_match(xy, &colorspace->end_points_xy, + 100) == 0) + { + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_benign_error(png_ptr, "inconsistent chromaticities"); + return 0; /* failed */ + } + + /* Only overwrite with preferred values */ + if (preferred == 0) + return 1; /* ok, but no change */ + } + + colorspace->end_points_xy = *xy; + colorspace->end_points_XYZ = *XYZ; + colorspace->flags |= PNG_COLORSPACE_HAVE_ENDPOINTS; + + /* The end points are normally quoted to two decimal digits, so allow +/-0.01 + * on this test. + */ + if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000) != 0) + colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB; + + else + colorspace->flags &= PNG_COLORSPACE_CANCEL( + PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB); + + return 2; /* ok and changed */ +} + +int /* PRIVATE */ +png_colorspace_set_chromaticities(png_const_structrp png_ptr, + png_colorspacerp colorspace, const png_xy *xy, int preferred) +{ + /* We must check the end points to ensure they are reasonable - in the past + * color management systems have crashed as a result of getting bogus + * colorant values, while this isn't the fault of libpng it is the + * responsibility of libpng because PNG carries the bomb and libpng is in a + * position to protect against it. + */ + png_XYZ XYZ; + + switch (png_colorspace_check_xy(&XYZ, xy)) + { + case 0: /* success */ + return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ, + preferred); + + case 1: + /* We can't invert the chromaticities so we can't produce value XYZ + * values. Likely as not a color management system will fail too. + */ + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_benign_error(png_ptr, "invalid chromaticities"); + break; + + default: + /* libpng is broken; this should be a warning but if it happens we + * want error reports so for the moment it is an error. + */ + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_error(png_ptr, "internal error checking chromaticities"); + } + + return 0; /* failed */ +} + +int /* PRIVATE */ +png_colorspace_set_endpoints(png_const_structrp png_ptr, + png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred) +{ + png_XYZ XYZ = *XYZ_in; + png_xy xy; + + switch (png_colorspace_check_XYZ(&xy, &XYZ)) + { + case 0: + return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ, + preferred); + + case 1: + /* End points are invalid. */ + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_benign_error(png_ptr, "invalid end points"); + break; + + default: + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_error(png_ptr, "internal error checking chromaticities"); + } + + return 0; /* failed */ +} + +#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED) +/* Error message generation */ +static char +png_icc_tag_char(png_uint_32 byte) +{ + byte &= 0xff; + if (byte >= 32 && byte <= 126) + return (char)byte; + else + return '?'; +} + +static void +png_icc_tag_name(char *name, png_uint_32 tag) +{ + name[0] = '\''; + name[1] = png_icc_tag_char(tag >> 24); + name[2] = png_icc_tag_char(tag >> 16); + name[3] = png_icc_tag_char(tag >> 8); + name[4] = png_icc_tag_char(tag ); + name[5] = '\''; +} + +static int +is_ICC_signature_char(png_alloc_size_t it) +{ + return it == 32 || (it >= 48 && it <= 57) || (it >= 65 && it <= 90) || + (it >= 97 && it <= 122); +} + +static int +is_ICC_signature(png_alloc_size_t it) +{ + return is_ICC_signature_char(it >> 24) /* checks all the top bits */ && + is_ICC_signature_char((it >> 16) & 0xff) && + is_ICC_signature_char((it >> 8) & 0xff) && + is_ICC_signature_char(it & 0xff); +} + +static int +png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_alloc_size_t value, png_const_charp reason) +{ + size_t pos; + char message[196]; /* see below for calculation */ + + if (colorspace != NULL) + colorspace->flags |= PNG_COLORSPACE_INVALID; + + pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */ + pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */ + pos = png_safecat(message, (sizeof message), pos, "': "); /* +2 = 90 */ + if (is_ICC_signature(value) != 0) + { + /* So 'value' is at most 4 bytes and the following cast is safe */ + png_icc_tag_name(message+pos, (png_uint_32)value); + pos += 6; /* total +8; less than the else clause */ + message[pos++] = ':'; + message[pos++] = ' '; + } +# ifdef PNG_WARNINGS_SUPPORTED + else + { + char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/ + + pos = png_safecat(message, (sizeof message), pos, + png_format_number(number, number+(sizeof number), + PNG_NUMBER_FORMAT_x, value)); + pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/ + } +# endif + /* The 'reason' is an arbitrary message, allow +79 maximum 195 */ + pos = png_safecat(message, (sizeof message), pos, reason); + PNG_UNUSED(pos) + + /* This is recoverable, but make it unconditionally an app_error on write to + * avoid writing invalid ICC profiles into PNG files (i.e., we handle them + * on read, with a warning, but on write unless the app turns off + * application errors the PNG won't be written.) + */ + png_chunk_report(png_ptr, message, + (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR); + + return 0; +} +#endif /* sRGB || iCCP */ + +#ifdef PNG_sRGB_SUPPORTED +int /* PRIVATE */ +png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, + int intent) +{ + /* sRGB sets known gamma, end points and (from the chunk) intent. */ + /* IMPORTANT: these are not necessarily the values found in an ICC profile + * because ICC profiles store values adapted to a D50 environment; it is + * expected that the ICC profile mediaWhitePointTag will be D50; see the + * checks and code elsewhere to understand this better. + * + * These XYZ values, which are accurate to 5dp, produce rgb to gray + * coefficients of (6968,23435,2366), which are reduced (because they add up + * to 32769 not 32768) to (6968,23434,2366). These are the values that + * libpng has traditionally used (and are the best values given the 15bit + * algorithm used by the rgb to gray code.) + */ + static const png_XYZ sRGB_XYZ = /* D65 XYZ (*not* the D50 adapted values!) */ + { + /* color X Y Z */ + /* red */ 41239, 21264, 1933, + /* green */ 35758, 71517, 11919, + /* blue */ 18048, 7219, 95053 + }; + + /* Do nothing if the colorspace is already invalidated. */ + if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) + return 0; + + /* Check the intent, then check for existing settings. It is valid for the + * PNG file to have cHRM or gAMA chunks along with sRGB, but the values must + * be consistent with the correct values. If, however, this function is + * called below because an iCCP chunk matches sRGB then it is quite + * conceivable that an older app recorded incorrect gAMA and cHRM because of + * an incorrect calculation based on the values in the profile - this does + * *not* invalidate the profile (though it still produces an error, which can + * be ignored.) + */ + if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST) + return png_icc_profile_error(png_ptr, colorspace, "sRGB", + (png_alloc_size_t)intent, "invalid sRGB rendering intent"); + + if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 && + colorspace->rendering_intent != intent) + return png_icc_profile_error(png_ptr, colorspace, "sRGB", + (png_alloc_size_t)intent, "inconsistent rendering intents"); + + if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0) + { + png_benign_error(png_ptr, "duplicate sRGB information ignored"); + return 0; + } + + /* If the standard sRGB cHRM chunk does not match the one from the PNG file + * warn but overwrite the value with the correct one. + */ + if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 && + !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy, + 100)) + png_chunk_report(png_ptr, "cHRM chunk does not match sRGB", + PNG_CHUNK_ERROR); + + /* This check is just done for the error reporting - the routine always + * returns true when the 'from' argument corresponds to sRGB (2). + */ + (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE, + 2/*from sRGB*/); + + /* intent: bugs in GCC force 'int' to be used as the parameter type. */ + colorspace->rendering_intent = (png_uint_16)intent; + colorspace->flags |= PNG_COLORSPACE_HAVE_INTENT; + + /* endpoints */ + colorspace->end_points_xy = sRGB_xy; + colorspace->end_points_XYZ = sRGB_XYZ; + colorspace->flags |= + (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB); + + /* gamma */ + colorspace->gamma = PNG_GAMMA_sRGB_INVERSE; + colorspace->flags |= PNG_COLORSPACE_HAVE_GAMMA; + + /* Finally record that we have an sRGB profile */ + colorspace->flags |= + (PNG_COLORSPACE_MATCHES_sRGB|PNG_COLORSPACE_FROM_sRGB); + + return 1; /* set */ +} +#endif /* sRGB */ + +#ifdef PNG_iCCP_SUPPORTED +/* Encoded value of D50 as an ICC XYZNumber. From the ICC 2010 spec the value + * is XYZ(0.9642,1.0,0.8249), which scales to: + * + * (63189.8112, 65536, 54060.6464) + */ +static const png_byte D50_nCIEXYZ[12] = + { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d }; + +static int /* bool */ +icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length) +{ + if (profile_length < 132) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "too short"); + return 1; +} + +#ifdef PNG_READ_iCCP_SUPPORTED +int /* PRIVATE */ +png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length) +{ + if (!icc_check_length(png_ptr, colorspace, name, profile_length)) + return 0; + + /* This needs to be here because the 'normal' check is in + * png_decompress_chunk, yet this happens after the attempt to + * png_malloc_base the required data. We only need this on read; on write + * the caller supplies the profile buffer so libpng doesn't allocate it. See + * the call to icc_check_length below (the write case). + */ +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + else if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds application limits"); +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds libpng limits"); +# else /* !SET_USER_LIMITS */ + /* This will get compiled out on all 32-bit and better systems. */ + else if (PNG_SIZE_MAX < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds system limits"); +# endif /* !SET_USER_LIMITS */ + + return 1; +} +#endif /* READ_iCCP */ + +int /* PRIVATE */ +png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length, + png_const_bytep profile/* first 132 bytes only */, int color_type) +{ + png_uint_32 temp; + + /* Length check; this cannot be ignored in this code because profile_length + * is used later to check the tag table, so even if the profile seems over + * long profile_length from the caller must be correct. The caller can fix + * this up on read or write by just passing in the profile header length. + */ + temp = png_get_uint_32(profile); + if (temp != profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "length does not match profile"); + + temp = (png_uint_32) (*(profile+8)); + if (temp > 3 && (profile_length & 3)) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "invalid length"); + + temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */ + if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */ + profile_length < 132+12*temp) /* truncated tag table */ + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "tag count too large"); + + /* The 'intent' must be valid or we can't store it, ICC limits the intent to + * 16 bits. + */ + temp = png_get_uint_32(profile+64); + if (temp >= 0xffff) /* The ICC limit */ + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "invalid rendering intent"); + + /* This is just a warning because the profile may be valid in future + * versions. + */ + if (temp >= PNG_sRGB_INTENT_LAST) + (void)png_icc_profile_error(png_ptr, NULL, name, temp, + "intent outside defined range"); + + /* At this point the tag table can't be checked because it hasn't necessarily + * been loaded; however, various header fields can be checked. These checks + * are for values permitted by the PNG spec in an ICC profile; the PNG spec + * restricts the profiles that can be passed in an iCCP chunk (they must be + * appropriate to processing PNG data!) + */ + + /* Data checks (could be skipped). These checks must be independent of the + * version number; however, the version number doesn't accomodate changes in + * the header fields (just the known tags and the interpretation of the + * data.) + */ + temp = png_get_uint_32(profile+36); /* signature 'ascp' */ + if (temp != 0x61637370) + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "invalid signature"); + + /* Currently the PCS illuminant/adopted white point (the computational + * white point) are required to be D50, + * however the profile contains a record of the illuminant so perhaps ICC + * expects to be able to change this in the future (despite the rationale in + * the introduction for using a fixed PCS adopted white.) Consequently the + * following is just a warning. + */ + if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0) + (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/, + "PCS illuminant is not D50"); + + /* The PNG spec requires this: + * "If the iCCP chunk is present, the image samples conform to the colour + * space represented by the embedded ICC profile as defined by the + * International Color Consortium [ICC]. The colour space of the ICC profile + * shall be an RGB colour space for colour images (PNG colour types 2, 3, and + * 6), or a greyscale colour space for greyscale images (PNG colour types 0 + * and 4)." + * + * This checking code ensures the embedded profile (on either read or write) + * conforms to the specification requirements. Notice that an ICC 'gray' + * color-space profile contains the information to transform the monochrome + * data to XYZ or L*a*b (according to which PCS the profile uses) and this + * should be used in preference to the standard libpng K channel replication + * into R, G and B channels. + * + * Previously it was suggested that an RGB profile on grayscale data could be + * handled. However it it is clear that using an RGB profile in this context + * must be an error - there is no specification of what it means. Thus it is + * almost certainly more correct to ignore the profile. + */ + temp = png_get_uint_32(profile+16); /* data colour space field */ + switch (temp) + { + case 0x52474220: /* 'RGB ' */ + if ((color_type & PNG_COLOR_MASK_COLOR) == 0) + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "RGB color space not permitted on grayscale PNG"); + break; + + case 0x47524159: /* 'GRAY' */ + if ((color_type & PNG_COLOR_MASK_COLOR) != 0) + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "Gray color space not permitted on RGB PNG"); + break; + + default: + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "invalid ICC profile color space"); + } + + /* It is up to the application to check that the profile class matches the + * application requirements; the spec provides no guidance, but it's pretty + * weird if the profile is not scanner ('scnr'), monitor ('mntr'), printer + * ('prtr') or 'spac' (for generic color spaces). Issue a warning in these + * cases. Issue an error for device link or abstract profiles - these don't + * contain the records necessary to transform the color-space to anything + * other than the target device (and not even that for an abstract profile). + * Profiles of these classes may not be embedded in images. + */ + temp = png_get_uint_32(profile+12); /* profile/device class */ + switch (temp) + { + case 0x73636e72: /* 'scnr' */ + case 0x6d6e7472: /* 'mntr' */ + case 0x70727472: /* 'prtr' */ + case 0x73706163: /* 'spac' */ + /* All supported */ + break; + + case 0x61627374: /* 'abst' */ + /* May not be embedded in an image */ + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "invalid embedded Abstract ICC profile"); + + case 0x6c696e6b: /* 'link' */ + /* DeviceLink profiles cannot be interpreted in a non-device specific + * fashion, if an app uses the AToB0Tag in the profile the results are + * undefined unless the result is sent to the intended device, + * therefore a DeviceLink profile should not be found embedded in a + * PNG. + */ + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "unexpected DeviceLink ICC profile class"); + + case 0x6e6d636c: /* 'nmcl' */ + /* A NamedColor profile is also device specific, however it doesn't + * contain an AToB0 tag that is open to misinterpretation. Almost + * certainly it will fail the tests below. + */ + (void)png_icc_profile_error(png_ptr, NULL, name, temp, + "unexpected NamedColor ICC profile class"); + break; + + default: + /* To allow for future enhancements to the profile accept unrecognized + * profile classes with a warning, these then hit the test below on the + * tag content to ensure they are backward compatible with one of the + * understood profiles. + */ + (void)png_icc_profile_error(png_ptr, NULL, name, temp, + "unrecognized ICC profile class"); + break; + } + + /* For any profile other than a device link one the PCS must be encoded + * either in XYZ or Lab. + */ + temp = png_get_uint_32(profile+20); + switch (temp) + { + case 0x58595a20: /* 'XYZ ' */ + case 0x4c616220: /* 'Lab ' */ + break; + + default: + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "unexpected ICC PCS encoding"); + } + + return 1; +} + +int /* PRIVATE */ +png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length, + png_const_bytep profile /* header plus whole tag table */) +{ + png_uint_32 tag_count = png_get_uint_32(profile+128); + png_uint_32 itag; + png_const_bytep tag = profile+132; /* The first tag */ + + /* First scan all the tags in the table and add bits to the icc_info value + * (temporarily in 'tags'). + */ + for (itag=0; itag < tag_count; ++itag, tag += 12) + { + png_uint_32 tag_id = png_get_uint_32(tag+0); + png_uint_32 tag_start = png_get_uint_32(tag+4); /* must be aligned */ + png_uint_32 tag_length = png_get_uint_32(tag+8);/* not padded */ + + /* The ICC specification does not exclude zero length tags, therefore the + * start might actually be anywhere if there is no data, but this would be + * a clear abuse of the intent of the standard so the start is checked for + * being in range. All defined tag types have an 8 byte header - a 4 byte + * type signature then 0. + */ + + /* This is a hard error; potentially it can cause read outside the + * profile. + */ + if (tag_start > profile_length || tag_length > profile_length - tag_start) + return png_icc_profile_error(png_ptr, colorspace, name, tag_id, + "ICC profile tag outside profile"); + + if ((tag_start & 3) != 0) + { + /* CNHP730S.icc shipped with Microsoft Windows 64 violates this; it is + * only a warning here because libpng does not care about the + * alignment. + */ + (void)png_icc_profile_error(png_ptr, NULL, name, tag_id, + "ICC profile tag start not a multiple of 4"); + } + } + + return 1; /* success, maybe with warnings */ +} + +#ifdef PNG_sRGB_SUPPORTED +#if PNG_sRGB_PROFILE_CHECKS >= 0 +/* Information about the known ICC sRGB profiles */ +static const struct +{ + png_uint_32 adler, crc, length; + png_uint_32 md5[4]; + png_byte have_md5; + png_byte is_broken; + png_uint_16 intent; + +# define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0) +# define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\ + { adler, crc, length, md5, broke, intent }, + +} png_sRGB_checks[] = +{ + /* This data comes from contrib/tools/checksum-icc run on downloads of + * all four ICC sRGB profiles from www.color.org. + */ + /* adler32, crc32, MD5[4], intent, date, length, file-name */ + PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9, + PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0, + "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc") + + /* ICC sRGB v2 perceptual no black-compensation: */ + PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21, + PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0, + "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc") + + PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae, + PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0, + "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc") + + /* ICC sRGB v4 perceptual */ + PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812, + PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0, + "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc") + + /* The following profiles have no known MD5 checksum. If there is a match + * on the (empty) MD5 the other fields are used to attempt a match and + * a warning is produced. The first two of these profiles have a 'cprt' tag + * which suggests that they were also made by Hewlett Packard. + */ + PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce, + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0, + "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc") + + /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not + * match the D50 PCS illuminant in the header (it is in fact the D65 values, + * so the white point is recorded as the un-adapted value.) The profiles + * below only differ in one byte - the intent - and are basically the same as + * the previous profile except for the mediaWhitePointTag error and a missing + * chromaticAdaptationTag. + */ + PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552, + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, + "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") + + PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d, + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, + "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") +}; + +static int +png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, + png_const_bytep profile, uLong adler) +{ + /* The quick check is to verify just the MD5 signature and trust the + * rest of the data. Because the profile has already been verified for + * correctness this is safe. png_colorspace_set_sRGB will check the 'intent' + * field too, so if the profile has been edited with an intent not defined + * by sRGB (but maybe defined by a later ICC specification) the read of + * the profile will fail at that point. + */ + + png_uint_32 length = 0; + png_uint_32 intent = 0x10000; /* invalid */ +#if PNG_sRGB_PROFILE_CHECKS > 1 + uLong crc = 0; /* the value for 0 length data */ +#endif + unsigned int i; + +#ifdef PNG_SET_OPTION_SUPPORTED + /* First see if PNG_SKIP_sRGB_CHECK_PROFILE has been set to "on" */ + if (((png_ptr->options >> PNG_SKIP_sRGB_CHECK_PROFILE) & 3) == + PNG_OPTION_ON) + return 0; +#endif + + for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i) + { + if (png_get_uint_32(profile+84) == png_sRGB_checks[i].md5[0] && + png_get_uint_32(profile+88) == png_sRGB_checks[i].md5[1] && + png_get_uint_32(profile+92) == png_sRGB_checks[i].md5[2] && + png_get_uint_32(profile+96) == png_sRGB_checks[i].md5[3]) + { + /* This may be one of the old HP profiles without an MD5, in that + * case we can only use the length and Adler32 (note that these + * are not used by default if there is an MD5!) + */ +# if PNG_sRGB_PROFILE_CHECKS == 0 + if (png_sRGB_checks[i].have_md5 != 0) + return 1+png_sRGB_checks[i].is_broken; +# endif + + /* Profile is unsigned or more checks have been configured in. */ + if (length == 0) + { + length = png_get_uint_32(profile); + intent = png_get_uint_32(profile+64); + } + + /* Length *and* intent must match */ + if (length == (png_uint_32) png_sRGB_checks[i].length && + intent == (png_uint_32) png_sRGB_checks[i].intent) + { + /* Now calculate the adler32 if not done already. */ + if (adler == 0) + { + adler = adler32(0, NULL, 0); + adler = adler32(adler, profile, length); + } + + if (adler == png_sRGB_checks[i].adler) + { + /* These basic checks suggest that the data has not been + * modified, but if the check level is more than 1 perform + * our own crc32 checksum on the data. + */ +# if PNG_sRGB_PROFILE_CHECKS > 1 + if (crc == 0) + { + crc = crc32(0, NULL, 0); + crc = crc32(crc, profile, length); + } + + /* So this check must pass for the 'return' below to happen. + */ + if (crc == png_sRGB_checks[i].crc) +# endif + { + if (png_sRGB_checks[i].is_broken != 0) + { + /* These profiles are known to have bad data that may cause + * problems if they are used, therefore attempt to + * discourage their use, skip the 'have_md5' warning below, + * which is made irrelevant by this error. + */ + png_chunk_report(png_ptr, "known incorrect sRGB profile", + PNG_CHUNK_ERROR); + } + + /* Warn that this being done; this isn't even an error since + * the profile is perfectly valid, but it would be nice if + * people used the up-to-date ones. + */ + else if (png_sRGB_checks[i].have_md5 == 0) + { + png_chunk_report(png_ptr, + "out-of-date sRGB profile with no signature", + PNG_CHUNK_WARNING); + } + + return 1+png_sRGB_checks[i].is_broken; + } + } + +# if PNG_sRGB_PROFILE_CHECKS > 0 + /* The signature matched, but the profile had been changed in some + * way. This probably indicates a data error or uninformed hacking. + * Fall through to "no match". + */ + png_chunk_report(png_ptr, + "Not recognizing known sRGB profile that has been edited", + PNG_CHUNK_WARNING); + break; +# endif + } + } + } + + return 0; /* no match */ +} + +void /* PRIVATE */ +png_icc_set_sRGB(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_bytep profile, uLong adler) +{ + /* Is this profile one of the known ICC sRGB profiles? If it is, just set + * the sRGB information. + */ + if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0) + (void)png_colorspace_set_sRGB(png_ptr, colorspace, + (int)/*already checked*/png_get_uint_32(profile+64)); +} +#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */ +#endif /* sRGB */ + +int /* PRIVATE */ +png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, + int color_type) +{ + if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) + return 0; + + if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 && + png_icc_check_header(png_ptr, colorspace, name, profile_length, profile, + color_type) != 0 && + png_icc_check_tag_table(png_ptr, colorspace, name, profile_length, + profile) != 0) + { +# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 + /* If no sRGB support, don't try storing sRGB information */ + png_icc_set_sRGB(png_ptr, colorspace, profile, 0); +# endif + return 1; + } + + /* Failure case */ + return 0; +} +#endif /* iCCP */ + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +void /* PRIVATE */ +png_colorspace_set_rgb_coefficients(png_structrp png_ptr) +{ + /* Set the rgb_to_gray coefficients from the colorspace. */ + if (png_ptr->rgb_to_gray_coefficients_set == 0 && + (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + { + /* png_set_background has not been called, get the coefficients from the Y + * values of the colorspace colorants. + */ + png_fixed_point r = png_ptr->colorspace.end_points_XYZ.red_Y; + png_fixed_point g = png_ptr->colorspace.end_points_XYZ.green_Y; + png_fixed_point b = png_ptr->colorspace.end_points_XYZ.blue_Y; + png_fixed_point total = r+g+b; + + if (total > 0 && + r >= 0 && png_muldiv(&r, r, 32768, total) && r >= 0 && r <= 32768 && + g >= 0 && png_muldiv(&g, g, 32768, total) && g >= 0 && g <= 32768 && + b >= 0 && png_muldiv(&b, b, 32768, total) && b >= 0 && b <= 32768 && + r+g+b <= 32769) + { + /* We allow 0 coefficients here. r+g+b may be 32769 if two or + * all of the coefficients were rounded up. Handle this by + * reducing the *largest* coefficient by 1; this matches the + * approach used for the default coefficients in pngrtran.c + */ + int add = 0; + + if (r+g+b > 32768) + add = -1; + else if (r+g+b < 32768) + add = 1; + + if (add != 0) + { + if (g >= r && g >= b) + g += add; + else if (r >= g && r >= b) + r += add; + else + b += add; + } + + /* Check for an internal error. */ + if (r+g+b != 32768) + png_error(png_ptr, + "internal error handling cHRM coefficients"); + + else + { + png_ptr->rgb_to_gray_red_coeff = (png_uint_16)r; + png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g; + } + } + + /* This is a png_error at present even though it could be ignored - + * it should never happen, but it is important that if it does, the + * bug is fixed. + */ + else + png_error(png_ptr, "internal error handling cHRM->XYZ"); + } +} +#endif /* READ_RGB_TO_GRAY */ + +#endif /* COLORSPACE */ + +#ifdef __GNUC__ +/* This exists solely to work round a warning from GNU C. */ +static int /* PRIVATE */ +png_gt(size_t a, size_t b) +{ + return a > b; +} +#else +# define png_gt(a,b) ((a) > (b)) +#endif + +void /* PRIVATE */ +png_check_IHDR(png_const_structrp png_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) +{ + int error = 0; + + /* Check for width and height valid values */ + if (width == 0) + { + png_warning(png_ptr, "Image width is zero in IHDR"); + error = 1; + } + + if (width > PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Invalid image width in IHDR"); + error = 1; + } + + if (png_gt(((width + 7) & (~7U)), + ((PNG_SIZE_MAX + - 48 /* big_row_buf hack */ + - 1) /* filter byte */ + / 8) /* 8-byte RGBA pixels */ + - 1)) /* extra max_pixel_depth pad */ + { + /* The size of the row must be within the limits of this architecture. + * Because the read code can perform arbitrary transformations the + * maximum size is checked here. Because the code in png_read_start_row + * adds extra space "for safety's sake" in several places a conservative + * limit is used here. + * + * NOTE: it would be far better to check the size that is actually used, + * but the effect in the real world is minor and the changes are more + * extensive, therefore much more dangerous and much more difficult to + * write in a way that avoids compiler warnings. + */ + png_warning(png_ptr, "Image width is too large for this architecture"); + error = 1; + } + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (width > png_ptr->user_width_max) +#else + if (width > PNG_USER_WIDTH_MAX) +#endif + { + png_warning(png_ptr, "Image width exceeds user limit in IHDR"); + error = 1; + } + + if (height == 0) + { + png_warning(png_ptr, "Image height is zero in IHDR"); + error = 1; + } + + if (height > PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Invalid image height in IHDR"); + error = 1; + } + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (height > png_ptr->user_height_max) +#else + if (height > PNG_USER_HEIGHT_MAX) +#endif + { + png_warning(png_ptr, "Image height exceeds user limit in IHDR"); + error = 1; + } + + /* Check other values */ + if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && + bit_depth != 8 && bit_depth != 16) + { + png_warning(png_ptr, "Invalid bit depth in IHDR"); + error = 1; + } + + if (color_type < 0 || color_type == 1 || + color_type == 5 || color_type > 6) + { + png_warning(png_ptr, "Invalid color type in IHDR"); + error = 1; + } + + if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || + ((color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) + { + png_warning(png_ptr, "Invalid color type/bit depth combination in IHDR"); + error = 1; + } + + if (interlace_type >= PNG_INTERLACE_LAST) + { + png_warning(png_ptr, "Unknown interlace method in IHDR"); + error = 1; + } + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + { + png_warning(png_ptr, "Unknown compression method in IHDR"); + error = 1; + } + +#ifdef PNG_MNG_FEATURES_SUPPORTED + /* Accept filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not read a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && + png_ptr->mng_features_permitted != 0) + png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); + + if (filter_type != PNG_FILTER_TYPE_BASE) + { + if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && + ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA))) + { + png_warning(png_ptr, "Unknown filter method in IHDR"); + error = 1; + } + + if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0) + { + png_warning(png_ptr, "Invalid filter method in IHDR"); + error = 1; + } + } + +#else + if (filter_type != PNG_FILTER_TYPE_BASE) + { + png_warning(png_ptr, "Unknown filter method in IHDR"); + error = 1; + } +#endif + + if (error == 1) + png_error(png_ptr, "Invalid IHDR data"); +} + +#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) +/* ASCII to fp functions */ +/* Check an ASCII formated floating point value, see the more detailed + * comments in pngpriv.h + */ +/* The following is used internally to preserve the sticky flags */ +#define png_fp_add(state, flags) ((state) |= (flags)) +#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY)) + +int /* PRIVATE */ +png_check_fp_number(png_const_charp string, png_size_t size, int *statep, + png_size_tp whereami) +{ + int state = *statep; + png_size_t i = *whereami; + + while (i < size) + { + int type; + /* First find the type of the next character */ + switch (string[i]) + { + case 43: type = PNG_FP_SAW_SIGN; break; + case 45: type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break; + case 46: type = PNG_FP_SAW_DOT; break; + case 48: type = PNG_FP_SAW_DIGIT; break; + case 49: case 50: case 51: case 52: + case 53: case 54: case 55: case 56: + case 57: type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break; + case 69: + case 101: type = PNG_FP_SAW_E; break; + default: goto PNG_FP_End; + } + + /* Now deal with this type according to the current + * state, the type is arranged to not overlap the + * bits of the PNG_FP_STATE. + */ + switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY)) + { + case PNG_FP_INTEGER + PNG_FP_SAW_SIGN: + if ((state & PNG_FP_SAW_ANY) != 0) + goto PNG_FP_End; /* not a part of the number */ + + png_fp_add(state, type); + break; + + case PNG_FP_INTEGER + PNG_FP_SAW_DOT: + /* Ok as trailer, ok as lead of fraction. */ + if ((state & PNG_FP_SAW_DOT) != 0) /* two dots */ + goto PNG_FP_End; + + else if ((state & PNG_FP_SAW_DIGIT) != 0) /* trailing dot? */ + png_fp_add(state, type); + + else + png_fp_set(state, PNG_FP_FRACTION | type); + + break; + + case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT: + if ((state & PNG_FP_SAW_DOT) != 0) /* delayed fraction */ + png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT); + + png_fp_add(state, type | PNG_FP_WAS_VALID); + + break; + + case PNG_FP_INTEGER + PNG_FP_SAW_E: + if ((state & PNG_FP_SAW_DIGIT) == 0) + goto PNG_FP_End; + + png_fp_set(state, PNG_FP_EXPONENT); + + break; + + /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN: + goto PNG_FP_End; ** no sign in fraction */ + + /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT: + goto PNG_FP_End; ** Because SAW_DOT is always set */ + + case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT: + png_fp_add(state, type | PNG_FP_WAS_VALID); + break; + + case PNG_FP_FRACTION + PNG_FP_SAW_E: + /* This is correct because the trailing '.' on an + * integer is handled above - so we can only get here + * with the sequence ".E" (with no preceding digits). + */ + if ((state & PNG_FP_SAW_DIGIT) == 0) + goto PNG_FP_End; + + png_fp_set(state, PNG_FP_EXPONENT); + + break; + + case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN: + if ((state & PNG_FP_SAW_ANY) != 0) + goto PNG_FP_End; /* not a part of the number */ + + png_fp_add(state, PNG_FP_SAW_SIGN); + + break; + + /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT: + goto PNG_FP_End; */ + + case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT: + png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID); + + break; + + /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E: + goto PNG_FP_End; */ + + default: goto PNG_FP_End; /* I.e. break 2 */ + } + + /* The character seems ok, continue. */ + ++i; + } + +PNG_FP_End: + /* Here at the end, update the state and return the correct + * return code. + */ + *statep = state; + *whereami = i; + + return (state & PNG_FP_SAW_DIGIT) != 0; +} + + +/* The same but for a complete string. */ +int +png_check_fp_string(png_const_charp string, png_size_t size) +{ + int state=0; + png_size_t char_index=0; + + if (png_check_fp_number(string, size, &state, &char_index) != 0 && + (char_index == size || string[char_index] == 0)) + return state /* must be non-zero - see above */; + + return 0; /* i.e. fail */ +} +#endif /* pCAL || sCAL */ + +#ifdef PNG_sCAL_SUPPORTED +# ifdef PNG_FLOATING_POINT_SUPPORTED +/* Utility used below - a simple accurate power of ten from an integral + * exponent. + */ +static double +png_pow10(int power) +{ + int recip = 0; + double d = 1; + + /* Handle negative exponent with a reciprocal at the end because + * 10 is exact whereas .1 is inexact in base 2 + */ + if (power < 0) + { + if (power < DBL_MIN_10_EXP) return 0; + recip = 1; power = -power; + } + + if (power > 0) + { + /* Decompose power bitwise. */ + double mult = 10; + do + { + if (power & 1) d *= mult; + mult *= mult; + power >>= 1; + } + while (power > 0); + + if (recip != 0) d = 1/d; + } + /* else power is 0 and d is 1 */ + + return d; +} + +/* Function to format a floating point value in ASCII with a given + * precision. + */ +#if GCC_STRICT_OVERFLOW +#pragma GCC diagnostic push +/* The problem arises below with exp_b10, which can never overflow because it + * comes, originally, from frexp and is therefore limited to a range which is + * typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)). + */ +#pragma GCC diagnostic warning "-Wstrict-overflow=2" +#endif /* GCC_STRICT_OVERFLOW */ +void /* PRIVATE */ +png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, + double fp, unsigned int precision) +{ + /* We use standard functions from math.h, but not printf because + * that would require stdio. The caller must supply a buffer of + * sufficient size or we will png_error. The tests on size and + * the space in ascii[] consumed are indicated below. + */ + if (precision < 1) + precision = DBL_DIG; + + /* Enforce the limit of the implementation precision too. */ + if (precision > DBL_DIG+1) + precision = DBL_DIG+1; + + /* Basic sanity checks */ + if (size >= precision+5) /* See the requirements below. */ + { + if (fp < 0) + { + fp = -fp; + *ascii++ = 45; /* '-' PLUS 1 TOTAL 1 */ + --size; + } + + if (fp >= DBL_MIN && fp <= DBL_MAX) + { + int exp_b10; /* A base 10 exponent */ + double base; /* 10^exp_b10 */ + + /* First extract a base 10 exponent of the number, + * the calculation below rounds down when converting + * from base 2 to base 10 (multiply by log10(2) - + * 0.3010, but 77/256 is 0.3008, so exp_b10 needs to + * be increased. Note that the arithmetic shift + * performs a floor() unlike C arithmetic - using a + * C multiply would break the following for negative + * exponents. + */ + (void)frexp(fp, &exp_b10); /* exponent to base 2 */ + + exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */ + + /* Avoid underflow here. */ + base = png_pow10(exp_b10); /* May underflow */ + + while (base < DBL_MIN || base < fp) + { + /* And this may overflow. */ + double test = png_pow10(exp_b10+1); + + if (test <= DBL_MAX) + { + ++exp_b10; base = test; + } + + else + break; + } + + /* Normalize fp and correct exp_b10, after this fp is in the + * range [.1,1) and exp_b10 is both the exponent and the digit + * *before* which the decimal point should be inserted + * (starting with 0 for the first digit). Note that this + * works even if 10^exp_b10 is out of range because of the + * test on DBL_MAX above. + */ + fp /= base; + while (fp >= 1) + { + fp /= 10; ++exp_b10; + } + + /* Because of the code above fp may, at this point, be + * less than .1, this is ok because the code below can + * handle the leading zeros this generates, so no attempt + * is made to correct that here. + */ + + { + unsigned int czero, clead, cdigits; + char exponent[10]; + + /* Allow up to two leading zeros - this will not lengthen + * the number compared to using E-n. + */ + if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */ + { + czero = 0U-exp_b10; /* PLUS 2 digits: TOTAL 3 */ + exp_b10 = 0; /* Dot added below before first output. */ + } + else + czero = 0; /* No zeros to add */ + + /* Generate the digit list, stripping trailing zeros and + * inserting a '.' before a digit if the exponent is 0. + */ + clead = czero; /* Count of leading zeros */ + cdigits = 0; /* Count of digits in list. */ + + do + { + double d; + + fp *= 10; + /* Use modf here, not floor and subtract, so that + * the separation is done in one step. At the end + * of the loop don't break the number into parts so + * that the final digit is rounded. + */ + if (cdigits+czero+1 < precision+clead) + fp = modf(fp, &d); + + else + { + d = floor(fp + .5); + + if (d > 9) + { + /* Rounding up to 10, handle that here. */ + if (czero > 0) + { + --czero; d = 1; + if (cdigits == 0) --clead; + } + else + { + while (cdigits > 0 && d > 9) + { + int ch = *--ascii; + + if (exp_b10 != (-1)) + ++exp_b10; + + else if (ch == 46) + { + ch = *--ascii; ++size; + /* Advance exp_b10 to '1', so that the + * decimal point happens after the + * previous digit. + */ + exp_b10 = 1; + } + + --cdigits; + d = ch - 47; /* I.e. 1+(ch-48) */ + } + + /* Did we reach the beginning? If so adjust the + * exponent but take into account the leading + * decimal point. + */ + if (d > 9) /* cdigits == 0 */ + { + if (exp_b10 == (-1)) + { + /* Leading decimal point (plus zeros?), if + * we lose the decimal point here it must + * be reentered below. + */ + int ch = *--ascii; + + if (ch == 46) + { + ++size; exp_b10 = 1; + } + + /* Else lost a leading zero, so 'exp_b10' is + * still ok at (-1) + */ + } + else + ++exp_b10; + + /* In all cases we output a '1' */ + d = 1; + } + } + } + fp = 0; /* Guarantees termination below. */ + } + + if (d == 0) + { + ++czero; + if (cdigits == 0) ++clead; + } + else + { + /* Included embedded zeros in the digit count. */ + cdigits += czero - clead; + clead = 0; + + while (czero > 0) + { + /* exp_b10 == (-1) means we just output the decimal + * place - after the DP don't adjust 'exp_b10' any + * more! + */ + if (exp_b10 != (-1)) + { + if (exp_b10 == 0) + { + *ascii++ = 46; --size; + } + /* PLUS 1: TOTAL 4 */ + --exp_b10; + } + *ascii++ = 48; --czero; + } + + if (exp_b10 != (-1)) + { + if (exp_b10 == 0) + { + *ascii++ = 46; --size; /* counted above */ + } + + --exp_b10; + } + *ascii++ = (char)(48 + (int)d); ++cdigits; + } + } + while (cdigits+czero < precision+clead && fp > DBL_MIN); + + /* The total output count (max) is now 4+precision */ + + /* Check for an exponent, if we don't need one we are + * done and just need to terminate the string. At + * this point exp_b10==(-1) is effectively a flag - it got + * to '-1' because of the decrement after outputting + * the decimal point above (the exponent required is + * *not* -1!) + */ + if (exp_b10 >= (-1) && exp_b10 <= 2) + { + /* The following only happens if we didn't output the + * leading zeros above for negative exponent, so this + * doesn't add to the digit requirement. Note that the + * two zeros here can only be output if the two leading + * zeros were *not* output, so this doesn't increase + * the output count. + */ + while (exp_b10-- > 0) *ascii++ = 48; + + *ascii = 0; + + /* Total buffer requirement (including the '\0') is + * 5+precision - see check at the start. + */ + return; + } + + /* Here if an exponent is required, adjust size for + * the digits we output but did not count. The total + * digit output here so far is at most 1+precision - no + * decimal point and no leading or trailing zeros have + * been output. + */ + size -= cdigits; + + *ascii++ = 69; --size; /* 'E': PLUS 1 TOTAL 2+precision */ + + /* The following use of an unsigned temporary avoids ambiguities in + * the signed arithmetic on exp_b10 and permits GCC at least to do + * better optimization. + */ + { + unsigned int uexp_b10; + + if (exp_b10 < 0) + { + *ascii++ = 45; --size; /* '-': PLUS 1 TOTAL 3+precision */ + uexp_b10 = 0U-exp_b10; + } + + else + uexp_b10 = 0U+exp_b10; + + cdigits = 0; + + while (uexp_b10 > 0) + { + exponent[cdigits++] = (char)(48 + uexp_b10 % 10); + uexp_b10 /= 10; + } + } + + /* Need another size check here for the exponent digits, so + * this need not be considered above. + */ + if (size > cdigits) + { + while (cdigits > 0) *ascii++ = exponent[--cdigits]; + + *ascii = 0; + + return; + } + } + } + else if (!(fp >= DBL_MIN)) + { + *ascii++ = 48; /* '0' */ + *ascii = 0; + return; + } + else + { + *ascii++ = 105; /* 'i' */ + *ascii++ = 110; /* 'n' */ + *ascii++ = 102; /* 'f' */ + *ascii = 0; + return; + } + } + + /* Here on buffer too small. */ + png_error(png_ptr, "ASCII conversion buffer too small"); +} +#if GCC_STRICT_OVERFLOW +#pragma GCC diagnostic pop +#endif /* GCC_STRICT_OVERFLOW */ + +# endif /* FLOATING_POINT */ + +# ifdef PNG_FIXED_POINT_SUPPORTED +/* Function to format a fixed point value in ASCII. + */ +void /* PRIVATE */ +png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii, + png_size_t size, png_fixed_point fp) +{ + /* Require space for 10 decimal digits, a decimal point, a minus sign and a + * trailing \0, 13 characters: + */ + if (size > 12) + { + png_uint_32 num; + + /* Avoid overflow here on the minimum integer. */ + if (fp < 0) + { + *ascii++ = 45; num = (png_uint_32)(-fp); + } + else + num = (png_uint_32)fp; + + if (num <= 0x80000000) /* else overflowed */ + { + unsigned int ndigits = 0, first = 16 /* flag value */; + char digits[10]; + + while (num) + { + /* Split the low digit off num: */ + unsigned int tmp = num/10; + num -= tmp*10; + digits[ndigits++] = (char)(48 + num); + /* Record the first non-zero digit, note that this is a number + * starting at 1, it's not actually the array index. + */ + if (first == 16 && num > 0) + first = ndigits; + num = tmp; + } + + if (ndigits > 0) + { + while (ndigits > 5) *ascii++ = digits[--ndigits]; + /* The remaining digits are fractional digits, ndigits is '5' or + * smaller at this point. It is certainly not zero. Check for a + * non-zero fractional digit: + */ + if (first <= 5) + { + unsigned int i; + *ascii++ = 46; /* decimal point */ + /* ndigits may be <5 for small numbers, output leading zeros + * then ndigits digits to first: + */ + i = 5; + while (ndigits < i) + { + *ascii++ = 48; --i; + } + while (ndigits >= first) *ascii++ = digits[--ndigits]; + /* Don't output the trailing zeros! */ + } + } + else + *ascii++ = 48; + + /* And null terminate the string: */ + *ascii = 0; + return; + } + } + + /* Here on buffer too small. */ + png_error(png_ptr, "ASCII conversion buffer too small"); +} +# endif /* FIXED_POINT */ +#endif /* SCAL */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ + !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ + (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ + defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ + (defined(PNG_sCAL_SUPPORTED) && \ + defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) +png_fixed_point +png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text) +{ + double r = floor(100000 * fp + .5); + + if (r > 2147483647. || r < -2147483648.) + png_fixed_error(png_ptr, text); + +# ifndef PNG_ERROR_TEXT_SUPPORTED + PNG_UNUSED(text) +# endif + + return (png_fixed_point)r; +} +#endif + +#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\ + defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) +/* muldiv functions */ +/* This API takes signed arguments and rounds the result to the nearest + * integer (or, for a fixed point number - the standard argument - to + * the nearest .00001). Overflow and divide by zero are signalled in + * the result, a boolean - true on success, false on overflow. + */ +#if GCC_STRICT_OVERFLOW /* from above */ +/* It is not obvious which comparison below gets optimized in such a way that + * signed overflow would change the result; looking through the code does not + * reveal any tests which have the form GCC complains about, so presumably the + * optimizer is moving an add or subtract into the 'if' somewhere. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wstrict-overflow=2" +#endif /* GCC_STRICT_OVERFLOW */ +int +png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, + png_int_32 divisor) +{ + /* Return a * times / divisor, rounded. */ + if (divisor != 0) + { + if (a == 0 || times == 0) + { + *res = 0; + return 1; + } + else + { +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = a; + r *= times; + r /= divisor; + r = floor(r+.5); + + /* A png_fixed_point is a 32-bit integer. */ + if (r <= 2147483647. && r >= -2147483648.) + { + *res = (png_fixed_point)r; + return 1; + } +#else + int negative = 0; + png_uint_32 A, T, D; + png_uint_32 s16, s32, s00; + + if (a < 0) + negative = 1, A = -a; + else + A = a; + + if (times < 0) + negative = !negative, T = -times; + else + T = times; + + if (divisor < 0) + negative = !negative, D = -divisor; + else + D = divisor; + + /* Following can't overflow because the arguments only + * have 31 bits each, however the result may be 32 bits. + */ + s16 = (A >> 16) * (T & 0xffff) + + (A & 0xffff) * (T >> 16); + /* Can't overflow because the a*times bit is only 30 + * bits at most. + */ + s32 = (A >> 16) * (T >> 16) + (s16 >> 16); + s00 = (A & 0xffff) * (T & 0xffff); + + s16 = (s16 & 0xffff) << 16; + s00 += s16; + + if (s00 < s16) + ++s32; /* carry */ + + if (s32 < D) /* else overflow */ + { + /* s32.s00 is now the 64-bit product, do a standard + * division, we know that s32 < D, so the maximum + * required shift is 31. + */ + int bitshift = 32; + png_fixed_point result = 0; /* NOTE: signed */ + + while (--bitshift >= 0) + { + png_uint_32 d32, d00; + + if (bitshift > 0) + d32 = D >> (32-bitshift), d00 = D << bitshift; + + else + d32 = 0, d00 = D; + + if (s32 > d32) + { + if (s00 < d00) --s32; /* carry */ + s32 -= d32, s00 -= d00, result += 1<= d00) + s32 = 0, s00 -= d00, result += 1<= (D >> 1)) + ++result; + + if (negative != 0) + result = -result; + + /* Check for overflow. */ + if ((negative != 0 && result <= 0) || + (negative == 0 && result >= 0)) + { + *res = result; + return 1; + } + } +#endif + } + } + + return 0; +} +#if GCC_STRICT_OVERFLOW +#pragma GCC diagnostic pop +#endif /* GCC_STRICT_OVERFLOW */ +#endif /* READ_GAMMA || INCH_CONVERSIONS */ + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) +/* The following is for when the caller doesn't much care about the + * result. + */ +png_fixed_point +png_muldiv_warn(png_const_structrp png_ptr, png_fixed_point a, png_int_32 times, + png_int_32 divisor) +{ + png_fixed_point result; + + if (png_muldiv(&result, a, times, divisor) != 0) + return result; + + png_warning(png_ptr, "fixed point overflow ignored"); + return 0; +} +#endif + +#ifdef PNG_GAMMA_SUPPORTED /* more fixed point functions for gamma */ +/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */ +png_fixed_point +png_reciprocal(png_fixed_point a) +{ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = floor(1E10/a+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; +#else + png_fixed_point res; + + if (png_muldiv(&res, 100000, 100000, a) != 0) + return res; +#endif + + return 0; /* error/overflow */ +} + +/* This is the shared test on whether a gamma value is 'significant' - whether + * it is worth doing gamma correction. + */ +int /* PRIVATE */ +png_gamma_significant(png_fixed_point gamma_val) +{ + return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED || + gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED; +} +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED +#ifdef PNG_16BIT_SUPPORTED +/* A local convenience routine. */ +static png_fixed_point +png_product2(png_fixed_point a, png_fixed_point b) +{ + /* The required result is 1/a * 1/b; the following preserves accuracy. */ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = a * 1E-5; + r *= b; + r = floor(r+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; +#else + png_fixed_point res; + + if (png_muldiv(&res, a, b, 100000) != 0) + return res; +#endif + + return 0; /* overflow */ +} +#endif /* 16BIT */ + +/* The inverse of the above. */ +png_fixed_point +png_reciprocal2(png_fixed_point a, png_fixed_point b) +{ + /* The required result is 1/a * 1/b; the following preserves accuracy. */ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + if (a != 0 && b != 0) + { + double r = 1E15/a; + r /= b; + r = floor(r+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; + } +#else + /* This may overflow because the range of png_fixed_point isn't symmetric, + * but this API is only used for the product of file and screen gamma so it + * doesn't matter that the smallest number it can produce is 1/21474, not + * 1/100000 + */ + png_fixed_point res = png_product2(a, b); + + if (res != 0) + return png_reciprocal(res); +#endif + + return 0; /* overflow */ +} +#endif /* READ_GAMMA */ + +#ifdef PNG_READ_GAMMA_SUPPORTED /* gamma table code */ +#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED +/* Fixed point gamma. + * + * The code to calculate the tables used below can be found in the shell script + * contrib/tools/intgamma.sh + * + * To calculate gamma this code implements fast log() and exp() calls using only + * fixed point arithmetic. This code has sufficient precision for either 8-bit + * or 16-bit sample values. + * + * The tables used here were calculated using simple 'bc' programs, but C double + * precision floating point arithmetic would work fine. + * + * 8-bit log table + * This is a table of -log(value/255)/log(2) for 'value' in the range 128 to + * 255, so it's the base 2 logarithm of a normalized 8-bit floating point + * mantissa. The numbers are 32-bit fractions. + */ +static const png_uint_32 +png_8bit_l2[128] = +{ + 4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U, + 3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U, + 3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U, + 3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U, + 3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U, + 2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U, + 2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U, + 2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U, + 2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U, + 2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U, + 1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U, + 1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U, + 1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U, + 1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U, + 1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U, + 971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U, + 803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U, + 639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U, + 479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U, + 324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U, + 172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U, + 24347096U, 0U + +#if 0 + /* The following are the values for 16-bit tables - these work fine for the + * 8-bit conversions but produce very slightly larger errors in the 16-bit + * log (about 1.2 as opposed to 0.7 absolute error in the final value). To + * use these all the shifts below must be adjusted appropriately. + */ + 65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054, + 57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803, + 50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068, + 43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782, + 37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887, + 31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339, + 25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098, + 20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132, + 15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415, + 10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523, + 6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495, + 1119, 744, 372 +#endif +}; + +static png_int_32 +png_log8bit(unsigned int x) +{ + unsigned int lg2 = 0; + /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log, + * because the log is actually negate that means adding 1. The final + * returned value thus has the range 0 (for 255 input) to 7.994 (for 1 + * input), return -1 for the overflow (log 0) case, - so the result is + * always at most 19 bits. + */ + if ((x &= 0xff) == 0) + return -1; + + if ((x & 0xf0) == 0) + lg2 = 4, x <<= 4; + + if ((x & 0xc0) == 0) + lg2 += 2, x <<= 2; + + if ((x & 0x80) == 0) + lg2 += 1, x <<= 1; + + /* result is at most 19 bits, so this cast is safe: */ + return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16)); +} + +/* The above gives exact (to 16 binary places) log2 values for 8-bit images, + * for 16-bit images we use the most significant 8 bits of the 16-bit value to + * get an approximation then multiply the approximation by a correction factor + * determined by the remaining up to 8 bits. This requires an additional step + * in the 16-bit case. + * + * We want log2(value/65535), we have log2(v'/255), where: + * + * value = v' * 256 + v'' + * = v' * f + * + * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128 + * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less + * than 258. The final factor also needs to correct for the fact that our 8-bit + * value is scaled by 255, whereas the 16-bit values must be scaled by 65535. + * + * This gives a final formula using a calculated value 'x' which is value/v' and + * scaling by 65536 to match the above table: + * + * log2(x/257) * 65536 + * + * Since these numbers are so close to '1' we can use simple linear + * interpolation between the two end values 256/257 (result -368.61) and 258/257 + * (result 367.179). The values used below are scaled by a further 64 to give + * 16-bit precision in the interpolation: + * + * Start (256): -23591 + * Zero (257): 0 + * End (258): 23499 + */ +#ifdef PNG_16BIT_SUPPORTED +static png_int_32 +png_log16bit(png_uint_32 x) +{ + unsigned int lg2 = 0; + + /* As above, but now the input has 16 bits. */ + if ((x &= 0xffff) == 0) + return -1; + + if ((x & 0xff00) == 0) + lg2 = 8, x <<= 8; + + if ((x & 0xf000) == 0) + lg2 += 4, x <<= 4; + + if ((x & 0xc000) == 0) + lg2 += 2, x <<= 2; + + if ((x & 0x8000) == 0) + lg2 += 1, x <<= 1; + + /* Calculate the base logarithm from the top 8 bits as a 28-bit fractional + * value. + */ + lg2 <<= 28; + lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4; + + /* Now we need to interpolate the factor, this requires a division by the top + * 8 bits. Do this with maximum precision. + */ + x = ((x << 16) + (x >> 9)) / (x >> 8); + + /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24, + * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly + * 16 bits to interpolate to get the low bits of the result. Round the + * answer. Note that the end point values are scaled by 64 to retain overall + * precision and that 'lg2' is current scaled by an extra 12 bits, so adjust + * the overall scaling by 6-12. Round at every step. + */ + x -= 1U << 24; + + if (x <= 65536U) /* <= '257' */ + lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12); + + else + lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12); + + /* Safe, because the result can't have more than 20 bits: */ + return (png_int_32)((lg2 + 2048) >> 12); +} +#endif /* 16BIT */ + +/* The 'exp()' case must invert the above, taking a 20-bit fixed point + * logarithmic value and returning a 16 or 8-bit number as appropriate. In + * each case only the low 16 bits are relevant - the fraction - since the + * integer bits (the top 4) simply determine a shift. + * + * The worst case is the 16-bit distinction between 65535 and 65534. This + * requires perhaps spurious accuracy in the decoding of the logarithm to + * distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance + * of getting this accuracy in practice. + * + * To deal with this the following exp() function works out the exponent of the + * fractional part of the logarithm by using an accurate 32-bit value from the + * top four fractional bits then multiplying in the remaining bits. + */ +static const png_uint_32 +png_32bit_exp[16] = +{ + /* NOTE: the first entry is deliberately set to the maximum 32-bit value. */ + 4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U, + 3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U, + 2553802834U, 2445529972U, 2341847524U, 2242560872U +}; + +/* Adjustment table; provided to explain the numbers in the code below. */ +#if 0 +for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"} + 11 44937.64284865548751208448 + 10 45180.98734845585101160448 + 9 45303.31936980687359311872 + 8 45364.65110595323018870784 + 7 45395.35850361789624614912 + 6 45410.72259715102037508096 + 5 45418.40724413220722311168 + 4 45422.25021786898173001728 + 3 45424.17186732298419044352 + 2 45425.13273269940811464704 + 1 45425.61317555035558641664 + 0 45425.85339951654943850496 +#endif + +static png_uint_32 +png_exp(png_fixed_point x) +{ + if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */ + { + /* Obtain a 4-bit approximation */ + png_uint_32 e = png_32bit_exp[(x >> 12) & 0x0f]; + + /* Incorporate the low 12 bits - these decrease the returned value by + * multiplying by a number less than 1 if the bit is set. The multiplier + * is determined by the above table and the shift. Notice that the values + * converge on 45426 and this is used to allow linear interpolation of the + * low bits. + */ + if (x & 0x800) + e -= (((e >> 16) * 44938U) + 16U) >> 5; + + if (x & 0x400) + e -= (((e >> 16) * 45181U) + 32U) >> 6; + + if (x & 0x200) + e -= (((e >> 16) * 45303U) + 64U) >> 7; + + if (x & 0x100) + e -= (((e >> 16) * 45365U) + 128U) >> 8; + + if (x & 0x080) + e -= (((e >> 16) * 45395U) + 256U) >> 9; + + if (x & 0x040) + e -= (((e >> 16) * 45410U) + 512U) >> 10; + + /* And handle the low 6 bits in a single block. */ + e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9; + + /* Handle the upper bits of x. */ + e >>= x >> 16; + return e; + } + + /* Check for overflow */ + if (x <= 0) + return png_32bit_exp[0]; + + /* Else underflow */ + return 0; +} + +static png_byte +png_exp8bit(png_fixed_point lg2) +{ + /* Get a 32-bit value: */ + png_uint_32 x = png_exp(lg2); + + /* Convert the 32-bit value to 0..255 by multiplying by 256-1. Note that the + * second, rounding, step can't overflow because of the first, subtraction, + * step. + */ + x -= x >> 8; + return (png_byte)(((x + 0x7fffffU) >> 24) & 0xff); +} + +#ifdef PNG_16BIT_SUPPORTED +static png_uint_16 +png_exp16bit(png_fixed_point lg2) +{ + /* Get a 32-bit value: */ + png_uint_32 x = png_exp(lg2); + + /* Convert the 32-bit value to 0..65535 by multiplying by 65536-1: */ + x -= x >> 16; + return (png_uint_16)((x + 32767U) >> 16); +} +#endif /* 16BIT */ +#endif /* FLOATING_ARITHMETIC */ + +png_byte +png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val) +{ + if (value > 0 && value < 255) + { +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + /* 'value' is unsigned, ANSI-C90 requires the compiler to correctly + * convert this to a floating point value. This includes values that + * would overflow if 'value' were to be converted to 'int'. + * + * Apparently GCC, however, does an intermediate conversion to (int) + * on some (ARM) but not all (x86) platforms, possibly because of + * hardware FP limitations. (E.g. if the hardware conversion always + * assumes the integer register contains a signed value.) This results + * in ANSI-C undefined behavior for large values. + * + * Other implementations on the same machine might actually be ANSI-C90 + * conformant and therefore compile spurious extra code for the large + * values. + * + * We can be reasonably sure that an unsigned to float conversion + * won't be faster than an int to float one. Therefore this code + * assumes responsibility for the undefined behavior, which it knows + * can't happen because of the check above. + * + * Note the argument to this routine is an (unsigned int) because, on + * 16-bit platforms, it is assigned a value which might be out of + * range for an (int); that would result in undefined behavior in the + * caller if the *argument* ('value') were to be declared (int). + */ + double r = floor(255*pow((int)/*SAFE*/value/255.,gamma_val*.00001)+.5); + return (png_byte)r; +# else + png_int_32 lg2 = png_log8bit(value); + png_fixed_point res; + + if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0) + return png_exp8bit(res); + + /* Overflow. */ + value = 0; +# endif + } + + return (png_byte)(value & 0xff); +} + +#ifdef PNG_16BIT_SUPPORTED +png_uint_16 +png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) +{ + if (value > 0 && value < 65535) + { +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + /* The same (unsigned int)->(double) constraints apply here as above, + * however in this case the (unsigned int) to (int) conversion can + * overflow on an ANSI-C90 compliant system so the cast needs to ensure + * that this is not possible. + */ + double r = floor(65535*pow((png_int_32)value/65535., + gamma_val*.00001)+.5); + return (png_uint_16)r; +# else + png_int_32 lg2 = png_log16bit(value); + png_fixed_point res; + + if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0) + return png_exp16bit(res); + + /* Overflow. */ + value = 0; +# endif + } + + return (png_uint_16)value; +} +#endif /* 16BIT */ + +/* This does the right thing based on the bit_depth field of the + * png_struct, interpreting values as 8-bit or 16-bit. While the result + * is nominally a 16-bit value if bit depth is 8 then the result is + * 8-bit (as are the arguments.) + */ +png_uint_16 /* PRIVATE */ +png_gamma_correct(png_structrp png_ptr, unsigned int value, + png_fixed_point gamma_val) +{ + if (png_ptr->bit_depth == 8) + return png_gamma_8bit_correct(value, gamma_val); + +#ifdef PNG_16BIT_SUPPORTED + else + return png_gamma_16bit_correct(value, gamma_val); +#else + /* should not reach this */ + return 0; +#endif /* 16BIT */ +} + +#ifdef PNG_16BIT_SUPPORTED +/* Internal function to build a single 16-bit table - the table consists of + * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount + * to shift the input values right (or 16-number_of_signifiant_bits). + * + * The caller is responsible for ensuring that the table gets cleaned up on + * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument + * should be somewhere that will be cleaned. + */ +static void +png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) +{ + /* Various values derived from 'shift': */ + PNG_CONST unsigned int num = 1U << (8U - shift); +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + /* CSE the division and work round wacky GCC warnings (see the comments + * in png_gamma_8bit_correct for where these come from.) + */ + PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1); +#endif + PNG_CONST unsigned int max = (1U << (16U - shift))-1U; + PNG_CONST unsigned int max_by_2 = 1U << (15U-shift); + unsigned int i; + + png_uint_16pp table = *ptable = + (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); + + for (i = 0; i < num; i++) + { + png_uint_16p sub_table = table[i] = + (png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16))); + + /* The 'threshold' test is repeated here because it can arise for one of + * the 16-bit tables even if the others don't hit it. + */ + if (png_gamma_significant(gamma_val) != 0) + { + /* The old code would overflow at the end and this would cause the + * 'pow' function to return a result >1, resulting in an + * arithmetic error. This code follows the spec exactly; ig is + * the recovered input sample, it always has 8-16 bits. + * + * We want input * 65535/max, rounded, the arithmetic fits in 32 + * bits (unsigned) so long as max <= 32767. + */ + unsigned int j; + for (j = 0; j < 256; j++) + { + png_uint_32 ig = (j << (8-shift)) + i; +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + /* Inline the 'max' scaling operation: */ + /* See png_gamma_8bit_correct for why the cast to (int) is + * required here. + */ + double d = floor(65535.*pow(ig*fmax, gamma_val*.00001)+.5); + sub_table[j] = (png_uint_16)d; +# else + if (shift != 0) + ig = (ig * 65535U + max_by_2)/max; + + sub_table[j] = png_gamma_16bit_correct(ig, gamma_val); +# endif + } + } + else + { + /* We must still build a table, but do it the fast way. */ + unsigned int j; + + for (j = 0; j < 256; j++) + { + png_uint_32 ig = (j << (8-shift)) + i; + + if (shift != 0) + ig = (ig * 65535U + max_by_2)/max; + + sub_table[j] = (png_uint_16)ig; + } + } + } +} + +/* NOTE: this function expects the *inverse* of the overall gamma transformation + * required. + */ +static void +png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) +{ + PNG_CONST unsigned int num = 1U << (8U - shift); + PNG_CONST unsigned int max = (1U << (16U - shift))-1U; + unsigned int i; + png_uint_32 last; + + png_uint_16pp table = *ptable = + (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); + + /* 'num' is the number of tables and also the number of low bits of low + * bits of the input 16-bit value used to select a table. Each table is + * itself indexed by the high 8 bits of the value. + */ + for (i = 0; i < num; i++) + table[i] = (png_uint_16p)png_malloc(png_ptr, + 256 * (sizeof (png_uint_16))); + + /* 'gamma_val' is set to the reciprocal of the value calculated above, so + * pow(out,g) is an *input* value. 'last' is the last input value set. + * + * In the loop 'i' is used to find output values. Since the output is + * 8-bit there are only 256 possible values. The tables are set up to + * select the closest possible output value for each input by finding + * the input value at the boundary between each pair of output values + * and filling the table up to that boundary with the lower output + * value. + * + * The boundary values are 0.5,1.5..253.5,254.5. Since these are 9-bit + * values the code below uses a 16-bit value in i; the values start at + * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last + * entries are filled with 255). Start i at 128 and fill all 'last' + * table entries <= 'max' + */ + last = 0; + for (i = 0; i < 255; ++i) /* 8-bit output value */ + { + /* Find the corresponding maximum input value */ + png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */ + + /* Find the boundary value in 16 bits: */ + png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val); + + /* Adjust (round) to (16-shift) bits: */ + bound = (bound * max + 32768U)/65535U + 1U; + + while (last < bound) + { + table[last & (0xffU >> shift)][last >> (8U - shift)] = out; + last++; + } + } + + /* And fill in the final entries. */ + while (last < (num << 8)) + { + table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U; + last++; + } +} +#endif /* 16BIT */ + +/* Build a single 8-bit table: same as the 16-bit case but much simpler (and + * typically much faster). Note that libpng currently does no sBIT processing + * (apparently contrary to the spec) so a 256-entry table is always generated. + */ +static void +png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, + PNG_CONST png_fixed_point gamma_val) +{ + unsigned int i; + png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); + + if (png_gamma_significant(gamma_val) != 0) + for (i=0; i<256; i++) + table[i] = png_gamma_8bit_correct(i, gamma_val); + + else + for (i=0; i<256; ++i) + table[i] = (png_byte)(i & 0xff); +} + +/* Used from png_read_destroy and below to release the memory used by the gamma + * tables. + */ +void /* PRIVATE */ +png_destroy_gamma_table(png_structrp png_ptr) +{ + png_free(png_ptr, png_ptr->gamma_table); + png_ptr->gamma_table = NULL; + +#ifdef PNG_16BIT_SUPPORTED + if (png_ptr->gamma_16_table != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_table[i]); + } + png_free(png_ptr, png_ptr->gamma_16_table); + png_ptr->gamma_16_table = NULL; + } +#endif /* 16BIT */ + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_free(png_ptr, png_ptr->gamma_from_1); + png_ptr->gamma_from_1 = NULL; + png_free(png_ptr, png_ptr->gamma_to_1); + png_ptr->gamma_to_1 = NULL; + +#ifdef PNG_16BIT_SUPPORTED + if (png_ptr->gamma_16_from_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_from_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_from_1); + png_ptr->gamma_16_from_1 = NULL; + } + if (png_ptr->gamma_16_to_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_to_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_to_1); + png_ptr->gamma_16_to_1 = NULL; + } +#endif /* 16BIT */ +#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ +} + +/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit + * tables, we don't make a full table if we are reducing to 8-bit in + * the future. Note also how the gamma_16 tables are segmented so that + * we don't need to allocate > 64K chunks for a full 16-bit table. + */ +void /* PRIVATE */ +png_build_gamma_table(png_structrp png_ptr, int bit_depth) +{ + png_debug(1, "in png_build_gamma_table"); + + /* Remove any existing table; this copes with multiple calls to + * png_read_update_info. The warning is because building the gamma tables + * multiple times is a performance hit - it's harmless but the ability to + * call png_read_update_info() multiple times is new in 1.5.6 so it seems + * sensible to warn if the app introduces such a hit. + */ + if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL) + { + png_warning(png_ptr, "gamma table being rebuilt"); + png_destroy_gamma_table(png_ptr); + } + + if (bit_depth <= 8) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_table, + png_ptr->screen_gamma > 0 ? + png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, + png_reciprocal(png_ptr->colorspace.gamma)); + + png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, + png_ptr->screen_gamma > 0 ? + png_reciprocal(png_ptr->screen_gamma) : + png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); + } +#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ + } +#ifdef PNG_16BIT_SUPPORTED + else + { + png_byte shift, sig_bit; + + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + sig_bit = png_ptr->sig_bit.red; + + if (png_ptr->sig_bit.green > sig_bit) + sig_bit = png_ptr->sig_bit.green; + + if (png_ptr->sig_bit.blue > sig_bit) + sig_bit = png_ptr->sig_bit.blue; + } + else + sig_bit = png_ptr->sig_bit.gray; + + /* 16-bit gamma code uses this equation: + * + * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] + * + * Where 'iv' is the input color value and 'ov' is the output value - + * pow(iv, gamma). + * + * Thus the gamma table consists of up to 256 256-entry tables. The table + * is selected by the (8-gamma_shift) most significant of the low 8 bits + * of the color value then indexed by the upper 8 bits: + * + * table[low bits][high 8 bits] + * + * So the table 'n' corresponds to all those 'iv' of: + * + * ..<(n+1 << gamma_shift)-1> + * + */ + if (sig_bit > 0 && sig_bit < 16U) + /* shift == insignificant bits */ + shift = (png_byte)((16U - sig_bit) & 0xff); + + else + shift = 0; /* keep all 16 bits */ + + if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) + { + /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively + * the significant bits in the *input* when the output will + * eventually be 8 bits. By default it is 11. + */ + if (shift < (16U - PNG_MAX_GAMMA_8)) + shift = (16U - PNG_MAX_GAMMA_8); + } + + if (shift > 8U) + shift = 8U; /* Guarantees at least one table! */ + + png_ptr->gamma_shift = shift; + + /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now + * PNG_COMPOSE). This effectively smashed the background calculation for + * 16-bit output because the 8-bit table assumes the result will be + * reduced to 8 bits. + */ + if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) + png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); + + else + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) + { + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, + png_reciprocal(png_ptr->colorspace.gamma)); + + /* Notice that the '16 from 1' table should be full precision, however + * the lookup on this table still uses gamma_shift, so it can't be. + * TODO: fix this. + */ + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : + png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); + } +#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ + } +#endif /* 16BIT */ +} +#endif /* READ_GAMMA */ + +/* HARDWARE OR SOFTWARE OPTION SUPPORT */ +#ifdef PNG_SET_OPTION_SUPPORTED +int PNGAPI +png_set_option(png_structrp png_ptr, int option, int onoff) +{ + if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT && + (option & 1) == 0) + { + png_uint_32 mask = 3U << option; + png_uint_32 setting = (2U + (onoff != 0)) << option; + png_uint_32 current = png_ptr->options; + + png_ptr->options = (png_uint_32)(((current & ~mask) | setting) & 0xff); + + return (int)(current & mask) >> option; + } + + return PNG_OPTION_INVALID; +} +#endif + +/* sRGB support */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +/* sRGB conversion tables; these are machine generated with the code in + * contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the + * specification (see the article at https://en.wikipedia.org/wiki/SRGB) + * is used, not the gamma=1/2.2 approximation use elsewhere in libpng. + * The sRGB to linear table is exact (to the nearest 16-bit linear fraction). + * The inverse (linear to sRGB) table has accuracies as follows: + * + * For all possible (255*65535+1) input values: + * + * error: -0.515566 - 0.625971, 79441 (0.475369%) of readings inexact + * + * For the input values corresponding to the 65536 16-bit values: + * + * error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact + * + * In all cases the inexact readings are only off by one. + */ + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +/* The convert-to-sRGB table is only currently required for read. */ +const png_uint_16 png_sRGB_table[256] = +{ + 0,20,40,60,80,99,119,139, + 159,179,199,219,241,264,288,313, + 340,367,396,427,458,491,526,562, + 599,637,677,718,761,805,851,898, + 947,997,1048,1101,1156,1212,1270,1330, + 1391,1453,1517,1583,1651,1720,1790,1863, + 1937,2013,2090,2170,2250,2333,2418,2504, + 2592,2681,2773,2866,2961,3058,3157,3258, + 3360,3464,3570,3678,3788,3900,4014,4129, + 4247,4366,4488,4611,4736,4864,4993,5124, + 5257,5392,5530,5669,5810,5953,6099,6246, + 6395,6547,6700,6856,7014,7174,7335,7500, + 7666,7834,8004,8177,8352,8528,8708,8889, + 9072,9258,9445,9635,9828,10022,10219,10417, + 10619,10822,11028,11235,11446,11658,11873,12090, + 12309,12530,12754,12980,13209,13440,13673,13909, + 14146,14387,14629,14874,15122,15371,15623,15878, + 16135,16394,16656,16920,17187,17456,17727,18001, + 18277,18556,18837,19121,19407,19696,19987,20281, + 20577,20876,21177,21481,21787,22096,22407,22721, + 23038,23357,23678,24002,24329,24658,24990,25325, + 25662,26001,26344,26688,27036,27386,27739,28094, + 28452,28813,29176,29542,29911,30282,30656,31033, + 31412,31794,32179,32567,32957,33350,33745,34143, + 34544,34948,35355,35764,36176,36591,37008,37429, + 37852,38278,38706,39138,39572,40009,40449,40891, + 41337,41785,42236,42690,43147,43606,44069,44534, + 45002,45473,45947,46423,46903,47385,47871,48359, + 48850,49344,49841,50341,50844,51349,51858,52369, + 52884,53401,53921,54445,54971,55500,56032,56567, + 57105,57646,58190,58737,59287,59840,60396,60955, + 61517,62082,62650,63221,63795,64372,64952,65535 +}; +#endif /* SIMPLIFIED_READ */ + +/* The base/delta tables are required for both read and write (but currently + * only the simplified versions.) + */ +const png_uint_16 png_sRGB_base[512] = +{ + 128,1782,3383,4644,5675,6564,7357,8074, + 8732,9346,9921,10463,10977,11466,11935,12384, + 12816,13233,13634,14024,14402,14769,15125,15473, + 15812,16142,16466,16781,17090,17393,17690,17981, + 18266,18546,18822,19093,19359,19621,19879,20133, + 20383,20630,20873,21113,21349,21583,21813,22041, + 22265,22487,22707,22923,23138,23350,23559,23767, + 23972,24175,24376,24575,24772,24967,25160,25352, + 25542,25730,25916,26101,26284,26465,26645,26823, + 27000,27176,27350,27523,27695,27865,28034,28201, + 28368,28533,28697,28860,29021,29182,29341,29500, + 29657,29813,29969,30123,30276,30429,30580,30730, + 30880,31028,31176,31323,31469,31614,31758,31902, + 32045,32186,32327,32468,32607,32746,32884,33021, + 33158,33294,33429,33564,33697,33831,33963,34095, + 34226,34357,34486,34616,34744,34873,35000,35127, + 35253,35379,35504,35629,35753,35876,35999,36122, + 36244,36365,36486,36606,36726,36845,36964,37083, + 37201,37318,37435,37551,37668,37783,37898,38013, + 38127,38241,38354,38467,38580,38692,38803,38915, + 39026,39136,39246,39356,39465,39574,39682,39790, + 39898,40005,40112,40219,40325,40431,40537,40642, + 40747,40851,40955,41059,41163,41266,41369,41471, + 41573,41675,41777,41878,41979,42079,42179,42279, + 42379,42478,42577,42676,42775,42873,42971,43068, + 43165,43262,43359,43456,43552,43648,43743,43839, + 43934,44028,44123,44217,44311,44405,44499,44592, + 44685,44778,44870,44962,45054,45146,45238,45329, + 45420,45511,45601,45692,45782,45872,45961,46051, + 46140,46229,46318,46406,46494,46583,46670,46758, + 46846,46933,47020,47107,47193,47280,47366,47452, + 47538,47623,47709,47794,47879,47964,48048,48133, + 48217,48301,48385,48468,48552,48635,48718,48801, + 48884,48966,49048,49131,49213,49294,49376,49458, + 49539,49620,49701,49782,49862,49943,50023,50103, + 50183,50263,50342,50422,50501,50580,50659,50738, + 50816,50895,50973,51051,51129,51207,51285,51362, + 51439,51517,51594,51671,51747,51824,51900,51977, + 52053,52129,52205,52280,52356,52432,52507,52582, + 52657,52732,52807,52881,52956,53030,53104,53178, + 53252,53326,53400,53473,53546,53620,53693,53766, + 53839,53911,53984,54056,54129,54201,54273,54345, + 54417,54489,54560,54632,54703,54774,54845,54916, + 54987,55058,55129,55199,55269,55340,55410,55480, + 55550,55620,55689,55759,55828,55898,55967,56036, + 56105,56174,56243,56311,56380,56448,56517,56585, + 56653,56721,56789,56857,56924,56992,57059,57127, + 57194,57261,57328,57395,57462,57529,57595,57662, + 57728,57795,57861,57927,57993,58059,58125,58191, + 58256,58322,58387,58453,58518,58583,58648,58713, + 58778,58843,58908,58972,59037,59101,59165,59230, + 59294,59358,59422,59486,59549,59613,59677,59740, + 59804,59867,59930,59993,60056,60119,60182,60245, + 60308,60370,60433,60495,60558,60620,60682,60744, + 60806,60868,60930,60992,61054,61115,61177,61238, + 61300,61361,61422,61483,61544,61605,61666,61727, + 61788,61848,61909,61969,62030,62090,62150,62211, + 62271,62331,62391,62450,62510,62570,62630,62689, + 62749,62808,62867,62927,62986,63045,63104,63163, + 63222,63281,63340,63398,63457,63515,63574,63632, + 63691,63749,63807,63865,63923,63981,64039,64097, + 64155,64212,64270,64328,64385,64443,64500,64557, + 64614,64672,64729,64786,64843,64900,64956,65013, + 65070,65126,65183,65239,65296,65352,65409,65465 +}; + +const png_byte png_sRGB_delta[512] = +{ + 207,201,158,129,113,100,90,82,77,72,68,64,61,59,56,54, + 52,50,49,47,46,45,43,42,41,40,39,39,38,37,36,36, + 35,34,34,33,33,32,32,31,31,30,30,30,29,29,28,28, + 28,27,27,27,27,26,26,26,25,25,25,25,24,24,24,24, + 23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21, + 21,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19, + 19,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17, + 17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15, + 15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14, + 14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13, + 13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12, + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, + 12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11, + 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, + 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, + 11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 +}; +#endif /* SIMPLIFIED READ/WRITE sRGB support */ + +/* SIMPLIFIED READ/WRITE SUPPORT */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +static int +png_image_free_function(png_voidp argument) +{ + png_imagep image = png_voidcast(png_imagep, argument); + png_controlp cp = image->opaque; + png_control c; + + /* Double check that we have a png_ptr - it should be impossible to get here + * without one. + */ + if (cp->png_ptr == NULL) + return 0; + + /* First free any data held in the control structure. */ +# ifdef PNG_STDIO_SUPPORTED + if (cp->owned_file != 0) + { + FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr); + cp->owned_file = 0; + + /* Ignore errors here. */ + if (fp != NULL) + { + cp->png_ptr->io_ptr = NULL; + (void)fclose(fp); + } + } +# endif + + /* Copy the control structure so that the original, allocated, version can be + * safely freed. Notice that a png_error here stops the remainder of the + * cleanup, but this is probably fine because that would indicate bad memory + * problems anyway. + */ + c = *cp; + image->opaque = &c; + png_free(c.png_ptr, cp); + + /* Then the structures, calling the correct API. */ + if (c.for_write != 0) + { +# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED + png_destroy_write_struct(&c.png_ptr, &c.info_ptr); +# else + png_error(c.png_ptr, "simplified write not supported"); +# endif + } + else + { +# ifdef PNG_SIMPLIFIED_READ_SUPPORTED + png_destroy_read_struct(&c.png_ptr, &c.info_ptr, NULL); +# else + png_error(c.png_ptr, "simplified read not supported"); +# endif + } + + /* Success. */ + return 1; +} + +void PNGAPI +png_image_free(png_imagep image) +{ + /* Safely call the real function, but only if doing so is safe at this point + * (if not inside an error handling context). Otherwise assume + * png_safe_execute will call this API after the return. + */ + if (image != NULL && image->opaque != NULL && + image->opaque->error_buf == NULL) + { + /* Ignore errors here: */ + (void)png_safe_execute(image, png_image_free_function, image); + image->opaque = NULL; + } +} + +int /* PRIVATE */ +png_image_error(png_imagep image, png_const_charp error_message) +{ + /* Utility to log an error. */ + png_safecat(image->message, (sizeof image->message), 0, error_message); + image->warning_or_error |= PNG_IMAGE_ERROR; + png_image_free(image); + return 0; +} + +#endif /* SIMPLIFIED READ/WRITE */ +#endif /* READ || WRITE */ diff --git a/xs/src/png/libpng/png.h b/xs/src/png/libpng/png.h new file mode 100644 index 0000000000..4c873f5c22 --- /dev/null +++ b/xs/src/png/libpng/png.h @@ -0,0 +1,3278 @@ + +/* png.h - header file for PNG reference library + * + * libpng version 1.6.34, September 29, 2017 + * + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license (See LICENSE, below) + * + * Authors and maintainers: + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.6.34, September 29, 2017: + * Glenn Randers-Pehrson. + * See also "Contributing Authors", below. + */ + +/* + * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + * + * If you modify libpng you may insert additional notices immediately following + * this sentence. + * + * This code is released under the libpng license. + * + * libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are + * Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are + * derived from libpng-1.0.6, and are distributed according to the same + * disclaimer and license as libpng-1.0.6 with the following individuals + * added to the list of Contributing Authors: + * + * Simon-Pierre Cadieux + * Eric S. Raymond + * Mans Rullgard + * Cosmin Truta + * Gilles Vollant + * James Yu + * Mandar Sahastrabuddhe + * Google Inc. + * Vadim Barkov + * + * and with the following additions to the disclaimer: + * + * There is no warranty against interference with your enjoyment of the + * library or against infringement. There is no warranty that our + * efforts or the library will fulfill any of your particular purposes + * or needs. This library is provided with all faults, and the entire + * risk of satisfactory quality, performance, accuracy, and effort is with + * the user. + * + * Some files in the "contrib" directory and some configure-generated + * files that are distributed with libpng have other copyright owners and + * are released under other open source licenses. + * + * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are + * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from + * libpng-0.96, and are distributed according to the same disclaimer and + * license as libpng-0.96, with the following individuals added to the list + * of Contributing Authors: + * + * Tom Lane + * Glenn Randers-Pehrson + * Willem van Schaik + * + * libpng versions 0.89, June 1996, through 0.96, May 1997, are + * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, + * and are distributed according to the same disclaimer and license as + * libpng-0.88, with the following individuals added to the list of + * Contributing Authors: + * + * John Bowler + * Kevin Bracey + * Sam Bushell + * Magnus Holmgren + * Greg Roelofs + * Tom Tanner + * + * Some files in the "scripts" directory have other copyright owners + * but are released under this license. + * + * libpng versions 0.5, May 1995, through 0.88, January 1996, are + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + * + * For the purposes of this copyright and license, "Contributing Authors" + * is defined as the following set of individuals: + * + * Andreas Dilger + * Dave Martindale + * Guy Eric Schalnat + * Paul Schmidt + * Tim Wegner + * + * The PNG Reference Library is supplied "AS IS". The Contributing Authors + * and Group 42, Inc. disclaim all warranties, expressed or implied, + * including, without limitation, the warranties of merchantability and of + * fitness for any purpose. The Contributing Authors and Group 42, Inc. + * assume no liability for direct, indirect, incidental, special, exemplary, + * or consequential damages, which may result from the use of the PNG + * Reference Library, even if advised of the possibility of such damage. + * + * Permission is hereby granted to use, copy, modify, and distribute this + * source code, or portions hereof, for any purpose, without fee, subject + * to the following restrictions: + * + * 1. The origin of this source code must not be misrepresented. + * + * 2. Altered versions must be plainly marked as such and must not + * be misrepresented as being the original source. + * + * 3. This Copyright notice may not be removed or altered from any + * source or altered source distribution. + * + * The Contributing Authors and Group 42, Inc. specifically permit, without + * fee, and encourage the use of this source code as a component to + * supporting the PNG file format in commercial products. If you use this + * source code in a product, acknowledgment is not required but would be + * appreciated. + * + * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. + * + * TRADEMARK: + * + * The name "libpng" has not been registered by the Copyright owner + * as a trademark in any jurisdiction. However, because libpng has + * been distributed and maintained world-wide, continually since 1995, + * the Copyright owner claims "common-law trademark protection" in any + * jurisdiction where common-law trademark is recognized. + * + * OSI CERTIFICATION: + * + * Libpng is OSI Certified Open Source Software. OSI Certified Open Source is + * a certification mark of the Open Source Initiative. OSI has not addressed + * the additional disclaimers inserted at version 1.0.7. + * + * EXPORT CONTROL: + * + * The Copyright owner believes that the Export Control Classification + * Number (ECCN) for libpng is EAR99, which means not subject to export + * controls or International Traffic in Arms Regulations (ITAR) because + * it is open source, publicly available software, that does not contain + * any encryption software. See the EAR, paragraphs 734.3(b)(3) and + * 734.7(b). + */ + +/* + * A "png_get_copyright" function is available, for convenient use in "about" + * boxes and the like: + * + * printf("%s", png_get_copyright(NULL)); + * + * Also, the PNG logo (in PNG format, of course) is supplied in the + * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). + */ + +/* + * The contributing authors would like to thank all those who helped + * with testing, bug fixes, and patience. This wouldn't have been + * possible without all of you. + * + * Thanks to Frank J. T. Wojcik for helping with the documentation. + */ + +/* Note about libpng version numbers: + * + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: + * + * source png.h png.h shared-lib + * version string int version + * ------- ------ ----- ---------- + * 0.89c "1.0 beta 3" 0.89 89 1.0.89 + * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] + * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] + * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] + * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] + * 0.97c 0.97 97 2.0.97 + * 0.98 0.98 98 2.0.98 + * 0.99 0.99 98 2.0.99 + * 0.99a-m 0.99 99 2.0.99 + * 1.00 1.00 100 2.1.0 [100 should be 10000] + * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] + * 1.0.1 png.h string is 10001 2.1.0 + * 1.0.1a-e identical to the 10002 from here on, the shared library + * 1.0.2 source version) 10002 is 2.V where V is the source code + * 1.0.2a-b 10003 version, except as noted. + * 1.0.3 10003 + * 1.0.3a-d 10004 + * 1.0.4 10004 + * 1.0.4a-f 10005 + * 1.0.5 (+ 2 patches) 10005 + * 1.0.5a-d 10006 + * 1.0.5e-r 10100 (not source compatible) + * 1.0.5s-v 10006 (not binary compatible) + * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) + * 1.0.6d-f 10007 (still binary incompatible) + * 1.0.6g 10007 + * 1.0.6h 10007 10.6h (testing xy.z so-numbering) + * 1.0.6i 10007 10.6i + * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) + * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) + * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) + * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) + * 1.0.7 1 10007 (still compatible) + * ... + * 1.0.19 10 10019 10.so.0.19[.0] + * ... + * 1.2.59 13 10257 12.so.0.59[.0] + * ... + * 1.5.30 15 10527 15.so.15.30[.0] + * ... + * 1.6.34 16 10633 16.so.16.34[.0] + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcNN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng.txt or libpng.3 for more information. The PNG specification + * is available as a W3C Recommendation and as an ISO Specification, + * + * + * If you just need to read a PNG file and don't want to read the documentation + * skip to the end of this file and read the section entitled 'simplified API'. + */ + +/* Version information for png.h - this should match the version in png.c */ +#define PNG_LIBPNG_VER_STRING "1.6.34" +#define PNG_HEADER_VERSION_STRING " libpng version 1.6.34 - September 29, 2017\n" + +#define PNG_LIBPNG_VER_SONUM 16 +#define PNG_LIBPNG_VER_DLLNUM 16 + +/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ +#define PNG_LIBPNG_VER_MAJOR 1 +#define PNG_LIBPNG_VER_MINOR 6 +#define PNG_LIBPNG_VER_RELEASE 34 + +/* This should match the numeric part of the final component of + * PNG_LIBPNG_VER_STRING, omitting any leading zero: + */ + +#define PNG_LIBPNG_VER_BUILD 0 + +/* Release Status */ +#define PNG_LIBPNG_BUILD_ALPHA 1 +#define PNG_LIBPNG_BUILD_BETA 2 +#define PNG_LIBPNG_BUILD_RC 3 +#define PNG_LIBPNG_BUILD_STABLE 4 +#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 + +/* Release-Specific Flags */ +#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with + PNG_LIBPNG_BUILD_STABLE only */ +#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with + PNG_LIBPNG_BUILD_SPECIAL */ +#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with + PNG_LIBPNG_BUILD_PRIVATE */ + +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE + +/* Careful here. At one time, Guy wanted to use 082, but that would be octal. + * We must not include leading zeros. + * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only + * version 1.0.0 was mis-numbered 100 instead of 10000). From + * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release + */ +#define PNG_LIBPNG_VER 10634 /* 1.6.34 */ + +/* Library configuration: these options cannot be changed after + * the library has been built. + */ +#ifndef PNGLCONF_H +/* If pnglibconf.h is missing, you can + * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h + */ +# include "pnglibconf.h" +#endif + +#ifndef PNG_VERSION_INFO_ONLY +/* Machine specific configuration. */ +# include "pngconf.h" +#endif + +/* + * Added at libpng-1.2.8 + * + * Ref MSDN: Private as priority over Special + * VS_FF_PRIVATEBUILD File *was not* built using standard release + * procedures. If this value is given, the StringFileInfo block must + * contain a PrivateBuild string. + * + * VS_FF_SPECIALBUILD File *was* built by the original company using + * standard release procedures but is a variation of the standard + * file of the same version number. If this value is given, the + * StringFileInfo block must contain a SpecialBuild string. + */ + +#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */ +# define PNG_LIBPNG_BUILD_TYPE \ + (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) +#else +# ifdef PNG_LIBPNG_SPECIALBUILD +# define PNG_LIBPNG_BUILD_TYPE \ + (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) +# else +# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) +# endif +#endif + +#ifndef PNG_VERSION_INFO_ONLY + +/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Version information for C files, stored in png.c. This had better match + * the version above. + */ +#define png_libpng_ver png_get_header_ver(NULL) + +/* This file is arranged in several sections: + * + * 1. [omitted] + * 2. Any configuration options that can be specified by for the application + * code when it is built. (Build time configuration is in pnglibconf.h) + * 3. Type definitions (base types are defined in pngconf.h), structure + * definitions. + * 4. Exported library functions. + * 5. Simplified API. + * 6. Implementation options. + * + * The library source code has additional files (principally pngpriv.h) that + * allow configuration of the library. + */ + +/* Section 1: [omitted] */ + +/* Section 2: run time configuration + * See pnglibconf.h for build time configuration + * + * Run time configuration allows the application to choose between + * implementations of certain arithmetic APIs. The default is set + * at build time and recorded in pnglibconf.h, but it is safe to + * override these (and only these) settings. Note that this won't + * change what the library does, only application code, and the + * settings can (and probably should) be made on a per-file basis + * by setting the #defines before including png.h + * + * Use macros to read integers from PNG data or use the exported + * functions? + * PNG_USE_READ_MACROS: use the macros (see below) Note that + * the macros evaluate their argument multiple times. + * PNG_NO_USE_READ_MACROS: call the relevant library function. + * + * Use the alternative algorithm for compositing alpha samples that + * does not use division? + * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division' + * algorithm. + * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm. + * + * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is + * false? + * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error + * APIs to png_warning. + * Otherwise the calls are mapped to png_error. + */ + +/* Section 3: type definitions, including structures and compile time + * constants. + * See pngconf.h for base types that vary by machine/system + */ + +/* This triggers a compiler error in png.c, if png.c and png.h + * do not agree upon the version number. + */ +typedef char* png_libpng_version_1_6_34; + +/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. + * + * png_struct is the cache of information used while reading or writing a single + * PNG file. One of these is always required, although the simplified API + * (below) hides the creation and destruction of it. + */ +typedef struct png_struct_def png_struct; +typedef const png_struct * png_const_structp; +typedef png_struct * png_structp; +typedef png_struct * * png_structpp; + +/* png_info contains information read from or to be written to a PNG file. One + * or more of these must exist while reading or creating a PNG file. The + * information is not used by libpng during read but is used to control what + * gets written when a PNG file is created. "png_get_" function calls read + * information during read and "png_set_" functions calls write information + * when creating a PNG. + * been moved into a separate header file that is not accessible to + * applications. Read libpng-manual.txt or libpng.3 for more info. + */ +typedef struct png_info_def png_info; +typedef png_info * png_infop; +typedef const png_info * png_const_infop; +typedef png_info * * png_infopp; + +/* Types with names ending 'p' are pointer types. The corresponding types with + * names ending 'rp' are identical pointer types except that the pointer is + * marked 'restrict', which means that it is the only pointer to the object + * passed to the function. Applications should not use the 'restrict' types; + * it is always valid to pass 'p' to a pointer with a function argument of the + * corresponding 'rp' type. Different compilers have different rules with + * regard to type matching in the presence of 'restrict'. For backward + * compatibility libpng callbacks never have 'restrict' in their parameters and, + * consequentially, writing portable application code is extremely difficult if + * an attempt is made to use 'restrict'. + */ +typedef png_struct * PNG_RESTRICT png_structrp; +typedef const png_struct * PNG_RESTRICT png_const_structrp; +typedef png_info * PNG_RESTRICT png_inforp; +typedef const png_info * PNG_RESTRICT png_const_inforp; + +/* Three color definitions. The order of the red, green, and blue, (and the + * exact size) is not important, although the size of the fields need to + * be png_byte or png_uint_16 (as defined below). + */ +typedef struct png_color_struct +{ + png_byte red; + png_byte green; + png_byte blue; +} png_color; +typedef png_color * png_colorp; +typedef const png_color * png_const_colorp; +typedef png_color * * png_colorpp; + +typedef struct png_color_16_struct +{ + png_byte index; /* used for palette files */ + png_uint_16 red; /* for use in red green blue files */ + png_uint_16 green; + png_uint_16 blue; + png_uint_16 gray; /* for use in grayscale files */ +} png_color_16; +typedef png_color_16 * png_color_16p; +typedef const png_color_16 * png_const_color_16p; +typedef png_color_16 * * png_color_16pp; + +typedef struct png_color_8_struct +{ + png_byte red; /* for use in red green blue files */ + png_byte green; + png_byte blue; + png_byte gray; /* for use in grayscale files */ + png_byte alpha; /* for alpha channel files */ +} png_color_8; +typedef png_color_8 * png_color_8p; +typedef const png_color_8 * png_const_color_8p; +typedef png_color_8 * * png_color_8pp; + +/* + * The following two structures are used for the in-core representation + * of sPLT chunks. + */ +typedef struct png_sPLT_entry_struct +{ + png_uint_16 red; + png_uint_16 green; + png_uint_16 blue; + png_uint_16 alpha; + png_uint_16 frequency; +} png_sPLT_entry; +typedef png_sPLT_entry * png_sPLT_entryp; +typedef const png_sPLT_entry * png_const_sPLT_entryp; +typedef png_sPLT_entry * * png_sPLT_entrypp; + +/* When the depth of the sPLT palette is 8 bits, the color and alpha samples + * occupy the LSB of their respective members, and the MSB of each member + * is zero-filled. The frequency member always occupies the full 16 bits. + */ + +typedef struct png_sPLT_struct +{ + png_charp name; /* palette name */ + png_byte depth; /* depth of palette samples */ + png_sPLT_entryp entries; /* palette entries */ + png_int_32 nentries; /* number of palette entries */ +} png_sPLT_t; +typedef png_sPLT_t * png_sPLT_tp; +typedef const png_sPLT_t * png_const_sPLT_tp; +typedef png_sPLT_t * * png_sPLT_tpp; + +#ifdef PNG_TEXT_SUPPORTED +/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, + * and whether that contents is compressed or not. The "key" field + * points to a regular zero-terminated C string. The "text" fields can be a + * regular C string, an empty string, or a NULL pointer. + * However, the structure returned by png_get_text() will always contain + * the "text" field as a regular zero-terminated C string (possibly + * empty), never a NULL pointer, so it can be safely used in printf() and + * other string-handling functions. Note that the "itxt_length", "lang", and + * "lang_key" members of the structure only exist when the library is built + * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by + * default without iTXt support. Also note that when iTXt *is* supported, + * the "lang" and "lang_key" fields contain NULL pointers when the + * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or + * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the + * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag" + * which is always 0 or 1, or its "compression method" which is always 0. + */ +typedef struct png_text_struct +{ + int compression; /* compression value: + -1: tEXt, none + 0: zTXt, deflate + 1: iTXt, none + 2: iTXt, deflate */ + png_charp key; /* keyword, 1-79 character description of "text" */ + png_charp text; /* comment, may be an empty string (ie "") + or a NULL pointer */ + png_size_t text_length; /* length of the text string */ + png_size_t itxt_length; /* length of the itxt string */ + png_charp lang; /* language code, 0-79 characters + or a NULL pointer */ + png_charp lang_key; /* keyword translated UTF-8 string, 0 or more + chars or a NULL pointer */ +} png_text; +typedef png_text * png_textp; +typedef const png_text * png_const_textp; +typedef png_text * * png_textpp; +#endif + +/* Supported compression types for text in PNG files (tEXt, and zTXt). + * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ +#define PNG_TEXT_COMPRESSION_NONE_WR -3 +#define PNG_TEXT_COMPRESSION_zTXt_WR -2 +#define PNG_TEXT_COMPRESSION_NONE -1 +#define PNG_TEXT_COMPRESSION_zTXt 0 +#define PNG_ITXT_COMPRESSION_NONE 1 +#define PNG_ITXT_COMPRESSION_zTXt 2 +#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ + +/* png_time is a way to hold the time in an machine independent way. + * Two conversions are provided, both from time_t and struct tm. There + * is no portable way to convert to either of these structures, as far + * as I know. If you know of a portable way, send it to me. As a side + * note - PNG has always been Year 2000 compliant! + */ +typedef struct png_time_struct +{ + png_uint_16 year; /* full year, as in, 1995 */ + png_byte month; /* month of year, 1 - 12 */ + png_byte day; /* day of month, 1 - 31 */ + png_byte hour; /* hour of day, 0 - 23 */ + png_byte minute; /* minute of hour, 0 - 59 */ + png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ +} png_time; +typedef png_time * png_timep; +typedef const png_time * png_const_timep; +typedef png_time * * png_timepp; + +#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\ + defined(PNG_USER_CHUNKS_SUPPORTED) +/* png_unknown_chunk is a structure to hold queued chunks for which there is + * no specific support. The idea is that we can use this to queue + * up private chunks for output even though the library doesn't actually + * know about their semantics. + * + * The data in the structure is set by libpng on read and used on write. + */ +typedef struct png_unknown_chunk_t +{ + png_byte name[5]; /* Textual chunk name with '\0' terminator */ + png_byte *data; /* Data, should not be modified on read! */ + png_size_t size; + + /* On write 'location' must be set using the flag values listed below. + * Notice that on read it is set by libpng however the values stored have + * more bits set than are listed below. Always treat the value as a + * bitmask. On write set only one bit - setting multiple bits may cause the + * chunk to be written in multiple places. + */ + png_byte location; /* mode of operation at read time */ +} +png_unknown_chunk; + +typedef png_unknown_chunk * png_unknown_chunkp; +typedef const png_unknown_chunk * png_const_unknown_chunkp; +typedef png_unknown_chunk * * png_unknown_chunkpp; +#endif + +/* Flag values for the unknown chunk location byte. */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_AFTER_IDAT 0x08 + +/* Maximum positive integer used in PNG is (2^31)-1 */ +#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) +#define PNG_UINT_32_MAX ((png_uint_32)(-1)) +#define PNG_SIZE_MAX ((png_size_t)(-1)) + +/* These are constants for fixed point values encoded in the + * PNG specification manner (x100000) + */ +#define PNG_FP_1 100000 +#define PNG_FP_HALF 50000 +#define PNG_FP_MAX ((png_fixed_point)0x7fffffffL) +#define PNG_FP_MIN (-PNG_FP_MAX) + +/* These describe the color_type field in png_info. */ +/* color type masks */ +#define PNG_COLOR_MASK_PALETTE 1 +#define PNG_COLOR_MASK_COLOR 2 +#define PNG_COLOR_MASK_ALPHA 4 + +/* color types. Note that not all combinations are legal */ +#define PNG_COLOR_TYPE_GRAY 0 +#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) +#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) +#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) +#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) +/* aliases */ +#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA +#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA + +/* This is for compression type. PNG 1.0-1.2 only define the single type. */ +#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ +#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE + +/* This is for filter type. PNG 1.0-1.2 only define the single type. */ +#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ +#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ +#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE + +/* These are for the interlacing type. These values should NOT be changed. */ +#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ +#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ +#define PNG_INTERLACE_LAST 2 /* Not a valid value */ + +/* These are for the oFFs chunk. These values should NOT be changed. */ +#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ +#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ +#define PNG_OFFSET_LAST 2 /* Not a valid value */ + +/* These are for the pCAL chunk. These values should NOT be changed. */ +#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ +#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ +#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ +#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ +#define PNG_EQUATION_LAST 4 /* Not a valid value */ + +/* These are for the sCAL chunk. These values should NOT be changed. */ +#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ +#define PNG_SCALE_METER 1 /* meters per pixel */ +#define PNG_SCALE_RADIAN 2 /* radians per pixel */ +#define PNG_SCALE_LAST 3 /* Not a valid value */ + +/* These are for the pHYs chunk. These values should NOT be changed. */ +#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ +#define PNG_RESOLUTION_METER 1 /* pixels/meter */ +#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ + +/* These are for the sRGB chunk. These values should NOT be changed. */ +#define PNG_sRGB_INTENT_PERCEPTUAL 0 +#define PNG_sRGB_INTENT_RELATIVE 1 +#define PNG_sRGB_INTENT_SATURATION 2 +#define PNG_sRGB_INTENT_ABSOLUTE 3 +#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ + +/* This is for text chunks */ +#define PNG_KEYWORD_MAX_LENGTH 79 + +/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ +#define PNG_MAX_PALETTE_LENGTH 256 + +/* These determine if an ancillary chunk's data has been successfully read + * from the PNG header, or if the application has filled in the corresponding + * data in the info_struct to be written into the output file. The values + * of the PNG_INFO_ defines should NOT be changed. + */ +#define PNG_INFO_gAMA 0x0001U +#define PNG_INFO_sBIT 0x0002U +#define PNG_INFO_cHRM 0x0004U +#define PNG_INFO_PLTE 0x0008U +#define PNG_INFO_tRNS 0x0010U +#define PNG_INFO_bKGD 0x0020U +#define PNG_INFO_hIST 0x0040U +#define PNG_INFO_pHYs 0x0080U +#define PNG_INFO_oFFs 0x0100U +#define PNG_INFO_tIME 0x0200U +#define PNG_INFO_pCAL 0x0400U +#define PNG_INFO_sRGB 0x0800U /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000U /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */ +#define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */ + +/* This is used for the transformation routines, as some of them + * change these values for the row. It also should enable using + * the routines for other purposes. + */ +typedef struct png_row_info_struct +{ + png_uint_32 width; /* width of row */ + png_size_t rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_byte pixel_depth; /* bits per pixel (depth * channels) */ +} png_row_info; + +typedef png_row_info * png_row_infop; +typedef png_row_info * * png_row_infopp; + +/* These are the function types for the I/O functions and for the functions + * that allow the user to override the default I/O functions with his or her + * own. The png_error_ptr type should match that of user-supplied warning + * and error functions, while the png_rw_ptr type should match that of the + * user read/write data functions. Note that the 'write' function must not + * modify the buffer it is passed. The 'read' function, on the other hand, is + * expected to return the read data in the buffer. + */ +typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); +typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); +typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); +typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, + int)); +typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, + int)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); +typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); + +/* The following callback receives png_uint_32 row_number, int pass for the + * png_bytep data of the row. When transforming an interlaced image the + * row number is the row number within the sub-image of the interlace pass, so + * the value will increase to the height of the sub-image (not the full image) + * then reset to 0 for the next pass. + * + * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to + * find the output pixel (x,y) given an interlaced sub-image pixel + * (row,col,pass). (See below for these macros.) + */ +typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, + png_uint_32, int)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, + png_bytep)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, + png_unknown_chunkp)); +#endif +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED +/* not used anywhere */ +/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This must match the function definition in , and the application + * must include this before png.h to obtain the definition of jmp_buf. The + * function is required to be PNG_NORETURN, but this is not checked. If the + * function does return the application will crash via an abort() or similar + * system level call. + * + * If you get a warning here while building the library you may need to make + * changes to ensure that pnglibconf.h records the calling convention used by + * your compiler. This may be very difficult - try using a different compiler + * to build the library! + */ +PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); +#endif + +/* Transform masks for the high-level interface */ +#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ +#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ +#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ +#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ +#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ +#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ +#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ +#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ +#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ +#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ +#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ +#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ +/* Added to libpng-1.2.34 */ +#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER +#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ +/* Added to libpng-1.4.0 */ +#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ +/* Added to libpng-1.5.4 */ +#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ +#if INT_MAX >= 0x8000 /* else this might break */ +#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ +#endif + +/* Flags for MNG supported features */ +#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 +#define PNG_FLAG_MNG_FILTER_64 0x04 +#define PNG_ALL_MNG_FEATURES 0x05 + +/* NOTE: prior to 1.5 these functions had no 'API' style declaration, + * this allowed the zlib default functions to be used on Windows + * platforms. In 1.5 the zlib default malloc (which just calls malloc and + * ignores the first argument) should be completely compatible with the + * following. + */ +typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, + png_alloc_size_t)); +typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); + +/* Section 4: exported functions + * Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng-manual.txt for the + * full explanation, see example.c for the summary. This just provides + * a simple one line description of the use of each function. + * + * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in + * pngconf.h and in the *.dfn files in the scripts directory. + * + * PNG_EXPORT(ordinal, type, name, (args)); + * + * ordinal: ordinal that is used while building + * *.def files. The ordinal value is only + * relevant when preprocessing png.h with + * the *.dfn files for building symbol table + * entries, and are removed by pngconf.h. + * type: return type of the function + * name: function name + * args: function arguments, with types + * + * When we wish to append attributes to a function prototype we use + * the PNG_EXPORTA() macro instead. + * + * PNG_EXPORTA(ordinal, type, name, (args), attributes); + * + * ordinal, type, name, and args: same as in PNG_EXPORT(). + * attributes: function attributes + */ + +/* Returns the version number of the library */ +PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); + +/* Tell lib we have already handled the first magic bytes. + * Handling more than 8 bytes from the beginning of the file is an error. + */ +PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); + +/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a + * PNG file. Returns zero if the supplied bytes match the 8-byte PNG + * signature, and non-zero otherwise. Having num_to_check == 0 or + * start > 7 will always fail (ie return non-zero). + */ +PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, + png_size_t num_to_check)); + +/* Simple signature checking function. This is the same as calling + * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). + */ +#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) + +/* Allocate and initialize png_ptr struct for reading, and any other memory. */ +PNG_EXPORTA(4, png_structp, png_create_read_struct, + (png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn), + PNG_ALLOCATED); + +/* Allocate and initialize png_ptr struct for writing, and any other memory */ +PNG_EXPORTA(5, png_structp, png_create_write_struct, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn), + PNG_ALLOCATED); + +PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, + (png_const_structrp png_ptr)); + +PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, + png_size_t size)); + +/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp + * match up. + */ +#ifdef PNG_SETJMP_SUPPORTED +/* This function returns the jmp_buf built in to *png_ptr. It must be + * supplied with an appropriate 'longjmp' function to use on that jmp_buf + * unless the default error function is overridden in which case NULL is + * acceptable. The size of the jmp_buf is checked against the actual size + * allocated by the library - the call will return NULL on a mismatch + * indicating an ABI mismatch. + */ +PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, + png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); +# define png_jmpbuf(png_ptr) \ + (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) +#endif +/* This function should be used by libpng applications in place of + * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it + * will use it; otherwise it will call PNG_ABORT(). This function was + * added in libpng-1.5.0. + */ +PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), + PNG_NORETURN); + +#ifdef PNG_READ_SUPPORTED +/* Reset the compression stream */ +PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); +#endif + +/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ +#ifdef PNG_USER_MEM_SUPPORTED +PNG_EXPORTA(11, png_structp, png_create_read_struct_2, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED); +PNG_EXPORTA(12, png_structp, png_create_write_struct_2, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED); +#endif + +/* Write the PNG file signature. */ +PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); + +/* Write a PNG chunk - size, type, (optional) data, CRC. */ +PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep + chunk_name, png_const_bytep data, png_size_t length)); + +/* Write the start of a PNG chunk - length and chunk name. */ +PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, + png_const_bytep chunk_name, png_uint_32 length)); + +/* Write the data of a PNG chunk started with png_write_chunk_start(). */ +PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, + png_const_bytep data, png_size_t length)); + +/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ +PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); + +/* Allocate and initialize the info structure */ +PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), + PNG_ALLOCATED); + +/* DEPRECATED: this function allowed init structures to be created using the + * default allocation method (typically malloc). Use is deprecated in 1.6.0 and + * the API will be removed in the future. + */ +PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, + png_size_t png_info_struct_size), PNG_DEPRECATED); + +/* Writes all the PNG information before the image. */ +PNG_EXPORT(20, void, png_write_info_before_PLTE, + (png_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(21, void, png_write_info, + (png_structrp png_ptr, png_const_inforp info_ptr)); + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the information before the actual image data. */ +PNG_EXPORT(22, void, png_read_info, + (png_structrp png_ptr, png_inforp info_ptr)); +#endif + +#ifdef PNG_TIME_RFC1123_SUPPORTED + /* Convert to a US string format: there is no localization support in this + * routine. The original implementation used a 29 character buffer in + * png_struct, this will be removed in future versions. + */ +#if PNG_LIBPNG_VER < 10700 +/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ +PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, + png_const_timep ptime),PNG_DEPRECATED); +#endif +PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], + png_const_timep ptime)); +#endif + +#ifdef PNG_CONVERT_tIME_SUPPORTED +/* Convert from a struct tm to png_time */ +PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, + const struct tm * ttime)); + +/* Convert from time_t to png_time. Uses gmtime() */ +PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); +#endif /* CONVERT_tIME */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ +PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); +PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); +PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); +PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); +#endif + +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion + * of a tRNS chunk if present. + */ +PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Use blue, green, red order for pixels. */ +PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +/* Expand the grayscale to 24-bit RGB if necessary. */ +PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +/* Reduce RGB to grayscale. */ +#define PNG_ERROR_ACTION_NONE 1 +#define PNG_ERROR_ACTION_WARN 2 +#define PNG_ERROR_ACTION_ERROR 3 +#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ + +PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, + int error_action, double red, double green)) +PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green)) + +PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp + png_ptr)); +#endif + +#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED +PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, + png_colorp palette)); +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED +/* How the alpha channel is interpreted - this affects how the color channels + * of a PNG file are returned to the calling application when an alpha channel, + * or a tRNS chunk in a palette file, is present. + * + * This has no effect on the way pixels are written into a PNG output + * datastream. The color samples in a PNG datastream are never premultiplied + * with the alpha samples. + * + * The default is to return data according to the PNG specification: the alpha + * channel is a linear measure of the contribution of the pixel to the + * corresponding composited pixel, and the color channels are unassociated + * (not premultiplied). The gamma encoded color channels must be scaled + * according to the contribution and to do this it is necessary to undo + * the encoding, scale the color values, perform the composition and reencode + * the values. This is the 'PNG' mode. + * + * The alternative is to 'associate' the alpha with the color information by + * storing color channel values that have been scaled by the alpha. + * image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes + * (the latter being the two common names for associated alpha color channels). + * + * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha + * value is equal to the maximum value. + * + * The final choice is to gamma encode the alpha channel as well. This is + * broken because, in practice, no implementation that uses this choice + * correctly undoes the encoding before handling alpha composition. Use this + * choice only if other serious errors in the software or hardware you use + * mandate it; the typical serious error is for dark halos to appear around + * opaque areas of the composited PNG image because of arithmetic overflow. + * + * The API function png_set_alpha_mode specifies which of these choices to use + * with an enumerated 'mode' value and the gamma of the required output: + */ +#define PNG_ALPHA_PNG 0 /* according to the PNG standard */ +#define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ +#define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ +#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ +#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ +#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ + +PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, + double output_gamma)) +PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, + int mode, png_fixed_point output_gamma)) +#endif + +#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) +/* The output_gamma value is a screen gamma in libpng terminology: it expresses + * how to decode the output values, not how they are encoded. + */ +#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ +#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ +#define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ +#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ +#endif + +/* The following are examples of calls to png_set_alpha_mode to achieve the + * required overall gamma correction and, where necessary, alpha + * premultiplication. + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); + * This is the default libpng handling of the alpha channel - it is not + * pre-multiplied into the color components. In addition the call states + * that the output is for a sRGB system and causes all PNG files without gAMA + * chunks to be assumed to be encoded using sRGB. + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); + * In this case the output is assumed to be something like an sRGB conformant + * display preceeded by a power-law lookup table of power 1.45. This is how + * early Mac systems behaved. + * + * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); + * This is the classic Jim Blinn approach and will work in academic + * environments where everything is done by the book. It has the shortcoming + * of assuming that input PNG data with no gamma information is linear - this + * is unlikely to be correct unless the PNG files where generated locally. + * Most of the time the output precision will be so low as to show + * significant banding in dark areas of the image. + * + * png_set_expand_16(pp); + * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); + * This is a somewhat more realistic Jim Blinn inspired approach. PNG files + * are assumed to have the sRGB encoding if not marked with a gamma value and + * the output is always 16 bits per component. This permits accurate scaling + * and processing of the data. If you know that your input PNG files were + * generated locally you might need to replace PNG_DEFAULT_sRGB with the + * correct value for your system. + * + * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); + * If you just need to composite the PNG image onto an existing background + * and if you control the code that does this you can use the optimization + * setting. In this case you just copy completely opaque pixels to the + * output. For pixels that are not completely transparent (you just skip + * those) you do the composition math using png_composite or png_composite_16 + * below then encode the resultant 8-bit or 16-bit values to match the output + * encoding. + * + * Other cases + * If neither the PNG nor the standard linear encoding work for you because + * of the software or hardware you use then you have a big problem. The PNG + * case will probably result in halos around the image. The linear encoding + * will probably result in a washed out, too bright, image (it's actually too + * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably + * substantially reduce the halos. Alternatively try: + * + * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); + * This option will also reduce the halos, but there will be slight dark + * halos round the opaque parts of the image where the background is light. + * In the OPTIMIZED mode the halos will be light halos where the background + * is dark. Take your pick - the halos are unavoidable unless you can get + * your hardware/software fixed! (The OPTIMIZED approach is slightly + * faster.) + * + * When the default gamma of PNG files doesn't match the output gamma. + * If you have PNG files with no gamma information png_set_alpha_mode allows + * you to provide a default gamma, but it also sets the ouput gamma to the + * matching value. If you know your PNG files have a gamma that doesn't + * match the output you can take advantage of the fact that + * png_set_alpha_mode always sets the output gamma but only sets the PNG + * default if it is not already set: + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); + * The first call sets both the default and the output gamma values, the + * second call overrides the output gamma without changing the default. This + * is easier than achieving the same effect with png_set_gamma. You must use + * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will + * fire if more than one call to png_set_alpha_mode and png_set_background is + * made in the same read operation, however multiple calls with PNG_ALPHA_PNG + * are ignored. + */ + +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */ +PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, + int flags)); +/* The values of the PNG_FILLER_ defines should NOT be changed */ +# define PNG_FILLER_BEFORE 0 +# define PNG_FILLER_AFTER 1 +/* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */ +PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, + png_uint_32 filler, int flags)); +#endif /* READ_FILLER || WRITE_FILLER */ + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swap bytes in 16-bit depth files. */ +PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ +PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ + defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Swap packing order of pixels in bytes. */ +PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Converts files to legal bit depths. */ +PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p + true_bits)); +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Have the code handle the interlacing. Returns the number of passes. + * MUST be called before png_read_update_info or png_start_read_image, + * otherwise it will not have the desired effect. Note that it is still + * necessary to call png_read_row or png_read_rows png_get_image_height + * times for each pass. +*/ +PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +/* Invert monochrome files */ +PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); +#endif + +#ifdef PNG_READ_BACKGROUND_SUPPORTED +/* Handle alpha and tRNS by replacing with a background color. Prior to + * libpng-1.5.4 this API must not be called before the PNG file header has been + * read. Doing so will result in unexpected behavior and possible warnings or + * errors if the PNG file contains a bKGD chunk. + */ +PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)) +PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, png_fixed_point background_gamma)) +#endif +#ifdef PNG_READ_BACKGROUND_SUPPORTED +# define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +# define PNG_BACKGROUND_GAMMA_SCREEN 1 +# define PNG_BACKGROUND_GAMMA_FILE 2 +# define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#endif + +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +/* Scale a 16-bit depth file down to 8-bit, accurately. */ +PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); +#endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED +#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */ +/* Strip the second byte of information from a 16-bit depth file. */ +PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED +/* Turn on quantizing, and reduce the palette to the number of colors + * available. + */ +PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_const_uint_16p histogram, int full_quantize)); +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* The threshold on gamma processing is configurable but hard-wired into the + * library. The following is the floating point variant. + */ +#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) + +/* Handle gamma correction. Screen_gamma=(display_exponent). + * NOTE: this API simply sets the screen and file gamma values. It will + * therefore override the value for gamma in a PNG file if it is called after + * the file header has been read - use with care - call before reading the PNG + * file for best results! + * + * These routines accept the same gamma values as png_set_alpha_mode (described + * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either + * API (floating point or fixed.) Notice, however, that the 'file_gamma' value + * is the inverse of a 'screen gamma' value. + */ +PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, + double screen_gamma, double override_file_gamma)) +PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, + png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) +#endif + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +/* Set how many lines between output flushes - 0 for no flushing */ +PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); +/* Flush the current PNG output buffer */ +PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); +#endif + +/* Optional update palette with requested transformations */ +PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); + +/* Optional call to update the users info structure */ +PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, + png_inforp info_ptr)); + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read one or more rows of image data. */ +PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows)); +#endif + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read a row of data. */ +PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, + png_bytep display_row)); +#endif + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the whole image into memory at once. */ +PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); +#endif + +/* Write a row of image data */ +PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, + png_const_bytep row)); + +/* Write a few rows of image data: (*row) is not written; however, the type + * is declared as writeable to maintain compatibility with previous versions + * of libpng and to allow the 'display_row' array from read_rows to be passed + * unchanged to write_rows. + */ +PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, + png_uint_32 num_rows)); + +/* Write the image data */ +PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); + +/* Write the end of the PNG file. */ +PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, + png_inforp info_ptr)); + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the end of the PNG file. */ +PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); +#endif + +/* Free any memory associated with the png_info_struct */ +PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, + png_infopp info_ptr_ptr)); + +/* Free any memory associated with the png_struct and the png_info_structs */ +PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, + png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); + +/* Free any memory associated with the png_struct and the png_info_structs */ +PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, + png_infopp info_ptr_ptr)); + +/* Set the libpng method of handling chunk CRC errors */ +PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, + int ancil_action)); + +/* Values for png_set_crc_action() say how to handle CRC errors in + * ancillary and critical chunks, and whether to use the data contained + * therein. Note that it is impossible to "discard" data in a critical + * chunk. For versions prior to 0.90, the action was always error/quit, + * whereas in version 0.90 and later, the action for CRC errors in ancillary + * chunks is warn/discard. These values should NOT be changed. + * + * value action:critical action:ancillary + */ +#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ +#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ +#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ +#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ +#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ +#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ + +#ifdef PNG_WRITE_SUPPORTED +/* These functions give the user control over the scan-line filtering in + * libpng and the compression methods used by zlib. These functions are + * mainly useful for testing, as the defaults should work with most users. + * Those users who are tight on memory or want faster performance at the + * expense of compression can modify them. See the compression library + * header file (zlib.h) for an explination of the compression functions. + */ + +/* Set the filtering method(s) used by libpng. Currently, the only valid + * value for "method" is 0. + */ +PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, + int filters)); +#endif /* WRITE */ + +/* Flags for png_set_filter() to say which filters to use. The flags + * are chosen so that they don't conflict with real filter types + * below, in case they are supplied instead of the #defined constants. + * These values should NOT be changed. + */ +#define PNG_NO_FILTERS 0x00 +#define PNG_FILTER_NONE 0x08 +#define PNG_FILTER_SUB 0x10 +#define PNG_FILTER_UP 0x20 +#define PNG_FILTER_AVG 0x40 +#define PNG_FILTER_PAETH 0x80 +#define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP) +#define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH) + +/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. + * These defines should NOT be changed. + */ +#define PNG_FILTER_VALUE_NONE 0 +#define PNG_FILTER_VALUE_SUB 1 +#define PNG_FILTER_VALUE_UP 2 +#define PNG_FILTER_VALUE_AVG 3 +#define PNG_FILTER_VALUE_PAETH 4 +#define PNG_FILTER_VALUE_LAST 5 + +#ifdef PNG_WRITE_SUPPORTED +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */ +PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, + int heuristic_method, int num_weights, png_const_doublep filter_weights, + png_const_doublep filter_costs)) +PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, + (png_structrp png_ptr, int heuristic_method, int num_weights, + png_const_fixed_point_p filter_weights, + png_const_fixed_point_p filter_costs)) +#endif /* WRITE_WEIGHTED_FILTER */ + +/* The following are no longer used and will be removed from libpng-1.7: */ +#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ +#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ +#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ +#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ + +/* Set the library compression level. Currently, valid values range from + * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 + * (0 - no compression, 9 - "maximal" compression). Note that tests have + * shown that zlib compression levels 3-6 usually perform as well as level 9 + * for PNG images, and do considerably fewer caclulations. In the future, + * these values may not correspond directly to the zlib compression levels. + */ +#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED +PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, + int level)); + +PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, + int mem_level)); + +PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, + int strategy)); + +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, + int window_bits)); + +PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, + int method)); +#endif /* WRITE_CUSTOMIZE_COMPRESSION */ + +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED +/* Also set zlib parameters for compressing non-IDAT chunks */ +PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, + int level)); + +PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, + int mem_level)); + +PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, + int strategy)); + +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +PNG_EXPORT(225, void, png_set_text_compression_window_bits, + (png_structrp png_ptr, int window_bits)); + +PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, + int method)); +#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */ +#endif /* WRITE */ + +/* These next functions are called for input/output, memory, and error + * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, + * and call standard C I/O routines such as fread(), fwrite(), and + * fprintf(). These functions can be made to use other I/O routines + * at run time for those applications that need to handle I/O in a + * different manner by calling png_set_???_fn(). See libpng-manual.txt for + * more information. + */ + +#ifdef PNG_STDIO_SUPPORTED +/* Initialize the input/output for the PNG file to the default functions. */ +PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); +#endif + +/* Replace the (error and abort), and warning functions with user + * supplied functions. If no messages are to be printed you must still + * write and use replacement functions. The replacement error_fn should + * still do a longjmp to the last setjmp location if you are using this + * method of error handling. If error_fn or warning_fn is NULL, the + * default function will be used. + */ + +PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); + +/* Return the user pointer associated with the error functions */ +PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); + +/* Replace the default data output functions with a user supplied one(s). + * If buffered output is not used, then output_flush_fn can be set to NULL. + * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time + * output_flush_fn will be ignored (and thus can be NULL). + * It is probably a mistake to use NULL for output_flush_fn if + * write_data_fn is not also NULL unless you have built libpng with + * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's + * default flush function, which uses the standard *FILE structure, will + * be used. + */ +PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, + png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); + +/* Replace the default data input function with a user supplied one. */ +PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, + png_rw_ptr read_data_fn)); + +/* Return the user pointer associated with the I/O functions */ +PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); + +PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, + png_read_status_ptr read_row_fn)); + +PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_USER_MEM_SUPPORTED +/* Replace the default memory allocation functions with user supplied one(s). */ +PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +/* Return the user pointer associated with the memory functions */ +PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); +#endif + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, + png_user_transform_ptr read_user_transform_fn)); +#endif + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, + png_user_transform_ptr write_user_transform_fn)); +#endif + +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED +PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, + png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); +/* Return the user pointer associated with the user transform functions */ +PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, + (png_const_structrp png_ptr)); +#endif + +#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED +/* Return information about the row currently being processed. Note that these + * APIs do not fail but will return unexpected results if called outside a user + * transform callback. Also note that when transforming an interlaced image the + * row number is the row number within the sub-image of the interlace pass, so + * the value will increase to the height of the sub-image (not the full image) + * then reset to 0 for the next pass. + * + * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to + * find the output pixel (x,y) given an interlaced sub-image pixel + * (row,col,pass). (See below for these macros.) + */ +PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); +PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); +#endif + +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED +/* This callback is called only for *unknown* chunks. If + * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known + * chunks to be treated as unknown, however in this case the callback must do + * any processing required by the chunk (e.g. by calling the appropriate + * png_set_ APIs.) + * + * There is no write support - on write, by default, all the chunks in the + * 'unknown' list are written in the specified position. + * + * The integer return from the callback function is interpreted thus: + * + * negative: An error occurred; png_chunk_error will be called. + * zero: The chunk was not handled, the chunk will be saved. A critical + * chunk will cause an error at this point unless it is to be saved. + * positive: The chunk was handled, libpng will ignore/discard it. + * + * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about + * how this behavior will change in libpng 1.7 + */ +PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +/* Sets the function callbacks for the push reader, and a pointer to a + * user-defined structure available to the callback functions. + */ +PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, + png_voidp progressive_ptr, png_progressive_info_ptr info_fn, + png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); + +/* Returns the user pointer associated with the push read functions */ +PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, + (png_const_structrp png_ptr)); + +/* Function to be called when data becomes available */ +PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, + png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)); + +/* A function which may be called *only* within png_process_data to stop the + * processing of any more data. The function returns the number of bytes + * remaining, excluding any that libpng has cached internally. A subsequent + * call to png_process_data must supply these bytes again. If the argument + * 'save' is set to true the routine will first save all the pending data and + * will always return 0. + */ +PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); + +/* A function which may be called *only* outside (after) a call to + * png_process_data. It returns the number of bytes of data to skip in the + * input. Normally it will return 0, but if it returns a non-zero value the + * application must skip than number of bytes of input data and pass the + * following data to the next call to png_process_data. + */ +PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); + +/* Function that combines rows. 'new_row' is a flag that should come from + * the callback and be non-NULL if anything needs to be done; the library + * stores its own version of the new data internally and ignores the passed + * in value. + */ +PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, + png_bytep old_row, png_const_bytep new_row)); +#endif /* PROGRESSIVE_READ */ + +PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED); +/* Added at libpng version 1.4.0 */ +PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED); + +/* Added at libpng version 1.2.4 */ +PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED); + +/* Frees a pointer allocated by png_malloc() */ +PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); + +/* Free data that was allocated internally */ +PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_32 free_me, int num)); + +/* Reassign responsibility for freeing existing data, whether allocated + * by libpng or by the application; this works on the png_info structure passed + * in, it does not change the state for other png_info structures. + * + * It is unlikely that this function works correctly as of 1.6.0 and using it + * may result either in memory leaks or double free of allocated data. + */ +PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr, + png_inforp info_ptr, int freer, png_uint_32 mask)); + +/* Assignments for png_data_freer */ +#define PNG_DESTROY_WILL_FREE_DATA 1 +#define PNG_SET_WILL_FREE_DATA 1 +#define PNG_USER_WILL_FREE_DATA 2 +/* Flags for png_ptr->free_me and info_ptr->free_me */ +#define PNG_FREE_HIST 0x0008U +#define PNG_FREE_ICCP 0x0010U +#define PNG_FREE_SPLT 0x0020U +#define PNG_FREE_ROWS 0x0040U +#define PNG_FREE_PCAL 0x0080U +#define PNG_FREE_SCAL 0x0100U +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_FREE_UNKN 0x0200U +#endif +/* PNG_FREE_LIST 0x0400U removed in 1.6.0 because it is ignored */ +#define PNG_FREE_PLTE 0x1000U +#define PNG_FREE_TRNS 0x2000U +#define PNG_FREE_TEXT 0x4000U +#define PNG_FREE_EXIF 0x8000U /* Added at libpng-1.6.31 */ +#define PNG_FREE_ALL 0xffffU +#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ + +#ifdef PNG_USER_MEM_SUPPORTED +PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); +PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, + png_voidp ptr), PNG_DEPRECATED); +#endif + +#ifdef PNG_ERROR_TEXT_SUPPORTED +/* Fatal error in PNG image of libpng - can't continue */ +PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, + png_const_charp error_message), PNG_NORETURN); + +/* The same, but the chunk name is prepended to the error string. */ +PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, + png_const_charp error_message), PNG_NORETURN); + +#else +/* Fatal error in PNG image of libpng - can't continue */ +PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); +# define png_error(s1,s2) png_err(s1) +# define png_chunk_error(s1,s2) png_err(s1) +#endif + +#ifdef PNG_WARNINGS_SUPPORTED +/* Non-fatal error in libpng. Can continue, but may have a problem. */ +PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, + png_const_charp warning_message)); + +/* Non-fatal error in libpng, chunk name is prepended to message. */ +PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, + png_const_charp warning_message)); +#else +# define png_warning(s1,s2) ((void)(s1)) +# define png_chunk_warning(s1,s2) ((void)(s1)) +#endif + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +/* Benign error in libpng. Can continue, but may have a problem. + * User can choose whether to handle as a fatal error or as a warning. */ +PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, + png_const_charp warning_message)); + +#ifdef PNG_READ_SUPPORTED +/* Same, chunk name is prepended to message (only during read) */ +PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, + png_const_charp warning_message)); +#endif + +PNG_EXPORT(109, void, png_set_benign_errors, + (png_structrp png_ptr, int allowed)); +#else +# ifdef PNG_ALLOW_BENIGN_ERRORS +# define png_benign_error png_warning +# define png_chunk_benign_error png_chunk_warning +# else +# define png_benign_error png_error +# define png_chunk_benign_error png_chunk_error +# endif +#endif + +/* The png_set_ functions are for storing values in the png_info_struct. + * Similarly, the png_get_ calls are used to read values from the + * png_info_struct, either storing the parameters in the passed variables, or + * setting pointers into the png_info_struct where the data is stored. The + * png_get_ functions return a non-zero value if the data was available + * in info_ptr, or return zero and do not change any of the parameters if the + * data was not available. + * + * These functions should be used instead of directly accessing png_info + * to avoid problems with future changes in the size and internal layout of + * png_info_struct. + */ +/* Returns "flag" if chunk data is valid in info_ptr. */ +PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 flag)); + +/* Returns number of bytes needed to hold a transformed row. */ +PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +#ifdef PNG_INFO_IMAGE_SUPPORTED +/* Returns row_pointers, which is an array of pointers to scanlines that was + * returned from png_read_png(). + */ +PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +/* Set row_pointers, which is an array of pointers to scanlines for use + * by png_write_png(). + */ +PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, + png_inforp info_ptr, png_bytepp row_pointers)); +#endif + +/* Returns number of color channels in image. */ +PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Returns image width in pixels. */ +PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +/* Returns image height in pixels. */ +PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +/* Returns image bit_depth. */ +PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +/* Returns image color_type. */ +PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +/* Returns image filter_type. */ +PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +/* Returns image interlace_type. */ +PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +/* Returns image compression_type. */ +PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + +/* Returns image resolution in pixels per meter, from pHYs chunk data. */ +PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); + +/* Returns pixel aspect ratio, computed from pHYs chunk data. */ +PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) +PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) + +/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ +PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); + +#endif /* EASY_ACCESS */ + +#ifdef PNG_READ_SUPPORTED +/* Returns pointer to signature string read from PNG header */ +PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); +#endif + +#ifdef PNG_bKGD_SUPPORTED +PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, + png_inforp info_ptr, png_color_16p *background)); +#endif + +#ifdef PNG_bKGD_SUPPORTED +PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_color_16p background)); +#endif + +#ifdef PNG_cHRM_SUPPORTED +PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, + png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)) +PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, + png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, + double *green_X, double *green_Y, double *green_Z, double *blue_X, + double *blue_Y, double *blue_Z)) +PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_white_x, png_fixed_point *int_white_y, + png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, + png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) +PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_red_X, png_fixed_point *int_red_Y, + png_fixed_point *int_red_Z, png_fixed_point *int_green_X, + png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, + png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, + png_fixed_point *int_blue_Z)) +#endif + +#ifdef PNG_cHRM_SUPPORTED +PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, + png_inforp info_ptr, + double white_x, double white_y, double red_x, double red_y, double green_x, + double green_y, double blue_x, double blue_y)) +PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, + png_inforp info_ptr, double red_X, double red_Y, double red_Z, + double green_X, double green_Y, double green_Z, double blue_X, + double blue_Y, double blue_Z)) +PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, png_fixed_point int_white_x, + png_fixed_point int_white_y, png_fixed_point int_red_x, + png_fixed_point int_red_y, png_fixed_point int_green_x, + png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)) +PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, + png_fixed_point int_red_Z, png_fixed_point int_green_X, + png_fixed_point int_green_Y, png_fixed_point int_green_Z, + png_fixed_point int_blue_X, png_fixed_point int_blue_Y, + png_fixed_point int_blue_Z)) +#endif + +#ifdef PNG_eXIf_SUPPORTED +PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr, + png_inforp info_ptr, png_bytep *exif)); +PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr, + png_inforp info_ptr, const png_bytep exif)); + +PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif)); +PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr, + png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif)); +#endif + +#ifdef PNG_gAMA_SUPPORTED +PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, + png_const_inforp info_ptr, double *file_gamma)) +PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_file_gamma)) +#endif + +#ifdef PNG_gAMA_SUPPORTED +PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, + png_inforp info_ptr, double file_gamma)) +PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, png_fixed_point int_file_gamma)) +#endif + +#ifdef PNG_hIST_SUPPORTED +PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_16p *hist)); +PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_uint_16p hist)); +#endif + +PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); + +PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); + +#ifdef PNG_oFFs_SUPPORTED +PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, + int *unit_type)); +#endif + +#ifdef PNG_oFFs_SUPPORTED +PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, + png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); +#endif + +#ifdef PNG_pCAL_SUPPORTED +PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, + png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, + png_int_32 *X1, int *type, int *nparams, png_charp *units, + png_charpp *params)); +#endif + +#ifdef PNG_pCAL_SUPPORTED +PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_const_charp units, png_charpp params)); +#endif + +#ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, + int *unit_type)); +#endif + +#ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#endif + +PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, + png_inforp info_ptr, png_colorp *palette, int *num_palette)); + +PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, + png_inforp info_ptr, png_const_colorp palette, int num_palette)); + +#ifdef PNG_sBIT_SUPPORTED +PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_color_8p *sig_bit)); +#endif + +#ifdef PNG_sBIT_SUPPORTED +PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_color_8p sig_bit)); +#endif + +#ifdef PNG_sRGB_SUPPORTED +PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, + png_const_inforp info_ptr, int *file_srgb_intent)); +#endif + +#ifdef PNG_sRGB_SUPPORTED +PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, + png_inforp info_ptr, int srgb_intent)); +PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, + png_inforp info_ptr, int srgb_intent)); +#endif + +#ifdef PNG_iCCP_SUPPORTED +PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, + png_inforp info_ptr, png_charpp name, int *compression_type, + png_bytepp profile, png_uint_32 *proflen)); +#endif + +#ifdef PNG_iCCP_SUPPORTED +PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_charp name, int compression_type, + png_const_bytep profile, png_uint_32 proflen)); +#endif + +#ifdef PNG_sPLT_SUPPORTED +PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_sPLT_tpp entries)); +#endif + +#ifdef PNG_sPLT_SUPPORTED +PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); +#endif + +#ifdef PNG_TEXT_SUPPORTED +/* png_get_text also returns the number of text chunks in *num_text */ +PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, + png_inforp info_ptr, png_textp *text_ptr, int *num_text)); +#endif + +/* Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + +#ifdef PNG_TEXT_SUPPORTED +PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_textp text_ptr, int num_text)); +#endif + +#ifdef PNG_tIME_SUPPORTED +PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, + png_inforp info_ptr, png_timep *mod_time)); +#endif + +#ifdef PNG_tIME_SUPPORTED +PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_timep mod_time)); +#endif + +#ifdef PNG_tRNS_SUPPORTED +PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, + png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, + png_color_16p *trans_color)); +#endif + +#ifdef PNG_tRNS_SUPPORTED +PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, + png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, + png_const_color_16p trans_color)); +#endif + +#ifdef PNG_sCAL_SUPPORTED +PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, + png_const_inforp info_ptr, int *unit, double *width, double *height)) +#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ + defined(PNG_FLOATING_POINT_SUPPORTED) +/* NOTE: this API is currently implemented using floating point arithmetic, + * consequently it can only be used on systems with floating point support. + * In any case the range of values supported by png_fixed_point is small and it + * is highly recommended that png_get_sCAL_s be used instead. + */ +PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, + png_fixed_point *width, png_fixed_point *height)) +#endif +PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, + (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, + png_charpp swidth, png_charpp sheight)); + +PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, + png_inforp info_ptr, int unit, double width, double height)) +PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, int unit, png_fixed_point width, + png_fixed_point height)) +PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, + png_inforp info_ptr, int unit, + png_const_charp swidth, png_const_charp sheight)); +#endif /* sCAL */ + +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED +/* Provide the default handling for all unknown chunks or, optionally, for + * specific unknown chunks. + * + * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was + * ignored and the default was used, the per-chunk setting only had an effect on + * write. If you wish to have chunk-specific handling on read in code that must + * work on earlier versions you must use a user chunk callback to specify the + * desired handling (keep or discard.) + * + * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The + * parameter is interpreted as follows: + * + * READ: + * PNG_HANDLE_CHUNK_AS_DEFAULT: + * Known chunks: do normal libpng processing, do not keep the chunk (but + * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) + * Unknown chunks: for a specific chunk use the global default, when used + * as the default discard the chunk data. + * PNG_HANDLE_CHUNK_NEVER: + * Discard the chunk data. + * PNG_HANDLE_CHUNK_IF_SAFE: + * Keep the chunk data if the chunk is not critical else raise a chunk + * error. + * PNG_HANDLE_CHUNK_ALWAYS: + * Keep the chunk data. + * + * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, + * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent + * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks + * it simply resets the behavior to the libpng default. + * + * INTERACTION WTIH USER CHUNK CALLBACKS: + * The per-chunk handling is always used when there is a png_user_chunk_ptr + * callback and the callback returns 0; the chunk is then always stored *unless* + * it is critical and the per-chunk setting is other than ALWAYS. Notice that + * the global default is *not* used in this case. (In effect the per-chunk + * value is incremented to at least IF_SAFE.) + * + * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and + * per-chunk defaults will be honored. If you want to preserve the current + * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE + * as the default - if you don't do this libpng 1.6 will issue a warning. + * + * If you want unhandled unknown chunks to be discarded in libpng 1.6 and + * earlier simply return '1' (handled). + * + * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: + * If this is *not* set known chunks will always be handled by libpng and + * will never be stored in the unknown chunk list. Known chunks listed to + * png_set_keep_unknown_chunks will have no effect. If it is set then known + * chunks listed with a keep other than AS_DEFAULT will *never* be processed + * by libpng, in addition critical chunks must either be processed by the + * callback or saved. + * + * The IHDR and IEND chunks must not be listed. Because this turns off the + * default handling for chunks that would otherwise be recognized the + * behavior of libpng transformations may well become incorrect! + * + * WRITE: + * When writing chunks the options only apply to the chunks specified by + * png_set_unknown_chunks (below), libpng will *always* write known chunks + * required by png_set_ calls and will always write the core critical chunks + * (as required for PLTE). + * + * Each chunk in the png_set_unknown_chunks list is looked up in the + * png_set_keep_unknown_chunks list to find the keep setting, this is then + * interpreted as follows: + * + * PNG_HANDLE_CHUNK_AS_DEFAULT: + * Write safe-to-copy chunks and write other chunks if the global + * default is set to _ALWAYS, otherwise don't write this chunk. + * PNG_HANDLE_CHUNK_NEVER: + * Do not write the chunk. + * PNG_HANDLE_CHUNK_IF_SAFE: + * Write the chunk if it is safe-to-copy, otherwise do not write it. + * PNG_HANDLE_CHUNK_ALWAYS: + * Write the chunk. + * + * Note that the default behavior is effectively the opposite of the read case - + * in read unknown chunks are not stored by default, in write they are written + * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different + * - on write the safe-to-copy bit is checked, on read the critical bit is + * checked and on read if the chunk is critical an error will be raised. + * + * num_chunks: + * =========== + * If num_chunks is positive, then the "keep" parameter specifies the manner + * for handling only those chunks appearing in the chunk_list array, + * otherwise the chunk list array is ignored. + * + * If num_chunks is 0 the "keep" parameter specifies the default behavior for + * unknown chunks, as described above. + * + * If num_chunks is negative, then the "keep" parameter specifies the manner + * for handling all unknown chunks plus all chunks recognized by libpng + * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to + * be processed by libpng. + */ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, + int keep, png_const_bytep chunk_list, int num_chunks)); +#endif /* HANDLE_AS_UNKNOWN */ + +/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; + * the result is therefore true (non-zero) if special handling is required, + * false for the default handling. + */ +PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, + png_const_bytep chunk_name)); +#endif /* SET_UNKNOWN_CHUNKS */ + +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_unknown_chunkp unknowns, + int num_unknowns)); + /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added + * unknowns to the location currently stored in the png_struct. This is + * invariably the wrong value on write. To fix this call the following API + * for each chunk in the list with the correct location. If you know your + * code won't be compiled on earlier versions you can rely on + * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing + * the correct thing. + */ + +PNG_EXPORT(175, void, png_set_unknown_chunk_location, + (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); + +PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, + png_inforp info_ptr, png_unknown_chunkpp entries)); +#endif + +/* Png_free_data() will turn off the "valid" flag for anything it frees. + * If you need to turn it off for a chunk that your application has freed, + * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); + */ +PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, + png_inforp info_ptr, int mask)); + +#ifdef PNG_INFO_IMAGE_SUPPORTED +/* The "params" pointer is currently not used and is for future expansion. */ +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, + int transforms, png_voidp params)); +#endif +#ifdef PNG_WRITE_SUPPORTED +PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, + int transforms, png_voidp params)); +#endif +#endif + +PNG_EXPORT(180, png_const_charp, png_get_copyright, + (png_const_structrp png_ptr)); +PNG_EXPORT(181, png_const_charp, png_get_header_ver, + (png_const_structrp png_ptr)); +PNG_EXPORT(182, png_const_charp, png_get_header_version, + (png_const_structrp png_ptr)); +PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, + (png_const_structrp png_ptr)); + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, + png_uint_32 mng_features_permitted)); +#endif + +/* For use in png_set_keep_unknown, added to version 1.2.6 */ +#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 +#define PNG_HANDLE_CHUNK_NEVER 1 +#define PNG_HANDLE_CHUNK_IF_SAFE 2 +#define PNG_HANDLE_CHUNK_ALWAYS 3 +#define PNG_HANDLE_CHUNK_LAST 4 + +/* Strip the prepended error numbers ("#nnn ") from error and warning + * messages before passing them to the error or warning handler. + */ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, + png_uint_32 strip_mode)); +#endif + +/* Added in libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, + png_uint_32 user_width_max, png_uint_32 user_height_max)); +PNG_EXPORT(187, png_uint_32, png_get_user_width_max, + (png_const_structrp png_ptr)); +PNG_EXPORT(188, png_uint_32, png_get_user_height_max, + (png_const_structrp png_ptr)); +/* Added in libpng-1.4.0 */ +PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, + png_uint_32 user_chunk_cache_max)); +PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, + (png_const_structrp png_ptr)); +/* Added in libpng-1.4.1 */ +PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, + png_alloc_size_t user_chunk_cache_max)); +PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, + (png_const_structrp png_ptr)); +#endif + +#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) +PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); + +PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); + +PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); + +PNG_FP_EXPORT(196, float, png_get_x_offset_inches, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) +#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ +PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) +#endif + +PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, + png_const_inforp info_ptr)) +#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ +PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) +#endif + +# ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, + int *unit_type)); +# endif /* pHYs */ +#endif /* INCH_CONVERSIONS */ + +/* Added in libpng-1.4.0 */ +#ifdef PNG_IO_STATE_SUPPORTED +PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); + +/* Removed from libpng 1.6; use png_get_io_chunk_type. */ +PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), + PNG_DEPRECATED) + +PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, + (png_const_structrp png_ptr)); + +/* The flags returned by png_get_io_state() are the following: */ +# define PNG_IO_NONE 0x0000 /* no I/O at this moment */ +# define PNG_IO_READING 0x0001 /* currently reading */ +# define PNG_IO_WRITING 0x0002 /* currently writing */ +# define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ +# define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ +# define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ +# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ +# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ +# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ +#endif /* IO_STATE */ + +/* Interlace support. The following macros are always defined so that if + * libpng interlace handling is turned off the macros may be used to handle + * interlaced images within the application. + */ +#define PNG_INTERLACE_ADAM7_PASSES 7 + +/* Two macros to return the first row and first column of the original, + * full, image which appears in a given pass. 'pass' is in the range 0 + * to 6 and the result is in the range 0 to 7. + */ +#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) +#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) + +/* A macro to return the offset between pixels in the output row for a pair of + * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that + * follows. Note that ROW_OFFSET is the offset from one row to the next whereas + * COL_OFFSET is from one column to the next, within a row. + */ +#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) +#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) + +/* Two macros to help evaluate the number of rows or columns in each + * pass. This is expressed as a shift - effectively log2 of the number or + * rows or columns in each 8x8 tile of the original image. + */ +#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) +#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) + +/* Hence two macros to determine the number of rows or columns in a given + * pass of an image given its height or width. In fact these macros may + * return non-zero even though the sub-image is empty, because the other + * dimension may be empty for a small image. + */ +#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) +#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) + +/* For the reader row callbacks (both progressive and sequential) it is + * necessary to find the row in the output image given a row in an interlaced + * image, so two more macros: + */ +#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ + (((y_in)<>(((7-(off))-(pass))<<2)) & 0xF) | \ + ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) + +#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ + ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) +#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ + ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) + +#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +/* With these routines we avoid an integer divide, which will be slower on + * most machines. However, it does take more operations than the corresponding + * divide method, so it may be slower on a few RISC systems. There are two + * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. + * + * Note that the rounding factors are NOT supposed to be the same! 128 and + * 32768 are correct for the NODIV code; 127 and 32767 are correct for the + * standard method. + * + * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] + */ + + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + +# define png_composite(composite, fg, alpha, bg) \ + { \ + png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ + * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 \ + - (png_uint_16)(alpha)) + 128); \ + (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \ + } + +# define png_composite_16(composite, fg, alpha, bg) \ + { \ + png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ + * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(65535 \ + - (png_uint_32)(alpha)) + 32768); \ + (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \ + } + +#else /* Standard method using integer division */ + +# define png_composite(composite, fg, alpha, bg) \ + (composite) = \ + (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + 127) / 255)) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = \ + (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ + 32767) / 65535)) +#endif /* READ_COMPOSITE_NODIV */ + +#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); +PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); +PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); +#endif + +PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, + png_const_bytep buf)); +/* No png_get_int_16 -- may be added if there's a real need for it. */ + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); +#endif +#ifdef PNG_SAVE_INT_32_SUPPORTED +PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); +#endif + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); +/* No png_save_int_16 -- may be added if there's a real need for it. */ +#endif + +#ifdef PNG_USE_READ_MACROS +/* Inline macros to do direct reads of bytes from the input buffer. + * The png_get_int_32() routine assumes we are using two's complement + * format for negative values, which is almost certainly true. + */ +# define PNG_get_uint_32(buf) \ + (((png_uint_32)(*(buf)) << 24) + \ + ((png_uint_32)(*((buf) + 1)) << 16) + \ + ((png_uint_32)(*((buf) + 2)) << 8) + \ + ((png_uint_32)(*((buf) + 3)))) + + /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the + * function) incorrectly returned a value of type png_uint_32. + */ +# define PNG_get_uint_16(buf) \ + ((png_uint_16) \ + (((unsigned int)(*(buf)) << 8) + \ + ((unsigned int)(*((buf) + 1))))) + +# define PNG_get_int_32(buf) \ + ((png_int_32)((*(buf) & 0x80) \ + ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \ + : (png_int_32)png_get_uint_32(buf))) + +/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, + * but defining a macro name prefixed with PNG_PREFIX. + */ +# ifndef PNG_PREFIX +# define png_get_uint_32(buf) PNG_get_uint_32(buf) +# define png_get_uint_16(buf) PNG_get_uint_16(buf) +# define png_get_int_32(buf) PNG_get_int_32(buf) +# endif +#else +# ifdef PNG_PREFIX + /* No macros; revert to the (redefined) function */ +# define PNG_get_uint_32 (png_get_uint_32) +# define PNG_get_uint_16 (png_get_uint_16) +# define PNG_get_int_32 (png_get_int_32) +# endif +#endif + +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED +PNG_EXPORT(242, void, png_set_check_for_invalid_index, + (png_structrp png_ptr, int allowed)); +# ifdef PNG_GET_PALETTE_MAX_SUPPORTED +PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, + png_const_infop info_ptr)); +# endif +#endif /* CHECK_FOR_INVALID_INDEX */ + +/******************************************************************************* + * Section 5: SIMPLIFIED API + ******************************************************************************* + * + * Please read the documentation in libpng-manual.txt (TODO: write said + * documentation) if you don't understand what follows. + * + * The simplified API hides the details of both libpng and the PNG file format + * itself. It allows PNG files to be read into a very limited number of + * in-memory bitmap formats or to be written from the same formats. If these + * formats do not accomodate your needs then you can, and should, use the more + * sophisticated APIs above - these support a wide variety of in-memory formats + * and a wide variety of sophisticated transformations to those formats as well + * as a wide variety of APIs to manipulate ancillary information. + * + * To read a PNG file using the simplified API: + * + * 1) Declare a 'png_image' structure (see below) on the stack, set the + * version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL + * (this is REQUIRED, your program may crash if you don't do it.) + * 2) Call the appropriate png_image_begin_read... function. + * 3) Set the png_image 'format' member to the required sample format. + * 4) Allocate a buffer for the image and, if required, the color-map. + * 5) Call png_image_finish_read to read the image and, if required, the + * color-map into your buffers. + * + * There are no restrictions on the format of the PNG input itself; all valid + * color types, bit depths, and interlace methods are acceptable, and the + * input image is transformed as necessary to the requested in-memory format + * during the png_image_finish_read() step. The only caveat is that if you + * request a color-mapped image from a PNG that is full-color or makes + * complex use of an alpha channel the transformation is extremely lossy and the + * result may look terrible. + * + * To write a PNG file using the simplified API: + * + * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. + * 2) Initialize the members of the structure that describe the image, setting + * the 'format' member to the format of the image samples. + * 3) Call the appropriate png_image_write... function with a pointer to the + * image and, if necessary, the color-map to write the PNG data. + * + * png_image is a structure that describes the in-memory format of an image + * when it is being read or defines the in-memory format of an image that you + * need to write: + */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) + +#define PNG_IMAGE_VERSION 1 + +typedef struct png_control *png_controlp; +typedef struct +{ + png_controlp opaque; /* Initialize to NULL, free with png_image_free */ + png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ + png_uint_32 width; /* Image width in pixels (columns) */ + png_uint_32 height; /* Image height in pixels (rows) */ + png_uint_32 format; /* Image format as defined below */ + png_uint_32 flags; /* A bit mask containing informational flags */ + png_uint_32 colormap_entries; + /* Number of entries in the color-map */ + + /* In the event of an error or warning the following field will be set to a + * non-zero value and the 'message' field will contain a '\0' terminated + * string with the libpng error or warning message. If both warnings and + * an error were encountered, only the error is recorded. If there + * are multiple warnings, only the first one is recorded. + * + * The upper 30 bits of this value are reserved, the low two bits contain + * a value as follows: + */ +# define PNG_IMAGE_WARNING 1 +# define PNG_IMAGE_ERROR 2 + /* + * The result is a two-bit code such that a value more than 1 indicates + * a failure in the API just called: + * + * 0 - no warning or error + * 1 - warning + * 2 - error + * 3 - error preceded by warning + */ +# define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) + + png_uint_32 warning_or_error; + + char message[64]; +} png_image, *png_imagep; + +/* The samples of the image have one to four channels whose components have + * original values in the range 0 to 1.0: + * + * 1: A single gray or luminance channel (G). + * 2: A gray/luminance channel and an alpha channel (GA). + * 3: Three red, green, blue color channels (RGB). + * 4: Three color channels and an alpha channel (RGBA). + * + * The components are encoded in one of two ways: + * + * a) As a small integer, value 0..255, contained in a single byte. For the + * alpha channel the original value is simply value/255. For the color or + * luminance channels the value is encoded according to the sRGB specification + * and matches the 8-bit format expected by typical display devices. + * + * The color/gray channels are not scaled (pre-multiplied) by the alpha + * channel and are suitable for passing to color management software. + * + * b) As a value in the range 0..65535, contained in a 2-byte integer. All + * channels can be converted to the original value by dividing by 65535; all + * channels are linear. Color channels use the RGB encoding (RGB end-points) of + * the sRGB specification. This encoding is identified by the + * PNG_FORMAT_FLAG_LINEAR flag below. + * + * When the simplified API needs to convert between sRGB and linear colorspaces, + * the actual sRGB transfer curve defined in the sRGB specification (see the + * article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 + * approximation used elsewhere in libpng. + * + * When an alpha channel is present it is expected to denote pixel coverage + * of the color or luminance channels and is returned as an associated alpha + * channel: the color/gray channels are scaled (pre-multiplied) by the alpha + * value. + * + * The samples are either contained directly in the image data, between 1 and 8 + * bytes per pixel according to the encoding, or are held in a color-map indexed + * by bytes in the image data. In the case of a color-map the color-map entries + * are individual samples, encoded as above, and the image data has one byte per + * pixel to select the relevant sample from the color-map. + */ + +/* PNG_FORMAT_* + * + * #defines to be used in png_image::format. Each #define identifies a + * particular layout of sample data and, if present, alpha values. There are + * separate defines for each of the two component encodings. + * + * A format is built up using single bit flag values. All combinations are + * valid. Formats can be built up from the flag values or you can use one of + * the predefined values below. When testing formats always use the FORMAT_FLAG + * macros to test for individual features - future versions of the library may + * add new flags. + * + * When reading or writing color-mapped images the format should be set to the + * format of the entries in the color-map then png_image_{read,write}_colormap + * called to read or write the color-map and set the format correctly for the + * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! + * + * NOTE: libpng can be built with particular features disabled. If you see + * compiler errors because the definition of one of the following flags has been + * compiled out it is because libpng does not have the required support. It is + * possible, however, for the libpng configuration to enable the format on just + * read or just write; in that case you may see an error at run time. You can + * guard against this by checking for the definition of the appropriate + * "_SUPPORTED" macro, one of: + * + * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED + */ +#define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ +#define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ +#define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2-byte channels else 1-byte */ +#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ + +#ifdef PNG_FORMAT_BGR_SUPPORTED +# define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ +#endif + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ +#endif + +#define PNG_FORMAT_FLAG_ASSOCIATED_ALPHA 0x40U /* alpha channel is associated */ + +/* Commonly used formats have predefined macros. + * + * First the single byte (sRGB) formats: + */ +#define PNG_FORMAT_GRAY 0 +#define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA +#define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) +#define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR +#define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) +#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) +#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) +#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) +#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) + +/* Then the linear 2-byte formats. When naming these "Y" is used to + * indicate a luminance (gray) channel. + */ +#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR +#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) +#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) +#define PNG_FORMAT_LINEAR_RGB_ALPHA \ + (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) + +/* With color-mapped formats the image data is one byte for each pixel, the byte + * is an index into the color-map which is formatted as above. To obtain a + * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP + * to one of the above definitions, or you can use one of the definitions below. + */ +#define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) + +/* PNG_IMAGE macros + * + * These are convenience macros to derive information from a png_image + * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the + * actual image sample values - either the entries in the color-map or the + * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values + * for the pixels and will always return 1 for color-mapped formats. The + * remaining macros return information about the rows in the image and the + * complete image. + * + * NOTE: All the macros that take a png_image::format parameter are compile time + * constants if the format parameter is, itself, a constant. Therefore these + * macros can be used in array declarations and case labels where required. + * Similarly the macros are also pre-processor constants (sizeof is not used) so + * they can be used in #if tests. + * + * First the information about the samples. + */ +#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ + (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) + /* Return the total number of channels in a given format: 1..4 */ + +#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ + ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) + /* Return the size in bytes of a single component of a pixel or color-map + * entry (as appropriate) in the image: 1 or 2. + */ + +#define PNG_IMAGE_SAMPLE_SIZE(fmt)\ + (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) + /* This is the size of the sample data for one sample. If the image is + * color-mapped it is the size of one color-map entry (and image pixels are + * one byte in size), otherwise it is the size of one image pixel. + */ + +#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ + (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) + /* The maximum size of the color-map required by the format expressed in a + * count of components. This can be used to compile-time allocate a + * color-map: + * + * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; + * + * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; + * + * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the + * information from one of the png_image_begin_read_ APIs and dynamically + * allocate the required memory. + */ + +/* Corresponding information about the pixels */ +#define PNG_IMAGE_PIXEL_(test,fmt)\ + (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) + +#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ + PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) + /* The number of separate channels (components) in a pixel; 1 for a + * color-mapped image. + */ + +#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ + PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) + /* The size, in bytes, of each component in a pixel; 1 for a color-mapped + * image. + */ + +#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) + /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ + +/* Information about the whole row, or whole image */ +#define PNG_IMAGE_ROW_STRIDE(image)\ + (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) + /* Return the total number of components in a single row of the image; this + * is the minimum 'row stride', the minimum count of components between each + * row. For a color-mapped image this is the minimum number of bytes in a + * row. + * + * WARNING: this macro overflows for some images with more than one component + * and very large image widths. libpng will refuse to process an image where + * this macro would overflow. + */ + +#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ + (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) + /* Return the size, in bytes, of an image buffer given a png_image and a row + * stride - the number of components to leave space for in each row. + * + * WARNING: this macro overflows a 32-bit integer for some large PNG images, + * libpng will refuse to process an image where such an overflow would occur. + */ + +#define PNG_IMAGE_SIZE(image)\ + PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) + /* Return the size, in bytes, of the image in memory given just a png_image; + * the row stride is the minimum stride required for the image. + */ + +#define PNG_IMAGE_COLORMAP_SIZE(image)\ + (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) + /* Return the size, in bytes, of the color-map of this image. If the image + * format is not a color-map format this will return a size sufficient for + * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if + * you don't want to allocate a color-map in this case. + */ + +/* PNG_IMAGE_FLAG_* + * + * Flags containing additional information about the image are held in the + * 'flags' field of png_image. + */ +#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 + /* This indicates the the RGB values of the in-memory bitmap do not + * correspond to the red, green and blue end-points defined by sRGB. + */ + +#define PNG_IMAGE_FLAG_FAST 0x02 + /* On write emphasise speed over compression; the resultant PNG file will be + * larger but will be produced significantly faster, particular for large + * images. Do not use this option for images which will be distributed, only + * used it when producing intermediate files that will be read back in + * repeatedly. For a typical 24-bit image the option will double the read + * speed at the cost of increasing the image size by 25%, however for many + * more compressible images the PNG file can be 10 times larger with only a + * slight speed gain. + */ + +#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 + /* On read if the image is a 16-bit per component image and there is no gAMA + * or sRGB chunk assume that the components are sRGB encoded. Notice that + * images output by the simplified API always have gamma information; setting + * this flag only affects the interpretation of 16-bit images from an + * external source. It is recommended that the application expose this flag + * to the user; the user can normally easily recognize the difference between + * linear and sRGB encoding. This flag has no effect on write - the data + * passed to the write APIs must have the correct encoding (as defined + * above.) + * + * If the flag is not set (the default) input 16-bit per component data is + * assumed to be linear. + * + * NOTE: the flag can only be set after the png_image_begin_read_ call, + * because that call initializes the 'flags' field. + */ + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +/* READ APIs + * --------- + * + * The png_image passed to the read APIs must have been initialized by setting + * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) + */ +#ifdef PNG_STDIO_SUPPORTED +PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, + const char *file_name)); + /* The named file is opened for read and the image header is filled in + * from the PNG header in the file. + */ + +PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, + FILE* file)); + /* The PNG header is read from the stdio FILE object. */ +#endif /* STDIO */ + +PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, + png_const_voidp memory, png_size_t size)); + /* The PNG header is read from the given memory buffer. */ + +PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, + png_const_colorp background, void *buffer, png_int_32 row_stride, + void *colormap)); + /* Finish reading the image into the supplied buffer and clean up the + * png_image structure. + * + * row_stride is the step, in byte or 2-byte units as appropriate, + * between adjacent rows. A positive stride indicates that the top-most row + * is first in the buffer - the normal top-down arrangement. A negative + * stride indicates that the bottom-most row is first in the buffer. + * + * background need only be supplied if an alpha channel must be removed from + * a png_byte format and the removal is to be done by compositing on a solid + * color; otherwise it may be NULL and any composition will be done directly + * onto the buffer. The value is an sRGB color to use for the background, + * for grayscale output the green channel is used. + * + * background must be supplied when an alpha channel must be removed from a + * single byte color-mapped output format, in other words if: + * + * 1) The original format from png_image_begin_read_from_* had + * PNG_FORMAT_FLAG_ALPHA set. + * 2) The format set by the application does not. + * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and + * PNG_FORMAT_FLAG_LINEAR *not* set. + * + * For linear output removing the alpha channel is always done by compositing + * on black and background is ignored. + * + * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must + * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. + * image->colormap_entries will be updated to the actual number of entries + * written to the colormap; this may be less than the original value. + */ + +PNG_EXPORT(238, void, png_image_free, (png_imagep image)); + /* Free any data allocated by libpng in image->opaque, setting the pointer to + * NULL. May be called at any time after the structure is initialized. + */ +#endif /* SIMPLIFIED_READ */ + +#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED +/* WRITE APIS + * ---------- + * For write you must initialize a png_image structure to describe the image to + * be written. To do this use memset to set the whole structure to 0 then + * initialize fields describing your image. + * + * version: must be set to PNG_IMAGE_VERSION + * opaque: must be initialized to NULL + * width: image width in pixels + * height: image height in rows + * format: the format of the data (image and color-map) you wish to write + * flags: set to 0 unless one of the defined flags applies; set + * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB + * values do not correspond to the colors in sRGB. + * colormap_entries: set to the number of entries in the color-map (0 to 256) + */ +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED +PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, + const char *file, int convert_to_8bit, const void *buffer, + png_int_32 row_stride, const void *colormap)); + /* Write the image to the named file. */ + +PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, + int convert_to_8_bit, const void *buffer, png_int_32 row_stride, + const void *colormap)); + /* Write the image to the given (FILE*). */ +#endif /* SIMPLIFIED_WRITE_STDIO */ + +/* With all write APIs if image is in one of the linear formats with 16-bit + * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG + * gamma encoded according to the sRGB specification, otherwise a 16-bit linear + * encoded PNG file is written. + * + * With color-mapped data formats the colormap parameter point to a color-map + * with at least image->colormap_entries encoded in the specified format. If + * the format is linear the written PNG color-map will be converted to sRGB + * regardless of the convert_to_8_bit flag. + * + * With all APIs row_stride is handled as in the read APIs - it is the spacing + * from one row to the next in component sized units (1 or 2 bytes) and if + * negative indicates a bottom-up row layout in the buffer. If row_stride is + * zero, libpng will calculate it for you from the image width and number of + * channels. + * + * Note that the write API does not support interlacing, sub-8-bit pixels or + * most ancillary chunks. If you need to write text chunks (e.g. for copyright + * notices) you need to use one of the other APIs. + */ + +PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory, + png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit, + const void *buffer, png_int_32 row_stride, const void *colormap)); + /* Write the image to the given memory buffer. The function both writes the + * whole PNG data stream to *memory and updates *memory_bytes with the count + * of bytes written. + * + * 'memory' may be NULL. In this case *memory_bytes is not read however on + * success the number of bytes which would have been written will still be + * stored in *memory_bytes. On failure *memory_bytes will contain 0. + * + * If 'memory' is not NULL it must point to memory[*memory_bytes] of + * writeable memory. + * + * If the function returns success memory[*memory_bytes] (if 'memory' is not + * NULL) contains the written PNG data. *memory_bytes will always be less + * than or equal to the original value. + * + * If the function returns false and *memory_bytes was not changed an error + * occured during write. If *memory_bytes was changed, or is not 0 if + * 'memory' was NULL, the write would have succeeded but for the memory + * buffer being too small. *memory_bytes contains the required number of + * bytes and will be bigger that the original value. + */ + +#define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\ + row_stride, colormap)\ + png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\ + row_stride, colormap) + /* Return the amount of memory in 'size' required to compress this image. + * The png_image structure 'image' must be filled in as in the above + * function and must not be changed before the actual write call, the buffer + * and all other parameters must also be identical to that in the final + * write call. The 'size' variable need not be initialized. + * + * NOTE: the macro returns true/false, if false is returned 'size' will be + * set to zero and the write failed and probably will fail if tried again. + */ + +/* You can pre-allocate the buffer by making sure it is of sufficient size + * regardless of the amount of compression achieved. The buffer size will + * always be bigger than the original image and it will never be filled. The + * following macros are provided to assist in allocating the buffer. + */ +#define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height) + /* The number of uncompressed bytes in the PNG byte encoding of the image; + * uncompressing the PNG IDAT data will give this number of bytes. + * + * NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this + * macro can because of the extra bytes used in the PNG byte encoding. You + * need to avoid this macro if your image size approaches 2^30 in width or + * height. The same goes for the remainder of these macros; they all produce + * bigger numbers than the actual in-memory image size. + */ +#ifndef PNG_ZLIB_MAX_SIZE +# define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U) + /* An upper bound on the number of compressed bytes given 'b' uncompressed + * bytes. This is based on deflateBounds() in zlib; different + * implementations of zlib compression may conceivably produce more data so + * if your zlib implementation is not zlib itself redefine this macro + * appropriately. + */ +#endif + +#define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\ + PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image)) + /* An upper bound on the size of the data in the PNG IDAT chunks. */ + +#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\ + ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\ + (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\ + 12U+3U*(image).colormap_entries/*PLTE data*/+\ + (((image).format&PNG_FORMAT_FLAG_ALPHA)?\ + 12U/*tRNS*/+(image).colormap_entries:0U):0U)+\ + 12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size)) + /* A helper for the following macro; if your compiler cannot handle the + * following macro use this one with the result of + * PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most + * compilers should handle this just fine.) + */ + +#define PNG_IMAGE_PNG_SIZE_MAX(image)\ + PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image)) + /* An upper bound on the total length of the PNG data stream for 'image'. + * The result is of type png_alloc_size_t, on 32-bit systems this may + * overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will + * run out of buffer space but return a corrected size which should work. + */ +#endif /* SIMPLIFIED_WRITE */ +/******************************************************************************* + * END OF SIMPLIFIED API + ******************************************************************************/ +#endif /* SIMPLIFIED_{READ|WRITE} */ + +/******************************************************************************* + * Section 6: IMPLEMENTATION OPTIONS + ******************************************************************************* + * + * Support for arbitrary implementation-specific optimizations. The API allows + * particular options to be turned on or off. 'Option' is the number of the + * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given + * by the PNG_OPTION_ defines below. + * + * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, + * are detected at run time, however sometimes it may be impossible + * to do this in user mode, in which case it is necessary to discover + * the capabilities in an OS specific way. Such capabilities are + * listed here when libpng has support for them and must be turned + * ON by the application if present. + * + * SOFTWARE: sometimes software optimizations actually result in performance + * decrease on some architectures or systems, or with some sets of + * PNG images. 'Software' options allow such optimizations to be + * selected at run time. + */ +#ifdef PNG_SET_OPTION_SUPPORTED +#ifdef PNG_ARM_NEON_API_SUPPORTED +# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ +#endif +#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */ +#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */ +#ifdef PNG_MIPS_MSA_API_SUPPORTED +# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */ +#endif +#define PNG_IGNORE_ADLER32 8 +#ifdef PNG_POWERPC_VSX_API_SUPPORTED +# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */ +#endif +#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */ + +/* Return values: NOTE: there are four values and 'off' is *not* zero */ +#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ +#define PNG_OPTION_INVALID 1 /* Option number out of range */ +#define PNG_OPTION_OFF 2 +#define PNG_OPTION_ON 3 + +PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, + int onoff)); +#endif /* SET_OPTION */ + +/******************************************************************************* + * END OF HARDWARE AND SOFTWARE OPTIONS + ******************************************************************************/ + +/* Maintainer: Put new public prototypes here ^, in libpng.3, in project + * defs, and in scripts/symbols.def. + */ + +/* The last ordinal number (this is the *last* one already used; the next + * one to use is one more than this.) + */ +#ifdef PNG_EXPORT_LAST_ORDINAL + PNG_EXPORT_LAST_ORDINAL(249); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +/* Do not put anything past this line */ +#endif /* PNG_H */ diff --git a/xs/src/png/libpng/pngconf.h b/xs/src/png/libpng/pngconf.h new file mode 100644 index 0000000000..d13b13e57a --- /dev/null +++ b/xs/src/png/libpng/pngconf.h @@ -0,0 +1,622 @@ + +/* pngconf.h - machine configurable file for libpng + * + * libpng version 1.6.34, September 29, 2017 + * + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * Any machine specific code is near the front of this file, so if you + * are configuring libpng for a machine, you may want to read the section + * starting here down to where it starts to typedef png_color, png_text, + * and png_info. + */ + +#ifndef PNGCONF_H +#define PNGCONF_H + +#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ + +/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C + * compiler for correct compilation. The following header files are required by + * the standard. If your compiler doesn't provide these header files, or they + * do not match the standard, you will need to provide/improve them. + */ +#include +#include + +/* Library header files. These header files are all defined by ISOC90; libpng + * expects conformant implementations, however, an ISOC90 conformant system need + * not provide these header files if the functionality cannot be implemented. + * In this case it will be necessary to disable the relevant parts of libpng in + * the build of pnglibconf.h. + * + * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not + * include this unnecessary header file. + */ + +#ifdef PNG_STDIO_SUPPORTED + /* Required for the definition of FILE: */ +# include +#endif + +#ifdef PNG_SETJMP_SUPPORTED + /* Required for the definition of jmp_buf and the declaration of longjmp: */ +# include +#endif + +#ifdef PNG_CONVERT_tIME_SUPPORTED + /* Required for struct tm: */ +# include +#endif + +#endif /* PNG_BUILDING_SYMBOL_TABLE */ + +/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using + * PNG_NO_CONST; this is no longer supported except for data declarations which + * apparently still cause problems in 2011 on some compilers. + */ +#define PNG_CONST const /* backward compatibility only */ + +/* This controls optimization of the reading of 16-bit and 32-bit values + * from PNG files. It can be set on a per-app-file basis - it + * just changes whether a macro is used when the function is called. + * The library builder sets the default; if read functions are not + * built into the library the macro implementation is forced on. + */ +#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED +# define PNG_USE_READ_MACROS +#endif +#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) +# if PNG_DEFAULT_READ_MACROS +# define PNG_USE_READ_MACROS +# endif +#endif + +/* COMPILER SPECIFIC OPTIONS. + * + * These options are provided so that a variety of difficult compilers + * can be used. Some are fixed at build time (e.g. PNG_API_RULE + * below) but still have compiler specific implementations, others + * may be changed on a per-file basis when compiling against libpng. + */ + +/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect + * against legacy (pre ISOC90) compilers that did not understand function + * prototypes. It is not required for modern C compilers. + */ +#ifndef PNGARG +# define PNGARG(arglist) arglist +#endif + +/* Function calling conventions. + * ============================= + * Normally it is not necessary to specify to the compiler how to call + * a function - it just does it - however on x86 systems derived from + * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems + * and some others) there are multiple ways to call a function and the + * default can be changed on the compiler command line. For this reason + * libpng specifies the calling convention of every exported function and + * every function called via a user supplied function pointer. This is + * done in this file by defining the following macros: + * + * PNGAPI Calling convention for exported functions. + * PNGCBAPI Calling convention for user provided (callback) functions. + * PNGCAPI Calling convention used by the ANSI-C library (required + * for longjmp callbacks and sometimes used internally to + * specify the calling convention for zlib). + * + * These macros should never be overridden. If it is necessary to + * change calling convention in a private build this can be done + * by setting PNG_API_RULE (which defaults to 0) to one of the values + * below to select the correct 'API' variants. + * + * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. + * This is correct in every known environment. + * PNG_API_RULE=1 Use the operating system convention for PNGAPI and + * the 'C' calling convention (from PNGCAPI) for + * callbacks (PNGCBAPI). This is no longer required + * in any known environment - if it has to be used + * please post an explanation of the problem to the + * libpng mailing list. + * + * These cases only differ if the operating system does not use the C + * calling convention, at present this just means the above cases + * (x86 DOS/Windows sytems) and, even then, this does not apply to + * Cygwin running on those systems. + * + * Note that the value must be defined in pnglibconf.h so that what + * the application uses to call the library matches the conventions + * set when building the library. + */ + +/* Symbol export + * ============= + * When building a shared library it is almost always necessary to tell + * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' + * is used to mark the symbols. On some systems these symbols can be + * extracted at link time and need no special processing by the compiler, + * on other systems the symbols are flagged by the compiler and just + * the declaration requires a special tag applied (unfortunately) in a + * compiler dependent way. Some systems can do either. + * + * A small number of older systems also require a symbol from a DLL to + * be flagged to the program that calls it. This is a problem because + * we do not know in the header file included by application code that + * the symbol will come from a shared library, as opposed to a statically + * linked one. For this reason the application must tell us by setting + * the magic flag PNG_USE_DLL to turn on the special processing before + * it includes png.h. + * + * Four additional macros are used to make this happen: + * + * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from + * the build or imported if PNG_USE_DLL is set - compiler + * and system specific. + * + * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to + * 'type', compiler specific. + * + * PNG_DLL_EXPORT Set to the magic to use during a libpng build to + * make a symbol exported from the DLL. Not used in the + * public header files; see pngpriv.h for how it is used + * in the libpng build. + * + * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come + * from a DLL - used to define PNG_IMPEXP when + * PNG_USE_DLL is set. + */ + +/* System specific discovery. + * ========================== + * This code is used at build time to find PNG_IMPEXP, the API settings + * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL + * import processing is possible. On Windows systems it also sets + * compiler-specific macros to the values required to change the calling + * conventions of the various functions. + */ +#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ + defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) + /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or + * MinGW on any architecture currently supported by Windows. Also includes + * Watcom builds but these need special treatment because they are not + * compatible with GCC or Visual C because of different calling conventions. + */ +# if PNG_API_RULE == 2 + /* If this line results in an error, either because __watcall is not + * understood or because of a redefine just below you cannot use *this* + * build of the library with the compiler you are using. *This* build was + * build using Watcom and applications must also be built using Watcom! + */ +# define PNGCAPI __watcall +# endif + +# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) +# define PNGCAPI __cdecl +# if PNG_API_RULE == 1 + /* If this line results in an error __stdcall is not understood and + * PNG_API_RULE should not have been set to '1'. + */ +# define PNGAPI __stdcall +# endif +# else + /* An older compiler, or one not detected (erroneously) above, + * if necessary override on the command line to get the correct + * variants for the compiler. + */ +# ifndef PNGCAPI +# define PNGCAPI _cdecl +# endif +# if PNG_API_RULE == 1 && !defined(PNGAPI) +# define PNGAPI _stdcall +# endif +# endif /* compiler/api */ + + /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ + +# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) +# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" +# endif + +# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ + (defined(__BORLANDC__) && __BORLANDC__ < 0x500) + /* older Borland and MSC + * compilers used '__export' and required this to be after + * the type. + */ +# ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP +# endif +# define PNG_DLL_EXPORT __export +# else /* newer compiler */ +# define PNG_DLL_EXPORT __declspec(dllexport) +# ifndef PNG_DLL_IMPORT +# define PNG_DLL_IMPORT __declspec(dllimport) +# endif +# endif /* compiler */ + +#else /* !Windows */ +# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) +# define PNGAPI _System +# else /* !Windows/x86 && !OS/2 */ + /* Use the defaults, or define PNG*API on the command line (but + * this will have to be done for every compile!) + */ +# endif /* other system, !OS/2 */ +#endif /* !Windows/x86 */ + +/* Now do all the defaulting . */ +#ifndef PNGCAPI +# define PNGCAPI +#endif +#ifndef PNGCBAPI +# define PNGCBAPI PNGCAPI +#endif +#ifndef PNGAPI +# define PNGAPI PNGCAPI +#endif + +/* PNG_IMPEXP may be set on the compilation system command line or (if not set) + * then in an internal header file when building the library, otherwise (when + * using the library) it is set here. + */ +#ifndef PNG_IMPEXP +# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) + /* This forces use of a DLL, disallowing static linking */ +# define PNG_IMPEXP PNG_DLL_IMPORT +# endif + +# ifndef PNG_IMPEXP +# define PNG_IMPEXP +# endif +#endif + +/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat + * 'attributes' as a storage class - the attributes go at the start of the + * function definition, and attributes are always appended regardless of the + * compiler. This considerably simplifies these macros but may cause problems + * if any compilers both need function attributes and fail to handle them as + * a storage class (this is unlikely.) + */ +#ifndef PNG_FUNCTION +# define PNG_FUNCTION(type, name, args, attributes) attributes type name args +#endif + +#ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type +#endif + + /* The ordinal value is only relevant when preprocessing png.h for symbol + * table entries, so we discard it here. See the .dfn files in the + * scripts directory. + */ + +#ifndef PNG_EXPORTA +# define PNG_EXPORTA(ordinal, type, name, args, attributes) \ + PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \ + PNG_LINKAGE_API attributes) +#endif + +/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, + * so make something non-empty to satisfy the requirement: + */ +#define PNG_EMPTY /*empty list*/ + +#define PNG_EXPORT(ordinal, type, name, args) \ + PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) + +/* Use PNG_REMOVED to comment out a removed interface. */ +#ifndef PNG_REMOVED +# define PNG_REMOVED(ordinal, type, name, args, attributes) +#endif + +#ifndef PNG_CALLBACK +# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) +#endif + +/* Support for compiler specific function attributes. These are used + * so that where compiler support is available incorrect use of API + * functions in png.h will generate compiler warnings. + * + * Added at libpng-1.2.41. + */ + +#ifndef PNG_NO_PEDANTIC_WARNINGS +# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED +# define PNG_PEDANTIC_WARNINGS_SUPPORTED +# endif +#endif + +#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED + /* Support for compiler specific function attributes. These are used + * so that where compiler support is available, incorrect use of API + * functions in png.h will generate compiler warnings. Added at libpng + * version 1.2.41. Disabling these removes the warnings but may also produce + * less efficient code. + */ +# if defined(__clang__) && defined(__has_attribute) + /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ +# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__) +# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) +# endif +# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__) +# define PNG_NORETURN __attribute__((__noreturn__)) +# endif +# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__) +# define PNG_ALLOCATED __attribute__((__malloc__)) +# endif +# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__) +# define PNG_DEPRECATED __attribute__((__deprecated__)) +# endif +# if !defined(PNG_PRIVATE) +# ifdef __has_extension +# if __has_extension(attribute_unavailable_with_message) +# define PNG_PRIVATE __attribute__((__unavailable__(\ + "This function is not exported by libpng."))) +# endif +# endif +# endif +# ifndef PNG_RESTRICT +# define PNG_RESTRICT __restrict +# endif + +# elif defined(__GNUC__) +# ifndef PNG_USE_RESULT +# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) +# endif +# ifndef PNG_NORETURN +# define PNG_NORETURN __attribute__((__noreturn__)) +# endif +# if __GNUC__ >= 3 +# ifndef PNG_ALLOCATED +# define PNG_ALLOCATED __attribute__((__malloc__)) +# endif +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __attribute__((__deprecated__)) +# endif +# ifndef PNG_PRIVATE +# if 0 /* Doesn't work so we use deprecated instead*/ +# define PNG_PRIVATE \ + __attribute__((warning("This function is not exported by libpng."))) +# else +# define PNG_PRIVATE \ + __attribute__((__deprecated__)) +# endif +# endif +# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) +# ifndef PNG_RESTRICT +# define PNG_RESTRICT __restrict +# endif +# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */ +# endif /* __GNUC__ >= 3 */ + +# elif defined(_MSC_VER) && (_MSC_VER >= 1300) +# ifndef PNG_USE_RESULT +# define PNG_USE_RESULT /* not supported */ +# endif +# ifndef PNG_NORETURN +# define PNG_NORETURN __declspec(noreturn) +# endif +# ifndef PNG_ALLOCATED +# if (_MSC_VER >= 1400) +# define PNG_ALLOCATED __declspec(restrict) +# endif +# endif +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __declspec(deprecated) +# endif +# ifndef PNG_PRIVATE +# define PNG_PRIVATE __declspec(deprecated) +# endif +# ifndef PNG_RESTRICT +# if (_MSC_VER >= 1400) +# define PNG_RESTRICT __restrict +# endif +# endif + +# elif defined(__WATCOMC__) +# ifndef PNG_RESTRICT +# define PNG_RESTRICT __restrict +# endif +# endif +#endif /* PNG_PEDANTIC_WARNINGS */ + +#ifndef PNG_DEPRECATED +# define PNG_DEPRECATED /* Use of this function is deprecated */ +#endif +#ifndef PNG_USE_RESULT +# define PNG_USE_RESULT /* The result of this function must be checked */ +#endif +#ifndef PNG_NORETURN +# define PNG_NORETURN /* This function does not return */ +#endif +#ifndef PNG_ALLOCATED +# define PNG_ALLOCATED /* The result of the function is new memory */ +#endif +#ifndef PNG_PRIVATE +# define PNG_PRIVATE /* This is a private libpng function */ +#endif +#ifndef PNG_RESTRICT +# define PNG_RESTRICT /* The C99 "restrict" feature */ +#endif + +#ifndef PNG_FP_EXPORT /* A floating point API. */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FP_EXPORT(ordinal, type, name, args)\ + PNG_EXPORT(ordinal, type, name, args); +# else /* No floating point APIs */ +# define PNG_FP_EXPORT(ordinal, type, name, args) +# endif +#endif +#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ +# ifdef PNG_FIXED_POINT_SUPPORTED +# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ + PNG_EXPORT(ordinal, type, name, args); +# else /* No fixed point APIs */ +# define PNG_FIXED_EXPORT(ordinal, type, name, args) +# endif +#endif + +#ifndef PNG_BUILDING_SYMBOL_TABLE +/* Some typedefs to get us started. These should be safe on most of the common + * platforms. + * + * png_uint_32 and png_int_32 may, currently, be larger than required to hold a + * 32-bit value however this is not normally advisable. + * + * png_uint_16 and png_int_16 should always be two bytes in size - this is + * verified at library build time. + * + * png_byte must always be one byte in size. + * + * The checks below use constants from limits.h, as defined by the ISOC90 + * standard. + */ +#if CHAR_BIT == 8 && UCHAR_MAX == 255 + typedef unsigned char png_byte; +#else +# error "libpng requires 8-bit bytes" +#endif + +#if INT_MIN == -32768 && INT_MAX == 32767 + typedef int png_int_16; +#elif SHRT_MIN == -32768 && SHRT_MAX == 32767 + typedef short png_int_16; +#else +# error "libpng requires a signed 16-bit type" +#endif + +#if UINT_MAX == 65535 + typedef unsigned int png_uint_16; +#elif USHRT_MAX == 65535 + typedef unsigned short png_uint_16; +#else +# error "libpng requires an unsigned 16-bit type" +#endif + +#if INT_MIN < -2147483646 && INT_MAX > 2147483646 + typedef int png_int_32; +#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 + typedef long int png_int_32; +#else +# error "libpng requires a signed 32-bit (or more) type" +#endif + +#if UINT_MAX > 4294967294U + typedef unsigned int png_uint_32; +#elif ULONG_MAX > 4294967294U + typedef unsigned long int png_uint_32; +#else +# error "libpng requires an unsigned 32-bit (or more) type" +#endif + +/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, + * requires an ISOC90 compiler and relies on consistent behavior of sizeof. + */ +typedef size_t png_size_t; +typedef ptrdiff_t png_ptrdiff_t; + +/* libpng needs to know the maximum value of 'size_t' and this controls the + * definition of png_alloc_size_t, below. This maximum value of size_t limits + * but does not control the maximum allocations the library makes - there is + * direct application control of this through png_set_user_limits(). + */ +#ifndef PNG_SMALL_SIZE_T + /* Compiler specific tests for systems where size_t is known to be less than + * 32 bits (some of these systems may no longer work because of the lack of + * 'far' support; see above.) + */ +# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ + (defined(_MSC_VER) && defined(MAXSEG_64K)) +# define PNG_SMALL_SIZE_T +# endif +#endif + +/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no + * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to + * png_alloc_size_t are not necessary; in fact, it is recommended not to use + * them at all so that the compiler can complain when something turns out to be + * problematic. + * + * Casts in the other direction (from png_alloc_size_t to png_size_t or + * png_uint_32) should be explicitly applied; however, we do not expect to + * encounter practical situations that require such conversions. + * + * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than + * 4294967295 - i.e. less than the maximum value of png_uint_32. + */ +#ifdef PNG_SMALL_SIZE_T + typedef png_uint_32 png_alloc_size_t; +#else + typedef png_size_t png_alloc_size_t; +#endif + +/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler + * implementations of Intel CPU specific support of user-mode segmented address + * spaces, where 16-bit pointers address more than 65536 bytes of memory using + * separate 'segment' registers. The implementation requires two different + * types of pointer (only one of which includes the segment value.) + * + * If required this support is available in version 1.2 of libpng and may be + * available in versions through 1.5, although the correctness of the code has + * not been verified recently. + */ + +/* Typedef for floating-point numbers that are converted to fixed-point with a + * multiple of 100,000, e.g., gamma + */ +typedef png_int_32 png_fixed_point; + +/* Add typedefs for pointers */ +typedef void * png_voidp; +typedef const void * png_const_voidp; +typedef png_byte * png_bytep; +typedef const png_byte * png_const_bytep; +typedef png_uint_32 * png_uint_32p; +typedef const png_uint_32 * png_const_uint_32p; +typedef png_int_32 * png_int_32p; +typedef const png_int_32 * png_const_int_32p; +typedef png_uint_16 * png_uint_16p; +typedef const png_uint_16 * png_const_uint_16p; +typedef png_int_16 * png_int_16p; +typedef const png_int_16 * png_const_int_16p; +typedef char * png_charp; +typedef const char * png_const_charp; +typedef png_fixed_point * png_fixed_point_p; +typedef const png_fixed_point * png_const_fixed_point_p; +typedef png_size_t * png_size_tp; +typedef const png_size_t * png_const_size_tp; + +#ifdef PNG_STDIO_SUPPORTED +typedef FILE * png_FILE_p; +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double * png_doublep; +typedef const double * png_const_doublep; +#endif + +/* Pointers to pointers; i.e. arrays */ +typedef png_byte * * png_bytepp; +typedef png_uint_32 * * png_uint_32pp; +typedef png_int_32 * * png_int_32pp; +typedef png_uint_16 * * png_uint_16pp; +typedef png_int_16 * * png_int_16pp; +typedef const char * * png_const_charpp; +typedef char * * png_charpp; +typedef png_fixed_point * * png_fixed_point_pp; +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double * * png_doublepp; +#endif + +/* Pointers to pointers to pointers; i.e., pointer to array */ +typedef char * * * png_charppp; + +#endif /* PNG_BUILDING_SYMBOL_TABLE */ + +#endif /* PNGCONF_H */ diff --git a/xs/src/png/libpng/pngdebug.h b/xs/src/png/libpng/pngdebug.h new file mode 100644 index 0000000000..15a7ed0c95 --- /dev/null +++ b/xs/src/png/libpng/pngdebug.h @@ -0,0 +1,153 @@ + +/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c + * + * Last changed in libpng 1.6.8 [December 19, 2013] + * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + * + * png_debug[1-2]?(level, message ,arg{0-2}) + * Expands to a statement (either a simple expression or a compound + * do..while(0) statement) that outputs a message with parameter + * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG + * is undefined, 0 or 1 every png_debug expands to a simple expression + * (actually ((void)0)). + * + * level: level of detail of message, starting at 0. A level 'n' + * message is preceded by 'n' 3-space indentations (not implemented + * on Microsoft compilers unless PNG_DEBUG_FILE is also + * defined, to allow debug DLL compilation with no standard IO). + * message: a printf(3) style text string. A trailing '\n' is added + * to the message. + * arg: 0 to 2 arguments for printf(3) style substitution in message. + */ +#ifndef PNGDEBUG_H +#define PNGDEBUG_H +/* These settings control the formatting of messages in png.c and pngerror.c */ +/* Moved to pngdebug.h at 1.5.0 */ +# ifndef PNG_LITERAL_SHARP +# define PNG_LITERAL_SHARP 0x23 +# endif +# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET +# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b +# endif +# ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET +# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d +# endif +# ifndef PNG_STRING_NEWLINE +# define PNG_STRING_NEWLINE "\n" +# endif + +#ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +# include +# if (PNG_DEBUG > 1) +# ifndef _DEBUG +# define _DEBUG +# endif +# ifndef png_debug +# define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) +# endif +# endif +# else /* PNG_DEBUG_FILE || !_MSC_VER */ +# ifndef PNG_STDIO_SUPPORTED +# include /* not included yet */ +# endif +# ifndef PNG_DEBUG_FILE +# define PNG_DEBUG_FILE stderr +# endif /* PNG_DEBUG_FILE */ + +# if (PNG_DEBUG > 1) +# ifdef __STDC__ +# ifndef png_debug +# define png_debug(l,m) \ + do { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \ + (num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \ + } while (0) +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + do { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \ + (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \ + } while (0) +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + do { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \ + (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\ + } while (0) +# endif +# else /* __STDC __ */ +# ifndef png_debug +# define png_debug(l,m) \ + do { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format); \ + } while (0) +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + do { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1); \ + } while (0) +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + do { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1,p2); \ + } while (0) +# endif +# endif /* __STDC __ */ +# endif /* (PNG_DEBUG > 1) */ + +# endif /* _MSC_VER */ +# endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +# define png_debug(l, m) ((void)0) +#endif +#ifndef png_debug1 +# define png_debug1(l, m, p1) ((void)0) +#endif +#ifndef png_debug2 +# define png_debug2(l, m, p1, p2) ((void)0) +#endif +#endif /* PNGDEBUG_H */ diff --git a/xs/src/png/libpng/pngerror.c b/xs/src/png/libpng/pngerror.c new file mode 100644 index 0000000000..ad48bfb986 --- /dev/null +++ b/xs/src/png/libpng/pngerror.c @@ -0,0 +1,963 @@ + +/* pngerror.c - stub functions for i/o and memory allocation + * + * Last changed in libpng 1.6.31 [July 27, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * This file provides a location for all error handling. Users who + * need special error handling are expected to write replacement functions + * and use png_set_error_fn() to use those functions. See the instructions + * at each function. + */ + +#include "pngpriv.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr, + png_const_charp error_message)),PNG_NORETURN); + +#ifdef PNG_WARNINGS_SUPPORTED +static void /* PRIVATE */ +png_default_warning PNGARG((png_const_structrp png_ptr, + png_const_charp warning_message)); +#endif /* WARNINGS */ + +/* This function is called whenever there is a fatal error. This function + * should not be changed. If there is a need to handle errors differently, + * you should supply a replacement error function and use png_set_error_fn() + * to replace the error function at run-time. + */ +#ifdef PNG_ERROR_TEXT_SUPPORTED +PNG_FUNCTION(void,PNGAPI +png_error,(png_const_structrp png_ptr, png_const_charp error_message), + PNG_NORETURN) +{ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + char msg[16]; + if (png_ptr != NULL) + { + if ((png_ptr->flags & + (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0) + { + if (*error_message == PNG_LITERAL_SHARP) + { + /* Strip "#nnnn " from beginning of error message. */ + int offset; + for (offset = 1; offset<15; offset++) + if (error_message[offset] == ' ') + break; + + if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0) + { + int i; + for (i = 0; i < offset - 1; i++) + msg[i] = error_message[i + 1]; + msg[i - 1] = '\0'; + error_message = msg; + } + + else + error_message += offset; + } + + else + { + if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0) + { + msg[0] = '0'; + msg[1] = '\0'; + error_message = msg; + } + } + } + } +#endif + if (png_ptr != NULL && png_ptr->error_fn != NULL) + (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), + error_message); + + /* If the custom handler doesn't exist, or if it returns, + use the default handler, which will not return. */ + png_default_error(png_ptr, error_message); +} +#else +PNG_FUNCTION(void,PNGAPI +png_err,(png_const_structrp png_ptr),PNG_NORETURN) +{ + /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed + * erroneously as '\0', instead of the empty string "". This was + * apparently an error, introduced in libpng-1.2.20, and png_default_error + * will crash in this case. + */ + if (png_ptr != NULL && png_ptr->error_fn != NULL) + (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), ""); + + /* If the custom handler doesn't exist, or if it returns, + use the default handler, which will not return. */ + png_default_error(png_ptr, ""); +} +#endif /* ERROR_TEXT */ + +/* Utility to safely appends strings to a buffer. This never errors out so + * error checking is not required in the caller. + */ +size_t +png_safecat(png_charp buffer, size_t bufsize, size_t pos, + png_const_charp string) +{ + if (buffer != NULL && pos < bufsize) + { + if (string != NULL) + while (*string != '\0' && pos < bufsize-1) + buffer[pos++] = *string++; + + buffer[pos] = '\0'; + } + + return pos; +} + +#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) +/* Utility to dump an unsigned value into a buffer, given a start pointer and + * and end pointer (which should point just *beyond* the end of the buffer!) + * Returns the pointer to the start of the formatted string. + */ +png_charp +png_format_number(png_const_charp start, png_charp end, int format, + png_alloc_size_t number) +{ + int count = 0; /* number of digits output */ + int mincount = 1; /* minimum number required */ + int output = 0; /* digit output (for the fixed point format) */ + + *--end = '\0'; + + /* This is written so that the loop always runs at least once, even with + * number zero. + */ + while (end > start && (number != 0 || count < mincount)) + { + + static const char digits[] = "0123456789ABCDEF"; + + switch (format) + { + case PNG_NUMBER_FORMAT_fixed: + /* Needs five digits (the fraction) */ + mincount = 5; + if (output != 0 || number % 10 != 0) + { + *--end = digits[number % 10]; + output = 1; + } + number /= 10; + break; + + case PNG_NUMBER_FORMAT_02u: + /* Expects at least 2 digits. */ + mincount = 2; + /* FALLTHROUGH */ + + case PNG_NUMBER_FORMAT_u: + *--end = digits[number % 10]; + number /= 10; + break; + + case PNG_NUMBER_FORMAT_02x: + /* This format expects at least two digits */ + mincount = 2; + /* FALLTHROUGH */ + + case PNG_NUMBER_FORMAT_x: + *--end = digits[number & 0xf]; + number >>= 4; + break; + + default: /* an error */ + number = 0; + break; + } + + /* Keep track of the number of digits added */ + ++count; + + /* Float a fixed number here: */ + if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start)) + { + /* End of the fraction, but maybe nothing was output? In that case + * drop the decimal point. If the number is a true zero handle that + * here. + */ + if (output != 0) + *--end = '.'; + else if (number == 0) /* and !output */ + *--end = '0'; + } + } + + return end; +} +#endif + +#ifdef PNG_WARNINGS_SUPPORTED +/* This function is called whenever there is a non-fatal error. This function + * should not be changed. If there is a need to handle warnings differently, + * you should supply a replacement warning function and use + * png_set_error_fn() to replace the warning function at run-time. + */ +void PNGAPI +png_warning(png_const_structrp png_ptr, png_const_charp warning_message) +{ + int offset = 0; + if (png_ptr != NULL) + { +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + if ((png_ptr->flags & + (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0) +#endif + { + if (*warning_message == PNG_LITERAL_SHARP) + { + for (offset = 1; offset < 15; offset++) + if (warning_message[offset] == ' ') + break; + } + } + } + if (png_ptr != NULL && png_ptr->warning_fn != NULL) + (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr), + warning_message + offset); + else + png_default_warning(png_ptr, warning_message + offset); +} + +/* These functions support 'formatted' warning messages with up to + * PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter + * is introduced by @, where 'number' starts at 1. This follows the + * standard established by X/Open for internationalizable error messages. + */ +void +png_warning_parameter(png_warning_parameters p, int number, + png_const_charp string) +{ + if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT) + (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string); +} + +void +png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, + png_alloc_size_t value) +{ + char buffer[PNG_NUMBER_BUFFER_SIZE]; + png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value)); +} + +void +png_warning_parameter_signed(png_warning_parameters p, int number, int format, + png_int_32 value) +{ + png_alloc_size_t u; + png_charp str; + char buffer[PNG_NUMBER_BUFFER_SIZE]; + + /* Avoid overflow by doing the negate in a png_alloc_size_t: */ + u = (png_alloc_size_t)value; + if (value < 0) + u = ~u + 1; + + str = PNG_FORMAT_NUMBER(buffer, format, u); + + if (value < 0 && str > buffer) + *--str = '-'; + + png_warning_parameter(p, number, str); +} + +void +png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p, + png_const_charp message) +{ + /* The internal buffer is just 192 bytes - enough for all our messages, + * overflow doesn't happen because this code checks! If someone figures + * out how to send us a message longer than 192 bytes, all that will + * happen is that the message will be truncated appropriately. + */ + size_t i = 0; /* Index in the msg[] buffer: */ + char msg[192]; + + /* Each iteration through the following loop writes at most one character + * to msg[i++] then returns here to validate that there is still space for + * the trailing '\0'. It may (in the case of a parameter) read more than + * one character from message[]; it must check for '\0' and continue to the + * test if it finds the end of string. + */ + while (i<(sizeof msg)-1 && *message != '\0') + { + /* '@' at end of string is now just printed (previously it was skipped); + * it is an error in the calling code to terminate the string with @. + */ + if (p != NULL && *message == '@' && message[1] != '\0') + { + int parameter_char = *++message; /* Consume the '@' */ + static const char valid_parameters[] = "123456789"; + int parameter = 0; + + /* Search for the parameter digit, the index in the string is the + * parameter to use. + */ + while (valid_parameters[parameter] != parameter_char && + valid_parameters[parameter] != '\0') + ++parameter; + + /* If the parameter digit is out of range it will just get printed. */ + if (parameter < PNG_WARNING_PARAMETER_COUNT) + { + /* Append this parameter */ + png_const_charp parm = p[parameter]; + png_const_charp pend = p[parameter] + (sizeof p[parameter]); + + /* No need to copy the trailing '\0' here, but there is no guarantee + * that parm[] has been initialized, so there is no guarantee of a + * trailing '\0': + */ + while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend) + msg[i++] = *parm++; + + /* Consume the parameter digit too: */ + ++message; + continue; + } + + /* else not a parameter and there is a character after the @ sign; just + * copy that. This is known not to be '\0' because of the test above. + */ + } + + /* At this point *message can't be '\0', even in the bad parameter case + * above where there is a lone '@' at the end of the message string. + */ + msg[i++] = *message++; + } + + /* i is always less than (sizeof msg), so: */ + msg[i] = '\0'; + + /* And this is the formatted message. It may be larger than + * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these + * are not (currently) formatted. + */ + png_warning(png_ptr, msg); +} +#endif /* WARNINGS */ + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +void PNGAPI +png_benign_error(png_const_structrp png_ptr, png_const_charp error_message) +{ + if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0) + { +# ifdef PNG_READ_SUPPORTED + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && + png_ptr->chunk_name != 0) + png_chunk_warning(png_ptr, error_message); + else +# endif + png_warning(png_ptr, error_message); + } + + else + { +# ifdef PNG_READ_SUPPORTED + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && + png_ptr->chunk_name != 0) + png_chunk_error(png_ptr, error_message); + else +# endif + png_error(png_ptr, error_message); + } + +# ifndef PNG_ERROR_TEXT_SUPPORTED + PNG_UNUSED(error_message) +# endif +} + +void /* PRIVATE */ +png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) +{ + if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); + +# ifndef PNG_ERROR_TEXT_SUPPORTED + PNG_UNUSED(error_message) +# endif +} + +void /* PRIVATE */ +png_app_error(png_const_structrp png_ptr, png_const_charp error_message) +{ + if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); + +# ifndef PNG_ERROR_TEXT_SUPPORTED + PNG_UNUSED(error_message) +# endif +} +#endif /* BENIGN_ERRORS */ + +#define PNG_MAX_ERROR_TEXT 196 /* Currently limited by profile_error in png.c */ +#if defined(PNG_WARNINGS_SUPPORTED) || \ + (defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)) +/* These utilities are used internally to build an error message that relates + * to the current chunk. The chunk name comes from png_ptr->chunk_name, + * which is used to prefix the message. The message is limited in length + * to 63 bytes. The name characters are output as hex digits wrapped in [] + * if the character is invalid. + */ +#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) +static PNG_CONST char png_digit[16] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F' +}; + +static void /* PRIVATE */ +png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp + error_message) +{ + png_uint_32 chunk_name = png_ptr->chunk_name; + int iout = 0, ishift = 24; + + while (ishift >= 0) + { + int c = (int)(chunk_name >> ishift) & 0xff; + + ishift -= 8; + if (isnonalpha(c) != 0) + { + buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET; + buffer[iout++] = png_digit[(c & 0xf0) >> 4]; + buffer[iout++] = png_digit[c & 0x0f]; + buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET; + } + + else + { + buffer[iout++] = (char)c; + } + } + + if (error_message == NULL) + buffer[iout] = '\0'; + + else + { + int iin = 0; + + buffer[iout++] = ':'; + buffer[iout++] = ' '; + + while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0') + buffer[iout++] = error_message[iin++]; + + /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */ + buffer[iout] = '\0'; + } +} +#endif /* WARNINGS || ERROR_TEXT */ + +#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) +PNG_FUNCTION(void,PNGAPI +png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message), + PNG_NORETURN) +{ + char msg[18+PNG_MAX_ERROR_TEXT]; + if (png_ptr == NULL) + png_error(png_ptr, error_message); + + else + { + png_format_buffer(png_ptr, msg, error_message); + png_error(png_ptr, msg); + } +} +#endif /* READ && ERROR_TEXT */ + +#ifdef PNG_WARNINGS_SUPPORTED +void PNGAPI +png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message) +{ + char msg[18+PNG_MAX_ERROR_TEXT]; + if (png_ptr == NULL) + png_warning(png_ptr, warning_message); + + else + { + png_format_buffer(png_ptr, msg, warning_message); + png_warning(png_ptr, msg); + } +} +#endif /* WARNINGS */ + +#ifdef PNG_READ_SUPPORTED +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +void PNGAPI +png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp + error_message) +{ + if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0) + png_chunk_warning(png_ptr, error_message); + + else + png_chunk_error(png_ptr, error_message); + +# ifndef PNG_ERROR_TEXT_SUPPORTED + PNG_UNUSED(error_message) +# endif +} +#endif +#endif /* READ */ + +void /* PRIVATE */ +png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error) +{ +# ifndef PNG_WARNINGS_SUPPORTED + PNG_UNUSED(message) +# endif + + /* This is always supported, but for just read or just write it + * unconditionally does the right thing. + */ +# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) +# endif + +# ifdef PNG_READ_SUPPORTED + { + if (error < PNG_CHUNK_ERROR) + png_chunk_warning(png_ptr, message); + + else + png_chunk_benign_error(png_ptr, message); + } +# endif + +# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) + else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) +# endif + +# ifdef PNG_WRITE_SUPPORTED + { + if (error < PNG_CHUNK_WRITE_ERROR) + png_app_warning(png_ptr, message); + + else + png_app_error(png_ptr, message); + } +# endif +} + +#ifdef PNG_ERROR_TEXT_SUPPORTED +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_FUNCTION(void, +png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) +{ +# define fixed_message "fixed point overflow in " +# define fixed_message_ln ((sizeof fixed_message)-1) + unsigned int iin; + char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; + memcpy(msg, fixed_message, fixed_message_ln); + iin = 0; + if (name != NULL) + while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0) + { + msg[fixed_message_ln + iin] = name[iin]; + ++iin; + } + msg[fixed_message_ln + iin] = 0; + png_error(png_ptr, msg); +} +#endif +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This API only exists if ANSI-C style error handling is used, + * otherwise it is necessary for png_default_error to be overridden. + */ +jmp_buf* PNGAPI +png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn, + size_t jmp_buf_size) +{ + /* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value + * and it must not change after that. Libpng doesn't care how big the + * buffer is, just that it doesn't change. + * + * If the buffer size is no *larger* than the size of jmp_buf when libpng is + * compiled a built in jmp_buf is returned; this preserves the pre-1.6.0 + * semantics that this call will not fail. If the size is larger, however, + * the buffer is allocated and this may fail, causing the function to return + * NULL. + */ + if (png_ptr == NULL) + return NULL; + + if (png_ptr->jmp_buf_ptr == NULL) + { + png_ptr->jmp_buf_size = 0; /* not allocated */ + + if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local)) + png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; + + else + { + png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *, + png_malloc_warn(png_ptr, jmp_buf_size)); + + if (png_ptr->jmp_buf_ptr == NULL) + return NULL; /* new NULL return on OOM */ + + png_ptr->jmp_buf_size = jmp_buf_size; + } + } + + else /* Already allocated: check the size */ + { + size_t size = png_ptr->jmp_buf_size; + + if (size == 0) + { + size = (sizeof png_ptr->jmp_buf_local); + if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local) + { + /* This is an internal error in libpng: somehow we have been left + * with a stack allocated jmp_buf when the application regained + * control. It's always possible to fix this up, but for the moment + * this is a png_error because that makes it easy to detect. + */ + png_error(png_ptr, "Libpng jmp_buf still allocated"); + /* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */ + } + } + + if (size != jmp_buf_size) + { + png_warning(png_ptr, "Application jmp_buf size changed"); + return NULL; /* caller will probably crash: no choice here */ + } + } + + /* Finally fill in the function, now we have a satisfactory buffer. It is + * valid to change the function on every call. + */ + png_ptr->longjmp_fn = longjmp_fn; + return png_ptr->jmp_buf_ptr; +} + +void /* PRIVATE */ +png_free_jmpbuf(png_structrp png_ptr) +{ + if (png_ptr != NULL) + { + jmp_buf *jb = png_ptr->jmp_buf_ptr; + + /* A size of 0 is used to indicate a local, stack, allocation of the + * pointer; used here and in png.c + */ + if (jb != NULL && png_ptr->jmp_buf_size > 0) + { + + /* This stuff is so that a failure to free the error control structure + * does not leave libpng in a state with no valid error handling: the + * free always succeeds, if there is an error it gets ignored. + */ + if (jb != &png_ptr->jmp_buf_local) + { + /* Make an internal, libpng, jmp_buf to return here */ + jmp_buf free_jmp_buf; + + if (!setjmp(free_jmp_buf)) + { + png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */ + png_ptr->jmp_buf_size = 0; /* stack allocation */ + png_ptr->longjmp_fn = longjmp; + png_free(png_ptr, jb); /* Return to setjmp on error */ + } + } + } + + /* *Always* cancel everything out: */ + png_ptr->jmp_buf_size = 0; + png_ptr->jmp_buf_ptr = NULL; + png_ptr->longjmp_fn = 0; + } +} +#endif + +/* This is the default error handling function. Note that replacements for + * this function MUST NOT RETURN, or the program will likely crash. This + * function is used by default, or if the program supplies NULL for the + * error function pointer in png_set_error_fn(). + */ +static PNG_FUNCTION(void /* PRIVATE */, +png_default_error,(png_const_structrp png_ptr, png_const_charp error_message), + PNG_NORETURN) +{ +#ifdef PNG_CONSOLE_IO_SUPPORTED +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + /* Check on NULL only added in 1.5.4 */ + if (error_message != NULL && *error_message == PNG_LITERAL_SHARP) + { + /* Strip "#nnnn " from beginning of error message. */ + int offset; + char error_number[16]; + for (offset = 0; offset<15; offset++) + { + error_number[offset] = error_message[offset + 1]; + if (error_message[offset] == ' ') + break; + } + + if ((offset > 1) && (offset < 15)) + { + error_number[offset - 1] = '\0'; + fprintf(stderr, "libpng error no. %s: %s", + error_number, error_message + offset + 1); + fprintf(stderr, PNG_STRING_NEWLINE); + } + + else + { + fprintf(stderr, "libpng error: %s, offset=%d", + error_message, offset); + fprintf(stderr, PNG_STRING_NEWLINE); + } + } + else +#endif + { + fprintf(stderr, "libpng error: %s", error_message ? error_message : + "undefined"); + fprintf(stderr, PNG_STRING_NEWLINE); + } +#else + PNG_UNUSED(error_message) /* Make compiler happy */ +#endif + png_longjmp(png_ptr, 1); +} + +PNG_FUNCTION(void,PNGAPI +png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN) +{ +#ifdef PNG_SETJMP_SUPPORTED + if (png_ptr != NULL && png_ptr->longjmp_fn != NULL && + png_ptr->jmp_buf_ptr != NULL) + png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val); +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(val) +#endif + + /* If control reaches this point, png_longjmp() must not return. The only + * choice is to terminate the whole process (or maybe the thread); to do + * this the ANSI-C abort() function is used unless a different method is + * implemented by overriding the default configuration setting for + * PNG_ABORT(). + */ + PNG_ABORT(); +} + +#ifdef PNG_WARNINGS_SUPPORTED +/* This function is called when there is a warning, but the library thinks + * it can continue anyway. Replacement functions don't have to do anything + * here if you don't want them to. In the default configuration, png_ptr is + * not used, but it is passed in case it may be useful. + */ +static void /* PRIVATE */ +png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message) +{ +#ifdef PNG_CONSOLE_IO_SUPPORTED +# ifdef PNG_ERROR_NUMBERS_SUPPORTED + if (*warning_message == PNG_LITERAL_SHARP) + { + int offset; + char warning_number[16]; + for (offset = 0; offset < 15; offset++) + { + warning_number[offset] = warning_message[offset + 1]; + if (warning_message[offset] == ' ') + break; + } + + if ((offset > 1) && (offset < 15)) + { + warning_number[offset + 1] = '\0'; + fprintf(stderr, "libpng warning no. %s: %s", + warning_number, warning_message + offset); + fprintf(stderr, PNG_STRING_NEWLINE); + } + + else + { + fprintf(stderr, "libpng warning: %s", + warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } + } + else +# endif + + { + fprintf(stderr, "libpng warning: %s", warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } +#else + PNG_UNUSED(warning_message) /* Make compiler happy */ +#endif + PNG_UNUSED(png_ptr) /* Make compiler happy */ +} +#endif /* WARNINGS */ + +/* This function is called when the application wants to use another method + * of handling errors and warnings. Note that the error function MUST NOT + * return to the calling routine or serious problems will occur. The return + * method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1) + */ +void PNGAPI +png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warning_fn) +{ + if (png_ptr == NULL) + return; + + png_ptr->error_ptr = error_ptr; + png_ptr->error_fn = error_fn; +#ifdef PNG_WARNINGS_SUPPORTED + png_ptr->warning_fn = warning_fn; +#else + PNG_UNUSED(warning_fn) +#endif +} + + +/* This function returns a pointer to the error_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy and png_read_destroy are called. + */ +png_voidp PNGAPI +png_get_error_ptr(png_const_structrp png_ptr) +{ + if (png_ptr == NULL) + return NULL; + + return ((png_voidp)png_ptr->error_ptr); +} + + +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +void PNGAPI +png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode) +{ + if (png_ptr != NULL) + { + png_ptr->flags &= + ((~(PNG_FLAG_STRIP_ERROR_NUMBERS | + PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); + } +} +#endif + +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) + /* Currently the above both depend on SETJMP_SUPPORTED, however it would be + * possible to implement without setjmp support just so long as there is some + * way to handle the error return here: + */ +PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI +png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), + PNG_NORETURN) +{ + const png_const_structrp png_ptr = png_nonconst_ptr; + png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); + + /* An error is always logged here, overwriting anything (typically a warning) + * that is already there: + */ + if (image != NULL) + { + png_safecat(image->message, (sizeof image->message), 0, error_message); + image->warning_or_error |= PNG_IMAGE_ERROR; + + /* Retrieve the jmp_buf from within the png_control, making this work for + * C++ compilation too is pretty tricky: C++ wants a pointer to the first + * element of a jmp_buf, but C doesn't tell us the type of that. + */ + if (image->opaque != NULL && image->opaque->error_buf != NULL) + longjmp(png_control_jmp_buf(image->opaque), 1); + + /* Missing longjmp buffer, the following is to help debugging: */ + { + size_t pos = png_safecat(image->message, (sizeof image->message), 0, + "bad longjmp: "); + png_safecat(image->message, (sizeof image->message), pos, + error_message); + } + } + + /* Here on an internal programming error. */ + abort(); +} + +#ifdef PNG_WARNINGS_SUPPORTED +void /* PRIVATE */ PNGCBAPI +png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message) +{ + const png_const_structrp png_ptr = png_nonconst_ptr; + png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); + + /* A warning is only logged if there is no prior warning or error. */ + if (image->warning_or_error == 0) + { + png_safecat(image->message, (sizeof image->message), 0, warning_message); + image->warning_or_error |= PNG_IMAGE_WARNING; + } +} +#endif + +int /* PRIVATE */ +png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg) +{ + volatile png_imagep image = image_in; + volatile int result; + volatile png_voidp saved_error_buf; + jmp_buf safe_jmpbuf; + + /* Safely execute function(arg) with png_error returning to this function. */ + saved_error_buf = image->opaque->error_buf; + result = setjmp(safe_jmpbuf) == 0; + + if (result != 0) + { + + image->opaque->error_buf = safe_jmpbuf; + result = function(arg); + } + + image->opaque->error_buf = saved_error_buf; + + /* And do the cleanup prior to any failure return. */ + if (result == 0) + png_image_free(image); + + return result; +} +#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */ +#endif /* READ || WRITE */ diff --git a/xs/src/png/libpng/pngget.c b/xs/src/png/libpng/pngget.c new file mode 100644 index 0000000000..26e9fb1c35 --- /dev/null +++ b/xs/src/png/libpng/pngget.c @@ -0,0 +1,1248 @@ + +/* pngget.c - retrieval of values from info struct + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + */ + +#include "pngpriv.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +png_uint_32 PNGAPI +png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 flag) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->valid & flag); + + return(0); +} + +png_size_t PNGAPI +png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->rowbytes); + + return(0); +} + +#ifdef PNG_INFO_IMAGE_SUPPORTED +png_bytepp PNGAPI +png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->row_pointers); + + return(0); +} +#endif + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Easy access to info, added in libpng-0.99 */ +png_uint_32 PNGAPI +png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return info_ptr->width; + + return (0); +} + +png_uint_32 PNGAPI +png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return info_ptr->height; + + return (0); +} + +png_byte PNGAPI +png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return info_ptr->bit_depth; + + return (0); +} + +png_byte PNGAPI +png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return info_ptr->color_type; + + return (0); +} + +png_byte PNGAPI +png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return info_ptr->filter_type; + + return (0); +} + +png_byte PNGAPI +png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return info_ptr->interlace_type; + + return (0); +} + +png_byte PNGAPI +png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return info_ptr->compression_type; + + return (0); +} + +png_uint_32 PNGAPI +png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp + info_ptr) +{ +#ifdef PNG_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs) != 0) + { + png_debug1(1, "in %s retrieval function", + "png_get_x_pixels_per_meter"); + + if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) + return (info_ptr->x_pixels_per_unit); + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return (0); +} + +png_uint_32 PNGAPI +png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp + info_ptr) +{ +#ifdef PNG_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs) != 0) + { + png_debug1(1, "in %s retrieval function", + "png_get_y_pixels_per_meter"); + + if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) + return (info_ptr->y_pixels_per_unit); + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return (0); +} + +png_uint_32 PNGAPI +png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ +#ifdef PNG_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs) != 0) + { + png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); + + if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && + info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) + return (info_ptr->x_pixels_per_unit); + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return (0); +} + +#ifdef PNG_FLOATING_POINT_SUPPORTED +float PNGAPI +png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp + info_ptr) +{ +#ifdef PNG_READ_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs) != 0) + { + png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); + + if (info_ptr->x_pixels_per_unit != 0) + return ((float)((float)info_ptr->y_pixels_per_unit + /(float)info_ptr->x_pixels_per_unit)); + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return ((float)0.0); +} +#endif + +#ifdef PNG_FIXED_POINT_SUPPORTED +png_fixed_point PNGAPI +png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, + png_const_inforp info_ptr) +{ +#ifdef PNG_READ_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs) != 0 && + info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 && + info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX && + info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) + { + png_fixed_point res; + + png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); + + /* The following casts work because a PNG 4 byte integer only has a valid + * range of 0..2^31-1; otherwise the cast might overflow. + */ + if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, + (png_int_32)info_ptr->x_pixels_per_unit) != 0) + return res; + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return 0; +} +#endif + +png_int_32 PNGAPI +png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ +#ifdef PNG_oFFs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_oFFs) != 0) + { + png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); + + if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) + return (info_ptr->x_offset); + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return (0); +} + +png_int_32 PNGAPI +png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ +#ifdef PNG_oFFs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_oFFs) != 0) + { + png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); + + if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) + return (info_ptr->y_offset); + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return (0); +} + +png_int_32 PNGAPI +png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ +#ifdef PNG_oFFs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_oFFs) != 0) + { + png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); + + if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) + return (info_ptr->x_offset); + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return (0); +} + +png_int_32 PNGAPI +png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ +#ifdef PNG_oFFs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_oFFs) != 0) + { + png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); + + if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) + return (info_ptr->y_offset); + } +#else + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) +#endif + + return (0); +} + +#ifdef PNG_INCH_CONVERSIONS_SUPPORTED +static png_uint_32 +ppi_from_ppm(png_uint_32 ppm) +{ +#if 0 + /* The conversion is *(2.54/100), in binary (32 digits): + * .00000110100000001001110101001001 + */ + png_uint_32 t1001, t1101; + ppm >>= 1; /* .1 */ + t1001 = ppm + (ppm >> 3); /* .1001 */ + t1101 = t1001 + (ppm >> 1); /* .1101 */ + ppm >>= 20; /* .000000000000000000001 */ + t1101 += t1101 >> 15; /* .1101000000000001101 */ + t1001 >>= 11; /* .000000000001001 */ + t1001 += t1001 >> 12; /* .000000000001001000000001001 */ + ppm += t1001; /* .000000000001001000001001001 */ + ppm += t1101; /* .110100000001001110101001001 */ + return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ +#else + /* The argument is a PNG unsigned integer, so it is not permitted + * to be bigger than 2^31. + */ + png_fixed_point result; + if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, + 5000) != 0) + return (png_uint_32)result; + + /* Overflow. */ + return 0; +#endif +} + +png_uint_32 PNGAPI +png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); +} + +png_uint_32 PNGAPI +png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); +} + +png_uint_32 PNGAPI +png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); +} + +#ifdef PNG_FIXED_POINT_SUPPORTED +static png_fixed_point +png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns) +{ + /* Convert from metres * 1,000,000 to inches * 100,000, meters to + * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127. + * Notice that this can overflow - a warning is output and 0 is + * returned. + */ + return png_muldiv_warn(png_ptr, microns, 500, 127); +} + +png_fixed_point PNGAPI +png_get_x_offset_inches_fixed(png_const_structrp png_ptr, + png_const_inforp info_ptr) +{ + return png_fixed_inches_from_microns(png_ptr, + png_get_x_offset_microns(png_ptr, info_ptr)); +} +#endif + +#ifdef PNG_FIXED_POINT_SUPPORTED +png_fixed_point PNGAPI +png_get_y_offset_inches_fixed(png_const_structrp png_ptr, + png_const_inforp info_ptr) +{ + return png_fixed_inches_from_microns(png_ptr, + png_get_y_offset_microns(png_ptr, info_ptr)); +} +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +float PNGAPI +png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + /* To avoid the overflow do the conversion directly in floating + * point. + */ + return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937); +} +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +float PNGAPI +png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + /* To avoid the overflow do the conversion directly in floating + * point. + */ + return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937); +} +#endif + +#ifdef PNG_pHYs_SUPPORTED +png_uint_32 PNGAPI +png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +{ + png_uint_32 retval = 0; + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs) != 0) + { + png_debug1(1, "in %s retrieval function", "pHYs"); + + if (res_x != NULL) + { + *res_x = info_ptr->x_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + + if (res_y != NULL) + { + *res_y = info_ptr->y_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + + if (unit_type != NULL) + { + *unit_type = (int)info_ptr->phys_unit_type; + retval |= PNG_INFO_pHYs; + + if (*unit_type == 1) + { + if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); + if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); + } + } + } + + return (retval); +} +#endif /* pHYs */ +#endif /* INCH_CONVERSIONS */ + +/* png_get_channels really belongs in here, too, but it's been around longer */ + +#endif /* EASY_ACCESS */ + + +png_byte PNGAPI +png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->channels); + + return (0); +} + +#ifdef PNG_READ_SUPPORTED +png_const_bytep PNGAPI +png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->signature); + + return (NULL); +} +#endif + +#ifdef PNG_bKGD_SUPPORTED +png_uint_32 PNGAPI +png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, + png_color_16p *background) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_bKGD) != 0 && + background != NULL) + { + png_debug1(1, "in %s retrieval function", "bKGD"); + + *background = &(info_ptr->background); + return (PNG_INFO_bKGD); + } + + return (0); +} +#endif + +#ifdef PNG_cHRM_SUPPORTED +/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the + * same time to correct the rgb grayscale coefficient defaults obtained from the + * cHRM chunk in 1.5.4 + */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, + double *white_x, double *white_y, double *red_x, double *red_y, + double *green_x, double *green_y, double *blue_x, double *blue_y) +{ + /* Quiet API change: this code used to only return the end points if a cHRM + * chunk was present, but the end points can also come from iCCP or sRGB + * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and + * the png_set_ APIs merely check that set end points are mutually + * consistent. + */ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + { + png_debug1(1, "in %s retrieval function", "cHRM"); + + if (white_x != NULL) + *white_x = png_float(png_ptr, + info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); + if (white_y != NULL) + *white_y = png_float(png_ptr, + info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); + if (red_x != NULL) + *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, + "cHRM red X"); + if (red_y != NULL) + *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, + "cHRM red Y"); + if (green_x != NULL) + *green_x = png_float(png_ptr, + info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); + if (green_y != NULL) + *green_y = png_float(png_ptr, + info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); + if (blue_x != NULL) + *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, + "cHRM blue X"); + if (blue_y != NULL) + *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, + "cHRM blue Y"); + return (PNG_INFO_cHRM); + } + + return (0); +} + +png_uint_32 PNGAPI +png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, + double *red_X, double *red_Y, double *red_Z, double *green_X, + double *green_Y, double *green_Z, double *blue_X, double *blue_Y, + double *blue_Z) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + { + png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); + + if (red_X != NULL) + *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, + "cHRM red X"); + if (red_Y != NULL) + *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, + "cHRM red Y"); + if (red_Z != NULL) + *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z, + "cHRM red Z"); + if (green_X != NULL) + *green_X = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); + if (green_Y != NULL) + *green_Y = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); + if (green_Z != NULL) + *green_Z = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); + if (blue_X != NULL) + *blue_X = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); + if (blue_Y != NULL) + *blue_Y = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); + if (blue_Z != NULL) + *blue_Z = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); + return (PNG_INFO_cHRM); + } + + return (0); +} +# endif + +# ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_red_X, png_fixed_point *int_red_Y, + png_fixed_point *int_red_Z, png_fixed_point *int_green_X, + png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, + png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, + png_fixed_point *int_blue_Z) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + { + png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); + + if (int_red_X != NULL) + *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; + if (int_red_Y != NULL) + *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y; + if (int_red_Z != NULL) + *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z; + if (int_green_X != NULL) + *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X; + if (int_green_Y != NULL) + *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y; + if (int_green_Z != NULL) + *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z; + if (int_blue_X != NULL) + *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X; + if (int_blue_Y != NULL) + *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y; + if (int_blue_Z != NULL) + *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z; + return (PNG_INFO_cHRM); + } + + return (0); +} + +png_uint_32 PNGAPI +png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, + png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, + png_fixed_point *blue_x, png_fixed_point *blue_y) +{ + png_debug1(1, "in %s retrieval function", "cHRM"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + { + if (white_x != NULL) + *white_x = info_ptr->colorspace.end_points_xy.whitex; + if (white_y != NULL) + *white_y = info_ptr->colorspace.end_points_xy.whitey; + if (red_x != NULL) + *red_x = info_ptr->colorspace.end_points_xy.redx; + if (red_y != NULL) + *red_y = info_ptr->colorspace.end_points_xy.redy; + if (green_x != NULL) + *green_x = info_ptr->colorspace.end_points_xy.greenx; + if (green_y != NULL) + *green_y = info_ptr->colorspace.end_points_xy.greeny; + if (blue_x != NULL) + *blue_x = info_ptr->colorspace.end_points_xy.bluex; + if (blue_y != NULL) + *blue_y = info_ptr->colorspace.end_points_xy.bluey; + return (PNG_INFO_cHRM); + } + + return (0); +} +# endif +#endif + +#ifdef PNG_gAMA_SUPPORTED +# ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *file_gamma) +{ + png_debug1(1, "in %s retrieval function", "gAMA"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && + file_gamma != NULL) + { + *file_gamma = info_ptr->colorspace.gamma; + return (PNG_INFO_gAMA); + } + + return (0); +} +# endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, + double *file_gamma) +{ + png_debug1(1, "in %s retrieval function", "gAMA(float)"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && + file_gamma != NULL) + { + *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, + "png_get_gAMA"); + return (PNG_INFO_gAMA); + } + + return (0); +} +# endif +#endif + +#ifdef PNG_sRGB_SUPPORTED +png_uint_32 PNGAPI +png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, + int *file_srgb_intent) +{ + png_debug1(1, "in %s retrieval function", "sRGB"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL) + { + *file_srgb_intent = info_ptr->colorspace.rendering_intent; + return (PNG_INFO_sRGB); + } + + return (0); +} +#endif + +#ifdef PNG_iCCP_SUPPORTED +png_uint_32 PNGAPI +png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, + png_charpp name, int *compression_type, + png_bytepp profile, png_uint_32 *proflen) +{ + png_debug1(1, "in %s retrieval function", "iCCP"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_iCCP) != 0 && + name != NULL && compression_type != NULL && profile != NULL && + proflen != NULL) + { + *name = info_ptr->iccp_name; + *profile = info_ptr->iccp_profile; + *proflen = png_get_uint_32(info_ptr->iccp_profile); + /* This is somewhat irrelevant since the profile data returned has + * actually been uncompressed. + */ + *compression_type = PNG_COMPRESSION_TYPE_BASE; + return (PNG_INFO_iCCP); + } + + return (0); +} +#endif + +#ifdef PNG_sPLT_SUPPORTED +int PNGAPI +png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, + png_sPLT_tpp spalettes) +{ + if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) + { + *spalettes = info_ptr->splt_palettes; + return info_ptr->splt_palettes_num; + } + + return (0); +} +#endif + +#ifdef PNG_eXIf_SUPPORTED +png_uint_32 PNGAPI +png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, + png_bytep *exif) +{ + png_warning(png_ptr, "png_get_eXIf does not work; use png_get_eXIf_1"); + PNG_UNUSED(info_ptr) + PNG_UNUSED(exif) + return 0; +} + +png_uint_32 PNGAPI +png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 *num_exif, png_bytep *exif) +{ + png_debug1(1, "in %s retrieval function", "eXIf"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL) + { + *num_exif = info_ptr->num_exif; + *exif = info_ptr->exif; + return (PNG_INFO_eXIf); + } + + return (0); +} +#endif + +#ifdef PNG_hIST_SUPPORTED +png_uint_32 PNGAPI +png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, + png_uint_16p *hist) +{ + png_debug1(1, "in %s retrieval function", "hIST"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL) + { + *hist = info_ptr->hist; + return (PNG_INFO_hIST); + } + + return (0); +} +#endif + +png_uint_32 PNGAPI +png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 *width, png_uint_32 *height, int *bit_depth, + int *color_type, int *interlace_type, int *compression_type, + int *filter_type) +{ + png_debug1(1, "in %s retrieval function", "IHDR"); + + if (png_ptr == NULL || info_ptr == NULL) + return (0); + + if (width != NULL) + *width = info_ptr->width; + + if (height != NULL) + *height = info_ptr->height; + + if (bit_depth != NULL) + *bit_depth = info_ptr->bit_depth; + + if (color_type != NULL) + *color_type = info_ptr->color_type; + + if (compression_type != NULL) + *compression_type = info_ptr->compression_type; + + if (filter_type != NULL) + *filter_type = info_ptr->filter_type; + + if (interlace_type != NULL) + *interlace_type = info_ptr->interlace_type; + + /* This is redundant if we can be sure that the info_ptr values were all + * assigned in png_set_IHDR(). We do the check anyhow in case an + * application has ignored our advice not to mess with the members + * of info_ptr directly. + */ + png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, + info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, + info_ptr->compression_type, info_ptr->filter_type); + + return (1); +} + +#ifdef PNG_oFFs_SUPPORTED +png_uint_32 PNGAPI +png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) +{ + png_debug1(1, "in %s retrieval function", "oFFs"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_oFFs) != 0 && + offset_x != NULL && offset_y != NULL && unit_type != NULL) + { + *offset_x = info_ptr->x_offset; + *offset_y = info_ptr->y_offset; + *unit_type = (int)info_ptr->offset_unit_type; + return (PNG_INFO_oFFs); + } + + return (0); +} +#endif + +#ifdef PNG_pCAL_SUPPORTED +png_uint_32 PNGAPI +png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, + png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, + png_charp *units, png_charpp *params) +{ + png_debug1(1, "in %s retrieval function", "pCAL"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pCAL) != 0 && + purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && + nparams != NULL && units != NULL && params != NULL) + { + *purpose = info_ptr->pcal_purpose; + *X0 = info_ptr->pcal_X0; + *X1 = info_ptr->pcal_X1; + *type = (int)info_ptr->pcal_type; + *nparams = (int)info_ptr->pcal_nparams; + *units = info_ptr->pcal_units; + *params = info_ptr->pcal_params; + return (PNG_INFO_pCAL); + } + + return (0); +} +#endif + +#ifdef PNG_sCAL_SUPPORTED +# ifdef PNG_FIXED_POINT_SUPPORTED +# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ + defined(PNG_FLOATING_POINT_SUPPORTED) +png_uint_32 PNGAPI +png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + int *unit, png_fixed_point *width, png_fixed_point *height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL) != 0) + { + *unit = info_ptr->scal_unit; + /*TODO: make this work without FP support; the API is currently eliminated + * if neither floating point APIs nor internal floating point arithmetic + * are enabled. + */ + *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); + *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), + "sCAL height"); + return (PNG_INFO_sCAL); + } + + return(0); +} +# endif /* FLOATING_ARITHMETIC */ +# endif /* FIXED_POINT */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, + int *unit, double *width, double *height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL) != 0) + { + *unit = info_ptr->scal_unit; + *width = atof(info_ptr->scal_s_width); + *height = atof(info_ptr->scal_s_height); + return (PNG_INFO_sCAL); + } + + return(0); +} +# endif /* FLOATING POINT */ +png_uint_32 PNGAPI +png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, + int *unit, png_charpp width, png_charpp height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL) != 0) + { + *unit = info_ptr->scal_unit; + *width = info_ptr->scal_s_width; + *height = info_ptr->scal_s_height; + return (PNG_INFO_sCAL); + } + + return(0); +} +#endif /* sCAL */ + +#ifdef PNG_pHYs_SUPPORTED +png_uint_32 PNGAPI +png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +{ + png_uint_32 retval = 0; + + png_debug1(1, "in %s retrieval function", "pHYs"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs) != 0) + { + if (res_x != NULL) + { + *res_x = info_ptr->x_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + + if (res_y != NULL) + { + *res_y = info_ptr->y_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + + if (unit_type != NULL) + { + *unit_type = (int)info_ptr->phys_unit_type; + retval |= PNG_INFO_pHYs; + } + } + + return (retval); +} +#endif /* pHYs */ + +png_uint_32 PNGAPI +png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, + png_colorp *palette, int *num_palette) +{ + png_debug1(1, "in %s retrieval function", "PLTE"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL) + { + *palette = info_ptr->palette; + *num_palette = info_ptr->num_palette; + png_debug1(3, "num_palette = %d", *num_palette); + return (PNG_INFO_PLTE); + } + + return (0); +} + +#ifdef PNG_sBIT_SUPPORTED +png_uint_32 PNGAPI +png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, + png_color_8p *sig_bit) +{ + png_debug1(1, "in %s retrieval function", "sBIT"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL) + { + *sig_bit = &(info_ptr->sig_bit); + return (PNG_INFO_sBIT); + } + + return (0); +} +#endif + +#ifdef PNG_TEXT_SUPPORTED +int PNGAPI +png_get_text(png_const_structrp png_ptr, png_inforp info_ptr, + png_textp *text_ptr, int *num_text) +{ + if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) + { + png_debug1(1, "in 0x%lx retrieval function", + (unsigned long)png_ptr->chunk_name); + + if (text_ptr != NULL) + *text_ptr = info_ptr->text; + + if (num_text != NULL) + *num_text = info_ptr->num_text; + + return info_ptr->num_text; + } + + if (num_text != NULL) + *num_text = 0; + + return(0); +} +#endif + +#ifdef PNG_tIME_SUPPORTED +png_uint_32 PNGAPI +png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, + png_timep *mod_time) +{ + png_debug1(1, "in %s retrieval function", "tIME"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL) + { + *mod_time = &(info_ptr->mod_time); + return (PNG_INFO_tIME); + } + + return (0); +} +#endif + +#ifdef PNG_tRNS_SUPPORTED +png_uint_32 PNGAPI +png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, + png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) +{ + png_uint_32 retval = 0; + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_tRNS) != 0) + { + png_debug1(1, "in %s retrieval function", "tRNS"); + + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (trans_alpha != NULL) + { + *trans_alpha = info_ptr->trans_alpha; + retval |= PNG_INFO_tRNS; + } + + if (trans_color != NULL) + *trans_color = &(info_ptr->trans_color); + } + + else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ + { + if (trans_color != NULL) + { + *trans_color = &(info_ptr->trans_color); + retval |= PNG_INFO_tRNS; + } + + if (trans_alpha != NULL) + *trans_alpha = NULL; + } + + if (num_trans != NULL) + { + *num_trans = info_ptr->num_trans; + retval |= PNG_INFO_tRNS; + } + } + + return (retval); +} +#endif + +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +int PNGAPI +png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, + png_unknown_chunkpp unknowns) +{ + if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) + { + *unknowns = info_ptr->unknown_chunks; + return info_ptr->unknown_chunks_num; + } + + return (0); +} +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +png_byte PNGAPI +png_get_rgb_to_gray_status (png_const_structrp png_ptr) +{ + return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); +} +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +png_voidp PNGAPI +png_get_user_chunk_ptr(png_const_structrp png_ptr) +{ + return (png_ptr ? png_ptr->user_chunk_ptr : NULL); +} +#endif + +png_size_t PNGAPI +png_get_compression_buffer_size(png_const_structrp png_ptr) +{ + if (png_ptr == NULL) + return 0; + +#ifdef PNG_WRITE_SUPPORTED + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) +#endif + { +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED + return png_ptr->IDAT_read_size; +#else + return PNG_IDAT_READ_SIZE; +#endif + } + +#ifdef PNG_WRITE_SUPPORTED + else + return png_ptr->zbuffer_size; +#endif +} + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +/* These functions were added to libpng 1.2.6 and were enabled + * by default in libpng-1.4.0 */ +png_uint_32 PNGAPI +png_get_user_width_max (png_const_structrp png_ptr) +{ + return (png_ptr ? png_ptr->user_width_max : 0); +} + +png_uint_32 PNGAPI +png_get_user_height_max (png_const_structrp png_ptr) +{ + return (png_ptr ? png_ptr->user_height_max : 0); +} + +/* This function was added to libpng 1.4.0 */ +png_uint_32 PNGAPI +png_get_chunk_cache_max (png_const_structrp png_ptr) +{ + return (png_ptr ? png_ptr->user_chunk_cache_max : 0); +} + +/* This function was added to libpng 1.4.1 */ +png_alloc_size_t PNGAPI +png_get_chunk_malloc_max (png_const_structrp png_ptr) +{ + return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); +} +#endif /* SET_USER_LIMITS */ + +/* These functions were added to libpng 1.4.0 */ +#ifdef PNG_IO_STATE_SUPPORTED +png_uint_32 PNGAPI +png_get_io_state (png_const_structrp png_ptr) +{ + return png_ptr->io_state; +} + +png_uint_32 PNGAPI +png_get_io_chunk_type (png_const_structrp png_ptr) +{ + return png_ptr->chunk_name; +} +#endif /* IO_STATE */ + +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED +# ifdef PNG_GET_PALETTE_MAX_SUPPORTED +int PNGAPI +png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return png_ptr->num_palette_max; + + return (-1); +} +# endif +#endif + +#endif /* READ || WRITE */ diff --git a/xs/src/png/libpng/pnginfo.h b/xs/src/png/libpng/pnginfo.h new file mode 100644 index 0000000000..d5f6149dbd --- /dev/null +++ b/xs/src/png/libpng/pnginfo.h @@ -0,0 +1,267 @@ + +/* pnginfo.h - header file for PNG reference library + * + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + + /* png_info is a structure that holds the information in a PNG file so + * that the application can find out the characteristics of the image. + * If you are reading the file, this structure will tell you what is + * in the PNG file. If you are writing the file, fill in the information + * you want to put into the PNG file, using png_set_*() functions, then + * call png_write_info(). + * + * The names chosen should be very close to the PNG specification, so + * consult that document for information about the meaning of each field. + * + * With libpng < 0.95, it was only possible to directly set and read the + * the values in the png_info_struct, which meant that the contents and + * order of the values had to remain fixed. With libpng 0.95 and later, + * however, there are now functions that abstract the contents of + * png_info_struct from the application, so this makes it easier to use + * libpng with dynamic libraries, and even makes it possible to use + * libraries that don't have all of the libpng ancillary chunk-handing + * functionality. In libpng-1.5.0 this was moved into a separate private + * file that is not visible to applications. + * + * The following members may have allocated storage attached that should be + * cleaned up before the structure is discarded: palette, trans, text, + * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, + * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these + * are automatically freed when the info structure is deallocated, if they were + * allocated internally by libpng. This behavior can be changed by means + * of the png_data_freer() function. + * + * More allocation details: all the chunk-reading functions that + * change these members go through the corresponding png_set_* + * functions. A function to clear these members is available: see + * png_free_data(). The png_set_* functions do not depend on being + * able to point info structure members to any of the storage they are + * passed (they make their own copies), EXCEPT that the png_set_text + * functions use the same storage passed to them in the text_ptr or + * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns + * functions do not make their own copies. + */ +#ifndef PNGINFO_H +#define PNGINFO_H + +struct png_info_def +{ + /* The following are necessary for every PNG file */ + png_uint_32 width; /* width of image in pixels (from IHDR) */ + png_uint_32 height; /* height of image in pixels (from IHDR) */ + png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ + png_size_t rowbytes; /* bytes needed to hold an untransformed row */ + png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ + png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ + png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ + png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ + png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ + /* The following three should have been named *_method not *_type */ + png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ + png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ + png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + + /* The following are set by png_set_IHDR, called from the application on + * write, but the are never actually used by the write code. + */ + png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte spare_byte; /* to align the data, and for future use */ + +#ifdef PNG_READ_SUPPORTED + /* This is never set during write */ + png_byte signature[8]; /* magic bytes read by libpng from start of file */ +#endif + + /* The rest of the data is optional. If you are reading, check the + * valid field to see if the information in these are valid. If you + * are writing, set the valid field to those chunks you want written, + * and initialize the appropriate fields below. + */ + +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) + /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are + * defined. When COLORSPACE is switched on all the colorspace-defining + * chunks should be enabled, when GAMMA is switched on all the gamma-defining + * chunks should be enabled. If this is not done it becomes possible to read + * inconsistent PNG files and assign a probably incorrect interpretation to + * the information. (In other words, by carefully choosing which chunks to + * recognize the system configuration can select an interpretation for PNG + * files containing ambiguous data and this will result in inconsistent + * behavior between different libpng builds!) + */ + png_colorspace colorspace; +#endif + +#ifdef PNG_iCCP_SUPPORTED + /* iCCP chunk data. */ + png_charp iccp_name; /* profile name */ + png_bytep iccp_profile; /* International Color Consortium profile data */ + png_uint_32 iccp_proflen; /* ICC profile data length */ +#endif + +#ifdef PNG_TEXT_SUPPORTED + /* The tEXt, and zTXt chunks contain human-readable textual data in + * uncompressed, compressed, and optionally compressed forms, respectively. + * The data in "text" is an array of pointers to uncompressed, + * null-terminated C strings. Each chunk has a keyword that describes the + * textual data contained in that chunk. Keywords are not required to be + * unique, and the text string may be empty. Any number of text chunks may + * be in an image. + */ + int num_text; /* number of comments read or comments to write */ + int max_text; /* current size of text array */ + png_textp text; /* array of comments read or comments to write */ +#endif /* TEXT */ + +#ifdef PNG_tIME_SUPPORTED + /* The tIME chunk holds the last time the displayed image data was + * modified. See the png_time struct for the contents of this struct. + */ + png_time mod_time; +#endif + +#ifdef PNG_sBIT_SUPPORTED + /* The sBIT chunk specifies the number of significant high-order bits + * in the pixel data. Values are in the range [1, bit_depth], and are + * only specified for the channels in the pixel data. The contents of + * the low-order bits is not specified. Data is valid if + * (valid & PNG_INFO_sBIT) is non-zero. + */ + png_color_8 sig_bit; /* significant bits in color channels */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ +defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The tRNS chunk supplies transparency data for paletted images and + * other image types that don't need a full alpha channel. There are + * "num_trans" transparency values for a paletted image, stored in the + * same order as the palette colors, starting from index 0. Values + * for the data are in the range [0, 255], ranging from fully transparent + * to fully opaque, respectively. For non-paletted images, there is a + * single color specified that should be treated as fully transparent. + * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. + */ + png_bytep trans_alpha; /* alpha values for paletted image */ + png_color_16 trans_color; /* transparent color for non-palette image */ +#endif + +#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The bKGD chunk gives the suggested image background color if the + * display program does not have its own background color and the image + * is needs to composited onto a background before display. The colors + * in "background" are normally in the same color space/depth as the + * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. + */ + png_color_16 background; +#endif + +#ifdef PNG_oFFs_SUPPORTED + /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards + * and downwards from the top-left corner of the display, page, or other + * application-specific co-ordinate space. See the PNG_OFFSET_ defines + * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. + */ + png_int_32 x_offset; /* x offset on page */ + png_int_32 y_offset; /* y offset on page */ + png_byte offset_unit_type; /* offset units type */ +#endif + +#ifdef PNG_pHYs_SUPPORTED + /* The pHYs chunk gives the physical pixel density of the image for + * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ + * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. + */ + png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ + png_uint_32 y_pixels_per_unit; /* vertical pixel density */ + png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ +#endif + +#ifdef PNG_eXIf_SUPPORTED + int num_exif; /* Added at libpng-1.6.31 */ + png_bytep exif; +# ifdef PNG_READ_eXIf_SUPPORTED + png_bytep eXIf_buf; /* Added at libpng-1.6.32 */ +# endif +#endif + +#ifdef PNG_hIST_SUPPORTED + /* The hIST chunk contains the relative frequency or importance of the + * various palette entries, so that a viewer can intelligently select a + * reduced-color palette, if required. Data is an array of "num_palette" + * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) + * is non-zero. + */ + png_uint_16p hist; +#endif + +#ifdef PNG_pCAL_SUPPORTED + /* The pCAL chunk describes a transformation between the stored pixel + * values and original physical data values used to create the image. + * The integer range [0, 2^bit_depth - 1] maps to the floating-point + * range given by [pcal_X0, pcal_X1], and are further transformed by a + * (possibly non-linear) transformation function given by "pcal_type" + * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ + * defines below, and the PNG-Group's PNG extensions document for a + * complete description of the transformations and how they should be + * implemented, and for a description of the ASCII parameter strings. + * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. + */ + png_charp pcal_purpose; /* pCAL chunk description string */ + png_int_32 pcal_X0; /* minimum value */ + png_int_32 pcal_X1; /* maximum value */ + png_charp pcal_units; /* Latin-1 string giving physical units */ + png_charpp pcal_params; /* ASCII strings containing parameter values */ + png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ + png_byte pcal_nparams; /* number of parameters given in pcal_params */ +#endif + +/* New members added in libpng-1.0.6 */ + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ + +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED + /* Storage for unknown chunks that the library doesn't recognize. */ + png_unknown_chunkp unknown_chunks; + + /* The type of this field is limited by the type of + * png_struct::user_chunk_cache_max, else overflow can occur. + */ + int unknown_chunks_num; +#endif + +#ifdef PNG_sPLT_SUPPORTED + /* Data on sPLT chunks (there may be more than one). */ + png_sPLT_tp splt_palettes; + int splt_palettes_num; /* Match type returned by png_get API */ +#endif + +#ifdef PNG_sCAL_SUPPORTED + /* The sCAL chunk describes the actual physical dimensions of the + * subject matter of the graphic. The chunk contains a unit specification + * a byte value, and two ASCII strings representing floating-point + * values. The values are width and height corresponsing to one pixel + * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is + * non-zero. + */ + png_byte scal_unit; /* unit of physical scale */ + png_charp scal_s_width; /* string containing height */ + png_charp scal_s_height; /* string containing width */ +#endif + +#ifdef PNG_INFO_IMAGE_SUPPORTED + /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) + non-zero */ + /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ + png_bytepp row_pointers; /* the image bits */ +#endif + +}; +#endif /* PNGINFO_H */ diff --git a/xs/src/png/libpng/pngmem.c b/xs/src/png/libpng/pngmem.c new file mode 100644 index 0000000000..ff3ef7e88c --- /dev/null +++ b/xs/src/png/libpng/pngmem.c @@ -0,0 +1,284 @@ + +/* pngmem.c - stub functions for memory allocation + * + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * This file provides a location for all memory allocation. Users who + * need special memory handling are expected to supply replacement + * functions for png_malloc() and png_free(), and to use + * png_create_read_struct_2() and png_create_write_struct_2() to + * identify the replacement functions. + */ + +#include "pngpriv.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +/* Free a png_struct */ +void /* PRIVATE */ +png_destroy_png_struct(png_structrp png_ptr) +{ + if (png_ptr != NULL) + { + /* png_free might call png_error and may certainly call + * png_get_mem_ptr, so fake a temporary png_struct to support this. + */ + png_struct dummy_struct = *png_ptr; + memset(png_ptr, 0, (sizeof *png_ptr)); + png_free(&dummy_struct, png_ptr); + +# ifdef PNG_SETJMP_SUPPORTED + /* We may have a jmp_buf left to deallocate. */ + png_free_jmpbuf(&dummy_struct); +# endif + } +} + +/* Allocate memory. For reasonable files, size should never exceed + * 64K. However, zlib may allocate more than 64K if you don't tell + * it not to. See zconf.h and png.h for more information. zlib does + * need to allocate exactly 64K, so whatever you call here must + * have the ability to do that. + */ +PNG_FUNCTION(png_voidp,PNGAPI +png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) +{ + png_voidp ret; + + ret = png_malloc(png_ptr, size); + + if (ret != NULL) + memset(ret, 0, size); + + return ret; +} + +/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of + * allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED. + * Checking and error handling must happen outside this routine; it returns NULL + * if the allocation cannot be done (for any reason.) + */ +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED) +{ + /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS + * allocators have also been removed in 1.6.0, so any 16-bit system now has + * to implement a user memory handler. This checks to be sure it isn't + * called with big numbers. + */ +#ifndef PNG_USER_MEM_SUPPORTED + PNG_UNUSED(png_ptr) +#endif + + /* Some compilers complain that this is always true. However, it + * can be false when integer overflow happens. + */ + if (size > 0 && size <= PNG_SIZE_MAX +# ifdef PNG_MAX_MALLOC_64K + && size <= 65536U +# endif + ) + { +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr != NULL && png_ptr->malloc_fn != NULL) + return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size); + + else +#endif + return malloc((size_t)size); /* checked for truncation above */ + } + + else + return NULL; +} + +#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\ + defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) +/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7 + * that arises because of the checks in png_realloc_array that are repeated in + * png_malloc_array. + */ +static png_voidp +png_malloc_array_checked(png_const_structrp png_ptr, int nelements, + size_t element_size) +{ + png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */ + + if (req <= PNG_SIZE_MAX/element_size) + return png_malloc_base(png_ptr, req * element_size); + + /* The failure case when the request is too large */ + return NULL; +} + +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_malloc_array,(png_const_structrp png_ptr, int nelements, + size_t element_size),PNG_ALLOCATED) +{ + if (nelements <= 0 || element_size == 0) + png_error(png_ptr, "internal error: array alloc"); + + return png_malloc_array_checked(png_ptr, nelements, element_size); +} + +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, + int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED) +{ + /* These are internal errors: */ + if (add_elements <= 0 || element_size == 0 || old_elements < 0 || + (old_array == NULL && old_elements > 0)) + png_error(png_ptr, "internal error: array realloc"); + + /* Check for overflow on the elements count (so the caller does not have to + * check.) + */ + if (add_elements <= INT_MAX - old_elements) + { + png_voidp new_array = png_malloc_array_checked(png_ptr, + old_elements+add_elements, element_size); + + if (new_array != NULL) + { + /* Because png_malloc_array worked the size calculations below cannot + * overflow. + */ + if (old_elements > 0) + memcpy(new_array, old_array, element_size*(unsigned)old_elements); + + memset((char*)new_array + element_size*(unsigned)old_elements, 0, + element_size*(unsigned)add_elements); + + return new_array; + } + } + + return NULL; /* error */ +} +#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */ + +/* Various functions that have different error handling are derived from this. + * png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate + * function png_malloc_default is also provided. + */ +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) +{ + png_voidp ret; + + if (png_ptr == NULL) + return NULL; + + ret = png_malloc_base(png_ptr, size); + + if (ret == NULL) + png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */ + + return ret; +} + +#ifdef PNG_USER_MEM_SUPPORTED +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED PNG_DEPRECATED) +{ + png_voidp ret; + + if (png_ptr == NULL) + return NULL; + + /* Passing 'NULL' here bypasses the application provided memory handler. */ + ret = png_malloc_base(NULL/*use malloc*/, size); + + if (ret == NULL) + png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */ + + return ret; +} +#endif /* USER_MEM */ + +/* This function was added at libpng version 1.2.3. The png_malloc_warn() + * function will issue a png_warning and return NULL instead of issuing a + * png_error, if it fails to allocate the requested memory. + */ +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED) +{ + if (png_ptr != NULL) + { + png_voidp ret = png_malloc_base(png_ptr, size); + + if (ret != NULL) + return ret; + + png_warning(png_ptr, "Out of memory"); + } + + return NULL; +} + +/* Free a pointer allocated by png_malloc(). If ptr is NULL, return + * without taking any action. + */ +void PNGAPI +png_free(png_const_structrp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL || ptr == NULL) + return; + +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr->free_fn != NULL) + png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr); + + else + png_free_default(png_ptr, ptr); +} + +PNG_FUNCTION(void,PNGAPI +png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED) +{ + if (png_ptr == NULL || ptr == NULL) + return; +#endif /* USER_MEM */ + + free(ptr); +} + +#ifdef PNG_USER_MEM_SUPPORTED +/* This function is called when the application wants to use another method + * of allocating and freeing memory. + */ +void PNGAPI +png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr + malloc_fn, png_free_ptr free_fn) +{ + if (png_ptr != NULL) + { + png_ptr->mem_ptr = mem_ptr; + png_ptr->malloc_fn = malloc_fn; + png_ptr->free_fn = free_fn; + } +} + +/* This function returns a pointer to the mem_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy and png_read_destroy are called. + */ +png_voidp PNGAPI +png_get_mem_ptr(png_const_structrp png_ptr) +{ + if (png_ptr == NULL) + return NULL; + + return png_ptr->mem_ptr; +} +#endif /* USER_MEM */ +#endif /* READ || WRITE */ diff --git a/xs/src/png/libpng/pngpread.c b/xs/src/png/libpng/pngpread.c new file mode 100644 index 0000000000..fbe361dc34 --- /dev/null +++ b/xs/src/png/libpng/pngpread.c @@ -0,0 +1,1096 @@ + +/* pngpread.c - read a png file in push mode + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "pngpriv.h" + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + +/* Push model modes */ +#define PNG_READ_SIG_MODE 0 +#define PNG_READ_CHUNK_MODE 1 +#define PNG_READ_IDAT_MODE 2 +#define PNG_READ_tEXt_MODE 4 +#define PNG_READ_zTXt_MODE 5 +#define PNG_READ_DONE_MODE 6 +#define PNG_READ_iTXt_MODE 7 +#define PNG_ERROR_MODE 8 + +#define PNG_PUSH_SAVE_BUFFER_IF_FULL \ +if (png_ptr->push_length + 4 > png_ptr->buffer_size) \ + { png_push_save_buffer(png_ptr); return; } +#define PNG_PUSH_SAVE_BUFFER_IF_LT(N) \ +if (png_ptr->buffer_size < N) \ + { png_push_save_buffer(png_ptr); return; } + +void PNGAPI +png_process_data(png_structrp png_ptr, png_inforp info_ptr, + png_bytep buffer, png_size_t buffer_size) +{ + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_push_restore_buffer(png_ptr, buffer, buffer_size); + + while (png_ptr->buffer_size) + { + png_process_some_data(png_ptr, info_ptr); + } +} + +png_size_t PNGAPI +png_process_data_pause(png_structrp png_ptr, int save) +{ + if (png_ptr != NULL) + { + /* It's easiest for the caller if we do the save; then the caller doesn't + * have to supply the same data again: + */ + if (save != 0) + png_push_save_buffer(png_ptr); + else + { + /* This includes any pending saved bytes: */ + png_size_t remaining = png_ptr->buffer_size; + png_ptr->buffer_size = 0; + + /* So subtract the saved buffer size, unless all the data + * is actually 'saved', in which case we just return 0 + */ + if (png_ptr->save_buffer_size < remaining) + return remaining - png_ptr->save_buffer_size; + } + } + + return 0; +} + +png_uint_32 PNGAPI +png_process_data_skip(png_structrp png_ptr) +{ +/* TODO: Deprecate and remove this API. + * Somewhere the implementation of this seems to have been lost, + * or abandoned. It was only to support some internal back-door access + * to png_struct) in libpng-1.4.x. + */ + png_app_warning(png_ptr, +"png_process_data_skip is not implemented in any current version of libpng"); + return 0; +} + +/* What we do with the incoming data depends on what we were previously + * doing before we ran out of data... + */ +void /* PRIVATE */ +png_process_some_data(png_structrp png_ptr, png_inforp info_ptr) +{ + if (png_ptr == NULL) + return; + + switch (png_ptr->process_mode) + { + case PNG_READ_SIG_MODE: + { + png_push_read_sig(png_ptr, info_ptr); + break; + } + + case PNG_READ_CHUNK_MODE: + { + png_push_read_chunk(png_ptr, info_ptr); + break; + } + + case PNG_READ_IDAT_MODE: + { + png_push_read_IDAT(png_ptr); + break; + } + + default: + { + png_ptr->buffer_size = 0; + break; + } + } +} + +/* Read any remaining signature bytes from the stream and compare them with + * the correct PNG signature. It is possible that this routine is called + * with bytes already read from the signature, either because they have been + * checked by the calling application, or because of multiple calls to this + * routine. + */ +void /* PRIVATE */ +png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr) +{ + png_size_t num_checked = png_ptr->sig_bytes, /* SAFE, does not exceed 8 */ + num_to_check = 8 - num_checked; + + if (png_ptr->buffer_size < num_to_check) + { + num_to_check = png_ptr->buffer_size; + } + + png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), + num_to_check); + png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check); + + if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) + { + if (num_checked < 4 && + png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) + png_error(png_ptr, "Not a PNG file"); + + else + png_error(png_ptr, "PNG file corrupted by ASCII conversion"); + } + else + { + if (png_ptr->sig_bytes >= 8) + { + png_ptr->process_mode = PNG_READ_CHUNK_MODE; + } + } +} + +void /* PRIVATE */ +png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) +{ + png_uint_32 chunk_name; +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + int keep; /* unknown handling method */ +#endif + + /* First we make sure we have enough data for the 4-byte chunk name + * and the 4-byte chunk length before proceeding with decoding the + * chunk data. To fully decode each of these chunks, we also make + * sure we have enough data in the buffer for the 4-byte CRC at the + * end of every chunk (except IDAT, which is handled separately). + */ + if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0) + { + png_byte chunk_length[4]; + png_byte chunk_tag[4]; + + PNG_PUSH_SAVE_BUFFER_IF_LT(8) + png_push_fill_buffer(png_ptr, chunk_length, 4); + png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); + png_reset_crc(png_ptr); + png_crc_read(png_ptr, chunk_tag, 4); + png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + png_check_chunk_length(png_ptr, png_ptr->push_length); + png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; + } + + chunk_name = png_ptr->chunk_name; + + if (chunk_name == png_IDAT) + { + if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + + /* If we reach an IDAT chunk, this means we have read all of the + * header chunks, and we can start reading the image (or if this + * is called after the image has been read - we have an error). + */ + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_error(png_ptr, "Missing IHDR before IDAT"); + + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + (png_ptr->mode & PNG_HAVE_PLTE) == 0) + png_error(png_ptr, "Missing PLTE before IDAT"); + + png_ptr->process_mode = PNG_READ_IDAT_MODE; + + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0) + if (png_ptr->push_length == 0) + return; + + png_ptr->mode |= PNG_HAVE_IDAT; + + if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) + png_benign_error(png_ptr, "Too many IDATs found"); + } + + if (chunk_name == png_IHDR) + { + if (png_ptr->push_length != 13) + png_error(png_ptr, "Invalid IHDR length"); + + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); + } + + else if (chunk_name == png_IEND) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); + + png_ptr->process_mode = PNG_READ_DONE_MODE; + png_push_have_end(png_ptr, info_ptr); + } + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep); + + if (chunk_name == png_PLTE) + png_ptr->mode |= PNG_HAVE_PLTE; + } +#endif + + else if (chunk_name == png_PLTE) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); + } + + else if (chunk_name == png_IDAT) + { + png_ptr->idat_size = png_ptr->push_length; + png_ptr->process_mode = PNG_READ_IDAT_MODE; + png_push_have_info(png_ptr, info_ptr); + png_ptr->zstream.avail_out = + (uInt) PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1; + png_ptr->zstream.next_out = png_ptr->row_buf; + return; + } + +#ifdef PNG_READ_gAMA_SUPPORTED + else if (png_ptr->chunk_name == png_gAMA) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_sBIT_SUPPORTED + else if (png_ptr->chunk_name == png_sBIT) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_cHRM_SUPPORTED + else if (png_ptr->chunk_name == png_cHRM) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_sRGB_SUPPORTED + else if (chunk_name == png_sRGB) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_iCCP_SUPPORTED + else if (png_ptr->chunk_name == png_iCCP) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_sPLT_SUPPORTED + else if (chunk_name == png_sPLT) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_tRNS_SUPPORTED + else if (chunk_name == png_tRNS) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_bKGD_SUPPORTED + else if (chunk_name == png_bKGD) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_hIST_SUPPORTED + else if (chunk_name == png_hIST) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_pHYs_SUPPORTED + else if (chunk_name == png_pHYs) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_oFFs_SUPPORTED + else if (chunk_name == png_oFFs) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); + } +#endif + +#ifdef PNG_READ_pCAL_SUPPORTED + else if (chunk_name == png_pCAL) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_sCAL_SUPPORTED + else if (chunk_name == png_sCAL) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_tIME_SUPPORTED + else if (chunk_name == png_tIME) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_tEXt_SUPPORTED + else if (chunk_name == png_tEXt) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_zTXt_SUPPORTED + else if (chunk_name == png_zTXt) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_iTXt_SUPPORTED + else if (chunk_name == png_iTXt) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); + } +#endif + + else + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, + PNG_HANDLE_CHUNK_AS_DEFAULT); + } + + png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; +} + +void PNGCBAPI +png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) +{ + png_bytep ptr; + + if (png_ptr == NULL) + return; + + ptr = buffer; + if (png_ptr->save_buffer_size != 0) + { + png_size_t save_size; + + if (length < png_ptr->save_buffer_size) + save_size = length; + + else + save_size = png_ptr->save_buffer_size; + + memcpy(ptr, png_ptr->save_buffer_ptr, save_size); + length -= save_size; + ptr += save_size; + png_ptr->buffer_size -= save_size; + png_ptr->save_buffer_size -= save_size; + png_ptr->save_buffer_ptr += save_size; + } + if (length != 0 && png_ptr->current_buffer_size != 0) + { + png_size_t save_size; + + if (length < png_ptr->current_buffer_size) + save_size = length; + + else + save_size = png_ptr->current_buffer_size; + + memcpy(ptr, png_ptr->current_buffer_ptr, save_size); + png_ptr->buffer_size -= save_size; + png_ptr->current_buffer_size -= save_size; + png_ptr->current_buffer_ptr += save_size; + } +} + +void /* PRIVATE */ +png_push_save_buffer(png_structrp png_ptr) +{ + if (png_ptr->save_buffer_size != 0) + { + if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) + { + png_size_t i, istop; + png_bytep sp; + png_bytep dp; + + istop = png_ptr->save_buffer_size; + for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; + i < istop; i++, sp++, dp++) + { + *dp = *sp; + } + } + } + if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > + png_ptr->save_buffer_max) + { + png_size_t new_max; + png_bytep old_buffer; + + if (png_ptr->save_buffer_size > PNG_SIZE_MAX - + (png_ptr->current_buffer_size + 256)) + { + png_error(png_ptr, "Potential overflow of save_buffer"); + } + + new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; + old_buffer = png_ptr->save_buffer; + png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr, + (png_size_t)new_max); + + if (png_ptr->save_buffer == NULL) + { + png_free(png_ptr, old_buffer); + png_error(png_ptr, "Insufficient memory for save_buffer"); + } + + if (old_buffer) + memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); + else if (png_ptr->save_buffer_size) + png_error(png_ptr, "save_buffer error"); + png_free(png_ptr, old_buffer); + png_ptr->save_buffer_max = new_max; + } + if (png_ptr->current_buffer_size) + { + memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, + png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); + png_ptr->save_buffer_size += png_ptr->current_buffer_size; + png_ptr->current_buffer_size = 0; + } + png_ptr->save_buffer_ptr = png_ptr->save_buffer; + png_ptr->buffer_size = 0; +} + +void /* PRIVATE */ +png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, + png_size_t buffer_length) +{ + png_ptr->current_buffer = buffer; + png_ptr->current_buffer_size = buffer_length; + png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; + png_ptr->current_buffer_ptr = png_ptr->current_buffer; +} + +void /* PRIVATE */ +png_push_read_IDAT(png_structrp png_ptr) +{ + if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0) + { + png_byte chunk_length[4]; + png_byte chunk_tag[4]; + + /* TODO: this code can be commoned up with the same code in push_read */ + PNG_PUSH_SAVE_BUFFER_IF_LT(8) + png_push_fill_buffer(png_ptr, chunk_length, 4); + png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); + png_reset_crc(png_ptr); + png_crc_read(png_ptr, chunk_tag, 4); + png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); + png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; + + if (png_ptr->chunk_name != png_IDAT) + { + png_ptr->process_mode = PNG_READ_CHUNK_MODE; + + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) + png_error(png_ptr, "Not enough compressed data"); + + return; + } + + png_ptr->idat_size = png_ptr->push_length; + } + + if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0) + { + png_size_t save_size = png_ptr->save_buffer_size; + png_uint_32 idat_size = png_ptr->idat_size; + + /* We want the smaller of 'idat_size' and 'current_buffer_size', but they + * are of different types and we don't know which variable has the fewest + * bits. Carefully select the smaller and cast it to the type of the + * larger - this cannot overflow. Do not cast in the following test - it + * will break on either 16-bit or 64-bit platforms. + */ + if (idat_size < save_size) + save_size = (png_size_t)idat_size; + + else + idat_size = (png_uint_32)save_size; + + png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); + + png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); + + png_ptr->idat_size -= idat_size; + png_ptr->buffer_size -= save_size; + png_ptr->save_buffer_size -= save_size; + png_ptr->save_buffer_ptr += save_size; + } + + if (png_ptr->idat_size != 0 && png_ptr->current_buffer_size != 0) + { + png_size_t save_size = png_ptr->current_buffer_size; + png_uint_32 idat_size = png_ptr->idat_size; + + /* We want the smaller of 'idat_size' and 'current_buffer_size', but they + * are of different types and we don't know which variable has the fewest + * bits. Carefully select the smaller and cast it to the type of the + * larger - this cannot overflow. + */ + if (idat_size < save_size) + save_size = (png_size_t)idat_size; + + else + idat_size = (png_uint_32)save_size; + + png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); + + png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); + + png_ptr->idat_size -= idat_size; + png_ptr->buffer_size -= save_size; + png_ptr->current_buffer_size -= save_size; + png_ptr->current_buffer_ptr += save_size; + } + + if (png_ptr->idat_size == 0) + { + PNG_PUSH_SAVE_BUFFER_IF_LT(4) + png_crc_finish(png_ptr, 0); + png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->zowner = 0; + } +} + +void /* PRIVATE */ +png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, + png_size_t buffer_length) +{ + /* The caller checks for a non-zero buffer length. */ + if (!(buffer_length > 0) || buffer == NULL) + png_error(png_ptr, "No IDAT data (internal error)"); + + /* This routine must process all the data it has been given + * before returning, calling the row callback as required to + * handle the uncompressed results. + */ + png_ptr->zstream.next_in = buffer; + /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */ + png_ptr->zstream.avail_in = (uInt)buffer_length; + + /* Keep going until the decompressed data is all processed + * or the stream marked as finished. + */ + while (png_ptr->zstream.avail_in > 0 && + (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) + { + int ret; + + /* We have data for zlib, but we must check that zlib + * has someplace to put the results. It doesn't matter + * if we don't expect any results -- it may be the input + * data is just the LZ end code. + */ + if (!(png_ptr->zstream.avail_out > 0)) + { + /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */ + png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1); + + png_ptr->zstream.next_out = png_ptr->row_buf; + } + + /* Using Z_SYNC_FLUSH here means that an unterminated + * LZ stream (a stream with a missing end code) can still + * be handled, otherwise (Z_NO_FLUSH) a future zlib + * implementation might defer output and therefore + * change the current behavior (see comments in inflate.c + * for why this doesn't happen at present with zlib 1.2.5). + */ + ret = PNG_INFLATE(png_ptr, Z_SYNC_FLUSH); + + /* Check for any failure before proceeding. */ + if (ret != Z_OK && ret != Z_STREAM_END) + { + /* Terminate the decompression. */ + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + png_ptr->zowner = 0; + + /* This may be a truncated stream (missing or + * damaged end code). Treat that as a warning. + */ + if (png_ptr->row_number >= png_ptr->num_rows || + png_ptr->pass > 6) + png_warning(png_ptr, "Truncated compressed data in IDAT"); + + else + { + if (ret == Z_DATA_ERROR) + png_benign_error(png_ptr, "IDAT: ADLER32 checksum mismatch"); + else + png_error(png_ptr, "Decompression error in IDAT"); + } + + /* Skip the check on unprocessed input */ + return; + } + + /* Did inflate output any data? */ + if (png_ptr->zstream.next_out != png_ptr->row_buf) + { + /* Is this unexpected data after the last row? + * If it is, artificially terminate the LZ output + * here. + */ + if (png_ptr->row_number >= png_ptr->num_rows || + png_ptr->pass > 6) + { + /* Extra data. */ + png_warning(png_ptr, "Extra compressed data in IDAT"); + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + png_ptr->zowner = 0; + + /* Do no more processing; skip the unprocessed + * input check below. + */ + return; + } + + /* Do we have a complete row? */ + if (png_ptr->zstream.avail_out == 0) + png_push_process_row(png_ptr); + } + + /* And check for the end of the stream. */ + if (ret == Z_STREAM_END) + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + } + + /* All the data should have been processed, if anything + * is left at this point we have bytes of IDAT data + * after the zlib end code. + */ + if (png_ptr->zstream.avail_in > 0) + png_warning(png_ptr, "Extra compression data in IDAT"); +} + +void /* PRIVATE */ +png_push_process_row(png_structrp png_ptr) +{ + /* 1.5.6: row_info moved out of png_struct to a local here. */ + png_row_info row_info; + + row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ + row_info.color_type = png_ptr->color_type; + row_info.bit_depth = png_ptr->bit_depth; + row_info.channels = png_ptr->channels; + row_info.pixel_depth = png_ptr->pixel_depth; + row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); + + if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) + { + if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) + png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, + png_ptr->prev_row + 1, png_ptr->row_buf[0]); + else + png_error(png_ptr, "bad adaptive filter value"); + } + + /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before + * 1.5.6, while the buffer really is this big in current versions of libpng + * it may not be in the future, so this was changed just to copy the + * interlaced row count: + */ + memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + if (png_ptr->transformations != 0) + png_do_read_transformations(png_ptr, &row_info); +#endif + + /* The transformed pixel depth should match the depth now in row_info. */ + if (png_ptr->transformed_pixel_depth == 0) + { + png_ptr->transformed_pixel_depth = row_info.pixel_depth; + if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) + png_error(png_ptr, "progressive row overflow"); + } + + else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) + png_error(png_ptr, "internal progressive row size calculation error"); + + +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Expand interlaced rows to full size */ + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) != 0) + { + if (png_ptr->pass < 6) + png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, + png_ptr->transformations); + + switch (png_ptr->pass) + { + case 0: + { + int i; + for (i = 0; i < 8 && png_ptr->pass == 0; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */ + } + + if (png_ptr->pass == 2) /* Pass 1 might be empty */ + { + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + } + + if (png_ptr->pass == 4 && png_ptr->height <= 4) + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + } + + if (png_ptr->pass == 6 && png_ptr->height <= 4) + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + + case 1: + { + int i; + for (i = 0; i < 8 && png_ptr->pass == 1; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 2) /* Skip top 4 generated rows */ + { + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 2: + { + int i; + + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 4) /* Pass 3 might be empty */ + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 3: + { + int i; + + for (i = 0; i < 4 && png_ptr->pass == 3; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 4) /* Skip top two generated rows */ + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 4: + { + int i; + + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 6) /* Pass 5 might be empty */ + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + + case 5: + { + int i; + + for (i = 0; i < 2 && png_ptr->pass == 5; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 6) /* Skip top generated row */ + { + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + + default: + case 6: + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + + if (png_ptr->pass != 6) + break; + + png_push_have_row(png_ptr, NULL); + png_read_push_finish_row(png_ptr); + } + } + } + else +#endif + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } +} + +void /* PRIVATE */ +png_read_push_finish_row(png_structrp png_ptr) +{ +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; + + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; + + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + + /* Height of interlace block. This is not currently used - if you need + * it, uncomment it here and in png.h + static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; + */ +#endif + + png_ptr->row_number++; + if (png_ptr->row_number < png_ptr->num_rows) + return; + +#ifdef PNG_READ_INTERLACING_SUPPORTED + if (png_ptr->interlaced != 0) + { + png_ptr->row_number = 0; + memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + + do + { + png_ptr->pass++; + if ((png_ptr->pass == 1 && png_ptr->width < 5) || + (png_ptr->pass == 3 && png_ptr->width < 3) || + (png_ptr->pass == 5 && png_ptr->width < 2)) + png_ptr->pass++; + + if (png_ptr->pass > 7) + png_ptr->pass--; + + if (png_ptr->pass >= 7) + break; + + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + if ((png_ptr->transformations & PNG_INTERLACE) != 0) + break; + + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + + } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); + } +#endif /* READ_INTERLACING */ +} + +void /* PRIVATE */ +png_push_have_info(png_structrp png_ptr, png_inforp info_ptr) +{ + if (png_ptr->info_fn != NULL) + (*(png_ptr->info_fn))(png_ptr, info_ptr); +} + +void /* PRIVATE */ +png_push_have_end(png_structrp png_ptr, png_inforp info_ptr) +{ + if (png_ptr->end_fn != NULL) + (*(png_ptr->end_fn))(png_ptr, info_ptr); +} + +void /* PRIVATE */ +png_push_have_row(png_structrp png_ptr, png_bytep row) +{ + if (png_ptr->row_fn != NULL) + (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, + (int)png_ptr->pass); +} + +#ifdef PNG_READ_INTERLACING_SUPPORTED +void PNGAPI +png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row, + png_const_bytep new_row) +{ + if (png_ptr == NULL) + return; + + /* new_row is a flag here - if it is NULL then the app callback was called + * from an empty row (see the calls to png_struct::row_fn below), otherwise + * it must be png_ptr->row_buf+1 + */ + if (new_row != NULL) + png_combine_row(png_ptr, old_row, 1/*blocky display*/); +} +#endif /* READ_INTERLACING */ + +void PNGAPI +png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn) +{ + if (png_ptr == NULL) + return; + + png_ptr->info_fn = info_fn; + png_ptr->row_fn = row_fn; + png_ptr->end_fn = end_fn; + + png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); +} + +png_voidp PNGAPI +png_get_progressive_ptr(png_const_structrp png_ptr) +{ + if (png_ptr == NULL) + return (NULL); + + return png_ptr->io_ptr; +} +#endif /* PROGRESSIVE_READ */ diff --git a/xs/src/png/libpng/pngpriv.h b/xs/src/png/libpng/pngpriv.h new file mode 100644 index 0000000000..1f2e90f2b3 --- /dev/null +++ b/xs/src/png/libpng/pngpriv.h @@ -0,0 +1,2120 @@ + +/* pngpriv.h - private declarations for use inside libpng + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* The symbols declared in this file (including the functions declared + * as extern) are PRIVATE. They are not part of the libpng public + * interface, and are not recommended for use by regular applications. + * Some of them may become public in the future; others may stay private, + * change in an incompatible way, or even disappear. + * Although the libpng users are not forbidden to include this header, + * they should be well aware of the issues that may arise from doing so. + */ + +#ifndef PNGPRIV_H +#define PNGPRIV_H + +/* Feature Test Macros. The following are defined here to ensure that correctly + * implemented libraries reveal the APIs libpng needs to build and hide those + * that are not needed and potentially damaging to the compilation. + * + * Feature Test Macros must be defined before any system header is included (see + * POSIX 1003.1 2.8.2 "POSIX Symbols." + * + * These macros only have an effect if the operating system supports either + * POSIX 1003.1 or C99, or both. On other operating systems (particularly + * Windows/Visual Studio) there is no effect; the OS specific tests below are + * still required (as of 2011-05-02.) + */ +#ifndef _POSIX_SOURCE +# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */ +#endif + +#ifndef PNG_VERSION_INFO_ONLY +/* Standard library headers not required by png.h: */ +# include +# include +#endif + +#define PNGLIB_BUILD /*libpng is being built, not used*/ + +/* If HAVE_CONFIG_H is defined during the build then the build system must + * provide an appropriate "config.h" file on the include path. The header file + * must provide definitions as required below (search for "HAVE_CONFIG_H"); + * see configure.ac for more details of the requirements. The macro + * "PNG_NO_CONFIG_H" is provided for maintainers to test for dependencies on + * 'configure'; define this macro to prevent the configure build including the + * configure generated config.h. Libpng is expected to compile without *any* + * special build system support on a reasonably ANSI-C compliant system. + */ +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include + + /* Pick up the definition of 'restrict' from config.h if it was read: */ +# define PNG_RESTRICT restrict +#endif + +/* To support symbol prefixing it is necessary to know *before* including png.h + * whether the fixed point (and maybe other) APIs are exported, because if they + * are not internal definitions may be required. This is handled below just + * before png.h is included, but load the configuration now if it is available. + */ +#ifndef PNGLCONF_H +# include "pnglibconf.h" +#endif + +/* Local renames may change non-exported API functions from png.h */ +#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H) +# include "pngprefix.h" +#endif + +#ifdef PNG_USER_CONFIG +# include "pngusr.h" + /* These should have been defined in pngusr.h */ +# ifndef PNG_USER_PRIVATEBUILD +# define PNG_USER_PRIVATEBUILD "Custom libpng build" +# endif +# ifndef PNG_USER_DLLFNAME_POSTFIX +# define PNG_USER_DLLFNAME_POSTFIX "Cb" +# endif +#endif + +/* Compile time options. + * ===================== + * In a multi-arch build the compiler may compile the code several times for the + * same object module, producing different binaries for different architectures. + * When this happens configure-time setting of the target host options cannot be + * done and this interferes with the handling of the ARM NEON optimizations, and + * possibly other similar optimizations. Put additional tests here; in general + * this is needed when the same option can be changed at both compile time and + * run time depending on the target OS (i.e. iOS vs Android.) + * + * NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because + * this is not possible with certain compilers (Oracle SUN OS CC), as a result + * it is necessary to ensure that all extern functions that *might* be used + * regardless of $(CFLAGS) get declared in this file. The test on __ARM_NEON__ + * below is one example of this behavior because it is controlled by the + * presence or not of -mfpu=neon on the GCC command line, it is possible to do + * this in $(CC), e.g. "CC=gcc -mfpu=neon", but people who build libpng rarely + * do this. + */ +#ifndef PNG_ARM_NEON_OPT + /* ARM NEON optimizations are being controlled by the compiler settings, + * typically the target FPU. If the FPU has been set to NEON (-mfpu=neon + * with GCC) then the compiler will define __ARM_NEON__ and we can rely + * unconditionally on NEON instructions not crashing, otherwise we must + * disable use of NEON instructions. + * + * NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they + * can only be turned on automatically if that is supported too. If + * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail + * to compile with an appropriate #error if ALIGNED_MEMORY has been turned + * off. + * + * Note that gcc-4.9 defines __ARM_NEON instead of the deprecated + * __ARM_NEON__, so we check both variants. + * + * To disable ARM_NEON optimizations entirely, and skip compiling the + * associated assembler code, pass --enable-arm-neon=no to configure + * or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS. + */ +# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \ + defined(PNG_ALIGNED_MEMORY_SUPPORTED) +# define PNG_ARM_NEON_OPT 2 +# else +# define PNG_ARM_NEON_OPT 0 +# endif +#endif + +#if PNG_ARM_NEON_OPT > 0 + /* NEON optimizations are to be at least considered by libpng, so enable the + * callbacks to do this. + */ +# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon + + /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used + * if possible - if __ARM_NEON__ is set and the compiler version is not known + * to be broken. This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can + * be: + * + * 1 The intrinsics code (the default with __ARM_NEON__) + * 2 The hand coded assembler (the default without __ARM_NEON__) + * + * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however + * this is *NOT* supported and may cease to work even after a minor revision + * to libpng. It *is* valid to do this for testing purposes, e.g. speed + * testing or a new compiler, but the results should be communicated to the + * libpng implementation list for incorporation in the next minor release. + */ +# ifndef PNG_ARM_NEON_IMPLEMENTATION +# if defined(__ARM_NEON__) || defined(__ARM_NEON) +# if defined(__clang__) + /* At present it is unknown by the libpng developers which versions + * of clang support the intrinsics, however some or perhaps all + * versions do not work with the assembler so this may be + * irrelevant, so just use the default (do nothing here.) + */ +# elif defined(__GNUC__) + /* GCC 4.5.4 NEON support is known to be broken. 4.6.3 is known to + * work, so if this *is* GCC, or G++, look for a version >4.5 + */ +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) +# define PNG_ARM_NEON_IMPLEMENTATION 2 +# endif /* no GNUC support */ +# endif /* __GNUC__ */ +# else /* !defined __ARM_NEON__ */ + /* The 'intrinsics' code simply won't compile without this -mfpu=neon: + */ +# define PNG_ARM_NEON_IMPLEMENTATION 2 +# endif /* __ARM_NEON__ */ +# endif /* !PNG_ARM_NEON_IMPLEMENTATION */ + +# ifndef PNG_ARM_NEON_IMPLEMENTATION + /* Use the intrinsics code by default. */ +# define PNG_ARM_NEON_IMPLEMENTATION 1 +# endif +#endif /* PNG_ARM_NEON_OPT > 0 */ + +#ifndef PNG_MIPS_MSA_OPT +# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED) +# define PNG_MIPS_MSA_OPT 2 +# else +# define PNG_MIPS_MSA_OPT 0 +# endif +#endif + +#ifndef PNG_POWERPC_VSX_OPT +# if defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__) +# define PNG_POWERPC_VSX_OPT 2 +# else +# define PNG_POWERPC_VSX_OPT 0 +# endif +#endif + +#ifndef PNG_INTEL_SSE_OPT +# ifdef PNG_INTEL_SSE + /* Only check for SSE if the build configuration has been modified to + * enable SSE optimizations. This means that these optimizations will + * be off by default. See contrib/intel for more details. + */ +# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \ + defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \ + (defined(_M_IX86_FP) && _M_IX86_FP >= 2) +# define PNG_INTEL_SSE_OPT 1 +# endif +# endif +#endif + +#if PNG_INTEL_SSE_OPT > 0 +# ifndef PNG_INTEL_SSE_IMPLEMENTATION +# if defined(__SSE4_1__) || defined(__AVX__) + /* We are not actually using AVX, but checking for AVX is the best + way we can detect SSE4.1 and SSSE3 on MSVC. + */ +# define PNG_INTEL_SSE_IMPLEMENTATION 3 +# elif defined(__SSSE3__) +# define PNG_INTEL_SSE_IMPLEMENTATION 2 +# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \ + (defined(_M_IX86_FP) && _M_IX86_FP >= 2) +# define PNG_INTEL_SSE_IMPLEMENTATION 1 +# else +# define PNG_INTEL_SSE_IMPLEMENTATION 0 +# endif +# endif + +# if PNG_INTEL_SSE_IMPLEMENTATION > 0 +# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2 +# endif +#endif + +#if PNG_MIPS_MSA_OPT > 0 +# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa +# ifndef PNG_MIPS_MSA_IMPLEMENTATION +# if defined(__mips_msa) +# if defined(__clang__) +# elif defined(__GNUC__) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) +# define PNG_MIPS_MSA_IMPLEMENTATION 2 +# endif /* no GNUC support */ +# endif /* __GNUC__ */ +# else /* !defined __mips_msa */ +# define PNG_MIPS_MSA_IMPLEMENTATION 2 +# endif /* __mips_msa */ +# endif /* !PNG_MIPS_MSA_IMPLEMENTATION */ + +# ifndef PNG_MIPS_MSA_IMPLEMENTATION +# define PNG_MIPS_MSA_IMPLEMENTATION 1 +# endif +#endif /* PNG_MIPS_MSA_OPT > 0 */ + +#if PNG_POWERPC_VSX_OPT > 0 +# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx +# define PNG_POWERPC_VSX_IMPLEMENTATION 1 +#endif + + +/* Is this a build of a DLL where compilation of the object modules requires + * different preprocessor settings to those required for a simple library? If + * so PNG_BUILD_DLL must be set. + * + * If libpng is used inside a DLL but that DLL does not export the libpng APIs + * PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a + * static library of libpng then link the DLL against that. + */ +#ifndef PNG_BUILD_DLL +# ifdef DLL_EXPORT + /* This is set by libtool when files are compiled for a DLL; libtool + * always compiles twice, even on systems where it isn't necessary. Set + * PNG_BUILD_DLL in case it is necessary: + */ +# define PNG_BUILD_DLL +# else +# ifdef _WINDLL + /* This is set by the Microsoft Visual Studio IDE in projects that + * build a DLL. It can't easily be removed from those projects (it + * isn't visible in the Visual Studio UI) so it is a fairly reliable + * indication that PNG_IMPEXP needs to be set to the DLL export + * attributes. + */ +# define PNG_BUILD_DLL +# else +# ifdef __DLL__ + /* This is set by the Borland C system when compiling for a DLL + * (as above.) + */ +# define PNG_BUILD_DLL +# else + /* Add additional compiler cases here. */ +# endif +# endif +# endif +#endif /* Setting PNG_BUILD_DLL if required */ + +/* See pngconf.h for more details: the builder of the library may set this on + * the command line to the right thing for the specific compilation system or it + * may be automagically set above (at present we know of no system where it does + * need to be set on the command line.) + * + * PNG_IMPEXP must be set here when building the library to prevent pngconf.h + * setting it to the "import" setting for a DLL build. + */ +#ifndef PNG_IMPEXP +# ifdef PNG_BUILD_DLL +# define PNG_IMPEXP PNG_DLL_EXPORT +# else + /* Not building a DLL, or the DLL doesn't require specific export + * definitions. + */ +# define PNG_IMPEXP +# endif +#endif + +/* No warnings for private or deprecated functions in the build: */ +#ifndef PNG_DEPRECATED +# define PNG_DEPRECATED +#endif +#ifndef PNG_PRIVATE +# define PNG_PRIVATE +#endif + +/* Symbol preprocessing support. + * + * To enable listing global, but internal, symbols the following macros should + * always be used to declare an extern data or function object in this file. + */ +#ifndef PNG_INTERNAL_DATA +# define PNG_INTERNAL_DATA(type, name, array) PNG_LINKAGE_DATA type name array +#endif + +#ifndef PNG_INTERNAL_FUNCTION +# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\ + PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes) +#endif + +#ifndef PNG_INTERNAL_CALLBACK +# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\ + PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\ + PNG_EMPTY attributes) +#endif + +/* If floating or fixed point APIs are disabled they may still be compiled + * internally. To handle this make sure they are declared as the appropriate + * internal extern function (otherwise the symbol prefixing stuff won't work and + * the functions will be used without definitions.) + * + * NOTE: although all the API functions are declared here they are not all + * actually built! Because the declarations are still made it is necessary to + * fake out types that they depend on. + */ +#ifndef PNG_FP_EXPORT +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FP_EXPORT(ordinal, type, name, args)\ + PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); +# ifndef PNG_VERSION_INFO_ONLY + typedef struct png_incomplete png_double; + typedef png_double* png_doublep; + typedef const png_double* png_const_doublep; + typedef png_double** png_doublepp; +# endif +# endif +#endif +#ifndef PNG_FIXED_EXPORT +# ifndef PNG_FIXED_POINT_SUPPORTED +# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ + PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); +# endif +#endif + +#include "png.h" + +/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */ +#ifndef PNG_DLL_EXPORT +# define PNG_DLL_EXPORT +#endif + +/* This is a global switch to set the compilation for an installed system + * (a release build). It can be set for testing debug builds to ensure that + * they will compile when the build type is switched to RC or STABLE, the + * default is just to use PNG_LIBPNG_BUILD_BASE_TYPE. Set this in CPPFLAGS + * with either: + * + * -DPNG_RELEASE_BUILD Turns on the release compile path + * -DPNG_RELEASE_BUILD=0 Turns it off + * or in your pngusr.h with + * #define PNG_RELEASE_BUILD=1 Turns on the release compile path + * #define PNG_RELEASE_BUILD=0 Turns it off + */ +#ifndef PNG_RELEASE_BUILD +# define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC) +#endif + +/* SECURITY and SAFETY: + * + * libpng is built with support for internal limits on image dimensions and + * memory usage. These are documented in scripts/pnglibconf.dfa of the + * source and recorded in the machine generated header file pnglibconf.h. + */ + +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. + * + * zlib provides 'MAXSEG_64K' which, if defined, indicates the + * same limit and pngconf.h (already included) sets the limit + * if certain operating systems are detected. + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +#ifndef PNG_UNUSED +/* Unused formal parameter warnings are silenced using the following macro + * which is expected to have no bad effects on performance (optimizing + * compilers will probably remove it entirely). Note that if you replace + * it with something other than whitespace, you must include the terminating + * semicolon. + */ +# define PNG_UNUSED(param) (void)param; +#endif + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536L +#endif + +/* If warnings or errors are turned off the code is disabled or redirected here. + * From 1.5.4 functions have been added to allow very limited formatting of + * error and warning messages - this code will also be disabled here. + */ +#ifdef PNG_WARNINGS_SUPPORTED +# define PNG_WARNING_PARAMETERS(p) png_warning_parameters p; +#else +# define png_warning_parameter(p,number,string) ((void)0) +# define png_warning_parameter_unsigned(p,number,format,value) ((void)0) +# define png_warning_parameter_signed(p,number,format,value) ((void)0) +# define png_formatted_warning(pp,p,message) ((void)(pp)) +# define PNG_WARNING_PARAMETERS(p) +#endif +#ifndef PNG_ERROR_TEXT_SUPPORTED +# define png_fixed_error(s1,s2) png_err(s1) +#endif + +/* Some fixed point APIs are still required even if not exported because + * they get used by the corresponding floating point APIs. This magic + * deals with this: + */ +#ifdef PNG_FIXED_POINT_SUPPORTED +# define PNGFAPI PNGAPI +#else +# define PNGFAPI /* PRIVATE */ +#endif + +#ifndef PNG_VERSION_INFO_ONLY +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ + +/* C allows up-casts from (void*) to any pointer and (const void*) to any + * pointer to a const object. C++ regards this as a type error and requires an + * explicit, static, cast and provides the static_cast<> rune to ensure that + * const is not cast away. + */ +#ifdef __cplusplus +# define png_voidcast(type, value) static_cast(value) +# define png_constcast(type, value) const_cast(value) +# define png_aligncast(type, value) \ + static_cast(static_cast(value)) +# define png_aligncastconst(type, value) \ + static_cast(static_cast(value)) +#else +# define png_voidcast(type, value) (value) +# ifdef _WIN64 +# ifdef __GNUC__ + typedef unsigned long long png_ptruint; +# else + typedef unsigned __int64 png_ptruint; +# endif +# else + typedef unsigned long png_ptruint; +# endif +# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value)) +# define png_aligncast(type, value) ((void*)(value)) +# define png_aligncastconst(type, value) ((const void*)(value)) +#endif /* __cplusplus */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\ + defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) + /* png.c requires the following ANSI-C constants if the conversion of + * floating point to ASCII is implemented therein: + * + * DBL_DIG Maximum number of decimal digits (can be set to any constant) + * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) + * DBL_MAX Maximum floating point number (can be set to an arbitrary value) + */ +# include + +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include +# endif +# else +# include +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include +# endif +#endif + +/* This provides the non-ANSI (far) memory allocation routines. */ +#if defined(__TURBOC__) && defined(__MSDOS__) +# include +# include +#endif + +#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ + defined(_WIN32) || defined(__WIN32__) +# include /* defines _WINDOWS_ macro */ +#endif +#endif /* PNG_VERSION_INFO_ONLY */ + +/* Moved here around 1.5.0beta36 from pngconf.h */ +/* Users may want to use these so they are not private. Any library + * functions that are passed far data must be model-independent. + */ + +/* Memory model/platform independent fns */ +#ifndef PNG_ABORT +# ifdef _WINDOWS_ +# define PNG_ABORT() ExitProcess(0) +# else +# define PNG_ABORT() abort() +# endif +#endif + +/* These macros may need to be architecture dependent. */ +#define PNG_ALIGN_NONE 0 /* do not use data alignment */ +#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */ +#ifdef offsetof +# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */ +#else +# define PNG_ALIGN_OFFSET -1 /* prevent the use of this */ +#endif +#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */ + +#ifndef PNG_ALIGN_TYPE + /* Default to using aligned access optimizations and requiring alignment to a + * multiple of the data type size. Override in a compiler specific fashion + * if necessary by inserting tests here: + */ +# define PNG_ALIGN_TYPE PNG_ALIGN_SIZE +#endif + +#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE + /* This is used because in some compiler implementations non-aligned + * structure members are supported, so the offsetof approach below fails. + * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access + * is good for performance. Do not do this unless you have tested the result + * and understand it. + */ +# define png_alignof(type) (sizeof (type)) +#else +# if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET +# define png_alignof(type) offsetof(struct{char c; type t;}, t) +# else +# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS +# define png_alignof(type) (1) +# endif + /* Else leave png_alignof undefined to prevent use thereof */ +# endif +#endif + +/* This implicitly assumes alignment is always to a power of 2. */ +#ifdef png_alignof +# define png_isaligned(ptr, type)\ + (((type)((const char*)ptr-(const char*)0) & \ + (type)(png_alignof(type)-1)) == 0) +#else +# define png_isaligned(ptr, type) 0 +#endif + +/* End of memory model/platform independent support */ +/* End of 1.5.0beta36 move from pngconf.h */ + +/* CONSTANTS and UTILITY MACROS + * These are used internally by libpng and not exposed in the API + */ + +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. Three of these + * are defined in png.h because they need to be visible to applications + * that call png_set_unknown_chunk(). + */ +/* #define PNG_HAVE_IHDR 0x01U (defined in png.h) */ +/* #define PNG_HAVE_PLTE 0x02U (defined in png.h) */ +#define PNG_HAVE_IDAT 0x04U +/* #define PNG_AFTER_IDAT 0x08U (defined in png.h) */ +#define PNG_HAVE_IEND 0x10U + /* 0x20U (unused) */ + /* 0x40U (unused) */ + /* 0x80U (unused) */ +#define PNG_HAVE_CHUNK_HEADER 0x100U +#define PNG_WROTE_tIME 0x200U +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U +#define PNG_BACKGROUND_IS_GRAY 0x800U +#define PNG_HAVE_PNG_SIGNATURE 0x1000U +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */ + /* 0x4000U (unused) */ +#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */ + +/* Flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001U +#define PNG_INTERLACE 0x0002U +#define PNG_PACK 0x0004U +#define PNG_SHIFT 0x0008U +#define PNG_SWAP_BYTES 0x0010U +#define PNG_INVERT_MONO 0x0020U +#define PNG_QUANTIZE 0x0040U +#define PNG_COMPOSE 0x0080U /* Was PNG_BACKGROUND */ +#define PNG_BACKGROUND_EXPAND 0x0100U +#define PNG_EXPAND_16 0x0200U /* Added to libpng 1.5.2 */ +#define PNG_16_TO_8 0x0400U /* Becomes 'chop' in 1.5.4 */ +#define PNG_RGBA 0x0800U +#define PNG_EXPAND 0x1000U +#define PNG_GAMMA 0x2000U +#define PNG_GRAY_TO_RGB 0x4000U +#define PNG_FILLER 0x8000U +#define PNG_PACKSWAP 0x10000U +#define PNG_SWAP_ALPHA 0x20000U +#define PNG_STRIP_ALPHA 0x40000U +#define PNG_INVERT_ALPHA 0x80000U +#define PNG_USER_TRANSFORM 0x100000U +#define PNG_RGB_TO_GRAY_ERR 0x200000U +#define PNG_RGB_TO_GRAY_WARN 0x400000U +#define PNG_RGB_TO_GRAY 0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */ +#define PNG_ENCODE_ALPHA 0x800000U /* Added to libpng-1.5.4 */ +#define PNG_ADD_ALPHA 0x1000000U /* Added to libpng-1.2.7 */ +#define PNG_EXPAND_tRNS 0x2000000U /* Added to libpng-1.2.9 */ +#define PNG_SCALE_16_TO_8 0x4000000U /* Added to libpng-1.5.4 */ + /* 0x8000000U unused */ + /* 0x10000000U unused */ + /* 0x20000000U unused */ + /* 0x40000000U unused */ +/* Flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001U +#define PNG_STRUCT_INFO 0x0002U + +/* Flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001U +#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002U /* Added to libpng-1.6.0 */ + /* 0x0004U unused */ +#define PNG_FLAG_ZSTREAM_ENDED 0x0008U /* Added to libpng-1.6.0 */ + /* 0x0010U unused */ + /* 0x0020U unused */ +#define PNG_FLAG_ROW_INIT 0x0040U +#define PNG_FLAG_FILLER_AFTER 0x0080U +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100U +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U +#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */ +#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */ +#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */ +/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */ +/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */ +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U +#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */ +#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */ +#define PNG_FLAG_APP_ERRORS_WARN 0x400000U /* Added to libpng-1.6.0 */ + /* 0x800000U unused */ + /* 0x1000000U unused */ + /* 0x2000000U unused */ + /* 0x4000000U unused */ + /* 0x8000000U unused */ + /* 0x10000000U unused */ + /* 0x20000000U unused */ + /* 0x40000000U unused */ + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* Save typing and make code easier to understand */ + +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255 + * by dividing by 257 *with rounding*. This macro is exact for the given range. + * See the discourse in pngrtran.c png_do_scale_16_to_8. The values in the + * macro were established by experiment (modifying the added value). The macro + * has a second variant that takes a value already scaled by 255 and divides by + * 65535 - this has a maximum error of .502. Over the range 0..65535*65535 it + * only gives off-by-one errors and only for 0.5% (1 in 200) of the values. + */ +#define PNG_DIV65535(v24) (((v24) + 32895) >> 16) +#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255) + +/* Added to libpng-1.2.6 JB */ +#define PNG_ROWBYTES(pixel_bits, width) \ + ((pixel_bits) >= 8 ? \ + ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \ + (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) ) + +/* This returns the number of trailing bits in the last byte of a row, 0 if the + * last byte is completely full of pixels. It is, in principle, (pixel_bits x + * width) % 8, but that would overflow for large 'width'. The second macro is + * the same except that it returns the number of unused bits in the last byte; + * (8-TRAILBITS), but 0 when TRAILBITS is 0. + * + * NOTE: these macros are intended to be self-evidently correct and never + * overflow on the assumption that pixel_bits is in the range 0..255. The + * arguments are evaluated only once and they can be signed (e.g. as a result of + * the integral promotions). The result of the expression always has type + * (png_uint_32), however the compiler always knows it is in the range 0..7. + */ +#define PNG_TRAILBITS(pixel_bits, width) \ + (((pixel_bits) * ((width) % (png_uint_32)8)) % 8) + +#define PNG_PADBITS(pixel_bits, width) \ + ((8 - PNG_TRAILBITS(pixel_bits, width)) % 8) + +/* PNG_OUT_OF_RANGE returns true if value is outside the range + * ideal-delta..ideal+delta. Each argument is evaluated twice. + * "ideal" and "delta" should be constants, normally simple + * integers, "value" a variable. Added to libpng-1.2.6 JB + */ +#define PNG_OUT_OF_RANGE(value, ideal, delta) \ + ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) + +/* Conversions between fixed and floating point, only defined if + * required (to make sure the code doesn't accidentally use float + * when it is supposedly disabled.) + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +/* The floating point conversion can't overflow, though it can and + * does lose accuracy relative to the original fixed point value. + * In practice this doesn't matter because png_fixed_point only + * stores numbers with very low precision. The png_ptr and s + * arguments are unused by default but are there in case error + * checking becomes a requirement. + */ +#define png_float(png_ptr, fixed, s) (.00001 * (fixed)) + +/* The fixed point conversion performs range checking and evaluates + * its argument multiple times, so must be used with care. The + * range checking uses the PNG specification values for a signed + * 32-bit fixed point value except that the values are deliberately + * rounded-to-zero to an integral value - 21474 (21474.83 is roughly + * (2^31-1) * 100000). 's' is a string that describes the value being + * converted. + * + * NOTE: this macro will raise a png_error if the range check fails, + * therefore it is normally only appropriate to use this on values + * that come from API calls or other sources where an out of range + * error indicates a programming error, not a data error! + * + * NOTE: by default this is off - the macro is not used - because the + * function call saves a lot of code. + */ +#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED +#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\ + ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0)) +#endif +/* else the corresponding function is defined below, inside the scope of the + * cplusplus test. + */ +#endif + +/* Constants for known chunk types. If you need to add a chunk, define the name + * here. For historical reasons these constants have the form png_; i.e. + * the prefix is lower case. Please use decimal values as the parameters to + * match the ISO PNG specification and to avoid relying on the C locale + * interpretation of character values. + * + * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values + * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string + * to be generated if required. + * + * PNG_32b correctly produces a value shifted by up to 24 bits, even on + * architectures where (int) is only 16 bits. + */ +#define PNG_32b(b,s) ((png_uint_32)(b) << (s)) +#define PNG_U32(b1,b2,b3,b4) \ + (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0)) + +/* Constants for known chunk types. + * + * MAINTAINERS: If you need to add a chunk, define the name here. + * For historical reasons these constants have the form png_; i.e. + * the prefix is lower case. Please use decimal values as the parameters to + * match the ISO PNG specification and to avoid relying on the C locale + * interpretation of character values. Please keep the list sorted. + * + * Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk + * type. In fact the specification does not express chunk types this way, + * however using a 32-bit value means that the chunk type can be read from the + * stream using exactly the same code as used for a 32-bit unsigned value and + * can be examined far more efficiently (using one arithmetic compare). + * + * Prior to 1.5.6 the chunk type constants were expressed as C strings. The + * libpng API still uses strings for 'unknown' chunks and a macro, + * PNG_STRING_FROM_CHUNK, allows a string to be generated if required. Notice + * that for portable code numeric values must still be used; the string "IHDR" + * is not portable and neither is PNG_U32('I', 'H', 'D', 'R'). + * + * In 1.7.0 the definitions will be made public in png.h to avoid having to + * duplicate the same definitions in application code. + */ +#define png_IDAT PNG_U32( 73, 68, 65, 84) +#define png_IEND PNG_U32( 73, 69, 78, 68) +#define png_IHDR PNG_U32( 73, 72, 68, 82) +#define png_PLTE PNG_U32( 80, 76, 84, 69) +#define png_bKGD PNG_U32( 98, 75, 71, 68) +#define png_cHRM PNG_U32( 99, 72, 82, 77) +#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */ +#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */ +#define png_gAMA PNG_U32(103, 65, 77, 65) +#define png_gIFg PNG_U32(103, 73, 70, 103) +#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */ +#define png_gIFx PNG_U32(103, 73, 70, 120) +#define png_hIST PNG_U32(104, 73, 83, 84) +#define png_iCCP PNG_U32(105, 67, 67, 80) +#define png_iTXt PNG_U32(105, 84, 88, 116) +#define png_oFFs PNG_U32(111, 70, 70, 115) +#define png_pCAL PNG_U32(112, 67, 65, 76) +#define png_pHYs PNG_U32(112, 72, 89, 115) +#define png_sBIT PNG_U32(115, 66, 73, 84) +#define png_sCAL PNG_U32(115, 67, 65, 76) +#define png_sPLT PNG_U32(115, 80, 76, 84) +#define png_sRGB PNG_U32(115, 82, 71, 66) +#define png_sTER PNG_U32(115, 84, 69, 82) +#define png_tEXt PNG_U32(116, 69, 88, 116) +#define png_tIME PNG_U32(116, 73, 77, 69) +#define png_tRNS PNG_U32(116, 82, 78, 83) +#define png_zTXt PNG_U32(122, 84, 88, 116) + +/* The following will work on (signed char*) strings, whereas the get_uint_32 + * macro will fail on top-bit-set values because of the sign extension. + */ +#define PNG_CHUNK_FROM_STRING(s)\ + PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3]) + +/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is + * signed and the argument is a (char[]) This macro will fail miserably on + * systems where (char) is more than 8 bits. + */ +#define PNG_STRING_FROM_CHUNK(s,c)\ + (void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \ + ((char*)(s))[1]=(char)(((c)>>16) & 0xff),\ + ((char*)(s))[2]=(char)(((c)>>8) & 0xff), \ + ((char*)(s))[3]=(char)((c & 0xff))) + +/* Do the same but terminate with a null character. */ +#define PNG_CSTRING_FROM_CHUNK(s,c)\ + (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0) + +/* Test on flag values as defined in the spec (section 5.4): */ +#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29)) +#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c)) +#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21)) +#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13)) +#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5)) + +/* Gamma values (new at libpng-1.5.4): */ +#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */ +#define PNG_GAMMA_MAC_INVERSE 65909 +#define PNG_GAMMA_sRGB_INVERSE 45455 + +/* Almost everything below is C specific; the #defines above can be used in + * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot. + */ +#ifndef PNG_VERSION_INFO_ONLY + +#include "pngstruct.h" +#include "pnginfo.h" + +/* Validate the include paths - the include path used to generate pnglibconf.h + * must match that used in the build, or we must be using pnglibconf.h.prebuilt: + */ +#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM +# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \ + "-I (include path) error: see the notes in pngpriv.h" + /* This means that when pnglibconf.h was built the copy of zlib.h that it + * used is not the same as the one being used here. Because the build of + * libpng makes decisions to use inflateInit2 and inflateReset2 based on the + * zlib version number and because this affects handling of certain broken + * PNG files the -I directives must match. + * + * The most likely explanation is that you passed a -I in CFLAGS. This will + * not work; all the preprocessor directories and in particular all the -I + * directives must be in CPPFLAGS. + */ +#endif + +/* This is used for 16-bit gamma tables -- only the top level pointers are + * const; this could be changed: + */ +typedef const png_uint_16p * png_const_uint_16pp; + +/* Added to libpng-1.5.7: sRGB conversion tables */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]); + /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value, + * 0..65535. This table gives the closest 16-bit answers (no errors). + */ +#endif + +PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]); +PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); + +#define PNG_sRGB_FROM_LINEAR(linear) \ + ((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \ + + ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))) + /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB + * encoded value with maximum error 0.646365. Note that the input is not a + * 16-bit value; it has been multiplied by 255! */ +#endif /* SIMPLIFIED_READ/WRITE */ + + +/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Internal functions; these are not exported from a DLL however because they + * are used within several of the C source files they have to be C extern. + * + * All of these functions must be declared with PNG_INTERNAL_FUNCTION. + */ + +/* Zlib support */ +#define PNG_UNEXPECTED_ZLIB_RETURN (-7) +PNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret), + PNG_EMPTY); + /* Used by the zlib handling functions to ensure that z_stream::msg is always + * set before they return. + */ + +#ifdef PNG_WRITE_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr, + png_compression_bufferp *list),PNG_EMPTY); + /* Free the buffer list used by the compressed write code. */ +#endif + +#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ + !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ + (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ + defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ + (defined(PNG_sCAL_SUPPORTED) && \ + defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) +PNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr, + double fp, png_const_charp text),PNG_EMPTY); +#endif + +/* Check the user version string for compatibility, returns false if the version + * numbers aren't compatible. + */ +PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr, + png_const_charp user_png_ver),PNG_EMPTY); + +/* Internal base allocator - no messages, NULL on failure to allocate. This + * does, however, call the application provided allocator and that could call + * png_error (although that would be a bug in the application implementation.) + */ +PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr, + png_alloc_size_t size),PNG_ALLOCATED); + +#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\ + defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) +/* Internal array allocator, outputs no error or warning messages on failure, + * just returns NULL. + */ +PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr, + int nelements, size_t element_size),PNG_ALLOCATED); + +/* The same but an existing array is extended by add_elements. This function + * also memsets the new elements to 0 and copies the old elements. The old + * array is not freed or altered. + */ +PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr, + png_const_voidp array, int old_elements, int add_elements, + size_t element_size),PNG_ALLOCATED); +#endif /* text, sPLT or unknown chunks */ + +/* Magic to create a struct when there is no struct to call the user supplied + * memory allocators. Because error handling has not been set up the memory + * handlers can't safely call png_error, but this is an obscure and undocumented + * restriction so libpng has to assume that the 'free' handler, at least, might + * call png_error. + */ +PNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, + png_free_ptr free_fn),PNG_ALLOCATED); + +/* Free memory from internal libpng struct */ +PNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr), + PNG_EMPTY); + +/* Free an allocated jmp_buf (always succeeds) */ +PNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY); + +/* Function to allocate memory for zlib. PNGAPI is disallowed. */ +PNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size), + PNG_ALLOCATED); + +/* Function to free memory for zlib. PNGAPI is disallowed. */ +PNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY); + +/* Next four functions are used internally as callbacks. PNGCBAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to + * PNGCBAPI at 1.5.0 + */ + +PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr, + png_bytep data, png_size_t length),PNG_EMPTY); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr, + png_bytep buffer, png_size_t length),PNG_EMPTY); +#endif + +PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr, + png_bytep data, png_size_t length),PNG_EMPTY); + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +# ifdef PNG_STDIO_SUPPORTED +PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr), + PNG_EMPTY); +# endif +#endif + +/* Reset the CRC variable */ +PNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY); + +/* Write the "data" buffer to whatever output you are using */ +PNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr, + png_const_bytep data, png_size_t length),PNG_EMPTY); + +/* Read and check the PNG file signature */ +PNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); + +/* Read the chunk header (length + type name) */ +PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr), + PNG_EMPTY); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data, + png_size_t length),PNG_EMPTY); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf, + png_uint_32 length),PNG_EMPTY); + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr, + png_uint_32 skip),PNG_EMPTY); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr, + png_const_bytep ptr, png_size_t length),PNG_EMPTY); + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY); +#endif + +/* Write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, + int compression_method, int filter_method, int interlace_method),PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr, + png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr, + png_const_bytep row_data, png_alloc_size_t row_data_length, int flush), + PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY); + +#ifdef PNG_WRITE_gAMA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr, + png_fixed_point file_gamma),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_sBIT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr, + png_const_color_8p sbit, int color_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_cHRM_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr, + const png_xy *xy), PNG_EMPTY); + /* The xy value must have been previously validated */ +#endif + +#ifdef PNG_WRITE_sRGB_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr, + int intent),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_eXIf_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_eXIf,(png_structrp png_ptr, + png_bytep exif, int num_exif),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_iCCP_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr, + png_const_charp name, png_const_bytep profile), PNG_EMPTY); + /* The profile must have been previously validated for correctness, the + * length comes from the first four bytes. Only the base, deflate, + * compression is supported. + */ +#endif + +#ifdef PNG_WRITE_sPLT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr, + png_const_sPLT_tp palette),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_tRNS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr, + png_const_bytep trans, png_const_color_16p values, int number, + int color_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_bKGD_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr, + png_const_color_16p values, int color_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_hIST_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr, + png_const_uint_16p hist, int num_hist),PNG_EMPTY); +#endif + +/* Chunks that have keywords */ +#ifdef PNG_WRITE_tEXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr, + png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_zTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp + key, png_const_charp text, int compression),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_iTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr, + int compression, png_const_charp key, png_const_charp lang, + png_const_charp lang_key, png_const_charp text),PNG_EMPTY); +#endif + +#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */ +PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr, + png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_oFFs_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_pCAL_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr, + png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, + png_const_charp units, png_charpp params),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_pHYs_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_tIME_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr, + png_const_timep mod_time),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_sCAL_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr, + int unit, png_const_charp width, png_const_charp height),PNG_EMPTY); +#endif + +/* Called when finished processing a row of data */ +PNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr), + PNG_EMPTY); + +/* Internal use only. Called before first row of data */ +PNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr), + PNG_EMPTY); + +/* Combine a row of data, dealing with alpha, etc. if requested. 'row' is an + * array of png_ptr->width pixels. If the image is not interlaced or this + * is the final pass this just does a memcpy, otherwise the "display" flag + * is used to determine whether to copy pixels that are not in the current pass. + * + * Because 'png_do_read_interlace' (below) replicates pixels this allows this + * function to achieve the documented 'blocky' appearance during interlaced read + * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row' + * are not changed if they are not in the current pass, when display is 0. + * + * 'display' must be 0 or 1, otherwise the memcpy will be done regardless. + * + * The API always reads from the png_struct row buffer and always assumes that + * it is full width (png_do_read_interlace has already been called.) + * + * This function is only ever used to write to row buffers provided by the + * caller of the relevant libpng API and the row must have already been + * transformed by the read transformations. + * + * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed + * bitmasks for use within the code, otherwise runtime generated masks are used. + * The default is compile time masks. + */ +#ifndef PNG_USE_COMPILE_TIME_MASKS +# define PNG_USE_COMPILE_TIME_MASKS 1 +#endif +PNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr, + png_bytep row, int display),PNG_EMPTY); + +#ifdef PNG_READ_INTERLACING_SUPPORTED +/* Expand an interlaced row: the 'row_info' describes the pass data that has + * been read in and must correspond to the pixels in 'row', the pixels are + * expanded (moved apart) in 'row' to match the final layout, when doing this + * the pixels are *replicated* to the intervening space. This is essential for + * the correct operation of png_combine_row, above. + */ +PNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED +/* Grab pixels out of a row for an interlaced pass */ +PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info, + png_bytep row, int pass),PNG_EMPTY); +#endif + +/* Unfilter a row: check the filter value before calling this, there is no point + * calling it for PNG_FILTER_VALUE_NONE. + */ +PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop + row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY); + +#if PNG_ARM_NEON_OPT > 0 +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info, + png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +#endif + +#if PNG_MIPS_MSA_OPT > 0 +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info, + png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +#endif + +#if PNG_POWERPC_VSX_OPT > 0 +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_vsx,(png_row_infop row_info, + png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_vsx,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_vsx,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_vsx,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_vsx,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_vsx,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_vsx,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +#endif + +#if PNG_INTEL_SSE_IMPLEMENTATION > 0 +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_sse2,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_sse2,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_sse2,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +#endif + +/* Choose the best filter to use and filter the row data */ +PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr, + png_row_infop row_info),PNG_EMPTY); + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr, + png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY); + /* Read 'avail_out' bytes of data from the IDAT stream. If the output buffer + * is NULL the function checks, instead, for the end of the stream. In this + * case a benign error will be issued if the stream end is not found or if + * extra data has to be consumed. + */ +PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr), + PNG_EMPTY); + /* This cleans up when the IDAT LZ stream does not end when the last image + * byte is read; there is still some pending input. + */ + +PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr), + PNG_EMPTY); + /* Finish a row while reading, dealing with interlacing passes, etc. */ +#endif /* SEQUENTIAL_READ */ + +/* Initialize the row buffers, etc. */ +PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY); + +#if ZLIB_VERNUM >= 0x1240 +PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush), + PNG_EMPTY); +# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush) +#else /* Zlib < 1.2.4 */ +# define PNG_INFLATE(pp, flush) inflate(&(pp)->zstream, flush) +#endif /* Zlib < 1.2.4 */ + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* Optional call to update the users info structure */ +PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +#endif + +/* Shared transform functions, defined in pngtran.c */ +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info, + png_bytep row, int at_start),PNG_EMPTY); +#endif + +#ifdef PNG_16BIT_SUPPORTED +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ + defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* Decode the IHDR chunk */ +PNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); + +#ifdef PNG_READ_bKGD_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_cHRM_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_eXIf_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_eXIf,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_gAMA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_hIST_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_iCCP_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif /* READ_iCCP */ + +#ifdef PNG_READ_iTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_oFFs_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_pCAL_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_pHYs_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_sBIT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_sCAL_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_sPLT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif /* READ_sPLT */ + +#ifdef PNG_READ_sRGB_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_tEXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_tIME_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_tRNS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_zTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr, + const png_uint_32 chunk_name),PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr, + const png_uint_32 chunk_length),PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY); + /* This is the function that gets called for unknown chunks. The 'keep' + * argument is either non-zero for a known chunk that has been set to be + * handled as unknown or zero for an unknown chunk. By default the function + * just skips the chunk or errors out if it is critical. + */ + +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\ + defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) +PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling, + (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY); + /* Exactly as the API png_handle_as_unknown() except that the argument is a + * 32-bit chunk name, not a string. + */ +#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */ + +/* Handle the transformations for reading and writing */ +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr, + png_row_infop row_info),PNG_EMPTY); +#endif +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr, + png_row_infop row_info),PNG_EMPTY); +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr), + PNG_EMPTY); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr, + png_bytep buffer, png_size_t buffer_length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr, + png_bytep buffer, png_size_t buffer_length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr, + png_bytep row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr), + PNG_EMPTY); +# ifdef PNG_READ_tEXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +# endif +# ifdef PNG_READ_zTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +# endif +# ifdef PNG_READ_iTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +# endif + +#endif /* PROGRESSIVE_READ */ + +/* Added at libpng version 1.6.0 */ +#ifdef PNG_GAMMA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY); + /* Set the colorspace gamma with a value provided by the application or by + * the gAMA chunk on read. The value will override anything set by an ICC + * profile. + */ + +PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr, + png_inforp info_ptr), PNG_EMPTY); + /* Synchronize the info 'valid' flags with the colorspace */ + +PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr, + png_inforp info_ptr), PNG_EMPTY); + /* Copy the png_struct colorspace to the info_struct and call the above to + * synchronize the flags. Checks for NULL info_ptr and does nothing. + */ +#endif + +/* Added at libpng version 1.4.0 */ +#ifdef PNG_COLORSPACE_SUPPORTED +/* These internal functions are for maintaining the colorspace structure within + * a png_info or png_struct (or, indeed, both). + */ +PNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities, + (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy, + int preferred), PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints, + (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ, + int preferred), PNG_EMPTY); + +#ifdef PNG_sRGB_SUPPORTED +PNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr, + png_colorspacerp colorspace, int intent), PNG_EMPTY); + /* This does set the colorspace gAMA and cHRM values too, but doesn't set the + * flags to write them, if it returns false there was a problem and an error + * message has already been output (but the colorspace may still need to be + * synced to record the invalid flag). + */ +#endif /* sRGB */ + +#ifdef PNG_iCCP_SUPPORTED +PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_charp name, + png_uint_32 profile_length, png_const_bytep profile, int color_type), + PNG_EMPTY); + /* The 'name' is used for information only */ + +/* Routines for checking parts of an ICC profile. */ +#ifdef PNG_READ_iCCP_SUPPORTED +PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_charp name, + png_uint_32 profile_length), PNG_EMPTY); +#endif /* READ_iCCP */ +PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_charp name, + png_uint_32 profile_length, + png_const_bytep profile /* first 132 bytes only */, int color_type), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_charp name, + png_uint_32 profile_length, + png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY); +#ifdef PNG_sRGB_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,( + png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_bytep profile, uLong adler), PNG_EMPTY); + /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may + * be zero to indicate that it is not available. It is used, if provided, + * as a fast check on the profile when checking to see if it is sRGB. + */ +#endif +#endif /* iCCP */ + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients, + (png_structrp png_ptr), PNG_EMPTY); + /* Set the rgb_to_gray coefficients from the colorspace Y values */ +#endif /* READ_RGB_TO_GRAY */ +#endif /* COLORSPACE */ + +/* Added at libpng version 1.4.0 */ +PNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type),PNG_EMPTY); + +/* Added at libpng version 1.5.10 */ +#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ + defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes, + (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY); +#endif + +#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr, + png_const_charp name),PNG_NORETURN); +#endif + +/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite + * the end. Always leaves the buffer nul terminated. Never errors out (and + * there is no error code.) + */ +PNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize, + size_t pos, png_const_charp string),PNG_EMPTY); + +/* Various internal functions to handle formatted warning messages, currently + * only implemented for warnings. + */ +#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) +/* Utility to dump an unsigned value into a buffer, given a start pointer and + * and end pointer (which should point just *beyond* the end of the buffer!) + * Returns the pointer to the start of the formatted string. This utility only + * does unsigned values. + */ +PNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start, + png_charp end, int format, png_alloc_size_t number),PNG_EMPTY); + +/* Convenience macro that takes an array: */ +#define PNG_FORMAT_NUMBER(buffer,format,number) \ + png_format_number(buffer, buffer + (sizeof buffer), format, number) + +/* Suggested size for a number buffer (enough for 64 bits and a sign!) */ +#define PNG_NUMBER_BUFFER_SIZE 24 + +/* These are the integer formats currently supported, the name is formed from + * the standard printf(3) format string. + */ +#define PNG_NUMBER_FORMAT_u 1 /* chose unsigned API! */ +#define PNG_NUMBER_FORMAT_02u 2 +#define PNG_NUMBER_FORMAT_d 1 /* chose signed API! */ +#define PNG_NUMBER_FORMAT_02d 2 +#define PNG_NUMBER_FORMAT_x 3 +#define PNG_NUMBER_FORMAT_02x 4 +#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */ +#endif + +#ifdef PNG_WARNINGS_SUPPORTED +/* New defines and members adding in libpng-1.5.4 */ +# define PNG_WARNING_PARAMETER_SIZE 32 +# define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */ + +/* An l-value of this type has to be passed to the APIs below to cache the + * values of the parameters to a formatted warning message. + */ +typedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][ + PNG_WARNING_PARAMETER_SIZE]; + +PNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p, + int number, png_const_charp string),PNG_EMPTY); + /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters, + * including the trailing '\0'. + */ +PNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned, + (png_warning_parameters p, int number, int format, png_alloc_size_t value), + PNG_EMPTY); + /* Use png_alloc_size_t because it is an unsigned type as big as any we + * need to output. Use the following for a signed value. + */ +PNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed, + (png_warning_parameters p, int number, int format, png_int_32 value), + PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr, + png_warning_parameters p, png_const_charp message),PNG_EMPTY); + /* 'message' follows the X/Open approach of using @1, @2 to insert + * parameters previously supplied using the above functions. Errors in + * specifying the parameters will simply result in garbage substitutions. + */ +#endif + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +/* Application errors (new in 1.6); use these functions (declared below) for + * errors in the parameters or order of API function calls on read. The + * 'warning' should be used for an error that can be handled completely; the + * 'error' for one which can be handled safely but which may lose application + * information or settings. + * + * By default these both result in a png_error call prior to release, while in a + * released version the 'warning' is just a warning. However if the application + * explicitly disables benign errors (explicitly permitting the code to lose + * information) they both turn into warnings. + * + * If benign errors aren't supported they end up as the corresponding base call + * (png_warning or png_error.) + */ +PNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr, + png_const_charp message),PNG_EMPTY); + /* The application provided invalid parameters to an API function or called + * an API function at the wrong time, libpng can completely recover. + */ + +PNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr, + png_const_charp message),PNG_EMPTY); + /* As above but libpng will ignore the call, or attempt some other partial + * recovery from the error. + */ +#else +# define png_app_warning(pp,s) png_warning(pp,s) +# define png_app_error(pp,s) png_error(pp,s) +#endif + +PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr, + png_const_charp message, int error),PNG_EMPTY); + /* Report a recoverable issue in chunk data. On read this is used to report + * a problem found while reading a particular chunk and the + * png_chunk_benign_error or png_chunk_warning function is used as + * appropriate. On write this is used to report an error that comes from + * data set via an application call to a png_set_ API and png_app_error or + * png_app_warning is used as appropriate. + * + * The 'error' parameter must have one of the following values: + */ +#define PNG_CHUNK_WARNING 0 /* never an error */ +#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */ +#define PNG_CHUNK_ERROR 2 /* always an error */ + +/* ASCII to FP interfaces, currently only implemented if sCAL + * support is required. + */ +#if defined(PNG_sCAL_SUPPORTED) +/* MAX_DIGITS is actually the maximum number of characters in an sCAL + * width or height, derived from the precision (number of significant + * digits - a build time settable option) and assumptions about the + * maximum ridiculous exponent. + */ +#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/) + +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr, + png_charp ascii, png_size_t size, double fp, unsigned int precision), + PNG_EMPTY); +#endif /* FLOATING_POINT */ + +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr, + png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY); +#endif /* FIXED_POINT */ +#endif /* sCAL */ + +#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) +/* An internal API to validate the format of a floating point number. + * The result is the index of the next character. If the number is + * not valid it will be the index of a character in the supposed number. + * + * The format of a number is defined in the PNG extensions specification + * and this API is strictly conformant to that spec, not anyone elses! + * + * The format as a regular expression is: + * + * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)? + * + * or: + * + * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)? + * + * The complexity is that either integer or fraction must be present and the + * fraction is permitted to have no digits only if the integer is present. + * + * NOTE: The dangling E problem. + * There is a PNG valid floating point number in the following: + * + * PNG floating point numbers are not greedy. + * + * Working this out requires *TWO* character lookahead (because of the + * sign), the parser does not do this - it will fail at the 'r' - this + * doesn't matter for PNG sCAL chunk values, but it requires more care + * if the value were ever to be embedded in something more complex. Use + * ANSI-C strtod if you need the lookahead. + */ +/* State table for the parser. */ +#define PNG_FP_INTEGER 0 /* before or in integer */ +#define PNG_FP_FRACTION 1 /* before or in fraction */ +#define PNG_FP_EXPONENT 2 /* before or in exponent */ +#define PNG_FP_STATE 3 /* mask for the above */ +#define PNG_FP_SAW_SIGN 4 /* Saw +/- in current state */ +#define PNG_FP_SAW_DIGIT 8 /* Saw a digit in current state */ +#define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */ +#define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */ +#define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */ + +/* These three values don't affect the parser. They are set but not used. + */ +#define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */ +#define PNG_FP_NEGATIVE 128 /* A negative number, including "-0" */ +#define PNG_FP_NONZERO 256 /* A non-zero value */ +#define PNG_FP_STICKY 448 /* The above three flags */ + +/* This is available for the caller to store in 'state' if required. Do not + * call the parser after setting it (the parser sometimes clears it.) + */ +#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */ + +/* Result codes for the parser (boolean - true meants ok, false means + * not ok yet.) + */ +#define PNG_FP_MAYBE 0 /* The number may be valid in the future */ +#define PNG_FP_OK 1 /* The number is valid */ + +/* Tests on the sticky non-zero and negative flags. To pass these checks + * the state must also indicate that the whole number is valid - this is + * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this + * is equivalent to PNG_FP_OK above.) + */ +#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO) + /* NZ_MASK: the string is valid and a non-zero negative value */ +#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO) + /* Z MASK: the string is valid and a non-zero value. */ + /* PNG_FP_SAW_DIGIT: the string is valid. */ +#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT) +#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK) +#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK) + +/* The actual parser. This can be called repeatedly. It updates + * the index into the string and the state variable (which must + * be initialized to 0). It returns a result code, as above. There + * is no point calling the parser any more if it fails to advance to + * the end of the string - it is stuck on an invalid character (or + * terminated by '\0'). + * + * Note that the pointer will consume an E or even an E+ and then leave + * a 'maybe' state even though a preceding integer.fraction is valid. + * The PNG_FP_WAS_VALID flag indicates that a preceding substring was + * a valid number. It's possible to recover from this by calling + * the parser again (from the start, with state 0) but with a string + * that omits the last character (i.e. set the size to the index of + * the problem character.) This has not been tested within libpng. + */ +PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string, + png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY); + +/* This is the same but it checks a complete string and returns true + * only if it just contains a floating point number. As of 1.5.4 this + * function also returns the state at the end of parsing the number if + * it was valid (otherwise it returns 0.) This can be used for testing + * for negative or zero values using the sticky flag. + */ +PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string, + png_size_t size),PNG_EMPTY); +#endif /* pCAL || sCAL */ + +#if defined(PNG_GAMMA_SUPPORTED) ||\ + defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) +/* Added at libpng version 1.5.0 */ +/* This is a utility to provide a*times/div (rounded) and indicate + * if there is an overflow. The result is a boolean - false (0) + * for overflow, true (1) if no overflow, in which case *res + * holds the result. + */ +PNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a, + png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) +/* Same deal, but issue a warning on overflow and return 0. */ +PNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn, + (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by, + png_int_32 divided_by),PNG_EMPTY); +#endif + +#ifdef PNG_GAMMA_SUPPORTED +/* Calculate a reciprocal - used for gamma values. This returns + * 0 if the argument is 0 in order to maintain an undefined value; + * there are no warnings. + */ +PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a), + PNG_EMPTY); + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* The same but gives a reciprocal of the product of two fixed point + * values. Accuracy is suitable for gamma calculations but this is + * not exact - use png_muldiv for that. Only required at present on read. + */ +PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a, + png_fixed_point b),PNG_EMPTY); +#endif + +/* Return true if the gamma value is significantly different from 1.0 */ +PNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value), + PNG_EMPTY); +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* Internal fixed point gamma correction. These APIs are called as + * required to convert single values - they don't need to be fast, + * they are not used when processing image pixel values. + * + * While the input is an 'unsigned' value it must actually be the + * correct bit value - 0..255 or 0..65535 as required. + */ +PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr, + unsigned int value, png_fixed_point gamma_value),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value, + png_fixed_point gamma_value),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value, + png_fixed_point gamma_value),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr, + int bit_depth),PNG_EMPTY); +#endif + +/* SIMPLIFIED READ/WRITE SUPPORT */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +/* The internal structure that png_image::opaque points to. */ +typedef struct png_control +{ + png_structp png_ptr; + png_infop info_ptr; + png_voidp error_buf; /* Always a jmp_buf at present. */ + + png_const_bytep memory; /* Memory buffer. */ + png_size_t size; /* Size of the memory buffer. */ + + unsigned int for_write :1; /* Otherwise it is a read structure */ + unsigned int owned_file :1; /* We own the file in io_ptr */ +} png_control; + +/* Return the pointer to the jmp_buf from a png_control: necessary because C + * does not reveal the type of the elements of jmp_buf. + */ +#ifdef __cplusplus +# define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0]) +#else +# define png_control_jmp_buf(pc) ((pc)->error_buf) +#endif + +/* Utility to safely execute a piece of libpng code catching and logging any + * errors that might occur. Returns true on success, false on failure (either + * of the function or as a result of a png_error.) + */ +PNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr, + png_const_charp error_message),PNG_NORETURN); + +#ifdef PNG_WARNINGS_SUPPORTED +PNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr, + png_const_charp warning_message),PNG_EMPTY); +#else +# define png_safe_warning 0/*dummy argument*/ +#endif + +PNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image, + int (*function)(png_voidp), png_voidp arg),PNG_EMPTY); + +/* Utility to log an error; this also cleans up the png_image; the function + * always returns 0 (false). + */ +PNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image, + png_const_charp error_message),PNG_EMPTY); + +#ifndef PNG_SIMPLIFIED_READ_SUPPORTED +/* png_image_free is used by the write code but not exported */ +PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY); +#endif /* !SIMPLIFIED_READ */ + +#endif /* SIMPLIFIED READ/WRITE */ + +/* These are initialization functions for hardware specific PNG filter + * optimizations; list these here then select the appropriate one at compile + * time using the macro PNG_FILTER_OPTIMIZATIONS. If the macro is not defined + * the generic code is used. + */ +#ifdef PNG_FILTER_OPTIMIZATIONS +PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, + unsigned int bpp), PNG_EMPTY); + /* Just declare the optimization that will be used */ +#else + /* List *all* the possible optimizations here - this branch is required if + * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in + * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing. + */ +# if PNG_ARM_NEON_OPT > 0 +PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon, + (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); +#endif + +#if PNG_MIPS_MSA_OPT > 0 +PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa, + (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); +#endif + +# if PNG_INTEL_SSE_IMPLEMENTATION > 0 +PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2, + (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); +# endif +#endif + +PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr, + png_const_charp key, png_bytep new_key), PNG_EMPTY); + +/* Maintainer: Put new private prototypes here ^ */ + +#include "pngdebug.h" + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +#endif /* PNGPRIV_H */ diff --git a/xs/src/png/libpng/pngread.c b/xs/src/png/libpng/pngread.c new file mode 100644 index 0000000000..da32e9ad9c --- /dev/null +++ b/xs/src/png/libpng/pngread.c @@ -0,0 +1,4219 @@ + +/* pngread.c - read a PNG file + * + * Last changed in libpng 1.6.33 [September 28, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * This file contains routines that an application calls directly to + * read a PNG file or stream. + */ + +#include "pngpriv.h" +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) +# include +#endif + +#ifdef PNG_READ_SUPPORTED + +/* Create a PNG structure for reading, and allocate any memory needed. */ +PNG_FUNCTION(png_structp,PNGAPI +png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) +{ +#ifndef PNG_USER_MEM_SUPPORTED + png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, + error_fn, warn_fn, NULL, NULL, NULL); +#else + return png_create_read_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, NULL, NULL, NULL); +} + +/* Alternate create PNG structure for reading, and allocate any memory + * needed. + */ +PNG_FUNCTION(png_structp,PNGAPI +png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) +{ + png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, + error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); +#endif /* USER_MEM */ + + if (png_ptr != NULL) + { + png_ptr->mode = PNG_IS_READ_STRUCT; + + /* Added in libpng-1.6.0; this can be used to detect a read structure if + * required (it will be zero in a write structure.) + */ +# ifdef PNG_SEQUENTIAL_READ_SUPPORTED + png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE; +# endif + +# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED + png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; + + /* In stable builds only warn if an application error can be completely + * handled. + */ +# if PNG_RELEASE_BUILD + png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; +# endif +# endif + + /* TODO: delay this, it can be done in png_init_io (if the app doesn't + * do it itself) avoiding setting the default function if it is not + * required. + */ + png_set_read_fn(png_ptr, NULL, NULL); + } + + return png_ptr; +} + + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the information before the actual image data. This has been + * changed in v0.90 to allow reading a file that already has the magic + * bytes read from the stream. You can tell libpng how many bytes have + * been read from the beginning of the stream (up to the maximum of 8) + * via png_set_sig_bytes(), and we will only check the remaining bytes + * here. The application can then have access to the signature bytes we + * read if it is determined that this isn't a valid PNG file. + */ +void PNGAPI +png_read_info(png_structrp png_ptr, png_inforp info_ptr) +{ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + int keep; +#endif + + png_debug(1, "in png_read_info"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* Read and check the PNG file signature. */ + png_read_sig(png_ptr, info_ptr); + + for (;;) + { + png_uint_32 length = png_read_chunk_header(png_ptr); + png_uint_32 chunk_name = png_ptr->chunk_name; + + /* IDAT logic needs to happen here to simplify getting the two flags + * right. + */ + if (chunk_name == png_IDAT) + { + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "Missing IHDR before IDAT"); + + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + (png_ptr->mode & PNG_HAVE_PLTE) == 0) + png_chunk_error(png_ptr, "Missing PLTE before IDAT"); + + else if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) + png_chunk_benign_error(png_ptr, "Too many IDATs found"); + + png_ptr->mode |= PNG_HAVE_IDAT; + } + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + png_ptr->mode |= PNG_AFTER_IDAT; + } + + /* This should be a binary subdivision search or a hash for + * matching the chunk name rather than a linear search. + */ + if (chunk_name == png_IHDR) + png_handle_IHDR(png_ptr, info_ptr, length); + + else if (chunk_name == png_IEND) + png_handle_IEND(png_ptr, info_ptr, length); + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) + { + png_handle_unknown(png_ptr, info_ptr, length, keep); + + if (chunk_name == png_PLTE) + png_ptr->mode |= PNG_HAVE_PLTE; + + else if (chunk_name == png_IDAT) + { + png_ptr->idat_size = 0; /* It has been consumed */ + break; + } + } +#endif + else if (chunk_name == png_PLTE) + png_handle_PLTE(png_ptr, info_ptr, length); + + else if (chunk_name == png_IDAT) + { + png_ptr->idat_size = length; + break; + } + +#ifdef PNG_READ_bKGD_SUPPORTED + else if (chunk_name == png_bKGD) + png_handle_bKGD(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_cHRM_SUPPORTED + else if (chunk_name == png_cHRM) + png_handle_cHRM(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_eXIf_SUPPORTED + else if (chunk_name == png_eXIf) + png_handle_eXIf(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_gAMA_SUPPORTED + else if (chunk_name == png_gAMA) + png_handle_gAMA(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_hIST_SUPPORTED + else if (chunk_name == png_hIST) + png_handle_hIST(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_oFFs_SUPPORTED + else if (chunk_name == png_oFFs) + png_handle_oFFs(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_pCAL_SUPPORTED + else if (chunk_name == png_pCAL) + png_handle_pCAL(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_sCAL_SUPPORTED + else if (chunk_name == png_sCAL) + png_handle_sCAL(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_pHYs_SUPPORTED + else if (chunk_name == png_pHYs) + png_handle_pHYs(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_sBIT_SUPPORTED + else if (chunk_name == png_sBIT) + png_handle_sBIT(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_sRGB_SUPPORTED + else if (chunk_name == png_sRGB) + png_handle_sRGB(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_iCCP_SUPPORTED + else if (chunk_name == png_iCCP) + png_handle_iCCP(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_sPLT_SUPPORTED + else if (chunk_name == png_sPLT) + png_handle_sPLT(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_tEXt_SUPPORTED + else if (chunk_name == png_tEXt) + png_handle_tEXt(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_tIME_SUPPORTED + else if (chunk_name == png_tIME) + png_handle_tIME(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_tRNS_SUPPORTED + else if (chunk_name == png_tRNS) + png_handle_tRNS(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_zTXt_SUPPORTED + else if (chunk_name == png_zTXt) + png_handle_zTXt(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_iTXt_SUPPORTED + else if (chunk_name == png_iTXt) + png_handle_iTXt(png_ptr, info_ptr, length); +#endif + + else + png_handle_unknown(png_ptr, info_ptr, length, + PNG_HANDLE_CHUNK_AS_DEFAULT); + } +} +#endif /* SEQUENTIAL_READ */ + +/* Optional call to update the users info_ptr structure */ +void PNGAPI +png_read_update_info(png_structrp png_ptr, png_inforp info_ptr) +{ + png_debug(1, "in png_read_update_info"); + + if (png_ptr != NULL) + { + if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) + { + png_read_start_row(png_ptr); + +# ifdef PNG_READ_TRANSFORMS_SUPPORTED + png_read_transform_info(png_ptr, info_ptr); +# else + PNG_UNUSED(info_ptr) +# endif + } + + /* New in 1.6.0 this avoids the bug of doing the initializations twice */ + else + png_app_error(png_ptr, + "png_read_update_info/png_start_read_image: duplicate call"); + } +} + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Initialize palette, background, etc, after transformations + * are set, but before any reading takes place. This allows + * the user to obtain a gamma-corrected palette, for example. + * If the user doesn't call this, we will do it ourselves. + */ +void PNGAPI +png_start_read_image(png_structrp png_ptr) +{ + png_debug(1, "in png_start_read_image"); + + if (png_ptr != NULL) + { + if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) + png_read_start_row(png_ptr); + + /* New in 1.6.0 this avoids the bug of doing the initializations twice */ + else + png_app_error(png_ptr, + "png_start_read_image/png_read_update_info: duplicate call"); + } +} +#endif /* SEQUENTIAL_READ */ + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_MNG_FEATURES_SUPPORTED +/* Undoes intrapixel differencing, + * NOTE: this is apparently only supported in the 'sequential' reader. + */ +static void +png_do_read_intrapixel(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_intrapixel"); + + if ( + (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + int bytes_per_pixel; + png_uint_32 row_width = row_info->width; + + if (row_info->bit_depth == 8) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 3; + + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 4; + + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + *(rp) = (png_byte)((256 + *rp + *(rp + 1)) & 0xff); + *(rp+2) = (png_byte)((256 + *(rp + 2) + *(rp + 1)) & 0xff); + } + } + else if (row_info->bit_depth == 16) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 6; + + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 8; + + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5); + png_uint_32 red = (s0 + s1 + 65536) & 0xffff; + png_uint_32 blue = (s2 + s1 + 65536) & 0xffff; + *(rp ) = (png_byte)((red >> 8) & 0xff); + *(rp + 1) = (png_byte)(red & 0xff); + *(rp + 4) = (png_byte)((blue >> 8) & 0xff); + *(rp + 5) = (png_byte)(blue & 0xff); + } + } + } +} +#endif /* MNG_FEATURES */ + +void PNGAPI +png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) +{ + png_row_info row_info; + + if (png_ptr == NULL) + return; + + png_debug2(1, "in png_read_row (row %lu, pass %d)", + (unsigned long)png_ptr->row_number, png_ptr->pass); + + /* png_read_start_row sets the information (in particular iwidth) for this + * interlace pass. + */ + if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) + png_read_start_row(png_ptr); + + /* 1.5.6: row_info moved out of png_struct to a local here. */ + row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ + row_info.color_type = png_ptr->color_type; + row_info.bit_depth = png_ptr->bit_depth; + row_info.channels = png_ptr->channels; + row_info.pixel_depth = png_ptr->pixel_depth; + row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); + +#ifdef PNG_WARNINGS_SUPPORTED + if (png_ptr->row_number == 0 && png_ptr->pass == 0) + { + /* Check for transforms that have been set but were defined out */ +#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) + if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) + png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined"); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) + if ((png_ptr->transformations & PNG_FILLER) != 0) + png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined"); +#endif + +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ + !defined(PNG_READ_PACKSWAP_SUPPORTED) + if ((png_ptr->transformations & PNG_PACKSWAP) != 0) + png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined"); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) + if ((png_ptr->transformations & PNG_PACK) != 0) + png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined"); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) + if ((png_ptr->transformations & PNG_SHIFT) != 0) + png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined"); +#endif + +#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) + if ((png_ptr->transformations & PNG_BGR) != 0) + png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined"); +#endif + +#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) + if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) + png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined"); +#endif + } +#endif /* WARNINGS */ + +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* If interlaced and we do not need a new row, combine row and return. + * Notice that the pixels we have from previous rows have been transformed + * already; we can only combine like with like (transformed or + * untransformed) and, because of the libpng API for interlaced images, this + * means we must transform before de-interlacing. + */ + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) != 0) + { + switch (png_ptr->pass) + { + case 0: + if (png_ptr->row_number & 0x07) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, 1/*display*/); + png_read_finish_row(png_ptr); + return; + } + break; + + case 1: + if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, 1/*display*/); + + png_read_finish_row(png_ptr); + return; + } + break; + + case 2: + if ((png_ptr->row_number & 0x07) != 4) + { + if (dsp_row != NULL && (png_ptr->row_number & 4)) + png_combine_row(png_ptr, dsp_row, 1/*display*/); + + png_read_finish_row(png_ptr); + return; + } + break; + + case 3: + if ((png_ptr->row_number & 3) || png_ptr->width < 3) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, 1/*display*/); + + png_read_finish_row(png_ptr); + return; + } + break; + + case 4: + if ((png_ptr->row_number & 3) != 2) + { + if (dsp_row != NULL && (png_ptr->row_number & 2)) + png_combine_row(png_ptr, dsp_row, 1/*display*/); + + png_read_finish_row(png_ptr); + return; + } + break; + + case 5: + if ((png_ptr->row_number & 1) || png_ptr->width < 2) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, 1/*display*/); + + png_read_finish_row(png_ptr); + return; + } + break; + + default: + case 6: + if ((png_ptr->row_number & 1) == 0) + { + png_read_finish_row(png_ptr); + return; + } + break; + } + } +#endif + + if ((png_ptr->mode & PNG_HAVE_IDAT) == 0) + png_error(png_ptr, "Invalid attempt to read row data"); + + /* Fill the row with IDAT data: */ + png_ptr->row_buf[0]=255; /* to force error if no data was found */ + png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1); + + if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) + { + if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) + png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, + png_ptr->prev_row + 1, png_ptr->row_buf[0]); + else + png_error(png_ptr, "bad adaptive filter value"); + } + + /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before + * 1.5.6, while the buffer really is this big in current versions of libpng + * it may not be in the future, so this was changed just to copy the + * interlaced count: + */ + memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); + +#ifdef PNG_MNG_FEATURES_SUPPORTED + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) + { + /* Intrapixel differencing */ + png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1); + } +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + if (png_ptr->transformations) + png_do_read_transformations(png_ptr, &row_info); +#endif + + /* The transformed pixel depth should match the depth now in row_info. */ + if (png_ptr->transformed_pixel_depth == 0) + { + png_ptr->transformed_pixel_depth = row_info.pixel_depth; + if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) + png_error(png_ptr, "sequential row overflow"); + } + + else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) + png_error(png_ptr, "internal sequential row size calculation error"); + +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Expand interlaced rows to full size */ + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) != 0) + { + if (png_ptr->pass < 6) + png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, + png_ptr->transformations); + + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, 1/*display*/); + + if (row != NULL) + png_combine_row(png_ptr, row, 0/*row*/); + } + + else +#endif + { + if (row != NULL) + png_combine_row(png_ptr, row, -1/*ignored*/); + + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, -1/*ignored*/); + } + png_read_finish_row(png_ptr); + + if (png_ptr->read_row_fn != NULL) + (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); + +} +#endif /* SEQUENTIAL_READ */ + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read one or more rows of image data. If the image is interlaced, + * and png_set_interlace_handling() has been called, the rows need to + * contain the contents of the rows from the previous pass. If the + * image has alpha or transparency, and png_handle_alpha()[*] has been + * called, the rows contents must be initialized to the contents of the + * screen. + * + * "row" holds the actual image, and pixels are placed in it + * as they arrive. If the image is displayed after each pass, it will + * appear to "sparkle" in. "display_row" can be used to display a + * "chunky" progressive image, with finer detail added as it becomes + * available. If you do not want this "chunky" display, you may pass + * NULL for display_row. If you do not want the sparkle display, and + * you have not called png_handle_alpha(), you may pass NULL for rows. + * If you have called png_handle_alpha(), and the image has either an + * alpha channel or a transparency chunk, you must provide a buffer for + * rows. In this case, you do not have to provide a display_row buffer + * also, but you may. If the image is not interlaced, or if you have + * not called png_set_interlace_handling(), the display_row buffer will + * be ignored, so pass NULL to it. + * + * [*] png_handle_alpha() does not exist yet, as of this version of libpng + */ + +void PNGAPI +png_read_rows(png_structrp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows) +{ + png_uint_32 i; + png_bytepp rp; + png_bytepp dp; + + png_debug(1, "in png_read_rows"); + + if (png_ptr == NULL) + return; + + rp = row; + dp = display_row; + if (rp != NULL && dp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep rptr = *rp++; + png_bytep dptr = *dp++; + + png_read_row(png_ptr, rptr, dptr); + } + + else if (rp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep rptr = *rp; + png_read_row(png_ptr, rptr, NULL); + rp++; + } + + else if (dp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep dptr = *dp; + png_read_row(png_ptr, NULL, dptr); + dp++; + } +} +#endif /* SEQUENTIAL_READ */ + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the entire image. If the image has an alpha channel or a tRNS + * chunk, and you have called png_handle_alpha()[*], you will need to + * initialize the image to the current image that PNG will be overlaying. + * We set the num_rows again here, in case it was incorrectly set in + * png_read_start_row() by a call to png_read_update_info() or + * png_start_read_image() if png_set_interlace_handling() wasn't called + * prior to either of these functions like it should have been. You can + * only call this function once. If you desire to have an image for + * each pass of a interlaced image, use png_read_rows() instead. + * + * [*] png_handle_alpha() does not exist yet, as of this version of libpng + */ +void PNGAPI +png_read_image(png_structrp png_ptr, png_bytepp image) +{ + png_uint_32 i, image_height; + int pass, j; + png_bytepp rp; + + png_debug(1, "in png_read_image"); + + if (png_ptr == NULL) + return; + +#ifdef PNG_READ_INTERLACING_SUPPORTED + if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) + { + pass = png_set_interlace_handling(png_ptr); + /* And make sure transforms are initialized. */ + png_start_read_image(png_ptr); + } + else + { + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) == 0) + { + /* Caller called png_start_read_image or png_read_update_info without + * first turning on the PNG_INTERLACE transform. We can fix this here, + * but the caller should do it! + */ + png_warning(png_ptr, "Interlace handling should be turned on when " + "using png_read_image"); + /* Make sure this is set correctly */ + png_ptr->num_rows = png_ptr->height; + } + + /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in + * the above error case. + */ + pass = png_set_interlace_handling(png_ptr); + } +#else + if (png_ptr->interlaced) + png_error(png_ptr, + "Cannot read interlaced image -- interlace handler disabled"); + + pass = 1; +#endif + + image_height=png_ptr->height; + + for (j = 0; j < pass; j++) + { + rp = image; + for (i = 0; i < image_height; i++) + { + png_read_row(png_ptr, *rp, NULL); + rp++; + } + } +} +#endif /* SEQUENTIAL_READ */ + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the end of the PNG file. Will not read past the end of the + * file, will verify the end is accurate, and will read any comments + * or time information at the end of the file, if info is not NULL. + */ +void PNGAPI +png_read_end(png_structrp png_ptr, png_inforp info_ptr) +{ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + int keep; +#endif + + png_debug(1, "in png_read_end"); + + if (png_ptr == NULL) + return; + + /* If png_read_end is called in the middle of reading the rows there may + * still be pending IDAT data and an owned zstream. Deal with this here. + */ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + if (png_chunk_unknown_handling(png_ptr, png_IDAT) == 0) +#endif + png_read_finish_IDAT(png_ptr); + +#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Report invalid palette index; added at libng-1.5.10 */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max > png_ptr->num_palette) + png_benign_error(png_ptr, "Read palette index exceeding num_palette"); +#endif + + do + { + png_uint_32 length = png_read_chunk_header(png_ptr); + png_uint_32 chunk_name = png_ptr->chunk_name; + + if (chunk_name != png_IDAT) + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + + if (chunk_name == png_IEND) + png_handle_IEND(png_ptr, info_ptr, length); + + else if (chunk_name == png_IHDR) + png_handle_IHDR(png_ptr, info_ptr, length); + + else if (info_ptr == NULL) + png_crc_finish(png_ptr, length); + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) + { + if (chunk_name == png_IDAT) + { + if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) + png_benign_error(png_ptr, ".Too many IDATs found"); + } + png_handle_unknown(png_ptr, info_ptr, length, keep); + if (chunk_name == png_PLTE) + png_ptr->mode |= PNG_HAVE_PLTE; + } +#endif + + else if (chunk_name == png_IDAT) + { + /* Zero length IDATs are legal after the last IDAT has been + * read, but not after other chunks have been read. 1.6 does not + * always read all the deflate data; specifically it cannot be relied + * upon to read the Adler32 at the end. If it doesn't ignore IDAT + * chunks which are longer than zero as well: + */ + if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) + png_benign_error(png_ptr, "..Too many IDATs found"); + + png_crc_finish(png_ptr, length); + } + else if (chunk_name == png_PLTE) + png_handle_PLTE(png_ptr, info_ptr, length); + +#ifdef PNG_READ_bKGD_SUPPORTED + else if (chunk_name == png_bKGD) + png_handle_bKGD(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_cHRM_SUPPORTED + else if (chunk_name == png_cHRM) + png_handle_cHRM(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_eXIf_SUPPORTED + else if (chunk_name == png_eXIf) + png_handle_eXIf(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_gAMA_SUPPORTED + else if (chunk_name == png_gAMA) + png_handle_gAMA(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_hIST_SUPPORTED + else if (chunk_name == png_hIST) + png_handle_hIST(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_oFFs_SUPPORTED + else if (chunk_name == png_oFFs) + png_handle_oFFs(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_pCAL_SUPPORTED + else if (chunk_name == png_pCAL) + png_handle_pCAL(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_sCAL_SUPPORTED + else if (chunk_name == png_sCAL) + png_handle_sCAL(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_pHYs_SUPPORTED + else if (chunk_name == png_pHYs) + png_handle_pHYs(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_sBIT_SUPPORTED + else if (chunk_name == png_sBIT) + png_handle_sBIT(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_sRGB_SUPPORTED + else if (chunk_name == png_sRGB) + png_handle_sRGB(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_iCCP_SUPPORTED + else if (chunk_name == png_iCCP) + png_handle_iCCP(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_sPLT_SUPPORTED + else if (chunk_name == png_sPLT) + png_handle_sPLT(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_tEXt_SUPPORTED + else if (chunk_name == png_tEXt) + png_handle_tEXt(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_tIME_SUPPORTED + else if (chunk_name == png_tIME) + png_handle_tIME(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_tRNS_SUPPORTED + else if (chunk_name == png_tRNS) + png_handle_tRNS(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_zTXt_SUPPORTED + else if (chunk_name == png_zTXt) + png_handle_zTXt(png_ptr, info_ptr, length); +#endif + +#ifdef PNG_READ_iTXt_SUPPORTED + else if (chunk_name == png_iTXt) + png_handle_iTXt(png_ptr, info_ptr, length); +#endif + + else + png_handle_unknown(png_ptr, info_ptr, length, + PNG_HANDLE_CHUNK_AS_DEFAULT); + } while ((png_ptr->mode & PNG_HAVE_IEND) == 0); +} +#endif /* SEQUENTIAL_READ */ + +/* Free all memory used in the read struct */ +static void +png_read_destroy(png_structrp png_ptr) +{ + png_debug(1, "in png_read_destroy"); + +#ifdef PNG_READ_GAMMA_SUPPORTED + png_destroy_gamma_table(png_ptr); +#endif + + png_free(png_ptr, png_ptr->big_row_buf); + png_ptr->big_row_buf = NULL; + png_free(png_ptr, png_ptr->big_prev_row); + png_ptr->big_prev_row = NULL; + png_free(png_ptr, png_ptr->read_buffer); + png_ptr->read_buffer = NULL; + +#ifdef PNG_READ_QUANTIZE_SUPPORTED + png_free(png_ptr, png_ptr->palette_lookup); + png_ptr->palette_lookup = NULL; + png_free(png_ptr, png_ptr->quantize_index); + png_ptr->quantize_index = NULL; +#endif + + if ((png_ptr->free_me & PNG_FREE_PLTE) != 0) + { + png_zfree(png_ptr, png_ptr->palette); + png_ptr->palette = NULL; + } + png_ptr->free_me &= ~PNG_FREE_PLTE; + +#if defined(PNG_tRNS_SUPPORTED) || \ + defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if ((png_ptr->free_me & PNG_FREE_TRNS) != 0) + { + png_free(png_ptr, png_ptr->trans_alpha); + png_ptr->trans_alpha = NULL; + } + png_ptr->free_me &= ~PNG_FREE_TRNS; +#endif + + inflateEnd(&png_ptr->zstream); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_free(png_ptr, png_ptr->save_buffer); + png_ptr->save_buffer = NULL; +#endif + +#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) && \ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + png_free(png_ptr, png_ptr->unknown_chunk.data); + png_ptr->unknown_chunk.data = NULL; +#endif + +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list = NULL; +#endif + + /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error + * callbacks are still set at this point. They are required to complete the + * destruction of the png_struct itself. + */ +} + +/* Free all memory used by the read */ +void PNGAPI +png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, + png_infopp end_info_ptr_ptr) +{ + png_structrp png_ptr = NULL; + + png_debug(1, "in png_destroy_read_struct"); + + if (png_ptr_ptr != NULL) + png_ptr = *png_ptr_ptr; + + if (png_ptr == NULL) + return; + + /* libpng 1.6.0: use the API to destroy info structs to ensure consistent + * behavior. Prior to 1.6.0 libpng did extra 'info' destruction in this API. + * The extra was, apparently, unnecessary yet this hides memory leak bugs. + */ + png_destroy_info_struct(png_ptr, end_info_ptr_ptr); + png_destroy_info_struct(png_ptr, info_ptr_ptr); + + *png_ptr_ptr = NULL; + png_read_destroy(png_ptr); + png_destroy_png_struct(png_ptr); +} + +void PNGAPI +png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn) +{ + if (png_ptr == NULL) + return; + + png_ptr->read_row_fn = read_row_fn; +} + + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_INFO_IMAGE_SUPPORTED +void PNGAPI +png_read_png(png_structrp png_ptr, png_inforp info_ptr, + int transforms, voidp params) +{ + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* png_read_info() gives us all of the information from the + * PNG file before the first IDAT (image data chunk). + */ + png_read_info(png_ptr, info_ptr); + if (info_ptr->height > PNG_UINT_32_MAX/(sizeof (png_bytep))) + png_error(png_ptr, "Image is too high to process with png_read_png()"); + + /* -------------- image transformations start here ------------------- */ + /* libpng 1.6.10: add code to cause a png_app_error if a selected TRANSFORM + * is not implemented. This will only happen in de-configured (non-default) + * libpng builds. The results can be unexpected - png_read_png may return + * short or mal-formed rows because the transform is skipped. + */ + + /* Tell libpng to strip 16-bit/color files down to 8 bits per color. + */ + if ((transforms & PNG_TRANSFORM_SCALE_16) != 0) + /* Added at libpng-1.5.4. "strip_16" produces the same result that it + * did in earlier versions, while "scale_16" is now more accurate. + */ +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_set_scale_16(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_SCALE_16 not supported"); +#endif + + /* If both SCALE and STRIP are required pngrtran will effectively cancel the + * latter by doing SCALE first. This is ok and allows apps not to check for + * which is supported to get the right answer. + */ + if ((transforms & PNG_TRANSFORM_STRIP_16) != 0) +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + png_set_strip_16(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_16 not supported"); +#endif + + /* Strip alpha bytes from the input data without combining with + * the background (not recommended). + */ + if ((transforms & PNG_TRANSFORM_STRIP_ALPHA) != 0) +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + png_set_strip_alpha(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_ALPHA not supported"); +#endif + + /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single + * byte into separate bytes (useful for paletted and grayscale images). + */ + if ((transforms & PNG_TRANSFORM_PACKING) != 0) +#ifdef PNG_READ_PACK_SUPPORTED + png_set_packing(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported"); +#endif + + /* Change the order of packed pixels to least significant bit first + * (not useful if you are using png_set_packing). + */ + if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0) +#ifdef PNG_READ_PACKSWAP_SUPPORTED + png_set_packswap(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported"); +#endif + + /* Expand paletted colors into true RGB triplets + * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel + * Expand paletted or RGB images with transparency to full alpha + * channels so the data will be available as RGBA quartets. + */ + if ((transforms & PNG_TRANSFORM_EXPAND) != 0) +#ifdef PNG_READ_EXPAND_SUPPORTED + png_set_expand(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND not supported"); +#endif + + /* We don't handle background color or gamma transformation or quantizing. + */ + + /* Invert monochrome files to have 0 as white and 1 as black + */ + if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0) +#ifdef PNG_READ_INVERT_SUPPORTED + png_set_invert_mono(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported"); +#endif + + /* If you want to shift the pixel values from the range [0,255] or + * [0,65535] to the original [0,7] or [0,31], or whatever range the + * colors were originally in: + */ + if ((transforms & PNG_TRANSFORM_SHIFT) != 0) +#ifdef PNG_READ_SHIFT_SUPPORTED + if ((info_ptr->valid & PNG_INFO_sBIT) != 0) + png_set_shift(png_ptr, &info_ptr->sig_bit); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported"); +#endif + + /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ + if ((transforms & PNG_TRANSFORM_BGR) != 0) +#ifdef PNG_READ_BGR_SUPPORTED + png_set_bgr(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported"); +#endif + + /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ + if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0) +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED + png_set_swap_alpha(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported"); +#endif + + /* Swap bytes of 16-bit files to least significant byte first */ + if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0) +#ifdef PNG_READ_SWAP_SUPPORTED + png_set_swap(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported"); +#endif + +/* Added at libpng-1.2.41 */ + /* Invert the alpha channel from opacity to transparency */ + if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0) +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED + png_set_invert_alpha(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported"); +#endif + +/* Added at libpng-1.2.41 */ + /* Expand grayscale image to RGB */ + if ((transforms & PNG_TRANSFORM_GRAY_TO_RGB) != 0) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + png_set_gray_to_rgb(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_GRAY_TO_RGB not supported"); +#endif + +/* Added at libpng-1.5.4 */ + if ((transforms & PNG_TRANSFORM_EXPAND_16) != 0) +#ifdef PNG_READ_EXPAND_16_SUPPORTED + png_set_expand_16(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND_16 not supported"); +#endif + + /* We don't handle adding filler bytes */ + + /* We use png_read_image and rely on that for interlace handling, but we also + * call png_read_update_info therefore must turn on interlace handling now: + */ + (void)png_set_interlace_handling(png_ptr); + + /* Optional call to gamma correct and add the background to the palette + * and update info structure. REQUIRED if you are expecting libpng to + * update the palette for you (i.e., you selected such a transform above). + */ + png_read_update_info(png_ptr, info_ptr); + + /* -------------- image transformations end here ------------------- */ + + png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); + if (info_ptr->row_pointers == NULL) + { + png_uint_32 iptr; + + info_ptr->row_pointers = png_voidcast(png_bytepp, png_malloc(png_ptr, + info_ptr->height * (sizeof (png_bytep)))); + + for (iptr=0; iptrheight; iptr++) + info_ptr->row_pointers[iptr] = NULL; + + info_ptr->free_me |= PNG_FREE_ROWS; + + for (iptr = 0; iptr < info_ptr->height; iptr++) + info_ptr->row_pointers[iptr] = png_voidcast(png_bytep, + png_malloc(png_ptr, info_ptr->rowbytes)); + } + + png_read_image(png_ptr, info_ptr->row_pointers); + info_ptr->valid |= PNG_INFO_IDAT; + + /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ + png_read_end(png_ptr, info_ptr); + + PNG_UNUSED(params) +} +#endif /* INFO_IMAGE */ +#endif /* SEQUENTIAL_READ */ + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +/* SIMPLIFIED READ + * + * This code currently relies on the sequential reader, though it could easily + * be made to work with the progressive one. + */ +/* Arguments to png_image_finish_read: */ + +/* Encoding of PNG data (used by the color-map code) */ +# define P_NOTSET 0 /* File encoding not yet known */ +# define P_sRGB 1 /* 8-bit encoded to sRGB gamma */ +# define P_LINEAR 2 /* 16-bit linear: not encoded, NOT pre-multiplied! */ +# define P_FILE 3 /* 8-bit encoded to file gamma, not sRGB or linear */ +# define P_LINEAR8 4 /* 8-bit linear: only from a file value */ + +/* Color-map processing: after libpng has run on the PNG image further + * processing may be needed to convert the data to color-map indices. + */ +#define PNG_CMAP_NONE 0 +#define PNG_CMAP_GA 1 /* Process GA data to a color-map with alpha */ +#define PNG_CMAP_TRANS 2 /* Process GA data to a background index */ +#define PNG_CMAP_RGB 3 /* Process RGB data */ +#define PNG_CMAP_RGB_ALPHA 4 /* Process RGBA data */ + +/* The following document where the background is for each processing case. */ +#define PNG_CMAP_NONE_BACKGROUND 256 +#define PNG_CMAP_GA_BACKGROUND 231 +#define PNG_CMAP_TRANS_BACKGROUND 254 +#define PNG_CMAP_RGB_BACKGROUND 256 +#define PNG_CMAP_RGB_ALPHA_BACKGROUND 216 + +typedef struct +{ + /* Arguments: */ + png_imagep image; + png_voidp buffer; + png_int_32 row_stride; + png_voidp colormap; + png_const_colorp background; + /* Local variables: */ + png_voidp local_row; + png_voidp first_row; + ptrdiff_t row_bytes; /* step between rows */ + int file_encoding; /* E_ values above */ + png_fixed_point gamma_to_linear; /* For P_FILE, reciprocal of gamma */ + int colormap_processing; /* PNG_CMAP_ values above */ +} png_image_read_control; + +/* Do all the *safe* initialization - 'safe' means that png_error won't be + * called, so setting up the jmp_buf is not required. This means that anything + * called from here must *not* call png_malloc - it has to call png_malloc_warn + * instead so that control is returned safely back to this routine. + */ +static int +png_image_read_init(png_imagep image) +{ + if (image->opaque == NULL) + { + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, image, + png_safe_error, png_safe_warning); + + /* And set the rest of the structure to NULL to ensure that the various + * fields are consistent. + */ + memset(image, 0, (sizeof *image)); + image->version = PNG_IMAGE_VERSION; + + if (png_ptr != NULL) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (info_ptr != NULL) + { + png_controlp control = png_voidcast(png_controlp, + png_malloc_warn(png_ptr, (sizeof *control))); + + if (control != NULL) + { + memset(control, 0, (sizeof *control)); + + control->png_ptr = png_ptr; + control->info_ptr = info_ptr; + control->for_write = 0; + + image->opaque = control; + return 1; + } + + /* Error clean up */ + png_destroy_info_struct(png_ptr, &info_ptr); + } + + png_destroy_read_struct(&png_ptr, NULL, NULL); + } + + return png_image_error(image, "png_image_read: out of memory"); + } + + return png_image_error(image, "png_image_read: opaque pointer not NULL"); +} + +/* Utility to find the base format of a PNG file from a png_struct. */ +static png_uint_32 +png_image_format(png_structrp png_ptr) +{ + png_uint_32 format = 0; + + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + format |= PNG_FORMAT_FLAG_COLOR; + + if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) + format |= PNG_FORMAT_FLAG_ALPHA; + + /* Use png_ptr here, not info_ptr, because by examination png_handle_tRNS + * sets the png_struct fields; that's all we are interested in here. The + * precise interaction with an app call to png_set_tRNS and PNG file reading + * is unclear. + */ + else if (png_ptr->num_trans > 0) + format |= PNG_FORMAT_FLAG_ALPHA; + + if (png_ptr->bit_depth == 16) + format |= PNG_FORMAT_FLAG_LINEAR; + + if ((png_ptr->color_type & PNG_COLOR_MASK_PALETTE) != 0) + format |= PNG_FORMAT_FLAG_COLORMAP; + + return format; +} + +/* Is the given gamma significantly different from sRGB? The test is the same + * one used in pngrtran.c when deciding whether to do gamma correction. The + * arithmetic optimizes the division by using the fact that the inverse of the + * file sRGB gamma is 2.2 + */ +static int +png_gamma_not_sRGB(png_fixed_point g) +{ + if (g < PNG_FP_1) + { + /* An uninitialized gamma is assumed to be sRGB for the simplified API. */ + if (g == 0) + return 0; + + return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */); + } + + return 1; +} + +/* Do the main body of a 'png_image_begin_read' function; read the PNG file + * header and fill in all the information. This is executed in a safe context, + * unlike the init routine above. + */ +static int +png_image_read_header(png_voidp argument) +{ + png_imagep image = png_voidcast(png_imagep, argument); + png_structrp png_ptr = image->opaque->png_ptr; + png_inforp info_ptr = image->opaque->info_ptr; + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED + png_set_benign_errors(png_ptr, 1/*warn*/); +#endif + png_read_info(png_ptr, info_ptr); + + /* Do this the fast way; just read directly out of png_struct. */ + image->width = png_ptr->width; + image->height = png_ptr->height; + + { + png_uint_32 format = png_image_format(png_ptr); + + image->format = format; + +#ifdef PNG_COLORSPACE_SUPPORTED + /* Does the colorspace match sRGB? If there is no color endpoint + * (colorant) information assume yes, otherwise require the + * 'ENDPOINTS_MATCHP_sRGB' colorspace flag to have been set. If the + * colorspace has been determined to be invalid ignore it. + */ + if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags + & (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB| + PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS)) + image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB; +#endif + } + + /* We need the maximum number of entries regardless of the format the + * application sets here. + */ + { + png_uint_32 cmap_entries; + + switch (png_ptr->color_type) + { + case PNG_COLOR_TYPE_GRAY: + cmap_entries = 1U << png_ptr->bit_depth; + break; + + case PNG_COLOR_TYPE_PALETTE: + cmap_entries = (png_uint_32)png_ptr->num_palette; + break; + + default: + cmap_entries = 256; + break; + } + + if (cmap_entries > 256) + cmap_entries = 256; + + image->colormap_entries = cmap_entries; + } + + return 1; +} + +#ifdef PNG_STDIO_SUPPORTED +int PNGAPI +png_image_begin_read_from_stdio(png_imagep image, FILE* file) +{ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (file != NULL) + { + if (png_image_read_init(image) != 0) + { + /* This is slightly evil, but png_init_io doesn't do anything other + * than this and we haven't changed the standard IO functions so + * this saves a 'safe' function. + */ + image->opaque->png_ptr->io_ptr = file; + return png_safe_execute(image, png_image_read_header, image); + } + } + + else + return png_image_error(image, + "png_image_begin_read_from_stdio: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION"); + + return 0; +} + +int PNGAPI +png_image_begin_read_from_file(png_imagep image, const char *file_name) +{ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (file_name != NULL) + { + FILE *fp = fopen(file_name, "rb"); + + if (fp != NULL) + { + if (png_image_read_init(image) != 0) + { + image->opaque->png_ptr->io_ptr = fp; + image->opaque->owned_file = 1; + return png_safe_execute(image, png_image_read_header, image); + } + + /* Clean up: just the opened file. */ + (void)fclose(fp); + } + + else + return png_image_error(image, strerror(errno)); + } + + else + return png_image_error(image, + "png_image_begin_read_from_file: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION"); + + return 0; +} +#endif /* STDIO */ + +static void PNGCBAPI +png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need) +{ + if (png_ptr != NULL) + { + png_imagep image = png_voidcast(png_imagep, png_ptr->io_ptr); + if (image != NULL) + { + png_controlp cp = image->opaque; + if (cp != NULL) + { + png_const_bytep memory = cp->memory; + png_size_t size = cp->size; + + if (memory != NULL && size >= need) + { + memcpy(out, memory, need); + cp->memory = memory + need; + cp->size = size - need; + return; + } + + png_error(png_ptr, "read beyond end of data"); + } + } + + png_error(png_ptr, "invalid memory read"); + } +} + +int PNGAPI png_image_begin_read_from_memory(png_imagep image, + png_const_voidp memory, png_size_t size) +{ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (memory != NULL && size > 0) + { + if (png_image_read_init(image) != 0) + { + /* Now set the IO functions to read from the memory buffer and + * store it into io_ptr. Again do this in-place to avoid calling a + * libpng function that requires error handling. + */ + image->opaque->memory = png_voidcast(png_const_bytep, memory); + image->opaque->size = size; + image->opaque->png_ptr->io_ptr = image; + image->opaque->png_ptr->read_data_fn = png_image_memory_read; + + return png_safe_execute(image, png_image_read_header, image); + } + } + + else + return png_image_error(image, + "png_image_begin_read_from_memory: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION"); + + return 0; +} + +/* Utility function to skip chunks that are not used by the simplified image + * read functions and an appropriate macro to call it. + */ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +static void +png_image_skip_unused_chunks(png_structrp png_ptr) +{ + /* Prepare the reader to ignore all recognized chunks whose data will not + * be used, i.e., all chunks recognized by libpng except for those + * involved in basic image reading: + * + * IHDR, PLTE, IDAT, IEND + * + * Or image data handling: + * + * tRNS, bKGD, gAMA, cHRM, sRGB, [iCCP] and sBIT. + * + * This provides a small performance improvement and eliminates any + * potential vulnerability to security problems in the unused chunks. + * + * At present the iCCP chunk data isn't used, so iCCP chunk can be ignored + * too. This allows the simplified API to be compiled without iCCP support, + * however if the support is there the chunk is still checked to detect + * errors (which are unfortunately quite common.) + */ + { + static PNG_CONST png_byte chunks_to_process[] = { + 98, 75, 71, 68, '\0', /* bKGD */ + 99, 72, 82, 77, '\0', /* cHRM */ + 103, 65, 77, 65, '\0', /* gAMA */ +# ifdef PNG_READ_iCCP_SUPPORTED + 105, 67, 67, 80, '\0', /* iCCP */ +# endif + 115, 66, 73, 84, '\0', /* sBIT */ + 115, 82, 71, 66, '\0', /* sRGB */ + }; + + /* Ignore unknown chunks and all other chunks except for the + * IHDR, PLTE, tRNS, IDAT, and IEND chunks. + */ + png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER, + NULL, -1); + + /* But do not ignore image data handling chunks */ + png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT, + chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5); + } +} + +# define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p) +#else +# define PNG_SKIP_CHUNKS(p) ((void)0) +#endif /* HANDLE_AS_UNKNOWN */ + +/* The following macro gives the exact rounded answer for all values in the + * range 0..255 (it actually divides by 51.2, but the rounding still generates + * the correct numbers 0..5 + */ +#define PNG_DIV51(v8) (((v8) * 5 + 130) >> 8) + +/* Utility functions to make particular color-maps */ +static void +set_file_encoding(png_image_read_control *display) +{ + png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma; + if (png_gamma_significant(g) != 0) + { + if (png_gamma_not_sRGB(g) != 0) + { + display->file_encoding = P_FILE; + display->gamma_to_linear = png_reciprocal(g); + } + + else + display->file_encoding = P_sRGB; + } + + else + display->file_encoding = P_LINEAR8; +} + +static unsigned int +decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) +{ + if (encoding == P_FILE) /* double check */ + encoding = display->file_encoding; + + if (encoding == P_NOTSET) /* must be the file encoding */ + { + set_file_encoding(display); + encoding = display->file_encoding; + } + + switch (encoding) + { + case P_FILE: + value = png_gamma_16bit_correct(value*257, display->gamma_to_linear); + break; + + case P_sRGB: + value = png_sRGB_table[value]; + break; + + case P_LINEAR: + break; + + case P_LINEAR8: + value *= 257; + break; + +#ifdef __GNUC__ + default: + png_error(display->image->opaque->png_ptr, + "unexpected encoding (internal error)"); +#endif + } + + return value; +} + +static png_uint_32 +png_colormap_compose(png_image_read_control *display, + png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, + png_uint_32 background, int encoding) +{ + /* The file value is composed on the background, the background has the given + * encoding and so does the result, the file is encoded with P_FILE and the + * file and alpha are 8-bit values. The (output) encoding will always be + * P_LINEAR or P_sRGB. + */ + png_uint_32 f = decode_gamma(display, foreground, foreground_encoding); + png_uint_32 b = decode_gamma(display, background, encoding); + + /* The alpha is always an 8-bit value (it comes from the palette), the value + * scaled by 255 is what PNG_sRGB_FROM_LINEAR requires. + */ + f = f * alpha + b * (255-alpha); + + if (encoding == P_LINEAR) + { + /* Scale to 65535; divide by 255, approximately (in fact this is extremely + * accurate, it divides by 255.00000005937181414556, with no overflow.) + */ + f *= 257; /* Now scaled by 65535 */ + f += f >> 16; + f = (f+32768) >> 16; + } + + else /* P_sRGB */ + f = PNG_sRGB_FROM_LINEAR(f); + + return f; +} + +/* NOTE: P_LINEAR values to this routine must be 16-bit, but P_FILE values must + * be 8-bit. + */ +static void +png_create_colormap_entry(png_image_read_control *display, + png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, + png_uint_32 alpha, int encoding) +{ + png_imagep image = display->image; + const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ? + P_LINEAR : P_sRGB; + const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && + (red != green || green != blue); + + if (ip > 255) + png_error(image->opaque->png_ptr, "color-map index out of range"); + + /* Update the cache with whether the file gamma is significantly different + * from sRGB. + */ + if (encoding == P_FILE) + { + if (display->file_encoding == P_NOTSET) + set_file_encoding(display); + + /* Note that the cached value may be P_FILE too, but if it is then the + * gamma_to_linear member has been set. + */ + encoding = display->file_encoding; + } + + if (encoding == P_FILE) + { + png_fixed_point g = display->gamma_to_linear; + + red = png_gamma_16bit_correct(red*257, g); + green = png_gamma_16bit_correct(green*257, g); + blue = png_gamma_16bit_correct(blue*257, g); + + if (convert_to_Y != 0 || output_encoding == P_LINEAR) + { + alpha *= 257; + encoding = P_LINEAR; + } + + else + { + red = PNG_sRGB_FROM_LINEAR(red * 255); + green = PNG_sRGB_FROM_LINEAR(green * 255); + blue = PNG_sRGB_FROM_LINEAR(blue * 255); + encoding = P_sRGB; + } + } + + else if (encoding == P_LINEAR8) + { + /* This encoding occurs quite frequently in test cases because PngSuite + * includes a gAMA 1.0 chunk with most images. + */ + red *= 257; + green *= 257; + blue *= 257; + alpha *= 257; + encoding = P_LINEAR; + } + + else if (encoding == P_sRGB && + (convert_to_Y != 0 || output_encoding == P_LINEAR)) + { + /* The values are 8-bit sRGB values, but must be converted to 16-bit + * linear. + */ + red = png_sRGB_table[red]; + green = png_sRGB_table[green]; + blue = png_sRGB_table[blue]; + alpha *= 257; + encoding = P_LINEAR; + } + + /* This is set if the color isn't gray but the output is. */ + if (encoding == P_LINEAR) + { + if (convert_to_Y != 0) + { + /* NOTE: these values are copied from png_do_rgb_to_gray */ + png_uint_32 y = (png_uint_32)6968 * red + (png_uint_32)23434 * green + + (png_uint_32)2366 * blue; + + if (output_encoding == P_LINEAR) + y = (y + 16384) >> 15; + + else + { + /* y is scaled by 32768, we need it scaled by 255: */ + y = (y + 128) >> 8; + y *= 255; + y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7); + alpha = PNG_DIV257(alpha); + encoding = P_sRGB; + } + + blue = red = green = y; + } + + else if (output_encoding == P_sRGB) + { + red = PNG_sRGB_FROM_LINEAR(red * 255); + green = PNG_sRGB_FROM_LINEAR(green * 255); + blue = PNG_sRGB_FROM_LINEAR(blue * 255); + alpha = PNG_DIV257(alpha); + encoding = P_sRGB; + } + } + + if (encoding != output_encoding) + png_error(image->opaque->png_ptr, "bad encoding (internal error)"); + + /* Store the value. */ + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 && + (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; +# else +# define afirst 0 +# endif +# ifdef PNG_FORMAT_BGR_SUPPORTED + const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; +# else +# define bgr 0 +# endif + + if (output_encoding == P_LINEAR) + { + png_uint_16p entry = png_voidcast(png_uint_16p, display->colormap); + + entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format); + + /* The linear 16-bit values must be pre-multiplied by the alpha channel + * value, if less than 65535 (this is, effectively, composite on black + * if the alpha channel is removed.) + */ + switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format)) + { + case 4: + entry[afirst ? 0 : 3] = (png_uint_16)alpha; + /* FALLTHROUGH */ + + case 3: + if (alpha < 65535) + { + if (alpha > 0) + { + blue = (blue * alpha + 32767U)/65535U; + green = (green * alpha + 32767U)/65535U; + red = (red * alpha + 32767U)/65535U; + } + + else + red = green = blue = 0; + } + entry[afirst + (2 ^ bgr)] = (png_uint_16)blue; + entry[afirst + 1] = (png_uint_16)green; + entry[afirst + bgr] = (png_uint_16)red; + break; + + case 2: + entry[1 ^ afirst] = (png_uint_16)alpha; + /* FALLTHROUGH */ + + case 1: + if (alpha < 65535) + { + if (alpha > 0) + green = (green * alpha + 32767U)/65535U; + + else + green = 0; + } + entry[afirst] = (png_uint_16)green; + break; + + default: + break; + } + } + + else /* output encoding is P_sRGB */ + { + png_bytep entry = png_voidcast(png_bytep, display->colormap); + + entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format); + + switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format)) + { + case 4: + entry[afirst ? 0 : 3] = (png_byte)alpha; + /* FALLTHROUGH */ + case 3: + entry[afirst + (2 ^ bgr)] = (png_byte)blue; + entry[afirst + 1] = (png_byte)green; + entry[afirst + bgr] = (png_byte)red; + break; + + case 2: + entry[1 ^ afirst] = (png_byte)alpha; + /* FALLTHROUGH */ + case 1: + entry[afirst] = (png_byte)green; + break; + + default: + break; + } + } + +# ifdef afirst +# undef afirst +# endif +# ifdef bgr +# undef bgr +# endif + } +} + +static int +make_gray_file_colormap(png_image_read_control *display) +{ + unsigned int i; + + for (i=0; i<256; ++i) + png_create_colormap_entry(display, i, i, i, i, 255, P_FILE); + + return (int)i; +} + +static int +make_gray_colormap(png_image_read_control *display) +{ + unsigned int i; + + for (i=0; i<256; ++i) + png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB); + + return (int)i; +} +#define PNG_GRAY_COLORMAP_ENTRIES 256 + +static int +make_ga_colormap(png_image_read_control *display) +{ + unsigned int i, a; + + /* Alpha is retained, the output will be a color-map with entries + * selected by six levels of alpha. One transparent entry, 6 gray + * levels for all the intermediate alpha values, leaving 230 entries + * for the opaque grays. The color-map entries are the six values + * [0..5]*51, the GA processing uses PNG_DIV51(value) to find the + * relevant entry. + * + * if (alpha > 229) // opaque + * { + * // The 231 entries are selected to make the math below work: + * base = 0; + * entry = (231 * gray + 128) >> 8; + * } + * else if (alpha < 26) // transparent + * { + * base = 231; + * entry = 0; + * } + * else // partially opaque + * { + * base = 226 + 6 * PNG_DIV51(alpha); + * entry = PNG_DIV51(gray); + * } + */ + i = 0; + while (i < 231) + { + unsigned int gray = (i * 256 + 115) / 231; + png_create_colormap_entry(display, i++, gray, gray, gray, 255, P_sRGB); + } + + /* 255 is used here for the component values for consistency with the code + * that undoes premultiplication in pngwrite.c. + */ + png_create_colormap_entry(display, i++, 255, 255, 255, 0, P_sRGB); + + for (a=1; a<5; ++a) + { + unsigned int g; + + for (g=0; g<6; ++g) + png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51, + P_sRGB); + } + + return (int)i; +} + +#define PNG_GA_COLORMAP_ENTRIES 256 + +static int +make_rgb_colormap(png_image_read_control *display) +{ + unsigned int i, r; + + /* Build a 6x6x6 opaque RGB cube */ + for (i=r=0; r<6; ++r) + { + unsigned int g; + + for (g=0; g<6; ++g) + { + unsigned int b; + + for (b=0; b<6; ++b) + png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255, + P_sRGB); + } + } + + return (int)i; +} + +#define PNG_RGB_COLORMAP_ENTRIES 216 + +/* Return a palette index to the above palette given three 8-bit sRGB values. */ +#define PNG_RGB_INDEX(r,g,b) \ + ((png_byte)(6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b))) + +static int +png_image_read_colormap(png_voidp argument) +{ + png_image_read_control *display = + png_voidcast(png_image_read_control*, argument); + const png_imagep image = display->image; + + const png_structrp png_ptr = image->opaque->png_ptr; + const png_uint_32 output_format = image->format; + const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ? + P_LINEAR : P_sRGB; + + unsigned int cmap_entries; + unsigned int output_processing; /* Output processing option */ + unsigned int data_encoding = P_NOTSET; /* Encoding libpng must produce */ + + /* Background information; the background color and the index of this color + * in the color-map if it exists (else 256). + */ + unsigned int background_index = 256; + png_uint_32 back_r, back_g, back_b; + + /* Flags to accumulate things that need to be done to the input. */ + int expand_tRNS = 0; + + /* Exclude the NYI feature of compositing onto a color-mapped buffer; it is + * very difficult to do, the results look awful, and it is difficult to see + * what possible use it is because the application can't control the + * color-map. + */ + if (((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0 || + png_ptr->num_trans > 0) /* alpha in input */ && + ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */) + { + if (output_encoding == P_LINEAR) /* compose on black */ + back_b = back_g = back_r = 0; + + else if (display->background == NULL /* no way to remove it */) + png_error(png_ptr, + "background color must be supplied to remove alpha/transparency"); + + /* Get a copy of the background color (this avoids repeating the checks + * below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the + * output format. + */ + else + { + back_g = display->background->green; + if ((output_format & PNG_FORMAT_FLAG_COLOR) != 0) + { + back_r = display->background->red; + back_b = display->background->blue; + } + else + back_b = back_r = back_g; + } + } + + else if (output_encoding == P_LINEAR) + back_b = back_r = back_g = 65535; + + else + back_b = back_r = back_g = 255; + + /* Default the input file gamma if required - this is necessary because + * libpng assumes that if no gamma information is present the data is in the + * output format, but the simplified API deduces the gamma from the input + * format. + */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0) + { + /* Do this directly, not using the png_colorspace functions, to ensure + * that it happens even if the colorspace is invalid (though probably if + * it is the setting will be ignored) Note that the same thing can be + * achieved at the application interface with png_set_gAMA. + */ + if (png_ptr->bit_depth == 16 && + (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) + png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR; + + else + png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE; + + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + } + + /* Decide what to do based on the PNG color type of the input data. The + * utility function png_create_colormap_entry deals with most aspects of the + * output transformations; this code works out how to produce bytes of + * color-map entries from the original format. + */ + switch (png_ptr->color_type) + { + case PNG_COLOR_TYPE_GRAY: + if (png_ptr->bit_depth <= 8) + { + /* There at most 256 colors in the output, regardless of + * transparency. + */ + unsigned int step, i, val, trans = 256/*ignore*/, back_alpha = 0; + + cmap_entries = 1U << png_ptr->bit_depth; + if (cmap_entries > image->colormap_entries) + png_error(png_ptr, "gray[8] color-map: too few entries"); + + step = 255 / (cmap_entries - 1); + output_processing = PNG_CMAP_NONE; + + /* If there is a tRNS chunk then this either selects a transparent + * value or, if the output has no alpha, the background color. + */ + if (png_ptr->num_trans > 0) + { + trans = png_ptr->trans_color.gray; + + if ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) + back_alpha = output_encoding == P_LINEAR ? 65535 : 255; + } + + /* png_create_colormap_entry just takes an RGBA and writes the + * corresponding color-map entry using the format from 'image', + * including the required conversion to sRGB or linear as + * appropriate. The input values are always either sRGB (if the + * gamma correction flag is 0) or 0..255 scaled file encoded values + * (if the function must gamma correct them). + */ + for (i=val=0; ibit_depth < 8) + png_set_packing(png_ptr); + } + + else /* bit depth is 16 */ + { + /* The 16-bit input values can be converted directly to 8-bit gamma + * encoded values; however, if a tRNS chunk is present 257 color-map + * entries are required. This means that the extra entry requires + * special processing; add an alpha channel, sacrifice gray level + * 254 and convert transparent (alpha==0) entries to that. + * + * Use libpng to chop the data to 8 bits. Convert it to sRGB at the + * same time to minimize quality loss. If a tRNS chunk is present + * this means libpng must handle it too; otherwise it is impossible + * to do the exact match on the 16-bit value. + * + * If the output has no alpha channel *and* the background color is + * gray then it is possible to let libpng handle the substitution by + * ensuring that the corresponding gray level matches the background + * color exactly. + */ + data_encoding = P_sRGB; + + if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "gray[16] color-map: too few entries"); + + cmap_entries = (unsigned int)make_gray_colormap(display); + + if (png_ptr->num_trans > 0) + { + unsigned int back_alpha; + + if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0) + back_alpha = 0; + + else + { + if (back_r == back_g && back_g == back_b) + { + /* Background is gray; no special processing will be + * required. + */ + png_color_16 c; + png_uint_32 gray = back_g; + + if (output_encoding == P_LINEAR) + { + gray = PNG_sRGB_FROM_LINEAR(gray * 255); + + /* And make sure the corresponding palette entry + * matches. + */ + png_create_colormap_entry(display, gray, back_g, back_g, + back_g, 65535, P_LINEAR); + } + + /* The background passed to libpng, however, must be the + * sRGB value. + */ + c.index = 0; /*unused*/ + c.gray = c.red = c.green = c.blue = (png_uint_16)gray; + + /* NOTE: does this work without expanding tRNS to alpha? + * It should be the color->gray case below apparently + * doesn't. + */ + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + + output_processing = PNG_CMAP_NONE; + break; + } +#ifdef __COVERITY__ + /* Coverity claims that output_encoding cannot be 2 (P_LINEAR) + * here. + */ + back_alpha = 255; +#else + back_alpha = output_encoding == P_LINEAR ? 65535 : 255; +#endif + } + + /* output_processing means that the libpng-processed row will be + * 8-bit GA and it has to be processing to single byte color-map + * values. Entry 254 is replaced by either a completely + * transparent entry or by the background color at full + * precision (and the background color is not a simple gray + * level in this case.) + */ + expand_tRNS = 1; + output_processing = PNG_CMAP_TRANS; + background_index = 254; + + /* And set (overwrite) color-map entry 254 to the actual + * background color at full precision. + */ + png_create_colormap_entry(display, 254, back_r, back_g, back_b, + back_alpha, output_encoding); + } + + else + output_processing = PNG_CMAP_NONE; + } + break; + + case PNG_COLOR_TYPE_GRAY_ALPHA: + /* 8-bit or 16-bit PNG with two channels - gray and alpha. A minimum + * of 65536 combinations. If, however, the alpha channel is to be + * removed there are only 256 possibilities if the background is gray. + * (Otherwise there is a subset of the 65536 possibilities defined by + * the triangle between black, white and the background color.) + * + * Reduce 16-bit files to 8-bit and sRGB encode the result. No need to + * worry about tRNS matching - tRNS is ignored if there is an alpha + * channel. + */ + data_encoding = P_sRGB; + + if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "gray+alpha color-map: too few entries"); + + cmap_entries = (unsigned int)make_ga_colormap(display); + + background_index = PNG_CMAP_GA_BACKGROUND; + output_processing = PNG_CMAP_GA; + } + + else /* alpha is removed */ + { + /* Alpha must be removed as the PNG data is processed when the + * background is a color because the G and A channels are + * independent and the vector addition (non-parallel vectors) is a + * 2-D problem. + * + * This can be reduced to the same algorithm as above by making a + * colormap containing gray levels (for the opaque grays), a + * background entry (for a transparent pixel) and a set of four six + * level color values, one set for each intermediate alpha value. + * See the comments in make_ga_colormap for how this works in the + * per-pixel processing. + * + * If the background is gray, however, we only need a 256 entry gray + * level color map. It is sufficient to make the entry generated + * for the background color be exactly the color specified. + */ + if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0 || + (back_r == back_g && back_g == back_b)) + { + /* Background is gray; no special processing will be required. */ + png_color_16 c; + png_uint_32 gray = back_g; + + if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "gray-alpha color-map: too few entries"); + + cmap_entries = (unsigned int)make_gray_colormap(display); + + if (output_encoding == P_LINEAR) + { + gray = PNG_sRGB_FROM_LINEAR(gray * 255); + + /* And make sure the corresponding palette entry matches. */ + png_create_colormap_entry(display, gray, back_g, back_g, + back_g, 65535, P_LINEAR); + } + + /* The background passed to libpng, however, must be the sRGB + * value. + */ + c.index = 0; /*unused*/ + c.gray = c.red = c.green = c.blue = (png_uint_16)gray; + + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + + output_processing = PNG_CMAP_NONE; + } + + else + { + png_uint_32 i, a; + + /* This is the same as png_make_ga_colormap, above, except that + * the entries are all opaque. + */ + if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "ga-alpha color-map: too few entries"); + + i = 0; + while (i < 231) + { + png_uint_32 gray = (i * 256 + 115) / 231; + png_create_colormap_entry(display, i++, gray, gray, gray, + 255, P_sRGB); + } + + /* NOTE: this preserves the full precision of the application + * background color. + */ + background_index = i; + png_create_colormap_entry(display, i++, back_r, back_g, back_b, +#ifdef __COVERITY__ + /* Coverity claims that output_encoding + * cannot be 2 (P_LINEAR) here. + */ 255U, +#else + output_encoding == P_LINEAR ? 65535U : 255U, +#endif + output_encoding); + + /* For non-opaque input composite on the sRGB background - this + * requires inverting the encoding for each component. The input + * is still converted to the sRGB encoding because this is a + * reasonable approximate to the logarithmic curve of human + * visual sensitivity, at least over the narrow range which PNG + * represents. Consequently 'G' is always sRGB encoded, while + * 'A' is linear. We need the linear background colors. + */ + if (output_encoding == P_sRGB) /* else already linear */ + { + /* This may produce a value not exactly matching the + * background, but that's ok because these numbers are only + * used when alpha != 0 + */ + back_r = png_sRGB_table[back_r]; + back_g = png_sRGB_table[back_g]; + back_b = png_sRGB_table[back_b]; + } + + for (a=1; a<5; ++a) + { + unsigned int g; + + /* PNG_sRGB_FROM_LINEAR expects a 16-bit linear value scaled + * by an 8-bit alpha value (0..255). + */ + png_uint_32 alpha = 51 * a; + png_uint_32 back_rx = (255-alpha) * back_r; + png_uint_32 back_gx = (255-alpha) * back_g; + png_uint_32 back_bx = (255-alpha) * back_b; + + for (g=0; g<6; ++g) + { + png_uint_32 gray = png_sRGB_table[g*51] * alpha; + + png_create_colormap_entry(display, i++, + PNG_sRGB_FROM_LINEAR(gray + back_rx), + PNG_sRGB_FROM_LINEAR(gray + back_gx), + PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB); + } + } + + cmap_entries = i; + output_processing = PNG_CMAP_GA; + } + } + break; + + case PNG_COLOR_TYPE_RGB: + case PNG_COLOR_TYPE_RGB_ALPHA: + /* Exclude the case where the output is gray; we can always handle this + * with the cases above. + */ + if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0) + { + /* The color-map will be grayscale, so we may as well convert the + * input RGB values to a simple grayscale and use the grayscale + * code above. + * + * NOTE: calling this apparently damages the recognition of the + * transparent color in background color handling; call + * png_set_tRNS_to_alpha before png_set_background_fixed. + */ + png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1, + -1); + data_encoding = P_sRGB; + + /* The output will now be one or two 8-bit gray or gray+alpha + * channels. The more complex case arises when the input has alpha. + */ + if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + png_ptr->num_trans > 0) && + (output_format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + /* Both input and output have an alpha channel, so no background + * processing is required; just map the GA bytes to the right + * color-map entry. + */ + expand_tRNS = 1; + + if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "rgb[ga] color-map: too few entries"); + + cmap_entries = (unsigned int)make_ga_colormap(display); + background_index = PNG_CMAP_GA_BACKGROUND; + output_processing = PNG_CMAP_GA; + } + + else + { + /* Either the input or the output has no alpha channel, so there + * will be no non-opaque pixels in the color-map; it will just be + * grayscale. + */ + if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "rgb[gray] color-map: too few entries"); + + /* Ideally this code would use libpng to do the gamma correction, + * but if an input alpha channel is to be removed we will hit the + * libpng bug in gamma+compose+rgb-to-gray (the double gamma + * correction bug). Fix this by dropping the gamma correction in + * this case and doing it in the palette; this will result in + * duplicate palette entries, but that's better than the + * alternative of double gamma correction. + */ + if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + png_ptr->num_trans > 0) && + png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0) + { + cmap_entries = (unsigned int)make_gray_file_colormap(display); + data_encoding = P_FILE; + } + + else + cmap_entries = (unsigned int)make_gray_colormap(display); + + /* But if the input has alpha or transparency it must be removed + */ + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + png_ptr->num_trans > 0) + { + png_color_16 c; + png_uint_32 gray = back_g; + + /* We need to ensure that the application background exists in + * the colormap and that completely transparent pixels map to + * it. Achieve this simply by ensuring that the entry + * selected for the background really is the background color. + */ + if (data_encoding == P_FILE) /* from the fixup above */ + { + /* The app supplied a gray which is in output_encoding, we + * need to convert it to a value of the input (P_FILE) + * encoding then set this palette entry to the required + * output encoding. + */ + if (output_encoding == P_sRGB) + gray = png_sRGB_table[gray]; /* now P_LINEAR */ + + gray = PNG_DIV257(png_gamma_16bit_correct(gray, + png_ptr->colorspace.gamma)); /* now P_FILE */ + + /* And make sure the corresponding palette entry contains + * exactly the required sRGB value. + */ + png_create_colormap_entry(display, gray, back_g, back_g, + back_g, 0/*unused*/, output_encoding); + } + + else if (output_encoding == P_LINEAR) + { + gray = PNG_sRGB_FROM_LINEAR(gray * 255); + + /* And make sure the corresponding palette entry matches. + */ + png_create_colormap_entry(display, gray, back_g, back_g, + back_g, 0/*unused*/, P_LINEAR); + } + + /* The background passed to libpng, however, must be the + * output (normally sRGB) value. + */ + c.index = 0; /*unused*/ + c.gray = c.red = c.green = c.blue = (png_uint_16)gray; + + /* NOTE: the following is apparently a bug in libpng. Without + * it the transparent color recognition in + * png_set_background_fixed seems to go wrong. + */ + expand_tRNS = 1; + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + } + + output_processing = PNG_CMAP_NONE; + } + } + + else /* output is color */ + { + /* We could use png_quantize here so long as there is no transparent + * color or alpha; png_quantize ignores alpha. Easier overall just + * to do it once and using PNG_DIV51 on the 6x6x6 reduced RGB cube. + * Consequently we always want libpng to produce sRGB data. + */ + data_encoding = P_sRGB; + + /* Is there any transparency or alpha? */ + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + png_ptr->num_trans > 0) + { + /* Is there alpha in the output too? If so all four channels are + * processed into a special RGB cube with alpha support. + */ + if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + png_uint_32 r; + + if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) + png_error(png_ptr, "rgb+alpha color-map: too few entries"); + + cmap_entries = (unsigned int)make_rgb_colormap(display); + + /* Add a transparent entry. */ + png_create_colormap_entry(display, cmap_entries, 255, 255, + 255, 0, P_sRGB); + + /* This is stored as the background index for the processing + * algorithm. + */ + background_index = cmap_entries++; + + /* Add 27 r,g,b entries each with alpha 0.5. */ + for (r=0; r<256; r = (r << 1) | 0x7f) + { + png_uint_32 g; + + for (g=0; g<256; g = (g << 1) | 0x7f) + { + png_uint_32 b; + + /* This generates components with the values 0, 127 and + * 255 + */ + for (b=0; b<256; b = (b << 1) | 0x7f) + png_create_colormap_entry(display, cmap_entries++, + r, g, b, 128, P_sRGB); + } + } + + expand_tRNS = 1; + output_processing = PNG_CMAP_RGB_ALPHA; + } + + else + { + /* Alpha/transparency must be removed. The background must + * exist in the color map (achieved by setting adding it after + * the 666 color-map). If the standard processing code will + * pick up this entry automatically that's all that is + * required; libpng can be called to do the background + * processing. + */ + unsigned int sample_size = + PNG_IMAGE_SAMPLE_SIZE(output_format); + png_uint_32 r, g, b; /* sRGB background */ + + if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) + png_error(png_ptr, "rgb-alpha color-map: too few entries"); + + cmap_entries = (unsigned int)make_rgb_colormap(display); + + png_create_colormap_entry(display, cmap_entries, back_r, + back_g, back_b, 0/*unused*/, output_encoding); + + if (output_encoding == P_LINEAR) + { + r = PNG_sRGB_FROM_LINEAR(back_r * 255); + g = PNG_sRGB_FROM_LINEAR(back_g * 255); + b = PNG_sRGB_FROM_LINEAR(back_b * 255); + } + + else + { + r = back_r; + g = back_g; + b = back_g; + } + + /* Compare the newly-created color-map entry with the one the + * PNG_CMAP_RGB algorithm will use. If the two entries don't + * match, add the new one and set this as the background + * index. + */ + if (memcmp((png_const_bytep)display->colormap + + sample_size * cmap_entries, + (png_const_bytep)display->colormap + + sample_size * PNG_RGB_INDEX(r,g,b), + sample_size) != 0) + { + /* The background color must be added. */ + background_index = cmap_entries++; + + /* Add 27 r,g,b entries each with created by composing with + * the background at alpha 0.5. + */ + for (r=0; r<256; r = (r << 1) | 0x7f) + { + for (g=0; g<256; g = (g << 1) | 0x7f) + { + /* This generates components with the values 0, 127 + * and 255 + */ + for (b=0; b<256; b = (b << 1) | 0x7f) + png_create_colormap_entry(display, cmap_entries++, + png_colormap_compose(display, r, P_sRGB, 128, + back_r, output_encoding), + png_colormap_compose(display, g, P_sRGB, 128, + back_g, output_encoding), + png_colormap_compose(display, b, P_sRGB, 128, + back_b, output_encoding), + 0/*unused*/, output_encoding); + } + } + + expand_tRNS = 1; + output_processing = PNG_CMAP_RGB_ALPHA; + } + + else /* background color is in the standard color-map */ + { + png_color_16 c; + + c.index = 0; /*unused*/ + c.red = (png_uint_16)back_r; + c.gray = c.green = (png_uint_16)back_g; + c.blue = (png_uint_16)back_b; + + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + + output_processing = PNG_CMAP_RGB; + } + } + } + + else /* no alpha or transparency in the input */ + { + /* Alpha in the output is irrelevant, simply map the opaque input + * pixels to the 6x6x6 color-map. + */ + if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "rgb color-map: too few entries"); + + cmap_entries = (unsigned int)make_rgb_colormap(display); + output_processing = PNG_CMAP_RGB; + } + } + break; + + case PNG_COLOR_TYPE_PALETTE: + /* It's already got a color-map. It may be necessary to eliminate the + * tRNS entries though. + */ + { + unsigned int num_trans = png_ptr->num_trans; + png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL; + png_const_colorp colormap = png_ptr->palette; + const int do_background = trans != NULL && + (output_format & PNG_FORMAT_FLAG_ALPHA) == 0; + unsigned int i; + + /* Just in case: */ + if (trans == NULL) + num_trans = 0; + + output_processing = PNG_CMAP_NONE; + data_encoding = P_FILE; /* Don't change from color-map indices */ + cmap_entries = (unsigned int)png_ptr->num_palette; + if (cmap_entries > 256) + cmap_entries = 256; + + if (cmap_entries > (unsigned int)image->colormap_entries) + png_error(png_ptr, "palette color-map: too few entries"); + + for (i=0; i < cmap_entries; ++i) + { + if (do_background != 0 && i < num_trans && trans[i] < 255) + { + if (trans[i] == 0) + png_create_colormap_entry(display, i, back_r, back_g, + back_b, 0, output_encoding); + + else + { + /* Must compose the PNG file color in the color-map entry + * on the sRGB color in 'back'. + */ + png_create_colormap_entry(display, i, + png_colormap_compose(display, colormap[i].red, + P_FILE, trans[i], back_r, output_encoding), + png_colormap_compose(display, colormap[i].green, + P_FILE, trans[i], back_g, output_encoding), + png_colormap_compose(display, colormap[i].blue, + P_FILE, trans[i], back_b, output_encoding), + output_encoding == P_LINEAR ? trans[i] * 257U : + trans[i], + output_encoding); + } + } + + else + png_create_colormap_entry(display, i, colormap[i].red, + colormap[i].green, colormap[i].blue, + i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/); + } + + /* The PNG data may have indices packed in fewer than 8 bits, it + * must be expanded if so. + */ + if (png_ptr->bit_depth < 8) + png_set_packing(png_ptr); + } + break; + + default: + png_error(png_ptr, "invalid PNG color type"); + /*NOT REACHED*/ + } + + /* Now deal with the output processing */ + if (expand_tRNS != 0 && png_ptr->num_trans > 0 && + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0) + png_set_tRNS_to_alpha(png_ptr); + + switch (data_encoding) + { + case P_sRGB: + /* Change to 8-bit sRGB */ + png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB); + /* FALLTHROUGH */ + + case P_FILE: + if (png_ptr->bit_depth > 8) + png_set_scale_16(png_ptr); + break; + +#ifdef __GNUC__ + default: + png_error(png_ptr, "bad data option (internal error)"); +#endif + } + + if (cmap_entries > 256 || cmap_entries > image->colormap_entries) + png_error(png_ptr, "color map overflow (BAD internal error)"); + + image->colormap_entries = cmap_entries; + + /* Double check using the recorded background index */ + switch (output_processing) + { + case PNG_CMAP_NONE: + if (background_index != PNG_CMAP_NONE_BACKGROUND) + goto bad_background; + break; + + case PNG_CMAP_GA: + if (background_index != PNG_CMAP_GA_BACKGROUND) + goto bad_background; + break; + + case PNG_CMAP_TRANS: + if (background_index >= cmap_entries || + background_index != PNG_CMAP_TRANS_BACKGROUND) + goto bad_background; + break; + + case PNG_CMAP_RGB: + if (background_index != PNG_CMAP_RGB_BACKGROUND) + goto bad_background; + break; + + case PNG_CMAP_RGB_ALPHA: + if (background_index != PNG_CMAP_RGB_ALPHA_BACKGROUND) + goto bad_background; + break; + + default: + png_error(png_ptr, "bad processing option (internal error)"); + + bad_background: + png_error(png_ptr, "bad background index (internal error)"); + } + + display->colormap_processing = (int)output_processing; + + return 1/*ok*/; +} + +/* The final part of the color-map read called from png_image_finish_read. */ +static int +png_image_read_and_map(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + int passes; + + /* Called when the libpng data must be transformed into the color-mapped + * form. There is a local row buffer in display->local and this routine must + * do the interlace handling. + */ + switch (png_ptr->interlaced) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + png_error(png_ptr, "unknown interlace type"); + } + + { + png_uint_32 height = image->height; + png_uint_32 width = image->width; + int proc = display->colormap_processing; + png_bytep first_row = png_voidcast(png_bytep, display->first_row); + ptrdiff_t step_row = display->row_bytes; + int pass; + + for (pass = 0; pass < passes; ++pass) + { + unsigned int startx, stepx, stepy; + png_uint_32 y; + + if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) + { + /* The row may be empty for a short image: */ + if (PNG_PASS_COLS(width, pass) == 0) + continue; + + startx = PNG_PASS_START_COL(pass); + stepx = PNG_PASS_COL_OFFSET(pass); + y = PNG_PASS_START_ROW(pass); + stepy = PNG_PASS_ROW_OFFSET(pass); + } + + else + { + y = 0; + startx = 0; + stepx = stepy = 1; + } + + for (; ylocal_row); + png_bytep outrow = first_row + y * step_row; + png_const_bytep end_row = outrow + width; + + /* Read read the libpng data into the temporary buffer. */ + png_read_row(png_ptr, inrow, NULL); + + /* Now process the row according to the processing option, note + * that the caller verifies that the format of the libpng output + * data is as required. + */ + outrow += startx; + switch (proc) + { + case PNG_CMAP_GA: + for (; outrow < end_row; outrow += stepx) + { + /* The data is always in the PNG order */ + unsigned int gray = *inrow++; + unsigned int alpha = *inrow++; + unsigned int entry; + + /* NOTE: this code is copied as a comment in + * make_ga_colormap above. Please update the + * comment if you change this code! + */ + if (alpha > 229) /* opaque */ + { + entry = (231 * gray + 128) >> 8; + } + else if (alpha < 26) /* transparent */ + { + entry = 231; + } + else /* partially opaque */ + { + entry = 226 + 6 * PNG_DIV51(alpha) + PNG_DIV51(gray); + } + + *outrow = (png_byte)entry; + } + break; + + case PNG_CMAP_TRANS: + for (; outrow < end_row; outrow += stepx) + { + png_byte gray = *inrow++; + png_byte alpha = *inrow++; + + if (alpha == 0) + *outrow = PNG_CMAP_TRANS_BACKGROUND; + + else if (gray != PNG_CMAP_TRANS_BACKGROUND) + *outrow = gray; + + else + *outrow = (png_byte)(PNG_CMAP_TRANS_BACKGROUND+1); + } + break; + + case PNG_CMAP_RGB: + for (; outrow < end_row; outrow += stepx) + { + *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], inrow[2]); + inrow += 3; + } + break; + + case PNG_CMAP_RGB_ALPHA: + for (; outrow < end_row; outrow += stepx) + { + unsigned int alpha = inrow[3]; + + /* Because the alpha entries only hold alpha==0.5 values + * split the processing at alpha==0.25 (64) and 0.75 + * (196). + */ + + if (alpha >= 196) + *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], + inrow[2]); + + else if (alpha < 64) + *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND; + + else + { + /* Likewise there are three entries for each of r, g + * and b. We could select the entry by popcount on + * the top two bits on those architectures that + * support it, this is what the code below does, + * crudely. + */ + unsigned int back_i = PNG_CMAP_RGB_ALPHA_BACKGROUND+1; + + /* Here are how the values map: + * + * 0x00 .. 0x3f -> 0 + * 0x40 .. 0xbf -> 1 + * 0xc0 .. 0xff -> 2 + * + * So, as above with the explicit alpha checks, the + * breakpoints are at 64 and 196. + */ + if (inrow[0] & 0x80) back_i += 9; /* red */ + if (inrow[0] & 0x40) back_i += 9; + if (inrow[0] & 0x80) back_i += 3; /* green */ + if (inrow[0] & 0x40) back_i += 3; + if (inrow[0] & 0x80) back_i += 1; /* blue */ + if (inrow[0] & 0x40) back_i += 1; + + *outrow = (png_byte)back_i; + } + + inrow += 4; + } + break; + + default: + break; + } + } + } + } + + return 1; +} + +static int +png_image_read_colormapped(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_controlp control = image->opaque; + png_structrp png_ptr = control->png_ptr; + png_inforp info_ptr = control->info_ptr; + + int passes = 0; /* As a flag */ + + PNG_SKIP_CHUNKS(png_ptr); + + /* Update the 'info' structure and make sure the result is as required; first + * make sure to turn on the interlace handling if it will be required + * (because it can't be turned on *after* the call to png_read_update_info!) + */ + if (display->colormap_processing == PNG_CMAP_NONE) + passes = png_set_interlace_handling(png_ptr); + + png_read_update_info(png_ptr, info_ptr); + + /* The expected output can be deduced from the colormap_processing option. */ + switch (display->colormap_processing) + { + case PNG_CMAP_NONE: + /* Output must be one channel and one byte per pixel, the output + * encoding can be anything. + */ + if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE || + info_ptr->color_type == PNG_COLOR_TYPE_GRAY) && + info_ptr->bit_depth == 8) + break; + + goto bad_output; + + case PNG_CMAP_TRANS: + case PNG_CMAP_GA: + /* Output must be two channels and the 'G' one must be sRGB, the latter + * can be checked with an exact number because it should have been set + * to this number above! + */ + if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + info_ptr->bit_depth == 8 && + png_ptr->screen_gamma == PNG_GAMMA_sRGB && + image->colormap_entries == 256) + break; + + goto bad_output; + + case PNG_CMAP_RGB: + /* Output must be 8-bit sRGB encoded RGB */ + if (info_ptr->color_type == PNG_COLOR_TYPE_RGB && + info_ptr->bit_depth == 8 && + png_ptr->screen_gamma == PNG_GAMMA_sRGB && + image->colormap_entries == 216) + break; + + goto bad_output; + + case PNG_CMAP_RGB_ALPHA: + /* Output must be 8-bit sRGB encoded RGBA */ + if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA && + info_ptr->bit_depth == 8 && + png_ptr->screen_gamma == PNG_GAMMA_sRGB && + image->colormap_entries == 244 /* 216 + 1 + 27 */) + break; + + goto bad_output; + + default: + bad_output: + png_error(png_ptr, "bad color-map processing (internal error)"); + } + + /* Now read the rows. Do this here if it is possible to read directly into + * the output buffer, otherwise allocate a local row buffer of the maximum + * size libpng requires and call the relevant processing routine safely. + */ + { + png_voidp first_row = display->buffer; + ptrdiff_t row_bytes = display->row_stride; + + /* The following expression is designed to work correctly whether it gives + * a signed or an unsigned result. + */ + if (row_bytes < 0) + { + char *ptr = png_voidcast(char*, first_row); + ptr += (image->height-1) * (-row_bytes); + first_row = png_voidcast(png_voidp, ptr); + } + + display->first_row = first_row; + display->row_bytes = row_bytes; + } + + if (passes == 0) + { + int result; + png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); + + display->local_row = row; + result = png_safe_execute(image, png_image_read_and_map, display); + display->local_row = NULL; + png_free(png_ptr, row); + + return result; + } + + else + { + png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes; + + while (--passes >= 0) + { + png_uint_32 y = image->height; + png_bytep row = png_voidcast(png_bytep, display->first_row); + + for (; y > 0; --y) + { + png_read_row(png_ptr, row, NULL); + row += row_bytes; + } + } + + return 1; + } +} + +/* Just the row reading part of png_image_read. */ +static int +png_image_read_composite(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + int passes; + + switch (png_ptr->interlaced) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + png_error(png_ptr, "unknown interlace type"); + } + + { + png_uint_32 height = image->height; + png_uint_32 width = image->width; + ptrdiff_t step_row = display->row_bytes; + unsigned int channels = + (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; + int pass; + + for (pass = 0; pass < passes; ++pass) + { + unsigned int startx, stepx, stepy; + png_uint_32 y; + + if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) + { + /* The row may be empty for a short image: */ + if (PNG_PASS_COLS(width, pass) == 0) + continue; + + startx = PNG_PASS_START_COL(pass) * channels; + stepx = PNG_PASS_COL_OFFSET(pass) * channels; + y = PNG_PASS_START_ROW(pass); + stepy = PNG_PASS_ROW_OFFSET(pass); + } + + else + { + y = 0; + startx = 0; + stepx = channels; + stepy = 1; + } + + for (; ylocal_row); + png_bytep outrow; + png_const_bytep end_row; + + /* Read the row, which is packed: */ + png_read_row(png_ptr, inrow, NULL); + + outrow = png_voidcast(png_bytep, display->first_row); + outrow += y * step_row; + end_row = outrow + width * channels; + + /* Now do the composition on each pixel in this row. */ + outrow += startx; + for (; outrow < end_row; outrow += stepx) + { + png_byte alpha = inrow[channels]; + + if (alpha > 0) /* else no change to the output */ + { + unsigned int c; + + for (c=0; cimage; + png_structrp png_ptr = image->opaque->png_ptr; + png_inforp info_ptr = image->opaque->info_ptr; + png_uint_32 height = image->height; + png_uint_32 width = image->width; + int pass, passes; + + /* Double check the convoluted logic below. We expect to get here with + * libpng doing rgb to gray and gamma correction but background processing + * left to the png_image_read_background function. The rows libpng produce + * might be 8 or 16-bit but should always have two channels; gray plus alpha. + */ + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) + png_error(png_ptr, "lost rgb to gray"); + + if ((png_ptr->transformations & PNG_COMPOSE) != 0) + png_error(png_ptr, "unexpected compose"); + + if (png_get_channels(png_ptr, info_ptr) != 2) + png_error(png_ptr, "lost/gained channels"); + + /* Expect the 8-bit case to always remove the alpha channel */ + if ((image->format & PNG_FORMAT_FLAG_LINEAR) == 0 && + (image->format & PNG_FORMAT_FLAG_ALPHA) != 0) + png_error(png_ptr, "unexpected 8-bit transformation"); + + switch (png_ptr->interlaced) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + png_error(png_ptr, "unknown interlace type"); + } + + /* Use direct access to info_ptr here because otherwise the simplified API + * would require PNG_EASY_ACCESS_SUPPORTED (just for this.) Note this is + * checking the value after libpng expansions, not the original value in the + * PNG. + */ + switch (info_ptr->bit_depth) + { + case 8: + /* 8-bit sRGB gray values with an alpha channel; the alpha channel is + * to be removed by composing on a background: either the row if + * display->background is NULL or display->background->green if not. + * Unlike the code above ALPHA_OPTIMIZED has *not* been done. + */ + { + png_bytep first_row = png_voidcast(png_bytep, display->first_row); + ptrdiff_t step_row = display->row_bytes; + + for (pass = 0; pass < passes; ++pass) + { + png_bytep row = png_voidcast(png_bytep, display->first_row); + unsigned int startx, stepx, stepy; + png_uint_32 y; + + if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) + { + /* The row may be empty for a short image: */ + if (PNG_PASS_COLS(width, pass) == 0) + continue; + + startx = PNG_PASS_START_COL(pass); + stepx = PNG_PASS_COL_OFFSET(pass); + y = PNG_PASS_START_ROW(pass); + stepy = PNG_PASS_ROW_OFFSET(pass); + } + + else + { + y = 0; + startx = 0; + stepx = stepy = 1; + } + + if (display->background == NULL) + { + for (; ylocal_row); + png_bytep outrow = first_row + y * step_row; + png_const_bytep end_row = outrow + width; + + /* Read the row, which is packed: */ + png_read_row(png_ptr, inrow, NULL); + + /* Now do the composition on each pixel in this row. */ + outrow += startx; + for (; outrow < end_row; outrow += stepx) + { + png_byte alpha = inrow[1]; + + if (alpha > 0) /* else no change to the output */ + { + png_uint_32 component = inrow[0]; + + if (alpha < 255) /* else just use component */ + { + /* Since PNG_OPTIMIZED_ALPHA was not set it is + * necessary to invert the sRGB transfer + * function and multiply the alpha out. + */ + component = png_sRGB_table[component] * alpha; + component += png_sRGB_table[outrow[0]] * + (255-alpha); + component = PNG_sRGB_FROM_LINEAR(component); + } + + outrow[0] = (png_byte)component; + } + + inrow += 2; /* gray and alpha channel */ + } + } + } + + else /* constant background value */ + { + png_byte background8 = display->background->green; + png_uint_16 background = png_sRGB_table[background8]; + + for (; ylocal_row); + png_bytep outrow = first_row + y * step_row; + png_const_bytep end_row = outrow + width; + + /* Read the row, which is packed: */ + png_read_row(png_ptr, inrow, NULL); + + /* Now do the composition on each pixel in this row. */ + outrow += startx; + for (; outrow < end_row; outrow += stepx) + { + png_byte alpha = inrow[1]; + + if (alpha > 0) /* else use background */ + { + png_uint_32 component = inrow[0]; + + if (alpha < 255) /* else just use component */ + { + component = png_sRGB_table[component] * alpha; + component += background * (255-alpha); + component = PNG_sRGB_FROM_LINEAR(component); + } + + outrow[0] = (png_byte)component; + } + + else + outrow[0] = background8; + + inrow += 2; /* gray and alpha channel */ + } + + row += display->row_bytes; + } + } + } + } + break; + + case 16: + /* 16-bit linear with pre-multiplied alpha; the pre-multiplication must + * still be done and, maybe, the alpha channel removed. This code also + * handles the alpha-first option. + */ + { + png_uint_16p first_row = png_voidcast(png_uint_16p, + display->first_row); + /* The division by two is safe because the caller passed in a + * stride which was multiplied by 2 (below) to get row_bytes. + */ + ptrdiff_t step_row = display->row_bytes / 2; + unsigned int preserve_alpha = (image->format & + PNG_FORMAT_FLAG_ALPHA) != 0; + unsigned int outchannels = 1U+preserve_alpha; + int swap_alpha = 0; + +# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED + if (preserve_alpha != 0 && + (image->format & PNG_FORMAT_FLAG_AFIRST) != 0) + swap_alpha = 1; +# endif + + for (pass = 0; pass < passes; ++pass) + { + unsigned int startx, stepx, stepy; + png_uint_32 y; + + /* The 'x' start and step are adjusted to output components here. + */ + if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) + { + /* The row may be empty for a short image: */ + if (PNG_PASS_COLS(width, pass) == 0) + continue; + + startx = PNG_PASS_START_COL(pass) * outchannels; + stepx = PNG_PASS_COL_OFFSET(pass) * outchannels; + y = PNG_PASS_START_ROW(pass); + stepy = PNG_PASS_ROW_OFFSET(pass); + } + + else + { + y = 0; + startx = 0; + stepx = outchannels; + stepy = 1; + } + + for (; ylocal_row), NULL); + inrow = png_voidcast(png_const_uint_16p, display->local_row); + + /* Now do the pre-multiplication on each pixel in this row. + */ + outrow += startx; + for (; outrow < end_row; outrow += stepx) + { + png_uint_32 component = inrow[0]; + png_uint_16 alpha = inrow[1]; + + if (alpha > 0) /* else 0 */ + { + if (alpha < 65535) /* else just use component */ + { + component *= alpha; + component += 32767; + component /= 65535; + } + } + + else + component = 0; + + outrow[swap_alpha] = (png_uint_16)component; + if (preserve_alpha != 0) + outrow[1 ^ swap_alpha] = alpha; + + inrow += 2; /* components and alpha channel */ + } + } + } + } + break; + +#ifdef __GNUC__ + default: + png_error(png_ptr, "unexpected bit depth"); +#endif + } + + return 1; +} + +/* The guts of png_image_finish_read as a png_safe_execute callback. */ +static int +png_image_read_direct(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + png_inforp info_ptr = image->opaque->info_ptr; + + png_uint_32 format = image->format; + int linear = (format & PNG_FORMAT_FLAG_LINEAR) != 0; + int do_local_compose = 0; + int do_local_background = 0; /* to avoid double gamma correction bug */ + int passes = 0; + + /* Add transforms to ensure the correct output format is produced then check + * that the required implementation support is there. Always expand; always + * need 8 bits minimum, no palette and expanded tRNS. + */ + png_set_expand(png_ptr); + + /* Now check the format to see if it was modified. */ + { + png_uint_32 base_format = png_image_format(png_ptr) & + ~PNG_FORMAT_FLAG_COLORMAP /* removed by png_set_expand */; + png_uint_32 change = format ^ base_format; + png_fixed_point output_gamma; + int mode; /* alpha mode */ + + /* Do this first so that we have a record if rgb to gray is happening. */ + if ((change & PNG_FORMAT_FLAG_COLOR) != 0) + { + /* gray<->color transformation required. */ + if ((format & PNG_FORMAT_FLAG_COLOR) != 0) + png_set_gray_to_rgb(png_ptr); + + else + { + /* libpng can't do both rgb to gray and + * background/pre-multiplication if there is also significant gamma + * correction, because both operations require linear colors and + * the code only supports one transform doing the gamma correction. + * Handle this by doing the pre-multiplication or background + * operation in this code, if necessary. + * + * TODO: fix this by rewriting pngrtran.c (!) + * + * For the moment (given that fixing this in pngrtran.c is an + * enormous change) 'do_local_background' is used to indicate that + * the problem exists. + */ + if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0) + do_local_background = 1/*maybe*/; + + png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, + PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT); + } + + change &= ~PNG_FORMAT_FLAG_COLOR; + } + + /* Set the gamma appropriately, linear for 16-bit input, sRGB otherwise. + */ + { + png_fixed_point input_gamma_default; + + if ((base_format & PNG_FORMAT_FLAG_LINEAR) != 0 && + (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) + input_gamma_default = PNG_GAMMA_LINEAR; + else + input_gamma_default = PNG_DEFAULT_sRGB; + + /* Call png_set_alpha_mode to set the default for the input gamma; the + * output gamma is set by a second call below. + */ + png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, input_gamma_default); + } + + if (linear != 0) + { + /* If there *is* an alpha channel in the input it must be multiplied + * out; use PNG_ALPHA_STANDARD, otherwise just use PNG_ALPHA_PNG. + */ + if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0) + mode = PNG_ALPHA_STANDARD; /* associated alpha */ + + else + mode = PNG_ALPHA_PNG; + + output_gamma = PNG_GAMMA_LINEAR; + } + + else + { + mode = PNG_ALPHA_PNG; + output_gamma = PNG_DEFAULT_sRGB; + } + + if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) + { + mode = PNG_ALPHA_OPTIMIZED; + change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA; + } + + /* If 'do_local_background' is set check for the presence of gamma + * correction; this is part of the work-round for the libpng bug + * described above. + * + * TODO: fix libpng and remove this. + */ + if (do_local_background != 0) + { + png_fixed_point gtest; + + /* This is 'png_gamma_threshold' from pngrtran.c; the test used for + * gamma correction, the screen gamma hasn't been set on png_struct + * yet; it's set below. png_struct::gamma, however, is set to the + * final value. + */ + if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma, + PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0) + do_local_background = 0; + + else if (mode == PNG_ALPHA_STANDARD) + { + do_local_background = 2/*required*/; + mode = PNG_ALPHA_PNG; /* prevent libpng doing it */ + } + + /* else leave as 1 for the checks below */ + } + + /* If the bit-depth changes then handle that here. */ + if ((change & PNG_FORMAT_FLAG_LINEAR) != 0) + { + if (linear != 0 /*16-bit output*/) + png_set_expand_16(png_ptr); + + else /* 8-bit output */ + png_set_scale_16(png_ptr); + + change &= ~PNG_FORMAT_FLAG_LINEAR; + } + + /* Now the background/alpha channel changes. */ + if ((change & PNG_FORMAT_FLAG_ALPHA) != 0) + { + /* Removing an alpha channel requires composition for the 8-bit + * formats; for the 16-bit it is already done, above, by the + * pre-multiplication and the channel just needs to be stripped. + */ + if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + /* If RGB->gray is happening the alpha channel must be left and the + * operation completed locally. + * + * TODO: fix libpng and remove this. + */ + if (do_local_background != 0) + do_local_background = 2/*required*/; + + /* 16-bit output: just remove the channel */ + else if (linear != 0) /* compose on black (well, pre-multiply) */ + png_set_strip_alpha(png_ptr); + + /* 8-bit output: do an appropriate compose */ + else if (display->background != NULL) + { + png_color_16 c; + + c.index = 0; /*unused*/ + c.red = display->background->red; + c.green = display->background->green; + c.blue = display->background->blue; + c.gray = display->background->green; + + /* This is always an 8-bit sRGB value, using the 'green' channel + * for gray is much better than calculating the luminance here; + * we can get off-by-one errors in that calculation relative to + * the app expectations and that will show up in transparent + * pixels. + */ + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + } + + else /* compose on row: implemented below. */ + { + do_local_compose = 1; + /* This leaves the alpha channel in the output, so it has to be + * removed by the code below. Set the encoding to the 'OPTIMIZE' + * one so the code only has to hack on the pixels that require + * composition. + */ + mode = PNG_ALPHA_OPTIMIZED; + } + } + + else /* output needs an alpha channel */ + { + /* This is tricky because it happens before the swap operation has + * been accomplished; however, the swap does *not* swap the added + * alpha channel (weird API), so it must be added in the correct + * place. + */ + png_uint_32 filler; /* opaque filler */ + int where; + + if (linear != 0) + filler = 65535; + + else + filler = 255; + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED + if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) + { + where = PNG_FILLER_BEFORE; + change &= ~PNG_FORMAT_FLAG_AFIRST; + } + + else +#endif + where = PNG_FILLER_AFTER; + + png_set_add_alpha(png_ptr, filler, where); + } + + /* This stops the (irrelevant) call to swap_alpha below. */ + change &= ~PNG_FORMAT_FLAG_ALPHA; + } + + /* Now set the alpha mode correctly; this is always done, even if there is + * no alpha channel in either the input or the output because it correctly + * sets the output gamma. + */ + png_set_alpha_mode_fixed(png_ptr, mode, output_gamma); + +# ifdef PNG_FORMAT_BGR_SUPPORTED + if ((change & PNG_FORMAT_FLAG_BGR) != 0) + { + /* Check only the output format; PNG is never BGR; don't do this if + * the output is gray, but fix up the 'format' value in that case. + */ + if ((format & PNG_FORMAT_FLAG_COLOR) != 0) + png_set_bgr(png_ptr); + + else + format &= ~PNG_FORMAT_FLAG_BGR; + + change &= ~PNG_FORMAT_FLAG_BGR; + } +# endif + +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if ((change & PNG_FORMAT_FLAG_AFIRST) != 0) + { + /* Only relevant if there is an alpha channel - it's particularly + * important to handle this correctly because do_local_compose may + * be set above and then libpng will keep the alpha channel for this + * code to remove. + */ + if ((format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + /* Disable this if doing a local background, + * TODO: remove this when local background is no longer required. + */ + if (do_local_background != 2) + png_set_swap_alpha(png_ptr); + } + + else + format &= ~PNG_FORMAT_FLAG_AFIRST; + + change &= ~PNG_FORMAT_FLAG_AFIRST; + } +# endif + + /* If the *output* is 16-bit then we need to check for a byte-swap on this + * architecture. + */ + if (linear != 0) + { + PNG_CONST png_uint_16 le = 0x0001; + + if ((*(png_const_bytep) & le) != 0) + png_set_swap(png_ptr); + } + + /* If change is not now 0 some transformation is missing - error out. */ + if (change != 0) + png_error(png_ptr, "png_read_image: unsupported transformation"); + } + + PNG_SKIP_CHUNKS(png_ptr); + + /* Update the 'info' structure and make sure the result is as required; first + * make sure to turn on the interlace handling if it will be required + * (because it can't be turned on *after* the call to png_read_update_info!) + * + * TODO: remove the do_local_background fixup below. + */ + if (do_local_compose == 0 && do_local_background != 2) + passes = png_set_interlace_handling(png_ptr); + + png_read_update_info(png_ptr, info_ptr); + + { + png_uint_32 info_format = 0; + + if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + info_format |= PNG_FORMAT_FLAG_COLOR; + + if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) + { + /* do_local_compose removes this channel below. */ + if (do_local_compose == 0) + { + /* do_local_background does the same if required. */ + if (do_local_background != 2 || + (format & PNG_FORMAT_FLAG_ALPHA) != 0) + info_format |= PNG_FORMAT_FLAG_ALPHA; + } + } + + else if (do_local_compose != 0) /* internal error */ + png_error(png_ptr, "png_image_read: alpha channel lost"); + + if ((format & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) { + info_format |= PNG_FORMAT_FLAG_ASSOCIATED_ALPHA; + } + + if (info_ptr->bit_depth == 16) + info_format |= PNG_FORMAT_FLAG_LINEAR; + +#ifdef PNG_FORMAT_BGR_SUPPORTED + if ((png_ptr->transformations & PNG_BGR) != 0) + info_format |= PNG_FORMAT_FLAG_BGR; +#endif + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (do_local_background == 2) + { + if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) + info_format |= PNG_FORMAT_FLAG_AFIRST; + } + + if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0 || + ((png_ptr->transformations & PNG_ADD_ALPHA) != 0 && + (png_ptr->flags & PNG_FLAG_FILLER_AFTER) == 0)) + { + if (do_local_background == 2) + png_error(png_ptr, "unexpected alpha swap transformation"); + + info_format |= PNG_FORMAT_FLAG_AFIRST; + } +# endif + + /* This is actually an internal error. */ + if (info_format != format) + png_error(png_ptr, "png_read_image: invalid transformations"); + } + + /* Now read the rows. If do_local_compose is set then it is necessary to use + * a local row buffer. The output will be GA, RGBA or BGRA and must be + * converted to G, RGB or BGR as appropriate. The 'local_row' member of the + * display acts as a flag. + */ + { + png_voidp first_row = display->buffer; + ptrdiff_t row_bytes = display->row_stride; + + if (linear != 0) + row_bytes *= 2; + + /* The following expression is designed to work correctly whether it gives + * a signed or an unsigned result. + */ + if (row_bytes < 0) + { + char *ptr = png_voidcast(char*, first_row); + ptr += (image->height-1) * (-row_bytes); + first_row = png_voidcast(png_voidp, ptr); + } + + display->first_row = first_row; + display->row_bytes = row_bytes; + } + + if (do_local_compose != 0) + { + int result; + png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); + + display->local_row = row; + result = png_safe_execute(image, png_image_read_composite, display); + display->local_row = NULL; + png_free(png_ptr, row); + + return result; + } + + else if (do_local_background == 2) + { + int result; + png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); + + display->local_row = row; + result = png_safe_execute(image, png_image_read_background, display); + display->local_row = NULL; + png_free(png_ptr, row); + + return result; + } + + else + { + png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes; + + while (--passes >= 0) + { + png_uint_32 y = image->height; + png_bytep row = png_voidcast(png_bytep, display->first_row); + + for (; y > 0; --y) + { + png_read_row(png_ptr, row, NULL); + row += row_bytes; + } + } + + return 1; + } +} + +int PNGAPI +png_image_finish_read(png_imagep image, png_const_colorp background, + void *buffer, png_int_32 row_stride, void *colormap) +{ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + /* Check for row_stride overflow. This check is not performed on the + * original PNG format because it may not occur in the output PNG format + * and libpng deals with the issues of reading the original. + */ + const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); + + /* The following checks just the 'row_stride' calculation to ensure it + * fits in a signed 32-bit value. Because channels/components can be + * either 1 or 2 bytes in size the length of a row can still overflow 32 + * bits; this is just to verify that the 'row_stride' argument can be + * represented. + */ + if (image->width <= 0x7fffffffU/channels) /* no overflow */ + { + png_uint_32 check; + const png_uint_32 png_row_stride = image->width * channels; + + if (row_stride == 0) + row_stride = (png_int_32)/*SAFE*/png_row_stride; + + if (row_stride < 0) + check = (png_uint_32)(-row_stride); + + else + check = (png_uint_32)row_stride; + + /* This verifies 'check', the absolute value of the actual stride + * passed in and detects overflow in the application calculation (i.e. + * if the app did actually pass in a non-zero 'row_stride'. + */ + if (image->opaque != NULL && buffer != NULL && check >= png_row_stride) + { + /* Now check for overflow of the image buffer calculation; this + * limits the whole image size to 32 bits for API compatibility with + * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro. + * + * The PNG_IMAGE_BUFFER_SIZE macro is: + * + * (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride)) + * + * And the component size is always 1 or 2, so make sure that the + * number of *bytes* that the application is saying are available + * does actually fit into a 32-bit number. + * + * NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE + * will be changed to use png_alloc_size_t; bigger images can be + * accomodated on 64-bit systems. + */ + if (image->height <= + 0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check) + { + if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 || + (image->colormap_entries > 0 && colormap != NULL)) + { + int result; + png_image_read_control display; + + memset(&display, 0, (sizeof display)); + display.image = image; + display.buffer = buffer; + display.row_stride = row_stride; + display.colormap = colormap; + display.background = background; + display.local_row = NULL; + + /* Choose the correct 'end' routine; for the color-map case + * all the setup has already been done. + */ + if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0) + result = + png_safe_execute(image, + png_image_read_colormap, &display) && + png_safe_execute(image, + png_image_read_colormapped, &display); + + else + result = + png_safe_execute(image, + png_image_read_direct, &display); + + png_image_free(image); + return result; + } + + else + return png_image_error(image, + "png_image_finish_read[color-map]: no color-map"); + } + + else + return png_image_error(image, + "png_image_finish_read: image too large"); + } + + else + return png_image_error(image, + "png_image_finish_read: invalid argument"); + } + + else + return png_image_error(image, + "png_image_finish_read: row_stride too large"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_finish_read: damaged PNG_IMAGE_VERSION"); + + return 0; +} + +#endif /* SIMPLIFIED_READ */ +#endif /* READ */ diff --git a/xs/src/png/libpng/pngrio.c b/xs/src/png/libpng/pngrio.c new file mode 100644 index 0000000000..7e26e855ca --- /dev/null +++ b/xs/src/png/libpng/pngrio.c @@ -0,0 +1,120 @@ + +/* pngrio.c - functions for data input + * + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * This file provides a location for all input. Users who need + * special handling are expected to write a function that has the same + * arguments as this and performs a similar function, but that possibly + * has a different input method. Note that you shouldn't change this + * function, but rather write a replacement function and then make + * libpng use it at run time with png_set_read_fn(...). + */ + +#include "pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +/* Read the data from whatever input you are using. The default routine + * reads from a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered reads. This should never be asked + * to read more than 64K on a 16-bit machine. + */ +void /* PRIVATE */ +png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length) +{ + png_debug1(4, "reading %d bytes", (int)length); + + if (png_ptr->read_data_fn != NULL) + (*(png_ptr->read_data_fn))(png_ptr, data, length); + + else + png_error(png_ptr, "Call to NULL read function"); +} + +#ifdef PNG_STDIO_SUPPORTED +/* This is the function that does the actual reading of data. If you are + * not reading from a standard C stream, you should create a replacement + * read_data function and use it at run time with png_set_read_fn(), rather + * than changing the library. + */ +void PNGCBAPI +png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + if (png_ptr == NULL) + return; + + /* fread() returns 0 on error, so it is OK to store this in a png_size_t + * instead of an int, which is what fread() actually returns. + */ + check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr)); + + if (check != length) + png_error(png_ptr, "Read Error"); +} +#endif + +/* This function allows the application to supply a new input function + * for libpng if standard C streams aren't being used. + * + * This function takes as its arguments: + * + * png_ptr - pointer to a png input data structure + * + * io_ptr - pointer to user supplied structure containing info about + * the input functions. May be NULL. + * + * read_data_fn - pointer to a new input function that takes as its + * arguments a pointer to a png_struct, a pointer to + * a location where input data can be stored, and a 32-bit + * unsigned int that is the number of bytes to be read. + * To exit and output any fatal error messages the new write + * function should call png_error(png_ptr, "Error msg"). + * May be NULL, in which case libpng's default function will + * be used. + */ +void PNGAPI +png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, + png_rw_ptr read_data_fn) +{ + if (png_ptr == NULL) + return; + + png_ptr->io_ptr = io_ptr; + +#ifdef PNG_STDIO_SUPPORTED + if (read_data_fn != NULL) + png_ptr->read_data_fn = read_data_fn; + + else + png_ptr->read_data_fn = png_default_read_data; +#else + png_ptr->read_data_fn = read_data_fn; +#endif + +#ifdef PNG_WRITE_SUPPORTED + /* It is an error to write to a read device */ + if (png_ptr->write_data_fn != NULL) + { + png_ptr->write_data_fn = NULL; + png_warning(png_ptr, + "Can't set both read_data_fn and write_data_fn in the" + " same structure"); + } +#endif + +#ifdef PNG_WRITE_FLUSH_SUPPORTED + png_ptr->output_flush_fn = NULL; +#endif +} +#endif /* READ */ diff --git a/xs/src/png/libpng/pngrtran.c b/xs/src/png/libpng/pngrtran.c new file mode 100644 index 0000000000..c189650313 --- /dev/null +++ b/xs/src/png/libpng/pngrtran.c @@ -0,0 +1,5010 @@ + +/* pngrtran.c - transforms the data in a row for PNG readers + * + * Last changed in libpng 1.6.33 [September 28, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * This file contains functions optionally called by an application + * in order to tell libpng how to handle data when reading a PNG. + * Transformations that are used in both reading and writing are + * in pngtrans.c. + */ + +#include "pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +/* Set the action on getting a CRC error for an ancillary or critical chunk. */ +void PNGAPI +png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) +{ + png_debug(1, "in png_set_crc_action"); + + if (png_ptr == NULL) + return; + + /* Tell libpng how we react to CRC errors in critical chunks */ + switch (crit_action) + { + case PNG_CRC_NO_CHANGE: /* Leave setting as is */ + break; + + case PNG_CRC_WARN_USE: /* Warn/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; + break; + + case PNG_CRC_QUIET_USE: /* Quiet/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | + PNG_FLAG_CRC_CRITICAL_IGNORE; + break; + + case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */ + png_warning(png_ptr, + "Can't discard critical data on CRC error"); + /* FALLTHROUGH */ + case PNG_CRC_ERROR_QUIT: /* Error/quit */ + + case PNG_CRC_DEFAULT: + default: + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + break; + } + + /* Tell libpng how we react to CRC errors in ancillary chunks */ + switch (ancil_action) + { + case PNG_CRC_NO_CHANGE: /* Leave setting as is */ + break; + + case PNG_CRC_WARN_USE: /* Warn/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; + break; + + case PNG_CRC_QUIET_USE: /* Quiet/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | + PNG_FLAG_CRC_ANCILLARY_NOWARN; + break; + + case PNG_CRC_ERROR_QUIT: /* Error/quit */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; + break; + + case PNG_CRC_WARN_DISCARD: /* Warn/discard data */ + + case PNG_CRC_DEFAULT: + default: + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + break; + } +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* Is it OK to set a transformation now? Only if png_start_read_image or + * png_read_update_info have not been called. It is not necessary for the IHDR + * to have been read in all cases; the need_IHDR parameter allows for this + * check too. + */ +static int +png_rtran_ok(png_structrp png_ptr, int need_IHDR) +{ + if (png_ptr != NULL) + { + if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) + png_app_error(png_ptr, + "invalid after png_start_read_image or png_read_update_info"); + + else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_app_error(png_ptr, "invalid before the PNG header has been read"); + + else + { + /* Turn on failure to initialize correctly for all transforms. */ + png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED; + + return 1; /* Ok */ + } + } + + return 0; /* no png_error possible! */ +} +#endif + +#ifdef PNG_READ_BACKGROUND_SUPPORTED +/* Handle alpha and tRNS via a background color */ +void PNGFAPI +png_set_background_fixed(png_structrp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, png_fixed_point background_gamma) +{ + png_debug(1, "in png_set_background_fixed"); + + if (png_rtran_ok(png_ptr, 0) == 0 || background_color == NULL) + return; + + if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) + { + png_warning(png_ptr, "Application must supply a known background gamma"); + return; + } + + png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA; + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + + png_ptr->background = *background_color; + png_ptr->background_gamma = background_gamma; + png_ptr->background_gamma_type = (png_byte)(background_gamma_code); + if (need_expand != 0) + png_ptr->transformations |= PNG_BACKGROUND_EXPAND; + else + png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_background(png_structrp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma) +{ + png_set_background_fixed(png_ptr, background_color, background_gamma_code, + need_expand, png_fixed(png_ptr, background_gamma, "png_set_background")); +} +# endif /* FLOATING_POINT */ +#endif /* READ_BACKGROUND */ + +/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the + * one that pngrtran does first (scale) happens. This is necessary to allow the + * TRANSFORM and API behavior to be somewhat consistent, and it's simpler. + */ +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +void PNGAPI +png_set_scale_16(png_structrp png_ptr) +{ + png_debug(1, "in png_set_scale_16"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= PNG_SCALE_16_TO_8; +} +#endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED +/* Chop 16-bit depth files to 8-bit depth */ +void PNGAPI +png_set_strip_16(png_structrp png_ptr) +{ + png_debug(1, "in png_set_strip_16"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= PNG_16_TO_8; +} +#endif + +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +void PNGAPI +png_set_strip_alpha(png_structrp png_ptr) +{ + png_debug(1, "in png_set_strip_alpha"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= PNG_STRIP_ALPHA; +} +#endif + +#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED) +static png_fixed_point +translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, + int is_screen) +{ + /* Check for flag values. The main reason for having the old Mac value as a + * flag is that it is pretty near impossible to work out what the correct + * value is from Apple documentation - a working Mac system is needed to + * discover the value! + */ + if (output_gamma == PNG_DEFAULT_sRGB || + output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB) + { + /* If there is no sRGB support this just sets the gamma to the standard + * sRGB value. (This is a side effect of using this function!) + */ +# ifdef PNG_READ_sRGB_SUPPORTED + png_ptr->flags |= PNG_FLAG_ASSUME_sRGB; +# else + PNG_UNUSED(png_ptr) +# endif + if (is_screen != 0) + output_gamma = PNG_GAMMA_sRGB; + else + output_gamma = PNG_GAMMA_sRGB_INVERSE; + } + + else if (output_gamma == PNG_GAMMA_MAC_18 || + output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18) + { + if (is_screen != 0) + output_gamma = PNG_GAMMA_MAC_OLD; + else + output_gamma = PNG_GAMMA_MAC_INVERSE; + } + + return output_gamma; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +static png_fixed_point +convert_gamma_value(png_structrp png_ptr, double output_gamma) +{ + /* The following silently ignores cases where fixed point (times 100,000) + * gamma values are passed to the floating point API. This is safe and it + * means the fixed point constants work just fine with the floating point + * API. The alternative would just lead to undetected errors and spurious + * bug reports. Negative values fail inside the _fixed API unless they + * correspond to the flag values. + */ + if (output_gamma > 0 && output_gamma < 128) + output_gamma *= PNG_FP_1; + + /* This preserves -1 and -2 exactly: */ + output_gamma = floor(output_gamma + .5); + + if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN) + png_fixed_error(png_ptr, "gamma value"); + + return (png_fixed_point)output_gamma; +} +# endif +#endif /* READ_ALPHA_MODE || READ_GAMMA */ + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED +void PNGFAPI +png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, + png_fixed_point output_gamma) +{ + int compose = 0; + png_fixed_point file_gamma; + + png_debug(1, "in png_set_alpha_mode"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/); + + /* Validate the value to ensure it is in a reasonable range. The value + * is expected to be 1 or greater, but this range test allows for some + * viewing correction values. The intent is to weed out users of this API + * who use the inverse of the gamma value accidentally! Since some of these + * values are reasonable this may have to be changed: + * + * 1.6.x: changed from 0.07..3 to 0.01..100 (to accomodate the optimal 16-bit + * gamma of 36, and its reciprocal.) + */ + if (output_gamma < 1000 || output_gamma > 10000000) + png_error(png_ptr, "output gamma out of expected range"); + + /* The default file gamma is the inverse of the output gamma; the output + * gamma may be changed below so get the file value first: + */ + file_gamma = png_reciprocal(output_gamma); + + /* There are really 8 possibilities here, composed of any combination + * of: + * + * premultiply the color channels + * do not encode non-opaque pixels + * encode the alpha as well as the color channels + * + * The differences disappear if the input/output ('screen') gamma is 1.0, + * because then the encoding is a no-op and there is only the choice of + * premultiplying the color channels or not. + * + * png_set_alpha_mode and png_set_background interact because both use + * png_compose to do the work. Calling both is only useful when + * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along + * with a default gamma value. Otherwise PNG_COMPOSE must not be set. + */ + switch (mode) + { + case PNG_ALPHA_PNG: /* default: png standard */ + /* No compose, but it may be set by png_set_background! */ + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + break; + + case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */ + compose = 1; + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + /* The output is linear: */ + output_gamma = PNG_FP_1; + break; + + case PNG_ALPHA_OPTIMIZED: /* associated, non-opaque pixels linear */ + compose = 1; + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA; + /* output_gamma records the encoding of opaque pixels! */ + break; + + case PNG_ALPHA_BROKEN: /* associated, non-linear, alpha encoded */ + compose = 1; + png_ptr->transformations |= PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + break; + + default: + png_error(png_ptr, "invalid alpha mode"); + } + + /* Only set the default gamma if the file gamma has not been set (this has + * the side effect that the gamma in a second call to png_set_alpha_mode will + * be ignored.) + */ + if (png_ptr->colorspace.gamma == 0) + { + png_ptr->colorspace.gamma = file_gamma; + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + } + + /* But always set the output gamma: */ + png_ptr->screen_gamma = output_gamma; + + /* Finally, if pre-multiplying, set the background fields to achieve the + * desired result. + */ + if (compose != 0) + { + /* And obtain alpha pre-multiplication by composing on black: */ + memset(&png_ptr->background, 0, (sizeof png_ptr->background)); + png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */ + png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE; + png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; + + if ((png_ptr->transformations & PNG_COMPOSE) != 0) + png_error(png_ptr, + "conflicting calls to set alpha mode and background"); + + png_ptr->transformations |= PNG_COMPOSE; + } +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma) +{ + png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr, + output_gamma)); +} +# endif +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED +/* Dither file to 8-bit. Supply a palette, the current number + * of elements in the palette, the maximum number of elements + * allowed, and a histogram if possible. If the current number + * of colors is greater than the maximum number, the palette will be + * modified to fit in the maximum number. "full_quantize" indicates + * whether we need a quantizing cube set up for RGB images, or if we + * simply are reducing the number of colors in a paletted image. + */ + +typedef struct png_dsort_struct +{ + struct png_dsort_struct * next; + png_byte left; + png_byte right; +} png_dsort; +typedef png_dsort * png_dsortp; +typedef png_dsort * * png_dsortpp; + +void PNGAPI +png_set_quantize(png_structrp png_ptr, png_colorp palette, + int num_palette, int maximum_colors, png_const_uint_16p histogram, + int full_quantize) +{ + png_debug(1, "in png_set_quantize"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= PNG_QUANTIZE; + + if (full_quantize == 0) + { + int i; + + png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, + (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); + for (i = 0; i < num_palette; i++) + png_ptr->quantize_index[i] = (png_byte)i; + } + + if (num_palette > maximum_colors) + { + if (histogram != NULL) + { + /* This is easy enough, just throw out the least used colors. + * Perhaps not the best solution, but good enough. + */ + + int i; + + /* Initialize an array to sort colors */ + png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, + (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); + + /* Initialize the quantize_sort array */ + for (i = 0; i < num_palette; i++) + png_ptr->quantize_sort[i] = (png_byte)i; + + /* Find the least used palette entries by starting a + * bubble sort, and running it until we have sorted + * out enough colors. Note that we don't care about + * sorting all the colors, just finding which are + * least used. + */ + + for (i = num_palette - 1; i >= maximum_colors; i--) + { + int done; /* To stop early if the list is pre-sorted */ + int j; + + done = 1; + for (j = 0; j < i; j++) + { + if (histogram[png_ptr->quantize_sort[j]] + < histogram[png_ptr->quantize_sort[j + 1]]) + { + png_byte t; + + t = png_ptr->quantize_sort[j]; + png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1]; + png_ptr->quantize_sort[j + 1] = t; + done = 0; + } + } + + if (done != 0) + break; + } + + /* Swap the palette around, and set up a table, if necessary */ + if (full_quantize != 0) + { + int j = num_palette; + + /* Put all the useful colors within the max, but don't + * move the others. + */ + for (i = 0; i < maximum_colors; i++) + { + if ((int)png_ptr->quantize_sort[i] >= maximum_colors) + { + do + j--; + while ((int)png_ptr->quantize_sort[j] >= maximum_colors); + + palette[i] = palette[j]; + } + } + } + else + { + int j = num_palette; + + /* Move all the used colors inside the max limit, and + * develop a translation table. + */ + for (i = 0; i < maximum_colors; i++) + { + /* Only move the colors we need to */ + if ((int)png_ptr->quantize_sort[i] >= maximum_colors) + { + png_color tmp_color; + + do + j--; + while ((int)png_ptr->quantize_sort[j] >= maximum_colors); + + tmp_color = palette[j]; + palette[j] = palette[i]; + palette[i] = tmp_color; + /* Indicate where the color went */ + png_ptr->quantize_index[j] = (png_byte)i; + png_ptr->quantize_index[i] = (png_byte)j; + } + } + + /* Find closest color for those colors we are not using */ + for (i = 0; i < num_palette; i++) + { + if ((int)png_ptr->quantize_index[i] >= maximum_colors) + { + int min_d, k, min_k, d_index; + + /* Find the closest color to one we threw out */ + d_index = png_ptr->quantize_index[i]; + min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); + for (k = 1, min_k = 0; k < maximum_colors; k++) + { + int d; + + d = PNG_COLOR_DIST(palette[d_index], palette[k]); + + if (d < min_d) + { + min_d = d; + min_k = k; + } + } + /* Point to closest color */ + png_ptr->quantize_index[i] = (png_byte)min_k; + } + } + } + png_free(png_ptr, png_ptr->quantize_sort); + png_ptr->quantize_sort = NULL; + } + else + { + /* This is much harder to do simply (and quickly). Perhaps + * we need to go through a median cut routine, but those + * don't always behave themselves with only a few colors + * as input. So we will just find the closest two colors, + * and throw out one of them (chosen somewhat randomly). + * [We don't understand this at all, so if someone wants to + * work on improving it, be our guest - AED, GRP] + */ + int i; + int max_d; + int num_new_palette; + png_dsortp t; + png_dsortpp hash; + + t = NULL; + + /* Initialize palette index arrays */ + png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, + (png_alloc_size_t)((png_uint_32)num_palette * + (sizeof (png_byte)))); + png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, + (png_alloc_size_t)((png_uint_32)num_palette * + (sizeof (png_byte)))); + + /* Initialize the sort array */ + for (i = 0; i < num_palette; i++) + { + png_ptr->index_to_palette[i] = (png_byte)i; + png_ptr->palette_to_index[i] = (png_byte)i; + } + + hash = (png_dsortpp)png_calloc(png_ptr, (png_alloc_size_t)(769 * + (sizeof (png_dsortp)))); + + num_new_palette = num_palette; + + /* Initial wild guess at how far apart the farthest pixel + * pair we will be eliminating will be. Larger + * numbers mean more areas will be allocated, Smaller + * numbers run the risk of not saving enough data, and + * having to do this all over again. + * + * I have not done extensive checking on this number. + */ + max_d = 96; + + while (num_new_palette > maximum_colors) + { + for (i = 0; i < num_new_palette - 1; i++) + { + int j; + + for (j = i + 1; j < num_new_palette; j++) + { + int d; + + d = PNG_COLOR_DIST(palette[i], palette[j]); + + if (d <= max_d) + { + + t = (png_dsortp)png_malloc_warn(png_ptr, + (png_alloc_size_t)(sizeof (png_dsort))); + + if (t == NULL) + break; + + t->next = hash[d]; + t->left = (png_byte)i; + t->right = (png_byte)j; + hash[d] = t; + } + } + if (t == NULL) + break; + } + + if (t != NULL) + for (i = 0; i <= max_d; i++) + { + if (hash[i] != NULL) + { + png_dsortp p; + + for (p = hash[i]; p; p = p->next) + { + if ((int)png_ptr->index_to_palette[p->left] + < num_new_palette && + (int)png_ptr->index_to_palette[p->right] + < num_new_palette) + { + int j, next_j; + + if (num_new_palette & 0x01) + { + j = p->left; + next_j = p->right; + } + else + { + j = p->right; + next_j = p->left; + } + + num_new_palette--; + palette[png_ptr->index_to_palette[j]] + = palette[num_new_palette]; + if (full_quantize == 0) + { + int k; + + for (k = 0; k < num_palette; k++) + { + if (png_ptr->quantize_index[k] == + png_ptr->index_to_palette[j]) + png_ptr->quantize_index[k] = + png_ptr->index_to_palette[next_j]; + + if ((int)png_ptr->quantize_index[k] == + num_new_palette) + png_ptr->quantize_index[k] = + png_ptr->index_to_palette[j]; + } + } + + png_ptr->index_to_palette[png_ptr->palette_to_index + [num_new_palette]] = png_ptr->index_to_palette[j]; + + png_ptr->palette_to_index[png_ptr->index_to_palette[j]] + = png_ptr->palette_to_index[num_new_palette]; + + png_ptr->index_to_palette[j] = + (png_byte)num_new_palette; + + png_ptr->palette_to_index[num_new_palette] = + (png_byte)j; + } + if (num_new_palette <= maximum_colors) + break; + } + if (num_new_palette <= maximum_colors) + break; + } + } + + for (i = 0; i < 769; i++) + { + if (hash[i] != NULL) + { + png_dsortp p = hash[i]; + while (p) + { + t = p->next; + png_free(png_ptr, p); + p = t; + } + } + hash[i] = 0; + } + max_d += 96; + } + png_free(png_ptr, hash); + png_free(png_ptr, png_ptr->palette_to_index); + png_free(png_ptr, png_ptr->index_to_palette); + png_ptr->palette_to_index = NULL; + png_ptr->index_to_palette = NULL; + } + num_palette = maximum_colors; + } + if (png_ptr->palette == NULL) + { + png_ptr->palette = palette; + } + png_ptr->num_palette = (png_uint_16)num_palette; + + if (full_quantize != 0) + { + int i; + png_bytep distance; + int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS + + PNG_QUANTIZE_BLUE_BITS; + int num_red = (1 << PNG_QUANTIZE_RED_BITS); + int num_green = (1 << PNG_QUANTIZE_GREEN_BITS); + int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS); + png_size_t num_entries = ((png_size_t)1 << total_bits); + + png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, + (png_alloc_size_t)(num_entries * (sizeof (png_byte)))); + + distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries * + (sizeof (png_byte)))); + + memset(distance, 0xff, num_entries * (sizeof (png_byte))); + + for (i = 0; i < num_palette; i++) + { + int ir, ig, ib; + int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS)); + int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS)); + int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS)); + + for (ir = 0; ir < num_red; ir++) + { + /* int dr = abs(ir - r); */ + int dr = ((ir > r) ? ir - r : r - ir); + int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS + + PNG_QUANTIZE_GREEN_BITS)); + + for (ig = 0; ig < num_green; ig++) + { + /* int dg = abs(ig - g); */ + int dg = ((ig > g) ? ig - g : g - ig); + int dt = dr + dg; + int dm = ((dr > dg) ? dr : dg); + int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS); + + for (ib = 0; ib < num_blue; ib++) + { + int d_index = index_g | ib; + /* int db = abs(ib - b); */ + int db = ((ib > b) ? ib - b : b - ib); + int dmax = ((dm > db) ? dm : db); + int d = dmax + dt + db; + + if (d < (int)distance[d_index]) + { + distance[d_index] = (png_byte)d; + png_ptr->palette_lookup[d_index] = (png_byte)i; + } + } + } + } + } + + png_free(png_ptr, distance); + } +} +#endif /* READ_QUANTIZE */ + +#ifdef PNG_READ_GAMMA_SUPPORTED +void PNGFAPI +png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, + png_fixed_point file_gamma) +{ + png_debug(1, "in png_set_gamma_fixed"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + /* New in libpng-1.5.4 - reserve particular negative values as flags. */ + scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/); + file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/); + + /* Checking the gamma values for being >0 was added in 1.5.4 along with the + * premultiplied alpha support; this actually hides an undocumented feature + * of the previous implementation which allowed gamma processing to be + * disabled in background handling. There is no evidence (so far) that this + * was being used; however, png_set_background itself accepted and must still + * accept '0' for the gamma value it takes, because it isn't always used. + * + * Since this is an API change (albeit a very minor one that removes an + * undocumented API feature) the following checks were only enabled in + * libpng-1.6.0. + */ + if (file_gamma <= 0) + png_error(png_ptr, "invalid file gamma in png_set_gamma"); + + if (scrn_gamma <= 0) + png_error(png_ptr, "invalid screen gamma in png_set_gamma"); + + /* Set the gamma values unconditionally - this overrides the value in the PNG + * file if a gAMA chunk was present. png_set_alpha_mode provides a + * different, easier, way to default the file gamma. + */ + png_ptr->colorspace.gamma = file_gamma; + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + png_ptr->screen_gamma = scrn_gamma; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma) +{ + png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma), + convert_gamma_value(png_ptr, file_gamma)); +} +# endif /* FLOATING_POINT */ +#endif /* READ_GAMMA */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* Expand paletted images to RGB, expand grayscale images of + * less than 8-bit depth to 8-bit depth, and expand tRNS chunks + * to alpha channels. + */ +void PNGAPI +png_set_expand(png_structrp png_ptr) +{ + png_debug(1, "in png_set_expand"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} + +/* GRR 19990627: the following three functions currently are identical + * to png_set_expand(). However, it is entirely reasonable that someone + * might wish to expand an indexed image to RGB but *not* expand a single, + * fully transparent palette entry to a full alpha channel--perhaps instead + * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace + * the transparent color with a particular RGB value, or drop tRNS entirely. + * IOW, a future version of the library may make the transformations flag + * a bit more fine-grained, with separate bits for each of these three + * functions. + * + * More to the point, these functions make it obvious what libpng will be + * doing, whereas "expand" can (and does) mean any number of things. + * + * GRP 20060307: In libpng-1.2.9, png_set_gray_1_2_4_to_8() was modified + * to expand only the sample depth but not to expand the tRNS to alpha + * and its name was changed to png_set_expand_gray_1_2_4_to_8(). + */ + +/* Expand paletted images to RGB. */ +void PNGAPI +png_set_palette_to_rgb(png_structrp png_ptr) +{ + png_debug(1, "in png_set_palette_to_rgb"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} + +/* Expand grayscale images of less than 8-bit depth to 8 bits. */ +void PNGAPI +png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr) +{ + png_debug(1, "in png_set_expand_gray_1_2_4_to_8"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= PNG_EXPAND; +} + +/* Expand tRNS chunks to alpha channels. */ +void PNGAPI +png_set_tRNS_to_alpha(png_structrp png_ptr) +{ + png_debug(1, "in png_set_tRNS_to_alpha"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} +#endif /* READ_EXPAND */ + +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise + * it may not work correctly.) + */ +void PNGAPI +png_set_expand_16(png_structrp png_ptr) +{ + png_debug(1, "in png_set_expand_16"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS); +} +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +void PNGAPI +png_set_gray_to_rgb(png_structrp png_ptr) +{ + png_debug(1, "in png_set_gray_to_rgb"); + + if (png_rtran_ok(png_ptr, 0) == 0) + return; + + /* Because rgb must be 8 bits or more: */ + png_set_expand_gray_1_2_4_to_8(png_ptr); + png_ptr->transformations |= PNG_GRAY_TO_RGB; +} +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +void PNGFAPI +png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, + png_fixed_point red, png_fixed_point green) +{ + png_debug(1, "in png_set_rgb_to_gray"); + + /* Need the IHDR here because of the check on color_type below. */ + /* TODO: fix this */ + if (png_rtran_ok(png_ptr, 1) == 0) + return; + + switch (error_action) + { + case PNG_ERROR_ACTION_NONE: + png_ptr->transformations |= PNG_RGB_TO_GRAY; + break; + + case PNG_ERROR_ACTION_WARN: + png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; + break; + + case PNG_ERROR_ACTION_ERROR: + png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; + break; + + default: + png_error(png_ptr, "invalid error action to rgb_to_gray"); + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) +#ifdef PNG_READ_EXPAND_SUPPORTED + png_ptr->transformations |= PNG_EXPAND; +#else + { + /* Make this an error in 1.6 because otherwise the application may assume + * that it just worked and get a memory overwrite. + */ + png_error(png_ptr, + "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); + + /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */ + } +#endif + { + if (red >= 0 && green >= 0 && red + green <= PNG_FP_1) + { + png_uint_16 red_int, green_int; + + /* NOTE: this calculation does not round, but this behavior is retained + * for consistency; the inaccuracy is very small. The code here always + * overwrites the coefficients, regardless of whether they have been + * defaulted or set already. + */ + red_int = (png_uint_16)(((png_uint_32)red*32768)/100000); + green_int = (png_uint_16)(((png_uint_32)green*32768)/100000); + + png_ptr->rgb_to_gray_red_coeff = red_int; + png_ptr->rgb_to_gray_green_coeff = green_int; + png_ptr->rgb_to_gray_coefficients_set = 1; + } + + else + { + if (red >= 0 && green >= 0) + png_app_warning(png_ptr, + "ignoring out of range rgb_to_gray coefficients"); + + /* Use the defaults, from the cHRM chunk if set, else the historical + * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See + * png_do_rgb_to_gray for more discussion of the values. In this case + * the coefficients are not marked as 'set' and are not overwritten if + * something has already provided a default. + */ + if (png_ptr->rgb_to_gray_red_coeff == 0 && + png_ptr->rgb_to_gray_green_coeff == 0) + { + png_ptr->rgb_to_gray_red_coeff = 6968; + png_ptr->rgb_to_gray_green_coeff = 23434; + /* png_ptr->rgb_to_gray_blue_coeff = 2366; */ + } + } + } +} + +#ifdef PNG_FLOATING_POINT_SUPPORTED +/* Convert a RGB image to a grayscale of the same width. This allows us, + * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. + */ + +void PNGAPI +png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red, + double green) +{ + png_set_rgb_to_gray_fixed(png_ptr, error_action, + png_fixed(png_ptr, red, "rgb to gray red coefficient"), + png_fixed(png_ptr, green, "rgb to gray green coefficient")); +} +#endif /* FLOATING POINT */ + +#endif /* RGB_TO_GRAY */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +void PNGAPI +png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr + read_user_transform_fn) +{ + png_debug(1, "in png_set_read_user_transform_fn"); + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED + png_ptr->transformations |= PNG_USER_TRANSFORM; + png_ptr->read_user_transform_fn = read_user_transform_fn; +#endif +} +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +#ifdef PNG_READ_GAMMA_SUPPORTED +/* In the case of gamma transformations only do transformations on images where + * the [file] gamma and screen_gamma are not close reciprocals, otherwise it + * slows things down slightly, and also needlessly introduces small errors. + */ +static int /* PRIVATE */ +png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma) +{ + /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma + * correction as a difference of the overall transform from 1.0 + * + * We want to compare the threshold with s*f - 1, if we get + * overflow here it is because of wacky gamma values so we + * turn on processing anyway. + */ + png_fixed_point gtest; + return !png_muldiv(>est, screen_gamma, file_gamma, PNG_FP_1) || + png_gamma_significant(gtest); +} +#endif + +/* Initialize everything needed for the read. This includes modifying + * the palette. + */ + +/* For the moment 'png_init_palette_transformations' and + * 'png_init_rgb_transformations' only do some flag canceling optimizations. + * The intent is that these two routines should have palette or rgb operations + * extracted from 'png_init_read_transformations'. + */ +static void /* PRIVATE */ +png_init_palette_transformations(png_structrp png_ptr) +{ + /* Called to handle the (input) palette case. In png_do_read_transformations + * the first step is to expand the palette if requested, so this code must + * take care to only make changes that are invariant with respect to the + * palette expansion, or only do them if there is no expansion. + * + * STRIP_ALPHA has already been handled in the caller (by setting num_trans + * to 0.) + */ + int input_has_alpha = 0; + int input_has_transparency = 0; + + if (png_ptr->num_trans > 0) + { + int i; + + /* Ignore if all the entries are opaque (unlikely!) */ + for (i=0; inum_trans; ++i) + { + if (png_ptr->trans_alpha[i] == 255) + continue; + else if (png_ptr->trans_alpha[i] == 0) + input_has_transparency = 1; + else + { + input_has_transparency = 1; + input_has_alpha = 1; + break; + } + } + } + + /* If no alpha we can optimize. */ + if (input_has_alpha == 0) + { + /* Any alpha means background and associative alpha processing is + * required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA + * and ENCODE_ALPHA are irrelevant. + */ + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + + if (input_has_transparency == 0) + png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); + } + +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) + /* png_set_background handling - deals with the complexity of whether the + * background color is in the file format or the screen format in the case + * where an 'expand' will happen. + */ + + /* The following code cannot be entered in the alpha pre-multiplication case + * because PNG_BACKGROUND_EXPAND is cancelled below. + */ + if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 && + (png_ptr->transformations & PNG_EXPAND) != 0) + { + { + png_ptr->background.red = + png_ptr->palette[png_ptr->background.index].red; + png_ptr->background.green = + png_ptr->palette[png_ptr->background.index].green; + png_ptr->background.blue = + png_ptr->palette[png_ptr->background.index].blue; + +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) + { + if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0) + { + /* Invert the alpha channel (in tRNS) unless the pixels are + * going to be expanded, in which case leave it for later + */ + int i, istop = png_ptr->num_trans; + + for (i=0; itrans_alpha[i] = (png_byte)(255 - + png_ptr->trans_alpha[i]); + } + } +#endif /* READ_INVERT_ALPHA */ + } + } /* background expand and (therefore) no alpha association. */ +#endif /* READ_EXPAND && READ_BACKGROUND */ +} + +static void /* PRIVATE */ +png_init_rgb_transformations(png_structrp png_ptr) +{ + /* Added to libpng-1.5.4: check the color type to determine whether there + * is any alpha or transparency in the image and simply cancel the + * background and alpha mode stuff if there isn't. + */ + int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0; + int input_has_transparency = png_ptr->num_trans > 0; + + /* If no alpha we can optimize. */ + if (input_has_alpha == 0) + { + /* Any alpha means background and associative alpha processing is + * required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA + * and ENCODE_ALPHA are irrelevant. + */ +# ifdef PNG_READ_ALPHA_MODE_SUPPORTED + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; +# endif + + if (input_has_transparency == 0) + png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); + } + +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) + /* png_set_background handling - deals with the complexity of whether the + * background color is in the file format or the screen format in the case + * where an 'expand' will happen. + */ + + /* The following code cannot be entered in the alpha pre-multiplication case + * because PNG_BACKGROUND_EXPAND is cancelled below. + */ + if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 && + (png_ptr->transformations & PNG_EXPAND) != 0 && + (png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) + /* i.e., GRAY or GRAY_ALPHA */ + { + { + /* Expand background and tRNS chunks */ + int gray = png_ptr->background.gray; + int trans_gray = png_ptr->trans_color.gray; + + switch (png_ptr->bit_depth) + { + case 1: + gray *= 0xff; + trans_gray *= 0xff; + break; + + case 2: + gray *= 0x55; + trans_gray *= 0x55; + break; + + case 4: + gray *= 0x11; + trans_gray *= 0x11; + break; + + default: + + case 8: + /* FALLTHROUGH */ /* (Already 8 bits) */ + + case 16: + /* Already a full 16 bits */ + break; + } + + png_ptr->background.red = png_ptr->background.green = + png_ptr->background.blue = (png_uint_16)gray; + + if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0) + { + png_ptr->trans_color.red = png_ptr->trans_color.green = + png_ptr->trans_color.blue = (png_uint_16)trans_gray; + } + } + } /* background expand and (therefore) no alpha association. */ +#endif /* READ_EXPAND && READ_BACKGROUND */ +} + +void /* PRIVATE */ +png_init_read_transformations(png_structrp png_ptr) +{ + png_debug(1, "in png_init_read_transformations"); + + /* This internal function is called from png_read_start_row in pngrutil.c + * and it is called before the 'rowbytes' calculation is done, so the code + * in here can change or update the transformations flags. + * + * First do updates that do not depend on the details of the PNG image data + * being processed. + */ + +#ifdef PNG_READ_GAMMA_SUPPORTED + /* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds + * png_set_alpha_mode and this is another source for a default file gamma so + * the test needs to be performed later - here. In addition prior to 1.5.4 + * the tests were repeated for the PALETTE color type here - this is no + * longer necessary (and doesn't seem to have been necessary before.) + */ + { + /* The following temporary indicates if overall gamma correction is + * required. + */ + int gamma_correction = 0; + + if (png_ptr->colorspace.gamma != 0) /* has been set */ + { + if (png_ptr->screen_gamma != 0) /* screen set too */ + gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma, + png_ptr->screen_gamma); + + else + /* Assume the output matches the input; a long time default behavior + * of libpng, although the standard has nothing to say about this. + */ + png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma); + } + + else if (png_ptr->screen_gamma != 0) + /* The converse - assume the file matches the screen, note that this + * perhaps undesireable default can (from 1.5.4) be changed by calling + * png_set_alpha_mode (even if the alpha handling mode isn't required + * or isn't changed from the default.) + */ + png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma); + + else /* neither are set */ + /* Just in case the following prevents any processing - file and screen + * are both assumed to be linear and there is no way to introduce a + * third gamma value other than png_set_background with 'UNIQUE', and, + * prior to 1.5.4 + */ + png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1; + + /* We have a gamma value now. */ + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + + /* Now turn the gamma transformation on or off as appropriate. Notice + * that PNG_GAMMA just refers to the file->screen correction. Alpha + * composition may independently cause gamma correction because it needs + * linear data (e.g. if the file has a gAMA chunk but the screen gamma + * hasn't been specified.) In any case this flag may get turned off in + * the code immediately below if the transform can be handled outside the + * row loop. + */ + if (gamma_correction != 0) + png_ptr->transformations |= PNG_GAMMA; + + else + png_ptr->transformations &= ~PNG_GAMMA; + } +#endif + + /* Certain transformations have the effect of preventing other + * transformations that happen afterward in png_do_read_transformations; + * resolve the interdependencies here. From the code of + * png_do_read_transformations the order is: + * + * 1) PNG_EXPAND (including PNG_EXPAND_tRNS) + * 2) PNG_STRIP_ALPHA (if no compose) + * 3) PNG_RGB_TO_GRAY + * 4) PNG_GRAY_TO_RGB iff !PNG_BACKGROUND_IS_GRAY + * 5) PNG_COMPOSE + * 6) PNG_GAMMA + * 7) PNG_STRIP_ALPHA (if compose) + * 8) PNG_ENCODE_ALPHA + * 9) PNG_SCALE_16_TO_8 + * 10) PNG_16_TO_8 + * 11) PNG_QUANTIZE (converts to palette) + * 12) PNG_EXPAND_16 + * 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY + * 14) PNG_INVERT_MONO + * 15) PNG_INVERT_ALPHA + * 16) PNG_SHIFT + * 17) PNG_PACK + * 18) PNG_BGR + * 19) PNG_PACKSWAP + * 20) PNG_FILLER (includes PNG_ADD_ALPHA) + * 21) PNG_SWAP_ALPHA + * 22) PNG_SWAP_BYTES + * 23) PNG_USER_TRANSFORM [must be last] + */ +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && + (png_ptr->transformations & PNG_COMPOSE) == 0) + { + /* Stripping the alpha channel happens immediately after the 'expand' + * transformations, before all other transformation, so it cancels out + * the alpha handling. It has the side effect negating the effect of + * PNG_EXPAND_tRNS too: + */ + png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA | + PNG_EXPAND_tRNS); + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + + /* Kill the tRNS chunk itself too. Prior to 1.5.4 this did not happen + * so transparency information would remain just so long as it wasn't + * expanded. This produces unexpected API changes if the set of things + * that do PNG_EXPAND_tRNS changes (perfectly possible given the + * documentation - which says ask for what you want, accept what you + * get.) This makes the behavior consistent from 1.5.4: + */ + png_ptr->num_trans = 0; + } +#endif /* STRIP_ALPHA supported, no COMPOSE */ + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA + * settings will have no effect. + */ + if (png_gamma_significant(png_ptr->screen_gamma) == 0) + { + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + } +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + /* Make sure the coefficients for the rgb to gray conversion are set + * appropriately. + */ + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) + png_colorspace_set_rgb_coefficients(png_ptr); +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) + /* Detect gray background and attempt to enable optimization for + * gray --> RGB case. + * + * Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or + * RGB_ALPHA (in which case need_expand is superfluous anyway), the + * background color might actually be gray yet not be flagged as such. + * This is not a problem for the current code, which uses + * PNG_BACKGROUND_IS_GRAY only to decide when to do the + * png_do_gray_to_rgb() transformation. + * + * TODO: this code needs to be revised to avoid the complexity and + * interdependencies. The color type of the background should be recorded in + * png_set_background, along with the bit depth, then the code has a record + * of exactly what color space the background is currently in. + */ + if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0) + { + /* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if + * the file was grayscale the background value is gray. + */ + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) + png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; + } + + else if ((png_ptr->transformations & PNG_COMPOSE) != 0) + { + /* PNG_COMPOSE: png_set_background was called with need_expand false, + * so the color is in the color space of the output or png_set_alpha_mode + * was called and the color is black. Ignore RGB_TO_GRAY because that + * happens before GRAY_TO_RGB. + */ + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0) + { + if (png_ptr->background.red == png_ptr->background.green && + png_ptr->background.red == png_ptr->background.blue) + { + png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; + png_ptr->background.gray = png_ptr->background.red; + } + } + } +#endif /* READ_EXPAND && READ_BACKGROUND */ +#endif /* READ_GRAY_TO_RGB */ + + /* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations + * can be performed directly on the palette, and some (such as rgb to gray) + * can be optimized inside the palette. This is particularly true of the + * composite (background and alpha) stuff, which can be pretty much all done + * in the palette even if the result is expanded to RGB or gray afterward. + * + * NOTE: this is Not Yet Implemented, the code behaves as in 1.5.1 and + * earlier and the palette stuff is actually handled on the first row. This + * leads to the reported bug that the palette returned by png_get_PLTE is not + * updated. + */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + png_init_palette_transformations(png_ptr); + + else + png_init_rgb_transformations(png_ptr); + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + defined(PNG_READ_EXPAND_16_SUPPORTED) + if ((png_ptr->transformations & PNG_EXPAND_16) != 0 && + (png_ptr->transformations & PNG_COMPOSE) != 0 && + (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 && + png_ptr->bit_depth != 16) + { + /* TODO: fix this. Because the expand_16 operation is after the compose + * handling the background color must be 8, not 16, bits deep, but the + * application will supply a 16-bit value so reduce it here. + * + * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at + * present, so that case is ok (until do_expand_16 is moved.) + * + * NOTE: this discards the low 16 bits of the user supplied background + * color, but until expand_16 works properly there is no choice! + */ +# define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x)) + CHOP(png_ptr->background.red); + CHOP(png_ptr->background.green); + CHOP(png_ptr->background.blue); + CHOP(png_ptr->background.gray); +# undef CHOP + } +#endif /* READ_BACKGROUND && READ_EXPAND_16 */ + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \ + defined(PNG_READ_STRIP_16_TO_8_SUPPORTED)) + if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) != 0 && + (png_ptr->transformations & PNG_COMPOSE) != 0 && + (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 && + png_ptr->bit_depth == 16) + { + /* On the other hand, if a 16-bit file is to be reduced to 8-bits per + * component this will also happen after PNG_COMPOSE and so the background + * color must be pre-expanded here. + * + * TODO: fix this too. + */ + png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257); + png_ptr->background.green = + (png_uint_16)(png_ptr->background.green * 257); + png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257); + png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257); + } +#endif + + /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the + * background support (see the comments in scripts/pnglibconf.dfa), this + * allows pre-multiplication of the alpha channel to be implemented as + * compositing on black. This is probably sub-optimal and has been done in + * 1.5.4 betas simply to enable external critique and testing (i.e. to + * implement the new API quickly, without lots of internal changes.) + */ + +#ifdef PNG_READ_GAMMA_SUPPORTED +# ifdef PNG_READ_BACKGROUND_SUPPORTED + /* Includes ALPHA_MODE */ + png_ptr->background_1 = png_ptr->background; +# endif + + /* This needs to change - in the palette image case a whole set of tables are + * built when it would be quicker to just calculate the correct value for + * each palette entry directly. Also, the test is too tricky - why check + * PNG_RGB_TO_GRAY if PNG_GAMMA is not set? The answer seems to be that + * PNG_GAMMA is cancelled even if the gamma is known? The test excludes the + * PNG_COMPOSE case, so apparently if there is no *overall* gamma correction + * the gamma tables will not be built even if composition is required on a + * gamma encoded value. + * + * In 1.5.4 this is addressed below by an additional check on the individual + * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the + * tables. + */ + if ((png_ptr->transformations & PNG_GAMMA) != 0 || + ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 && + (png_gamma_significant(png_ptr->colorspace.gamma) != 0 || + png_gamma_significant(png_ptr->screen_gamma) != 0)) || + ((png_ptr->transformations & PNG_COMPOSE) != 0 && + (png_gamma_significant(png_ptr->colorspace.gamma) != 0 || + png_gamma_significant(png_ptr->screen_gamma) != 0 +# ifdef PNG_READ_BACKGROUND_SUPPORTED + || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE && + png_gamma_significant(png_ptr->background_gamma) != 0) +# endif + )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 && + png_gamma_significant(png_ptr->screen_gamma) != 0)) + { + png_build_gamma_table(png_ptr, png_ptr->bit_depth); + +#ifdef PNG_READ_BACKGROUND_SUPPORTED + if ((png_ptr->transformations & PNG_COMPOSE) != 0) + { + /* Issue a warning about this combination: because RGB_TO_GRAY is + * optimized to do the gamma transform if present yet do_background has + * to do the same thing if both options are set a + * double-gamma-correction happens. This is true in all versions of + * libpng to date. + */ + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) + png_warning(png_ptr, + "libpng does not support gamma+background+rgb_to_gray"); + + if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0) + { + /* We don't get to here unless there is a tRNS chunk with non-opaque + * entries - see the checking code at the start of this function. + */ + png_color back, back_1; + png_colorp palette = png_ptr->palette; + int num_palette = png_ptr->num_palette; + int i; + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) + { + + back.red = png_ptr->gamma_table[png_ptr->background.red]; + back.green = png_ptr->gamma_table[png_ptr->background.green]; + back.blue = png_ptr->gamma_table[png_ptr->background.blue]; + + back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; + back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; + back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; + } + else + { + png_fixed_point g, gs; + + switch (png_ptr->background_gamma_type) + { + case PNG_BACKGROUND_GAMMA_SCREEN: + g = (png_ptr->screen_gamma); + gs = PNG_FP_1; + break; + + case PNG_BACKGROUND_GAMMA_FILE: + g = png_reciprocal(png_ptr->colorspace.gamma); + gs = png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma); + break; + + case PNG_BACKGROUND_GAMMA_UNIQUE: + g = png_reciprocal(png_ptr->background_gamma); + gs = png_reciprocal2(png_ptr->background_gamma, + png_ptr->screen_gamma); + break; + default: + g = PNG_FP_1; /* back_1 */ + gs = PNG_FP_1; /* back */ + break; + } + + if (png_gamma_significant(gs) != 0) + { + back.red = png_gamma_8bit_correct(png_ptr->background.red, + gs); + back.green = png_gamma_8bit_correct(png_ptr->background.green, + gs); + back.blue = png_gamma_8bit_correct(png_ptr->background.blue, + gs); + } + + else + { + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + } + + if (png_gamma_significant(g) != 0) + { + back_1.red = png_gamma_8bit_correct(png_ptr->background.red, + g); + back_1.green = png_gamma_8bit_correct( + png_ptr->background.green, g); + back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, + g); + } + + else + { + back_1.red = (png_byte)png_ptr->background.red; + back_1.green = (png_byte)png_ptr->background.green; + back_1.blue = (png_byte)png_ptr->background.blue; + } + } + + for (i = 0; i < num_palette; i++) + { + if (i < (int)png_ptr->num_trans && + png_ptr->trans_alpha[i] != 0xff) + { + if (png_ptr->trans_alpha[i] == 0) + { + palette[i] = back; + } + else /* if (png_ptr->trans_alpha[i] != 0xff) */ + { + png_byte v, w; + + v = png_ptr->gamma_to_1[palette[i].red]; + png_composite(w, v, png_ptr->trans_alpha[i], back_1.red); + palette[i].red = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[palette[i].green]; + png_composite(w, v, png_ptr->trans_alpha[i], back_1.green); + palette[i].green = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[palette[i].blue]; + png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue); + palette[i].blue = png_ptr->gamma_from_1[w]; + } + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + + /* Prevent the transformations being done again. + * + * NOTE: this is highly dubious; it removes the transformations in + * place. This seems inconsistent with the general treatment of the + * transformations elsewhere. + */ + png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA); + } /* color_type == PNG_COLOR_TYPE_PALETTE */ + + /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ + else /* color_type != PNG_COLOR_TYPE_PALETTE */ + { + int gs_sig, g_sig; + png_fixed_point g = PNG_FP_1; /* Correction to linear */ + png_fixed_point gs = PNG_FP_1; /* Correction to screen */ + + switch (png_ptr->background_gamma_type) + { + case PNG_BACKGROUND_GAMMA_SCREEN: + g = png_ptr->screen_gamma; + /* gs = PNG_FP_1; */ + break; + + case PNG_BACKGROUND_GAMMA_FILE: + g = png_reciprocal(png_ptr->colorspace.gamma); + gs = png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma); + break; + + case PNG_BACKGROUND_GAMMA_UNIQUE: + g = png_reciprocal(png_ptr->background_gamma); + gs = png_reciprocal2(png_ptr->background_gamma, + png_ptr->screen_gamma); + break; + + default: + png_error(png_ptr, "invalid background gamma type"); + } + + g_sig = png_gamma_significant(g); + gs_sig = png_gamma_significant(gs); + + if (g_sig != 0) + png_ptr->background_1.gray = png_gamma_correct(png_ptr, + png_ptr->background.gray, g); + + if (gs_sig != 0) + png_ptr->background.gray = png_gamma_correct(png_ptr, + png_ptr->background.gray, gs); + + if ((png_ptr->background.red != png_ptr->background.green) || + (png_ptr->background.red != png_ptr->background.blue) || + (png_ptr->background.red != png_ptr->background.gray)) + { + /* RGB or RGBA with color background */ + if (g_sig != 0) + { + png_ptr->background_1.red = png_gamma_correct(png_ptr, + png_ptr->background.red, g); + + png_ptr->background_1.green = png_gamma_correct(png_ptr, + png_ptr->background.green, g); + + png_ptr->background_1.blue = png_gamma_correct(png_ptr, + png_ptr->background.blue, g); + } + + if (gs_sig != 0) + { + png_ptr->background.red = png_gamma_correct(png_ptr, + png_ptr->background.red, gs); + + png_ptr->background.green = png_gamma_correct(png_ptr, + png_ptr->background.green, gs); + + png_ptr->background.blue = png_gamma_correct(png_ptr, + png_ptr->background.blue, gs); + } + } + + else + { + /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ + png_ptr->background_1.red = png_ptr->background_1.green + = png_ptr->background_1.blue = png_ptr->background_1.gray; + + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + } + + /* The background is now in screen gamma: */ + png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN; + } /* color_type != PNG_COLOR_TYPE_PALETTE */ + }/* png_ptr->transformations & PNG_BACKGROUND */ + + else + /* Transformation does not include PNG_BACKGROUND */ +#endif /* READ_BACKGROUND */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + /* RGB_TO_GRAY needs to have non-gamma-corrected values! */ + && ((png_ptr->transformations & PNG_EXPAND) == 0 || + (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) +#endif + ) + { + png_colorp palette = png_ptr->palette; + int num_palette = png_ptr->num_palette; + int i; + + /* NOTE: there are other transformations that should probably be in + * here too. + */ + for (i = 0; i < num_palette; i++) + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + + /* Done the gamma correction. */ + png_ptr->transformations &= ~PNG_GAMMA; + } /* color_type == PALETTE && !PNG_BACKGROUND transformation */ + } +#ifdef PNG_READ_BACKGROUND_SUPPORTED + else +#endif +#endif /* READ_GAMMA */ + +#ifdef PNG_READ_BACKGROUND_SUPPORTED + /* No GAMMA transformation (see the hanging else 4 lines above) */ + if ((png_ptr->transformations & PNG_COMPOSE) != 0 && + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) + { + int i; + int istop = (int)png_ptr->num_trans; + png_color back; + png_colorp palette = png_ptr->palette; + + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + + for (i = 0; i < istop; i++) + { + if (png_ptr->trans_alpha[i] == 0) + { + palette[i] = back; + } + + else if (png_ptr->trans_alpha[i] != 0xff) + { + /* The png_composite() macro is defined in png.h */ + png_composite(palette[i].red, palette[i].red, + png_ptr->trans_alpha[i], back.red); + + png_composite(palette[i].green, palette[i].green, + png_ptr->trans_alpha[i], back.green); + + png_composite(palette[i].blue, palette[i].blue, + png_ptr->trans_alpha[i], back.blue); + } + } + + png_ptr->transformations &= ~PNG_COMPOSE; + } +#endif /* READ_BACKGROUND */ + +#ifdef PNG_READ_SHIFT_SUPPORTED + if ((png_ptr->transformations & PNG_SHIFT) != 0 && + (png_ptr->transformations & PNG_EXPAND) == 0 && + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) + { + int i; + int istop = png_ptr->num_palette; + int shift = 8 - png_ptr->sig_bit.red; + + png_ptr->transformations &= ~PNG_SHIFT; + + /* significant bits can be in the range 1 to 7 for a meaninful result, if + * the number of significant bits is 0 then no shift is done (this is an + * error condition which is silently ignored.) + */ + if (shift > 0 && shift < 8) + for (i=0; ipalette[i].red; + + component >>= shift; + png_ptr->palette[i].red = (png_byte)component; + } + + shift = 8 - png_ptr->sig_bit.green; + if (shift > 0 && shift < 8) + for (i=0; ipalette[i].green; + + component >>= shift; + png_ptr->palette[i].green = (png_byte)component; + } + + shift = 8 - png_ptr->sig_bit.blue; + if (shift > 0 && shift < 8) + for (i=0; ipalette[i].blue; + + component >>= shift; + png_ptr->palette[i].blue = (png_byte)component; + } + } +#endif /* READ_SHIFT */ +} + +/* Modify the info structure to reflect the transformations. The + * info should be updated so a PNG file could be written with it, + * assuming the transformations result in valid PNG data. + */ +void /* PRIVATE */ +png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) +{ + png_debug(1, "in png_read_transform_info"); + +#ifdef PNG_READ_EXPAND_SUPPORTED + if ((png_ptr->transformations & PNG_EXPAND) != 0) + { + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + /* This check must match what actually happens in + * png_do_expand_palette; if it ever checks the tRNS chunk to see if + * it is all opaque we must do the same (at present it does not.) + */ + if (png_ptr->num_trans > 0) + info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; + + else + info_ptr->color_type = PNG_COLOR_TYPE_RGB; + + info_ptr->bit_depth = 8; + info_ptr->num_trans = 0; + + if (png_ptr->palette == NULL) + png_error (png_ptr, "Palette is NULL in indexed image"); + } + else + { + if (png_ptr->num_trans != 0) + { + if ((png_ptr->transformations & PNG_EXPAND_tRNS) != 0) + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; + } + if (info_ptr->bit_depth < 8) + info_ptr->bit_depth = 8; + + info_ptr->num_trans = 0; + } + } +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + /* The following is almost certainly wrong unless the background value is in + * the screen space! + */ + if ((png_ptr->transformations & PNG_COMPOSE) != 0) + info_ptr->background = png_ptr->background; +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED + /* The following used to be conditional on PNG_GAMMA (prior to 1.5.4), + * however it seems that the code in png_init_read_transformations, which has + * been called before this from png_read_update_info->png_read_start_row + * sometimes does the gamma transform and cancels the flag. + * + * TODO: this looks wrong; the info_ptr should end up with a gamma equal to + * the screen_gamma value. The following probably results in weirdness if + * the info_ptr is used by the app after the rows have been read. + */ + info_ptr->colorspace.gamma = png_ptr->colorspace.gamma; +#endif + + if (info_ptr->bit_depth == 16) + { +# ifdef PNG_READ_16BIT_SUPPORTED +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0) + info_ptr->bit_depth = 8; +# endif + +# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + if ((png_ptr->transformations & PNG_16_TO_8) != 0) + info_ptr->bit_depth = 8; +# endif + +# else + /* No 16-bit support: force chopping 16-bit input down to 8, in this case + * the app program can chose if both APIs are available by setting the + * correct scaling to use. + */ +# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + /* For compatibility with previous versions use the strip method by + * default. This code works because if PNG_SCALE_16_TO_8 is already + * set the code below will do that in preference to the chop. + */ + png_ptr->transformations |= PNG_16_TO_8; + info_ptr->bit_depth = 8; +# else + +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_ptr->transformations |= PNG_SCALE_16_TO_8; + info_ptr->bit_depth = 8; +# else + + CONFIGURATION ERROR: you must enable at least one 16 to 8 method +# endif +# endif +#endif /* !READ_16BIT */ + } + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0) + info_ptr->color_type = (png_byte)(info_ptr->color_type | + PNG_COLOR_MASK_COLOR); +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) + info_ptr->color_type = (png_byte)(info_ptr->color_type & + ~PNG_COLOR_MASK_COLOR); +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED + if ((png_ptr->transformations & PNG_QUANTIZE) != 0) + { + if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || + (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && + png_ptr->palette_lookup != 0 && info_ptr->bit_depth == 8) + { + info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; + } + } +#endif + +#ifdef PNG_READ_EXPAND_16_SUPPORTED + if ((png_ptr->transformations & PNG_EXPAND_16) != 0 && + info_ptr->bit_depth == 8 && + info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) + { + info_ptr->bit_depth = 16; + } +#endif + +#ifdef PNG_READ_PACK_SUPPORTED + if ((png_ptr->transformations & PNG_PACK) != 0 && + (info_ptr->bit_depth < 8)) + info_ptr->bit_depth = 8; +#endif + + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + info_ptr->channels = 1; + + else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + info_ptr->channels = 3; + + else + info_ptr->channels = 1; + +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0) + { + info_ptr->color_type = (png_byte)(info_ptr->color_type & + ~PNG_COLOR_MASK_ALPHA); + info_ptr->num_trans = 0; + } +#endif + + if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) + info_ptr->channels++; + +#ifdef PNG_READ_FILLER_SUPPORTED + /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ + if ((png_ptr->transformations & PNG_FILLER) != 0 && + (info_ptr->color_type == PNG_COLOR_TYPE_RGB || + info_ptr->color_type == PNG_COLOR_TYPE_GRAY)) + { + info_ptr->channels++; + /* If adding a true alpha channel not just filler */ + if ((png_ptr->transformations & PNG_ADD_ALPHA) != 0) + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; + } +#endif + +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ +defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) + { + if (png_ptr->user_transform_depth != 0) + info_ptr->bit_depth = png_ptr->user_transform_depth; + + if (png_ptr->user_transform_channels != 0) + info_ptr->channels = png_ptr->user_transform_channels; + } +#endif + + info_ptr->pixel_depth = (png_byte)(info_ptr->channels * + info_ptr->bit_depth); + + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width); + + /* Adding in 1.5.4: cache the above value in png_struct so that we can later + * check in png_rowbytes that the user buffer won't get overwritten. Note + * that the field is not always set - if png_read_update_info isn't called + * the application has to either not do any transforms or get the calculation + * right itself. + */ + png_ptr->info_rowbytes = info_ptr->rowbytes; + +#ifndef PNG_READ_EXPAND_SUPPORTED + if (png_ptr != NULL) + return; +#endif +} + +#ifdef PNG_READ_PACK_SUPPORTED +/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, + * without changing the actual values. Thus, if you had a row with + * a bit depth of 1, you would end up with bytes that only contained + * the numbers 0 or 1. If you would rather they contain 0 and 255, use + * png_do_shift() after this. + */ +static void +png_do_unpack(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_unpack"); + + if (row_info->bit_depth < 8) + { + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + switch (row_info->bit_depth) + { + case 1: + { + png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = 7U - ((row_width + 7U) & 0x07); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x01); + + if (shift == 7) + { + shift = 0; + sp--; + } + + else + shift++; + + dp--; + } + break; + } + + case 2: + { + + png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x03); + + if (shift == 6) + { + shift = 0; + sp--; + } + + else + shift += 2; + + dp--; + } + break; + } + + case 4: + { + png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x0f); + + if (shift == 4) + { + shift = 0; + sp--; + } + + else + shift = 4; + + dp--; + } + break; + } + + default: + break; + } + row_info->bit_depth = 8; + row_info->pixel_depth = (png_byte)(8 * row_info->channels); + row_info->rowbytes = row_width * row_info->channels; + } +} +#endif + +#ifdef PNG_READ_SHIFT_SUPPORTED +/* Reverse the effects of png_do_shift. This routine merely shifts the + * pixels back to their significant bits values. Thus, if you have + * a row of bit depth 8, but only 5 are significant, this will shift + * the values back to 0 through 31. + */ +static void +png_do_unshift(png_row_infop row_info, png_bytep row, + png_const_color_8p sig_bits) +{ + int color_type; + + png_debug(1, "in png_do_unshift"); + + /* The palette case has already been handled in the _init routine. */ + color_type = row_info->color_type; + + if (color_type != PNG_COLOR_TYPE_PALETTE) + { + int shift[4]; + int channels = 0; + int bit_depth = row_info->bit_depth; + + if ((color_type & PNG_COLOR_MASK_COLOR) != 0) + { + shift[channels++] = bit_depth - sig_bits->red; + shift[channels++] = bit_depth - sig_bits->green; + shift[channels++] = bit_depth - sig_bits->blue; + } + + else + { + shift[channels++] = bit_depth - sig_bits->gray; + } + + if ((color_type & PNG_COLOR_MASK_ALPHA) != 0) + { + shift[channels++] = bit_depth - sig_bits->alpha; + } + + { + int c, have_shift; + + for (c = have_shift = 0; c < channels; ++c) + { + /* A shift of more than the bit depth is an error condition but it + * gets ignored here. + */ + if (shift[c] <= 0 || shift[c] >= bit_depth) + shift[c] = 0; + + else + have_shift = 1; + } + + if (have_shift == 0) + return; + } + + switch (bit_depth) + { + default: + /* Must be 1bpp gray: should not be here! */ + /* NOTREACHED */ + break; + + case 2: + /* Must be 2bpp gray */ + /* assert(channels == 1 && shift[0] == 1) */ + { + png_bytep bp = row; + png_bytep bp_end = bp + row_info->rowbytes; + + while (bp < bp_end) + { + int b = (*bp >> 1) & 0x55; + *bp++ = (png_byte)b; + } + break; + } + + case 4: + /* Must be 4bpp gray */ + /* assert(channels == 1) */ + { + png_bytep bp = row; + png_bytep bp_end = bp + row_info->rowbytes; + int gray_shift = shift[0]; + int mask = 0xf >> gray_shift; + + mask |= mask << 4; + + while (bp < bp_end) + { + int b = (*bp >> gray_shift) & mask; + *bp++ = (png_byte)b; + } + break; + } + + case 8: + /* Single byte components, G, GA, RGB, RGBA */ + { + png_bytep bp = row; + png_bytep bp_end = bp + row_info->rowbytes; + int channel = 0; + + while (bp < bp_end) + { + int b = *bp >> shift[channel]; + if (++channel >= channels) + channel = 0; + *bp++ = (png_byte)b; + } + break; + } + +#ifdef PNG_READ_16BIT_SUPPORTED + case 16: + /* Double byte components, G, GA, RGB, RGBA */ + { + png_bytep bp = row; + png_bytep bp_end = bp + row_info->rowbytes; + int channel = 0; + + while (bp < bp_end) + { + int value = (bp[0] << 8) + bp[1]; + + value >>= shift[channel]; + if (++channel >= channels) + channel = 0; + *bp++ = (png_byte)(value >> 8); + *bp++ = (png_byte)value; + } + break; + } +#endif + } + } +} +#endif + +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +/* Scale rows of bit depth 16 down to 8 accurately */ +static void +png_do_scale_16_to_8(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_scale_16_to_8"); + + if (row_info->bit_depth == 16) + { + png_bytep sp = row; /* source */ + png_bytep dp = row; /* destination */ + png_bytep ep = sp + row_info->rowbytes; /* end+1 */ + + while (sp < ep) + { + /* The input is an array of 16-bit components, these must be scaled to + * 8 bits each. For a 16-bit value V the required value (from the PNG + * specification) is: + * + * (V * 255) / 65535 + * + * This reduces to round(V / 257), or floor((V + 128.5)/257) + * + * Represent V as the two byte value vhi.vlo. Make a guess that the + * result is the top byte of V, vhi, then the correction to this value + * is: + * + * error = floor(((V-vhi.vhi) + 128.5) / 257) + * = floor(((vlo-vhi) + 128.5) / 257) + * + * This can be approximated using integer arithmetic (and a signed + * shift): + * + * error = (vlo-vhi+128) >> 8; + * + * The approximate differs from the exact answer only when (vlo-vhi) is + * 128; it then gives a correction of +1 when the exact correction is + * 0. This gives 128 errors. The exact answer (correct for all 16-bit + * input values) is: + * + * error = (vlo-vhi+128)*65535 >> 24; + * + * An alternative arithmetic calculation which also gives no errors is: + * + * (V * 255 + 32895) >> 16 + */ + + png_int_32 tmp = *sp++; /* must be signed! */ + tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24; + *dp++ = (png_byte)tmp; + } + + row_info->bit_depth = 8; + row_info->pixel_depth = (png_byte)(8 * row_info->channels); + row_info->rowbytes = row_info->width * row_info->channels; + } +} +#endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED +static void +/* Simply discard the low byte. This was the default behavior prior + * to libpng-1.5.4. + */ +png_do_chop(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_chop"); + + if (row_info->bit_depth == 16) + { + png_bytep sp = row; /* source */ + png_bytep dp = row; /* destination */ + png_bytep ep = sp + row_info->rowbytes; /* end+1 */ + + while (sp < ep) + { + *dp++ = *sp; + sp += 2; /* skip low byte */ + } + + row_info->bit_depth = 8; + row_info->pixel_depth = (png_byte)(8 * row_info->channels); + row_info->rowbytes = row_info->width * row_info->channels; + } +} +#endif + +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED +static void +png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_swap_alpha"); + + { + png_uint_32 row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + /* This converts from RGBA to ARGB */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save; + } + } + +#ifdef PNG_READ_16BIT_SUPPORTED + /* This converts from RRGGBBAA to AARRGGBB */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save[2]; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save[0] = *(--sp); + save[1] = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save[0]; + *(--dp) = save[1]; + } + } +#endif + } + + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + /* This converts from GA to AG */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save; + } + } + +#ifdef PNG_READ_16BIT_SUPPORTED + /* This converts from GGAA to AAGG */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save[2]; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save[0] = *(--sp); + save[1] = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save[0]; + *(--dp) = save[1]; + } + } +#endif + } + } +} +#endif + +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED +static void +png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) +{ + png_uint_32 row_width; + png_debug(1, "in png_do_read_invert_alpha"); + + row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + if (row_info->bit_depth == 8) + { + /* This inverts the alpha channel in RGBA */ + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: +*/ + sp-=3; + dp=sp; + } + } + +#ifdef PNG_READ_16BIT_SUPPORTED + /* This inverts the alpha channel in RRGGBBAA */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: +*/ + sp-=6; + dp=sp; + } + } +#endif + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (row_info->bit_depth == 8) + { + /* This inverts the alpha channel in GA */ + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = *(--sp); + } + } + +#ifdef PNG_READ_16BIT_SUPPORTED + else + { + /* This inverts the alpha channel in GGAA */ + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); +/* + *(--dp) = *(--sp); + *(--dp) = *(--sp); +*/ + sp-=2; + dp=sp; + } + } +#endif + } +} +#endif + +#ifdef PNG_READ_FILLER_SUPPORTED +/* Add filler channel if we have RGB color */ +static void +png_do_read_filler(png_row_infop row_info, png_bytep row, + png_uint_32 filler, png_uint_32 flags) +{ + png_uint_32 i; + png_uint_32 row_width = row_info->width; + +#ifdef PNG_READ_16BIT_SUPPORTED + png_byte hi_filler = (png_byte)(filler>>8); +#endif + png_byte lo_filler = (png_byte)filler; + + png_debug(1, "in png_do_read_filler"); + + if ( + row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + if (row_info->bit_depth == 8) + { + if ((flags & PNG_FLAG_FILLER_AFTER) != 0) + { + /* This changes the data from G to GX */ + png_bytep sp = row + (png_size_t)row_width; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 1; i < row_width; i++) + { + *(--dp) = lo_filler; + *(--dp) = *(--sp); + } + *(--dp) = lo_filler; + row_info->channels = 2; + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + + else + { + /* This changes the data from G to XG */ + png_bytep sp = row + (png_size_t)row_width; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = lo_filler; + } + row_info->channels = 2; + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + } + +#ifdef PNG_READ_16BIT_SUPPORTED + else if (row_info->bit_depth == 16) + { + if ((flags & PNG_FLAG_FILLER_AFTER) != 0) + { + /* This changes the data from GG to GGXX */ + png_bytep sp = row + (png_size_t)row_width * 2; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 1; i < row_width; i++) + { + *(--dp) = lo_filler; + *(--dp) = hi_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = lo_filler; + *(--dp) = hi_filler; + row_info->channels = 2; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + + else + { + /* This changes the data from GG to XXGG */ + png_bytep sp = row + (png_size_t)row_width * 2; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = lo_filler; + *(--dp) = hi_filler; + } + row_info->channels = 2; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + } +#endif + } /* COLOR_TYPE == GRAY */ + else if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + if (row_info->bit_depth == 8) + { + if ((flags & PNG_FLAG_FILLER_AFTER) != 0) + { + /* This changes the data from RGB to RGBX */ + png_bytep sp = row + (png_size_t)row_width * 3; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 1; i < row_width; i++) + { + *(--dp) = lo_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = lo_filler; + row_info->channels = 4; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + + else + { + /* This changes the data from RGB to XRGB */ + png_bytep sp = row + (png_size_t)row_width * 3; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = lo_filler; + } + row_info->channels = 4; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + } + +#ifdef PNG_READ_16BIT_SUPPORTED + else if (row_info->bit_depth == 16) + { + if ((flags & PNG_FLAG_FILLER_AFTER) != 0) + { + /* This changes the data from RRGGBB to RRGGBBXX */ + png_bytep sp = row + (png_size_t)row_width * 6; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 1; i < row_width; i++) + { + *(--dp) = lo_filler; + *(--dp) = hi_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = lo_filler; + *(--dp) = hi_filler; + row_info->channels = 4; + row_info->pixel_depth = 64; + row_info->rowbytes = row_width * 8; + } + + else + { + /* This changes the data from RRGGBB to XXRRGGBB */ + png_bytep sp = row + (png_size_t)row_width * 6; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = lo_filler; + *(--dp) = hi_filler; + } + + row_info->channels = 4; + row_info->pixel_depth = 64; + row_info->rowbytes = row_width * 8; + } + } +#endif + } /* COLOR_TYPE == RGB */ +} +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +/* Expand grayscale files to RGB, with or without alpha */ +static void +png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) +{ + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + png_debug(1, "in png_do_gray_to_rgb"); + + if (row_info->bit_depth >= 8 && + (row_info->color_type & PNG_COLOR_MASK_COLOR) == 0) + { + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + if (row_info->bit_depth == 8) + { + /* This changes G to RGB */ + png_bytep sp = row + (png_size_t)row_width - 1; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(dp--) = *sp; + *(dp--) = *sp; + *(dp--) = *(sp--); + } + } + + else + { + /* This changes GG to RRGGBB */ + png_bytep sp = row + (png_size_t)row_width * 2 - 1; + png_bytep dp = sp + (png_size_t)row_width * 4; + for (i = 0; i < row_width; i++) + { + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *(sp--); + *(dp--) = *(sp--); + } + } + } + + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (row_info->bit_depth == 8) + { + /* This changes GA to RGBA */ + png_bytep sp = row + (png_size_t)row_width * 2 - 1; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(dp--) = *(sp--); + *(dp--) = *sp; + *(dp--) = *sp; + *(dp--) = *(sp--); + } + } + + else + { + /* This changes GGAA to RRGGBBAA */ + png_bytep sp = row + (png_size_t)row_width * 4 - 1; + png_bytep dp = sp + (png_size_t)row_width * 4; + for (i = 0; i < row_width; i++) + { + *(dp--) = *(sp--); + *(dp--) = *(sp--); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *(sp--); + *(dp--) = *(sp--); + } + } + } + row_info->channels = (png_byte)(row_info->channels + 2); + row_info->color_type |= PNG_COLOR_MASK_COLOR; + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + } +} +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +/* Reduce RGB files to grayscale, with or without alpha + * using the equation given in Poynton's ColorFAQ of 1998-01-04 at + * (THIS LINK IS DEAD June 2008 but + * versions dated 1998 through November 2002 have been archived at + * https://web.archive.org/web/20000816232553/www.inforamp.net/ + * ~poynton/notes/colour_and_gamma/ColorFAQ.txt ) + * Charles Poynton poynton at poynton.com + * + * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + * + * which can be expressed with integers as + * + * Y = (6969 * R + 23434 * G + 2365 * B)/32768 + * + * Poynton's current link (as of January 2003 through July 2011): + * + * has changed the numbers slightly: + * + * Y = 0.2126*R + 0.7152*G + 0.0722*B + * + * which can be expressed with integers as + * + * Y = (6966 * R + 23436 * G + 2366 * B)/32768 + * + * Historically, however, libpng uses numbers derived from the ITU-R Rec 709 + * end point chromaticities and the D65 white point. Depending on the + * precision used for the D65 white point this produces a variety of different + * numbers, however if the four decimal place value used in ITU-R Rec 709 is + * used (0.3127,0.3290) the Y calculation would be: + * + * Y = (6968 * R + 23435 * G + 2366 * B)/32768 + * + * While this is correct the rounding results in an overflow for white, because + * the sum of the rounded coefficients is 32769, not 32768. Consequently + * libpng uses, instead, the closest non-overflowing approximation: + * + * Y = (6968 * R + 23434 * G + 2366 * B)/32768 + * + * Starting with libpng-1.5.5, if the image being converted has a cHRM chunk + * (including an sRGB chunk) then the chromaticities are used to calculate the + * coefficients. See the chunk handling in pngrutil.c for more information. + * + * In all cases the calculation is to be done in a linear colorspace. If no + * gamma information is available to correct the encoding of the original RGB + * values this results in an implicit assumption that the original PNG RGB + * values were linear. + * + * Other integer coefficents can be used via png_set_rgb_to_gray(). Because + * the API takes just red and green coefficients the blue coefficient is + * calculated to make the sum 32768. This will result in different rounding + * to that used above. + */ +static int +png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) + +{ + int rgb_error = 0; + + png_debug(1, "in png_do_rgb_to_gray"); + + if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 && + (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; + PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; + PNG_CONST png_uint_32 bc = 32768 - rc - gc; + PNG_CONST png_uint_32 row_width = row_info->width; + PNG_CONST int have_alpha = + (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0; + + if (row_info->bit_depth == 8) + { +#ifdef PNG_READ_GAMMA_SUPPORTED + /* Notice that gamma to/from 1 are not necessarily inverses (if + * there is an overall gamma correction). Prior to 1.5.5 this code + * checked the linearized values for equality; this doesn't match + * the documentation, the original values must be checked. + */ + if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + + if (red != green || red != blue) + { + red = png_ptr->gamma_to_1[red]; + green = png_ptr->gamma_to_1[green]; + blue = png_ptr->gamma_to_1[blue]; + + rgb_error |= 1; + *(dp++) = png_ptr->gamma_from_1[ + (rc*red + gc*green + bc*blue + 16384)>>15]; + } + + else + { + /* If there is no overall correction the table will not be + * set. + */ + if (png_ptr->gamma_table != NULL) + red = png_ptr->gamma_table[red]; + + *(dp++) = red; + } + + if (have_alpha != 0) + *(dp++) = *(sp++); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + + if (red != green || red != blue) + { + rgb_error |= 1; + /* NOTE: this is the historical approach which simply + * truncates the results. + */ + *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); + } + + else + *(dp++) = red; + + if (have_alpha != 0) + *(dp++) = *(sp++); + } + } + } + + else /* RGB bit_depth == 16 */ + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, w; + png_byte hi,lo; + + hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo)); + + if (red == green && red == blue) + { + if (png_ptr->gamma_16_table != NULL) + w = png_ptr->gamma_16_table[(red & 0xff) + >> png_ptr->gamma_shift][red >> 8]; + + else + w = red; + } + + else + { + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red & 0xff) + >> png_ptr->gamma_shift][red>>8]; + png_uint_16 green_1 = + png_ptr->gamma_16_to_1[(green & 0xff) >> + png_ptr->gamma_shift][green>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue & 0xff) + >> png_ptr->gamma_shift][blue>>8]; + png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 + + bc*blue_1 + 16384)>>15); + w = png_ptr->gamma_16_from_1[(gray16 & 0xff) >> + png_ptr->gamma_shift][gray16 >> 8]; + rgb_error |= 1; + } + + *(dp++) = (png_byte)((w>>8) & 0xff); + *(dp++) = (png_byte)(w & 0xff); + + if (have_alpha != 0) + { + *(dp++) = *(sp++); + *(dp++) = *(sp++); + } + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, gray16; + png_byte hi,lo; + + hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo)); + + if (red != green || red != blue) + rgb_error |= 1; + + /* From 1.5.5 in the 16-bit case do the accurate conversion even + * in the 'fast' case - this is because this is where the code + * ends up when handling linear 16-bit data. + */ + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >> + 15); + *(dp++) = (png_byte)((gray16 >> 8) & 0xff); + *(dp++) = (png_byte)(gray16 & 0xff); + + if (have_alpha != 0) + { + *(dp++) = *(sp++); + *(dp++) = *(sp++); + } + } + } + } + + row_info->channels = (png_byte)(row_info->channels - 2); + row_info->color_type = (png_byte)(row_info->color_type & + ~PNG_COLOR_MASK_COLOR); + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + } + return rgb_error; +} +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) +/* Replace any alpha or transparency with the supplied background color. + * "background" is already in the screen gamma, while "background_1" is + * at a gamma of 1.0. Paletted files have already been taken care of. + */ +static void +png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) +{ +#ifdef PNG_READ_GAMMA_SUPPORTED + png_const_bytep gamma_table = png_ptr->gamma_table; + png_const_bytep gamma_from_1 = png_ptr->gamma_from_1; + png_const_bytep gamma_to_1 = png_ptr->gamma_to_1; + png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table; + png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1; + png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1; + int gamma_shift = png_ptr->gamma_shift; + int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0; +#endif + + png_bytep sp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + int shift; + + png_debug(1, "in png_do_compose"); + + { + switch (row_info->color_type) + { + case PNG_COLOR_TYPE_GRAY: + { + switch (row_info->bit_depth) + { + case 1: + { + sp = row; + shift = 7; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x01) + == png_ptr->trans_color.gray) + { + unsigned int tmp = *sp & (0x7f7f >> (7 - shift)); + tmp |= + (unsigned int)(png_ptr->background.gray << shift); + *sp = (png_byte)(tmp & 0xff); + } + + if (shift == 0) + { + shift = 7; + sp++; + } + + else + shift--; + } + break; + } + + case 2: + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_table != NULL) + { + sp = row; + shift = 6; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x03) + == png_ptr->trans_color.gray) + { + unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); + tmp |= + (unsigned int)png_ptr->background.gray << shift; + *sp = (png_byte)(tmp & 0xff); + } + + else + { + unsigned int p = (*sp >> shift) & 0x03; + unsigned int g = (gamma_table [p | (p << 2) | + (p << 4) | (p << 6)] >> 6) & 0x03; + unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); + tmp |= (unsigned int)(g << shift); + *sp = (png_byte)(tmp & 0xff); + } + + if (shift == 0) + { + shift = 6; + sp++; + } + + else + shift -= 2; + } + } + + else +#endif + { + sp = row; + shift = 6; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x03) + == png_ptr->trans_color.gray) + { + unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); + tmp |= + (unsigned int)png_ptr->background.gray << shift; + *sp = (png_byte)(tmp & 0xff); + } + + if (shift == 0) + { + shift = 6; + sp++; + } + + else + shift -= 2; + } + } + break; + } + + case 4: + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_table != NULL) + { + sp = row; + shift = 4; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x0f) + == png_ptr->trans_color.gray) + { + unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); + tmp |= + (unsigned int)(png_ptr->background.gray << shift); + *sp = (png_byte)(tmp & 0xff); + } + + else + { + unsigned int p = (*sp >> shift) & 0x0f; + unsigned int g = (gamma_table[p | (p << 4)] >> 4) & + 0x0f; + unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); + tmp |= (unsigned int)(g << shift); + *sp = (png_byte)(tmp & 0xff); + } + + if (shift == 0) + { + shift = 4; + sp++; + } + + else + shift -= 4; + } + } + + else +#endif + { + sp = row; + shift = 4; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x0f) + == png_ptr->trans_color.gray) + { + unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); + tmp |= + (unsigned int)(png_ptr->background.gray << shift); + *sp = (png_byte)(tmp & 0xff); + } + + if (shift == 0) + { + shift = 4; + sp++; + } + + else + shift -= 4; + } + } + break; + } + + case 8: + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_table != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp++) + { + if (*sp == png_ptr->trans_color.gray) + *sp = (png_byte)png_ptr->background.gray; + + else + *sp = gamma_table[*sp]; + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp++) + { + if (*sp == png_ptr->trans_color.gray) + *sp = (png_byte)png_ptr->background.gray; + } + } + break; + } + + case 16: + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_16 != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 2) + { + png_uint_16 v; + + v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + + if (v == png_ptr->trans_color.gray) + { + /* Background is already in screen gamma */ + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray + & 0xff); + } + + else + { + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 2) + { + png_uint_16 v; + + v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + + if (v == png_ptr->trans_color.gray) + { + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray + & 0xff); + } + } + } + break; + } + + default: + break; + } + break; + } + + case PNG_COLOR_TYPE_RGB: + { + if (row_info->bit_depth == 8) + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_table != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 3) + { + if (*sp == png_ptr->trans_color.red && + *(sp + 1) == png_ptr->trans_color.green && + *(sp + 2) == png_ptr->trans_color.blue) + { + *sp = (png_byte)png_ptr->background.red; + *(sp + 1) = (png_byte)png_ptr->background.green; + *(sp + 2) = (png_byte)png_ptr->background.blue; + } + + else + { + *sp = gamma_table[*sp]; + *(sp + 1) = gamma_table[*(sp + 1)]; + *(sp + 2) = gamma_table[*(sp + 2)]; + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 3) + { + if (*sp == png_ptr->trans_color.red && + *(sp + 1) == png_ptr->trans_color.green && + *(sp + 2) == png_ptr->trans_color.blue) + { + *sp = (png_byte)png_ptr->background.red; + *(sp + 1) = (png_byte)png_ptr->background.green; + *(sp + 2) = (png_byte)png_ptr->background.blue; + } + } + } + } + else /* if (row_info->bit_depth == 16) */ + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_16 != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 6) + { + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + + png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + + png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + + *(sp + 5)); + + if (r == png_ptr->trans_color.red && + g == png_ptr->trans_color.green && + b == png_ptr->trans_color.blue) + { + /* Background is already in screen gamma */ + *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); + *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); + } + + else + { + png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + + v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; + *(sp + 2) = (png_byte)((v >> 8) & 0xff); + *(sp + 3) = (png_byte)(v & 0xff); + + v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; + *(sp + 4) = (png_byte)((v >> 8) & 0xff); + *(sp + 5) = (png_byte)(v & 0xff); + } + } + } + + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 6) + { + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + + png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + + png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + + *(sp + 5)); + + if (r == png_ptr->trans_color.red && + g == png_ptr->trans_color.green && + b == png_ptr->trans_color.blue) + { + *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); + *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); + } + } + } + } + break; + } + + case PNG_COLOR_TYPE_GRAY_ALPHA: + { + if (row_info->bit_depth == 8) + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_to_1 != NULL && gamma_from_1 != NULL && + gamma_table != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 2) + { + png_uint_16 a = *(sp + 1); + + if (a == 0xff) + *sp = gamma_table[*sp]; + + else if (a == 0) + { + /* Background is already in screen gamma */ + *sp = (png_byte)png_ptr->background.gray; + } + + else + { + png_byte v, w; + + v = gamma_to_1[*sp]; + png_composite(w, v, a, png_ptr->background_1.gray); + if (optimize == 0) + w = gamma_from_1[w]; + *sp = w; + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 2) + { + png_byte a = *(sp + 1); + + if (a == 0) + *sp = (png_byte)png_ptr->background.gray; + + else if (a < 0xff) + png_composite(*sp, *sp, a, png_ptr->background.gray); + } + } + } + else /* if (png_ptr->bit_depth == 16) */ + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_16 != NULL && gamma_16_from_1 != NULL && + gamma_16_to_1 != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 4) + { + png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + + if (a == (png_uint_16)0xffff) + { + png_uint_16 v; + + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + } + + else if (a == 0) + { + /* Background is already in screen gamma */ + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); + } + + else + { + png_uint_16 g, v, w; + + g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; + png_composite_16(v, g, a, png_ptr->background_1.gray); + if (optimize != 0) + w = v; + else + w = gamma_16_from_1[(v & 0xff) >> + gamma_shift][v >> 8]; + *sp = (png_byte)((w >> 8) & 0xff); + *(sp + 1) = (png_byte)(w & 0xff); + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 4) + { + png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + + if (a == 0) + { + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); + } + + else if (a < 0xffff) + { + png_uint_16 g, v; + + g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_composite_16(v, g, a, png_ptr->background.gray); + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + } + } + } + } + break; + } + + case PNG_COLOR_TYPE_RGB_ALPHA: + { + if (row_info->bit_depth == 8) + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_to_1 != NULL && gamma_from_1 != NULL && + gamma_table != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 4) + { + png_byte a = *(sp + 3); + + if (a == 0xff) + { + *sp = gamma_table[*sp]; + *(sp + 1) = gamma_table[*(sp + 1)]; + *(sp + 2) = gamma_table[*(sp + 2)]; + } + + else if (a == 0) + { + /* Background is already in screen gamma */ + *sp = (png_byte)png_ptr->background.red; + *(sp + 1) = (png_byte)png_ptr->background.green; + *(sp + 2) = (png_byte)png_ptr->background.blue; + } + + else + { + png_byte v, w; + + v = gamma_to_1[*sp]; + png_composite(w, v, a, png_ptr->background_1.red); + if (optimize == 0) w = gamma_from_1[w]; + *sp = w; + + v = gamma_to_1[*(sp + 1)]; + png_composite(w, v, a, png_ptr->background_1.green); + if (optimize == 0) w = gamma_from_1[w]; + *(sp + 1) = w; + + v = gamma_to_1[*(sp + 2)]; + png_composite(w, v, a, png_ptr->background_1.blue); + if (optimize == 0) w = gamma_from_1[w]; + *(sp + 2) = w; + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 4) + { + png_byte a = *(sp + 3); + + if (a == 0) + { + *sp = (png_byte)png_ptr->background.red; + *(sp + 1) = (png_byte)png_ptr->background.green; + *(sp + 2) = (png_byte)png_ptr->background.blue; + } + + else if (a < 0xff) + { + png_composite(*sp, *sp, a, png_ptr->background.red); + + png_composite(*(sp + 1), *(sp + 1), a, + png_ptr->background.green); + + png_composite(*(sp + 2), *(sp + 2), a, + png_ptr->background.blue); + } + } + } + } + else /* if (row_info->bit_depth == 16) */ + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (gamma_16 != NULL && gamma_16_from_1 != NULL && + gamma_16_to_1 != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 8) + { + png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) + << 8) + (png_uint_16)(*(sp + 7))); + + if (a == (png_uint_16)0xffff) + { + png_uint_16 v; + + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + + v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; + *(sp + 2) = (png_byte)((v >> 8) & 0xff); + *(sp + 3) = (png_byte)(v & 0xff); + + v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; + *(sp + 4) = (png_byte)((v >> 8) & 0xff); + *(sp + 5) = (png_byte)(v & 0xff); + } + + else if (a == 0) + { + /* Background is already in screen gamma */ + *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); + *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); + } + + else + { + png_uint_16 v, w; + + v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; + png_composite_16(w, v, a, png_ptr->background_1.red); + if (optimize == 0) + w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> + 8]; + *sp = (png_byte)((w >> 8) & 0xff); + *(sp + 1) = (png_byte)(w & 0xff); + + v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; + png_composite_16(w, v, a, png_ptr->background_1.green); + if (optimize == 0) + w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> + 8]; + + *(sp + 2) = (png_byte)((w >> 8) & 0xff); + *(sp + 3) = (png_byte)(w & 0xff); + + v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; + png_composite_16(w, v, a, png_ptr->background_1.blue); + if (optimize == 0) + w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> + 8]; + + *(sp + 4) = (png_byte)((w >> 8) & 0xff); + *(sp + 5) = (png_byte)(w & 0xff); + } + } + } + + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 8) + { + png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) + << 8) + (png_uint_16)(*(sp + 7))); + + if (a == 0) + { + *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); + *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); + } + + else if (a < 0xffff) + { + png_uint_16 v; + + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + + *(sp + 5)); + + png_composite_16(v, r, a, png_ptr->background.red); + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + + png_composite_16(v, g, a, png_ptr->background.green); + *(sp + 2) = (png_byte)((v >> 8) & 0xff); + *(sp + 3) = (png_byte)(v & 0xff); + + png_composite_16(v, b, a, png_ptr->background.blue); + *(sp + 4) = (png_byte)((v >> 8) & 0xff); + *(sp + 5) = (png_byte)(v & 0xff); + } + } + } + } + break; + } + + default: + break; + } + } +} +#endif /* READ_BACKGROUND || READ_ALPHA_MODE */ + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* Gamma correct the image, avoiding the alpha channel. Make sure + * you do this after you deal with the transparency issue on grayscale + * or RGB images. If your bit depth is 8, use gamma_table, if it + * is 16, use gamma_16_table and gamma_shift. Build these with + * build_gamma_table(). + */ +static void +png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) +{ + png_const_bytep gamma_table = png_ptr->gamma_table; + png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table; + int gamma_shift = png_ptr->gamma_shift; + + png_bytep sp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_gamma"); + + if (((row_info->bit_depth <= 8 && gamma_table != NULL) || + (row_info->bit_depth == 16 && gamma_16_table != NULL))) + { + switch (row_info->color_type) + { + case PNG_COLOR_TYPE_RGB: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + } + } + + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + } + } + break; + } + + case PNG_COLOR_TYPE_RGB_ALPHA: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + + *sp = gamma_table[*sp]; + sp++; + + *sp = gamma_table[*sp]; + sp++; + + sp++; + } + } + + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 4; + } + } + break; + } + + case PNG_COLOR_TYPE_GRAY_ALPHA: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp += 2; + } + } + + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 4; + } + } + break; + } + + case PNG_COLOR_TYPE_GRAY: + { + if (row_info->bit_depth == 2) + { + sp = row; + for (i = 0; i < row_width; i += 4) + { + int a = *sp & 0xc0; + int b = *sp & 0x30; + int c = *sp & 0x0c; + int d = *sp & 0x03; + + *sp = (png_byte)( + ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| + ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| + ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| + ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); + sp++; + } + } + + if (row_info->bit_depth == 4) + { + sp = row; + for (i = 0; i < row_width; i += 2) + { + int msb = *sp & 0xf0; + int lsb = *sp & 0x0f; + + *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) + | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); + sp++; + } + } + + else if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + } + } + + else if (row_info->bit_depth == 16) + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + } + } + break; + } + + default: + break; + } + } +} +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED +/* Encode the alpha channel to the output gamma (the input channel is always + * linear.) Called only with color types that have an alpha channel. Needs the + * from_1 tables. + */ +static void +png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) +{ + png_uint_32 row_width = row_info->width; + + png_debug(1, "in png_do_encode_alpha"); + + if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0) + { + if (row_info->bit_depth == 8) + { + PNG_CONST png_bytep table = png_ptr->gamma_from_1; + + if (table != NULL) + { + PNG_CONST int step = + (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2; + + /* The alpha channel is the last component: */ + row += step - 1; + + for (; row_width > 0; --row_width, row += step) + *row = table[*row]; + + return; + } + } + + else if (row_info->bit_depth == 16) + { + PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1; + PNG_CONST int gamma_shift = png_ptr->gamma_shift; + + if (table != NULL) + { + PNG_CONST int step = + (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4; + + /* The alpha channel is the last component: */ + row += step - 2; + + for (; row_width > 0; --row_width, row += step) + { + png_uint_16 v; + + v = table[*(row + 1) >> gamma_shift][*row]; + *row = (png_byte)((v >> 8) & 0xff); + *(row + 1) = (png_byte)(v & 0xff); + } + + return; + } + } + } + + /* Only get to here if called with a weird row_info; no harm has been done, + * so just issue a warning. + */ + png_warning(png_ptr, "png_do_encode_alpha: unexpected call"); +} +#endif + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* Expands a palette row to an RGB or RGBA row depending + * upon whether you supply trans and num_trans. + */ +static void +png_do_expand_palette(png_row_infop row_info, png_bytep row, + png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) +{ + int shift, value; + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_expand_palette"); + + if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (row_info->bit_depth < 8) + { + switch (row_info->bit_depth) + { + case 1: + { + sp = row + (png_size_t)((row_width - 1) >> 3); + dp = row + (png_size_t)row_width - 1; + shift = 7 - (int)((row_width + 7) & 0x07); + for (i = 0; i < row_width; i++) + { + if ((*sp >> shift) & 0x01) + *dp = 1; + + else + *dp = 0; + + if (shift == 7) + { + shift = 0; + sp--; + } + + else + shift++; + + dp--; + } + break; + } + + case 2: + { + sp = row + (png_size_t)((row_width - 1) >> 2); + dp = row + (png_size_t)row_width - 1; + shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x03; + *dp = (png_byte)value; + if (shift == 6) + { + shift = 0; + sp--; + } + + else + shift += 2; + + dp--; + } + break; + } + + case 4: + { + sp = row + (png_size_t)((row_width - 1) >> 1); + dp = row + (png_size_t)row_width - 1; + shift = (int)((row_width & 0x01) << 2); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x0f; + *dp = (png_byte)value; + if (shift == 4) + { + shift = 0; + sp--; + } + + else + shift += 4; + + dp--; + } + break; + } + + default: + break; + } + row_info->bit_depth = 8; + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + + if (row_info->bit_depth == 8) + { + { + if (num_trans > 0) + { + sp = row + (png_size_t)row_width - 1; + dp = row + ((png_size_t)row_width << 2) - 1; + + for (i = 0; i < row_width; i++) + { + if ((int)(*sp) >= num_trans) + *dp-- = 0xff; + + else + *dp-- = trans_alpha[*sp]; + + *dp-- = palette[*sp].blue; + *dp-- = palette[*sp].green; + *dp-- = palette[*sp].red; + sp--; + } + row_info->bit_depth = 8; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + row_info->color_type = 6; + row_info->channels = 4; + } + + else + { + sp = row + (png_size_t)row_width - 1; + dp = row + (png_size_t)(row_width * 3) - 1; + + for (i = 0; i < row_width; i++) + { + *dp-- = palette[*sp].blue; + *dp-- = palette[*sp].green; + *dp-- = palette[*sp].red; + sp--; + } + + row_info->bit_depth = 8; + row_info->pixel_depth = 24; + row_info->rowbytes = row_width * 3; + row_info->color_type = 2; + row_info->channels = 3; + } + } + } + } +} + +/* If the bit depth < 8, it is expanded to 8. Also, if the already + * expanded transparency value is supplied, an alpha channel is built. + */ +static void +png_do_expand(png_row_infop row_info, png_bytep row, + png_const_color_16p trans_color) +{ + int shift, value; + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_expand"); + + { + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + unsigned int gray = trans_color != NULL ? trans_color->gray : 0; + + if (row_info->bit_depth < 8) + { + switch (row_info->bit_depth) + { + case 1: + { + gray = (gray & 0x01) * 0xff; + sp = row + (png_size_t)((row_width - 1) >> 3); + dp = row + (png_size_t)row_width - 1; + shift = 7 - (int)((row_width + 7) & 0x07); + for (i = 0; i < row_width; i++) + { + if ((*sp >> shift) & 0x01) + *dp = 0xff; + + else + *dp = 0; + + if (shift == 7) + { + shift = 0; + sp--; + } + + else + shift++; + + dp--; + } + break; + } + + case 2: + { + gray = (gray & 0x03) * 0x55; + sp = row + (png_size_t)((row_width - 1) >> 2); + dp = row + (png_size_t)row_width - 1; + shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x03; + *dp = (png_byte)(value | (value << 2) | (value << 4) | + (value << 6)); + if (shift == 6) + { + shift = 0; + sp--; + } + + else + shift += 2; + + dp--; + } + break; + } + + case 4: + { + gray = (gray & 0x0f) * 0x11; + sp = row + (png_size_t)((row_width - 1) >> 1); + dp = row + (png_size_t)row_width - 1; + shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x0f; + *dp = (png_byte)(value | (value << 4)); + if (shift == 4) + { + shift = 0; + sp--; + } + + else + shift = 4; + + dp--; + } + break; + } + + default: + break; + } + + row_info->bit_depth = 8; + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + + if (trans_color != NULL) + { + if (row_info->bit_depth == 8) + { + gray = gray & 0xff; + sp = row + (png_size_t)row_width - 1; + dp = row + ((png_size_t)row_width << 1) - 1; + + for (i = 0; i < row_width; i++) + { + if ((*sp & 0xffU) == gray) + *dp-- = 0; + + else + *dp-- = 0xff; + + *dp-- = *sp--; + } + } + + else if (row_info->bit_depth == 16) + { + unsigned int gray_high = (gray >> 8) & 0xff; + unsigned int gray_low = gray & 0xff; + sp = row + row_info->rowbytes - 1; + dp = row + (row_info->rowbytes << 1) - 1; + for (i = 0; i < row_width; i++) + { + if ((*(sp - 1) & 0xffU) == gray_high && + (*(sp) & 0xffU) == gray_low) + { + *dp-- = 0; + *dp-- = 0; + } + + else + { + *dp-- = 0xff; + *dp-- = 0xff; + } + + *dp-- = *sp--; + *dp-- = *sp--; + } + } + + row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; + row_info->channels = 2; + row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, + row_width); + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB && + trans_color != NULL) + { + if (row_info->bit_depth == 8) + { + png_byte red = (png_byte)(trans_color->red & 0xff); + png_byte green = (png_byte)(trans_color->green & 0xff); + png_byte blue = (png_byte)(trans_color->blue & 0xff); + sp = row + (png_size_t)row_info->rowbytes - 1; + dp = row + ((png_size_t)row_width << 2) - 1; + for (i = 0; i < row_width; i++) + { + if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue) + *dp-- = 0; + + else + *dp-- = 0xff; + + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + } + } + else if (row_info->bit_depth == 16) + { + png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff); + png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff); + png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff); + png_byte red_low = (png_byte)(trans_color->red & 0xff); + png_byte green_low = (png_byte)(trans_color->green & 0xff); + png_byte blue_low = (png_byte)(trans_color->blue & 0xff); + sp = row + row_info->rowbytes - 1; + dp = row + ((png_size_t)row_width << 3) - 1; + for (i = 0; i < row_width; i++) + { + if (*(sp - 5) == red_high && + *(sp - 4) == red_low && + *(sp - 3) == green_high && + *(sp - 2) == green_low && + *(sp - 1) == blue_high && + *(sp ) == blue_low) + { + *dp-- = 0; + *dp-- = 0; + } + + else + { + *dp-- = 0xff; + *dp-- = 0xff; + } + + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + } + } + row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; + row_info->channels = 4; + row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + } + } +} +#endif + +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* If the bit depth is 8 and the color type is not a palette type expand the + * whole row to 16 bits. Has no effect otherwise. + */ +static void +png_do_expand_16(png_row_infop row_info, png_bytep row) +{ + if (row_info->bit_depth == 8 && + row_info->color_type != PNG_COLOR_TYPE_PALETTE) + { + /* The row have a sequence of bytes containing [0..255] and we need + * to turn it into another row containing [0..65535], to do this we + * calculate: + * + * (input / 255) * 65535 + * + * Which happens to be exactly input * 257 and this can be achieved + * simply by byte replication in place (copying backwards). + */ + png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */ + png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */ + while (dp > sp) + { + dp[-2] = dp[-1] = *--sp; dp -= 2; + } + + row_info->rowbytes *= 2; + row_info->bit_depth = 16; + row_info->pixel_depth = (png_byte)(row_info->channels * 16); + } +} +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED +static void +png_do_quantize(png_row_infop row_info, png_bytep row, + png_const_bytep palette_lookup, png_const_bytep quantize_lookup) +{ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_quantize"); + + if (row_info->bit_depth == 8) + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup) + { + int r, g, b, p; + sp = row; + dp = row; + for (i = 0; i < row_width; i++) + { + r = *sp++; + g = *sp++; + b = *sp++; + + /* This looks real messy, but the compiler will reduce + * it down to a reasonable formula. For example, with + * 5 bits per color, we get: + * p = (((r >> 3) & 0x1f) << 10) | + * (((g >> 3) & 0x1f) << 5) | + * ((b >> 3) & 0x1f); + */ + p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) & + ((1 << PNG_QUANTIZE_RED_BITS) - 1)) << + (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) | + (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) & + ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) << + (PNG_QUANTIZE_BLUE_BITS)) | + ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) & + ((1 << PNG_QUANTIZE_BLUE_BITS) - 1)); + + *dp++ = palette_lookup[p]; + } + + row_info->color_type = PNG_COLOR_TYPE_PALETTE; + row_info->channels = 1; + row_info->pixel_depth = row_info->bit_depth; + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + } + + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && + palette_lookup != NULL) + { + int r, g, b, p; + sp = row; + dp = row; + for (i = 0; i < row_width; i++) + { + r = *sp++; + g = *sp++; + b = *sp++; + sp++; + + p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) & + ((1 << PNG_QUANTIZE_RED_BITS) - 1)) << + (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) | + (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) & + ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) << + (PNG_QUANTIZE_BLUE_BITS)) | + ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) & + ((1 << PNG_QUANTIZE_BLUE_BITS) - 1)); + + *dp++ = palette_lookup[p]; + } + + row_info->color_type = PNG_COLOR_TYPE_PALETTE; + row_info->channels = 1; + row_info->pixel_depth = row_info->bit_depth; + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); + } + + else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && + quantize_lookup) + { + sp = row; + + for (i = 0; i < row_width; i++, sp++) + { + *sp = quantize_lookup[*sp]; + } + } + } +} +#endif /* READ_QUANTIZE */ + +/* Transform the row. The order of transformations is significant, + * and is very touchy. If you add a transformation, take care to + * decide how it fits in with the other transformations here. + */ +void /* PRIVATE */ +png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) +{ + png_debug(1, "in png_do_read_transformations"); + + if (png_ptr->row_buf == NULL) + { + /* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this + * error is incredibly rare and incredibly easy to debug without this + * information. + */ + png_error(png_ptr, "NULL row buffer"); + } + + /* The following is debugging; prior to 1.5.4 the code was never compiled in; + * in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro + * PNG_WARN_UNINITIALIZED_ROW removed. In 1.6 the new flag is set only for + * all transformations, however in practice the ROW_INIT always gets done on + * demand, if necessary. + */ + if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 && + (png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) + { + /* Application has failed to call either png_read_start_image() or + * png_read_update_info() after setting transforms that expand pixels. + * This check added to libpng-1.2.19 (but not enabled until 1.5.4). + */ + png_error(png_ptr, "Uninitialized row"); + } + +#ifdef PNG_READ_EXPAND_SUPPORTED + if ((png_ptr->transformations & PNG_EXPAND) != 0) + { + if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_do_expand_palette(row_info, png_ptr->row_buf + 1, + png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans); + } + + else + { + if (png_ptr->num_trans != 0 && + (png_ptr->transformations & PNG_EXPAND_tRNS) != 0) + png_do_expand(row_info, png_ptr->row_buf + 1, + &(png_ptr->trans_color)); + + else + png_do_expand(row_info, png_ptr->row_buf + 1, + NULL); + } + } +#endif + +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && + (png_ptr->transformations & PNG_COMPOSE) == 0 && + (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) + png_do_strip_channel(row_info, png_ptr->row_buf + 1, + 0 /* at_start == false, because SWAP_ALPHA happens later */); +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) + { + int rgb_error = + png_do_rgb_to_gray(png_ptr, row_info, + png_ptr->row_buf + 1); + + if (rgb_error != 0) + { + png_ptr->rgb_to_gray_status=1; + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == + PNG_RGB_TO_GRAY_WARN) + png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); + + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == + PNG_RGB_TO_GRAY_ERR) + png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); + } + } +#endif + +/* From Andreas Dilger e-mail to png-implement, 26 March 1998: + * + * In most cases, the "simple transparency" should be done prior to doing + * gray-to-RGB, or you will have to test 3x as many bytes to check if a + * pixel is transparent. You would also need to make sure that the + * transparency information is upgraded to RGB. + * + * To summarize, the current flow is: + * - Gray + simple transparency -> compare 1 or 2 gray bytes and composite + * with background "in place" if transparent, + * convert to RGB if necessary + * - Gray + alpha -> composite with gray background and remove alpha bytes, + * convert to RGB if necessary + * + * To support RGB backgrounds for gray images we need: + * - Gray + simple transparency -> convert to RGB + simple transparency, + * compare 3 or 6 bytes and composite with + * background "in place" if transparent + * (3x compare/pixel compared to doing + * composite with gray bkgrnd) + * - Gray + alpha -> convert to RGB + alpha, composite with background and + * remove alpha bytes (3x float + * operations/pixel compared with composite + * on gray background) + * + * Greg's change will do this. The reason it wasn't done before is for + * performance, as this increases the per-pixel operations. If we would check + * in advance if the background was gray or RGB, and position the gray-to-RGB + * transform appropriately, then it would save a lot of work/time. + */ + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + /* If gray -> RGB, do so now only if background is non-gray; else do later + * for performance reasons + */ + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 && + (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) == 0) + png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + if ((png_ptr->transformations & PNG_COMPOSE) != 0) + png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr); +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED + if ((png_ptr->transformations & PNG_GAMMA) != 0 && +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + /* Because RGB_TO_GRAY does the gamma transform. */ + (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0 && +#endif +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + /* Because PNG_COMPOSE does the gamma transform if there is something to + * do (if there is an alpha channel or transparency.) + */ + !((png_ptr->transformations & PNG_COMPOSE) != 0 && + ((png_ptr->num_trans != 0) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) && +#endif + /* Because png_init_read_transformations transforms the palette, unless + * RGB_TO_GRAY will do the transform. + */ + (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) + png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr); +#endif + +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && + (png_ptr->transformations & PNG_COMPOSE) != 0 && + (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) + png_do_strip_channel(row_info, png_ptr->row_buf + 1, + 0 /* at_start == false, because SWAP_ALPHA happens later */); +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + if ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 && + (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0) + png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr); +#endif + +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0) + png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + /* There is no harm in doing both of these because only one has any effect, + * by putting the 'scale' option first if the app asks for scale (either by + * calling the API or in a TRANSFORM flag) this is what happens. + */ + if ((png_ptr->transformations & PNG_16_TO_8) != 0) + png_do_chop(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED + if ((png_ptr->transformations & PNG_QUANTIZE) != 0) + { + png_do_quantize(row_info, png_ptr->row_buf + 1, + png_ptr->palette_lookup, png_ptr->quantize_index); + + if (row_info->rowbytes == 0) + png_error(png_ptr, "png_do_quantize returned rowbytes=0"); + } +#endif /* READ_QUANTIZE */ + +#ifdef PNG_READ_EXPAND_16_SUPPORTED + /* Do the expansion now, after all the arithmetic has been done. Notice + * that previous transformations can handle the PNG_EXPAND_16 flag if this + * is efficient (particularly true in the case of gamma correction, where + * better accuracy results faster!) + */ + if ((png_ptr->transformations & PNG_EXPAND_16) != 0) + png_do_expand_16(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + /* NOTE: moved here in 1.5.4 (from much later in this list.) */ + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 && + (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) != 0) + png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_INVERT_SUPPORTED + if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) + png_do_invert(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) + png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_SHIFT_SUPPORTED + if ((png_ptr->transformations & PNG_SHIFT) != 0) + png_do_unshift(row_info, png_ptr->row_buf + 1, + &(png_ptr->shift)); +#endif + +#ifdef PNG_READ_PACK_SUPPORTED + if ((png_ptr->transformations & PNG_PACK) != 0) + png_do_unpack(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Added at libpng-1.5.10 */ + if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max >= 0) + png_do_check_palette_indexes(png_ptr, row_info); +#endif + +#ifdef PNG_READ_BGR_SUPPORTED + if ((png_ptr->transformations & PNG_BGR) != 0) + png_do_bgr(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_PACKSWAP_SUPPORTED + if ((png_ptr->transformations & PNG_PACKSWAP) != 0) + png_do_packswap(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_FILLER_SUPPORTED + if ((png_ptr->transformations & PNG_FILLER) != 0) + png_do_read_filler(row_info, png_ptr->row_buf + 1, + (png_uint_32)png_ptr->filler, png_ptr->flags); +#endif + +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0) + png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_16BIT_SUPPORTED +#ifdef PNG_READ_SWAP_SUPPORTED + if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) + png_do_swap(row_info, png_ptr->row_buf + 1); +#endif +#endif + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED + if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) + { + if (png_ptr->read_user_transform_fn != NULL) + (*(png_ptr->read_user_transform_fn)) /* User read transform function */ + (png_ptr, /* png_ptr */ + row_info, /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_size_t rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED + if (png_ptr->user_transform_depth != 0) + row_info->bit_depth = png_ptr->user_transform_depth; + + if (png_ptr->user_transform_channels != 0) + row_info->channels = png_ptr->user_transform_channels; +#endif + row_info->pixel_depth = (png_byte)(row_info->bit_depth * + row_info->channels); + + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width); + } +#endif +} + +#endif /* READ_TRANSFORMS */ +#endif /* READ */ diff --git a/xs/src/png/libpng/pngrutil.c b/xs/src/png/libpng/pngrutil.c new file mode 100644 index 0000000000..8692933bd8 --- /dev/null +++ b/xs/src/png/libpng/pngrutil.c @@ -0,0 +1,4661 @@ + +/* pngrutil.c - utilities to read a PNG file + * + * Last changed in libpng 1.6.33 [September 28, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * This file contains routines that are only called from within + * libpng itself during the course of reading an image. + */ + +#include "pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +png_uint_32 PNGAPI +png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf) +{ + png_uint_32 uval = png_get_uint_32(buf); + + if (uval > PNG_UINT_31_MAX) + png_error(png_ptr, "PNG unsigned integer out of range"); + + return (uval); +} + +#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED) +/* The following is a variation on the above for use with the fixed + * point values used for gAMA and cHRM. Instead of png_error it + * issues a warning and returns (-1) - an invalid value because both + * gAMA and cHRM use *unsigned* integers for fixed point values. + */ +#define PNG_FIXED_ERROR (-1) + +static png_fixed_point /* PRIVATE */ +png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf) +{ + png_uint_32 uval = png_get_uint_32(buf); + + if (uval <= PNG_UINT_31_MAX) + return (png_fixed_point)uval; /* known to be in range */ + + /* The caller can turn off the warning by passing NULL. */ + if (png_ptr != NULL) + png_warning(png_ptr, "PNG fixed point integer out of range"); + + return PNG_FIXED_ERROR; +} +#endif + +#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED +/* NOTE: the read macros will obscure these definitions, so that if + * PNG_USE_READ_MACROS is set the library will not use them internally, + * but the APIs will still be available externally. + * + * The parentheses around "PNGAPI function_name" in the following three + * functions are necessary because they allow the macros to co-exist with + * these (unused but exported) functions. + */ + +/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ +png_uint_32 (PNGAPI +png_get_uint_32)(png_const_bytep buf) +{ + png_uint_32 uval = + ((png_uint_32)(*(buf )) << 24) + + ((png_uint_32)(*(buf + 1)) << 16) + + ((png_uint_32)(*(buf + 2)) << 8) + + ((png_uint_32)(*(buf + 3)) ) ; + + return uval; +} + +/* Grab a signed 32-bit integer from a buffer in big-endian format. The + * data is stored in the PNG file in two's complement format and there + * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore + * the following code does a two's complement to native conversion. + */ +png_int_32 (PNGAPI +png_get_int_32)(png_const_bytep buf) +{ + png_uint_32 uval = png_get_uint_32(buf); + if ((uval & 0x80000000) == 0) /* non-negative */ + return (png_int_32)uval; + + uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ + if ((uval & 0x80000000) == 0) /* no overflow */ + return -(png_int_32)uval; + /* The following has to be safe; this function only gets called on PNG data + * and if we get here that data is invalid. 0 is the most safe value and + * if not then an attacker would surely just generate a PNG with 0 instead. + */ + return 0; +} + +/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ +png_uint_16 (PNGAPI +png_get_uint_16)(png_const_bytep buf) +{ + /* ANSI-C requires an int value to accomodate at least 16 bits so this + * works and allows the compiler not to worry about possible narrowing + * on 32-bit systems. (Pre-ANSI systems did not make integers smaller + * than 16 bits either.) + */ + unsigned int val = + ((unsigned int)(*buf) << 8) + + ((unsigned int)(*(buf + 1))); + + return (png_uint_16)val; +} + +#endif /* READ_INT_FUNCTIONS */ + +/* Read and check the PNG file signature */ +void /* PRIVATE */ +png_read_sig(png_structrp png_ptr, png_inforp info_ptr) +{ + png_size_t num_checked, num_to_check; + + /* Exit if the user application does not expect a signature. */ + if (png_ptr->sig_bytes >= 8) + return; + + num_checked = png_ptr->sig_bytes; + num_to_check = 8 - num_checked; + +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE; +#endif + + /* The signature must be serialized in a single I/O call. */ + png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); + png_ptr->sig_bytes = 8; + + if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0) + { + if (num_checked < 4 && + png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) + png_error(png_ptr, "Not a PNG file"); + else + png_error(png_ptr, "PNG file corrupted by ASCII conversion"); + } + if (num_checked < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; +} + +/* Read the chunk header (length + type name). + * Put the type name into png_ptr->chunk_name, and return the length. + */ +png_uint_32 /* PRIVATE */ +png_read_chunk_header(png_structrp png_ptr) +{ + png_byte buf[8]; + png_uint_32 length; + +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR; +#endif + + /* Read the length and the chunk name. + * This must be performed in a single I/O call. + */ + png_read_data(png_ptr, buf, 8); + length = png_get_uint_31(png_ptr, buf); + + /* Put the chunk name into png_ptr->chunk_name. */ + png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4); + + png_debug2(0, "Reading %lx chunk, length = %lu", + (unsigned long)png_ptr->chunk_name, (unsigned long)length); + + /* Reset the crc and run it over the chunk name. */ + png_reset_crc(png_ptr); + png_calculate_crc(png_ptr, buf + 4, 4); + + /* Check to see if chunk name is valid. */ + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + + /* Check for too-large chunk length */ + png_check_chunk_length(png_ptr, length); + +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA; +#endif + + return length; +} + +/* Read data, and (optionally) run it through the CRC. */ +void /* PRIVATE */ +png_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length) +{ + if (png_ptr == NULL) + return; + + png_read_data(png_ptr, buf, length); + png_calculate_crc(png_ptr, buf, length); +} + +/* Optionally skip data and then check the CRC. Depending on whether we + * are reading an ancillary or critical chunk, and how the program has set + * things up, we may calculate the CRC on the data and print a message. + * Returns '1' if there was a CRC error, '0' otherwise. + */ +int /* PRIVATE */ +png_crc_finish(png_structrp png_ptr, png_uint_32 skip) +{ + /* The size of the local buffer for inflate is a good guess as to a + * reasonable size to use for buffering reads from the application. + */ + while (skip > 0) + { + png_uint_32 len; + png_byte tmpbuf[PNG_INFLATE_BUF_SIZE]; + + len = (sizeof tmpbuf); + if (len > skip) + len = skip; + skip -= len; + + png_crc_read(png_ptr, tmpbuf, len); + } + + if (png_crc_error(png_ptr) != 0) + { + if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ? + (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0 : + (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE) != 0) + { + png_chunk_warning(png_ptr, "CRC error"); + } + + else + png_chunk_error(png_ptr, "CRC error"); + + return (1); + } + + return (0); +} + +/* Compare the CRC stored in the PNG file with that calculated by libpng from + * the data it has read thus far. + */ +int /* PRIVATE */ +png_crc_error(png_structrp png_ptr) +{ + png_byte crc_bytes[4]; + png_uint_32 crc; + int need_crc = 1; + + if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0) + { + if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == + (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) + need_crc = 0; + } + + else /* critical */ + { + if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0) + need_crc = 0; + } + +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC; +#endif + + /* The chunk CRC must be serialized in a single I/O call. */ + png_read_data(png_ptr, crc_bytes, 4); + + if (need_crc != 0) + { + crc = png_get_uint_32(crc_bytes); + return ((int)(crc != png_ptr->crc)); + } + + else + return (0); +} + +#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\ + defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_sCAL_SUPPORTED) ||\ + defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) ||\ + defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_SEQUENTIAL_READ_SUPPORTED) +/* Manage the read buffer; this simply reallocates the buffer if it is not small + * enough (or if it is not allocated). The routine returns a pointer to the + * buffer; if an error occurs and 'warn' is set the routine returns NULL, else + * it will call png_error (via png_malloc) on failure. (warn == 2 means + * 'silent'). + */ +static png_bytep +png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) +{ + png_bytep buffer = png_ptr->read_buffer; + + if (buffer != NULL && new_size > png_ptr->read_buffer_size) + { + png_ptr->read_buffer = NULL; + png_ptr->read_buffer = NULL; + png_ptr->read_buffer_size = 0; + png_free(png_ptr, buffer); + buffer = NULL; + } + + if (buffer == NULL) + { + buffer = png_voidcast(png_bytep, png_malloc_base(png_ptr, new_size)); + + if (buffer != NULL) + { + memset(buffer, 0, new_size); /* just in case */ + png_ptr->read_buffer = buffer; + png_ptr->read_buffer_size = new_size; + } + + else if (warn < 2) /* else silent */ + { + if (warn != 0) + png_chunk_warning(png_ptr, "insufficient memory to read chunk"); + + else + png_chunk_error(png_ptr, "insufficient memory to read chunk"); + } + } + + return buffer; +} +#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */ + +/* png_inflate_claim: claim the zstream for some nefarious purpose that involves + * decompression. Returns Z_OK on success, else a zlib error code. It checks + * the owner but, in final release builds, just issues a warning if some other + * chunk apparently owns the stream. Prior to release it does a png_error. + */ +static int +png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) +{ + if (png_ptr->zowner != 0) + { + char msg[64]; + + PNG_STRING_FROM_CHUNK(msg, png_ptr->zowner); + /* So the message that results is " using zstream"; this is an + * internal error, but is very useful for debugging. i18n requirements + * are minimal. + */ + (void)png_safecat(msg, (sizeof msg), 4, " using zstream"); +#if PNG_RELEASE_BUILD + png_chunk_warning(png_ptr, msg); + png_ptr->zowner = 0; +#else + png_chunk_error(png_ptr, msg); +#endif + } + + /* Implementation note: unlike 'png_deflate_claim' this internal function + * does not take the size of the data as an argument. Some efficiency could + * be gained by using this when it is known *if* the zlib stream itself does + * not record the number; however, this is an illusion: the original writer + * of the PNG may have selected a lower window size, and we really must + * follow that because, for systems with with limited capabilities, we + * would otherwise reject the application's attempts to use a smaller window + * size (zlib doesn't have an interface to say "this or lower"!). + * + * inflateReset2 was added to zlib 1.2.4; before this the window could not be + * reset, therefore it is necessary to always allocate the maximum window + * size with earlier zlibs just in case later compressed chunks need it. + */ + { + int ret; /* zlib return code */ +#if ZLIB_VERNUM >= 0x1240 + int window_bits = 0; + +# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) + if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) == + PNG_OPTION_ON) + { + window_bits = 15; + png_ptr->zstream_start = 0; /* fixed window size */ + } + + else + { + png_ptr->zstream_start = 1; + } +# endif + +#endif /* ZLIB_VERNUM >= 0x1240 */ + + /* Set this for safety, just in case the previous owner left pointers to + * memory allocations. + */ + png_ptr->zstream.next_in = NULL; + png_ptr->zstream.avail_in = 0; + png_ptr->zstream.next_out = NULL; + png_ptr->zstream.avail_out = 0; + + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) + { +#if ZLIB_VERNUM >= 0x1240 + ret = inflateReset2(&png_ptr->zstream, window_bits); +#else + ret = inflateReset(&png_ptr->zstream); +#endif + } + + else + { +#if ZLIB_VERNUM >= 0x1240 + ret = inflateInit2(&png_ptr->zstream, window_bits); +#else + ret = inflateInit(&png_ptr->zstream); +#endif + + if (ret == Z_OK) + png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; + } + +#if ZLIB_VERNUM >= 0x1290 && \ + defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32) + if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON) + /* Turn off validation of the ADLER32 checksum in IDAT chunks */ + ret = inflateValidate(&png_ptr->zstream, 0); +#endif + + if (ret == Z_OK) + png_ptr->zowner = owner; + + else + png_zstream_error(png_ptr, ret); + + return ret; + } + +#ifdef window_bits +# undef window_bits +#endif +} + +#if ZLIB_VERNUM >= 0x1240 +/* Handle the start of the inflate stream if we called inflateInit2(strm,0); + * in this case some zlib versions skip validation of the CINFO field and, in + * certain circumstances, libpng may end up displaying an invalid image, in + * contrast to implementations that call zlib in the normal way (e.g. libpng + * 1.5). + */ +int /* PRIVATE */ +png_zlib_inflate(png_structrp png_ptr, int flush) +{ + if (png_ptr->zstream_start && png_ptr->zstream.avail_in > 0) + { + if ((*png_ptr->zstream.next_in >> 4) > 7) + { + png_ptr->zstream.msg = "invalid window size (libpng)"; + return Z_DATA_ERROR; + } + + png_ptr->zstream_start = 0; + } + + return inflate(&png_ptr->zstream, flush); +} +#endif /* Zlib >= 1.2.4 */ + +#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED +#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED) +/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to + * allow the caller to do multiple calls if required. If the 'finish' flag is + * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must + * be returned or there has been a problem, otherwise Z_SYNC_FLUSH is used and + * Z_OK or Z_STREAM_END will be returned on success. + * + * The input and output sizes are updated to the actual amounts of data consumed + * or written, not the amount available (as in a z_stream). The data pointers + * are not changed, so the next input is (data+input_size) and the next + * available output is (output+output_size). + */ +static int +png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, + /* INPUT: */ png_const_bytep input, png_uint_32p input_size_ptr, + /* OUTPUT: */ png_bytep output, png_alloc_size_t *output_size_ptr) +{ + if (png_ptr->zowner == owner) /* Else not claimed */ + { + int ret; + png_alloc_size_t avail_out = *output_size_ptr; + png_uint_32 avail_in = *input_size_ptr; + + /* zlib can't necessarily handle more than 65535 bytes at once (i.e. it + * can't even necessarily handle 65536 bytes) because the type uInt is + * "16 bits or more". Consequently it is necessary to chunk the input to + * zlib. This code uses ZLIB_IO_MAX, from pngpriv.h, as the maximum (the + * maximum value that can be stored in a uInt.) It is possible to set + * ZLIB_IO_MAX to a lower value in pngpriv.h and this may sometimes have + * a performance advantage, because it reduces the amount of data accessed + * at each step and that may give the OS more time to page it in. + */ + png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); + /* avail_in and avail_out are set below from 'size' */ + png_ptr->zstream.avail_in = 0; + png_ptr->zstream.avail_out = 0; + + /* Read directly into the output if it is available (this is set to + * a local buffer below if output is NULL). + */ + if (output != NULL) + png_ptr->zstream.next_out = output; + + do + { + uInt avail; + Byte local_buffer[PNG_INFLATE_BUF_SIZE]; + + /* zlib INPUT BUFFER */ + /* The setting of 'avail_in' used to be outside the loop; by setting it + * inside it is possible to chunk the input to zlib and simply rely on + * zlib to advance the 'next_in' pointer. This allows arbitrary + * amounts of data to be passed through zlib at the unavoidable cost of + * requiring a window save (memcpy of up to 32768 output bytes) + * every ZLIB_IO_MAX input bytes. + */ + avail_in += png_ptr->zstream.avail_in; /* not consumed last time */ + + avail = ZLIB_IO_MAX; + + if (avail_in < avail) + avail = (uInt)avail_in; /* safe: < than ZLIB_IO_MAX */ + + avail_in -= avail; + png_ptr->zstream.avail_in = avail; + + /* zlib OUTPUT BUFFER */ + avail_out += png_ptr->zstream.avail_out; /* not written last time */ + + avail = ZLIB_IO_MAX; /* maximum zlib can process */ + + if (output == NULL) + { + /* Reset the output buffer each time round if output is NULL and + * make available the full buffer, up to 'remaining_space' + */ + png_ptr->zstream.next_out = local_buffer; + if ((sizeof local_buffer) < avail) + avail = (sizeof local_buffer); + } + + if (avail_out < avail) + avail = (uInt)avail_out; /* safe: < ZLIB_IO_MAX */ + + png_ptr->zstream.avail_out = avail; + avail_out -= avail; + + /* zlib inflate call */ + /* In fact 'avail_out' may be 0 at this point, that happens at the end + * of the read when the final LZ end code was not passed at the end of + * the previous chunk of input data. Tell zlib if we have reached the + * end of the output buffer. + */ + ret = PNG_INFLATE(png_ptr, avail_out > 0 ? Z_NO_FLUSH : + (finish ? Z_FINISH : Z_SYNC_FLUSH)); + } while (ret == Z_OK); + + /* For safety kill the local buffer pointer now */ + if (output == NULL) + png_ptr->zstream.next_out = NULL; + + /* Claw back the 'size' and 'remaining_space' byte counts. */ + avail_in += png_ptr->zstream.avail_in; + avail_out += png_ptr->zstream.avail_out; + + /* Update the input and output sizes; the updated values are the amount + * consumed or written, effectively the inverse of what zlib uses. + */ + if (avail_out > 0) + *output_size_ptr -= avail_out; + + if (avail_in > 0) + *input_size_ptr -= avail_in; + + /* Ensure png_ptr->zstream.msg is set (even in the success case!) */ + png_zstream_error(png_ptr, ret); + return ret; + } + + else + { + /* This is a bad internal error. The recovery assigns to the zstream msg + * pointer, which is not owned by the caller, but this is safe; it's only + * used on errors! + */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed"); + return Z_STREAM_ERROR; + } +} + +/* + * Decompress trailing data in a chunk. The assumption is that read_buffer + * points at an allocated area holding the contents of a chunk with a + * trailing compressed part. What we get back is an allocated area + * holding the original prefix part and an uncompressed version of the + * trailing part (the malloc area passed in is freed). + */ +static int +png_decompress_chunk(png_structrp png_ptr, + png_uint_32 chunklength, png_uint_32 prefix_size, + png_alloc_size_t *newlength /* must be initialized to the maximum! */, + int terminate /*add a '\0' to the end of the uncompressed data*/) +{ + /* TODO: implement different limits for different types of chunk. + * + * The caller supplies *newlength set to the maximum length of the + * uncompressed data, but this routine allocates space for the prefix and + * maybe a '\0' terminator too. We have to assume that 'prefix_size' is + * limited only by the maximum chunk size. + */ + png_alloc_size_t limit = PNG_SIZE_MAX; + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < limit) + limit = png_ptr->user_chunk_malloc_max; +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + if (PNG_USER_CHUNK_MALLOC_MAX < limit) + limit = PNG_USER_CHUNK_MALLOC_MAX; +# endif + + if (limit >= prefix_size + (terminate != 0)) + { + int ret; + + limit -= prefix_size + (terminate != 0); + + if (limit < *newlength) + *newlength = limit; + + /* Now try to claim the stream. */ + ret = png_inflate_claim(png_ptr, png_ptr->chunk_name); + + if (ret == Z_OK) + { + png_uint_32 lzsize = chunklength - prefix_size; + + ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, + /* input: */ png_ptr->read_buffer + prefix_size, &lzsize, + /* output: */ NULL, newlength); + + if (ret == Z_STREAM_END) + { + /* Use 'inflateReset' here, not 'inflateReset2' because this + * preserves the previously decided window size (otherwise it would + * be necessary to store the previous window size.) In practice + * this doesn't matter anyway, because png_inflate will call inflate + * with Z_FINISH in almost all cases, so the window will not be + * maintained. + */ + if (inflateReset(&png_ptr->zstream) == Z_OK) + { + /* Because of the limit checks above we know that the new, + * expanded, size will fit in a size_t (let alone an + * png_alloc_size_t). Use png_malloc_base here to avoid an + * extra OOM message. + */ + png_alloc_size_t new_size = *newlength; + png_alloc_size_t buffer_size = prefix_size + new_size + + (terminate != 0); + png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr, + buffer_size)); + + if (text != NULL) + { + memset(text, 0, buffer_size); + + ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, + png_ptr->read_buffer + prefix_size, &lzsize, + text + prefix_size, newlength); + + if (ret == Z_STREAM_END) + { + if (new_size == *newlength) + { + if (terminate != 0) + text[prefix_size + *newlength] = 0; + + if (prefix_size > 0) + memcpy(text, png_ptr->read_buffer, prefix_size); + + { + png_bytep old_ptr = png_ptr->read_buffer; + + png_ptr->read_buffer = text; + png_ptr->read_buffer_size = buffer_size; + text = old_ptr; /* freed below */ + } + } + + else + { + /* The size changed on the second read, there can be no + * guarantee that anything is correct at this point. + * The 'msg' pointer has been set to "unexpected end of + * LZ stream", which is fine, but return an error code + * that the caller won't accept. + */ + ret = PNG_UNEXPECTED_ZLIB_RETURN; + } + } + + else if (ret == Z_OK) + ret = PNG_UNEXPECTED_ZLIB_RETURN; /* for safety */ + + /* Free the text pointer (this is the old read_buffer on + * success) + */ + png_free(png_ptr, text); + + /* This really is very benign, but it's still an error because + * the extra space may otherwise be used as a Trojan Horse. + */ + if (ret == Z_STREAM_END && + chunklength - prefix_size != lzsize) + png_chunk_benign_error(png_ptr, "extra compressed data"); + } + + else + { + /* Out of memory allocating the buffer */ + ret = Z_MEM_ERROR; + png_zstream_error(png_ptr, Z_MEM_ERROR); + } + } + + else + { + /* inflateReset failed, store the error message */ + png_zstream_error(png_ptr, ret); + ret = PNG_UNEXPECTED_ZLIB_RETURN; + } + } + + else if (ret == Z_OK) + ret = PNG_UNEXPECTED_ZLIB_RETURN; + + /* Release the claimed stream */ + png_ptr->zowner = 0; + } + + else /* the claim failed */ if (ret == Z_STREAM_END) /* impossible! */ + ret = PNG_UNEXPECTED_ZLIB_RETURN; + + return ret; + } + + else + { + /* Application/configuration limits exceeded */ + png_zstream_error(png_ptr, Z_MEM_ERROR); + return Z_MEM_ERROR; + } +} +#endif /* READ_zTXt || READ_iTXt */ +#endif /* READ_COMPRESSED_TEXT */ + +#ifdef PNG_READ_iCCP_SUPPORTED +/* Perform a partial read and decompress, producing 'avail_out' bytes and + * reading from the current chunk as required. + */ +static int +png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, + png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, + int finish) +{ + if (png_ptr->zowner == png_ptr->chunk_name) + { + int ret; + + /* next_in and avail_in must have been initialized by the caller. */ + png_ptr->zstream.next_out = next_out; + png_ptr->zstream.avail_out = 0; /* set in the loop */ + + do + { + if (png_ptr->zstream.avail_in == 0) + { + if (read_size > *chunk_bytes) + read_size = (uInt)*chunk_bytes; + *chunk_bytes -= read_size; + + if (read_size > 0) + png_crc_read(png_ptr, read_buffer, read_size); + + png_ptr->zstream.next_in = read_buffer; + png_ptr->zstream.avail_in = read_size; + } + + if (png_ptr->zstream.avail_out == 0) + { + uInt avail = ZLIB_IO_MAX; + if (avail > *out_size) + avail = (uInt)*out_size; + *out_size -= avail; + + png_ptr->zstream.avail_out = avail; + } + + /* Use Z_SYNC_FLUSH when there is no more chunk data to ensure that all + * the available output is produced; this allows reading of truncated + * streams. + */ + ret = PNG_INFLATE(png_ptr, *chunk_bytes > 0 ? + Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH)); + } + while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0)); + + *out_size += png_ptr->zstream.avail_out; + png_ptr->zstream.avail_out = 0; /* Should not be required, but is safe */ + + /* Ensure the error message pointer is always set: */ + png_zstream_error(png_ptr, ret); + return ret; + } + + else + { + png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed"); + return Z_STREAM_ERROR; + } +} +#endif /* READ_iCCP */ + +/* Read and check the IDHR chunk */ + +void /* PRIVATE */ +png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte buf[13]; + png_uint_32 width, height; + int bit_depth, color_type, compression_type, filter_type; + int interlace_type; + + png_debug(1, "in png_handle_IHDR"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) != 0) + png_chunk_error(png_ptr, "out of place"); + + /* Check the length */ + if (length != 13) + png_chunk_error(png_ptr, "invalid"); + + png_ptr->mode |= PNG_HAVE_IHDR; + + png_crc_read(png_ptr, buf, 13); + png_crc_finish(png_ptr, 0); + + width = png_get_uint_31(png_ptr, buf); + height = png_get_uint_31(png_ptr, buf + 4); + bit_depth = buf[8]; + color_type = buf[9]; + compression_type = buf[10]; + filter_type = buf[11]; + interlace_type = buf[12]; + + /* Set internal variables */ + png_ptr->width = width; + png_ptr->height = height; + png_ptr->bit_depth = (png_byte)bit_depth; + png_ptr->interlaced = (png_byte)interlace_type; + png_ptr->color_type = (png_byte)color_type; +#ifdef PNG_MNG_FEATURES_SUPPORTED + png_ptr->filter_type = (png_byte)filter_type; +#endif + png_ptr->compression_type = (png_byte)compression_type; + + /* Find number of channels */ + switch (png_ptr->color_type) + { + default: /* invalid, png_set_IHDR calls png_error */ + case PNG_COLOR_TYPE_GRAY: + case PNG_COLOR_TYPE_PALETTE: + png_ptr->channels = 1; + break; + + case PNG_COLOR_TYPE_RGB: + png_ptr->channels = 3; + break; + + case PNG_COLOR_TYPE_GRAY_ALPHA: + png_ptr->channels = 2; + break; + + case PNG_COLOR_TYPE_RGB_ALPHA: + png_ptr->channels = 4; + break; + } + + /* Set up other useful info */ + png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels); + png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); + png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); + png_debug1(3, "channels = %d", png_ptr->channels); + png_debug1(3, "rowbytes = %lu", (unsigned long)png_ptr->rowbytes); + png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, + color_type, interlace_type, compression_type, filter_type); +} + +/* Read and check the palette */ +void /* PRIVATE */ +png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_color palette[PNG_MAX_PALETTE_LENGTH]; + int max_palette_length, num, i; +#ifdef PNG_POINTER_INDEXING_SUPPORTED + png_colorp pal_ptr; +#endif + + png_debug(1, "in png_handle_PLTE"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + /* Moved to before the 'after IDAT' check below because otherwise duplicate + * PLTE chunks are potentially ignored (the spec says there shall not be more + * than one PLTE, the error is not treated as benign, so this check trumps + * the requirement that PLTE appears before IDAT.) + */ + else if ((png_ptr->mode & PNG_HAVE_PLTE) != 0) + png_chunk_error(png_ptr, "duplicate"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + /* This is benign because the non-benign error happened before, when an + * IDAT was encountered in a color-mapped image with no PLTE. + */ + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + png_ptr->mode |= PNG_HAVE_PLTE; + + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "ignored in grayscale PNG"); + return; + } + +#ifndef PNG_READ_OPT_PLTE_SUPPORTED + if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) + { + png_crc_finish(png_ptr, length); + return; + } +#endif + + if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) + { + png_crc_finish(png_ptr, length); + + if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) + png_chunk_benign_error(png_ptr, "invalid"); + + else + png_chunk_error(png_ptr, "invalid"); + + return; + } + + /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */ + num = (int)length / 3; + + /* If the palette has 256 or fewer entries but is too large for the bit + * depth, we don't issue an error, to preserve the behavior of previous + * libpng versions. We silently truncate the unused extra palette entries + * here. + */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + max_palette_length = (1 << png_ptr->bit_depth); + else + max_palette_length = PNG_MAX_PALETTE_LENGTH; + + if (num > max_palette_length) + num = max_palette_length; + +#ifdef PNG_POINTER_INDEXING_SUPPORTED + for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) + { + png_byte buf[3]; + + png_crc_read(png_ptr, buf, 3); + pal_ptr->red = buf[0]; + pal_ptr->green = buf[1]; + pal_ptr->blue = buf[2]; + } +#else + for (i = 0; i < num; i++) + { + png_byte buf[3]; + + png_crc_read(png_ptr, buf, 3); + /* Don't depend upon png_color being any order */ + palette[i].red = buf[0]; + palette[i].green = buf[1]; + palette[i].blue = buf[2]; + } +#endif + + /* If we actually need the PLTE chunk (ie for a paletted image), we do + * whatever the normal CRC configuration tells us. However, if we + * have an RGB image, the PLTE can be considered ancillary, so + * we will act as though it is. + */ +#ifndef PNG_READ_OPT_PLTE_SUPPORTED + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) +#endif + { + png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3)); + } + +#ifndef PNG_READ_OPT_PLTE_SUPPORTED + else if (png_crc_error(png_ptr) != 0) /* Only if we have a CRC error */ + { + /* If we don't want to use the data from an ancillary chunk, + * we have two options: an error abort, or a warning and we + * ignore the data in this chunk (which should be OK, since + * it's considered ancillary for a RGB or RGBA image). + * + * IMPLEMENTATION NOTE: this is only here because png_crc_finish uses the + * chunk type to determine whether to check the ancillary or the critical + * flags. + */ + if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE) == 0) + { + if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) != 0) + return; + + else + png_chunk_error(png_ptr, "CRC error"); + } + + /* Otherwise, we (optionally) emit a warning and use the chunk. */ + else if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0) + png_chunk_warning(png_ptr, "CRC error"); + } +#endif + + /* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to its + * own copy of the palette. This has the side effect that when png_start_row + * is called (this happens after any call to png_read_update_info) the + * info_ptr palette gets changed. This is extremely unexpected and + * confusing. + * + * Fix this by not sharing the palette in this way. + */ + png_set_PLTE(png_ptr, info_ptr, palette, num); + + /* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before + * IDAT. Prior to 1.6.0 this was not checked; instead the code merely + * checked the apparent validity of a tRNS chunk inserted before PLTE on a + * palette PNG. 1.6.0 attempts to rigorously follow the standard and + * therefore does a benign error if the erroneous condition is detected *and* + * cancels the tRNS if the benign error returns. The alternative is to + * amend the standard since it would be rather hypocritical of the standards + * maintainers to ignore it. + */ +#ifdef PNG_READ_tRNS_SUPPORTED + if (png_ptr->num_trans > 0 || + (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)) + { + /* Cancel this because otherwise it would be used if the transforms + * require it. Don't cancel the 'valid' flag because this would prevent + * detection of duplicate chunks. + */ + png_ptr->num_trans = 0; + + if (info_ptr != NULL) + info_ptr->num_trans = 0; + + png_chunk_benign_error(png_ptr, "tRNS must be after"); + } +#endif + +#ifdef PNG_READ_hIST_SUPPORTED + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0) + png_chunk_benign_error(png_ptr, "hIST must be after"); +#endif + +#ifdef PNG_READ_bKGD_SUPPORTED + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0) + png_chunk_benign_error(png_ptr, "bKGD must be after"); +#endif +} + +void /* PRIVATE */ +png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_debug(1, "in png_handle_IEND"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0 || + (png_ptr->mode & PNG_HAVE_IDAT) == 0) + png_chunk_error(png_ptr, "out of place"); + + png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); + + png_crc_finish(png_ptr, length); + + if (length != 0) + png_chunk_benign_error(png_ptr, "invalid"); + + PNG_UNUSED(info_ptr) +} + +#ifdef PNG_READ_gAMA_SUPPORTED +void /* PRIVATE */ +png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_fixed_point igamma; + png_byte buf[4]; + + png_debug(1, "in png_handle_gAMA"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + if (length != 4) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 4); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + igamma = png_get_fixed_point(NULL, buf); + + png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma); + png_colorspace_sync(png_ptr, info_ptr); +} +#endif + +#ifdef PNG_READ_sBIT_SUPPORTED +void /* PRIVATE */ +png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + unsigned int truelen, i; + png_byte sample_depth; + png_byte buf[4]; + + png_debug(1, "in png_handle_sBIT"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + truelen = 3; + sample_depth = 8; + } + + else + { + truelen = png_ptr->channels; + sample_depth = png_ptr->bit_depth; + } + + if (length != truelen || length > 4) + { + png_chunk_benign_error(png_ptr, "invalid"); + png_crc_finish(png_ptr, length); + return; + } + + buf[0] = buf[1] = buf[2] = buf[3] = sample_depth; + png_crc_read(png_ptr, buf, truelen); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + for (i=0; i sample_depth) + { + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + } + + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + png_ptr->sig_bit.red = buf[0]; + png_ptr->sig_bit.green = buf[1]; + png_ptr->sig_bit.blue = buf[2]; + png_ptr->sig_bit.alpha = buf[3]; + } + + else + { + png_ptr->sig_bit.gray = buf[0]; + png_ptr->sig_bit.red = buf[0]; + png_ptr->sig_bit.green = buf[0]; + png_ptr->sig_bit.blue = buf[0]; + png_ptr->sig_bit.alpha = buf[1]; + } + + png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); +} +#endif + +#ifdef PNG_READ_cHRM_SUPPORTED +void /* PRIVATE */ +png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte buf[32]; + png_xy xy; + + png_debug(1, "in png_handle_cHRM"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + if (length != 32) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 32); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + xy.whitex = png_get_fixed_point(NULL, buf); + xy.whitey = png_get_fixed_point(NULL, buf + 4); + xy.redx = png_get_fixed_point(NULL, buf + 8); + xy.redy = png_get_fixed_point(NULL, buf + 12); + xy.greenx = png_get_fixed_point(NULL, buf + 16); + xy.greeny = png_get_fixed_point(NULL, buf + 20); + xy.bluex = png_get_fixed_point(NULL, buf + 24); + xy.bluey = png_get_fixed_point(NULL, buf + 28); + + if (xy.whitex == PNG_FIXED_ERROR || + xy.whitey == PNG_FIXED_ERROR || + xy.redx == PNG_FIXED_ERROR || + xy.redy == PNG_FIXED_ERROR || + xy.greenx == PNG_FIXED_ERROR || + xy.greeny == PNG_FIXED_ERROR || + xy.bluex == PNG_FIXED_ERROR || + xy.bluey == PNG_FIXED_ERROR) + { + png_chunk_benign_error(png_ptr, "invalid values"); + return; + } + + /* If a colorspace error has already been output skip this chunk */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0) + return; + + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0) + { + png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; + png_colorspace_sync(png_ptr, info_ptr); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; + (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy, + 1/*prefer cHRM values*/); + png_colorspace_sync(png_ptr, info_ptr); +} +#endif + +#ifdef PNG_READ_sRGB_SUPPORTED +void /* PRIVATE */ +png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte intent; + + png_debug(1, "in png_handle_sRGB"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + if (length != 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, &intent, 1); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* If a colorspace error has already been output skip this chunk */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0) + return; + + /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect + * this. + */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) != 0) + { + png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; + png_colorspace_sync(png_ptr, info_ptr); + png_chunk_benign_error(png_ptr, "too many profiles"); + return; + } + + (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent); + png_colorspace_sync(png_ptr, info_ptr); +} +#endif /* READ_sRGB */ + +#ifdef PNG_READ_iCCP_SUPPORTED +void /* PRIVATE */ +png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +/* Note: this does not properly handle profiles that are > 64K under DOS */ +{ + png_const_charp errmsg = NULL; /* error message output, or no error */ + int finished = 0; /* crc checked */ + + png_debug(1, "in png_handle_iCCP"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + /* Consistent with all the above colorspace handling an obviously *invalid* + * chunk is just ignored, so does not invalidate the color space. An + * alternative is to set the 'invalid' flags at the start of this routine + * and only clear them in they were not set before and all the tests pass. + */ + + /* The keyword must be at least one character and there is a + * terminator (0) byte and the compression method byte, and the + * 'zlib' datastream is at least 11 bytes. + */ + if (length < 14) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too short"); + return; + } + + /* If a colorspace error has already been output skip this chunk */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0) + { + png_crc_finish(png_ptr, length); + return; + } + + /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect + * this. + */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) == 0) + { + uInt read_length, keyword_length; + char keyword[81]; + + /* Find the keyword; the keyword plus separator and compression method + * bytes can be at most 81 characters long. + */ + read_length = 81; /* maximum */ + if (read_length > length) + read_length = (uInt)length; + + png_crc_read(png_ptr, (png_bytep)keyword, read_length); + length -= read_length; + + /* The minimum 'zlib' stream is assumed to be just the 2 byte header, + * 5 bytes minimum 'deflate' stream, and the 4 byte checksum. + */ + if (length < 11) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too short"); + return; + } + + keyword_length = 0; + while (keyword_length < 80 && keyword_length < read_length && + keyword[keyword_length] != 0) + ++keyword_length; + + /* TODO: make the keyword checking common */ + if (keyword_length >= 1 && keyword_length <= 79) + { + /* We only understand '0' compression - deflate - so if we get a + * different value we can't safely decode the chunk. + */ + if (keyword_length+1 < read_length && + keyword[keyword_length+1] == PNG_COMPRESSION_TYPE_BASE) + { + read_length -= keyword_length+2; + + if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK) + { + Byte profile_header[132]={0}; + Byte local_buffer[PNG_INFLATE_BUF_SIZE]; + png_alloc_size_t size = (sizeof profile_header); + + png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2); + png_ptr->zstream.avail_in = read_length; + (void)png_inflate_read(png_ptr, local_buffer, + (sizeof local_buffer), &length, profile_header, &size, + 0/*finish: don't, because the output is too small*/); + + if (size == 0) + { + /* We have the ICC profile header; do the basic header checks. + */ + const png_uint_32 profile_length = + png_get_uint_32(profile_header); + + if (png_icc_check_length(png_ptr, &png_ptr->colorspace, + keyword, profile_length) != 0) + { + /* The length is apparently ok, so we can check the 132 + * byte header. + */ + if (png_icc_check_header(png_ptr, &png_ptr->colorspace, + keyword, profile_length, profile_header, + png_ptr->color_type) != 0) + { + /* Now read the tag table; a variable size buffer is + * needed at this point, allocate one for the whole + * profile. The header check has already validated + * that none of this stuff will overflow. + */ + const png_uint_32 tag_count = png_get_uint_32( + profile_header+128); + png_bytep profile = png_read_buffer(png_ptr, + profile_length, 2/*silent*/); + + if (profile != NULL) + { + memcpy(profile, profile_header, + (sizeof profile_header)); + + size = 12 * tag_count; + + (void)png_inflate_read(png_ptr, local_buffer, + (sizeof local_buffer), &length, + profile + (sizeof profile_header), &size, 0); + + /* Still expect a buffer error because we expect + * there to be some tag data! + */ + if (size == 0) + { + if (png_icc_check_tag_table(png_ptr, + &png_ptr->colorspace, keyword, profile_length, + profile) != 0) + { + /* The profile has been validated for basic + * security issues, so read the whole thing in. + */ + size = profile_length - (sizeof profile_header) + - 12 * tag_count; + + (void)png_inflate_read(png_ptr, local_buffer, + (sizeof local_buffer), &length, + profile + (sizeof profile_header) + + 12 * tag_count, &size, 1/*finish*/); + + if (length > 0 && !(png_ptr->flags & + PNG_FLAG_BENIGN_ERRORS_WARN)) + errmsg = "extra compressed data"; + + /* But otherwise allow extra data: */ + else if (size == 0) + { + if (length > 0) + { + /* This can be handled completely, so + * keep going. + */ + png_chunk_warning(png_ptr, + "extra compressed data"); + } + + png_crc_finish(png_ptr, length); + finished = 1; + +# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 + /* Check for a match against sRGB */ + png_icc_set_sRGB(png_ptr, + &png_ptr->colorspace, profile, + png_ptr->zstream.adler); +# endif + + /* Steal the profile for info_ptr. */ + if (info_ptr != NULL) + { + png_free_data(png_ptr, info_ptr, + PNG_FREE_ICCP, 0); + + info_ptr->iccp_name = png_voidcast(char*, + png_malloc_base(png_ptr, + keyword_length+1)); + if (info_ptr->iccp_name != NULL) + { + memcpy(info_ptr->iccp_name, keyword, + keyword_length+1); + info_ptr->iccp_proflen = + profile_length; + info_ptr->iccp_profile = profile; + png_ptr->read_buffer = NULL; /*steal*/ + info_ptr->free_me |= PNG_FREE_ICCP; + info_ptr->valid |= PNG_INFO_iCCP; + } + + else + { + png_ptr->colorspace.flags |= + PNG_COLORSPACE_INVALID; + errmsg = "out of memory"; + } + } + + /* else the profile remains in the read + * buffer which gets reused for subsequent + * chunks. + */ + + if (info_ptr != NULL) + png_colorspace_sync(png_ptr, info_ptr); + + if (errmsg == NULL) + { + png_ptr->zowner = 0; + return; + } + } + if (errmsg == NULL) + errmsg = png_ptr->zstream.msg; + } + /* else png_icc_check_tag_table output an error */ + } + else /* profile truncated */ + errmsg = png_ptr->zstream.msg; + } + + else + errmsg = "out of memory"; + } + + /* else png_icc_check_header output an error */ + } + + /* else png_icc_check_length output an error */ + } + + else /* profile truncated */ + errmsg = png_ptr->zstream.msg; + + /* Release the stream */ + png_ptr->zowner = 0; + } + + else /* png_inflate_claim failed */ + errmsg = png_ptr->zstream.msg; + } + + else + errmsg = "bad compression method"; /* or missing */ + } + + else + errmsg = "bad keyword"; + } + + else + errmsg = "too many profiles"; + + /* Failure: the reason is in 'errmsg' */ + if (finished == 0) + png_crc_finish(png_ptr, length); + + png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; + png_colorspace_sync(png_ptr, info_ptr); + if (errmsg != NULL) /* else already output */ + png_chunk_benign_error(png_ptr, errmsg); +} +#endif /* READ_iCCP */ + +#ifdef PNG_READ_sPLT_SUPPORTED +void /* PRIVATE */ +png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +/* Note: this does not properly handle chunks that are > 64K under DOS */ +{ + png_bytep entry_start, buffer; + png_sPLT_t new_palette; + png_sPLT_entryp pp; + png_uint_32 data_length; + int entry_size, i; + png_uint_32 skip = 0; + png_uint_32 dl; + png_size_t max_dl; + + png_debug(1, "in png_handle_sPLT"); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_warning(png_ptr, "No space in chunk cache for sPLT"); + png_crc_finish(png_ptr, length); + return; + } + } +#endif + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + +#ifdef PNG_MAX_MALLOC_64K + if (length > 65535U) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too large to fit in memory"); + return; + } +#endif + + buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); + if (buffer == NULL) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } + + + /* WARNING: this may break if size_t is less than 32 bits; it is assumed + * that the PNG_MAX_MALLOC_64K test is enabled in this case, but this is a + * potential breakage point if the types in pngconf.h aren't exactly right. + */ + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, skip) != 0) + return; + + buffer[length] = 0; + + for (entry_start = buffer; *entry_start; entry_start++) + /* Empty loop to find end of name */ ; + + ++entry_start; + + /* A sample depth should follow the separator, and we should be on it */ + if (length < 2U || entry_start > buffer + (length - 2U)) + { + png_warning(png_ptr, "malformed sPLT chunk"); + return; + } + + new_palette.depth = *entry_start++; + entry_size = (new_palette.depth == 8 ? 6 : 10); + /* This must fit in a png_uint_32 because it is derived from the original + * chunk data length. + */ + data_length = length - (png_uint_32)(entry_start - buffer); + + /* Integrity-check the data length */ + if ((data_length % (unsigned int)entry_size) != 0) + { + png_warning(png_ptr, "sPLT chunk has bad length"); + return; + } + + dl = (png_uint_32)(data_length / (unsigned int)entry_size); + max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry)); + + if (dl > max_dl) + { + png_warning(png_ptr, "sPLT chunk too long"); + return; + } + + new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size); + + new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, + (png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry))); + + if (new_palette.entries == NULL) + { + png_warning(png_ptr, "sPLT chunk requires too much memory"); + return; + } + +#ifdef PNG_POINTER_INDEXING_SUPPORTED + for (i = 0; i < new_palette.nentries; i++) + { + pp = new_palette.entries + i; + + if (new_palette.depth == 8) + { + pp->red = *entry_start++; + pp->green = *entry_start++; + pp->blue = *entry_start++; + pp->alpha = *entry_start++; + } + + else + { + pp->red = png_get_uint_16(entry_start); entry_start += 2; + pp->green = png_get_uint_16(entry_start); entry_start += 2; + pp->blue = png_get_uint_16(entry_start); entry_start += 2; + pp->alpha = png_get_uint_16(entry_start); entry_start += 2; + } + + pp->frequency = png_get_uint_16(entry_start); entry_start += 2; + } +#else + pp = new_palette.entries; + + for (i = 0; i < new_palette.nentries; i++) + { + + if (new_palette.depth == 8) + { + pp[i].red = *entry_start++; + pp[i].green = *entry_start++; + pp[i].blue = *entry_start++; + pp[i].alpha = *entry_start++; + } + + else + { + pp[i].red = png_get_uint_16(entry_start); entry_start += 2; + pp[i].green = png_get_uint_16(entry_start); entry_start += 2; + pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; + pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; + } + + pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2; + } +#endif + + /* Discard all chunk data except the name and stash that */ + new_palette.name = (png_charp)buffer; + + png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); + + png_free(png_ptr, new_palette.entries); +} +#endif /* READ_sPLT */ + +#ifdef PNG_READ_tRNS_SUPPORTED +void /* PRIVATE */ +png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; + + png_debug(1, "in png_handle_tRNS"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + png_byte buf[2]; + + if (length != 2) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 2); + png_ptr->num_trans = 1; + png_ptr->trans_color.gray = png_get_uint_16(buf); + } + + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + png_byte buf[6]; + + if (length != 6) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, length); + png_ptr->num_trans = 1; + png_ptr->trans_color.red = png_get_uint_16(buf); + png_ptr->trans_color.green = png_get_uint_16(buf + 2); + png_ptr->trans_color.blue = png_get_uint_16(buf + 4); + } + + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if ((png_ptr->mode & PNG_HAVE_PLTE) == 0) + { + /* TODO: is this actually an error in the ISO spec? */ + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + if (length > (unsigned int) png_ptr->num_palette || + length > (unsigned int) PNG_MAX_PALETTE_LENGTH || + length == 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, readbuf, length); + png_ptr->num_trans = (png_uint_16)length; + } + + else + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid with alpha channel"); + return; + } + + if (png_crc_finish(png_ptr, 0) != 0) + { + png_ptr->num_trans = 0; + return; + } + + /* TODO: this is a horrible side effect in the palette case because the + * png_struct ends up with a pointer to the tRNS buffer owned by the + * png_info. Fix this. + */ + png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, + &(png_ptr->trans_color)); +} +#endif + +#ifdef PNG_READ_bKGD_SUPPORTED +void /* PRIVATE */ +png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + unsigned int truelen; + png_byte buf[6]; + png_color_16 background; + + png_debug(1, "in png_handle_bKGD"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + (png_ptr->mode & PNG_HAVE_PLTE) == 0)) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + truelen = 1; + + else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + truelen = 6; + + else + truelen = 2; + + if (length != truelen) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, truelen); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* We convert the index value into RGB components so that we can allow + * arbitrary RGB values for background when we have transparency, and + * so it is easy to determine the RGB values of the background color + * from the info_ptr struct. + */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + background.index = buf[0]; + + if (info_ptr != NULL && info_ptr->num_palette != 0) + { + if (buf[0] >= info_ptr->num_palette) + { + png_chunk_benign_error(png_ptr, "invalid index"); + return; + } + + background.red = (png_uint_16)png_ptr->palette[buf[0]].red; + background.green = (png_uint_16)png_ptr->palette[buf[0]].green; + background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue; + } + + else + background.red = background.green = background.blue = 0; + + background.gray = 0; + } + + else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) /* GRAY */ + { + background.index = 0; + background.red = + background.green = + background.blue = + background.gray = png_get_uint_16(buf); + } + + else + { + background.index = 0; + background.red = png_get_uint_16(buf); + background.green = png_get_uint_16(buf + 2); + background.blue = png_get_uint_16(buf + 4); + background.gray = 0; + } + + png_set_bKGD(png_ptr, info_ptr, &background); +} +#endif + +#ifdef PNG_READ_eXIf_SUPPORTED +void /* PRIVATE */ +png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + unsigned int i; + + png_debug(1, "in png_handle_eXIf"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + if (length < 2) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too short"); + return; + } + + else if (info_ptr == NULL || (info_ptr->valid & PNG_INFO_eXIf) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + info_ptr->free_me |= PNG_FREE_EXIF; + + info_ptr->eXIf_buf = png_voidcast(png_bytep, + png_malloc_warn(png_ptr, length)); + + if (info_ptr->eXIf_buf == NULL) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } + + for (i = 0; i < length; i++) + { + png_byte buf[1]; + png_crc_read(png_ptr, buf, 1); + info_ptr->eXIf_buf[i] = buf[0]; + if (i == 1 && buf[0] != 'M' && buf[0] != 'I' + && info_ptr->eXIf_buf[0] != buf[0]) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "incorrect byte-order specifier"); + png_free(png_ptr, info_ptr->eXIf_buf); + info_ptr->eXIf_buf = NULL; + return; + } + } + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf); + + png_free(png_ptr, info_ptr->eXIf_buf); + info_ptr->eXIf_buf = NULL; +} +#endif + +#ifdef PNG_READ_hIST_SUPPORTED +void /* PRIVATE */ +png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + unsigned int num, i; + png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; + + png_debug(1, "in png_handle_hIST"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 || + (png_ptr->mode & PNG_HAVE_PLTE) == 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + num = length / 2 ; + + if (num != (unsigned int) png_ptr->num_palette || + num > (unsigned int) PNG_MAX_PALETTE_LENGTH) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + for (i = 0; i < num; i++) + { + png_byte buf[2]; + + png_crc_read(png_ptr, buf, 2); + readbuf[i] = png_get_uint_16(buf); + } + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + png_set_hIST(png_ptr, info_ptr, readbuf); +} +#endif + +#ifdef PNG_READ_pHYs_SUPPORTED +void /* PRIVATE */ +png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte buf[9]; + png_uint_32 res_x, res_y; + int unit_type; + + png_debug(1, "in png_handle_pHYs"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + if (length != 9) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 9); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + res_x = png_get_uint_32(buf); + res_y = png_get_uint_32(buf + 4); + unit_type = buf[8]; + png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); +} +#endif + +#ifdef PNG_READ_oFFs_SUPPORTED +void /* PRIVATE */ +png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte buf[9]; + png_int_32 offset_x, offset_y; + int unit_type; + + png_debug(1, "in png_handle_oFFs"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + if (length != 9) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 9); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + offset_x = png_get_int_32(buf); + offset_y = png_get_int_32(buf + 4); + unit_type = buf[8]; + png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); +} +#endif + +#ifdef PNG_READ_pCAL_SUPPORTED +/* Read the pCAL chunk (described in the PNG Extensions document) */ +void /* PRIVATE */ +png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_int_32 X0, X1; + png_byte type, nparams; + png_bytep buffer, buf, units, endptr; + png_charpp params; + int i; + + png_debug(1, "in png_handle_pCAL"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + png_debug1(2, "Allocating and reading pCAL chunk data (%u bytes)", + length + 1); + + buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); + + if (buffer == NULL) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } + + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + buffer[length] = 0; /* Null terminate the last string */ + + png_debug(3, "Finding end of pCAL purpose string"); + for (buf = buffer; *buf; buf++) + /* Empty loop */ ; + + endptr = buffer + length; + + /* We need to have at least 12 bytes after the purpose string + * in order to get the parameter information. + */ + if (endptr - buf <= 12) + { + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_debug(3, "Reading pCAL X0, X1, type, nparams, and units"); + X0 = png_get_int_32((png_bytep)buf+1); + X1 = png_get_int_32((png_bytep)buf+5); + type = buf[9]; + nparams = buf[10]; + units = buf + 11; + + png_debug(3, "Checking pCAL equation type and number of parameters"); + /* Check that we have the right number of parameters for known + * equation types. + */ + if ((type == PNG_EQUATION_LINEAR && nparams != 2) || + (type == PNG_EQUATION_BASE_E && nparams != 3) || + (type == PNG_EQUATION_ARBITRARY && nparams != 3) || + (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) + { + png_chunk_benign_error(png_ptr, "invalid parameter count"); + return; + } + + else if (type >= PNG_EQUATION_LAST) + { + png_chunk_benign_error(png_ptr, "unrecognized equation type"); + } + + for (buf = units; *buf; buf++) + /* Empty loop to move past the units string. */ ; + + png_debug(3, "Allocating pCAL parameters array"); + + params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, + nparams * (sizeof (png_charp)))); + + if (params == NULL) + { + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } + + /* Get pointers to the start of each parameter string. */ + for (i = 0; i < nparams; i++) + { + buf++; /* Skip the null string terminator from previous parameter. */ + + png_debug1(3, "Reading pCAL parameter %d", i); + + for (params[i] = (png_charp)buf; buf <= endptr && *buf != 0; buf++) + /* Empty loop to move past each parameter string */ ; + + /* Make sure we haven't run out of data yet */ + if (buf > endptr) + { + png_free(png_ptr, params); + png_chunk_benign_error(png_ptr, "invalid data"); + return; + } + } + + png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams, + (png_charp)units, params); + + png_free(png_ptr, params); +} +#endif + +#ifdef PNG_READ_sCAL_SUPPORTED +/* Read the sCAL chunk */ +void /* PRIVATE */ +png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_bytep buffer; + png_size_t i; + int state; + + png_debug(1, "in png_handle_sCAL"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + /* Need unit type, width, \0, height: minimum 4 bytes */ + else if (length < 4) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)", + length + 1); + + buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); + + if (buffer == NULL) + { + png_chunk_benign_error(png_ptr, "out of memory"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buffer, length); + buffer[length] = 0; /* Null terminate the last string */ + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* Validate the unit. */ + if (buffer[0] != 1 && buffer[0] != 2) + { + png_chunk_benign_error(png_ptr, "invalid unit"); + return; + } + + /* Validate the ASCII numbers, need two ASCII numbers separated by + * a '\0' and they need to fit exactly in the chunk data. + */ + i = 1; + state = 0; + + if (png_check_fp_number((png_const_charp)buffer, length, &state, &i) == 0 || + i >= length || buffer[i++] != 0) + png_chunk_benign_error(png_ptr, "bad width format"); + + else if (PNG_FP_IS_POSITIVE(state) == 0) + png_chunk_benign_error(png_ptr, "non-positive width"); + + else + { + png_size_t heighti = i; + + state = 0; + if (png_check_fp_number((png_const_charp)buffer, length, + &state, &i) == 0 || i != length) + png_chunk_benign_error(png_ptr, "bad height format"); + + else if (PNG_FP_IS_POSITIVE(state) == 0) + png_chunk_benign_error(png_ptr, "non-positive height"); + + else + /* This is the (only) success case. */ + png_set_sCAL_s(png_ptr, info_ptr, buffer[0], + (png_charp)buffer+1, (png_charp)buffer+heighti); + } +} +#endif + +#ifdef PNG_READ_tIME_SUPPORTED +void /* PRIVATE */ +png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte buf[7]; + png_time mod_time; + + png_debug(1, "in png_handle_tIME"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + png_ptr->mode |= PNG_AFTER_IDAT; + + if (length != 7) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 7); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + mod_time.second = buf[6]; + mod_time.minute = buf[5]; + mod_time.hour = buf[4]; + mod_time.day = buf[3]; + mod_time.month = buf[2]; + mod_time.year = png_get_uint_16(buf); + + png_set_tIME(png_ptr, info_ptr, &mod_time); +} +#endif + +#ifdef PNG_READ_tEXt_SUPPORTED +/* Note: this does not properly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_text text_info; + png_bytep buffer; + png_charp key; + png_charp text; + png_uint_32 skip = 0; + + png_debug(1, "in png_handle_tEXt"); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); + return; + } + } +#endif + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + png_ptr->mode |= PNG_AFTER_IDAT; + +#ifdef PNG_MAX_MALLOC_64K + if (length > 65535U) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too large to fit in memory"); + return; + } +#endif + + buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); + + if (buffer == NULL) + { + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } + + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, skip) != 0) + return; + + key = (png_charp)buffer; + key[length] = 0; + + for (text = key; *text; text++) + /* Empty loop to find end of key */ ; + + if (text != key + length) + text++; + + text_info.compression = PNG_TEXT_COMPRESSION_NONE; + text_info.key = key; + text_info.lang = NULL; + text_info.lang_key = NULL; + text_info.itxt_length = 0; + text_info.text = text; + text_info.text_length = strlen(text); + + if (png_set_text_2(png_ptr, info_ptr, &text_info, 1) != 0) + png_warning(png_ptr, "Insufficient memory to process text chunk"); +} +#endif + +#ifdef PNG_READ_zTXt_SUPPORTED +/* Note: this does not correctly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_const_charp errmsg = NULL; + png_bytep buffer; + png_uint_32 keyword_length; + + png_debug(1, "in png_handle_zTXt"); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); + return; + } + } +#endif + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + png_ptr->mode |= PNG_AFTER_IDAT; + + /* Note, "length" is sufficient here; we won't be adding + * a null terminator later. + */ + buffer = png_read_buffer(png_ptr, length, 2/*silent*/); + + if (buffer == NULL) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } + + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* TODO: also check that the keyword contents match the spec! */ + for (keyword_length = 0; + keyword_length < length && buffer[keyword_length] != 0; + ++keyword_length) + /* Empty loop to find end of name */ ; + + if (keyword_length > 79 || keyword_length < 1) + errmsg = "bad keyword"; + + /* zTXt must have some LZ data after the keyword, although it may expand to + * zero bytes; we need a '\0' at the end of the keyword, the compression type + * then the LZ data: + */ + else if (keyword_length + 3 > length) + errmsg = "truncated"; + + else if (buffer[keyword_length+1] != PNG_COMPRESSION_TYPE_BASE) + errmsg = "unknown compression type"; + + else + { + png_alloc_size_t uncompressed_length = PNG_SIZE_MAX; + + /* TODO: at present png_decompress_chunk imposes a single application + * level memory limit, this should be split to different values for iCCP + * and text chunks. + */ + if (png_decompress_chunk(png_ptr, length, keyword_length+2, + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + { + png_text text; + + if (png_ptr->read_buffer == NULL) + errmsg="Read failure in png_handle_zTXt"; + else + { + /* It worked; png_ptr->read_buffer now looks like a tEXt chunk + * except for the extra compression type byte and the fact that + * it isn't necessarily '\0' terminated. + */ + buffer = png_ptr->read_buffer; + buffer[uncompressed_length+(keyword_length+2)] = 0; + + text.compression = PNG_TEXT_COMPRESSION_zTXt; + text.key = (png_charp)buffer; + text.text = (png_charp)(buffer + keyword_length+2); + text.text_length = uncompressed_length; + text.itxt_length = 0; + text.lang = NULL; + text.lang_key = NULL; + + if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0) + errmsg = "insufficient memory"; + } + } + + else + errmsg = png_ptr->zstream.msg; + } + + if (errmsg != NULL) + png_chunk_benign_error(png_ptr, errmsg); +} +#endif + +#ifdef PNG_READ_iTXt_SUPPORTED +/* Note: this does not correctly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_const_charp errmsg = NULL; + png_bytep buffer; + png_uint_32 prefix_length; + + png_debug(1, "in png_handle_iTXt"); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); + return; + } + } +#endif + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + png_ptr->mode |= PNG_AFTER_IDAT; + + buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); + + if (buffer == NULL) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } + + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* First the keyword. */ + for (prefix_length=0; + prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* Perform a basic check on the keyword length here. */ + if (prefix_length > 79 || prefix_length < 1) + errmsg = "bad keyword"; + + /* Expect keyword, compression flag, compression type, language, translated + * keyword (both may be empty but are 0 terminated) then the text, which may + * be empty. + */ + else if (prefix_length + 5 > length) + errmsg = "truncated"; + + else if (buffer[prefix_length+1] == 0 || + (buffer[prefix_length+1] == 1 && + buffer[prefix_length+2] == PNG_COMPRESSION_TYPE_BASE)) + { + int compressed = buffer[prefix_length+1] != 0; + png_uint_32 language_offset, translated_keyword_offset; + png_alloc_size_t uncompressed_length = 0; + + /* Now the language tag */ + prefix_length += 3; + language_offset = prefix_length; + + for (; prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* WARNING: the length may be invalid here, this is checked below. */ + translated_keyword_offset = ++prefix_length; + + for (; prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* prefix_length should now be at the trailing '\0' of the translated + * keyword, but it may already be over the end. None of this arithmetic + * can overflow because chunks are at most 2^31 bytes long, but on 16-bit + * systems the available allocation may overflow. + */ + ++prefix_length; + + if (compressed == 0 && prefix_length <= length) + uncompressed_length = length - prefix_length; + + else if (compressed != 0 && prefix_length < length) + { + uncompressed_length = PNG_SIZE_MAX; + + /* TODO: at present png_decompress_chunk imposes a single application + * level memory limit, this should be split to different values for + * iCCP and text chunks. + */ + if (png_decompress_chunk(png_ptr, length, prefix_length, + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + buffer = png_ptr->read_buffer; + + else + errmsg = png_ptr->zstream.msg; + } + + else + errmsg = "truncated"; + + if (errmsg == NULL) + { + png_text text; + + buffer[uncompressed_length+prefix_length] = 0; + + if (compressed == 0) + text.compression = PNG_ITXT_COMPRESSION_NONE; + + else + text.compression = PNG_ITXT_COMPRESSION_zTXt; + + text.key = (png_charp)buffer; + text.lang = (png_charp)buffer + language_offset; + text.lang_key = (png_charp)buffer + translated_keyword_offset; + text.text = (png_charp)buffer + prefix_length; + text.text_length = 0; + text.itxt_length = uncompressed_length; + + if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0) + errmsg = "insufficient memory"; + } + } + + else + errmsg = "bad compression info"; + + if (errmsg != NULL) + png_chunk_benign_error(png_ptr, errmsg); +} +#endif + +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */ +static int +png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) +{ + png_alloc_size_t limit = PNG_SIZE_MAX; + + if (png_ptr->unknown_chunk.data != NULL) + { + png_free(png_ptr, png_ptr->unknown_chunk.data); + png_ptr->unknown_chunk.data = NULL; + } + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < limit) + limit = png_ptr->user_chunk_malloc_max; + +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + if (PNG_USER_CHUNK_MALLOC_MAX < limit) + limit = PNG_USER_CHUNK_MALLOC_MAX; +# endif + + if (length <= limit) + { + PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name); + /* The following is safe because of the PNG_SIZE_MAX init above */ + png_ptr->unknown_chunk.size = (png_size_t)length/*SAFE*/; + /* 'mode' is a flag array, only the bottom four bits matter here */ + png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/; + + if (length == 0) + png_ptr->unknown_chunk.data = NULL; + + else + { + /* Do a 'warn' here - it is handled below. */ + png_ptr->unknown_chunk.data = png_voidcast(png_bytep, + png_malloc_warn(png_ptr, length)); + } + } + + if (png_ptr->unknown_chunk.data == NULL && length > 0) + { + /* This is benign because we clean up correctly */ + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "unknown chunk exceeds memory limits"); + return 0; + } + + else + { + if (length > 0) + png_crc_read(png_ptr, png_ptr->unknown_chunk.data, length); + png_crc_finish(png_ptr, 0); + return 1; + } +} +#endif /* READ_UNKNOWN_CHUNKS */ + +/* Handle an unknown, or known but disabled, chunk */ +void /* PRIVATE */ +png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, + png_uint_32 length, int keep) +{ + int handled = 0; /* the chunk was handled */ + + png_debug(1, "in png_handle_unknown"); + +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED + /* NOTE: this code is based on the code in libpng-1.4.12 except for fixing + * the bug which meant that setting a non-default behavior for a specific + * chunk would be ignored (the default was always used unless a user + * callback was installed). + * + * 'keep' is the value from the png_chunk_unknown_handling, the setting for + * this specific chunk_name, if PNG_HANDLE_AS_UNKNOWN_SUPPORTED, if not it + * will always be PNG_HANDLE_CHUNK_AS_DEFAULT and it needs to be set here. + * This is just an optimization to avoid multiple calls to the lookup + * function. + */ +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name); +# endif +# endif + + /* One of the following methods will read the chunk or skip it (at least one + * of these is always defined because this is the only way to switch on + * PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + */ +# ifdef PNG_READ_USER_CHUNKS_SUPPORTED + /* The user callback takes precedence over the chunk keep value, but the + * keep value is still required to validate a save of a critical chunk. + */ + if (png_ptr->read_user_chunk_fn != NULL) + { + if (png_cache_unknown_chunk(png_ptr, length) != 0) + { + /* Callback to user unknown chunk handler */ + int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr, + &png_ptr->unknown_chunk); + + /* ret is: + * negative: An error occurred; png_chunk_error will be called. + * zero: The chunk was not handled, the chunk will be discarded + * unless png_set_keep_unknown_chunks has been used to set + * a 'keep' behavior for this particular chunk, in which + * case that will be used. A critical chunk will cause an + * error at this point unless it is to be saved. + * positive: The chunk was handled, libpng will ignore/discard it. + */ + if (ret < 0) + png_chunk_error(png_ptr, "error in user chunk"); + + else if (ret == 0) + { + /* If the keep value is 'default' or 'never' override it, but + * still error out on critical chunks unless the keep value is + * 'always' While this is weird it is the behavior in 1.4.12. + * A possible improvement would be to obey the value set for the + * chunk, but this would be an API change that would probably + * damage some applications. + * + * The png_app_warning below catches the case that matters, where + * the application has not set specific save or ignore for this + * chunk or global save or ignore. + */ + if (keep < PNG_HANDLE_CHUNK_IF_SAFE) + { +# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE) + { + png_chunk_warning(png_ptr, "Saving unknown chunk:"); + png_app_warning(png_ptr, + "forcing save of an unhandled chunk;" + " please call png_set_keep_unknown_chunks"); + /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ + } +# endif + keep = PNG_HANDLE_CHUNK_IF_SAFE; + } + } + + else /* chunk was handled */ + { + handled = 1; + /* Critical chunks can be safely discarded at this point. */ + keep = PNG_HANDLE_CHUNK_NEVER; + } + } + + else + keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */ + } + + else + /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */ +# endif /* READ_USER_CHUNKS */ + +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + { + /* keep is currently just the per-chunk setting, if there was no + * setting change it to the global default now (not that this may + * still be AS_DEFAULT) then obtain the cache of the chunk if required, + * if not simply skip the chunk. + */ + if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) + keep = png_ptr->unknown_default; + + if (keep == PNG_HANDLE_CHUNK_ALWAYS || + (keep == PNG_HANDLE_CHUNK_IF_SAFE && + PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))) + { + if (png_cache_unknown_chunk(png_ptr, length) == 0) + keep = PNG_HANDLE_CHUNK_NEVER; + } + + else + png_crc_finish(png_ptr, length); + } +# else +# ifndef PNG_READ_USER_CHUNKS_SUPPORTED +# error no method to support READ_UNKNOWN_CHUNKS +# endif + + { + /* If here there is no read callback pointer set and no support is + * compiled in to just save the unknown chunks, so simply skip this + * chunk. If 'keep' is something other than AS_DEFAULT or NEVER then + * the app has erroneously asked for unknown chunk saving when there + * is no support. + */ + if (keep > PNG_HANDLE_CHUNK_NEVER) + png_app_error(png_ptr, "no unknown chunk support available"); + + png_crc_finish(png_ptr, length); + } +# endif + +# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED + /* Now store the chunk in the chunk list if appropriate, and if the limits + * permit it. + */ + if (keep == PNG_HANDLE_CHUNK_ALWAYS || + (keep == PNG_HANDLE_CHUNK_IF_SAFE && + PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))) + { +# ifdef PNG_USER_LIMITS_SUPPORTED + switch (png_ptr->user_chunk_cache_max) + { + case 2: + png_ptr->user_chunk_cache_max = 1; + png_chunk_benign_error(png_ptr, "no space in chunk cache"); + /* FALLTHROUGH */ + case 1: + /* NOTE: prior to 1.6.0 this case resulted in an unknown critical + * chunk being skipped, now there will be a hard error below. + */ + break; + + default: /* not at limit */ + --(png_ptr->user_chunk_cache_max); + /* FALLTHROUGH */ + case 0: /* no limit */ +# endif /* USER_LIMITS */ + /* Here when the limit isn't reached or when limits are compiled + * out; store the chunk. + */ + png_set_unknown_chunks(png_ptr, info_ptr, + &png_ptr->unknown_chunk, 1); + handled = 1; +# ifdef PNG_USER_LIMITS_SUPPORTED + break; + } +# endif + } +# else /* no store support: the chunk must be handled by the user callback */ + PNG_UNUSED(info_ptr) +# endif + + /* Regardless of the error handling below the cached data (if any) can be + * freed now. Notice that the data is not freed if there is a png_error, but + * it will be freed by destroy_read_struct. + */ + if (png_ptr->unknown_chunk.data != NULL) + png_free(png_ptr, png_ptr->unknown_chunk.data); + png_ptr->unknown_chunk.data = NULL; + +#else /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ + /* There is no support to read an unknown chunk, so just skip it. */ + png_crc_finish(png_ptr, length); + PNG_UNUSED(info_ptr) + PNG_UNUSED(keep) +#endif /* !READ_UNKNOWN_CHUNKS */ + + /* Check for unhandled critical chunks */ + if (handled == 0 && PNG_CHUNK_CRITICAL(png_ptr->chunk_name)) + png_chunk_error(png_ptr, "unhandled critical chunk"); +} + +/* This function is called to verify that a chunk name is valid. + * This function can't have the "critical chunk check" incorporated + * into it, since in the future we will need to be able to call user + * functions to handle unknown critical chunks after we check that + * the chunk name itself is valid. + */ + +/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is: + * + * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) + */ + +void /* PRIVATE */ +png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name) +{ + int i; + png_uint_32 cn=chunk_name; + + png_debug(1, "in png_check_chunk_name"); + + for (i=1; i<=4; ++i) + { + int c = cn & 0xff; + + if (c < 65 || c > 122 || (c > 90 && c < 97)) + png_chunk_error(png_ptr, "invalid chunk type"); + + cn >>= 8; + } +} + +void /* PRIVATE */ +png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length) +{ + png_alloc_size_t limit = PNG_UINT_31_MAX; + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < limit) + limit = png_ptr->user_chunk_malloc_max; +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + if (PNG_USER_CHUNK_MALLOC_MAX < limit) + limit = PNG_USER_CHUNK_MALLOC_MAX; +# endif + if (png_ptr->chunk_name == png_IDAT) + { + png_alloc_size_t idat_limit = PNG_UINT_31_MAX; + size_t row_factor = + (png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1) + + 1 + (png_ptr->interlaced? 6: 0)); + if (png_ptr->height > PNG_UINT_32_MAX/row_factor) + idat_limit=PNG_UINT_31_MAX; + else + idat_limit = png_ptr->height * row_factor; + row_factor = row_factor > 32566? 32566 : row_factor; + idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */ + idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX; + limit = limit < idat_limit? idat_limit : limit; + } + + if (length > limit) + { + png_debug2(0," length = %lu, limit = %lu", + (unsigned long)length,(unsigned long)limit); + png_chunk_error(png_ptr, "chunk data is too large"); + } +} + +/* Combines the row recently read in with the existing pixels in the row. This + * routine takes care of alpha and transparency if requested. This routine also + * handles the two methods of progressive display of interlaced images, + * depending on the 'display' value; if 'display' is true then the whole row + * (dp) is filled from the start by replicating the available pixels. If + * 'display' is false only those pixels present in the pass are filled in. + */ +void /* PRIVATE */ +png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) +{ + unsigned int pixel_depth = png_ptr->transformed_pixel_depth; + png_const_bytep sp = png_ptr->row_buf + 1; + png_alloc_size_t row_width = png_ptr->width; + unsigned int pass = png_ptr->pass; + png_bytep end_ptr = 0; + png_byte end_byte = 0; + unsigned int end_mask; + + png_debug(1, "in png_combine_row"); + + /* Added in 1.5.6: it should not be possible to enter this routine until at + * least one row has been read from the PNG data and transformed. + */ + if (pixel_depth == 0) + png_error(png_ptr, "internal row logic error"); + + /* Added in 1.5.4: the pixel depth should match the information returned by + * any call to png_read_update_info at this point. Do not continue if we got + * this wrong. + */ + if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes != + PNG_ROWBYTES(pixel_depth, row_width)) + png_error(png_ptr, "internal row size calculation error"); + + /* Don't expect this to ever happen: */ + if (row_width == 0) + png_error(png_ptr, "internal row width error"); + + /* Preserve the last byte in cases where only part of it will be overwritten, + * the multiply below may overflow, we don't care because ANSI-C guarantees + * we get the low bits. + */ + end_mask = (pixel_depth * row_width) & 7; + if (end_mask != 0) + { + /* end_ptr == NULL is a flag to say do nothing */ + end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1; + end_byte = *end_ptr; +# ifdef PNG_READ_PACKSWAP_SUPPORTED + if ((png_ptr->transformations & PNG_PACKSWAP) != 0) + /* little-endian byte */ + end_mask = (unsigned int)(0xff << end_mask); + + else /* big-endian byte */ +# endif + end_mask = 0xff >> end_mask; + /* end_mask is now the bits to *keep* from the destination row */ + } + + /* For non-interlaced images this reduces to a memcpy(). A memcpy() + * will also happen if interlacing isn't supported or if the application + * does not call png_set_interlace_handling(). In the latter cases the + * caller just gets a sequence of the unexpanded rows from each interlace + * pass. + */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) != 0 && + pass < 6 && (display == 0 || + /* The following copies everything for 'display' on passes 0, 2 and 4. */ + (display == 1 && (pass & 1) != 0))) + { + /* Narrow images may have no bits in a pass; the caller should handle + * this, but this test is cheap: + */ + if (row_width <= PNG_PASS_START_COL(pass)) + return; + + if (pixel_depth < 8) + { + /* For pixel depths up to 4 bpp the 8-pixel mask can be expanded to fit + * into 32 bits, then a single loop over the bytes using the four byte + * values in the 32-bit mask can be used. For the 'display' option the + * expanded mask may also not require any masking within a byte. To + * make this work the PACKSWAP option must be taken into account - it + * simply requires the pixels to be reversed in each byte. + * + * The 'regular' case requires a mask for each of the first 6 passes, + * the 'display' case does a copy for the even passes in the range + * 0..6. This has already been handled in the test above. + * + * The masks are arranged as four bytes with the first byte to use in + * the lowest bits (little-endian) regardless of the order (PACKSWAP or + * not) of the pixels in each byte. + * + * NOTE: the whole of this logic depends on the caller of this function + * only calling it on rows appropriate to the pass. This function only + * understands the 'x' logic; the 'y' logic is handled by the caller. + * + * The following defines allow generation of compile time constant bit + * masks for each pixel depth and each possibility of swapped or not + * swapped bytes. Pass 'p' is in the range 0..6; 'x', a pixel index, + * is in the range 0..7; and the result is 1 if the pixel is to be + * copied in the pass, 0 if not. 'S' is for the sparkle method, 'B' + * for the block method. + * + * With some compilers a compile time expression of the general form: + * + * (shift >= 32) ? (a >> (shift-32)) : (b >> shift) + * + * Produces warnings with values of 'shift' in the range 33 to 63 + * because the right hand side of the ?: expression is evaluated by + * the compiler even though it isn't used. Microsoft Visual C (various + * versions) and the Intel C compiler are known to do this. To avoid + * this the following macros are used in 1.5.6. This is a temporary + * solution to avoid destabilizing the code during the release process. + */ +# if PNG_USE_COMPILE_TIME_MASKS +# define PNG_LSR(x,s) ((x)>>((s) & 0x1f)) +# define PNG_LSL(x,s) ((x)<<((s) & 0x1f)) +# else +# define PNG_LSR(x,s) ((x)>>(s)) +# define PNG_LSL(x,s) ((x)<<(s)) +# endif +# define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\ + PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1) +# define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\ + PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1) + + /* Return a mask for pass 'p' pixel 'x' at depth 'd'. The mask is + * little endian - the first pixel is at bit 0 - however the extra + * parameter 's' can be set to cause the mask position to be swapped + * within each byte, to match the PNG format. This is done by XOR of + * the shift with 7, 6 or 4 for bit depths 1, 2 and 4. + */ +# define PIXEL_MASK(p,x,d,s) \ + (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0)))) + + /* Hence generate the appropriate 'block' or 'sparkle' pixel copy mask. + */ +# define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) +# define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) + + /* Combine 8 of these to get the full mask. For the 1-bpp and 2-bpp + * cases the result needs replicating, for the 4-bpp case the above + * generates a full 32 bits. + */ +# define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1))) + +# define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\ + S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\ + S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d) + +# define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\ + B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\ + B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d) + +#if PNG_USE_COMPILE_TIME_MASKS + /* Utility macros to construct all the masks for a depth/swap + * combination. The 's' parameter says whether the format is PNG + * (big endian bytes) or not. Only the three odd-numbered passes are + * required for the display/block algorithm. + */ +# define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\ + S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) } + +# define B_MASKS(d,s) { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) } + +# define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2)) + + /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and + * then pass: + */ + static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] = + { + /* Little-endian byte masks for PACKSWAP */ + { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) }, + /* Normal (big-endian byte) masks - PNG format */ + { S_MASKS(1,1), S_MASKS(2,1), S_MASKS(4,1) } + }; + + /* display_mask has only three entries for the odd passes, so index by + * pass>>1. + */ + static PNG_CONST png_uint_32 display_mask[2][3][3] = + { + /* Little-endian byte masks for PACKSWAP */ + { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) }, + /* Normal (big-endian byte) masks - PNG format */ + { B_MASKS(1,1), B_MASKS(2,1), B_MASKS(4,1) } + }; + +# define MASK(pass,depth,display,png)\ + ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\ + row_mask[png][DEPTH_INDEX(depth)][pass]) + +#else /* !PNG_USE_COMPILE_TIME_MASKS */ + /* This is the runtime alternative: it seems unlikely that this will + * ever be either smaller or faster than the compile time approach. + */ +# define MASK(pass,depth,display,png)\ + ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png)) +#endif /* !USE_COMPILE_TIME_MASKS */ + + /* Use the appropriate mask to copy the required bits. In some cases + * the byte mask will be 0 or 0xff; optimize these cases. row_width is + * the number of pixels, but the code copies bytes, so it is necessary + * to special case the end. + */ + png_uint_32 pixels_per_byte = 8 / pixel_depth; + png_uint_32 mask; + +# ifdef PNG_READ_PACKSWAP_SUPPORTED + if ((png_ptr->transformations & PNG_PACKSWAP) != 0) + mask = MASK(pass, pixel_depth, display, 0); + + else +# endif + mask = MASK(pass, pixel_depth, display, 1); + + for (;;) + { + png_uint_32 m; + + /* It doesn't matter in the following if png_uint_32 has more than + * 32 bits because the high bits always match those in m<<24; it is, + * however, essential to use OR here, not +, because of this. + */ + m = mask; + mask = (m >> 8) | (m << 24); /* rotate right to good compilers */ + m &= 0xff; + + if (m != 0) /* something to copy */ + { + if (m != 0xff) + *dp = (png_byte)((*dp & ~m) | (*sp & m)); + else + *dp = *sp; + } + + /* NOTE: this may overwrite the last byte with garbage if the image + * is not an exact number of bytes wide; libpng has always done + * this. + */ + if (row_width <= pixels_per_byte) + break; /* May need to restore part of the last byte */ + + row_width -= pixels_per_byte; + ++dp; + ++sp; + } + } + + else /* pixel_depth >= 8 */ + { + unsigned int bytes_to_copy, bytes_to_jump; + + /* Validate the depth - it must be a multiple of 8 */ + if (pixel_depth & 7) + png_error(png_ptr, "invalid user transform pixel depth"); + + pixel_depth >>= 3; /* now in bytes */ + row_width *= pixel_depth; + + /* Regardless of pass number the Adam 7 interlace always results in a + * fixed number of pixels to copy then to skip. There may be a + * different number of pixels to skip at the start though. + */ + { + unsigned int offset = PNG_PASS_START_COL(pass) * pixel_depth; + + row_width -= offset; + dp += offset; + sp += offset; + } + + /* Work out the bytes to copy. */ + if (display != 0) + { + /* When doing the 'block' algorithm the pixel in the pass gets + * replicated to adjacent pixels. This is why the even (0,2,4,6) + * passes are skipped above - the entire expanded row is copied. + */ + bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth; + + /* But don't allow this number to exceed the actual row width. */ + if (bytes_to_copy > row_width) + bytes_to_copy = (unsigned int)/*SAFE*/row_width; + } + + else /* normal row; Adam7 only ever gives us one pixel to copy. */ + bytes_to_copy = pixel_depth; + + /* In Adam7 there is a constant offset between where the pixels go. */ + bytes_to_jump = PNG_PASS_COL_OFFSET(pass) * pixel_depth; + + /* And simply copy these bytes. Some optimization is possible here, + * depending on the value of 'bytes_to_copy'. Special case the low + * byte counts, which we know to be frequent. + * + * Notice that these cases all 'return' rather than 'break' - this + * avoids an unnecessary test on whether to restore the last byte + * below. + */ + switch (bytes_to_copy) + { + case 1: + for (;;) + { + *dp = *sp; + + if (row_width <= bytes_to_jump) + return; + + dp += bytes_to_jump; + sp += bytes_to_jump; + row_width -= bytes_to_jump; + } + + case 2: + /* There is a possibility of a partial copy at the end here; this + * slows the code down somewhat. + */ + do + { + dp[0] = sp[0]; dp[1] = sp[1]; + + if (row_width <= bytes_to_jump) + return; + + sp += bytes_to_jump; + dp += bytes_to_jump; + row_width -= bytes_to_jump; + } + while (row_width > 1); + + /* And there can only be one byte left at this point: */ + *dp = *sp; + return; + + case 3: + /* This can only be the RGB case, so each copy is exactly one + * pixel and it is not necessary to check for a partial copy. + */ + for (;;) + { + dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2]; + + if (row_width <= bytes_to_jump) + return; + + sp += bytes_to_jump; + dp += bytes_to_jump; + row_width -= bytes_to_jump; + } + + default: +#if PNG_ALIGN_TYPE != PNG_ALIGN_NONE + /* Check for double byte alignment and, if possible, use a + * 16-bit copy. Don't attempt this for narrow images - ones that + * are less than an interlace panel wide. Don't attempt it for + * wide bytes_to_copy either - use the memcpy there. + */ + if (bytes_to_copy < 16 /*else use memcpy*/ && + png_isaligned(dp, png_uint_16) && + png_isaligned(sp, png_uint_16) && + bytes_to_copy % (sizeof (png_uint_16)) == 0 && + bytes_to_jump % (sizeof (png_uint_16)) == 0) + { + /* Everything is aligned for png_uint_16 copies, but try for + * png_uint_32 first. + */ + if (png_isaligned(dp, png_uint_32) && + png_isaligned(sp, png_uint_32) && + bytes_to_copy % (sizeof (png_uint_32)) == 0 && + bytes_to_jump % (sizeof (png_uint_32)) == 0) + { + png_uint_32p dp32 = png_aligncast(png_uint_32p,dp); + png_const_uint_32p sp32 = png_aligncastconst( + png_const_uint_32p, sp); + size_t skip = (bytes_to_jump-bytes_to_copy) / + (sizeof (png_uint_32)); + + do + { + size_t c = bytes_to_copy; + do + { + *dp32++ = *sp32++; + c -= (sizeof (png_uint_32)); + } + while (c > 0); + + if (row_width <= bytes_to_jump) + return; + + dp32 += skip; + sp32 += skip; + row_width -= bytes_to_jump; + } + while (bytes_to_copy <= row_width); + + /* Get to here when the row_width truncates the final copy. + * There will be 1-3 bytes left to copy, so don't try the + * 16-bit loop below. + */ + dp = (png_bytep)dp32; + sp = (png_const_bytep)sp32; + do + *dp++ = *sp++; + while (--row_width > 0); + return; + } + + /* Else do it in 16-bit quantities, but only if the size is + * not too large. + */ + else + { + png_uint_16p dp16 = png_aligncast(png_uint_16p, dp); + png_const_uint_16p sp16 = png_aligncastconst( + png_const_uint_16p, sp); + size_t skip = (bytes_to_jump-bytes_to_copy) / + (sizeof (png_uint_16)); + + do + { + size_t c = bytes_to_copy; + do + { + *dp16++ = *sp16++; + c -= (sizeof (png_uint_16)); + } + while (c > 0); + + if (row_width <= bytes_to_jump) + return; + + dp16 += skip; + sp16 += skip; + row_width -= bytes_to_jump; + } + while (bytes_to_copy <= row_width); + + /* End of row - 1 byte left, bytes_to_copy > row_width: */ + dp = (png_bytep)dp16; + sp = (png_const_bytep)sp16; + do + *dp++ = *sp++; + while (--row_width > 0); + return; + } + } +#endif /* ALIGN_TYPE code */ + + /* The true default - use a memcpy: */ + for (;;) + { + memcpy(dp, sp, bytes_to_copy); + + if (row_width <= bytes_to_jump) + return; + + sp += bytes_to_jump; + dp += bytes_to_jump; + row_width -= bytes_to_jump; + if (bytes_to_copy > row_width) + bytes_to_copy = (unsigned int)/*SAFE*/row_width; + } + } + + /* NOT REACHED*/ + } /* pixel_depth >= 8 */ + + /* Here if pixel_depth < 8 to check 'end_ptr' below. */ + } + else +#endif /* READ_INTERLACING */ + + /* If here then the switch above wasn't used so just memcpy the whole row + * from the temporary row buffer (notice that this overwrites the end of the + * destination row if it is a partial byte.) + */ + memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width)); + + /* Restore the overwritten bits from the last byte if necessary. */ + if (end_ptr != NULL) + *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask)); +} + +#ifdef PNG_READ_INTERLACING_SUPPORTED +void /* PRIVATE */ +png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, + png_uint_32 transformations /* Because these may affect the byte layout */) +{ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Offset to next interlace block */ + static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + png_debug(1, "in png_do_read_interlace"); + if (row != NULL && row_info != NULL) + { + png_uint_32 final_width; + + final_width = row_info->width * png_pass_inc[pass]; + + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); + png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; + int jstop = (int)png_pass_inc[pass]; + png_byte v; + png_uint_32 i; + int j; + +#ifdef PNG_READ_PACKSWAP_SUPPORTED + if ((transformations & PNG_PACKSWAP) != 0) + { + sshift = ((row_info->width + 7) & 0x07); + dshift = ((final_width + 7) & 0x07); + s_start = 7; + s_end = 0; + s_inc = -1; + } + + else +#endif + { + sshift = 7 - ((row_info->width + 7) & 0x07); + dshift = 7 - ((final_width + 7) & 0x07); + s_start = 0; + s_end = 7; + s_inc = 1; + } + + for (i = 0; i < row_info->width; i++) + { + v = (png_byte)((*sp >> sshift) & 0x01); + for (j = 0; j < jstop; j++) + { + unsigned int tmp = *dp & (0x7f7f >> (7 - dshift)); + tmp |= (unsigned int)(v << dshift); + *dp = (png_byte)(tmp & 0xff); + + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + + else + dshift = (unsigned int)((int)dshift + s_inc); + } + + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + + else + sshift = (unsigned int)((int)sshift + s_inc); + } + break; + } + + case 2: + { + png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); + png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; + int jstop = (int)png_pass_inc[pass]; + png_uint_32 i; + +#ifdef PNG_READ_PACKSWAP_SUPPORTED + if ((transformations & PNG_PACKSWAP) != 0) + { + sshift = (((row_info->width + 3) & 0x03) << 1); + dshift = (((final_width + 3) & 0x03) << 1); + s_start = 6; + s_end = 0; + s_inc = -2; + } + + else +#endif + { + sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1); + dshift = ((3 - ((final_width + 3) & 0x03)) << 1); + s_start = 0; + s_end = 6; + s_inc = 2; + } + + for (i = 0; i < row_info->width; i++) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0x03); + for (j = 0; j < jstop; j++) + { + unsigned int tmp = *dp & (0x3f3f >> (6 - dshift)); + tmp |= (unsigned int)(v << dshift); + *dp = (png_byte)(tmp & 0xff); + + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + + else + dshift = (unsigned int)((int)dshift + s_inc); + } + + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + + else + sshift = (unsigned int)((int)sshift + s_inc); + } + break; + } + + case 4: + { + png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); + png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; + png_uint_32 i; + int jstop = (int)png_pass_inc[pass]; + +#ifdef PNG_READ_PACKSWAP_SUPPORTED + if ((transformations & PNG_PACKSWAP) != 0) + { + sshift = (((row_info->width + 1) & 0x01) << 2); + dshift = (((final_width + 1) & 0x01) << 2); + s_start = 4; + s_end = 0; + s_inc = -4; + } + + else +#endif + { + sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2); + dshift = ((1 - ((final_width + 1) & 0x01)) << 2); + s_start = 0; + s_end = 4; + s_inc = 4; + } + + for (i = 0; i < row_info->width; i++) + { + png_byte v = (png_byte)((*sp >> sshift) & 0x0f); + int j; + + for (j = 0; j < jstop; j++) + { + unsigned int tmp = *dp & (0xf0f >> (4 - dshift)); + tmp |= (unsigned int)(v << dshift); + *dp = (png_byte)(tmp & 0xff); + + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + + else + dshift = (unsigned int)((int)dshift + s_inc); + } + + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + + else + sshift = (unsigned int)((int)sshift + s_inc); + } + break; + } + + default: + { + png_size_t pixel_bytes = (row_info->pixel_depth >> 3); + + png_bytep sp = row + (png_size_t)(row_info->width - 1) + * pixel_bytes; + + png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; + + int jstop = (int)png_pass_inc[pass]; + png_uint_32 i; + + for (i = 0; i < row_info->width; i++) + { + png_byte v[8]; /* SAFE; pixel_depth does not exceed 64 */ + int j; + + memcpy(v, sp, pixel_bytes); + + for (j = 0; j < jstop; j++) + { + memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + + sp -= pixel_bytes; + } + break; + } + } + + row_info->width = final_width; + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width); + } +#ifndef PNG_READ_PACKSWAP_SUPPORTED + PNG_UNUSED(transformations) /* Silence compiler warning */ +#endif +} +#endif /* READ_INTERLACING */ + +static void +png_read_filter_row_sub(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i; + png_size_t istop = row_info->rowbytes; + unsigned int bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + + PNG_UNUSED(prev_row) + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); + rp++; + } +} + +static void +png_read_filter_row_up(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i; + png_size_t istop = row_info->rowbytes; + png_bytep rp = row; + png_const_bytep pp = prev_row; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } +} + +static void +png_read_filter_row_avg(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i; + png_bytep rp = row; + png_const_bytep pp = prev_row; + unsigned int bpp = (row_info->pixel_depth + 7) >> 3; + png_size_t istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + + rp++; + } +} + +static void +png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp_end = row + row_info->rowbytes; + int a, c; + + /* First pixel/byte */ + c = *prev_row++; + a = *row + c; + *row++ = (png_byte)a; + + /* Remainder */ + while (row < rp_end) + { + int b, pa, pb, pc, p; + + a &= 0xff; /* From previous iteration or start */ + b = *prev_row++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* Find the best predictor, the least of pa, pb, pc favoring the earlier + * ones in the case of a tie. + */ + if (pb < pa) + { + pa = pb; a = b; + } + if (pc < pa) a = c; + + /* Calculate the current pixel in a, and move the previous row pixel to c + * for the next time round the loop + */ + c = b; + a += *row; + *row++ = (png_byte)a; + } +} + +static void +png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + unsigned int bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp_end = row + bpp; + + /* Process the first pixel in the row completely (this is the same as 'up' + * because there is only one candidate predictor for the first row). + */ + while (row < rp_end) + { + int a = *row + *prev_row++; + *row++ = (png_byte)a; + } + + /* Remainder */ + rp_end = rp_end + (row_info->rowbytes - bpp); + + while (row < rp_end) + { + int a, b, c, pa, pb, pc, p; + + c = *(prev_row - bpp); + a = *(row - bpp); + b = *prev_row++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + if (pb < pa) + { + pa = pb; a = b; + } + if (pc < pa) a = c; + + a += *row; + *row++ = (png_byte)a; + } +} + +static void +png_init_filter_functions(png_structrp pp) + /* This function is called once for every PNG image (except for PNG images + * that only use PNG_FILTER_VALUE_NONE for all rows) to set the + * implementations required to reverse the filtering of PNG rows. Reversing + * the filter is the first transformation performed on the row data. It is + * performed in place, therefore an implementation can be selected based on + * the image pixel format. If the implementation depends on image width then + * take care to ensure that it works correctly if the image is interlaced - + * interlacing causes the actual row width to vary. + */ +{ + unsigned int bpp = (pp->pixel_depth + 7) >> 3; + + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub; + pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg; + if (bpp == 1) + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth_1byte_pixel; + else + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth_multibyte_pixel; + +#ifdef PNG_FILTER_OPTIMIZATIONS + /* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to + * call to install hardware optimizations for the above functions; simply + * replace whatever elements of the pp->read_filter[] array with a hardware + * specific (or, for that matter, generic) optimization. + * + * To see an example of this examine what configure.ac does when + * --enable-arm-neon is specified on the command line. + */ + PNG_FILTER_OPTIMIZATIONS(pp, bpp); +#endif +} + +void /* PRIVATE */ +png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, + png_const_bytep prev_row, int filter) +{ + /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define + * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic + * implementations. See png_init_filter_functions above. + */ + if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST) + { + if (pp->read_filter[0] == NULL) + png_init_filter_functions(pp); + + pp->read_filter[filter-1](row_info, row, prev_row); + } +} + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +void /* PRIVATE */ +png_read_IDAT_data(png_structrp png_ptr, png_bytep output, + png_alloc_size_t avail_out) +{ + /* Loop reading IDATs and decompressing the result into output[avail_out] */ + png_ptr->zstream.next_out = output; + png_ptr->zstream.avail_out = 0; /* safety: set below */ + + if (output == NULL) + avail_out = 0; + + do + { + int ret; + png_byte tmpbuf[PNG_INFLATE_BUF_SIZE]; + + if (png_ptr->zstream.avail_in == 0) + { + uInt avail_in; + png_bytep buffer; + + while (png_ptr->idat_size == 0) + { + png_crc_finish(png_ptr, 0); + + png_ptr->idat_size = png_read_chunk_header(png_ptr); + /* This is an error even in the 'check' case because the code just + * consumed a non-IDAT header. + */ + if (png_ptr->chunk_name != png_IDAT) + png_error(png_ptr, "Not enough image data"); + } + + avail_in = png_ptr->IDAT_read_size; + + if (avail_in > png_ptr->idat_size) + avail_in = (uInt)png_ptr->idat_size; + + /* A PNG with a gradually increasing IDAT size will defeat this attempt + * to minimize memory usage by causing lots of re-allocs, but + * realistically doing IDAT_read_size re-allocs is not likely to be a + * big problem. + */ + buffer = png_read_buffer(png_ptr, avail_in, 0/*error*/); + + png_crc_read(png_ptr, buffer, avail_in); + png_ptr->idat_size -= avail_in; + + png_ptr->zstream.next_in = buffer; + png_ptr->zstream.avail_in = avail_in; + } + + /* And set up the output side. */ + if (output != NULL) /* standard read */ + { + uInt out = ZLIB_IO_MAX; + + if (out > avail_out) + out = (uInt)avail_out; + + avail_out -= out; + png_ptr->zstream.avail_out = out; + } + + else /* after last row, checking for end */ + { + png_ptr->zstream.next_out = tmpbuf; + png_ptr->zstream.avail_out = (sizeof tmpbuf); + } + + /* Use NO_FLUSH; this gives zlib the maximum opportunity to optimize the + * process. If the LZ stream is truncated the sequential reader will + * terminally damage the stream, above, by reading the chunk header of the + * following chunk (it then exits with png_error). + * + * TODO: deal more elegantly with truncated IDAT lists. + */ + ret = PNG_INFLATE(png_ptr, Z_NO_FLUSH); + + /* Take the unconsumed output back. */ + if (output != NULL) + avail_out += png_ptr->zstream.avail_out; + + else /* avail_out counts the extra bytes */ + avail_out += (sizeof tmpbuf) - png_ptr->zstream.avail_out; + + png_ptr->zstream.avail_out = 0; + + if (ret == Z_STREAM_END) + { + /* Do this for safety; we won't read any more into this row. */ + png_ptr->zstream.next_out = NULL; + + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + + if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0) + png_chunk_benign_error(png_ptr, "Extra compressed data"); + break; + } + + if (ret != Z_OK) + { + png_zstream_error(png_ptr, ret); + + if (output != NULL) + png_chunk_error(png_ptr, png_ptr->zstream.msg); + + else /* checking */ + { + png_chunk_benign_error(png_ptr, png_ptr->zstream.msg); + return; + } + } + } while (avail_out > 0); + + if (avail_out > 0) + { + /* The stream ended before the image; this is the same as too few IDATs so + * should be handled the same way. + */ + if (output != NULL) + png_error(png_ptr, "Not enough image data"); + + else /* the deflate stream contained extra data */ + png_chunk_benign_error(png_ptr, "Too much image data"); + } +} + +void /* PRIVATE */ +png_read_finish_IDAT(png_structrp png_ptr) +{ + /* We don't need any more data and the stream should have ended, however the + * LZ end code may actually not have been processed. In this case we must + * read it otherwise stray unread IDAT data or, more likely, an IDAT chunk + * may still remain to be consumed. + */ + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) + { + /* The NULL causes png_read_IDAT_data to swallow any remaining bytes in + * the compressed stream, but the stream may be damaged too, so even after + * this call we may need to terminate the zstream ownership. + */ + png_read_IDAT_data(png_ptr, NULL, 0); + png_ptr->zstream.next_out = NULL; /* safety */ + + /* Now clear everything out for safety; the following may not have been + * done. + */ + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) + { + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + } + } + + /* If the zstream has not been released do it now *and* terminate the reading + * of the final IDAT chunk. + */ + if (png_ptr->zowner == png_IDAT) + { + /* Always do this; the pointers otherwise point into the read buffer. */ + png_ptr->zstream.next_in = NULL; + png_ptr->zstream.avail_in = 0; + + /* Now we no longer own the zstream. */ + png_ptr->zowner = 0; + + /* The slightly weird semantics of the sequential IDAT reading is that we + * are always in or at the end of an IDAT chunk, so we always need to do a + * crc_finish here. If idat_size is non-zero we also need to read the + * spurious bytes at the end of the chunk now. + */ + (void)png_crc_finish(png_ptr, png_ptr->idat_size); + } +} + +void /* PRIVATE */ +png_read_finish_row(png_structrp png_ptr) +{ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + + png_debug(1, "in png_read_finish_row"); + png_ptr->row_number++; + if (png_ptr->row_number < png_ptr->num_rows) + return; + + if (png_ptr->interlaced != 0) + { + png_ptr->row_number = 0; + + /* TO DO: don't do this if prev_row isn't needed (requires + * read-ahead of the next row's filter byte. + */ + memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + + do + { + png_ptr->pass++; + + if (png_ptr->pass >= 7) + break; + + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + if ((png_ptr->transformations & PNG_INTERLACE) == 0) + { + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + } + + else /* if (png_ptr->transformations & PNG_INTERLACE) */ + break; /* libpng deinterlacing sees every row */ + + } while (png_ptr->num_rows == 0 || png_ptr->iwidth == 0); + + if (png_ptr->pass < 7) + return; + } + + /* Here after at the end of the last row of the last pass. */ + png_read_finish_IDAT(png_ptr); +} +#endif /* SEQUENTIAL_READ */ + +void /* PRIVATE */ +png_read_start_row(png_structrp png_ptr) +{ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + + unsigned int max_pixel_depth; + png_size_t row_bytes; + + png_debug(1, "in png_read_start_row"); + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + png_init_read_transformations(png_ptr); +#endif + if (png_ptr->interlaced != 0) + { + if ((png_ptr->transformations & PNG_INTERLACE) == 0) + png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - + png_pass_ystart[0]) / png_pass_yinc[0]; + + else + png_ptr->num_rows = png_ptr->height; + + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + } + + else + { + png_ptr->num_rows = png_ptr->height; + png_ptr->iwidth = png_ptr->width; + } + + max_pixel_depth = (unsigned int)png_ptr->pixel_depth; + + /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of + * calculations to calculate the final pixel depth, then + * png_do_read_transforms actually does the transforms. This means that the + * code which effectively calculates this value is actually repeated in three + * separate places. They must all match. Innocent changes to the order of + * transformations can and will break libpng in a way that causes memory + * overwrites. + * + * TODO: fix this. + */ +#ifdef PNG_READ_PACK_SUPPORTED + if ((png_ptr->transformations & PNG_PACK) != 0 && png_ptr->bit_depth < 8) + max_pixel_depth = 8; +#endif + +#ifdef PNG_READ_EXPAND_SUPPORTED + if ((png_ptr->transformations & PNG_EXPAND) != 0) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (png_ptr->num_trans != 0) + max_pixel_depth = 32; + + else + max_pixel_depth = 24; + } + + else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + if (max_pixel_depth < 8) + max_pixel_depth = 8; + + if (png_ptr->num_trans != 0) + max_pixel_depth *= 2; + } + + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + if (png_ptr->num_trans != 0) + { + max_pixel_depth *= 4; + max_pixel_depth /= 3; + } + } + } +#endif + +#ifdef PNG_READ_EXPAND_16_SUPPORTED + if ((png_ptr->transformations & PNG_EXPAND_16) != 0) + { +# ifdef PNG_READ_EXPAND_SUPPORTED + /* In fact it is an error if it isn't supported, but checking is + * the safe way. + */ + if ((png_ptr->transformations & PNG_EXPAND) != 0) + { + if (png_ptr->bit_depth < 16) + max_pixel_depth *= 2; + } + else +# endif + png_ptr->transformations &= ~PNG_EXPAND_16; + } +#endif + +#ifdef PNG_READ_FILLER_SUPPORTED + if ((png_ptr->transformations & (PNG_FILLER)) != 0) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + if (max_pixel_depth <= 8) + max_pixel_depth = 16; + + else + max_pixel_depth = 32; + } + + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB || + png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (max_pixel_depth <= 32) + max_pixel_depth = 32; + + else + max_pixel_depth = 64; + } + } +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0) + { + if ( +#ifdef PNG_READ_EXPAND_SUPPORTED + (png_ptr->num_trans != 0 && + (png_ptr->transformations & PNG_EXPAND) != 0) || +#endif +#ifdef PNG_READ_FILLER_SUPPORTED + (png_ptr->transformations & (PNG_FILLER)) != 0 || +#endif + png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (max_pixel_depth <= 16) + max_pixel_depth = 32; + + else + max_pixel_depth = 64; + } + + else + { + if (max_pixel_depth <= 8) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + max_pixel_depth = 32; + + else + max_pixel_depth = 24; + } + + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + max_pixel_depth = 64; + + else + max_pixel_depth = 48; + } + } +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ +defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) + { + unsigned int user_pixel_depth = png_ptr->user_transform_depth * + png_ptr->user_transform_channels; + + if (user_pixel_depth > max_pixel_depth) + max_pixel_depth = user_pixel_depth; + } +#endif + + /* This value is stored in png_struct and double checked in the row read + * code. + */ + png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth; + png_ptr->transformed_pixel_depth = 0; /* calculated on demand */ + + /* Align the width on the next larger 8 pixels. Mainly used + * for interlacing + */ + row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); + /* Calculate the maximum bytes needed, adding a byte and a pixel + * for safety's sake + */ + row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) + + 1 + ((max_pixel_depth + 7) >> 3U); + +#ifdef PNG_MAX_MALLOC_64K + if (row_bytes > (png_uint_32)65536L) + png_error(png_ptr, "This image requires a row greater than 64KB"); +#endif + + if (row_bytes + 48 > png_ptr->old_big_row_buf_size) + { + png_free(png_ptr, png_ptr->big_row_buf); + png_free(png_ptr, png_ptr->big_prev_row); + + if (png_ptr->interlaced != 0) + png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, + row_bytes + 48); + + else + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48); + + png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48); + +#ifdef PNG_ALIGNED_MEMORY_SUPPORTED + /* Use 16-byte aligned memory for row_buf with at least 16 bytes + * of padding before and after row_buf; treat prev_row similarly. + * NOTE: the alignment is to the start of the pixels, one beyond the start + * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this + * was incorrect; the filter byte was aligned, which had the exact + * opposite effect of that intended. + */ + { + png_bytep temp = png_ptr->big_row_buf + 32; + int extra = (int)((temp - (png_bytep)0) & 0x0f); + png_ptr->row_buf = temp - extra - 1/*filter byte*/; + + temp = png_ptr->big_prev_row + 32; + extra = (int)((temp - (png_bytep)0) & 0x0f); + png_ptr->prev_row = temp - extra - 1/*filter byte*/; + } + +#else + /* Use 31 bytes of padding before and 17 bytes after row_buf. */ + png_ptr->row_buf = png_ptr->big_row_buf + 31; + png_ptr->prev_row = png_ptr->big_prev_row + 31; +#endif + png_ptr->old_big_row_buf_size = row_bytes + 48; + } + +#ifdef PNG_MAX_MALLOC_64K + if (png_ptr->rowbytes > 65535) + png_error(png_ptr, "This image requires a row greater than 64KB"); + +#endif + if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1)) + png_error(png_ptr, "Row has too many bytes to allocate in memory"); + + memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + + png_debug1(3, "width = %u,", png_ptr->width); + png_debug1(3, "height = %u,", png_ptr->height); + png_debug1(3, "iwidth = %u,", png_ptr->iwidth); + png_debug1(3, "num_rows = %u,", png_ptr->num_rows); + png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes); + png_debug1(3, "irowbytes = %lu", + (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1); + + /* The sequential reader needs a buffer for IDAT, but the progressive reader + * does not, so free the read buffer now regardless; the sequential reader + * reallocates it on demand. + */ + if (png_ptr->read_buffer != NULL) + { + png_bytep buffer = png_ptr->read_buffer; + + png_ptr->read_buffer_size = 0; + png_ptr->read_buffer = NULL; + png_free(png_ptr, buffer); + } + + /* Finally claim the zstream for the inflate of the IDAT data, use the bits + * value from the stream (note that this will result in a fatal error if the + * IDAT stream has a bogus deflate header window_bits value, but this should + * not be happening any longer!) + */ + if (png_inflate_claim(png_ptr, png_IDAT) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); + + png_ptr->flags |= PNG_FLAG_ROW_INIT; +} +#endif /* READ */ diff --git a/xs/src/png/libpng/pngset.c b/xs/src/png/libpng/pngset.c new file mode 100644 index 0000000000..6f3a1ee11e --- /dev/null +++ b/xs/src/png/libpng/pngset.c @@ -0,0 +1,1802 @@ + +/* pngset.c - storage of image information into info struct + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * The functions here are used during reads to store data from the file + * into the info struct, and during writes to store application data + * into the info struct for writing into the file. This abstracts the + * info struct and allows us to change the structure in the future. + */ + +#include "pngpriv.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +#ifdef PNG_bKGD_SUPPORTED +void PNGAPI +png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_color_16p background) +{ + png_debug1(1, "in %s storage function", "bKGD"); + + if (png_ptr == NULL || info_ptr == NULL || background == NULL) + return; + + info_ptr->background = *background; + info_ptr->valid |= PNG_INFO_bKGD; +} +#endif + +#ifdef PNG_cHRM_SUPPORTED +void PNGFAPI +png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, + png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, + png_fixed_point blue_x, png_fixed_point blue_y) +{ + png_xy xy; + + png_debug1(1, "in %s storage function", "cHRM fixed"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + xy.redx = red_x; + xy.redy = red_y; + xy.greenx = green_x; + xy.greeny = green_y; + xy.bluex = blue_x; + xy.bluey = blue_y; + xy.whitex = white_x; + xy.whitey = white_y; + + if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy, + 2/* override with app values*/) != 0) + info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; + + png_colorspace_sync_info(png_ptr, info_ptr); +} + +void PNGFAPI +png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + png_fixed_point int_red_X, png_fixed_point int_red_Y, + png_fixed_point int_red_Z, png_fixed_point int_green_X, + png_fixed_point int_green_Y, png_fixed_point int_green_Z, + png_fixed_point int_blue_X, png_fixed_point int_blue_Y, + png_fixed_point int_blue_Z) +{ + png_XYZ XYZ; + + png_debug1(1, "in %s storage function", "cHRM XYZ fixed"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + XYZ.red_X = int_red_X; + XYZ.red_Y = int_red_Y; + XYZ.red_Z = int_red_Z; + XYZ.green_X = int_green_X; + XYZ.green_Y = int_green_Y; + XYZ.green_Z = int_green_Z; + XYZ.blue_X = int_blue_X; + XYZ.blue_Y = int_blue_Y; + XYZ.blue_Z = int_blue_Z; + + if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace, + &XYZ, 2) != 0) + info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; + + png_colorspace_sync_info(png_ptr, info_ptr); +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, + double white_x, double white_y, double red_x, double red_y, + double green_x, double green_y, double blue_x, double blue_y) +{ + png_set_cHRM_fixed(png_ptr, info_ptr, + png_fixed(png_ptr, white_x, "cHRM White X"), + png_fixed(png_ptr, white_y, "cHRM White Y"), + png_fixed(png_ptr, red_x, "cHRM Red X"), + png_fixed(png_ptr, red_y, "cHRM Red Y"), + png_fixed(png_ptr, green_x, "cHRM Green X"), + png_fixed(png_ptr, green_y, "cHRM Green Y"), + png_fixed(png_ptr, blue_x, "cHRM Blue X"), + png_fixed(png_ptr, blue_y, "cHRM Blue Y")); +} + +void PNGAPI +png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, + double red_Y, double red_Z, double green_X, double green_Y, double green_Z, + double blue_X, double blue_Y, double blue_Z) +{ + png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, + png_fixed(png_ptr, red_X, "cHRM Red X"), + png_fixed(png_ptr, red_Y, "cHRM Red Y"), + png_fixed(png_ptr, red_Z, "cHRM Red Z"), + png_fixed(png_ptr, green_X, "cHRM Green X"), + png_fixed(png_ptr, green_Y, "cHRM Green Y"), + png_fixed(png_ptr, green_Z, "cHRM Green Z"), + png_fixed(png_ptr, blue_X, "cHRM Blue X"), + png_fixed(png_ptr, blue_Y, "cHRM Blue Y"), + png_fixed(png_ptr, blue_Z, "cHRM Blue Z")); +} +# endif /* FLOATING_POINT */ + +#endif /* cHRM */ + +#ifdef PNG_eXIf_SUPPORTED +void PNGAPI +png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, + const png_bytep eXIf_buf) +{ + png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1"); + PNG_UNUSED(info_ptr) + PNG_UNUSED(eXIf_buf) +} + +void PNGAPI +png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr, + const png_uint_32 num_exif, const png_bytep eXIf_buf) +{ + int i; + + png_debug1(1, "in %s storage function", "eXIf"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (info_ptr->exif) + { + png_free(png_ptr, info_ptr->exif); + info_ptr->exif = NULL; + } + + info_ptr->num_exif = num_exif; + + info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr, + info_ptr->num_exif)); + + if (info_ptr->exif == NULL) + { + png_warning(png_ptr, "Insufficient memory for eXIf chunk data"); + return; + } + + info_ptr->free_me |= PNG_FREE_EXIF; + + for (i = 0; i < (int) info_ptr->num_exif; i++) + info_ptr->exif[i] = eXIf_buf[i]; + + info_ptr->valid |= PNG_INFO_eXIf; +} +#endif /* eXIf */ + +#ifdef PNG_gAMA_SUPPORTED +void PNGFAPI +png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + png_fixed_point file_gamma) +{ + png_debug1(1, "in %s storage function", "gAMA"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma); + png_colorspace_sync_info(png_ptr, info_ptr); +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_gAMA(png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma) +{ + png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma, + "png_set_gAMA")); +} +# endif +#endif + +#ifdef PNG_hIST_SUPPORTED +void PNGAPI +png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_uint_16p hist) +{ + int i; + + png_debug1(1, "in %s storage function", "hIST"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (info_ptr->num_palette == 0 || info_ptr->num_palette + > PNG_MAX_PALETTE_LENGTH) + { + png_warning(png_ptr, + "Invalid palette size, hIST allocation skipped"); + + return; + } + + png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); + + /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in + * version 1.2.1 + */ + info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr, + PNG_MAX_PALETTE_LENGTH * (sizeof (png_uint_16)))); + + if (info_ptr->hist == NULL) + { + png_warning(png_ptr, "Insufficient memory for hIST chunk data"); + + return; + } + + info_ptr->free_me |= PNG_FREE_HIST; + + for (i = 0; i < info_ptr->num_palette; i++) + info_ptr->hist[i] = hist[i]; + + info_ptr->valid |= PNG_INFO_hIST; +} +#endif + +void PNGAPI +png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) +{ + png_debug1(1, "in %s storage function", "IHDR"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->width = width; + info_ptr->height = height; + info_ptr->bit_depth = (png_byte)bit_depth; + info_ptr->color_type = (png_byte)color_type; + info_ptr->compression_type = (png_byte)compression_type; + info_ptr->filter_type = (png_byte)filter_type; + info_ptr->interlace_type = (png_byte)interlace_type; + + png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, + info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, + info_ptr->compression_type, info_ptr->filter_type); + + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + info_ptr->channels = 1; + + else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + info_ptr->channels = 3; + + else + info_ptr->channels = 1; + + if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) + info_ptr->channels++; + + info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); + + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); +} + +#ifdef PNG_oFFs_SUPPORTED +void PNGAPI +png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr, + png_int_32 offset_x, png_int_32 offset_y, int unit_type) +{ + png_debug1(1, "in %s storage function", "oFFs"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->x_offset = offset_x; + info_ptr->y_offset = offset_y; + info_ptr->offset_unit_type = (png_byte)unit_type; + info_ptr->valid |= PNG_INFO_oFFs; +} +#endif + +#ifdef PNG_pCAL_SUPPORTED +void PNGAPI +png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, + int nparams, png_const_charp units, png_charpp params) +{ + png_size_t length; + int i; + + png_debug1(1, "in %s storage function", "pCAL"); + + if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL + || (nparams > 0 && params == NULL)) + return; + + length = strlen(purpose) + 1; + png_debug1(3, "allocating purpose for info (%lu bytes)", + (unsigned long)length); + + /* TODO: validate format of calibration name and unit name */ + + /* Check that the type matches the specification. */ + if (type < 0 || type > 3) + { + png_chunk_report(png_ptr, "Invalid pCAL equation type", + PNG_CHUNK_WRITE_ERROR); + return; + } + + if (nparams < 0 || nparams > 255) + { + png_chunk_report(png_ptr, "Invalid pCAL parameter count", + PNG_CHUNK_WRITE_ERROR); + return; + } + + /* Validate params[nparams] */ + for (i=0; ipcal_purpose = png_voidcast(png_charp, + png_malloc_warn(png_ptr, length)); + + if (info_ptr->pcal_purpose == NULL) + { + png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose", + PNG_CHUNK_WRITE_ERROR); + return; + } + + memcpy(info_ptr->pcal_purpose, purpose, length); + + png_debug(3, "storing X0, X1, type, and nparams in info"); + info_ptr->pcal_X0 = X0; + info_ptr->pcal_X1 = X1; + info_ptr->pcal_type = (png_byte)type; + info_ptr->pcal_nparams = (png_byte)nparams; + + length = strlen(units) + 1; + png_debug1(3, "allocating units for info (%lu bytes)", + (unsigned long)length); + + info_ptr->pcal_units = png_voidcast(png_charp, + png_malloc_warn(png_ptr, length)); + + if (info_ptr->pcal_units == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL units"); + + return; + } + + memcpy(info_ptr->pcal_units, units, length); + + info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, + (png_size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp))))); + + if (info_ptr->pcal_params == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL params"); + + return; + } + + memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) * + (sizeof (png_charp))); + + for (i = 0; i < nparams; i++) + { + length = strlen(params[i]) + 1; + png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, + (unsigned long)length); + + info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); + + if (info_ptr->pcal_params[i] == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL parameter"); + + return; + } + + memcpy(info_ptr->pcal_params[i], params[i], length); + } + + info_ptr->valid |= PNG_INFO_pCAL; + info_ptr->free_me |= PNG_FREE_PCAL; +} +#endif + +#ifdef PNG_sCAL_SUPPORTED +void PNGAPI +png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, + int unit, png_const_charp swidth, png_const_charp sheight) +{ + png_size_t lengthw = 0, lengthh = 0; + + png_debug1(1, "in %s storage function", "sCAL"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* Double check the unit (should never get here with an invalid + * unit unless this is an API call.) + */ + if (unit != 1 && unit != 2) + png_error(png_ptr, "Invalid sCAL unit"); + + if (swidth == NULL || (lengthw = strlen(swidth)) == 0 || + swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw)) + png_error(png_ptr, "Invalid sCAL width"); + + if (sheight == NULL || (lengthh = strlen(sheight)) == 0 || + sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh)) + png_error(png_ptr, "Invalid sCAL height"); + + info_ptr->scal_unit = (png_byte)unit; + + ++lengthw; + + png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw); + + info_ptr->scal_s_width = png_voidcast(png_charp, + png_malloc_warn(png_ptr, lengthw)); + + if (info_ptr->scal_s_width == NULL) + { + png_warning(png_ptr, "Memory allocation failed while processing sCAL"); + + return; + } + + memcpy(info_ptr->scal_s_width, swidth, lengthw); + + ++lengthh; + + png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh); + + info_ptr->scal_s_height = png_voidcast(png_charp, + png_malloc_warn(png_ptr, lengthh)); + + if (info_ptr->scal_s_height == NULL) + { + png_free (png_ptr, info_ptr->scal_s_width); + info_ptr->scal_s_width = NULL; + + png_warning(png_ptr, "Memory allocation failed while processing sCAL"); + + return; + } + + memcpy(info_ptr->scal_s_height, sheight, lengthh); + + info_ptr->valid |= PNG_INFO_sCAL; + info_ptr->free_me |= PNG_FREE_SCAL; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit, + double width, double height) +{ + png_debug1(1, "in %s storage function", "sCAL"); + + /* Check the arguments. */ + if (width <= 0) + png_warning(png_ptr, "Invalid sCAL width ignored"); + + else if (height <= 0) + png_warning(png_ptr, "Invalid sCAL height ignored"); + + else + { + /* Convert 'width' and 'height' to ASCII. */ + char swidth[PNG_sCAL_MAX_DIGITS+1]; + char sheight[PNG_sCAL_MAX_DIGITS+1]; + + png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width, + PNG_sCAL_PRECISION); + png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height, + PNG_sCAL_PRECISION); + + png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); + } +} +# endif + +# ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit, + png_fixed_point width, png_fixed_point height) +{ + png_debug1(1, "in %s storage function", "sCAL"); + + /* Check the arguments. */ + if (width <= 0) + png_warning(png_ptr, "Invalid sCAL width ignored"); + + else if (height <= 0) + png_warning(png_ptr, "Invalid sCAL height ignored"); + + else + { + /* Convert 'width' and 'height' to ASCII. */ + char swidth[PNG_sCAL_MAX_DIGITS+1]; + char sheight[PNG_sCAL_MAX_DIGITS+1]; + + png_ascii_from_fixed(png_ptr, swidth, (sizeof swidth), width); + png_ascii_from_fixed(png_ptr, sheight, (sizeof sheight), height); + + png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); + } +} +# endif +#endif + +#ifdef PNG_pHYs_SUPPORTED +void PNGAPI +png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr, + png_uint_32 res_x, png_uint_32 res_y, int unit_type) +{ + png_debug1(1, "in %s storage function", "pHYs"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->x_pixels_per_unit = res_x; + info_ptr->y_pixels_per_unit = res_y; + info_ptr->phys_unit_type = (png_byte)unit_type; + info_ptr->valid |= PNG_INFO_pHYs; +} +#endif + +void PNGAPI +png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, + png_const_colorp palette, int num_palette) +{ + + png_uint_32 max_palette_length; + + png_debug1(1, "in %s storage function", "PLTE"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + max_palette_length = (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ? + (1 << info_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH; + + if (num_palette < 0 || num_palette > (int) max_palette_length) + { + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + png_error(png_ptr, "Invalid palette length"); + + else + { + png_warning(png_ptr, "Invalid palette length"); + + return; + } + } + + if ((num_palette > 0 && palette == NULL) || + (num_palette == 0 +# ifdef PNG_MNG_FEATURES_SUPPORTED + && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 +# endif + )) + { + png_error(png_ptr, "Invalid palette"); + } + + /* It may not actually be necessary to set png_ptr->palette here; + * we do it for backward compatibility with the way the png_handle_tRNS + * function used to do the allocation. + * + * 1.6.0: the above statement appears to be incorrect; something has to set + * the palette inside png_struct on read. + */ + png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); + + /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead + * of num_palette entries, in case of an invalid PNG file or incorrect + * call to png_set_PLTE() with too-large sample values. + */ + png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr, + PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)))); + + if (num_palette > 0) + memcpy(png_ptr->palette, palette, (unsigned int)num_palette * + (sizeof (png_color))); + info_ptr->palette = png_ptr->palette; + info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; + + info_ptr->free_me |= PNG_FREE_PLTE; + + info_ptr->valid |= PNG_INFO_PLTE; +} + +#ifdef PNG_sBIT_SUPPORTED +void PNGAPI +png_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_color_8p sig_bit) +{ + png_debug1(1, "in %s storage function", "sBIT"); + + if (png_ptr == NULL || info_ptr == NULL || sig_bit == NULL) + return; + + info_ptr->sig_bit = *sig_bit; + info_ptr->valid |= PNG_INFO_sBIT; +} +#endif + +#ifdef PNG_sRGB_SUPPORTED +void PNGAPI +png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent) +{ + png_debug1(1, "in %s storage function", "sRGB"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + (void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent); + png_colorspace_sync_info(png_ptr, info_ptr); +} + +void PNGAPI +png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, + int srgb_intent) +{ + png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, + srgb_intent) != 0) + { + /* This causes the gAMA and cHRM to be written too */ + info_ptr->colorspace.flags |= + PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; + } + + png_colorspace_sync_info(png_ptr, info_ptr); +} +#endif /* sRGB */ + + +#ifdef PNG_iCCP_SUPPORTED +void PNGAPI +png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_charp name, int compression_type, + png_const_bytep profile, png_uint_32 proflen) +{ + png_charp new_iccp_name; + png_bytep new_iccp_profile; + png_size_t length; + + png_debug1(1, "in %s storage function", "iCCP"); + + if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) + return; + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + png_app_error(png_ptr, "Invalid iCCP compression method"); + + /* Set the colorspace first because this validates the profile; do not + * override previously set app cHRM or gAMA here (because likely as not the + * application knows better than libpng what the correct values are.) Pass + * the info_ptr color_type field to png_colorspace_set_ICC because in the + * write case it has not yet been stored in png_ptr. + */ + { + int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name, + proflen, profile, info_ptr->color_type); + + png_colorspace_sync_info(png_ptr, info_ptr); + + /* Don't do any of the copying if the profile was bad, or inconsistent. */ + if (result == 0) + return; + + /* But do write the gAMA and cHRM chunks from the profile. */ + info_ptr->colorspace.flags |= + PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; + } + + length = strlen(name)+1; + new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length)); + + if (new_iccp_name == NULL) + { + png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk"); + + return; + } + + memcpy(new_iccp_name, name, length); + new_iccp_profile = png_voidcast(png_bytep, + png_malloc_warn(png_ptr, proflen)); + + if (new_iccp_profile == NULL) + { + png_free(png_ptr, new_iccp_name); + png_benign_error(png_ptr, + "Insufficient memory to process iCCP profile"); + + return; + } + + memcpy(new_iccp_profile, profile, proflen); + + png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); + + info_ptr->iccp_proflen = proflen; + info_ptr->iccp_name = new_iccp_name; + info_ptr->iccp_profile = new_iccp_profile; + info_ptr->free_me |= PNG_FREE_ICCP; + info_ptr->valid |= PNG_INFO_iCCP; +} +#endif + +#ifdef PNG_TEXT_SUPPORTED +void PNGAPI +png_set_text(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_textp text_ptr, int num_text) +{ + int ret; + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); + + if (ret != 0) + png_error(png_ptr, "Insufficient memory to store text"); +} + +int /* PRIVATE */ +png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_textp text_ptr, int num_text) +{ + int i; + + png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U : + (unsigned long)png_ptr->chunk_name); + + if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL) + return(0); + + /* Make sure we have enough space in the "text" array in info_struct + * to hold all of the incoming text_ptr objects. This compare can't overflow + * because max_text >= num_text (anyway, subtract of two positive integers + * can't overflow in any case.) + */ + if (num_text > info_ptr->max_text - info_ptr->num_text) + { + int old_num_text = info_ptr->num_text; + int max_text; + png_textp new_text = NULL; + + /* Calculate an appropriate max_text, checking for overflow. */ + max_text = old_num_text; + if (num_text <= INT_MAX - max_text) + { + max_text += num_text; + + /* Round up to a multiple of 8 */ + if (max_text < INT_MAX-8) + max_text = (max_text + 8) & ~0x7; + + else + max_text = INT_MAX; + + /* Now allocate a new array and copy the old members in; this does all + * the overflow checks. + */ + new_text = png_voidcast(png_textp,png_realloc_array(png_ptr, + info_ptr->text, old_num_text, max_text-old_num_text, + sizeof *new_text)); + } + + if (new_text == NULL) + { + png_chunk_report(png_ptr, "too many text chunks", + PNG_CHUNK_WRITE_ERROR); + + return 1; + } + + png_free(png_ptr, info_ptr->text); + + info_ptr->text = new_text; + info_ptr->free_me |= PNG_FREE_TEXT; + info_ptr->max_text = max_text; + /* num_text is adjusted below as the entries are copied in */ + + png_debug1(3, "allocated %d entries for info_ptr->text", max_text); + } + + for (i = 0; i < num_text; i++) + { + size_t text_length, key_len; + size_t lang_len, lang_key_len; + png_textp textp = &(info_ptr->text[info_ptr->num_text]); + + if (text_ptr[i].key == NULL) + continue; + + if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE || + text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST) + { + png_chunk_report(png_ptr, "text compression mode is out of range", + PNG_CHUNK_WRITE_ERROR); + continue; + } + + key_len = strlen(text_ptr[i].key); + + if (text_ptr[i].compression <= 0) + { + lang_len = 0; + lang_key_len = 0; + } + + else +# ifdef PNG_iTXt_SUPPORTED + { + /* Set iTXt data */ + + if (text_ptr[i].lang != NULL) + lang_len = strlen(text_ptr[i].lang); + + else + lang_len = 0; + + if (text_ptr[i].lang_key != NULL) + lang_key_len = strlen(text_ptr[i].lang_key); + + else + lang_key_len = 0; + } +# else /* iTXt */ + { + png_chunk_report(png_ptr, "iTXt chunk not supported", + PNG_CHUNK_WRITE_ERROR); + continue; + } +# endif + + if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') + { + text_length = 0; +# ifdef PNG_iTXt_SUPPORTED + if (text_ptr[i].compression > 0) + textp->compression = PNG_ITXT_COMPRESSION_NONE; + + else +# endif + textp->compression = PNG_TEXT_COMPRESSION_NONE; + } + + else + { + text_length = strlen(text_ptr[i].text); + textp->compression = text_ptr[i].compression; + } + + textp->key = png_voidcast(png_charp,png_malloc_base(png_ptr, + key_len + text_length + lang_len + lang_key_len + 4)); + + if (textp->key == NULL) + { + png_chunk_report(png_ptr, "text chunk: out of memory", + PNG_CHUNK_WRITE_ERROR); + + return 1; + } + + png_debug2(2, "Allocated %lu bytes at %p in png_set_text", + (unsigned long)(png_uint_32) + (key_len + lang_len + lang_key_len + text_length + 4), + textp->key); + + memcpy(textp->key, text_ptr[i].key, key_len); + *(textp->key + key_len) = '\0'; + + if (text_ptr[i].compression > 0) + { + textp->lang = textp->key + key_len + 1; + memcpy(textp->lang, text_ptr[i].lang, lang_len); + *(textp->lang + lang_len) = '\0'; + textp->lang_key = textp->lang + lang_len + 1; + memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); + *(textp->lang_key + lang_key_len) = '\0'; + textp->text = textp->lang_key + lang_key_len + 1; + } + + else + { + textp->lang=NULL; + textp->lang_key=NULL; + textp->text = textp->key + key_len + 1; + } + + if (text_length != 0) + memcpy(textp->text, text_ptr[i].text, text_length); + + *(textp->text + text_length) = '\0'; + +# ifdef PNG_iTXt_SUPPORTED + if (textp->compression > 0) + { + textp->text_length = 0; + textp->itxt_length = text_length; + } + + else +# endif + { + textp->text_length = text_length; + textp->itxt_length = 0; + } + + info_ptr->num_text++; + png_debug1(3, "transferred text chunk %d", info_ptr->num_text); + } + + return(0); +} +#endif + +#ifdef PNG_tIME_SUPPORTED +void PNGAPI +png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_timep mod_time) +{ + png_debug1(1, "in %s storage function", "tIME"); + + if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL || + (png_ptr->mode & PNG_WROTE_tIME) != 0) + return; + + if (mod_time->month == 0 || mod_time->month > 12 || + mod_time->day == 0 || mod_time->day > 31 || + mod_time->hour > 23 || mod_time->minute > 59 || + mod_time->second > 60) + { + png_warning(png_ptr, "Ignoring invalid time value"); + + return; + } + + info_ptr->mod_time = *mod_time; + info_ptr->valid |= PNG_INFO_tIME; +} +#endif + +#ifdef PNG_tRNS_SUPPORTED +void PNGAPI +png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, + png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color) +{ + png_debug1(1, "in %s storage function", "tRNS"); + + if (png_ptr == NULL || info_ptr == NULL) + + return; + + if (trans_alpha != NULL) + { + /* It may not actually be necessary to set png_ptr->trans_alpha here; + * we do it for backward compatibility with the way the png_handle_tRNS + * function used to do the allocation. + * + * 1.6.0: The above statement is incorrect; png_handle_tRNS effectively + * relies on png_set_tRNS storing the information in png_struct + * (otherwise it won't be there for the code in pngrtran.c). + */ + + png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); + + if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) + { + /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ + info_ptr->trans_alpha = png_voidcast(png_bytep, + png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); + memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); + } + png_ptr->trans_alpha = info_ptr->trans_alpha; + } + + if (trans_color != NULL) + { +#ifdef PNG_WARNINGS_SUPPORTED + if (info_ptr->bit_depth < 16) + { + int sample_max = (1 << info_ptr->bit_depth) - 1; + + if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && + trans_color->gray > sample_max) || + (info_ptr->color_type == PNG_COLOR_TYPE_RGB && + (trans_color->red > sample_max || + trans_color->green > sample_max || + trans_color->blue > sample_max))) + png_warning(png_ptr, + "tRNS chunk has out-of-range samples for bit_depth"); + } +#endif + + info_ptr->trans_color = *trans_color; + + if (num_trans == 0) + num_trans = 1; + } + + info_ptr->num_trans = (png_uint_16)num_trans; + + if (num_trans != 0) + { + info_ptr->valid |= PNG_INFO_tRNS; + info_ptr->free_me |= PNG_FREE_TRNS; + } +} +#endif + +#ifdef PNG_sPLT_SUPPORTED +void PNGAPI +png_set_sPLT(png_const_structrp png_ptr, + png_inforp info_ptr, png_const_sPLT_tp entries, int nentries) +/* + * entries - array of png_sPLT_t structures + * to be added to the list of palettes + * in the info structure. + * + * nentries - number of palette structures to be + * added. + */ +{ + png_sPLT_tp np; + + if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL) + return; + + /* Use the internal realloc function, which checks for all the possible + * overflows. Notice that the parameters are (int) and (size_t) + */ + np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr, + info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries, + sizeof *np)); + + if (np == NULL) + { + /* Out of memory or too many chunks */ + png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR); + + return; + } + + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes = np; + info_ptr->free_me |= PNG_FREE_SPLT; + + np += info_ptr->splt_palettes_num; + + do + { + png_size_t length; + + /* Skip invalid input entries */ + if (entries->name == NULL || entries->entries == NULL) + { + /* png_handle_sPLT doesn't do this, so this is an app error */ + png_app_error(png_ptr, "png_set_sPLT: invalid sPLT"); + /* Just skip the invalid entry */ + continue; + } + + np->depth = entries->depth; + + /* In the event of out-of-memory just return - there's no point keeping + * on trying to add sPLT chunks. + */ + length = strlen(entries->name) + 1; + np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length)); + + if (np->name == NULL) + break; + + memcpy(np->name, entries->name, length); + + /* IMPORTANT: we have memory now that won't get freed if something else + * goes wrong; this code must free it. png_malloc_array produces no + * warnings; use a png_chunk_report (below) if there is an error. + */ + np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr, + entries->nentries, sizeof (png_sPLT_entry))); + + if (np->entries == NULL) + { + png_free(png_ptr, np->name); + np->name = NULL; + break; + } + + np->nentries = entries->nentries; + /* This multiply can't overflow because png_malloc_array has already + * checked it when doing the allocation. + */ + memcpy(np->entries, entries->entries, + (unsigned int)entries->nentries * sizeof (png_sPLT_entry)); + + /* Note that 'continue' skips the advance of the out pointer and out + * count, so an invalid entry is not added. + */ + info_ptr->valid |= PNG_INFO_sPLT; + ++(info_ptr->splt_palettes_num); + ++np; + ++entries; + } + while (--nentries); + + if (nentries > 0) + png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR); +} +#endif /* sPLT */ + +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +static png_byte +check_location(png_const_structrp png_ptr, int location) +{ + location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT); + + /* New in 1.6.0; copy the location and check it. This is an API + * change; previously the app had to use the + * png_set_unknown_chunk_location API below for each chunk. + */ + if (location == 0 && (png_ptr->mode & PNG_IS_READ_STRUCT) == 0) + { + /* Write struct, so unknown chunks come from the app */ + png_app_warning(png_ptr, + "png_set_unknown_chunks now expects a valid location"); + /* Use the old behavior */ + location = (png_byte)(png_ptr->mode & + (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)); + } + + /* This need not be an internal error - if the app calls + * png_set_unknown_chunks on a read pointer it must get the location right. + */ + if (location == 0) + png_error(png_ptr, "invalid location in png_set_unknown_chunks"); + + /* Now reduce the location to the top-most set bit by removing each least + * significant bit in turn. + */ + while (location != (location & -location)) + location &= ~(location & -location); + + /* The cast is safe because 'location' is a bit mask and only the low four + * bits are significant. + */ + return (png_byte)location; +} + +void PNGAPI +png_set_unknown_chunks(png_const_structrp png_ptr, + png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) +{ + png_unknown_chunkp np; + + if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 || + unknowns == NULL) + return; + + /* Check for the failure cases where support has been disabled at compile + * time. This code is hardly ever compiled - it's here because + * STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this + * code) but may be meaningless if the read or write handling of unknown + * chunks is not compiled in. + */ +# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \ + defined(PNG_READ_SUPPORTED) + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) + { + png_app_error(png_ptr, "no unknown chunk support on read"); + + return; + } +# endif +# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \ + defined(PNG_WRITE_SUPPORTED) + if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) + { + png_app_error(png_ptr, "no unknown chunk support on write"); + + return; + } +# endif + + /* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that + * unknown critical chunks could be lost with just a warning resulting in + * undefined behavior. Now png_chunk_report is used to provide behavior + * appropriate to read or write. + */ + np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr, + info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns, + sizeof *np)); + + if (np == NULL) + { + png_chunk_report(png_ptr, "too many unknown chunks", + PNG_CHUNK_WRITE_ERROR); + + return; + } + + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks = np; /* safe because it is initialized */ + info_ptr->free_me |= PNG_FREE_UNKN; + + np += info_ptr->unknown_chunks_num; + + /* Increment unknown_chunks_num each time round the loop to protect the + * just-allocated chunk data. + */ + for (; num_unknowns > 0; --num_unknowns, ++unknowns) + { + memcpy(np->name, unknowns->name, (sizeof np->name)); + np->name[(sizeof np->name)-1] = '\0'; + np->location = check_location(png_ptr, unknowns->location); + + if (unknowns->size == 0) + { + np->data = NULL; + np->size = 0; + } + + else + { + np->data = png_voidcast(png_bytep, + png_malloc_base(png_ptr, unknowns->size)); + + if (np->data == NULL) + { + png_chunk_report(png_ptr, "unknown chunk: out of memory", + PNG_CHUNK_WRITE_ERROR); + /* But just skip storing the unknown chunk */ + continue; + } + + memcpy(np->data, unknowns->data, unknowns->size); + np->size = unknowns->size; + } + + /* These increments are skipped on out-of-memory for the data - the + * unknown chunk entry gets overwritten if the png_chunk_report returns. + * This is correct in the read case (the chunk is just dropped.) + */ + ++np; + ++(info_ptr->unknown_chunks_num); + } +} + +void PNGAPI +png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, + int chunk, int location) +{ + /* This API is pretty pointless in 1.6.0 because the location can be set + * before the call to png_set_unknown_chunks. + * + * TODO: add a png_app_warning in 1.7 + */ + if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && + chunk < info_ptr->unknown_chunks_num) + { + if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0) + { + png_app_error(png_ptr, "invalid unknown chunk location"); + /* Fake out the pre 1.6.0 behavior: */ + if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */ + location = PNG_AFTER_IDAT; + + else + location = PNG_HAVE_IHDR; /* also undocumented */ + } + + info_ptr->unknown_chunks[chunk].location = + check_location(png_ptr, location); + } +} +#endif /* STORE_UNKNOWN_CHUNKS */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +png_uint_32 PNGAPI +png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features) +{ + png_debug(1, "in png_permit_mng_features"); + + if (png_ptr == NULL) + return 0; + + png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES; + + return png_ptr->mng_features_permitted; +} +#endif + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +static unsigned int +add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep) +{ + unsigned int i; + + /* Utility function: update the 'keep' state of a chunk if it is already in + * the list, otherwise add it to the list. + */ + for (i=0; i= PNG_HANDLE_CHUNK_LAST) + { + png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep"); + + return; + } + + if (num_chunks_in <= 0) + { + png_ptr->unknown_default = keep; + + /* '0' means just set the flags, so stop here */ + if (num_chunks_in == 0) + return; + } + + if (num_chunks_in < 0) + { + /* Ignore all unknown chunks and all chunks recognized by + * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND + */ + static PNG_CONST png_byte chunks_to_ignore[] = { + 98, 75, 71, 68, '\0', /* bKGD */ + 99, 72, 82, 77, '\0', /* cHRM */ + 101, 88, 73, 102, '\0', /* eXIf */ + 103, 65, 77, 65, '\0', /* gAMA */ + 104, 73, 83, 84, '\0', /* hIST */ + 105, 67, 67, 80, '\0', /* iCCP */ + 105, 84, 88, 116, '\0', /* iTXt */ + 111, 70, 70, 115, '\0', /* oFFs */ + 112, 67, 65, 76, '\0', /* pCAL */ + 112, 72, 89, 115, '\0', /* pHYs */ + 115, 66, 73, 84, '\0', /* sBIT */ + 115, 67, 65, 76, '\0', /* sCAL */ + 115, 80, 76, 84, '\0', /* sPLT */ + 115, 84, 69, 82, '\0', /* sTER */ + 115, 82, 71, 66, '\0', /* sRGB */ + 116, 69, 88, 116, '\0', /* tEXt */ + 116, 73, 77, 69, '\0', /* tIME */ + 122, 84, 88, 116, '\0' /* zTXt */ + }; + + chunk_list = chunks_to_ignore; + num_chunks = (unsigned int)/*SAFE*/(sizeof chunks_to_ignore)/5U; + } + + else /* num_chunks_in > 0 */ + { + if (chunk_list == NULL) + { + /* Prior to 1.6.0 this was silently ignored, now it is an app_error + * which can be switched off. + */ + png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list"); + + return; + } + + num_chunks = (unsigned int)num_chunks_in; + } + + old_num_chunks = png_ptr->num_chunk_list; + if (png_ptr->chunk_list == NULL) + old_num_chunks = 0; + + /* Since num_chunks is always restricted to UINT_MAX/5 this can't overflow. + */ + if (num_chunks + old_num_chunks > UINT_MAX/5) + { + png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks"); + + return; + } + + /* If these chunks are being reset to the default then no more memory is + * required because add_one_chunk above doesn't extend the list if the 'keep' + * parameter is the default. + */ + if (keep != 0) + { + new_list = png_voidcast(png_bytep, png_malloc(png_ptr, + 5 * (num_chunks + old_num_chunks))); + + if (old_num_chunks > 0) + memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks); + } + + else if (old_num_chunks > 0) + new_list = png_ptr->chunk_list; + + else + new_list = NULL; + + /* Add the new chunks together with each one's handling code. If the chunk + * already exists the code is updated, otherwise the chunk is added to the + * end. (In libpng 1.6.0 order no longer matters because this code enforces + * the earlier convention that the last setting is the one that is used.) + */ + if (new_list != NULL) + { + png_const_bytep inlist; + png_bytep outlist; + unsigned int i; + + for (i=0; ichunk_list != new_list) + png_free(png_ptr, new_list); + + new_list = NULL; + } + } + + else + num_chunks = 0; + + png_ptr->num_chunk_list = num_chunks; + + if (png_ptr->chunk_list != new_list) + { + if (png_ptr->chunk_list != NULL) + png_free(png_ptr, png_ptr->chunk_list); + + png_ptr->chunk_list = new_list; + } +} +#endif + +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED +void PNGAPI +png_set_read_user_chunk_fn(png_structrp png_ptr, png_voidp user_chunk_ptr, + png_user_chunk_ptr read_user_chunk_fn) +{ + png_debug(1, "in png_set_read_user_chunk_fn"); + + if (png_ptr == NULL) + return; + + png_ptr->read_user_chunk_fn = read_user_chunk_fn; + png_ptr->user_chunk_ptr = user_chunk_ptr; +} +#endif + +#ifdef PNG_INFO_IMAGE_SUPPORTED +void PNGAPI +png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, + png_bytepp row_pointers) +{ + png_debug1(1, "in %s storage function", "rows"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (info_ptr->row_pointers != NULL && + (info_ptr->row_pointers != row_pointers)) + png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); + + info_ptr->row_pointers = row_pointers; + + if (row_pointers != NULL) + info_ptr->valid |= PNG_INFO_IDAT; +} +#endif + +void PNGAPI +png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) +{ + if (png_ptr == NULL) + return; + + if (size == 0 || size > PNG_UINT_31_MAX) + png_error(png_ptr, "invalid compression buffer size"); + +# ifdef PNG_SEQUENTIAL_READ_SUPPORTED + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) + { + png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */ + return; + } +# endif + +# ifdef PNG_WRITE_SUPPORTED + if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) + { + if (png_ptr->zowner != 0) + { + png_warning(png_ptr, + "Compression buffer size cannot be changed because it is in use"); + + return; + } + +#ifndef __COVERITY__ + /* Some compilers complain that this is always false. However, it + * can be true when integer overflow happens. + */ + if (size > ZLIB_IO_MAX) + { + png_warning(png_ptr, + "Compression buffer size limited to system maximum"); + size = ZLIB_IO_MAX; /* must fit */ + } +#endif + + if (size < 6) + { + /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH + * if this is permitted. + */ + png_warning(png_ptr, + "Compression buffer size cannot be reduced below 6"); + + return; + } + + if (png_ptr->zbuffer_size != size) + { + png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); + png_ptr->zbuffer_size = (uInt)size; + } + } +# endif +} + +void PNGAPI +png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask) +{ + if (png_ptr != NULL && info_ptr != NULL) + info_ptr->valid &= (unsigned int)(~mask); +} + + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +/* This function was added to libpng 1.2.6 */ +void PNGAPI +png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, + png_uint_32 user_height_max) +{ + /* Images with dimensions larger than these limits will be + * rejected by png_set_IHDR(). To accept any PNG datastream + * regardless of dimensions, set both limits to 0x7fffffff. + */ + if (png_ptr == NULL) + return; + + png_ptr->user_width_max = user_width_max; + png_ptr->user_height_max = user_height_max; +} + +/* This function was added to libpng 1.4.0 */ +void PNGAPI +png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max) +{ + if (png_ptr != NULL) + png_ptr->user_chunk_cache_max = user_chunk_cache_max; +} + +/* This function was added to libpng 1.4.1 */ +void PNGAPI +png_set_chunk_malloc_max (png_structrp png_ptr, + png_alloc_size_t user_chunk_malloc_max) +{ + if (png_ptr != NULL) + png_ptr->user_chunk_malloc_max = user_chunk_malloc_max; +} +#endif /* ?SET_USER_LIMITS */ + + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +void PNGAPI +png_set_benign_errors(png_structrp png_ptr, int allowed) +{ + png_debug(1, "in png_set_benign_errors"); + + /* If allowed is 1, png_benign_error() is treated as a warning. + * + * If allowed is 0, png_benign_error() is treated as an error (which + * is the default behavior if png_set_benign_errors() is not called). + */ + + if (allowed != 0) + png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN | + PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN; + + else + png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN | + PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN); +} +#endif /* BENIGN_ERRORS */ + +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Whether to report invalid palette index; added at libng-1.5.10. + * It is possible for an indexed (color-type==3) PNG file to contain + * pixels with invalid (out-of-range) indexes if the PLTE chunk has + * fewer entries than the image's bit-depth would allow. We recover + * from this gracefully by filling any incomplete palette with zeros + * (opaque black). By default, when this occurs libpng will issue + * a benign error. This API can be used to override that behavior. + */ +void PNGAPI +png_set_check_for_invalid_index(png_structrp png_ptr, int allowed) +{ + png_debug(1, "in png_set_check_for_invalid_index"); + + if (allowed > 0) + png_ptr->num_palette_max = 0; + + else + png_ptr->num_palette_max = -1; +} +#endif + +#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, + * and if invalid, correct the keyword rather than discarding the entire + * chunk. The PNG 1.0 specification requires keywords 1-79 characters in + * length, forbids leading or trailing whitespace, multiple internal spaces, + * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. + * + * The 'new_key' buffer must be 80 characters in size (for the keyword plus a + * trailing '\0'). If this routine returns 0 then there was no keyword, or a + * valid one could not be generated, and the caller must png_error. + */ +png_uint_32 /* PRIVATE */ +png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) +{ +#ifdef PNG_WARNINGS_SUPPORTED + png_const_charp orig_key = key; +#endif + png_uint_32 key_len = 0; + int bad_character = 0; + int space = 1; + + png_debug(1, "in png_check_keyword"); + + if (key == NULL) + { + *new_key = 0; + return 0; + } + + while (*key && key_len < 79) + { + png_byte ch = (png_byte)*key++; + + if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) + { + *new_key++ = ch; ++key_len; space = 0; + } + + else if (space == 0) + { + /* A space or an invalid character when one wasn't seen immediately + * before; output just a space. + */ + *new_key++ = 32; ++key_len; space = 1; + + /* If the character was not a space then it is invalid. */ + if (ch != 32) + bad_character = ch; + } + + else if (bad_character == 0) + bad_character = ch; /* just skip it, record the first error */ + } + + if (key_len > 0 && space != 0) /* trailing space */ + { + --key_len; --new_key; + if (bad_character == 0) + bad_character = 32; + } + + /* Terminate the keyword */ + *new_key = 0; + + if (key_len == 0) + return 0; + +#ifdef PNG_WARNINGS_SUPPORTED + /* Try to only output one warning per keyword: */ + if (*key != 0) /* keyword too long */ + png_warning(png_ptr, "keyword truncated"); + + else if (bad_character != 0) + { + PNG_WARNING_PARAMETERS(p) + + png_warning_parameter(p, 1, orig_key); + png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character); + + png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); + } +#else /* !WARNINGS */ + PNG_UNUSED(png_ptr) +#endif /* !WARNINGS */ + + return key_len; +} +#endif /* TEXT || pCAL || iCCP || sPLT */ +#endif /* READ || WRITE */ diff --git a/xs/src/png/libpng/pngstruct.h b/xs/src/png/libpng/pngstruct.h new file mode 100644 index 0000000000..d83f971253 --- /dev/null +++ b/xs/src/png/libpng/pngstruct.h @@ -0,0 +1,483 @@ + +/* pngstruct.h - header file for PNG reference library + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application. + */ + +#ifndef PNGSTRUCT_H +#define PNGSTRUCT_H +/* zlib.h defines the structure z_stream, an instance of which is included + * in this structure and is required for decompressing the LZ compressed + * data in PNG files. + */ +#ifndef ZLIB_CONST + /* We must ensure that zlib uses 'const' in declarations. */ +# define ZLIB_CONST +#endif +#include "zlib.h" +#ifdef const + /* zlib.h sometimes #defines const to nothing, undo this. */ +# undef const +#endif + +/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility + * with older builds. + */ +#if ZLIB_VERNUM < 0x1260 +# define PNGZ_MSG_CAST(s) png_constcast(char*,s) +# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b) +#else +# define PNGZ_MSG_CAST(s) (s) +# define PNGZ_INPUT_CAST(b) (b) +#endif + +/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib + * can handle at once. This type need be no larger than 16 bits (so maximum of + * 65535), this define allows us to discover how big it is, but limited by the + * maximuum for png_size_t. The value can be overriden in a library build + * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably + * lower value (e.g. 255 works). A lower value may help memory usage (slightly) + * and may even improve performance on some systems (and degrade it on others.) + */ +#ifndef ZLIB_IO_MAX +# define ZLIB_IO_MAX ((uInt)-1) +#endif + +#ifdef PNG_WRITE_SUPPORTED +/* The type of a compression buffer list used by the write code. */ +typedef struct png_compression_buffer +{ + struct png_compression_buffer *next; + png_byte output[1]; /* actually zbuf_size */ +} png_compression_buffer, *png_compression_bufferp; + +#define PNG_COMPRESSION_BUFFER_SIZE(pp)\ + (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size) +#endif + +/* Colorspace support; structures used in png_struct, png_info and in internal + * functions to hold and communicate information about the color space. + * + * PNG_COLORSPACE_SUPPORTED is only required if the application will perform + * colorspace corrections, otherwise all the colorspace information can be + * skipped and the size of libpng can be reduced (significantly) by compiling + * out the colorspace support. + */ +#ifdef PNG_COLORSPACE_SUPPORTED +/* The chromaticities of the red, green and blue colorants and the chromaticity + * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)). + */ +typedef struct png_xy +{ + png_fixed_point redx, redy; + png_fixed_point greenx, greeny; + png_fixed_point bluex, bluey; + png_fixed_point whitex, whitey; +} png_xy; + +/* The same data as above but encoded as CIE XYZ values. When this data comes + * from chromaticities the sum of the Y values is assumed to be 1.0 + */ +typedef struct png_XYZ +{ + png_fixed_point red_X, red_Y, red_Z; + png_fixed_point green_X, green_Y, green_Z; + png_fixed_point blue_X, blue_Y, blue_Z; +} png_XYZ; +#endif /* COLORSPACE */ + +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) +/* A colorspace is all the above plus, potentially, profile information; + * however at present libpng does not use the profile internally so it is only + * stored in the png_info struct (if iCCP is supported.) The rendering intent + * is retained here and is checked. + * + * The file gamma encoding information is also stored here and gamma correction + * is done by libpng, whereas color correction must currently be done by the + * application. + */ +typedef struct png_colorspace +{ +#ifdef PNG_GAMMA_SUPPORTED + png_fixed_point gamma; /* File gamma */ +#endif + +#ifdef PNG_COLORSPACE_SUPPORTED + png_xy end_points_xy; /* End points as chromaticities */ + png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */ + png_uint_16 rendering_intent; /* Rendering intent of a profile */ +#endif + + /* Flags are always defined to simplify the code. */ + png_uint_16 flags; /* As defined below */ +} png_colorspace, * PNG_RESTRICT png_colorspacerp; + +typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp; + +/* General flags for the 'flags' field */ +#define PNG_COLORSPACE_HAVE_GAMMA 0x0001 +#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002 +#define PNG_COLORSPACE_HAVE_INTENT 0x0004 +#define PNG_COLORSPACE_FROM_gAMA 0x0008 +#define PNG_COLORSPACE_FROM_cHRM 0x0010 +#define PNG_COLORSPACE_FROM_sRGB 0x0020 +#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040 +#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */ +#define PNG_COLORSPACE_INVALID 0x8000 +#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags)) +#endif /* COLORSPACE || GAMMA */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */ + png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */ + jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */ + size_t jmp_buf_size; /* size of the above, if allocated */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ +#ifdef PNG_WARNINGS_SUPPORTED + png_error_ptr warning_fn; /* function for printing warnings */ +#endif + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions */ + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */ + z_stream zstream; /* decompression structure */ + +#ifdef PNG_WRITE_SUPPORTED + png_compression_bufferp zbuffer_list; /* Created on demand during write */ + uInt zbuffer_size; /* size of the actual buffer */ + + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ +#endif +/* Added at libpng 1.5.4 */ +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED + int zlib_text_level; /* holds zlib compression level */ + int zlib_text_method; /* holds zlib compression method */ + int zlib_text_window_bits; /* holds zlib compression window bits */ + int zlib_text_mem_level; /* holds zlib compression memory level */ + int zlib_text_strategy; /* holds zlib compression strategy */ +#endif +/* End of material added at libpng 1.5.4 */ +/* Added at libpng 1.6.0 */ +#ifdef PNG_WRITE_SUPPORTED + int zlib_set_level; /* Actual values set into the zstream on write */ + int zlib_set_method; + int zlib_set_window_bits; + int zlib_set_mem_level; + int zlib_set_strategy; +#endif + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_size_t rowbytes; /* size of row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row. + * While reading this is a pointer into + * big_prev_row; while writing it is separately + * allocated if needed. + */ + png_bytep row_buf; /* buffer to save current (unfiltered) row. + * While reading, this is a pointer into + * big_row_buf; while writing it is separately + * allocated. + */ +#ifdef PNG_WRITE_FILTER_SUPPORTED + png_bytep try_row; /* buffer to save trial row when filtering */ + png_bytep tst_row; /* buffer to save best trial row when filtering */ +#endif + png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + +/* Added at libpng-1.5.10 */ +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED + int num_palette_max; /* maximum palette index found in IDAT */ +#endif + + png_uint_16 num_trans; /* number of transparency values */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row: write only */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ +#ifdef PNG_WRITE_SUPPORTED + png_byte usr_channels; /* channels at start of write: write only */ +#endif + png_byte sig_bytes; /* magic bytes read/written from start of file */ + png_byte maximum_pixel_depth; + /* pixel depth used for the row buffers */ + png_byte transformed_pixel_depth; + /* pixel depth after read/write transforms */ +#if ZLIB_VERNUM >= 0x1240 + png_byte zstream_start; /* at start of an input zlib stream */ +#endif /* Zlib >= 1.2.4 */ +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif + +#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + png_byte background_gamma_type; + png_fixed_point background_gamma; + png_color_16 background; /* background color in screen gamma space */ +#ifdef PNG_READ_GAMMA_SUPPORTED + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif +#endif /* bKGD */ + +#ifdef PNG_WRITE_FLUSH_SUPPORTED + png_flush_ptr output_flush_fn; /* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED + int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */ + png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */ + + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans_alpha; /* alpha values for paletted files */ + png_color_16 trans_color; /* transparent color for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +#endif /* PROGRESSIVE_READ */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* For the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED + png_bytep palette_lookup; /* lookup table for quantizing */ + png_bytep quantize_index; /* index translation for palette files */ +#endif + +/* Options */ +#ifdef PNG_SET_OPTION_SUPPORTED + png_uint_32 options; /* On/off state (up to 16 options) */ +#endif + +#if PNG_LIBPNG_VER < 10700 +/* To do: remove this from libpng-1.7 */ +#ifdef PNG_TIME_RFC1123_SUPPORTED + char time_buffer[29]; /* String to hold RFC 1123 time text */ +#endif +#endif + +/* New members added in libpng-1.0.6 */ + + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ + +#ifdef PNG_USER_CHUNKS_SUPPORTED + png_voidp user_chunk_ptr; +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif +#endif + +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + int unknown_default; /* As PNG_HANDLE_* */ + unsigned int num_chunk_list; /* Number of entries in the list */ + png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name + * followed by a PNG_HANDLE_* byte */ +#endif + +/* New members added in libpng-1.0.3 */ +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + png_byte rgb_to_gray_status; + /* Added in libpng 1.5.5 to record setting of coefficients: */ + png_byte rgb_to_gray_coefficients_set; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */ +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) +/* Changed from png_byte to png_uint_32 at version 1.2.0 */ + png_uint_32 mng_features_permitted; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#ifdef PNG_MNG_FEATURES_SUPPORTED + png_byte filter_type; +#endif + +/* New members added in libpng-1.2.0 */ + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +/* New member added in libpng-1.0.13 and 1.2.0 */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +#ifdef PNG_READ_QUANTIZE_SUPPORTED +/* The following three members were added at version 1.0.14 and 1.2.4 */ + png_bytep quantize_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is + in the palette */ + png_bytep palette_to_index; /* which original index points to this + palette color */ +#endif + +/* New members added in libpng-1.0.16 and 1.2.6 */ + png_byte compression_type; + +#ifdef PNG_USER_LIMITS_SUPPORTED + png_uint_32 user_width_max; + png_uint_32 user_height_max; + + /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown + * chunks that can be stored (0 means unlimited). + */ + png_uint_32 user_chunk_cache_max; + + /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk + * can occupy when decompressed. 0 means unlimited. + */ + png_alloc_size_t user_chunk_malloc_max; +#endif + +/* New member added in libpng-1.0.25 and 1.2.17 */ +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED + /* Temporary storage for unknown chunk that the library doesn't recognize, + * used while reading the chunk. + */ + png_unknown_chunk unknown_chunk; +#endif + +/* New member added in libpng-1.2.26 */ + png_size_t old_big_row_buf_size; + +#ifdef PNG_READ_SUPPORTED +/* New member added in libpng-1.2.30 */ + png_bytep read_buffer; /* buffer for reading chunk data */ + png_alloc_size_t read_buffer_size; /* current size of the buffer */ +#endif +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED + uInt IDAT_read_size; /* limit on read buffer size for IDAT */ +#endif + +#ifdef PNG_IO_STATE_SUPPORTED +/* New member added in libpng-1.4.0 */ + png_uint_32 io_state; +#endif + +/* New member added in libpng-1.5.6 */ + png_bytep big_prev_row; + +/* New member added in libpng-1.5.7 */ + void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info, + png_bytep row, png_const_bytep prev_row); + +#ifdef PNG_READ_SUPPORTED +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) + png_colorspace colorspace; +#endif +#endif +}; +#endif /* PNGSTRUCT_H */ diff --git a/xs/src/png/libpng/pngtest.c b/xs/src/png/libpng/pngtest.c new file mode 100644 index 0000000000..9d5075791f --- /dev/null +++ b/xs/src/png/libpng/pngtest.c @@ -0,0 +1,2156 @@ + +/* pngtest.c - a simple test program to test libpng + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * This program reads in a PNG image, writes it out again, and then + * compares the two files. If the files are identical, this shows that + * the basic chunk handling, filtering, and (de)compression code is working + * properly. It does not currently test all of the transforms, although + * it probably should. + * + * The program will report "FAIL" in certain legitimate cases: + * 1) when the compression level or filter selection method is changed. + * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. + * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks + * exist in the input file. + * 4) others not listed here... + * In these cases, it is best to check with another tool such as "pngcheck" + * to see what the differences between the two files are. + * + * If a filename is given on the command-line, then this file is used + * for the input, rather than the default "pngtest.png". This allows + * testing a wide variety of files easily. You can also test a number + * of files at once by typing "pngtest -m file1.png file2.png ..." + */ + +#define _POSIX_SOURCE 1 + +#include +#include +#include + +/* Defined so I can write to a file on gui/windowing platforms */ +/* #define STDERR stderr */ +#define STDERR stdout /* For DOS */ + +#include "png.h" + +/* Known chunks that exist in pngtest.png must be supported or pngtest will fail + * simply as a result of re-ordering them. This may be fixed in 1.7 + * + * pngtest allocates a single row buffer for each row and overwrites it, + * therefore if the write side doesn't support the writing of interlaced images + * nothing can be done for an interlaced image (and the code below will fail + * horribly trying to write extra data after writing garbage). + */ +#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\ + defined PNG_READ_bKGD_SUPPORTED &&\ + defined PNG_READ_cHRM_SUPPORTED &&\ + defined PNG_READ_gAMA_SUPPORTED &&\ + defined PNG_READ_oFFs_SUPPORTED &&\ + defined PNG_READ_pCAL_SUPPORTED &&\ + defined PNG_READ_pHYs_SUPPORTED &&\ + defined PNG_READ_sBIT_SUPPORTED &&\ + defined PNG_READ_sCAL_SUPPORTED &&\ + defined PNG_READ_sRGB_SUPPORTED &&\ + defined PNG_READ_sPLT_SUPPORTED &&\ + defined PNG_READ_tEXt_SUPPORTED &&\ + defined PNG_READ_tIME_SUPPORTED &&\ + defined PNG_READ_zTXt_SUPPORTED &&\ + (defined PNG_WRITE_INTERLACING_SUPPORTED || PNG_LIBPNG_VER >= 10700) + +#ifdef PNG_ZLIB_HEADER +# include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */ +#else +# include "zlib.h" +#endif + +/* Copied from pngpriv.h but only used in error messages below. */ +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif +#define FCLOSE(file) fclose(file) + +#ifndef PNG_STDIO_SUPPORTED +typedef FILE * png_FILE_p; +#endif + +/* Makes pngtest verbose so we can find problems. */ +#ifndef PNG_DEBUG +# define PNG_DEBUG 0 +#endif + +#if PNG_DEBUG > 1 +# define pngtest_debug(m) ((void)fprintf(stderr, m "\n")) +# define pngtest_debug1(m,p1) ((void)fprintf(stderr, m "\n", p1)) +# define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m "\n", p1, p2)) +#else +# define pngtest_debug(m) ((void)0) +# define pngtest_debug1(m,p1) ((void)0) +# define pngtest_debug2(m,p1,p2) ((void)0) +#endif + +#if !PNG_DEBUG +# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */ +#endif + +#ifndef PNG_UNUSED +# define PNG_UNUSED(param) (void)param; +#endif + +/* Turn on CPU timing +#define PNGTEST_TIMING +*/ + +#ifndef PNG_FLOATING_POINT_SUPPORTED +#undef PNGTEST_TIMING +#endif + +#ifdef PNGTEST_TIMING +static float t_start, t_stop, t_decode, t_encode, t_misc; +#include +#endif + +#ifdef PNG_TIME_RFC1123_SUPPORTED +#define PNG_tIME_STRING_LENGTH 29 +static int tIME_chunk_present = 0; +static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present"; + +#if PNG_LIBPNG_VER < 10619 +#define png_convert_to_rfc1123_buffer(ts, t) tIME_to_str(read_ptr, ts, t) + +static int +tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t) +{ + png_const_charp str = png_convert_to_rfc1123(png_ptr, t); + + if (str == NULL) + return 0; + + strcpy(ts, str); + return 1; +} +#endif /* older libpng */ +#endif + +static int verbose = 0; +static int strict = 0; +static int relaxed = 0; +static int xfail = 0; +static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */ +static int error_count = 0; /* count calls to png_error */ +static int warning_count = 0; /* count calls to png_warning */ + +/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) png_ptr->jmpbuf +#endif + +/* Defines for unknown chunk handling if required. */ +#ifndef PNG_HANDLE_CHUNK_ALWAYS +# define PNG_HANDLE_CHUNK_ALWAYS 3 +#endif +#ifndef PNG_HANDLE_CHUNK_IF_SAFE +# define PNG_HANDLE_CHUNK_IF_SAFE 2 +#endif + +/* Utility to save typing/errors, the argument must be a name */ +#define MEMZERO(var) ((void)memset(&var, 0, sizeof var)) + +/* Example of using row callbacks to make a simple progress meter */ +static int status_pass = 1; +static int status_dots_requested = 0; +static int status_dots = 1; + +static void PNGCBAPI +read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) +{ + if (png_ptr == NULL || row_number > PNG_UINT_31_MAX) + return; + + if (status_pass != pass) + { + fprintf(stdout, "\n Pass %d: ", pass); + status_pass = pass; + status_dots = 31; + } + + status_dots--; + + if (status_dots == 0) + { + fprintf(stdout, "\n "); + status_dots=30; + } + + fprintf(stdout, "r"); +} + +#ifdef PNG_WRITE_SUPPORTED +static void PNGCBAPI +write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) +{ + if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) + return; + + fprintf(stdout, "w"); +} +#endif + + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +/* Example of using a user transform callback (doesn't do anything at present). + */ +static void PNGCBAPI +read_user_callback(png_structp png_ptr, png_row_infop row_info, png_bytep data) +{ + PNG_UNUSED(png_ptr) + PNG_UNUSED(row_info) + PNG_UNUSED(data) +} +#endif + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +/* Example of using user transform callback (we don't transform anything, + * but merely count the zero samples) + */ + +static png_uint_32 zero_samples; + +static void PNGCBAPI +count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) +{ + png_bytep dp = data; + if (png_ptr == NULL) + return; + + /* Contents of row_info: + * png_uint_32 width width of row + * png_uint_32 rowbytes number of bytes in row + * png_byte color_type color type of pixels + * png_byte bit_depth bit depth of samples + * png_byte channels number of channels (1-4) + * png_byte pixel_depth bits per pixel (depth*channels) + */ + + /* Counts the number of zero samples (or zero pixels if color_type is 3 */ + + if (row_info->color_type == 0 || row_info->color_type == 3) + { + int pos = 0; + png_uint_32 n, nstop; + + for (n = 0, nstop=row_info->width; nbit_depth == 1) + { + if (((*dp << pos++ ) & 0x80) == 0) + zero_samples++; + + if (pos == 8) + { + pos = 0; + dp++; + } + } + + if (row_info->bit_depth == 2) + { + if (((*dp << (pos+=2)) & 0xc0) == 0) + zero_samples++; + + if (pos == 8) + { + pos = 0; + dp++; + } + } + + if (row_info->bit_depth == 4) + { + if (((*dp << (pos+=4)) & 0xf0) == 0) + zero_samples++; + + if (pos == 8) + { + pos = 0; + dp++; + } + } + + if (row_info->bit_depth == 8) + if (*dp++ == 0) + zero_samples++; + + if (row_info->bit_depth == 16) + { + if ((*dp | *(dp+1)) == 0) + zero_samples++; + dp+=2; + } + } + } + else /* Other color types */ + { + png_uint_32 n, nstop; + int channel; + int color_channels = row_info->channels; + if (row_info->color_type > 3) + color_channels--; + + for (n = 0, nstop=row_info->width; nbit_depth == 8) + if (*dp++ == 0) + zero_samples++; + + if (row_info->bit_depth == 16) + { + if ((*dp | *(dp+1)) == 0) + zero_samples++; + + dp+=2; + } + } + if (row_info->color_type > 3) + { + dp++; + if (row_info->bit_depth == 16) + dp++; + } + } + } +} +#endif /* WRITE_USER_TRANSFORM */ + +#ifndef PNG_STDIO_SUPPORTED +/* START of code to validate stdio-free compilation */ +/* These copies of the default read/write functions come from pngrio.c and + * pngwio.c. They allow "don't include stdio" testing of the library. + * This is the function that does the actual reading of data. If you are + * not reading from a standard C stream, you should create a replacement + * read_data function and use it at run time with png_set_read_fn(), rather + * than changing the library. + */ + +#ifdef PNG_IO_STATE_SUPPORTED +void +pngtest_check_io_state(png_structp png_ptr, png_size_t data_length, + png_uint_32 io_op); +void +pngtest_check_io_state(png_structp png_ptr, png_size_t data_length, + png_uint_32 io_op) +{ + png_uint_32 io_state = png_get_io_state(png_ptr); + int err = 0; + + /* Check if the current operation (reading / writing) is as expected. */ + if ((io_state & PNG_IO_MASK_OP) != io_op) + png_error(png_ptr, "Incorrect operation in I/O state"); + + /* Check if the buffer size specific to the current location + * (file signature / header / data / crc) is as expected. + */ + switch (io_state & PNG_IO_MASK_LOC) + { + case PNG_IO_SIGNATURE: + if (data_length > 8) + err = 1; + break; + case PNG_IO_CHUNK_HDR: + if (data_length != 8) + err = 1; + break; + case PNG_IO_CHUNK_DATA: + break; /* no restrictions here */ + case PNG_IO_CHUNK_CRC: + if (data_length != 4) + err = 1; + break; + default: + err = 1; /* uninitialized */ + } + if (err != 0) + png_error(png_ptr, "Bad I/O state or buffer size"); +} +#endif + +static void PNGCBAPI +pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check = 0; + png_voidp io_ptr; + + /* fread() returns 0 on error, so it is OK to store this in a png_size_t + * instead of an int, which is what fread() actually returns. + */ + io_ptr = png_get_io_ptr(png_ptr); + if (io_ptr != NULL) + { + check = fread(data, 1, length, (png_FILE_p)io_ptr); + } + + if (check != length) + { + png_error(png_ptr, "Read Error"); + } + +#ifdef PNG_IO_STATE_SUPPORTED + pngtest_check_io_state(png_ptr, length, PNG_IO_READING); +#endif +} + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +static void PNGCBAPI +pngtest_flush(png_structp png_ptr) +{ + /* Do nothing; fflush() is said to be just a waste of energy. */ + PNG_UNUSED(png_ptr) /* Stifle compiler warning */ +} +#endif + +/* This is the function that does the actual writing of data. If you are + * not writing to a standard C stream, you should create a replacement + * write_data function and use it at run time with png_set_write_fn(), rather + * than changing the library. + */ +static void PNGCBAPI +pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr)); + + if (check != length) + { + png_error(png_ptr, "Write Error"); + } + +#ifdef PNG_IO_STATE_SUPPORTED + pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING); +#endif +} +#endif /* !STDIO */ + +/* This function is called when there is a warning, but the library thinks + * it can continue anyway. Replacement functions don't have to do anything + * here if you don't want to. In the default configuration, png_ptr is + * not used, but it is passed in case it may be useful. + */ +typedef struct +{ + PNG_CONST char *file_name; +} pngtest_error_parameters; + +static void PNGCBAPI +pngtest_warning(png_structp png_ptr, png_const_charp message) +{ + PNG_CONST char *name = "UNKNOWN (ERROR!)"; + pngtest_error_parameters *test = + (pngtest_error_parameters*)png_get_error_ptr(png_ptr); + + ++warning_count; + + if (test != NULL && test->file_name != NULL) + name = test->file_name; + + fprintf(STDERR, "\n%s: libpng warning: %s\n", name, message); +} + +/* This is the default error handling function. Note that replacements for + * this function MUST NOT RETURN, or the program will likely crash. This + * function is used by default, or if the program supplies NULL for the + * error function pointer in png_set_error_fn(). + */ +static void PNGCBAPI +pngtest_error(png_structp png_ptr, png_const_charp message) +{ + ++error_count; + + pngtest_warning(png_ptr, message); + /* We can return because png_error calls the default handler, which is + * actually OK in this case. + */ +} + +/* END of code to validate stdio-free compilation */ + +/* START of code to validate memory allocation and deallocation */ +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + +/* Allocate memory. For reasonable files, size should never exceed + * 64K. However, zlib may allocate more than 64K if you don't tell + * it not to. See zconf.h and png.h for more information. zlib does + * need to allocate exactly 64K, so whatever you call here must + * have the ability to do that. + * + * This piece of code can be compiled to validate max 64K allocations + * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. + */ +typedef struct memory_information +{ + png_alloc_size_t size; + png_voidp pointer; + struct memory_information *next; +} memory_information; +typedef memory_information *memory_infop; + +static memory_infop pinformation = NULL; +static int current_allocation = 0; +static int maximum_allocation = 0; +static int total_allocation = 0; +static int num_allocations = 0; + +png_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr, + png_alloc_size_t size)); +void PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); + +png_voidp +PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size) +{ + + /* png_malloc has already tested for NULL; png_create_struct calls + * png_debug_malloc directly, with png_ptr == NULL which is OK + */ + + if (size == 0) + return (NULL); + + /* This calls the library allocator twice, once to get the requested + buffer and once to get a new free list entry. */ + { + /* Disable malloc_fn and free_fn */ + memory_infop pinfo; + png_set_mem_fn(png_ptr, NULL, NULL, NULL); + pinfo = (memory_infop)png_malloc(png_ptr, + (sizeof *pinfo)); + pinfo->size = size; + current_allocation += size; + total_allocation += size; + num_allocations ++; + + if (current_allocation > maximum_allocation) + maximum_allocation = current_allocation; + + pinfo->pointer = png_malloc(png_ptr, size); + /* Restore malloc_fn and free_fn */ + + png_set_mem_fn(png_ptr, + NULL, png_debug_malloc, png_debug_free); + + if (size != 0 && pinfo->pointer == NULL) + { + current_allocation -= size; + total_allocation -= size; + png_error(png_ptr, + "out of memory in pngtest->png_debug_malloc"); + } + + pinfo->next = pinformation; + pinformation = pinfo; + /* Make sure the caller isn't assuming zeroed memory. */ + memset(pinfo->pointer, 0xdd, pinfo->size); + + if (verbose != 0) + printf("png_malloc %lu bytes at %p\n", (unsigned long)size, + pinfo->pointer); + + return (png_voidp)(pinfo->pointer); + } +} + +/* Free a pointer. It is removed from the list at the same time. */ +void PNGCBAPI +png_debug_free(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL) + fprintf(STDERR, "NULL pointer to png_debug_free.\n"); + + if (ptr == 0) + { +#if 0 /* This happens all the time. */ + fprintf(STDERR, "WARNING: freeing NULL pointer\n"); +#endif + return; + } + + /* Unlink the element from the list. */ + if (pinformation != NULL) + { + memory_infop *ppinfo = &pinformation; + + for (;;) + { + memory_infop pinfo = *ppinfo; + + if (pinfo->pointer == ptr) + { + *ppinfo = pinfo->next; + current_allocation -= pinfo->size; + if (current_allocation < 0) + fprintf(STDERR, "Duplicate free of memory\n"); + /* We must free the list element too, but first kill + the memory that is to be freed. */ + memset(ptr, 0x55, pinfo->size); + free(pinfo); + pinfo = NULL; + break; + } + + if (pinfo->next == NULL) + { + fprintf(STDERR, "Pointer %p not found\n", ptr); + break; + } + + ppinfo = &pinfo->next; + } + } + + /* Finally free the data. */ + if (verbose != 0) + printf("Freeing %p\n", ptr); + + if (ptr != NULL) + free(ptr); + ptr = NULL; +} +#endif /* USER_MEM && DEBUG */ +/* END of code to test memory allocation/deallocation */ + + +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED +/* Demonstration of user chunk support of the sTER and vpAg chunks */ + +/* (sTER is a public chunk not yet known by libpng. vpAg is a private +chunk used in ImageMagick to store "virtual page" size). */ + +static struct user_chunk_data +{ + png_const_infop info_ptr; + png_uint_32 vpAg_width, vpAg_height; + png_byte vpAg_units; + png_byte sTER_mode; + int location[2]; +} +user_chunk_data; + +/* Used for location and order; zero means nothing. */ +#define have_sTER 0x01 +#define have_vpAg 0x02 +#define before_PLTE 0x10 +#define before_IDAT 0x20 +#define after_IDAT 0x40 + +static void +init_callback_info(png_const_infop info_ptr) +{ + MEMZERO(user_chunk_data); + user_chunk_data.info_ptr = info_ptr; +} + +static int +set_location(png_structp png_ptr, struct user_chunk_data *data, int what) +{ + int location; + + if ((data->location[0] & what) != 0 || (data->location[1] & what) != 0) + return 0; /* already have one of these */ + + /* Find where we are (the code below zeroes info_ptr to indicate that the + * chunks before the first IDAT have been read.) + */ + if (data->info_ptr == NULL) /* after IDAT */ + location = what | after_IDAT; + + else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE) != 0) + location = what | before_IDAT; + + else + location = what | before_PLTE; + + if (data->location[0] == 0) + data->location[0] = location; + + else + data->location[1] = location; + + return 1; /* handled */ +} + +static int PNGCBAPI +read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk) +{ + struct user_chunk_data *my_user_chunk_data = + (struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr); + + if (my_user_chunk_data == NULL) + png_error(png_ptr, "lost user chunk pointer"); + + /* Return one of the following: + * return (-n); chunk had an error + * return (0); did not recognize + * return (n); success + * + * The unknown chunk structure contains the chunk data: + * png_byte name[5]; + * png_byte *data; + * png_size_t size; + * + * Note that libpng has already taken care of the CRC handling. + */ + + if (chunk->name[0] == 115 && chunk->name[1] == 84 && /* s T */ + chunk->name[2] == 69 && chunk->name[3] == 82) /* E R */ + { + /* Found sTER chunk */ + if (chunk->size != 1) + return (-1); /* Error return */ + + if (chunk->data[0] != 0 && chunk->data[0] != 1) + return (-1); /* Invalid mode */ + + if (set_location(png_ptr, my_user_chunk_data, have_sTER) != 0) + { + my_user_chunk_data->sTER_mode=chunk->data[0]; + return (1); + } + + else + return (0); /* duplicate sTER - give it to libpng */ + } + + if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */ + chunk->name[2] != 65 || chunk->name[3] != 103) /* A g */ + return (0); /* Did not recognize */ + + /* Found ImageMagick vpAg chunk */ + + if (chunk->size != 9) + return (-1); /* Error return */ + + if (set_location(png_ptr, my_user_chunk_data, have_vpAg) == 0) + return (0); /* duplicate vpAg */ + + my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data); + my_user_chunk_data->vpAg_height = png_get_uint_31(png_ptr, chunk->data + 4); + my_user_chunk_data->vpAg_units = chunk->data[8]; + + return (1); +} + +#ifdef PNG_WRITE_SUPPORTED +static void +write_sTER_chunk(png_structp write_ptr) +{ + png_byte sTER[5] = {115, 84, 69, 82, '\0'}; + + if (verbose != 0) + fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode); + + png_write_chunk(write_ptr, sTER, &user_chunk_data.sTER_mode, 1); +} + +static void +write_vpAg_chunk(png_structp write_ptr) +{ + png_byte vpAg[5] = {118, 112, 65, 103, '\0'}; + + png_byte vpag_chunk_data[9]; + + if (verbose != 0) + fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n", + (unsigned long)user_chunk_data.vpAg_width, + (unsigned long)user_chunk_data.vpAg_height, + user_chunk_data.vpAg_units); + + png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width); + png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height); + vpag_chunk_data[8] = user_chunk_data.vpAg_units; + png_write_chunk(write_ptr, vpAg, vpag_chunk_data, 9); +} + +static void +write_chunks(png_structp write_ptr, int location) +{ + int i; + + /* Notice that this preserves the original chunk order, however chunks + * intercepted by the callback will be written *after* chunks passed to + * libpng. This will actually reverse a pair of sTER chunks or a pair of + * vpAg chunks, resulting in an error later. This is not worth worrying + * about - the chunks should not be duplicated! + */ + for (i=0; i<2; ++i) + { + if (user_chunk_data.location[i] == (location | have_sTER)) + write_sTER_chunk(write_ptr); + + else if (user_chunk_data.location[i] == (location | have_vpAg)) + write_vpAg_chunk(write_ptr); + } +} +#endif /* WRITE */ +#else /* !READ_USER_CHUNKS */ +# define write_chunks(pp,loc) ((void)0) +#endif +/* END of code to demonstrate user chunk support */ + +/* START of code to check that libpng has the required text support; this only + * checks for the write support because if read support is missing the chunk + * will simply not be reported back to pngtest. + */ +#ifdef PNG_TEXT_SUPPORTED +static void +pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr, + int num_text) +{ + while (num_text > 0) + { + switch (text_ptr[--num_text].compression) + { + case PNG_TEXT_COMPRESSION_NONE: + break; + + case PNG_TEXT_COMPRESSION_zTXt: +# ifndef PNG_WRITE_zTXt_SUPPORTED + ++unsupported_chunks; + /* In libpng 1.7 this now does an app-error, so stop it: */ + text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE; +# endif + break; + + case PNG_ITXT_COMPRESSION_NONE: + case PNG_ITXT_COMPRESSION_zTXt: +# ifndef PNG_WRITE_iTXt_SUPPORTED + ++unsupported_chunks; + text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE; +# endif + break; + + default: + /* This is an error */ + png_error(png_ptr, "invalid text chunk compression field"); + break; + } + } +} +#endif +/* END of code to check that libpng has the required text support */ + +/* Test one file */ +static int +test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) +{ + static png_FILE_p fpin; + static png_FILE_p fpout; /* "static" prevents setjmp corruption */ + pngtest_error_parameters error_parameters; + png_structp read_ptr; + png_infop read_info_ptr, end_info_ptr; +#ifdef PNG_WRITE_SUPPORTED + png_structp write_ptr; + png_infop write_info_ptr; + png_infop write_end_info_ptr; +#ifdef PNG_WRITE_FILTER_SUPPORTED + int interlace_preserved = 1; +#endif /* WRITE_FILTER */ +#else /* !WRITE */ + png_structp write_ptr = NULL; + png_infop write_info_ptr = NULL; + png_infop write_end_info_ptr = NULL; +#endif /* !WRITE */ + png_bytep row_buf; + png_uint_32 y; + png_uint_32 width, height; + volatile int num_passes; + int pass; + int bit_depth, color_type; + + row_buf = NULL; + error_parameters.file_name = inname; + + if ((fpin = fopen(inname, "rb")) == NULL) + { + fprintf(STDERR, "Could not find input file %s\n", inname); + return (1); + } + + if ((fpout = fopen(outname, "wb")) == NULL) + { + fprintf(STDERR, "Could not open output file %s\n", outname); + FCLOSE(fpin); + return (1); + } + + pngtest_debug("Allocating read and write structures"); +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + read_ptr = + png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL, + NULL, NULL, NULL, png_debug_malloc, png_debug_free); +#else + read_ptr = + png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); +#endif + png_set_error_fn(read_ptr, &error_parameters, pngtest_error, + pngtest_warning); + +#ifdef PNG_WRITE_SUPPORTED +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + write_ptr = + png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL, + NULL, NULL, NULL, png_debug_malloc, png_debug_free); +#else + write_ptr = + png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); +#endif + png_set_error_fn(write_ptr, &error_parameters, pngtest_error, + pngtest_warning); +#endif + pngtest_debug("Allocating read_info, write_info and end_info structures"); + read_info_ptr = png_create_info_struct(read_ptr); + end_info_ptr = png_create_info_struct(read_ptr); +#ifdef PNG_WRITE_SUPPORTED + write_info_ptr = png_create_info_struct(write_ptr); + write_end_info_ptr = png_create_info_struct(write_ptr); +#endif + +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED + init_callback_info(read_info_ptr); + png_set_read_user_chunk_fn(read_ptr, &user_chunk_data, + read_user_chunk_callback); +#endif + +#ifdef PNG_SETJMP_SUPPORTED + pngtest_debug("Setting jmpbuf for read struct"); + if (setjmp(png_jmpbuf(read_ptr))) + { + fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); + png_free(read_ptr, row_buf); + row_buf = NULL; + if (verbose != 0) + fprintf(STDERR, " destroy read structs\n"); + png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); +#ifdef PNG_WRITE_SUPPORTED + if (verbose != 0) + fprintf(STDERR, " destroy write structs\n"); + png_destroy_info_struct(write_ptr, &write_end_info_ptr); + png_destroy_write_struct(&write_ptr, &write_info_ptr); +#endif + FCLOSE(fpin); + FCLOSE(fpout); + return (1); + } + +#ifdef PNG_WRITE_SUPPORTED + pngtest_debug("Setting jmpbuf for write struct"); + + if (setjmp(png_jmpbuf(write_ptr))) + { + fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); + if (verbose != 0) + fprintf(STDERR, " destroying read structs\n"); + png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); + if (verbose != 0) + fprintf(STDERR, " destroying write structs\n"); + png_destroy_info_struct(write_ptr, &write_end_info_ptr); + png_destroy_write_struct(&write_ptr, &write_info_ptr); + FCLOSE(fpin); + FCLOSE(fpout); + return (1); + } +#endif +#endif + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED + if (strict != 0) + { + /* Treat png_benign_error() as errors on read */ + png_set_benign_errors(read_ptr, 0); + +# ifdef PNG_WRITE_SUPPORTED + /* Treat them as errors on write */ + png_set_benign_errors(write_ptr, 0); +# endif + + /* if strict is not set, then app warnings and errors are treated as + * warnings in release builds, but not in unstable builds; this can be + * changed with '--relaxed'. + */ + } + + else if (relaxed != 0) + { + /* Allow application (pngtest) errors and warnings to pass */ + png_set_benign_errors(read_ptr, 1); + + /* Turn off CRC checking while reading */ + png_set_crc_action(read_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE); + +#ifdef PNG_IGNORE_ADLER32 + /* Turn off ADLER32 checking while reading */ + png_set_option(read_ptr, PNG_IGNORE_ADLER32, PNG_OPTION_ON); +#endif + +# ifdef PNG_WRITE_SUPPORTED + png_set_benign_errors(write_ptr, 1); +# endif + + } +#endif /* BENIGN_ERRORS */ + + pngtest_debug("Initializing input and output streams"); +#ifdef PNG_STDIO_SUPPORTED + png_init_io(read_ptr, fpin); +# ifdef PNG_WRITE_SUPPORTED + png_init_io(write_ptr, fpout); +# endif +#else + png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); +# ifdef PNG_WRITE_SUPPORTED + png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, +# ifdef PNG_WRITE_FLUSH_SUPPORTED + pngtest_flush); +# else + NULL); +# endif +# endif +#endif + + if (status_dots_requested == 1) + { +#ifdef PNG_WRITE_SUPPORTED + png_set_write_status_fn(write_ptr, write_row_callback); +#endif + png_set_read_status_fn(read_ptr, read_row_callback); + } + + else + { +#ifdef PNG_WRITE_SUPPORTED + png_set_write_status_fn(write_ptr, NULL); +#endif + png_set_read_status_fn(read_ptr, NULL); + } + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED + png_set_read_user_transform_fn(read_ptr, read_user_callback); +#endif +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED + zero_samples = 0; + png_set_write_user_transform_fn(write_ptr, count_zero_samples); +#endif + +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + /* Preserve all the unknown chunks, if possible. If this is disabled then, + * even if the png_{get,set}_unknown_chunks stuff is enabled, we can't use + * libpng to *save* the unknown chunks on read (because we can't switch the + * save option on!) + * + * Notice that if SET_UNKNOWN_CHUNKS is *not* supported read will discard all + * unknown chunks and write will write them all. + */ +#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, + NULL, 0); +#endif +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS, + NULL, 0); +#endif +#endif + + pngtest_debug("Reading info struct"); + png_read_info(read_ptr, read_info_ptr); + +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED + /* This is a bit of a hack; there is no obvious way in the callback function + * to determine that the chunks before the first IDAT have been read, so + * remove the info_ptr (which is only used to determine position relative to + * PLTE) here to indicate that we are after the IDAT. + */ + user_chunk_data.info_ptr = NULL; +#endif + + pngtest_debug("Transferring info struct"); + { + int interlace_type, compression_type, filter_type; + + if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, + &color_type, &interlace_type, &compression_type, &filter_type) != 0) + { + png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, + color_type, interlace_type, compression_type, filter_type); + /* num_passes may not be available below if interlace support is not + * provided by libpng for both read and write. + */ + switch (interlace_type) + { + case PNG_INTERLACE_NONE: + num_passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + num_passes = 7; + break; + + default: + png_error(read_ptr, "invalid interlace type"); + /*NOT REACHED*/ + } + } + + else + png_error(read_ptr, "png_get_IHDR failed"); + } +#ifdef PNG_FIXED_POINT_SUPPORTED +#ifdef PNG_cHRM_SUPPORTED + { + png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, + blue_y; + + if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, + &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0) + { + png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, + red_y, green_x, green_y, blue_x, blue_y); + } + } +#endif +#ifdef PNG_gAMA_SUPPORTED + { + png_fixed_point gamma; + + if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma) != 0) + png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); + } +#endif +#else /* Use floating point versions */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_cHRM_SUPPORTED + { + double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, + blue_y; + + if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, + &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0) + { + png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x, + red_y, green_x, green_y, blue_x, blue_y); + } + } +#endif +#ifdef PNG_gAMA_SUPPORTED + { + double gamma; + + if (png_get_gAMA(read_ptr, read_info_ptr, &gamma) != 0) + png_set_gAMA(write_ptr, write_info_ptr, gamma); + } +#endif +#endif /* Floating point */ +#endif /* Fixed point */ +#ifdef PNG_iCCP_SUPPORTED + { + png_charp name; + png_bytep profile; + png_uint_32 proflen; + int compression_type; + + if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, + &profile, &proflen) != 0) + { + png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, + profile, proflen); + } + } +#endif +#ifdef PNG_sRGB_SUPPORTED + { + int intent; + + if (png_get_sRGB(read_ptr, read_info_ptr, &intent) != 0) + png_set_sRGB(write_ptr, write_info_ptr, intent); + } +#endif + { + png_colorp palette; + int num_palette; + + if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette) != 0) + png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); + } +#ifdef PNG_bKGD_SUPPORTED + { + png_color_16p background; + + if (png_get_bKGD(read_ptr, read_info_ptr, &background) != 0) + { + png_set_bKGD(write_ptr, write_info_ptr, background); + } + } +#endif +#ifdef PNG_READ_eXIf_SUPPORTED + { + png_bytep exif=NULL; + png_uint_32 exif_length; + + if (png_get_eXIf_1(read_ptr, read_info_ptr, &exif_length, &exif) != 0) + { + if (exif_length > 1) + fprintf(STDERR," eXIf type %c%c, %lu bytes\n",exif[0],exif[1], + (unsigned long)exif_length); +# ifdef PNG_WRITE_eXIf_SUPPORTED + png_set_eXIf_1(write_ptr, write_info_ptr, exif_length, exif); +# endif + } + } +#endif +#ifdef PNG_hIST_SUPPORTED + { + png_uint_16p hist; + + if (png_get_hIST(read_ptr, read_info_ptr, &hist) != 0) + png_set_hIST(write_ptr, write_info_ptr, hist); + } +#endif +#ifdef PNG_oFFs_SUPPORTED + { + png_int_32 offset_x, offset_y; + int unit_type; + + if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y, + &unit_type) != 0) + { + png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); + } + } +#endif +#ifdef PNG_pCAL_SUPPORTED + { + png_charp purpose, units; + png_charpp params; + png_int_32 X0, X1; + int type, nparams; + + if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, + &nparams, &units, ¶ms) != 0) + { + png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, + nparams, units, params); + } + } +#endif +#ifdef PNG_pHYs_SUPPORTED + { + png_uint_32 res_x, res_y; + int unit_type; + + if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, + &unit_type) != 0) + png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); + } +#endif +#ifdef PNG_sBIT_SUPPORTED + { + png_color_8p sig_bit; + + if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit) != 0) + png_set_sBIT(write_ptr, write_info_ptr, sig_bit); + } +#endif +#ifdef PNG_sCAL_SUPPORTED +#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ + defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) + { + int unit; + double scal_width, scal_height; + + if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width, + &scal_height) != 0) + { + png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height); + } + } +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + { + int unit; + png_charp scal_width, scal_height; + + if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, + &scal_height) != 0) + { + png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, + scal_height); + } + } +#endif +#endif +#endif + +#ifdef PNG_sPLT_SUPPORTED + { + png_sPLT_tp entries; + + int num_entries = (int) png_get_sPLT(read_ptr, read_info_ptr, &entries); + if (num_entries) + { + png_set_sPLT(write_ptr, write_info_ptr, entries, num_entries); + } + } +#endif + +#ifdef PNG_TEXT_SUPPORTED + { + png_textp text_ptr; + int num_text; + + if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) + { + pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); + + pngtest_check_text_support(read_ptr, text_ptr, num_text); + + if (verbose != 0) + { + int i; + + fprintf(STDERR,"\n"); + for (i=0; igray > sample_max) || + (color_type == PNG_COLOR_TYPE_RGB && + ((int)trans_color->red > sample_max || + (int)trans_color->green > sample_max || + (int)trans_color->blue > sample_max)))) + png_set_tRNS(write_ptr, write_info_ptr, trans_alpha, num_trans, + trans_color); + } + } +#endif +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + { + png_unknown_chunkp unknowns; + int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr, + &unknowns); + + if (num_unknowns != 0) + { + png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, + num_unknowns); +#if PNG_LIBPNG_VER < 10600 + /* Copy the locations from the read_info_ptr. The automatically + * generated locations in write_end_info_ptr are wrong prior to 1.6.0 + * because they are reset from the write pointer (removed in 1.6.0). + */ + { + int i; + for (i = 0; i < num_unknowns; i++) + png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, + unknowns[i].location); + } +#endif + } + } +#endif + +#ifdef PNG_WRITE_SUPPORTED + pngtest_debug("Writing info struct"); + + /* Write the info in two steps so that if we write the 'unknown' chunks here + * they go to the correct place. + */ + png_write_info_before_PLTE(write_ptr, write_info_ptr); + + write_chunks(write_ptr, before_PLTE); /* before PLTE */ + + png_write_info(write_ptr, write_info_ptr); + + write_chunks(write_ptr, before_IDAT); /* after PLTE */ + + png_write_info(write_ptr, write_end_info_ptr); + + write_chunks(write_ptr, after_IDAT); /* after IDAT */ + +#ifdef PNG_COMPRESSION_COMPAT + /* Test the 'compatibility' setting here, if it is available. */ + png_set_compression(write_ptr, PNG_COMPRESSION_COMPAT); +#endif +#endif + +#ifdef SINGLE_ROWBUF_ALLOC + pngtest_debug("Allocating row buffer..."); + row_buf = (png_bytep)png_malloc(read_ptr, + png_get_rowbytes(read_ptr, read_info_ptr)); + + pngtest_debug1("\t0x%08lx", (unsigned long)row_buf); +#endif /* SINGLE_ROWBUF_ALLOC */ + pngtest_debug("Writing row data"); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) &&\ + defined(PNG_WRITE_INTERLACING_SUPPORTED) + /* Both must be defined for libpng to be able to handle the interlace, + * otherwise it gets handled below by simply reading and writing the passes + * directly. + */ + if (png_set_interlace_handling(read_ptr) != num_passes) + png_error(write_ptr, + "png_set_interlace_handling(read): wrong pass count "); + if (png_set_interlace_handling(write_ptr) != num_passes) + png_error(write_ptr, + "png_set_interlace_handling(write): wrong pass count "); +#else /* png_set_interlace_handling not called on either read or write */ +# define calc_pass_height +#endif /* not using libpng interlace handling */ + +#ifdef PNGTEST_TIMING + t_stop = (float)clock(); + t_misc += (t_stop - t_start); + t_start = t_stop; +#endif + for (pass = 0; pass < num_passes; pass++) + { +# ifdef calc_pass_height + png_uint_32 pass_height; + + if (num_passes == 7) /* interlaced */ + { + if (PNG_PASS_COLS(width, pass) > 0) + pass_height = PNG_PASS_ROWS(height, pass); + + else + pass_height = 0; + } + + else /* not interlaced */ + pass_height = height; +# else +# define pass_height height +# endif + + pngtest_debug1("Writing row data for pass %d", pass); + for (y = 0; y < pass_height; y++) + { +#ifndef SINGLE_ROWBUF_ALLOC + pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y); + + row_buf = (png_bytep)png_malloc(read_ptr, + png_get_rowbytes(read_ptr, read_info_ptr)); + + pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf, + (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr)); + +#endif /* !SINGLE_ROWBUF_ALLOC */ + png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1); + +#ifdef PNG_WRITE_SUPPORTED +#ifdef PNGTEST_TIMING + t_stop = (float)clock(); + t_decode += (t_stop - t_start); + t_start = t_stop; +#endif + png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); +#ifdef PNGTEST_TIMING + t_stop = (float)clock(); + t_encode += (t_stop - t_start); + t_start = t_stop; +#endif +#endif /* WRITE */ + +#ifndef SINGLE_ROWBUF_ALLOC + pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y); + png_free(read_ptr, row_buf); + row_buf = NULL; +#endif /* !SINGLE_ROWBUF_ALLOC */ + } + } + +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +# ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED + png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); +# endif +# ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); +# endif +#endif + + pngtest_debug("Reading and writing end_info data"); + + png_read_end(read_ptr, end_info_ptr); +#ifdef PNG_TEXT_SUPPORTED + { + png_textp text_ptr; + int num_text; + + if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) + { + pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); + + pngtest_check_text_support(read_ptr, text_ptr, num_text); + + if (verbose != 0) + { + int i; + + fprintf(STDERR,"\n"); + for (i=0; i 1) + fprintf(STDERR," eXIf type %c%c, %lu bytes\n",exif[0],exif[1], + (unsigned long)exif_length); +# ifdef PNG_WRITE_eXIf_SUPPORTED + png_set_eXIf_1(write_ptr, write_end_info_ptr, exif_length, exif); +# endif + } + } +#endif +#ifdef PNG_tIME_SUPPORTED + { + png_timep mod_time; + + if (png_get_tIME(read_ptr, end_info_ptr, &mod_time) != 0) + { + png_set_tIME(write_ptr, write_end_info_ptr, mod_time); +#ifdef PNG_TIME_RFC1123_SUPPORTED + if (png_convert_to_rfc1123_buffer(tIME_string, mod_time) != 0) + tIME_string[(sizeof tIME_string) - 1] = '\0'; + + else + { + strncpy(tIME_string, "*** invalid time ***", sizeof tIME_string); + tIME_string[(sizeof tIME_string)-1] = '\0'; + } + + tIME_chunk_present++; +#endif /* TIME_RFC1123 */ + } + } +#endif +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + { + png_unknown_chunkp unknowns; + int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr, + &unknowns); + + if (num_unknowns != 0) + { + png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, + num_unknowns); +#if PNG_LIBPNG_VER < 10600 + /* Copy the locations from the read_info_ptr. The automatically + * generated locations in write_end_info_ptr are wrong prior to 1.6.0 + * because they are reset from the write pointer (removed in 1.6.0). + */ + { + int i; + for (i = 0; i < num_unknowns; i++) + png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, + unknowns[i].location); + } +#endif + } + } +#endif + +#ifdef PNG_WRITE_SUPPORTED +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED + /* Normally one would use Z_DEFAULT_STRATEGY for text compression. + * This is here just to make pngtest replicate the results from libpng + * versions prior to 1.5.4, and to test this new API. + */ + png_set_text_compression_strategy(write_ptr, Z_FILTERED); +#endif + + /* When the unknown vpAg/sTER chunks are written by pngtest the only way to + * do it is to write them *before* calling png_write_end. When unknown + * chunks are written by libpng, however, they are written just before IEND. + * There seems to be no way round this, however vpAg/sTER are not expected + * after IDAT. + */ + write_chunks(write_ptr, after_IDAT); + + png_write_end(write_ptr, write_end_info_ptr); +#endif + +#ifdef PNG_EASY_ACCESS_SUPPORTED + if (verbose != 0) + { + png_uint_32 iwidth, iheight; + iwidth = png_get_image_width(write_ptr, write_info_ptr); + iheight = png_get_image_height(write_ptr, write_info_ptr); + fprintf(STDERR, "\n Image width = %lu, height = %lu\n", + (unsigned long)iwidth, (unsigned long)iheight); + } +#endif + + pngtest_debug("Destroying data structs"); +#ifdef SINGLE_ROWBUF_ALLOC + pngtest_debug("destroying row_buf for read_ptr"); + png_free(read_ptr, row_buf); + row_buf = NULL; +#endif /* SINGLE_ROWBUF_ALLOC */ + pngtest_debug("destroying read_ptr, read_info_ptr, end_info_ptr"); + png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); +#ifdef PNG_WRITE_SUPPORTED + pngtest_debug("destroying write_end_info_ptr"); + png_destroy_info_struct(write_ptr, &write_end_info_ptr); + pngtest_debug("destroying write_ptr, write_info_ptr"); + png_destroy_write_struct(&write_ptr, &write_info_ptr); +#endif + pngtest_debug("Destruction complete."); + + FCLOSE(fpin); + FCLOSE(fpout); + + /* Summarize any warnings or errors and in 'strict' mode fail the test. + * Unsupported chunks can result in warnings, in that case ignore the strict + * setting, otherwise fail the test on warnings as well as errors. + */ + if (error_count > 0) + { + /* We don't really expect to get here because of the setjmp handling + * above, but this is safe. + */ + fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)", + inname, error_count, warning_count); + + if (strict != 0) + return (1); + } + +# ifdef PNG_WRITE_SUPPORTED + /* If there is no write support nothing was written! */ + else if (unsupported_chunks > 0) + { + fprintf(STDERR, "\n %s: unsupported chunks (%d)%s", + inname, unsupported_chunks, strict ? ": IGNORED --strict!" : ""); + } +# endif + + else if (warning_count > 0) + { + fprintf(STDERR, "\n %s: %d libpng warnings found", + inname, warning_count); + + if (strict != 0) + return (1); + } + + pngtest_debug("Opening files for comparison"); + if ((fpin = fopen(inname, "rb")) == NULL) + { + fprintf(STDERR, "Could not find file %s\n", inname); + return (1); + } + + if ((fpout = fopen(outname, "rb")) == NULL) + { + fprintf(STDERR, "Could not find file %s\n", outname); + FCLOSE(fpin); + return (1); + } + +#if defined (PNG_WRITE_SUPPORTED) /* else nothing was written */ &&\ + defined (PNG_WRITE_FILTER_SUPPORTED) + if (interlace_preserved != 0) /* else the files will be changed */ + { + for (;;) + { + static int wrote_question = 0; + png_size_t num_in, num_out; + char inbuf[256], outbuf[256]; + + num_in = fread(inbuf, 1, sizeof inbuf, fpin); + num_out = fread(outbuf, 1, sizeof outbuf, fpout); + + if (num_in != num_out) + { + fprintf(STDERR, "\nFiles %s and %s are of a different size\n", + inname, outname); + + if (wrote_question == 0 && unsupported_chunks == 0) + { + fprintf(STDERR, + " Was %s written with the same maximum IDAT" + " chunk size (%d bytes),", + inname, PNG_ZBUF_SIZE); + fprintf(STDERR, + "\n filtering heuristic (libpng default), compression"); + fprintf(STDERR, + " level (zlib default),\n and zlib version (%s)?\n\n", + ZLIB_VERSION); + wrote_question = 1; + } + + FCLOSE(fpin); + FCLOSE(fpout); + + if (strict != 0 && unsupported_chunks == 0) + return (1); + + else + return (0); + } + + if (num_in == 0) + break; + + if (memcmp(inbuf, outbuf, num_in)) + { + fprintf(STDERR, "\nFiles %s and %s are different\n", inname, + outname); + + if (wrote_question == 0 && unsupported_chunks == 0) + { + fprintf(STDERR, + " Was %s written with the same maximum" + " IDAT chunk size (%d bytes),", + inname, PNG_ZBUF_SIZE); + fprintf(STDERR, + "\n filtering heuristic (libpng default), compression"); + fprintf(STDERR, + " level (zlib default),\n and zlib version (%s)?\n\n", + ZLIB_VERSION); + wrote_question = 1; + } + + FCLOSE(fpin); + FCLOSE(fpout); + + /* NOTE: the unsupported_chunks escape is permitted here because + * unsupported text chunk compression will result in the compression + * mode being changed (to NONE) yet, in the test case, the result + * can be exactly the same size! + */ + if (strict != 0 && unsupported_chunks == 0) + return (1); + + else + return (0); + } + } + } +#endif /* WRITE && WRITE_FILTER */ + + FCLOSE(fpin); + FCLOSE(fpout); + + return (0); +} + +/* Input and output filenames */ +#ifdef RISCOS +static PNG_CONST char *inname = "pngtest/png"; +static PNG_CONST char *outname = "pngout/png"; +#else +static PNG_CONST char *inname = "pngtest.png"; +static PNG_CONST char *outname = "pngout.png"; +#endif + +int +main(int argc, char *argv[]) +{ + int multiple = 0; + int ierror = 0; + + png_structp dummy_ptr; + + fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); + fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); + fprintf(STDERR, "%s", png_get_copyright(NULL)); + /* Show the version of libpng used in building the library */ + fprintf(STDERR, " library (%lu):%s", + (unsigned long)png_access_version_number(), + png_get_header_version(NULL)); + + /* Show the version of libpng used in building the application */ + fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, + PNG_HEADER_VERSION_STRING); + + /* Do some consistency checking on the memory allocation settings, I'm + * not sure this matters, but it is nice to know, the first of these + * tests should be impossible because of the way the macros are set + * in pngconf.h + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) + fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); +#endif + /* I think the following can happen. */ +#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) + fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); +#endif + + if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) + { + fprintf(STDERR, + "Warning: versions are different between png.h and png.c\n"); + fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); + fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); + ++ierror; + } + + if (argc > 1) + { + if (strcmp(argv[1], "-m") == 0) + { + multiple = 1; + status_dots_requested = 0; + } + + else if (strcmp(argv[1], "-mv") == 0 || + strcmp(argv[1], "-vm") == 0 ) + { + multiple = 1; + verbose = 1; + status_dots_requested = 1; + } + + else if (strcmp(argv[1], "-v") == 0) + { + verbose = 1; + status_dots_requested = 1; + inname = argv[2]; + } + + else if (strcmp(argv[1], "--strict") == 0) + { + status_dots_requested = 0; + verbose = 1; + inname = argv[2]; + strict++; + relaxed = 0; + multiple=1; + } + + else if (strcmp(argv[1], "--relaxed") == 0) + { + status_dots_requested = 0; + verbose = 1; + inname = argv[2]; + strict = 0; + relaxed++; + multiple=1; + } + else if (strcmp(argv[1], "--xfail") == 0) + { + status_dots_requested = 0; + verbose = 1; + inname = argv[2]; + strict = 0; + xfail++; + relaxed++; + multiple=1; + } + + else + { + inname = argv[1]; + status_dots_requested = 0; + } + } + + if (multiple == 0 && argc == 3 + verbose) + outname = argv[2 + verbose]; + + if ((multiple == 0 && argc > 3 + verbose) || + (multiple != 0 && argc < 2)) + { + fprintf(STDERR, + "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", + argv[0], argv[0]); + fprintf(STDERR, + " reads/writes one PNG file (without -m) or multiple files (-m)\n"); + fprintf(STDERR, + " with -m %s is used as a temporary file\n", outname); + exit(1); + } + + if (multiple != 0) + { + int i; +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + int allocation_now = current_allocation; +#endif + for (i=2; i 0 + fprintf(STDERR, "\n"); +#endif + kerror = test_one_file(argv[i], outname); + if (kerror == 0) + { +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED + fprintf(STDERR, "\n PASS (%lu zero samples)\n", + (unsigned long)zero_samples); +#else + fprintf(STDERR, " PASS\n"); +#endif +#ifdef PNG_TIME_RFC1123_SUPPORTED + if (tIME_chunk_present != 0) + fprintf(STDERR, " tIME = %s\n", tIME_string); + + tIME_chunk_present = 0; +#endif /* TIME_RFC1123 */ + } + + else + { + if (xfail) + fprintf(STDERR, " XFAIL\n"); + else + { + fprintf(STDERR, " FAIL\n"); + ierror += kerror; + } + } +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + if (allocation_now != current_allocation) + fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", + current_allocation - allocation_now); + + if (current_allocation != 0) + { + memory_infop pinfo = pinformation; + + fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", + current_allocation); + + while (pinfo != NULL) + { + fprintf(STDERR, " %lu bytes at %p\n", + (unsigned long)pinfo->size, + pinfo->pointer); + pinfo = pinfo->next; + } + } +#endif + } +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + fprintf(STDERR, " Current memory allocation: %10d bytes\n", + current_allocation); + fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", + maximum_allocation); + fprintf(STDERR, " Total memory allocation: %10d bytes\n", + total_allocation); + fprintf(STDERR, " Number of allocations: %10d\n", + num_allocations); +#endif + } + + else + { + int i; + for (i = 0; i<3; ++i) + { + int kerror; +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + int allocation_now = current_allocation; +#endif + if (i == 1) + status_dots_requested = 1; + + else if (verbose == 0) + status_dots_requested = 0; + + if (i == 0 || verbose == 1 || ierror != 0) + { + fprintf(STDERR, "\n Testing %s:", inname); +#if PNG_DEBUG > 0 + fprintf(STDERR, "\n"); +#endif + } + + kerror = test_one_file(inname, outname); + + if (kerror == 0) + { + if (verbose == 1 || i == 2) + { +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED + fprintf(STDERR, "\n PASS (%lu zero samples)\n", + (unsigned long)zero_samples); +#else + fprintf(STDERR, " PASS\n"); +#endif +#ifdef PNG_TIME_RFC1123_SUPPORTED + if (tIME_chunk_present != 0) + fprintf(STDERR, " tIME = %s\n", tIME_string); +#endif /* TIME_RFC1123 */ + } + } + + else + { + if (verbose == 0 && i != 2) + { + fprintf(STDERR, "\n Testing %s:", inname); +#if PNG_DEBUG > 0 + fprintf(STDERR, "\n"); +#endif + } + + if (xfail) + fprintf(STDERR, " XFAIL\n"); + else + { + fprintf(STDERR, " FAIL\n"); + ierror += kerror; + } + } +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + if (allocation_now != current_allocation) + fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", + current_allocation - allocation_now); + + if (current_allocation != 0) + { + memory_infop pinfo = pinformation; + + fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", + current_allocation); + + while (pinfo != NULL) + { + fprintf(STDERR, " %lu bytes at %p\n", + (unsigned long)pinfo->size, pinfo->pointer); + pinfo = pinfo->next; + } + } +#endif + } +#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG + fprintf(STDERR, " Current memory allocation: %10d bytes\n", + current_allocation); + fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", + maximum_allocation); + fprintf(STDERR, " Total memory allocation: %10d bytes\n", + total_allocation); + fprintf(STDERR, " Number of allocations: %10d\n", + num_allocations); +#endif + } + +#ifdef PNGTEST_TIMING + t_stop = (float)clock(); + t_misc += (t_stop - t_start); + t_start = t_stop; + fprintf(STDERR, " CPU time used = %.3f seconds", + (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); + fprintf(STDERR, " (decoding %.3f,\n", + t_decode/(float)CLOCKS_PER_SEC); + fprintf(STDERR, " encoding %.3f ,", + t_encode/(float)CLOCKS_PER_SEC); + fprintf(STDERR, " other %.3f seconds)\n\n", + t_misc/(float)CLOCKS_PER_SEC); +#endif + + if (ierror == 0) + fprintf(STDERR, " libpng passes test\n"); + + else + fprintf(STDERR, " libpng FAILS test\n"); + + dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + fprintf(STDERR, " Default limits:\n"); + fprintf(STDERR, " width_max = %lu\n", + (unsigned long) png_get_user_width_max(dummy_ptr)); + fprintf(STDERR, " height_max = %lu\n", + (unsigned long) png_get_user_height_max(dummy_ptr)); + if (png_get_chunk_cache_max(dummy_ptr) == 0) + fprintf(STDERR, " cache_max = unlimited\n"); + else + fprintf(STDERR, " cache_max = %lu\n", + (unsigned long) png_get_chunk_cache_max(dummy_ptr)); + if (png_get_chunk_malloc_max(dummy_ptr) == 0) + fprintf(STDERR, " malloc_max = unlimited\n"); + else + fprintf(STDERR, " malloc_max = %lu\n", + (unsigned long) png_get_chunk_malloc_max(dummy_ptr)); + png_destroy_read_struct(&dummy_ptr, NULL, NULL); + + return (int)(ierror != 0); +} +#else +int +main(void) +{ + fprintf(STDERR, + " test ignored because libpng was not built with read support\n"); + /* And skip this test */ + return PNG_LIBPNG_VER < 10600 ? 0 : 77; +} +#endif + +/* Generate a compiler error if there is an old png.h in the search path. */ +typedef png_libpng_version_1_6_34 Your_png_h_is_not_version_1_6_34; diff --git a/xs/src/png/libpng/pngtrans.c b/xs/src/png/libpng/pngtrans.c new file mode 100644 index 0000000000..6882f0fd7b --- /dev/null +++ b/xs/src/png/libpng/pngtrans.c @@ -0,0 +1,864 @@ + +/* pngtrans.c - transforms the data in a row (used by both readers and writers) + * + * Last changed in libpng 1.6.33 [September 28, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "pngpriv.h" + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Turn on BGR-to-RGB mapping */ +void PNGAPI +png_set_bgr(png_structrp png_ptr) +{ + png_debug(1, "in png_set_bgr"); + + if (png_ptr == NULL) + return; + + png_ptr->transformations |= PNG_BGR; +} +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Turn on 16-bit byte swapping */ +void PNGAPI +png_set_swap(png_structrp png_ptr) +{ + png_debug(1, "in png_set_swap"); + + if (png_ptr == NULL) + return; + + if (png_ptr->bit_depth == 16) + png_ptr->transformations |= PNG_SWAP_BYTES; +} +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Turn on pixel packing */ +void PNGAPI +png_set_packing(png_structrp png_ptr) +{ + png_debug(1, "in png_set_packing"); + + if (png_ptr == NULL) + return; + + if (png_ptr->bit_depth < 8) + { + png_ptr->transformations |= PNG_PACK; +# ifdef PNG_WRITE_SUPPORTED + png_ptr->usr_bit_depth = 8; +# endif + } +} +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Turn on packed pixel swapping */ +void PNGAPI +png_set_packswap(png_structrp png_ptr) +{ + png_debug(1, "in png_set_packswap"); + + if (png_ptr == NULL) + return; + + if (png_ptr->bit_depth < 8) + png_ptr->transformations |= PNG_PACKSWAP; +} +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +void PNGAPI +png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits) +{ + png_debug(1, "in png_set_shift"); + + if (png_ptr == NULL) + return; + + png_ptr->transformations |= PNG_SHIFT; + png_ptr->shift = *true_bits; +} +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +int PNGAPI +png_set_interlace_handling(png_structrp png_ptr) +{ + png_debug(1, "in png_set_interlace handling"); + + if (png_ptr != 0 && png_ptr->interlaced != 0) + { + png_ptr->transformations |= PNG_INTERLACE; + return (7); + } + + return (1); +} +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte on read, or remove a filler or alpha byte on write. + * The filler type has changed in v0.95 to allow future 2-byte fillers + * for 48-bit input data, as well as to avoid problems with some compilers + * that don't like bytes as parameters. + */ +void PNGAPI +png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc) +{ + png_debug(1, "in png_set_filler"); + + if (png_ptr == NULL) + return; + + /* In libpng 1.6 it is possible to determine whether this is a read or write + * operation and therefore to do more checking here for a valid call. + */ + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) + { +# ifdef PNG_READ_FILLER_SUPPORTED + /* On read png_set_filler is always valid, regardless of the base PNG + * format, because other transformations can give a format where the + * filler code can execute (basically an 8 or 16-bit component RGB or G + * format.) + * + * NOTE: usr_channels is not used by the read code! (This has led to + * confusion in the past.) The filler is only used in the read code. + */ + png_ptr->filler = (png_uint_16)filler; +# else + png_app_error(png_ptr, "png_set_filler not supported on read"); + PNG_UNUSED(filler) /* not used in the write case */ + return; +# endif + } + + else /* write */ + { +# ifdef PNG_WRITE_FILLER_SUPPORTED + /* On write the usr_channels parameter must be set correctly at the + * start to record the number of channels in the app-supplied data. + */ + switch (png_ptr->color_type) + { + case PNG_COLOR_TYPE_RGB: + png_ptr->usr_channels = 4; + break; + + case PNG_COLOR_TYPE_GRAY: + if (png_ptr->bit_depth >= 8) + { + png_ptr->usr_channels = 2; + break; + } + + else + { + /* There simply isn't any code in libpng to strip out bits + * from bytes when the components are less than a byte in + * size! + */ + png_app_error(png_ptr, + "png_set_filler is invalid for" + " low bit depth gray output"); + return; + } + + default: + png_app_error(png_ptr, + "png_set_filler: inappropriate color type"); + return; + } +# else + png_app_error(png_ptr, "png_set_filler not supported on write"); + return; +# endif + } + + /* Here on success - libpng supports the operation, set the transformation + * and the flag to say where the filler channel is. + */ + png_ptr->transformations |= PNG_FILLER; + + if (filler_loc == PNG_FILLER_AFTER) + png_ptr->flags |= PNG_FLAG_FILLER_AFTER; + + else + png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; +} + +/* Added to libpng-1.2.7 */ +void PNGAPI +png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc) +{ + png_debug(1, "in png_set_add_alpha"); + + if (png_ptr == NULL) + return; + + png_set_filler(png_ptr, filler, filler_loc); + /* The above may fail to do anything. */ + if ((png_ptr->transformations & PNG_FILLER) != 0) + png_ptr->transformations |= PNG_ADD_ALPHA; +} + +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +void PNGAPI +png_set_swap_alpha(png_structrp png_ptr) +{ + png_debug(1, "in png_set_swap_alpha"); + + if (png_ptr == NULL) + return; + + png_ptr->transformations |= PNG_SWAP_ALPHA; +} +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +void PNGAPI +png_set_invert_alpha(png_structrp png_ptr) +{ + png_debug(1, "in png_set_invert_alpha"); + + if (png_ptr == NULL) + return; + + png_ptr->transformations |= PNG_INVERT_ALPHA; +} +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +void PNGAPI +png_set_invert_mono(png_structrp png_ptr) +{ + png_debug(1, "in png_set_invert_mono"); + + if (png_ptr == NULL) + return; + + png_ptr->transformations |= PNG_INVERT_MONO; +} + +/* Invert monochrome grayscale data */ +void /* PRIVATE */ +png_do_invert(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_invert"); + + /* This test removed from libpng version 1.0.13 and 1.2.0: + * if (row_info->bit_depth == 1 && + */ + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + png_bytep rp = row; + png_size_t i; + png_size_t istop = row_info->rowbytes; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(~(*rp)); + rp++; + } + } + + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + row_info->bit_depth == 8) + { + png_bytep rp = row; + png_size_t i; + png_size_t istop = row_info->rowbytes; + + for (i = 0; i < istop; i += 2) + { + *rp = (png_byte)(~(*rp)); + rp += 2; + } + } + +#ifdef PNG_16BIT_SUPPORTED + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + row_info->bit_depth == 16) + { + png_bytep rp = row; + png_size_t i; + png_size_t istop = row_info->rowbytes; + + for (i = 0; i < istop; i += 4) + { + *rp = (png_byte)(~(*rp)); + *(rp + 1) = (png_byte)(~(*(rp + 1))); + rp += 4; + } + } +#endif +} +#endif + +#ifdef PNG_16BIT_SUPPORTED +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swaps byte order on 16-bit depth images */ +void /* PRIVATE */ +png_do_swap(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_swap"); + + if (row_info->bit_depth == 16) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop= row_info->width * row_info->channels; + + for (i = 0; i < istop; i++, rp += 2) + { +#ifdef PNG_BUILTIN_BSWAP16_SUPPORTED + /* Feature added to libpng-1.6.11 for testing purposes, not + * enabled by default. + */ + *(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp); +#else + png_byte t = *rp; + *rp = *(rp + 1); + *(rp + 1) = t; +#endif + } + } +} +#endif +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) +static PNG_CONST png_byte onebppswaptable[256] = { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, + 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, + 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, + 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, + 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, + 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, + 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, + 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, + 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, + 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, + 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, + 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, + 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, + 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, + 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, + 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, + 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF +}; + +static PNG_CONST png_byte twobppswaptable[256] = { + 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, + 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, + 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, + 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, + 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, + 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, + 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, + 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, + 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, + 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, + 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, + 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, + 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, + 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, + 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, + 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, + 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, + 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, + 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, + 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, + 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, + 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, + 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, + 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, + 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, + 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, + 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, + 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, + 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, + 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, + 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, + 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF +}; + +static PNG_CONST png_byte fourbppswaptable[256] = { + 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, + 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, + 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, + 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, + 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, + 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, + 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, + 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, + 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, + 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, + 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, + 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, + 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, + 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, + 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, + 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, + 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, + 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, + 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, + 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, + 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, + 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, + 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, + 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, + 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, + 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, + 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, + 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, + 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, + 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, + 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, + 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF +}; + +/* Swaps pixel packing order within bytes */ +void /* PRIVATE */ +png_do_packswap(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_packswap"); + + if (row_info->bit_depth < 8) + { + png_bytep rp; + png_const_bytep end, table; + + end = row + row_info->rowbytes; + + if (row_info->bit_depth == 1) + table = onebppswaptable; + + else if (row_info->bit_depth == 2) + table = twobppswaptable; + + else if (row_info->bit_depth == 4) + table = fourbppswaptable; + + else + return; + + for (rp = row; rp < end; rp++) + *rp = table[*rp]; + } +} +#endif /* PACKSWAP || WRITE_PACKSWAP */ + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +/* Remove a channel - this used to be 'png_do_strip_filler' but it used a + * somewhat weird combination of flags to determine what to do. All the calls + * to png_do_strip_filler are changed in 1.5.2 to call this instead with the + * correct arguments. + * + * The routine isn't general - the channel must be the channel at the start or + * end (not in the middle) of each pixel. + */ +void /* PRIVATE */ +png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) +{ + png_bytep sp = row; /* source pointer */ + png_bytep dp = row; /* destination pointer */ + png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */ + + /* At the start sp will point to the first byte to copy and dp to where + * it is copied to. ep always points just beyond the end of the row, so + * the loop simply copies (channels-1) channels until sp reaches ep. + * + * at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc. + * nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc. + */ + + /* GA, GX, XG cases */ + if (row_info->channels == 2) + { + if (row_info->bit_depth == 8) + { + if (at_start != 0) /* Skip initial filler */ + ++sp; + else /* Skip initial channel and, for sp, the filler */ + { + sp += 2; ++dp; + } + + /* For a 1 pixel wide image there is nothing to do */ + while (sp < ep) + { + *dp++ = *sp; sp += 2; + } + + row_info->pixel_depth = 8; + } + + else if (row_info->bit_depth == 16) + { + if (at_start != 0) /* Skip initial filler */ + sp += 2; + else /* Skip initial channel and, for sp, the filler */ + { + sp += 4; dp += 2; + } + + while (sp < ep) + { + *dp++ = *sp++; *dp++ = *sp; sp += 3; + } + + row_info->pixel_depth = 16; + } + + else + return; /* bad bit depth */ + + row_info->channels = 1; + + /* Finally fix the color type if it records an alpha channel */ + if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + row_info->color_type = PNG_COLOR_TYPE_GRAY; + } + + /* RGBA, RGBX, XRGB cases */ + else if (row_info->channels == 4) + { + if (row_info->bit_depth == 8) + { + if (at_start != 0) /* Skip initial filler */ + ++sp; + else /* Skip initial channels and, for sp, the filler */ + { + sp += 4; dp += 3; + } + + /* Note that the loop adds 3 to dp and 4 to sp each time. */ + while (sp < ep) + { + *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2; + } + + row_info->pixel_depth = 24; + } + + else if (row_info->bit_depth == 16) + { + if (at_start != 0) /* Skip initial filler */ + sp += 2; + else /* Skip initial channels and, for sp, the filler */ + { + sp += 8; dp += 6; + } + + while (sp < ep) + { + /* Copy 6 bytes, skip 2 */ + *dp++ = *sp++; *dp++ = *sp++; + *dp++ = *sp++; *dp++ = *sp++; + *dp++ = *sp++; *dp++ = *sp; sp += 3; + } + + row_info->pixel_depth = 48; + } + + else + return; /* bad bit depth */ + + row_info->channels = 3; + + /* Finally fix the color type if it records an alpha channel */ + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + row_info->color_type = PNG_COLOR_TYPE_RGB; + } + + else + return; /* The filler channel has gone already */ + + /* Fix the rowbytes value. */ + row_info->rowbytes = (png_size_t)(dp-row); +} +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Swaps red and blue bytes within a pixel */ +void /* PRIVATE */ +png_do_bgr(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_bgr"); + + if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + png_uint_32 row_width = row_info->width; + if (row_info->bit_depth == 8) + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 3) + { + png_byte save = *rp; + *rp = *(rp + 2); + *(rp + 2) = save; + } + } + + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 4) + { + png_byte save = *rp; + *rp = *(rp + 2); + *(rp + 2) = save; + } + } + } + +#ifdef PNG_16BIT_SUPPORTED + else if (row_info->bit_depth == 16) + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 6) + { + png_byte save = *rp; + *rp = *(rp + 4); + *(rp + 4) = save; + save = *(rp + 1); + *(rp + 1) = *(rp + 5); + *(rp + 5) = save; + } + } + + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 8) + { + png_byte save = *rp; + *rp = *(rp + 4); + *(rp + 4) = save; + save = *(rp + 1); + *(rp + 1) = *(rp + 5); + *(rp + 5) = save; + } + } + } +#endif + } +} +#endif /* READ_BGR || WRITE_BGR */ + +#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ + defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) +/* Added at libpng-1.5.10 */ +void /* PRIVATE */ +png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) +{ + if (png_ptr->num_palette < (1 << row_info->bit_depth) && + png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */ + { + /* Calculations moved outside switch in an attempt to stop different + * compiler warnings. 'padding' is in *bits* within the last byte, it is + * an 'int' because pixel_depth becomes an 'int' in the expression below, + * and this calculation is used because it avoids warnings that other + * forms produced on either GCC or MSVC. + */ + int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width); + png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1; + + switch (row_info->bit_depth) + { + case 1: + { + /* in this case, all bytes must be 0 so we don't need + * to unpack the pixels except for the rightmost one. + */ + for (; rp > png_ptr->row_buf; rp--) + { + if ((*rp >> padding) != 0) + png_ptr->num_palette_max = 1; + padding = 0; + } + + break; + } + + case 2: + { + for (; rp > png_ptr->row_buf; rp--) + { + int i = ((*rp >> padding) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 2) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 4) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 6) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + padding = 0; + } + + break; + } + + case 4: + { + for (; rp > png_ptr->row_buf; rp--) + { + int i = ((*rp >> padding) & 0x0f); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 4) & 0x0f); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + padding = 0; + } + + break; + } + + case 8: + { + for (; rp > png_ptr->row_buf; rp--) + { + if (*rp > png_ptr->num_palette_max) + png_ptr->num_palette_max = (int) *rp; + } + + break; + } + + default: + break; + } + } +} +#endif /* CHECK_FOR_INVALID_INDEX */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED +void PNGAPI +png_set_user_transform_info(png_structrp png_ptr, png_voidp + user_transform_ptr, int user_transform_depth, int user_transform_channels) +{ + png_debug(1, "in png_set_user_transform_info"); + + if (png_ptr == NULL) + return; + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && + (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) + { + png_app_error(png_ptr, + "info change after png_start_read_image or png_read_update_info"); + return; + } +#endif + + png_ptr->user_transform_ptr = user_transform_ptr; + png_ptr->user_transform_depth = (png_byte)user_transform_depth; + png_ptr->user_transform_channels = (png_byte)user_transform_channels; +} +#endif + +/* This function returns a pointer to the user_transform_ptr associated with + * the user transform functions. The application should free any memory + * associated with this pointer before png_write_destroy and png_read_destroy + * are called. + */ +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED +png_voidp PNGAPI +png_get_user_transform_ptr(png_const_structrp png_ptr) +{ + if (png_ptr == NULL) + return (NULL); + + return png_ptr->user_transform_ptr; +} +#endif + +#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED +png_uint_32 PNGAPI +png_get_current_row_number(png_const_structrp png_ptr) +{ + /* See the comments in png.h - this is the sub-image row when reading an + * interlaced image. + */ + if (png_ptr != NULL) + return png_ptr->row_number; + + return PNG_UINT_32_MAX; /* help the app not to fail silently */ +} + +png_byte PNGAPI +png_get_current_pass_number(png_const_structrp png_ptr) +{ + if (png_ptr != NULL) + return png_ptr->pass; + return 8; /* invalid */ +} +#endif /* USER_TRANSFORM_INFO */ +#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */ +#endif /* READ || WRITE */ diff --git a/xs/src/png/libpng/pngwio.c b/xs/src/png/libpng/pngwio.c new file mode 100644 index 0000000000..37c7c3a7f0 --- /dev/null +++ b/xs/src/png/libpng/pngwio.c @@ -0,0 +1,168 @@ + +/* pngwio.c - functions for data output + * + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * This file provides a location for all output. Users who need + * special handling are expected to write functions that have the same + * arguments as these and perform similar functions, but that possibly + * use different output methods. Note that you shouldn't change these + * functions, but rather write replacement functions and then change + * them at run time with png_set_write_fn(...). + */ + +#include "pngpriv.h" + +#ifdef PNG_WRITE_SUPPORTED + +/* Write the data to whatever output you are using. The default routine + * writes to a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered writes. This should never be asked + * to write more than 64K on a 16-bit machine. + */ + +void /* PRIVATE */ +png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) +{ + /* NOTE: write_data_fn must not change the buffer! */ + if (png_ptr->write_data_fn != NULL ) + (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data), + length); + + else + png_error(png_ptr, "Call to NULL write function"); +} + +#ifdef PNG_STDIO_SUPPORTED +/* This is the function that does the actual writing of data. If you are + * not writing to a standard C stream, you should create a replacement + * write_data function and use it at run time with png_set_write_fn(), rather + * than changing the library. + */ +void PNGCBAPI +png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + if (png_ptr == NULL) + return; + + check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); + + if (check != length) + png_error(png_ptr, "Write Error"); +} +#endif + +/* This function is called to output any data pending writing (normally + * to disk). After png_flush is called, there should be no data pending + * writing in any buffers. + */ +#ifdef PNG_WRITE_FLUSH_SUPPORTED +void /* PRIVATE */ +png_flush(png_structrp png_ptr) +{ + if (png_ptr->output_flush_fn != NULL) + (*(png_ptr->output_flush_fn))(png_ptr); +} + +# ifdef PNG_STDIO_SUPPORTED +void PNGCBAPI +png_default_flush(png_structp png_ptr) +{ + png_FILE_p io_ptr; + + if (png_ptr == NULL) + return; + + io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr)); + fflush(io_ptr); +} +# endif +#endif + +/* This function allows the application to supply new output functions for + * libpng if standard C streams aren't being used. + * + * This function takes as its arguments: + * png_ptr - pointer to a png output data structure + * io_ptr - pointer to user supplied structure containing info about + * the output functions. May be NULL. + * write_data_fn - pointer to a new output function that takes as its + * arguments a pointer to a png_struct, a pointer to + * data to be written, and a 32-bit unsigned int that is + * the number of bytes to be written. The new write + * function should call png_error(png_ptr, "Error msg") + * to exit and output any fatal error messages. May be + * NULL, in which case libpng's default function will + * be used. + * flush_data_fn - pointer to a new flush function that takes as its + * arguments a pointer to a png_struct. After a call to + * the flush function, there should be no data in any buffers + * or pending transmission. If the output method doesn't do + * any buffering of output, a function prototype must still be + * supplied although it doesn't have to do anything. If + * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile + * time, output_flush_fn will be ignored, although it must be + * supplied for compatibility. May be NULL, in which case + * libpng's default function will be used, if + * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not + * a good idea if io_ptr does not point to a standard + * *FILE structure. + */ +void PNGAPI +png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, + png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) +{ + if (png_ptr == NULL) + return; + + png_ptr->io_ptr = io_ptr; + +#ifdef PNG_STDIO_SUPPORTED + if (write_data_fn != NULL) + png_ptr->write_data_fn = write_data_fn; + + else + png_ptr->write_data_fn = png_default_write_data; +#else + png_ptr->write_data_fn = write_data_fn; +#endif + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +# ifdef PNG_STDIO_SUPPORTED + + if (output_flush_fn != NULL) + png_ptr->output_flush_fn = output_flush_fn; + + else + png_ptr->output_flush_fn = png_default_flush; + +# else + png_ptr->output_flush_fn = output_flush_fn; +# endif +#else + PNG_UNUSED(output_flush_fn) +#endif /* WRITE_FLUSH */ + +#ifdef PNG_READ_SUPPORTED + /* It is an error to read while writing a png file */ + if (png_ptr->read_data_fn != NULL) + { + png_ptr->read_data_fn = NULL; + + png_warning(png_ptr, + "Can't set both read_data_fn and write_data_fn in the" + " same structure"); + } +#endif +} +#endif /* WRITE */ diff --git a/xs/src/png/libpng/pngwrite.c b/xs/src/png/libpng/pngwrite.c new file mode 100644 index 0000000000..a16d77ce00 --- /dev/null +++ b/xs/src/png/libpng/pngwrite.c @@ -0,0 +1,2396 @@ + +/* pngwrite.c - general routines to write a PNG file + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "pngpriv.h" +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED +# include +#endif /* SIMPLIFIED_WRITE_STDIO */ + +#ifdef PNG_WRITE_SUPPORTED + +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +/* Write out all the unknown chunks for the current given location */ +static void +write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, + unsigned int where) +{ + if (info_ptr->unknown_chunks_num != 0) + { + png_const_unknown_chunkp up; + + png_debug(5, "writing extra chunks"); + + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + ++up) + if ((up->location & where) != 0) + { + /* If per-chunk unknown chunk handling is enabled use it, otherwise + * just write the chunks the application has set. + */ +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + int keep = png_handle_as_unknown(png_ptr, up->name); + + /* NOTE: this code is radically different from the read side in the + * matter of handling an ancillary unknown chunk. In the read side + * the default behavior is to discard it, in the code below the default + * behavior is to write it. Critical chunks are, however, only + * written if explicitly listed or if the default is set to write all + * unknown chunks. + * + * The default handling is also slightly weird - it is not possible to + * stop the writing of all unsafe-to-copy chunks! + * + * TODO: REVIEW: this would seem to be a bug. + */ + if (keep != PNG_HANDLE_CHUNK_NEVER && + ((up->name[3] & 0x20) /* safe-to-copy overrides everything */ || + keep == PNG_HANDLE_CHUNK_ALWAYS || + (keep == PNG_HANDLE_CHUNK_AS_DEFAULT && + png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS))) +#endif + { + /* TODO: review, what is wrong with a zero length unknown chunk? */ + if (up->size == 0) + png_warning(png_ptr, "Writing zero-length unknown chunk"); + + png_write_chunk(png_ptr, up->name, up->data, up->size); + } + } + } +} +#endif /* WRITE_UNKNOWN_CHUNKS */ + +/* Writes all the PNG information. This is the suggested way to use the + * library. If you have a new chunk to add, make a function to write it, + * and put it in the correct location here. If you want the chunk written + * after the image data, put it in png_write_end(). I strongly encourage + * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing + * the chunk, as that will keep the code from breaking if you want to just + * write a plain PNG file. If you have long comments, I suggest writing + * them in png_write_end(), and compressing them. + */ +void PNGAPI +png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) +{ + png_debug(1, "in png_write_info_before_PLTE"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0) + { + /* Write PNG signature */ + png_write_sig(png_ptr); + +#ifdef PNG_MNG_FEATURES_SUPPORTED + if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \ + png_ptr->mng_features_permitted != 0) + { + png_warning(png_ptr, + "MNG features are not allowed in a PNG datastream"); + png_ptr->mng_features_permitted = 0; + } +#endif + + /* Write IHDR information. */ + png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, + info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, + info_ptr->filter_type, +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + info_ptr->interlace_type +#else + 0 +#endif + ); + + /* The rest of these check to see if the valid field has the appropriate + * flag set, and if it does, writes the chunk. + * + * 1.6.0: COLORSPACE support controls the writing of these chunks too, and + * the chunks will be written if the WRITE routine is there and + * information * is available in the COLORSPACE. (See + * png_colorspace_sync_info in png.c for where the valid flags get set.) + * + * Under certain circumstances the colorspace can be invalidated without + * syncing the info_struct 'valid' flags; this happens if libpng detects + * an error and calls png_error while the color space is being set, yet + * the application continues writing the PNG. So check the 'invalid' + * flag here too. + */ +#ifdef PNG_GAMMA_SUPPORTED +# ifdef PNG_WRITE_gAMA_SUPPORTED + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && + (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 && + (info_ptr->valid & PNG_INFO_gAMA) != 0) + png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma); +# endif +#endif + +#ifdef PNG_COLORSPACE_SUPPORTED + /* Write only one of sRGB or an ICC profile. If a profile was supplied + * and it matches one of the known sRGB ones issue a warning. + */ +# ifdef PNG_WRITE_iCCP_SUPPORTED + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && + (info_ptr->valid & PNG_INFO_iCCP) != 0) + { +# ifdef PNG_WRITE_sRGB_SUPPORTED + if ((info_ptr->valid & PNG_INFO_sRGB) != 0) + png_app_warning(png_ptr, + "profile matches sRGB but writing iCCP instead"); +# endif + + png_write_iCCP(png_ptr, info_ptr->iccp_name, + info_ptr->iccp_profile); + } +# ifdef PNG_WRITE_sRGB_SUPPORTED + else +# endif +# endif + +# ifdef PNG_WRITE_sRGB_SUPPORTED + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && + (info_ptr->valid & PNG_INFO_sRGB) != 0) + png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent); +# endif /* WRITE_sRGB */ +#endif /* COLORSPACE */ + +#ifdef PNG_WRITE_sBIT_SUPPORTED + if ((info_ptr->valid & PNG_INFO_sBIT) != 0) + png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); +#endif + +#ifdef PNG_COLORSPACE_SUPPORTED +# ifdef PNG_WRITE_cHRM_SUPPORTED + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && + (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 && + (info_ptr->valid & PNG_INFO_cHRM) != 0) + png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy); +# endif +#endif + +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR); +#endif + + png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; + } +} + +void PNGAPI +png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) +{ +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) + int i; +#endif + + png_debug(1, "in png_write_info"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_write_info_before_PLTE(png_ptr, info_ptr); + + if ((info_ptr->valid & PNG_INFO_PLTE) != 0) + png_write_PLTE(png_ptr, info_ptr->palette, + (png_uint_32)info_ptr->num_palette); + + else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + png_error(png_ptr, "Valid palette required for paletted images"); + +#ifdef PNG_WRITE_tRNS_SUPPORTED + if ((info_ptr->valid & PNG_INFO_tRNS) !=0) + { +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED + /* Invert the alpha channel (in tRNS) */ + if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 && + info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + int j, jend; + + jend = info_ptr->num_trans; + if (jend > PNG_MAX_PALETTE_LENGTH) + jend = PNG_MAX_PALETTE_LENGTH; + + for (j = 0; jtrans_alpha[j] = + (png_byte)(255 - info_ptr->trans_alpha[j]); + } +#endif + png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color), + info_ptr->num_trans, info_ptr->color_type); + } +#endif +#ifdef PNG_WRITE_bKGD_SUPPORTED + if ((info_ptr->valid & PNG_INFO_bKGD) != 0) + png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); +#endif + +#ifdef PNG_WRITE_eXIf_SUPPORTED + if ((info_ptr->valid & PNG_INFO_eXIf) != 0) + png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif); +#endif + +#ifdef PNG_WRITE_hIST_SUPPORTED + if ((info_ptr->valid & PNG_INFO_hIST) != 0) + png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); +#endif + +#ifdef PNG_WRITE_oFFs_SUPPORTED + if ((info_ptr->valid & PNG_INFO_oFFs) != 0) + png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, + info_ptr->offset_unit_type); +#endif + +#ifdef PNG_WRITE_pCAL_SUPPORTED + if ((info_ptr->valid & PNG_INFO_pCAL) != 0) + png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, + info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, + info_ptr->pcal_units, info_ptr->pcal_params); +#endif + +#ifdef PNG_WRITE_sCAL_SUPPORTED + if ((info_ptr->valid & PNG_INFO_sCAL) != 0) + png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, + info_ptr->scal_s_width, info_ptr->scal_s_height); +#endif /* sCAL */ + +#ifdef PNG_WRITE_pHYs_SUPPORTED + if ((info_ptr->valid & PNG_INFO_pHYs) != 0) + png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, + info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); +#endif /* pHYs */ + +#ifdef PNG_WRITE_tIME_SUPPORTED + if ((info_ptr->valid & PNG_INFO_tIME) != 0) + { + png_write_tIME(png_ptr, &(info_ptr->mod_time)); + png_ptr->mode |= PNG_WROTE_tIME; + } +#endif /* tIME */ + +#ifdef PNG_WRITE_sPLT_SUPPORTED + if ((info_ptr->valid & PNG_INFO_sPLT) != 0) + for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) + png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); +#endif /* sPLT */ + +#ifdef PNG_WRITE_TEXT_SUPPORTED + /* Check to see if we need to write text chunks */ + for (i = 0; i < info_ptr->num_text; i++) + { + png_debug2(2, "Writing header text chunk %d, type %d", i, + info_ptr->text[i].compression); + /* An internationalized chunk? */ + if (info_ptr->text[i].compression > 0) + { +#ifdef PNG_WRITE_iTXt_SUPPORTED + /* Write international chunk */ + png_write_iTXt(png_ptr, + info_ptr->text[i].compression, + info_ptr->text[i].key, + info_ptr->text[i].lang, + info_ptr->text[i].lang_key, + info_ptr->text[i].text); + /* Mark this chunk as written */ + if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; + else + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; +#else + png_warning(png_ptr, "Unable to write international text"); +#endif + } + + /* If we want a compressed text chunk */ + else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) + { +#ifdef PNG_WRITE_zTXt_SUPPORTED + /* Write compressed chunk */ + png_write_zTXt(png_ptr, info_ptr->text[i].key, + info_ptr->text[i].text, info_ptr->text[i].compression); + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; +#else + png_warning(png_ptr, "Unable to write compressed text"); +#endif + } + + else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) + { +#ifdef PNG_WRITE_tEXt_SUPPORTED + /* Write uncompressed chunk */ + png_write_tEXt(png_ptr, info_ptr->text[i].key, + info_ptr->text[i].text, + 0); + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; +#else + /* Can't get here */ + png_warning(png_ptr, "Unable to write uncompressed text"); +#endif + } + } +#endif /* tEXt */ + +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE); +#endif +} + +/* Writes the end of the PNG file. If you don't want to write comments or + * time information, you can pass NULL for info. If you already wrote these + * in png_write_info(), do not write them again here. If you have long + * comments, I suggest writing them here, and compressing them. + */ +void PNGAPI +png_write_end(png_structrp png_ptr, png_inforp info_ptr) +{ + png_debug(1, "in png_write_end"); + + if (png_ptr == NULL) + return; + + if ((png_ptr->mode & PNG_HAVE_IDAT) == 0) + png_error(png_ptr, "No IDATs written into file"); + +#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED + if (png_ptr->num_palette_max > png_ptr->num_palette) + png_benign_error(png_ptr, "Wrote palette index exceeding num_palette"); +#endif + + /* See if user wants us to write information chunks */ + if (info_ptr != NULL) + { +#ifdef PNG_WRITE_TEXT_SUPPORTED + int i; /* local index variable */ +#endif +#ifdef PNG_WRITE_tIME_SUPPORTED + /* Check to see if user has supplied a time chunk */ + if ((info_ptr->valid & PNG_INFO_tIME) != 0 && + (png_ptr->mode & PNG_WROTE_tIME) == 0) + png_write_tIME(png_ptr, &(info_ptr->mod_time)); + +#endif +#ifdef PNG_WRITE_TEXT_SUPPORTED + /* Loop through comment chunks */ + for (i = 0; i < info_ptr->num_text; i++) + { + png_debug2(2, "Writing trailer text chunk %d, type %d", i, + info_ptr->text[i].compression); + /* An internationalized chunk? */ + if (info_ptr->text[i].compression > 0) + { +#ifdef PNG_WRITE_iTXt_SUPPORTED + /* Write international chunk */ + png_write_iTXt(png_ptr, + info_ptr->text[i].compression, + info_ptr->text[i].key, + info_ptr->text[i].lang, + info_ptr->text[i].lang_key, + info_ptr->text[i].text); + /* Mark this chunk as written */ + if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; + else + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; +#else + png_warning(png_ptr, "Unable to write international text"); +#endif + } + + else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) + { +#ifdef PNG_WRITE_zTXt_SUPPORTED + /* Write compressed chunk */ + png_write_zTXt(png_ptr, info_ptr->text[i].key, + info_ptr->text[i].text, info_ptr->text[i].compression); + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; +#else + png_warning(png_ptr, "Unable to write compressed text"); +#endif + } + + else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) + { +#ifdef PNG_WRITE_tEXt_SUPPORTED + /* Write uncompressed chunk */ + png_write_tEXt(png_ptr, info_ptr->text[i].key, + info_ptr->text[i].text, 0); + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; +#else + png_warning(png_ptr, "Unable to write uncompressed text"); +#endif + } + } +#endif + +#ifdef PNG_WRITE_eXIf_SUPPORTED + if ((info_ptr->valid & PNG_INFO_eXIf) != 0) + png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif); +#endif + +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT); +#endif + } + + png_ptr->mode |= PNG_AFTER_IDAT; + + /* Write end of PNG file */ + png_write_IEND(png_ptr); + + /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03, + * and restored again in libpng-1.2.30, may cause some applications that + * do not set png_ptr->output_flush_fn to crash. If your application + * experiences a problem, please try building libpng with + * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to + * png-mng-implement at lists.sf.net . + */ +#ifdef PNG_WRITE_FLUSH_SUPPORTED +# ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED + png_flush(png_ptr); +# endif +#endif +} + +#ifdef PNG_CONVERT_tIME_SUPPORTED +void PNGAPI +png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime) +{ + png_debug(1, "in png_convert_from_struct_tm"); + + ptime->year = (png_uint_16)(1900 + ttime->tm_year); + ptime->month = (png_byte)(ttime->tm_mon + 1); + ptime->day = (png_byte)ttime->tm_mday; + ptime->hour = (png_byte)ttime->tm_hour; + ptime->minute = (png_byte)ttime->tm_min; + ptime->second = (png_byte)ttime->tm_sec; +} + +void PNGAPI +png_convert_from_time_t(png_timep ptime, time_t ttime) +{ + struct tm *tbuf; + + png_debug(1, "in png_convert_from_time_t"); + + tbuf = gmtime(&ttime); + png_convert_from_struct_tm(ptime, tbuf); +} +#endif + +/* Initialize png_ptr structure, and allocate any memory needed */ +PNG_FUNCTION(png_structp,PNGAPI +png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) +{ +#ifndef PNG_USER_MEM_SUPPORTED + png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr, + error_fn, warn_fn, NULL, NULL, NULL); +#else + return png_create_write_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, NULL, NULL, NULL); +} + +/* Alternate initialize png_ptr structure, and allocate any memory needed */ +PNG_FUNCTION(png_structp,PNGAPI +png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) +{ + png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr, + error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); +#endif /* USER_MEM */ + if (png_ptr != NULL) + { + /* Set the zlib control values to defaults; they can be overridden by the + * application after the struct has been created. + */ + png_ptr->zbuffer_size = PNG_ZBUF_SIZE; + + /* The 'zlib_strategy' setting is irrelevant because png_default_claim in + * pngwutil.c defaults it according to whether or not filters will be + * used, and ignores this setting. + */ + png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY; + png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION; + png_ptr->zlib_mem_level = 8; + png_ptr->zlib_window_bits = 15; + png_ptr->zlib_method = 8; + +#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED + png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY; + png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION; + png_ptr->zlib_text_mem_level = 8; + png_ptr->zlib_text_window_bits = 15; + png_ptr->zlib_text_method = 8; +#endif /* WRITE_COMPRESSED_TEXT */ + + /* This is a highly dubious configuration option; by default it is off, + * but it may be appropriate for private builds that are testing + * extensions not conformant to the current specification, or of + * applications that must not fail to write at all costs! + */ +#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED + /* In stable builds only warn if an application error can be completely + * handled. + */ + png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; +#endif + + /* App warnings are warnings in release (or release candidate) builds but + * are errors during development. + */ +#if PNG_RELEASE_BUILD + png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; +#endif + + /* TODO: delay this, it can be done in png_init_io() (if the app doesn't + * do it itself) avoiding setting the default function if it is not + * required. + */ + png_set_write_fn(png_ptr, NULL, NULL, NULL); + } + + return png_ptr; +} + + +/* Write a few rows of image data. If the image is interlaced, + * either you will have to write the 7 sub images, or, if you + * have called png_set_interlace_handling(), you will have to + * "write" the image seven times. + */ +void PNGAPI +png_write_rows(png_structrp png_ptr, png_bytepp row, + png_uint_32 num_rows) +{ + png_uint_32 i; /* row counter */ + png_bytepp rp; /* row pointer */ + + png_debug(1, "in png_write_rows"); + + if (png_ptr == NULL) + return; + + /* Loop through the rows */ + for (i = 0, rp = row; i < num_rows; i++, rp++) + { + png_write_row(png_ptr, *rp); + } +} + +/* Write the image. You only need to call this function once, even + * if you are writing an interlaced image. + */ +void PNGAPI +png_write_image(png_structrp png_ptr, png_bytepp image) +{ + png_uint_32 i; /* row index */ + int pass, num_pass; /* pass variables */ + png_bytepp rp; /* points to current row */ + + if (png_ptr == NULL) + return; + + png_debug(1, "in png_write_image"); + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Initialize interlace handling. If image is not interlaced, + * this will set pass to 1 + */ + num_pass = png_set_interlace_handling(png_ptr); +#else + num_pass = 1; +#endif + /* Loop through passes */ + for (pass = 0; pass < num_pass; pass++) + { + /* Loop through image */ + for (i = 0, rp = image; i < png_ptr->height; i++, rp++) + { + png_write_row(png_ptr, *rp); + } + } +} + +#ifdef PNG_MNG_FEATURES_SUPPORTED +/* Performs intrapixel differencing */ +static void +png_do_write_intrapixel(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_write_intrapixel"); + + if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + int bytes_per_pixel; + png_uint_32 row_width = row_info->width; + if (row_info->bit_depth == 8) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 3; + + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 4; + + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + *(rp) = (png_byte)(*rp - *(rp + 1)); + *(rp + 2) = (png_byte)(*(rp + 2) - *(rp + 1)); + } + } + +#ifdef PNG_WRITE_16BIT_SUPPORTED + else if (row_info->bit_depth == 16) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 6; + + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 8; + + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5); + png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); + png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); + *(rp ) = (png_byte)(red >> 8); + *(rp + 1) = (png_byte)red; + *(rp + 4) = (png_byte)(blue >> 8); + *(rp + 5) = (png_byte)blue; + } + } +#endif /* WRITE_16BIT */ + } +} +#endif /* MNG_FEATURES */ + +/* Called by user to write a row of image data */ +void PNGAPI +png_write_row(png_structrp png_ptr, png_const_bytep row) +{ + /* 1.5.6: moved from png_struct to be a local structure: */ + png_row_info row_info; + + if (png_ptr == NULL) + return; + + png_debug2(1, "in png_write_row (row %u, pass %d)", + png_ptr->row_number, png_ptr->pass); + + /* Initialize transformations and other stuff if first time */ + if (png_ptr->row_number == 0 && png_ptr->pass == 0) + { + /* Make sure we wrote the header info */ + if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0) + png_error(png_ptr, + "png_write_info was never called before png_write_row"); + + /* Check for transforms that have been set but were defined out */ +#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) + if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) + png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined"); +#endif + +#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) + if ((png_ptr->transformations & PNG_FILLER) != 0) + png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined"); +#endif +#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ + defined(PNG_READ_PACKSWAP_SUPPORTED) + if ((png_ptr->transformations & PNG_PACKSWAP) != 0) + png_warning(png_ptr, + "PNG_WRITE_PACKSWAP_SUPPORTED is not defined"); +#endif + +#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) + if ((png_ptr->transformations & PNG_PACK) != 0) + png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined"); +#endif + +#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) + if ((png_ptr->transformations & PNG_SHIFT) != 0) + png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined"); +#endif + +#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) + if ((png_ptr->transformations & PNG_BGR) != 0) + png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined"); +#endif + +#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) + if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) + png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined"); +#endif + + png_write_start_row(png_ptr); + } + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* If interlaced and not interested in row, return */ + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) != 0) + { + switch (png_ptr->pass) + { + case 0: + if ((png_ptr->row_number & 0x07) != 0) + { + png_write_finish_row(png_ptr); + return; + } + break; + + case 1: + if ((png_ptr->row_number & 0x07) != 0 || png_ptr->width < 5) + { + png_write_finish_row(png_ptr); + return; + } + break; + + case 2: + if ((png_ptr->row_number & 0x07) != 4) + { + png_write_finish_row(png_ptr); + return; + } + break; + + case 3: + if ((png_ptr->row_number & 0x03) != 0 || png_ptr->width < 3) + { + png_write_finish_row(png_ptr); + return; + } + break; + + case 4: + if ((png_ptr->row_number & 0x03) != 2) + { + png_write_finish_row(png_ptr); + return; + } + break; + + case 5: + if ((png_ptr->row_number & 0x01) != 0 || png_ptr->width < 2) + { + png_write_finish_row(png_ptr); + return; + } + break; + + case 6: + if ((png_ptr->row_number & 0x01) == 0) + { + png_write_finish_row(png_ptr); + return; + } + break; + + default: /* error: ignore it */ + break; + } + } +#endif + + /* Set up row info for transformations */ + row_info.color_type = png_ptr->color_type; + row_info.width = png_ptr->usr_width; + row_info.channels = png_ptr->usr_channels; + row_info.bit_depth = png_ptr->usr_bit_depth; + row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels); + row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); + + png_debug1(3, "row_info->color_type = %d", row_info.color_type); + png_debug1(3, "row_info->width = %u", row_info.width); + png_debug1(3, "row_info->channels = %d", row_info.channels); + png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth); + png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth); + png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes); + + /* Copy user's row into buffer, leaving room for filter byte. */ + memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes); + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Handle interlacing */ + if (png_ptr->interlaced && png_ptr->pass < 6 && + (png_ptr->transformations & PNG_INTERLACE) != 0) + { + png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass); + /* This should always get caught above, but still ... */ + if (row_info.width == 0) + { + png_write_finish_row(png_ptr); + return; + } + } +#endif + +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED + /* Handle other transformations */ + if (png_ptr->transformations != 0) + png_do_write_transformations(png_ptr, &row_info); +#endif + + /* At this point the row_info pixel depth must match the 'transformed' depth, + * which is also the output depth. + */ + if (row_info.pixel_depth != png_ptr->pixel_depth || + row_info.pixel_depth != png_ptr->transformed_pixel_depth) + png_error(png_ptr, "internal write transform logic error"); + +#ifdef PNG_MNG_FEATURES_SUPPORTED + /* Write filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not write a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) + { + /* Intrapixel differencing */ + png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1); + } +#endif + +/* Added at libpng-1.5.10 */ +#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Check for out-of-range palette index */ + if (row_info.color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max >= 0) + png_do_check_palette_indexes(png_ptr, &row_info); +#endif + + /* Find a filter if necessary, filter the row and write it out. */ + png_write_find_filter(png_ptr, &row_info); + + if (png_ptr->write_row_fn != NULL) + (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); +} + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +/* Set the automatic flush interval or 0 to turn flushing off */ +void PNGAPI +png_set_flush(png_structrp png_ptr, int nrows) +{ + png_debug(1, "in png_set_flush"); + + if (png_ptr == NULL) + return; + + png_ptr->flush_dist = (nrows < 0 ? 0 : (png_uint_32)nrows); +} + +/* Flush the current output buffers now */ +void PNGAPI +png_write_flush(png_structrp png_ptr) +{ + png_debug(1, "in png_write_flush"); + + if (png_ptr == NULL) + return; + + /* We have already written out all of the data */ + if (png_ptr->row_number >= png_ptr->num_rows) + return; + + png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH); + png_ptr->flush_rows = 0; + png_flush(png_ptr); +} +#endif /* WRITE_FLUSH */ + +/* Free any memory used in png_ptr struct without freeing the struct itself. */ +static void +png_write_destroy(png_structrp png_ptr) +{ + png_debug(1, "in png_write_destroy"); + + /* Free any memory zlib uses */ + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) + deflateEnd(&png_ptr->zstream); + + /* Free our memory. png_free checks NULL for us. */ + png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); + png_free(png_ptr, png_ptr->row_buf); + png_ptr->row_buf = NULL; +#ifdef PNG_WRITE_FILTER_SUPPORTED + png_free(png_ptr, png_ptr->prev_row); + png_free(png_ptr, png_ptr->try_row); + png_free(png_ptr, png_ptr->tst_row); + png_ptr->prev_row = NULL; + png_ptr->try_row = NULL; + png_ptr->tst_row = NULL; +#endif + +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list = NULL; +#endif + + /* The error handling and memory handling information is left intact at this + * point: the jmp_buf may still have to be freed. See png_destroy_png_struct + * for how this happens. + */ +} + +/* Free all memory used by the write. + * In libpng 1.6.0 this API changed quietly to no longer accept a NULL value for + * *png_ptr_ptr. Prior to 1.6.0 it would accept such a value and it would free + * the passed in info_structs but it would quietly fail to free any of the data + * inside them. In 1.6.0 it quietly does nothing (it has to be quiet because it + * has no png_ptr.) + */ +void PNGAPI +png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) +{ + png_debug(1, "in png_destroy_write_struct"); + + if (png_ptr_ptr != NULL) + { + png_structrp png_ptr = *png_ptr_ptr; + + if (png_ptr != NULL) /* added in libpng 1.6.0 */ + { + png_destroy_info_struct(png_ptr, info_ptr_ptr); + + *png_ptr_ptr = NULL; + png_write_destroy(png_ptr); + png_destroy_png_struct(png_ptr); + } + } +} + +/* Allow the application to select one or more row filters to use. */ +void PNGAPI +png_set_filter(png_structrp png_ptr, int method, int filters) +{ + png_debug(1, "in png_set_filter"); + + if (png_ptr == NULL) + return; + +#ifdef PNG_MNG_FEATURES_SUPPORTED + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && + (method == PNG_INTRAPIXEL_DIFFERENCING)) + method = PNG_FILTER_TYPE_BASE; + +#endif + if (method == PNG_FILTER_TYPE_BASE) + { + switch (filters & (PNG_ALL_FILTERS | 0x07)) + { +#ifdef PNG_WRITE_FILTER_SUPPORTED + case 5: + case 6: + case 7: png_app_error(png_ptr, "Unknown row filter for method 0"); +#endif /* WRITE_FILTER */ + /* FALLTHROUGH */ + case PNG_FILTER_VALUE_NONE: + png_ptr->do_filter = PNG_FILTER_NONE; break; + +#ifdef PNG_WRITE_FILTER_SUPPORTED + case PNG_FILTER_VALUE_SUB: + png_ptr->do_filter = PNG_FILTER_SUB; break; + + case PNG_FILTER_VALUE_UP: + png_ptr->do_filter = PNG_FILTER_UP; break; + + case PNG_FILTER_VALUE_AVG: + png_ptr->do_filter = PNG_FILTER_AVG; break; + + case PNG_FILTER_VALUE_PAETH: + png_ptr->do_filter = PNG_FILTER_PAETH; break; + + default: + png_ptr->do_filter = (png_byte)filters; break; +#else + default: + png_app_error(png_ptr, "Unknown row filter for method 0"); +#endif /* WRITE_FILTER */ + } + +#ifdef PNG_WRITE_FILTER_SUPPORTED + /* If we have allocated the row_buf, this means we have already started + * with the image and we should have allocated all of the filter buffers + * that have been selected. If prev_row isn't already allocated, then + * it is too late to start using the filters that need it, since we + * will be missing the data in the previous row. If an application + * wants to start and stop using particular filters during compression, + * it should start out with all of the filters, and then remove them + * or add them back after the start of compression. + * + * NOTE: this is a nasty constraint on the code, because it means that the + * prev_row buffer must be maintained even if there are currently no + * 'prev_row' requiring filters active. + */ + if (png_ptr->row_buf != NULL) + { + int num_filters; + png_alloc_size_t buf_size; + + /* Repeat the checks in png_write_start_row; 1 pixel high or wide + * images cannot benefit from certain filters. If this isn't done here + * the check below will fire on 1 pixel high images. + */ + if (png_ptr->height == 1) + filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); + + if (png_ptr->width == 1) + filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH); + + if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0 + && png_ptr->prev_row == NULL) + { + /* This is the error case, however it is benign - the previous row + * is not available so the filter can't be used. Just warn here. + */ + png_app_warning(png_ptr, + "png_set_filter: UP/AVG/PAETH cannot be added after start"); + filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); + } + + num_filters = 0; + + if (filters & PNG_FILTER_SUB) + num_filters++; + + if (filters & PNG_FILTER_UP) + num_filters++; + + if (filters & PNG_FILTER_AVG) + num_filters++; + + if (filters & PNG_FILTER_PAETH) + num_filters++; + + /* Allocate needed row buffers if they have not already been + * allocated. + */ + buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth, + png_ptr->width) + 1; + + if (png_ptr->try_row == NULL) + png_ptr->try_row = png_voidcast(png_bytep, + png_malloc(png_ptr, buf_size)); + + if (num_filters > 1) + { + if (png_ptr->tst_row == NULL) + png_ptr->tst_row = png_voidcast(png_bytep, + png_malloc(png_ptr, buf_size)); + } + } + png_ptr->do_filter = (png_byte)filters; +#endif + } + else + png_error(png_ptr, "Unknown custom filter method"); +} + +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */ +/* Provide floating and fixed point APIs */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method, + int num_weights, png_const_doublep filter_weights, + png_const_doublep filter_costs) +{ + PNG_UNUSED(png_ptr) + PNG_UNUSED(heuristic_method) + PNG_UNUSED(num_weights) + PNG_UNUSED(filter_weights) + PNG_UNUSED(filter_costs) +} +#endif /* FLOATING_POINT */ + +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method, + int num_weights, png_const_fixed_point_p filter_weights, + png_const_fixed_point_p filter_costs) +{ + PNG_UNUSED(png_ptr) + PNG_UNUSED(heuristic_method) + PNG_UNUSED(num_weights) + PNG_UNUSED(filter_weights) + PNG_UNUSED(filter_costs) +} +#endif /* FIXED_POINT */ +#endif /* WRITE_WEIGHTED_FILTER */ + +#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED +void PNGAPI +png_set_compression_level(png_structrp png_ptr, int level) +{ + png_debug(1, "in png_set_compression_level"); + + if (png_ptr == NULL) + return; + + png_ptr->zlib_level = level; +} + +void PNGAPI +png_set_compression_mem_level(png_structrp png_ptr, int mem_level) +{ + png_debug(1, "in png_set_compression_mem_level"); + + if (png_ptr == NULL) + return; + + png_ptr->zlib_mem_level = mem_level; +} + +void PNGAPI +png_set_compression_strategy(png_structrp png_ptr, int strategy) +{ + png_debug(1, "in png_set_compression_strategy"); + + if (png_ptr == NULL) + return; + + /* The flag setting here prevents the libpng dynamic selection of strategy. + */ + png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; + png_ptr->zlib_strategy = strategy; +} + +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +void PNGAPI +png_set_compression_window_bits(png_structrp png_ptr, int window_bits) +{ + if (png_ptr == NULL) + return; + + /* Prior to 1.6.0 this would warn but then set the window_bits value. This + * meant that negative window bits values could be selected that would cause + * libpng to write a non-standard PNG file with raw deflate or gzip + * compressed IDAT or ancillary chunks. Such files can be read and there is + * no warning on read, so this seems like a very bad idea. + */ + if (window_bits > 15) + { + png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); + window_bits = 15; + } + + else if (window_bits < 8) + { + png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); + window_bits = 8; + } + + png_ptr->zlib_window_bits = window_bits; +} + +void PNGAPI +png_set_compression_method(png_structrp png_ptr, int method) +{ + png_debug(1, "in png_set_compression_method"); + + if (png_ptr == NULL) + return; + + /* This would produce an invalid PNG file if it worked, but it doesn't and + * deflate will fault it, so it is harmless to just warn here. + */ + if (method != 8) + png_warning(png_ptr, "Only compression method 8 is supported by PNG"); + + png_ptr->zlib_method = method; +} +#endif /* WRITE_CUSTOMIZE_COMPRESSION */ + +/* The following were added to libpng-1.5.4 */ +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED +void PNGAPI +png_set_text_compression_level(png_structrp png_ptr, int level) +{ + png_debug(1, "in png_set_text_compression_level"); + + if (png_ptr == NULL) + return; + + png_ptr->zlib_text_level = level; +} + +void PNGAPI +png_set_text_compression_mem_level(png_structrp png_ptr, int mem_level) +{ + png_debug(1, "in png_set_text_compression_mem_level"); + + if (png_ptr == NULL) + return; + + png_ptr->zlib_text_mem_level = mem_level; +} + +void PNGAPI +png_set_text_compression_strategy(png_structrp png_ptr, int strategy) +{ + png_debug(1, "in png_set_text_compression_strategy"); + + if (png_ptr == NULL) + return; + + png_ptr->zlib_text_strategy = strategy; +} + +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +void PNGAPI +png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits) +{ + if (png_ptr == NULL) + return; + + if (window_bits > 15) + { + png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); + window_bits = 15; + } + + else if (window_bits < 8) + { + png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); + window_bits = 8; + } + + png_ptr->zlib_text_window_bits = window_bits; +} + +void PNGAPI +png_set_text_compression_method(png_structrp png_ptr, int method) +{ + png_debug(1, "in png_set_text_compression_method"); + + if (png_ptr == NULL) + return; + + if (method != 8) + png_warning(png_ptr, "Only compression method 8 is supported by PNG"); + + png_ptr->zlib_text_method = method; +} +#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */ +/* end of API added to libpng-1.5.4 */ + +void PNGAPI +png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn) +{ + if (png_ptr == NULL) + return; + + png_ptr->write_row_fn = write_row_fn; +} + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +void PNGAPI +png_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr + write_user_transform_fn) +{ + png_debug(1, "in png_set_write_user_transform_fn"); + + if (png_ptr == NULL) + return; + + png_ptr->transformations |= PNG_USER_TRANSFORM; + png_ptr->write_user_transform_fn = write_user_transform_fn; +} +#endif + + +#ifdef PNG_INFO_IMAGE_SUPPORTED +void PNGAPI +png_write_png(png_structrp png_ptr, png_inforp info_ptr, + int transforms, voidp params) +{ + if (png_ptr == NULL || info_ptr == NULL) + return; + + if ((info_ptr->valid & PNG_INFO_IDAT) == 0) + { + png_app_error(png_ptr, "no rows for png_write_image to write"); + return; + } + + /* Write the file header information. */ + png_write_info(png_ptr, info_ptr); + + /* ------ these transformations don't touch the info structure ------- */ + + /* Invert monochrome pixels */ + if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0) +#ifdef PNG_WRITE_INVERT_SUPPORTED + png_set_invert_mono(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported"); +#endif + + /* Shift the pixels up to a legal bit depth and fill in + * as appropriate to correctly scale the image. + */ + if ((transforms & PNG_TRANSFORM_SHIFT) != 0) +#ifdef PNG_WRITE_SHIFT_SUPPORTED + if ((info_ptr->valid & PNG_INFO_sBIT) != 0) + png_set_shift(png_ptr, &info_ptr->sig_bit); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported"); +#endif + + /* Pack pixels into bytes */ + if ((transforms & PNG_TRANSFORM_PACKING) != 0) +#ifdef PNG_WRITE_PACK_SUPPORTED + png_set_packing(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported"); +#endif + + /* Swap location of alpha bytes from ARGB to RGBA */ + if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0) +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED + png_set_swap_alpha(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported"); +#endif + + /* Remove a filler (X) from XRGB/RGBX/AG/GA into to convert it into + * RGB, note that the code expects the input color type to be G or RGB; no + * alpha channel. + */ + if ((transforms & (PNG_TRANSFORM_STRIP_FILLER_AFTER| + PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0) + { +#ifdef PNG_WRITE_FILLER_SUPPORTED + if ((transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) != 0) + { + if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0) + png_app_error(png_ptr, + "PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported"); + + /* Continue if ignored - this is the pre-1.6.10 behavior */ + png_set_filler(png_ptr, 0, PNG_FILLER_AFTER); + } + + else if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0) + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_FILLER not supported"); +#endif + } + + /* Flip BGR pixels to RGB */ + if ((transforms & PNG_TRANSFORM_BGR) != 0) +#ifdef PNG_WRITE_BGR_SUPPORTED + png_set_bgr(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported"); +#endif + + /* Swap bytes of 16-bit files to most significant byte first */ + if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0) +#ifdef PNG_WRITE_SWAP_SUPPORTED + png_set_swap(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported"); +#endif + + /* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats */ + if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0) +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED + png_set_packswap(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported"); +#endif + + /* Invert the alpha channel from opacity to transparency */ + if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0) +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED + png_set_invert_alpha(png_ptr); +#else + png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported"); +#endif + + /* ----------------------- end of transformations ------------------- */ + + /* Write the bits */ + png_write_image(png_ptr, info_ptr->row_pointers); + + /* It is REQUIRED to call this to finish writing the rest of the file */ + png_write_end(png_ptr, info_ptr); + + PNG_UNUSED(params) +} +#endif + + +#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED +/* Initialize the write structure - general purpose utility. */ +static int +png_image_write_init(png_imagep image) +{ + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image, + png_safe_error, png_safe_warning); + + if (png_ptr != NULL) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (info_ptr != NULL) + { + png_controlp control = png_voidcast(png_controlp, + png_malloc_warn(png_ptr, (sizeof *control))); + + if (control != NULL) + { + memset(control, 0, (sizeof *control)); + + control->png_ptr = png_ptr; + control->info_ptr = info_ptr; + control->for_write = 1; + + image->opaque = control; + return 1; + } + + /* Error clean up */ + png_destroy_info_struct(png_ptr, &info_ptr); + } + + png_destroy_write_struct(&png_ptr, NULL); + } + + return png_image_error(image, "png_image_write_: out of memory"); +} + +/* Arguments to png_image_write_main: */ +typedef struct +{ + /* Arguments: */ + png_imagep image; + png_const_voidp buffer; + png_int_32 row_stride; + png_const_voidp colormap; + int convert_to_8bit; + /* Local variables: */ + png_const_voidp first_row; + ptrdiff_t row_bytes; + png_voidp local_row; + /* Byte count for memory writing */ + png_bytep memory; + png_alloc_size_t memory_bytes; /* not used for STDIO */ + png_alloc_size_t output_bytes; /* running total */ +} png_image_write_control; + +/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to + * do any necessary byte swapping. The component order is defined by the + * png_image format value. + */ +static int +png_write_image_16bit(png_voidp argument) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + + png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, + display->first_row); + png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); + png_uint_16p row_end; + const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? + 3 : 1; + int aindex = 0; + png_uint_32 y = image->height; + + if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) + { +# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED + if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0) + { + aindex = -1; + ++input_row; /* To point to the first component */ + ++output_row; + } + else + aindex = (int)channels; +# else + aindex = (int)channels; +# endif + } + + else + png_error(png_ptr, "png_write_image: internal call error"); + + /* Work out the output row end and count over this, note that the increment + * above to 'row' means that row_end can actually be beyond the end of the + * row; this is correct. + */ + row_end = output_row + image->width * (channels+1); + + for (; y > 0; --y) + { + png_const_uint_16p in_ptr = input_row; + png_uint_16p out_ptr = output_row; + + while (out_ptr < row_end) + { + const png_uint_16 alpha = in_ptr[aindex]; + png_uint_32 reciprocal = 0; + int c; + + out_ptr[aindex] = alpha; + + /* Calculate a reciprocal. The correct calculation is simply + * component/alpha*65535 << 15. (I.e. 15 bits of precision); this + * allows correct rounding by adding .5 before the shift. 'reciprocal' + * is only initialized when required. + */ + if (alpha > 0 && alpha < 65535) + reciprocal = ((0xffff<<15)+(alpha>>1))/alpha; + + c = (int)channels; + do /* always at least one channel */ + { + png_uint_16 component = *in_ptr++; + + /* The following gives 65535 for an alpha of 0, which is fine, + * otherwise if 0/0 is represented as some other value there is more + * likely to be a discontinuity which will probably damage + * compression when moving from a fully transparent area to a + * nearly transparent one. (The assumption here is that opaque + * areas tend not to be 0 intensity.) + */ + if (component >= alpha) + component = 65535; + + /* component 0 && alpha < 65535) + { + png_uint_32 calc = component * reciprocal; + calc += 16384; /* round to nearest */ + component = (png_uint_16)(calc >> 15); + } + + *out_ptr++ = component; + } + while (--c > 0); + + /* Skip to next component (skip the intervening alpha channel) */ + ++in_ptr; + ++out_ptr; + } + + png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); + } + + return 1; +} + +/* Given 16-bit input (1 to 4 channels) write 8-bit output. If an alpha channel + * is present it must be removed from the components, the components are then + * written in sRGB encoding. No components are added or removed. + * + * Calculate an alpha reciprocal to reverse pre-multiplication. As above the + * calculation can be done to 15 bits of accuracy; however, the output needs to + * be scaled in the range 0..255*65535, so include that scaling here. + */ +# define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha) + +static png_byte +png_unpremultiply(png_uint_32 component, png_uint_32 alpha, + png_uint_32 reciprocal/*from the above macro*/) +{ + /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0 + * is represented as some other value there is more likely to be a + * discontinuity which will probably damage compression when moving from a + * fully transparent area to a nearly transparent one. (The assumption here + * is that opaque areas tend not to be 0 intensity.) + * + * There is a rounding problem here; if alpha is less than 128 it will end up + * as 0 when scaled to 8 bits. To avoid introducing spurious colors into the + * output change for this too. + */ + if (component >= alpha || alpha < 128) + return 255; + + /* component 0) + { + /* The test is that alpha/257 (rounded) is less than 255, the first value + * that becomes 255 is 65407. + * NOTE: this must agree with the PNG_DIV257 macro (which must, therefore, + * be exact!) [Could also test reciprocal != 0] + */ + if (alpha < 65407) + { + component *= reciprocal; + component += 64; /* round to nearest */ + component >>= 7; + } + + else + component *= 255; + + /* Convert the component to sRGB. */ + return (png_byte)PNG_sRGB_FROM_LINEAR(component); + } + + else + return 0; +} + +static int +png_write_image_8bit(png_voidp argument) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + + png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, + display->first_row); + png_bytep output_row = png_voidcast(png_bytep, display->local_row); + png_uint_32 y = image->height; + const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? + 3 : 1; + + if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + png_bytep row_end; + int aindex; + +# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED + if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0) + { + aindex = -1; + ++input_row; /* To point to the first component */ + ++output_row; + } + + else +# endif + aindex = (int)channels; + + /* Use row_end in place of a loop counter: */ + row_end = output_row + image->width * (channels+1); + + for (; y > 0; --y) + { + png_const_uint_16p in_ptr = input_row; + png_bytep out_ptr = output_row; + + while (out_ptr < row_end) + { + png_uint_16 alpha = in_ptr[aindex]; + png_byte alphabyte = (png_byte)PNG_DIV257(alpha); + png_uint_32 reciprocal = 0; + int c; + + /* Scale and write the alpha channel. */ + out_ptr[aindex] = alphabyte; + + if (alphabyte > 0 && alphabyte < 255) + reciprocal = UNP_RECIPROCAL(alpha); + + c = (int)channels; + do /* always at least one channel */ + *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal); + while (--c > 0); + + /* Skip to next component (skip the intervening alpha channel) */ + ++in_ptr; + ++out_ptr; + } /* while out_ptr < row_end */ + + png_write_row(png_ptr, png_voidcast(png_const_bytep, + display->local_row)); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); + } /* while y */ + } + + else + { + /* No alpha channel, so the row_end really is the end of the row and it + * is sufficient to loop over the components one by one. + */ + png_bytep row_end = output_row + image->width * channels; + + for (; y > 0; --y) + { + png_const_uint_16p in_ptr = input_row; + png_bytep out_ptr = output_row; + + while (out_ptr < row_end) + { + png_uint_32 component = *in_ptr++; + + component *= 255; + *out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component); + } + + png_write_row(png_ptr, output_row); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); + } + } + + return 1; +} + +static void +png_image_set_PLTE(png_image_write_control *display) +{ + const png_imagep image = display->image; + const void *cmap = display->colormap; + const int entries = image->colormap_entries > 256 ? 256 : + (int)image->colormap_entries; + + /* NOTE: the caller must check for cmap != NULL and entries != 0 */ + const png_uint_32 format = image->format; + const unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); + +# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\ + defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED) + const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 && + (format & PNG_FORMAT_FLAG_ALPHA) != 0; +# else +# define afirst 0 +# endif + +# ifdef PNG_FORMAT_BGR_SUPPORTED + const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; +# else +# define bgr 0 +# endif + + int i, num_trans; + png_color palette[256]; + png_byte tRNS[256]; + + memset(tRNS, 255, (sizeof tRNS)); + memset(palette, 0, (sizeof palette)); + + for (i=num_trans=0; i= 3) /* RGB */ + { + palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 * + entry[(2 ^ bgr)]); + palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 * + entry[1]); + palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 * + entry[bgr]); + } + + else /* Gray */ + palette[i].blue = palette[i].red = palette[i].green = + (png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry); + } + + else /* alpha */ + { + png_uint_16 alpha = entry[afirst ? 0 : channels-1]; + png_byte alphabyte = (png_byte)PNG_DIV257(alpha); + png_uint_32 reciprocal = 0; + + /* Calculate a reciprocal, as in the png_write_image_8bit code above + * this is designed to produce a value scaled to 255*65535 when + * divided by 128 (i.e. asr 7). + */ + if (alphabyte > 0 && alphabyte < 255) + reciprocal = (((0xffff*0xff)<<7)+(alpha>>1))/alpha; + + tRNS[i] = alphabyte; + if (alphabyte < 255) + num_trans = i+1; + + if (channels >= 3) /* RGB */ + { + palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)], + alpha, reciprocal); + palette[i].green = png_unpremultiply(entry[afirst + 1], alpha, + reciprocal); + palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha, + reciprocal); + } + + else /* gray */ + palette[i].blue = palette[i].red = palette[i].green = + png_unpremultiply(entry[afirst], alpha, reciprocal); + } + } + + else /* Color-map has sRGB values */ + { + png_const_bytep entry = png_voidcast(png_const_bytep, cmap); + + entry += (unsigned int)i * channels; + + switch (channels) + { + case 4: + tRNS[i] = entry[afirst ? 0 : 3]; + if (tRNS[i] < 255) + num_trans = i+1; + /* FALLTHROUGH */ + case 3: + palette[i].blue = entry[afirst + (2 ^ bgr)]; + palette[i].green = entry[afirst + 1]; + palette[i].red = entry[afirst + bgr]; + break; + + case 2: + tRNS[i] = entry[1 ^ afirst]; + if (tRNS[i] < 255) + num_trans = i+1; + /* FALLTHROUGH */ + case 1: + palette[i].blue = palette[i].red = palette[i].green = + entry[afirst]; + break; + + default: + break; + } + } + } + +# ifdef afirst +# undef afirst +# endif +# ifdef bgr +# undef bgr +# endif + + png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette, + entries); + + if (num_trans > 0) + png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS, + num_trans, NULL); + + image->colormap_entries = (png_uint_32)entries; +} + +static int +png_image_write_main(png_voidp argument) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + png_inforp info_ptr = image->opaque->info_ptr; + png_uint_32 format = image->format; + + /* The following four ints are actually booleans */ + int colormap = (format & PNG_FORMAT_FLAG_COLORMAP); + int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */ + int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA); + int write_16bit = linear && (display->convert_to_8bit == 0); + +# ifdef PNG_BENIGN_ERRORS_SUPPORTED + /* Make sure we error out on any bad situation */ + png_set_benign_errors(png_ptr, 0/*error*/); +# endif + + /* Default the 'row_stride' parameter if required, also check the row stride + * and total image size to ensure that they are within the system limits. + */ + { + const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); + + if (image->width <= 0x7fffffffU/channels) /* no overflow */ + { + png_uint_32 check; + const png_uint_32 png_row_stride = image->width * channels; + + if (display->row_stride == 0) + display->row_stride = (png_int_32)/*SAFE*/png_row_stride; + + if (display->row_stride < 0) + check = (png_uint_32)(-display->row_stride); + + else + check = (png_uint_32)display->row_stride; + + if (check >= png_row_stride) + { + /* Now check for overflow of the image buffer calculation; this + * limits the whole image size to 32 bits for API compatibility with + * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro. + */ + if (image->height > 0xffffffffU/png_row_stride) + png_error(image->opaque->png_ptr, "memory image too large"); + } + + else + png_error(image->opaque->png_ptr, "supplied row stride too small"); + } + + else + png_error(image->opaque->png_ptr, "image row stride too large"); + } + + /* Set the required transforms then write the rows in the correct order. */ + if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0) + { + if (display->colormap != NULL && image->colormap_entries > 0) + { + png_uint_32 entries = image->colormap_entries; + + png_set_IHDR(png_ptr, info_ptr, image->width, image->height, + entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)), + PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + png_image_set_PLTE(display); + } + + else + png_error(image->opaque->png_ptr, + "no color-map for color-mapped image"); + } + + else + png_set_IHDR(png_ptr, info_ptr, image->width, image->height, + write_16bit ? 16 : 8, + ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) + + ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0), + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + /* Counter-intuitively the data transformations must be called *after* + * png_write_info, not before as in the read code, but the 'set' functions + * must still be called before. Just set the color space information, never + * write an interlaced image. + */ + + if (write_16bit != 0) + { + /* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */ + png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR); + + if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0) + png_set_cHRM_fixed(png_ptr, info_ptr, + /* color x y */ + /* white */ 31270, 32900, + /* red */ 64000, 33000, + /* green */ 30000, 60000, + /* blue */ 15000, 6000 + ); + } + + else if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0) + png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL); + + /* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit + * space must still be gamma encoded. + */ + else + png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE); + + /* Write the file header. */ + png_write_info(png_ptr, info_ptr); + + /* Now set up the data transformations (*after* the header is written), + * remove the handled transformations from the 'format' flags for checking. + * + * First check for a little endian system if writing 16-bit files. + */ + if (write_16bit != 0) + { + PNG_CONST png_uint_16 le = 0x0001; + + if ((*(png_const_bytep) & le) != 0) + png_set_swap(png_ptr); + } + +# ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED + if ((format & PNG_FORMAT_FLAG_BGR) != 0) + { + if (colormap == 0 && (format & PNG_FORMAT_FLAG_COLOR) != 0) + png_set_bgr(png_ptr); + format &= ~PNG_FORMAT_FLAG_BGR; + } +# endif + +# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED + if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) + { + if (colormap == 0 && (format & PNG_FORMAT_FLAG_ALPHA) != 0) + png_set_swap_alpha(png_ptr); + format &= ~PNG_FORMAT_FLAG_AFIRST; + } +# endif + + /* If there are 16 or fewer color-map entries we wrote a lower bit depth + * above, but the application data is still byte packed. + */ + if (colormap != 0 && image->colormap_entries <= 16) + png_set_packing(png_ptr); + + /* That should have handled all (both) the transforms. */ + if ((format & ~(png_uint_32)(PNG_FORMAT_FLAG_COLOR | PNG_FORMAT_FLAG_LINEAR | + PNG_FORMAT_FLAG_ALPHA | PNG_FORMAT_FLAG_COLORMAP)) != 0) + png_error(png_ptr, "png_write_image: unsupported transformation"); + + { + png_const_bytep row = png_voidcast(png_const_bytep, display->buffer); + ptrdiff_t row_bytes = display->row_stride; + + if (linear != 0) + row_bytes *= (sizeof (png_uint_16)); + + if (row_bytes < 0) + row += (image->height-1) * (-row_bytes); + + display->first_row = row; + display->row_bytes = row_bytes; + } + + /* Apply 'fast' options if the flag is set. */ + if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0) + { + png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS); + /* NOTE: determined by experiment using pngstest, this reflects some + * balance between the time to write the image once and the time to read + * it about 50 times. The speed-up in pngstest was about 10-20% of the + * total (user) time on a heavily loaded system. + */ +# ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED + png_set_compression_level(png_ptr, 3); +# endif + } + + /* Check for the cases that currently require a pre-transform on the row + * before it is written. This only applies when the input is 16-bit and + * either there is an alpha channel or it is converted to 8-bit. + */ + if ((linear != 0 && alpha != 0 ) || + (colormap == 0 && display->convert_to_8bit != 0)) + { + png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr, + png_get_rowbytes(png_ptr, info_ptr))); + int result; + + display->local_row = row; + if (write_16bit != 0) + result = png_safe_execute(image, png_write_image_16bit, display); + else + result = png_safe_execute(image, png_write_image_8bit, display); + display->local_row = NULL; + + png_free(png_ptr, row); + + /* Skip the 'write_end' on error: */ + if (result == 0) + return 0; + } + + /* Otherwise this is the case where the input is in a format currently + * supported by the rest of the libpng write code; call it directly. + */ + else + { + png_const_bytep row = png_voidcast(png_const_bytep, display->first_row); + ptrdiff_t row_bytes = display->row_bytes; + png_uint_32 y = image->height; + + for (; y > 0; --y) + { + png_write_row(png_ptr, row); + row += row_bytes; + } + } + + png_write_end(png_ptr, info_ptr); + return 1; +} + + +static void (PNGCBAPI +image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data, + png_size_t size) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/); + const png_alloc_size_t ob = display->output_bytes; + + /* Check for overflow; this should never happen: */ + if (size <= ((png_alloc_size_t)-1) - ob) + { + /* I don't think libpng ever does this, but just in case: */ + if (size > 0) + { + if (display->memory_bytes >= ob+size) /* writing */ + memcpy(display->memory+ob, data, size); + + /* Always update the size: */ + display->output_bytes = ob+size; + } + } + + else + png_error(png_ptr, "png_image_write_to_memory: PNG too big"); +} + +static void (PNGCBAPI +image_memory_flush)(png_structp png_ptr) +{ + PNG_UNUSED(png_ptr) +} + +static int +png_image_write_memory(png_voidp argument) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + argument); + + /* The rest of the memory-specific init and write_main in an error protected + * environment. This case needs to use callbacks for the write operations + * since libpng has no built in support for writing to memory. + */ + png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/, + image_memory_write, image_memory_flush); + + return png_image_write_main(display); +} + +int PNGAPI +png_image_write_to_memory(png_imagep image, void *memory, + png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit, + const void *buffer, png_int_32 row_stride, const void *colormap) +{ + /* Write the image to the given buffer, or count the bytes if it is NULL */ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (memory_bytes != NULL && buffer != NULL) + { + /* This is to give the caller an easier error detection in the NULL + * case and guard against uninitialized variable problems: + */ + if (memory == NULL) + *memory_bytes = 0; + + if (png_image_write_init(image) != 0) + { + png_image_write_control display; + int result; + + memset(&display, 0, (sizeof display)); + display.image = image; + display.buffer = buffer; + display.row_stride = row_stride; + display.colormap = colormap; + display.convert_to_8bit = convert_to_8bit; + display.memory = png_voidcast(png_bytep, memory); + display.memory_bytes = *memory_bytes; + display.output_bytes = 0; + + result = png_safe_execute(image, png_image_write_memory, &display); + png_image_free(image); + + /* write_memory returns true even if we ran out of buffer. */ + if (result) + { + /* On out-of-buffer this function returns '0' but still updates + * memory_bytes: + */ + if (memory != NULL && display.output_bytes > *memory_bytes) + result = 0; + + *memory_bytes = display.output_bytes; + } + + return result; + } + + else + return 0; + } + + else + return png_image_error(image, + "png_image_write_to_memory: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_write_to_memory: incorrect PNG_IMAGE_VERSION"); + + else + return 0; +} + +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED +int PNGAPI +png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, + const void *buffer, png_int_32 row_stride, const void *colormap) +{ + /* Write the image to the given (FILE*). */ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (file != NULL && buffer != NULL) + { + if (png_image_write_init(image) != 0) + { + png_image_write_control display; + int result; + + /* This is slightly evil, but png_init_io doesn't do anything other + * than this and we haven't changed the standard IO functions so + * this saves a 'safe' function. + */ + image->opaque->png_ptr->io_ptr = file; + + memset(&display, 0, (sizeof display)); + display.image = image; + display.buffer = buffer; + display.row_stride = row_stride; + display.colormap = colormap; + display.convert_to_8bit = convert_to_8bit; + + result = png_safe_execute(image, png_image_write_main, &display); + png_image_free(image); + return result; + } + + else + return 0; + } + + else + return png_image_error(image, + "png_image_write_to_stdio: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION"); + + else + return 0; +} + +int PNGAPI +png_image_write_to_file(png_imagep image, const char *file_name, + int convert_to_8bit, const void *buffer, png_int_32 row_stride, + const void *colormap) +{ + /* Write the image to the named file. */ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (file_name != NULL && buffer != NULL) + { + FILE *fp = fopen(file_name, "wb"); + + if (fp != NULL) + { + if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer, + row_stride, colormap) != 0) + { + int error; /* from fflush/fclose */ + + /* Make sure the file is flushed correctly. */ + if (fflush(fp) == 0 && ferror(fp) == 0) + { + if (fclose(fp) == 0) + return 1; + + error = errno; /* from fclose */ + } + + else + { + error = errno; /* from fflush or ferror */ + (void)fclose(fp); + } + + (void)remove(file_name); + /* The image has already been cleaned up; this is just used to + * set the error (because the original write succeeded). + */ + return png_image_error(image, strerror(error)); + } + + else + { + /* Clean up: just the opened file. */ + (void)fclose(fp); + (void)remove(file_name); + return 0; + } + } + + else + return png_image_error(image, strerror(errno)); + } + + else + return png_image_error(image, + "png_image_write_to_file: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_write_to_file: incorrect PNG_IMAGE_VERSION"); + + else + return 0; +} +#endif /* SIMPLIFIED_WRITE_STDIO */ +#endif /* SIMPLIFIED_WRITE */ +#endif /* WRITE */ diff --git a/xs/src/png/libpng/pngwtran.c b/xs/src/png/libpng/pngwtran.c new file mode 100644 index 0000000000..377b43e5ca --- /dev/null +++ b/xs/src/png/libpng/pngwtran.c @@ -0,0 +1,576 @@ + +/* pngwtran.c - transforms the data in a row for PNG writers + * + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "pngpriv.h" + +#ifdef PNG_WRITE_SUPPORTED +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED + +#ifdef PNG_WRITE_PACK_SUPPORTED +/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The + * row_info bit depth should be 8 (one pixel per byte). The channels + * should be 1 (this only happens on grayscale and paletted images). + */ +static void +png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) +{ + png_debug(1, "in png_do_pack"); + + if (row_info->bit_depth == 8 && + row_info->channels == 1) + { + switch ((int)bit_depth) + { + case 1: + { + png_bytep sp, dp; + int mask, v; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + sp = row; + dp = row; + mask = 0x80; + v = 0; + + for (i = 0; i < row_width; i++) + { + if (*sp != 0) + v |= mask; + + sp++; + + if (mask > 1) + mask >>= 1; + + else + { + mask = 0x80; + *dp = (png_byte)v; + dp++; + v = 0; + } + } + + if (mask != 0x80) + *dp = (png_byte)v; + + break; + } + + case 2: + { + png_bytep sp, dp; + unsigned int shift; + int v; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + sp = row; + dp = row; + shift = 6; + v = 0; + + for (i = 0; i < row_width; i++) + { + png_byte value; + + value = (png_byte)(*sp & 0x03); + v |= (value << shift); + + if (shift == 0) + { + shift = 6; + *dp = (png_byte)v; + dp++; + v = 0; + } + + else + shift -= 2; + + sp++; + } + + if (shift != 6) + *dp = (png_byte)v; + + break; + } + + case 4: + { + png_bytep sp, dp; + unsigned int shift; + int v; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + sp = row; + dp = row; + shift = 4; + v = 0; + + for (i = 0; i < row_width; i++) + { + png_byte value; + + value = (png_byte)(*sp & 0x0f); + v |= (value << shift); + + if (shift == 0) + { + shift = 4; + *dp = (png_byte)v; + dp++; + v = 0; + } + + else + shift -= 4; + + sp++; + } + + if (shift != 4) + *dp = (png_byte)v; + + break; + } + + default: + break; + } + + row_info->bit_depth = (png_byte)bit_depth; + row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, + row_info->width); + } +} +#endif + +#ifdef PNG_WRITE_SHIFT_SUPPORTED +/* Shift pixel values to take advantage of whole range. Pass the + * true number of bits in bit_depth. The row should be packed + * according to row_info->bit_depth. Thus, if you had a row of + * bit depth 4, but the pixels only had values from 0 to 7, you + * would pass 3 as bit_depth, and this routine would translate the + * data to 0 to 15. + */ +static void +png_do_shift(png_row_infop row_info, png_bytep row, + png_const_color_8p bit_depth) +{ + png_debug(1, "in png_do_shift"); + + if (row_info->color_type != PNG_COLOR_TYPE_PALETTE) + { + int shift_start[4], shift_dec[4]; + unsigned int channels = 0; + + if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + shift_start[channels] = row_info->bit_depth - bit_depth->red; + shift_dec[channels] = bit_depth->red; + channels++; + + shift_start[channels] = row_info->bit_depth - bit_depth->green; + shift_dec[channels] = bit_depth->green; + channels++; + + shift_start[channels] = row_info->bit_depth - bit_depth->blue; + shift_dec[channels] = bit_depth->blue; + channels++; + } + + else + { + shift_start[channels] = row_info->bit_depth - bit_depth->gray; + shift_dec[channels] = bit_depth->gray; + channels++; + } + + if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0) + { + shift_start[channels] = row_info->bit_depth - bit_depth->alpha; + shift_dec[channels] = bit_depth->alpha; + channels++; + } + + /* With low row depths, could only be grayscale, so one channel */ + if (row_info->bit_depth < 8) + { + png_bytep bp = row; + png_size_t i; + unsigned int mask; + png_size_t row_bytes = row_info->rowbytes; + + if (bit_depth->gray == 1 && row_info->bit_depth == 2) + mask = 0x55; + + else if (row_info->bit_depth == 4 && bit_depth->gray == 3) + mask = 0x11; + + else + mask = 0xff; + + for (i = 0; i < row_bytes; i++, bp++) + { + int j; + unsigned int v, out; + + v = *bp; + out = 0; + + for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) + { + if (j > 0) + out |= v << j; + + else + out |= (v >> (-j)) & mask; + } + + *bp = (png_byte)(out & 0xff); + } + } + + else if (row_info->bit_depth == 8) + { + png_bytep bp = row; + png_uint_32 i; + png_uint_32 istop = channels * row_info->width; + + for (i = 0; i < istop; i++, bp++) + { + + const unsigned int c = i%channels; + int j; + unsigned int v, out; + + v = *bp; + out = 0; + + for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) + { + if (j > 0) + out |= v << j; + + else + out |= v >> (-j); + } + + *bp = (png_byte)(out & 0xff); + } + } + + else + { + png_bytep bp; + png_uint_32 i; + png_uint_32 istop = channels * row_info->width; + + for (bp = row, i = 0; i < istop; i++) + { + const unsigned int c = i%channels; + int j; + unsigned int value, v; + + v = png_get_uint_16(bp); + value = 0; + + for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) + { + if (j > 0) + value |= v << j; + + else + value |= v >> (-j); + } + *bp++ = (png_byte)((value >> 8) & 0xff); + *bp++ = (png_byte)(value & 0xff); + } + } + } +} +#endif + +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED +static void +png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_write_swap_alpha"); + + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + if (row_info->bit_depth == 8) + { + /* This converts from ARGB to RGBA */ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + png_byte save = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = save; + } + } + +#ifdef PNG_WRITE_16BIT_SUPPORTED + else + { + /* This converts from AARRGGBB to RRGGBBAA */ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + png_byte save[2]; + save[0] = *(sp++); + save[1] = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = save[0]; + *(dp++) = save[1]; + } + } +#endif /* WRITE_16BIT */ + } + + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (row_info->bit_depth == 8) + { + /* This converts from AG to GA */ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + png_byte save = *(sp++); + *(dp++) = *(sp++); + *(dp++) = save; + } + } + +#ifdef PNG_WRITE_16BIT_SUPPORTED + else + { + /* This converts from AAGG to GGAA */ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + png_byte save[2]; + save[0] = *(sp++); + save[1] = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = save[0]; + *(dp++) = save[1]; + } + } +#endif /* WRITE_16BIT */ + } + } +} +#endif + +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED +static void +png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_write_invert_alpha"); + + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + if (row_info->bit_depth == 8) + { + /* This inverts the alpha channel in RGBA */ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + /* Does nothing + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + */ + sp+=3; dp = sp; + *dp = (png_byte)(255 - *(sp++)); + } + } + +#ifdef PNG_WRITE_16BIT_SUPPORTED + else + { + /* This inverts the alpha channel in RRGGBBAA */ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + /* Does nothing + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + *(dp++) = *(sp++); + */ + sp+=6; dp = sp; + *(dp++) = (png_byte)(255 - *(sp++)); + *dp = (png_byte)(255 - *(sp++)); + } + } +#endif /* WRITE_16BIT */ + } + + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (row_info->bit_depth == 8) + { + /* This inverts the alpha channel in GA */ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + *(dp++) = *(sp++); + *(dp++) = (png_byte)(255 - *(sp++)); + } + } + +#ifdef PNG_WRITE_16BIT_SUPPORTED + else + { + /* This inverts the alpha channel in GGAA */ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + for (i = 0, sp = dp = row; i < row_width; i++) + { + /* Does nothing + *(dp++) = *(sp++); + *(dp++) = *(sp++); + */ + sp+=2; dp = sp; + *(dp++) = (png_byte)(255 - *(sp++)); + *dp = (png_byte)(255 - *(sp++)); + } + } +#endif /* WRITE_16BIT */ + } + } +} +#endif + +/* Transform the data according to the user's wishes. The order of + * transformations is significant. + */ +void /* PRIVATE */ +png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) +{ + png_debug(1, "in png_do_write_transformations"); + + if (png_ptr == NULL) + return; + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED + if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) + if (png_ptr->write_user_transform_fn != NULL) + (*(png_ptr->write_user_transform_fn)) /* User write transform + function */ + (png_ptr, /* png_ptr */ + row_info, /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_size_t rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#endif + +#ifdef PNG_WRITE_FILLER_SUPPORTED + if ((png_ptr->transformations & PNG_FILLER) != 0) + png_do_strip_channel(row_info, png_ptr->row_buf + 1, + !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); +#endif + +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED + if ((png_ptr->transformations & PNG_PACKSWAP) != 0) + png_do_packswap(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_WRITE_PACK_SUPPORTED + if ((png_ptr->transformations & PNG_PACK) != 0) + png_do_pack(row_info, png_ptr->row_buf + 1, + (png_uint_32)png_ptr->bit_depth); +#endif + +#ifdef PNG_WRITE_SWAP_SUPPORTED +# ifdef PNG_16BIT_SUPPORTED + if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) + png_do_swap(row_info, png_ptr->row_buf + 1); +# endif +#endif + +#ifdef PNG_WRITE_SHIFT_SUPPORTED + if ((png_ptr->transformations & PNG_SHIFT) != 0) + png_do_shift(row_info, png_ptr->row_buf + 1, + &(png_ptr->shift)); +#endif + +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0) + png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) + png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_WRITE_BGR_SUPPORTED + if ((png_ptr->transformations & PNG_BGR) != 0) + png_do_bgr(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_WRITE_INVERT_SUPPORTED + if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) + png_do_invert(row_info, png_ptr->row_buf + 1); +#endif +} +#endif /* WRITE_TRANSFORMS */ +#endif /* WRITE */ diff --git a/xs/src/png/libpng/pngwutil.c b/xs/src/png/libpng/pngwutil.c new file mode 100644 index 0000000000..0d4fb1336c --- /dev/null +++ b/xs/src/png/libpng/pngwutil.c @@ -0,0 +1,2784 @@ + +/* pngwutil.c - utilities to write a PNG file + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "pngpriv.h" + +#ifdef PNG_WRITE_SUPPORTED + +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +/* Place a 32-bit number into a buffer in PNG byte order. We work + * with unsigned numbers for convenience, although one supported + * ancillary chunk uses signed (two's complement) numbers. + */ +void PNGAPI +png_save_uint_32(png_bytep buf, png_uint_32 i) +{ + buf[0] = (png_byte)((i >> 24) & 0xffU); + buf[1] = (png_byte)((i >> 16) & 0xffU); + buf[2] = (png_byte)((i >> 8) & 0xffU); + buf[3] = (png_byte)( i & 0xffU); +} + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +void PNGAPI +png_save_uint_16(png_bytep buf, unsigned int i) +{ + buf[0] = (png_byte)((i >> 8) & 0xffU); + buf[1] = (png_byte)( i & 0xffU); +} +#endif + +/* Simple function to write the signature. If we have already written + * the magic bytes of the signature, or more likely, the PNG stream is + * being embedded into another stream and doesn't need its own signature, + * we should call png_set_sig_bytes() to tell libpng how many of the + * bytes have already been written. + */ +void PNGAPI +png_write_sig(png_structrp png_ptr) +{ + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the signature is being written */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE; +#endif + + /* Write the rest of the 8 byte signature */ + png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], + (png_size_t)(8 - png_ptr->sig_bytes)); + + if (png_ptr->sig_bytes < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; +} + +/* Write the start of a PNG chunk. The type is the chunk type. + * The total_length is the sum of the lengths of all the data you will be + * passing in png_write_chunk_data(). + */ +static void +png_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name, + png_uint_32 length) +{ + png_byte buf[8]; + +#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) + PNG_CSTRING_FROM_CHUNK(buf, chunk_name); + png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length); +#endif + + if (png_ptr == NULL) + return; + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the chunk header is being written. + * PNG_IO_CHUNK_HDR requires a single I/O call. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR; +#endif + + /* Write the length and the chunk name */ + png_save_uint_32(buf, length); + png_save_uint_32(buf + 4, chunk_name); + png_write_data(png_ptr, buf, 8); + + /* Put the chunk name into png_ptr->chunk_name */ + png_ptr->chunk_name = chunk_name; + + /* Reset the crc and run it over the chunk name */ + png_reset_crc(png_ptr); + + png_calculate_crc(png_ptr, buf + 4, 4); + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that chunk data will (possibly) be written. + * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA; +#endif +} + +void PNGAPI +png_write_chunk_start(png_structrp png_ptr, png_const_bytep chunk_string, + png_uint_32 length) +{ + png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length); +} + +/* Write the data of a PNG chunk started with png_write_chunk_header(). + * Note that multiple calls to this function are allowed, and that the + * sum of the lengths from these calls *must* add up to the total_length + * given to png_write_chunk_header(). + */ +void PNGAPI +png_write_chunk_data(png_structrp png_ptr, png_const_bytep data, + png_size_t length) +{ + /* Write the data, and run the CRC over it */ + if (png_ptr == NULL) + return; + + if (data != NULL && length > 0) + { + png_write_data(png_ptr, data, length); + + /* Update the CRC after writing the data, + * in case the user I/O routine alters it. + */ + png_calculate_crc(png_ptr, data, length); + } +} + +/* Finish a chunk started with png_write_chunk_header(). */ +void PNGAPI +png_write_chunk_end(png_structrp png_ptr) +{ + png_byte buf[4]; + + if (png_ptr == NULL) return; + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the chunk CRC is being written. + * PNG_IO_CHUNK_CRC requires a single I/O function call. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC; +#endif + + /* Write the crc in a single operation */ + png_save_uint_32(buf, png_ptr->crc); + + png_write_data(png_ptr, buf, (png_size_t)4); +} + +/* Write a PNG chunk all at once. The type is an array of ASCII characters + * representing the chunk name. The array must be at least 4 bytes in + * length, and does not need to be null terminated. To be safe, pass the + * pre-defined chunk names here, and if you need a new one, define it + * where the others are defined. The length is the length of the data. + * All the data must be present. If that is not possible, use the + * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() + * functions instead. + */ +static void +png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, + png_const_bytep data, png_size_t length) +{ + if (png_ptr == NULL) + return; + + /* On 64-bit architectures 'length' may not fit in a png_uint_32. */ + if (length > PNG_UINT_31_MAX) + png_error(png_ptr, "length exceeds PNG maximum"); + + png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length); + png_write_chunk_data(png_ptr, data, length); + png_write_chunk_end(png_ptr); +} + +/* This is the API that calls the internal function above. */ +void PNGAPI +png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string, + png_const_bytep data, png_size_t length) +{ + png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data, + length); +} + +/* This is used below to find the size of an image to pass to png_deflate_claim, + * so it only needs to be accurate if the size is less than 16384 bytes (the + * point at which a lower LZ window size can be used.) + */ +static png_alloc_size_t +png_image_size(png_structrp png_ptr) +{ + /* Only return sizes up to the maximum of a png_uint_32; do this by limiting + * the width and height used to 15 bits. + */ + png_uint_32 h = png_ptr->height; + + if (png_ptr->rowbytes < 32768 && h < 32768) + { + if (png_ptr->interlaced != 0) + { + /* Interlacing makes the image larger because of the replication of + * both the filter byte and the padding to a byte boundary. + */ + png_uint_32 w = png_ptr->width; + unsigned int pd = png_ptr->pixel_depth; + png_alloc_size_t cb_base; + int pass; + + for (cb_base=0, pass=0; pass<=6; ++pass) + { + png_uint_32 pw = PNG_PASS_COLS(w, pass); + + if (pw > 0) + cb_base += (PNG_ROWBYTES(pd, pw)+1) * PNG_PASS_ROWS(h, pass); + } + + return cb_base; + } + + else + return (png_ptr->rowbytes+1) * h; + } + + else + return 0xffffffffU; +} + +#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED + /* This is the code to hack the first two bytes of the deflate stream (the + * deflate header) to correct the windowBits value to match the actual data + * size. Note that the second argument is the *uncompressed* size but the + * first argument is the *compressed* data (and it must be deflate + * compressed.) + */ +static void +optimize_cmf(png_bytep data, png_alloc_size_t data_size) +{ + /* Optimize the CMF field in the zlib stream. The resultant zlib stream is + * still compliant to the stream specification. + */ + if (data_size <= 16384) /* else windowBits must be 15 */ + { + unsigned int z_cmf = data[0]; /* zlib compression method and flags */ + + if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) + { + unsigned int z_cinfo; + unsigned int half_z_window_size; + + z_cinfo = z_cmf >> 4; + half_z_window_size = 1U << (z_cinfo + 7); + + if (data_size <= half_z_window_size) /* else no change */ + { + unsigned int tmp; + + do + { + half_z_window_size >>= 1; + --z_cinfo; + } + while (z_cinfo > 0 && data_size <= half_z_window_size); + + z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); + + data[0] = (png_byte)z_cmf; + tmp = data[1] & 0xe0; + tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f; + data[1] = (png_byte)tmp; + } + } + } +} +#endif /* WRITE_OPTIMIZE_CMF */ + +/* Initialize the compressor for the appropriate type of compression. */ +static int +png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, + png_alloc_size_t data_size) +{ + if (png_ptr->zowner != 0) + { +#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED) + char msg[64]; + + PNG_STRING_FROM_CHUNK(msg, owner); + msg[4] = ':'; + msg[5] = ' '; + PNG_STRING_FROM_CHUNK(msg+6, png_ptr->zowner); + /* So the message that results is " using zstream"; this is an + * internal error, but is very useful for debugging. i18n requirements + * are minimal. + */ + (void)png_safecat(msg, (sizeof msg), 10, " using zstream"); +#endif +#if PNG_RELEASE_BUILD + png_warning(png_ptr, msg); + + /* Attempt sane error recovery */ + if (png_ptr->zowner == png_IDAT) /* don't steal from IDAT */ + { + png_ptr->zstream.msg = PNGZ_MSG_CAST("in use by IDAT"); + return Z_STREAM_ERROR; + } + + png_ptr->zowner = 0; +#else + png_error(png_ptr, msg); +#endif + } + + { + int level = png_ptr->zlib_level; + int method = png_ptr->zlib_method; + int windowBits = png_ptr->zlib_window_bits; + int memLevel = png_ptr->zlib_mem_level; + int strategy; /* set below */ + int ret; /* zlib return code */ + + if (owner == png_IDAT) + { + if ((png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) != 0) + strategy = png_ptr->zlib_strategy; + + else if (png_ptr->do_filter != PNG_FILTER_NONE) + strategy = PNG_Z_DEFAULT_STRATEGY; + + else + strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY; + } + + else + { +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED + level = png_ptr->zlib_text_level; + method = png_ptr->zlib_text_method; + windowBits = png_ptr->zlib_text_window_bits; + memLevel = png_ptr->zlib_text_mem_level; + strategy = png_ptr->zlib_text_strategy; +#else + /* If customization is not supported the values all come from the + * IDAT values except for the strategy, which is fixed to the + * default. (This is the pre-1.6.0 behavior too, although it was + * implemented in a very different way.) + */ + strategy = Z_DEFAULT_STRATEGY; +#endif + } + + /* Adjust 'windowBits' down if larger than 'data_size'; to stop this + * happening just pass 32768 as the data_size parameter. Notice that zlib + * requires an extra 262 bytes in the window in addition to the data to be + * able to see the whole of the data, so if data_size+262 takes us to the + * next windowBits size we need to fix up the value later. (Because even + * though deflate needs the extra window, inflate does not!) + */ + if (data_size <= 16384) + { + /* IMPLEMENTATION NOTE: this 'half_window_size' stuff is only here to + * work round a Microsoft Visual C misbehavior which, contrary to C-90, + * widens the result of the following shift to 64-bits if (and, + * apparently, only if) it is used in a test. + */ + unsigned int half_window_size = 1U << (windowBits-1); + + while (data_size + 262 <= half_window_size) + { + half_window_size >>= 1; + --windowBits; + } + } + + /* Check against the previous initialized values, if any. */ + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0 && + (png_ptr->zlib_set_level != level || + png_ptr->zlib_set_method != method || + png_ptr->zlib_set_window_bits != windowBits || + png_ptr->zlib_set_mem_level != memLevel || + png_ptr->zlib_set_strategy != strategy)) + { + if (deflateEnd(&png_ptr->zstream) != Z_OK) + png_warning(png_ptr, "deflateEnd failed (ignored)"); + + png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED; + } + + /* For safety clear out the input and output pointers (currently zlib + * doesn't use them on Init, but it might in the future). + */ + png_ptr->zstream.next_in = NULL; + png_ptr->zstream.avail_in = 0; + png_ptr->zstream.next_out = NULL; + png_ptr->zstream.avail_out = 0; + + /* Now initialize if required, setting the new parameters, otherwise just + * do a simple reset to the previous parameters. + */ + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) + ret = deflateReset(&png_ptr->zstream); + + else + { + ret = deflateInit2(&png_ptr->zstream, level, method, windowBits, + memLevel, strategy); + + if (ret == Z_OK) + png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; + } + + /* The return code is from either deflateReset or deflateInit2; they have + * pretty much the same set of error codes. + */ + if (ret == Z_OK) + png_ptr->zowner = owner; + + else + png_zstream_error(png_ptr, ret); + + return ret; + } +} + +/* Clean up (or trim) a linked list of compression buffers. */ +void /* PRIVATE */ +png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp) +{ + png_compression_bufferp list = *listp; + + if (list != NULL) + { + *listp = NULL; + + do + { + png_compression_bufferp next = list->next; + + png_free(png_ptr, list); + list = next; + } + while (list != NULL); + } +} + +#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED +/* This pair of functions encapsulates the operation of (a) compressing a + * text string, and (b) issuing it later as a series of chunk data writes. + * The compression_state structure is shared context for these functions + * set up by the caller to allow access to the relevant local variables. + * + * compression_buffer (new in 1.6.0) is just a linked list of zbuffer_size + * temporary buffers. From 1.6.0 it is retained in png_struct so that it will + * be correctly freed in the event of a write error (previous implementations + * just leaked memory.) + */ +typedef struct +{ + png_const_bytep input; /* The uncompressed input data */ + png_alloc_size_t input_len; /* Its length */ + png_uint_32 output_len; /* Final compressed length */ + png_byte output[1024]; /* First block of output */ +} compression_state; + +static void +png_text_compress_init(compression_state *comp, png_const_bytep input, + png_alloc_size_t input_len) +{ + comp->input = input; + comp->input_len = input_len; + comp->output_len = 0; +} + +/* Compress the data in the compression state input */ +static int +png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, + compression_state *comp, png_uint_32 prefix_len) +{ + int ret; + + /* To find the length of the output it is necessary to first compress the + * input. The result is buffered rather than using the two-pass algorithm + * that is used on the inflate side; deflate is assumed to be slower and a + * PNG writer is assumed to have more memory available than a PNG reader. + * + * IMPLEMENTATION NOTE: the zlib API deflateBound() can be used to find an + * upper limit on the output size, but it is always bigger than the input + * size so it is likely to be more efficient to use this linked-list + * approach. + */ + ret = png_deflate_claim(png_ptr, chunk_name, comp->input_len); + + if (ret != Z_OK) + return ret; + + /* Set up the compression buffers, we need a loop here to avoid overflowing a + * uInt. Use ZLIB_IO_MAX to limit the input. The output is always limited + * by the output buffer size, so there is no need to check that. Since this + * is ANSI-C we know that an 'int', hence a uInt, is always at least 16 bits + * in size. + */ + { + png_compression_bufferp *end = &png_ptr->zbuffer_list; + png_alloc_size_t input_len = comp->input_len; /* may be zero! */ + png_uint_32 output_len; + + /* zlib updates these for us: */ + png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input); + png_ptr->zstream.avail_in = 0; /* Set below */ + png_ptr->zstream.next_out = comp->output; + png_ptr->zstream.avail_out = (sizeof comp->output); + + output_len = png_ptr->zstream.avail_out; + + do + { + uInt avail_in = ZLIB_IO_MAX; + + if (avail_in > input_len) + avail_in = (uInt)input_len; + + input_len -= avail_in; + + png_ptr->zstream.avail_in = avail_in; + + if (png_ptr->zstream.avail_out == 0) + { + png_compression_buffer *next; + + /* Chunk data is limited to 2^31 bytes in length, so the prefix + * length must be counted here. + */ + if (output_len + prefix_len > PNG_UINT_31_MAX) + { + ret = Z_MEM_ERROR; + break; + } + + /* Need a new (malloc'ed) buffer, but there may be one present + * already. + */ + next = *end; + if (next == NULL) + { + next = png_voidcast(png_compression_bufferp, png_malloc_base + (png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); + + if (next == NULL) + { + ret = Z_MEM_ERROR; + break; + } + + /* Link in this buffer (so that it will be freed later) */ + next->next = NULL; + *end = next; + } + + png_ptr->zstream.next_out = next->output; + png_ptr->zstream.avail_out = png_ptr->zbuffer_size; + output_len += png_ptr->zstream.avail_out; + + /* Move 'end' to the next buffer pointer. */ + end = &next->next; + } + + /* Compress the data */ + ret = deflate(&png_ptr->zstream, + input_len > 0 ? Z_NO_FLUSH : Z_FINISH); + + /* Claw back input data that was not consumed (because avail_in is + * reset above every time round the loop). + */ + input_len += png_ptr->zstream.avail_in; + png_ptr->zstream.avail_in = 0; /* safety */ + } + while (ret == Z_OK); + + /* There may be some space left in the last output buffer. This needs to + * be subtracted from output_len. + */ + output_len -= png_ptr->zstream.avail_out; + png_ptr->zstream.avail_out = 0; /* safety */ + comp->output_len = output_len; + + /* Now double check the output length, put in a custom message if it is + * too long. Otherwise ensure the z_stream::msg pointer is set to + * something. + */ + if (output_len + prefix_len >= PNG_UINT_31_MAX) + { + png_ptr->zstream.msg = PNGZ_MSG_CAST("compressed data too long"); + ret = Z_MEM_ERROR; + } + + else + png_zstream_error(png_ptr, ret); + + /* Reset zlib for another zTXt/iTXt or image data */ + png_ptr->zowner = 0; + + /* The only success case is Z_STREAM_END, input_len must be 0; if not this + * is an internal error. + */ + if (ret == Z_STREAM_END && input_len == 0) + { +#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED + /* Fix up the deflate header, if required */ + optimize_cmf(comp->output, comp->input_len); +#endif + /* But Z_OK is returned, not Z_STREAM_END; this allows the claim + * function above to return Z_STREAM_END on an error (though it never + * does in the current versions of zlib.) + */ + return Z_OK; + } + + else + return ret; + } +} + +/* Ship the compressed text out via chunk writes */ +static void +png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp) +{ + png_uint_32 output_len = comp->output_len; + png_const_bytep output = comp->output; + png_uint_32 avail = (sizeof comp->output); + png_compression_buffer *next = png_ptr->zbuffer_list; + + for (;;) + { + if (avail > output_len) + avail = output_len; + + png_write_chunk_data(png_ptr, output, avail); + + output_len -= avail; + + if (output_len == 0 || next == NULL) + break; + + avail = png_ptr->zbuffer_size; + output = next->output; + next = next->next; + } + + /* This is an internal error; 'next' must have been NULL! */ + if (output_len > 0) + png_error(png_ptr, "error writing ancillary chunked compressed data"); +} +#endif /* WRITE_COMPRESSED_TEXT */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. Note that the rest of this code depends upon this + * information being correct. + */ +void /* PRIVATE */ +png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, + int bit_depth, int color_type, int compression_type, int filter_type, + int interlace_type) +{ + png_byte buf[13]; /* Buffer to store the IHDR info */ + int is_invalid_depth; + + png_debug(1, "in png_write_IHDR"); + + /* Check that we have valid input data from the application info */ + switch (color_type) + { + case PNG_COLOR_TYPE_GRAY: + switch (bit_depth) + { + case 1: + case 2: + case 4: + case 8: +#ifdef PNG_WRITE_16BIT_SUPPORTED + case 16: +#endif + png_ptr->channels = 1; break; + + default: + png_error(png_ptr, + "Invalid bit depth for grayscale image"); + } + break; + + case PNG_COLOR_TYPE_RGB: + is_invalid_depth = (bit_depth != 8); +#ifdef PNG_WRITE_16BIT_SUPPORTED + is_invalid_depth = (is_invalid_depth && bit_depth != 16); +#endif + if (is_invalid_depth) + png_error(png_ptr, "Invalid bit depth for RGB image"); + + png_ptr->channels = 3; + break; + + case PNG_COLOR_TYPE_PALETTE: + switch (bit_depth) + { + case 1: + case 2: + case 4: + case 8: + png_ptr->channels = 1; + break; + + default: + png_error(png_ptr, "Invalid bit depth for paletted image"); + } + break; + + case PNG_COLOR_TYPE_GRAY_ALPHA: + is_invalid_depth = (bit_depth != 8); +#ifdef PNG_WRITE_16BIT_SUPPORTED + is_invalid_depth = (is_invalid_depth && bit_depth != 16); +#endif + if (is_invalid_depth) + png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); + + png_ptr->channels = 2; + break; + + case PNG_COLOR_TYPE_RGB_ALPHA: + is_invalid_depth = (bit_depth != 8); +#ifdef PNG_WRITE_16BIT_SUPPORTED + is_invalid_depth = (is_invalid_depth && bit_depth != 16); +#endif + if (is_invalid_depth) + png_error(png_ptr, "Invalid bit depth for RGBA image"); + + png_ptr->channels = 4; + break; + + default: + png_error(png_ptr, "Invalid image color type specified"); + } + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + { + png_warning(png_ptr, "Invalid compression type specified"); + compression_type = PNG_COMPRESSION_TYPE_BASE; + } + + /* Write filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not write a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if ( +#ifdef PNG_MNG_FEATURES_SUPPORTED + !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && + ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && +#endif + filter_type != PNG_FILTER_TYPE_BASE) + { + png_warning(png_ptr, "Invalid filter type specified"); + filter_type = PNG_FILTER_TYPE_BASE; + } + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + if (interlace_type != PNG_INTERLACE_NONE && + interlace_type != PNG_INTERLACE_ADAM7) + { + png_warning(png_ptr, "Invalid interlace type specified"); + interlace_type = PNG_INTERLACE_ADAM7; + } +#else + interlace_type=PNG_INTERLACE_NONE; +#endif + + /* Save the relevant information */ + png_ptr->bit_depth = (png_byte)bit_depth; + png_ptr->color_type = (png_byte)color_type; + png_ptr->interlaced = (png_byte)interlace_type; +#ifdef PNG_MNG_FEATURES_SUPPORTED + png_ptr->filter_type = (png_byte)filter_type; +#endif + png_ptr->compression_type = (png_byte)compression_type; + png_ptr->width = width; + png_ptr->height = height; + + png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); + png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); + /* Set the usr info, so any transformations can modify it */ + png_ptr->usr_width = png_ptr->width; + png_ptr->usr_bit_depth = png_ptr->bit_depth; + png_ptr->usr_channels = png_ptr->channels; + + /* Pack the header information into the buffer */ + png_save_uint_32(buf, width); + png_save_uint_32(buf + 4, height); + buf[8] = (png_byte)bit_depth; + buf[9] = (png_byte)color_type; + buf[10] = (png_byte)compression_type; + buf[11] = (png_byte)filter_type; + buf[12] = (png_byte)interlace_type; + + /* Write the chunk */ + png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13); + + if ((png_ptr->do_filter) == PNG_NO_FILTERS) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || + png_ptr->bit_depth < 8) + png_ptr->do_filter = PNG_FILTER_NONE; + + else + png_ptr->do_filter = PNG_ALL_FILTERS; + } + + png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */ +} + +/* Write the palette. We are careful not to trust png_color to be in the + * correct order for PNG, so people can redefine it to any convenient + * structure. + */ +void /* PRIVATE */ +png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, + png_uint_32 num_pal) +{ + png_uint_32 max_palette_length, i; + png_const_colorp pal_ptr; + png_byte buf[3]; + + png_debug(1, "in png_write_PLTE"); + + max_palette_length = (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ? + (1 << png_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH; + + if (( +#ifdef PNG_MNG_FEATURES_SUPPORTED + (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 && +#endif + num_pal == 0) || num_pal > max_palette_length) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_error(png_ptr, "Invalid number of colors in palette"); + } + + else + { + png_warning(png_ptr, "Invalid number of colors in palette"); + return; + } + } + + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) + { + png_warning(png_ptr, + "Ignoring request to write a PLTE chunk in grayscale PNG"); + + return; + } + + png_ptr->num_palette = (png_uint_16)num_pal; + png_debug1(3, "num_palette = %d", png_ptr->num_palette); + + png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3)); +#ifdef PNG_POINTER_INDEXING_SUPPORTED + + for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) + { + buf[0] = pal_ptr->red; + buf[1] = pal_ptr->green; + buf[2] = pal_ptr->blue; + png_write_chunk_data(png_ptr, buf, (png_size_t)3); + } + +#else + /* This is a little slower but some buggy compilers need to do this + * instead + */ + pal_ptr=palette; + + for (i = 0; i < num_pal; i++) + { + buf[0] = pal_ptr[i].red; + buf[1] = pal_ptr[i].green; + buf[2] = pal_ptr[i].blue; + png_write_chunk_data(png_ptr, buf, (png_size_t)3); + } + +#endif + png_write_chunk_end(png_ptr); + png_ptr->mode |= PNG_HAVE_PLTE; +} + +/* This is similar to png_text_compress, above, except that it does not require + * all of the data at once and, instead of buffering the compressed result, + * writes it as IDAT chunks. Unlike png_text_compress it *can* png_error out + * because it calls the write interface. As a result it does its own error + * reporting and does not return an error code. In the event of error it will + * just call png_error. The input data length may exceed 32-bits. The 'flush' + * parameter is exactly the same as that to deflate, with the following + * meanings: + * + * Z_NO_FLUSH: normal incremental output of compressed data + * Z_SYNC_FLUSH: do a SYNC_FLUSH, used by png_write_flush + * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up + * + * The routine manages the acquire and release of the png_ptr->zstream by + * checking and (at the end) clearing png_ptr->zowner; it does some sanity + * checks on the 'mode' flags while doing this. + */ +void /* PRIVATE */ +png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, + png_alloc_size_t input_len, int flush) +{ + if (png_ptr->zowner != png_IDAT) + { + /* First time. Ensure we have a temporary buffer for compression and + * trim the buffer list if it has more than one entry to free memory. + * If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been + * created at this point, but the check here is quick and safe. + */ + if (png_ptr->zbuffer_list == NULL) + { + png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp, + png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); + png_ptr->zbuffer_list->next = NULL; + } + + else + png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list->next); + + /* It is a terminal error if we can't claim the zstream. */ + if (png_deflate_claim(png_ptr, png_IDAT, png_image_size(png_ptr)) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); + + /* The output state is maintained in png_ptr->zstream, so it must be + * initialized here after the claim. + */ + png_ptr->zstream.next_out = png_ptr->zbuffer_list->output; + png_ptr->zstream.avail_out = png_ptr->zbuffer_size; + } + + /* Now loop reading and writing until all the input is consumed or an error + * terminates the operation. The _out values are maintained across calls to + * this function, but the input must be reset each time. + */ + png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); + png_ptr->zstream.avail_in = 0; /* set below */ + for (;;) + { + int ret; + + /* INPUT: from the row data */ + uInt avail = ZLIB_IO_MAX; + + if (avail > input_len) + avail = (uInt)input_len; /* safe because of the check */ + + png_ptr->zstream.avail_in = avail; + input_len -= avail; + + ret = deflate(&png_ptr->zstream, input_len > 0 ? Z_NO_FLUSH : flush); + + /* Include as-yet unconsumed input */ + input_len += png_ptr->zstream.avail_in; + png_ptr->zstream.avail_in = 0; + + /* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note + * that these two zstream fields are preserved across the calls, therefore + * there is no need to set these up on entry to the loop. + */ + if (png_ptr->zstream.avail_out == 0) + { + png_bytep data = png_ptr->zbuffer_list->output; + uInt size = png_ptr->zbuffer_size; + + /* Write an IDAT containing the data then reset the buffer. The + * first IDAT may need deflate header optimization. + */ +#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED + if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 && + png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) + optimize_cmf(data, png_image_size(png_ptr)); +#endif + + if (size > 0) + png_write_complete_chunk(png_ptr, png_IDAT, data, size); + png_ptr->mode |= PNG_HAVE_IDAT; + + png_ptr->zstream.next_out = data; + png_ptr->zstream.avail_out = size; + + /* For SYNC_FLUSH or FINISH it is essential to keep calling zlib with + * the same flush parameter until it has finished output, for NO_FLUSH + * it doesn't matter. + */ + if (ret == Z_OK && flush != Z_NO_FLUSH) + continue; + } + + /* The order of these checks doesn't matter much; it just affects which + * possible error might be detected if multiple things go wrong at once. + */ + if (ret == Z_OK) /* most likely return code! */ + { + /* If all the input has been consumed then just return. If Z_FINISH + * was used as the flush parameter something has gone wrong if we get + * here. + */ + if (input_len == 0) + { + if (flush == Z_FINISH) + png_error(png_ptr, "Z_OK on Z_FINISH with output space"); + + return; + } + } + + else if (ret == Z_STREAM_END && flush == Z_FINISH) + { + /* This is the end of the IDAT data; any pending output must be + * flushed. For small PNG files we may still be at the beginning. + */ + png_bytep data = png_ptr->zbuffer_list->output; + uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out; + +#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED + if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 && + png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) + optimize_cmf(data, png_image_size(png_ptr)); +#endif + + if (size > 0) + png_write_complete_chunk(png_ptr, png_IDAT, data, size); + png_ptr->zstream.avail_out = 0; + png_ptr->zstream.next_out = NULL; + png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT; + + png_ptr->zowner = 0; /* Release the stream */ + return; + } + + else + { + /* This is an error condition. */ + png_zstream_error(png_ptr, ret); + png_error(png_ptr, png_ptr->zstream.msg); + } + } +} + +/* Write an IEND chunk */ +void /* PRIVATE */ +png_write_IEND(png_structrp png_ptr) +{ + png_debug(1, "in png_write_IEND"); + + png_write_complete_chunk(png_ptr, png_IEND, NULL, (png_size_t)0); + png_ptr->mode |= PNG_HAVE_IEND; +} + +#ifdef PNG_WRITE_gAMA_SUPPORTED +/* Write a gAMA chunk */ +void /* PRIVATE */ +png_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma) +{ + png_byte buf[4]; + + png_debug(1, "in png_write_gAMA"); + + /* file_gamma is saved in 1/100,000ths */ + png_save_uint_32(buf, (png_uint_32)file_gamma); + png_write_complete_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); +} +#endif + +#ifdef PNG_WRITE_sRGB_SUPPORTED +/* Write a sRGB chunk */ +void /* PRIVATE */ +png_write_sRGB(png_structrp png_ptr, int srgb_intent) +{ + png_byte buf[1]; + + png_debug(1, "in png_write_sRGB"); + + if (srgb_intent >= PNG_sRGB_INTENT_LAST) + png_warning(png_ptr, + "Invalid sRGB rendering intent specified"); + + buf[0]=(png_byte)srgb_intent; + png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1); +} +#endif + +#ifdef PNG_WRITE_iCCP_SUPPORTED +/* Write an iCCP chunk */ +void /* PRIVATE */ +png_write_iCCP(png_structrp png_ptr, png_const_charp name, + png_const_bytep profile) +{ + png_uint_32 name_len; + png_uint_32 profile_len; + png_byte new_name[81]; /* 1 byte for the compression byte */ + compression_state comp; + png_uint_32 temp; + + png_debug(1, "in png_write_iCCP"); + + /* These are all internal problems: the profile should have been checked + * before when it was stored. + */ + if (profile == NULL) + png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */ + + profile_len = png_get_uint_32(profile); + + if (profile_len < 132) + png_error(png_ptr, "ICC profile too short"); + + temp = (png_uint_32) (*(profile+8)); + if (temp > 3 && (profile_len & 0x03)) + png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)"); + + { + png_uint_32 embedded_profile_len = png_get_uint_32(profile); + + if (profile_len != embedded_profile_len) + png_error(png_ptr, "Profile length does not match profile"); + } + + name_len = png_check_keyword(png_ptr, name, new_name); + + if (name_len == 0) + png_error(png_ptr, "iCCP: invalid keyword"); + + new_name[++name_len] = PNG_COMPRESSION_TYPE_BASE; + + /* Make sure we include the NULL after the name and the compression type */ + ++name_len; + + png_text_compress_init(&comp, profile, profile_len); + + /* Allow for keyword terminator and compression byte */ + if (png_text_compress(png_ptr, png_iCCP, &comp, name_len) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); + + png_write_chunk_header(png_ptr, png_iCCP, name_len + comp.output_len); + + png_write_chunk_data(png_ptr, new_name, name_len); + + png_write_compressed_data_out(png_ptr, &comp); + + png_write_chunk_end(png_ptr); +} +#endif + +#ifdef PNG_WRITE_sPLT_SUPPORTED +/* Write a sPLT chunk */ +void /* PRIVATE */ +png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette) +{ + png_uint_32 name_len; + png_byte new_name[80]; + png_byte entrybuf[10]; + png_size_t entry_size = (spalette->depth == 8 ? 6 : 10); + png_size_t palette_size = entry_size * (png_size_t)spalette->nentries; + png_sPLT_entryp ep; +#ifndef PNG_POINTER_INDEXING_SUPPORTED + int i; +#endif + + png_debug(1, "in png_write_sPLT"); + + name_len = png_check_keyword(png_ptr, spalette->name, new_name); + + if (name_len == 0) + png_error(png_ptr, "sPLT: invalid keyword"); + + /* Make sure we include the NULL after the name */ + png_write_chunk_header(png_ptr, png_sPLT, + (png_uint_32)(name_len + 2 + palette_size)); + + png_write_chunk_data(png_ptr, (png_bytep)new_name, + (png_size_t)(name_len + 1)); + + png_write_chunk_data(png_ptr, &spalette->depth, (png_size_t)1); + + /* Loop through each palette entry, writing appropriately */ +#ifdef PNG_POINTER_INDEXING_SUPPORTED + for (ep = spalette->entries; epentries + spalette->nentries; ep++) + { + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep->red; + entrybuf[1] = (png_byte)ep->green; + entrybuf[2] = (png_byte)ep->blue; + entrybuf[3] = (png_byte)ep->alpha; + png_save_uint_16(entrybuf + 4, ep->frequency); + } + + else + { + png_save_uint_16(entrybuf + 0, ep->red); + png_save_uint_16(entrybuf + 2, ep->green); + png_save_uint_16(entrybuf + 4, ep->blue); + png_save_uint_16(entrybuf + 6, ep->alpha); + png_save_uint_16(entrybuf + 8, ep->frequency); + } + + png_write_chunk_data(png_ptr, entrybuf, entry_size); + } +#else + ep=spalette->entries; + for (i = 0; i>spalette->nentries; i++) + { + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep[i].red; + entrybuf[1] = (png_byte)ep[i].green; + entrybuf[2] = (png_byte)ep[i].blue; + entrybuf[3] = (png_byte)ep[i].alpha; + png_save_uint_16(entrybuf + 4, ep[i].frequency); + } + + else + { + png_save_uint_16(entrybuf + 0, ep[i].red); + png_save_uint_16(entrybuf + 2, ep[i].green); + png_save_uint_16(entrybuf + 4, ep[i].blue); + png_save_uint_16(entrybuf + 6, ep[i].alpha); + png_save_uint_16(entrybuf + 8, ep[i].frequency); + } + + png_write_chunk_data(png_ptr, entrybuf, entry_size); + } +#endif + + png_write_chunk_end(png_ptr); +} +#endif + +#ifdef PNG_WRITE_sBIT_SUPPORTED +/* Write the sBIT chunk */ +void /* PRIVATE */ +png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) +{ + png_byte buf[4]; + png_size_t size; + + png_debug(1, "in png_write_sBIT"); + + /* Make sure we don't depend upon the order of PNG_COLOR_8 */ + if ((color_type & PNG_COLOR_MASK_COLOR) != 0) + { + png_byte maxbits; + + maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : + png_ptr->usr_bit_depth); + + if (sbit->red == 0 || sbit->red > maxbits || + sbit->green == 0 || sbit->green > maxbits || + sbit->blue == 0 || sbit->blue > maxbits) + { + png_warning(png_ptr, "Invalid sBIT depth specified"); + return; + } + + buf[0] = sbit->red; + buf[1] = sbit->green; + buf[2] = sbit->blue; + size = 3; + } + + else + { + if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) + { + png_warning(png_ptr, "Invalid sBIT depth specified"); + return; + } + + buf[0] = sbit->gray; + size = 1; + } + + if ((color_type & PNG_COLOR_MASK_ALPHA) != 0) + { + if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) + { + png_warning(png_ptr, "Invalid sBIT depth specified"); + return; + } + + buf[size++] = sbit->alpha; + } + + png_write_complete_chunk(png_ptr, png_sBIT, buf, size); +} +#endif + +#ifdef PNG_WRITE_cHRM_SUPPORTED +/* Write the cHRM chunk */ +void /* PRIVATE */ +png_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy) +{ + png_byte buf[32]; + + png_debug(1, "in png_write_cHRM"); + + /* Each value is saved in 1/100,000ths */ + png_save_int_32(buf, xy->whitex); + png_save_int_32(buf + 4, xy->whitey); + + png_save_int_32(buf + 8, xy->redx); + png_save_int_32(buf + 12, xy->redy); + + png_save_int_32(buf + 16, xy->greenx); + png_save_int_32(buf + 20, xy->greeny); + + png_save_int_32(buf + 24, xy->bluex); + png_save_int_32(buf + 28, xy->bluey); + + png_write_complete_chunk(png_ptr, png_cHRM, buf, 32); +} +#endif + +#ifdef PNG_WRITE_tRNS_SUPPORTED +/* Write the tRNS chunk */ +void /* PRIVATE */ +png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, + png_const_color_16p tran, int num_trans, int color_type) +{ + png_byte buf[6]; + + png_debug(1, "in png_write_tRNS"); + + if (color_type == PNG_COLOR_TYPE_PALETTE) + { + if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) + { + png_app_warning(png_ptr, + "Invalid number of transparent colors specified"); + return; + } + + /* Write the chunk out as it is */ + png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, + (png_size_t)num_trans); + } + + else if (color_type == PNG_COLOR_TYPE_GRAY) + { + /* One 16-bit value */ + if (tran->gray >= (1 << png_ptr->bit_depth)) + { + png_app_warning(png_ptr, + "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); + + return; + } + + png_save_uint_16(buf, tran->gray); + png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)2); + } + + else if (color_type == PNG_COLOR_TYPE_RGB) + { + /* Three 16-bit values */ + png_save_uint_16(buf, tran->red); + png_save_uint_16(buf + 2, tran->green); + png_save_uint_16(buf + 4, tran->blue); +#ifdef PNG_WRITE_16BIT_SUPPORTED + if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0) +#else + if ((buf[0] | buf[2] | buf[4]) != 0) +#endif + { + png_app_warning(png_ptr, + "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); + return; + } + + png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)6); + } + + else + { + png_app_warning(png_ptr, "Can't write tRNS with an alpha channel"); + } +} +#endif + +#ifdef PNG_WRITE_bKGD_SUPPORTED +/* Write the background chunk */ +void /* PRIVATE */ +png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) +{ + png_byte buf[6]; + + png_debug(1, "in png_write_bKGD"); + + if (color_type == PNG_COLOR_TYPE_PALETTE) + { + if ( +#ifdef PNG_MNG_FEATURES_SUPPORTED + (png_ptr->num_palette != 0 || + (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0) && +#endif + back->index >= png_ptr->num_palette) + { + png_warning(png_ptr, "Invalid background palette index"); + return; + } + + buf[0] = back->index; + png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1); + } + + else if ((color_type & PNG_COLOR_MASK_COLOR) != 0) + { + png_save_uint_16(buf, back->red); + png_save_uint_16(buf + 2, back->green); + png_save_uint_16(buf + 4, back->blue); +#ifdef PNG_WRITE_16BIT_SUPPORTED + if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0) +#else + if ((buf[0] | buf[2] | buf[4]) != 0) +#endif + { + png_warning(png_ptr, + "Ignoring attempt to write 16-bit bKGD chunk " + "when bit_depth is 8"); + + return; + } + + png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)6); + } + + else + { + if (back->gray >= (1 << png_ptr->bit_depth)) + { + png_warning(png_ptr, + "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); + + return; + } + + png_save_uint_16(buf, back->gray); + png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)2); + } +} +#endif + +#ifdef PNG_WRITE_eXIf_SUPPORTED +/* Write the Exif data */ +void /* PRIVATE */ +png_write_eXIf(png_structrp png_ptr, png_bytep exif, int num_exif) +{ + int i; + png_byte buf[1]; + + png_debug(1, "in png_write_eXIf"); + + png_write_chunk_header(png_ptr, png_eXIf, (png_uint_32)(num_exif)); + + for (i = 0; i < num_exif; i++) + { + buf[0] = exif[i]; + png_write_chunk_data(png_ptr, buf, (png_size_t)1); + } + + png_write_chunk_end(png_ptr); +} +#endif + +#ifdef PNG_WRITE_hIST_SUPPORTED +/* Write the histogram */ +void /* PRIVATE */ +png_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist) +{ + int i; + png_byte buf[3]; + + png_debug(1, "in png_write_hIST"); + + if (num_hist > (int)png_ptr->num_palette) + { + png_debug2(3, "num_hist = %d, num_palette = %d", num_hist, + png_ptr->num_palette); + + png_warning(png_ptr, "Invalid number of histogram entries specified"); + return; + } + + png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); + + for (i = 0; i < num_hist; i++) + { + png_save_uint_16(buf, hist[i]); + png_write_chunk_data(png_ptr, buf, (png_size_t)2); + } + + png_write_chunk_end(png_ptr); +} +#endif + +#ifdef PNG_WRITE_tEXt_SUPPORTED +/* Write a tEXt chunk */ +void /* PRIVATE */ +png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, + png_size_t text_len) +{ + png_uint_32 key_len; + png_byte new_key[80]; + + png_debug(1, "in png_write_tEXt"); + + key_len = png_check_keyword(png_ptr, key, new_key); + + if (key_len == 0) + png_error(png_ptr, "tEXt: invalid keyword"); + + if (text == NULL || *text == '\0') + text_len = 0; + + else + text_len = strlen(text); + + if (text_len > PNG_UINT_31_MAX - (key_len+1)) + png_error(png_ptr, "tEXt: text too long"); + + /* Make sure we include the 0 after the key */ + png_write_chunk_header(png_ptr, png_tEXt, + (png_uint_32)/*checked above*/(key_len + text_len + 1)); + /* + * We leave it to the application to meet PNG-1.0 requirements on the + * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of + * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. + * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. + */ + png_write_chunk_data(png_ptr, new_key, key_len + 1); + + if (text_len != 0) + png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len); + + png_write_chunk_end(png_ptr); +} +#endif + +#ifdef PNG_WRITE_zTXt_SUPPORTED +/* Write a compressed text chunk */ +void /* PRIVATE */ +png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, + int compression) +{ + png_uint_32 key_len; + png_byte new_key[81]; + compression_state comp; + + png_debug(1, "in png_write_zTXt"); + + if (compression == PNG_TEXT_COMPRESSION_NONE) + { + png_write_tEXt(png_ptr, key, text, 0); + return; + } + + if (compression != PNG_TEXT_COMPRESSION_zTXt) + png_error(png_ptr, "zTXt: invalid compression type"); + + key_len = png_check_keyword(png_ptr, key, new_key); + + if (key_len == 0) + png_error(png_ptr, "zTXt: invalid keyword"); + + /* Add the compression method and 1 for the keyword separator. */ + new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE; + ++key_len; + + /* Compute the compressed data; do it now for the length */ + png_text_compress_init(&comp, (png_const_bytep)text, + text == NULL ? 0 : strlen(text)); + + if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); + + /* Write start of chunk */ + png_write_chunk_header(png_ptr, png_zTXt, key_len + comp.output_len); + + /* Write key */ + png_write_chunk_data(png_ptr, new_key, key_len); + + /* Write the compressed data */ + png_write_compressed_data_out(png_ptr, &comp); + + /* Close the chunk */ + png_write_chunk_end(png_ptr); +} +#endif + +#ifdef PNG_WRITE_iTXt_SUPPORTED +/* Write an iTXt chunk */ +void /* PRIVATE */ +png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, + png_const_charp lang, png_const_charp lang_key, png_const_charp text) +{ + png_uint_32 key_len, prefix_len; + png_size_t lang_len, lang_key_len; + png_byte new_key[82]; + compression_state comp; + + png_debug(1, "in png_write_iTXt"); + + key_len = png_check_keyword(png_ptr, key, new_key); + + if (key_len == 0) + png_error(png_ptr, "iTXt: invalid keyword"); + + /* Set the compression flag */ + switch (compression) + { + case PNG_ITXT_COMPRESSION_NONE: + case PNG_TEXT_COMPRESSION_NONE: + compression = new_key[++key_len] = 0; /* no compression */ + break; + + case PNG_TEXT_COMPRESSION_zTXt: + case PNG_ITXT_COMPRESSION_zTXt: + compression = new_key[++key_len] = 1; /* compressed */ + break; + + default: + png_error(png_ptr, "iTXt: invalid compression"); + } + + new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE; + ++key_len; /* for the keywod separator */ + + /* We leave it to the application to meet PNG-1.0 requirements on the + * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of + * any non-Latin-1 characters except for NEWLINE. ISO PNG, however, + * specifies that the text is UTF-8 and this really doesn't require any + * checking. + * + * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. + * + * TODO: validate the language tag correctly (see the spec.) + */ + if (lang == NULL) lang = ""; /* empty language is valid */ + lang_len = strlen(lang)+1; + if (lang_key == NULL) lang_key = ""; /* may be empty */ + lang_key_len = strlen(lang_key)+1; + if (text == NULL) text = ""; /* may be empty */ + + prefix_len = key_len; + if (lang_len > PNG_UINT_31_MAX-prefix_len) + prefix_len = PNG_UINT_31_MAX; + else + prefix_len = (png_uint_32)(prefix_len + lang_len); + + if (lang_key_len > PNG_UINT_31_MAX-prefix_len) + prefix_len = PNG_UINT_31_MAX; + else + prefix_len = (png_uint_32)(prefix_len + lang_key_len); + + png_text_compress_init(&comp, (png_const_bytep)text, strlen(text)); + + if (compression != 0) + { + if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); + } + + else + { + if (comp.input_len > PNG_UINT_31_MAX-prefix_len) + png_error(png_ptr, "iTXt: uncompressed text too long"); + + /* So the string will fit in a chunk: */ + comp.output_len = (png_uint_32)/*SAFE*/comp.input_len; + } + + png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len); + + png_write_chunk_data(png_ptr, new_key, key_len); + + png_write_chunk_data(png_ptr, (png_const_bytep)lang, lang_len); + + png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len); + + if (compression != 0) + png_write_compressed_data_out(png_ptr, &comp); + + else + png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len); + + png_write_chunk_end(png_ptr); +} +#endif + +#ifdef PNG_WRITE_oFFs_SUPPORTED +/* Write the oFFs chunk */ +void /* PRIVATE */ +png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset, + int unit_type) +{ + png_byte buf[9]; + + png_debug(1, "in png_write_oFFs"); + + if (unit_type >= PNG_OFFSET_LAST) + png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); + + png_save_int_32(buf, x_offset); + png_save_int_32(buf + 4, y_offset); + buf[8] = (png_byte)unit_type; + + png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9); +} +#endif +#ifdef PNG_WRITE_pCAL_SUPPORTED +/* Write the pCAL chunk (described in the PNG extensions document) */ +void /* PRIVATE */ +png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, + png_int_32 X1, int type, int nparams, png_const_charp units, + png_charpp params) +{ + png_uint_32 purpose_len; + png_size_t units_len, total_len; + png_size_tp params_len; + png_byte buf[10]; + png_byte new_purpose[80]; + int i; + + png_debug1(1, "in png_write_pCAL (%d parameters)", nparams); + + if (type >= PNG_EQUATION_LAST) + png_error(png_ptr, "Unrecognized equation type for pCAL chunk"); + + purpose_len = png_check_keyword(png_ptr, purpose, new_purpose); + + if (purpose_len == 0) + png_error(png_ptr, "pCAL: invalid keyword"); + + ++purpose_len; /* terminator */ + + png_debug1(3, "pCAL purpose length = %d", (int)purpose_len); + units_len = strlen(units) + (nparams == 0 ? 0 : 1); + png_debug1(3, "pCAL units length = %d", (int)units_len); + total_len = purpose_len + units_len + 10; + + params_len = (png_size_tp)png_malloc(png_ptr, + (png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (png_size_t)))); + + /* Find the length of each parameter, making sure we don't count the + * null terminator for the last parameter. + */ + for (i = 0; i < nparams; i++) + { + params_len[i] = strlen(params[i]) + (i == nparams - 1 ? 0 : 1); + png_debug2(3, "pCAL parameter %d length = %lu", i, + (unsigned long)params_len[i]); + total_len += params_len[i]; + } + + png_debug1(3, "pCAL total length = %d", (int)total_len); + png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, new_purpose, purpose_len); + png_save_int_32(buf, X0); + png_save_int_32(buf + 4, X1); + buf[8] = (png_byte)type; + buf[9] = (png_byte)nparams; + png_write_chunk_data(png_ptr, buf, (png_size_t)10); + png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len); + + for (i = 0; i < nparams; i++) + { + png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]); + } + + png_free(png_ptr, params_len); + png_write_chunk_end(png_ptr); +} +#endif + +#ifdef PNG_WRITE_sCAL_SUPPORTED +/* Write the sCAL chunk */ +void /* PRIVATE */ +png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width, + png_const_charp height) +{ + png_byte buf[64]; + png_size_t wlen, hlen, total_len; + + png_debug(1, "in png_write_sCAL_s"); + + wlen = strlen(width); + hlen = strlen(height); + total_len = wlen + hlen + 2; + + if (total_len > 64) + { + png_warning(png_ptr, "Can't write sCAL (buffer too small)"); + return; + } + + buf[0] = (png_byte)unit; + memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */ + memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */ + + png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); + png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len); +} +#endif + +#ifdef PNG_WRITE_pHYs_SUPPORTED +/* Write the pHYs chunk */ +void /* PRIVATE */ +png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit, + png_uint_32 y_pixels_per_unit, + int unit_type) +{ + png_byte buf[9]; + + png_debug(1, "in png_write_pHYs"); + + if (unit_type >= PNG_RESOLUTION_LAST) + png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); + + png_save_uint_32(buf, x_pixels_per_unit); + png_save_uint_32(buf + 4, y_pixels_per_unit); + buf[8] = (png_byte)unit_type; + + png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9); +} +#endif + +#ifdef PNG_WRITE_tIME_SUPPORTED +/* Write the tIME chunk. Use either png_convert_from_struct_tm() + * or png_convert_from_time_t(), or fill in the structure yourself. + */ +void /* PRIVATE */ +png_write_tIME(png_structrp png_ptr, png_const_timep mod_time) +{ + png_byte buf[7]; + + png_debug(1, "in png_write_tIME"); + + if (mod_time->month > 12 || mod_time->month < 1 || + mod_time->day > 31 || mod_time->day < 1 || + mod_time->hour > 23 || mod_time->second > 60) + { + png_warning(png_ptr, "Invalid time specified for tIME chunk"); + return; + } + + png_save_uint_16(buf, mod_time->year); + buf[2] = mod_time->month; + buf[3] = mod_time->day; + buf[4] = mod_time->hour; + buf[5] = mod_time->minute; + buf[6] = mod_time->second; + + png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7); +} +#endif + +/* Initializes the row writing capability of libpng */ +void /* PRIVATE */ +png_write_start_row(png_structrp png_ptr) +{ +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif + + png_alloc_size_t buf_size; + int usr_pixel_depth; + +#ifdef PNG_WRITE_FILTER_SUPPORTED + png_byte filters; +#endif + + png_debug(1, "in png_write_start_row"); + + usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth; + buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1; + + /* 1.5.6: added to allow checking in the row write code. */ + png_ptr->transformed_pixel_depth = png_ptr->pixel_depth; + png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth; + + /* Set up row buffer */ + png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size)); + + png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; + +#ifdef PNG_WRITE_FILTER_SUPPORTED + filters = png_ptr->do_filter; + + if (png_ptr->height == 1) + filters &= 0xff & ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); + + if (png_ptr->width == 1) + filters &= 0xff & ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH); + + if (filters == 0) + filters = PNG_FILTER_NONE; + + png_ptr->do_filter = filters; + + if (((filters & (PNG_FILTER_SUB | PNG_FILTER_UP | PNG_FILTER_AVG | + PNG_FILTER_PAETH)) != 0) && png_ptr->try_row == NULL) + { + int num_filters = 0; + + png_ptr->try_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size)); + + if (filters & PNG_FILTER_SUB) + num_filters++; + + if (filters & PNG_FILTER_UP) + num_filters++; + + if (filters & PNG_FILTER_AVG) + num_filters++; + + if (filters & PNG_FILTER_PAETH) + num_filters++; + + if (num_filters > 1) + png_ptr->tst_row = png_voidcast(png_bytep, png_malloc(png_ptr, + buf_size)); + } + + /* We only need to keep the previous row if we are using one of the following + * filters. + */ + if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0) + png_ptr->prev_row = png_voidcast(png_bytep, + png_calloc(png_ptr, buf_size)); +#endif /* WRITE_FILTER */ + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* If interlaced, we need to set up width and height of pass */ + if (png_ptr->interlaced != 0) + { + if ((png_ptr->transformations & PNG_INTERLACE) == 0) + { + png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - + png_pass_ystart[0]) / png_pass_yinc[0]; + + png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - + png_pass_start[0]) / png_pass_inc[0]; + } + + else + { + png_ptr->num_rows = png_ptr->height; + png_ptr->usr_width = png_ptr->width; + } + } + + else +#endif + { + png_ptr->num_rows = png_ptr->height; + png_ptr->usr_width = png_ptr->width; + } +} + +/* Internal use only. Called when finished processing a row of data. */ +void /* PRIVATE */ +png_write_finish_row(png_structrp png_ptr) +{ +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif + + png_debug(1, "in png_write_finish_row"); + + /* Next row */ + png_ptr->row_number++; + + /* See if we are done */ + if (png_ptr->row_number < png_ptr->num_rows) + return; + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* If interlaced, go to next pass */ + if (png_ptr->interlaced != 0) + { + png_ptr->row_number = 0; + if ((png_ptr->transformations & PNG_INTERLACE) != 0) + { + png_ptr->pass++; + } + + else + { + /* Loop until we find a non-zero width or height pass */ + do + { + png_ptr->pass++; + + if (png_ptr->pass >= 7) + break; + + png_ptr->usr_width = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + + if ((png_ptr->transformations & PNG_INTERLACE) != 0) + break; + + } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); + + } + + /* Reset the row above the image for the next pass */ + if (png_ptr->pass < 7) + { + if (png_ptr->prev_row != NULL) + memset(png_ptr->prev_row, 0, + (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* + png_ptr->usr_bit_depth, png_ptr->width)) + 1); + + return; + } + } +#endif + + /* If we get here, we've just written the last row, so we need + to flush the compressor */ + png_compress_IDAT(png_ptr, NULL, 0, Z_FINISH); +} + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED +/* Pick out the correct pixels for the interlace pass. + * The basic idea here is to go through the row with a source + * pointer and a destination pointer (sp and dp), and copy the + * correct pixels for the pass. As the row gets compacted, + * sp will always be >= dp, so we should never overwrite anything. + * See the default: case for the easiest code to understand. + */ +void /* PRIVATE */ +png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) +{ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + png_debug(1, "in png_do_write_interlace"); + + /* We don't have to do anything on the last pass (6) */ + if (pass < 6) + { + /* Each pixel depth is handled separately */ + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp; + png_bytep dp; + unsigned int shift; + int d; + int value; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + dp = row; + d = 0; + shift = 7; + + for (i = png_pass_start[pass]; i < row_width; + i += png_pass_inc[pass]) + { + sp = row + (png_size_t)(i >> 3); + value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01; + d |= (value << shift); + + if (shift == 0) + { + shift = 7; + *dp++ = (png_byte)d; + d = 0; + } + + else + shift--; + + } + if (shift != 7) + *dp = (png_byte)d; + + break; + } + + case 2: + { + png_bytep sp; + png_bytep dp; + unsigned int shift; + int d; + int value; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + dp = row; + shift = 6; + d = 0; + + for (i = png_pass_start[pass]; i < row_width; + i += png_pass_inc[pass]) + { + sp = row + (png_size_t)(i >> 2); + value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03; + d |= (value << shift); + + if (shift == 0) + { + shift = 6; + *dp++ = (png_byte)d; + d = 0; + } + + else + shift -= 2; + } + if (shift != 6) + *dp = (png_byte)d; + + break; + } + + case 4: + { + png_bytep sp; + png_bytep dp; + unsigned int shift; + int d; + int value; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + dp = row; + shift = 4; + d = 0; + for (i = png_pass_start[pass]; i < row_width; + i += png_pass_inc[pass]) + { + sp = row + (png_size_t)(i >> 1); + value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; + d |= (value << shift); + + if (shift == 0) + { + shift = 4; + *dp++ = (png_byte)d; + d = 0; + } + + else + shift -= 4; + } + if (shift != 4) + *dp = (png_byte)d; + + break; + } + + default: + { + png_bytep sp; + png_bytep dp; + png_uint_32 i; + png_uint_32 row_width = row_info->width; + png_size_t pixel_bytes; + + /* Start at the beginning */ + dp = row; + + /* Find out how many bytes each pixel takes up */ + pixel_bytes = (row_info->pixel_depth >> 3); + + /* Loop through the row, only looking at the pixels that matter */ + for (i = png_pass_start[pass]; i < row_width; + i += png_pass_inc[pass]) + { + /* Find out where the original pixel is */ + sp = row + (png_size_t)i * pixel_bytes; + + /* Move the pixel */ + if (dp != sp) + memcpy(dp, sp, pixel_bytes); + + /* Next pixel */ + dp += pixel_bytes; + } + break; + } + } + /* Set new row width */ + row_info->width = (row_info->width + + png_pass_inc[pass] - 1 - + png_pass_start[pass]) / + png_pass_inc[pass]; + + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, + row_info->width); + } +} +#endif + + +/* This filters the row, chooses which filter to use, if it has not already + * been specified by the application, and then writes the row out with the + * chosen filter. + */ +static void /* PRIVATE */ +png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, + png_size_t row_bytes); + +#ifdef PNG_WRITE_FILTER_SUPPORTED +static png_size_t /* PRIVATE */ +png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes, const png_size_t lmins) +{ + png_bytep rp, dp, lp; + png_size_t i; + png_size_t sum = 0; + unsigned int v; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; + i++, rp++, dp++) + { + v = *dp = *rp; +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else + sum += (v < 128) ? v : 256 - v; +#endif + } + + for (lp = png_ptr->row_buf + 1; i < row_bytes; + i++, rp++, lp++, dp++) + { + v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else + sum += (v < 128) ? v : 256 - v; +#endif + + if (sum > lmins) /* We are already worse, don't continue. */ + break; + } + + return (sum); +} + +static void /* PRIVATE */ +png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, lp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; + i++, rp++, dp++) + { + *dp = *rp; + } + + for (lp = png_ptr->row_buf + 1; i < row_bytes; + i++, rp++, lp++, dp++) + { + *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); + } +} + +static png_size_t /* PRIVATE */ +png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, + const png_size_t lmins) +{ + png_bytep rp, dp, pp; + png_size_t i; + png_size_t sum = 0; + unsigned int v; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < row_bytes; + i++, rp++, pp++, dp++) + { + v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else + sum += (v < 128) ? v : 256 - v; +#endif + + if (sum > lmins) /* We are already worse, don't continue. */ + break; + } + + return (sum); +} +static void /* PRIVATE */ +png_setup_up_row_only(png_structrp png_ptr, const png_size_t row_bytes) +{ + png_bytep rp, dp, pp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < row_bytes; + i++, rp++, pp++, dp++) + { + *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); + } +} + +static png_size_t /* PRIVATE */ +png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes, const png_size_t lmins) +{ + png_bytep rp, dp, pp, lp; + png_uint_32 i; + png_size_t sum = 0; + unsigned int v; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < bpp; i++) + { + v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); + +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else + sum += (v < 128) ? v : 256 - v; +#endif + } + + for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) + { + v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) + & 0xff); + +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else + sum += (v < 128) ? v : 256 - v; +#endif + + if (sum > lmins) /* We are already worse, don't continue. */ + break; + } + + return (sum); +} +static void /* PRIVATE */ +png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, pp, lp; + png_uint_32 i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < bpp; i++) + { + *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); + } + + for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) + { + *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) + & 0xff); + } +} + +static png_size_t /* PRIVATE */ +png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes, const png_size_t lmins) +{ + png_bytep rp, dp, pp, cp, lp; + png_size_t i; + png_size_t sum = 0; + unsigned int v; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < bpp; i++) + { + v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); + +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else + sum += (v < 128) ? v : 256 - v; +#endif + } + + for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; + i++) + { + int a, b, c, pa, pb, pc, p; + + b = *pp++; + c = *cp++; + a = *lp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); + +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else + sum += (v < 128) ? v : 256 - v; +#endif + + if (sum > lmins) /* We are already worse, don't continue. */ + break; + } + + return (sum); +} +static void /* PRIVATE */ +png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, pp, cp, lp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < bpp; i++) + { + *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); + } + + for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; + i++) + { + int a, b, c, pa, pb, pc, p; + + b = *pp++; + c = *cp++; + a = *lp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); + } +} +#endif /* WRITE_FILTER */ + +void /* PRIVATE */ +png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) +{ +#ifndef PNG_WRITE_FILTER_SUPPORTED + png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1); +#else + unsigned int filter_to_do = png_ptr->do_filter; + png_bytep row_buf; + png_bytep best_row; + png_uint_32 bpp; + png_size_t mins; + png_size_t row_bytes = row_info->rowbytes; + + png_debug(1, "in png_write_find_filter"); + + /* Find out how many bytes offset each pixel is */ + bpp = (row_info->pixel_depth + 7) >> 3; + + row_buf = png_ptr->row_buf; + mins = PNG_SIZE_MAX - 256/* so we can detect potential overflow of the + running sum */; + + /* The prediction method we use is to find which method provides the + * smallest value when summing the absolute values of the distances + * from zero, using anything >= 128 as negative numbers. This is known + * as the "minimum sum of absolute differences" heuristic. Other + * heuristics are the "weighted minimum sum of absolute differences" + * (experimental and can in theory improve compression), and the "zlib + * predictive" method (not implemented yet), which does test compressions + * of lines using different filter methods, and then chooses the + * (series of) filter(s) that give minimum compressed data size (VERY + * computationally expensive). + * + * GRR 980525: consider also + * + * (1) minimum sum of absolute differences from running average (i.e., + * keep running sum of non-absolute differences & count of bytes) + * [track dispersion, too? restart average if dispersion too large?] + * + * (1b) minimum sum of absolute differences from sliding average, probably + * with window size <= deflate window (usually 32K) + * + * (2) minimum sum of squared differences from zero or running average + * (i.e., ~ root-mean-square approach) + */ + + + /* We don't need to test the 'no filter' case if this is the only filter + * that has been chosen, as it doesn't actually do anything to the data. + */ + best_row = png_ptr->row_buf; + + if (PNG_SIZE_MAX/128 <= row_bytes) + { + /* Overflow can occur in the calculation, just select the lowest set + * filter. + */ + filter_to_do &= 0U-filter_to_do; + } + else if ((filter_to_do & PNG_FILTER_NONE) != 0 && + filter_to_do != PNG_FILTER_NONE) + { + /* Overflow not possible and multiple filters in the list, including the + * 'none' filter. + */ + png_bytep rp; + png_size_t sum = 0; + png_size_t i; + unsigned int v; + + { + for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) + { + v = *rp; +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else + sum += (v < 128) ? v : 256 - v; +#endif + } + } + + mins = sum; + } + + /* Sub filter */ + if (filter_to_do == PNG_FILTER_SUB) + /* It's the only filter so no testing is needed */ + { + png_setup_sub_row_only(png_ptr, bpp, row_bytes); + best_row = png_ptr->try_row; + } + + else if ((filter_to_do & PNG_FILTER_SUB) != 0) + { + png_size_t sum; + png_size_t lmins = mins; + + sum = png_setup_sub_row(png_ptr, bpp, row_bytes, lmins); + + if (sum < mins) + { + mins = sum; + best_row = png_ptr->try_row; + if (png_ptr->tst_row != NULL) + { + png_ptr->try_row = png_ptr->tst_row; + png_ptr->tst_row = best_row; + } + } + } + + /* Up filter */ + if (filter_to_do == PNG_FILTER_UP) + { + png_setup_up_row_only(png_ptr, row_bytes); + best_row = png_ptr->try_row; + } + + else if ((filter_to_do & PNG_FILTER_UP) != 0) + { + png_size_t sum; + png_size_t lmins = mins; + + sum = png_setup_up_row(png_ptr, row_bytes, lmins); + + if (sum < mins) + { + mins = sum; + best_row = png_ptr->try_row; + if (png_ptr->tst_row != NULL) + { + png_ptr->try_row = png_ptr->tst_row; + png_ptr->tst_row = best_row; + } + } + } + + /* Avg filter */ + if (filter_to_do == PNG_FILTER_AVG) + { + png_setup_avg_row_only(png_ptr, bpp, row_bytes); + best_row = png_ptr->try_row; + } + + else if ((filter_to_do & PNG_FILTER_AVG) != 0) + { + png_size_t sum; + png_size_t lmins = mins; + + sum= png_setup_avg_row(png_ptr, bpp, row_bytes, lmins); + + if (sum < mins) + { + mins = sum; + best_row = png_ptr->try_row; + if (png_ptr->tst_row != NULL) + { + png_ptr->try_row = png_ptr->tst_row; + png_ptr->tst_row = best_row; + } + } + } + + /* Paeth filter */ + if (filter_to_do == PNG_FILTER_PAETH) + { + png_setup_paeth_row_only(png_ptr, bpp, row_bytes); + best_row = png_ptr->try_row; + } + + else if ((filter_to_do & PNG_FILTER_PAETH) != 0) + { + png_size_t sum; + png_size_t lmins = mins; + + sum = png_setup_paeth_row(png_ptr, bpp, row_bytes, lmins); + + if (sum < mins) + { + best_row = png_ptr->try_row; + if (png_ptr->tst_row != NULL) + { + png_ptr->try_row = png_ptr->tst_row; + png_ptr->tst_row = best_row; + } + } + } + + /* Do the actual writing of the filtered row data from the chosen filter. */ + png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1); + +#endif /* WRITE_FILTER */ +} + + +/* Do the actual writing of a previously filtered row. */ +static void +png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, + png_size_t full_row_length/*includes filter byte*/) +{ + png_debug(1, "in png_write_filtered_row"); + + png_debug1(2, "filter = %d", filtered_row[0]); + + png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH); + +#ifdef PNG_WRITE_FILTER_SUPPORTED + /* Swap the current and previous rows */ + if (png_ptr->prev_row != NULL) + { + png_bytep tptr; + + tptr = png_ptr->prev_row; + png_ptr->prev_row = png_ptr->row_buf; + png_ptr->row_buf = tptr; + } +#endif /* WRITE_FILTER */ + + /* Finish row - updates counters and flushes zlib if last row */ + png_write_finish_row(png_ptr); + +#ifdef PNG_WRITE_FLUSH_SUPPORTED + png_ptr->flush_rows++; + + if (png_ptr->flush_dist > 0 && + png_ptr->flush_rows >= png_ptr->flush_dist) + { + png_write_flush(png_ptr); + } +#endif /* WRITE_FLUSH */ +} +#endif /* WRITE */ diff --git a/xs/src/png/libpng/scripts/genchk.cmake.in b/xs/src/png/libpng/scripts/genchk.cmake.in new file mode 100644 index 0000000000..ab3b9d7469 --- /dev/null +++ b/xs/src/png/libpng/scripts/genchk.cmake.in @@ -0,0 +1,37 @@ +# genchk.cmake.in +# Generate .chk from .out with awk (generic), based upon the automake logic. + +# Copyright (C) 2016 Glenn Randers-Pehrson +# Written by Roger Leigh, 2016 + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# Variables substituted from CMakeLists.txt +set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@") + +set(AWK "@AWK@") + +get_filename_component(INPUTEXT "${INPUT}" EXT) +get_filename_component(OUTPUTEXT "${OUTPUT}" EXT) +get_filename_component(INPUTBASE "${INPUT}" NAME_WE) +get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE) +get_filename_component(INPUTDIR "${INPUT}" PATH) +get_filename_component(OUTPUTDIR "${OUTPUT}" PATH) + +if("${INPUTEXT}" STREQUAL ".out" AND "${OUTPUTEXT}" STREQUAL ".chk") + # Generate .chk from .out with awk (generic) + file(REMOVE "${OUTPUT}" "${OUTPUTDIR}/${OUTPUTBASE}.new") + execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/checksym.awk" + "${SRCDIR}/scripts/${INPUTBASE}.def" + "of=${OUTPUTDIR}/${OUTPUTBASE}.new" + "${INPUT}" + RESULT_VARIABLE AWK_FAIL) + if(AWK_FAIL) + message(FATAL_ERROR "Failed to generate ${OUTPUTDIR}/${OUTPUTBASE}.new") + endif() + file(RENAME "${OUTPUTDIR}/${OUTPUTBASE}.new" "${OUTPUT}") +else() + message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}") +endif() diff --git a/xs/src/png/libpng/scripts/genout.cmake.in b/xs/src/png/libpng/scripts/genout.cmake.in new file mode 100644 index 0000000000..01f12de2fc --- /dev/null +++ b/xs/src/png/libpng/scripts/genout.cmake.in @@ -0,0 +1,93 @@ +# genout.cmake.in +# Generate .out from .c with awk (generic), based upon the automake logic. + +# Copyright (C) 2016 Glenn Randers-Pehrson +# Written by Roger Leigh, 2016 + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# Variables substituted from CMakeLists.txt +set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@") +set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@") + +set(AWK "@AWK@") +set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") +set(CMAKE_C_FLAGS @CMAKE_C_FLAGS@) +set(INCDIR "@CMAKE_CURRENT_BINARY_DIR@") +set(PNG_PREFIX "@PNG_PREFIX@") +set(PNGLIB_MAJOR "@PNGLIB_MAJOR@") +set(PNGLIB_MINOR "@PNGLIB_MINOR@") +set(PNGLIB_VERSION "@PNGLIB_VERSION@") +set(ZLIBINCDIR "@ZLIB_INCLUDE_DIR@") + +set(PLATFORM_C_FLAGS) +if(APPLE) + set(CMAKE_OSX_ARCHITECTURES "@CMAKE_OSX_ARCHITECTURES@") + set(CMAKE_OSX_SYSROOT "@CMAKE_OSX_SYSROOT@") + if(CMAKE_OSX_ARCHITECTURES) + set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}) + endif() + if(CMAKE_OSX_SYSROOT) + set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}) + endif() +endif() + +get_filename_component(INPUTEXT "${INPUT}" EXT) +get_filename_component(OUTPUTEXT "${OUTPUT}" EXT) +get_filename_component(INPUTBASE "${INPUT}" NAME_WE) +get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE) +get_filename_component(INPUTDIR "${INPUT}" PATH) +get_filename_component(OUTPUTDIR "${OUTPUT}" PATH) + +if ("${INPUTEXT}" STREQUAL ".c" AND "${OUTPUTEXT}" STREQUAL ".out") + get_filename_component(GENDIR "${OUTPUT}" PATH) + file(MAKE_DIRECTORY "${GENDIR}") + + file(REMOVE "${OUTPUT}.tf1" "${OUTPUT}.tf2") + + set(INCLUDES "-I${INCDIR}") + if(ZLIBINCDIR) + foreach(dir ${ZLIBINCDIR}) + list(APPEND INCLUDES "-I${dir}") + endforeach() + endif() + + if(PNG_PREFIX) + set(PNG_PREFIX_DEF "-DPNG_PREFIX=${PNG_PREFIX}") + endif() + + execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" + ${CMAKE_C_FLAGS} + ${PLATFORM_C_FLAGS} + "-I${SRCDIR}" + "-I${BINDIR}" + ${INCLUDES} + "-DPNGLIB_LIBNAME=PNG${PNGLIB_MAJOR}${PNGLIB_MINOR}_0" + "-DPNGLIB_VERSION=${PNGLIB_VERSION}" + "-DSYMBOL_PREFIX=${SYMBOL_PREFIX}" + "-DPNG_NO_USE_READ_MACROS" + "-DPNG_BUILDING_SYMBOL_TABLE" + ${PNG_PREFIX_DEF} + "${INPUT}" + OUTPUT_FILE "${OUTPUT}.tf1" + WORKING_DIRECTORY "${BINDIR}" + RESULT_VARIABLE CPP_FAIL) + if(CPP_FAIL) + message(FATAL_ERROR "Failed to generate ${OUTPUT}.tf1") + endif() + + execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/dfn.awk" + "out=${OUTPUT}.tf2" "${OUTPUT}.tf1" + WORKING_DIRECTORY "${BINDIR}" + RESULT_VARIABLE AWK_FAIL) + if(AWK_FAIL) + message(FATAL_ERROR "Failed to generate ${OUTPUT}.tf2") + endif() + + file(REMOVE "${OUTPUT}.tf1") + file(RENAME "${OUTPUT}.tf2" "${OUTPUT}") +else() + message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}") +endif() diff --git a/xs/src/png/libpng/scripts/gensrc.cmake.in b/xs/src/png/libpng/scripts/gensrc.cmake.in new file mode 100644 index 0000000000..f28a622662 --- /dev/null +++ b/xs/src/png/libpng/scripts/gensrc.cmake.in @@ -0,0 +1,138 @@ +# gensrc.cmake.in +# Generate source files with awk, based upon the automake logic. + +# Copyright (C) 2016 Glenn Randers-Pehrson +# Written by Roger Leigh, 2016 + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# Variables substituted from CMakeLists.txt +set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@") +set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@") + +set(AWK "@AWK@") +set(DFA_XTRA "@DFA_XTRA@") +set(PNG_PREFIX "@PNG_PREFIX@") +set(PNGLIB_VERSION "@PNGLIB_VERSION@") + +if("${OUTPUT}" STREQUAL "scripts/pnglibconf.c") + # Generate scripts/pnglibconf.c + + file(REMOVE "${BINDIR}/pnglibconf.tf6" "${BINDIR}/pnglibconf.tf7") + + execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "com ${PNGLIB_VERSION} STANDARD API DEFINITION" + COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk" + "out=pnglibconf.tf6" "logunsupported=1" "version=search" + "${SRCDIR}/pngconf.h" "-" + "${SRCDIR}/scripts/pnglibconf.dfa" + WORKING_DIRECTORY "${BINDIR}" + RESULT_VARIABLE AWK_FAIL) + if(AWK_FAIL) + message(FATAL_ERROR "Failed to generate pnglibconf.tf6") + endif() + + execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk" + "out=pnglibconf.tf7" "pnglibconf.tf6" + WORKING_DIRECTORY "${BINDIR}" + RESULT_VARIABLE AWK_FAIL) + if(AWK_FAIL) + message(FATAL_ERROR "Failed to generate pnglibconf.tf7") + endif() + + file(REMOVE "pnglibconf.tf6") + file(MAKE_DIRECTORY "${BINDIR}/scripts") + file(RENAME "pnglibconf.tf7" "${BINDIR}/scripts/pnglibconf.c") + +elseif ("${OUTPUT}" STREQUAL "pnglibconf.c") + # Generate pnglibconf.c + + file(REMOVE "${BINDIR}/pnglibconf.tf4" "${BINDIR}/pnglibconf.tf5") + + execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk" + out=pnglibconf.tf4 version=search + ${SRCDIR}/pngconf.h ${SRCDIR}/scripts/pnglibconf.dfa + ${SRCDIR}/pngusr.dfa ${DFA_XTRA} + WORKING_DIRECTORY "${BINDIR}" + RESULT_VARIABLE AWK_FAIL) + if(AWK_FAIL) + message(FATAL_ERROR "Failed to generate pnglibconf.tf4") + endif() + + execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk" + out=pnglibconf.tf5 pnglibconf.tf4 + WORKING_DIRECTORY "${BINDIR}" + RESULT_VARIABLE AWK_FAIL) + if(AWK_FAIL) + message(FATAL_ERROR "Failed to generate pnglibconf.tf5") + endif() + + file(REMOVE "pnglibconf.tf4") + file(MAKE_DIRECTORY "${BINDIR}/scripts") + file(RENAME "pnglibconf.tf5" "${BINDIR}/pnglibconf.c") + +elseif ("${OUTPUT}" STREQUAL "pnglibconf.h") + # Generate pnglibconf.h + + file(REMOVE "${BINDIR}/${OUTPUT}") + if(PNG_PREFIX) + file(REMOVE "pnglibconf.tf8") + + execute_process(COMMAND "${AWK}" "s==0 && NR>1{print prev} + s==0{prev=\$0} + s==1{print \"#define\", \$1, \"${PNG_PREFIX}\" \$1} + s==2{print \"#define ${PNG_PREFIX}png_\" \$1, \"PNG_\" \$1} + END{print prev}" s=0 pnglibconf.out s=1 "${BINDIR}/scripts/prefix.out" + s=2 "${SRCDIR}/scripts/macro.lst" + OUTPUT_FILE pnglibconf.tf8 + RESULT_VARIABLE AWK_FAIL) + if(AWK_FAIL) + message(FATAL_ERROR "Failed to generate pnglibconf.tf8") + endif() + + file(RENAME "pnglibconf.tf8" "${BINDIR}/${OUTPUT}") + else() + execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${BINDIR}/pnglibconf.out" + "${BINDIR}/${OUTPUT}" + RESULT_VARIABLE COPY_FAIL) + if(COPY_FAIL) + message(FATAL_ERROR "Failed to create pnglibconf.h") + endif() + endif() + +elseif ("${OUTPUT}" STREQUAL "pngprefix.h") + # Generate pngprefix.h + + file(REMOVE "${BINDIR}/${OUTPUT}") + + if(PNG_PREFIX) + file(REMOVE "pngprefix.tf1") + + execute_process(COMMAND "${AWK}" + "{print \"#define\", \$1, \"${PNG_PREFIX}\" \$1}" + "${BINDIR}/scripts/intprefix.out" + OUTPUT_FILE "pngprefix.tf1" + RESULT_VARIABLE AWK_FAIL) + if(AWK_FAIL) + message(FATAL_ERROR "Failed to generate pngprefix.tf1") + endif() + + file(RENAME "pngprefix.tf1" "${BINDIR}/${OUTPUT}") + else() + file(WRITE "${BINDIR}/${OUTPUT}" "/* No libpng symbol prefix configured. */") + endif() + +elseif("${OUTPUT}" STREQUAL "scripts/pnglibconf.h.prebuilt") + # Generate scripts/pnglibconf.h.prebuilt (fails build) + + message(STATUS "Attempting to build scripts/pnglibconf.h.prebuilt") + message(STATUS "This is a machine generated file, but if you want to make") + message(STATUS "a new one simply build the 'genfiles' target, and copy") + message(STATUS "scripts/pnglibconf.out to scripts/pnglibconf.h.prebuilt") + message(STATUS "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)") + message(FATAL_ERROR "Stopping build") + +else() + message(FATAL_ERROR "Unsupported output: ${OUTPUT}") +endif() diff --git a/xs/src/png/libpng/scripts/libpng-config-body.in b/xs/src/png/libpng/scripts/libpng-config-body.in new file mode 100644 index 0000000000..b466432d54 --- /dev/null +++ b/xs/src/png/libpng/scripts/libpng-config-body.in @@ -0,0 +1,96 @@ + +usage() +{ + cat <

%dT8#&n9#M4$?9@Y?VN*Gm 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. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs b/xs/src/png/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs new file mode 100644 index 0000000000..b110dae6a1 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs @@ -0,0 +1,202 @@ +// +// © Copyright Henrik Ravn 2004 +// +// Use, modification and distribution are subject to the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +using System; +using System.Runtime.InteropServices; +using System.Text; + + +namespace DotZLib +{ + #region ChecksumGeneratorBase + ///

+ /// Implements the common functionality needed for all s + /// + /// + public abstract class ChecksumGeneratorBase : ChecksumGenerator + { + /// + /// The value of the current checksum + /// + protected uint _current; + + /// + /// Initializes a new instance of the checksum generator base - the current checksum is + /// set to zero + /// + public ChecksumGeneratorBase() + { + _current = 0; + } + + /// + /// Initializes a new instance of the checksum generator basewith a specified value + /// + /// The value to set the current checksum to + public ChecksumGeneratorBase(uint initialValue) + { + _current = initialValue; + } + + /// + /// Resets the current checksum to zero + /// + public void Reset() { _current = 0; } + + /// + /// Gets the current checksum value + /// + public uint Value { get { return _current; } } + + /// + /// Updates the current checksum with part of an array of bytes + /// + /// The data to update the checksum with + /// Where in data to start updating + /// The number of bytes from data to use + /// The sum of offset and count is larger than the length of data + /// data is a null reference + /// Offset or count is negative. + /// All the other Update methods are implmeneted in terms of this one. + /// This is therefore the only method a derived class has to implement + public abstract void Update(byte[] data, int offset, int count); + + /// + /// Updates the current checksum with an array of bytes. + /// + /// The data to update the checksum with + public void Update(byte[] data) + { + Update(data, 0, data.Length); + } + + /// + /// Updates the current checksum with the data from a string + /// + /// The string to update the checksum with + /// The characters in the string are converted by the UTF-8 encoding + public void Update(string data) + { + Update(Encoding.UTF8.GetBytes(data)); + } + + /// + /// Updates the current checksum with the data from a string, using a specific encoding + /// + /// The string to update the checksum with + /// The encoding to use + public void Update(string data, Encoding encoding) + { + Update(encoding.GetBytes(data)); + } + + } + #endregion + + #region CRC32 + /// + /// Implements a CRC32 checksum generator + /// + public sealed class CRC32Checksum : ChecksumGeneratorBase + { + #region DLL imports + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern uint crc32(uint crc, int data, uint length); + + #endregion + + /// + /// Initializes a new instance of the CRC32 checksum generator + /// + public CRC32Checksum() : base() {} + + /// + /// Initializes a new instance of the CRC32 checksum generator with a specified value + /// + /// The value to set the current checksum to + public CRC32Checksum(uint initialValue) : base(initialValue) {} + + /// + /// Updates the current checksum with part of an array of bytes + /// + /// The data to update the checksum with + /// Where in data to start updating + /// The number of bytes from data to use + /// The sum of offset and count is larger than the length of data + /// data is a null reference + /// Offset or count is negative. + public override void Update(byte[] data, int offset, int count) + { + if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); + if ((offset+count) > data.Length) throw new ArgumentException(); + GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned); + try + { + _current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count); + } + finally + { + hData.Free(); + } + } + + } + #endregion + + #region Adler + /// + /// Implements a checksum generator that computes the Adler checksum on data + /// + public sealed class AdlerChecksum : ChecksumGeneratorBase + { + #region DLL imports + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern uint adler32(uint adler, int data, uint length); + + #endregion + + /// + /// Initializes a new instance of the Adler checksum generator + /// + public AdlerChecksum() : base() {} + + /// + /// Initializes a new instance of the Adler checksum generator with a specified value + /// + /// The value to set the current checksum to + public AdlerChecksum(uint initialValue) : base(initialValue) {} + + /// + /// Updates the current checksum with part of an array of bytes + /// + /// The data to update the checksum with + /// Where in data to start updating + /// The number of bytes from data to use + /// The sum of offset and count is larger than the length of data + /// data is a null reference + /// Offset or count is negative. + public override void Update(byte[] data, int offset, int count) + { + if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); + if ((offset+count) > data.Length) throw new ArgumentException(); + GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned); + try + { + _current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count); + } + finally + { + hData.Free(); + } + } + + } + #endregion + +} \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs b/xs/src/png/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs new file mode 100644 index 0000000000..9c8d601954 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs @@ -0,0 +1,83 @@ +// +// © Copyright Henrik Ravn 2004 +// +// Use, modification and distribution are subject to the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +using System; +using System.Diagnostics; + +namespace DotZLib +{ + + /// + /// This class implements a circular buffer + /// + internal class CircularBuffer + { + #region Private data + private int _capacity; + private int _head; + private int _tail; + private int _size; + private byte[] _buffer; + #endregion + + public CircularBuffer(int capacity) + { + Debug.Assert( capacity > 0 ); + _buffer = new byte[capacity]; + _capacity = capacity; + _head = 0; + _tail = 0; + _size = 0; + } + + public int Size { get { return _size; } } + + public int Put(byte[] source, int offset, int count) + { + Debug.Assert( count > 0 ); + int trueCount = Math.Min(count, _capacity - Size); + for (int i = 0; i < trueCount; ++i) + _buffer[(_tail+i) % _capacity] = source[offset+i]; + _tail += trueCount; + _tail %= _capacity; + _size += trueCount; + return trueCount; + } + + public bool Put(byte b) + { + if (Size == _capacity) // no room + return false; + _buffer[_tail++] = b; + _tail %= _capacity; + ++_size; + return true; + } + + public int Get(byte[] destination, int offset, int count) + { + int trueCount = Math.Min(count,Size); + for (int i = 0; i < trueCount; ++i) + destination[offset + i] = _buffer[(_head+i) % _capacity]; + _head += trueCount; + _head %= _capacity; + _size -= trueCount; + return trueCount; + } + + public int Get() + { + if (Size == 0) + return -1; + + int result = (int)_buffer[_head++ % _capacity]; + --_size; + return result; + } + + } +} diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/CodecBase.cs b/xs/src/png/zlib/contrib/dotzlib/DotZLib/CodecBase.cs new file mode 100644 index 0000000000..b0eb78a022 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/CodecBase.cs @@ -0,0 +1,198 @@ +// +// © Copyright Henrik Ravn 2004 +// +// Use, modification and distribution are subject to the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +using System; +using System.Runtime.InteropServices; + +namespace DotZLib +{ + /// + /// Implements the common functionality needed for all s + /// + public abstract class CodecBase : Codec, IDisposable + { + + #region Data members + + /// + /// Instance of the internal zlib buffer structure that is + /// passed to all functions in the zlib dll + /// + internal ZStream _ztream = new ZStream(); + + /// + /// True if the object instance has been disposed, false otherwise + /// + protected bool _isDisposed = false; + + /// + /// The size of the internal buffers + /// + protected const int kBufferSize = 16384; + + private byte[] _outBuffer = new byte[kBufferSize]; + private byte[] _inBuffer = new byte[kBufferSize]; + + private GCHandle _hInput; + private GCHandle _hOutput; + + private uint _checksum = 0; + + #endregion + + /// + /// Initializes a new instance of the CodeBase class. + /// + public CodecBase() + { + try + { + _hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned); + _hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned); + } + catch (Exception) + { + CleanUp(false); + throw; + } + } + + + #region Codec Members + + /// + /// Occurs when more processed data are available. + /// + public event DataAvailableHandler DataAvailable; + + /// + /// Fires the event + /// + protected void OnDataAvailable() + { + if (_ztream.total_out > 0) + { + if (DataAvailable != null) + DataAvailable( _outBuffer, 0, (int)_ztream.total_out); + resetOutput(); + } + } + + /// + /// Adds more data to the codec to be processed. + /// + /// Byte array containing the data to be added to the codec + /// Adding data may, or may not, raise the DataAvailable event + public void Add(byte[] data) + { + Add(data,0,data.Length); + } + + /// + /// Adds more data to the codec to be processed. + /// + /// Byte array containing the data to be added to the codec + /// The index of the first byte to add from data + /// The number of bytes to add + /// Adding data may, or may not, raise the DataAvailable event + /// This must be implemented by a derived class + public abstract void Add(byte[] data, int offset, int count); + + /// + /// Finishes up any pending data that needs to be processed and handled. + /// + /// This must be implemented by a derived class + public abstract void Finish(); + + /// + /// Gets the checksum of the data that has been added so far + /// + public uint Checksum { get { return _checksum; } } + + #endregion + + #region Destructor & IDisposable stuff + + /// + /// Destroys this instance + /// + ~CodecBase() + { + CleanUp(false); + } + + /// + /// Releases any unmanaged resources and calls the method of the derived class + /// + public void Dispose() + { + CleanUp(true); + } + + /// + /// Performs any codec specific cleanup + /// + /// This must be implemented by a derived class + protected abstract void CleanUp(); + + // performs the release of the handles and calls the dereived CleanUp() + private void CleanUp(bool isDisposing) + { + if (!_isDisposed) + { + CleanUp(); + if (_hInput.IsAllocated) + _hInput.Free(); + if (_hOutput.IsAllocated) + _hOutput.Free(); + + _isDisposed = true; + } + } + + + #endregion + + #region Helper methods + + /// + /// Copies a number of bytes to the internal codec buffer - ready for proccesing + /// + /// The byte array that contains the data to copy + /// The index of the first byte to copy + /// The number of bytes to copy from data + protected void copyInput(byte[] data, int startIndex, int count) + { + Array.Copy(data, startIndex, _inBuffer,0, count); + _ztream.next_in = _hInput.AddrOfPinnedObject(); + _ztream.total_in = 0; + _ztream.avail_in = (uint)count; + + } + + /// + /// Resets the internal output buffers to a known state - ready for processing + /// + protected void resetOutput() + { + _ztream.total_out = 0; + _ztream.avail_out = kBufferSize; + _ztream.next_out = _hOutput.AddrOfPinnedObject(); + } + + /// + /// Updates the running checksum property + /// + /// The new checksum value + protected void setChecksum(uint newSum) + { + _checksum = newSum; + } + #endregion + + } +} diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/Deflater.cs b/xs/src/png/zlib/contrib/dotzlib/DotZLib/Deflater.cs new file mode 100644 index 0000000000..9039f41f66 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/Deflater.cs @@ -0,0 +1,106 @@ +// +// © Copyright Henrik Ravn 2004 +// +// Use, modification and distribution are subject to the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace DotZLib +{ + + /// + /// Implements a data compressor, using the deflate algorithm in the ZLib dll + /// + public sealed class Deflater : CodecBase + { + #region Dll imports + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] + private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int deflate(ref ZStream sz, int flush); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int deflateReset(ref ZStream sz); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int deflateEnd(ref ZStream sz); + #endregion + + /// + /// Constructs an new instance of the Deflater + /// + /// The compression level to use for this Deflater + public Deflater(CompressLevel level) : base() + { + int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream)); + if (retval != 0) + throw new ZLibException(retval, "Could not initialize deflater"); + + resetOutput(); + } + + /// + /// Adds more data to the codec to be processed. + /// + /// Byte array containing the data to be added to the codec + /// The index of the first byte to add from data + /// The number of bytes to add + /// Adding data may, or may not, raise the DataAvailable event + public override void Add(byte[] data, int offset, int count) + { + if (data == null) throw new ArgumentNullException(); + if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); + if ((offset+count) > data.Length) throw new ArgumentException(); + + int total = count; + int inputIndex = offset; + int err = 0; + + while (err >= 0 && inputIndex < total) + { + copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize)); + while (err >= 0 && _ztream.avail_in > 0) + { + err = deflate(ref _ztream, (int)FlushTypes.None); + if (err == 0) + while (_ztream.avail_out == 0) + { + OnDataAvailable(); + err = deflate(ref _ztream, (int)FlushTypes.None); + } + inputIndex += (int)_ztream.total_in; + } + } + setChecksum( _ztream.adler ); + } + + + /// + /// Finishes up any pending data that needs to be processed and handled. + /// + public override void Finish() + { + int err; + do + { + err = deflate(ref _ztream, (int)FlushTypes.Finish); + OnDataAvailable(); + } + while (err == 0); + setChecksum( _ztream.adler ); + deflateReset(ref _ztream); + resetOutput(); + } + + /// + /// Closes the internal zlib deflate stream + /// + protected override void CleanUp() { deflateEnd(ref _ztream); } + + } +} diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/DotZLib.cs b/xs/src/png/zlib/contrib/dotzlib/DotZLib/DotZLib.cs new file mode 100644 index 0000000000..90c7c3b380 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/DotZLib.cs @@ -0,0 +1,288 @@ +// +// © Copyright Henrik Ravn 2004 +// +// Use, modification and distribution are subject to the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; + + +namespace DotZLib +{ + + #region Internal types + + /// + /// Defines constants for the various flush types used with zlib + /// + internal enum FlushTypes + { + None, Partial, Sync, Full, Finish, Block + } + + #region ZStream structure + // internal mapping of the zlib zstream structure for marshalling + [StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)] + internal struct ZStream + { + public IntPtr next_in; + public uint avail_in; + public uint total_in; + + public IntPtr next_out; + public uint avail_out; + public uint total_out; + + [MarshalAs(UnmanagedType.LPStr)] + string msg; + uint state; + + uint zalloc; + uint zfree; + uint opaque; + + int data_type; + public uint adler; + uint reserved; + } + + #endregion + + #endregion + + #region Public enums + /// + /// Defines constants for the available compression levels in zlib + /// + public enum CompressLevel : int + { + /// + /// The default compression level with a reasonable compromise between compression and speed + /// + Default = -1, + /// + /// No compression at all. The data are passed straight through. + /// + None = 0, + /// + /// The maximum compression rate available. + /// + Best = 9, + /// + /// The fastest available compression level. + /// + Fastest = 1 + } + #endregion + + #region Exception classes + /// + /// The exception that is thrown when an error occurs on the zlib dll + /// + public class ZLibException : ApplicationException + { + /// + /// Initializes a new instance of the class with a specified + /// error message and error code + /// + /// The zlib error code that caused the exception + /// A message that (hopefully) describes the error + public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg)) + { + } + + /// + /// Initializes a new instance of the class with a specified + /// error code + /// + /// The zlib error code that caused the exception + public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode)) + { + } + } + #endregion + + #region Interfaces + + /// + /// Declares methods and properties that enables a running checksum to be calculated + /// + public interface ChecksumGenerator + { + /// + /// Gets the current value of the checksum + /// + uint Value { get; } + + /// + /// Clears the current checksum to 0 + /// + void Reset(); + + /// + /// Updates the current checksum with an array of bytes + /// + /// The data to update the checksum with + void Update(byte[] data); + + /// + /// Updates the current checksum with part of an array of bytes + /// + /// The data to update the checksum with + /// Where in data to start updating + /// The number of bytes from data to use + /// The sum of offset and count is larger than the length of data + /// data is a null reference + /// Offset or count is negative. + void Update(byte[] data, int offset, int count); + + /// + /// Updates the current checksum with the data from a string + /// + /// The string to update the checksum with + /// The characters in the string are converted by the UTF-8 encoding + void Update(string data); + + /// + /// Updates the current checksum with the data from a string, using a specific encoding + /// + /// The string to update the checksum with + /// The encoding to use + void Update(string data, Encoding encoding); + } + + + /// + /// Represents the method that will be called from a codec when new data + /// are available. + /// + /// The byte array containing the processed data + /// The index of the first processed byte in data + /// The number of processed bytes available + /// On return from this method, the data may be overwritten, so grab it while you can. + /// You cannot assume that startIndex will be zero. + /// + public delegate void DataAvailableHandler(byte[] data, int startIndex, int count); + + /// + /// Declares methods and events for implementing compressors/decompressors + /// + public interface Codec + { + /// + /// Occurs when more processed data are available. + /// + event DataAvailableHandler DataAvailable; + + /// + /// Adds more data to the codec to be processed. + /// + /// Byte array containing the data to be added to the codec + /// Adding data may, or may not, raise the DataAvailable event + void Add(byte[] data); + + /// + /// Adds more data to the codec to be processed. + /// + /// Byte array containing the data to be added to the codec + /// The index of the first byte to add from data + /// The number of bytes to add + /// Adding data may, or may not, raise the DataAvailable event + void Add(byte[] data, int offset, int count); + + /// + /// Finishes up any pending data that needs to be processed and handled. + /// + void Finish(); + + /// + /// Gets the checksum of the data that has been added so far + /// + uint Checksum { get; } + + + } + + #endregion + + #region Classes + /// + /// Encapsulates general information about the ZLib library + /// + public class Info + { + #region DLL imports + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern uint zlibCompileFlags(); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern string zlibVersion(); + #endregion + + #region Private stuff + private uint _flags; + + // helper function that unpacks a bitsize mask + private static int bitSize(uint bits) + { + switch (bits) + { + case 0: return 16; + case 1: return 32; + case 2: return 64; + } + return -1; + } + #endregion + + /// + /// Constructs an instance of the Info class. + /// + public Info() + { + _flags = zlibCompileFlags(); + } + + /// + /// True if the library is compiled with debug info + /// + public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } } + + /// + /// True if the library is compiled with assembly optimizations + /// + public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } } + + /// + /// Gets the size of the unsigned int that was compiled into Zlib + /// + public int SizeOfUInt { get { return bitSize(_flags & 3); } } + + /// + /// Gets the size of the unsigned long that was compiled into Zlib + /// + public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } } + + /// + /// Gets the size of the pointers that were compiled into Zlib + /// + public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } } + + /// + /// Gets the size of the z_off_t type that was compiled into Zlib + /// + public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } } + + /// + /// Gets the version of ZLib as a string, e.g. "1.2.1" + /// + public static string Version { get { return zlibVersion(); } } + } + + #endregion + +} diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj b/xs/src/png/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj new file mode 100644 index 0000000000..dea7fb16a9 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/GZipStream.cs b/xs/src/png/zlib/contrib/dotzlib/DotZLib/GZipStream.cs new file mode 100644 index 0000000000..f0eada1d24 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/GZipStream.cs @@ -0,0 +1,301 @@ +// +// © Copyright Henrik Ravn 2004 +// +// Use, modification and distribution are subject to the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace DotZLib +{ + /// + /// Implements a compressed , in GZip (.gz) format. + /// + public class GZipStream : Stream, IDisposable + { + #region Dll Imports + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] + private static extern IntPtr gzopen(string name, string mode); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int gzclose(IntPtr gzFile); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int gzwrite(IntPtr gzFile, int data, int length); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int gzread(IntPtr gzFile, int data, int length); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int gzgetc(IntPtr gzFile); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int gzputc(IntPtr gzFile, int c); + + #endregion + + #region Private data + private IntPtr _gzFile; + private bool _isDisposed = false; + private bool _isWriting; + #endregion + + #region Constructors + /// + /// Creates a new file as a writeable GZipStream + /// + /// The name of the compressed file to create + /// The compression level to use when adding data + /// If an error occurred in the internal zlib function + public GZipStream(string fileName, CompressLevel level) + { + _isWriting = true; + _gzFile = gzopen(fileName, String.Format("wb{0}", (int)level)); + if (_gzFile == IntPtr.Zero) + throw new ZLibException(-1, "Could not open " + fileName); + } + + /// + /// Opens an existing file as a readable GZipStream + /// + /// The name of the file to open + /// If an error occurred in the internal zlib function + public GZipStream(string fileName) + { + _isWriting = false; + _gzFile = gzopen(fileName, "rb"); + if (_gzFile == IntPtr.Zero) + throw new ZLibException(-1, "Could not open " + fileName); + + } + #endregion + + #region Access properties + /// + /// Returns true of this stream can be read from, false otherwise + /// + public override bool CanRead + { + get + { + return !_isWriting; + } + } + + + /// + /// Returns false. + /// + public override bool CanSeek + { + get + { + return false; + } + } + + /// + /// Returns true if this tsream is writeable, false otherwise + /// + public override bool CanWrite + { + get + { + return _isWriting; + } + } + #endregion + + #region Destructor & IDispose stuff + + /// + /// Destroys this instance + /// + ~GZipStream() + { + cleanUp(false); + } + + /// + /// Closes the external file handle + /// + public void Dispose() + { + cleanUp(true); + } + + // Does the actual closing of the file handle. + private void cleanUp(bool isDisposing) + { + if (!_isDisposed) + { + gzclose(_gzFile); + _isDisposed = true; + } + } + #endregion + + #region Basic reading and writing + /// + /// Attempts to read a number of bytes from the stream. + /// + /// The destination data buffer + /// The index of the first destination byte in buffer + /// The number of bytes requested + /// The number of bytes read + /// If buffer is null + /// If count or offset are negative + /// If offset + count is > buffer.Length + /// If this stream is not readable. + /// If this stream has been disposed. + public override int Read(byte[] buffer, int offset, int count) + { + if (!CanRead) throw new NotSupportedException(); + if (buffer == null) throw new ArgumentNullException(); + if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); + if ((offset+count) > buffer.Length) throw new ArgumentException(); + if (_isDisposed) throw new ObjectDisposedException("GZipStream"); + + GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned); + int result; + try + { + result = gzread(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count); + if (result < 0) + throw new IOException(); + } + finally + { + h.Free(); + } + return result; + } + + /// + /// Attempts to read a single byte from the stream. + /// + /// The byte that was read, or -1 in case of error or End-Of-File + public override int ReadByte() + { + if (!CanRead) throw new NotSupportedException(); + if (_isDisposed) throw new ObjectDisposedException("GZipStream"); + return gzgetc(_gzFile); + } + + /// + /// Writes a number of bytes to the stream + /// + /// + /// + /// + /// If buffer is null + /// If count or offset are negative + /// If offset + count is > buffer.Length + /// If this stream is not writeable. + /// If this stream has been disposed. + public override void Write(byte[] buffer, int offset, int count) + { + if (!CanWrite) throw new NotSupportedException(); + if (buffer == null) throw new ArgumentNullException(); + if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); + if ((offset+count) > buffer.Length) throw new ArgumentException(); + if (_isDisposed) throw new ObjectDisposedException("GZipStream"); + + GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned); + try + { + int result = gzwrite(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count); + if (result < 0) + throw new IOException(); + } + finally + { + h.Free(); + } + } + + /// + /// Writes a single byte to the stream + /// + /// The byte to add to the stream. + /// If this stream is not writeable. + /// If this stream has been disposed. + public override void WriteByte(byte value) + { + if (!CanWrite) throw new NotSupportedException(); + if (_isDisposed) throw new ObjectDisposedException("GZipStream"); + + int result = gzputc(_gzFile, (int)value); + if (result < 0) + throw new IOException(); + } + #endregion + + #region Position & length stuff + /// + /// Not supported. + /// + /// + /// Always thrown + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + /// + /// Not suppported. + /// + /// + /// + /// + /// Always thrown + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } + + /// + /// Flushes the GZipStream. + /// + /// In this implementation, this method does nothing. This is because excessive + /// flushing may degrade the achievable compression rates. + public override void Flush() + { + // left empty on purpose + } + + /// + /// Gets/sets the current position in the GZipStream. Not suppported. + /// + /// In this implementation this property is not supported + /// Always thrown + public override long Position + { + get + { + throw new NotSupportedException(); + } + set + { + throw new NotSupportedException(); + } + } + + /// + /// Gets the size of the stream. Not suppported. + /// + /// In this implementation this property is not supported + /// Always thrown + public override long Length + { + get + { + throw new NotSupportedException(); + } + } + #endregion + } +} diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/Inflater.cs b/xs/src/png/zlib/contrib/dotzlib/DotZLib/Inflater.cs new file mode 100644 index 0000000000..d295f26804 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/Inflater.cs @@ -0,0 +1,105 @@ +// +// © Copyright Henrik Ravn 2004 +// +// Use, modification and distribution are subject to the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace DotZLib +{ + + /// + /// Implements a data decompressor, using the inflate algorithm in the ZLib dll + /// + public class Inflater : CodecBase + { + #region Dll imports + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] + private static extern int inflateInit_(ref ZStream sz, string vs, int size); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int inflate(ref ZStream sz, int flush); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int inflateReset(ref ZStream sz); + + [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] + private static extern int inflateEnd(ref ZStream sz); + #endregion + + /// + /// Constructs an new instance of the Inflater + /// + public Inflater() : base() + { + int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream)); + if (retval != 0) + throw new ZLibException(retval, "Could not initialize inflater"); + + resetOutput(); + } + + + /// + /// Adds more data to the codec to be processed. + /// + /// Byte array containing the data to be added to the codec + /// The index of the first byte to add from data + /// The number of bytes to add + /// Adding data may, or may not, raise the DataAvailable event + public override void Add(byte[] data, int offset, int count) + { + if (data == null) throw new ArgumentNullException(); + if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); + if ((offset+count) > data.Length) throw new ArgumentException(); + + int total = count; + int inputIndex = offset; + int err = 0; + + while (err >= 0 && inputIndex < total) + { + copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize)); + err = inflate(ref _ztream, (int)FlushTypes.None); + if (err == 0) + while (_ztream.avail_out == 0) + { + OnDataAvailable(); + err = inflate(ref _ztream, (int)FlushTypes.None); + } + + inputIndex += (int)_ztream.total_in; + } + setChecksum( _ztream.adler ); + } + + + /// + /// Finishes up any pending data that needs to be processed and handled. + /// + public override void Finish() + { + int err; + do + { + err = inflate(ref _ztream, (int)FlushTypes.Finish); + OnDataAvailable(); + } + while (err == 0); + setChecksum( _ztream.adler ); + inflateReset(ref _ztream); + resetOutput(); + } + + /// + /// Closes the internal zlib inflate stream + /// + protected override void CleanUp() { inflateEnd(ref _ztream); } + + + } +} diff --git a/xs/src/png/zlib/contrib/dotzlib/DotZLib/UnitTests.cs b/xs/src/png/zlib/contrib/dotzlib/DotZLib/UnitTests.cs new file mode 100644 index 0000000000..6d8aebb799 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/DotZLib/UnitTests.cs @@ -0,0 +1,274 @@ +// +// © Copyright Henrik Ravn 2004 +// +// Use, modification and distribution are subject to the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +using System; +using System.Collections; +using System.IO; + +// uncomment the define below to include unit tests +//#define nunit +#if nunit +using NUnit.Framework; + +// Unit tests for the DotZLib class library +// ---------------------------------------- +// +// Use this with NUnit 2 from http://www.nunit.org +// + +namespace DotZLibTests +{ + using DotZLib; + + // helper methods + internal class Utils + { + public static bool byteArrEqual( byte[] lhs, byte[] rhs ) + { + if (lhs.Length != rhs.Length) + return false; + for (int i = lhs.Length-1; i >= 0; --i) + if (lhs[i] != rhs[i]) + return false; + return true; + } + + } + + + [TestFixture] + public class CircBufferTests + { + #region Circular buffer tests + [Test] + public void SinglePutGet() + { + CircularBuffer buf = new CircularBuffer(10); + Assert.AreEqual( 0, buf.Size ); + Assert.AreEqual( -1, buf.Get() ); + + Assert.IsTrue(buf.Put( 1 )); + Assert.AreEqual( 1, buf.Size ); + Assert.AreEqual( 1, buf.Get() ); + Assert.AreEqual( 0, buf.Size ); + Assert.AreEqual( -1, buf.Get() ); + } + + [Test] + public void BlockPutGet() + { + CircularBuffer buf = new CircularBuffer(10); + byte[] arr = {1,2,3,4,5,6,7,8,9,10}; + Assert.AreEqual( 10, buf.Put(arr,0,10) ); + Assert.AreEqual( 10, buf.Size ); + Assert.IsFalse( buf.Put(11) ); + Assert.AreEqual( 1, buf.Get() ); + Assert.IsTrue( buf.Put(11) ); + + byte[] arr2 = (byte[])arr.Clone(); + Assert.AreEqual( 9, buf.Get(arr2,1,9) ); + Assert.IsTrue( Utils.byteArrEqual(arr,arr2) ); + } + + #endregion + } + + [TestFixture] + public class ChecksumTests + { + #region CRC32 Tests + [Test] + public void CRC32_Null() + { + CRC32Checksum crc32 = new CRC32Checksum(); + Assert.AreEqual( 0, crc32.Value ); + + crc32 = new CRC32Checksum(1); + Assert.AreEqual( 1, crc32.Value ); + + crc32 = new CRC32Checksum(556); + Assert.AreEqual( 556, crc32.Value ); + } + + [Test] + public void CRC32_Data() + { + CRC32Checksum crc32 = new CRC32Checksum(); + byte[] data = { 1,2,3,4,5,6,7 }; + crc32.Update(data); + Assert.AreEqual( 0x70e46888, crc32.Value ); + + crc32 = new CRC32Checksum(); + crc32.Update("penguin"); + Assert.AreEqual( 0x0e5c1a120, crc32.Value ); + + crc32 = new CRC32Checksum(1); + crc32.Update("penguin"); + Assert.AreEqual(0x43b6aa94, crc32.Value); + + } + #endregion + + #region Adler tests + + [Test] + public void Adler_Null() + { + AdlerChecksum adler = new AdlerChecksum(); + Assert.AreEqual(0, adler.Value); + + adler = new AdlerChecksum(1); + Assert.AreEqual( 1, adler.Value ); + + adler = new AdlerChecksum(556); + Assert.AreEqual( 556, adler.Value ); + } + + [Test] + public void Adler_Data() + { + AdlerChecksum adler = new AdlerChecksum(1); + byte[] data = { 1,2,3,4,5,6,7 }; + adler.Update(data); + Assert.AreEqual( 0x5b001d, adler.Value ); + + adler = new AdlerChecksum(); + adler.Update("penguin"); + Assert.AreEqual(0x0bcf02f6, adler.Value ); + + adler = new AdlerChecksum(1); + adler.Update("penguin"); + Assert.AreEqual(0x0bd602f7, adler.Value); + + } + #endregion + } + + [TestFixture] + public class InfoTests + { + #region Info tests + [Test] + public void Info_Version() + { + Info info = new Info(); + Assert.AreEqual("1.2.11", Info.Version); + Assert.AreEqual(32, info.SizeOfUInt); + Assert.AreEqual(32, info.SizeOfULong); + Assert.AreEqual(32, info.SizeOfPointer); + Assert.AreEqual(32, info.SizeOfOffset); + } + #endregion + } + + [TestFixture] + public class DeflateInflateTests + { + #region Deflate tests + [Test] + public void Deflate_Init() + { + using (Deflater def = new Deflater(CompressLevel.Default)) + { + } + } + + private ArrayList compressedData = new ArrayList(); + private uint adler1; + + private ArrayList uncompressedData = new ArrayList(); + private uint adler2; + + public void CDataAvail(byte[] data, int startIndex, int count) + { + for (int i = 0; i < count; ++i) + compressedData.Add(data[i+startIndex]); + } + + [Test] + public void Deflate_Compress() + { + compressedData.Clear(); + + byte[] testData = new byte[35000]; + for (int i = 0; i < testData.Length; ++i) + testData[i] = 5; + + using (Deflater def = new Deflater((CompressLevel)5)) + { + def.DataAvailable += new DataAvailableHandler(CDataAvail); + def.Add(testData); + def.Finish(); + adler1 = def.Checksum; + } + } + #endregion + + #region Inflate tests + [Test] + public void Inflate_Init() + { + using (Inflater inf = new Inflater()) + { + } + } + + private void DDataAvail(byte[] data, int startIndex, int count) + { + for (int i = 0; i < count; ++i) + uncompressedData.Add(data[i+startIndex]); + } + + [Test] + public void Inflate_Expand() + { + uncompressedData.Clear(); + + using (Inflater inf = new Inflater()) + { + inf.DataAvailable += new DataAvailableHandler(DDataAvail); + inf.Add((byte[])compressedData.ToArray(typeof(byte))); + inf.Finish(); + adler2 = inf.Checksum; + } + Assert.AreEqual( adler1, adler2 ); + } + #endregion + } + + [TestFixture] + public class GZipStreamTests + { + #region GZipStream test + [Test] + public void GZipStream_WriteRead() + { + using (GZipStream gzOut = new GZipStream("gzstream.gz", CompressLevel.Best)) + { + BinaryWriter writer = new BinaryWriter(gzOut); + writer.Write("hi there"); + writer.Write(Math.PI); + writer.Write(42); + } + + using (GZipStream gzIn = new GZipStream("gzstream.gz")) + { + BinaryReader reader = new BinaryReader(gzIn); + string s = reader.ReadString(); + Assert.AreEqual("hi there",s); + double d = reader.ReadDouble(); + Assert.AreEqual(Math.PI, d); + int i = reader.ReadInt32(); + Assert.AreEqual(42,i); + } + + } + #endregion + } +} + +#endif diff --git a/xs/src/png/zlib/contrib/dotzlib/LICENSE_1_0.txt b/xs/src/png/zlib/contrib/dotzlib/LICENSE_1_0.txt new file mode 100644 index 0000000000..127a5bc39b --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/dotzlib/readme.txt b/xs/src/png/zlib/contrib/dotzlib/readme.txt new file mode 100644 index 0000000000..4d8c2dd932 --- /dev/null +++ b/xs/src/png/zlib/contrib/dotzlib/readme.txt @@ -0,0 +1,58 @@ +This directory contains a .Net wrapper class library for the ZLib1.dll + +The wrapper includes support for inflating/deflating memory buffers, +.Net streaming wrappers for the gz streams part of zlib, and wrappers +for the checksum parts of zlib. See DotZLib/UnitTests.cs for examples. + +Directory structure: +-------------------- + +LICENSE_1_0.txt - License file. +readme.txt - This file. +DotZLib.chm - Class library documentation +DotZLib.build - NAnt build file +DotZLib.sln - Microsoft Visual Studio 2003 solution file + +DotZLib\*.cs - Source files for the class library + +Unit tests: +----------- +The file DotZLib/UnitTests.cs contains unit tests for use with NUnit 2.1 or higher. +To include unit tests in the build, define nunit before building. + + +Build instructions: +------------------- + +1. Using Visual Studio.Net 2003: + Open DotZLib.sln in VS.Net and build from there. Output file (DotZLib.dll) + will be found ./DotZLib/bin/release or ./DotZLib/bin/debug, depending on + you are building the release or debug version of the library. Check + DotZLib/UnitTests.cs for instructions on how to include unit tests in the + build. + +2. Using NAnt: + Open a command prompt with access to the build environment and run nant + in the same directory as the DotZLib.build file. + You can define 2 properties on the nant command-line to control the build: + debug={true|false} to toggle between release/debug builds (default=true). + nunit={true|false} to include or esclude unit tests (default=true). + Also the target clean will remove binaries. + Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release + or ./DotZLib/bin/debug, depending on whether you are building the release + or debug version of the library. + + Examples: + nant -D:debug=false -D:nunit=false + will build a release mode version of the library without unit tests. + nant + will build a debug version of the library with unit tests + nant clean + will remove all previously built files. + + +--------------------------------- +Copyright (c) Henrik Ravn 2004 + +Use, modification and distribution are subject to the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/xs/src/png/zlib/contrib/gcc_gvmat64/gvmat64.S b/xs/src/png/zlib/contrib/gcc_gvmat64/gvmat64.S new file mode 100644 index 0000000000..23309fa286 --- /dev/null +++ b/xs/src/png/zlib/contrib/gcc_gvmat64/gvmat64.S @@ -0,0 +1,574 @@ +/* +;uInt longest_match_x64( +; deflate_state *s, +; IPos cur_match); // current match + +; gvmat64.S -- Asm portion of the optimized longest_match for 32 bits x86_64 +; (AMD64 on Athlon 64, Opteron, Phenom +; and Intel EM64T on Pentium 4 with EM64T, Pentium D, Core 2 Duo, Core I5/I7) +; this file is translation from gvmat64.asm to GCC 4.x (for Linux, Mac XCode) +; Copyright (C) 1995-2010 Jean-loup Gailly, Brian Raiter and Gilles Vollant. +; +; File written by Gilles Vollant, by converting to assembly the longest_match +; from Jean-loup Gailly in deflate.c of zLib and infoZip zip. +; and by taking inspiration on asm686 with masm, optimised assembly code +; from Brian Raiter, written 1998 +; +; This software is provided 'as-is', without any express or implied +; warranty. In no event will the authors be held liable for any damages +; arising from the use of this software. +; +; Permission is granted to anyone to use this software for any purpose, +; including commercial applications, and to alter it and redistribute it +; freely, subject to the following restrictions: +; +; 1. The origin of this software must not be misrepresented; you must not +; claim that you wrote the original software. If you use this software +; in a product, an acknowledgment in the product documentation would be +; appreciated but is not required. +; 2. Altered source versions must be plainly marked as such, and must not be +; misrepresented as being the original software +; 3. This notice may not be removed or altered from any source distribution. +; +; http://www.zlib.net +; http://www.winimage.com/zLibDll +; http://www.muppetlabs.com/~breadbox/software/assembly.html +; +; to compile this file for zLib, I use option: +; gcc -c -arch x86_64 gvmat64.S + + +;uInt longest_match(s, cur_match) +; deflate_state *s; +; IPos cur_match; // current match / +; +; with XCode for Mac, I had strange error with some jump on intel syntax +; this is why BEFORE_JMP and AFTER_JMP are used + */ + + +#define BEFORE_JMP .att_syntax +#define AFTER_JMP .intel_syntax noprefix + +#ifndef NO_UNDERLINE +# define match_init _match_init +# define longest_match _longest_match +#endif + +.intel_syntax noprefix + +.globl match_init, longest_match +.text +longest_match: + + + +#define LocalVarsSize 96 +/* +; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12 +; free register : r14,r15 +; register can be saved : rsp +*/ + +#define chainlenwmask (rsp + 8 - LocalVarsSize) +#define nicematch (rsp + 16 - LocalVarsSize) + +#define save_rdi (rsp + 24 - LocalVarsSize) +#define save_rsi (rsp + 32 - LocalVarsSize) +#define save_rbx (rsp + 40 - LocalVarsSize) +#define save_rbp (rsp + 48 - LocalVarsSize) +#define save_r12 (rsp + 56 - LocalVarsSize) +#define save_r13 (rsp + 64 - LocalVarsSize) +#define save_r14 (rsp + 72 - LocalVarsSize) +#define save_r15 (rsp + 80 - LocalVarsSize) + + +/* +; all the +4 offsets are due to the addition of pending_buf_size (in zlib +; in the deflate_state structure since the asm code was first written +; (if you compile with zlib 1.0.4 or older, remove the +4). +; Note : these value are good with a 8 bytes boundary pack structure +*/ + +#define MAX_MATCH 258 +#define MIN_MATCH 3 +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) + +/* +;;; Offsets for fields in the deflate_state structure. These numbers +;;; are calculated from the definition of deflate_state, with the +;;; assumption that the compiler will dword-align the fields. (Thus, +;;; changing the definition of deflate_state could easily cause this +;;; program to crash horribly, without so much as a warning at +;;; compile time. Sigh.) + +; all the +zlib1222add offsets are due to the addition of fields +; in zlib in the deflate_state structure since the asm code was first written +; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). +; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). +; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). +*/ + + + +/* you can check the structure offset by running + +#include +#include +#include "deflate.h" + +void print_depl() +{ +deflate_state ds; +deflate_state *s=&ds; +printf("size pointer=%u\n",(int)sizeof(void*)); + +printf("#define dsWSize %u\n",(int)(((char*)&(s->w_size))-((char*)s))); +printf("#define dsWMask %u\n",(int)(((char*)&(s->w_mask))-((char*)s))); +printf("#define dsWindow %u\n",(int)(((char*)&(s->window))-((char*)s))); +printf("#define dsPrev %u\n",(int)(((char*)&(s->prev))-((char*)s))); +printf("#define dsMatchLen %u\n",(int)(((char*)&(s->match_length))-((char*)s))); +printf("#define dsPrevMatch %u\n",(int)(((char*)&(s->prev_match))-((char*)s))); +printf("#define dsStrStart %u\n",(int)(((char*)&(s->strstart))-((char*)s))); +printf("#define dsMatchStart %u\n",(int)(((char*)&(s->match_start))-((char*)s))); +printf("#define dsLookahead %u\n",(int)(((char*)&(s->lookahead))-((char*)s))); +printf("#define dsPrevLen %u\n",(int)(((char*)&(s->prev_length))-((char*)s))); +printf("#define dsMaxChainLen %u\n",(int)(((char*)&(s->max_chain_length))-((char*)s))); +printf("#define dsGoodMatch %u\n",(int)(((char*)&(s->good_match))-((char*)s))); +printf("#define dsNiceMatch %u\n",(int)(((char*)&(s->nice_match))-((char*)s))); +} +*/ + +#define dsWSize 68 +#define dsWMask 76 +#define dsWindow 80 +#define dsPrev 96 +#define dsMatchLen 144 +#define dsPrevMatch 148 +#define dsStrStart 156 +#define dsMatchStart 160 +#define dsLookahead 164 +#define dsPrevLen 168 +#define dsMaxChainLen 172 +#define dsGoodMatch 188 +#define dsNiceMatch 192 + +#define window_size [ rcx + dsWSize] +#define WMask [ rcx + dsWMask] +#define window_ad [ rcx + dsWindow] +#define prev_ad [ rcx + dsPrev] +#define strstart [ rcx + dsStrStart] +#define match_start [ rcx + dsMatchStart] +#define Lookahead [ rcx + dsLookahead] //; 0ffffffffh on infozip +#define prev_length [ rcx + dsPrevLen] +#define max_chain_length [ rcx + dsMaxChainLen] +#define good_match [ rcx + dsGoodMatch] +#define nice_match [ rcx + dsNiceMatch] + +/* +; windows: +; parameter 1 in rcx(deflate state s), param 2 in rdx (cur match) + +; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and +; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp +; +; All registers must be preserved across the call, except for +; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. + +; +; gcc on macosx-linux: +; see http://www.x86-64.org/documentation/abi-0.99.pdf +; param 1 in rdi, param 2 in rsi +; rbx, rsp, rbp, r12 to r15 must be preserved + +;;; Save registers that the compiler may be using, and adjust esp to +;;; make room for our stack frame. + + +;;; Retrieve the function arguments. r8d will hold cur_match +;;; throughout the entire function. edx will hold the pointer to the +;;; deflate_state structure during the function's setup (before +;;; entering the main loop. + +; ms: parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match) +; mac: param 1 in rdi, param 2 rsi +; this clear high 32 bits of r8, which can be garbage in both r8 and rdx +*/ + mov [save_rbx],rbx + mov [save_rbp],rbp + + + mov rcx,rdi + + mov r8d,esi + + + mov [save_r12],r12 + mov [save_r13],r13 + mov [save_r14],r14 + mov [save_r15],r15 + + +//;;; uInt wmask = s->w_mask; +//;;; unsigned chain_length = s->max_chain_length; +//;;; if (s->prev_length >= s->good_match) { +//;;; chain_length >>= 2; +//;;; } + + + mov edi, prev_length + mov esi, good_match + mov eax, WMask + mov ebx, max_chain_length + cmp edi, esi + jl LastMatchGood + shr ebx, 2 +LastMatchGood: + +//;;; chainlen is decremented once beforehand so that the function can +//;;; use the sign flag instead of the zero flag for the exit test. +//;;; It is then shifted into the high word, to make room for the wmask +//;;; value, which it will always accompany. + + dec ebx + shl ebx, 16 + or ebx, eax + +//;;; on zlib only +//;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + + + mov eax, nice_match + mov [chainlenwmask], ebx + mov r10d, Lookahead + cmp r10d, eax + cmovnl r10d, eax + mov [nicematch],r10d + + + +//;;; register Bytef *scan = s->window + s->strstart; + mov r10, window_ad + mov ebp, strstart + lea r13, [r10 + rbp] + +//;;; Determine how many bytes the scan ptr is off from being +//;;; dword-aligned. + + mov r9,r13 + neg r13 + and r13,3 + +//;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? +//;;; s->strstart - (IPos)MAX_DIST(s) : NIL; + + + mov eax, window_size + sub eax, MIN_LOOKAHEAD + + + xor edi,edi + sub ebp, eax + + mov r11d, prev_length + + cmovng ebp,edi + +//;;; int best_len = s->prev_length; + + +//;;; Store the sum of s->window + best_len in esi locally, and in esi. + + lea rsi,[r10+r11] + +//;;; register ush scan_start = *(ushf*)scan; +//;;; register ush scan_end = *(ushf*)(scan+best_len-1); +//;;; Posf *prev = s->prev; + + movzx r12d,word ptr [r9] + movzx ebx, word ptr [r9 + r11 - 1] + + mov rdi, prev_ad + +//;;; Jump into the main loop. + + mov edx, [chainlenwmask] + + cmp bx,word ptr [rsi + r8 - 1] + jz LookupLoopIsZero + + + +LookupLoop1: + and r8d, edx + + movzx r8d, word ptr [rdi + r8*2] + cmp r8d, ebp + jbe LeaveNow + + + + sub edx, 0x00010000 + BEFORE_JMP + js LeaveNow + AFTER_JMP + +LoopEntry1: + cmp bx,word ptr [rsi + r8 - 1] + BEFORE_JMP + jz LookupLoopIsZero + AFTER_JMP + +LookupLoop2: + and r8d, edx + + movzx r8d, word ptr [rdi + r8*2] + cmp r8d, ebp + BEFORE_JMP + jbe LeaveNow + AFTER_JMP + sub edx, 0x00010000 + BEFORE_JMP + js LeaveNow + AFTER_JMP + +LoopEntry2: + cmp bx,word ptr [rsi + r8 - 1] + BEFORE_JMP + jz LookupLoopIsZero + AFTER_JMP + +LookupLoop4: + and r8d, edx + + movzx r8d, word ptr [rdi + r8*2] + cmp r8d, ebp + BEFORE_JMP + jbe LeaveNow + AFTER_JMP + sub edx, 0x00010000 + BEFORE_JMP + js LeaveNow + AFTER_JMP + +LoopEntry4: + + cmp bx,word ptr [rsi + r8 - 1] + BEFORE_JMP + jnz LookupLoop1 + jmp LookupLoopIsZero + AFTER_JMP +/* +;;; do { +;;; match = s->window + cur_match; +;;; if (*(ushf*)(match+best_len-1) != scan_end || +;;; *(ushf*)match != scan_start) continue; +;;; [...] +;;; } while ((cur_match = prev[cur_match & wmask]) > limit +;;; && --chain_length != 0); +;;; +;;; Here is the inner loop of the function. The function will spend the +;;; majority of its time in this loop, and majority of that time will +;;; be spent in the first ten instructions. +;;; +;;; Within this loop: +;;; ebx = scanend +;;; r8d = curmatch +;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) +;;; esi = windowbestlen - i.e., (window + bestlen) +;;; edi = prev +;;; ebp = limit +*/ +.balign 16 +LookupLoop: + and r8d, edx + + movzx r8d, word ptr [rdi + r8*2] + cmp r8d, ebp + BEFORE_JMP + jbe LeaveNow + AFTER_JMP + sub edx, 0x00010000 + BEFORE_JMP + js LeaveNow + AFTER_JMP + +LoopEntry: + + cmp bx,word ptr [rsi + r8 - 1] + BEFORE_JMP + jnz LookupLoop1 + AFTER_JMP +LookupLoopIsZero: + cmp r12w, word ptr [r10 + r8] + BEFORE_JMP + jnz LookupLoop1 + AFTER_JMP + + +//;;; Store the current value of chainlen. + mov [chainlenwmask], edx +/* +;;; Point edi to the string under scrutiny, and esi to the string we +;;; are hoping to match it up with. In actuality, esi and edi are +;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is +;;; initialized to -(MAX_MATCH_8 - scanalign). +*/ + lea rsi,[r8+r10] + mov rdx, 0xfffffffffffffef8 //; -(MAX_MATCH_8) + lea rsi, [rsi + r13 + 0x0108] //;MAX_MATCH_8] + lea rdi, [r9 + r13 + 0x0108] //;MAX_MATCH_8] + + prefetcht1 [rsi+rdx] + prefetcht1 [rdi+rdx] + +/* +;;; Test the strings for equality, 8 bytes at a time. At the end, +;;; adjust rdx so that it is offset to the exact byte that mismatched. +;;; +;;; We already know at this point that the first three bytes of the +;;; strings match each other, and they can be safely passed over before +;;; starting the compare loop. So what this code does is skip over 0-3 +;;; bytes, as much as necessary in order to dword-align the edi +;;; pointer. (rsi will still be misaligned three times out of four.) +;;; +;;; It should be confessed that this loop usually does not represent +;;; much of the total running time. Replacing it with a more +;;; straightforward "rep cmpsb" would not drastically degrade +;;; performance. +*/ + +LoopCmps: + mov rax, [rsi + rdx] + xor rax, [rdi + rdx] + jnz LeaveLoopCmps + + mov rax, [rsi + rdx + 8] + xor rax, [rdi + rdx + 8] + jnz LeaveLoopCmps8 + + + mov rax, [rsi + rdx + 8+8] + xor rax, [rdi + rdx + 8+8] + jnz LeaveLoopCmps16 + + add rdx,8+8+8 + + BEFORE_JMP + jnz LoopCmps + jmp LenMaximum + AFTER_JMP + +LeaveLoopCmps16: add rdx,8 +LeaveLoopCmps8: add rdx,8 +LeaveLoopCmps: + + test eax, 0x0000FFFF + jnz LenLower + + test eax,0xffffffff + + jnz LenLower32 + + add rdx,4 + shr rax,32 + or ax,ax + BEFORE_JMP + jnz LenLower + AFTER_JMP + +LenLower32: + shr eax,16 + add rdx,2 + +LenLower: + sub al, 1 + adc rdx, 0 +//;;; Calculate the length of the match. If it is longer than MAX_MATCH, +//;;; then automatically accept it as the best possible match and leave. + + lea rax, [rdi + rdx] + sub rax, r9 + cmp eax, MAX_MATCH + BEFORE_JMP + jge LenMaximum + AFTER_JMP +/* +;;; If the length of the match is not longer than the best match we +;;; have so far, then forget it and return to the lookup loop. +;/////////////////////////////////// +*/ + cmp eax, r11d + jg LongerMatch + + lea rsi,[r10+r11] + + mov rdi, prev_ad + mov edx, [chainlenwmask] + BEFORE_JMP + jmp LookupLoop + AFTER_JMP +/* +;;; s->match_start = cur_match; +;;; best_len = len; +;;; if (len >= nice_match) break; +;;; scan_end = *(ushf*)(scan+best_len-1); +*/ +LongerMatch: + mov r11d, eax + mov match_start, r8d + cmp eax, [nicematch] + BEFORE_JMP + jge LeaveNow + AFTER_JMP + + lea rsi,[r10+rax] + + movzx ebx, word ptr [r9 + rax - 1] + mov rdi, prev_ad + mov edx, [chainlenwmask] + BEFORE_JMP + jmp LookupLoop + AFTER_JMP + +//;;; Accept the current string, with the maximum possible length. + +LenMaximum: + mov r11d,MAX_MATCH + mov match_start, r8d + +//;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; +//;;; return s->lookahead; + +LeaveNow: + mov eax, Lookahead + cmp r11d, eax + cmovng eax, r11d + + + +//;;; Restore the stack and return from whence we came. + + +// mov rsi,[save_rsi] +// mov rdi,[save_rdi] + mov rbx,[save_rbx] + mov rbp,[save_rbp] + mov r12,[save_r12] + mov r13,[save_r13] + mov r14,[save_r14] + mov r15,[save_r15] + + + ret 0 +//; please don't remove this string ! +//; Your can freely use gvmat64 in any free or commercial app +//; but it is far better don't remove the string in the binary! + // db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0 + + +match_init: + ret 0 + + diff --git a/xs/src/png/zlib/contrib/infback9/README b/xs/src/png/zlib/contrib/infback9/README new file mode 100644 index 0000000000..e75ed13294 --- /dev/null +++ b/xs/src/png/zlib/contrib/infback9/README @@ -0,0 +1 @@ +See infback9.h for what this is and how to use it. diff --git a/xs/src/png/zlib/contrib/infback9/infback9.c b/xs/src/png/zlib/contrib/infback9/infback9.c new file mode 100644 index 0000000000..05fb3e3380 --- /dev/null +++ b/xs/src/png/zlib/contrib/infback9/infback9.c @@ -0,0 +1,615 @@ +/* infback9.c -- inflate deflate64 data using a call-back interface + * Copyright (C) 1995-2008 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "infback9.h" +#include "inftree9.h" +#include "inflate9.h" + +#define WSIZE 65536UL + +/* + strm provides memory allocation functions in zalloc and zfree, or + Z_NULL to use the library memory allocation functions. + + window is a user-supplied window and output buffer that is 64K bytes. + */ +int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) +z_stream FAR *strm; +unsigned char FAR *window; +const char *version; +int stream_size; +{ + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL || window == Z_NULL) + return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + state = (struct inflate_state FAR *)ZALLOC(strm, 1, + sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (voidpf)state; + state->window = window; + return Z_OK; +} + +/* + Build and output length and distance decoding tables for fixed code + decoding. + */ +#ifdef MAKEFIXED +#include + +void makefixed9(void) +{ + unsigned sym, bits, low, size; + code *next, *lenfix, *distfix; + struct inflate_state state; + code fixed[544]; + + /* literal/length table */ + sym = 0; + while (sym < 144) state.lens[sym++] = 8; + while (sym < 256) state.lens[sym++] = 9; + while (sym < 280) state.lens[sym++] = 7; + while (sym < 288) state.lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table9(LENS, state.lens, 288, &(next), &(bits), state.work); + + /* distance table */ + sym = 0; + while (sym < 32) state.lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table9(DISTS, state.lens, 32, &(next), &(bits), state.work); + + /* write tables */ + puts(" /* inffix9.h -- table for decoding deflate64 fixed codes"); + puts(" * Generated automatically by makefixed9()."); + puts(" */"); + puts(""); + puts(" /* WARNING: this file should *not* be used by applications."); + puts(" It is part of the implementation of this library and is"); + puts(" subject to change. Applications should only use zlib.h."); + puts(" */"); + puts(""); + size = 1U << 9; + printf(" static const code lenfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 6) == 0) printf("\n "); + printf("{%u,%u,%d}", lenfix[low].op, lenfix[low].bits, + lenfix[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); + size = 1U << 5; + printf("\n static const code distfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 5) == 0) printf("\n "); + printf("{%u,%u,%d}", distfix[low].op, distfix[low].bits, + distfix[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); +} +#endif /* MAKEFIXED */ + +/* Macros for inflateBack(): */ + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Assure that some input is available. If input is requested, but denied, + then return a Z_BUF_ERROR from inflateBack(). */ +#define PULL() \ + do { \ + if (have == 0) { \ + have = in(in_desc, &next); \ + if (have == 0) { \ + next = Z_NULL; \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflateBack() + with an error if there is no input available. */ +#define PULLBYTE() \ + do { \ + PULL(); \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflateBack() with + an error. */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n <= 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* Assure that some output space is available, by writing out the window + if it's full. If the write fails, return from inflateBack() with a + Z_BUF_ERROR. */ +#define ROOM() \ + do { \ + if (left == 0) { \ + put = window; \ + left = WSIZE; \ + wrap = 1; \ + if (out(out_desc, put, (unsigned)left)) { \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + +/* + strm provides the memory allocation functions and window buffer on input, + and provides information on the unused input on return. For Z_DATA_ERROR + returns, strm will also provide an error message. + + in() and out() are the call-back input and output functions. When + inflateBack() needs more input, it calls in(). When inflateBack() has + filled the window with output, or when it completes with data in the + window, it calls out() to write out the data. The application must not + change the provided input until in() is called again or inflateBack() + returns. The application must not change the window/output buffer until + inflateBack() returns. + + in() and out() are called with a descriptor parameter provided in the + inflateBack() call. This parameter can be a structure that provides the + information required to do the read or write, as well as accumulated + information on the input and output such as totals and check values. + + in() should return zero on failure. out() should return non-zero on + failure. If either in() or out() fails, than inflateBack() returns a + Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it + was in() or out() that caused in the error. Otherwise, inflateBack() + returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format + error, or Z_MEM_ERROR if it could not allocate memory for the state. + inflateBack() can also return Z_STREAM_ERROR if the input parameters + are not correct, i.e. strm is Z_NULL or the state was not initialized. + */ +int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) +z_stream FAR *strm; +in_func in; +void FAR *in_desc; +out_func out; +void FAR *out_desc; +{ + struct inflate_state FAR *state; + z_const unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have; /* available input */ + unsigned long left; /* available output */ + inflate_mode mode; /* current inflate mode */ + int lastblock; /* true if processing last block */ + int wrap; /* true if the window has wrapped */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned extra; /* extra bits needed */ + unsigned long length; /* literal or length of data to copy */ + unsigned long offset; /* distance back to copy string from */ + unsigned long copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + code here; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; +#include "inffix9.h" + + /* Check that the strm exists and that the state was initialized */ + if (strm == Z_NULL || strm->state == Z_NULL) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* Reset the state */ + strm->msg = Z_NULL; + mode = TYPE; + lastblock = 0; + wrap = 0; + window = state->window; + next = strm->next_in; + have = next != Z_NULL ? strm->avail_in : 0; + hold = 0; + bits = 0; + put = window; + left = WSIZE; + lencode = Z_NULL; + distcode = Z_NULL; + + /* Inflate until end of block marked as last */ + for (;;) + switch (mode) { + case TYPE: + /* determine and dispatch block type */ + if (lastblock) { + BYTEBITS(); + mode = DONE; + break; + } + NEEDBITS(3); + lastblock = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + lastblock ? " (last)" : "")); + mode = STORED; + break; + case 1: /* fixed block */ + lencode = lenfix; + lenbits = 9; + distcode = distfix; + distbits = 5; + Tracev((stderr, "inflate: fixed codes block%s\n", + lastblock ? " (last)" : "")); + mode = LEN; /* decode codes */ + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + lastblock ? " (last)" : "")); + mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + mode = BAD; + } + DROPBITS(2); + break; + + case STORED: + /* get and verify stored block length */ + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + mode = BAD; + break; + } + length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %lu\n", + length)); + INITBITS(); + + /* copy stored block from input to output */ + while (length != 0) { + copy = length; + PULL(); + ROOM(); + if (copy > have) copy = have; + if (copy > left) copy = left; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + length -= copy; + } + Tracev((stderr, "inflate: stored end\n")); + mode = TYPE; + break; + + case TABLE: + /* get dynamic table entries descriptor */ + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); + if (state->nlen > 286) { + strm->msg = (char *)"too many length symbols"; + mode = BAD; + break; + } + Tracev((stderr, "inflate: table sizes ok\n")); + + /* get code length code lengths (not a typo) */ + state->have = 0; + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + lencode = (code const FAR *)(state->next); + lenbits = 7; + ret = inflate_table9(CODES, state->lens, 19, &(state->next), + &(lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + + /* get length and distance code code lengths */ + state->have = 0; + while (state->have < state->nlen + state->ndist) { + for (;;) { + here = lencode[BITS(lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.val < 16) { + NEEDBITS(here.bits); + DROPBITS(here.bits); + state->lens[state->have++] = here.val; + } + else { + if (here.val == 16) { + NEEDBITS(here.bits + 2); + DROPBITS(here.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + mode = BAD; + break; + } + len = (unsigned)(state->lens[state->have - 1]); + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (here.val == 17) { + NEEDBITS(here.bits + 3); + DROPBITS(here.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(here.bits + 7); + DROPBITS(here.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (mode == BAD) break; + + /* check for end-of-block code (better have one) */ + if (state->lens[256] == 0) { + strm->msg = (char *)"invalid code -- missing end-of-block"; + mode = BAD; + break; + } + + /* build code tables -- note: do not change the lenbits or distbits + values here (9 and 6) without reading the comments in inftree9.h + concerning the ENOUGH constants, which depend on those values */ + state->next = state->codes; + lencode = (code const FAR *)(state->next); + lenbits = 9; + ret = inflate_table9(LENS, state->lens, state->nlen, + &(state->next), &(lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + mode = BAD; + break; + } + distcode = (code const FAR *)(state->next); + distbits = 6; + ret = inflate_table9(DISTS, state->lens + state->nlen, + state->ndist, &(state->next), &(distbits), + state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + mode = LEN; + + case LEN: + /* get a literal, length, or end-of-block code */ + for (;;) { + here = lencode[BITS(lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.op && (here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(here.bits); + length = (unsigned)here.val; + + /* process literal */ + if (here.op == 0) { + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + ROOM(); + *put++ = (unsigned char)(length); + left--; + mode = LEN; + break; + } + + /* process end of block */ + if (here.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + mode = TYPE; + break; + } + + /* invalid code */ + if (here.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + mode = BAD; + break; + } + + /* length code -- get extra bits, if any */ + extra = (unsigned)(here.op) & 31; + if (extra != 0) { + NEEDBITS(extra); + length += BITS(extra); + DROPBITS(extra); + } + Tracevv((stderr, "inflate: length %lu\n", length)); + + /* get distance code */ + for (;;) { + here = distcode[BITS(distbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if ((here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(here.bits); + if (here.op & 64) { + strm->msg = (char *)"invalid distance code"; + mode = BAD; + break; + } + offset = (unsigned)here.val; + + /* get distance extra bits, if any */ + extra = (unsigned)(here.op) & 15; + if (extra != 0) { + NEEDBITS(extra); + offset += BITS(extra); + DROPBITS(extra); + } + if (offset > WSIZE - (wrap ? 0: left)) { + strm->msg = (char *)"invalid distance too far back"; + mode = BAD; + break; + } + Tracevv((stderr, "inflate: distance %lu\n", offset)); + + /* copy match from window to output */ + do { + ROOM(); + copy = WSIZE - offset; + if (copy < left) { + from = put + copy; + copy = left - copy; + } + else { + from = put - offset; + copy = left; + } + if (copy > length) copy = length; + length -= copy; + left -= copy; + do { + *put++ = *from++; + } while (--copy); + } while (length != 0); + break; + + case DONE: + /* inflate stream terminated properly -- write leftover output */ + ret = Z_STREAM_END; + if (left < WSIZE) { + if (out(out_desc, window, (unsigned)(WSIZE - left))) + ret = Z_BUF_ERROR; + } + goto inf_leave; + + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + + default: /* can't happen, but makes compilers happy */ + ret = Z_STREAM_ERROR; + goto inf_leave; + } + + /* Return unused input */ + inf_leave: + strm->next_in = next; + strm->avail_in = have; + return ret; +} + +int ZEXPORT inflateBack9End(strm) +z_stream FAR *strm; +{ + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} diff --git a/xs/src/png/zlib/contrib/infback9/infback9.h b/xs/src/png/zlib/contrib/infback9/infback9.h new file mode 100644 index 0000000000..1073c0a38e --- /dev/null +++ b/xs/src/png/zlib/contrib/infback9/infback9.h @@ -0,0 +1,37 @@ +/* infback9.h -- header for using inflateBack9 functions + * Copyright (C) 2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * This header file and associated patches provide a decoder for PKWare's + * undocumented deflate64 compression method (method 9). Use with infback9.c, + * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported. + * This should be compiled with zlib, since it uses zutil.h and zutil.o. + * This code has not yet been tested on 16-bit architectures. See the + * comments in zlib.h for inflateBack() usage. These functions are used + * identically, except that there is no windowBits parameter, and a 64K + * window must be provided. Also if int's are 16 bits, then a zero for + * the third parameter of the "out" function actually means 65536UL. + * zlib.h must be included before this header file. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm)); +ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define inflateBack9Init(strm, window) \ + inflateBack9Init_((strm), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + +#ifdef __cplusplus +} +#endif diff --git a/xs/src/png/zlib/contrib/infback9/inffix9.h b/xs/src/png/zlib/contrib/infback9/inffix9.h new file mode 100644 index 0000000000..ee5671d2df --- /dev/null +++ b/xs/src/png/zlib/contrib/infback9/inffix9.h @@ -0,0 +1,107 @@ + /* inffix9.h -- table for decoding deflate64 fixed codes + * Generated automatically by makefixed9(). + */ + + /* WARNING: this file should *not* be used by applications. + It is part of the implementation of this library and is + subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{132,8,115},{130,7,31},{0,8,112}, + {0,8,48},{0,9,192},{128,7,10},{0,8,96},{0,8,32},{0,9,160}, + {0,8,0},{0,8,128},{0,8,64},{0,9,224},{128,7,6},{0,8,88}, + {0,8,24},{0,9,144},{131,7,59},{0,8,120},{0,8,56},{0,9,208}, + {129,7,17},{0,8,104},{0,8,40},{0,9,176},{0,8,8},{0,8,136}, + {0,8,72},{0,9,240},{128,7,4},{0,8,84},{0,8,20},{133,8,227}, + {131,7,43},{0,8,116},{0,8,52},{0,9,200},{129,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232}, + {128,7,8},{0,8,92},{0,8,28},{0,9,152},{132,7,83},{0,8,124}, + {0,8,60},{0,9,216},{130,7,23},{0,8,108},{0,8,44},{0,9,184}, + {0,8,12},{0,8,140},{0,8,76},{0,9,248},{128,7,3},{0,8,82}, + {0,8,18},{133,8,163},{131,7,35},{0,8,114},{0,8,50},{0,9,196}, + {129,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},{0,8,130}, + {0,8,66},{0,9,228},{128,7,7},{0,8,90},{0,8,26},{0,9,148}, + {132,7,67},{0,8,122},{0,8,58},{0,9,212},{130,7,19},{0,8,106}, + {0,8,42},{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244}, + {128,7,5},{0,8,86},{0,8,22},{65,8,0},{131,7,51},{0,8,118}, + {0,8,54},{0,9,204},{129,7,15},{0,8,102},{0,8,38},{0,9,172}, + {0,8,6},{0,8,134},{0,8,70},{0,9,236},{128,7,9},{0,8,94}, + {0,8,30},{0,9,156},{132,7,99},{0,8,126},{0,8,62},{0,9,220}, + {130,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{133,8,131}, + {130,7,31},{0,8,113},{0,8,49},{0,9,194},{128,7,10},{0,8,97}, + {0,8,33},{0,9,162},{0,8,1},{0,8,129},{0,8,65},{0,9,226}, + {128,7,6},{0,8,89},{0,8,25},{0,9,146},{131,7,59},{0,8,121}, + {0,8,57},{0,9,210},{129,7,17},{0,8,105},{0,8,41},{0,9,178}, + {0,8,9},{0,8,137},{0,8,73},{0,9,242},{128,7,4},{0,8,85}, + {0,8,21},{144,8,3},{131,7,43},{0,8,117},{0,8,53},{0,9,202}, + {129,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133}, + {0,8,69},{0,9,234},{128,7,8},{0,8,93},{0,8,29},{0,9,154}, + {132,7,83},{0,8,125},{0,8,61},{0,9,218},{130,7,23},{0,8,109}, + {0,8,45},{0,9,186},{0,8,13},{0,8,141},{0,8,77},{0,9,250}, + {128,7,3},{0,8,83},{0,8,19},{133,8,195},{131,7,35},{0,8,115}, + {0,8,51},{0,9,198},{129,7,11},{0,8,99},{0,8,35},{0,9,166}, + {0,8,3},{0,8,131},{0,8,67},{0,9,230},{128,7,7},{0,8,91}, + {0,8,27},{0,9,150},{132,7,67},{0,8,123},{0,8,59},{0,9,214}, + {130,7,19},{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139}, + {0,8,75},{0,9,246},{128,7,5},{0,8,87},{0,8,23},{77,8,0}, + {131,7,51},{0,8,119},{0,8,55},{0,9,206},{129,7,15},{0,8,103}, + {0,8,39},{0,9,174},{0,8,7},{0,8,135},{0,8,71},{0,9,238}, + {128,7,9},{0,8,95},{0,8,31},{0,9,158},{132,7,99},{0,8,127}, + {0,8,63},{0,9,222},{130,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80}, + {0,8,16},{132,8,115},{130,7,31},{0,8,112},{0,8,48},{0,9,193}, + {128,7,10},{0,8,96},{0,8,32},{0,9,161},{0,8,0},{0,8,128}, + {0,8,64},{0,9,225},{128,7,6},{0,8,88},{0,8,24},{0,9,145}, + {131,7,59},{0,8,120},{0,8,56},{0,9,209},{129,7,17},{0,8,104}, + {0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},{0,9,241}, + {128,7,4},{0,8,84},{0,8,20},{133,8,227},{131,7,43},{0,8,116}, + {0,8,52},{0,9,201},{129,7,13},{0,8,100},{0,8,36},{0,9,169}, + {0,8,4},{0,8,132},{0,8,68},{0,9,233},{128,7,8},{0,8,92}, + {0,8,28},{0,9,153},{132,7,83},{0,8,124},{0,8,60},{0,9,217}, + {130,7,23},{0,8,108},{0,8,44},{0,9,185},{0,8,12},{0,8,140}, + {0,8,76},{0,9,249},{128,7,3},{0,8,82},{0,8,18},{133,8,163}, + {131,7,35},{0,8,114},{0,8,50},{0,9,197},{129,7,11},{0,8,98}, + {0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {128,7,7},{0,8,90},{0,8,26},{0,9,149},{132,7,67},{0,8,122}, + {0,8,58},{0,9,213},{130,7,19},{0,8,106},{0,8,42},{0,9,181}, + {0,8,10},{0,8,138},{0,8,74},{0,9,245},{128,7,5},{0,8,86}, + {0,8,22},{65,8,0},{131,7,51},{0,8,118},{0,8,54},{0,9,205}, + {129,7,15},{0,8,102},{0,8,38},{0,9,173},{0,8,6},{0,8,134}, + {0,8,70},{0,9,237},{128,7,9},{0,8,94},{0,8,30},{0,9,157}, + {132,7,99},{0,8,126},{0,8,62},{0,9,221},{130,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253}, + {96,7,0},{0,8,81},{0,8,17},{133,8,131},{130,7,31},{0,8,113}, + {0,8,49},{0,9,195},{128,7,10},{0,8,97},{0,8,33},{0,9,163}, + {0,8,1},{0,8,129},{0,8,65},{0,9,227},{128,7,6},{0,8,89}, + {0,8,25},{0,9,147},{131,7,59},{0,8,121},{0,8,57},{0,9,211}, + {129,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},{0,8,137}, + {0,8,73},{0,9,243},{128,7,4},{0,8,85},{0,8,21},{144,8,3}, + {131,7,43},{0,8,117},{0,8,53},{0,9,203},{129,7,13},{0,8,101}, + {0,8,37},{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235}, + {128,7,8},{0,8,93},{0,8,29},{0,9,155},{132,7,83},{0,8,125}, + {0,8,61},{0,9,219},{130,7,23},{0,8,109},{0,8,45},{0,9,187}, + {0,8,13},{0,8,141},{0,8,77},{0,9,251},{128,7,3},{0,8,83}, + {0,8,19},{133,8,195},{131,7,35},{0,8,115},{0,8,51},{0,9,199}, + {129,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{128,7,7},{0,8,91},{0,8,27},{0,9,151}, + {132,7,67},{0,8,123},{0,8,59},{0,9,215},{130,7,19},{0,8,107}, + {0,8,43},{0,9,183},{0,8,11},{0,8,139},{0,8,75},{0,9,247}, + {128,7,5},{0,8,87},{0,8,23},{77,8,0},{131,7,51},{0,8,119}, + {0,8,55},{0,9,207},{129,7,15},{0,8,103},{0,8,39},{0,9,175}, + {0,8,7},{0,8,135},{0,8,71},{0,9,239},{128,7,9},{0,8,95}, + {0,8,31},{0,9,159},{132,7,99},{0,8,127},{0,8,63},{0,9,223}, + {130,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143}, + {0,8,79},{0,9,255} + }; + + static const code distfix[32] = { + {128,5,1},{135,5,257},{131,5,17},{139,5,4097},{129,5,5}, + {137,5,1025},{133,5,65},{141,5,16385},{128,5,3},{136,5,513}, + {132,5,33},{140,5,8193},{130,5,9},{138,5,2049},{134,5,129}, + {142,5,32769},{128,5,2},{135,5,385},{131,5,25},{139,5,6145}, + {129,5,7},{137,5,1537},{133,5,97},{141,5,24577},{128,5,4}, + {136,5,769},{132,5,49},{140,5,12289},{130,5,13},{138,5,3073}, + {134,5,193},{142,5,49153} + }; diff --git a/xs/src/png/zlib/contrib/infback9/inflate9.h b/xs/src/png/zlib/contrib/infback9/inflate9.h new file mode 100644 index 0000000000..ee9a79394b --- /dev/null +++ b/xs/src/png/zlib/contrib/infback9/inflate9.h @@ -0,0 +1,47 @@ +/* inflate9.h -- internal inflate state definition + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Possible inflate modes between inflate() calls */ +typedef enum { + TYPE, /* i: waiting for type bits, including last-flag bit */ + STORED, /* i: waiting for stored size (length and complement) */ + TABLE, /* i: waiting for dynamic block table lengths */ + LEN, /* i: waiting for length/lit code */ + DONE, /* finished check, done -- remain here until reset */ + BAD /* got a data error -- remain here until reset */ +} inflate_mode; + +/* + State transitions between above modes - + + (most modes can go to the BAD mode -- not shown for clarity) + + Read deflate blocks: + TYPE -> STORED or TABLE or LEN or DONE + STORED -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN + Read deflate codes: + LEN -> LEN or TYPE + */ + +/* state maintained between inflate() calls. Approximately 7K bytes. */ +struct inflate_state { + /* sliding window */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ +}; diff --git a/xs/src/png/zlib/contrib/infback9/inftree9.c b/xs/src/png/zlib/contrib/infback9/inftree9.c new file mode 100644 index 0000000000..5f4a76798d --- /dev/null +++ b/xs/src/png/zlib/contrib/infback9/inftree9.c @@ -0,0 +1,324 @@ +/* inftree9.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2017 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftree9.h" + +#define MAXBITS 15 + +const char inflate9_copyright[] = + " inflate9 1.2.11 Copyright 1995-2017 Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* + Build a set of tables to decode the provided canonical Huffman code. + The code lengths are lens[0..codes-1]. The result starts at *table, + whose indices are 0..2^bits-1. work is a writable array of at least + lens shorts, which is used as a work area. type is the type of code + to be generated, CODES, LENS, or DISTS. On return, zero is success, + -1 is an invalid code, and +1 means that ENOUGH isn't enough. table + on return points to the next available entry's address. bits is the + requested root table index bits, and on return it is the actual root + table index bits. It will differ if the request is greater than the + longest code or if it is less than the shortest code. + */ +int inflate_table9(type, lens, codes, table, bits, work) +codetype type; +unsigned short FAR *lens; +unsigned codes; +code FAR * FAR *table; +unsigned FAR *bits; +unsigned short FAR *work; +{ + unsigned len; /* a code's length in bits */ + unsigned sym; /* index of code symbols */ + unsigned min, max; /* minimum and maximum code lengths */ + unsigned root; /* number of index bits for root table */ + unsigned curr; /* number of index bits for current table */ + unsigned drop; /* code bits to drop for sub-table */ + int left; /* number of prefix codes available */ + unsigned used; /* code entries in table used */ + unsigned huff; /* Huffman code */ + unsigned incr; /* for incrementing code, index */ + unsigned fill; /* index for replicating entries */ + unsigned low; /* low bits for current root entry */ + unsigned mask; /* mask for low root bits */ + code this; /* table entry for duplication */ + code FAR *next; /* next available space in table */ + const unsigned short FAR *base; /* base value table to use */ + const unsigned short FAR *extra; /* extra bits table to use */ + int end; /* use base and extra for symbol > end */ + unsigned short count[MAXBITS+1]; /* number of codes of each length */ + unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ + static const unsigned short lbase[31] = { /* Length codes 257..285 base */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, + 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, + 131, 163, 195, 227, 3, 0, 0}; + static const unsigned short lext[31] = { /* Length codes 257..285 extra */ + 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, + 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, + 133, 133, 133, 133, 144, 77, 202}; + static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, + 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, + 4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153}; + static const unsigned short dext[32] = { /* Distance codes 0..31 extra */ + 128, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, + 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138, + 139, 139, 140, 140, 141, 141, 142, 142}; + + /* + Process a set of code lengths to create a canonical Huffman code. The + code lengths are lens[0..codes-1]. Each length corresponds to the + symbols 0..codes-1. The Huffman code is generated by first sorting the + symbols by length from short to long, and retaining the symbol order + for codes with equal lengths. Then the code starts with all zero bits + for the first code of the shortest length, and the codes are integer + increments for the same length, and zeros are appended as the length + increases. For the deflate format, these bits are stored backwards + from their more natural integer increment ordering, and so when the + decoding tables are built in the large loop below, the integer codes + are incremented backwards. + + This routine assumes, but does not check, that all of the entries in + lens[] are in the range 0..MAXBITS. The caller must assure this. + 1..MAXBITS is interpreted as that code length. zero means that that + symbol does not occur in this code. + + The codes are sorted by computing a count of codes for each length, + creating from that a table of starting indices for each length in the + sorted table, and then entering the symbols in order in the sorted + table. The sorted table is work[], with that space being provided by + the caller. + + The length counts are used for other purposes as well, i.e. finding + the minimum and maximum length codes, determining if there are any + codes at all, checking for a valid set of lengths, and looking ahead + at length counts to determine sub-table sizes when building the + decoding tables. + */ + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAXBITS; len++) + count[len] = 0; + for (sym = 0; sym < codes; sym++) + count[lens[sym]]++; + + /* bound code lengths, force root to be within code lengths */ + root = *bits; + for (max = MAXBITS; max >= 1; max--) + if (count[max] != 0) break; + if (root > max) root = max; + if (max == 0) return -1; /* no codes! */ + for (min = 1; min <= MAXBITS; min++) + if (count[min] != 0) break; + if (root < min) root = min; + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) return -1; /* over-subscribed */ + } + if (left > 0 && (type == CODES || max != 1)) + return -1; /* incomplete set */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + count[len]; + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) + if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; + + /* + Create and fill in decoding tables. In this loop, the table being + filled is at next and has curr index bits. The code being used is huff + with length len. That code is converted to an index by dropping drop + bits off of the bottom. For codes where len is less than drop + curr, + those top drop + curr - len bits are incremented through all values to + fill the table with replicated entries. + + root is the number of index bits for the root table. When len exceeds + root, sub-tables are created pointed to by the root entry with an index + of the low root bits of huff. This is saved in low to check for when a + new sub-table should be started. drop is zero when the root table is + being filled, and drop is root when sub-tables are being filled. + + When a new sub-table is needed, it is necessary to look ahead in the + code lengths to determine what size sub-table is needed. The length + counts are used for this, and so count[] is decremented as codes are + entered in the tables. + + used keeps track of how many table entries have been allocated from the + provided *table space. It is checked for LENS and DIST tables against + the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in + the initial root table size constants. See the comments in inftree9.h + for more information. + + sym increments through all symbols, and the loop terminates when + all codes of length max, i.e. all codes, have been processed. This + routine permits incomplete codes, so another loop after this one fills + in the rest of the decoding tables with invalid code markers. + */ + + /* set up for code type */ + switch (type) { + case CODES: + base = extra = work; /* dummy value--not used */ + end = 19; + break; + case LENS: + base = lbase; + base -= 257; + extra = lext; + extra -= 257; + end = 256; + break; + default: /* DISTS */ + base = dbase; + extra = dext; + end = -1; + } + + /* initialize state for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = *table; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = (unsigned)(-1); /* trigger new sub-table when len > root */ + used = 1U << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if ((type == LENS && used >= ENOUGH_LENS) || + (type == DISTS && used >= ENOUGH_DISTS)) + return 1; + + /* process all codes and make table entries */ + for (;;) { + /* create table entry */ + this.bits = (unsigned char)(len - drop); + if ((int)(work[sym]) < end) { + this.op = (unsigned char)0; + this.val = work[sym]; + } + else if ((int)(work[sym]) > end) { + this.op = (unsigned char)(extra[work[sym]]); + this.val = base[work[sym]]; + } + else { + this.op = (unsigned char)(32 + 64); /* end of block */ + this.val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1U << (len - drop); + fill = 1U << curr; + do { + fill -= incr; + next[(huff >> drop) + fill] = this; + } while (fill != 0); + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + + /* go to next symbol, update count, len */ + sym++; + if (--(count[len]) == 0) { + if (len == max) break; + len = lens[work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) != low) { + /* if first time, transition to sub-tables */ + if (drop == 0) + drop = root; + + /* increment past last table */ + next += 1U << curr; + + /* determine length of next table */ + curr = len - drop; + left = (int)(1 << curr); + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) break; + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1U << curr; + if ((type == LENS && used >= ENOUGH_LENS) || + (type == DISTS && used >= ENOUGH_DISTS)) + return 1; + + /* point entry in root table to sub-table */ + low = huff & mask; + (*table)[low].op = (unsigned char)curr; + (*table)[low].bits = (unsigned char)root; + (*table)[low].val = (unsigned short)(next - *table); + } + } + + /* + Fill in rest of table for incomplete codes. This loop is similar to the + loop above in incrementing huff for table indices. It is assumed that + len is equal to curr + drop, so there is no loop needed to increment + through high index bits. When the current sub-table is filled, the loop + drops back to the root table to fill in any remaining entries there. + */ + this.op = (unsigned char)64; /* invalid code marker */ + this.bits = (unsigned char)(len - drop); + this.val = (unsigned short)0; + while (huff != 0) { + /* when done with sub-table, drop back to root table */ + if (drop != 0 && (huff & mask) != low) { + drop = 0; + len = root; + next = *table; + curr = root; + this.bits = (unsigned char)len; + } + + /* put invalid code marker in table */ + next[huff >> drop] = this; + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + } + + /* set return parameters */ + *table += used; + *bits = root; + return 0; +} diff --git a/xs/src/png/zlib/contrib/infback9/inftree9.h b/xs/src/png/zlib/contrib/infback9/inftree9.h new file mode 100644 index 0000000000..5ab21f0c6d --- /dev/null +++ b/xs/src/png/zlib/contrib/infback9/inftree9.h @@ -0,0 +1,61 @@ +/* inftree9.h -- header to use inftree9.c + * Copyright (C) 1995-2008 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + +/* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 100eeeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + +/* Maximum size of the dynamic table. The maximum number of code structures is + 1446, which is the sum of 852 for literal/length codes and 594 for distance + codes. These values were found by exhaustive searches using the program + examples/enough.c found in the zlib distribtution. The arguments to that + program are the number of symbols, the initial root table size, and the + maximum bit length of a code. "enough 286 9 15" for literal/length codes + returns returns 852, and "enough 32 6 15" for distance codes returns 594. + The initial root table size (9 or 6) is found in the fifth argument of the + inflate_table() calls in infback9.c. If the root table size is changed, + then these maximum sizes would be need to be recalculated and updated. */ +#define ENOUGH_LENS 852 +#define ENOUGH_DISTS 594 +#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) + +/* Type of code to build for inflate_table9() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; + +extern int inflate_table9 OF((codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work)); diff --git a/xs/src/png/zlib/contrib/inflate86/inffas86.c b/xs/src/png/zlib/contrib/inflate86/inffas86.c new file mode 100644 index 0000000000..7292f67b75 --- /dev/null +++ b/xs/src/png/zlib/contrib/inflate86/inffas86.c @@ -0,0 +1,1157 @@ +/* inffas86.c is a hand tuned assembler version of + * + * inffast.c -- fast decoding + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Copyright (C) 2003 Chris Anderson + * Please use the copyright conditions above. + * + * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also + * slightly quicker on x86 systems because, instead of using rep movsb to copy + * data, it uses rep movsw, which moves data in 2-byte chunks instead of single + * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates + * from http://fedora.linux.duke.edu/fc1_x86_64 + * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with + * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version, + * when decompressing mozilla-source-1.3.tar.gz. + * + * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from + * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at + * the moment. I have successfully compiled and tested this code with gcc2.96, + * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S + * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX + * enabled. I will attempt to merge the MMX code into this version. Newer + * versions of this and inffast.S can be found at + * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +/* Mark Adler's comments from inffast.c: */ + +/* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state->mode == LEN + strm->avail_in >= 6 + strm->avail_out >= 258 + start >= strm->avail_out + state->bits < 8 + + On return, state->mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm->avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm->avail_out >= 258 for each loop to avoid checking for + output space. + */ +void inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + struct inffast_ar { +/* 64 32 x86 x86_64 */ +/* ar offset register */ +/* 0 0 */ void *esp; /* esp save */ +/* 8 4 */ void *ebp; /* ebp save */ +/* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */ +/* 24 12 */ unsigned char FAR *last; /* r9 while in < last */ +/* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */ +/* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */ +/* 48 24 */ unsigned char FAR *end; /* r10 while out < end */ +/* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */ +/* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */ +/* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */ +/* 80 40 */ unsigned long hold; /* edx rdx local strm->hold */ +/* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */ +/* 92 48 */ unsigned wsize; /* window size */ +/* 96 52 */ unsigned write; /* window write index */ +/*100 56 */ unsigned lmask; /* r12 mask for lcode */ +/*104 60 */ unsigned dmask; /* r13 mask for dcode */ +/*108 64 */ unsigned len; /* r14 match length */ +/*112 68 */ unsigned dist; /* r15 match distance */ +/*116 72 */ unsigned status; /* set when state chng*/ + } ar; + +#if defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 ) +#define PAD_AVAIL_IN 6 +#define PAD_AVAIL_OUT 258 +#else +#define PAD_AVAIL_IN 5 +#define PAD_AVAIL_OUT 257 +#endif + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + ar.in = strm->next_in; + ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN); + ar.out = strm->next_out; + ar.beg = ar.out - (start - strm->avail_out); + ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT); + ar.wsize = state->wsize; + ar.write = state->wnext; + ar.window = state->window; + ar.hold = state->hold; + ar.bits = state->bits; + ar.lcode = state->lencode; + ar.dcode = state->distcode; + ar.lmask = (1U << state->lenbits) - 1; + ar.dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + + /* align in on 1/2 hold size boundary */ + while (((unsigned long)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) { + ar.hold += (unsigned long)*ar.in++ << ar.bits; + ar.bits += 8; + } + +#if defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 ) + __asm__ __volatile__ ( +" leaq %0, %%rax\n" +" movq %%rbp, 8(%%rax)\n" /* save regs rbp and rsp */ +" movq %%rsp, (%%rax)\n" +" movq %%rax, %%rsp\n" /* make rsp point to &ar */ +" movq 16(%%rsp), %%rsi\n" /* rsi = in */ +" movq 32(%%rsp), %%rdi\n" /* rdi = out */ +" movq 24(%%rsp), %%r9\n" /* r9 = last */ +" movq 48(%%rsp), %%r10\n" /* r10 = end */ +" movq 64(%%rsp), %%rbp\n" /* rbp = lcode */ +" movq 72(%%rsp), %%r11\n" /* r11 = dcode */ +" movq 80(%%rsp), %%rdx\n" /* rdx = hold */ +" movl 88(%%rsp), %%ebx\n" /* ebx = bits */ +" movl 100(%%rsp), %%r12d\n" /* r12d = lmask */ +" movl 104(%%rsp), %%r13d\n" /* r13d = dmask */ + /* r14d = len */ + /* r15d = dist */ +" cld\n" +" cmpq %%rdi, %%r10\n" +" je .L_one_time\n" /* if only one decode left */ +" cmpq %%rsi, %%r9\n" +" je .L_one_time\n" +" jmp .L_do_loop\n" + +".L_one_time:\n" +" movq %%r12, %%r8\n" /* r8 = lmask */ +" cmpb $32, %%bl\n" +" ja .L_get_length_code_one_time\n" + +" lodsl\n" /* eax = *(uint *)in++ */ +" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ +" addb $32, %%bl\n" /* bits += 32 */ +" shlq %%cl, %%rax\n" +" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ +" jmp .L_get_length_code_one_time\n" + +".align 32,0x90\n" +".L_while_test:\n" +" cmpq %%rdi, %%r10\n" +" jbe .L_break_loop\n" +" cmpq %%rsi, %%r9\n" +" jbe .L_break_loop\n" + +".L_do_loop:\n" +" movq %%r12, %%r8\n" /* r8 = lmask */ +" cmpb $32, %%bl\n" +" ja .L_get_length_code\n" /* if (32 < bits) */ + +" lodsl\n" /* eax = *(uint *)in++ */ +" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ +" addb $32, %%bl\n" /* bits += 32 */ +" shlq %%cl, %%rax\n" +" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ + +".L_get_length_code:\n" +" andq %%rdx, %%r8\n" /* r8 &= hold */ +" movl (%%rbp,%%r8,4), %%eax\n" /* eax = lcode[hold & lmask] */ + +" movb %%ah, %%cl\n" /* cl = this.bits */ +" subb %%ah, %%bl\n" /* bits -= this.bits */ +" shrq %%cl, %%rdx\n" /* hold >>= this.bits */ + +" testb %%al, %%al\n" +" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ + +" movq %%r12, %%r8\n" /* r8 = lmask */ +" shrl $16, %%eax\n" /* output this.val char */ +" stosb\n" + +".L_get_length_code_one_time:\n" +" andq %%rdx, %%r8\n" /* r8 &= hold */ +" movl (%%rbp,%%r8,4), %%eax\n" /* eax = lcode[hold & lmask] */ + +".L_dolen:\n" +" movb %%ah, %%cl\n" /* cl = this.bits */ +" subb %%ah, %%bl\n" /* bits -= this.bits */ +" shrq %%cl, %%rdx\n" /* hold >>= this.bits */ + +" testb %%al, %%al\n" +" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ + +" shrl $16, %%eax\n" /* output this.val char */ +" stosb\n" +" jmp .L_while_test\n" + +".align 32,0x90\n" +".L_test_for_length_base:\n" +" movl %%eax, %%r14d\n" /* len = this */ +" shrl $16, %%r14d\n" /* len = this.val */ +" movb %%al, %%cl\n" + +" testb $16, %%al\n" +" jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */ +" andb $15, %%cl\n" /* op &= 15 */ +" jz .L_decode_distance\n" /* if (!op) */ + +".L_add_bits_to_len:\n" +" subb %%cl, %%bl\n" +" xorl %%eax, %%eax\n" +" incl %%eax\n" +" shll %%cl, %%eax\n" +" decl %%eax\n" +" andl %%edx, %%eax\n" /* eax &= hold */ +" shrq %%cl, %%rdx\n" +" addl %%eax, %%r14d\n" /* len += hold & mask[op] */ + +".L_decode_distance:\n" +" movq %%r13, %%r8\n" /* r8 = dmask */ +" cmpb $32, %%bl\n" +" ja .L_get_distance_code\n" /* if (32 < bits) */ + +" lodsl\n" /* eax = *(uint *)in++ */ +" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ +" addb $32, %%bl\n" /* bits += 32 */ +" shlq %%cl, %%rax\n" +" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ + +".L_get_distance_code:\n" +" andq %%rdx, %%r8\n" /* r8 &= hold */ +" movl (%%r11,%%r8,4), %%eax\n" /* eax = dcode[hold & dmask] */ + +".L_dodist:\n" +" movl %%eax, %%r15d\n" /* dist = this */ +" shrl $16, %%r15d\n" /* dist = this.val */ +" movb %%ah, %%cl\n" +" subb %%ah, %%bl\n" /* bits -= this.bits */ +" shrq %%cl, %%rdx\n" /* hold >>= this.bits */ +" movb %%al, %%cl\n" /* cl = this.op */ + +" testb $16, %%al\n" /* if ((op & 16) == 0) */ +" jz .L_test_for_second_level_dist\n" +" andb $15, %%cl\n" /* op &= 15 */ +" jz .L_check_dist_one\n" + +".L_add_bits_to_dist:\n" +" subb %%cl, %%bl\n" +" xorl %%eax, %%eax\n" +" incl %%eax\n" +" shll %%cl, %%eax\n" +" decl %%eax\n" /* (1 << op) - 1 */ +" andl %%edx, %%eax\n" /* eax &= hold */ +" shrq %%cl, %%rdx\n" +" addl %%eax, %%r15d\n" /* dist += hold & ((1 << op) - 1) */ + +".L_check_window:\n" +" movq %%rsi, %%r8\n" /* save in so from can use it's reg */ +" movq %%rdi, %%rax\n" +" subq 40(%%rsp), %%rax\n" /* nbytes = out - beg */ + +" cmpl %%r15d, %%eax\n" +" jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */ + +" movl %%r14d, %%ecx\n" /* ecx = len */ +" movq %%rdi, %%rsi\n" +" subq %%r15, %%rsi\n" /* from = out - dist */ + +" sarl %%ecx\n" +" jnc .L_copy_two\n" /* if len % 2 == 0 */ + +" rep movsw\n" +" movb (%%rsi), %%al\n" +" movb %%al, (%%rdi)\n" +" incq %%rdi\n" + +" movq %%r8, %%rsi\n" /* move in back to %rsi, toss from */ +" jmp .L_while_test\n" + +".L_copy_two:\n" +" rep movsw\n" +" movq %%r8, %%rsi\n" /* move in back to %rsi, toss from */ +" jmp .L_while_test\n" + +".align 32,0x90\n" +".L_check_dist_one:\n" +" cmpl $1, %%r15d\n" /* if dist 1, is a memset */ +" jne .L_check_window\n" +" cmpq %%rdi, 40(%%rsp)\n" /* if out == beg, outside window */ +" je .L_check_window\n" + +" movl %%r14d, %%ecx\n" /* ecx = len */ +" movb -1(%%rdi), %%al\n" +" movb %%al, %%ah\n" + +" sarl %%ecx\n" +" jnc .L_set_two\n" +" movb %%al, (%%rdi)\n" +" incq %%rdi\n" + +".L_set_two:\n" +" rep stosw\n" +" jmp .L_while_test\n" + +".align 32,0x90\n" +".L_test_for_second_level_length:\n" +" testb $64, %%al\n" +" jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */ + +" xorl %%eax, %%eax\n" +" incl %%eax\n" +" shll %%cl, %%eax\n" +" decl %%eax\n" +" andl %%edx, %%eax\n" /* eax &= hold */ +" addl %%r14d, %%eax\n" /* eax += len */ +" movl (%%rbp,%%rax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/ +" jmp .L_dolen\n" + +".align 32,0x90\n" +".L_test_for_second_level_dist:\n" +" testb $64, %%al\n" +" jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */ + +" xorl %%eax, %%eax\n" +" incl %%eax\n" +" shll %%cl, %%eax\n" +" decl %%eax\n" +" andl %%edx, %%eax\n" /* eax &= hold */ +" addl %%r15d, %%eax\n" /* eax += dist */ +" movl (%%r11,%%rax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/ +" jmp .L_dodist\n" + +".align 32,0x90\n" +".L_clip_window:\n" +" movl %%eax, %%ecx\n" /* ecx = nbytes */ +" movl 92(%%rsp), %%eax\n" /* eax = wsize, prepare for dist cmp */ +" negl %%ecx\n" /* nbytes = -nbytes */ + +" cmpl %%r15d, %%eax\n" +" jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */ + +" addl %%r15d, %%ecx\n" /* nbytes = dist - nbytes */ +" cmpl $0, 96(%%rsp)\n" +" jne .L_wrap_around_window\n" /* if (write != 0) */ + +" movq 56(%%rsp), %%rsi\n" /* from = window */ +" subl %%ecx, %%eax\n" /* eax -= nbytes */ +" addq %%rax, %%rsi\n" /* from += wsize - nbytes */ + +" movl %%r14d, %%eax\n" /* eax = len */ +" cmpl %%ecx, %%r14d\n" +" jbe .L_do_copy\n" /* if (nbytes >= len) */ + +" subl %%ecx, %%eax\n" /* eax -= nbytes */ +" rep movsb\n" +" movq %%rdi, %%rsi\n" +" subq %%r15, %%rsi\n" /* from = &out[ -dist ] */ +" jmp .L_do_copy\n" + +".align 32,0x90\n" +".L_wrap_around_window:\n" +" movl 96(%%rsp), %%eax\n" /* eax = write */ +" cmpl %%eax, %%ecx\n" +" jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */ + +" movl 92(%%rsp), %%esi\n" /* from = wsize */ +" addq 56(%%rsp), %%rsi\n" /* from += window */ +" addq %%rax, %%rsi\n" /* from += write */ +" subq %%rcx, %%rsi\n" /* from -= nbytes */ +" subl %%eax, %%ecx\n" /* nbytes -= write */ + +" movl %%r14d, %%eax\n" /* eax = len */ +" cmpl %%ecx, %%eax\n" +" jbe .L_do_copy\n" /* if (nbytes >= len) */ + +" subl %%ecx, %%eax\n" /* len -= nbytes */ +" rep movsb\n" +" movq 56(%%rsp), %%rsi\n" /* from = window */ +" movl 96(%%rsp), %%ecx\n" /* nbytes = write */ +" cmpl %%ecx, %%eax\n" +" jbe .L_do_copy\n" /* if (nbytes >= len) */ + +" subl %%ecx, %%eax\n" /* len -= nbytes */ +" rep movsb\n" +" movq %%rdi, %%rsi\n" +" subq %%r15, %%rsi\n" /* from = out - dist */ +" jmp .L_do_copy\n" + +".align 32,0x90\n" +".L_contiguous_in_window:\n" +" movq 56(%%rsp), %%rsi\n" /* rsi = window */ +" addq %%rax, %%rsi\n" +" subq %%rcx, %%rsi\n" /* from += write - nbytes */ + +" movl %%r14d, %%eax\n" /* eax = len */ +" cmpl %%ecx, %%eax\n" +" jbe .L_do_copy\n" /* if (nbytes >= len) */ + +" subl %%ecx, %%eax\n" /* len -= nbytes */ +" rep movsb\n" +" movq %%rdi, %%rsi\n" +" subq %%r15, %%rsi\n" /* from = out - dist */ +" jmp .L_do_copy\n" /* if (nbytes >= len) */ + +".align 32,0x90\n" +".L_do_copy:\n" +" movl %%eax, %%ecx\n" /* ecx = len */ +" rep movsb\n" + +" movq %%r8, %%rsi\n" /* move in back to %esi, toss from */ +" jmp .L_while_test\n" + +".L_test_for_end_of_block:\n" +" testb $32, %%al\n" +" jz .L_invalid_literal_length_code\n" +" movl $1, 116(%%rsp)\n" +" jmp .L_break_loop_with_status\n" + +".L_invalid_literal_length_code:\n" +" movl $2, 116(%%rsp)\n" +" jmp .L_break_loop_with_status\n" + +".L_invalid_distance_code:\n" +" movl $3, 116(%%rsp)\n" +" jmp .L_break_loop_with_status\n" + +".L_invalid_distance_too_far:\n" +" movl $4, 116(%%rsp)\n" +" jmp .L_break_loop_with_status\n" + +".L_break_loop:\n" +" movl $0, 116(%%rsp)\n" + +".L_break_loop_with_status:\n" +/* put in, out, bits, and hold back into ar and pop esp */ +" movq %%rsi, 16(%%rsp)\n" /* in */ +" movq %%rdi, 32(%%rsp)\n" /* out */ +" movl %%ebx, 88(%%rsp)\n" /* bits */ +" movq %%rdx, 80(%%rsp)\n" /* hold */ +" movq (%%rsp), %%rax\n" /* restore rbp and rsp */ +" movq 8(%%rsp), %%rbp\n" +" movq %%rax, %%rsp\n" + : + : "m" (ar) + : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", + "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" + ); +#elif ( defined( __GNUC__ ) || defined( __ICC ) ) && defined( __i386 ) + __asm__ __volatile__ ( +" leal %0, %%eax\n" +" movl %%esp, (%%eax)\n" /* save esp, ebp */ +" movl %%ebp, 4(%%eax)\n" +" movl %%eax, %%esp\n" +" movl 8(%%esp), %%esi\n" /* esi = in */ +" movl 16(%%esp), %%edi\n" /* edi = out */ +" movl 40(%%esp), %%edx\n" /* edx = hold */ +" movl 44(%%esp), %%ebx\n" /* ebx = bits */ +" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ + +" cld\n" +" jmp .L_do_loop\n" + +".align 32,0x90\n" +".L_while_test:\n" +" cmpl %%edi, 24(%%esp)\n" /* out < end */ +" jbe .L_break_loop\n" +" cmpl %%esi, 12(%%esp)\n" /* in < last */ +" jbe .L_break_loop\n" + +".L_do_loop:\n" +" cmpb $15, %%bl\n" +" ja .L_get_length_code\n" /* if (15 < bits) */ + +" xorl %%eax, %%eax\n" +" lodsw\n" /* al = *(ushort *)in++ */ +" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ +" addb $16, %%bl\n" /* bits += 16 */ +" shll %%cl, %%eax\n" +" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ + +".L_get_length_code:\n" +" movl 56(%%esp), %%eax\n" /* eax = lmask */ +" andl %%edx, %%eax\n" /* eax &= hold */ +" movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[hold & lmask] */ + +".L_dolen:\n" +" movb %%ah, %%cl\n" /* cl = this.bits */ +" subb %%ah, %%bl\n" /* bits -= this.bits */ +" shrl %%cl, %%edx\n" /* hold >>= this.bits */ + +" testb %%al, %%al\n" +" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ + +" shrl $16, %%eax\n" /* output this.val char */ +" stosb\n" +" jmp .L_while_test\n" + +".align 32,0x90\n" +".L_test_for_length_base:\n" +" movl %%eax, %%ecx\n" /* len = this */ +" shrl $16, %%ecx\n" /* len = this.val */ +" movl %%ecx, 64(%%esp)\n" /* save len */ +" movb %%al, %%cl\n" + +" testb $16, %%al\n" +" jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */ +" andb $15, %%cl\n" /* op &= 15 */ +" jz .L_decode_distance\n" /* if (!op) */ +" cmpb %%cl, %%bl\n" +" jae .L_add_bits_to_len\n" /* if (op <= bits) */ + +" movb %%cl, %%ch\n" /* stash op in ch, freeing cl */ +" xorl %%eax, %%eax\n" +" lodsw\n" /* al = *(ushort *)in++ */ +" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ +" addb $16, %%bl\n" /* bits += 16 */ +" shll %%cl, %%eax\n" +" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ +" movb %%ch, %%cl\n" /* move op back to ecx */ + +".L_add_bits_to_len:\n" +" subb %%cl, %%bl\n" +" xorl %%eax, %%eax\n" +" incl %%eax\n" +" shll %%cl, %%eax\n" +" decl %%eax\n" +" andl %%edx, %%eax\n" /* eax &= hold */ +" shrl %%cl, %%edx\n" +" addl %%eax, 64(%%esp)\n" /* len += hold & mask[op] */ + +".L_decode_distance:\n" +" cmpb $15, %%bl\n" +" ja .L_get_distance_code\n" /* if (15 < bits) */ + +" xorl %%eax, %%eax\n" +" lodsw\n" /* al = *(ushort *)in++ */ +" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ +" addb $16, %%bl\n" /* bits += 16 */ +" shll %%cl, %%eax\n" +" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ + +".L_get_distance_code:\n" +" movl 60(%%esp), %%eax\n" /* eax = dmask */ +" movl 36(%%esp), %%ecx\n" /* ecx = dcode */ +" andl %%edx, %%eax\n" /* eax &= hold */ +" movl (%%ecx,%%eax,4), %%eax\n"/* eax = dcode[hold & dmask] */ + +".L_dodist:\n" +" movl %%eax, %%ebp\n" /* dist = this */ +" shrl $16, %%ebp\n" /* dist = this.val */ +" movb %%ah, %%cl\n" +" subb %%ah, %%bl\n" /* bits -= this.bits */ +" shrl %%cl, %%edx\n" /* hold >>= this.bits */ +" movb %%al, %%cl\n" /* cl = this.op */ + +" testb $16, %%al\n" /* if ((op & 16) == 0) */ +" jz .L_test_for_second_level_dist\n" +" andb $15, %%cl\n" /* op &= 15 */ +" jz .L_check_dist_one\n" +" cmpb %%cl, %%bl\n" +" jae .L_add_bits_to_dist\n" /* if (op <= bits) 97.6% */ + +" movb %%cl, %%ch\n" /* stash op in ch, freeing cl */ +" xorl %%eax, %%eax\n" +" lodsw\n" /* al = *(ushort *)in++ */ +" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ +" addb $16, %%bl\n" /* bits += 16 */ +" shll %%cl, %%eax\n" +" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ +" movb %%ch, %%cl\n" /* move op back to ecx */ + +".L_add_bits_to_dist:\n" +" subb %%cl, %%bl\n" +" xorl %%eax, %%eax\n" +" incl %%eax\n" +" shll %%cl, %%eax\n" +" decl %%eax\n" /* (1 << op) - 1 */ +" andl %%edx, %%eax\n" /* eax &= hold */ +" shrl %%cl, %%edx\n" +" addl %%eax, %%ebp\n" /* dist += hold & ((1 << op) - 1) */ + +".L_check_window:\n" +" movl %%esi, 8(%%esp)\n" /* save in so from can use it's reg */ +" movl %%edi, %%eax\n" +" subl 20(%%esp), %%eax\n" /* nbytes = out - beg */ + +" cmpl %%ebp, %%eax\n" +" jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */ + +" movl 64(%%esp), %%ecx\n" /* ecx = len */ +" movl %%edi, %%esi\n" +" subl %%ebp, %%esi\n" /* from = out - dist */ + +" sarl %%ecx\n" +" jnc .L_copy_two\n" /* if len % 2 == 0 */ + +" rep movsw\n" +" movb (%%esi), %%al\n" +" movb %%al, (%%edi)\n" +" incl %%edi\n" + +" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ +" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ +" jmp .L_while_test\n" + +".L_copy_two:\n" +" rep movsw\n" +" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ +" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ +" jmp .L_while_test\n" + +".align 32,0x90\n" +".L_check_dist_one:\n" +" cmpl $1, %%ebp\n" /* if dist 1, is a memset */ +" jne .L_check_window\n" +" cmpl %%edi, 20(%%esp)\n" +" je .L_check_window\n" /* out == beg, if outside window */ + +" movl 64(%%esp), %%ecx\n" /* ecx = len */ +" movb -1(%%edi), %%al\n" +" movb %%al, %%ah\n" + +" sarl %%ecx\n" +" jnc .L_set_two\n" +" movb %%al, (%%edi)\n" +" incl %%edi\n" + +".L_set_two:\n" +" rep stosw\n" +" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ +" jmp .L_while_test\n" + +".align 32,0x90\n" +".L_test_for_second_level_length:\n" +" testb $64, %%al\n" +" jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */ + +" xorl %%eax, %%eax\n" +" incl %%eax\n" +" shll %%cl, %%eax\n" +" decl %%eax\n" +" andl %%edx, %%eax\n" /* eax &= hold */ +" addl 64(%%esp), %%eax\n" /* eax += len */ +" movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/ +" jmp .L_dolen\n" + +".align 32,0x90\n" +".L_test_for_second_level_dist:\n" +" testb $64, %%al\n" +" jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */ + +" xorl %%eax, %%eax\n" +" incl %%eax\n" +" shll %%cl, %%eax\n" +" decl %%eax\n" +" andl %%edx, %%eax\n" /* eax &= hold */ +" addl %%ebp, %%eax\n" /* eax += dist */ +" movl 36(%%esp), %%ecx\n" /* ecx = dcode */ +" movl (%%ecx,%%eax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/ +" jmp .L_dodist\n" + +".align 32,0x90\n" +".L_clip_window:\n" +" movl %%eax, %%ecx\n" +" movl 48(%%esp), %%eax\n" /* eax = wsize */ +" negl %%ecx\n" /* nbytes = -nbytes */ +" movl 28(%%esp), %%esi\n" /* from = window */ + +" cmpl %%ebp, %%eax\n" +" jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */ + +" addl %%ebp, %%ecx\n" /* nbytes = dist - nbytes */ +" cmpl $0, 52(%%esp)\n" +" jne .L_wrap_around_window\n" /* if (write != 0) */ + +" subl %%ecx, %%eax\n" +" addl %%eax, %%esi\n" /* from += wsize - nbytes */ + +" movl 64(%%esp), %%eax\n" /* eax = len */ +" cmpl %%ecx, %%eax\n" +" jbe .L_do_copy\n" /* if (nbytes >= len) */ + +" subl %%ecx, %%eax\n" /* len -= nbytes */ +" rep movsb\n" +" movl %%edi, %%esi\n" +" subl %%ebp, %%esi\n" /* from = out - dist */ +" jmp .L_do_copy\n" + +".align 32,0x90\n" +".L_wrap_around_window:\n" +" movl 52(%%esp), %%eax\n" /* eax = write */ +" cmpl %%eax, %%ecx\n" +" jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */ + +" addl 48(%%esp), %%esi\n" /* from += wsize */ +" addl %%eax, %%esi\n" /* from += write */ +" subl %%ecx, %%esi\n" /* from -= nbytes */ +" subl %%eax, %%ecx\n" /* nbytes -= write */ + +" movl 64(%%esp), %%eax\n" /* eax = len */ +" cmpl %%ecx, %%eax\n" +" jbe .L_do_copy\n" /* if (nbytes >= len) */ + +" subl %%ecx, %%eax\n" /* len -= nbytes */ +" rep movsb\n" +" movl 28(%%esp), %%esi\n" /* from = window */ +" movl 52(%%esp), %%ecx\n" /* nbytes = write */ +" cmpl %%ecx, %%eax\n" +" jbe .L_do_copy\n" /* if (nbytes >= len) */ + +" subl %%ecx, %%eax\n" /* len -= nbytes */ +" rep movsb\n" +" movl %%edi, %%esi\n" +" subl %%ebp, %%esi\n" /* from = out - dist */ +" jmp .L_do_copy\n" + +".align 32,0x90\n" +".L_contiguous_in_window:\n" +" addl %%eax, %%esi\n" +" subl %%ecx, %%esi\n" /* from += write - nbytes */ + +" movl 64(%%esp), %%eax\n" /* eax = len */ +" cmpl %%ecx, %%eax\n" +" jbe .L_do_copy\n" /* if (nbytes >= len) */ + +" subl %%ecx, %%eax\n" /* len -= nbytes */ +" rep movsb\n" +" movl %%edi, %%esi\n" +" subl %%ebp, %%esi\n" /* from = out - dist */ +" jmp .L_do_copy\n" /* if (nbytes >= len) */ + +".align 32,0x90\n" +".L_do_copy:\n" +" movl %%eax, %%ecx\n" +" rep movsb\n" + +" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ +" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ +" jmp .L_while_test\n" + +".L_test_for_end_of_block:\n" +" testb $32, %%al\n" +" jz .L_invalid_literal_length_code\n" +" movl $1, 72(%%esp)\n" +" jmp .L_break_loop_with_status\n" + +".L_invalid_literal_length_code:\n" +" movl $2, 72(%%esp)\n" +" jmp .L_break_loop_with_status\n" + +".L_invalid_distance_code:\n" +" movl $3, 72(%%esp)\n" +" jmp .L_break_loop_with_status\n" + +".L_invalid_distance_too_far:\n" +" movl 8(%%esp), %%esi\n" +" movl $4, 72(%%esp)\n" +" jmp .L_break_loop_with_status\n" + +".L_break_loop:\n" +" movl $0, 72(%%esp)\n" + +".L_break_loop_with_status:\n" +/* put in, out, bits, and hold back into ar and pop esp */ +" movl %%esi, 8(%%esp)\n" /* save in */ +" movl %%edi, 16(%%esp)\n" /* save out */ +" movl %%ebx, 44(%%esp)\n" /* save bits */ +" movl %%edx, 40(%%esp)\n" /* save hold */ +" movl 4(%%esp), %%ebp\n" /* restore esp, ebp */ +" movl (%%esp), %%esp\n" + : + : "m" (ar) + : "memory", "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" + ); +#elif defined( _MSC_VER ) && ! defined( _M_AMD64 ) + __asm { + lea eax, ar + mov [eax], esp /* save esp, ebp */ + mov [eax+4], ebp + mov esp, eax + mov esi, [esp+8] /* esi = in */ + mov edi, [esp+16] /* edi = out */ + mov edx, [esp+40] /* edx = hold */ + mov ebx, [esp+44] /* ebx = bits */ + mov ebp, [esp+32] /* ebp = lcode */ + + cld + jmp L_do_loop + +ALIGN 4 +L_while_test: + cmp [esp+24], edi + jbe L_break_loop + cmp [esp+12], esi + jbe L_break_loop + +L_do_loop: + cmp bl, 15 + ja L_get_length_code /* if (15 < bits) */ + + xor eax, eax + lodsw /* al = *(ushort *)in++ */ + mov cl, bl /* cl = bits, needs it for shifting */ + add bl, 16 /* bits += 16 */ + shl eax, cl + or edx, eax /* hold |= *((ushort *)in)++ << bits */ + +L_get_length_code: + mov eax, [esp+56] /* eax = lmask */ + and eax, edx /* eax &= hold */ + mov eax, [ebp+eax*4] /* eax = lcode[hold & lmask] */ + +L_dolen: + mov cl, ah /* cl = this.bits */ + sub bl, ah /* bits -= this.bits */ + shr edx, cl /* hold >>= this.bits */ + + test al, al + jnz L_test_for_length_base /* if (op != 0) 45.7% */ + + shr eax, 16 /* output this.val char */ + stosb + jmp L_while_test + +ALIGN 4 +L_test_for_length_base: + mov ecx, eax /* len = this */ + shr ecx, 16 /* len = this.val */ + mov [esp+64], ecx /* save len */ + mov cl, al + + test al, 16 + jz L_test_for_second_level_length /* if ((op & 16) == 0) 8% */ + and cl, 15 /* op &= 15 */ + jz L_decode_distance /* if (!op) */ + cmp bl, cl + jae L_add_bits_to_len /* if (op <= bits) */ + + mov ch, cl /* stash op in ch, freeing cl */ + xor eax, eax + lodsw /* al = *(ushort *)in++ */ + mov cl, bl /* cl = bits, needs it for shifting */ + add bl, 16 /* bits += 16 */ + shl eax, cl + or edx, eax /* hold |= *((ushort *)in)++ << bits */ + mov cl, ch /* move op back to ecx */ + +L_add_bits_to_len: + sub bl, cl + xor eax, eax + inc eax + shl eax, cl + dec eax + and eax, edx /* eax &= hold */ + shr edx, cl + add [esp+64], eax /* len += hold & mask[op] */ + +L_decode_distance: + cmp bl, 15 + ja L_get_distance_code /* if (15 < bits) */ + + xor eax, eax + lodsw /* al = *(ushort *)in++ */ + mov cl, bl /* cl = bits, needs it for shifting */ + add bl, 16 /* bits += 16 */ + shl eax, cl + or edx, eax /* hold |= *((ushort *)in)++ << bits */ + +L_get_distance_code: + mov eax, [esp+60] /* eax = dmask */ + mov ecx, [esp+36] /* ecx = dcode */ + and eax, edx /* eax &= hold */ + mov eax, [ecx+eax*4]/* eax = dcode[hold & dmask] */ + +L_dodist: + mov ebp, eax /* dist = this */ + shr ebp, 16 /* dist = this.val */ + mov cl, ah + sub bl, ah /* bits -= this.bits */ + shr edx, cl /* hold >>= this.bits */ + mov cl, al /* cl = this.op */ + + test al, 16 /* if ((op & 16) == 0) */ + jz L_test_for_second_level_dist + and cl, 15 /* op &= 15 */ + jz L_check_dist_one + cmp bl, cl + jae L_add_bits_to_dist /* if (op <= bits) 97.6% */ + + mov ch, cl /* stash op in ch, freeing cl */ + xor eax, eax + lodsw /* al = *(ushort *)in++ */ + mov cl, bl /* cl = bits, needs it for shifting */ + add bl, 16 /* bits += 16 */ + shl eax, cl + or edx, eax /* hold |= *((ushort *)in)++ << bits */ + mov cl, ch /* move op back to ecx */ + +L_add_bits_to_dist: + sub bl, cl + xor eax, eax + inc eax + shl eax, cl + dec eax /* (1 << op) - 1 */ + and eax, edx /* eax &= hold */ + shr edx, cl + add ebp, eax /* dist += hold & ((1 << op) - 1) */ + +L_check_window: + mov [esp+8], esi /* save in so from can use it's reg */ + mov eax, edi + sub eax, [esp+20] /* nbytes = out - beg */ + + cmp eax, ebp + jb L_clip_window /* if (dist > nbytes) 4.2% */ + + mov ecx, [esp+64] /* ecx = len */ + mov esi, edi + sub esi, ebp /* from = out - dist */ + + sar ecx, 1 + jnc L_copy_two + + rep movsw + mov al, [esi] + mov [edi], al + inc edi + + mov esi, [esp+8] /* move in back to %esi, toss from */ + mov ebp, [esp+32] /* ebp = lcode */ + jmp L_while_test + +L_copy_two: + rep movsw + mov esi, [esp+8] /* move in back to %esi, toss from */ + mov ebp, [esp+32] /* ebp = lcode */ + jmp L_while_test + +ALIGN 4 +L_check_dist_one: + cmp ebp, 1 /* if dist 1, is a memset */ + jne L_check_window + cmp [esp+20], edi + je L_check_window /* out == beg, if outside window */ + + mov ecx, [esp+64] /* ecx = len */ + mov al, [edi-1] + mov ah, al + + sar ecx, 1 + jnc L_set_two + mov [edi], al /* memset out with from[-1] */ + inc edi + +L_set_two: + rep stosw + mov ebp, [esp+32] /* ebp = lcode */ + jmp L_while_test + +ALIGN 4 +L_test_for_second_level_length: + test al, 64 + jnz L_test_for_end_of_block /* if ((op & 64) != 0) */ + + xor eax, eax + inc eax + shl eax, cl + dec eax + and eax, edx /* eax &= hold */ + add eax, [esp+64] /* eax += len */ + mov eax, [ebp+eax*4] /* eax = lcode[val+(hold&mask[op])]*/ + jmp L_dolen + +ALIGN 4 +L_test_for_second_level_dist: + test al, 64 + jnz L_invalid_distance_code /* if ((op & 64) != 0) */ + + xor eax, eax + inc eax + shl eax, cl + dec eax + and eax, edx /* eax &= hold */ + add eax, ebp /* eax += dist */ + mov ecx, [esp+36] /* ecx = dcode */ + mov eax, [ecx+eax*4] /* eax = dcode[val+(hold&mask[op])]*/ + jmp L_dodist + +ALIGN 4 +L_clip_window: + mov ecx, eax + mov eax, [esp+48] /* eax = wsize */ + neg ecx /* nbytes = -nbytes */ + mov esi, [esp+28] /* from = window */ + + cmp eax, ebp + jb L_invalid_distance_too_far /* if (dist > wsize) */ + + add ecx, ebp /* nbytes = dist - nbytes */ + cmp dword ptr [esp+52], 0 + jne L_wrap_around_window /* if (write != 0) */ + + sub eax, ecx + add esi, eax /* from += wsize - nbytes */ + + mov eax, [esp+64] /* eax = len */ + cmp eax, ecx + jbe L_do_copy /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, edi + sub esi, ebp /* from = out - dist */ + jmp L_do_copy + +ALIGN 4 +L_wrap_around_window: + mov eax, [esp+52] /* eax = write */ + cmp ecx, eax + jbe L_contiguous_in_window /* if (write >= nbytes) */ + + add esi, [esp+48] /* from += wsize */ + add esi, eax /* from += write */ + sub esi, ecx /* from -= nbytes */ + sub ecx, eax /* nbytes -= write */ + + mov eax, [esp+64] /* eax = len */ + cmp eax, ecx + jbe L_do_copy /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, [esp+28] /* from = window */ + mov ecx, [esp+52] /* nbytes = write */ + cmp eax, ecx + jbe L_do_copy /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, edi + sub esi, ebp /* from = out - dist */ + jmp L_do_copy + +ALIGN 4 +L_contiguous_in_window: + add esi, eax + sub esi, ecx /* from += write - nbytes */ + + mov eax, [esp+64] /* eax = len */ + cmp eax, ecx + jbe L_do_copy /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, edi + sub esi, ebp /* from = out - dist */ + jmp L_do_copy + +ALIGN 4 +L_do_copy: + mov ecx, eax + rep movsb + + mov esi, [esp+8] /* move in back to %esi, toss from */ + mov ebp, [esp+32] /* ebp = lcode */ + jmp L_while_test + +L_test_for_end_of_block: + test al, 32 + jz L_invalid_literal_length_code + mov dword ptr [esp+72], 1 + jmp L_break_loop_with_status + +L_invalid_literal_length_code: + mov dword ptr [esp+72], 2 + jmp L_break_loop_with_status + +L_invalid_distance_code: + mov dword ptr [esp+72], 3 + jmp L_break_loop_with_status + +L_invalid_distance_too_far: + mov esi, [esp+4] + mov dword ptr [esp+72], 4 + jmp L_break_loop_with_status + +L_break_loop: + mov dword ptr [esp+72], 0 + +L_break_loop_with_status: +/* put in, out, bits, and hold back into ar and pop esp */ + mov [esp+8], esi /* save in */ + mov [esp+16], edi /* save out */ + mov [esp+44], ebx /* save bits */ + mov [esp+40], edx /* save hold */ + mov ebp, [esp+4] /* restore esp, ebp */ + mov esp, [esp] + } +#else +#error "x86 architecture not defined" +#endif + + if (ar.status > 1) { + if (ar.status == 2) + strm->msg = "invalid literal/length code"; + else if (ar.status == 3) + strm->msg = "invalid distance code"; + else + strm->msg = "invalid distance too far back"; + state->mode = BAD; + } + else if ( ar.status == 1 ) { + state->mode = TYPE; + } + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + ar.len = ar.bits >> 3; + ar.in -= ar.len; + ar.bits -= ar.len << 3; + ar.hold &= (1U << ar.bits) - 1; + + /* update state and return */ + strm->next_in = ar.in; + strm->next_out = ar.out; + strm->avail_in = (unsigned)(ar.in < ar.last ? + PAD_AVAIL_IN + (ar.last - ar.in) : + PAD_AVAIL_IN - (ar.in - ar.last)); + strm->avail_out = (unsigned)(ar.out < ar.end ? + PAD_AVAIL_OUT + (ar.end - ar.out) : + PAD_AVAIL_OUT - (ar.out - ar.end)); + state->hold = ar.hold; + state->bits = ar.bits; + return; +} + diff --git a/xs/src/png/zlib/contrib/inflate86/inffast.S b/xs/src/png/zlib/contrib/inflate86/inffast.S new file mode 100644 index 0000000000..2245a2905b --- /dev/null +++ b/xs/src/png/zlib/contrib/inflate86/inffast.S @@ -0,0 +1,1368 @@ +/* + * inffast.S is a hand tuned assembler version of: + * + * inffast.c -- fast decoding + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Copyright (C) 2003 Chris Anderson + * Please use the copyright conditions above. + * + * This version (Jan-23-2003) of inflate_fast was coded and tested under + * GNU/Linux on a pentium 3, using the gcc-3.2 compiler distribution. On that + * machine, I found that gzip style archives decompressed about 20% faster than + * the gcc-3.2 -O3 -fomit-frame-pointer compiled version. Your results will + * depend on how large of a buffer is used for z_stream.next_in & next_out + * (8K-32K worked best for my 256K cpu cache) and how much overhead there is in + * stream processing I/O and crc32/addler32. In my case, this routine used + * 70% of the cpu time and crc32 used 20%. + * + * I am confident that this version will work in the general case, but I have + * not tested a wide variety of datasets or a wide variety of platforms. + * + * Jan-24-2003 -- Added -DUSE_MMX define for slightly faster inflating. + * It should be a runtime flag instead of compile time flag... + * + * Jan-26-2003 -- Added runtime check for MMX support with cpuid instruction. + * With -DUSE_MMX, only MMX code is compiled. With -DNO_MMX, only non-MMX code + * is compiled. Without either option, runtime detection is enabled. Runtime + * detection should work on all modern cpus and the recomended algorithm (flip + * ID bit on eflags and then use the cpuid instruction) is used in many + * multimedia applications. Tested under win2k with gcc-2.95 and gas-2.12 + * distributed with cygwin3. Compiling with gcc-2.95 -c inffast.S -o + * inffast.obj generates a COFF object which can then be linked with MSVC++ + * compiled code. Tested under FreeBSD 4.7 with gcc-2.95. + * + * Jan-28-2003 -- Tested Athlon XP... MMX mode is slower than no MMX (and + * slower than compiler generated code). Adjusted cpuid check to use the MMX + * code only for Pentiums < P4 until I have more data on the P4. Speed + * improvment is only about 15% on the Athlon when compared with code generated + * with MSVC++. Not sure yet, but I think the P4 will also be slower using the + * MMX mode because many of it's x86 ALU instructions execute in .5 cycles and + * have less latency than MMX ops. Added code to buffer the last 11 bytes of + * the input stream since the MMX code grabs bits in chunks of 32, which + * differs from the inffast.c algorithm. I don't think there would have been + * read overruns where a page boundary was crossed (a segfault), but there + * could have been overruns when next_in ends on unaligned memory (unintialized + * memory read). + * + * Mar-13-2003 -- P4 MMX is slightly slower than P4 NO_MMX. I created a C + * version of the non-MMX code so that it doesn't depend on zstrm and zstate + * structure offsets which are hard coded in this file. This was last tested + * with zlib-1.2.0 which is currently in beta testing, newer versions of this + * and inffas86.c can be found at http://www.eetbeetee.com/zlib/ and + * http://www.charm.net/~christop/zlib/ + */ + + +/* + * if you have underscore linking problems (_inflate_fast undefined), try + * using -DGAS_COFF + */ +#if ! defined( GAS_COFF ) && ! defined( GAS_ELF ) + +#if defined( WIN32 ) || defined( __CYGWIN__ ) +#define GAS_COFF /* windows object format */ +#else +#define GAS_ELF +#endif + +#endif /* ! GAS_COFF && ! GAS_ELF */ + + +#if defined( GAS_COFF ) + +/* coff externals have underscores */ +#define inflate_fast _inflate_fast +#define inflate_fast_use_mmx _inflate_fast_use_mmx + +#endif /* GAS_COFF */ + + +.file "inffast.S" + +.globl inflate_fast + +.text +.align 4,0 +.L_invalid_literal_length_code_msg: +.string "invalid literal/length code" + +.align 4,0 +.L_invalid_distance_code_msg: +.string "invalid distance code" + +.align 4,0 +.L_invalid_distance_too_far_msg: +.string "invalid distance too far back" + +#if ! defined( NO_MMX ) +.align 4,0 +.L_mask: /* mask[N] = ( 1 << N ) - 1 */ +.long 0 +.long 1 +.long 3 +.long 7 +.long 15 +.long 31 +.long 63 +.long 127 +.long 255 +.long 511 +.long 1023 +.long 2047 +.long 4095 +.long 8191 +.long 16383 +.long 32767 +.long 65535 +.long 131071 +.long 262143 +.long 524287 +.long 1048575 +.long 2097151 +.long 4194303 +.long 8388607 +.long 16777215 +.long 33554431 +.long 67108863 +.long 134217727 +.long 268435455 +.long 536870911 +.long 1073741823 +.long 2147483647 +.long 4294967295 +#endif /* NO_MMX */ + +.text + +/* + * struct z_stream offsets, in zlib.h + */ +#define next_in_strm 0 /* strm->next_in */ +#define avail_in_strm 4 /* strm->avail_in */ +#define next_out_strm 12 /* strm->next_out */ +#define avail_out_strm 16 /* strm->avail_out */ +#define msg_strm 24 /* strm->msg */ +#define state_strm 28 /* strm->state */ + +/* + * struct inflate_state offsets, in inflate.h + */ +#define mode_state 0 /* state->mode */ +#define wsize_state 32 /* state->wsize */ +#define write_state 40 /* state->write */ +#define window_state 44 /* state->window */ +#define hold_state 48 /* state->hold */ +#define bits_state 52 /* state->bits */ +#define lencode_state 68 /* state->lencode */ +#define distcode_state 72 /* state->distcode */ +#define lenbits_state 76 /* state->lenbits */ +#define distbits_state 80 /* state->distbits */ + +/* + * inflate_fast's activation record + */ +#define local_var_size 64 /* how much local space for vars */ +#define strm_sp 88 /* first arg: z_stream * (local_var_size + 24) */ +#define start_sp 92 /* second arg: unsigned int (local_var_size + 28) */ + +/* + * offsets for local vars on stack + */ +#define out 60 /* unsigned char* */ +#define window 56 /* unsigned char* */ +#define wsize 52 /* unsigned int */ +#define write 48 /* unsigned int */ +#define in 44 /* unsigned char* */ +#define beg 40 /* unsigned char* */ +#define buf 28 /* char[ 12 ] */ +#define len 24 /* unsigned int */ +#define last 20 /* unsigned char* */ +#define end 16 /* unsigned char* */ +#define dcode 12 /* code* */ +#define lcode 8 /* code* */ +#define dmask 4 /* unsigned int */ +#define lmask 0 /* unsigned int */ + +/* + * typedef enum inflate_mode consts, in inflate.h + */ +#define INFLATE_MODE_TYPE 11 /* state->mode flags enum-ed in inflate.h */ +#define INFLATE_MODE_BAD 26 + + +#if ! defined( USE_MMX ) && ! defined( NO_MMX ) + +#define RUN_TIME_MMX + +#define CHECK_MMX 1 +#define DO_USE_MMX 2 +#define DONT_USE_MMX 3 + +.globl inflate_fast_use_mmx + +.data + +.align 4,0 +inflate_fast_use_mmx: /* integer flag for run time control 1=check,2=mmx,3=no */ +.long CHECK_MMX + +#if defined( GAS_ELF ) +/* elf info */ +.type inflate_fast_use_mmx,@object +.size inflate_fast_use_mmx,4 +#endif + +#endif /* RUN_TIME_MMX */ + +#if defined( GAS_COFF ) +/* coff info: scl 2 = extern, type 32 = function */ +.def inflate_fast; .scl 2; .type 32; .endef +#endif + +.text + +.align 32,0x90 +inflate_fast: + pushl %edi + pushl %esi + pushl %ebp + pushl %ebx + pushf /* save eflags (strm_sp, state_sp assumes this is 32 bits) */ + subl $local_var_size, %esp + cld + +#define strm_r %esi +#define state_r %edi + + movl strm_sp(%esp), strm_r + movl state_strm(strm_r), state_r + + /* in = strm->next_in; + * out = strm->next_out; + * last = in + strm->avail_in - 11; + * beg = out - (start - strm->avail_out); + * end = out + (strm->avail_out - 257); + */ + movl avail_in_strm(strm_r), %edx + movl next_in_strm(strm_r), %eax + + addl %eax, %edx /* avail_in += next_in */ + subl $11, %edx /* avail_in -= 11 */ + + movl %eax, in(%esp) + movl %edx, last(%esp) + + movl start_sp(%esp), %ebp + movl avail_out_strm(strm_r), %ecx + movl next_out_strm(strm_r), %ebx + + subl %ecx, %ebp /* start -= avail_out */ + negl %ebp /* start = -start */ + addl %ebx, %ebp /* start += next_out */ + + subl $257, %ecx /* avail_out -= 257 */ + addl %ebx, %ecx /* avail_out += out */ + + movl %ebx, out(%esp) + movl %ebp, beg(%esp) + movl %ecx, end(%esp) + + /* wsize = state->wsize; + * write = state->write; + * window = state->window; + * hold = state->hold; + * bits = state->bits; + * lcode = state->lencode; + * dcode = state->distcode; + * lmask = ( 1 << state->lenbits ) - 1; + * dmask = ( 1 << state->distbits ) - 1; + */ + + movl lencode_state(state_r), %eax + movl distcode_state(state_r), %ecx + + movl %eax, lcode(%esp) + movl %ecx, dcode(%esp) + + movl $1, %eax + movl lenbits_state(state_r), %ecx + shll %cl, %eax + decl %eax + movl %eax, lmask(%esp) + + movl $1, %eax + movl distbits_state(state_r), %ecx + shll %cl, %eax + decl %eax + movl %eax, dmask(%esp) + + movl wsize_state(state_r), %eax + movl write_state(state_r), %ecx + movl window_state(state_r), %edx + + movl %eax, wsize(%esp) + movl %ecx, write(%esp) + movl %edx, window(%esp) + + movl hold_state(state_r), %ebp + movl bits_state(state_r), %ebx + +#undef strm_r +#undef state_r + +#define in_r %esi +#define from_r %esi +#define out_r %edi + + movl in(%esp), in_r + movl last(%esp), %ecx + cmpl in_r, %ecx + ja .L_align_long /* if in < last */ + + addl $11, %ecx /* ecx = &in[ avail_in ] */ + subl in_r, %ecx /* ecx = avail_in */ + movl $12, %eax + subl %ecx, %eax /* eax = 12 - avail_in */ + leal buf(%esp), %edi + rep movsb /* memcpy( buf, in, avail_in ) */ + movl %eax, %ecx + xorl %eax, %eax + rep stosb /* memset( &buf[ avail_in ], 0, 12 - avail_in ) */ + leal buf(%esp), in_r /* in = buf */ + movl in_r, last(%esp) /* last = in, do just one iteration */ + jmp .L_is_aligned + + /* align in_r on long boundary */ +.L_align_long: + testl $3, in_r + jz .L_is_aligned + xorl %eax, %eax + movb (in_r), %al + incl in_r + movl %ebx, %ecx + addl $8, %ebx + shll %cl, %eax + orl %eax, %ebp + jmp .L_align_long + +.L_is_aligned: + movl out(%esp), out_r + +#if defined( NO_MMX ) + jmp .L_do_loop +#endif + +#if defined( USE_MMX ) + jmp .L_init_mmx +#endif + +/*** Runtime MMX check ***/ + +#if defined( RUN_TIME_MMX ) +.L_check_mmx: + cmpl $DO_USE_MMX, inflate_fast_use_mmx + je .L_init_mmx + ja .L_do_loop /* > 2 */ + + pushl %eax + pushl %ebx + pushl %ecx + pushl %edx + pushf + movl (%esp), %eax /* copy eflags to eax */ + xorl $0x200000, (%esp) /* try toggling ID bit of eflags (bit 21) + * to see if cpu supports cpuid... + * ID bit method not supported by NexGen but + * bios may load a cpuid instruction and + * cpuid may be disabled on Cyrix 5-6x86 */ + popf + pushf + popl %edx /* copy new eflags to edx */ + xorl %eax, %edx /* test if ID bit is flipped */ + jz .L_dont_use_mmx /* not flipped if zero */ + xorl %eax, %eax + cpuid + cmpl $0x756e6547, %ebx /* check for GenuineIntel in ebx,ecx,edx */ + jne .L_dont_use_mmx + cmpl $0x6c65746e, %ecx + jne .L_dont_use_mmx + cmpl $0x49656e69, %edx + jne .L_dont_use_mmx + movl $1, %eax + cpuid /* get cpu features */ + shrl $8, %eax + andl $15, %eax + cmpl $6, %eax /* check for Pentium family, is 0xf for P4 */ + jne .L_dont_use_mmx + testl $0x800000, %edx /* test if MMX feature is set (bit 23) */ + jnz .L_use_mmx + jmp .L_dont_use_mmx +.L_use_mmx: + movl $DO_USE_MMX, inflate_fast_use_mmx + jmp .L_check_mmx_pop +.L_dont_use_mmx: + movl $DONT_USE_MMX, inflate_fast_use_mmx +.L_check_mmx_pop: + popl %edx + popl %ecx + popl %ebx + popl %eax + jmp .L_check_mmx +#endif + + +/*** Non-MMX code ***/ + +#if defined ( NO_MMX ) || defined( RUN_TIME_MMX ) + +#define hold_r %ebp +#define bits_r %bl +#define bitslong_r %ebx + +.align 32,0x90 +.L_while_test: + /* while (in < last && out < end) + */ + cmpl out_r, end(%esp) + jbe .L_break_loop /* if (out >= end) */ + + cmpl in_r, last(%esp) + jbe .L_break_loop + +.L_do_loop: + /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out + * + * do { + * if (bits < 15) { + * hold |= *((unsigned short *)in)++ << bits; + * bits += 16 + * } + * this = lcode[hold & lmask] + */ + cmpb $15, bits_r + ja .L_get_length_code /* if (15 < bits) */ + + xorl %eax, %eax + lodsw /* al = *(ushort *)in++ */ + movb bits_r, %cl /* cl = bits, needs it for shifting */ + addb $16, bits_r /* bits += 16 */ + shll %cl, %eax + orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ + +.L_get_length_code: + movl lmask(%esp), %edx /* edx = lmask */ + movl lcode(%esp), %ecx /* ecx = lcode */ + andl hold_r, %edx /* edx &= hold */ + movl (%ecx,%edx,4), %eax /* eax = lcode[hold & lmask] */ + +.L_dolen: + /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out + * + * dolen: + * bits -= this.bits; + * hold >>= this.bits + */ + movb %ah, %cl /* cl = this.bits */ + subb %ah, bits_r /* bits -= this.bits */ + shrl %cl, hold_r /* hold >>= this.bits */ + + /* check if op is a literal + * if (op == 0) { + * PUP(out) = this.val; + * } + */ + testb %al, %al + jnz .L_test_for_length_base /* if (op != 0) 45.7% */ + + shrl $16, %eax /* output this.val char */ + stosb + jmp .L_while_test + +.L_test_for_length_base: + /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = len + * + * else if (op & 16) { + * len = this.val + * op &= 15 + * if (op) { + * if (op > bits) { + * hold |= *((unsigned short *)in)++ << bits; + * bits += 16 + * } + * len += hold & mask[op]; + * bits -= op; + * hold >>= op; + * } + */ +#define len_r %edx + movl %eax, len_r /* len = this */ + shrl $16, len_r /* len = this.val */ + movb %al, %cl + + testb $16, %al + jz .L_test_for_second_level_length /* if ((op & 16) == 0) 8% */ + andb $15, %cl /* op &= 15 */ + jz .L_save_len /* if (!op) */ + cmpb %cl, bits_r + jae .L_add_bits_to_len /* if (op <= bits) */ + + movb %cl, %ch /* stash op in ch, freeing cl */ + xorl %eax, %eax + lodsw /* al = *(ushort *)in++ */ + movb bits_r, %cl /* cl = bits, needs it for shifting */ + addb $16, bits_r /* bits += 16 */ + shll %cl, %eax + orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ + movb %ch, %cl /* move op back to ecx */ + +.L_add_bits_to_len: + movl $1, %eax + shll %cl, %eax + decl %eax + subb %cl, bits_r + andl hold_r, %eax /* eax &= hold */ + shrl %cl, hold_r + addl %eax, len_r /* len += hold & mask[op] */ + +.L_save_len: + movl len_r, len(%esp) /* save len */ +#undef len_r + +.L_decode_distance: + /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * + * if (bits < 15) { + * hold |= *((unsigned short *)in)++ << bits; + * bits += 16 + * } + * this = dcode[hold & dmask]; + * dodist: + * bits -= this.bits; + * hold >>= this.bits; + * op = this.op; + */ + + cmpb $15, bits_r + ja .L_get_distance_code /* if (15 < bits) */ + + xorl %eax, %eax + lodsw /* al = *(ushort *)in++ */ + movb bits_r, %cl /* cl = bits, needs it for shifting */ + addb $16, bits_r /* bits += 16 */ + shll %cl, %eax + orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ + +.L_get_distance_code: + movl dmask(%esp), %edx /* edx = dmask */ + movl dcode(%esp), %ecx /* ecx = dcode */ + andl hold_r, %edx /* edx &= hold */ + movl (%ecx,%edx,4), %eax /* eax = dcode[hold & dmask] */ + +#define dist_r %edx +.L_dodist: + movl %eax, dist_r /* dist = this */ + shrl $16, dist_r /* dist = this.val */ + movb %ah, %cl + subb %ah, bits_r /* bits -= this.bits */ + shrl %cl, hold_r /* hold >>= this.bits */ + + /* if (op & 16) { + * dist = this.val + * op &= 15 + * if (op > bits) { + * hold |= *((unsigned short *)in)++ << bits; + * bits += 16 + * } + * dist += hold & mask[op]; + * bits -= op; + * hold >>= op; + */ + movb %al, %cl /* cl = this.op */ + + testb $16, %al /* if ((op & 16) == 0) */ + jz .L_test_for_second_level_dist + andb $15, %cl /* op &= 15 */ + jz .L_check_dist_one + cmpb %cl, bits_r + jae .L_add_bits_to_dist /* if (op <= bits) 97.6% */ + + movb %cl, %ch /* stash op in ch, freeing cl */ + xorl %eax, %eax + lodsw /* al = *(ushort *)in++ */ + movb bits_r, %cl /* cl = bits, needs it for shifting */ + addb $16, bits_r /* bits += 16 */ + shll %cl, %eax + orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ + movb %ch, %cl /* move op back to ecx */ + +.L_add_bits_to_dist: + movl $1, %eax + shll %cl, %eax + decl %eax /* (1 << op) - 1 */ + subb %cl, bits_r + andl hold_r, %eax /* eax &= hold */ + shrl %cl, hold_r + addl %eax, dist_r /* dist += hold & ((1 << op) - 1) */ + jmp .L_check_window + +.L_check_window: + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes + * + * nbytes = out - beg; + * if (dist <= nbytes) { + * from = out - dist; + * do { + * PUP(out) = PUP(from); + * } while (--len > 0) { + * } + */ + + movl in_r, in(%esp) /* save in so from can use it's reg */ + movl out_r, %eax + subl beg(%esp), %eax /* nbytes = out - beg */ + + cmpl dist_r, %eax + jb .L_clip_window /* if (dist > nbytes) 4.2% */ + + movl len(%esp), %ecx + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + + subl $3, %ecx + movb (from_r), %al + movb %al, (out_r) + movb 1(from_r), %al + movb 2(from_r), %dl + addl $3, from_r + movb %al, 1(out_r) + movb %dl, 2(out_r) + addl $3, out_r + rep movsb + + movl in(%esp), in_r /* move in back to %esi, toss from */ + jmp .L_while_test + +.align 16,0x90 +.L_check_dist_one: + cmpl $1, dist_r + jne .L_check_window + cmpl out_r, beg(%esp) + je .L_check_window + + decl out_r + movl len(%esp), %ecx + movb (out_r), %al + subl $3, %ecx + + movb %al, 1(out_r) + movb %al, 2(out_r) + movb %al, 3(out_r) + addl $4, out_r + rep stosb + + jmp .L_while_test + +.align 16,0x90 +.L_test_for_second_level_length: + /* else if ((op & 64) == 0) { + * this = lcode[this.val + (hold & mask[op])]; + * } + */ + testb $64, %al + jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ + + movl $1, %eax + shll %cl, %eax + decl %eax + andl hold_r, %eax /* eax &= hold */ + addl %edx, %eax /* eax += this.val */ + movl lcode(%esp), %edx /* edx = lcode */ + movl (%edx,%eax,4), %eax /* eax = lcode[val + (hold&mask[op])] */ + jmp .L_dolen + +.align 16,0x90 +.L_test_for_second_level_dist: + /* else if ((op & 64) == 0) { + * this = dcode[this.val + (hold & mask[op])]; + * } + */ + testb $64, %al + jnz .L_invalid_distance_code /* if ((op & 64) != 0) */ + + movl $1, %eax + shll %cl, %eax + decl %eax + andl hold_r, %eax /* eax &= hold */ + addl %edx, %eax /* eax += this.val */ + movl dcode(%esp), %edx /* edx = dcode */ + movl (%edx,%eax,4), %eax /* eax = dcode[val + (hold&mask[op])] */ + jmp .L_dodist + +.align 16,0x90 +.L_clip_window: + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes + * + * else { + * if (dist > wsize) { + * invalid distance + * } + * from = window; + * nbytes = dist - nbytes; + * if (write == 0) { + * from += wsize - nbytes; + */ +#define nbytes_r %ecx + movl %eax, nbytes_r + movl wsize(%esp), %eax /* prepare for dist compare */ + negl nbytes_r /* nbytes = -nbytes */ + movl window(%esp), from_r /* from = window */ + + cmpl dist_r, %eax + jb .L_invalid_distance_too_far /* if (dist > wsize) */ + + addl dist_r, nbytes_r /* nbytes = dist - nbytes */ + cmpl $0, write(%esp) + jne .L_wrap_around_window /* if (write != 0) */ + + subl nbytes_r, %eax + addl %eax, from_r /* from += wsize - nbytes */ + + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes, %eax = len + * + * if (nbytes < len) { + * len -= nbytes; + * do { + * PUP(out) = PUP(from); + * } while (--nbytes); + * from = out - dist; + * } + * } + */ +#define len_r %eax + movl len(%esp), len_r + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1 + + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1 + +.L_wrap_around_window: + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes, %eax = write, %eax = len + * + * else if (write < nbytes) { + * from += wsize + write - nbytes; + * nbytes -= write; + * if (nbytes < len) { + * len -= nbytes; + * do { + * PUP(out) = PUP(from); + * } while (--nbytes); + * from = window; + * nbytes = write; + * if (nbytes < len) { + * len -= nbytes; + * do { + * PUP(out) = PUP(from); + * } while(--nbytes); + * from = out - dist; + * } + * } + * } + */ +#define write_r %eax + movl write(%esp), write_r + cmpl write_r, nbytes_r + jbe .L_contiguous_in_window /* if (write >= nbytes) */ + + addl wsize(%esp), from_r + addl write_r, from_r + subl nbytes_r, from_r /* from += wsize + write - nbytes */ + subl write_r, nbytes_r /* nbytes -= write */ +#undef write_r + + movl len(%esp), len_r + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl window(%esp), from_r /* from = window */ + movl write(%esp), nbytes_r /* nbytes = write */ + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1 + +.L_contiguous_in_window: + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes, %eax = write, %eax = len + * + * else { + * from += write - nbytes; + * if (nbytes < len) { + * len -= nbytes; + * do { + * PUP(out) = PUP(from); + * } while (--nbytes); + * from = out - dist; + * } + * } + */ +#define write_r %eax + addl write_r, from_r + subl nbytes_r, from_r /* from += write - nbytes */ +#undef write_r + + movl len(%esp), len_r + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + +.L_do_copy1: + /* regs: %esi = from, %esi = in, %ebp = hold, %bl = bits, %edi = out + * %eax = len + * + * while (len > 0) { + * PUP(out) = PUP(from); + * len--; + * } + * } + * } while (in < last && out < end); + */ +#undef nbytes_r +#define in_r %esi + movl len_r, %ecx + rep movsb + + movl in(%esp), in_r /* move in back to %esi, toss from */ + jmp .L_while_test + +#undef len_r +#undef dist_r + +#endif /* NO_MMX || RUN_TIME_MMX */ + + +/*** MMX code ***/ + +#if defined( USE_MMX ) || defined( RUN_TIME_MMX ) + +.align 32,0x90 +.L_init_mmx: + emms + +#undef bits_r +#undef bitslong_r +#define bitslong_r %ebp +#define hold_mm %mm0 + movd %ebp, hold_mm + movl %ebx, bitslong_r + +#define used_mm %mm1 +#define dmask2_mm %mm2 +#define lmask2_mm %mm3 +#define lmask_mm %mm4 +#define dmask_mm %mm5 +#define tmp_mm %mm6 + + movd lmask(%esp), lmask_mm + movq lmask_mm, lmask2_mm + movd dmask(%esp), dmask_mm + movq dmask_mm, dmask2_mm + pxor used_mm, used_mm + movl lcode(%esp), %ebx /* ebx = lcode */ + jmp .L_do_loop_mmx + +.align 32,0x90 +.L_while_test_mmx: + /* while (in < last && out < end) + */ + cmpl out_r, end(%esp) + jbe .L_break_loop /* if (out >= end) */ + + cmpl in_r, last(%esp) + jbe .L_break_loop + +.L_do_loop_mmx: + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + + cmpl $32, bitslong_r + ja .L_get_length_code_mmx /* if (32 < bits) */ + + movd bitslong_r, tmp_mm + movd (in_r), %mm7 + addl $4, in_r + psllq tmp_mm, %mm7 + addl $32, bitslong_r + por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */ + +.L_get_length_code_mmx: + pand hold_mm, lmask_mm + movd lmask_mm, %eax + movq lmask2_mm, lmask_mm + movl (%ebx,%eax,4), %eax /* eax = lcode[hold & lmask] */ + +.L_dolen_mmx: + movzbl %ah, %ecx /* ecx = this.bits */ + movd %ecx, used_mm + subl %ecx, bitslong_r /* bits -= this.bits */ + + testb %al, %al + jnz .L_test_for_length_base_mmx /* if (op != 0) 45.7% */ + + shrl $16, %eax /* output this.val char */ + stosb + jmp .L_while_test_mmx + +.L_test_for_length_base_mmx: +#define len_r %edx + movl %eax, len_r /* len = this */ + shrl $16, len_r /* len = this.val */ + + testb $16, %al + jz .L_test_for_second_level_length_mmx /* if ((op & 16) == 0) 8% */ + andl $15, %eax /* op &= 15 */ + jz .L_decode_distance_mmx /* if (!op) */ + + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd %eax, used_mm + movd hold_mm, %ecx + subl %eax, bitslong_r + andl .L_mask(,%eax,4), %ecx + addl %ecx, len_r /* len += hold & mask[op] */ + +.L_decode_distance_mmx: + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + + cmpl $32, bitslong_r + ja .L_get_dist_code_mmx /* if (32 < bits) */ + + movd bitslong_r, tmp_mm + movd (in_r), %mm7 + addl $4, in_r + psllq tmp_mm, %mm7 + addl $32, bitslong_r + por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */ + +.L_get_dist_code_mmx: + movl dcode(%esp), %ebx /* ebx = dcode */ + pand hold_mm, dmask_mm + movd dmask_mm, %eax + movq dmask2_mm, dmask_mm + movl (%ebx,%eax,4), %eax /* eax = dcode[hold & lmask] */ + +.L_dodist_mmx: +#define dist_r %ebx + movzbl %ah, %ecx /* ecx = this.bits */ + movl %eax, dist_r + shrl $16, dist_r /* dist = this.val */ + subl %ecx, bitslong_r /* bits -= this.bits */ + movd %ecx, used_mm + + testb $16, %al /* if ((op & 16) == 0) */ + jz .L_test_for_second_level_dist_mmx + andl $15, %eax /* op &= 15 */ + jz .L_check_dist_one_mmx + +.L_add_bits_to_dist_mmx: + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd %eax, used_mm /* save bit length of current op */ + movd hold_mm, %ecx /* get the next bits on input stream */ + subl %eax, bitslong_r /* bits -= op bits */ + andl .L_mask(,%eax,4), %ecx /* ecx = hold & mask[op] */ + addl %ecx, dist_r /* dist += hold & mask[op] */ + +.L_check_window_mmx: + movl in_r, in(%esp) /* save in so from can use it's reg */ + movl out_r, %eax + subl beg(%esp), %eax /* nbytes = out - beg */ + + cmpl dist_r, %eax + jb .L_clip_window_mmx /* if (dist > nbytes) 4.2% */ + + movl len_r, %ecx + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + + subl $3, %ecx + movb (from_r), %al + movb %al, (out_r) + movb 1(from_r), %al + movb 2(from_r), %dl + addl $3, from_r + movb %al, 1(out_r) + movb %dl, 2(out_r) + addl $3, out_r + rep movsb + + movl in(%esp), in_r /* move in back to %esi, toss from */ + movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ + jmp .L_while_test_mmx + +.align 16,0x90 +.L_check_dist_one_mmx: + cmpl $1, dist_r + jne .L_check_window_mmx + cmpl out_r, beg(%esp) + je .L_check_window_mmx + + decl out_r + movl len_r, %ecx + movb (out_r), %al + subl $3, %ecx + + movb %al, 1(out_r) + movb %al, 2(out_r) + movb %al, 3(out_r) + addl $4, out_r + rep stosb + + movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ + jmp .L_while_test_mmx + +.align 16,0x90 +.L_test_for_second_level_length_mmx: + testb $64, %al + jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ + + andl $15, %eax + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd hold_mm, %ecx + andl .L_mask(,%eax,4), %ecx + addl len_r, %ecx + movl (%ebx,%ecx,4), %eax /* eax = lcode[hold & lmask] */ + jmp .L_dolen_mmx + +.align 16,0x90 +.L_test_for_second_level_dist_mmx: + testb $64, %al + jnz .L_invalid_distance_code /* if ((op & 64) != 0) */ + + andl $15, %eax + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd hold_mm, %ecx + andl .L_mask(,%eax,4), %ecx + movl dcode(%esp), %eax /* ecx = dcode */ + addl dist_r, %ecx + movl (%eax,%ecx,4), %eax /* eax = lcode[hold & lmask] */ + jmp .L_dodist_mmx + +.align 16,0x90 +.L_clip_window_mmx: +#define nbytes_r %ecx + movl %eax, nbytes_r + movl wsize(%esp), %eax /* prepare for dist compare */ + negl nbytes_r /* nbytes = -nbytes */ + movl window(%esp), from_r /* from = window */ + + cmpl dist_r, %eax + jb .L_invalid_distance_too_far /* if (dist > wsize) */ + + addl dist_r, nbytes_r /* nbytes = dist - nbytes */ + cmpl $0, write(%esp) + jne .L_wrap_around_window_mmx /* if (write != 0) */ + + subl nbytes_r, %eax + addl %eax, from_r /* from += wsize - nbytes */ + + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1_mmx + + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1_mmx + +.L_wrap_around_window_mmx: +#define write_r %eax + movl write(%esp), write_r + cmpl write_r, nbytes_r + jbe .L_contiguous_in_window_mmx /* if (write >= nbytes) */ + + addl wsize(%esp), from_r + addl write_r, from_r + subl nbytes_r, from_r /* from += wsize + write - nbytes */ + subl write_r, nbytes_r /* nbytes -= write */ +#undef write_r + + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl window(%esp), from_r /* from = window */ + movl write(%esp), nbytes_r /* nbytes = write */ + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1_mmx + +.L_contiguous_in_window_mmx: +#define write_r %eax + addl write_r, from_r + subl nbytes_r, from_r /* from += write - nbytes */ +#undef write_r + + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + +.L_do_copy1_mmx: +#undef nbytes_r +#define in_r %esi + movl len_r, %ecx + rep movsb + + movl in(%esp), in_r /* move in back to %esi, toss from */ + movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ + jmp .L_while_test_mmx + +#undef hold_r +#undef bitslong_r + +#endif /* USE_MMX || RUN_TIME_MMX */ + + +/*** USE_MMX, NO_MMX, and RUNTIME_MMX from here on ***/ + +.L_invalid_distance_code: + /* else { + * strm->msg = "invalid distance code"; + * state->mode = BAD; + * } + */ + movl $.L_invalid_distance_code_msg, %ecx + movl $INFLATE_MODE_BAD, %edx + jmp .L_update_stream_state + +.L_test_for_end_of_block: + /* else if (op & 32) { + * state->mode = TYPE; + * break; + * } + */ + testb $32, %al + jz .L_invalid_literal_length_code /* if ((op & 32) == 0) */ + + movl $0, %ecx + movl $INFLATE_MODE_TYPE, %edx + jmp .L_update_stream_state + +.L_invalid_literal_length_code: + /* else { + * strm->msg = "invalid literal/length code"; + * state->mode = BAD; + * } + */ + movl $.L_invalid_literal_length_code_msg, %ecx + movl $INFLATE_MODE_BAD, %edx + jmp .L_update_stream_state + +.L_invalid_distance_too_far: + /* strm->msg = "invalid distance too far back"; + * state->mode = BAD; + */ + movl in(%esp), in_r /* from_r has in's reg, put in back */ + movl $.L_invalid_distance_too_far_msg, %ecx + movl $INFLATE_MODE_BAD, %edx + jmp .L_update_stream_state + +.L_update_stream_state: + /* set strm->msg = %ecx, strm->state->mode = %edx */ + movl strm_sp(%esp), %eax + testl %ecx, %ecx /* if (msg != NULL) */ + jz .L_skip_msg + movl %ecx, msg_strm(%eax) /* strm->msg = msg */ +.L_skip_msg: + movl state_strm(%eax), %eax /* state = strm->state */ + movl %edx, mode_state(%eax) /* state->mode = edx (BAD | TYPE) */ + jmp .L_break_loop + +.align 32,0x90 +.L_break_loop: + +/* + * Regs: + * + * bits = %ebp when mmx, and in %ebx when non-mmx + * hold = %hold_mm when mmx, and in %ebp when non-mmx + * in = %esi + * out = %edi + */ + +#if defined( USE_MMX ) || defined( RUN_TIME_MMX ) + +#if defined( RUN_TIME_MMX ) + + cmpl $DO_USE_MMX, inflate_fast_use_mmx + jne .L_update_next_in + +#endif /* RUN_TIME_MMX */ + + movl %ebp, %ebx + +.L_update_next_in: + +#endif + +#define strm_r %eax +#define state_r %edx + + /* len = bits >> 3; + * in -= len; + * bits -= len << 3; + * hold &= (1U << bits) - 1; + * state->hold = hold; + * state->bits = bits; + * strm->next_in = in; + * strm->next_out = out; + */ + movl strm_sp(%esp), strm_r + movl %ebx, %ecx + movl state_strm(strm_r), state_r + shrl $3, %ecx + subl %ecx, in_r + shll $3, %ecx + subl %ecx, %ebx + movl out_r, next_out_strm(strm_r) + movl %ebx, bits_state(state_r) + movl %ebx, %ecx + + leal buf(%esp), %ebx + cmpl %ebx, last(%esp) + jne .L_buf_not_used /* if buf != last */ + + subl %ebx, in_r /* in -= buf */ + movl next_in_strm(strm_r), %ebx + movl %ebx, last(%esp) /* last = strm->next_in */ + addl %ebx, in_r /* in += strm->next_in */ + movl avail_in_strm(strm_r), %ebx + subl $11, %ebx + addl %ebx, last(%esp) /* last = &strm->next_in[ avail_in - 11 ] */ + +.L_buf_not_used: + movl in_r, next_in_strm(strm_r) + + movl $1, %ebx + shll %cl, %ebx + decl %ebx + +#if defined( USE_MMX ) || defined( RUN_TIME_MMX ) + +#if defined( RUN_TIME_MMX ) + + cmpl $DO_USE_MMX, inflate_fast_use_mmx + jne .L_update_hold + +#endif /* RUN_TIME_MMX */ + + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd hold_mm, %ebp + + emms + +.L_update_hold: + +#endif /* USE_MMX || RUN_TIME_MMX */ + + andl %ebx, %ebp + movl %ebp, hold_state(state_r) + +#define last_r %ebx + + /* strm->avail_in = in < last ? 11 + (last - in) : 11 - (in - last) */ + movl last(%esp), last_r + cmpl in_r, last_r + jbe .L_last_is_smaller /* if (in >= last) */ + + subl in_r, last_r /* last -= in */ + addl $11, last_r /* last += 11 */ + movl last_r, avail_in_strm(strm_r) + jmp .L_fixup_out +.L_last_is_smaller: + subl last_r, in_r /* in -= last */ + negl in_r /* in = -in */ + addl $11, in_r /* in += 11 */ + movl in_r, avail_in_strm(strm_r) + +#undef last_r +#define end_r %ebx + +.L_fixup_out: + /* strm->avail_out = out < end ? 257 + (end - out) : 257 - (out - end)*/ + movl end(%esp), end_r + cmpl out_r, end_r + jbe .L_end_is_smaller /* if (out >= end) */ + + subl out_r, end_r /* end -= out */ + addl $257, end_r /* end += 257 */ + movl end_r, avail_out_strm(strm_r) + jmp .L_done +.L_end_is_smaller: + subl end_r, out_r /* out -= end */ + negl out_r /* out = -out */ + addl $257, out_r /* out += 257 */ + movl out_r, avail_out_strm(strm_r) + +#undef end_r +#undef strm_r +#undef state_r + +.L_done: + addl $local_var_size, %esp + popf + popl %ebx + popl %ebp + popl %esi + popl %edi + ret + +#if defined( GAS_ELF ) +/* elf info */ +.type inflate_fast,@function +.size inflate_fast,.-inflate_fast +#endif diff --git a/xs/src/png/zlib/contrib/iostream/test.cpp b/xs/src/png/zlib/contrib/iostream/test.cpp new file mode 100644 index 0000000000..7d265b3b5c --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream/test.cpp @@ -0,0 +1,24 @@ + +#include "zfstream.h" + +int main() { + + // Construct a stream object with this filebuffer. Anything sent + // to this stream will go to standard out. + gzofstream os( 1, ios::out ); + + // This text is getting compressed and sent to stdout. + // To prove this, run 'test | zcat'. + os << "Hello, Mommy" << endl; + + os << setcompressionlevel( Z_NO_COMPRESSION ); + os << "hello, hello, hi, ho!" << endl; + + setcompressionlevel( os, Z_DEFAULT_COMPRESSION ) + << "I'm compressing again" << endl; + + os.close(); + + return 0; + +} diff --git a/xs/src/png/zlib/contrib/iostream/zfstream.cpp b/xs/src/png/zlib/contrib/iostream/zfstream.cpp new file mode 100644 index 0000000000..d0cd85faaf --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream/zfstream.cpp @@ -0,0 +1,329 @@ + +#include "zfstream.h" + +gzfilebuf::gzfilebuf() : + file(NULL), + mode(0), + own_file_descriptor(0) +{ } + +gzfilebuf::~gzfilebuf() { + + sync(); + if ( own_file_descriptor ) + close(); + +} + +gzfilebuf *gzfilebuf::open( const char *name, + int io_mode ) { + + if ( is_open() ) + return NULL; + + char char_mode[10]; + char *p = char_mode; + + if ( io_mode & ios::in ) { + mode = ios::in; + *p++ = 'r'; + } else if ( io_mode & ios::app ) { + mode = ios::app; + *p++ = 'a'; + } else { + mode = ios::out; + *p++ = 'w'; + } + + if ( io_mode & ios::binary ) { + mode |= ios::binary; + *p++ = 'b'; + } + + // Hard code the compression level + if ( io_mode & (ios::out|ios::app )) { + *p++ = '9'; + } + + // Put the end-of-string indicator + *p = '\0'; + + if ( (file = gzopen(name, char_mode)) == NULL ) + return NULL; + + own_file_descriptor = 1; + + return this; + +} + +gzfilebuf *gzfilebuf::attach( int file_descriptor, + int io_mode ) { + + if ( is_open() ) + return NULL; + + char char_mode[10]; + char *p = char_mode; + + if ( io_mode & ios::in ) { + mode = ios::in; + *p++ = 'r'; + } else if ( io_mode & ios::app ) { + mode = ios::app; + *p++ = 'a'; + } else { + mode = ios::out; + *p++ = 'w'; + } + + if ( io_mode & ios::binary ) { + mode |= ios::binary; + *p++ = 'b'; + } + + // Hard code the compression level + if ( io_mode & (ios::out|ios::app )) { + *p++ = '9'; + } + + // Put the end-of-string indicator + *p = '\0'; + + if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) + return NULL; + + own_file_descriptor = 0; + + return this; + +} + +gzfilebuf *gzfilebuf::close() { + + if ( is_open() ) { + + sync(); + gzclose( file ); + file = NULL; + + } + + return this; + +} + +int gzfilebuf::setcompressionlevel( int comp_level ) { + + return gzsetparams(file, comp_level, -2); + +} + +int gzfilebuf::setcompressionstrategy( int comp_strategy ) { + + return gzsetparams(file, -2, comp_strategy); + +} + + +streampos gzfilebuf::seekoff( streamoff off, ios::seek_dir dir, int which ) { + + return streampos(EOF); + +} + +int gzfilebuf::underflow() { + + // If the file hasn't been opened for reading, error. + if ( !is_open() || !(mode & ios::in) ) + return EOF; + + // if a buffer doesn't exists, allocate one. + if ( !base() ) { + + if ( (allocate()) == EOF ) + return EOF; + setp(0,0); + + } else { + + if ( in_avail() ) + return (unsigned char) *gptr(); + + if ( out_waiting() ) { + if ( flushbuf() == EOF ) + return EOF; + } + + } + + // Attempt to fill the buffer. + + int result = fillbuf(); + if ( result == EOF ) { + // disable get area + setg(0,0,0); + return EOF; + } + + return (unsigned char) *gptr(); + +} + +int gzfilebuf::overflow( int c ) { + + if ( !is_open() || !(mode & ios::out) ) + return EOF; + + if ( !base() ) { + if ( allocate() == EOF ) + return EOF; + setg(0,0,0); + } else { + if (in_avail()) { + return EOF; + } + if (out_waiting()) { + if (flushbuf() == EOF) + return EOF; + } + } + + int bl = blen(); + setp( base(), base() + bl); + + if ( c != EOF ) { + + *pptr() = c; + pbump(1); + + } + + return 0; + +} + +int gzfilebuf::sync() { + + if ( !is_open() ) + return EOF; + + if ( out_waiting() ) + return flushbuf(); + + return 0; + +} + +int gzfilebuf::flushbuf() { + + int n; + char *q; + + q = pbase(); + n = pptr() - q; + + if ( gzwrite( file, q, n) < n ) + return EOF; + + setp(0,0); + + return 0; + +} + +int gzfilebuf::fillbuf() { + + int required; + char *p; + + p = base(); + + required = blen(); + + int t = gzread( file, p, required ); + + if ( t <= 0) return EOF; + + setg( base(), base(), base()+t); + + return t; + +} + +gzfilestream_common::gzfilestream_common() : + ios( gzfilestream_common::rdbuf() ) +{ } + +gzfilestream_common::~gzfilestream_common() +{ } + +void gzfilestream_common::attach( int fd, int io_mode ) { + + if ( !buffer.attach( fd, io_mode) ) + clear( ios::failbit | ios::badbit ); + else + clear(); + +} + +void gzfilestream_common::open( const char *name, int io_mode ) { + + if ( !buffer.open( name, io_mode ) ) + clear( ios::failbit | ios::badbit ); + else + clear(); + +} + +void gzfilestream_common::close() { + + if ( !buffer.close() ) + clear( ios::failbit | ios::badbit ); + +} + +gzfilebuf *gzfilestream_common::rdbuf() +{ + return &buffer; +} + +gzifstream::gzifstream() : + ios( gzfilestream_common::rdbuf() ) +{ + clear( ios::badbit ); +} + +gzifstream::gzifstream( const char *name, int io_mode ) : + ios( gzfilestream_common::rdbuf() ) +{ + gzfilestream_common::open( name, io_mode ); +} + +gzifstream::gzifstream( int fd, int io_mode ) : + ios( gzfilestream_common::rdbuf() ) +{ + gzfilestream_common::attach( fd, io_mode ); +} + +gzifstream::~gzifstream() { } + +gzofstream::gzofstream() : + ios( gzfilestream_common::rdbuf() ) +{ + clear( ios::badbit ); +} + +gzofstream::gzofstream( const char *name, int io_mode ) : + ios( gzfilestream_common::rdbuf() ) +{ + gzfilestream_common::open( name, io_mode ); +} + +gzofstream::gzofstream( int fd, int io_mode ) : + ios( gzfilestream_common::rdbuf() ) +{ + gzfilestream_common::attach( fd, io_mode ); +} + +gzofstream::~gzofstream() { } diff --git a/xs/src/png/zlib/contrib/iostream/zfstream.h b/xs/src/png/zlib/contrib/iostream/zfstream.h new file mode 100644 index 0000000000..ed79098a3a --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream/zfstream.h @@ -0,0 +1,128 @@ + +#ifndef zfstream_h +#define zfstream_h + +#include +#include "zlib.h" + +class gzfilebuf : public streambuf { + +public: + + gzfilebuf( ); + virtual ~gzfilebuf(); + + gzfilebuf *open( const char *name, int io_mode ); + gzfilebuf *attach( int file_descriptor, int io_mode ); + gzfilebuf *close(); + + int setcompressionlevel( int comp_level ); + int setcompressionstrategy( int comp_strategy ); + + inline int is_open() const { return (file !=NULL); } + + virtual streampos seekoff( streamoff, ios::seek_dir, int ); + + virtual int sync(); + +protected: + + virtual int underflow(); + virtual int overflow( int = EOF ); + +private: + + gzFile file; + short mode; + short own_file_descriptor; + + int flushbuf(); + int fillbuf(); + +}; + +class gzfilestream_common : virtual public ios { + + friend class gzifstream; + friend class gzofstream; + friend gzofstream &setcompressionlevel( gzofstream &, int ); + friend gzofstream &setcompressionstrategy( gzofstream &, int ); + +public: + virtual ~gzfilestream_common(); + + void attach( int fd, int io_mode ); + void open( const char *name, int io_mode ); + void close(); + +protected: + gzfilestream_common(); + +private: + gzfilebuf *rdbuf(); + + gzfilebuf buffer; + +}; + +class gzifstream : public gzfilestream_common, public istream { + +public: + + gzifstream(); + gzifstream( const char *name, int io_mode = ios::in ); + gzifstream( int fd, int io_mode = ios::in ); + + virtual ~gzifstream(); + +}; + +class gzofstream : public gzfilestream_common, public ostream { + +public: + + gzofstream(); + gzofstream( const char *name, int io_mode = ios::out ); + gzofstream( int fd, int io_mode = ios::out ); + + virtual ~gzofstream(); + +}; + +template class gzomanip { + friend gzofstream &operator<<(gzofstream &, const gzomanip &); +public: + gzomanip(gzofstream &(*f)(gzofstream &, T), T v) : func(f), val(v) { } +private: + gzofstream &(*func)(gzofstream &, T); + T val; +}; + +template gzofstream &operator<<(gzofstream &s, const gzomanip &m) +{ + return (*m.func)(s, m.val); +} + +inline gzofstream &setcompressionlevel( gzofstream &s, int l ) +{ + (s.rdbuf())->setcompressionlevel(l); + return s; +} + +inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) +{ + (s.rdbuf())->setcompressionstrategy(l); + return s; +} + +inline gzomanip setcompressionlevel(int l) +{ + return gzomanip(&setcompressionlevel,l); +} + +inline gzomanip setcompressionstrategy(int l) +{ + return gzomanip(&setcompressionstrategy,l); +} + +#endif diff --git a/xs/src/png/zlib/contrib/iostream2/zstream.h b/xs/src/png/zlib/contrib/iostream2/zstream.h new file mode 100644 index 0000000000..43d2332b79 --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream2/zstream.h @@ -0,0 +1,307 @@ +/* + * + * Copyright (c) 1997 + * Christian Michelsen Research AS + * Advanced Computing + * Fantoftvegen 38, 5036 BERGEN, Norway + * http://www.cmr.no + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Christian Michelsen Research AS makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef ZSTREAM__H +#define ZSTREAM__H + +/* + * zstream.h - C++ interface to the 'zlib' general purpose compression library + * $Id: zstream.h 1.1 1997-06-25 12:00:56+02 tyge Exp tyge $ + */ + +#include +#include +#include +#include "zlib.h" + +#if defined(_WIN32) +# include +# include +# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) +#else +# define SET_BINARY_MODE(file) +#endif + +class zstringlen { +public: + zstringlen(class izstream&); + zstringlen(class ozstream&, const char*); + size_t value() const { return val.word; } +private: + struct Val { unsigned char byte; size_t word; } val; +}; + +// ----------------------------- izstream ----------------------------- + +class izstream +{ + public: + izstream() : m_fp(0) {} + izstream(FILE* fp) : m_fp(0) { open(fp); } + izstream(const char* name) : m_fp(0) { open(name); } + ~izstream() { close(); } + + /* Opens a gzip (.gz) file for reading. + * open() can be used to read a file which is not in gzip format; + * in this case read() will directly read from the file without + * decompression. errno can be checked to distinguish two error + * cases (if errno is zero, the zlib error is Z_MEM_ERROR). + */ + void open(const char* name) { + if (m_fp) close(); + m_fp = ::gzopen(name, "rb"); + } + + void open(FILE* fp) { + SET_BINARY_MODE(fp); + if (m_fp) close(); + m_fp = ::gzdopen(fileno(fp), "rb"); + } + + /* Flushes all pending input if necessary, closes the compressed file + * and deallocates all the (de)compression state. The return value is + * the zlib error number (see function error() below). + */ + int close() { + int r = ::gzclose(m_fp); + m_fp = 0; return r; + } + + /* Binary read the given number of bytes from the compressed file. + */ + int read(void* buf, size_t len) { + return ::gzread(m_fp, buf, len); + } + + /* Returns the error message for the last error which occurred on the + * given compressed file. errnum is set to zlib error number. If an + * error occurred in the file system and not in the compression library, + * errnum is set to Z_ERRNO and the application may consult errno + * to get the exact error code. + */ + const char* error(int* errnum) { + return ::gzerror(m_fp, errnum); + } + + gzFile fp() { return m_fp; } + + private: + gzFile m_fp; +}; + +/* + * Binary read the given (array of) object(s) from the compressed file. + * If the input file was not in gzip format, read() copies the objects number + * of bytes into the buffer. + * returns the number of uncompressed bytes actually read + * (0 for end of file, -1 for error). + */ +template +inline int read(izstream& zs, T* x, Items items) { + return ::gzread(zs.fp(), x, items*sizeof(T)); +} + +/* + * Binary input with the '>' operator. + */ +template +inline izstream& operator>(izstream& zs, T& x) { + ::gzread(zs.fp(), &x, sizeof(T)); + return zs; +} + + +inline zstringlen::zstringlen(izstream& zs) { + zs > val.byte; + if (val.byte == 255) zs > val.word; + else val.word = val.byte; +} + +/* + * Read length of string + the string with the '>' operator. + */ +inline izstream& operator>(izstream& zs, char* x) { + zstringlen len(zs); + ::gzread(zs.fp(), x, len.value()); + x[len.value()] = '\0'; + return zs; +} + +inline char* read_string(izstream& zs) { + zstringlen len(zs); + char* x = new char[len.value()+1]; + ::gzread(zs.fp(), x, len.value()); + x[len.value()] = '\0'; + return x; +} + +// ----------------------------- ozstream ----------------------------- + +class ozstream +{ + public: + ozstream() : m_fp(0), m_os(0) { + } + ozstream(FILE* fp, int level = Z_DEFAULT_COMPRESSION) + : m_fp(0), m_os(0) { + open(fp, level); + } + ozstream(const char* name, int level = Z_DEFAULT_COMPRESSION) + : m_fp(0), m_os(0) { + open(name, level); + } + ~ozstream() { + close(); + } + + /* Opens a gzip (.gz) file for writing. + * The compression level parameter should be in 0..9 + * errno can be checked to distinguish two error cases + * (if errno is zero, the zlib error is Z_MEM_ERROR). + */ + void open(const char* name, int level = Z_DEFAULT_COMPRESSION) { + char mode[4] = "wb\0"; + if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; + if (m_fp) close(); + m_fp = ::gzopen(name, mode); + } + + /* open from a FILE pointer. + */ + void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) { + SET_BINARY_MODE(fp); + char mode[4] = "wb\0"; + if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; + if (m_fp) close(); + m_fp = ::gzdopen(fileno(fp), mode); + } + + /* Flushes all pending output if necessary, closes the compressed file + * and deallocates all the (de)compression state. The return value is + * the zlib error number (see function error() below). + */ + int close() { + if (m_os) { + ::gzwrite(m_fp, m_os->str(), m_os->pcount()); + delete[] m_os->str(); delete m_os; m_os = 0; + } + int r = ::gzclose(m_fp); m_fp = 0; return r; + } + + /* Binary write the given number of bytes into the compressed file. + */ + int write(const void* buf, size_t len) { + return ::gzwrite(m_fp, (voidp) buf, len); + } + + /* Flushes all pending output into the compressed file. The parameter + * _flush is as in the deflate() function. The return value is the zlib + * error number (see function gzerror below). flush() returns Z_OK if + * the flush_ parameter is Z_FINISH and all output could be flushed. + * flush() should be called only when strictly necessary because it can + * degrade compression. + */ + int flush(int _flush) { + os_flush(); + return ::gzflush(m_fp, _flush); + } + + /* Returns the error message for the last error which occurred on the + * given compressed file. errnum is set to zlib error number. If an + * error occurred in the file system and not in the compression library, + * errnum is set to Z_ERRNO and the application may consult errno + * to get the exact error code. + */ + const char* error(int* errnum) { + return ::gzerror(m_fp, errnum); + } + + gzFile fp() { return m_fp; } + + ostream& os() { + if (m_os == 0) m_os = new ostrstream; + return *m_os; + } + + void os_flush() { + if (m_os && m_os->pcount()>0) { + ostrstream* oss = new ostrstream; + oss->fill(m_os->fill()); + oss->flags(m_os->flags()); + oss->precision(m_os->precision()); + oss->width(m_os->width()); + ::gzwrite(m_fp, m_os->str(), m_os->pcount()); + delete[] m_os->str(); delete m_os; m_os = oss; + } + } + + private: + gzFile m_fp; + ostrstream* m_os; +}; + +/* + * Binary write the given (array of) object(s) into the compressed file. + * returns the number of uncompressed bytes actually written + * (0 in case of error). + */ +template +inline int write(ozstream& zs, const T* x, Items items) { + return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T)); +} + +/* + * Binary output with the '<' operator. + */ +template +inline ozstream& operator<(ozstream& zs, const T& x) { + ::gzwrite(zs.fp(), (voidp) &x, sizeof(T)); + return zs; +} + +inline zstringlen::zstringlen(ozstream& zs, const char* x) { + val.byte = 255; val.word = ::strlen(x); + if (val.word < 255) zs < (val.byte = val.word); + else zs < val; +} + +/* + * Write length of string + the string with the '<' operator. + */ +inline ozstream& operator<(ozstream& zs, const char* x) { + zstringlen len(zs, x); + ::gzwrite(zs.fp(), (voidp) x, len.value()); + return zs; +} + +#ifdef _MSC_VER +inline ozstream& operator<(ozstream& zs, char* const& x) { + return zs < (const char*) x; +} +#endif + +/* + * Ascii write with the << operator; + */ +template +inline ostream& operator<<(ozstream& zs, const T& x) { + zs.os_flush(); + return zs.os() << x; +} + +#endif diff --git a/xs/src/png/zlib/contrib/iostream2/zstream_test.cpp b/xs/src/png/zlib/contrib/iostream2/zstream_test.cpp new file mode 100644 index 0000000000..6273f62d62 --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream2/zstream_test.cpp @@ -0,0 +1,25 @@ +#include "zstream.h" +#include +#include +#include + +void main() { + char h[256] = "Hello"; + char* g = "Goodbye"; + ozstream out("temp.gz"); + out < "This works well" < h < g; + out.close(); + + izstream in("temp.gz"); // read it back + char *x = read_string(in), *y = new char[256], z[256]; + in > y > z; + in.close(); + cout << x << endl << y << endl << z << endl; + + out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results + out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl; + out << z << endl << y << endl << x << endl; + out << 1.1234567890123456789 << endl; + + delete[] x; delete[] y; +} diff --git a/xs/src/png/zlib/contrib/iostream3/README b/xs/src/png/zlib/contrib/iostream3/README new file mode 100644 index 0000000000..f7b319ab91 --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream3/README @@ -0,0 +1,35 @@ +These classes provide a C++ stream interface to the zlib library. It allows you +to do things like: + + gzofstream outf("blah.gz"); + outf << "These go into the gzip file " << 123 << endl; + +It does this by deriving a specialized stream buffer for gzipped files, which is +the way Stroustrup would have done it. :-> + +The gzifstream and gzofstream classes were originally written by Kevin Ruland +and made available in the zlib contrib/iostream directory. The older version still +compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of +this version. + +The new classes are as standard-compliant as possible, closely following the +approach of the standard library's fstream classes. It compiles under gcc versions +3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard +library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs +from the previous one in the following respects: +- added showmanyc +- added setbuf, with support for unbuffered output via setbuf(0,0) +- a few bug fixes of stream behavior +- gzipped output file opened with default compression level instead of maximum level +- setcompressionlevel()/strategy() members replaced by single setcompression() + +The code is provided "as is", with the permission to use, copy, modify, distribute +and sell it for any purpose without fee. + +Ludwig Schwardt + + +DSP Lab +Electrical & Electronic Engineering Department +University of Stellenbosch +South Africa diff --git a/xs/src/png/zlib/contrib/iostream3/TODO b/xs/src/png/zlib/contrib/iostream3/TODO new file mode 100644 index 0000000000..7032f97be0 --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream3/TODO @@ -0,0 +1,17 @@ +Possible upgrades to gzfilebuf: + +- The ability to do putback (e.g. putbackfail) + +- The ability to seek (zlib supports this, but could be slow/tricky) + +- Simultaneous read/write access (does it make sense?) + +- Support for ios_base::ate open mode + +- Locale support? + +- Check public interface to see which calls give problems + (due to dependence on library internals) + +- Override operator<<(ostream&, gzfilebuf*) to allow direct copying + of stream buffer to stream ( i.e. os << is.rdbuf(); ) diff --git a/xs/src/png/zlib/contrib/iostream3/test.cc b/xs/src/png/zlib/contrib/iostream3/test.cc new file mode 100644 index 0000000000..94235334f2 --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream3/test.cc @@ -0,0 +1,50 @@ +/* + * Test program for gzifstream and gzofstream + * + * by Ludwig Schwardt + * original version by Kevin Ruland + */ + +#include "zfstream.h" +#include // for cout + +int main() { + + gzofstream outf; + gzifstream inf; + char buf[80]; + + outf.open("test1.txt.gz"); + outf << "The quick brown fox sidestepped the lazy canine\n" + << 1.3 << "\nPlan " << 9 << std::endl; + outf.close(); + std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n" + << "The quick brown fox sidestepped the lazy canine\n" + << 1.3 << "\nPlan " << 9 << std::endl; + + std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n"; + inf.open("test1.txt.gz"); + while (inf.getline(buf,80,'\n')) { + std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; + } + inf.close(); + + outf.rdbuf()->pubsetbuf(0,0); + outf.open("test2.txt.gz"); + outf << setcompression(Z_NO_COMPRESSION) + << "The quick brown fox sidestepped the lazy canine\n" + << 1.3 << "\nPlan " << 9 << std::endl; + outf.close(); + std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form"; + + std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n"; + inf.rdbuf()->pubsetbuf(0,0); + inf.open("test2.txt.gz"); + while (inf.getline(buf,80,'\n')) { + std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; + } + inf.close(); + + return 0; + +} diff --git a/xs/src/png/zlib/contrib/iostream3/zfstream.cc b/xs/src/png/zlib/contrib/iostream3/zfstream.cc new file mode 100644 index 0000000000..94eb933444 --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream3/zfstream.cc @@ -0,0 +1,479 @@ +/* + * A C++ I/O streams interface to the zlib gz* functions + * + * by Ludwig Schwardt + * original version by Kevin Ruland + * + * This version is standard-compliant and compatible with gcc 3.x. + */ + +#include "zfstream.h" +#include // for strcpy, strcat, strlen (mode strings) +#include // for BUFSIZ + +// Internal buffer sizes (default and "unbuffered" versions) +#define BIGBUFSIZE BUFSIZ +#define SMALLBUFSIZE 1 + +/*****************************************************************************/ + +// Default constructor +gzfilebuf::gzfilebuf() +: file(NULL), io_mode(std::ios_base::openmode(0)), own_fd(false), + buffer(NULL), buffer_size(BIGBUFSIZE), own_buffer(true) +{ + // No buffers to start with + this->disable_buffer(); +} + +// Destructor +gzfilebuf::~gzfilebuf() +{ + // Sync output buffer and close only if responsible for file + // (i.e. attached streams should be left open at this stage) + this->sync(); + if (own_fd) + this->close(); + // Make sure internal buffer is deallocated + this->disable_buffer(); +} + +// Set compression level and strategy +int +gzfilebuf::setcompression(int comp_level, + int comp_strategy) +{ + return gzsetparams(file, comp_level, comp_strategy); +} + +// Open gzipped file +gzfilebuf* +gzfilebuf::open(const char *name, + std::ios_base::openmode mode) +{ + // Fail if file already open + if (this->is_open()) + return NULL; + // Don't support simultaneous read/write access (yet) + if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) + return NULL; + + // Build mode string for gzopen and check it [27.8.1.3.2] + char char_mode[6] = "\0\0\0\0\0"; + if (!this->open_mode(mode, char_mode)) + return NULL; + + // Attempt to open file + if ((file = gzopen(name, char_mode)) == NULL) + return NULL; + + // On success, allocate internal buffer and set flags + this->enable_buffer(); + io_mode = mode; + own_fd = true; + return this; +} + +// Attach to gzipped file +gzfilebuf* +gzfilebuf::attach(int fd, + std::ios_base::openmode mode) +{ + // Fail if file already open + if (this->is_open()) + return NULL; + // Don't support simultaneous read/write access (yet) + if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) + return NULL; + + // Build mode string for gzdopen and check it [27.8.1.3.2] + char char_mode[6] = "\0\0\0\0\0"; + if (!this->open_mode(mode, char_mode)) + return NULL; + + // Attempt to attach to file + if ((file = gzdopen(fd, char_mode)) == NULL) + return NULL; + + // On success, allocate internal buffer and set flags + this->enable_buffer(); + io_mode = mode; + own_fd = false; + return this; +} + +// Close gzipped file +gzfilebuf* +gzfilebuf::close() +{ + // Fail immediately if no file is open + if (!this->is_open()) + return NULL; + // Assume success + gzfilebuf* retval = this; + // Attempt to sync and close gzipped file + if (this->sync() == -1) + retval = NULL; + if (gzclose(file) < 0) + retval = NULL; + // File is now gone anyway (postcondition [27.8.1.3.8]) + file = NULL; + own_fd = false; + // Destroy internal buffer if it exists + this->disable_buffer(); + return retval; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +// Convert int open mode to mode string +bool +gzfilebuf::open_mode(std::ios_base::openmode mode, + char* c_mode) const +{ + bool testb = mode & std::ios_base::binary; + bool testi = mode & std::ios_base::in; + bool testo = mode & std::ios_base::out; + bool testt = mode & std::ios_base::trunc; + bool testa = mode & std::ios_base::app; + + // Check for valid flag combinations - see [27.8.1.3.2] (Table 92) + // Original zfstream hardcoded the compression level to maximum here... + // Double the time for less than 1% size improvement seems + // excessive though - keeping it at the default level + // To change back, just append "9" to the next three mode strings + if (!testi && testo && !testt && !testa) + strcpy(c_mode, "w"); + if (!testi && testo && !testt && testa) + strcpy(c_mode, "a"); + if (!testi && testo && testt && !testa) + strcpy(c_mode, "w"); + if (testi && !testo && !testt && !testa) + strcpy(c_mode, "r"); + // No read/write mode yet +// if (testi && testo && !testt && !testa) +// strcpy(c_mode, "r+"); +// if (testi && testo && testt && !testa) +// strcpy(c_mode, "w+"); + + // Mode string should be empty for invalid combination of flags + if (strlen(c_mode) == 0) + return false; + if (testb) + strcat(c_mode, "b"); + return true; +} + +// Determine number of characters in internal get buffer +std::streamsize +gzfilebuf::showmanyc() +{ + // Calls to underflow will fail if file not opened for reading + if (!this->is_open() || !(io_mode & std::ios_base::in)) + return -1; + // Make sure get area is in use + if (this->gptr() && (this->gptr() < this->egptr())) + return std::streamsize(this->egptr() - this->gptr()); + else + return 0; +} + +// Fill get area from gzipped file +gzfilebuf::int_type +gzfilebuf::underflow() +{ + // If something is left in the get area by chance, return it + // (this shouldn't normally happen, as underflow is only supposed + // to be called when gptr >= egptr, but it serves as error check) + if (this->gptr() && (this->gptr() < this->egptr())) + return traits_type::to_int_type(*(this->gptr())); + + // If the file hasn't been opened for reading, produce error + if (!this->is_open() || !(io_mode & std::ios_base::in)) + return traits_type::eof(); + + // Attempt to fill internal buffer from gzipped file + // (buffer must be guaranteed to exist...) + int bytes_read = gzread(file, buffer, buffer_size); + // Indicates error or EOF + if (bytes_read <= 0) + { + // Reset get area + this->setg(buffer, buffer, buffer); + return traits_type::eof(); + } + // Make all bytes read from file available as get area + this->setg(buffer, buffer, buffer + bytes_read); + + // Return next character in get area + return traits_type::to_int_type(*(this->gptr())); +} + +// Write put area to gzipped file +gzfilebuf::int_type +gzfilebuf::overflow(int_type c) +{ + // Determine whether put area is in use + if (this->pbase()) + { + // Double-check pointer range + if (this->pptr() > this->epptr() || this->pptr() < this->pbase()) + return traits_type::eof(); + // Add extra character to buffer if not EOF + if (!traits_type::eq_int_type(c, traits_type::eof())) + { + *(this->pptr()) = traits_type::to_char_type(c); + this->pbump(1); + } + // Number of characters to write to file + int bytes_to_write = this->pptr() - this->pbase(); + // Overflow doesn't fail if nothing is to be written + if (bytes_to_write > 0) + { + // If the file hasn't been opened for writing, produce error + if (!this->is_open() || !(io_mode & std::ios_base::out)) + return traits_type::eof(); + // If gzipped file won't accept all bytes written to it, fail + if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write) + return traits_type::eof(); + // Reset next pointer to point to pbase on success + this->pbump(-bytes_to_write); + } + } + // Write extra character to file if not EOF + else if (!traits_type::eq_int_type(c, traits_type::eof())) + { + // If the file hasn't been opened for writing, produce error + if (!this->is_open() || !(io_mode & std::ios_base::out)) + return traits_type::eof(); + // Impromptu char buffer (allows "unbuffered" output) + char_type last_char = traits_type::to_char_type(c); + // If gzipped file won't accept this character, fail + if (gzwrite(file, &last_char, 1) != 1) + return traits_type::eof(); + } + + // If you got here, you have succeeded (even if c was EOF) + // The return value should therefore be non-EOF + if (traits_type::eq_int_type(c, traits_type::eof())) + return traits_type::not_eof(c); + else + return c; +} + +// Assign new buffer +std::streambuf* +gzfilebuf::setbuf(char_type* p, + std::streamsize n) +{ + // First make sure stuff is sync'ed, for safety + if (this->sync() == -1) + return NULL; + // If buffering is turned off on purpose via setbuf(0,0), still allocate one... + // "Unbuffered" only really refers to put [27.8.1.4.10], while get needs at + // least a buffer of size 1 (very inefficient though, therefore make it bigger?) + // This follows from [27.5.2.4.3]/12 (gptr needs to point at something, it seems) + if (!p || !n) + { + // Replace existing buffer (if any) with small internal buffer + this->disable_buffer(); + buffer = NULL; + buffer_size = 0; + own_buffer = true; + this->enable_buffer(); + } + else + { + // Replace existing buffer (if any) with external buffer + this->disable_buffer(); + buffer = p; + buffer_size = n; + own_buffer = false; + this->enable_buffer(); + } + return this; +} + +// Write put area to gzipped file (i.e. ensures that put area is empty) +int +gzfilebuf::sync() +{ + return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +// Allocate internal buffer +void +gzfilebuf::enable_buffer() +{ + // If internal buffer required, allocate one + if (own_buffer && !buffer) + { + // Check for buffered vs. "unbuffered" + if (buffer_size > 0) + { + // Allocate internal buffer + buffer = new char_type[buffer_size]; + // Get area starts empty and will be expanded by underflow as need arises + this->setg(buffer, buffer, buffer); + // Setup entire internal buffer as put area. + // The one-past-end pointer actually points to the last element of the buffer, + // so that overflow(c) can safely add the extra character c to the sequence. + // These pointers remain in place for the duration of the buffer + this->setp(buffer, buffer + buffer_size - 1); + } + else + { + // Even in "unbuffered" case, (small?) get buffer is still required + buffer_size = SMALLBUFSIZE; + buffer = new char_type[buffer_size]; + this->setg(buffer, buffer, buffer); + // "Unbuffered" means no put buffer + this->setp(0, 0); + } + } + else + { + // If buffer already allocated, reset buffer pointers just to make sure no + // stale chars are lying around + this->setg(buffer, buffer, buffer); + this->setp(buffer, buffer + buffer_size - 1); + } +} + +// Destroy internal buffer +void +gzfilebuf::disable_buffer() +{ + // If internal buffer exists, deallocate it + if (own_buffer && buffer) + { + // Preserve unbuffered status by zeroing size + if (!this->pbase()) + buffer_size = 0; + delete[] buffer; + buffer = NULL; + this->setg(0, 0, 0); + this->setp(0, 0); + } + else + { + // Reset buffer pointers to initial state if external buffer exists + this->setg(buffer, buffer, buffer); + if (buffer) + this->setp(buffer, buffer + buffer_size - 1); + else + this->setp(0, 0); + } +} + +/*****************************************************************************/ + +// Default constructor initializes stream buffer +gzifstream::gzifstream() +: std::istream(NULL), sb() +{ this->init(&sb); } + +// Initialize stream buffer and open file +gzifstream::gzifstream(const char* name, + std::ios_base::openmode mode) +: std::istream(NULL), sb() +{ + this->init(&sb); + this->open(name, mode); +} + +// Initialize stream buffer and attach to file +gzifstream::gzifstream(int fd, + std::ios_base::openmode mode) +: std::istream(NULL), sb() +{ + this->init(&sb); + this->attach(fd, mode); +} + +// Open file and go into fail() state if unsuccessful +void +gzifstream::open(const char* name, + std::ios_base::openmode mode) +{ + if (!sb.open(name, mode | std::ios_base::in)) + this->setstate(std::ios_base::failbit); + else + this->clear(); +} + +// Attach to file and go into fail() state if unsuccessful +void +gzifstream::attach(int fd, + std::ios_base::openmode mode) +{ + if (!sb.attach(fd, mode | std::ios_base::in)) + this->setstate(std::ios_base::failbit); + else + this->clear(); +} + +// Close file +void +gzifstream::close() +{ + if (!sb.close()) + this->setstate(std::ios_base::failbit); +} + +/*****************************************************************************/ + +// Default constructor initializes stream buffer +gzofstream::gzofstream() +: std::ostream(NULL), sb() +{ this->init(&sb); } + +// Initialize stream buffer and open file +gzofstream::gzofstream(const char* name, + std::ios_base::openmode mode) +: std::ostream(NULL), sb() +{ + this->init(&sb); + this->open(name, mode); +} + +// Initialize stream buffer and attach to file +gzofstream::gzofstream(int fd, + std::ios_base::openmode mode) +: std::ostream(NULL), sb() +{ + this->init(&sb); + this->attach(fd, mode); +} + +// Open file and go into fail() state if unsuccessful +void +gzofstream::open(const char* name, + std::ios_base::openmode mode) +{ + if (!sb.open(name, mode | std::ios_base::out)) + this->setstate(std::ios_base::failbit); + else + this->clear(); +} + +// Attach to file and go into fail() state if unsuccessful +void +gzofstream::attach(int fd, + std::ios_base::openmode mode) +{ + if (!sb.attach(fd, mode | std::ios_base::out)) + this->setstate(std::ios_base::failbit); + else + this->clear(); +} + +// Close file +void +gzofstream::close() +{ + if (!sb.close()) + this->setstate(std::ios_base::failbit); +} diff --git a/xs/src/png/zlib/contrib/iostream3/zfstream.h b/xs/src/png/zlib/contrib/iostream3/zfstream.h new file mode 100644 index 0000000000..8574479ae1 --- /dev/null +++ b/xs/src/png/zlib/contrib/iostream3/zfstream.h @@ -0,0 +1,466 @@ +/* + * A C++ I/O streams interface to the zlib gz* functions + * + * by Ludwig Schwardt + * original version by Kevin Ruland + * + * This version is standard-compliant and compatible with gcc 3.x. + */ + +#ifndef ZFSTREAM_H +#define ZFSTREAM_H + +#include // not iostream, since we don't need cin/cout +#include +#include "zlib.h" + +/*****************************************************************************/ + +/** + * @brief Gzipped file stream buffer class. + * + * This class implements basic_filebuf for gzipped files. It doesn't yet support + * seeking (allowed by zlib but slow/limited), putback and read/write access + * (tricky). Otherwise, it attempts to be a drop-in replacement for the standard + * file streambuf. +*/ +class gzfilebuf : public std::streambuf +{ +public: + // Default constructor. + gzfilebuf(); + + // Destructor. + virtual + ~gzfilebuf(); + + /** + * @brief Set compression level and strategy on the fly. + * @param comp_level Compression level (see zlib.h for allowed values) + * @param comp_strategy Compression strategy (see zlib.h for allowed values) + * @return Z_OK on success, Z_STREAM_ERROR otherwise. + * + * Unfortunately, these parameters cannot be modified separately, as the + * previous zfstream version assumed. Since the strategy is seldom changed, + * it can default and setcompression(level) then becomes like the old + * setcompressionlevel(level). + */ + int + setcompression(int comp_level, + int comp_strategy = Z_DEFAULT_STRATEGY); + + /** + * @brief Check if file is open. + * @return True if file is open. + */ + bool + is_open() const { return (file != NULL); } + + /** + * @brief Open gzipped file. + * @param name File name. + * @param mode Open mode flags. + * @return @c this on success, NULL on failure. + */ + gzfilebuf* + open(const char* name, + std::ios_base::openmode mode); + + /** + * @brief Attach to already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags. + * @return @c this on success, NULL on failure. + */ + gzfilebuf* + attach(int fd, + std::ios_base::openmode mode); + + /** + * @brief Close gzipped file. + * @return @c this on success, NULL on failure. + */ + gzfilebuf* + close(); + +protected: + /** + * @brief Convert ios open mode int to mode string used by zlib. + * @return True if valid mode flag combination. + */ + bool + open_mode(std::ios_base::openmode mode, + char* c_mode) const; + + /** + * @brief Number of characters available in stream buffer. + * @return Number of characters. + * + * This indicates number of characters in get area of stream buffer. + * These characters can be read without accessing the gzipped file. + */ + virtual std::streamsize + showmanyc(); + + /** + * @brief Fill get area from gzipped file. + * @return First character in get area on success, EOF on error. + * + * This actually reads characters from gzipped file to stream + * buffer. Always buffered. + */ + virtual int_type + underflow(); + + /** + * @brief Write put area to gzipped file. + * @param c Extra character to add to buffer contents. + * @return Non-EOF on success, EOF on error. + * + * This actually writes characters in stream buffer to + * gzipped file. With unbuffered output this is done one + * character at a time. + */ + virtual int_type + overflow(int_type c = traits_type::eof()); + + /** + * @brief Installs external stream buffer. + * @param p Pointer to char buffer. + * @param n Size of external buffer. + * @return @c this on success, NULL on failure. + * + * Call setbuf(0,0) to enable unbuffered output. + */ + virtual std::streambuf* + setbuf(char_type* p, + std::streamsize n); + + /** + * @brief Flush stream buffer to file. + * @return 0 on success, -1 on error. + * + * This calls underflow(EOF) to do the job. + */ + virtual int + sync(); + +// +// Some future enhancements +// +// virtual int_type uflow(); +// virtual int_type pbackfail(int_type c = traits_type::eof()); +// virtual pos_type +// seekoff(off_type off, +// std::ios_base::seekdir way, +// std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); +// virtual pos_type +// seekpos(pos_type sp, +// std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); + +private: + /** + * @brief Allocate internal buffer. + * + * This function is safe to call multiple times. It will ensure + * that a proper internal buffer exists if it is required. If the + * buffer already exists or is external, the buffer pointers will be + * reset to their original state. + */ + void + enable_buffer(); + + /** + * @brief Destroy internal buffer. + * + * This function is safe to call multiple times. It will ensure + * that the internal buffer is deallocated if it exists. In any + * case, it will also reset the buffer pointers. + */ + void + disable_buffer(); + + /** + * Underlying file pointer. + */ + gzFile file; + + /** + * Mode in which file was opened. + */ + std::ios_base::openmode io_mode; + + /** + * @brief True if this object owns file descriptor. + * + * This makes the class responsible for closing the file + * upon destruction. + */ + bool own_fd; + + /** + * @brief Stream buffer. + * + * For simplicity this remains allocated on the free store for the + * entire life span of the gzfilebuf object, unless replaced by setbuf. + */ + char_type* buffer; + + /** + * @brief Stream buffer size. + * + * Defaults to system default buffer size (typically 8192 bytes). + * Modified by setbuf. + */ + std::streamsize buffer_size; + + /** + * @brief True if this object owns stream buffer. + * + * This makes the class responsible for deleting the buffer + * upon destruction. + */ + bool own_buffer; +}; + +/*****************************************************************************/ + +/** + * @brief Gzipped file input stream class. + * + * This class implements ifstream for gzipped files. Seeking and putback + * is not supported yet. +*/ +class gzifstream : public std::istream +{ +public: + // Default constructor + gzifstream(); + + /** + * @brief Construct stream on gzipped file to be opened. + * @param name File name. + * @param mode Open mode flags (forced to contain ios::in). + */ + explicit + gzifstream(const char* name, + std::ios_base::openmode mode = std::ios_base::in); + + /** + * @brief Construct stream on already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags (forced to contain ios::in). + */ + explicit + gzifstream(int fd, + std::ios_base::openmode mode = std::ios_base::in); + + /** + * Obtain underlying stream buffer. + */ + gzfilebuf* + rdbuf() const + { return const_cast(&sb); } + + /** + * @brief Check if file is open. + * @return True if file is open. + */ + bool + is_open() { return sb.is_open(); } + + /** + * @brief Open gzipped file. + * @param name File name. + * @param mode Open mode flags (forced to contain ios::in). + * + * Stream will be in state good() if file opens successfully; + * otherwise in state fail(). This differs from the behavior of + * ifstream, which never sets the state to good() and therefore + * won't allow you to reuse the stream for a second file unless + * you manually clear() the state. The choice is a matter of + * convenience. + */ + void + open(const char* name, + std::ios_base::openmode mode = std::ios_base::in); + + /** + * @brief Attach to already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags (forced to contain ios::in). + * + * Stream will be in state good() if attach succeeded; otherwise + * in state fail(). + */ + void + attach(int fd, + std::ios_base::openmode mode = std::ios_base::in); + + /** + * @brief Close gzipped file. + * + * Stream will be in state fail() if close failed. + */ + void + close(); + +private: + /** + * Underlying stream buffer. + */ + gzfilebuf sb; +}; + +/*****************************************************************************/ + +/** + * @brief Gzipped file output stream class. + * + * This class implements ofstream for gzipped files. Seeking and putback + * is not supported yet. +*/ +class gzofstream : public std::ostream +{ +public: + // Default constructor + gzofstream(); + + /** + * @brief Construct stream on gzipped file to be opened. + * @param name File name. + * @param mode Open mode flags (forced to contain ios::out). + */ + explicit + gzofstream(const char* name, + std::ios_base::openmode mode = std::ios_base::out); + + /** + * @brief Construct stream on already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags (forced to contain ios::out). + */ + explicit + gzofstream(int fd, + std::ios_base::openmode mode = std::ios_base::out); + + /** + * Obtain underlying stream buffer. + */ + gzfilebuf* + rdbuf() const + { return const_cast(&sb); } + + /** + * @brief Check if file is open. + * @return True if file is open. + */ + bool + is_open() { return sb.is_open(); } + + /** + * @brief Open gzipped file. + * @param name File name. + * @param mode Open mode flags (forced to contain ios::out). + * + * Stream will be in state good() if file opens successfully; + * otherwise in state fail(). This differs from the behavior of + * ofstream, which never sets the state to good() and therefore + * won't allow you to reuse the stream for a second file unless + * you manually clear() the state. The choice is a matter of + * convenience. + */ + void + open(const char* name, + std::ios_base::openmode mode = std::ios_base::out); + + /** + * @brief Attach to already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags (forced to contain ios::out). + * + * Stream will be in state good() if attach succeeded; otherwise + * in state fail(). + */ + void + attach(int fd, + std::ios_base::openmode mode = std::ios_base::out); + + /** + * @brief Close gzipped file. + * + * Stream will be in state fail() if close failed. + */ + void + close(); + +private: + /** + * Underlying stream buffer. + */ + gzfilebuf sb; +}; + +/*****************************************************************************/ + +/** + * @brief Gzipped file output stream manipulator class. + * + * This class defines a two-argument manipulator for gzofstream. It is used + * as base for the setcompression(int,int) manipulator. +*/ +template + class gzomanip2 + { + public: + // Allows insertor to peek at internals + template + friend gzofstream& + operator<<(gzofstream&, + const gzomanip2&); + + // Constructor + gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), + T1 v1, + T2 v2); + private: + // Underlying manipulator function + gzofstream& + (*func)(gzofstream&, T1, T2); + + // Arguments for manipulator function + T1 val1; + T2 val2; + }; + +/*****************************************************************************/ + +// Manipulator function thunks through to stream buffer +inline gzofstream& +setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) +{ + (gzs.rdbuf())->setcompression(l, s); + return gzs; +} + +// Manipulator constructor stores arguments +template + inline + gzomanip2::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), + T1 v1, + T2 v2) + : func(f), val1(v1), val2(v2) + { } + +// Insertor applies underlying manipulator function to stream +template + inline gzofstream& + operator<<(gzofstream& s, const gzomanip2& m) + { return (*m.func)(s, m.val1, m.val2); } + +// Insert this onto stream to simplify setting of compression level +inline gzomanip2 +setcompression(int l, int s = Z_DEFAULT_STRATEGY) +{ return gzomanip2(&setcompression, l, s); } + +#endif // ZFSTREAM_H diff --git a/xs/src/png/zlib/contrib/masmx64/bld_ml64.bat b/xs/src/png/zlib/contrib/masmx64/bld_ml64.bat new file mode 100644 index 0000000000..f74bcef5b4 --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx64/bld_ml64.bat @@ -0,0 +1,2 @@ +ml64.exe /Flinffasx64 /c /Zi inffasx64.asm +ml64.exe /Flgvmat64 /c /Zi gvmat64.asm diff --git a/xs/src/png/zlib/contrib/masmx64/gvmat64.asm b/xs/src/png/zlib/contrib/masmx64/gvmat64.asm new file mode 100644 index 0000000000..c1817f1be9 --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx64/gvmat64.asm @@ -0,0 +1,553 @@ +;uInt longest_match_x64( +; deflate_state *s, +; IPos cur_match); /* current match */ + +; gvmat64.asm -- Asm portion of the optimized longest_match for 32 bits x86_64 +; (AMD64 on Athlon 64, Opteron, Phenom +; and Intel EM64T on Pentium 4 with EM64T, Pentium D, Core 2 Duo, Core I5/I7) +; Copyright (C) 1995-2010 Jean-loup Gailly, Brian Raiter and Gilles Vollant. +; +; File written by Gilles Vollant, by converting to assembly the longest_match +; from Jean-loup Gailly in deflate.c of zLib and infoZip zip. +; +; and by taking inspiration on asm686 with masm, optimised assembly code +; from Brian Raiter, written 1998 +; +; This software is provided 'as-is', without any express or implied +; warranty. In no event will the authors be held liable for any damages +; arising from the use of this software. +; +; Permission is granted to anyone to use this software for any purpose, +; including commercial applications, and to alter it and redistribute it +; freely, subject to the following restrictions: +; +; 1. The origin of this software must not be misrepresented; you must not +; claim that you wrote the original software. If you use this software +; in a product, an acknowledgment in the product documentation would be +; appreciated but is not required. +; 2. Altered source versions must be plainly marked as such, and must not be +; misrepresented as being the original software +; 3. This notice may not be removed or altered from any source distribution. +; +; +; +; http://www.zlib.net +; http://www.winimage.com/zLibDll +; http://www.muppetlabs.com/~breadbox/software/assembly.html +; +; to compile this file for infozip Zip, I use option: +; ml64.exe /Flgvmat64 /c /Zi /DINFOZIP gvmat64.asm +; +; to compile this file for zLib, I use option: +; ml64.exe /Flgvmat64 /c /Zi gvmat64.asm +; Be carrefull to adapt zlib1222add below to your version of zLib +; (if you use a version of zLib before 1.0.4 or after 1.2.2.2, change +; value of zlib1222add later) +; +; This file compile with Microsoft Macro Assembler (x64) for AMD64 +; +; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK +; +; (you can get Windows WDK with ml64 for AMD64 from +; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price) +; + + +;uInt longest_match(s, cur_match) +; deflate_state *s; +; IPos cur_match; /* current match */ +.code +longest_match PROC + + +;LocalVarsSize equ 88 + LocalVarsSize equ 72 + +; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12 +; free register : r14,r15 +; register can be saved : rsp + + chainlenwmask equ rsp + 8 - LocalVarsSize ; high word: current chain len + ; low word: s->wmask +;window equ rsp + xx - LocalVarsSize ; local copy of s->window ; stored in r10 +;windowbestlen equ rsp + xx - LocalVarsSize ; s->window + bestlen , use r10+r11 +;scanstart equ rsp + xx - LocalVarsSize ; first two bytes of string ; stored in r12w +;scanend equ rsp + xx - LocalVarsSize ; last two bytes of string use ebx +;scanalign equ rsp + xx - LocalVarsSize ; dword-misalignment of string r13 +;bestlen equ rsp + xx - LocalVarsSize ; size of best match so far -> r11d +;scan equ rsp + xx - LocalVarsSize ; ptr to string wanting match -> r9 +IFDEF INFOZIP +ELSE + nicematch equ (rsp + 16 - LocalVarsSize) ; a good enough match size +ENDIF + +save_rdi equ rsp + 24 - LocalVarsSize +save_rsi equ rsp + 32 - LocalVarsSize +save_rbx equ rsp + 40 - LocalVarsSize +save_rbp equ rsp + 48 - LocalVarsSize +save_r12 equ rsp + 56 - LocalVarsSize +save_r13 equ rsp + 64 - LocalVarsSize +;save_r14 equ rsp + 72 - LocalVarsSize +;save_r15 equ rsp + 80 - LocalVarsSize + + +; summary of register usage +; scanend ebx +; scanendw bx +; chainlenwmask edx +; curmatch rsi +; curmatchd esi +; windowbestlen r8 +; scanalign r9 +; scanalignd r9d +; window r10 +; bestlen r11 +; bestlend r11d +; scanstart r12d +; scanstartw r12w +; scan r13 +; nicematch r14d +; limit r15 +; limitd r15d +; prev rcx + +; all the +4 offsets are due to the addition of pending_buf_size (in zlib +; in the deflate_state structure since the asm code was first written +; (if you compile with zlib 1.0.4 or older, remove the +4). +; Note : these value are good with a 8 bytes boundary pack structure + + + MAX_MATCH equ 258 + MIN_MATCH equ 3 + MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) + + +;;; Offsets for fields in the deflate_state structure. These numbers +;;; are calculated from the definition of deflate_state, with the +;;; assumption that the compiler will dword-align the fields. (Thus, +;;; changing the definition of deflate_state could easily cause this +;;; program to crash horribly, without so much as a warning at +;;; compile time. Sigh.) + +; all the +zlib1222add offsets are due to the addition of fields +; in zlib in the deflate_state structure since the asm code was first written +; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). +; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). +; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). + + +IFDEF INFOZIP + +_DATA SEGMENT +COMM window_size:DWORD +; WMask ; 7fff +COMM window:BYTE:010040H +COMM prev:WORD:08000H +; MatchLen : unused +; PrevMatch : unused +COMM strstart:DWORD +COMM match_start:DWORD +; Lookahead : ignore +COMM prev_length:DWORD ; PrevLen +COMM max_chain_length:DWORD +COMM good_match:DWORD +COMM nice_match:DWORD +prev_ad equ OFFSET prev +window_ad equ OFFSET window +nicematch equ nice_match +_DATA ENDS +WMask equ 07fffh + +ELSE + + IFNDEF zlib1222add + zlib1222add equ 8 + ENDIF +dsWSize equ 56+zlib1222add+(zlib1222add/2) +dsWMask equ 64+zlib1222add+(zlib1222add/2) +dsWindow equ 72+zlib1222add +dsPrev equ 88+zlib1222add +dsMatchLen equ 128+zlib1222add +dsPrevMatch equ 132+zlib1222add +dsStrStart equ 140+zlib1222add +dsMatchStart equ 144+zlib1222add +dsLookahead equ 148+zlib1222add +dsPrevLen equ 152+zlib1222add +dsMaxChainLen equ 156+zlib1222add +dsGoodMatch equ 172+zlib1222add +dsNiceMatch equ 176+zlib1222add + +window_size equ [ rcx + dsWSize] +WMask equ [ rcx + dsWMask] +window_ad equ [ rcx + dsWindow] +prev_ad equ [ rcx + dsPrev] +strstart equ [ rcx + dsStrStart] +match_start equ [ rcx + dsMatchStart] +Lookahead equ [ rcx + dsLookahead] ; 0ffffffffh on infozip +prev_length equ [ rcx + dsPrevLen] +max_chain_length equ [ rcx + dsMaxChainLen] +good_match equ [ rcx + dsGoodMatch] +nice_match equ [ rcx + dsNiceMatch] +ENDIF + +; parameter 1 in r8(deflate state s), param 2 in rdx (cur match) + +; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and +; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp +; +; All registers must be preserved across the call, except for +; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. + + + +;;; Save registers that the compiler may be using, and adjust esp to +;;; make room for our stack frame. + + +;;; Retrieve the function arguments. r8d will hold cur_match +;;; throughout the entire function. edx will hold the pointer to the +;;; deflate_state structure during the function's setup (before +;;; entering the main loop. + +; parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match) + +; this clear high 32 bits of r8, which can be garbage in both r8 and rdx + + mov [save_rdi],rdi + mov [save_rsi],rsi + mov [save_rbx],rbx + mov [save_rbp],rbp +IFDEF INFOZIP + mov r8d,ecx +ELSE + mov r8d,edx +ENDIF + mov [save_r12],r12 + mov [save_r13],r13 +; mov [save_r14],r14 +; mov [save_r15],r15 + + +;;; uInt wmask = s->w_mask; +;;; unsigned chain_length = s->max_chain_length; +;;; if (s->prev_length >= s->good_match) { +;;; chain_length >>= 2; +;;; } + + mov edi, prev_length + mov esi, good_match + mov eax, WMask + mov ebx, max_chain_length + cmp edi, esi + jl LastMatchGood + shr ebx, 2 +LastMatchGood: + +;;; chainlen is decremented once beforehand so that the function can +;;; use the sign flag instead of the zero flag for the exit test. +;;; It is then shifted into the high word, to make room for the wmask +;;; value, which it will always accompany. + + dec ebx + shl ebx, 16 + or ebx, eax + +;;; on zlib only +;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + +IFDEF INFOZIP + mov [chainlenwmask], ebx +; on infozip nice_match = [nice_match] +ELSE + mov eax, nice_match + mov [chainlenwmask], ebx + mov r10d, Lookahead + cmp r10d, eax + cmovnl r10d, eax + mov [nicematch],r10d +ENDIF + +;;; register Bytef *scan = s->window + s->strstart; + mov r10, window_ad + mov ebp, strstart + lea r13, [r10 + rbp] + +;;; Determine how many bytes the scan ptr is off from being +;;; dword-aligned. + + mov r9,r13 + neg r13 + and r13,3 + +;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? +;;; s->strstart - (IPos)MAX_DIST(s) : NIL; +IFDEF INFOZIP + mov eax,07efah ; MAX_DIST = (WSIZE-MIN_LOOKAHEAD) (0x8000-(3+8+1)) +ELSE + mov eax, window_size + sub eax, MIN_LOOKAHEAD +ENDIF + xor edi,edi + sub ebp, eax + + mov r11d, prev_length + + cmovng ebp,edi + +;;; int best_len = s->prev_length; + + +;;; Store the sum of s->window + best_len in esi locally, and in esi. + + lea rsi,[r10+r11] + +;;; register ush scan_start = *(ushf*)scan; +;;; register ush scan_end = *(ushf*)(scan+best_len-1); +;;; Posf *prev = s->prev; + + movzx r12d,word ptr [r9] + movzx ebx, word ptr [r9 + r11 - 1] + + mov rdi, prev_ad + +;;; Jump into the main loop. + + mov edx, [chainlenwmask] + + cmp bx,word ptr [rsi + r8 - 1] + jz LookupLoopIsZero + +LookupLoop1: + and r8d, edx + + movzx r8d, word ptr [rdi + r8*2] + cmp r8d, ebp + jbe LeaveNow + sub edx, 00010000h + js LeaveNow + +LoopEntry1: + cmp bx,word ptr [rsi + r8 - 1] + jz LookupLoopIsZero + +LookupLoop2: + and r8d, edx + + movzx r8d, word ptr [rdi + r8*2] + cmp r8d, ebp + jbe LeaveNow + sub edx, 00010000h + js LeaveNow + +LoopEntry2: + cmp bx,word ptr [rsi + r8 - 1] + jz LookupLoopIsZero + +LookupLoop4: + and r8d, edx + + movzx r8d, word ptr [rdi + r8*2] + cmp r8d, ebp + jbe LeaveNow + sub edx, 00010000h + js LeaveNow + +LoopEntry4: + + cmp bx,word ptr [rsi + r8 - 1] + jnz LookupLoop1 + jmp LookupLoopIsZero + + +;;; do { +;;; match = s->window + cur_match; +;;; if (*(ushf*)(match+best_len-1) != scan_end || +;;; *(ushf*)match != scan_start) continue; +;;; [...] +;;; } while ((cur_match = prev[cur_match & wmask]) > limit +;;; && --chain_length != 0); +;;; +;;; Here is the inner loop of the function. The function will spend the +;;; majority of its time in this loop, and majority of that time will +;;; be spent in the first ten instructions. +;;; +;;; Within this loop: +;;; ebx = scanend +;;; r8d = curmatch +;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) +;;; esi = windowbestlen - i.e., (window + bestlen) +;;; edi = prev +;;; ebp = limit + +LookupLoop: + and r8d, edx + + movzx r8d, word ptr [rdi + r8*2] + cmp r8d, ebp + jbe LeaveNow + sub edx, 00010000h + js LeaveNow + +LoopEntry: + + cmp bx,word ptr [rsi + r8 - 1] + jnz LookupLoop1 +LookupLoopIsZero: + cmp r12w, word ptr [r10 + r8] + jnz LookupLoop1 + + +;;; Store the current value of chainlen. + mov [chainlenwmask], edx + +;;; Point edi to the string under scrutiny, and esi to the string we +;;; are hoping to match it up with. In actuality, esi and edi are +;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is +;;; initialized to -(MAX_MATCH_8 - scanalign). + + lea rsi,[r8+r10] + mov rdx, 0fffffffffffffef8h; -(MAX_MATCH_8) + lea rsi, [rsi + r13 + 0108h] ;MAX_MATCH_8] + lea rdi, [r9 + r13 + 0108h] ;MAX_MATCH_8] + + prefetcht1 [rsi+rdx] + prefetcht1 [rdi+rdx] + + +;;; Test the strings for equality, 8 bytes at a time. At the end, +;;; adjust rdx so that it is offset to the exact byte that mismatched. +;;; +;;; We already know at this point that the first three bytes of the +;;; strings match each other, and they can be safely passed over before +;;; starting the compare loop. So what this code does is skip over 0-3 +;;; bytes, as much as necessary in order to dword-align the edi +;;; pointer. (rsi will still be misaligned three times out of four.) +;;; +;;; It should be confessed that this loop usually does not represent +;;; much of the total running time. Replacing it with a more +;;; straightforward "rep cmpsb" would not drastically degrade +;;; performance. + + +LoopCmps: + mov rax, [rsi + rdx] + xor rax, [rdi + rdx] + jnz LeaveLoopCmps + + mov rax, [rsi + rdx + 8] + xor rax, [rdi + rdx + 8] + jnz LeaveLoopCmps8 + + + mov rax, [rsi + rdx + 8+8] + xor rax, [rdi + rdx + 8+8] + jnz LeaveLoopCmps16 + + add rdx,8+8+8 + + jnz short LoopCmps + jmp short LenMaximum +LeaveLoopCmps16: add rdx,8 +LeaveLoopCmps8: add rdx,8 +LeaveLoopCmps: + + test eax, 0000FFFFh + jnz LenLower + + test eax,0ffffffffh + + jnz LenLower32 + + add rdx,4 + shr rax,32 + or ax,ax + jnz LenLower + +LenLower32: + shr eax,16 + add rdx,2 +LenLower: sub al, 1 + adc rdx, 0 +;;; Calculate the length of the match. If it is longer than MAX_MATCH, +;;; then automatically accept it as the best possible match and leave. + + lea rax, [rdi + rdx] + sub rax, r9 + cmp eax, MAX_MATCH + jge LenMaximum + +;;; If the length of the match is not longer than the best match we +;;; have so far, then forget it and return to the lookup loop. +;/////////////////////////////////// + + cmp eax, r11d + jg LongerMatch + + lea rsi,[r10+r11] + + mov rdi, prev_ad + mov edx, [chainlenwmask] + jmp LookupLoop + +;;; s->match_start = cur_match; +;;; best_len = len; +;;; if (len >= nice_match) break; +;;; scan_end = *(ushf*)(scan+best_len-1); + +LongerMatch: + mov r11d, eax + mov match_start, r8d + cmp eax, [nicematch] + jge LeaveNow + + lea rsi,[r10+rax] + + movzx ebx, word ptr [r9 + rax - 1] + mov rdi, prev_ad + mov edx, [chainlenwmask] + jmp LookupLoop + +;;; Accept the current string, with the maximum possible length. + +LenMaximum: + mov r11d,MAX_MATCH + mov match_start, r8d + +;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; +;;; return s->lookahead; + +LeaveNow: +IFDEF INFOZIP + mov eax,r11d +ELSE + mov eax, Lookahead + cmp r11d, eax + cmovng eax, r11d +ENDIF + +;;; Restore the stack and return from whence we came. + + + mov rsi,[save_rsi] + mov rdi,[save_rdi] + mov rbx,[save_rbx] + mov rbp,[save_rbp] + mov r12,[save_r12] + mov r13,[save_r13] +; mov r14,[save_r14] +; mov r15,[save_r15] + + + ret 0 +; please don't remove this string ! +; Your can freely use gvmat64 in any free or commercial app +; but it is far better don't remove the string in the binary! + db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0 +longest_match ENDP + +match_init PROC + ret 0 +match_init ENDP + + +END diff --git a/xs/src/png/zlib/contrib/masmx64/inffas8664.c b/xs/src/png/zlib/contrib/masmx64/inffas8664.c new file mode 100644 index 0000000000..aa861a3339 --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx64/inffas8664.c @@ -0,0 +1,186 @@ +/* inffas8664.c is a hand tuned assembler version of inffast.c - fast decoding + * version for AMD64 on Windows using Microsoft C compiler + * + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Copyright (C) 2003 Chris Anderson + * Please use the copyright conditions above. + * + * 2005 - Adaptation to Microsoft C Compiler for AMD64 by Gilles Vollant + * + * inffas8664.c call function inffas8664fnc in inffasx64.asm + * inffasx64.asm is automatically convert from AMD64 portion of inffas86.c + * + * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also + * slightly quicker on x86 systems because, instead of using rep movsb to copy + * data, it uses rep movsw, which moves data in 2-byte chunks instead of single + * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates + * from http://fedora.linux.duke.edu/fc1_x86_64 + * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with + * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version, + * when decompressing mozilla-source-1.3.tar.gz. + * + * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from + * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at + * the moment. I have successfully compiled and tested this code with gcc2.96, + * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S + * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX + * enabled. I will attempt to merge the MMX code into this version. Newer + * versions of this and inffast.S can be found at + * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ + * + */ + +#include +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +/* Mark Adler's comments from inffast.c: */ + +/* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state->mode == LEN + strm->avail_in >= 6 + strm->avail_out >= 258 + start >= strm->avail_out + state->bits < 8 + + On return, state->mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm->avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm->avail_out >= 258 for each loop to avoid checking for + output space. + */ + + + + typedef struct inffast_ar { +/* 64 32 x86 x86_64 */ +/* ar offset register */ +/* 0 0 */ void *esp; /* esp save */ +/* 8 4 */ void *ebp; /* ebp save */ +/* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */ +/* 24 12 */ unsigned char FAR *last; /* r9 while in < last */ +/* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */ +/* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */ +/* 48 24 */ unsigned char FAR *end; /* r10 while out < end */ +/* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */ +/* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */ +/* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */ +/* 80 40 */ size_t /*unsigned long */hold; /* edx rdx local strm->hold */ +/* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */ +/* 92 48 */ unsigned wsize; /* window size */ +/* 96 52 */ unsigned write; /* window write index */ +/*100 56 */ unsigned lmask; /* r12 mask for lcode */ +/*104 60 */ unsigned dmask; /* r13 mask for dcode */ +/*108 64 */ unsigned len; /* r14 match length */ +/*112 68 */ unsigned dist; /* r15 match distance */ +/*116 72 */ unsigned status; /* set when state chng*/ + } type_ar; +#ifdef ASMINF + +void inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + type_ar ar; + void inffas8664fnc(struct inffast_ar * par); + + + +#if (defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )) || (defined(_MSC_VER) && defined(_M_AMD64)) +#define PAD_AVAIL_IN 6 +#define PAD_AVAIL_OUT 258 +#else +#define PAD_AVAIL_IN 5 +#define PAD_AVAIL_OUT 257 +#endif + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + + ar.in = strm->next_in; + ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN); + ar.out = strm->next_out; + ar.beg = ar.out - (start - strm->avail_out); + ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT); + ar.wsize = state->wsize; + ar.write = state->wnext; + ar.window = state->window; + ar.hold = state->hold; + ar.bits = state->bits; + ar.lcode = state->lencode; + ar.dcode = state->distcode; + ar.lmask = (1U << state->lenbits) - 1; + ar.dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + + /* align in on 1/2 hold size boundary */ + while (((size_t)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) { + ar.hold += (unsigned long)*ar.in++ << ar.bits; + ar.bits += 8; + } + + inffas8664fnc(&ar); + + if (ar.status > 1) { + if (ar.status == 2) + strm->msg = "invalid literal/length code"; + else if (ar.status == 3) + strm->msg = "invalid distance code"; + else + strm->msg = "invalid distance too far back"; + state->mode = BAD; + } + else if ( ar.status == 1 ) { + state->mode = TYPE; + } + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + ar.len = ar.bits >> 3; + ar.in -= ar.len; + ar.bits -= ar.len << 3; + ar.hold &= (1U << ar.bits) - 1; + + /* update state and return */ + strm->next_in = ar.in; + strm->next_out = ar.out; + strm->avail_in = (unsigned)(ar.in < ar.last ? + PAD_AVAIL_IN + (ar.last - ar.in) : + PAD_AVAIL_IN - (ar.in - ar.last)); + strm->avail_out = (unsigned)(ar.out < ar.end ? + PAD_AVAIL_OUT + (ar.end - ar.out) : + PAD_AVAIL_OUT - (ar.out - ar.end)); + state->hold = (unsigned long)ar.hold; + state->bits = ar.bits; + return; +} + +#endif diff --git a/xs/src/png/zlib/contrib/masmx64/inffasx64.asm b/xs/src/png/zlib/contrib/masmx64/inffasx64.asm new file mode 100644 index 0000000000..41ec82392e --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx64/inffasx64.asm @@ -0,0 +1,396 @@ +; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding +; version for AMD64 on Windows using Microsoft C compiler +; +; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c +; inffasx64.asm is called by inffas8664.c, which contain more info. + + +; to compile this file, I use option +; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm +; with Microsoft Macro Assembler (x64) for AMD64 +; + +; This file compile with Microsoft Macro Assembler (x64) for AMD64 +; +; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK +; +; (you can get Windows WDK with ml64 for AMD64 from +; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price) +; + + +.code +inffas8664fnc PROC + +; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and +; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp +; +; All registers must be preserved across the call, except for +; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch. + + + mov [rsp-8],rsi + mov [rsp-16],rdi + mov [rsp-24],r12 + mov [rsp-32],r13 + mov [rsp-40],r14 + mov [rsp-48],r15 + mov [rsp-56],rbx + + mov rax,rcx + + mov [rax+8], rbp ; /* save regs rbp and rsp */ + mov [rax], rsp + + mov rsp, rax ; /* make rsp point to &ar */ + + mov rsi, [rsp+16] ; /* rsi = in */ + mov rdi, [rsp+32] ; /* rdi = out */ + mov r9, [rsp+24] ; /* r9 = last */ + mov r10, [rsp+48] ; /* r10 = end */ + mov rbp, [rsp+64] ; /* rbp = lcode */ + mov r11, [rsp+72] ; /* r11 = dcode */ + mov rdx, [rsp+80] ; /* rdx = hold */ + mov ebx, [rsp+88] ; /* ebx = bits */ + mov r12d, [rsp+100] ; /* r12d = lmask */ + mov r13d, [rsp+104] ; /* r13d = dmask */ + ; /* r14d = len */ + ; /* r15d = dist */ + + + cld + cmp r10, rdi + je L_one_time ; /* if only one decode left */ + cmp r9, rsi + + jne L_do_loop + + +L_one_time: + mov r8, r12 ; /* r8 = lmask */ + cmp bl, 32 + ja L_get_length_code_one_time + + lodsd ; /* eax = *(uint *)in++ */ + mov cl, bl ; /* cl = bits, needs it for shifting */ + add bl, 32 ; /* bits += 32 */ + shl rax, cl + or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ + jmp L_get_length_code_one_time + +ALIGN 4 +L_while_test: + cmp r10, rdi + jbe L_break_loop + cmp r9, rsi + jbe L_break_loop + +L_do_loop: + mov r8, r12 ; /* r8 = lmask */ + cmp bl, 32 + ja L_get_length_code ; /* if (32 < bits) */ + + lodsd ; /* eax = *(uint *)in++ */ + mov cl, bl ; /* cl = bits, needs it for shifting */ + add bl, 32 ; /* bits += 32 */ + shl rax, cl + or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ + +L_get_length_code: + and r8, rdx ; /* r8 &= hold */ + mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */ + + mov cl, ah ; /* cl = this.bits */ + sub bl, ah ; /* bits -= this.bits */ + shr rdx, cl ; /* hold >>= this.bits */ + + test al, al + jnz L_test_for_length_base ; /* if (op != 0) 45.7% */ + + mov r8, r12 ; /* r8 = lmask */ + shr eax, 16 ; /* output this.val char */ + stosb + +L_get_length_code_one_time: + and r8, rdx ; /* r8 &= hold */ + mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */ + +L_dolen: + mov cl, ah ; /* cl = this.bits */ + sub bl, ah ; /* bits -= this.bits */ + shr rdx, cl ; /* hold >>= this.bits */ + + test al, al + jnz L_test_for_length_base ; /* if (op != 0) 45.7% */ + + shr eax, 16 ; /* output this.val char */ + stosb + jmp L_while_test + +ALIGN 4 +L_test_for_length_base: + mov r14d, eax ; /* len = this */ + shr r14d, 16 ; /* len = this.val */ + mov cl, al + + test al, 16 + jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */ + and cl, 15 ; /* op &= 15 */ + jz L_decode_distance ; /* if (!op) */ + +L_add_bits_to_len: + sub bl, cl + xor eax, eax + inc eax + shl eax, cl + dec eax + and eax, edx ; /* eax &= hold */ + shr rdx, cl + add r14d, eax ; /* len += hold & mask[op] */ + +L_decode_distance: + mov r8, r13 ; /* r8 = dmask */ + cmp bl, 32 + ja L_get_distance_code ; /* if (32 < bits) */ + + lodsd ; /* eax = *(uint *)in++ */ + mov cl, bl ; /* cl = bits, needs it for shifting */ + add bl, 32 ; /* bits += 32 */ + shl rax, cl + or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ + +L_get_distance_code: + and r8, rdx ; /* r8 &= hold */ + mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */ + +L_dodist: + mov r15d, eax ; /* dist = this */ + shr r15d, 16 ; /* dist = this.val */ + mov cl, ah + sub bl, ah ; /* bits -= this.bits */ + shr rdx, cl ; /* hold >>= this.bits */ + mov cl, al ; /* cl = this.op */ + + test al, 16 ; /* if ((op & 16) == 0) */ + jz L_test_for_second_level_dist + and cl, 15 ; /* op &= 15 */ + jz L_check_dist_one + +L_add_bits_to_dist: + sub bl, cl + xor eax, eax + inc eax + shl eax, cl + dec eax ; /* (1 << op) - 1 */ + and eax, edx ; /* eax &= hold */ + shr rdx, cl + add r15d, eax ; /* dist += hold & ((1 << op) - 1) */ + +L_check_window: + mov r8, rsi ; /* save in so from can use it's reg */ + mov rax, rdi + sub rax, [rsp+40] ; /* nbytes = out - beg */ + + cmp eax, r15d + jb L_clip_window ; /* if (dist > nbytes) 4.2% */ + + mov ecx, r14d ; /* ecx = len */ + mov rsi, rdi + sub rsi, r15 ; /* from = out - dist */ + + sar ecx, 1 + jnc L_copy_two ; /* if len % 2 == 0 */ + + rep movsw + mov al, [rsi] + mov [rdi], al + inc rdi + + mov rsi, r8 ; /* move in back to %rsi, toss from */ + jmp L_while_test + +L_copy_two: + rep movsw + mov rsi, r8 ; /* move in back to %rsi, toss from */ + jmp L_while_test + +ALIGN 4 +L_check_dist_one: + cmp r15d, 1 ; /* if dist 1, is a memset */ + jne L_check_window + cmp [rsp+40], rdi ; /* if out == beg, outside window */ + je L_check_window + + mov ecx, r14d ; /* ecx = len */ + mov al, [rdi-1] + mov ah, al + + sar ecx, 1 + jnc L_set_two + mov [rdi], al + inc rdi + +L_set_two: + rep stosw + jmp L_while_test + +ALIGN 4 +L_test_for_second_level_length: + test al, 64 + jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */ + + xor eax, eax + inc eax + shl eax, cl + dec eax + and eax, edx ; /* eax &= hold */ + add eax, r14d ; /* eax += len */ + mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/ + jmp L_dolen + +ALIGN 4 +L_test_for_second_level_dist: + test al, 64 + jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */ + + xor eax, eax + inc eax + shl eax, cl + dec eax + and eax, edx ; /* eax &= hold */ + add eax, r15d ; /* eax += dist */ + mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/ + jmp L_dodist + +ALIGN 4 +L_clip_window: + mov ecx, eax ; /* ecx = nbytes */ + mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */ + neg ecx ; /* nbytes = -nbytes */ + + cmp eax, r15d + jb L_invalid_distance_too_far ; /* if (dist > wsize) */ + + add ecx, r15d ; /* nbytes = dist - nbytes */ + cmp dword ptr [rsp+96], 0 + jne L_wrap_around_window ; /* if (write != 0) */ + + mov rsi, [rsp+56] ; /* from = window */ + sub eax, ecx ; /* eax -= nbytes */ + add rsi, rax ; /* from += wsize - nbytes */ + + mov eax, r14d ; /* eax = len */ + cmp r14d, ecx + jbe L_do_copy ; /* if (nbytes >= len) */ + + sub eax, ecx ; /* eax -= nbytes */ + rep movsb + mov rsi, rdi + sub rsi, r15 ; /* from = &out[ -dist ] */ + jmp L_do_copy + +ALIGN 4 +L_wrap_around_window: + mov eax, [rsp+96] ; /* eax = write */ + cmp ecx, eax + jbe L_contiguous_in_window ; /* if (write >= nbytes) */ + + mov esi, [rsp+92] ; /* from = wsize */ + add rsi, [rsp+56] ; /* from += window */ + add rsi, rax ; /* from += write */ + sub rsi, rcx ; /* from -= nbytes */ + sub ecx, eax ; /* nbytes -= write */ + + mov eax, r14d ; /* eax = len */ + cmp eax, ecx + jbe L_do_copy ; /* if (nbytes >= len) */ + + sub eax, ecx ; /* len -= nbytes */ + rep movsb + mov rsi, [rsp+56] ; /* from = window */ + mov ecx, [rsp+96] ; /* nbytes = write */ + cmp eax, ecx + jbe L_do_copy ; /* if (nbytes >= len) */ + + sub eax, ecx ; /* len -= nbytes */ + rep movsb + mov rsi, rdi + sub rsi, r15 ; /* from = out - dist */ + jmp L_do_copy + +ALIGN 4 +L_contiguous_in_window: + mov rsi, [rsp+56] ; /* rsi = window */ + add rsi, rax + sub rsi, rcx ; /* from += write - nbytes */ + + mov eax, r14d ; /* eax = len */ + cmp eax, ecx + jbe L_do_copy ; /* if (nbytes >= len) */ + + sub eax, ecx ; /* len -= nbytes */ + rep movsb + mov rsi, rdi + sub rsi, r15 ; /* from = out - dist */ + jmp L_do_copy ; /* if (nbytes >= len) */ + +ALIGN 4 +L_do_copy: + mov ecx, eax ; /* ecx = len */ + rep movsb + + mov rsi, r8 ; /* move in back to %esi, toss from */ + jmp L_while_test + +L_test_for_end_of_block: + test al, 32 + jz L_invalid_literal_length_code + mov dword ptr [rsp+116], 1 + jmp L_break_loop_with_status + +L_invalid_literal_length_code: + mov dword ptr [rsp+116], 2 + jmp L_break_loop_with_status + +L_invalid_distance_code: + mov dword ptr [rsp+116], 3 + jmp L_break_loop_with_status + +L_invalid_distance_too_far: + mov dword ptr [rsp+116], 4 + jmp L_break_loop_with_status + +L_break_loop: + mov dword ptr [rsp+116], 0 + +L_break_loop_with_status: +; /* put in, out, bits, and hold back into ar and pop esp */ + mov [rsp+16], rsi ; /* in */ + mov [rsp+32], rdi ; /* out */ + mov [rsp+88], ebx ; /* bits */ + mov [rsp+80], rdx ; /* hold */ + + mov rax, [rsp] ; /* restore rbp and rsp */ + mov rbp, [rsp+8] + mov rsp, rax + + + + mov rsi,[rsp-8] + mov rdi,[rsp-16] + mov r12,[rsp-24] + mov r13,[rsp-32] + mov r14,[rsp-40] + mov r15,[rsp-48] + mov rbx,[rsp-56] + + ret 0 +; : +; : "m" (ar) +; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", +; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" +; ); + +inffas8664fnc ENDP +;_TEXT ENDS +END diff --git a/xs/src/png/zlib/contrib/masmx64/readme.txt b/xs/src/png/zlib/contrib/masmx64/readme.txt new file mode 100644 index 0000000000..652571c7a5 --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx64/readme.txt @@ -0,0 +1,31 @@ +Summary +------- +This directory contains ASM implementations of the functions +longest_match() and inflate_fast(), for 64 bits x86 (both AMD64 and Intel EM64t), +for use with Microsoft Macro Assembler (x64) for AMD64 and Microsoft C++ 64 bits. + +gvmat64.asm is written by Gilles Vollant (2005), by using Brian Raiter 686/32 bits + assembly optimized version from Jean-loup Gailly original longest_match function + +inffasx64.asm and inffas8664.c were written by Chris Anderson, by optimizing + original function from Mark Adler + +Use instructions +---------------- +Assemble the .asm files using MASM and put the object files into the zlib source +directory. You can also get object files here: + + http://www.winimage.com/zLibDll/zlib124_masm_obj.zip + +define ASMV and ASMINF in your project. Include inffas8664.c in your source tree, +and inffasx64.obj and gvmat64.obj as object to link. + + +Build instructions +------------------ +run bld_64.bat with Microsoft Macro Assembler (x64) for AMD64 (ml64.exe) + +ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK + +You can get Windows 2003 server DDK with ml64 and cl for AMD64 from + http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) diff --git a/xs/src/png/zlib/contrib/masmx86/bld_ml32.bat b/xs/src/png/zlib/contrib/masmx86/bld_ml32.bat new file mode 100644 index 0000000000..fcf5755e46 --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx86/bld_ml32.bat @@ -0,0 +1,2 @@ +ml /coff /Zi /c /Flmatch686.lst match686.asm +ml /coff /Zi /c /Flinffas32.lst inffas32.asm diff --git a/xs/src/png/zlib/contrib/masmx86/inffas32.asm b/xs/src/png/zlib/contrib/masmx86/inffas32.asm new file mode 100644 index 0000000000..cb37a81e4e --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx86/inffas32.asm @@ -0,0 +1,1080 @@ +;/* inffas32.asm is a hand tuned assembler version of inffast.c -- fast decoding +; * +; * inffas32.asm is derivated from inffas86.c, with translation of assembly code +; * +; * Copyright (C) 1995-2003 Mark Adler +; * For conditions of distribution and use, see copyright notice in zlib.h +; * +; * Copyright (C) 2003 Chris Anderson +; * Please use the copyright conditions above. +; * +; * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from +; * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at +; * the moment. I have successfully compiled and tested this code with gcc2.96, +; * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S +; * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX +; * enabled. I will attempt to merge the MMX code into this version. Newer +; * versions of this and inffast.S can be found at +; * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ +; * +; * 2005 : modification by Gilles Vollant +; */ +; For Visual C++ 4.x and higher and ML 6.x and higher +; ml.exe is in directory \MASM611C of Win95 DDK +; ml.exe is also distributed in http://www.masm32.com/masmdl.htm +; and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/ +; +; +; compile with command line option +; ml /coff /Zi /c /Flinffas32.lst inffas32.asm + +; if you define NO_GZIP (see inflate.h), compile with +; ml /coff /Zi /c /Flinffas32.lst /DNO_GUNZIP inffas32.asm + + +; zlib122sup is 0 fort zlib 1.2.2.1 and lower +; zlib122sup is 8 fort zlib 1.2.2.2 and more (with addition of dmax and head +; in inflate_state in inflate.h) +zlib1222sup equ 8 + + +IFDEF GUNZIP + INFLATE_MODE_TYPE equ 11 + INFLATE_MODE_BAD equ 26 +ELSE + IFNDEF NO_GUNZIP + INFLATE_MODE_TYPE equ 11 + INFLATE_MODE_BAD equ 26 + ELSE + INFLATE_MODE_TYPE equ 3 + INFLATE_MODE_BAD equ 17 + ENDIF +ENDIF + + +; 75 "inffast.S" +;FILE "inffast.S" + +;;;GLOBAL _inflate_fast + +;;;SECTION .text + + + + .586p + .mmx + + name inflate_fast_x86 + .MODEL FLAT + +_DATA segment +inflate_fast_use_mmx: + dd 1 + + +_TEXT segment + + + +ALIGN 4 + db 'Fast decoding Code from Chris Anderson' + db 0 + +ALIGN 4 +invalid_literal_length_code_msg: + db 'invalid literal/length code' + db 0 + +ALIGN 4 +invalid_distance_code_msg: + db 'invalid distance code' + db 0 + +ALIGN 4 +invalid_distance_too_far_msg: + db 'invalid distance too far back' + db 0 + + +ALIGN 4 +inflate_fast_mask: +dd 0 +dd 1 +dd 3 +dd 7 +dd 15 +dd 31 +dd 63 +dd 127 +dd 255 +dd 511 +dd 1023 +dd 2047 +dd 4095 +dd 8191 +dd 16383 +dd 32767 +dd 65535 +dd 131071 +dd 262143 +dd 524287 +dd 1048575 +dd 2097151 +dd 4194303 +dd 8388607 +dd 16777215 +dd 33554431 +dd 67108863 +dd 134217727 +dd 268435455 +dd 536870911 +dd 1073741823 +dd 2147483647 +dd 4294967295 + + +mode_state equ 0 ;/* state->mode */ +wsize_state equ (32+zlib1222sup) ;/* state->wsize */ +write_state equ (36+4+zlib1222sup) ;/* state->write */ +window_state equ (40+4+zlib1222sup) ;/* state->window */ +hold_state equ (44+4+zlib1222sup) ;/* state->hold */ +bits_state equ (48+4+zlib1222sup) ;/* state->bits */ +lencode_state equ (64+4+zlib1222sup) ;/* state->lencode */ +distcode_state equ (68+4+zlib1222sup) ;/* state->distcode */ +lenbits_state equ (72+4+zlib1222sup) ;/* state->lenbits */ +distbits_state equ (76+4+zlib1222sup) ;/* state->distbits */ + + +;;SECTION .text +; 205 "inffast.S" +;GLOBAL inflate_fast_use_mmx + +;SECTION .data + + +; GLOBAL inflate_fast_use_mmx:object +;.size inflate_fast_use_mmx, 4 +; 226 "inffast.S" +;SECTION .text + +ALIGN 4 +_inflate_fast proc near +.FPO (16, 4, 0, 0, 1, 0) + push edi + push esi + push ebp + push ebx + pushfd + sub esp,64 + cld + + + + + mov esi, [esp+88] + mov edi, [esi+28] + + + + + + + + mov edx, [esi+4] + mov eax, [esi+0] + + add edx,eax + sub edx,11 + + mov [esp+44],eax + mov [esp+20],edx + + mov ebp, [esp+92] + mov ecx, [esi+16] + mov ebx, [esi+12] + + sub ebp,ecx + neg ebp + add ebp,ebx + + sub ecx,257 + add ecx,ebx + + mov [esp+60],ebx + mov [esp+40],ebp + mov [esp+16],ecx +; 285 "inffast.S" + mov eax, [edi+lencode_state] + mov ecx, [edi+distcode_state] + + mov [esp+8],eax + mov [esp+12],ecx + + mov eax,1 + mov ecx, [edi+lenbits_state] + shl eax,cl + dec eax + mov [esp+0],eax + + mov eax,1 + mov ecx, [edi+distbits_state] + shl eax,cl + dec eax + mov [esp+4],eax + + mov eax, [edi+wsize_state] + mov ecx, [edi+write_state] + mov edx, [edi+window_state] + + mov [esp+52],eax + mov [esp+48],ecx + mov [esp+56],edx + + mov ebp, [edi+hold_state] + mov ebx, [edi+bits_state] +; 321 "inffast.S" + mov esi, [esp+44] + mov ecx, [esp+20] + cmp ecx,esi + ja L_align_long + + add ecx,11 + sub ecx,esi + mov eax,12 + sub eax,ecx + lea edi, [esp+28] + rep movsb + mov ecx,eax + xor eax,eax + rep stosb + lea esi, [esp+28] + mov [esp+20],esi + jmp L_is_aligned + + +L_align_long: + test esi,3 + jz L_is_aligned + xor eax,eax + mov al, [esi] + inc esi + mov ecx,ebx + add ebx,8 + shl eax,cl + or ebp,eax + jmp L_align_long + +L_is_aligned: + mov edi, [esp+60] +; 366 "inffast.S" +L_check_mmx: + cmp dword ptr [inflate_fast_use_mmx],2 + je L_init_mmx + ja L_do_loop + + push eax + push ebx + push ecx + push edx + pushfd + mov eax, [esp] + xor dword ptr [esp],0200000h + + + + + popfd + pushfd + pop edx + xor edx,eax + jz L_dont_use_mmx + xor eax,eax + cpuid + cmp ebx,0756e6547h + jne L_dont_use_mmx + cmp ecx,06c65746eh + jne L_dont_use_mmx + cmp edx,049656e69h + jne L_dont_use_mmx + mov eax,1 + cpuid + shr eax,8 + and eax,15 + cmp eax,6 + jne L_dont_use_mmx + test edx,0800000h + jnz L_use_mmx + jmp L_dont_use_mmx +L_use_mmx: + mov dword ptr [inflate_fast_use_mmx],2 + jmp L_check_mmx_pop +L_dont_use_mmx: + mov dword ptr [inflate_fast_use_mmx],3 +L_check_mmx_pop: + pop edx + pop ecx + pop ebx + pop eax + jmp L_check_mmx +; 426 "inffast.S" +ALIGN 4 +L_do_loop: +; 437 "inffast.S" + cmp bl,15 + ja L_get_length_code + + xor eax,eax + lodsw + mov cl,bl + add bl,16 + shl eax,cl + or ebp,eax + +L_get_length_code: + mov edx, [esp+0] + mov ecx, [esp+8] + and edx,ebp + mov eax, [ecx+edx*4] + +L_dolen: + + + + + + + mov cl,ah + sub bl,ah + shr ebp,cl + + + + + + + test al,al + jnz L_test_for_length_base + + shr eax,16 + stosb + +L_while_test: + + + cmp [esp+16],edi + jbe L_break_loop + + cmp [esp+20],esi + ja L_do_loop + jmp L_break_loop + +L_test_for_length_base: +; 502 "inffast.S" + mov edx,eax + shr edx,16 + mov cl,al + + test al,16 + jz L_test_for_second_level_length + and cl,15 + jz L_save_len + cmp bl,cl + jae L_add_bits_to_len + + mov ch,cl + xor eax,eax + lodsw + mov cl,bl + add bl,16 + shl eax,cl + or ebp,eax + mov cl,ch + +L_add_bits_to_len: + mov eax,1 + shl eax,cl + dec eax + sub bl,cl + and eax,ebp + shr ebp,cl + add edx,eax + +L_save_len: + mov [esp+24],edx + + +L_decode_distance: +; 549 "inffast.S" + cmp bl,15 + ja L_get_distance_code + + xor eax,eax + lodsw + mov cl,bl + add bl,16 + shl eax,cl + or ebp,eax + +L_get_distance_code: + mov edx, [esp+4] + mov ecx, [esp+12] + and edx,ebp + mov eax, [ecx+edx*4] + + +L_dodist: + mov edx,eax + shr edx,16 + mov cl,ah + sub bl,ah + shr ebp,cl +; 584 "inffast.S" + mov cl,al + + test al,16 + jz L_test_for_second_level_dist + and cl,15 + jz L_check_dist_one + cmp bl,cl + jae L_add_bits_to_dist + + mov ch,cl + xor eax,eax + lodsw + mov cl,bl + add bl,16 + shl eax,cl + or ebp,eax + mov cl,ch + +L_add_bits_to_dist: + mov eax,1 + shl eax,cl + dec eax + sub bl,cl + and eax,ebp + shr ebp,cl + add edx,eax + jmp L_check_window + +L_check_window: +; 625 "inffast.S" + mov [esp+44],esi + mov eax,edi + sub eax, [esp+40] + + cmp eax,edx + jb L_clip_window + + mov ecx, [esp+24] + mov esi,edi + sub esi,edx + + sub ecx,3 + mov al, [esi] + mov [edi],al + mov al, [esi+1] + mov dl, [esi+2] + add esi,3 + mov [edi+1],al + mov [edi+2],dl + add edi,3 + rep movsb + + mov esi, [esp+44] + jmp L_while_test + +ALIGN 4 +L_check_dist_one: + cmp edx,1 + jne L_check_window + cmp [esp+40],edi + je L_check_window + + dec edi + mov ecx, [esp+24] + mov al, [edi] + sub ecx,3 + + mov [edi+1],al + mov [edi+2],al + mov [edi+3],al + add edi,4 + rep stosb + + jmp L_while_test + +ALIGN 4 +L_test_for_second_level_length: + + + + + test al,64 + jnz L_test_for_end_of_block + + mov eax,1 + shl eax,cl + dec eax + and eax,ebp + add eax,edx + mov edx, [esp+8] + mov eax, [edx+eax*4] + jmp L_dolen + +ALIGN 4 +L_test_for_second_level_dist: + + + + + test al,64 + jnz L_invalid_distance_code + + mov eax,1 + shl eax,cl + dec eax + and eax,ebp + add eax,edx + mov edx, [esp+12] + mov eax, [edx+eax*4] + jmp L_dodist + +ALIGN 4 +L_clip_window: +; 721 "inffast.S" + mov ecx,eax + mov eax, [esp+52] + neg ecx + mov esi, [esp+56] + + cmp eax,edx + jb L_invalid_distance_too_far + + add ecx,edx + cmp dword ptr [esp+48],0 + jne L_wrap_around_window + + sub eax,ecx + add esi,eax +; 749 "inffast.S" + mov eax, [esp+24] + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi,edi + sub esi,edx + jmp L_do_copy1 + + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi,edi + sub esi,edx + jmp L_do_copy1 + +L_wrap_around_window: +; 793 "inffast.S" + mov eax, [esp+48] + cmp ecx,eax + jbe L_contiguous_in_window + + add esi, [esp+52] + add esi,eax + sub esi,ecx + sub ecx,eax + + + mov eax, [esp+24] + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi, [esp+56] + mov ecx, [esp+48] + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi,edi + sub esi,edx + jmp L_do_copy1 + +L_contiguous_in_window: +; 836 "inffast.S" + add esi,eax + sub esi,ecx + + + mov eax, [esp+24] + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi,edi + sub esi,edx + +L_do_copy1: +; 862 "inffast.S" + mov ecx,eax + rep movsb + + mov esi, [esp+44] + jmp L_while_test +; 878 "inffast.S" +ALIGN 4 +L_init_mmx: + emms + + + + + + movd mm0,ebp + mov ebp,ebx +; 896 "inffast.S" + movd mm4,dword ptr [esp+0] + movq mm3,mm4 + movd mm5,dword ptr [esp+4] + movq mm2,mm5 + pxor mm1,mm1 + mov ebx, [esp+8] + jmp L_do_loop_mmx + +ALIGN 4 +L_do_loop_mmx: + psrlq mm0,mm1 + + cmp ebp,32 + ja L_get_length_code_mmx + + movd mm6,ebp + movd mm7,dword ptr [esi] + add esi,4 + psllq mm7,mm6 + add ebp,32 + por mm0,mm7 + +L_get_length_code_mmx: + pand mm4,mm0 + movd eax,mm4 + movq mm4,mm3 + mov eax, [ebx+eax*4] + +L_dolen_mmx: + movzx ecx,ah + movd mm1,ecx + sub ebp,ecx + + test al,al + jnz L_test_for_length_base_mmx + + shr eax,16 + stosb + +L_while_test_mmx: + + + cmp [esp+16],edi + jbe L_break_loop + + cmp [esp+20],esi + ja L_do_loop_mmx + jmp L_break_loop + +L_test_for_length_base_mmx: + + mov edx,eax + shr edx,16 + + test al,16 + jz L_test_for_second_level_length_mmx + and eax,15 + jz L_decode_distance_mmx + + psrlq mm0,mm1 + movd mm1,eax + movd ecx,mm0 + sub ebp,eax + and ecx, [inflate_fast_mask+eax*4] + add edx,ecx + +L_decode_distance_mmx: + psrlq mm0,mm1 + + cmp ebp,32 + ja L_get_dist_code_mmx + + movd mm6,ebp + movd mm7,dword ptr [esi] + add esi,4 + psllq mm7,mm6 + add ebp,32 + por mm0,mm7 + +L_get_dist_code_mmx: + mov ebx, [esp+12] + pand mm5,mm0 + movd eax,mm5 + movq mm5,mm2 + mov eax, [ebx+eax*4] + +L_dodist_mmx: + + movzx ecx,ah + mov ebx,eax + shr ebx,16 + sub ebp,ecx + movd mm1,ecx + + test al,16 + jz L_test_for_second_level_dist_mmx + and eax,15 + jz L_check_dist_one_mmx + +L_add_bits_to_dist_mmx: + psrlq mm0,mm1 + movd mm1,eax + movd ecx,mm0 + sub ebp,eax + and ecx, [inflate_fast_mask+eax*4] + add ebx,ecx + +L_check_window_mmx: + mov [esp+44],esi + mov eax,edi + sub eax, [esp+40] + + cmp eax,ebx + jb L_clip_window_mmx + + mov ecx,edx + mov esi,edi + sub esi,ebx + + sub ecx,3 + mov al, [esi] + mov [edi],al + mov al, [esi+1] + mov dl, [esi+2] + add esi,3 + mov [edi+1],al + mov [edi+2],dl + add edi,3 + rep movsb + + mov esi, [esp+44] + mov ebx, [esp+8] + jmp L_while_test_mmx + +ALIGN 4 +L_check_dist_one_mmx: + cmp ebx,1 + jne L_check_window_mmx + cmp [esp+40],edi + je L_check_window_mmx + + dec edi + mov ecx,edx + mov al, [edi] + sub ecx,3 + + mov [edi+1],al + mov [edi+2],al + mov [edi+3],al + add edi,4 + rep stosb + + mov ebx, [esp+8] + jmp L_while_test_mmx + +ALIGN 4 +L_test_for_second_level_length_mmx: + test al,64 + jnz L_test_for_end_of_block + + and eax,15 + psrlq mm0,mm1 + movd ecx,mm0 + and ecx, [inflate_fast_mask+eax*4] + add ecx,edx + mov eax, [ebx+ecx*4] + jmp L_dolen_mmx + +ALIGN 4 +L_test_for_second_level_dist_mmx: + test al,64 + jnz L_invalid_distance_code + + and eax,15 + psrlq mm0,mm1 + movd ecx,mm0 + and ecx, [inflate_fast_mask+eax*4] + mov eax, [esp+12] + add ecx,ebx + mov eax, [eax+ecx*4] + jmp L_dodist_mmx + +ALIGN 4 +L_clip_window_mmx: + + mov ecx,eax + mov eax, [esp+52] + neg ecx + mov esi, [esp+56] + + cmp eax,ebx + jb L_invalid_distance_too_far + + add ecx,ebx + cmp dword ptr [esp+48],0 + jne L_wrap_around_window_mmx + + sub eax,ecx + add esi,eax + + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi,edi + sub esi,ebx + jmp L_do_copy1_mmx + + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi,edi + sub esi,ebx + jmp L_do_copy1_mmx + +L_wrap_around_window_mmx: + + mov eax, [esp+48] + cmp ecx,eax + jbe L_contiguous_in_window_mmx + + add esi, [esp+52] + add esi,eax + sub esi,ecx + sub ecx,eax + + + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi, [esp+56] + mov ecx, [esp+48] + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi,edi + sub esi,ebx + jmp L_do_copy1_mmx + +L_contiguous_in_window_mmx: + + add esi,eax + sub esi,ecx + + + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi,edi + sub esi,ebx + +L_do_copy1_mmx: + + + mov ecx,edx + rep movsb + + mov esi, [esp+44] + mov ebx, [esp+8] + jmp L_while_test_mmx +; 1174 "inffast.S" +L_invalid_distance_code: + + + + + + mov ecx, invalid_distance_code_msg + mov edx,INFLATE_MODE_BAD + jmp L_update_stream_state + +L_test_for_end_of_block: + + + + + + test al,32 + jz L_invalid_literal_length_code + + mov ecx,0 + mov edx,INFLATE_MODE_TYPE + jmp L_update_stream_state + +L_invalid_literal_length_code: + + + + + + mov ecx, invalid_literal_length_code_msg + mov edx,INFLATE_MODE_BAD + jmp L_update_stream_state + +L_invalid_distance_too_far: + + + + mov esi, [esp+44] + mov ecx, invalid_distance_too_far_msg + mov edx,INFLATE_MODE_BAD + jmp L_update_stream_state + +L_update_stream_state: + + mov eax, [esp+88] + test ecx,ecx + jz L_skip_msg + mov [eax+24],ecx +L_skip_msg: + mov eax, [eax+28] + mov [eax+mode_state],edx + jmp L_break_loop + +ALIGN 4 +L_break_loop: +; 1243 "inffast.S" + cmp dword ptr [inflate_fast_use_mmx],2 + jne L_update_next_in + + + + mov ebx,ebp + +L_update_next_in: +; 1266 "inffast.S" + mov eax, [esp+88] + mov ecx,ebx + mov edx, [eax+28] + shr ecx,3 + sub esi,ecx + shl ecx,3 + sub ebx,ecx + mov [eax+12],edi + mov [edx+bits_state],ebx + mov ecx,ebx + + lea ebx, [esp+28] + cmp [esp+20],ebx + jne L_buf_not_used + + sub esi,ebx + mov ebx, [eax+0] + mov [esp+20],ebx + add esi,ebx + mov ebx, [eax+4] + sub ebx,11 + add [esp+20],ebx + +L_buf_not_used: + mov [eax+0],esi + + mov ebx,1 + shl ebx,cl + dec ebx + + + + + + cmp dword ptr [inflate_fast_use_mmx],2 + jne L_update_hold + + + + psrlq mm0,mm1 + movd ebp,mm0 + + emms + +L_update_hold: + + + + and ebp,ebx + mov [edx+hold_state],ebp + + + + + mov ebx, [esp+20] + cmp ebx,esi + jbe L_last_is_smaller + + sub ebx,esi + add ebx,11 + mov [eax+4],ebx + jmp L_fixup_out +L_last_is_smaller: + sub esi,ebx + neg esi + add esi,11 + mov [eax+4],esi + + + + +L_fixup_out: + + mov ebx, [esp+16] + cmp ebx,edi + jbe L_end_is_smaller + + sub ebx,edi + add ebx,257 + mov [eax+16],ebx + jmp L_done +L_end_is_smaller: + sub edi,ebx + neg edi + add edi,257 + mov [eax+16],edi + + + + + +L_done: + add esp,64 + popfd + pop ebx + pop ebp + pop esi + pop edi + ret +_inflate_fast endp + +_TEXT ends +end diff --git a/xs/src/png/zlib/contrib/masmx86/match686.asm b/xs/src/png/zlib/contrib/masmx86/match686.asm new file mode 100644 index 0000000000..69e0eed01d --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx86/match686.asm @@ -0,0 +1,479 @@ +; match686.asm -- Asm portion of the optimized longest_match for 32 bits x86 +; Copyright (C) 1995-1996 Jean-loup Gailly, Brian Raiter and Gilles Vollant. +; File written by Gilles Vollant, by converting match686.S from Brian Raiter +; for MASM. This is as assembly version of longest_match +; from Jean-loup Gailly in deflate.c +; +; http://www.zlib.net +; http://www.winimage.com/zLibDll +; http://www.muppetlabs.com/~breadbox/software/assembly.html +; +; For Visual C++ 4.x and higher and ML 6.x and higher +; ml.exe is distributed in +; http://www.microsoft.com/downloads/details.aspx?FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64 +; +; this file contain two implementation of longest_match +; +; this longest_match was written by Brian raiter (1998), optimized for Pentium Pro +; (and the faster known version of match_init on modern Core 2 Duo and AMD Phenom) +; +; for using an assembly version of longest_match, you need define ASMV in project +; +; compile the asm file running +; ml /coff /Zi /c /Flmatch686.lst match686.asm +; and do not include match686.obj in your project +; +; note: contrib of zLib 1.2.3 and earlier contained both a deprecated version for +; Pentium (prior Pentium Pro) and this version for Pentium Pro and modern processor +; with autoselect (with cpu detection code) +; if you want support the old pentium optimization, you can still use these version +; +; this file is not optimized for old pentium, but it compatible with all x86 32 bits +; processor (starting 80386) +; +; +; see below : zlib1222add must be adjuster if you use a zlib version < 1.2.2.2 + +;uInt longest_match(s, cur_match) +; deflate_state *s; +; IPos cur_match; /* current match */ + + NbStack equ 76 + cur_match equ dword ptr[esp+NbStack-0] + str_s equ dword ptr[esp+NbStack-4] +; 5 dword on top (ret,ebp,esi,edi,ebx) + adrret equ dword ptr[esp+NbStack-8] + pushebp equ dword ptr[esp+NbStack-12] + pushedi equ dword ptr[esp+NbStack-16] + pushesi equ dword ptr[esp+NbStack-20] + pushebx equ dword ptr[esp+NbStack-24] + + chain_length equ dword ptr [esp+NbStack-28] + limit equ dword ptr [esp+NbStack-32] + best_len equ dword ptr [esp+NbStack-36] + window equ dword ptr [esp+NbStack-40] + prev equ dword ptr [esp+NbStack-44] + scan_start equ word ptr [esp+NbStack-48] + wmask equ dword ptr [esp+NbStack-52] + match_start_ptr equ dword ptr [esp+NbStack-56] + nice_match equ dword ptr [esp+NbStack-60] + scan equ dword ptr [esp+NbStack-64] + + windowlen equ dword ptr [esp+NbStack-68] + match_start equ dword ptr [esp+NbStack-72] + strend equ dword ptr [esp+NbStack-76] + NbStackAdd equ (NbStack-24) + + .386p + + name gvmatch + .MODEL FLAT + + + +; all the +zlib1222add offsets are due to the addition of fields +; in zlib in the deflate_state structure since the asm code was first written +; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). +; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). +; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). + + zlib1222add equ 8 + +; Note : these value are good with a 8 bytes boundary pack structure + dep_chain_length equ 74h+zlib1222add + dep_window equ 30h+zlib1222add + dep_strstart equ 64h+zlib1222add + dep_prev_length equ 70h+zlib1222add + dep_nice_match equ 88h+zlib1222add + dep_w_size equ 24h+zlib1222add + dep_prev equ 38h+zlib1222add + dep_w_mask equ 2ch+zlib1222add + dep_good_match equ 84h+zlib1222add + dep_match_start equ 68h+zlib1222add + dep_lookahead equ 6ch+zlib1222add + + +_TEXT segment + +IFDEF NOUNDERLINE + public longest_match + public match_init +ELSE + public _longest_match + public _match_init +ENDIF + + MAX_MATCH equ 258 + MIN_MATCH equ 3 + MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) + + + +MAX_MATCH equ 258 +MIN_MATCH equ 3 +MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1) +MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h) + + +;;; stack frame offsets + +chainlenwmask equ esp + 0 ; high word: current chain len + ; low word: s->wmask +window equ esp + 4 ; local copy of s->window +windowbestlen equ esp + 8 ; s->window + bestlen +scanstart equ esp + 16 ; first two bytes of string +scanend equ esp + 12 ; last two bytes of string +scanalign equ esp + 20 ; dword-misalignment of string +nicematch equ esp + 24 ; a good enough match size +bestlen equ esp + 28 ; size of best match so far +scan equ esp + 32 ; ptr to string wanting match + +LocalVarsSize equ 36 +; saved ebx byte esp + 36 +; saved edi byte esp + 40 +; saved esi byte esp + 44 +; saved ebp byte esp + 48 +; return address byte esp + 52 +deflatestate equ esp + 56 ; the function arguments +curmatch equ esp + 60 + +;;; Offsets for fields in the deflate_state structure. These numbers +;;; are calculated from the definition of deflate_state, with the +;;; assumption that the compiler will dword-align the fields. (Thus, +;;; changing the definition of deflate_state could easily cause this +;;; program to crash horribly, without so much as a warning at +;;; compile time. Sigh.) + +dsWSize equ 36+zlib1222add +dsWMask equ 44+zlib1222add +dsWindow equ 48+zlib1222add +dsPrev equ 56+zlib1222add +dsMatchLen equ 88+zlib1222add +dsPrevMatch equ 92+zlib1222add +dsStrStart equ 100+zlib1222add +dsMatchStart equ 104+zlib1222add +dsLookahead equ 108+zlib1222add +dsPrevLen equ 112+zlib1222add +dsMaxChainLen equ 116+zlib1222add +dsGoodMatch equ 132+zlib1222add +dsNiceMatch equ 136+zlib1222add + + +;;; match686.asm -- Pentium-Pro-optimized version of longest_match() +;;; Written for zlib 1.1.2 +;;; Copyright (C) 1998 Brian Raiter +;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html +;;; +;; +;; This software is provided 'as-is', without any express or implied +;; warranty. In no event will the authors be held liable for any damages +;; arising from the use of this software. +;; +;; Permission is granted to anyone to use this software for any purpose, +;; including commercial applications, and to alter it and redistribute it +;; freely, subject to the following restrictions: +;; +;; 1. The origin of this software must not be misrepresented; you must not +;; claim that you wrote the original software. If you use this software +;; in a product, an acknowledgment in the product documentation would be +;; appreciated but is not required. +;; 2. Altered source versions must be plainly marked as such, and must not be +;; misrepresented as being the original software +;; 3. This notice may not be removed or altered from any source distribution. +;; + +;GLOBAL _longest_match, _match_init + + +;SECTION .text + +;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch) + +;_longest_match: + IFDEF NOUNDERLINE + longest_match proc near + ELSE + _longest_match proc near + ENDIF +.FPO (9, 4, 0, 0, 1, 0) + +;;; Save registers that the compiler may be using, and adjust esp to +;;; make room for our stack frame. + + push ebp + push edi + push esi + push ebx + sub esp, LocalVarsSize + +;;; Retrieve the function arguments. ecx will hold cur_match +;;; throughout the entire function. edx will hold the pointer to the +;;; deflate_state structure during the function's setup (before +;;; entering the main loop. + + mov edx, [deflatestate] + mov ecx, [curmatch] + +;;; uInt wmask = s->w_mask; +;;; unsigned chain_length = s->max_chain_length; +;;; if (s->prev_length >= s->good_match) { +;;; chain_length >>= 2; +;;; } + + mov eax, [edx + dsPrevLen] + mov ebx, [edx + dsGoodMatch] + cmp eax, ebx + mov eax, [edx + dsWMask] + mov ebx, [edx + dsMaxChainLen] + jl LastMatchGood + shr ebx, 2 +LastMatchGood: + +;;; chainlen is decremented once beforehand so that the function can +;;; use the sign flag instead of the zero flag for the exit test. +;;; It is then shifted into the high word, to make room for the wmask +;;; value, which it will always accompany. + + dec ebx + shl ebx, 16 + or ebx, eax + mov [chainlenwmask], ebx + +;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + mov eax, [edx + dsNiceMatch] + mov ebx, [edx + dsLookahead] + cmp ebx, eax + jl LookaheadLess + mov ebx, eax +LookaheadLess: mov [nicematch], ebx + +;;; register Bytef *scan = s->window + s->strstart; + + mov esi, [edx + dsWindow] + mov [window], esi + mov ebp, [edx + dsStrStart] + lea edi, [esi + ebp] + mov [scan], edi + +;;; Determine how many bytes the scan ptr is off from being +;;; dword-aligned. + + mov eax, edi + neg eax + and eax, 3 + mov [scanalign], eax + +;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? +;;; s->strstart - (IPos)MAX_DIST(s) : NIL; + + mov eax, [edx + dsWSize] + sub eax, MIN_LOOKAHEAD + sub ebp, eax + jg LimitPositive + xor ebp, ebp +LimitPositive: + +;;; int best_len = s->prev_length; + + mov eax, [edx + dsPrevLen] + mov [bestlen], eax + +;;; Store the sum of s->window + best_len in esi locally, and in esi. + + add esi, eax + mov [windowbestlen], esi + +;;; register ush scan_start = *(ushf*)scan; +;;; register ush scan_end = *(ushf*)(scan+best_len-1); +;;; Posf *prev = s->prev; + + movzx ebx, word ptr [edi] + mov [scanstart], ebx + movzx ebx, word ptr [edi + eax - 1] + mov [scanend], ebx + mov edi, [edx + dsPrev] + +;;; Jump into the main loop. + + mov edx, [chainlenwmask] + jmp short LoopEntry + +align 4 + +;;; do { +;;; match = s->window + cur_match; +;;; if (*(ushf*)(match+best_len-1) != scan_end || +;;; *(ushf*)match != scan_start) continue; +;;; [...] +;;; } while ((cur_match = prev[cur_match & wmask]) > limit +;;; && --chain_length != 0); +;;; +;;; Here is the inner loop of the function. The function will spend the +;;; majority of its time in this loop, and majority of that time will +;;; be spent in the first ten instructions. +;;; +;;; Within this loop: +;;; ebx = scanend +;;; ecx = curmatch +;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) +;;; esi = windowbestlen - i.e., (window + bestlen) +;;; edi = prev +;;; ebp = limit + +LookupLoop: + and ecx, edx + movzx ecx, word ptr [edi + ecx*2] + cmp ecx, ebp + jbe LeaveNow + sub edx, 00010000h + js LeaveNow +LoopEntry: movzx eax, word ptr [esi + ecx - 1] + cmp eax, ebx + jnz LookupLoop + mov eax, [window] + movzx eax, word ptr [eax + ecx] + cmp eax, [scanstart] + jnz LookupLoop + +;;; Store the current value of chainlen. + + mov [chainlenwmask], edx + +;;; Point edi to the string under scrutiny, and esi to the string we +;;; are hoping to match it up with. In actuality, esi and edi are +;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is +;;; initialized to -(MAX_MATCH_8 - scanalign). + + mov esi, [window] + mov edi, [scan] + add esi, ecx + mov eax, [scanalign] + mov edx, 0fffffef8h; -(MAX_MATCH_8) + lea edi, [edi + eax + 0108h] ;MAX_MATCH_8] + lea esi, [esi + eax + 0108h] ;MAX_MATCH_8] + +;;; Test the strings for equality, 8 bytes at a time. At the end, +;;; adjust edx so that it is offset to the exact byte that mismatched. +;;; +;;; We already know at this point that the first three bytes of the +;;; strings match each other, and they can be safely passed over before +;;; starting the compare loop. So what this code does is skip over 0-3 +;;; bytes, as much as necessary in order to dword-align the edi +;;; pointer. (esi will still be misaligned three times out of four.) +;;; +;;; It should be confessed that this loop usually does not represent +;;; much of the total running time. Replacing it with a more +;;; straightforward "rep cmpsb" would not drastically degrade +;;; performance. + +LoopCmps: + mov eax, [esi + edx] + xor eax, [edi + edx] + jnz LeaveLoopCmps + mov eax, [esi + edx + 4] + xor eax, [edi + edx + 4] + jnz LeaveLoopCmps4 + add edx, 8 + jnz LoopCmps + jmp short LenMaximum +LeaveLoopCmps4: add edx, 4 +LeaveLoopCmps: test eax, 0000FFFFh + jnz LenLower + add edx, 2 + shr eax, 16 +LenLower: sub al, 1 + adc edx, 0 + +;;; Calculate the length of the match. If it is longer than MAX_MATCH, +;;; then automatically accept it as the best possible match and leave. + + lea eax, [edi + edx] + mov edi, [scan] + sub eax, edi + cmp eax, MAX_MATCH + jge LenMaximum + +;;; If the length of the match is not longer than the best match we +;;; have so far, then forget it and return to the lookup loop. + + mov edx, [deflatestate] + mov ebx, [bestlen] + cmp eax, ebx + jg LongerMatch + mov esi, [windowbestlen] + mov edi, [edx + dsPrev] + mov ebx, [scanend] + mov edx, [chainlenwmask] + jmp LookupLoop + +;;; s->match_start = cur_match; +;;; best_len = len; +;;; if (len >= nice_match) break; +;;; scan_end = *(ushf*)(scan+best_len-1); + +LongerMatch: mov ebx, [nicematch] + mov [bestlen], eax + mov [edx + dsMatchStart], ecx + cmp eax, ebx + jge LeaveNow + mov esi, [window] + add esi, eax + mov [windowbestlen], esi + movzx ebx, word ptr [edi + eax - 1] + mov edi, [edx + dsPrev] + mov [scanend], ebx + mov edx, [chainlenwmask] + jmp LookupLoop + +;;; Accept the current string, with the maximum possible length. + +LenMaximum: mov edx, [deflatestate] + mov dword ptr [bestlen], MAX_MATCH + mov [edx + dsMatchStart], ecx + +;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; +;;; return s->lookahead; + +LeaveNow: + mov edx, [deflatestate] + mov ebx, [bestlen] + mov eax, [edx + dsLookahead] + cmp ebx, eax + jg LookaheadRet + mov eax, ebx +LookaheadRet: + +;;; Restore the stack and return from whence we came. + + add esp, LocalVarsSize + pop ebx + pop esi + pop edi + pop ebp + + ret +; please don't remove this string ! +; Your can freely use match686 in any free or commercial app if you don't remove the string in the binary! + db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah + + + IFDEF NOUNDERLINE + longest_match endp + ELSE + _longest_match endp + ENDIF + + IFDEF NOUNDERLINE + match_init proc near + ret + match_init endp + ELSE + _match_init proc near + ret + _match_init endp + ENDIF + + +_TEXT ends +end diff --git a/xs/src/png/zlib/contrib/masmx86/readme.txt b/xs/src/png/zlib/contrib/masmx86/readme.txt new file mode 100644 index 0000000000..3f8888679f --- /dev/null +++ b/xs/src/png/zlib/contrib/masmx86/readme.txt @@ -0,0 +1,27 @@ + +Summary +------- +This directory contains ASM implementations of the functions +longest_match() and inflate_fast(). + + +Use instructions +---------------- +Assemble using MASM, and copy the object files into the zlib source +directory, then run the appropriate makefile, as suggested below. You can +donwload MASM from here: + + http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64 + +You can also get objects files here: + + http://www.winimage.com/zLibDll/zlib124_masm_obj.zip + +Build instructions +------------------ +* With Microsoft C and MASM: +nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj" + +* With Borland C and TASM: +make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj" OBJPA="+match686c.obj+match686.obj+inffas32.obj" + diff --git a/xs/src/png/zlib/contrib/minizip/Makefile b/xs/src/png/zlib/contrib/minizip/Makefile new file mode 100644 index 0000000000..84eaad20d4 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/Makefile @@ -0,0 +1,25 @@ +CC=cc +CFLAGS=-O -I../.. + +UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a +ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a + +.c.o: + $(CC) -c $(CFLAGS) $*.c + +all: miniunz minizip + +miniunz: $(UNZ_OBJS) + $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) + +minizip: $(ZIP_OBJS) + $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) + +test: miniunz minizip + ./minizip test readme.txt + ./miniunz -l test.zip + mv readme.txt readme.old + ./miniunz test.zip + +clean: + /bin/rm -f *.o *~ minizip miniunz diff --git a/xs/src/png/zlib/contrib/minizip/Makefile.am b/xs/src/png/zlib/contrib/minizip/Makefile.am new file mode 100644 index 0000000000..d343011ebc --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/Makefile.am @@ -0,0 +1,45 @@ +lib_LTLIBRARIES = libminizip.la + +if COND_DEMOS +bin_PROGRAMS = miniunzip minizip +endif + +zlib_top_srcdir = $(top_srcdir)/../.. +zlib_top_builddir = $(top_builddir)/../.. + +AM_CPPFLAGS = -I$(zlib_top_srcdir) +AM_LDFLAGS = -L$(zlib_top_builddir) + +if WIN32 +iowin32_src = iowin32.c +iowin32_h = iowin32.h +endif + +libminizip_la_SOURCES = \ + ioapi.c \ + mztools.c \ + unzip.c \ + zip.c \ + ${iowin32_src} + +libminizip_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 -lz + +minizip_includedir = $(includedir)/minizip +minizip_include_HEADERS = \ + crypt.h \ + ioapi.h \ + mztools.h \ + unzip.h \ + zip.h \ + ${iowin32_h} + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = minizip.pc + +EXTRA_PROGRAMS = miniunzip minizip + +miniunzip_SOURCES = miniunz.c +miniunzip_LDADD = libminizip.la + +minizip_SOURCES = minizip.c +minizip_LDADD = libminizip.la -lz diff --git a/xs/src/png/zlib/contrib/minizip/MiniZip64_Changes.txt b/xs/src/png/zlib/contrib/minizip/MiniZip64_Changes.txt new file mode 100644 index 0000000000..13a1bd91a9 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/MiniZip64_Changes.txt @@ -0,0 +1,6 @@ + +MiniZip 1.1 was derrived from MiniZip at version 1.01f + +Change in 1.0 (Okt 2009) + - **TODO - Add history** + diff --git a/xs/src/png/zlib/contrib/minizip/MiniZip64_info.txt b/xs/src/png/zlib/contrib/minizip/MiniZip64_info.txt new file mode 100644 index 0000000000..57d7152420 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/MiniZip64_info.txt @@ -0,0 +1,74 @@ +MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson + +Introduction +--------------------- +MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html ) + +When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0. +All possible work was done for compatibility. + + +Background +--------------------- +When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64 +support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ ) + +That was used as a starting point. And after that ZIP64 support was added to zip.c +some refactoring and code cleanup was also done. + + +Changed from MiniZip 1.0 to MiniZip 1.1 +--------------------------------------- +* Added ZIP64 support for unzip ( by Even Rouault ) +* Added ZIP64 support for zip ( by Mathias Svensson ) +* Reverted some changed that Even Rouault did. +* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users. +* Added unzip patch for BZIP Compression method (patch create by Daniel Borca) +* Added BZIP Compress method for zip +* Did some refactoring and code cleanup + + +Credits + + Gilles Vollant - Original MiniZip author + Even Rouault - ZIP64 unzip Support + Daniel Borca - BZip Compression method support in unzip + Mathias Svensson - ZIP64 zip support + Mathias Svensson - BZip Compression method support in zip + + Resources + + ZipLayout http://result42.com/projects/ZipFileLayout + Command line tool for Windows that shows the layout and information of the headers in a zip archive. + Used when debugging and validating the creation of zip files using MiniZip64 + + + ZIP App Note http://www.pkware.com/documents/casestudies/APPNOTE.TXT + Zip File specification + + +Notes. + * To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined. + +License +---------------------------------------------------------- + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +---------------------------------------------------------- + diff --git a/xs/src/png/zlib/contrib/minizip/configure.ac b/xs/src/png/zlib/contrib/minizip/configure.ac new file mode 100644 index 0000000000..5b11970977 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/configure.ac @@ -0,0 +1,32 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_INIT([minizip], [1.2.11], [bugzilla.redhat.com]) +AC_CONFIG_SRCDIR([minizip.c]) +AM_INIT_AUTOMAKE([foreign]) +LT_INIT + +AC_MSG_CHECKING([whether to build example programs]) +AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs])) +AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes]) +if test "$enable_demos" = yes +then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +case "${host}" in + *-mingw* | mingw*) + WIN32="yes" + ;; + *) + ;; +esac +AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) + + +AC_SUBST([HAVE_UNISTD_H], [0]) +AC_CHECK_HEADER([unistd.h], [HAVE_UNISTD_H=1], []) +AC_CONFIG_FILES([Makefile minizip.pc]) +AC_OUTPUT diff --git a/xs/src/png/zlib/contrib/minizip/crypt.h b/xs/src/png/zlib/contrib/minizip/crypt.h new file mode 100644 index 0000000000..1e9e8200b2 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/crypt.h @@ -0,0 +1,131 @@ +/* crypt.h -- base code for crypt/uncrypt ZIPfile + + + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant + + This code is a modified version of crypting code in Infozip distribution + + The encryption/decryption parts of this source code (as opposed to the + non-echoing password parts) were originally written in Europe. The + whole source package can be freely distributed, including from the USA. + (Prior to January 2000, re-export from the US was a violation of US law.) + + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + + If you don't need crypting in your application, just define symbols + NOCRYPT and NOUNCRYPT. + + This code support the "Traditional PKWARE Encryption". + + The new AES encryption added on Zip format by Winzip (see the page + http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong + Encryption is not supported. +*/ + +#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) + +/*********************************************************************** + * Return the next byte in the pseudo-random sequence + */ +static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) +{ + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an + * unpredictable manner on 16-bit systems; not a problem + * with any known compiler so far, though */ + + temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; + return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); +} + +/*********************************************************************** + * Update the encryption keys with the next byte of plain text + */ +static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) +{ + (*(pkeys+0)) = CRC32((*(pkeys+0)), c); + (*(pkeys+1)) += (*(pkeys+0)) & 0xff; + (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; + { + register int keyshift = (int)((*(pkeys+1)) >> 24); + (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); + } + return c; +} + + +/*********************************************************************** + * Initialize the encryption keys and the random header according to + * the given password. + */ +static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) +{ + *(pkeys+0) = 305419896L; + *(pkeys+1) = 591751049L; + *(pkeys+2) = 878082192L; + while (*passwd != '\0') { + update_keys(pkeys,pcrc_32_tab,(int)*passwd); + passwd++; + } +} + +#define zdecode(pkeys,pcrc_32_tab,c) \ + (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) + +#define zencode(pkeys,pcrc_32_tab,c,t) \ + (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) + +#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED + +#define RAND_HEAD_LEN 12 + /* "last resort" source for second part of crypt seed pattern */ +# ifndef ZCR_SEED2 +# define ZCR_SEED2 3141592654UL /* use PI as default pattern */ +# endif + +static int crypthead(const char* passwd, /* password string */ + unsigned char* buf, /* where to write header */ + int bufSize, + unsigned long* pkeys, + const z_crc_t* pcrc_32_tab, + unsigned long crcForCrypting) +{ + int n; /* index in random header */ + int t; /* temporary */ + int c; /* random byte */ + unsigned char header[RAND_HEAD_LEN-2]; /* random header */ + static unsigned calls = 0; /* ensure different random header each time */ + + if (bufSize> 7) & 0xff; + header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); + } + /* Encrypt random header (last two bytes is high word of crc) */ + init_keys(passwd, pkeys, pcrc_32_tab); + for (n = 0; n < RAND_HEAD_LEN-2; n++) + { + buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); + } + buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); + buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); + return n; +} + +#endif diff --git a/xs/src/png/zlib/contrib/minizip/ioapi.c b/xs/src/png/zlib/contrib/minizip/ioapi.c new file mode 100644 index 0000000000..7f5c191b2a --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/ioapi.c @@ -0,0 +1,247 @@ +/* ioapi.h -- IO base function header for compress/uncompress .zip + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + +*/ + +#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS))) + #define _CRT_SECURE_NO_WARNINGS +#endif + +#if defined(__APPLE__) || defined(IOAPI_NO_64) +// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions +#define FOPEN_FUNC(filename, mode) fopen(filename, mode) +#define FTELLO_FUNC(stream) ftello(stream) +#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) +#else +#define FOPEN_FUNC(filename, mode) fopen64(filename, mode) +#define FTELLO_FUNC(stream) ftello64(stream) +#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) +#endif + + +#include "ioapi.h" + +voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) +{ + if (pfilefunc->zfile_func64.zopen64_file != NULL) + return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); + else + { + return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); + } +} + +long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) +{ + if (pfilefunc->zfile_func64.zseek64_file != NULL) + return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); + else + { + uLong offsetTruncated = (uLong)offset; + if (offsetTruncated != offset) + return -1; + else + return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); + } +} + +ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) +{ + if (pfilefunc->zfile_func64.zseek64_file != NULL) + return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); + else + { + uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); + if ((tell_uLong) == MAXU32) + return (ZPOS64_T)-1; + else + return tell_uLong; + } +} + +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) +{ + p_filefunc64_32->zfile_func64.zopen64_file = NULL; + p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; + p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; + p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; + p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; + p_filefunc64_32->zfile_func64.ztell64_file = NULL; + p_filefunc64_32->zfile_func64.zseek64_file = NULL; + p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; + p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; + p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque; + p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; + p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; +} + + + +static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); +static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); +static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); +static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); +static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); +static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); + +static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) +{ + FILE* file = NULL; + const char* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = fopen(filename, mode_fopen); + return file; +} + +static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) +{ + FILE* file = NULL; + const char* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = FOPEN_FUNC((const char*)filename, mode_fopen); + return file; +} + + +static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) +{ + uLong ret; + ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); + return ret; +} + +static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) +{ + uLong ret; + ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); + return ret; +} + +static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) +{ + long ret; + ret = ftell((FILE *)stream); + return ret; +} + + +static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) +{ + ZPOS64_T ret; + ret = FTELLO_FUNC((FILE *)stream); + return ret; +} + +static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) +{ + int fseek_origin=0; + long ret; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + fseek_origin = SEEK_CUR; + break; + case ZLIB_FILEFUNC_SEEK_END : + fseek_origin = SEEK_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + fseek_origin = SEEK_SET; + break; + default: return -1; + } + ret = 0; + if (fseek((FILE *)stream, offset, fseek_origin) != 0) + ret = -1; + return ret; +} + +static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) +{ + int fseek_origin=0; + long ret; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + fseek_origin = SEEK_CUR; + break; + case ZLIB_FILEFUNC_SEEK_END : + fseek_origin = SEEK_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + fseek_origin = SEEK_SET; + break; + default: return -1; + } + ret = 0; + + if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0) + ret = -1; + + return ret; +} + + +static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) +{ + int ret; + ret = fclose((FILE *)stream); + return ret; +} + +static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) +{ + int ret; + ret = ferror((FILE *)stream); + return ret; +} + +void fill_fopen_filefunc (pzlib_filefunc_def) + zlib_filefunc_def* pzlib_filefunc_def; +{ + pzlib_filefunc_def->zopen_file = fopen_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell_file = ftell_file_func; + pzlib_filefunc_def->zseek_file = fseek_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; +} + +void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = fopen64_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell64_file = ftell64_file_func; + pzlib_filefunc_def->zseek64_file = fseek64_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; +} diff --git a/xs/src/png/zlib/contrib/minizip/ioapi.h b/xs/src/png/zlib/contrib/minizip/ioapi.h new file mode 100644 index 0000000000..8dcbdb06e3 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/ioapi.h @@ -0,0 +1,208 @@ +/* ioapi.h -- IO base function header for compress/uncompress .zip + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + + Changes + + Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) + Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. + More if/def section may be needed to support other platforms + Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. + (but you should use iowin32.c for windows instead) + +*/ + +#ifndef _ZLIBIOAPI64_H +#define _ZLIBIOAPI64_H + +#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) + + // Linux needs this to support file operation on files larger then 4+GB + // But might need better if/def to select just the platforms that needs them. + + #ifndef __USE_FILE_OFFSET64 + #define __USE_FILE_OFFSET64 + #endif + #ifndef __USE_LARGEFILE64 + #define __USE_LARGEFILE64 + #endif + #ifndef _LARGEFILE64_SOURCE + #define _LARGEFILE64_SOURCE + #endif + #ifndef _FILE_OFFSET_BIT + #define _FILE_OFFSET_BIT 64 + #endif + +#endif + +#include +#include +#include "zlib.h" + +#if defined(USE_FILE32API) +#define fopen64 fopen +#define ftello64 ftell +#define fseeko64 fseek +#else +#ifdef __FreeBSD__ +#define fopen64 fopen +#define ftello64 ftello +#define fseeko64 fseeko +#endif +#ifdef _MSC_VER + #define fopen64 fopen + #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) + #define ftello64 _ftelli64 + #define fseeko64 _fseeki64 + #else // old MSC + #define ftello64 ftell + #define fseeko64 fseek + #endif +#endif +#endif + +/* +#ifndef ZPOS64_T + #ifdef _WIN32 + #define ZPOS64_T fpos_t + #else + #include + #define ZPOS64_T uint64_t + #endif +#endif +*/ + +#ifdef HAVE_MINIZIP64_CONF_H +#include "mz64conf.h" +#endif + +/* a type choosen by DEFINE */ +#ifdef HAVE_64BIT_INT_CUSTOM +typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; +#else +#ifdef HAS_STDINT_H +#include "stdint.h" +typedef uint64_t ZPOS64_T; +#else + +/* Maximum unsigned 32-bit value used as placeholder for zip64 */ +#define MAXU32 0xffffffff + +#if defined(_MSC_VER) || defined(__BORLANDC__) +typedef unsigned __int64 ZPOS64_T; +#else +typedef unsigned long long int ZPOS64_T; +#endif +#endif +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + +#define ZLIB_FILEFUNC_SEEK_CUR (1) +#define ZLIB_FILEFUNC_SEEK_END (2) +#define ZLIB_FILEFUNC_SEEK_SET (0) + +#define ZLIB_FILEFUNC_MODE_READ (1) +#define ZLIB_FILEFUNC_MODE_WRITE (2) +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) + +#define ZLIB_FILEFUNC_MODE_EXISTING (4) +#define ZLIB_FILEFUNC_MODE_CREATE (8) + + +#ifndef ZCALLBACK + #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) + #define ZCALLBACK CALLBACK + #else + #define ZCALLBACK + #endif +#endif + + + + +typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); +typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); +typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); +typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); + +typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); +typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); + + +/* here is the "old" 32 bits structure structure */ +typedef struct zlib_filefunc_def_s +{ + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; +} zlib_filefunc_def; + +typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); +typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); +typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); + +typedef struct zlib_filefunc64_def_s +{ + open64_file_func zopen64_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell64_file_func ztell64_file; + seek64_file_func zseek64_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; +} zlib_filefunc64_def; + +void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); +void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); + +/* now internal definition, only for zip.c and unzip.h */ +typedef struct zlib_filefunc64_32_def_s +{ + zlib_filefunc64_def zfile_func64; + open_file_func zopen32_file; + tell_file_func ztell32_file; + seek_file_func zseek32_file; +} zlib_filefunc64_32_def; + + +#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) +#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) +//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) +//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) +#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) +#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) + +voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); +long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); +ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); + +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); + +#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) +#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) +#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/xs/src/png/zlib/contrib/minizip/iowin32.c b/xs/src/png/zlib/contrib/minizip/iowin32.c new file mode 100644 index 0000000000..274f39eb1d --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/iowin32.c @@ -0,0 +1,462 @@ +/* iowin32.c -- IO base function header for compress/uncompress .zip + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + +*/ + +#include + +#include "zlib.h" +#include "ioapi.h" +#include "iowin32.h" + +#ifndef INVALID_HANDLE_VALUE +#define INVALID_HANDLE_VALUE (0xFFFFFFFF) +#endif + +#ifndef INVALID_SET_FILE_POINTER +#define INVALID_SET_FILE_POINTER ((DWORD)-1) +#endif + + +// see Include/shared/winapifamily.h in the Windows Kit +#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API))) +#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP) +#define IOWIN32_USING_WINRT_API 1 +#endif +#endif + +voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); +uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); +ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream)); +long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); +int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream)); +int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream)); + +typedef struct +{ + HANDLE hf; + int error; +} WIN32FILE_IOWIN; + + +static void win32_translate_open_mode(int mode, + DWORD* lpdwDesiredAccess, + DWORD* lpdwCreationDisposition, + DWORD* lpdwShareMode, + DWORD* lpdwFlagsAndAttributes) +{ + *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0; + + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + { + *lpdwDesiredAccess = GENERIC_READ; + *lpdwCreationDisposition = OPEN_EXISTING; + *lpdwShareMode = FILE_SHARE_READ; + } + else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + { + *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; + *lpdwCreationDisposition = OPEN_EXISTING; + } + else if (mode & ZLIB_FILEFUNC_MODE_CREATE) + { + *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; + *lpdwCreationDisposition = CREATE_ALWAYS; + } +} + +static voidpf win32_build_iowin(HANDLE hFile) +{ + voidpf ret=NULL; + + if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) + { + WIN32FILE_IOWIN w32fiow; + w32fiow.hf = hFile; + w32fiow.error = 0; + ret = malloc(sizeof(WIN32FILE_IOWIN)); + + if (ret==NULL) + CloseHandle(hFile); + else + *((WIN32FILE_IOWIN*)ret) = w32fiow; + } + return ret; +} + +voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode) +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = NULL; + + win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); + +#ifdef IOWIN32_USING_WINRT_API +#ifdef UNICODE + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + { + WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; + MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); + hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); + } +#endif +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); +#endif + + return win32_build_iowin(hFile); +} + + +voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode) +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = NULL; + + win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); + +#ifdef IOWIN32_USING_WINRT_API + if ((filename!=NULL) && (dwDesiredAccess != 0)) + { + WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; + MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); + hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); + } +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); +#endif + + return win32_build_iowin(hFile); +} + + +voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode) +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = NULL; + + win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); + +#ifdef IOWIN32_USING_WINRT_API + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL); +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); +#endif + + return win32_build_iowin(hFile); +} + + +voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode) +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = NULL; + + win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); + +#ifdef IOWIN32_USING_WINRT_API +#ifdef UNICODE + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + { + WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; + MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); + hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); + } +#endif +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); +#endif + + return win32_build_iowin(hFile); +} + + +uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size) +{ + uLong ret=0; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + + if (hFile != NULL) + { + if (!ReadFile(hFile, buf, size, &ret, NULL)) + { + DWORD dwErr = GetLastError(); + if (dwErr == ERROR_HANDLE_EOF) + dwErr = 0; + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + } + } + + return ret; +} + + +uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size) +{ + uLong ret=0; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + + if (hFile != NULL) + { + if (!WriteFile(hFile, buf, size, &ret, NULL)) + { + DWORD dwErr = GetLastError(); + if (dwErr == ERROR_HANDLE_EOF) + dwErr = 0; + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + } + } + + return ret; +} + +static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) +{ +#ifdef IOWIN32_USING_WINRT_API + return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); +#else + LONG lHigh = pos.HighPart; + DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod); + BOOL fOk = TRUE; + if (dwNewPos == 0xFFFFFFFF) + if (GetLastError() != NO_ERROR) + fOk = FALSE; + if ((newPos != NULL) && (fOk)) + { + newPos->LowPart = dwNewPos; + newPos->HighPart = lHigh; + } + return fOk; +#endif +} + +long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) +{ + long ret=-1; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + { + LARGE_INTEGER pos; + pos.QuadPart = 0; + + if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT)) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = -1; + } + else + ret=(long)pos.LowPart; + } + return ret; +} + +ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) +{ + ZPOS64_T ret= (ZPOS64_T)-1; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream)->hf; + + if (hFile) + { + LARGE_INTEGER pos; + pos.QuadPart = 0; + + if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT)) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = (ZPOS64_T)-1; + } + else + ret=pos.QuadPart; + } + return ret; +} + + +long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin) +{ + DWORD dwMoveMethod=0xFFFFFFFF; + HANDLE hFile = NULL; + + long ret=-1; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + dwMoveMethod = FILE_CURRENT; + break; + case ZLIB_FILEFUNC_SEEK_END : + dwMoveMethod = FILE_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + dwMoveMethod = FILE_BEGIN; + break; + default: return -1; + } + + if (hFile != NULL) + { + LARGE_INTEGER pos; + pos.QuadPart = offset; + if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod)) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = -1; + } + else + ret=0; + } + return ret; +} + +long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin) +{ + DWORD dwMoveMethod=0xFFFFFFFF; + HANDLE hFile = NULL; + long ret=-1; + + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream)->hf; + + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + dwMoveMethod = FILE_CURRENT; + break; + case ZLIB_FILEFUNC_SEEK_END : + dwMoveMethod = FILE_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + dwMoveMethod = FILE_BEGIN; + break; + default: return -1; + } + + if (hFile) + { + LARGE_INTEGER pos; + pos.QuadPart = offset; + if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod)) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = -1; + } + else + ret=0; + } + return ret; +} + +int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) +{ + int ret=-1; + + if (stream!=NULL) + { + HANDLE hFile; + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + { + CloseHandle(hFile); + ret=0; + } + free(stream); + } + return ret; +} + +int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) +{ + int ret=-1; + if (stream!=NULL) + { + ret = ((WIN32FILE_IOWIN*)stream) -> error; + } + return ret; +} + +void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen_file = win32_open_file_func; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell_file = win32_tell_file_func; + pzlib_filefunc_def->zseek_file = win32_seek_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque = NULL; +} + +void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = win32_open64_file_func; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; + pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque = NULL; +} + + +void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; + pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque = NULL; +} + + +void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; + pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque = NULL; +} diff --git a/xs/src/png/zlib/contrib/minizip/iowin32.h b/xs/src/png/zlib/contrib/minizip/iowin32.h new file mode 100644 index 0000000000..0ca0969a7d --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/iowin32.h @@ -0,0 +1,28 @@ +/* iowin32.h -- IO base function header for compress/uncompress .zip + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + +*/ + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); +void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); +void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); +void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); + +#ifdef __cplusplus +} +#endif diff --git a/xs/src/png/zlib/contrib/minizip/make_vms.com b/xs/src/png/zlib/contrib/minizip/make_vms.com new file mode 100644 index 0000000000..9ac13a98fa --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/make_vms.com @@ -0,0 +1,25 @@ +$ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig +$ open/write zdef vmsdefs.h +$ copy sys$input: zdef +$ deck +#define unix +#define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from +#define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator +#define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord +#define Write_EndOfCentralDirectoryRecord Write_EoDRecord +$ eod +$ close zdef +$ copy vmsdefs.h,ioapi.h_orig ioapi.h +$ cc/include=[--]/prefix=all ioapi.c +$ cc/include=[--]/prefix=all miniunz.c +$ cc/include=[--]/prefix=all unzip.c +$ cc/include=[--]/prefix=all minizip.c +$ cc/include=[--]/prefix=all zip.c +$ link miniunz,unzip,ioapi,[--]libz.olb/lib +$ link minizip,zip,ioapi,[--]libz.olb/lib +$ mcr []minizip test minizip_info.txt +$ mcr []miniunz -l test.zip +$ rename minizip_info.txt; minizip_info.txt_old +$ mcr []miniunz test.zip +$ delete test.zip;* +$exit diff --git a/xs/src/png/zlib/contrib/minizip/miniunz.c b/xs/src/png/zlib/contrib/minizip/miniunz.c new file mode 100644 index 0000000000..3d65401be5 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/miniunz.c @@ -0,0 +1,660 @@ +/* + miniunz.c + Version 1.1, February 14h, 2010 + sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications of Unzip for Zip64 + Copyright (C) 2007-2008 Even Rouault + + Modifications for Zip64 support on both zip and unzip + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) +*/ + +#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) + #ifndef __USE_FILE_OFFSET64 + #define __USE_FILE_OFFSET64 + #endif + #ifndef __USE_LARGEFILE64 + #define __USE_LARGEFILE64 + #endif + #ifndef _LARGEFILE64_SOURCE + #define _LARGEFILE64_SOURCE + #endif + #ifndef _FILE_OFFSET_BIT + #define _FILE_OFFSET_BIT 64 + #endif +#endif + +#ifdef __APPLE__ +// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions +#define FOPEN_FUNC(filename, mode) fopen(filename, mode) +#define FTELLO_FUNC(stream) ftello(stream) +#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) +#else +#define FOPEN_FUNC(filename, mode) fopen64(filename, mode) +#define FTELLO_FUNC(stream) ftello64(stream) +#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) +#endif + + +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +# include +# include +#else +# include +# include +#endif + + +#include "unzip.h" + +#define CASESENSITIVITY (0) +#define WRITEBUFFERSIZE (8192) +#define MAXFILENAME (256) + +#ifdef _WIN32 +#define USEWIN32IOAPI +#include "iowin32.h" +#endif +/* + mini unzip, demo of unzip package + + usage : + Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir] + + list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT + if it exists +*/ + + +/* change_file_date : change the date/time of a file + filename : the filename of the file where date/time must be modified + dosdate : the new date at the MSDos format (4 bytes) + tmu_date : the SAME new date at the tm_unz format */ +void change_file_date(filename,dosdate,tmu_date) + const char *filename; + uLong dosdate; + tm_unz tmu_date; +{ +#ifdef _WIN32 + HANDLE hFile; + FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; + + hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE, + 0,NULL,OPEN_EXISTING,0,NULL); + GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); + DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); + LocalFileTimeToFileTime(&ftLocal,&ftm); + SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); + CloseHandle(hFile); +#else +#ifdef unix || __APPLE__ + struct utimbuf ut; + struct tm newdate; + newdate.tm_sec = tmu_date.tm_sec; + newdate.tm_min=tmu_date.tm_min; + newdate.tm_hour=tmu_date.tm_hour; + newdate.tm_mday=tmu_date.tm_mday; + newdate.tm_mon=tmu_date.tm_mon; + if (tmu_date.tm_year > 1900) + newdate.tm_year=tmu_date.tm_year - 1900; + else + newdate.tm_year=tmu_date.tm_year ; + newdate.tm_isdst=-1; + + ut.actime=ut.modtime=mktime(&newdate); + utime(filename,&ut); +#endif +#endif +} + + +/* mymkdir and change_file_date are not 100 % portable + As I don't know well Unix, I wait feedback for the unix portion */ + +int mymkdir(dirname) + const char* dirname; +{ + int ret=0; +#ifdef _WIN32 + ret = _mkdir(dirname); +#elif unix + ret = mkdir (dirname,0775); +#elif __APPLE__ + ret = mkdir (dirname,0775); +#endif + return ret; +} + +int makedir (newdir) + char *newdir; +{ + char *buffer ; + char *p; + int len = (int)strlen(newdir); + + if (len <= 0) + return 0; + + buffer = (char*)malloc(len+1); + if (buffer==NULL) + { + printf("Error allocating memory\n"); + return UNZ_INTERNALERROR; + } + strcpy(buffer,newdir); + + if (buffer[len-1] == '/') { + buffer[len-1] = '\0'; + } + if (mymkdir(buffer) == 0) + { + free(buffer); + return 1; + } + + p = buffer+1; + while (1) + { + char hold; + + while(*p && *p != '\\' && *p != '/') + p++; + hold = *p; + *p = 0; + if ((mymkdir(buffer) == -1) && (errno == ENOENT)) + { + printf("couldn't create directory %s\n",buffer); + free(buffer); + return 0; + } + if (hold == 0) + break; + *p++ = hold; + } + free(buffer); + return 1; +} + +void do_banner() +{ + printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); + printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); +} + +void do_help() +{ + printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ + " -e Extract without pathname (junk paths)\n" \ + " -x Extract with pathname\n" \ + " -v list files\n" \ + " -l list files\n" \ + " -d directory to extract into\n" \ + " -o overwrite files without prompting\n" \ + " -p extract crypted file using password\n\n"); +} + +void Display64BitsSize(ZPOS64_T n, int size_char) +{ + /* to avoid compatibility problem , we do here the conversion */ + char number[21]; + int offset=19; + int pos_string = 19; + number[20]=0; + for (;;) { + number[offset]=(char)((n%10)+'0'); + if (number[offset] != '0') + pos_string=offset; + n/=10; + if (offset==0) + break; + offset--; + } + { + int size_display_string = 19-pos_string; + while (size_char > size_display_string) + { + size_char--; + printf(" "); + } + } + + printf("%s",&number[pos_string]); +} + +int do_list(uf) + unzFile uf; +{ + uLong i; + unz_global_info64 gi; + int err; + + err = unzGetGlobalInfo64(uf,&gi); + if (err!=UNZ_OK) + printf("error %d with zipfile in unzGetGlobalInfo \n",err); + printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); + printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); + for (i=0;i0) + ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size); + + /* display a '*' if the file is crypted */ + if ((file_info.flag & 1) != 0) + charCrypt='*'; + + if (file_info.compression_method==0) + string_method="Stored"; + else + if (file_info.compression_method==Z_DEFLATED) + { + uInt iLevel=(uInt)((file_info.flag & 0x6)/2); + if (iLevel==0) + string_method="Defl:N"; + else if (iLevel==1) + string_method="Defl:X"; + else if ((iLevel==2) || (iLevel==3)) + string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ + } + else + if (file_info.compression_method==Z_BZIP2ED) + { + string_method="BZip2 "; + } + else + string_method="Unkn. "; + + Display64BitsSize(file_info.uncompressed_size,7); + printf(" %6s%c",string_method,charCrypt); + Display64BitsSize(file_info.compressed_size,7); + printf(" %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", + ratio, + (uLong)file_info.tmu_date.tm_mon + 1, + (uLong)file_info.tmu_date.tm_mday, + (uLong)file_info.tmu_date.tm_year % 100, + (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, + (uLong)file_info.crc,filename_inzip); + if ((i+1)='a') && (rep<='z')) + rep -= 0x20; + } + while ((rep!='Y') && (rep!='N') && (rep!='A')); + } + + if (rep == 'N') + skip = 1; + + if (rep == 'A') + *popt_overwrite=1; + } + + if ((skip==0) && (err==UNZ_OK)) + { + fout=FOPEN_FUNC(write_filename,"wb"); + /* some zipfile don't contain directory alone before file */ + if ((fout==NULL) && ((*popt_extract_without_path)==0) && + (filename_withoutpath!=(char*)filename_inzip)) + { + char c=*(filename_withoutpath-1); + *(filename_withoutpath-1)='\0'; + makedir(write_filename); + *(filename_withoutpath-1)=c; + fout=FOPEN_FUNC(write_filename,"wb"); + } + + if (fout==NULL) + { + printf("error opening %s\n",write_filename); + } + } + + if (fout!=NULL) + { + printf(" extracting: %s\n",write_filename); + + do + { + err = unzReadCurrentFile(uf,buf,size_buf); + if (err<0) + { + printf("error %d with zipfile in unzReadCurrentFile\n",err); + break; + } + if (err>0) + if (fwrite(buf,err,1,fout)!=1) + { + printf("error in writing extracted file\n"); + err=UNZ_ERRNO; + break; + } + } + while (err>0); + if (fout) + fclose(fout); + + if (err==0) + change_file_date(write_filename,file_info.dosDate, + file_info.tmu_date); + } + + if (err==UNZ_OK) + { + err = unzCloseCurrentFile (uf); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzCloseCurrentFile\n",err); + } + } + else + unzCloseCurrentFile(uf); /* don't lose the error */ + } + + free(buf); + return err; +} + + +int do_extract(uf,opt_extract_without_path,opt_overwrite,password) + unzFile uf; + int opt_extract_without_path; + int opt_overwrite; + const char* password; +{ + uLong i; + unz_global_info64 gi; + int err; + FILE* fout=NULL; + + err = unzGetGlobalInfo64(uf,&gi); + if (err!=UNZ_OK) + printf("error %d with zipfile in unzGetGlobalInfo \n",err); + + for (i=0;i insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +miniunzip - uncompress and examine ZIP archives +.SH SYNOPSIS +.B miniunzip +.RI [ -exvlo ] +zipfile [ files_to_extract ] [-d tempdir] +.SH DESCRIPTION +.B minizip +is a simple tool which allows the extraction of compressed file +archives in the ZIP format used by the MS-DOS utility PKZIP. It was +written as a demonstration of the +.IR zlib (3) +library and therefore lack many of the features of the +.IR unzip (1) +program. +.SH OPTIONS +A number of options are supported. With the exception of +.BI \-d\ tempdir +these must be supplied before any +other arguments and are: +.TP +.BI \-l\ ,\ \-\-v +List the files in the archive without extracting them. +.TP +.B \-o +Overwrite files without prompting for confirmation. +.TP +.B \-x +Extract files (default). +.PP +The +.I zipfile +argument is the name of the archive to process. The next argument can be used +to specify a single file to extract from the archive. + +Lastly, the following option can be specified at the end of the command-line: +.TP +.BI \-d\ tempdir +Extract the archive in the directory +.I tempdir +rather than the current directory. +.SH SEE ALSO +.BR minizip (1), +.BR zlib (3), +.BR unzip (1). +.SH AUTHOR +This program was written by Gilles Vollant. This manual page was +written by Mark Brown . The -d tempdir option +was added by Dirk Eddelbuettel . diff --git a/xs/src/png/zlib/contrib/minizip/minizip.1 b/xs/src/png/zlib/contrib/minizip/minizip.1 new file mode 100644 index 0000000000..1154484c1c --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/minizip.1 @@ -0,0 +1,46 @@ +.\" Hey, EMACS: -*- nroff -*- +.TH minizip 1 "May 2, 2001" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +minizip - create ZIP archives +.SH SYNOPSIS +.B minizip +.RI [ -o ] +zipfile [ " files" ... ] +.SH DESCRIPTION +.B minizip +is a simple tool which allows the creation of compressed file archives +in the ZIP format used by the MS-DOS utility PKZIP. It was written as +a demonstration of the +.IR zlib (3) +library and therefore lack many of the features of the +.IR zip (1) +program. +.SH OPTIONS +The first argument supplied is the name of the ZIP archive to create or +.RI -o +in which case it is ignored and the second argument treated as the +name of the ZIP file. If the ZIP file already exists it will be +overwritten. +.PP +Subsequent arguments specify a list of files to place in the ZIP +archive. If none are specified then an empty archive will be created. +.SH SEE ALSO +.BR miniunzip (1), +.BR zlib (3), +.BR zip (1). +.SH AUTHOR +This program was written by Gilles Vollant. This manual page was +written by Mark Brown . + diff --git a/xs/src/png/zlib/contrib/minizip/minizip.c b/xs/src/png/zlib/contrib/minizip/minizip.c new file mode 100644 index 0000000000..4288962ece --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/minizip.c @@ -0,0 +1,520 @@ +/* + minizip.c + Version 1.1, February 14h, 2010 + sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications of Unzip for Zip64 + Copyright (C) 2007-2008 Even Rouault + + Modifications for Zip64 support on both zip and unzip + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) +*/ + + +#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) + #ifndef __USE_FILE_OFFSET64 + #define __USE_FILE_OFFSET64 + #endif + #ifndef __USE_LARGEFILE64 + #define __USE_LARGEFILE64 + #endif + #ifndef _LARGEFILE64_SOURCE + #define _LARGEFILE64_SOURCE + #endif + #ifndef _FILE_OFFSET_BIT + #define _FILE_OFFSET_BIT 64 + #endif +#endif + +#ifdef __APPLE__ +// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions +#define FOPEN_FUNC(filename, mode) fopen(filename, mode) +#define FTELLO_FUNC(stream) ftello(stream) +#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) +#else +#define FOPEN_FUNC(filename, mode) fopen64(filename, mode) +#define FTELLO_FUNC(stream) ftello64(stream) +#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) +#endif + + + +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +# include +# include +#else +# include +# include +# include +# include +#endif + +#include "zip.h" + +#ifdef _WIN32 + #define USEWIN32IOAPI + #include "iowin32.h" +#endif + + + +#define WRITEBUFFERSIZE (16384) +#define MAXFILENAME (256) + +#ifdef _WIN32 +uLong filetime(f, tmzip, dt) + char *f; /* name of file to get info on */ + tm_zip *tmzip; /* return value: access, modific. and creation times */ + uLong *dt; /* dostime */ +{ + int ret = 0; + { + FILETIME ftLocal; + HANDLE hFind; + WIN32_FIND_DATAA ff32; + + hFind = FindFirstFileA(f,&ff32); + if (hFind != INVALID_HANDLE_VALUE) + { + FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); + FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); + FindClose(hFind); + ret = 1; + } + } + return ret; +} +#else +#ifdef unix || __APPLE__ +uLong filetime(f, tmzip, dt) + char *f; /* name of file to get info on */ + tm_zip *tmzip; /* return value: access, modific. and creation times */ + uLong *dt; /* dostime */ +{ + int ret=0; + struct stat s; /* results of stat() */ + struct tm* filedate; + time_t tm_t=0; + + if (strcmp(f,"-")!=0) + { + char name[MAXFILENAME+1]; + int len = strlen(f); + if (len > MAXFILENAME) + len = MAXFILENAME; + + strncpy(name, f,MAXFILENAME-1); + /* strncpy doesnt append the trailing NULL, of the string is too long. */ + name[ MAXFILENAME ] = '\0'; + + if (name[len - 1] == '/') + name[len - 1] = '\0'; + /* not all systems allow stat'ing a file with / appended */ + if (stat(name,&s)==0) + { + tm_t = s.st_mtime; + ret = 1; + } + } + filedate = localtime(&tm_t); + + tmzip->tm_sec = filedate->tm_sec; + tmzip->tm_min = filedate->tm_min; + tmzip->tm_hour = filedate->tm_hour; + tmzip->tm_mday = filedate->tm_mday; + tmzip->tm_mon = filedate->tm_mon ; + tmzip->tm_year = filedate->tm_year; + + return ret; +} +#else +uLong filetime(f, tmzip, dt) + char *f; /* name of file to get info on */ + tm_zip *tmzip; /* return value: access, modific. and creation times */ + uLong *dt; /* dostime */ +{ + return 0; +} +#endif +#endif + + + + +int check_exist_file(filename) + const char* filename; +{ + FILE* ftestexist; + int ret = 1; + ftestexist = FOPEN_FUNC(filename,"rb"); + if (ftestexist==NULL) + ret = 0; + else + fclose(ftestexist); + return ret; +} + +void do_banner() +{ + printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n"); + printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n"); +} + +void do_help() +{ + printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \ + " -o Overwrite existing file.zip\n" \ + " -a Append to existing file.zip\n" \ + " -0 Store only\n" \ + " -1 Compress faster\n" \ + " -9 Compress better\n\n" \ + " -j exclude path. store only the file name.\n\n"); +} + +/* calculate the CRC32 of a file, + because to encrypt a file, we need known the CRC32 of the file before */ +int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) +{ + unsigned long calculate_crc=0; + int err=ZIP_OK; + FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); + + unsigned long size_read = 0; + unsigned long total_read = 0; + if (fin==NULL) + { + err = ZIP_ERRNO; + } + + if (err == ZIP_OK) + do + { + err = ZIP_OK; + size_read = (int)fread(buf,1,size_buf,fin); + if (size_read < size_buf) + if (feof(fin)==0) + { + printf("error in reading %s\n",filenameinzip); + err = ZIP_ERRNO; + } + + if (size_read>0) + calculate_crc = crc32(calculate_crc,buf,size_read); + total_read += size_read; + + } while ((err == ZIP_OK) && (size_read>0)); + + if (fin) + fclose(fin); + + *result_crc=calculate_crc; + printf("file %s crc %lx\n", filenameinzip, calculate_crc); + return err; +} + +int isLargeFile(const char* filename) +{ + int largeFile = 0; + ZPOS64_T pos = 0; + FILE* pFile = FOPEN_FUNC(filename, "rb"); + + if(pFile != NULL) + { + int n = FSEEKO_FUNC(pFile, 0, SEEK_END); + pos = FTELLO_FUNC(pFile); + + printf("File : %s is %lld bytes\n", filename, pos); + + if(pos >= 0xffffffff) + largeFile = 1; + + fclose(pFile); + } + + return largeFile; +} + +int main(argc,argv) + int argc; + char *argv[]; +{ + int i; + int opt_overwrite=0; + int opt_compress_level=Z_DEFAULT_COMPRESSION; + int opt_exclude_path=0; + int zipfilenamearg = 0; + char filename_try[MAXFILENAME+16]; + int zipok; + int err=0; + int size_buf=0; + void* buf=NULL; + const char* password=NULL; + + + do_banner(); + if (argc==1) + { + do_help(); + return 0; + } + else + { + for (i=1;i='0') && (c<='9')) + opt_compress_level = c-'0'; + if ((c=='j') || (c=='J')) + opt_exclude_path = 1; + + if (((c=='p') || (c=='P')) && (i+1='a') && (rep<='z')) + rep -= 0x20; + } + while ((rep!='Y') && (rep!='N') && (rep!='A')); + if (rep=='N') + zipok = 0; + if (rep=='A') + opt_overwrite = 2; + } + } + + if (zipok==1) + { + zipFile zf; + int errclose; +# ifdef USEWIN32IOAPI + zlib_filefunc64_def ffunc; + fill_win32_filefunc64A(&ffunc); + zf = zipOpen2_64(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc); +# else + zf = zipOpen64(filename_try,(opt_overwrite==2) ? 2 : 0); +# endif + + if (zf == NULL) + { + printf("error opening %s\n",filename_try); + err= ZIP_ERRNO; + } + else + printf("creating %s\n",filename_try); + + for (i=zipfilenamearg+1;(i='0') || (argv[i][1]<='9'))) && + (strlen(argv[i]) == 2))) + { + FILE * fin; + int size_read; + const char* filenameinzip = argv[i]; + const char *savefilenameinzip; + zip_fileinfo zi; + unsigned long crcFile=0; + int zip64 = 0; + + zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = + zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; + zi.dosDate = 0; + zi.internal_fa = 0; + zi.external_fa = 0; + filetime(filenameinzip,&zi.tmz_date,&zi.dosDate); + +/* + err = zipOpenNewFileInZip(zf,filenameinzip,&zi, + NULL,0,NULL,0,NULL / * comment * /, + (opt_compress_level != 0) ? Z_DEFLATED : 0, + opt_compress_level); +*/ + if ((password != NULL) && (err==ZIP_OK)) + err = getFileCrc(filenameinzip,buf,size_buf,&crcFile); + + zip64 = isLargeFile(filenameinzip); + + /* The path name saved, should not include a leading slash. */ + /*if it did, windows/xp and dynazip couldn't read the zip file. */ + savefilenameinzip = filenameinzip; + while( savefilenameinzip[0] == '\\' || savefilenameinzip[0] == '/' ) + { + savefilenameinzip++; + } + + /*should the zip file contain any path at all?*/ + if( opt_exclude_path ) + { + const char *tmpptr; + const char *lastslash = 0; + for( tmpptr = savefilenameinzip; *tmpptr; tmpptr++) + { + if( *tmpptr == '\\' || *tmpptr == '/') + { + lastslash = tmpptr; + } + } + if( lastslash != NULL ) + { + savefilenameinzip = lastslash+1; // base filename follows last slash. + } + } + + /**/ + err = zipOpenNewFileInZip3_64(zf,savefilenameinzip,&zi, + NULL,0,NULL,0,NULL /* comment*/, + (opt_compress_level != 0) ? Z_DEFLATED : 0, + opt_compress_level,0, + /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */ + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + password,crcFile, zip64); + + if (err != ZIP_OK) + printf("error in opening %s in zipfile\n",filenameinzip); + else + { + fin = FOPEN_FUNC(filenameinzip,"rb"); + if (fin==NULL) + { + err=ZIP_ERRNO; + printf("error in opening %s for reading\n",filenameinzip); + } + } + + if (err == ZIP_OK) + do + { + err = ZIP_OK; + size_read = (int)fread(buf,1,size_buf,fin); + if (size_read < size_buf) + if (feof(fin)==0) + { + printf("error in reading %s\n",filenameinzip); + err = ZIP_ERRNO; + } + + if (size_read>0) + { + err = zipWriteInFileInZip (zf,buf,size_read); + if (err<0) + { + printf("error in writing %s in the zipfile\n", + filenameinzip); + } + + } + } while ((err == ZIP_OK) && (size_read>0)); + + if (fin) + fclose(fin); + + if (err<0) + err=ZIP_ERRNO; + else + { + err = zipCloseFileInZip(zf); + if (err!=ZIP_OK) + printf("error in closing %s in the zipfile\n", + filenameinzip); + } + } + } + errclose = zipClose(zf,NULL); + if (errclose != ZIP_OK) + printf("error in closing %s\n",filename_try); + } + else + { + do_help(); + } + + free(buf); + return 0; +} diff --git a/xs/src/png/zlib/contrib/minizip/minizip.pc.in b/xs/src/png/zlib/contrib/minizip/minizip.pc.in new file mode 100644 index 0000000000..69b5b7fdcb --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/minizip.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@/minizip + +Name: minizip +Description: Minizip zip file manipulation library +Requires: +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -lminizip +Libs.private: -lz +Cflags: -I${includedir} diff --git a/xs/src/png/zlib/contrib/minizip/mztools.c b/xs/src/png/zlib/contrib/minizip/mztools.c new file mode 100644 index 0000000000..96891c2e0b --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/mztools.c @@ -0,0 +1,291 @@ +/* + Additional tools for Minizip + Code: Xavier Roche '2004 + License: Same as ZLIB (www.gzip.org) +*/ + +/* Code */ +#include +#include +#include +#include "zlib.h" +#include "unzip.h" + +#define READ_8(adr) ((unsigned char)*(adr)) +#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) +#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) + +#define WRITE_8(buff, n) do { \ + *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ +} while(0) +#define WRITE_16(buff, n) do { \ + WRITE_8((unsigned char*)(buff), n); \ + WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ +} while(0) +#define WRITE_32(buff, n) do { \ + WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ + WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ +} while(0) + +extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) +const char* file; +const char* fileOut; +const char* fileOutTmp; +uLong* nRecovered; +uLong* bytesRecovered; +{ + int err = Z_OK; + FILE* fpZip = fopen(file, "rb"); + FILE* fpOut = fopen(fileOut, "wb"); + FILE* fpOutCD = fopen(fileOutTmp, "wb"); + if (fpZip != NULL && fpOut != NULL) { + int entries = 0; + uLong totalBytes = 0; + char header[30]; + char filename[1024]; + char extra[1024]; + int offset = 0; + int offsetCD = 0; + while ( fread(header, 1, 30, fpZip) == 30 ) { + int currentOffset = offset; + + /* File entry */ + if (READ_32(header) == 0x04034b50) { + unsigned int version = READ_16(header + 4); + unsigned int gpflag = READ_16(header + 6); + unsigned int method = READ_16(header + 8); + unsigned int filetime = READ_16(header + 10); + unsigned int filedate = READ_16(header + 12); + unsigned int crc = READ_32(header + 14); /* crc */ + unsigned int cpsize = READ_32(header + 18); /* compressed size */ + unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ + unsigned int fnsize = READ_16(header + 26); /* file name length */ + unsigned int extsize = READ_16(header + 28); /* extra field length */ + filename[0] = extra[0] = '\0'; + + /* Header */ + if (fwrite(header, 1, 30, fpOut) == 30) { + offset += 30; + } else { + err = Z_ERRNO; + break; + } + + /* Filename */ + if (fnsize > 0) { + if (fnsize < sizeof(filename)) { + if (fread(filename, 1, fnsize, fpZip) == fnsize) { + if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { + offset += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (extsize < sizeof(extra)) { + if (fread(extra, 1, extsize, fpZip) == extsize) { + if (fwrite(extra, 1, extsize, fpOut) == extsize) { + offset += extsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } + + /* Data */ + { + int dataSize = cpsize; + if (dataSize == 0) { + dataSize = uncpsize; + } + if (dataSize > 0) { + char* data = malloc(dataSize); + if (data != NULL) { + if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { + if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { + offset += dataSize; + totalBytes += dataSize; + } else { + err = Z_ERRNO; + } + } else { + err = Z_ERRNO; + } + free(data); + if (err != Z_OK) { + break; + } + } else { + err = Z_MEM_ERROR; + break; + } + } + } + + /* Central directory entry */ + { + char header[46]; + char* comment = ""; + int comsize = (int) strlen(comment); + WRITE_32(header, 0x02014b50); + WRITE_16(header + 4, version); + WRITE_16(header + 6, version); + WRITE_16(header + 8, gpflag); + WRITE_16(header + 10, method); + WRITE_16(header + 12, filetime); + WRITE_16(header + 14, filedate); + WRITE_32(header + 16, crc); + WRITE_32(header + 20, cpsize); + WRITE_32(header + 24, uncpsize); + WRITE_16(header + 28, fnsize); + WRITE_16(header + 30, extsize); + WRITE_16(header + 32, comsize); + WRITE_16(header + 34, 0); /* disk # */ + WRITE_16(header + 36, 0); /* int attrb */ + WRITE_32(header + 38, 0); /* ext attrb */ + WRITE_32(header + 42, currentOffset); + /* Header */ + if (fwrite(header, 1, 46, fpOutCD) == 46) { + offsetCD += 46; + + /* Filename */ + if (fnsize > 0) { + if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { + offsetCD += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { + offsetCD += extsize; + } else { + err = Z_ERRNO; + break; + } + } + + /* Comment field */ + if (comsize > 0) { + if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { + offsetCD += comsize; + } else { + err = Z_ERRNO; + break; + } + } + + + } else { + err = Z_ERRNO; + break; + } + } + + /* Success */ + entries++; + + } else { + break; + } + } + + /* Final central directory */ + { + int entriesZip = entries; + char header[22]; + char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; + int comsize = (int) strlen(comment); + if (entriesZip > 0xffff) { + entriesZip = 0xffff; + } + WRITE_32(header, 0x06054b50); + WRITE_16(header + 4, 0); /* disk # */ + WRITE_16(header + 6, 0); /* disk # */ + WRITE_16(header + 8, entriesZip); /* hack */ + WRITE_16(header + 10, entriesZip); /* hack */ + WRITE_32(header + 12, offsetCD); /* size of CD */ + WRITE_32(header + 16, offset); /* offset to CD */ + WRITE_16(header + 20, comsize); /* comment */ + + /* Header */ + if (fwrite(header, 1, 22, fpOutCD) == 22) { + + /* Comment field */ + if (comsize > 0) { + if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { + err = Z_ERRNO; + } + } + + } else { + err = Z_ERRNO; + } + } + + /* Final merge (file + central directory) */ + fclose(fpOutCD); + if (err == Z_OK) { + fpOutCD = fopen(fileOutTmp, "rb"); + if (fpOutCD != NULL) { + int nRead; + char buffer[8192]; + while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { + if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { + err = Z_ERRNO; + break; + } + } + fclose(fpOutCD); + } + } + + /* Close */ + fclose(fpZip); + fclose(fpOut); + + /* Wipe temporary file */ + (void)remove(fileOutTmp); + + /* Number of recovered entries */ + if (err == Z_OK) { + if (nRecovered != NULL) { + *nRecovered = entries; + } + if (bytesRecovered != NULL) { + *bytesRecovered = totalBytes; + } + } + } else { + err = Z_STREAM_ERROR; + } + return err; +} diff --git a/xs/src/png/zlib/contrib/minizip/mztools.h b/xs/src/png/zlib/contrib/minizip/mztools.h new file mode 100644 index 0000000000..a49a426ec2 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/mztools.h @@ -0,0 +1,37 @@ +/* + Additional tools for Minizip + Code: Xavier Roche '2004 + License: Same as ZLIB (www.gzip.org) +*/ + +#ifndef _zip_tools_H +#define _zip_tools_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#include "unzip.h" + +/* Repair a ZIP file (missing central directory) + file: file to recover + fileOut: output file after recovery + fileOutTmp: temporary file name used for recovery +*/ +extern int ZEXPORT unzRepair(const char* file, + const char* fileOut, + const char* fileOutTmp, + uLong* nRecovered, + uLong* bytesRecovered); + + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/xs/src/png/zlib/contrib/minizip/unzip.c b/xs/src/png/zlib/contrib/minizip/unzip.c new file mode 100644 index 0000000000..bcfb9416ec --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/unzip.c @@ -0,0 +1,2125 @@ +/* unzip.c -- IO for uncompress .zip files using zlib + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications of Unzip for Zip64 + Copyright (C) 2007-2008 Even Rouault + + Modifications for Zip64 support on both zip and unzip + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + + + ------------------------------------------------------------------------------------ + Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of + compatibility with older software. The following is from the original crypt.c. + Code woven in by Terry Thorsen 1/2003. + + Copyright (c) 1990-2000 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2000-Apr-09 or later + (the contents of which are also included in zip.h) for terms of use. + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html + + crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] + + The encryption/decryption parts of this source code (as opposed to the + non-echoing password parts) were originally written in Europe. The + whole source package can be freely distributed, including from the USA. + (Prior to January 2000, re-export from the US was a violation of US law.) + + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + + ------------------------------------------------------------------------------------ + + Changes in unzip.c + + 2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos + 2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz* + 2007-2008 - Even Rouault - Remove old C style function prototypes + 2007-2008 - Even Rouault - Add unzip support for ZIP64 + + Copyright (C) 2007-2008 Even Rouault + + + Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). + Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G + should only read the compressed/uncompressed size from the Zip64 format if + the size from normal header was 0xFFFFFFFF + Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant + Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) + Patch created by Daniel Borca + + Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer + + Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson + +*/ + + +#include +#include +#include + +#ifndef NOUNCRYPT + #define NOUNCRYPT +#endif + +#include "zlib.h" +#include "unzip.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + + +#ifndef CASESENSITIVITYDEFAULT_NO +# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) +# define CASESENSITIVITYDEFAULT_NO +# endif +#endif + + +#ifndef UNZ_BUFSIZE +#define UNZ_BUFSIZE (16384) +#endif + +#ifndef UNZ_MAXFILENAMEINZIP +#define UNZ_MAXFILENAMEINZIP (256) +#endif + +#ifndef ALLOC +# define ALLOC(size) (malloc(size)) +#endif +#ifndef TRYFREE +# define TRYFREE(p) {if (p) free(p);} +#endif + +#define SIZECENTRALDIRITEM (0x2e) +#define SIZEZIPLOCALHEADER (0x1e) + + +const char unz_copyright[] = + " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; + +/* unz_file_info_interntal contain internal info about a file in zipfile*/ +typedef struct unz_file_info64_internal_s +{ + ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */ +} unz_file_info64_internal; + + +/* file_in_zip_read_info_s contain internal information about a file in zipfile, + when reading and decompress it */ +typedef struct +{ + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ + +#ifdef HAVE_BZIP2 + bz_stream bstream; /* bzLib stream structure for bziped */ +#endif + + ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ + + ZPOS64_T offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + ZPOS64_T pos_local_extrafield; /* position in the local extra field in read*/ + ZPOS64_T total_out_64; + + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ + ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + zlib_filefunc64_32_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + int raw; +} file_in_zip64_read_info_s; + + +/* unz64_s contain internal information about the zipfile +*/ +typedef struct +{ + zlib_filefunc64_32_def z_filefunc; + int is64bitOpenFunction; + voidpf filestream; /* io structore of the zipfile */ + unz_global_info64 gi; /* public global information */ + ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + ZPOS64_T num_file; /* number of the current file in the zipfile*/ + ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/ + ZPOS64_T current_file_ok; /* flag about the usability of the current file*/ + ZPOS64_T central_pos; /* position of the beginning of the central dir*/ + + ZPOS64_T size_central_dir; /* size of the central directory */ + ZPOS64_T offset_central_dir; /* offset of start of central directory with + respect to the starting disk number */ + + unz_file_info64 cur_file_info; /* public info about the current file in zip*/ + unz_file_info64_internal cur_file_info_internal; /* private info about it*/ + file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current + file if we are decompressing it */ + int encrypted; + + int isZip64; + +# ifndef NOUNCRYPT + unsigned long keys[3]; /* keys defining the pseudo-random sequence */ + const z_crc_t* pcrc_32_tab; +# endif +} unz64_s; + + +#ifndef NOUNCRYPT +#include "crypt.h" +#endif + +/* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been successfully opened for reading. +*/ + + +local int unz64local_getByte OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + int *pi)); + +local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi) +{ + unsigned char c; + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); + if (err==1) + { + *pi = (int)c; + return UNZ_OK; + } + else + { + if (ZERROR64(*pzlib_filefunc_def,filestream)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } +} + + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets +*/ +local int unz64local_getShort OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + +local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX) +{ + uLong x ; + int i = 0; + int err; + + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((uLong)i)<<8; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int unz64local_getLong OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + +local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX) +{ + uLong x ; + int i = 0; + int err; + + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((uLong)i)<<8; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((uLong)i)<<16; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<24; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int unz64local_getLong64 OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + ZPOS64_T *pX)); + + +local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + ZPOS64_T *pX) +{ + ZPOS64_T x ; + int i = 0; + int err; + + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x = (ZPOS64_T)i; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<8; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<16; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<24; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<32; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<40; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<48; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<56; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + +/* My own strcmpi / strcasecmp */ +local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2) +{ + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= 0x20; + if ((c2>='a') && (c2<='z')) + c2 -= 0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1c2) + return 1; + } +} + + +#ifdef CASESENSITIVITYDEFAULT_NO +#define CASESENSITIVITYDEFAULTVALUE 2 +#else +#define CASESENSITIVITYDEFAULTVALUE 1 +#endif + +#ifndef STRCMPCASENOSENTIVEFUNCTION +#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal +#endif + +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) + +*/ +extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, + const char* fileName2, + int iCaseSensitivity) + +{ + if (iCaseSensitivity==0) + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; + + if (iCaseSensitivity==1) + return strcmp(fileName1,fileName2); + + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); +} + +#ifndef BUFREADCOMMENT +#define BUFREADCOMMENT (0x400) +#endif + +/* + Locate the Central directory of a zipfile (at the end, just before + the global comment) +*/ +local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); +local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) +{ + unsigned char* buf; + ZPOS64_T uSizeFile; + ZPOS64_T uBackRead; + ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uPosFound=0; + + if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); + if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; +} + + +/* + Locate the Central directory 64 of a zipfile (at the end, just before + the global comment) +*/ +local ZPOS64_T unz64local_SearchCentralDir64 OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream)); + +local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream) +{ + unsigned char* buf; + ZPOS64_T uSizeFile; + ZPOS64_T uBackRead; + ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uPosFound=0; + uLong uL; + ZPOS64_T relativeOffset; + + if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); + if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + if (uPosFound == 0) + return 0; + + /* Zip64 end of central directory locator */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) + return 0; + + /* the signature, already checked */ + if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) + return 0; + + /* number of the disk with the start of the zip64 end of central directory */ + if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) + return 0; + if (uL != 0) + return 0; + + /* relative offset of the zip64 end of central directory record */ + if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK) + return 0; + + /* total number of disks */ + if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) + return 0; + if (uL != 1) + return 0; + + /* Goto end of central directory record */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) + return 0; + + /* the signature */ + if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) + return 0; + + if (uL != 0x06064b50) + return 0; + + return relativeOffset; +} + +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer + "zlib/zlib114.zip". + If the zipfile cannot be opened (file doesn't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ +local unzFile unzOpenInternal (const void *path, + zlib_filefunc64_32_def* pzlib_filefunc64_32_def, + int is64bitOpenFunction) +{ + unz64_s us; + unz64_s *s; + ZPOS64_T central_pos; + uLong uL; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + ZPOS64_T number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + + int err=UNZ_OK; + + if (unz_copyright[0]!=' ') + return NULL; + + us.z_filefunc.zseek32_file = NULL; + us.z_filefunc.ztell32_file = NULL; + if (pzlib_filefunc64_32_def==NULL) + fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); + else + us.z_filefunc = *pzlib_filefunc64_32_def; + us.is64bitOpenFunction = is64bitOpenFunction; + + + + us.filestream = ZOPEN64(us.z_filefunc, + path, + ZLIB_FILEFUNC_MODE_READ | + ZLIB_FILEFUNC_MODE_EXISTING); + if (us.filestream==NULL) + return NULL; + + central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream); + if (central_pos) + { + uLong uS; + ZPOS64_T uL64; + + us.isZip64 = 1; + + if (ZSEEK64(us.z_filefunc, us.filestream, + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* size of zip64 end of central directory record */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK) + err=UNZ_ERRNO; + + /* version made by */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) + err=UNZ_ERRNO; + + /* version needed to extract */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central directory on this disk */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central directory */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + us.gi.size_comment = 0; + } + else + { + central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream); + if (central_pos==0) + err=UNZ_ERRNO; + + us.isZip64 = 0; + + if (ZSEEK64(us.z_filefunc, us.filestream, + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + us.gi.number_entry = uL; + + /* total number of entries in the central dir */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + number_entry_CD = uL; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + us.size_central_dir = uL; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + us.offset_central_dir = uL; + + /* zipfile comment length */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; + } + + if ((central_pospfile_in_zip_read!=NULL) + unzCloseCurrentFile(file); + + ZCLOSE64(s->z_filefunc, s->filestream); + TRYFREE(s); + return UNZ_OK; +} + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ +extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info) +{ + unz64_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; +} + +extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32) +{ + unz64_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + /* to do : check if number_entry is not truncated */ + pglobal_info32->number_entry = (uLong)s->gi.number_entry; + pglobal_info32->size_comment = s->gi.size_comment; + return UNZ_OK; +} +/* + Translate date/time from Dos format to tm_unz (readable more easilty) +*/ +local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) +{ + ZPOS64_T uDate; + uDate = (ZPOS64_T)(ulDosDate>>16); + ptm->tm_mday = (uInt)(uDate&0x1f) ; + ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + + ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; +} + +/* + Get Info about the current file in the zipfile, with internal only info +*/ +local int unz64local_GetCurrentFileInfoInternal OF((unzFile file, + unz_file_info64 *pfile_info, + unz_file_info64_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + +local int unz64local_GetCurrentFileInfoInternal (unzFile file, + unz_file_info64 *pfile_info, + unz_file_info64_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize) +{ + unz64_s* s; + unz_file_info64 file_info; + unz_file_info64_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; + uLong uL; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + if (ZSEEK64(s->z_filefunc, s->filestream, + s->pos_in_central_dir+s->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + + /* we check the magic */ + if (err==UNZ_OK) + { + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; + } + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; + + unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) + err=UNZ_ERRNO; + file_info.compressed_size = uL; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) + err=UNZ_ERRNO; + file_info.uncompressed_size = uL; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + // relative offset of local header + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) + err=UNZ_ERRNO; + file_info_internal.offset_curfile = uL; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename0) && (fileNameBufferSize>0)) + if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } + + // Read extrafield + if ((err==UNZ_OK) && (extraField!=NULL)) + { + ZPOS64_T uSizeRead ; + if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + + lSeek += file_info.size_file_extra - (uLong)uSizeRead; + } + else + lSeek += file_info.size_file_extra; + + + if ((err==UNZ_OK) && (file_info.size_file_extra != 0)) + { + uLong acc = 0; + + // since lSeek now points to after the extra field we need to move back + lSeek -= file_info.size_file_extra; + + if (lSeek!=0) + { + if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + + while(acc < file_info.size_file_extra) + { + uLong headerId; + uLong dataSize; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK) + err=UNZ_ERRNO; + + /* ZIP64 extra fields */ + if (headerId == 0x0001) + { + uLong uL; + + if(file_info.uncompressed_size == MAXU32) + { + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info.compressed_size == MAXU32) + { + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info_internal.offset_curfile == MAXU32) + { + /* Relative Header offset */ + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info.disk_num_start == MAXU32) + { + /* Disk Start Number */ + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) + err=UNZ_ERRNO; + } + + } + else + { + if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) + err=UNZ_ERRNO; + } + + acc += 2 + 2 + dataSize; + } + } + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; + + + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; + + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; + + return err; +} + + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. +*/ +extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file, + unz_file_info64 * pfile_info, + char * szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char* szComment, uLong commentBufferSize) +{ + return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); +} + +extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, + unz_file_info * pfile_info, + char * szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char* szComment, uLong commentBufferSize) +{ + int err; + unz_file_info64 file_info64; + err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); + if ((err==UNZ_OK) && (pfile_info != NULL)) + { + pfile_info->version = file_info64.version; + pfile_info->version_needed = file_info64.version_needed; + pfile_info->flag = file_info64.flag; + pfile_info->compression_method = file_info64.compression_method; + pfile_info->dosDate = file_info64.dosDate; + pfile_info->crc = file_info64.crc; + + pfile_info->size_filename = file_info64.size_filename; + pfile_info->size_file_extra = file_info64.size_file_extra; + pfile_info->size_file_comment = file_info64.size_file_comment; + + pfile_info->disk_num_start = file_info64.disk_num_start; + pfile_info->internal_fa = file_info64.internal_fa; + pfile_info->external_fa = file_info64.external_fa; + + pfile_info->tmu_date = file_info64.tmu_date, + + + pfile_info->compressed_size = (uLong)file_info64.compressed_size; + pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; + + } + return err; +} +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ +extern int ZEXPORT unzGoToFirstFile (unzFile file) +{ + int err=UNZ_OK; + unz64_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ +extern int ZEXPORT unzGoToNextFile (unzFile file) +{ + unz64_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ +extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) +{ + unz64_s* s; + int err; + + /* We remember the 'current' position in the file so that we can jump + * back there if we fail. + */ + unz_file_info64 cur_file_infoSaved; + unz_file_info64_internal cur_file_info_internalSaved; + ZPOS64_T num_fileSaved; + ZPOS64_T pos_in_central_dirSaved; + + + if (file==NULL) + return UNZ_PARAMERROR; + + if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) + return UNZ_PARAMERROR; + + s=(unz64_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + /* Save the current state */ + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; + cur_file_infoSaved = s->cur_file_info; + cur_file_info_internalSaved = s->cur_file_info_internal; + + err = unzGoToFirstFile(file); + + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + err = unzGetCurrentFileInfo64(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (err == UNZ_OK) + { + if (unzStringFileNameCompare(szCurrentFileName, + szFileName,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } + } + + /* We failed, so restore the state of the 'current file' to where we + * were. + */ + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + s->cur_file_info = cur_file_infoSaved; + s->cur_file_info_internal = cur_file_info_internalSaved; + return err; +} + + +/* +/////////////////////////////////////////// +// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) +// I need random access +// +// Further optimization could be realized by adding an ability +// to cache the directory in memory. The goal being a single +// comprehensive file read to put the file I need in a memory. +*/ + +/* +typedef struct unz_file_pos_s +{ + ZPOS64_T pos_in_zip_directory; // offset in file + ZPOS64_T num_of_file; // # of file +} unz_file_pos; +*/ + +extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) +{ + unz64_s* s; + + if (file==NULL || file_pos==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + file_pos->pos_in_zip_directory = s->pos_in_central_dir; + file_pos->num_of_file = s->num_file; + + return UNZ_OK; +} + +extern int ZEXPORT unzGetFilePos( + unzFile file, + unz_file_pos* file_pos) +{ + unz64_file_pos file_pos64; + int err = unzGetFilePos64(file,&file_pos64); + if (err==UNZ_OK) + { + file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory; + file_pos->num_of_file = (uLong)file_pos64.num_of_file; + } + return err; +} + +extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) +{ + unz64_s* s; + int err; + + if (file==NULL || file_pos==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + + /* jump to the right spot */ + s->pos_in_central_dir = file_pos->pos_in_zip_directory; + s->num_file = file_pos->num_of_file; + + /* set the current file */ + err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + /* return results */ + s->current_file_ok = (err == UNZ_OK); + return err; +} + +extern int ZEXPORT unzGoToFilePos( + unzFile file, + unz_file_pos* file_pos) +{ + unz64_file_pos file_pos64; + if (file_pos == NULL) + return UNZ_PARAMERROR; + + file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; + file_pos64.num_of_file = file_pos->num_of_file; + return unzGoToFilePos64(file,&file_pos64); +} + +/* +// Unzip Helper Functions - should be here? +/////////////////////////////////////////// +*/ + +/* + Read the local header of the current zipfile + Check the coherency of the local header and info in the end of central + directory about this file + store in *piSizeVar the size of extra info in local header + (filename and size of extra field data) +*/ +local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar, + ZPOS64_T * poffset_local_extrafield, + uInt * psize_local_extrafield) +{ + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; + + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; + + if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + + if (err==UNZ_OK) + { + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; + } + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + err=UNZ_ERRNO; +/* + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; +*/ + if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; + + if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && +/* #ifdef HAVE_BZIP2 */ + (s->cur_file_info.compression_method!=Z_BZIP2ED) && +/* #endif */ + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; + + *piSizeVar += (uInt)size_filename; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; + + *piSizeVar += (uInt)size_extra_field; + + return err; +} + +/* + Open for reading data the current file in the zipfile. + If there is no error and the file is opened, the return value is UNZ_OK. +*/ +extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, + int* level, int raw, const char* password) +{ + int err=UNZ_OK; + uInt iSizeVar; + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ +# ifndef NOUNCRYPT + char source[12]; +# else + if (password != NULL) + return UNZ_PARAMERROR; +# endif + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; + + if (s->pfile_in_zip_read != NULL) + unzCloseCurrentFile(file); + + if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + pfile_in_zip_read_info->raw=raw; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if (method!=NULL) + *method = (int)s->cur_file_info.compression_method; + + if (level!=NULL) + { + *level = 6; + switch (s->cur_file_info.flag & 0x06) + { + case 6 : *level = 1; break; + case 4 : *level = 2; break; + case 2 : *level = 9; break; + } + } + + if ((s->cur_file_info.compression_method!=0) && +/* #ifdef HAVE_BZIP2 */ + (s->cur_file_info.compression_method!=Z_BZIP2ED) && +/* #endif */ + (s->cur_file_info.compression_method!=Z_DEFLATED)) + + err=UNZ_BADZIPFILE; + + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->total_out_64=0; + pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; + pfile_in_zip_read_info->filestream=s->filestream; + pfile_in_zip_read_info->z_filefunc=s->z_filefunc; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + + pfile_in_zip_read_info->stream.total_out = 0; + + if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw)) + { +#ifdef HAVE_BZIP2 + pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0; + pfile_in_zip_read_info->bstream.bzfree = (free_func)0; + pfile_in_zip_read_info->bstream.opaque = (voidpf)0; + pfile_in_zip_read_info->bstream.state = (voidpf)0; + + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + pfile_in_zip_read_info->stream.next_in = (voidpf)0; + pfile_in_zip_read_info->stream.avail_in = 0; + + err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; + else + { + TRYFREE(pfile_in_zip_read_info); + return err; + } +#else + pfile_in_zip_read_info->raw=1; +#endif + } + else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + pfile_in_zip_read_info->stream.next_in = 0; + pfile_in_zip_read_info->stream.avail_in = 0; + + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; + else + { + TRYFREE(pfile_in_zip_read_info); + return err; + } + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * size of both compressed and uncompressed data + */ + } + pfile_in_zip_read_info->rest_read_compressed = + s->cur_file_info.compressed_size ; + pfile_in_zip_read_info->rest_read_uncompressed = + s->cur_file_info.uncompressed_size ; + + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; + + s->pfile_in_zip_read = pfile_in_zip_read_info; + s->encrypted = 0; + +# ifndef NOUNCRYPT + if (password != NULL) + { + int i; + s->pcrc_32_tab = get_crc_table(); + init_keys(password,s->keys,s->pcrc_32_tab); + if (ZSEEK64(s->z_filefunc, s->filestream, + s->pfile_in_zip_read->pos_in_zipfile + + s->pfile_in_zip_read->byte_before_the_zipfile, + SEEK_SET)!=0) + return UNZ_INTERNALERROR; + if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12) + return UNZ_INTERNALERROR; + + for (i = 0; i<12; i++) + zdecode(s->keys,s->pcrc_32_tab,source[i]); + + s->pfile_in_zip_read->pos_in_zipfile+=12; + s->encrypted=1; + } +# endif + + + return UNZ_OK; +} + +extern int ZEXPORT unzOpenCurrentFile (unzFile file) +{ + return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); +} + +extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password) +{ + return unzOpenCurrentFile3(file, NULL, NULL, 0, password); +} + +extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw) +{ + return unzOpenCurrentFile3(file, method, level, raw, NULL); +} + +/** Addition for GDAL : START */ + +extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) +{ + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + s=(unz64_s*)file; + if (file==NULL) + return 0; //UNZ_PARAMERROR; + pfile_in_zip_read_info=s->pfile_in_zip_read; + if (pfile_in_zip_read_info==NULL) + return 0; //UNZ_PARAMERROR; + return pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile; +} + +/** Addition for GDAL : END */ + +/* + Read bytes from the current file. + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ +extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) +{ + int err=UNZ_OK; + uInt iRead = 0; + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if (pfile_in_zip_read_info->read_buffer == NULL) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; + + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && + (!(pfile_in_zip_read_info->raw))) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + + if ((len>pfile_in_zip_read_info->rest_read_compressed+ + pfile_in_zip_read_info->stream.avail_in) && + (pfile_in_zip_read_info->raw)) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_compressed+ + pfile_in_zip_read_info->stream.avail_in; + + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && + (pfile_in_zip_read_info->rest_read_compressed>0)) + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + if (ZREAD64(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->read_buffer, + uReadThis)!=uReadThis) + return UNZ_ERRNO; + + +# ifndef NOUNCRYPT + if(s->encrypted) + { + uInt i; + for(i=0;iread_buffer[i] = + zdecode(s->keys,s->pcrc_32_tab, + pfile_in_zip_read_info->read_buffer[i]); + } +# endif + + + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = + (Bytef*)pfile_in_zip_read_info->read_buffer; + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } + + if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) + { + uInt uDoCopy,i ; + + if ((pfile_in_zip_read_info->stream.avail_in == 0) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + return (iRead==0) ? UNZ_EOF : iRead; + + if (pfile_in_zip_read_info->stream.avail_out < + pfile_in_zip_read_info->stream.avail_in) + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0;istream.next_out+i) = + *(pfile_in_zip_read_info->stream.next_in+i); + + pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy; + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; + pfile_in_zip_read_info->stream.total_out += uDoCopy; + iRead += uDoCopy; + } + else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) + { +#ifdef HAVE_BZIP2 + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + + pfile_in_zip_read_info->bstream.next_in = (char*)pfile_in_zip_read_info->stream.next_in; + pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in; + pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in; + pfile_in_zip_read_info->bstream.total_in_hi32 = 0; + pfile_in_zip_read_info->bstream.next_out = (char*)pfile_in_zip_read_info->stream.next_out; + pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out; + pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out; + pfile_in_zip_read_info->bstream.total_out_hi32 = 0; + + uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32; + bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out; + + err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream); + + uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); + pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in; + pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in; + pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32; + pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out; + pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out; + pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32; + + if (err==BZ_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=BZ_OK) + break; +#endif + } // end Z_BZIP2ED + else + { + ZPOS64_T uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + ZPOS64_T uOutThis; + int flush=Z_SYNC_FLUSH; + + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); + + if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) + err = Z_DATA_ERROR; + + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; + + pfile_in_zip_read_info->crc32 = + crc32(pfile_in_zip_read_info->crc32,bufBefore, + (uInt)(uOutThis)); + + pfile_in_zip_read_info->rest_read_uncompressed -= + uOutThis; + + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } + + if (err==Z_OK) + return iRead; + return err; +} + + +/* + Give the current position in uncompressed data +*/ +extern z_off_t ZEXPORT unztell (unzFile file) +{ + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + return (z_off_t)pfile_in_zip_read_info->stream.total_out; +} + +extern ZPOS64_T ZEXPORT unztell64 (unzFile file) +{ + + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return (ZPOS64_T)-1; + s=(unz64_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return (ZPOS64_T)-1; + + return pfile_in_zip_read_info->total_out_64; +} + + +/* + return 1 if the end of file was reached, 0 elsewhere +*/ +extern int ZEXPORT unzeof (unzFile file) +{ + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; +} + + + +/* +Read extra field from the current file (opened by unzOpenCurrentFile) +This is the local-header version of the extra field (sometimes, there is +more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field that can be read + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ +extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len) +{ + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + uInt read_now; + ZPOS64_T size_to_read; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); + + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; + + if (read_now==0) + return 0; + + if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->offset_local_extrafield + + pfile_in_zip_read_info->pos_local_extrafield, + ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + if (ZREAD64(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + buf,read_now)!=read_now) + return UNZ_ERRNO; + + return (int)read_now; +} + +/* + Close the file in zip opened with unzOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ +extern int ZEXPORT unzCloseCurrentFile (unzFile file) +{ + int err=UNZ_OK; + + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && + (!pfile_in_zip_read_info->raw)) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } + + + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) + inflateEnd(&pfile_in_zip_read_info->stream); +#ifdef HAVE_BZIP2 + else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) + BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); +#endif + + + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); + + s->pfile_in_zip_read=NULL; + + return err; +} + + +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ +extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf) +{ + unz64_s* s; + uLong uReadThis ; + if (file==NULL) + return (int)UNZ_PARAMERROR; + s=(unz64_s*)file; + + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) + uReadThis = s->gi.size_comment; + + if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + if (uReadThis>0) + { + *szComment='\0'; + if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) + return UNZ_ERRNO; + } + + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) + *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; +} + +/* Additions by RX '2004 */ +extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) +{ + unz64_s* s; + + if (file==NULL) + return 0; //UNZ_PARAMERROR; + s=(unz64_s*)file; + if (!s->current_file_ok) + return 0; + if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) + if (s->num_file==s->gi.number_entry) + return 0; + return s->pos_in_central_dir; +} + +extern uLong ZEXPORT unzGetOffset (unzFile file) +{ + ZPOS64_T offset64; + + if (file==NULL) + return 0; //UNZ_PARAMERROR; + offset64 = unzGetOffset64(file); + return (uLong)offset64; +} + +extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) +{ + unz64_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + + s->pos_in_central_dir = pos; + s->num_file = s->gi.number_entry; /* hack */ + err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + +extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) +{ + return unzSetOffset64(file,pos); +} diff --git a/xs/src/png/zlib/contrib/minizip/unzip.h b/xs/src/png/zlib/contrib/minizip/unzip.h new file mode 100644 index 0000000000..2104e39150 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/unzip.h @@ -0,0 +1,437 @@ +/* unzip.h -- IO for uncompress .zip files using zlib + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications of Unzip for Zip64 + Copyright (C) 2007-2008 Even Rouault + + Modifications for Zip64 support on both zip and unzip + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + + --------------------------------------------------------------------------------- + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + --------------------------------------------------------------------------------- + + Changes + + See header of unzip64.c + +*/ + +#ifndef _unz64_H +#define _unz64_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#ifndef _ZLIBIOAPI_H +#include "ioapi.h" +#endif + +#ifdef HAVE_BZIP2 +#include "bzlib.h" +#endif + +#define Z_BZIP2ED 12 + +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagunzFile__ { int unused; } unzFile__; +typedef unzFile__ *unzFile; +#else +typedef voidp unzFile; +#endif + + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (Z_ERRNO) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) + +/* tm_unz contain date/time info */ +typedef struct tm_unz_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_unz; + +/* unz_global_info structure contain global data about the ZIPfile + These data comes from the end of central dir */ +typedef struct unz_global_info64_s +{ + ZPOS64_T number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ +} unz_global_info64; + +typedef struct unz_global_info_s +{ + uLong number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ +} unz_global_info; + +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_info64_s +{ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + ZPOS64_T compressed_size; /* compressed size 8 bytes */ + ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; +} unz_file_info64; + +typedef struct unz_file_info_s +{ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; +} unz_file_info; + +extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, + const char* fileName2, + int iCaseSensitivity)); +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) +*/ + + +extern unzFile ZEXPORT unzOpen OF((const char *path)); +extern unzFile ZEXPORT unzOpen64 OF((const void *path)); +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer + "zlib/zlib113.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. + the "64" function take a const void* pointer, because the path is just the + value passed to the open64_file_func callback. + Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path + is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* + does not describe the reality +*/ + + +extern unzFile ZEXPORT unzOpen2 OF((const char *path, + zlib_filefunc_def* pzlib_filefunc_def)); +/* + Open a Zip file, like unzOpen, but provide a set of file low level API + for read/write the zip file (see ioapi.h) +*/ + +extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, + zlib_filefunc64_def* pzlib_filefunc_def)); +/* + Open a Zip file, like unz64Open, but provide a set of file low level API + for read/write the zip file (see ioapi.h) +*/ + +extern int ZEXPORT unzClose OF((unzFile file)); +/* + Close a ZipFile opened with unzOpen. + If there is files inside the .Zip opened with unzOpenCurrentFile (see later), + these files MUST be closed with unzCloseCurrentFile before call unzClose. + return UNZ_OK if there is no problem. */ + +extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, + unz_global_info *pglobal_info)); + +extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, + unz_global_info64 *pglobal_info)); +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ + + +extern int ZEXPORT unzGetGlobalComment OF((unzFile file, + char *szComment, + uLong uSizeBuf)); +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ + + +/***************************************************************************/ +/* Unzip package allow you browse the directory of the zipfile */ + +extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ + +extern int ZEXPORT unzGoToNextFile OF((unzFile file)); +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ + +extern int ZEXPORT unzLocateFile OF((unzFile file, + const char *szFileName, + int iCaseSensitivity)); +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ + + +/* ****************************************** */ +/* Ryan supplied functions */ +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_pos_s +{ + uLong pos_in_zip_directory; /* offset in zip file directory */ + uLong num_of_file; /* # of file */ +} unz_file_pos; + +extern int ZEXPORT unzGetFilePos( + unzFile file, + unz_file_pos* file_pos); + +extern int ZEXPORT unzGoToFilePos( + unzFile file, + unz_file_pos* file_pos); + +typedef struct unz64_file_pos_s +{ + ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */ + ZPOS64_T num_of_file; /* # of file */ +} unz64_file_pos; + +extern int ZEXPORT unzGetFilePos64( + unzFile file, + unz64_file_pos* file_pos); + +extern int ZEXPORT unzGoToFilePos64( + unzFile file, + const unz64_file_pos* file_pos); + +/* ****************************************** */ + +extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, + unz_file_info64 *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + +extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); +/* + Get Info about the current file + if pfile_info!=NULL, the *pfile_info structure will contain somes info about + the current file + if szFileName!=NULL, the filemane string will be copied in szFileName + (fileNameBufferSize is the size of the buffer) + if extraField!=NULL, the extra field information will be copied in extraField + (extraFieldBufferSize is the size of the buffer). + This is the Central-header version of the extra field + if szComment!=NULL, the comment string of the file will be copied in szComment + (commentBufferSize is the size of the buffer) +*/ + + +/** Addition for GDAL : START */ + +extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); + +/** Addition for GDAL : END */ + + +/***************************************************************************/ +/* for reading the content of the current zipfile, you can open it, read data + from it, and close it (you can close it before reading all the file) + */ + +extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); +/* + Open for reading data the current file in the zipfile. + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, + const char* password)); +/* + Open for reading data the current file in the zipfile. + password is a crypting password + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, + int* method, + int* level, + int raw)); +/* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + if raw==1 + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL +*/ + +extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, + int* method, + int* level, + int raw, + const char* password)); +/* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + if raw==1 + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL +*/ + + +extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); +/* + Close the file in zip opened with unzOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ + +extern int ZEXPORT unzReadCurrentFile OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read bytes from the current file (opened by unzOpenCurrentFile) + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ + +extern z_off_t ZEXPORT unztell OF((unzFile file)); + +extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); +/* + Give the current position in uncompressed data +*/ + +extern int ZEXPORT unzeof OF((unzFile file)); +/* + return 1 if the end of file was reached, 0 elsewhere +*/ + +extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ + +/***************************************************************************/ + +/* Get the current file offset */ +extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file); +extern uLong ZEXPORT unzGetOffset (unzFile file); + +/* Set the current file offset */ +extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos); +extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); + + + +#ifdef __cplusplus +} +#endif + +#endif /* _unz64_H */ diff --git a/xs/src/png/zlib/contrib/minizip/zip.c b/xs/src/png/zlib/contrib/minizip/zip.c new file mode 100644 index 0000000000..44e88a9cb9 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/zip.c @@ -0,0 +1,2007 @@ +/* zip.c -- IO on .zip files using zlib + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + + Changes + Oct-2009 - Mathias Svensson - Remove old C style function prototypes + Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives + Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. + Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data + It is used when recreting zip archive with RAW when deleting items from a zip. + ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed. + Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) + Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer + +*/ + + +#include +#include +#include +#include +#include "zlib.h" +#include "zip.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +#ifndef VERSIONMADEBY +# define VERSIONMADEBY (0x0) /* platform depedent */ +#endif + +#ifndef Z_BUFSIZE +#define Z_BUFSIZE (64*1024) //(16384) +#endif + +#ifndef Z_MAXFILENAMEINZIP +#define Z_MAXFILENAMEINZIP (256) +#endif + +#ifndef ALLOC +# define ALLOC(size) (malloc(size)) +#endif +#ifndef TRYFREE +# define TRYFREE(p) {if (p) free(p);} +#endif + +/* +#define SIZECENTRALDIRITEM (0x2e) +#define SIZEZIPLOCALHEADER (0x1e) +*/ + +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + + +// NOT sure that this work on ALL platform +#define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32)) + +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +#ifndef DEF_MEM_LEVEL +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +#endif +const char zip_copyright[] =" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; + + +#define SIZEDATA_INDATABLOCK (4096-(4*4)) + +#define LOCALHEADERMAGIC (0x04034b50) +#define CENTRALHEADERMAGIC (0x02014b50) +#define ENDHEADERMAGIC (0x06054b50) +#define ZIP64ENDHEADERMAGIC (0x6064b50) +#define ZIP64ENDLOCHEADERMAGIC (0x7064b50) + +#define FLAG_LOCALHEADER_OFFSET (0x06) +#define CRC_LOCALHEADER_OFFSET (0x0e) + +#define SIZECENTRALHEADER (0x2e) /* 46 */ + +typedef struct linkedlist_datablock_internal_s +{ + struct linkedlist_datablock_internal_s* next_datablock; + uLong avail_in_this_block; + uLong filled_in_this_block; + uLong unused; /* for future use and alignment */ + unsigned char data[SIZEDATA_INDATABLOCK]; +} linkedlist_datablock_internal; + +typedef struct linkedlist_data_s +{ + linkedlist_datablock_internal* first_block; + linkedlist_datablock_internal* last_block; +} linkedlist_data; + + +typedef struct +{ + z_stream stream; /* zLib stream structure for inflate */ +#ifdef HAVE_BZIP2 + bz_stream bstream; /* bzLib stream structure for bziped */ +#endif + + int stream_initialised; /* 1 is stream is initialised */ + uInt pos_in_buffered_data; /* last written byte in buffered_data */ + + ZPOS64_T pos_local_header; /* offset of the local header of the file + currenty writing */ + char* central_header; /* central header data for the current file */ + uLong size_centralExtra; + uLong size_centralheader; /* size of the central header for cur file */ + uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ + uLong flag; /* flag of the file currently writing */ + + int method; /* compression method of file currenty wr.*/ + int raw; /* 1 for directly writing raw data */ + Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ + uLong dosDate; + uLong crc32; + int encrypt; + int zip64; /* Add ZIP64 extened information in the extra field */ + ZPOS64_T pos_zip64extrainfo; + ZPOS64_T totalCompressedData; + ZPOS64_T totalUncompressedData; +#ifndef NOCRYPT + unsigned long keys[3]; /* keys defining the pseudo-random sequence */ + const z_crc_t* pcrc_32_tab; + int crypt_header_size; +#endif +} curfile64_info; + +typedef struct +{ + zlib_filefunc64_32_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + linkedlist_data central_dir;/* datablock with central dir in construction*/ + int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ + curfile64_info ci; /* info on the file curretly writing */ + + ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ + ZPOS64_T add_position_when_writing_offset; + ZPOS64_T number_entry; + +#ifndef NO_ADDFILEINEXISTINGZIP + char *globalcomment; +#endif + +} zip64_internal; + + +#ifndef NOCRYPT +#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED +#include "crypt.h" +#endif + +local linkedlist_datablock_internal* allocate_new_datablock() +{ + linkedlist_datablock_internal* ldi; + ldi = (linkedlist_datablock_internal*) + ALLOC(sizeof(linkedlist_datablock_internal)); + if (ldi!=NULL) + { + ldi->next_datablock = NULL ; + ldi->filled_in_this_block = 0 ; + ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; + } + return ldi; +} + +local void free_datablock(linkedlist_datablock_internal* ldi) +{ + while (ldi!=NULL) + { + linkedlist_datablock_internal* ldinext = ldi->next_datablock; + TRYFREE(ldi); + ldi = ldinext; + } +} + +local void init_linkedlist(linkedlist_data* ll) +{ + ll->first_block = ll->last_block = NULL; +} + +local void free_linkedlist(linkedlist_data* ll) +{ + free_datablock(ll->first_block); + ll->first_block = ll->last_block = NULL; +} + + +local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) +{ + linkedlist_datablock_internal* ldi; + const unsigned char* from_copy; + + if (ll==NULL) + return ZIP_INTERNALERROR; + + if (ll->last_block == NULL) + { + ll->first_block = ll->last_block = allocate_new_datablock(); + if (ll->first_block == NULL) + return ZIP_INTERNALERROR; + } + + ldi = ll->last_block; + from_copy = (unsigned char*)buf; + + while (len>0) + { + uInt copy_this; + uInt i; + unsigned char* to_copy; + + if (ldi->avail_in_this_block==0) + { + ldi->next_datablock = allocate_new_datablock(); + if (ldi->next_datablock == NULL) + return ZIP_INTERNALERROR; + ldi = ldi->next_datablock ; + ll->last_block = ldi; + } + + if (ldi->avail_in_this_block < len) + copy_this = (uInt)ldi->avail_in_this_block; + else + copy_this = (uInt)len; + + to_copy = &(ldi->data[ldi->filled_in_this_block]); + + for (i=0;ifilled_in_this_block += copy_this; + ldi->avail_in_this_block -= copy_this; + from_copy += copy_this ; + len -= copy_this; + } + return ZIP_OK; +} + + + +/****************************************************************************/ + +#ifndef NO_ADDFILEINEXISTINGZIP +/* =========================================================================== + Inputs a long in LSB order to the given file + nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) +*/ + +local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); +local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) +{ + unsigned char buf[8]; + int n; + for (n = 0; n < nbByte; n++) + { + buf[n] = (unsigned char)(x & 0xff); + x >>= 8; + } + if (x != 0) + { /* data overflow - hack for ZIP64 (X Roche) */ + for (n = 0; n < nbByte; n++) + { + buf[n] = 0xff; + } + } + + if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) + return ZIP_ERRNO; + else + return ZIP_OK; +} + +local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); +local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) +{ + unsigned char* buf=(unsigned char*)dest; + int n; + for (n = 0; n < nbByte; n++) { + buf[n] = (unsigned char)(x & 0xff); + x >>= 8; + } + + if (x != 0) + { /* data overflow - hack for ZIP64 */ + for (n = 0; n < nbByte; n++) + { + buf[n] = 0xff; + } + } +} + +/****************************************************************************/ + + +local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) +{ + uLong year = (uLong)ptm->tm_year; + if (year>=1980) + year-=1980; + else if (year>=80) + year-=80; + return + (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | + ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); +} + + +/****************************************************************************/ + +local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); + +local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi) +{ + unsigned char c; + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); + if (err==1) + { + *pi = (int)c; + return ZIP_OK; + } + else + { + if (ZERROR64(*pzlib_filefunc_def,filestream)) + return ZIP_ERRNO; + else + return ZIP_EOF; + } +} + + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets +*/ +local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); + +local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) +{ + uLong x ; + int i = 0; + int err; + + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==ZIP_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); + +local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) +{ + uLong x ; + int i = 0; + int err; + + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<16; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<24; + + if (err==ZIP_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)); + + +local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) +{ + ZPOS64_T x; + int i = 0; + int err; + + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x = (ZPOS64_T)i; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<8; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<16; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<24; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<32; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<40; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<48; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<56; + + if (err==ZIP_OK) + *pX = x; + else + *pX = 0; + + return err; +} + +#ifndef BUFREADCOMMENT +#define BUFREADCOMMENT (0x400) +#endif +/* + Locate the Central directory of a zipfile (at the end, just before + the global comment) +*/ +local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); + +local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) +{ + unsigned char* buf; + ZPOS64_T uSizeFile; + ZPOS64_T uBackRead; + ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uPosFound=0; + + if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); + if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; +} + +/* +Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before +the global comment) +*/ +local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); + +local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) +{ + unsigned char* buf; + ZPOS64_T uSizeFile; + ZPOS64_T uBackRead; + ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uPosFound=0; + uLong uL; + ZPOS64_T relativeOffset; + + if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); + if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + { + // Signature "0x07064b50" Zip64 end of central directory locater + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) + { + uPosFound = uReadPos+i; + break; + } + } + + if (uPosFound!=0) + break; + } + + TRYFREE(buf); + if (uPosFound == 0) + return 0; + + /* Zip64 end of central directory locator */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) + return 0; + + /* the signature, already checked */ + if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) + return 0; + + /* number of the disk with the start of the zip64 end of central directory */ + if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) + return 0; + if (uL != 0) + return 0; + + /* relative offset of the zip64 end of central directory record */ + if (zip64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=ZIP_OK) + return 0; + + /* total number of disks */ + if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) + return 0; + if (uL != 1) + return 0; + + /* Goto Zip64 end of central directory record */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) + return 0; + + /* the signature */ + if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) + return 0; + + if (uL != 0x06064b50) // signature of 'Zip64 end of central directory' + return 0; + + return relativeOffset; +} + +int LoadCentralDirectoryRecord(zip64_internal* pziinit) +{ + int err=ZIP_OK; + ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + + ZPOS64_T size_central_dir; /* size of the central directory */ + ZPOS64_T offset_central_dir; /* offset of start of central directory */ + ZPOS64_T central_pos; + uLong uL; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + ZPOS64_T number_entry; + ZPOS64_T number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + uLong VersionMadeBy; + uLong VersionNeeded; + uLong size_comment; + + int hasZIP64Record = 0; + + // check first if we find a ZIP64 record + central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream); + if(central_pos > 0) + { + hasZIP64Record = 1; + } + else if(central_pos == 0) + { + central_pos = zip64local_SearchCentralDir(&pziinit->z_filefunc,pziinit->filestream); + } + +/* disable to allow appending to empty ZIP archive + if (central_pos==0) + err=ZIP_ERRNO; +*/ + + if(hasZIP64Record) + { + ZPOS64_T sizeEndOfCentralDirectory; + if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos, ZLIB_FILEFUNC_SEEK_SET) != 0) + err=ZIP_ERRNO; + + /* the signature, already checked */ + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK) + err=ZIP_ERRNO; + + /* size of zip64 end of central directory record */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &sizeEndOfCentralDirectory)!=ZIP_OK) + err=ZIP_ERRNO; + + /* version made by */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionMadeBy)!=ZIP_OK) + err=ZIP_ERRNO; + + /* version needed to extract */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionNeeded)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of this disk */ + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of the disk with the start of the central directory */ + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central directory on this disk */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &number_entry)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central directory */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&number_entry_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) + err=ZIP_BADZIPFILE; + + /* size of the central directory */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&size_central_dir)!=ZIP_OK) + err=ZIP_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK) + err=ZIP_ERRNO; + + // TODO.. + // read the comment from the standard central header. + size_comment = 0; + } + else + { + // Read End of central Directory info + if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=ZIP_ERRNO; + + /* the signature, already checked */ + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of this disk */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of the disk with the start of the central directory */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central dir on this disk */ + number_entry = 0; + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) + err=ZIP_ERRNO; + else + number_entry = uL; + + /* total number of entries in the central dir */ + number_entry_CD = 0; + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) + err=ZIP_ERRNO; + else + number_entry_CD = uL; + + if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) + err=ZIP_BADZIPFILE; + + /* size of the central directory */ + size_central_dir = 0; + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) + err=ZIP_ERRNO; + else + size_central_dir = uL; + + /* offset of start of central directory with respect to the starting disk number */ + offset_central_dir = 0; + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) + err=ZIP_ERRNO; + else + offset_central_dir = uL; + + + /* zipfile global comment length */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &size_comment)!=ZIP_OK) + err=ZIP_ERRNO; + } + + if ((central_posz_filefunc, pziinit->filestream); + return ZIP_ERRNO; + } + + if (size_comment>0) + { + pziinit->globalcomment = (char*)ALLOC(size_comment+1); + if (pziinit->globalcomment) + { + size_comment = ZREAD64(pziinit->z_filefunc, pziinit->filestream, pziinit->globalcomment,size_comment); + pziinit->globalcomment[size_comment]=0; + } + } + + byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir); + pziinit->add_position_when_writing_offset = byte_before_the_zipfile; + + { + ZPOS64_T size_central_dir_to_read = size_central_dir; + size_t buf_size = SIZEDATA_INDATABLOCK; + void* buf_read = (void*)ALLOC(buf_size); + if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir + byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0) + err=ZIP_ERRNO; + + while ((size_central_dir_to_read>0) && (err==ZIP_OK)) + { + ZPOS64_T read_this = SIZEDATA_INDATABLOCK; + if (read_this > size_central_dir_to_read) + read_this = size_central_dir_to_read; + + if (ZREAD64(pziinit->z_filefunc, pziinit->filestream,buf_read,(uLong)read_this) != read_this) + err=ZIP_ERRNO; + + if (err==ZIP_OK) + err = add_data_in_datablock(&pziinit->central_dir,buf_read, (uLong)read_this); + + size_central_dir_to_read-=read_this; + } + TRYFREE(buf_read); + } + pziinit->begin_pos = byte_before_the_zipfile; + pziinit->number_entry = number_entry_CD; + + if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0) + err=ZIP_ERRNO; + + return err; +} + + +#endif /* !NO_ADDFILEINEXISTINGZIP*/ + + +/************************************************************/ +extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) +{ + zip64_internal ziinit; + zip64_internal* zi; + int err=ZIP_OK; + + ziinit.z_filefunc.zseek32_file = NULL; + ziinit.z_filefunc.ztell32_file = NULL; + if (pzlib_filefunc64_32_def==NULL) + fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); + else + ziinit.z_filefunc = *pzlib_filefunc64_32_def; + + ziinit.filestream = ZOPEN64(ziinit.z_filefunc, + pathname, + (append == APPEND_STATUS_CREATE) ? + (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : + (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); + + if (ziinit.filestream == NULL) + return NULL; + + if (append == APPEND_STATUS_CREATEAFTER) + ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END); + + ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream); + ziinit.in_opened_file_inzip = 0; + ziinit.ci.stream_initialised = 0; + ziinit.number_entry = 0; + ziinit.add_position_when_writing_offset = 0; + init_linkedlist(&(ziinit.central_dir)); + + + + zi = (zip64_internal*)ALLOC(sizeof(zip64_internal)); + if (zi==NULL) + { + ZCLOSE64(ziinit.z_filefunc,ziinit.filestream); + return NULL; + } + + /* now we add file in a zipfile */ +# ifndef NO_ADDFILEINEXISTINGZIP + ziinit.globalcomment = NULL; + if (append == APPEND_STATUS_ADDINZIP) + { + // Read and Cache Central Directory Records + err = LoadCentralDirectoryRecord(&ziinit); + } + + if (globalcomment) + { + *globalcomment = ziinit.globalcomment; + } +# endif /* !NO_ADDFILEINEXISTINGZIP*/ + + if (err != ZIP_OK) + { +# ifndef NO_ADDFILEINEXISTINGZIP + TRYFREE(ziinit.globalcomment); +# endif /* !NO_ADDFILEINEXISTINGZIP*/ + TRYFREE(zi); + return NULL; + } + else + { + *zi = ziinit; + return (zipFile)zi; + } +} + +extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) +{ + if (pzlib_filefunc32_def != NULL) + { + zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; + fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); + return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); + } + else + return zipOpen3(pathname, append, globalcomment, NULL); +} + +extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) +{ + if (pzlib_filefunc_def != NULL) + { + zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; + zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; + zlib_filefunc64_32_def_fill.ztell32_file = NULL; + zlib_filefunc64_32_def_fill.zseek32_file = NULL; + return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); + } + else + return zipOpen3(pathname, append, globalcomment, NULL); +} + + + +extern zipFile ZEXPORT zipOpen (const char* pathname, int append) +{ + return zipOpen3((const void*)pathname,append,NULL,NULL); +} + +extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) +{ + return zipOpen3(pathname,append,NULL,NULL); +} + +int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) +{ + /* write the local header */ + int err; + uInt size_filename = (uInt)strlen(filename); + uInt size_extrafield = size_extrafield_local; + + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC, 4); + + if (err==ZIP_OK) + { + if(zi->ci.zip64) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */ + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ + } + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); + + // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ + if (err==ZIP_OK) + { + if(zi->ci.zip64) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */ + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ + } + if (err==ZIP_OK) + { + if(zi->ci.zip64) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* uncompressed size, unknown */ + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ + } + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); + + if(zi->ci.zip64) + { + size_extrafield += 20; + } + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield,2); + + if ((err==ZIP_OK) && (size_filename > 0)) + { + if (ZWRITE64(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) + err = ZIP_ERRNO; + } + + if ((err==ZIP_OK) && (size_extrafield_local > 0)) + { + if (ZWRITE64(zi->z_filefunc, zi->filestream, extrafield_local, size_extrafield_local) != size_extrafield_local) + err = ZIP_ERRNO; + } + + + if ((err==ZIP_OK) && (zi->ci.zip64)) + { + // write the Zip64 extended info + short HeaderID = 1; + short DataSize = 16; + ZPOS64_T CompressedSize = 0; + ZPOS64_T UncompressedSize = 0; + + // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) + zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream); + + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2); + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2); + + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8); + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8); + } + + return err; +} + +/* + NOTE. + When writing RAW the ZIP64 extended information in extrafield_local and extrafield_global needs to be stripped + before calling this function it can be done with zipRemoveExtraInfoBlock + + It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize + unnecessary allocations. + */ +extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, + uLong versionMadeBy, uLong flagBase, int zip64) +{ + zip64_internal* zi; + uInt size_filename; + uInt size_comment; + uInt i; + int err = ZIP_OK; + +# ifdef NOCRYPT + (crcForCrypting); + if (password != NULL) + return ZIP_PARAMERROR; +# endif + + if (file == NULL) + return ZIP_PARAMERROR; + +#ifdef HAVE_BZIP2 + if ((method!=0) && (method!=Z_DEFLATED) && (method!=Z_BZIP2ED)) + return ZIP_PARAMERROR; +#else + if ((method!=0) && (method!=Z_DEFLATED)) + return ZIP_PARAMERROR; +#endif + + zi = (zip64_internal*)file; + + if (zi->in_opened_file_inzip == 1) + { + err = zipCloseFileInZip (file); + if (err != ZIP_OK) + return err; + } + + if (filename==NULL) + filename="-"; + + if (comment==NULL) + size_comment = 0; + else + size_comment = (uInt)strlen(comment); + + size_filename = (uInt)strlen(filename); + + if (zipfi == NULL) + zi->ci.dosDate = 0; + else + { + if (zipfi->dosDate != 0) + zi->ci.dosDate = zipfi->dosDate; + else + zi->ci.dosDate = zip64local_TmzDateToDosDate(&zipfi->tmz_date); + } + + zi->ci.flag = flagBase; + if ((level==8) || (level==9)) + zi->ci.flag |= 2; + if (level==2) + zi->ci.flag |= 4; + if (level==1) + zi->ci.flag |= 6; + if (password != NULL) + zi->ci.flag |= 1; + + zi->ci.crc32 = 0; + zi->ci.method = method; + zi->ci.encrypt = 0; + zi->ci.stream_initialised = 0; + zi->ci.pos_in_buffered_data = 0; + zi->ci.raw = raw; + zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream); + + zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment; + zi->ci.size_centralExtraFree = 32; // Extra space we have reserved in case we need to add ZIP64 extra info data + + zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree); + + zi->ci.size_centralExtra = size_extrafield_global; + zip64local_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); + /* version info */ + zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)versionMadeBy,2); + zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); + zip64local_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); + zip64local_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); + zip64local_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); + zip64local_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ + zip64local_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ + zip64local_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ + zip64local_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); + zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); + zip64local_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); + zip64local_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ + + if (zipfi==NULL) + zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); + else + zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); + + if (zipfi==NULL) + zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); + else + zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); + + if(zi->ci.pos_local_header >= 0xffffffff) + zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4); + else + zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writing_offset,4); + + for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); + + for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = + *(((const char*)extrafield_global)+i); + + for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ + size_extrafield_global+i) = *(comment+i); + if (zi->ci.central_header == NULL) + return ZIP_INTERNALERROR; + + zi->ci.zip64 = zip64; + zi->ci.totalCompressedData = 0; + zi->ci.totalUncompressedData = 0; + zi->ci.pos_zip64extrainfo = 0; + + err = Write_LocalFileHeader(zi, filename, size_extrafield_local, extrafield_local); + +#ifdef HAVE_BZIP2 + zi->ci.bstream.avail_in = (uInt)0; + zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; + zi->ci.bstream.total_in_hi32 = 0; + zi->ci.bstream.total_in_lo32 = 0; + zi->ci.bstream.total_out_hi32 = 0; + zi->ci.bstream.total_out_lo32 = 0; +#endif + + zi->ci.stream.avail_in = (uInt)0; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + zi->ci.stream.total_in = 0; + zi->ci.stream.total_out = 0; + zi->ci.stream.data_type = Z_BINARY; + +#ifdef HAVE_BZIP2 + if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED || zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) +#else + if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) +#endif + { + if(zi->ci.method == Z_DEFLATED) + { + zi->ci.stream.zalloc = (alloc_func)0; + zi->ci.stream.zfree = (free_func)0; + zi->ci.stream.opaque = (voidpf)0; + + if (windowBits>0) + windowBits = -windowBits; + + err = deflateInit2(&zi->ci.stream, level, Z_DEFLATED, windowBits, memLevel, strategy); + + if (err==Z_OK) + zi->ci.stream_initialised = Z_DEFLATED; + } + else if(zi->ci.method == Z_BZIP2ED) + { +#ifdef HAVE_BZIP2 + // Init BZip stuff here + zi->ci.bstream.bzalloc = 0; + zi->ci.bstream.bzfree = 0; + zi->ci.bstream.opaque = (voidpf)0; + + err = BZ2_bzCompressInit(&zi->ci.bstream, level, 0,35); + if(err == BZ_OK) + zi->ci.stream_initialised = Z_BZIP2ED; +#endif + } + + } + +# ifndef NOCRYPT + zi->ci.crypt_header_size = 0; + if ((err==Z_OK) && (password != NULL)) + { + unsigned char bufHead[RAND_HEAD_LEN]; + unsigned int sizeHead; + zi->ci.encrypt = 1; + zi->ci.pcrc_32_tab = get_crc_table(); + /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ + + sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); + zi->ci.crypt_header_size = sizeHead; + + if (ZWRITE64(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) + err = ZIP_ERRNO; + } +# endif + + if (err==Z_OK) + zi->in_opened_file_inzip = 1; + return err; +} + +extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, + uLong versionMadeBy, uLong flagBase) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, versionMadeBy, flagBase, 0); +} + +extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, VERSIONMADEBY, 0, 0); +} + +extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, int zip64) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, VERSIONMADEBY, 0, zip64); +} + +extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, 0); +} + +extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, int zip64) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, zip64); +} + +extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void*extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int zip64) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, zip64); +} + +extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void*extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, 0); +} + +local int zip64FlushWriteBuffer(zip64_internal* zi) +{ + int err=ZIP_OK; + + if (zi->ci.encrypt != 0) + { +#ifndef NOCRYPT + uInt i; + int t; + for (i=0;ici.pos_in_buffered_data;i++) + zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t); +#endif + } + + if (ZWRITE64(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) != zi->ci.pos_in_buffered_data) + err = ZIP_ERRNO; + + zi->ci.totalCompressedData += zi->ci.pos_in_buffered_data; + +#ifdef HAVE_BZIP2 + if(zi->ci.method == Z_BZIP2ED) + { + zi->ci.totalUncompressedData += zi->ci.bstream.total_in_lo32; + zi->ci.bstream.total_in_lo32 = 0; + zi->ci.bstream.total_in_hi32 = 0; + } + else +#endif + { + zi->ci.totalUncompressedData += zi->ci.stream.total_in; + zi->ci.stream.total_in = 0; + } + + + zi->ci.pos_in_buffered_data = 0; + + return err; +} + +extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) +{ + zip64_internal* zi; + int err=ZIP_OK; + + if (file == NULL) + return ZIP_PARAMERROR; + zi = (zip64_internal*)file; + + if (zi->in_opened_file_inzip == 0) + return ZIP_PARAMERROR; + + zi->ci.crc32 = crc32(zi->ci.crc32,buf,(uInt)len); + +#ifdef HAVE_BZIP2 + if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw)) + { + zi->ci.bstream.next_in = (void*)buf; + zi->ci.bstream.avail_in = len; + err = BZ_RUN_OK; + + while ((err==BZ_RUN_OK) && (zi->ci.bstream.avail_in>0)) + { + if (zi->ci.bstream.avail_out == 0) + { + if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; + } + + + if(err != BZ_RUN_OK) + break; + + if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) + { + uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32; +// uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; + err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN); + + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ; + } + } + + if(err == BZ_RUN_OK) + err = ZIP_OK; + } + else +#endif + { + zi->ci.stream.next_in = (Bytef*)buf; + zi->ci.stream.avail_in = len; + + while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) + { + if (zi->ci.stream.avail_out == 0) + { + if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + } + + + if(err != ZIP_OK) + break; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + uLong uTotalOutBefore = zi->ci.stream.total_out; + err=deflate(&zi->ci.stream, Z_NO_FLUSH); + if(uTotalOutBefore > zi->ci.stream.total_out) + { + int bBreak = 0; + bBreak++; + } + + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + } + else + { + uInt copy_this,i; + if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) + copy_this = zi->ci.stream.avail_in; + else + copy_this = zi->ci.stream.avail_out; + + for (i = 0; i < copy_this; i++) + *(((char*)zi->ci.stream.next_out)+i) = + *(((const char*)zi->ci.stream.next_in)+i); + { + zi->ci.stream.avail_in -= copy_this; + zi->ci.stream.avail_out-= copy_this; + zi->ci.stream.next_in+= copy_this; + zi->ci.stream.next_out+= copy_this; + zi->ci.stream.total_in+= copy_this; + zi->ci.stream.total_out+= copy_this; + zi->ci.pos_in_buffered_data += copy_this; + } + } + }// while(...) + } + + return err; +} + +extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) +{ + return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); +} + +extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) +{ + zip64_internal* zi; + ZPOS64_T compressed_size; + uLong invalidValue = 0xffffffff; + short datasize = 0; + int err=ZIP_OK; + + if (file == NULL) + return ZIP_PARAMERROR; + zi = (zip64_internal*)file; + + if (zi->in_opened_file_inzip == 0) + return ZIP_PARAMERROR; + zi->ci.stream.avail_in = 0; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + while (err==ZIP_OK) + { + uLong uTotalOutBefore; + if (zi->ci.stream.avail_out == 0) + { + if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + } + uTotalOutBefore = zi->ci.stream.total_out; + err=deflate(&zi->ci.stream, Z_FINISH); + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + } + } + else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) + { +#ifdef HAVE_BZIP2 + err = BZ_FINISH_OK; + while (err==BZ_FINISH_OK) + { + uLong uTotalOutBefore; + if (zi->ci.bstream.avail_out == 0) + { + if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; + } + uTotalOutBefore = zi->ci.bstream.total_out_lo32; + err=BZ2_bzCompress(&zi->ci.bstream, BZ_FINISH); + if(err == BZ_STREAM_END) + err = Z_STREAM_END; + + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore); + } + + if(err == BZ_FINISH_OK) + err = ZIP_OK; +#endif + } + + if (err==Z_STREAM_END) + err=ZIP_OK; /* this is normal */ + + if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) + { + if (zip64FlushWriteBuffer(zi)==ZIP_ERRNO) + err = ZIP_ERRNO; + } + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + int tmp_err = deflateEnd(&zi->ci.stream); + if (err == ZIP_OK) + err = tmp_err; + zi->ci.stream_initialised = 0; + } +#ifdef HAVE_BZIP2 + else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) + { + int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream); + if (err==ZIP_OK) + err = tmperr; + zi->ci.stream_initialised = 0; + } +#endif + + if (!zi->ci.raw) + { + crc32 = (uLong)zi->ci.crc32; + uncompressed_size = zi->ci.totalUncompressedData; + } + compressed_size = zi->ci.totalCompressedData; + +# ifndef NOCRYPT + compressed_size += zi->ci.crypt_header_size; +# endif + + // update Current Item crc and sizes, + if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff) + { + /*version Made by*/ + zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2); + /*version needed*/ + zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)45,2); + + } + + zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ + + + if(compressed_size >= 0xffffffff) + zip64local_putValue_inmemory(zi->ci.central_header+20, invalidValue,4); /*compr size*/ + else + zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/ + + /// set internal file attributes field + if (zi->ci.stream.data_type == Z_ASCII) + zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); + + if(uncompressed_size >= 0xffffffff) + zip64local_putValue_inmemory(zi->ci.central_header+24, invalidValue,4); /*uncompr size*/ + else + zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/ + + // Add ZIP64 extra info field for uncompressed size + if(uncompressed_size >= 0xffffffff) + datasize += 8; + + // Add ZIP64 extra info field for compressed size + if(compressed_size >= 0xffffffff) + datasize += 8; + + // Add ZIP64 extra info field for relative offset to local file header of current file + if(zi->ci.pos_local_header >= 0xffffffff) + datasize += 8; + + if(datasize > 0) + { + char* p = NULL; + + if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree) + { + // we can not write more data to the buffer that we have room for. + return ZIP_BADZIPFILE; + } + + p = zi->ci.central_header + zi->ci.size_centralheader; + + // Add Extra Information Header for 'ZIP64 information' + zip64local_putValue_inmemory(p, 0x0001, 2); // HeaderID + p += 2; + zip64local_putValue_inmemory(p, datasize, 2); // DataSize + p += 2; + + if(uncompressed_size >= 0xffffffff) + { + zip64local_putValue_inmemory(p, uncompressed_size, 8); + p += 8; + } + + if(compressed_size >= 0xffffffff) + { + zip64local_putValue_inmemory(p, compressed_size, 8); + p += 8; + } + + if(zi->ci.pos_local_header >= 0xffffffff) + { + zip64local_putValue_inmemory(p, zi->ci.pos_local_header, 8); + p += 8; + } + + // Update how much extra free space we got in the memory buffer + // and increase the centralheader size so the new ZIP64 fields are included + // ( 4 below is the size of HeaderID and DataSize field ) + zi->ci.size_centralExtraFree -= datasize + 4; + zi->ci.size_centralheader += datasize + 4; + + // Update the extra info size field + zi->ci.size_centralExtra += datasize + 4; + zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2); + } + + if (err==ZIP_OK) + err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader); + + free(zi->ci.central_header); + + if (err==ZIP_OK) + { + // Update the LocalFileHeader with the new values. + + ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); + + if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) + err = ZIP_ERRNO; + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ + + if(uncompressed_size >= 0xffffffff || compressed_size >= 0xffffffff ) + { + if(zi->ci.pos_zip64extrainfo > 0) + { + // Update the size in the ZIP64 extended field. + if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0) + err = ZIP_ERRNO; + + if (err==ZIP_OK) /* compressed size, unknown */ + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, uncompressed_size, 8); + + if (err==ZIP_OK) /* uncompressed size, unknown */ + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8); + } + else + err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for zip64 info -> fatal + } + else + { + if (err==ZIP_OK) /* compressed size, unknown */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); + + if (err==ZIP_OK) /* uncompressed size, unknown */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); + } + + if (ZSEEK64(zi->z_filefunc,zi->filestream, cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) + err = ZIP_ERRNO; + } + + zi->number_entry ++; + zi->in_opened_file_inzip = 0; + + return err; +} + +extern int ZEXPORT zipCloseFileInZip (zipFile file) +{ + return zipCloseFileInZipRaw (file,0,0); +} + +int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) +{ + int err = ZIP_OK; + ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; + + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); + + /*num disks*/ + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); + + /*relative offset*/ + if (err==ZIP_OK) /* Relative offset to the Zip64EndOfCentralDirectory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, pos,8); + + /*total disks*/ /* Do not support spawning of disk so always say 1 here*/ + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)1,4); + + return err; +} + +int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) +{ + int err = ZIP_OK; + + uLong Zip64DataSize = 44; + + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); + + if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); // why ZPOS64_T of this ? + + if (err==ZIP_OK) /* version made by */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); + + if (err==ZIP_OK) /* version needed */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); + + if (err==ZIP_OK) /* number of this disk */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); + + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); + + if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8); + + if (err==ZIP_OK) /* total number of entries in the central dir */ + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8); + + if (err==ZIP_OK) /* size of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)size_centraldir,8); + + if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ + { + ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); + } + return err; +} +int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) +{ + int err = ZIP_OK; + + /*signature*/ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); + + if (err==ZIP_OK) /* number of this disk */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + + if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ + { + { + if(zi->number_entry >= 0xFFFF) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + } + } + + if (err==ZIP_OK) /* total number of entries in the central dir */ + { + if(zi->number_entry >= 0xFFFF) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + } + + if (err==ZIP_OK) /* size of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); + + if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ + { + ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; + if(pos >= 0xffffffff) + { + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4); + } + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writing_offset),4); + } + + return err; +} + +int Write_GlobalComment(zip64_internal* zi, const char* global_comment) +{ + int err = ZIP_OK; + uInt size_global_comment = 0; + + if(global_comment != NULL) + size_global_comment = (uInt)strlen(global_comment); + + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); + + if (err == ZIP_OK && size_global_comment > 0) + { + if (ZWRITE64(zi->z_filefunc,zi->filestream, global_comment, size_global_comment) != size_global_comment) + err = ZIP_ERRNO; + } + return err; +} + +extern int ZEXPORT zipClose (zipFile file, const char* global_comment) +{ + zip64_internal* zi; + int err = 0; + uLong size_centraldir = 0; + ZPOS64_T centraldir_pos_inzip; + ZPOS64_T pos; + + if (file == NULL) + return ZIP_PARAMERROR; + + zi = (zip64_internal*)file; + + if (zi->in_opened_file_inzip == 1) + { + err = zipCloseFileInZip (file); + } + +#ifndef NO_ADDFILEINEXISTINGZIP + if (global_comment==NULL) + global_comment = zi->globalcomment; +#endif + + centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); + + if (err==ZIP_OK) + { + linkedlist_datablock_internal* ldi = zi->central_dir.first_block; + while (ldi!=NULL) + { + if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) + { + if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->filled_in_this_block) != ldi->filled_in_this_block) + err = ZIP_ERRNO; + } + + size_centraldir += ldi->filled_in_this_block; + ldi = ldi->next_datablock; + } + } + free_linkedlist(&(zi->central_dir)); + + pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; + if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) + { + ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); + Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); + + Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos); + } + + if (err==ZIP_OK) + err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); + + if(err == ZIP_OK) + err = Write_GlobalComment(zi, global_comment); + + if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0) + if (err == ZIP_OK) + err = ZIP_ERRNO; + +#ifndef NO_ADDFILEINEXISTINGZIP + TRYFREE(zi->globalcomment); +#endif + TRYFREE(zi); + + return err; +} + +extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) +{ + char* p = pData; + int size = 0; + char* pNewHeader; + char* pTmp; + short header; + short dataSize; + + int retVal = ZIP_OK; + + if(pData == NULL || *dataLen < 4) + return ZIP_PARAMERROR; + + pNewHeader = (char*)ALLOC(*dataLen); + pTmp = pNewHeader; + + while(p < (pData + *dataLen)) + { + header = *(short*)p; + dataSize = *(((short*)p)+1); + + if( header == sHeader ) // Header found. + { + p += dataSize + 4; // skip it. do not copy to temp buffer + } + else + { + // Extra Info block should not be removed, So copy it to the temp buffer. + memcpy(pTmp, p, dataSize + 4); + p += dataSize + 4; + size += dataSize + 4; + } + + } + + if(size < *dataLen) + { + // clean old extra info block. + memset(pData,0, *dataLen); + + // copy the new extra info block over the old + if(size > 0) + memcpy(pData, pNewHeader, size); + + // set the new extra info size + *dataLen = size; + + retVal = ZIP_OK; + } + else + retVal = ZIP_ERRNO; + + TRYFREE(pNewHeader); + + return retVal; +} diff --git a/xs/src/png/zlib/contrib/minizip/zip.h b/xs/src/png/zlib/contrib/minizip/zip.h new file mode 100644 index 0000000000..8aaebb6234 --- /dev/null +++ b/xs/src/png/zlib/contrib/minizip/zip.h @@ -0,0 +1,362 @@ +/* zip.h -- IO on .zip files using zlib + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) + + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + + --------------------------------------------------------------------------- + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + --------------------------------------------------------------------------- + + Changes + + See header of zip.h + +*/ + +#ifndef _zip12_H +#define _zip12_H + +#ifdef __cplusplus +extern "C" { +#endif + +//#define HAVE_BZIP2 + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#ifndef _ZLIBIOAPI_H +#include "ioapi.h" +#endif + +#ifdef HAVE_BZIP2 +#include "bzlib.h" +#endif + +#define Z_BZIP2ED 12 + +#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagzipFile__ { int unused; } zipFile__; +typedef zipFile__ *zipFile; +#else +typedef voidp zipFile; +#endif + +#define ZIP_OK (0) +#define ZIP_EOF (0) +#define ZIP_ERRNO (Z_ERRNO) +#define ZIP_PARAMERROR (-102) +#define ZIP_BADZIPFILE (-103) +#define ZIP_INTERNALERROR (-104) + +#ifndef DEF_MEM_LEVEL +# if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +# else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +# endif +#endif +/* default memLevel */ + +/* tm_zip contain date/time info */ +typedef struct tm_zip_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_zip; + +typedef struct +{ + tm_zip tmz_date; /* date in understandable format */ + uLong dosDate; /* if dos_date == 0, tmu_date is used */ +/* uLong flag; */ /* general purpose bit flag 2 bytes */ + + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ +} zip_fileinfo; + +typedef const char* zipcharpc; + + +#define APPEND_STATUS_CREATE (0) +#define APPEND_STATUS_CREATEAFTER (1) +#define APPEND_STATUS_ADDINZIP (2) + +extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); +extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); +/* + Create a zipfile. + pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on + an Unix computer "zlib/zlib113.zip". + if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip + will be created at the end of the file. + (useful if the file contain a self extractor code) + if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will + add files in existing zip (be sure you don't add file that doesn't exist) + If the zipfile cannot be opened, the return value is NULL. + Else, the return value is a zipFile Handle, usable with other function + of this zip package. +*/ + +/* Note : there is no delete function into a zipfile. + If you want delete file into a zipfile, you must open a zipfile, and create another + Of couse, you can use RAW reading and writing to copy the file you did not want delte +*/ + +extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc_def* pzlib_filefunc_def)); + +extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc64_def* pzlib_filefunc_def)); + +extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level)); + +extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int zip64)); + +/* + Open a file in the ZIP for writing. + filename : the filename in zip (if NULL, '-' without quote will be used + *zipfi contain supplemental information + if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local + contains the extrafield data the the local header + if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global + contains the extrafield data the the local header + if comment != NULL, comment contain the comment string + method contain the compression method (0 for store, Z_DEFLATED for deflate) + level contain the level of compression (can be Z_DEFAULT_COMPRESSION) + zip64 is set to 1 if a zip64 extended information block should be added to the local file header. + this MUST be '1' if the uncompressed size is >= 0xffffffff. + +*/ + + +extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw)); + + +extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int zip64)); +/* + Same than zipOpenNewFileInZip, except if raw=1, we write raw file + */ + +extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting)); + +extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + int zip64 + )); + +/* + Same than zipOpenNewFileInZip2, except + windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 + password : crypting password (NULL for no crypting) + crcForCrypting : crc of file to compress (needed for crypting) + */ + +extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + uLong versionMadeBy, + uLong flagBase + )); + + +extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + uLong versionMadeBy, + uLong flagBase, + int zip64 + )); +/* + Same than zipOpenNewFileInZip4, except + versionMadeBy : value for Version made by field + flag : value for flag field (compression level info will be added) + */ + + +extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, + const void* buf, + unsigned len)); +/* + Write data in the zipfile +*/ + +extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); +/* + Close the current file in the zipfile +*/ + +extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, + uLong uncompressed_size, + uLong crc32)); + +extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, + ZPOS64_T uncompressed_size, + uLong crc32)); + +/* + Close the current file in the zipfile, for file opened with + parameter raw=1 in zipOpenNewFileInZip2 + uncompressed_size and crc32 are value for the uncompressed size +*/ + +extern int ZEXPORT zipClose OF((zipFile file, + const char* global_comment)); +/* + Close the zipfile +*/ + + +extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); +/* + zipRemoveExtraInfoBlock - Added by Mathias Svensson + + Remove extra information block from a extra information data for the local file header or central directory header + + It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode. + + 0x0001 is the signature header for the ZIP64 extra information blocks + + usage. + Remove ZIP64 Extra information from a central director extra field data + zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001); + + Remove ZIP64 Extra information from a Local File Header extra field data + zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001); +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _zip64_H */ diff --git a/xs/src/png/zlib/contrib/pascal/example.pas b/xs/src/png/zlib/contrib/pascal/example.pas new file mode 100644 index 0000000000..5518b36a73 --- /dev/null +++ b/xs/src/png/zlib/contrib/pascal/example.pas @@ -0,0 +1,599 @@ +(* example.c -- usage example of the zlib compression library + * Copyright (C) 1995-2003 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Pascal translation + * Copyright (C) 1998 by Jacques Nomssi Nzali. + * For conditions of distribution and use, see copyright notice in readme.txt + * + * Adaptation to the zlibpas interface + * Copyright (C) 2003 by Cosmin Truta. + * For conditions of distribution and use, see copyright notice in readme.txt + *) + +program example; + +{$DEFINE TEST_COMPRESS} +{DO NOT $DEFINE TEST_GZIO} +{$DEFINE TEST_DEFLATE} +{$DEFINE TEST_INFLATE} +{$DEFINE TEST_FLUSH} +{$DEFINE TEST_SYNC} +{$DEFINE TEST_DICT} + +uses SysUtils, zlibpas; + +const TESTFILE = 'foo.gz'; + +(* "hello world" would be more standard, but the repeated "hello" + * stresses the compression code better, sorry... + *) +const hello: PChar = 'hello, hello!'; + +const dictionary: PChar = 'hello'; + +var dictId: LongInt; (* Adler32 value of the dictionary *) + +procedure CHECK_ERR(err: Integer; msg: String); +begin + if err <> Z_OK then + begin + WriteLn(msg, ' error: ', err); + Halt(1); + end; +end; + +procedure EXIT_ERR(const msg: String); +begin + WriteLn('Error: ', msg); + Halt(1); +end; + +(* =========================================================================== + * Test compress and uncompress + *) +{$IFDEF TEST_COMPRESS} +procedure test_compress(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen: LongInt); +var err: Integer; + len: LongInt; +begin + len := StrLen(hello)+1; + + err := compress(compr, comprLen, hello, len); + CHECK_ERR(err, 'compress'); + + StrCopy(PChar(uncompr), 'garbage'); + + err := uncompress(uncompr, uncomprLen, compr, comprLen); + CHECK_ERR(err, 'uncompress'); + + if StrComp(PChar(uncompr), hello) <> 0 then + EXIT_ERR('bad uncompress') + else + WriteLn('uncompress(): ', PChar(uncompr)); +end; +{$ENDIF} + +(* =========================================================================== + * Test read/write of .gz files + *) +{$IFDEF TEST_GZIO} +procedure test_gzio(const fname: PChar; (* compressed file name *) + uncompr: Pointer; + uncomprLen: LongInt); +var err: Integer; + len: Integer; + zfile: gzFile; + pos: LongInt; +begin + len := StrLen(hello)+1; + + zfile := gzopen(fname, 'wb'); + if zfile = NIL then + begin + WriteLn('gzopen error'); + Halt(1); + end; + gzputc(zfile, 'h'); + if gzputs(zfile, 'ello') <> 4 then + begin + WriteLn('gzputs err: ', gzerror(zfile, err)); + Halt(1); + end; + {$IFDEF GZ_FORMAT_STRING} + if gzprintf(zfile, ', %s!', 'hello') <> 8 then + begin + WriteLn('gzprintf err: ', gzerror(zfile, err)); + Halt(1); + end; + {$ELSE} + if gzputs(zfile, ', hello!') <> 8 then + begin + WriteLn('gzputs err: ', gzerror(zfile, err)); + Halt(1); + end; + {$ENDIF} + gzseek(zfile, 1, SEEK_CUR); (* add one zero byte *) + gzclose(zfile); + + zfile := gzopen(fname, 'rb'); + if zfile = NIL then + begin + WriteLn('gzopen error'); + Halt(1); + end; + + StrCopy(PChar(uncompr), 'garbage'); + + if gzread(zfile, uncompr, uncomprLen) <> len then + begin + WriteLn('gzread err: ', gzerror(zfile, err)); + Halt(1); + end; + if StrComp(PChar(uncompr), hello) <> 0 then + begin + WriteLn('bad gzread: ', PChar(uncompr)); + Halt(1); + end + else + WriteLn('gzread(): ', PChar(uncompr)); + + pos := gzseek(zfile, -8, SEEK_CUR); + if (pos <> 6) or (gztell(zfile) <> pos) then + begin + WriteLn('gzseek error, pos=', pos, ', gztell=', gztell(zfile)); + Halt(1); + end; + + if gzgetc(zfile) <> ' ' then + begin + WriteLn('gzgetc error'); + Halt(1); + end; + + if gzungetc(' ', zfile) <> ' ' then + begin + WriteLn('gzungetc error'); + Halt(1); + end; + + gzgets(zfile, PChar(uncompr), uncomprLen); + uncomprLen := StrLen(PChar(uncompr)); + if uncomprLen <> 7 then (* " hello!" *) + begin + WriteLn('gzgets err after gzseek: ', gzerror(zfile, err)); + Halt(1); + end; + if StrComp(PChar(uncompr), hello + 6) <> 0 then + begin + WriteLn('bad gzgets after gzseek'); + Halt(1); + end + else + WriteLn('gzgets() after gzseek: ', PChar(uncompr)); + + gzclose(zfile); +end; +{$ENDIF} + +(* =========================================================================== + * Test deflate with small buffers + *) +{$IFDEF TEST_DEFLATE} +procedure test_deflate(compr: Pointer; comprLen: LongInt); +var c_stream: z_stream; (* compression stream *) + err: Integer; + len: LongInt; +begin + len := StrLen(hello)+1; + + c_stream.zalloc := NIL; + c_stream.zfree := NIL; + c_stream.opaque := NIL; + + err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, 'deflateInit'); + + c_stream.next_in := hello; + c_stream.next_out := compr; + + while (c_stream.total_in <> len) and + (c_stream.total_out < comprLen) do + begin + c_stream.avail_out := 1; { force small buffers } + c_stream.avail_in := 1; + err := deflate(c_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'deflate'); + end; + + (* Finish the stream, still forcing small buffers: *) + while TRUE do + begin + c_stream.avail_out := 1; + err := deflate(c_stream, Z_FINISH); + if err = Z_STREAM_END then + break; + CHECK_ERR(err, 'deflate'); + end; + + err := deflateEnd(c_stream); + CHECK_ERR(err, 'deflateEnd'); +end; +{$ENDIF} + +(* =========================================================================== + * Test inflate with small buffers + *) +{$IFDEF TEST_INFLATE} +procedure test_inflate(compr: Pointer; comprLen : LongInt; + uncompr: Pointer; uncomprLen : LongInt); +var err: Integer; + d_stream: z_stream; (* decompression stream *) +begin + StrCopy(PChar(uncompr), 'garbage'); + + d_stream.zalloc := NIL; + d_stream.zfree := NIL; + d_stream.opaque := NIL; + + d_stream.next_in := compr; + d_stream.avail_in := 0; + d_stream.next_out := uncompr; + + err := inflateInit(d_stream); + CHECK_ERR(err, 'inflateInit'); + + while (d_stream.total_out < uncomprLen) and + (d_stream.total_in < comprLen) do + begin + d_stream.avail_out := 1; (* force small buffers *) + d_stream.avail_in := 1; + err := inflate(d_stream, Z_NO_FLUSH); + if err = Z_STREAM_END then + break; + CHECK_ERR(err, 'inflate'); + end; + + err := inflateEnd(d_stream); + CHECK_ERR(err, 'inflateEnd'); + + if StrComp(PChar(uncompr), hello) <> 0 then + EXIT_ERR('bad inflate') + else + WriteLn('inflate(): ', PChar(uncompr)); +end; +{$ENDIF} + +(* =========================================================================== + * Test deflate with large buffers and dynamic change of compression level + *) +{$IFDEF TEST_DEFLATE} +procedure test_large_deflate(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen: LongInt); +var c_stream: z_stream; (* compression stream *) + err: Integer; +begin + c_stream.zalloc := NIL; + c_stream.zfree := NIL; + c_stream.opaque := NIL; + + err := deflateInit(c_stream, Z_BEST_SPEED); + CHECK_ERR(err, 'deflateInit'); + + c_stream.next_out := compr; + c_stream.avail_out := Integer(comprLen); + + (* At this point, uncompr is still mostly zeroes, so it should compress + * very well: + *) + c_stream.next_in := uncompr; + c_stream.avail_in := Integer(uncomprLen); + err := deflate(c_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'deflate'); + if c_stream.avail_in <> 0 then + EXIT_ERR('deflate not greedy'); + + (* Feed in already compressed data and switch to no compression: *) + deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); + c_stream.next_in := compr; + c_stream.avail_in := Integer(comprLen div 2); + err := deflate(c_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'deflate'); + + (* Switch back to compressing mode: *) + deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED); + c_stream.next_in := uncompr; + c_stream.avail_in := Integer(uncomprLen); + err := deflate(c_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'deflate'); + + err := deflate(c_stream, Z_FINISH); + if err <> Z_STREAM_END then + EXIT_ERR('deflate should report Z_STREAM_END'); + + err := deflateEnd(c_stream); + CHECK_ERR(err, 'deflateEnd'); +end; +{$ENDIF} + +(* =========================================================================== + * Test inflate with large buffers + *) +{$IFDEF TEST_INFLATE} +procedure test_large_inflate(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen: LongInt); +var err: Integer; + d_stream: z_stream; (* decompression stream *) +begin + StrCopy(PChar(uncompr), 'garbage'); + + d_stream.zalloc := NIL; + d_stream.zfree := NIL; + d_stream.opaque := NIL; + + d_stream.next_in := compr; + d_stream.avail_in := Integer(comprLen); + + err := inflateInit(d_stream); + CHECK_ERR(err, 'inflateInit'); + + while TRUE do + begin + d_stream.next_out := uncompr; (* discard the output *) + d_stream.avail_out := Integer(uncomprLen); + err := inflate(d_stream, Z_NO_FLUSH); + if err = Z_STREAM_END then + break; + CHECK_ERR(err, 'large inflate'); + end; + + err := inflateEnd(d_stream); + CHECK_ERR(err, 'inflateEnd'); + + if d_stream.total_out <> 2 * uncomprLen + comprLen div 2 then + begin + WriteLn('bad large inflate: ', d_stream.total_out); + Halt(1); + end + else + WriteLn('large_inflate(): OK'); +end; +{$ENDIF} + +(* =========================================================================== + * Test deflate with full flush + *) +{$IFDEF TEST_FLUSH} +procedure test_flush(compr: Pointer; var comprLen : LongInt); +var c_stream: z_stream; (* compression stream *) + err: Integer; + len: Integer; +begin + len := StrLen(hello)+1; + + c_stream.zalloc := NIL; + c_stream.zfree := NIL; + c_stream.opaque := NIL; + + err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, 'deflateInit'); + + c_stream.next_in := hello; + c_stream.next_out := compr; + c_stream.avail_in := 3; + c_stream.avail_out := Integer(comprLen); + err := deflate(c_stream, Z_FULL_FLUSH); + CHECK_ERR(err, 'deflate'); + + Inc(PByteArray(compr)^[3]); (* force an error in first compressed block *) + c_stream.avail_in := len - 3; + + err := deflate(c_stream, Z_FINISH); + if err <> Z_STREAM_END then + CHECK_ERR(err, 'deflate'); + + err := deflateEnd(c_stream); + CHECK_ERR(err, 'deflateEnd'); + + comprLen := c_stream.total_out; +end; +{$ENDIF} + +(* =========================================================================== + * Test inflateSync() + *) +{$IFDEF TEST_SYNC} +procedure test_sync(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen : LongInt); +var err: Integer; + d_stream: z_stream; (* decompression stream *) +begin + StrCopy(PChar(uncompr), 'garbage'); + + d_stream.zalloc := NIL; + d_stream.zfree := NIL; + d_stream.opaque := NIL; + + d_stream.next_in := compr; + d_stream.avail_in := 2; (* just read the zlib header *) + + err := inflateInit(d_stream); + CHECK_ERR(err, 'inflateInit'); + + d_stream.next_out := uncompr; + d_stream.avail_out := Integer(uncomprLen); + + inflate(d_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'inflate'); + + d_stream.avail_in := Integer(comprLen-2); (* read all compressed data *) + err := inflateSync(d_stream); (* but skip the damaged part *) + CHECK_ERR(err, 'inflateSync'); + + err := inflate(d_stream, Z_FINISH); + if err <> Z_DATA_ERROR then + EXIT_ERR('inflate should report DATA_ERROR'); + (* Because of incorrect adler32 *) + + err := inflateEnd(d_stream); + CHECK_ERR(err, 'inflateEnd'); + + WriteLn('after inflateSync(): hel', PChar(uncompr)); +end; +{$ENDIF} + +(* =========================================================================== + * Test deflate with preset dictionary + *) +{$IFDEF TEST_DICT} +procedure test_dict_deflate(compr: Pointer; comprLen: LongInt); +var c_stream: z_stream; (* compression stream *) + err: Integer; +begin + c_stream.zalloc := NIL; + c_stream.zfree := NIL; + c_stream.opaque := NIL; + + err := deflateInit(c_stream, Z_BEST_COMPRESSION); + CHECK_ERR(err, 'deflateInit'); + + err := deflateSetDictionary(c_stream, dictionary, StrLen(dictionary)); + CHECK_ERR(err, 'deflateSetDictionary'); + + dictId := c_stream.adler; + c_stream.next_out := compr; + c_stream.avail_out := Integer(comprLen); + + c_stream.next_in := hello; + c_stream.avail_in := StrLen(hello)+1; + + err := deflate(c_stream, Z_FINISH); + if err <> Z_STREAM_END then + EXIT_ERR('deflate should report Z_STREAM_END'); + + err := deflateEnd(c_stream); + CHECK_ERR(err, 'deflateEnd'); +end; +{$ENDIF} + +(* =========================================================================== + * Test inflate with a preset dictionary + *) +{$IFDEF TEST_DICT} +procedure test_dict_inflate(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen: LongInt); +var err: Integer; + d_stream: z_stream; (* decompression stream *) +begin + StrCopy(PChar(uncompr), 'garbage'); + + d_stream.zalloc := NIL; + d_stream.zfree := NIL; + d_stream.opaque := NIL; + + d_stream.next_in := compr; + d_stream.avail_in := Integer(comprLen); + + err := inflateInit(d_stream); + CHECK_ERR(err, 'inflateInit'); + + d_stream.next_out := uncompr; + d_stream.avail_out := Integer(uncomprLen); + + while TRUE do + begin + err := inflate(d_stream, Z_NO_FLUSH); + if err = Z_STREAM_END then + break; + if err = Z_NEED_DICT then + begin + if d_stream.adler <> dictId then + EXIT_ERR('unexpected dictionary'); + err := inflateSetDictionary(d_stream, dictionary, StrLen(dictionary)); + end; + CHECK_ERR(err, 'inflate with dict'); + end; + + err := inflateEnd(d_stream); + CHECK_ERR(err, 'inflateEnd'); + + if StrComp(PChar(uncompr), hello) <> 0 then + EXIT_ERR('bad inflate with dict') + else + WriteLn('inflate with dictionary: ', PChar(uncompr)); +end; +{$ENDIF} + +var compr, uncompr: Pointer; + comprLen, uncomprLen: LongInt; + +begin + if zlibVersion^ <> ZLIB_VERSION[1] then + EXIT_ERR('Incompatible zlib version'); + + WriteLn('zlib version: ', zlibVersion); + WriteLn('zlib compile flags: ', Format('0x%x', [zlibCompileFlags])); + + comprLen := 10000 * SizeOf(Integer); (* don't overflow on MSDOS *) + uncomprLen := comprLen; + GetMem(compr, comprLen); + GetMem(uncompr, uncomprLen); + if (compr = NIL) or (uncompr = NIL) then + EXIT_ERR('Out of memory'); + (* compr and uncompr are cleared to avoid reading uninitialized + * data and to ensure that uncompr compresses well. + *) + FillChar(compr^, comprLen, 0); + FillChar(uncompr^, uncomprLen, 0); + + {$IFDEF TEST_COMPRESS} + WriteLn('** Testing compress'); + test_compress(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + + {$IFDEF TEST_GZIO} + WriteLn('** Testing gzio'); + if ParamCount >= 1 then + test_gzio(ParamStr(1), uncompr, uncomprLen) + else + test_gzio(TESTFILE, uncompr, uncomprLen); + {$ENDIF} + + {$IFDEF TEST_DEFLATE} + WriteLn('** Testing deflate with small buffers'); + test_deflate(compr, comprLen); + {$ENDIF} + {$IFDEF TEST_INFLATE} + WriteLn('** Testing inflate with small buffers'); + test_inflate(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + + {$IFDEF TEST_DEFLATE} + WriteLn('** Testing deflate with large buffers'); + test_large_deflate(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + {$IFDEF TEST_INFLATE} + WriteLn('** Testing inflate with large buffers'); + test_large_inflate(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + + {$IFDEF TEST_FLUSH} + WriteLn('** Testing deflate with full flush'); + test_flush(compr, comprLen); + {$ENDIF} + {$IFDEF TEST_SYNC} + WriteLn('** Testing inflateSync'); + test_sync(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + comprLen := uncomprLen; + + {$IFDEF TEST_DICT} + WriteLn('** Testing deflate and inflate with preset dictionary'); + test_dict_deflate(compr, comprLen); + test_dict_inflate(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + + FreeMem(compr, comprLen); + FreeMem(uncompr, uncomprLen); +end. diff --git a/xs/src/png/zlib/contrib/pascal/readme.txt b/xs/src/png/zlib/contrib/pascal/readme.txt new file mode 100644 index 0000000000..60e87c8a33 --- /dev/null +++ b/xs/src/png/zlib/contrib/pascal/readme.txt @@ -0,0 +1,76 @@ + +This directory contains a Pascal (Delphi, Kylix) interface to the +zlib data compression library. + + +Directory listing +================= + +zlibd32.mak makefile for Borland C++ +example.pas usage example of zlib +zlibpas.pas the Pascal interface to zlib +readme.txt this file + + +Compatibility notes +=================== + +- Although the name "zlib" would have been more normal for the + zlibpas unit, this name is already taken by Borland's ZLib unit. + This is somehow unfortunate, because that unit is not a genuine + interface to the full-fledged zlib functionality, but a suite of + class wrappers around zlib streams. Other essential features, + such as checksums, are missing. + It would have been more appropriate for that unit to have a name + like "ZStreams", or something similar. + +- The C and zlib-supplied types int, uInt, long, uLong, etc. are + translated directly into Pascal types of similar sizes (Integer, + LongInt, etc.), to avoid namespace pollution. In particular, + there is no conversion of unsigned int into a Pascal unsigned + integer. The Word type is non-portable and has the same size + (16 bits) both in a 16-bit and in a 32-bit environment, unlike + Integer. Even if there is a 32-bit Cardinal type, there is no + real need for unsigned int in zlib under a 32-bit environment. + +- Except for the callbacks, the zlib function interfaces are + assuming the calling convention normally used in Pascal + (__pascal for DOS and Windows16, __fastcall for Windows32). + Since the cdecl keyword is used, the old Turbo Pascal does + not work with this interface. + +- The gz* function interfaces are not translated, to avoid + interfacing problems with the C runtime library. Besides, + gzprintf(gzFile file, const char *format, ...) + cannot be translated into Pascal. + + +Legal issues +============ + +The zlibpas interface is: + Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler. + Copyright (C) 1998 by Bob Dellaca. + Copyright (C) 2003 by Cosmin Truta. + +The example program is: + Copyright (C) 1995-2003 by Jean-loup Gailly. + Copyright (C) 1998,1999,2000 by Jacques Nomssi Nzali. + Copyright (C) 2003 by Cosmin Truta. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + diff --git a/xs/src/png/zlib/contrib/pascal/zlibd32.mak b/xs/src/png/zlib/contrib/pascal/zlibd32.mak new file mode 100644 index 0000000000..9bb00b7cc4 --- /dev/null +++ b/xs/src/png/zlib/contrib/pascal/zlibd32.mak @@ -0,0 +1,99 @@ +# Makefile for zlib +# For use with Delphi and C++ Builder under Win32 +# Updated for zlib 1.2.x by Cosmin Truta + +# ------------ Borland C++ ------------ + +# This project uses the Delphi (fastcall/register) calling convention: +LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl + +CC = bcc32 +LD = bcc32 +AR = tlib +# do not use "-pr" in CFLAGS +CFLAGS = -a -d -k- -O2 $(LOC) +LDFLAGS = + + +# variables +ZLIB_LIB = zlib.lib + +OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj +OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj +OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj +OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj + + +# targets +all: $(ZLIB_LIB) example.exe minigzip.exe + +.c.obj: + $(CC) -c $(CFLAGS) $*.c + +adler32.obj: adler32.c zlib.h zconf.h + +compress.obj: compress.c zlib.h zconf.h + +crc32.obj: crc32.c zlib.h zconf.h crc32.h + +deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + +gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h + +gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h + +gzread.obj: gzread.c zlib.h zconf.h gzguts.h + +gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h + +infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + +inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + +trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + +uncompr.obj: uncompr.c zlib.h zconf.h + +zutil.obj: zutil.c zutil.h zlib.h zconf.h + +example.obj: test/example.c zlib.h zconf.h + +minigzip.obj: test/minigzip.c zlib.h zconf.h + + +# For the sake of the old Borland make, +# the command line is cut to fit in the MS-DOS 128 byte limit: +$(ZLIB_LIB): $(OBJ1) $(OBJ2) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + + +# testing +test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + +example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + +minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + + +# cleanup +clean: + -del *.obj + -del *.exe + -del *.lib + -del *.tds + -del zlib.bak + -del foo.gz + diff --git a/xs/src/png/zlib/contrib/pascal/zlibpas.pas b/xs/src/png/zlib/contrib/pascal/zlibpas.pas new file mode 100644 index 0000000000..a0dff11b50 --- /dev/null +++ b/xs/src/png/zlib/contrib/pascal/zlibpas.pas @@ -0,0 +1,276 @@ +(* zlibpas -- Pascal interface to the zlib data compression library + * + * Copyright (C) 2003 Cosmin Truta. + * Derived from original sources by Bob Dellaca. + * For conditions of distribution and use, see copyright notice in readme.txt + *) + +unit zlibpas; + +interface + +const + ZLIB_VERSION = '1.2.11'; + ZLIB_VERNUM = $12a0; + +type + alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; + cdecl; + free_func = procedure(opaque, address: Pointer); + cdecl; + + in_func = function(opaque: Pointer; var buf: PByte): Integer; + cdecl; + out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer; + cdecl; + + z_streamp = ^z_stream; + z_stream = packed record + next_in: PChar; (* next input byte *) + avail_in: Integer; (* number of bytes available at next_in *) + total_in: LongInt; (* total nb of input bytes read so far *) + + next_out: PChar; (* next output byte should be put there *) + avail_out: Integer; (* remaining free space at next_out *) + total_out: LongInt; (* total nb of bytes output so far *) + + msg: PChar; (* last error message, NULL if no error *) + state: Pointer; (* not visible by applications *) + + zalloc: alloc_func; (* used to allocate the internal state *) + zfree: free_func; (* used to free the internal state *) + opaque: Pointer; (* private data object passed to zalloc and zfree *) + + data_type: Integer; (* best guess about the data type: ascii or binary *) + adler: LongInt; (* adler32 value of the uncompressed data *) + reserved: LongInt; (* reserved for future use *) + end; + + gz_headerp = ^gz_header; + gz_header = packed record + text: Integer; (* true if compressed data believed to be text *) + time: LongInt; (* modification time *) + xflags: Integer; (* extra flags (not used when writing a gzip file) *) + os: Integer; (* operating system *) + extra: PChar; (* pointer to extra field or Z_NULL if none *) + extra_len: Integer; (* extra field length (valid if extra != Z_NULL) *) + extra_max: Integer; (* space at extra (only when reading header) *) + name: PChar; (* pointer to zero-terminated file name or Z_NULL *) + name_max: Integer; (* space at name (only when reading header) *) + comment: PChar; (* pointer to zero-terminated comment or Z_NULL *) + comm_max: Integer; (* space at comment (only when reading header) *) + hcrc: Integer; (* true if there was or will be a header crc *) + done: Integer; (* true when done reading gzip header *) + end; + +(* constants *) +const + Z_NO_FLUSH = 0; + Z_PARTIAL_FLUSH = 1; + Z_SYNC_FLUSH = 2; + Z_FULL_FLUSH = 3; + Z_FINISH = 4; + Z_BLOCK = 5; + Z_TREES = 6; + + Z_OK = 0; + Z_STREAM_END = 1; + Z_NEED_DICT = 2; + Z_ERRNO = -1; + Z_STREAM_ERROR = -2; + Z_DATA_ERROR = -3; + Z_MEM_ERROR = -4; + Z_BUF_ERROR = -5; + Z_VERSION_ERROR = -6; + + Z_NO_COMPRESSION = 0; + Z_BEST_SPEED = 1; + Z_BEST_COMPRESSION = 9; + Z_DEFAULT_COMPRESSION = -1; + + Z_FILTERED = 1; + Z_HUFFMAN_ONLY = 2; + Z_RLE = 3; + Z_FIXED = 4; + Z_DEFAULT_STRATEGY = 0; + + Z_BINARY = 0; + Z_TEXT = 1; + Z_ASCII = 1; + Z_UNKNOWN = 2; + + Z_DEFLATED = 8; + +(* basic functions *) +function zlibVersion: PChar; +function deflateInit(var strm: z_stream; level: Integer): Integer; +function deflate(var strm: z_stream; flush: Integer): Integer; +function deflateEnd(var strm: z_stream): Integer; +function inflateInit(var strm: z_stream): Integer; +function inflate(var strm: z_stream; flush: Integer): Integer; +function inflateEnd(var strm: z_stream): Integer; + +(* advanced functions *) +function deflateInit2(var strm: z_stream; level, method, windowBits, + memLevel, strategy: Integer): Integer; +function deflateSetDictionary(var strm: z_stream; const dictionary: PChar; + dictLength: Integer): Integer; +function deflateCopy(var dest, source: z_stream): Integer; +function deflateReset(var strm: z_stream): Integer; +function deflateParams(var strm: z_stream; level, strategy: Integer): Integer; +function deflateTune(var strm: z_stream; good_length, max_lazy, nice_length, max_chain: Integer): Integer; +function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; +function deflatePending(var strm: z_stream; var pending: Integer; var bits: Integer): Integer; +function deflatePrime(var strm: z_stream; bits, value: Integer): Integer; +function deflateSetHeader(var strm: z_stream; head: gz_header): Integer; +function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; +function inflateSetDictionary(var strm: z_stream; const dictionary: PChar; + dictLength: Integer): Integer; +function inflateSync(var strm: z_stream): Integer; +function inflateCopy(var dest, source: z_stream): Integer; +function inflateReset(var strm: z_stream): Integer; +function inflateReset2(var strm: z_stream; windowBits: Integer): Integer; +function inflatePrime(var strm: z_stream; bits, value: Integer): Integer; +function inflateMark(var strm: z_stream): LongInt; +function inflateGetHeader(var strm: z_stream; var head: gz_header): Integer; +function inflateBackInit(var strm: z_stream; + windowBits: Integer; window: PChar): Integer; +function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer; + out_fn: out_func; out_desc: Pointer): Integer; +function inflateBackEnd(var strm: z_stream): Integer; +function zlibCompileFlags: LongInt; + +(* utility functions *) +function compress(dest: PChar; var destLen: LongInt; + const source: PChar; sourceLen: LongInt): Integer; +function compress2(dest: PChar; var destLen: LongInt; + const source: PChar; sourceLen: LongInt; + level: Integer): Integer; +function compressBound(sourceLen: LongInt): LongInt; +function uncompress(dest: PChar; var destLen: LongInt; + const source: PChar; sourceLen: LongInt): Integer; + +(* checksum functions *) +function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; +function adler32_combine(adler1, adler2, len2: LongInt): LongInt; +function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; +function crc32_combine(crc1, crc2, len2: LongInt): LongInt; + +(* various hacks, don't look :) *) +function deflateInit_(var strm: z_stream; level: Integer; + const version: PChar; stream_size: Integer): Integer; +function inflateInit_(var strm: z_stream; const version: PChar; + stream_size: Integer): Integer; +function deflateInit2_(var strm: z_stream; + level, method, windowBits, memLevel, strategy: Integer; + const version: PChar; stream_size: Integer): Integer; +function inflateInit2_(var strm: z_stream; windowBits: Integer; + const version: PChar; stream_size: Integer): Integer; +function inflateBackInit_(var strm: z_stream; + windowBits: Integer; window: PChar; + const version: PChar; stream_size: Integer): Integer; + + +implementation + +{$L adler32.obj} +{$L compress.obj} +{$L crc32.obj} +{$L deflate.obj} +{$L infback.obj} +{$L inffast.obj} +{$L inflate.obj} +{$L inftrees.obj} +{$L trees.obj} +{$L uncompr.obj} +{$L zutil.obj} + +function adler32; external; +function adler32_combine; external; +function compress; external; +function compress2; external; +function compressBound; external; +function crc32; external; +function crc32_combine; external; +function deflate; external; +function deflateBound; external; +function deflateCopy; external; +function deflateEnd; external; +function deflateInit_; external; +function deflateInit2_; external; +function deflateParams; external; +function deflatePending; external; +function deflatePrime; external; +function deflateReset; external; +function deflateSetDictionary; external; +function deflateSetHeader; external; +function deflateTune; external; +function inflate; external; +function inflateBack; external; +function inflateBackEnd; external; +function inflateBackInit_; external; +function inflateCopy; external; +function inflateEnd; external; +function inflateGetHeader; external; +function inflateInit_; external; +function inflateInit2_; external; +function inflateMark; external; +function inflatePrime; external; +function inflateReset; external; +function inflateReset2; external; +function inflateSetDictionary; external; +function inflateSync; external; +function uncompress; external; +function zlibCompileFlags; external; +function zlibVersion; external; + +function deflateInit(var strm: z_stream; level: Integer): Integer; +begin + Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); +end; + +function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel, + strategy: Integer): Integer; +begin + Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + ZLIB_VERSION, sizeof(z_stream)); +end; + +function inflateInit(var strm: z_stream): Integer; +begin + Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); +end; + +function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; +begin + Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream)); +end; + +function inflateBackInit(var strm: z_stream; + windowBits: Integer; window: PChar): Integer; +begin + Result := inflateBackInit_(strm, windowBits, window, + ZLIB_VERSION, sizeof(z_stream)); +end; + +function _malloc(Size: Integer): Pointer; cdecl; +begin + GetMem(Result, Size); +end; + +procedure _free(Block: Pointer); cdecl; +begin + FreeMem(Block); +end; + +procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; +begin + FillChar(P^, count, B); +end; + +procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; +begin + Move(source^, dest^, count); +end; + +end. diff --git a/xs/src/png/zlib/contrib/puff/Makefile b/xs/src/png/zlib/contrib/puff/Makefile new file mode 100644 index 0000000000..0e2594c808 --- /dev/null +++ b/xs/src/png/zlib/contrib/puff/Makefile @@ -0,0 +1,42 @@ +CFLAGS=-O + +puff: puff.o pufftest.o + +puff.o: puff.h + +pufftest.o: puff.h + +test: puff + puff zeros.raw + +puft: puff.c puff.h pufftest.o + cc -fprofile-arcs -ftest-coverage -o puft puff.c pufftest.o + +# puff full coverage test (should say 100%) +cov: puft + @rm -f *.gcov *.gcda + @puft -w zeros.raw 2>&1 | cat > /dev/null + @echo '04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 + @echo '00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 + @echo '00 00 00 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 254 + @echo '00 01 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 + @echo '01 01 00 fe ff 0a' | xxd -r -p | puft -f 2>&1 | cat > /dev/null + @echo '02 7e ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 + @echo '02' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 + @echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 + @echo '04 80 49 92 24 49 92 24 71 ff ff 93 11 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 249 + @echo '04 c0 81 08 00 00 00 00 20 7f eb 0b 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 + @echo '0b 00 00' | xxd -r -p | puft -f 2>&1 | cat > /dev/null + @echo '1a 07' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 + @echo '0c c0 81 00 00 00 00 00 90 ff 6b 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 245 + @puft -f zeros.raw 2>&1 | cat > /dev/null + @echo 'fc 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 253 + @echo '04 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 252 + @echo '04 00 24 49' | xxd -r -p | puft 2> /dev/null || test $$? -eq 251 + @echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 84' | xxd -r -p | puft 2> /dev/null || test $$? -eq 248 + @echo '04 00 24 e9 ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 250 + @echo '04 00 24 e9 ff 6d' | xxd -r -p | puft 2> /dev/null || test $$? -eq 247 + @gcov -n puff.c + +clean: + rm -f puff puft *.o *.gc* diff --git a/xs/src/png/zlib/contrib/puff/README b/xs/src/png/zlib/contrib/puff/README new file mode 100644 index 0000000000..bbc4cb595e --- /dev/null +++ b/xs/src/png/zlib/contrib/puff/README @@ -0,0 +1,63 @@ +Puff -- A Simple Inflate +3 Mar 2003 +Mark Adler +madler@alumni.caltech.edu + +What this is -- + +puff.c provides the routine puff() to decompress the deflate data format. It +does so more slowly than zlib, but the code is about one-fifth the size of the +inflate code in zlib, and written to be very easy to read. + +Why I wrote this -- + +puff.c was written to document the deflate format unambiguously, by virtue of +being working C code. It is meant to supplement RFC 1951, which formally +describes the deflate format. I have received many questions on details of the +deflate format, and I hope that reading this code will answer those questions. +puff.c is heavily commented with details of the deflate format, especially +those little nooks and cranies of the format that might not be obvious from a +specification. + +puff.c may also be useful in applications where code size or memory usage is a +very limited resource, and speed is not as important. + +How to use it -- + +Well, most likely you should just be reading puff.c and using zlib for actual +applications, but if you must ... + +Include puff.h in your code, which provides this prototype: + +int puff(unsigned char *dest, /* pointer to destination pointer */ + unsigned long *destlen, /* amount of output space */ + unsigned char *source, /* pointer to source data pointer */ + unsigned long *sourcelen); /* amount of input available */ + +Then you can call puff() to decompress a deflate stream that is in memory in +its entirety at source, to a sufficiently sized block of memory for the +decompressed data at dest. puff() is the only external symbol in puff.c The +only C library functions that puff.c needs are setjmp() and longjmp(), which +are used to simplify error checking in the code to improve readabilty. puff.c +does no memory allocation, and uses less than 2K bytes off of the stack. + +If destlen is not enough space for the uncompressed data, then inflate will +return an error without writing more than destlen bytes. Note that this means +that in order to decompress the deflate data successfully, you need to know +the size of the uncompressed data ahead of time. + +If needed, puff() can determine the size of the uncompressed data with no +output space. This is done by passing dest equal to (unsigned char *)0. Then +the initial value of *destlen is ignored and *destlen is set to the length of +the uncompressed data. So if the size of the uncompressed data is not known, +then two passes of puff() can be used--first to determine the size, and second +to do the actual inflation after allocating the appropriate memory. Not +pretty, but it works. (This is one of the reasons you should be using zlib.) + +The deflate format is self-terminating. If the deflate stream does not end +in *sourcelen bytes, puff() will return an error without reading at or past +endsource. + +On return, *sourcelen is updated to the amount of input data consumed, and +*destlen is updated to the size of the uncompressed data. See the comments +in puff.c for the possible return codes for puff(). diff --git a/xs/src/png/zlib/contrib/puff/puff.c b/xs/src/png/zlib/contrib/puff/puff.c new file mode 100644 index 0000000000..c6c90d7142 --- /dev/null +++ b/xs/src/png/zlib/contrib/puff/puff.c @@ -0,0 +1,840 @@ +/* + * puff.c + * Copyright (C) 2002-2013 Mark Adler + * For conditions of distribution and use, see copyright notice in puff.h + * version 2.3, 21 Jan 2013 + * + * puff.c is a simple inflate written to be an unambiguous way to specify the + * deflate format. It is not written for speed but rather simplicity. As a + * side benefit, this code might actually be useful when small code is more + * important than speed, such as bootstrap applications. For typical deflate + * data, zlib's inflate() is about four times as fast as puff(). zlib's + * inflate compiles to around 20K on my machine, whereas puff.c compiles to + * around 4K on my machine (a PowerPC using GNU cc). If the faster decode() + * function here is used, then puff() is only twice as slow as zlib's + * inflate(). + * + * All dynamically allocated memory comes from the stack. The stack required + * is less than 2K bytes. This code is compatible with 16-bit int's and + * assumes that long's are at least 32 bits. puff.c uses the short data type, + * assumed to be 16 bits, for arrays in order to conserve memory. The code + * works whether integers are stored big endian or little endian. + * + * In the comments below are "Format notes" that describe the inflate process + * and document some of the less obvious aspects of the format. This source + * code is meant to supplement RFC 1951, which formally describes the deflate + * format: + * + * http://www.zlib.org/rfc-deflate.html + */ + +/* + * Change history: + * + * 1.0 10 Feb 2002 - First version + * 1.1 17 Feb 2002 - Clarifications of some comments and notes + * - Update puff() dest and source pointers on negative + * errors to facilitate debugging deflators + * - Remove longest from struct huffman -- not needed + * - Simplify offs[] index in construct() + * - Add input size and checking, using longjmp() to + * maintain easy readability + * - Use short data type for large arrays + * - Use pointers instead of long to specify source and + * destination sizes to avoid arbitrary 4 GB limits + * 1.2 17 Mar 2002 - Add faster version of decode(), doubles speed (!), + * but leave simple version for readabilty + * - Make sure invalid distances detected if pointers + * are 16 bits + * - Fix fixed codes table error + * - Provide a scanning mode for determining size of + * uncompressed data + * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Gailly] + * - Add a puff.h file for the interface + * - Add braces in puff() for else do [Gailly] + * - Use indexes instead of pointers for readability + * 1.4 31 Mar 2002 - Simplify construct() code set check + * - Fix some comments + * - Add FIXLCODES #define + * 1.5 6 Apr 2002 - Minor comment fixes + * 1.6 7 Aug 2002 - Minor format changes + * 1.7 3 Mar 2003 - Added test code for distribution + * - Added zlib-like license + * 1.8 9 Jan 2004 - Added some comments on no distance codes case + * 1.9 21 Feb 2008 - Fix bug on 16-bit integer architectures [Pohland] + * - Catch missing end-of-block symbol error + * 2.0 25 Jul 2008 - Add #define to permit distance too far back + * - Add option in TEST code for puff to write the data + * - Add option in TEST code to skip input bytes + * - Allow TEST code to read from piped stdin + * 2.1 4 Apr 2010 - Avoid variable initialization for happier compilers + * - Avoid unsigned comparisons for even happier compilers + * 2.2 25 Apr 2010 - Fix bug in variable initializations [Oberhumer] + * - Add const where appropriate [Oberhumer] + * - Split if's and ?'s for coverage testing + * - Break out test code to separate file + * - Move NIL to puff.h + * - Allow incomplete code only if single code length is 1 + * - Add full code coverage test to Makefile + * 2.3 21 Jan 2013 - Check for invalid code length codes in dynamic blocks + */ + +#include /* for setjmp(), longjmp(), and jmp_buf */ +#include "puff.h" /* prototype for puff() */ + +#define local static /* for local function definitions */ + +/* + * Maximums for allocations and loops. It is not useful to change these -- + * they are fixed by the deflate format. + */ +#define MAXBITS 15 /* maximum bits in a code */ +#define MAXLCODES 286 /* maximum number of literal/length codes */ +#define MAXDCODES 30 /* maximum number of distance codes */ +#define MAXCODES (MAXLCODES+MAXDCODES) /* maximum codes lengths to read */ +#define FIXLCODES 288 /* number of fixed literal/length codes */ + +/* input and output state */ +struct state { + /* output state */ + unsigned char *out; /* output buffer */ + unsigned long outlen; /* available space at out */ + unsigned long outcnt; /* bytes written to out so far */ + + /* input state */ + const unsigned char *in; /* input buffer */ + unsigned long inlen; /* available input at in */ + unsigned long incnt; /* bytes read so far */ + int bitbuf; /* bit buffer */ + int bitcnt; /* number of bits in bit buffer */ + + /* input limit error return state for bits() and decode() */ + jmp_buf env; +}; + +/* + * Return need bits from the input stream. This always leaves less than + * eight bits in the buffer. bits() works properly for need == 0. + * + * Format notes: + * + * - Bits are stored in bytes from the least significant bit to the most + * significant bit. Therefore bits are dropped from the bottom of the bit + * buffer, using shift right, and new bytes are appended to the top of the + * bit buffer, using shift left. + */ +local int bits(struct state *s, int need) +{ + long val; /* bit accumulator (can use up to 20 bits) */ + + /* load at least need bits into val */ + val = s->bitbuf; + while (s->bitcnt < need) { + if (s->incnt == s->inlen) + longjmp(s->env, 1); /* out of input */ + val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */ + s->bitcnt += 8; + } + + /* drop need bits and update buffer, always zero to seven bits left */ + s->bitbuf = (int)(val >> need); + s->bitcnt -= need; + + /* return need bits, zeroing the bits above that */ + return (int)(val & ((1L << need) - 1)); +} + +/* + * Process a stored block. + * + * Format notes: + * + * - After the two-bit stored block type (00), the stored block length and + * stored bytes are byte-aligned for fast copying. Therefore any leftover + * bits in the byte that has the last bit of the type, as many as seven, are + * discarded. The value of the discarded bits are not defined and should not + * be checked against any expectation. + * + * - The second inverted copy of the stored block length does not have to be + * checked, but it's probably a good idea to do so anyway. + * + * - A stored block can have zero length. This is sometimes used to byte-align + * subsets of the compressed data for random access or partial recovery. + */ +local int stored(struct state *s) +{ + unsigned len; /* length of stored block */ + + /* discard leftover bits from current byte (assumes s->bitcnt < 8) */ + s->bitbuf = 0; + s->bitcnt = 0; + + /* get length and check against its one's complement */ + if (s->incnt + 4 > s->inlen) + return 2; /* not enough input */ + len = s->in[s->incnt++]; + len |= s->in[s->incnt++] << 8; + if (s->in[s->incnt++] != (~len & 0xff) || + s->in[s->incnt++] != ((~len >> 8) & 0xff)) + return -2; /* didn't match complement! */ + + /* copy len bytes from in to out */ + if (s->incnt + len > s->inlen) + return 2; /* not enough input */ + if (s->out != NIL) { + if (s->outcnt + len > s->outlen) + return 1; /* not enough output space */ + while (len--) + s->out[s->outcnt++] = s->in[s->incnt++]; + } + else { /* just scanning */ + s->outcnt += len; + s->incnt += len; + } + + /* done with a valid stored block */ + return 0; +} + +/* + * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of + * each length, which for a canonical code are stepped through in order. + * symbol[] are the symbol values in canonical order, where the number of + * entries is the sum of the counts in count[]. The decoding process can be + * seen in the function decode() below. + */ +struct huffman { + short *count; /* number of symbols of each length */ + short *symbol; /* canonically ordered symbols */ +}; + +/* + * Decode a code from the stream s using huffman table h. Return the symbol or + * a negative value if there is an error. If all of the lengths are zero, i.e. + * an empty code, or if the code is incomplete and an invalid code is received, + * then -10 is returned after reading MAXBITS bits. + * + * Format notes: + * + * - The codes as stored in the compressed data are bit-reversed relative to + * a simple integer ordering of codes of the same lengths. Hence below the + * bits are pulled from the compressed data one at a time and used to + * build the code value reversed from what is in the stream in order to + * permit simple integer comparisons for decoding. A table-based decoding + * scheme (as used in zlib) does not need to do this reversal. + * + * - The first code for the shortest length is all zeros. Subsequent codes of + * the same length are simply integer increments of the previous code. When + * moving up a length, a zero bit is appended to the code. For a complete + * code, the last code of the longest length will be all ones. + * + * - Incomplete codes are handled by this decoder, since they are permitted + * in the deflate format. See the format notes for fixed() and dynamic(). + */ +#ifdef SLOW +local int decode(struct state *s, const struct huffman *h) +{ + int len; /* current number of bits in code */ + int code; /* len bits being decoded */ + int first; /* first code of length len */ + int count; /* number of codes of length len */ + int index; /* index of first code of length len in symbol table */ + + code = first = index = 0; + for (len = 1; len <= MAXBITS; len++) { + code |= bits(s, 1); /* get next bit */ + count = h->count[len]; + if (code - count < first) /* if length len, return symbol */ + return h->symbol[index + (code - first)]; + index += count; /* else update for next length */ + first += count; + first <<= 1; + code <<= 1; + } + return -10; /* ran out of codes */ +} + +/* + * A faster version of decode() for real applications of this code. It's not + * as readable, but it makes puff() twice as fast. And it only makes the code + * a few percent larger. + */ +#else /* !SLOW */ +local int decode(struct state *s, const struct huffman *h) +{ + int len; /* current number of bits in code */ + int code; /* len bits being decoded */ + int first; /* first code of length len */ + int count; /* number of codes of length len */ + int index; /* index of first code of length len in symbol table */ + int bitbuf; /* bits from stream */ + int left; /* bits left in next or left to process */ + short *next; /* next number of codes */ + + bitbuf = s->bitbuf; + left = s->bitcnt; + code = first = index = 0; + len = 1; + next = h->count + 1; + while (1) { + while (left--) { + code |= bitbuf & 1; + bitbuf >>= 1; + count = *next++; + if (code - count < first) { /* if length len, return symbol */ + s->bitbuf = bitbuf; + s->bitcnt = (s->bitcnt - len) & 7; + return h->symbol[index + (code - first)]; + } + index += count; /* else update for next length */ + first += count; + first <<= 1; + code <<= 1; + len++; + } + left = (MAXBITS+1) - len; + if (left == 0) + break; + if (s->incnt == s->inlen) + longjmp(s->env, 1); /* out of input */ + bitbuf = s->in[s->incnt++]; + if (left > 8) + left = 8; + } + return -10; /* ran out of codes */ +} +#endif /* SLOW */ + +/* + * Given the list of code lengths length[0..n-1] representing a canonical + * Huffman code for n symbols, construct the tables required to decode those + * codes. Those tables are the number of codes of each length, and the symbols + * sorted by length, retaining their original order within each length. The + * return value is zero for a complete code set, negative for an over- + * subscribed code set, and positive for an incomplete code set. The tables + * can be used if the return value is zero or positive, but they cannot be used + * if the return value is negative. If the return value is zero, it is not + * possible for decode() using that table to return an error--any stream of + * enough bits will resolve to a symbol. If the return value is positive, then + * it is possible for decode() using that table to return an error for received + * codes past the end of the incomplete lengths. + * + * Not used by decode(), but used for error checking, h->count[0] is the number + * of the n symbols not in the code. So n - h->count[0] is the number of + * codes. This is useful for checking for incomplete codes that have more than + * one symbol, which is an error in a dynamic block. + * + * Assumption: for all i in 0..n-1, 0 <= length[i] <= MAXBITS + * This is assured by the construction of the length arrays in dynamic() and + * fixed() and is not verified by construct(). + * + * Format notes: + * + * - Permitted and expected examples of incomplete codes are one of the fixed + * codes and any code with a single symbol which in deflate is coded as one + * bit instead of zero bits. See the format notes for fixed() and dynamic(). + * + * - Within a given code length, the symbols are kept in ascending order for + * the code bits definition. + */ +local int construct(struct huffman *h, const short *length, int n) +{ + int symbol; /* current symbol when stepping through length[] */ + int len; /* current length when stepping through h->count[] */ + int left; /* number of possible codes left of current length */ + short offs[MAXBITS+1]; /* offsets in symbol table for each length */ + + /* count number of codes of each length */ + for (len = 0; len <= MAXBITS; len++) + h->count[len] = 0; + for (symbol = 0; symbol < n; symbol++) + (h->count[length[symbol]])++; /* assumes lengths are within bounds */ + if (h->count[0] == n) /* no codes! */ + return 0; /* complete, but decode() will fail */ + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; /* one possible code of zero length */ + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; /* one more bit, double codes left */ + left -= h->count[len]; /* deduct count from possible codes */ + if (left < 0) + return left; /* over-subscribed--return negative */ + } /* left > 0 means incomplete */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + h->count[len]; + + /* + * put symbols in table sorted by length, by symbol order within each + * length + */ + for (symbol = 0; symbol < n; symbol++) + if (length[symbol] != 0) + h->symbol[offs[length[symbol]]++] = symbol; + + /* return zero for complete set, positive for incomplete set */ + return left; +} + +/* + * Decode literal/length and distance codes until an end-of-block code. + * + * Format notes: + * + * - Compressed data that is after the block type if fixed or after the code + * description if dynamic is a combination of literals and length/distance + * pairs terminated by and end-of-block code. Literals are simply Huffman + * coded bytes. A length/distance pair is a coded length followed by a + * coded distance to represent a string that occurs earlier in the + * uncompressed data that occurs again at the current location. + * + * - Literals, lengths, and the end-of-block code are combined into a single + * code of up to 286 symbols. They are 256 literals (0..255), 29 length + * symbols (257..285), and the end-of-block symbol (256). + * + * - There are 256 possible lengths (3..258), and so 29 symbols are not enough + * to represent all of those. Lengths 3..10 and 258 are in fact represented + * by just a length symbol. Lengths 11..257 are represented as a symbol and + * some number of extra bits that are added as an integer to the base length + * of the length symbol. The number of extra bits is determined by the base + * length symbol. These are in the static arrays below, lens[] for the base + * lengths and lext[] for the corresponding number of extra bits. + * + * - The reason that 258 gets its own symbol is that the longest length is used + * often in highly redundant files. Note that 258 can also be coded as the + * base value 227 plus the maximum extra value of 31. While a good deflate + * should never do this, it is not an error, and should be decoded properly. + * + * - If a length is decoded, including its extra bits if any, then it is + * followed a distance code. There are up to 30 distance symbols. Again + * there are many more possible distances (1..32768), so extra bits are added + * to a base value represented by the symbol. The distances 1..4 get their + * own symbol, but the rest require extra bits. The base distances and + * corresponding number of extra bits are below in the static arrays dist[] + * and dext[]. + * + * - Literal bytes are simply written to the output. A length/distance pair is + * an instruction to copy previously uncompressed bytes to the output. The + * copy is from distance bytes back in the output stream, copying for length + * bytes. + * + * - Distances pointing before the beginning of the output data are not + * permitted. + * + * - Overlapped copies, where the length is greater than the distance, are + * allowed and common. For example, a distance of one and a length of 258 + * simply copies the last byte 258 times. A distance of four and a length of + * twelve copies the last four bytes three times. A simple forward copy + * ignoring whether the length is greater than the distance or not implements + * this correctly. You should not use memcpy() since its behavior is not + * defined for overlapped arrays. You should not use memmove() or bcopy() + * since though their behavior -is- defined for overlapping arrays, it is + * defined to do the wrong thing in this case. + */ +local int codes(struct state *s, + const struct huffman *lencode, + const struct huffman *distcode) +{ + int symbol; /* decoded symbol */ + int len; /* length for copy */ + unsigned dist; /* distance for copy */ + static const short lens[29] = { /* Size base for length codes 257..285 */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; + static const short lext[29] = { /* Extra bits for length codes 257..285 */ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; + static const short dists[30] = { /* Offset base for distance codes 0..29 */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577}; + static const short dext[30] = { /* Extra bits for distance codes 0..29 */ + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13}; + + /* decode literals and length/distance pairs */ + do { + symbol = decode(s, lencode); + if (symbol < 0) + return symbol; /* invalid symbol */ + if (symbol < 256) { /* literal: symbol is the byte */ + /* write out the literal */ + if (s->out != NIL) { + if (s->outcnt == s->outlen) + return 1; + s->out[s->outcnt] = symbol; + } + s->outcnt++; + } + else if (symbol > 256) { /* length */ + /* get and compute length */ + symbol -= 257; + if (symbol >= 29) + return -10; /* invalid fixed code */ + len = lens[symbol] + bits(s, lext[symbol]); + + /* get and check distance */ + symbol = decode(s, distcode); + if (symbol < 0) + return symbol; /* invalid symbol */ + dist = dists[symbol] + bits(s, dext[symbol]); +#ifndef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + if (dist > s->outcnt) + return -11; /* distance too far back */ +#endif + + /* copy length bytes from distance bytes back */ + if (s->out != NIL) { + if (s->outcnt + len > s->outlen) + return 1; + while (len--) { + s->out[s->outcnt] = +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + dist > s->outcnt ? + 0 : +#endif + s->out[s->outcnt - dist]; + s->outcnt++; + } + } + else + s->outcnt += len; + } + } while (symbol != 256); /* end of block symbol */ + + /* done with a valid fixed or dynamic block */ + return 0; +} + +/* + * Process a fixed codes block. + * + * Format notes: + * + * - This block type can be useful for compressing small amounts of data for + * which the size of the code descriptions in a dynamic block exceeds the + * benefit of custom codes for that block. For fixed codes, no bits are + * spent on code descriptions. Instead the code lengths for literal/length + * codes and distance codes are fixed. The specific lengths for each symbol + * can be seen in the "for" loops below. + * + * - The literal/length code is complete, but has two symbols that are invalid + * and should result in an error if received. This cannot be implemented + * simply as an incomplete code since those two symbols are in the "middle" + * of the code. They are eight bits long and the longest literal/length\ + * code is nine bits. Therefore the code must be constructed with those + * symbols, and the invalid symbols must be detected after decoding. + * + * - The fixed distance codes also have two invalid symbols that should result + * in an error if received. Since all of the distance codes are the same + * length, this can be implemented as an incomplete code. Then the invalid + * codes are detected while decoding. + */ +local int fixed(struct state *s) +{ + static int virgin = 1; + static short lencnt[MAXBITS+1], lensym[FIXLCODES]; + static short distcnt[MAXBITS+1], distsym[MAXDCODES]; + static struct huffman lencode, distcode; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + int symbol; + short lengths[FIXLCODES]; + + /* construct lencode and distcode */ + lencode.count = lencnt; + lencode.symbol = lensym; + distcode.count = distcnt; + distcode.symbol = distsym; + + /* literal/length table */ + for (symbol = 0; symbol < 144; symbol++) + lengths[symbol] = 8; + for (; symbol < 256; symbol++) + lengths[symbol] = 9; + for (; symbol < 280; symbol++) + lengths[symbol] = 7; + for (; symbol < FIXLCODES; symbol++) + lengths[symbol] = 8; + construct(&lencode, lengths, FIXLCODES); + + /* distance table */ + for (symbol = 0; symbol < MAXDCODES; symbol++) + lengths[symbol] = 5; + construct(&distcode, lengths, MAXDCODES); + + /* do this just once */ + virgin = 0; + } + + /* decode data until end-of-block code */ + return codes(s, &lencode, &distcode); +} + +/* + * Process a dynamic codes block. + * + * Format notes: + * + * - A dynamic block starts with a description of the literal/length and + * distance codes for that block. New dynamic blocks allow the compressor to + * rapidly adapt to changing data with new codes optimized for that data. + * + * - The codes used by the deflate format are "canonical", which means that + * the actual bits of the codes are generated in an unambiguous way simply + * from the number of bits in each code. Therefore the code descriptions + * are simply a list of code lengths for each symbol. + * + * - The code lengths are stored in order for the symbols, so lengths are + * provided for each of the literal/length symbols, and for each of the + * distance symbols. + * + * - If a symbol is not used in the block, this is represented by a zero as + * as the code length. This does not mean a zero-length code, but rather + * that no code should be created for this symbol. There is no way in the + * deflate format to represent a zero-length code. + * + * - The maximum number of bits in a code is 15, so the possible lengths for + * any code are 1..15. + * + * - The fact that a length of zero is not permitted for a code has an + * interesting consequence. Normally if only one symbol is used for a given + * code, then in fact that code could be represented with zero bits. However + * in deflate, that code has to be at least one bit. So for example, if + * only a single distance base symbol appears in a block, then it will be + * represented by a single code of length one, in particular one 0 bit. This + * is an incomplete code, since if a 1 bit is received, it has no meaning, + * and should result in an error. So incomplete distance codes of one symbol + * should be permitted, and the receipt of invalid codes should be handled. + * + * - It is also possible to have a single literal/length code, but that code + * must be the end-of-block code, since every dynamic block has one. This + * is not the most efficient way to create an empty block (an empty fixed + * block is fewer bits), but it is allowed by the format. So incomplete + * literal/length codes of one symbol should also be permitted. + * + * - If there are only literal codes and no lengths, then there are no distance + * codes. This is represented by one distance code with zero bits. + * + * - The list of up to 286 length/literal lengths and up to 30 distance lengths + * are themselves compressed using Huffman codes and run-length encoding. In + * the list of code lengths, a 0 symbol means no code, a 1..15 symbol means + * that length, and the symbols 16, 17, and 18 are run-length instructions. + * Each of 16, 17, and 18 are follwed by extra bits to define the length of + * the run. 16 copies the last length 3 to 6 times. 17 represents 3 to 10 + * zero lengths, and 18 represents 11 to 138 zero lengths. Unused symbols + * are common, hence the special coding for zero lengths. + * + * - The symbols for 0..18 are Huffman coded, and so that code must be + * described first. This is simply a sequence of up to 19 three-bit values + * representing no code (0) or the code length for that symbol (1..7). + * + * - A dynamic block starts with three fixed-size counts from which is computed + * the number of literal/length code lengths, the number of distance code + * lengths, and the number of code length code lengths (ok, you come up with + * a better name!) in the code descriptions. For the literal/length and + * distance codes, lengths after those provided are considered zero, i.e. no + * code. The code length code lengths are received in a permuted order (see + * the order[] array below) to make a short code length code length list more + * likely. As it turns out, very short and very long codes are less likely + * to be seen in a dynamic code description, hence what may appear initially + * to be a peculiar ordering. + * + * - Given the number of literal/length code lengths (nlen) and distance code + * lengths (ndist), then they are treated as one long list of nlen + ndist + * code lengths. Therefore run-length coding can and often does cross the + * boundary between the two sets of lengths. + * + * - So to summarize, the code description at the start of a dynamic block is + * three counts for the number of code lengths for the literal/length codes, + * the distance codes, and the code length codes. This is followed by the + * code length code lengths, three bits each. This is used to construct the + * code length code which is used to read the remainder of the lengths. Then + * the literal/length code lengths and distance lengths are read as a single + * set of lengths using the code length codes. Codes are constructed from + * the resulting two sets of lengths, and then finally you can start + * decoding actual compressed data in the block. + * + * - For reference, a "typical" size for the code description in a dynamic + * block is around 80 bytes. + */ +local int dynamic(struct state *s) +{ + int nlen, ndist, ncode; /* number of lengths in descriptor */ + int index; /* index of lengths[] */ + int err; /* construct() return value */ + short lengths[MAXCODES]; /* descriptor code lengths */ + short lencnt[MAXBITS+1], lensym[MAXLCODES]; /* lencode memory */ + short distcnt[MAXBITS+1], distsym[MAXDCODES]; /* distcode memory */ + struct huffman lencode, distcode; /* length and distance codes */ + static const short order[19] = /* permutation of code length codes */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + /* construct lencode and distcode */ + lencode.count = lencnt; + lencode.symbol = lensym; + distcode.count = distcnt; + distcode.symbol = distsym; + + /* get number of lengths in each table, check lengths */ + nlen = bits(s, 5) + 257; + ndist = bits(s, 5) + 1; + ncode = bits(s, 4) + 4; + if (nlen > MAXLCODES || ndist > MAXDCODES) + return -3; /* bad counts */ + + /* read code length code lengths (really), missing lengths are zero */ + for (index = 0; index < ncode; index++) + lengths[order[index]] = bits(s, 3); + for (; index < 19; index++) + lengths[order[index]] = 0; + + /* build huffman table for code lengths codes (use lencode temporarily) */ + err = construct(&lencode, lengths, 19); + if (err != 0) /* require complete code set here */ + return -4; + + /* read length/literal and distance code length tables */ + index = 0; + while (index < nlen + ndist) { + int symbol; /* decoded value */ + int len; /* last length to repeat */ + + symbol = decode(s, &lencode); + if (symbol < 0) + return symbol; /* invalid symbol */ + if (symbol < 16) /* length in 0..15 */ + lengths[index++] = symbol; + else { /* repeat instruction */ + len = 0; /* assume repeating zeros */ + if (symbol == 16) { /* repeat last length 3..6 times */ + if (index == 0) + return -5; /* no last length! */ + len = lengths[index - 1]; /* last length */ + symbol = 3 + bits(s, 2); + } + else if (symbol == 17) /* repeat zero 3..10 times */ + symbol = 3 + bits(s, 3); + else /* == 18, repeat zero 11..138 times */ + symbol = 11 + bits(s, 7); + if (index + symbol > nlen + ndist) + return -6; /* too many lengths! */ + while (symbol--) /* repeat last or zero symbol times */ + lengths[index++] = len; + } + } + + /* check for end-of-block code -- there better be one! */ + if (lengths[256] == 0) + return -9; + + /* build huffman table for literal/length codes */ + err = construct(&lencode, lengths, nlen); + if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) + return -7; /* incomplete code ok only for single length 1 code */ + + /* build huffman table for distance codes */ + err = construct(&distcode, lengths + nlen, ndist); + if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) + return -8; /* incomplete code ok only for single length 1 code */ + + /* decode data until end-of-block code */ + return codes(s, &lencode, &distcode); +} + +/* + * Inflate source to dest. On return, destlen and sourcelen are updated to the + * size of the uncompressed data and the size of the deflate data respectively. + * On success, the return value of puff() is zero. If there is an error in the + * source data, i.e. it is not in the deflate format, then a negative value is + * returned. If there is not enough input available or there is not enough + * output space, then a positive error is returned. In that case, destlen and + * sourcelen are not updated to facilitate retrying from the beginning with the + * provision of more input data or more output space. In the case of invalid + * inflate data (a negative error), the dest and source pointers are updated to + * facilitate the debugging of deflators. + * + * puff() also has a mode to determine the size of the uncompressed output with + * no output written. For this dest must be (unsigned char *)0. In this case, + * the input value of *destlen is ignored, and on return *destlen is set to the + * size of the uncompressed output. + * + * The return codes are: + * + * 2: available inflate data did not terminate + * 1: output space exhausted before completing inflate + * 0: successful inflate + * -1: invalid block type (type == 3) + * -2: stored block length did not match one's complement + * -3: dynamic block code description: too many length or distance codes + * -4: dynamic block code description: code lengths codes incomplete + * -5: dynamic block code description: repeat lengths with no first length + * -6: dynamic block code description: repeat more than specified lengths + * -7: dynamic block code description: invalid literal/length code lengths + * -8: dynamic block code description: invalid distance code lengths + * -9: dynamic block code description: missing end-of-block code + * -10: invalid literal/length or distance code in fixed or dynamic block + * -11: distance is too far back in fixed or dynamic block + * + * Format notes: + * + * - Three bits are read for each block to determine the kind of block and + * whether or not it is the last block. Then the block is decoded and the + * process repeated if it was not the last block. + * + * - The leftover bits in the last byte of the deflate data after the last + * block (if it was a fixed or dynamic block) are undefined and have no + * expected values to check. + */ +int puff(unsigned char *dest, /* pointer to destination pointer */ + unsigned long *destlen, /* amount of output space */ + const unsigned char *source, /* pointer to source data pointer */ + unsigned long *sourcelen) /* amount of input available */ +{ + struct state s; /* input/output state */ + int last, type; /* block information */ + int err; /* return value */ + + /* initialize output state */ + s.out = dest; + s.outlen = *destlen; /* ignored if dest is NIL */ + s.outcnt = 0; + + /* initialize input state */ + s.in = source; + s.inlen = *sourcelen; + s.incnt = 0; + s.bitbuf = 0; + s.bitcnt = 0; + + /* return if bits() or decode() tries to read past available input */ + if (setjmp(s.env) != 0) /* if came back here via longjmp() */ + err = 2; /* then skip do-loop, return error */ + else { + /* process blocks until last block or error */ + do { + last = bits(&s, 1); /* one if last block */ + type = bits(&s, 2); /* block type 0..3 */ + err = type == 0 ? + stored(&s) : + (type == 1 ? + fixed(&s) : + (type == 2 ? + dynamic(&s) : + -1)); /* type == 3, invalid */ + if (err != 0) + break; /* return with error */ + } while (!last); + } + + /* update the lengths and return */ + if (err <= 0) { + *destlen = s.outcnt; + *sourcelen = s.incnt; + } + return err; +} diff --git a/xs/src/png/zlib/contrib/puff/puff.h b/xs/src/png/zlib/contrib/puff/puff.h new file mode 100644 index 0000000000..e23a245431 --- /dev/null +++ b/xs/src/png/zlib/contrib/puff/puff.h @@ -0,0 +1,35 @@ +/* puff.h + Copyright (C) 2002-2013 Mark Adler, all rights reserved + version 2.3, 21 Jan 2013 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Mark Adler madler@alumni.caltech.edu + */ + + +/* + * See puff.c for purpose and usage. + */ +#ifndef NIL +# define NIL ((unsigned char *)0) /* for no output option */ +#endif + +int puff(unsigned char *dest, /* pointer to destination pointer */ + unsigned long *destlen, /* amount of output space */ + const unsigned char *source, /* pointer to source data pointer */ + unsigned long *sourcelen); /* amount of input available */ diff --git a/xs/src/png/zlib/contrib/puff/pufftest.c b/xs/src/png/zlib/contrib/puff/pufftest.c new file mode 100644 index 0000000000..776481488c --- /dev/null +++ b/xs/src/png/zlib/contrib/puff/pufftest.c @@ -0,0 +1,165 @@ +/* + * pufftest.c + * Copyright (C) 2002-2013 Mark Adler + * For conditions of distribution and use, see copyright notice in puff.h + * version 2.3, 21 Jan 2013 + */ + +/* Example of how to use puff(). + + Usage: puff [-w] [-f] [-nnn] file + ... | puff [-w] [-f] [-nnn] + + where file is the input file with deflate data, nnn is the number of bytes + of input to skip before inflating (e.g. to skip a zlib or gzip header), and + -w is used to write the decompressed data to stdout. -f is for coverage + testing, and causes pufftest to fail with not enough output space (-f does + a write like -w, so -w is not required). */ + +#include +#include +#include "puff.h" + +#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) +# include +# include +# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) +#else +# define SET_BINARY_MODE(file) +#endif + +#define local static + +/* Return size times approximately the cube root of 2, keeping the result as 1, + 3, or 5 times a power of 2 -- the result is always > size, until the result + is the maximum value of an unsigned long, where it remains. This is useful + to keep reallocations less than ~33% over the actual data. */ +local size_t bythirds(size_t size) +{ + int n; + size_t m; + + m = size; + for (n = 0; m; n++) + m >>= 1; + if (n < 3) + return size + 1; + n -= 3; + m = size >> n; + m += m == 6 ? 2 : 1; + m <<= n; + return m > size ? m : (size_t)(-1); +} + +/* Read the input file *name, or stdin if name is NULL, into allocated memory. + Reallocate to larger buffers until the entire file is read in. Return a + pointer to the allocated data, or NULL if there was a memory allocation + failure. *len is the number of bytes of data read from the input file (even + if load() returns NULL). If the input file was empty or could not be opened + or read, *len is zero. */ +local void *load(const char *name, size_t *len) +{ + size_t size; + void *buf, *swap; + FILE *in; + + *len = 0; + buf = malloc(size = 4096); + if (buf == NULL) + return NULL; + in = name == NULL ? stdin : fopen(name, "rb"); + if (in != NULL) { + for (;;) { + *len += fread((char *)buf + *len, 1, size - *len, in); + if (*len < size) break; + size = bythirds(size); + if (size == *len || (swap = realloc(buf, size)) == NULL) { + free(buf); + buf = NULL; + break; + } + buf = swap; + } + fclose(in); + } + return buf; +} + +int main(int argc, char **argv) +{ + int ret, put = 0, fail = 0; + unsigned skip = 0; + char *arg, *name = NULL; + unsigned char *source = NULL, *dest; + size_t len = 0; + unsigned long sourcelen, destlen; + + /* process arguments */ + while (arg = *++argv, --argc) + if (arg[0] == '-') { + if (arg[1] == 'w' && arg[2] == 0) + put = 1; + else if (arg[1] == 'f' && arg[2] == 0) + fail = 1, put = 1; + else if (arg[1] >= '0' && arg[1] <= '9') + skip = (unsigned)atoi(arg + 1); + else { + fprintf(stderr, "invalid option %s\n", arg); + return 3; + } + } + else if (name != NULL) { + fprintf(stderr, "only one file name allowed\n"); + return 3; + } + else + name = arg; + source = load(name, &len); + if (source == NULL) { + fprintf(stderr, "memory allocation failure\n"); + return 4; + } + if (len == 0) { + fprintf(stderr, "could not read %s, or it was empty\n", + name == NULL ? "" : name); + free(source); + return 3; + } + if (skip >= len) { + fprintf(stderr, "skip request of %d leaves no input\n", skip); + free(source); + return 3; + } + + /* test inflate data with offset skip */ + len -= skip; + sourcelen = (unsigned long)len; + ret = puff(NIL, &destlen, source + skip, &sourcelen); + if (ret) + fprintf(stderr, "puff() failed with return code %d\n", ret); + else { + fprintf(stderr, "puff() succeeded uncompressing %lu bytes\n", destlen); + if (sourcelen < len) fprintf(stderr, "%lu compressed bytes unused\n", + len - sourcelen); + } + + /* if requested, inflate again and write decompressd data to stdout */ + if (put && ret == 0) { + if (fail) + destlen >>= 1; + dest = malloc(destlen); + if (dest == NULL) { + fprintf(stderr, "memory allocation failure\n"); + free(source); + return 4; + } + puff(dest, &destlen, source + skip, &sourcelen); + SET_BINARY_MODE(stdout); + fwrite(dest, 1, destlen, stdout); + free(dest); + } + + /* clean up */ + free(source); + return ret; +} diff --git a/xs/src/png/zlib/contrib/puff/zeros.raw b/xs/src/png/zlib/contrib/puff/zeros.raw new file mode 100644 index 0000000000000000000000000000000000000000..0a90e76b300205a44a0ecbf613e64aaaef2e51e7 GIT binary patch literal 2517 zcmYdFkYHV$AkxzmXu#!mP=i#?5{3o^3jqcYc(h*%Opg+yAut*OqaiT#LSPd+y9&tF zP5<`ixi4UXdB8xJfs^6ee;AkH?VUytyFsD;HLIJ(gg5bUnNh}Q2#kinXb22!2pr%5 E0JRq+;s5{u literal 0 HcmV?d00001 diff --git a/xs/src/png/zlib/contrib/testzlib/testzlib.c b/xs/src/png/zlib/contrib/testzlib/testzlib.c new file mode 100644 index 0000000000..8626c92ad1 --- /dev/null +++ b/xs/src/png/zlib/contrib/testzlib/testzlib.c @@ -0,0 +1,275 @@ +#include +#include +#include + +#include "zlib.h" + + +void MyDoMinus64(LARGE_INTEGER *R,LARGE_INTEGER A,LARGE_INTEGER B) +{ + R->HighPart = A.HighPart - B.HighPart; + if (A.LowPart >= B.LowPart) + R->LowPart = A.LowPart - B.LowPart; + else + { + R->LowPart = A.LowPart - B.LowPart; + R->HighPart --; + } +} + +#ifdef _M_X64 +// see http://msdn2.microsoft.com/library/twchhe95(en-us,vs.80).aspx for __rdtsc +unsigned __int64 __rdtsc(void); +void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) +{ + // printf("rdtsc = %I64x\n",__rdtsc()); + pbeginTime64->QuadPart=__rdtsc(); +} + +LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) +{ + LARGE_INTEGER LIres; + unsigned _int64 res=__rdtsc()-((unsigned _int64)(beginTime64.QuadPart)); + LIres.QuadPart=res; + // printf("rdtsc = %I64x\n",__rdtsc()); + return LIres; +} +#else +#ifdef _M_IX86 +void myGetRDTSC32(LARGE_INTEGER * pbeginTime64) +{ + DWORD dwEdx,dwEax; + _asm + { + rdtsc + mov dwEax,eax + mov dwEdx,edx + } + pbeginTime64->LowPart=dwEax; + pbeginTime64->HighPart=dwEdx; +} + +void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) +{ + myGetRDTSC32(pbeginTime64); +} + +LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) +{ + LARGE_INTEGER LIres,endTime64; + myGetRDTSC32(&endTime64); + + LIres.LowPart=LIres.HighPart=0; + MyDoMinus64(&LIres,endTime64,beginTime64); + return LIres; +} +#else +void myGetRDTSC32(LARGE_INTEGER * pbeginTime64) +{ +} + +void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) +{ +} + +LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) +{ + LARGE_INTEGER lr; + lr.QuadPart=0; + return lr; +} +#endif +#endif + +void BeginCountPerfCounter(LARGE_INTEGER * pbeginTime64,BOOL fComputeTimeQueryPerf) +{ + if ((!fComputeTimeQueryPerf) || (!QueryPerformanceCounter(pbeginTime64))) + { + pbeginTime64->LowPart = GetTickCount(); + pbeginTime64->HighPart = 0; + } +} + +DWORD GetMsecSincePerfCounter(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) +{ + LARGE_INTEGER endTime64,ticksPerSecond,ticks; + DWORDLONG ticksShifted,tickSecShifted; + DWORD dwLog=16+0; + DWORD dwRet; + if ((!fComputeTimeQueryPerf) || (!QueryPerformanceCounter(&endTime64))) + dwRet = (GetTickCount() - beginTime64.LowPart)*1; + else + { + MyDoMinus64(&ticks,endTime64,beginTime64); + QueryPerformanceFrequency(&ticksPerSecond); + + + { + ticksShifted = Int64ShrlMod32(*(DWORDLONG*)&ticks,dwLog); + tickSecShifted = Int64ShrlMod32(*(DWORDLONG*)&ticksPerSecond,dwLog); + + } + + dwRet = (DWORD)((((DWORD)ticksShifted)*1000)/(DWORD)(tickSecShifted)); + dwRet *=1; + } + return dwRet; +} + +int ReadFileMemory(const char* filename,long* plFileSize,unsigned char** pFilePtr) +{ + FILE* stream; + unsigned char* ptr; + int retVal=1; + stream=fopen(filename, "rb"); + if (stream==NULL) + return 0; + + fseek(stream,0,SEEK_END); + + *plFileSize=ftell(stream); + fseek(stream,0,SEEK_SET); + ptr=malloc((*plFileSize)+1); + if (ptr==NULL) + retVal=0; + else + { + if (fread(ptr, 1, *plFileSize,stream) != (*plFileSize)) + retVal=0; + } + fclose(stream); + *pFilePtr=ptr; + return retVal; +} + +int main(int argc, char *argv[]) +{ + int BlockSizeCompress=0x8000; + int BlockSizeUncompress=0x8000; + int cprLevel=Z_DEFAULT_COMPRESSION ; + long lFileSize; + unsigned char* FilePtr; + long lBufferSizeCpr; + long lBufferSizeUncpr; + long lCompressedSize=0; + unsigned char* CprPtr; + unsigned char* UncprPtr; + long lSizeCpr,lSizeUncpr; + DWORD dwGetTick,dwMsecQP; + LARGE_INTEGER li_qp,li_rdtsc,dwResRdtsc; + + if (argc<=1) + { + printf("run TestZlib [BlockSizeCompress] [BlockSizeUncompress] [compres. level]\n"); + return 0; + } + + if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) + { + printf("error reading %s\n",argv[1]); + return 1; + } + else printf("file %s read, %u bytes\n",argv[1],lFileSize); + + if (argc>=3) + BlockSizeCompress=atol(argv[2]); + + if (argc>=4) + BlockSizeUncompress=atol(argv[3]); + + if (argc>=5) + cprLevel=(int)atol(argv[4]); + + lBufferSizeCpr = lFileSize + (lFileSize/0x10) + 0x200; + lBufferSizeUncpr = lBufferSizeCpr; + + CprPtr=(unsigned char*)malloc(lBufferSizeCpr + BlockSizeCompress); + + BeginCountPerfCounter(&li_qp,TRUE); + dwGetTick=GetTickCount(); + BeginCountRdtsc(&li_rdtsc); + { + z_stream zcpr; + int ret=Z_OK; + long lOrigToDo = lFileSize; + long lOrigDone = 0; + int step=0; + memset(&zcpr,0,sizeof(z_stream)); + deflateInit(&zcpr,cprLevel); + + zcpr.next_in = FilePtr; + zcpr.next_out = CprPtr; + + + do + { + long all_read_before = zcpr.total_in; + zcpr.avail_in = min(lOrigToDo,BlockSizeCompress); + zcpr.avail_out = BlockSizeCompress; + ret=deflate(&zcpr,(zcpr.avail_in==lOrigToDo) ? Z_FINISH : Z_SYNC_FLUSH); + lOrigDone += (zcpr.total_in-all_read_before); + lOrigToDo -= (zcpr.total_in-all_read_before); + step++; + } while (ret==Z_OK); + + lSizeCpr=zcpr.total_out; + deflateEnd(&zcpr); + dwGetTick=GetTickCount()-dwGetTick; + dwMsecQP=GetMsecSincePerfCounter(li_qp,TRUE); + dwResRdtsc=GetResRdtsc(li_rdtsc,TRUE); + printf("total compress size = %u, in %u step\n",lSizeCpr,step); + printf("time = %u msec = %f sec\n",dwGetTick,dwGetTick/(double)1000.); + printf("defcpr time QP = %u msec = %f sec\n",dwMsecQP,dwMsecQP/(double)1000.); + printf("defcpr result rdtsc = %I64x\n\n",dwResRdtsc.QuadPart); + } + + CprPtr=(unsigned char*)realloc(CprPtr,lSizeCpr); + UncprPtr=(unsigned char*)malloc(lBufferSizeUncpr + BlockSizeUncompress); + + BeginCountPerfCounter(&li_qp,TRUE); + dwGetTick=GetTickCount(); + BeginCountRdtsc(&li_rdtsc); + { + z_stream zcpr; + int ret=Z_OK; + long lOrigToDo = lSizeCpr; + long lOrigDone = 0; + int step=0; + memset(&zcpr,0,sizeof(z_stream)); + inflateInit(&zcpr); + + zcpr.next_in = CprPtr; + zcpr.next_out = UncprPtr; + + + do + { + long all_read_before = zcpr.total_in; + zcpr.avail_in = min(lOrigToDo,BlockSizeUncompress); + zcpr.avail_out = BlockSizeUncompress; + ret=inflate(&zcpr,Z_SYNC_FLUSH); + lOrigDone += (zcpr.total_in-all_read_before); + lOrigToDo -= (zcpr.total_in-all_read_before); + step++; + } while (ret==Z_OK); + + lSizeUncpr=zcpr.total_out; + inflateEnd(&zcpr); + dwGetTick=GetTickCount()-dwGetTick; + dwMsecQP=GetMsecSincePerfCounter(li_qp,TRUE); + dwResRdtsc=GetResRdtsc(li_rdtsc,TRUE); + printf("total uncompress size = %u, in %u step\n",lSizeUncpr,step); + printf("time = %u msec = %f sec\n",dwGetTick,dwGetTick/(double)1000.); + printf("uncpr time QP = %u msec = %f sec\n",dwMsecQP,dwMsecQP/(double)1000.); + printf("uncpr result rdtsc = %I64x\n\n",dwResRdtsc.QuadPart); + } + + if (lSizeUncpr==lFileSize) + { + if (memcmp(FilePtr,UncprPtr,lFileSize)==0) + printf("compare ok\n"); + + } + + return 0; +} diff --git a/xs/src/png/zlib/contrib/testzlib/testzlib.txt b/xs/src/png/zlib/contrib/testzlib/testzlib.txt new file mode 100644 index 0000000000..e508bb22ff --- /dev/null +++ b/xs/src/png/zlib/contrib/testzlib/testzlib.txt @@ -0,0 +1,10 @@ +To build testzLib with Visual Studio 2005: + +copy to a directory file from : +- root of zLib tree +- contrib/testzlib +- contrib/masmx86 +- contrib/masmx64 +- contrib/vstudio/vc7 + +and open testzlib8.sln \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/untgz/Makefile b/xs/src/png/zlib/contrib/untgz/Makefile new file mode 100644 index 0000000000..b54266fba2 --- /dev/null +++ b/xs/src/png/zlib/contrib/untgz/Makefile @@ -0,0 +1,14 @@ +CC=cc +CFLAGS=-g + +untgz: untgz.o ../../libz.a + $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz + +untgz.o: untgz.c ../../zlib.h + $(CC) $(CFLAGS) -c -I../.. untgz.c + +../../libz.a: + cd ../..; ./configure; make + +clean: + rm -f untgz untgz.o *~ diff --git a/xs/src/png/zlib/contrib/untgz/Makefile.msc b/xs/src/png/zlib/contrib/untgz/Makefile.msc new file mode 100644 index 0000000000..77b8602213 --- /dev/null +++ b/xs/src/png/zlib/contrib/untgz/Makefile.msc @@ -0,0 +1,17 @@ +CC=cl +CFLAGS=-MD + +untgz.exe: untgz.obj ..\..\zlib.lib + $(CC) $(CFLAGS) untgz.obj ..\..\zlib.lib + +untgz.obj: untgz.c ..\..\zlib.h + $(CC) $(CFLAGS) -c -I..\.. untgz.c + +..\..\zlib.lib: + cd ..\.. + $(MAKE) -f win32\makefile.msc + cd contrib\untgz + +clean: + -del untgz.obj + -del untgz.exe diff --git a/xs/src/png/zlib/contrib/untgz/untgz.c b/xs/src/png/zlib/contrib/untgz/untgz.c new file mode 100644 index 0000000000..2c391e5986 --- /dev/null +++ b/xs/src/png/zlib/contrib/untgz/untgz.c @@ -0,0 +1,674 @@ +/* + * untgz.c -- Display contents and extract files from a gzip'd TAR file + * + * written by Pedro A. Aranda Gutierrez + * adaptation to Unix by Jean-loup Gailly + * various fixes by Cosmin Truta + */ + +#include +#include +#include +#include +#include + +#include "zlib.h" + +#ifdef unix +# include +#else +# include +# include +#endif + +#ifdef WIN32 +#include +# ifndef F_OK +# define F_OK 0 +# endif +# define mkdir(dirname,mode) _mkdir(dirname) +# ifdef _MSC_VER +# define access(path,mode) _access(path,mode) +# define chmod(path,mode) _chmod(path,mode) +# define strdup(str) _strdup(str) +# endif +#else +# include +#endif + + +/* values used in typeflag field */ + +#define REGTYPE '0' /* regular file */ +#define AREGTYPE '\0' /* regular file */ +#define LNKTYPE '1' /* link */ +#define SYMTYPE '2' /* reserved */ +#define CHRTYPE '3' /* character special */ +#define BLKTYPE '4' /* block special */ +#define DIRTYPE '5' /* directory */ +#define FIFOTYPE '6' /* FIFO special */ +#define CONTTYPE '7' /* reserved */ + +/* GNU tar extensions */ + +#define GNUTYPE_DUMPDIR 'D' /* file names from dumped directory */ +#define GNUTYPE_LONGLINK 'K' /* long link name */ +#define GNUTYPE_LONGNAME 'L' /* long file name */ +#define GNUTYPE_MULTIVOL 'M' /* continuation of file from another volume */ +#define GNUTYPE_NAMES 'N' /* file name that does not fit into main hdr */ +#define GNUTYPE_SPARSE 'S' /* sparse file */ +#define GNUTYPE_VOLHDR 'V' /* tape/volume header */ + + +/* tar header */ + +#define BLOCKSIZE 512 +#define SHORTNAMESIZE 100 + +struct tar_header +{ /* byte offset */ + char name[100]; /* 0 */ + char mode[8]; /* 100 */ + char uid[8]; /* 108 */ + char gid[8]; /* 116 */ + char size[12]; /* 124 */ + char mtime[12]; /* 136 */ + char chksum[8]; /* 148 */ + char typeflag; /* 156 */ + char linkname[100]; /* 157 */ + char magic[6]; /* 257 */ + char version[2]; /* 263 */ + char uname[32]; /* 265 */ + char gname[32]; /* 297 */ + char devmajor[8]; /* 329 */ + char devminor[8]; /* 337 */ + char prefix[155]; /* 345 */ + /* 500 */ +}; + +union tar_buffer +{ + char buffer[BLOCKSIZE]; + struct tar_header header; +}; + +struct attr_item +{ + struct attr_item *next; + char *fname; + int mode; + time_t time; +}; + +enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; + +char *TGZfname OF((const char *)); +void TGZnotfound OF((const char *)); + +int getoct OF((char *, int)); +char *strtime OF((time_t *)); +int setfiletime OF((char *, time_t)); +void push_attr OF((struct attr_item **, char *, int, time_t)); +void restore_attr OF((struct attr_item **)); + +int ExprMatch OF((char *, char *)); + +int makedir OF((char *)); +int matchname OF((int, int, char **, char *)); + +void error OF((const char *)); +int tar OF((gzFile, int, int, int, char **)); + +void help OF((int)); +int main OF((int, char **)); + +char *prog; + +const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; + +/* return the file name of the TGZ archive */ +/* or NULL if it does not exist */ + +char *TGZfname (const char *arcname) +{ + static char buffer[1024]; + int origlen,i; + + strcpy(buffer,arcname); + origlen = strlen(buffer); + + for (i=0; TGZsuffix[i]; i++) + { + strcpy(buffer+origlen,TGZsuffix[i]); + if (access(buffer,F_OK) == 0) + return buffer; + } + return NULL; +} + + +/* error message for the filename */ + +void TGZnotfound (const char *arcname) +{ + int i; + + fprintf(stderr,"%s: Couldn't find ",prog); + for (i=0;TGZsuffix[i];i++) + fprintf(stderr,(TGZsuffix[i+1]) ? "%s%s, " : "or %s%s\n", + arcname, + TGZsuffix[i]); + exit(1); +} + + +/* convert octal digits to int */ +/* on error return -1 */ + +int getoct (char *p,int width) +{ + int result = 0; + char c; + + while (width--) + { + c = *p++; + if (c == 0) + break; + if (c == ' ') + continue; + if (c < '0' || c > '7') + return -1; + result = result * 8 + (c - '0'); + } + return result; +} + + +/* convert time_t to string */ +/* use the "YYYY/MM/DD hh:mm:ss" format */ + +char *strtime (time_t *t) +{ + struct tm *local; + static char result[32]; + + local = localtime(t); + sprintf(result,"%4d/%02d/%02d %02d:%02d:%02d", + local->tm_year+1900, local->tm_mon+1, local->tm_mday, + local->tm_hour, local->tm_min, local->tm_sec); + return result; +} + + +/* set file time */ + +int setfiletime (char *fname,time_t ftime) +{ +#ifdef WIN32 + static int isWinNT = -1; + SYSTEMTIME st; + FILETIME locft, modft; + struct tm *loctm; + HANDLE hFile; + int result; + + loctm = localtime(&ftime); + if (loctm == NULL) + return -1; + + st.wYear = (WORD)loctm->tm_year + 1900; + st.wMonth = (WORD)loctm->tm_mon + 1; + st.wDayOfWeek = (WORD)loctm->tm_wday; + st.wDay = (WORD)loctm->tm_mday; + st.wHour = (WORD)loctm->tm_hour; + st.wMinute = (WORD)loctm->tm_min; + st.wSecond = (WORD)loctm->tm_sec; + st.wMilliseconds = 0; + if (!SystemTimeToFileTime(&st, &locft) || + !LocalFileTimeToFileTime(&locft, &modft)) + return -1; + + if (isWinNT < 0) + isWinNT = (GetVersion() < 0x80000000) ? 1 : 0; + hFile = CreateFile(fname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, + (isWinNT ? FILE_FLAG_BACKUP_SEMANTICS : 0), + NULL); + if (hFile == INVALID_HANDLE_VALUE) + return -1; + result = SetFileTime(hFile, NULL, NULL, &modft) ? 0 : -1; + CloseHandle(hFile); + return result; +#else + struct utimbuf settime; + + settime.actime = settime.modtime = ftime; + return utime(fname,&settime); +#endif +} + + +/* push file attributes */ + +void push_attr(struct attr_item **list,char *fname,int mode,time_t time) +{ + struct attr_item *item; + + item = (struct attr_item *)malloc(sizeof(struct attr_item)); + if (item == NULL) + error("Out of memory"); + item->fname = strdup(fname); + item->mode = mode; + item->time = time; + item->next = *list; + *list = item; +} + + +/* restore file attributes */ + +void restore_attr(struct attr_item **list) +{ + struct attr_item *item, *prev; + + for (item = *list; item != NULL; ) + { + setfiletime(item->fname,item->time); + chmod(item->fname,item->mode); + prev = item; + item = item->next; + free(prev); + } + *list = NULL; +} + + +/* match regular expression */ + +#define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) + +int ExprMatch (char *string,char *expr) +{ + while (1) + { + if (ISSPECIAL(*expr)) + { + if (*expr == '/') + { + if (*string != '\\' && *string != '/') + return 0; + string ++; expr++; + } + else if (*expr == '*') + { + if (*expr ++ == 0) + return 1; + while (*++string != *expr) + if (*string == 0) + return 0; + } + } + else + { + if (*string != *expr) + return 0; + if (*expr++ == 0) + return 1; + string++; + } + } +} + + +/* recursive mkdir */ +/* abort on ENOENT; ignore other errors like "directory already exists" */ +/* return 1 if OK */ +/* 0 on error */ + +int makedir (char *newdir) +{ + char *buffer = strdup(newdir); + char *p; + int len = strlen(buffer); + + if (len <= 0) { + free(buffer); + return 0; + } + if (buffer[len-1] == '/') { + buffer[len-1] = '\0'; + } + if (mkdir(buffer, 0755) == 0) + { + free(buffer); + return 1; + } + + p = buffer+1; + while (1) + { + char hold; + + while(*p && *p != '\\' && *p != '/') + p++; + hold = *p; + *p = 0; + if ((mkdir(buffer, 0755) == -1) && (errno == ENOENT)) + { + fprintf(stderr,"%s: Couldn't create directory %s\n",prog,buffer); + free(buffer); + return 0; + } + if (hold == 0) + break; + *p++ = hold; + } + free(buffer); + return 1; +} + + +int matchname (int arg,int argc,char **argv,char *fname) +{ + if (arg == argc) /* no arguments given (untgz tgzarchive) */ + return 1; + + while (arg < argc) + if (ExprMatch(fname,argv[arg++])) + return 1; + + return 0; /* ignore this for the moment being */ +} + + +/* tar file list or extract */ + +int tar (gzFile in,int action,int arg,int argc,char **argv) +{ + union tar_buffer buffer; + int len; + int err; + int getheader = 1; + int remaining = 0; + FILE *outfile = NULL; + char fname[BLOCKSIZE]; + int tarmode; + time_t tartime; + struct attr_item *attributes = NULL; + + if (action == TGZ_LIST) + printf(" date time size file\n" + " ---------- -------- --------- -------------------------------------\n"); + while (1) + { + len = gzread(in, &buffer, BLOCKSIZE); + if (len < 0) + error(gzerror(in, &err)); + /* + * Always expect complete blocks to process + * the tar information. + */ + if (len != BLOCKSIZE) + { + action = TGZ_INVALID; /* force error exit */ + remaining = 0; /* force I/O cleanup */ + } + + /* + * If we have to get a tar header + */ + if (getheader >= 1) + { + /* + * if we met the end of the tar + * or the end-of-tar block, + * we are done + */ + if (len == 0 || buffer.header.name[0] == 0) + break; + + tarmode = getoct(buffer.header.mode,8); + tartime = (time_t)getoct(buffer.header.mtime,12); + if (tarmode == -1 || tartime == (time_t)-1) + { + buffer.header.name[0] = 0; + action = TGZ_INVALID; + } + + if (getheader == 1) + { + strncpy(fname,buffer.header.name,SHORTNAMESIZE); + if (fname[SHORTNAMESIZE-1] != 0) + fname[SHORTNAMESIZE] = 0; + } + else + { + /* + * The file name is longer than SHORTNAMESIZE + */ + if (strncmp(fname,buffer.header.name,SHORTNAMESIZE-1) != 0) + error("bad long name"); + getheader = 1; + } + + /* + * Act according to the type flag + */ + switch (buffer.header.typeflag) + { + case DIRTYPE: + if (action == TGZ_LIST) + printf(" %s %s\n",strtime(&tartime),fname); + if (action == TGZ_EXTRACT) + { + makedir(fname); + push_attr(&attributes,fname,tarmode,tartime); + } + break; + case REGTYPE: + case AREGTYPE: + remaining = getoct(buffer.header.size,12); + if (remaining == -1) + { + action = TGZ_INVALID; + break; + } + if (action == TGZ_LIST) + printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); + else if (action == TGZ_EXTRACT) + { + if (matchname(arg,argc,argv,fname)) + { + outfile = fopen(fname,"wb"); + if (outfile == NULL) { + /* try creating directory */ + char *p = strrchr(fname, '/'); + if (p != NULL) { + *p = '\0'; + makedir(fname); + *p = '/'; + outfile = fopen(fname,"wb"); + } + } + if (outfile != NULL) + printf("Extracting %s\n",fname); + else + fprintf(stderr, "%s: Couldn't create %s",prog,fname); + } + else + outfile = NULL; + } + getheader = 0; + break; + case GNUTYPE_LONGLINK: + case GNUTYPE_LONGNAME: + remaining = getoct(buffer.header.size,12); + if (remaining < 0 || remaining >= BLOCKSIZE) + { + action = TGZ_INVALID; + break; + } + len = gzread(in, fname, BLOCKSIZE); + if (len < 0) + error(gzerror(in, &err)); + if (fname[BLOCKSIZE-1] != 0 || (int)strlen(fname) > remaining) + { + action = TGZ_INVALID; + break; + } + getheader = 2; + break; + default: + if (action == TGZ_LIST) + printf(" %s <---> %s\n",strtime(&tartime),fname); + break; + } + } + else + { + unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; + + if (outfile != NULL) + { + if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) + { + fprintf(stderr, + "%s: Error writing %s -- skipping\n",prog,fname); + fclose(outfile); + outfile = NULL; + remove(fname); + } + } + remaining -= bytes; + } + + if (remaining == 0) + { + getheader = 1; + if (outfile != NULL) + { + fclose(outfile); + outfile = NULL; + if (action != TGZ_INVALID) + push_attr(&attributes,fname,tarmode,tartime); + } + } + + /* + * Abandon if errors are found + */ + if (action == TGZ_INVALID) + { + error("broken archive"); + break; + } + } + + /* + * Restore file modes and time stamps + */ + restore_attr(&attributes); + + if (gzclose(in) != Z_OK) + error("failed gzclose"); + + return 0; +} + + +/* ============================================================ */ + +void help(int exitval) +{ + printf("untgz version 0.2.1\n" + " using zlib version %s\n\n", + zlibVersion()); + printf("Usage: untgz file.tgz extract all files\n" + " untgz file.tgz fname ... extract selected files\n" + " untgz -l file.tgz list archive contents\n" + " untgz -h display this help\n"); + exit(exitval); +} + +void error(const char *msg) +{ + fprintf(stderr, "%s: %s\n", prog, msg); + exit(1); +} + + +/* ============================================================ */ + +#if defined(WIN32) && defined(__GNUC__) +int _CRT_glob = 0; /* disable argument globbing in MinGW */ +#endif + +int main(int argc,char **argv) +{ + int action = TGZ_EXTRACT; + int arg = 1; + char *TGZfile; + gzFile *f; + + prog = strrchr(argv[0],'\\'); + if (prog == NULL) + { + prog = strrchr(argv[0],'/'); + if (prog == NULL) + { + prog = strrchr(argv[0],':'); + if (prog == NULL) + prog = argv[0]; + else + prog++; + } + else + prog++; + } + else + prog++; + + if (argc == 1) + help(0); + + if (strcmp(argv[arg],"-l") == 0) + { + action = TGZ_LIST; + if (argc == ++arg) + help(0); + } + else if (strcmp(argv[arg],"-h") == 0) + { + help(0); + } + + if ((TGZfile = TGZfname(argv[arg])) == NULL) + TGZnotfound(argv[arg]); + + ++arg; + if ((action == TGZ_LIST) && (arg != argc)) + help(1); + +/* + * Process the TGZ file + */ + switch(action) + { + case TGZ_LIST: + case TGZ_EXTRACT: + f = gzopen(TGZfile,"rb"); + if (f == NULL) + { + fprintf(stderr,"%s: Couldn't gzopen %s\n",prog,TGZfile); + return 1; + } + exit(tar(f, action, arg, argc, argv)); + break; + + default: + error("Unknown option"); + exit(1); + } + + return 0; +} diff --git a/xs/src/png/zlib/contrib/vstudio/readme.txt b/xs/src/png/zlib/contrib/vstudio/readme.txt new file mode 100644 index 0000000000..48cccc0d2a --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/readme.txt @@ -0,0 +1,78 @@ +Building instructions for the DLL versions of Zlib 1.2.11 +======================================================== + +This directory contains projects that build zlib and minizip using +Microsoft Visual C++ 9.0/10.0. + +You don't need to build these projects yourself. You can download the +binaries from: + http://www.winimage.com/zLibDll + +More information can be found at this site. + + + + + +Build instructions for Visual Studio 2008 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Compile assembly code (with Visual Studio Command Prompt) by running: + bld_ml64.bat (in contrib\masmx64) + bld_ml32.bat (in contrib\masmx86) +- Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008 +- Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32" + +Build instructions for Visual Studio 2010 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc10\zlibvc.sln with Microsoft Visual C++ 2010 + +Build instructions for Visual Studio 2012 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc11\zlibvc.sln with Microsoft Visual C++ 2012 + +Build instructions for Visual Studio 2013 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc12\zlibvc.sln with Microsoft Visual C++ 2013 + +Build instructions for Visual Studio 2015 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc14\zlibvc.sln with Microsoft Visual C++ 2015 + + +Important +--------- +- To use zlibwapi.dll in your application, you must define the + macro ZLIB_WINAPI when compiling your application's source files. + + +Additional notes +---------------- +- This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built + by Gilles Vollant from the zlib 1.1.x sources, and distributed at + http://www.winimage.com/zLibDll + It uses the WINAPI calling convention for the exported functions, and + includes the minizip functionality. If your application needs that + particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll. + +- The new DLL was renamed because there exist several incompatible + versions of zlib.dll on the Internet. + +- There is also an official DLL build of zlib, named zlib1.dll. This one + is exporting the functions using the CDECL convention. See the file + win32\DLL_FAQ.txt found in this zlib distribution. + +- There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol + has a slightly different effect. To avoid compatibility problems, do + not define it here. + + +Gilles Vollant +info@winimage.com + +Visual Studio 2013 and 2015 Projects from Sean Hunt +seandhunt_7@yahoo.com diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/miniunz.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc10/miniunz.vcxproj new file mode 100644 index 0000000000..1b3624215a --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/miniunz.vcxproj @@ -0,0 +1,310 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694382A} + Win32Proj + + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + true + false + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + true + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + true + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + false + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebug + false + + + $(IntDir) + Level3 + EditAndContinue + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters b/xs/src/png/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters new file mode 100644 index 0000000000..0bd12210ca --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {048af943-022b-4db6-beeb-a54c34774ee2} + cpp;c;cxx;def;odl;idl;hpj;bat;asm + + + {c1d600d2-888f-4aea-b73e-8b0dd9befa0c} + h;hpp;hxx;hm;inl;inc + + + {0844199a-966b-4f19-81db-1e0125e141b9} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/minizip.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc10/minizip.vcxproj new file mode 100644 index 0000000000..ccd3651df6 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/minizip.vcxproj @@ -0,0 +1,307 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} + Win32Proj + + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + true + false + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + false + x64\$(Configuration)\ + x64\$(Configuration)\ + true + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + true + false + x64\$(Configuration)\ + x64\$(Configuration)\ + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebug + false + + + $(IntDir) + Level3 + EditAndContinue + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters b/xs/src/png/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters new file mode 100644 index 0000000000..7076d76ff6 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {c0419b40-bf50-40da-b153-ff74215b79de} + cpp;c;cxx;def;odl;idl;hpj;bat;asm + + + {bb87b070-735b-478e-92ce-7383abb2f36c} + h;hpp;hxx;hm;inl;inc + + + {f46ab6a6-548f-43cb-ae96-681abb5bd5db} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/testzlib.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc10/testzlib.vcxproj new file mode 100644 index 0000000000..476b8ea453 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/testzlib.vcxproj @@ -0,0 +1,420 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} + testzlib + Win32Proj + + + + Application + MultiByte + true + + + Application + MultiByte + true + + + Application + MultiByte + + + Application + MultiByte + true + + + Application + MultiByte + true + + + Application + MultiByte + + + Application + true + + + Application + true + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + true + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + true + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebug + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + EditAndContinue + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters b/xs/src/png/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters new file mode 100644 index 0000000000..3276491039 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters @@ -0,0 +1,58 @@ + + + + + {c1f6a2e3-5da5-4955-8653-310d3efe05a9} + cpp;c;cxx;def;odl;idl;hpj;bat;asm + + + {c2aaffdc-2c95-4d6f-8466-4bec5890af2c} + h;hpp;hxx;hm;inl;inc + + + {c274fe07-05f2-461c-964b-f6341e4e7eb5} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj new file mode 100644 index 0000000000..8e38876fa3 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj @@ -0,0 +1,310 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694366A} + Win32Proj + + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + true + false + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + true + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + true + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + false + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebug + false + + + $(IntDir) + Level3 + EditAndContinue + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters b/xs/src/png/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters new file mode 100644 index 0000000000..ab87f09f47 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {fa61a89f-93fc-4c89-b29e-36224b7592f4} + cpp;c;cxx;def;odl;idl;hpj;bat;asm + + + {d4b85da0-2ba2-4934-b57f-e2584e3848ee} + h;hpp;hxx;hm;inl;inc + + + {e573e075-00bd-4a7d-bd67-a8cc9bfc5aca} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/zlib.rc b/xs/src/png/zlib/contrib/vstudio/vc10/zlib.rc new file mode 100644 index 0000000000..c4e4b016e9 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.2.11\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/zlibstat.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc10/zlibstat.vcxproj new file mode 100644 index 0000000000..45389a3521 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/zlibstat.vcxproj @@ -0,0 +1,473 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDebug + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + Itanium + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters b/xs/src/png/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters new file mode 100644 index 0000000000..0c8b2501cc --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters @@ -0,0 +1,77 @@ + + + + + {174213f6-7f66-4ae8-a3a8-a1e0a1e6ffdd} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.def b/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.def new file mode 100644 index 0000000000..f876c3bcab --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.def @@ -0,0 +1,153 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.2 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.sln b/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.sln new file mode 100644 index 0000000000..649f40c7ea --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.sln @@ -0,0 +1,135 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Itanium = Debug|Itanium + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Itanium = Release|Itanium + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.Build.0 = Debug|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.Build.0 = Release|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.Build.0 = Debug|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.Build.0 = Release|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.Build.0 = Debug|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.Build.0 = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.Build.0 = Debug|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.Build.0 = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.vcxproj new file mode 100644 index 0000000000..7d7c49a6dd --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.vcxproj @@ -0,0 +1,657 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {8FD826F8-3739-44E6-8CC8-997122E53B8D} + + + + DynamicLibrary + false + true + + + DynamicLibrary + false + true + + + DynamicLibrary + false + + + DynamicLibrary + false + true + + + DynamicLibrary + false + true + + + DynamicLibrary + false + + + DynamicLibrary + false + true + + + DynamicLibrary + false + true + + + DynamicLibrary + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + true + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + true + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + true + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + zlibwapid + zlibwapi + zlibwapi + zlibwapid + zlibwapi + zlibwapi + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + + + MultiThreadedDebug + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + true + .\zlibvc.def + true + true + Windows + false + + + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + true + false + .\zlibvc.def + true + Windows + false + + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + true + false + .\zlibvc.def + true + Windows + false + + + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + true + .\zlibvc.def + true + true + Windows + MachineX64 + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + true + false + .\zlibvc.def + true + Windows + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + true + false + .\zlibvc.def + true + Windows + MachineX64 + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters b/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters new file mode 100644 index 0000000000..22786824fc --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters @@ -0,0 +1,118 @@ + + + + + {07934a85-8b61-443d-a0ee-b2eedb74f3cd} + cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90 + + + {1d99675b-433d-4a21-9e50-ed4ab8b19762} + h;hpp;hxx;hm;inl;fi;fd + + + {431c0958-fa71-44d0-9084-2d19d100c0cc} + ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/miniunz.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc11/miniunz.vcxproj new file mode 100644 index 0000000000..99be63d69c --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/miniunz.vcxproj @@ -0,0 +1,314 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694382A} + Win32Proj + + + + Application + MultiByte + v110 + + + Application + Unicode + v110 + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + true + false + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + true + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + true + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + false + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/minizip.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc11/minizip.vcxproj new file mode 100644 index 0000000000..d6e98f4d57 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/minizip.vcxproj @@ -0,0 +1,311 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} + Win32Proj + + + + Application + MultiByte + v110 + + + Application + Unicode + v110 + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + true + false + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + false + x64\$(Configuration)\ + x64\$(Configuration)\ + true + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + true + false + x64\$(Configuration)\ + x64\$(Configuration)\ + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/testzlib.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc11/testzlib.vcxproj new file mode 100644 index 0000000000..0115dd17b9 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/testzlib.vcxproj @@ -0,0 +1,426 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} + testzlib + Win32Proj + + + + Application + MultiByte + true + v110 + + + Application + MultiByte + true + v110 + + + Application + Unicode + v110 + + + Application + MultiByte + true + + + Application + MultiByte + true + + + Application + MultiByte + + + Application + true + v110 + + + Application + true + v110 + + + Application + v110 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + true + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + true + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj new file mode 100644 index 0000000000..9d36336eb8 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj @@ -0,0 +1,314 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694366A} + Win32Proj + + + + Application + MultiByte + v110 + + + Application + Unicode + v110 + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + true + false + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + true + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + true + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + false + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/zlib.rc b/xs/src/png/zlib/contrib/vstudio/vc11/zlib.rc new file mode 100644 index 0000000000..c4e4b016e9 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.2.11\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/zlibstat.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc11/zlibstat.vcxproj new file mode 100644 index 0000000000..64b4d869dc --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/zlibstat.vcxproj @@ -0,0 +1,464 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + + + + StaticLibrary + false + v110 + + + StaticLibrary + false + v110 + + + StaticLibrary + false + v110 + Unicode + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + v110 + + + StaticLibrary + false + v110 + + + StaticLibrary + false + v110 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.def b/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.def new file mode 100644 index 0000000000..f876c3bcab --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.def @@ -0,0 +1,153 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.2 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.sln b/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.sln new file mode 100644 index 0000000000..b7e3812661 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.sln @@ -0,0 +1,117 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Itanium = Debug|Itanium + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Itanium = Release|Itanium + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.vcxproj new file mode 100644 index 0000000000..c4cffccf1d --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc11/zlibvc.vcxproj @@ -0,0 +1,688 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {8FD826F8-3739-44E6-8CC8-997122E53B8D} + + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + v110 + Unicode + + + DynamicLibrary + false + true + + + DynamicLibrary + false + true + + + DynamicLibrary + false + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + v110 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + true + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + true + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + true + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\contrib\masmx64 +bld_ml64.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/miniunz.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc12/miniunz.vcxproj new file mode 100644 index 0000000000..d88ac7fc7d --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/miniunz.vcxproj @@ -0,0 +1,316 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694382A} + Win32Proj + + + + Application + MultiByte + v120 + + + Application + Unicode + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + true + false + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + true + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + true + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + false + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/minizip.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc12/minizip.vcxproj new file mode 100644 index 0000000000..f1f239c9e0 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/minizip.vcxproj @@ -0,0 +1,313 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} + Win32Proj + + + + Application + MultiByte + v120 + + + Application + Unicode + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + true + false + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + false + x64\$(Configuration)\ + x64\$(Configuration)\ + true + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + true + false + x64\$(Configuration)\ + x64\$(Configuration)\ + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/testzlib.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc12/testzlib.vcxproj new file mode 100644 index 0000000000..64b2cbe34a --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/testzlib.vcxproj @@ -0,0 +1,430 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} + testzlib + Win32Proj + + + + Application + MultiByte + true + v120 + + + Application + MultiByte + true + v120 + + + Application + Unicode + v120 + + + Application + MultiByte + true + v120 + + + Application + MultiByte + true + v120 + + + Application + MultiByte + v120 + + + Application + true + v120 + + + Application + true + v120 + + + Application + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + true + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + true + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + false + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj new file mode 100644 index 0000000000..c66573a8bf --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj @@ -0,0 +1,316 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694366A} + Win32Proj + + + + Application + MultiByte + v120 + + + Application + Unicode + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + true + false + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + true + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + true + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + false + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/zlib.rc b/xs/src/png/zlib/contrib/vstudio/vc12/zlib.rc new file mode 100644 index 0000000000..c4e4b016e9 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.2.11\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/zlibstat.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc12/zlibstat.vcxproj new file mode 100644 index 0000000000..3fdee7c507 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/zlibstat.vcxproj @@ -0,0 +1,467 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + Unicode + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.def b/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.def new file mode 100644 index 0000000000..f876c3bcab --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.def @@ -0,0 +1,153 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.2 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.sln b/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.sln new file mode 100644 index 0000000000..dcda229849 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.sln @@ -0,0 +1,119 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Itanium = Debug|Itanium + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Itanium = Release|Itanium + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.vcxproj new file mode 100644 index 0000000000..ab2b6c3603 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc12/zlibvc.vcxproj @@ -0,0 +1,692 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {8FD826F8-3739-44E6-8CC8-997122E53B8D} + + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + v120 + Unicode + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + true + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + true + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + true + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + false + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\contrib\masmx64 +bld_ml64.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/miniunz.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc14/miniunz.vcxproj new file mode 100644 index 0000000000..9b5c07587d --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/miniunz.vcxproj @@ -0,0 +1,316 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694382A} + Win32Proj + + + + Application + MultiByte + v140 + + + Application + Unicode + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + true + false + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + true + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + true + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + false + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/minizip.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc14/minizip.vcxproj new file mode 100644 index 0000000000..968a410a12 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/minizip.vcxproj @@ -0,0 +1,313 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} + Win32Proj + + + + Application + MultiByte + v140 + + + Application + Unicode + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + true + false + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + false + x64\$(Configuration)\ + x64\$(Configuration)\ + true + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + true + false + x64\$(Configuration)\ + x64\$(Configuration)\ + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/testzlib.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc14/testzlib.vcxproj new file mode 100644 index 0000000000..2c371252ae --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/testzlib.vcxproj @@ -0,0 +1,430 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} + testzlib + Win32Proj + + + + Application + MultiByte + true + v140 + + + Application + MultiByte + true + v140 + + + Application + Unicode + v140 + + + Application + MultiByte + true + v140 + + + Application + MultiByte + true + v140 + + + Application + MultiByte + v140 + + + Application + true + v140 + + + Application + true + v140 + + + Application + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + true + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + true + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + false + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj new file mode 100644 index 0000000000..d87474dec6 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj @@ -0,0 +1,316 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694366A} + Win32Proj + + + + Application + MultiByte + v140 + + + Application + Unicode + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + true + false + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + true + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + true + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + false + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/zlib.rc b/xs/src/png/zlib/contrib/vstudio/vc14/zlib.rc new file mode 100644 index 0000000000..c4e4b016e9 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.2.11\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/zlibstat.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc14/zlibstat.vcxproj new file mode 100644 index 0000000000..3e4b986392 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/zlibstat.vcxproj @@ -0,0 +1,467 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + Unicode + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.def b/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.def new file mode 100644 index 0000000000..f876c3bcab --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.def @@ -0,0 +1,153 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.2 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.sln b/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.sln new file mode 100644 index 0000000000..6f4a1076a4 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.sln @@ -0,0 +1,119 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Itanium = Debug|Itanium + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Itanium = Release|Itanium + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.vcxproj b/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.vcxproj new file mode 100644 index 0000000000..f8f673cb05 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc14/zlibvc.vcxproj @@ -0,0 +1,692 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {8FD826F8-3739-44E6-8CC8-997122E53B8D} + + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + v140 + Unicode + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + true + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + true + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + true + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + false + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\contrib\masmx64 +bld_ml64.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/miniunz.vcproj b/xs/src/png/zlib/contrib/vstudio/vc9/miniunz.vcproj new file mode 100644 index 0000000000..038a9e5faf --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/miniunz.vcproj @@ -0,0 +1,565 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/minizip.vcproj b/xs/src/png/zlib/contrib/vstudio/vc9/minizip.vcproj new file mode 100644 index 0000000000..ad40239914 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/minizip.vcproj @@ -0,0 +1,562 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/testzlib.vcproj b/xs/src/png/zlib/contrib/vstudio/vc9/testzlib.vcproj new file mode 100644 index 0000000000..c9f19d24ef --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/testzlib.vcproj @@ -0,0 +1,852 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/testzlibdll.vcproj b/xs/src/png/zlib/contrib/vstudio/vc9/testzlibdll.vcproj new file mode 100644 index 0000000000..d7530fd7dc --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/testzlibdll.vcproj @@ -0,0 +1,565 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/zlib.rc b/xs/src/png/zlib/contrib/vstudio/vc9/zlib.rc new file mode 100644 index 0000000000..c4e4b016e9 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.2.11\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/zlibstat.vcproj b/xs/src/png/zlib/contrib/vstudio/vc9/zlibstat.vcproj new file mode 100644 index 0000000000..d4ffb46b24 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/zlibstat.vcproj @@ -0,0 +1,835 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.def b/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.def new file mode 100644 index 0000000000..f876c3bcab --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.def @@ -0,0 +1,153 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.2 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.sln b/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.sln new file mode 100644 index 0000000000..75c64c3f4a --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.sln @@ -0,0 +1,144 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestZlibDll", "testzlibdll.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" + ProjectSection(ProjectDependencies) = postProject + {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" + ProjectSection(ProjectDependencies) = postProject + {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" + ProjectSection(ProjectDependencies) = postProject + {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Itanium = Debug|Itanium + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Itanium = Release|Itanium + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.Build.0 = Debug|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.Build.0 = Release|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.Build.0 = Debug|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.Build.0 = Release|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.Build.0 = Debug|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.Build.0 = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.Build.0 = Debug|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.Build.0 = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.vcproj b/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.vcproj new file mode 100644 index 0000000000..95bb241f30 --- /dev/null +++ b/xs/src/png/zlib/contrib/vstudio/vc9/zlibvc.vcproj @@ -0,0 +1,1156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/png/zlib/crc32.c b/xs/src/png/zlib/crc32.c new file mode 100644 index 0000000000..9580440c0e --- /dev/null +++ b/xs/src/png/zlib/crc32.c @@ -0,0 +1,442 @@ +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Thanks to Rodney Brown for his contribution of faster + * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing + * tables for updating the shift register in one step with three exclusive-ors + * instead of four steps with four exclusive-ors. This results in about a + * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. + */ + +/* @(#) $Id$ */ + +/* + Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore + protection on the static variables used to control the first-use generation + of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should + first call get_crc_table() to initialize the tables before allowing more than + one thread to use crc32(). + + DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. + */ + +#ifdef MAKECRCH +# include +# ifndef DYNAMIC_CRC_TABLE +# define DYNAMIC_CRC_TABLE +# endif /* !DYNAMIC_CRC_TABLE */ +#endif /* MAKECRCH */ + +#include "zutil.h" /* for STDC and FAR definitions */ + +/* Definitions for doing the crc four data bytes at a time. */ +#if !defined(NOBYFOUR) && defined(Z_U4) +# define BYFOUR +#endif +#ifdef BYFOUR + local unsigned long crc32_little OF((unsigned long, + const unsigned char FAR *, z_size_t)); + local unsigned long crc32_big OF((unsigned long, + const unsigned char FAR *, z_size_t)); +# define TBLS 8 +#else +# define TBLS 1 +#endif /* BYFOUR */ + +/* Local functions for crc concatenation */ +local unsigned long gf2_matrix_times OF((unsigned long *mat, + unsigned long vec)); +local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); +local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); + + +#ifdef DYNAMIC_CRC_TABLE + +local volatile int crc_table_empty = 1; +local z_crc_t FAR crc_table[TBLS][256]; +local void make_crc_table OF((void)); +#ifdef MAKECRCH + local void write_table OF((FILE *, const z_crc_t FAR *)); +#endif /* MAKECRCH */ +/* + Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The first table is simply the CRC of all possible eight bit values. This is + all the information needed to generate CRCs on data a byte at a time for all + combinations of CRC register values and incoming bytes. The remaining tables + allow for word-at-a-time CRC calculation for both big-endian and little- + endian machines, where a word is four bytes. +*/ +local void make_crc_table() +{ + z_crc_t c; + int n, k; + z_crc_t poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static volatile int first = 1; /* flag to limit concurrent making */ + static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* See if another task is already doing this (not thread-safe, but better + than nothing -- significantly reduces duration of vulnerability in + case the advice about DYNAMIC_CRC_TABLE is ignored) */ + if (first) { + first = 0; + + /* make exclusive-or pattern from polynomial (0xedb88320UL) */ + poly = 0; + for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) + poly |= (z_crc_t)1 << (31 - p[n]); + + /* generate a crc for every 8-bit value */ + for (n = 0; n < 256; n++) { + c = (z_crc_t)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[0][n] = c; + } + +#ifdef BYFOUR + /* generate crc for each value followed by one, two, and three zeros, + and then the byte reversal of those as well as the first table */ + for (n = 0; n < 256; n++) { + c = crc_table[0][n]; + crc_table[4][n] = ZSWAP32(c); + for (k = 1; k < 4; k++) { + c = crc_table[0][c & 0xff] ^ (c >> 8); + crc_table[k][n] = c; + crc_table[k + 4][n] = ZSWAP32(c); + } + } +#endif /* BYFOUR */ + + crc_table_empty = 0; + } + else { /* not first */ + /* wait for the other guy to finish (not efficient, but rare) */ + while (crc_table_empty) + ; + } + +#ifdef MAKECRCH + /* write out CRC tables to crc32.h */ + { + FILE *out; + + out = fopen("crc32.h", "w"); + if (out == NULL) return; + fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); + fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); + fprintf(out, "local const z_crc_t FAR "); + fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); + write_table(out, crc_table[0]); +# ifdef BYFOUR + fprintf(out, "#ifdef BYFOUR\n"); + for (k = 1; k < 8; k++) { + fprintf(out, " },\n {\n"); + write_table(out, crc_table[k]); + } + fprintf(out, "#endif\n"); +# endif /* BYFOUR */ + fprintf(out, " }\n};\n"); + fclose(out); + } +#endif /* MAKECRCH */ +} + +#ifdef MAKECRCH +local void write_table(out, table) + FILE *out; + const z_crc_t FAR *table; +{ + int n; + + for (n = 0; n < 256; n++) + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", + (unsigned long)(table[n]), + n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); +} +#endif /* MAKECRCH */ + +#else /* !DYNAMIC_CRC_TABLE */ +/* ======================================================================== + * Tables of CRC-32s of all single-byte values, made by make_crc_table(). + */ +#include "crc32.h" +#endif /* DYNAMIC_CRC_TABLE */ + +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const z_crc_t FAR * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + return (const z_crc_t FAR *)crc_table; +} + +/* ========================================================================= */ +#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) +#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 + +/* ========================================================================= */ +unsigned long ZEXPORT crc32_z(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + z_size_t len; +{ + if (buf == Z_NULL) return 0UL; + +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + +#ifdef BYFOUR + if (sizeof(void *) == sizeof(ptrdiff_t)) { + z_crc_t endian; + + endian = 1; + if (*((unsigned char *)(&endian))) + return crc32_little(crc, buf, len); + else + return crc32_big(crc, buf, len); + } +#endif /* BYFOUR */ + crc = crc ^ 0xffffffffUL; + while (len >= 8) { + DO8; + len -= 8; + } + if (len) do { + DO1; + } while (--len); + return crc ^ 0xffffffffUL; +} + +/* ========================================================================= */ +unsigned long ZEXPORT crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + uInt len; +{ + return crc32_z(crc, buf, len); +} + +#ifdef BYFOUR + +/* + This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit + integer pointer type. This violates the strict aliasing rule, where a + compiler can assume, for optimization purposes, that two pointers to + fundamentally different types won't ever point to the same memory. This can + manifest as a problem only if one of the pointers is written to. This code + only reads from those pointers. So long as this code remains isolated in + this compilation unit, there won't be a problem. For this reason, this code + should not be copied and pasted into a compilation unit in which other code + writes to the buffer that is passed to these routines. + */ + +/* ========================================================================= */ +#define DOLIT4 c ^= *buf4++; \ + c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ + crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] +#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 + +/* ========================================================================= */ +local unsigned long crc32_little(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + z_size_t len; +{ + register z_crc_t c; + register const z_crc_t FAR *buf4; + + c = (z_crc_t)crc; + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + len--; + } + + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; + while (len >= 32) { + DOLIT32; + len -= 32; + } + while (len >= 4) { + DOLIT4; + len -= 4; + } + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + } while (--len); + c = ~c; + return (unsigned long)c; +} + +/* ========================================================================= */ +#define DOBIG4 c ^= *buf4++; \ + c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ + crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] +#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 + +/* ========================================================================= */ +local unsigned long crc32_big(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + z_size_t len; +{ + register z_crc_t c; + register const z_crc_t FAR *buf4; + + c = ZSWAP32((z_crc_t)crc); + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + len--; + } + + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; + while (len >= 32) { + DOBIG32; + len -= 32; + } + while (len >= 4) { + DOBIG4; + len -= 4; + } + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + } while (--len); + c = ~c; + return (unsigned long)(ZSWAP32(c)); +} + +#endif /* BYFOUR */ + +#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ + +/* ========================================================================= */ +local unsigned long gf2_matrix_times(mat, vec) + unsigned long *mat; + unsigned long vec; +{ + unsigned long sum; + + sum = 0; + while (vec) { + if (vec & 1) + sum ^= *mat; + vec >>= 1; + mat++; + } + return sum; +} + +/* ========================================================================= */ +local void gf2_matrix_square(square, mat) + unsigned long *square; + unsigned long *mat; +{ + int n; + + for (n = 0; n < GF2_DIM; n++) + square[n] = gf2_matrix_times(mat, mat[n]); +} + +/* ========================================================================= */ +local uLong crc32_combine_(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off64_t len2; +{ + int n; + unsigned long row; + unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ + unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ + + /* degenerate case (also disallow negative lengths) */ + if (len2 <= 0) + return crc1; + + /* put operator for one zero bit in odd */ + odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ + row = 1; + for (n = 1; n < GF2_DIM; n++) { + odd[n] = row; + row <<= 1; + } + + /* put operator for two zero bits in even */ + gf2_matrix_square(even, odd); + + /* put operator for four zero bits in odd */ + gf2_matrix_square(odd, even); + + /* apply len2 zeros to crc1 (first square will put the operator for one + zero byte, eight zero bits, in even) */ + do { + /* apply zeros operator for this bit of len2 */ + gf2_matrix_square(even, odd); + if (len2 & 1) + crc1 = gf2_matrix_times(even, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + if (len2 == 0) + break; + + /* another iteration of the loop with odd and even swapped */ + gf2_matrix_square(odd, even); + if (len2 & 1) + crc1 = gf2_matrix_times(odd, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + } while (len2 != 0); + + /* return combined crc */ + crc1 ^= crc2; + return crc1; +} + +/* ========================================================================= */ +uLong ZEXPORT crc32_combine(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off_t len2; +{ + return crc32_combine_(crc1, crc2, len2); +} + +uLong ZEXPORT crc32_combine64(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off64_t len2; +{ + return crc32_combine_(crc1, crc2, len2); +} diff --git a/xs/src/png/zlib/crc32.h b/xs/src/png/zlib/crc32.h new file mode 100644 index 0000000000..9e0c778102 --- /dev/null +++ b/xs/src/png/zlib/crc32.h @@ -0,0 +1,441 @@ +/* crc32.h -- tables for rapid CRC calculation + * Generated automatically by crc32.c + */ + +local const z_crc_t FAR crc_table[TBLS][256] = +{ + { + 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, + 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, + 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, + 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, + 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, + 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, + 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, + 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, + 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, + 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, + 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, + 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, + 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, + 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, + 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, + 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, + 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, + 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, + 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, + 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, + 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, + 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, + 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, + 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, + 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, + 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, + 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, + 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, + 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, + 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, + 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, + 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, + 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, + 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, + 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, + 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, + 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, + 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, + 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, + 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, + 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, + 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, + 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, + 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, + 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, + 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, + 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, + 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, + 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, + 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, + 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, + 0x2d02ef8dUL +#ifdef BYFOUR + }, + { + 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, + 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, + 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, + 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, + 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, + 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, + 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, + 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, + 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, + 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, + 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, + 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, + 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, + 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, + 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, + 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, + 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, + 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, + 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, + 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, + 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, + 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, + 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, + 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, + 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, + 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, + 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, + 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, + 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, + 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, + 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, + 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, + 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, + 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, + 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, + 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, + 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, + 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, + 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, + 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, + 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, + 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, + 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, + 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, + 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, + 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, + 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, + 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, + 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, + 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, + 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, + 0x9324fd72UL + }, + { + 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, + 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, + 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, + 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, + 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, + 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, + 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, + 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, + 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, + 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, + 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, + 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, + 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, + 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, + 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, + 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, + 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, + 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, + 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, + 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, + 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, + 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, + 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, + 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, + 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, + 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, + 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, + 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, + 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, + 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, + 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, + 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, + 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, + 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, + 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, + 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, + 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, + 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, + 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, + 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, + 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, + 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, + 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, + 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, + 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, + 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, + 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, + 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, + 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, + 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, + 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, + 0xbe9834edUL + }, + { + 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, + 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, + 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, + 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, + 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, + 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, + 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, + 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, + 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, + 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, + 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, + 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, + 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, + 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, + 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, + 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, + 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, + 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, + 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, + 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, + 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, + 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, + 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, + 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, + 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, + 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, + 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, + 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, + 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, + 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, + 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, + 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, + 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, + 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, + 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, + 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, + 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, + 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, + 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, + 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, + 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, + 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, + 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, + 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, + 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, + 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, + 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, + 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, + 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, + 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, + 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, + 0xde0506f1UL + }, + { + 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, + 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, + 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, + 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, + 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, + 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, + 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, + 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, + 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, + 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, + 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, + 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, + 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, + 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, + 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, + 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, + 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, + 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, + 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, + 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, + 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, + 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, + 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, + 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, + 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, + 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, + 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, + 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, + 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, + 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, + 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, + 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, + 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, + 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, + 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, + 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, + 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, + 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, + 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, + 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, + 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, + 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, + 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, + 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, + 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, + 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, + 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, + 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, + 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, + 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, + 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, + 0x8def022dUL + }, + { + 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, + 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, + 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, + 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, + 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, + 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, + 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, + 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, + 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, + 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, + 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, + 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, + 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, + 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, + 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, + 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, + 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, + 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, + 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, + 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, + 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, + 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, + 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, + 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, + 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, + 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, + 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, + 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, + 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, + 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, + 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, + 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, + 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, + 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, + 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, + 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, + 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, + 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, + 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, + 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, + 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, + 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, + 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, + 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, + 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, + 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, + 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, + 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, + 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, + 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, + 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, + 0x72fd2493UL + }, + { + 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, + 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, + 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, + 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, + 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, + 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, + 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, + 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, + 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, + 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, + 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, + 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, + 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, + 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, + 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, + 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, + 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, + 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, + 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, + 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, + 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, + 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, + 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, + 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, + 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, + 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, + 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, + 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, + 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, + 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, + 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, + 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, + 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, + 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, + 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, + 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, + 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, + 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, + 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, + 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, + 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, + 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, + 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, + 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, + 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, + 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, + 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, + 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, + 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, + 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, + 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, + 0xed3498beUL + }, + { + 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, + 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, + 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, + 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, + 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, + 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, + 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, + 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, + 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, + 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, + 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, + 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, + 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, + 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, + 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, + 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, + 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, + 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, + 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, + 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, + 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, + 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, + 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, + 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, + 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, + 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, + 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, + 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, + 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, + 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, + 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, + 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, + 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, + 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, + 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, + 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, + 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, + 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, + 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, + 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, + 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, + 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, + 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, + 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, + 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, + 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, + 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, + 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, + 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, + 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, + 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, + 0xf10605deUL +#endif + } +}; diff --git a/xs/src/png/zlib/deflate.c b/xs/src/png/zlib/deflate.c new file mode 100644 index 0000000000..1ec761448d --- /dev/null +++ b/xs/src/png/zlib/deflate.c @@ -0,0 +1,2163 @@ +/* deflate.c -- compress data using the deflation algorithm + * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process depends on being able to identify portions + * of the input text which are identical to earlier input (within a + * sliding window trailing behind the input currently being processed). + * + * The most straightforward technique turns out to be the fastest for + * most input files: try all possible matches and select the longest. + * The key feature of this algorithm is that insertions into the string + * dictionary are very simple and thus fast, and deletions are avoided + * completely. Insertions are performed at each input character, whereas + * string matches are performed only when the previous match ends. So it + * is preferable to spend more time in matches to allow very fast string + * insertions and avoid deletions. The matching algorithm for small + * strings is inspired from that of Rabin & Karp. A brute force approach + * is used to find longer strings when a small match has been found. + * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze + * (by Leonid Broukhis). + * A previous version of this file used a more sophisticated algorithm + * (by Fiala and Greene) which is guaranteed to run in linear amortized + * time, but has a larger average cost, uses more memory and is patented. + * However the F&G algorithm may be faster for some highly redundant + * files if the parameter max_chain_length (described below) is too large. + * + * ACKNOWLEDGEMENTS + * + * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and + * I found it in 'freeze' written by Leonid Broukhis. + * Thanks to many people for bug reports and testing. + * + * REFERENCES + * + * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". + * Available in http://tools.ietf.org/html/rfc1951 + * + * A description of the Rabin and Karp algorithm is given in the book + * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. + * + * Fiala,E.R., and Greene,D.H. + * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 + * + */ + +/* @(#) $Id$ */ + +#include "deflate.h" + +const char deflate_copyright[] = + " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* =========================================================================== + * Function prototypes. + */ +typedef enum { + need_more, /* block not completed, need more input or more output */ + block_done, /* block flush performed */ + finish_started, /* finish started, need only more output at next deflate */ + finish_done /* finish done, accept no more input or output */ +} block_state; + +typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +/* Compression function. Returns the block state after the call. */ + +local int deflateStateCheck OF((z_streamp strm)); +local void slide_hash OF((deflate_state *s)); +local void fill_window OF((deflate_state *s)); +local block_state deflate_stored OF((deflate_state *s, int flush)); +local block_state deflate_fast OF((deflate_state *s, int flush)); +#ifndef FASTEST +local block_state deflate_slow OF((deflate_state *s, int flush)); +#endif +local block_state deflate_rle OF((deflate_state *s, int flush)); +local block_state deflate_huff OF((deflate_state *s, int flush)); +local void lm_init OF((deflate_state *s)); +local void putShortMSB OF((deflate_state *s, uInt b)); +local void flush_pending OF((z_streamp strm)); +local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +#ifdef ASMV +# pragma message("Assembler code may have bugs -- use at your own risk") + void match_init OF((void)); /* asm code initialization */ + uInt longest_match OF((deflate_state *s, IPos cur_match)); +#else +local uInt longest_match OF((deflate_state *s, IPos cur_match)); +#endif + +#ifdef ZLIB_DEBUG +local void check_match OF((deflate_state *s, IPos start, IPos match, + int length)); +#endif + +/* =========================================================================== + * Local data + */ + +#define NIL 0 +/* Tail of hash chains */ + +#ifndef TOO_FAR +# define TOO_FAR 4096 +#endif +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ +typedef struct config_s { + ush good_length; /* reduce lazy search above this match length */ + ush max_lazy; /* do not perform lazy search above this match length */ + ush nice_length; /* quit search above this match length */ + ush max_chain; + compress_func func; +} config; + +#ifdef FASTEST +local const config configuration_table[2] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ +#else +local const config configuration_table[10] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ +/* 2 */ {4, 5, 16, 8, deflate_fast}, +/* 3 */ {4, 6, 32, 32, deflate_fast}, + +/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ +/* 5 */ {8, 16, 32, 32, deflate_slow}, +/* 6 */ {8, 16, 128, 128, deflate_slow}, +/* 7 */ {8, 32, 128, 256, deflate_slow}, +/* 8 */ {32, 128, 258, 1024, deflate_slow}, +/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ +#endif + +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ + +/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ +#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0)) + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to UPDATE_HASH are made with consecutive input + * characters, so that a running hash key can be computed from the previous + * key instead of complete recalculation each time. + */ +#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) + + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * If this file is compiled with -DFASTEST, the compression level is forced + * to 1, and no hash chains are maintained. + * IN assertion: all calls to INSERT_STRING are made with consecutive input + * characters and the first MIN_MATCH bytes of str are valid (except for + * the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef FASTEST +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#else +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#endif + +/* =========================================================================== + * Initialize the hash table (avoiding 64K overflow for 16 bit systems). + * prev[] will be initialized on the fly. + */ +#define CLEAR_HASH(s) \ + s->head[s->hash_size-1] = NIL; \ + zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + +/* =========================================================================== + * Slide the hash table when sliding the window down (could be avoided with 32 + * bit values at the expense of memory usage). We slide even when level == 0 to + * keep the hash table consistent if we switch back to level > 0 later. + */ +local void slide_hash(s) + deflate_state *s; +{ + unsigned n, m; + Posf *p; + uInt wsize = s->w_size; + + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m - wsize : NIL); + } while (--n); + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m - wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif +} + +/* ========================================================================= */ +int ZEXPORT deflateInit_(strm, level, version, stream_size) + z_streamp strm; + int level; + const char *version; + int stream_size; +{ + return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, version, stream_size); + /* To do: ignore strm->next_in if we use it as window */ +} + +/* ========================================================================= */ +int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + version, stream_size) + z_streamp strm; + int level; + int method; + int windowBits; + int memLevel; + int strategy; + const char *version; + int stream_size; +{ + deflate_state *s; + int wrap = 1; + static const char my_version[] = ZLIB_VERSION; + + ushf *overlay; + /* We overlay pending_buf and d_buf+l_buf. This works since the average + * output size for (length,distance) codes is <= 24 bits. + */ + + if (version == Z_NULL || version[0] != my_version[0] || + stream_size != sizeof(z_stream)) { + return Z_VERSION_ERROR; + } + if (strm == Z_NULL) return Z_STREAM_ERROR; + + strm->msg = Z_NULL; + if (strm->zalloc == (alloc_func)0) { +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; +#endif + } + if (strm->zfree == (free_func)0) +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zfree = zcfree; +#endif + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + + if (windowBits < 0) { /* suppress zlib wrapper */ + wrap = 0; + windowBits = -windowBits; + } +#ifdef GZIP + else if (windowBits > 15) { + wrap = 2; /* write gzip wrapper instead */ + windowBits -= 16; + } +#endif + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || + windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || + strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) { + return Z_STREAM_ERROR; + } + if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ + s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); + if (s == Z_NULL) return Z_MEM_ERROR; + strm->state = (struct internal_state FAR *)s; + s->strm = strm; + s->status = INIT_STATE; /* to pass state test in deflateReset() */ + + s->wrap = wrap; + s->gzhead = Z_NULL; + s->w_bits = (uInt)windowBits; + s->w_size = 1 << s->w_bits; + s->w_mask = s->w_size - 1; + + s->hash_bits = (uInt)memLevel + 7; + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); + + s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + + s->high_water = 0; /* nothing written to s->window yet */ + + s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ + + overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + s->pending_buf = (uchf *) overlay; + s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + + if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || + s->pending_buf == Z_NULL) { + s->status = FINISH_STATE; + strm->msg = ERR_MSG(Z_MEM_ERROR); + deflateEnd (strm); + return Z_MEM_ERROR; + } + s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + + s->level = level; + s->strategy = strategy; + s->method = (Byte)method; + + return deflateReset(strm); +} + +/* ========================================================================= + * Check for a valid deflate stream state. Return 0 if ok, 1 if not. + */ +local int deflateStateCheck (strm) + z_streamp strm; +{ + deflate_state *s; + if (strm == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) + return 1; + s = strm->state; + if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE && +#ifdef GZIP + s->status != GZIP_STATE && +#endif + s->status != EXTRA_STATE && + s->status != NAME_STATE && + s->status != COMMENT_STATE && + s->status != HCRC_STATE && + s->status != BUSY_STATE && + s->status != FINISH_STATE)) + return 1; + return 0; +} + +/* ========================================================================= */ +int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) + z_streamp strm; + const Bytef *dictionary; + uInt dictLength; +{ + deflate_state *s; + uInt str, n; + int wrap; + unsigned avail; + z_const unsigned char *next; + + if (deflateStateCheck(strm) || dictionary == Z_NULL) + return Z_STREAM_ERROR; + s = strm->state; + wrap = s->wrap; + if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) + return Z_STREAM_ERROR; + + /* when using zlib wrappers, compute Adler-32 for provided dictionary */ + if (wrap == 1) + strm->adler = adler32(strm->adler, dictionary, dictLength); + s->wrap = 0; /* avoid computing Adler-32 in read_buf */ + + /* if dictionary would fill window, just replace the history */ + if (dictLength >= s->w_size) { + if (wrap == 0) { /* already empty otherwise */ + CLEAR_HASH(s); + s->strstart = 0; + s->block_start = 0L; + s->insert = 0; + } + dictionary += dictLength - s->w_size; /* use the tail */ + dictLength = s->w_size; + } + + /* insert dictionary into window and hash */ + avail = strm->avail_in; + next = strm->next_in; + strm->avail_in = dictLength; + strm->next_in = (z_const Bytef *)dictionary; + fill_window(s); + while (s->lookahead >= MIN_MATCH) { + str = s->strstart; + n = s->lookahead - (MIN_MATCH-1); + do { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + } while (--n); + s->strstart = str; + s->lookahead = MIN_MATCH-1; + fill_window(s); + } + s->strstart += s->lookahead; + s->block_start = (long)s->strstart; + s->insert = s->lookahead; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + strm->next_in = next; + strm->avail_in = avail; + s->wrap = wrap; + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength) + z_streamp strm; + Bytef *dictionary; + uInt *dictLength; +{ + deflate_state *s; + uInt len; + + if (deflateStateCheck(strm)) + return Z_STREAM_ERROR; + s = strm->state; + len = s->strstart + s->lookahead; + if (len > s->w_size) + len = s->w_size; + if (dictionary != Z_NULL && len) + zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len); + if (dictLength != Z_NULL) + *dictLength = len; + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateResetKeep (strm) + z_streamp strm; +{ + deflate_state *s; + + if (deflateStateCheck(strm)) { + return Z_STREAM_ERROR; + } + + strm->total_in = strm->total_out = 0; + strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ + strm->data_type = Z_UNKNOWN; + + s = (deflate_state *)strm->state; + s->pending = 0; + s->pending_out = s->pending_buf; + + if (s->wrap < 0) { + s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ + } + s->status = +#ifdef GZIP + s->wrap == 2 ? GZIP_STATE : +#endif + s->wrap ? INIT_STATE : BUSY_STATE; + strm->adler = +#ifdef GZIP + s->wrap == 2 ? crc32(0L, Z_NULL, 0) : +#endif + adler32(0L, Z_NULL, 0); + s->last_flush = Z_NO_FLUSH; + + _tr_init(s); + + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateReset (strm) + z_streamp strm; +{ + int ret; + + ret = deflateResetKeep(strm); + if (ret == Z_OK) + lm_init(strm->state); + return ret; +} + +/* ========================================================================= */ +int ZEXPORT deflateSetHeader (strm, head) + z_streamp strm; + gz_headerp head; +{ + if (deflateStateCheck(strm) || strm->state->wrap != 2) + return Z_STREAM_ERROR; + strm->state->gzhead = head; + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflatePending (strm, pending, bits) + unsigned *pending; + int *bits; + z_streamp strm; +{ + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; + if (pending != Z_NULL) + *pending = strm->state->pending; + if (bits != Z_NULL) + *bits = strm->state->bi_valid; + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflatePrime (strm, bits, value) + z_streamp strm; + int bits; + int value; +{ + deflate_state *s; + int put; + + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; + s = strm->state; + if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) + return Z_BUF_ERROR; + do { + put = Buf_size - s->bi_valid; + if (put > bits) + put = bits; + s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid); + s->bi_valid += put; + _tr_flush_bits(s); + value >>= put; + bits -= put; + } while (bits); + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateParams(strm, level, strategy) + z_streamp strm; + int level; + int strategy; +{ + deflate_state *s; + compress_func func; + + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; + s = strm->state; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { + return Z_STREAM_ERROR; + } + func = configuration_table[s->level].func; + + if ((strategy != s->strategy || func != configuration_table[level].func) && + s->high_water) { + /* Flush the last buffer: */ + int err = deflate(strm, Z_BLOCK); + if (err == Z_STREAM_ERROR) + return err; + if (strm->avail_out == 0) + return Z_BUF_ERROR; + } + if (s->level != level) { + if (s->level == 0 && s->matches != 0) { + if (s->matches == 1) + slide_hash(s); + else + CLEAR_HASH(s); + s->matches = 0; + } + s->level = level; + s->max_lazy_match = configuration_table[level].max_lazy; + s->good_match = configuration_table[level].good_length; + s->nice_match = configuration_table[level].nice_length; + s->max_chain_length = configuration_table[level].max_chain; + } + s->strategy = strategy; + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) + z_streamp strm; + int good_length; + int max_lazy; + int nice_length; + int max_chain; +{ + deflate_state *s; + + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; + s = strm->state; + s->good_match = (uInt)good_length; + s->max_lazy_match = (uInt)max_lazy; + s->nice_match = nice_length; + s->max_chain_length = (uInt)max_chain; + return Z_OK; +} + +/* ========================================================================= + * For the default windowBits of 15 and memLevel of 8, this function returns + * a close to exact, as well as small, upper bound on the compressed size. + * They are coded as constants here for a reason--if the #define's are + * changed, then this function needs to be changed as well. The return + * value for 15 and 8 only works for those exact settings. + * + * For any setting other than those defaults for windowBits and memLevel, + * the value returned is a conservative worst case for the maximum expansion + * resulting from using fixed blocks instead of stored blocks, which deflate + * can emit on compressed data for some combinations of the parameters. + * + * This function could be more sophisticated to provide closer upper bounds for + * every combination of windowBits and memLevel. But even the conservative + * upper bound of about 14% expansion does not seem onerous for output buffer + * allocation. + */ +uLong ZEXPORT deflateBound(strm, sourceLen) + z_streamp strm; + uLong sourceLen; +{ + deflate_state *s; + uLong complen, wraplen; + + /* conservative upper bound for compressed data */ + complen = sourceLen + + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; + + /* if can't get parameters, return conservative bound plus zlib wrapper */ + if (deflateStateCheck(strm)) + return complen + 6; + + /* compute wrapper length */ + s = strm->state; + switch (s->wrap) { + case 0: /* raw deflate */ + wraplen = 0; + break; + case 1: /* zlib wrapper */ + wraplen = 6 + (s->strstart ? 4 : 0); + break; +#ifdef GZIP + case 2: /* gzip wrapper */ + wraplen = 18; + if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ + Bytef *str; + if (s->gzhead->extra != Z_NULL) + wraplen += 2 + s->gzhead->extra_len; + str = s->gzhead->name; + if (str != Z_NULL) + do { + wraplen++; + } while (*str++); + str = s->gzhead->comment; + if (str != Z_NULL) + do { + wraplen++; + } while (*str++); + if (s->gzhead->hcrc) + wraplen += 2; + } + break; +#endif + default: /* for compiler happiness */ + wraplen = 6; + } + + /* if not default parameters, return conservative bound */ + if (s->w_bits != 15 || s->hash_bits != 8 + 7) + return complen + wraplen; + + /* default settings: return tight bound for that case */ + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + + (sourceLen >> 25) + 13 - 6 + wraplen; +} + +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +local void putShortMSB (s, b) + deflate_state *s; + uInt b; +{ + put_byte(s, (Byte)(b >> 8)); + put_byte(s, (Byte)(b & 0xff)); +} + +/* ========================================================================= + * Flush as much pending output as possible. All deflate() output, except for + * some deflate_stored() output, goes through this function so some + * applications may wish to modify it to avoid allocating a large + * strm->next_out buffer and copying into it. (See also read_buf()). + */ +local void flush_pending(strm) + z_streamp strm; +{ + unsigned len; + deflate_state *s = strm->state; + + _tr_flush_bits(s); + len = s->pending; + if (len > strm->avail_out) len = strm->avail_out; + if (len == 0) return; + + zmemcpy(strm->next_out, s->pending_out, len); + strm->next_out += len; + s->pending_out += len; + strm->total_out += len; + strm->avail_out -= len; + s->pending -= len; + if (s->pending == 0) { + s->pending_out = s->pending_buf; + } +} + +/* =========================================================================== + * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1]. + */ +#define HCRC_UPDATE(beg) \ + do { \ + if (s->gzhead->hcrc && s->pending > (beg)) \ + strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ + s->pending - (beg)); \ + } while (0) + +/* ========================================================================= */ +int ZEXPORT deflate (strm, flush) + z_streamp strm; + int flush; +{ + int old_flush; /* value of flush param for previous deflate call */ + deflate_state *s; + + if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { + return Z_STREAM_ERROR; + } + s = strm->state; + + if (strm->next_out == Z_NULL || + (strm->avail_in != 0 && strm->next_in == Z_NULL) || + (s->status == FINISH_STATE && flush != Z_FINISH)) { + ERR_RETURN(strm, Z_STREAM_ERROR); + } + if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); + + old_flush = s->last_flush; + s->last_flush = flush; + + /* Flush as much pending output as possible */ + if (s->pending != 0) { + flush_pending(strm); + if (strm->avail_out == 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUF_ERROR. + */ + } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && + flush != Z_FINISH) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s->status == FINISH_STATE && strm->avail_in != 0) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* Write the header */ + if (s->status == INIT_STATE) { + /* zlib header */ + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags; + + if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) + level_flags = 0; + else if (s->level < 6) + level_flags = 1; + else if (s->level == 6) + level_flags = 2; + else + level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = adler32(0L, Z_NULL, 0); + s->status = BUSY_STATE; + + /* Compression must start with an empty pending buffer */ + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } +#ifdef GZIP + if (s->status == GZIP_STATE) { + /* gzip header */ + strm->adler = crc32(0L, Z_NULL, 0); + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + if (s->gzhead == Z_NULL) { + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, OS_CODE); + s->status = BUSY_STATE; + + /* Compression must start with an empty pending buffer */ + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } + else { + put_byte(s, (s->gzhead->text ? 1 : 0) + + (s->gzhead->hcrc ? 2 : 0) + + (s->gzhead->extra == Z_NULL ? 0 : 4) + + (s->gzhead->name == Z_NULL ? 0 : 8) + + (s->gzhead->comment == Z_NULL ? 0 : 16) + ); + put_byte(s, (Byte)(s->gzhead->time & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, s->gzhead->os & 0xff); + if (s->gzhead->extra != Z_NULL) { + put_byte(s, s->gzhead->extra_len & 0xff); + put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); + } + if (s->gzhead->hcrc) + strm->adler = crc32(strm->adler, s->pending_buf, + s->pending); + s->gzindex = 0; + s->status = EXTRA_STATE; + } + } + if (s->status == EXTRA_STATE) { + if (s->gzhead->extra != Z_NULL) { + ulg beg = s->pending; /* start of bytes to update crc */ + uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex; + while (s->pending + left > s->pending_buf_size) { + uInt copy = s->pending_buf_size - s->pending; + zmemcpy(s->pending_buf + s->pending, + s->gzhead->extra + s->gzindex, copy); + s->pending = s->pending_buf_size; + HCRC_UPDATE(beg); + s->gzindex += copy; + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + beg = 0; + left -= copy; + } + zmemcpy(s->pending_buf + s->pending, + s->gzhead->extra + s->gzindex, left); + s->pending += left; + HCRC_UPDATE(beg); + s->gzindex = 0; + } + s->status = NAME_STATE; + } + if (s->status == NAME_STATE) { + if (s->gzhead->name != Z_NULL) { + ulg beg = s->pending; /* start of bytes to update crc */ + int val; + do { + if (s->pending == s->pending_buf_size) { + HCRC_UPDATE(beg); + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + beg = 0; + } + val = s->gzhead->name[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + HCRC_UPDATE(beg); + s->gzindex = 0; + } + s->status = COMMENT_STATE; + } + if (s->status == COMMENT_STATE) { + if (s->gzhead->comment != Z_NULL) { + ulg beg = s->pending; /* start of bytes to update crc */ + int val; + do { + if (s->pending == s->pending_buf_size) { + HCRC_UPDATE(beg); + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + beg = 0; + } + val = s->gzhead->comment[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + HCRC_UPDATE(beg); + } + s->status = HCRC_STATE; + } + if (s->status == HCRC_STATE) { + if (s->gzhead->hcrc) { + if (s->pending + 2 > s->pending_buf_size) { + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + strm->adler = crc32(0L, Z_NULL, 0); + } + s->status = BUSY_STATE; + + /* Compression must start with an empty pending buffer */ + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } +#endif + + /* Start a new block or continue the current one. + */ + if (strm->avail_in != 0 || s->lookahead != 0 || + (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { + block_state bstate; + + bstate = s->level == 0 ? deflate_stored(s, flush) : + s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : + s->strategy == Z_RLE ? deflate_rle(s, flush) : + (*(configuration_table[s->level].func))(s, flush); + + if (bstate == finish_started || bstate == finish_done) { + s->status = FINISH_STATE; + } + if (bstate == need_more || bstate == finish_started) { + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } + if (bstate == block_done) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(s); + } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ + _tr_stored_block(s, (char*)0, 0L, 0); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush == Z_FULL_FLUSH) { + CLEAR_HASH(s); /* forget history */ + if (s->lookahead == 0) { + s->strstart = 0; + s->block_start = 0L; + s->insert = 0; + } + } + } + flush_pending(strm); + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + + if (flush != Z_FINISH) return Z_OK; + if (s->wrap <= 0) return Z_STREAM_END; + + /* Write the trailer */ +#ifdef GZIP + if (s->wrap == 2) { + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); + put_byte(s, (Byte)(strm->total_in & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); + } + else +#endif + { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + flush_pending(strm); + /* If avail_out is zero, the application will call deflate again + * to flush the rest. + */ + if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ + return s->pending != 0 ? Z_OK : Z_STREAM_END; +} + +/* ========================================================================= */ +int ZEXPORT deflateEnd (strm) + z_streamp strm; +{ + int status; + + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; + + status = strm->state->status; + + /* Deallocate in reverse order of allocations: */ + TRY_FREE(strm, strm->state->pending_buf); + TRY_FREE(strm, strm->state->head); + TRY_FREE(strm, strm->state->prev); + TRY_FREE(strm, strm->state->window); + + ZFREE(strm, strm->state); + strm->state = Z_NULL; + + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; +} + +/* ========================================================================= + * Copy the source state to the destination state. + * To simplify the source, this is not supported for 16-bit MSDOS (which + * doesn't have enough memory anyway to duplicate compression states). + */ +int ZEXPORT deflateCopy (dest, source) + z_streamp dest; + z_streamp source; +{ +#ifdef MAXSEG_64K + return Z_STREAM_ERROR; +#else + deflate_state *ds; + deflate_state *ss; + ushf *overlay; + + + if (deflateStateCheck(source) || dest == Z_NULL) { + return Z_STREAM_ERROR; + } + + ss = source->state; + + zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); + + ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); + if (ds == Z_NULL) return Z_MEM_ERROR; + dest->state = (struct internal_state FAR *) ds; + zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); + ds->strm = dest; + + ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); + ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); + overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); + ds->pending_buf = (uchf *) overlay; + + if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || + ds->pending_buf == Z_NULL) { + deflateEnd (dest); + return Z_MEM_ERROR; + } + /* following zmemcpy do not work for 16-bit MSDOS */ + zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); + zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); + zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + + ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); + ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); + ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; + + ds->l_desc.dyn_tree = ds->dyn_ltree; + ds->d_desc.dyn_tree = ds->dyn_dtree; + ds->bl_desc.dyn_tree = ds->bl_tree; + + return Z_OK; +#endif /* MAXSEG_64K */ +} + +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local unsigned read_buf(strm, buf, size) + z_streamp strm; + Bytef *buf; + unsigned size; +{ + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + zmemcpy(buf, strm->next_in, len); + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, buf, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, buf, len); + } +#endif + strm->next_in += len; + strm->total_in += len; + + return len; +} + +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init (s) + deflate_state *s; +{ + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->insert = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +#ifndef FASTEST +#ifdef ASMV + match_init(); /* initialize the asm code */ +#endif +#endif +} + +#ifndef FASTEST +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + * OUT assertion: the match length is not greater than s->lookahead. + */ +#ifndef ASMV +/* For 80x86 and 680x0, an optimized version will be provided in match.asm or + * match.S. The code will be functionally equivalent. + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + int best_len = (int)s->prev_length; /* best match length so far */ + int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + s->strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Posf *prev = s->prev; + uInt wmask = s->w_mask; + +#ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; + register ush scan_start = *(ushf*)scan; + register ush scan_end = *(ushf*)(scan+best_len-1); +#else + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end = scan[best_len]; +#endif + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead; + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + Assert(cur_match < s->strstart, "no future"); + match = s->window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2. Note that the checks below + * for insufficient lookahead only occur occasionally for performance + * reasons. Therefore uninitialized memory will be accessed, and + * conditional jumps will be made that depend on those values. + * However the length of the match is limited to the lookahead, so + * the output of deflate is not affected by the uninitialized values. + */ +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ushf*)(match+best_len-1) != scan_end || + *(ushf*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++, match++; + do { + } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + +#else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + +#endif /* UNALIGNED_OK */ + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; +#ifdef UNALIGNED_OK + scan_end = *(ushf*)(scan+best_len-1); +#else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; +#endif + } + } while ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0); + + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + return s->lookahead; +} +#endif /* ASMV */ + +#else /* FASTEST */ + +/* --------------------------------------------------------------------------- + * Optimized version for FASTEST only + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + Assert(cur_match < s->strstart, "no future"); + + match = s->window + cur_match; + + /* Return failure if the match length is less than 2: + */ + if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match += 2; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + + if (len < MIN_MATCH) return MIN_MATCH - 1; + + s->match_start = cur_match; + return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; +} + +#endif /* FASTEST */ + +#ifdef ZLIB_DEBUG + +#define EQUAL 0 +/* result of memcmp for equal strings */ + +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +local void check_match(s, start, match, length) + deflate_state *s; + IPos start, match; + int length; +{ + /* check that the match is indeed a match */ + if (zmemcmp(s->window + match, + s->window + start, length) != EQUAL) { + fprintf(stderr, " start %u, match %u, length %d\n", + start, match, length); + do { + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + } while (--length != 0); + z_error("invalid match"); + } + if (z_verbose > 1) { + fprintf(stderr,"\\[%d,%d]", start-match, length); + do { putc(s->window[start++], stderr); } while (--length != 0); + } +} +#else +# define check_match(s, start, match, length) +#endif /* ZLIB_DEBUG */ + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(s) + deflate_state *s; +{ + unsigned n; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize+MAX_DIST(s)) { + + zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + slide_hash(s); + more += wsize; + } + if (s->strm->avail_in == 0) break; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead + s->insert >= MIN_MATCH) { + uInt str = s->strstart - s->insert; + s->ins_h = s->window[str]; + UPDATE_HASH(s, s->ins_h, s->window[str + 1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + while (s->insert) { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + s->insert--; + if (s->lookahead + s->insert < MIN_MATCH) + break; + } + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + zmemzero(s->window + curr, (unsigned)init); + s->high_water = curr + init; + } + else if (s->high_water < (ulg)curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = (ulg)curr + WIN_INIT - s->high_water; + if (init > s->window_size - s->high_water) + init = s->window_size - s->high_water; + zmemzero(s->window + s->high_water, (unsigned)init); + s->high_water += init; + } + } + + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + "not enough room for search"); +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK_ONLY(s, last) { \ + _tr_flush_block(s, (s->block_start >= 0L ? \ + (charf *)&s->window[(unsigned)s->block_start] : \ + (charf *)Z_NULL), \ + (ulg)((long)s->strstart - s->block_start), \ + (last)); \ + s->block_start = s->strstart; \ + flush_pending(s->strm); \ + Tracev((stderr,"[FLUSH]")); \ +} + +/* Same but force premature exit if necessary. */ +#define FLUSH_BLOCK(s, last) { \ + FLUSH_BLOCK_ONLY(s, last); \ + if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ +} + +/* Maximum stored block length in deflate format (not including header). */ +#define MAX_STORED 65535 + +/* Minimum of a and b. */ +#define MIN(a, b) ((a) > (b) ? (b) : (a)) + +/* =========================================================================== + * Copy without compression as much as possible from the input stream, return + * the current block state. + * + * In case deflateParams() is used to later switch to a non-zero compression + * level, s->matches (otherwise unused when storing) keeps track of the number + * of hash table slides to perform. If s->matches is 1, then one hash table + * slide will be done when switching. If s->matches is 2, the maximum value + * allowed here, then the hash table will be cleared, since two or more slides + * is the same as a clear. + * + * deflate_stored() is written to minimize the number of times an input byte is + * copied. It is most efficient with large input and output buffers, which + * maximizes the opportunites to have a single copy from next_in to next_out. + */ +local block_state deflate_stored(s, flush) + deflate_state *s; + int flush; +{ + /* Smallest worthy block size when not flushing or finishing. By default + * this is 32K. This can be as small as 507 bytes for memLevel == 1. For + * large input and output buffers, the stored block size will be larger. + */ + unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); + + /* Copy as many min_block or larger stored blocks directly to next_out as + * possible. If flushing, copy the remaining available input to next_out as + * stored blocks, if there is enough space. + */ + unsigned len, left, have, last = 0; + unsigned used = s->strm->avail_in; + do { + /* Set len to the maximum size block that we can copy directly with the + * available input data and output space. Set left to how much of that + * would be copied from what's left in the window. + */ + len = MAX_STORED; /* maximum deflate stored block length */ + have = (s->bi_valid + 42) >> 3; /* number of header bytes */ + if (s->strm->avail_out < have) /* need room for header */ + break; + /* maximum stored block length that will fit in avail_out: */ + have = s->strm->avail_out - have; + left = s->strstart - s->block_start; /* bytes left in window */ + if (len > (ulg)left + s->strm->avail_in) + len = left + s->strm->avail_in; /* limit len to the input */ + if (len > have) + len = have; /* limit len to the output */ + + /* If the stored block would be less than min_block in length, or if + * unable to copy all of the available input when flushing, then try + * copying to the window and the pending buffer instead. Also don't + * write an empty block when flushing -- deflate() does that. + */ + if (len < min_block && ((len == 0 && flush != Z_FINISH) || + flush == Z_NO_FLUSH || + len != left + s->strm->avail_in)) + break; + + /* Make a dummy stored block in pending to get the header bytes, + * including any pending bits. This also updates the debugging counts. + */ + last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0; + _tr_stored_block(s, (char *)0, 0L, last); + + /* Replace the lengths in the dummy stored block with len. */ + s->pending_buf[s->pending - 4] = len; + s->pending_buf[s->pending - 3] = len >> 8; + s->pending_buf[s->pending - 2] = ~len; + s->pending_buf[s->pending - 1] = ~len >> 8; + + /* Write the stored block header bytes. */ + flush_pending(s->strm); + +#ifdef ZLIB_DEBUG + /* Update debugging counts for the data about to be copied. */ + s->compressed_len += len << 3; + s->bits_sent += len << 3; +#endif + + /* Copy uncompressed bytes from the window to next_out. */ + if (left) { + if (left > len) + left = len; + zmemcpy(s->strm->next_out, s->window + s->block_start, left); + s->strm->next_out += left; + s->strm->avail_out -= left; + s->strm->total_out += left; + s->block_start += left; + len -= left; + } + + /* Copy uncompressed bytes directly from next_in to next_out, updating + * the check value. + */ + if (len) { + read_buf(s->strm, s->strm->next_out, len); + s->strm->next_out += len; + s->strm->avail_out -= len; + s->strm->total_out += len; + } + } while (last == 0); + + /* Update the sliding window with the last s->w_size bytes of the copied + * data, or append all of the copied data to the existing window if less + * than s->w_size bytes were copied. Also update the number of bytes to + * insert in the hash tables, in the event that deflateParams() switches to + * a non-zero compression level. + */ + used -= s->strm->avail_in; /* number of input bytes directly copied */ + if (used) { + /* If any input was used, then no unused input remains in the window, + * therefore s->block_start == s->strstart. + */ + if (used >= s->w_size) { /* supplant the previous history */ + s->matches = 2; /* clear hash */ + zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size); + s->strstart = s->w_size; + } + else { + if (s->window_size - s->strstart <= used) { + /* Slide the window down. */ + s->strstart -= s->w_size; + zmemcpy(s->window, s->window + s->w_size, s->strstart); + if (s->matches < 2) + s->matches++; /* add a pending slide_hash() */ + } + zmemcpy(s->window + s->strstart, s->strm->next_in - used, used); + s->strstart += used; + } + s->block_start = s->strstart; + s->insert += MIN(used, s->w_size - s->insert); + } + if (s->high_water < s->strstart) + s->high_water = s->strstart; + + /* If the last block was written to next_out, then done. */ + if (last) + return finish_done; + + /* If flushing and all input has been consumed, then done. */ + if (flush != Z_NO_FLUSH && flush != Z_FINISH && + s->strm->avail_in == 0 && (long)s->strstart == s->block_start) + return block_done; + + /* Fill the window with any remaining input. */ + have = s->window_size - s->strstart - 1; + if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { + /* Slide the window down. */ + s->block_start -= s->w_size; + s->strstart -= s->w_size; + zmemcpy(s->window, s->window + s->w_size, s->strstart); + if (s->matches < 2) + s->matches++; /* add a pending slide_hash() */ + have += s->w_size; /* more space now */ + } + if (have > s->strm->avail_in) + have = s->strm->avail_in; + if (have) { + read_buf(s->strm, s->window + s->strstart, have); + s->strstart += have; + } + if (s->high_water < s->strstart) + s->high_water = s->strstart; + + /* There was not enough avail_out to write a complete worthy or flushed + * stored block to next_out. Write a stored block to pending instead, if we + * have enough input for a worthy block, or if flushing and there is enough + * room for the remaining input as a stored block in the pending buffer. + */ + have = (s->bi_valid + 42) >> 3; /* number of header bytes */ + /* maximum stored block length that will fit in pending: */ + have = MIN(s->pending_buf_size - have, MAX_STORED); + min_block = MIN(have, s->w_size); + left = s->strstart - s->block_start; + if (left >= min_block || + ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && + s->strm->avail_in == 0 && left <= have)) { + len = MIN(left, have); + last = flush == Z_FINISH && s->strm->avail_in == 0 && + len == left ? 1 : 0; + _tr_stored_block(s, (charf *)s->window + s->block_start, len, last); + s->block_start += len; + flush_pending(s->strm); + } + + /* We've done all we can with the available input and output. */ + return last ? finish_started : need_more; +} + +/* =========================================================================== + * Compress as much as possible from the input stream, return the current + * block state. + * This function does not perform lazy evaluation of matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +local block_state deflate_fast(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + hash_head = NIL; + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s->match_length = longest_match (s, hash_head); + /* longest_match() sets match_start */ + } + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->match_start, s->match_length); + + _tr_tally_dist(s, s->strstart - s->match_start, + s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ +#ifndef FASTEST + if (s->match_length <= s->max_insert_length && + s->lookahead >= MIN_MATCH) { + s->match_length--; /* string at strstart already in table */ + do { + s->strstart++; + INSERT_STRING(s, s->strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s->match_length != 0); + s->strstart++; + } else +#endif + { + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if (s->last_lit) + FLUSH_BLOCK(s, 0); + return block_done; +} + +#ifndef FASTEST +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +local block_state deflate_slow(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head; /* head of hash chain */ + int bflush; /* set if current block must be flushed */ + + /* Process the input block. */ + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + hash_head = NIL; + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + */ + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = MIN_MATCH-1; + + if (hash_head != NIL && s->prev_length < s->max_lazy_match && + s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s->match_length = longest_match (s, hash_head); + /* longest_match() sets match_start */ + + if (s->match_length <= 5 && (s->strategy == Z_FILTERED +#if TOO_FAR <= 32767 + || (s->match_length == MIN_MATCH && + s->strstart - s->match_start > TOO_FAR) +#endif + )) { + + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + s->match_length = MIN_MATCH-1; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { + uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; + /* Do not insert strings in hash table beyond this. */ + + check_match(s, s->strstart-1, s->prev_match, s->prev_length); + + _tr_tally_dist(s, s->strstart -1 - s->prev_match, + s->prev_length - MIN_MATCH, bflush); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. If there is not + * enough lookahead, the last two strings are not inserted in + * the hash table. + */ + s->lookahead -= s->prev_length-1; + s->prev_length -= 2; + do { + if (++s->strstart <= max_insert) { + INSERT_STRING(s, s->strstart, hash_head); + } + } while (--s->prev_length != 0); + s->match_available = 0; + s->match_length = MIN_MATCH-1; + s->strstart++; + + if (bflush) FLUSH_BLOCK(s, 0); + + } else if (s->match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { + FLUSH_BLOCK_ONLY(s, 0); + } + s->strstart++; + s->lookahead--; + if (s->strm->avail_out == 0) return need_more; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + s->match_available = 1; + s->strstart++; + s->lookahead--; + } + } + Assert (flush != Z_NO_FLUSH, "no flush?"); + if (s->match_available) { + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + s->match_available = 0; + } + s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if (s->last_lit) + FLUSH_BLOCK(s, 0); + return block_done; +} +#endif /* FASTEST */ + +/* =========================================================================== + * For Z_RLE, simply look for runs of bytes, generate matches only of distance + * one. Do not maintain a hash table. (It will be regenerated if this run of + * deflate switches away from Z_RLE.) + */ +local block_state deflate_rle(s, flush) + deflate_state *s; + int flush; +{ + int bflush; /* set if current block must be flushed */ + uInt prev; /* byte at distance one to match */ + Bytef *scan, *strend; /* scan goes up to strend for length of run */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the longest run, plus one for the unrolled loop. + */ + if (s->lookahead <= MAX_MATCH) { + fill_window(s); + if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* See how many times the previous byte repeats */ + s->match_length = 0; + if (s->lookahead >= MIN_MATCH && s->strstart > 0) { + scan = s->window + s->strstart - 1; + prev = *scan; + if (prev == *++scan && prev == *++scan && prev == *++scan) { + strend = s->window + s->strstart + MAX_MATCH; + do { + } while (prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + scan < strend); + s->match_length = MAX_MATCH - (uInt)(strend - scan); + if (s->match_length > s->lookahead) + s->match_length = s->lookahead; + } + Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); + } + + /* Emit match if have run of MIN_MATCH or longer, else emit literal */ + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->strstart - 1, s->match_length); + + _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + s->strstart += s->match_length; + s->match_length = 0; + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + s->insert = 0; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if (s->last_lit) + FLUSH_BLOCK(s, 0); + return block_done; +} + +/* =========================================================================== + * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. + * (It will be regenerated if this run of deflate switches away from Huffman.) + */ +local block_state deflate_huff(s, flush) + deflate_state *s; + int flush; +{ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we have a literal to write. */ + if (s->lookahead == 0) { + fill_window(s); + if (s->lookahead == 0) { + if (flush == Z_NO_FLUSH) + return need_more; + break; /* flush the current block */ + } + } + + /* Output a literal byte */ + s->match_length = 0; + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + if (bflush) FLUSH_BLOCK(s, 0); + } + s->insert = 0; + if (flush == Z_FINISH) { + FLUSH_BLOCK(s, 1); + return finish_done; + } + if (s->last_lit) + FLUSH_BLOCK(s, 0); + return block_done; +} diff --git a/xs/src/png/zlib/deflate.h b/xs/src/png/zlib/deflate.h new file mode 100644 index 0000000000..23ecdd312b --- /dev/null +++ b/xs/src/png/zlib/deflate.h @@ -0,0 +1,349 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-2016 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef DEFLATE_H +#define DEFLATE_H + +#include "zutil.h" + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer creation by deflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip encoding + should be left enabled. */ +#ifndef NO_GZIP +# define GZIP +#endif + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define Buf_size 16 +/* size of bit buffer in bi_buf */ + +#define INIT_STATE 42 /* zlib header -> BUSY_STATE */ +#ifdef GZIP +# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */ +#endif +#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */ +#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */ +#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */ +#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */ +#define BUSY_STATE 113 /* deflate -> FINISH_STATE */ +#define FINISH_STATE 666 /* stream complete */ +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + const static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + ulg pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + gz_headerp gzhead; /* gzip header information to write */ + ulg gzindex; /* where in extra, name, or comment */ + Byte method; /* can only be DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to suppress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + uchf *l_buf; /* buffer for literals or lengths */ + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt last_lit; /* running index in l_buf */ + + ushf *d_buf; + /* Buffer for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + uInt insert; /* bytes at end of window left to insert */ + +#ifdef ZLIB_DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + + ulg high_water; + /* High water mark offset in window for initialized bytes -- bytes above + * this are set to zero in order to avoid memory check warnings when + * longest match routines access bytes past the input. This is then + * updated to the new high water mark. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + +#define WIN_INIT MAX_MATCH +/* Number of bytes after end of data in window to initialize in order to avoid + memory checker errors from longest match routines */ + + /* in trees.c */ +void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); +int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); +void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, + ulg stored_len, int last)); +void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); +void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); +void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, + ulg stored_len, int last)); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef ZLIB_DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch ZLIB_INTERNAL _length_code[]; + extern uch ZLIB_INTERNAL _dist_code[]; +#else + extern const uch ZLIB_INTERNAL _length_code[]; + extern const uch ZLIB_INTERNAL _dist_code[]; +#endif + +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif /* DEFLATE_H */ diff --git a/xs/src/png/zlib/gzclose.c b/xs/src/png/zlib/gzclose.c new file mode 100644 index 0000000000..caeb99a317 --- /dev/null +++ b/xs/src/png/zlib/gzclose.c @@ -0,0 +1,25 @@ +/* gzclose.c -- zlib gzclose() function + * Copyright (C) 2004, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "gzguts.h" + +/* gzclose() is in a separate file so that it is linked in only if it is used. + That way the other gzclose functions can be used instead to avoid linking in + unneeded compression or decompression routines. */ +int ZEXPORT gzclose(file) + gzFile file; +{ +#ifndef NO_GZCOMPRESS + gz_statep state; + + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + + return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); +#else + return gzclose_r(file); +#endif +} diff --git a/xs/src/png/zlib/gzguts.h b/xs/src/png/zlib/gzguts.h new file mode 100644 index 0000000000..990a4d2514 --- /dev/null +++ b/xs/src/png/zlib/gzguts.h @@ -0,0 +1,218 @@ +/* gzguts.h -- zlib internal header definitions for gz* operations + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#ifdef _LARGEFILE64_SOURCE +# ifndef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE 1 +# endif +# ifdef _FILE_OFFSET_BITS +# undef _FILE_OFFSET_BITS +# endif +#endif + +#ifdef HAVE_HIDDEN +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +#else +# define ZLIB_INTERNAL +#endif + +#include +#include "zlib.h" +#ifdef STDC +# include +# include +# include +#endif + +#ifndef _POSIX_SOURCE +# define _POSIX_SOURCE +#endif +#include + +#ifdef _WIN32 +# include +#endif + +#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) +# include +#endif + +#if defined(_WIN32) || defined(__CYGWIN__) +# define WIDECHAR +#endif + +#ifdef WINAPI_FAMILY +# define open _open +# define read _read +# define write _write +# define close _close +#endif + +#ifdef NO_DEFLATE /* for compatibility with old definition */ +# define NO_GZCOMPRESS +#endif + +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS +/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 +/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) +# define vsnprintf _vsnprintf +# endif +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +# ifdef VMS +# define NO_vsnprintf +# endif +# ifdef __OS400__ +# define NO_vsnprintf +# endif +# ifdef __MVS__ +# define NO_vsnprintf +# endif +#endif + +/* unlike snprintf (which is required in C99), _snprintf does not guarantee + null termination of the result -- however this is only used in gzlib.c where + the result is assured to fit in the space provided */ +#if defined(_MSC_VER) && _MSC_VER < 1900 +# define snprintf _snprintf +#endif + +#ifndef local +# define local static +#endif +/* since "static" is used to mean two completely different things in C, we + define "local" for the non-static meaning of "static", for readability + (compile with -Dlocal if your debugger can't find static symbols) */ + +/* gz* functions always use library allocation functions */ +#ifndef STDC + extern voidp malloc OF((uInt size)); + extern void free OF((voidpf ptr)); +#endif + +/* get errno and strerror definition */ +#if defined UNDER_CE +# include +# define zstrerror() gz_strwinerror((DWORD)GetLastError()) +#else +# ifndef NO_STRERROR +# include +# define zstrerror() strerror(errno) +# else +# define zstrerror() "stdio error (consult errno)" +# endif +#endif + +/* provide prototypes for these when building zlib without LFS */ +#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); +#endif + +/* default memLevel */ +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif + +/* default i/o buffer size -- double this for output when reading (this and + twice this must be able to fit in an unsigned type) */ +#define GZBUFSIZE 8192 + +/* gzip modes, also provide a little integrity check on the passed structure */ +#define GZ_NONE 0 +#define GZ_READ 7247 +#define GZ_WRITE 31153 +#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ + +/* values for gz_state how */ +#define LOOK 0 /* look for a gzip header */ +#define COPY 1 /* copy input directly */ +#define GZIP 2 /* decompress a gzip stream */ + +/* internal gzip file state data structure */ +typedef struct { + /* exposed contents for gzgetc() macro */ + struct gzFile_s x; /* "x" for exposed */ + /* x.have: number of bytes available at x.next */ + /* x.next: next output data to deliver or write */ + /* x.pos: current position in uncompressed data */ + /* used for both reading and writing */ + int mode; /* see gzip modes above */ + int fd; /* file descriptor */ + char *path; /* path or fd for error messages */ + unsigned size; /* buffer size, zero if not allocated yet */ + unsigned want; /* requested buffer size, default is GZBUFSIZE */ + unsigned char *in; /* input buffer (double-sized when writing) */ + unsigned char *out; /* output buffer (double-sized when reading) */ + int direct; /* 0 if processing gzip, 1 if transparent */ + /* just for reading */ + int how; /* 0: get header, 1: copy, 2: decompress */ + z_off64_t start; /* where the gzip data started, for rewinding */ + int eof; /* true if end of input file reached */ + int past; /* true if read requested past end */ + /* just for writing */ + int level; /* compression level */ + int strategy; /* compression strategy */ + /* seek request */ + z_off64_t skip; /* amount to skip (already rewound if backwards) */ + int seek; /* true if seek request pending */ + /* error information */ + int err; /* error code */ + char *msg; /* error message */ + /* zlib inflate or deflate stream */ + z_stream strm; /* stream structure in-place (not a pointer) */ +} gz_state; +typedef gz_state FAR *gz_statep; + +/* shared functions */ +void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); +#if defined UNDER_CE +char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); +#endif + +/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t + value -- needed when comparing unsigned to z_off64_t, which is signed + (possible z_off64_t types off_t, off64_t, and long are all signed) */ +#ifdef INT_MAX +# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) +#else +unsigned ZLIB_INTERNAL gz_intmax OF((void)); +# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) +#endif diff --git a/xs/src/png/zlib/gzlib.c b/xs/src/png/zlib/gzlib.c new file mode 100644 index 0000000000..4105e6aff9 --- /dev/null +++ b/xs/src/png/zlib/gzlib.c @@ -0,0 +1,637 @@ +/* gzlib.c -- zlib functions common to reading and writing gzip files + * Copyright (C) 2004-2017 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "gzguts.h" + +#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__) +# define LSEEK _lseeki64 +#else +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +# define LSEEK lseek64 +#else +# define LSEEK lseek +#endif +#endif + +/* Local functions */ +local void gz_reset OF((gz_statep)); +local gzFile gz_open OF((const void *, int, const char *)); + +#if defined UNDER_CE + +/* Map the Windows error number in ERROR to a locale-dependent error message + string and return a pointer to it. Typically, the values for ERROR come + from GetLastError. + + The string pointed to shall not be modified by the application, but may be + overwritten by a subsequent call to gz_strwinerror + + The gz_strwinerror function does not change the current setting of + GetLastError. */ +char ZLIB_INTERNAL *gz_strwinerror (error) + DWORD error; +{ + static char buf[1024]; + + wchar_t *msgbuf; + DWORD lasterr = GetLastError(); + DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_ALLOCATE_BUFFER, + NULL, + error, + 0, /* Default language */ + (LPVOID)&msgbuf, + 0, + NULL); + if (chars != 0) { + /* If there is an \r\n appended, zap it. */ + if (chars >= 2 + && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { + chars -= 2; + msgbuf[chars] = 0; + } + + if (chars > sizeof (buf) - 1) { + chars = sizeof (buf) - 1; + msgbuf[chars] = 0; + } + + wcstombs(buf, msgbuf, chars + 1); + LocalFree(msgbuf); + } + else { + sprintf(buf, "unknown win32 error (%ld)", error); + } + + SetLastError(lasterr); + return buf; +} + +#endif /* UNDER_CE */ + +/* Reset gzip file state */ +local void gz_reset(state) + gz_statep state; +{ + state->x.have = 0; /* no output data available */ + if (state->mode == GZ_READ) { /* for reading ... */ + state->eof = 0; /* not at end of file */ + state->past = 0; /* have not read past end yet */ + state->how = LOOK; /* look for gzip header */ + } + state->seek = 0; /* no seek request pending */ + gz_error(state, Z_OK, NULL); /* clear error */ + state->x.pos = 0; /* no uncompressed data yet */ + state->strm.avail_in = 0; /* no input data yet */ +} + +/* Open a gzip file either by name or file descriptor. */ +local gzFile gz_open(path, fd, mode) + const void *path; + int fd; + const char *mode; +{ + gz_statep state; + z_size_t len; + int oflag; +#ifdef O_CLOEXEC + int cloexec = 0; +#endif +#ifdef O_EXCL + int exclusive = 0; +#endif + + /* check input */ + if (path == NULL) + return NULL; + + /* allocate gzFile structure to return */ + state = (gz_statep)malloc(sizeof(gz_state)); + if (state == NULL) + return NULL; + state->size = 0; /* no buffers allocated yet */ + state->want = GZBUFSIZE; /* requested buffer size */ + state->msg = NULL; /* no error message yet */ + + /* interpret mode */ + state->mode = GZ_NONE; + state->level = Z_DEFAULT_COMPRESSION; + state->strategy = Z_DEFAULT_STRATEGY; + state->direct = 0; + while (*mode) { + if (*mode >= '0' && *mode <= '9') + state->level = *mode - '0'; + else + switch (*mode) { + case 'r': + state->mode = GZ_READ; + break; +#ifndef NO_GZCOMPRESS + case 'w': + state->mode = GZ_WRITE; + break; + case 'a': + state->mode = GZ_APPEND; + break; +#endif + case '+': /* can't read and write at the same time */ + free(state); + return NULL; + case 'b': /* ignore -- will request binary anyway */ + break; +#ifdef O_CLOEXEC + case 'e': + cloexec = 1; + break; +#endif +#ifdef O_EXCL + case 'x': + exclusive = 1; + break; +#endif + case 'f': + state->strategy = Z_FILTERED; + break; + case 'h': + state->strategy = Z_HUFFMAN_ONLY; + break; + case 'R': + state->strategy = Z_RLE; + break; + case 'F': + state->strategy = Z_FIXED; + break; + case 'T': + state->direct = 1; + break; + default: /* could consider as an error, but just ignore */ + ; + } + mode++; + } + + /* must provide an "r", "w", or "a" */ + if (state->mode == GZ_NONE) { + free(state); + return NULL; + } + + /* can't force transparent read */ + if (state->mode == GZ_READ) { + if (state->direct) { + free(state); + return NULL; + } + state->direct = 1; /* for empty file */ + } + + /* save the path name for error messages */ +#ifdef WIDECHAR + if (fd == -2) { + len = wcstombs(NULL, path, 0); + if (len == (z_size_t)-1) + len = 0; + } + else +#endif + len = strlen((const char *)path); + state->path = (char *)malloc(len + 1); + if (state->path == NULL) { + free(state); + return NULL; + } +#ifdef WIDECHAR + if (fd == -2) + if (len) + wcstombs(state->path, path, len + 1); + else + *(state->path) = 0; + else +#endif +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + (void)snprintf(state->path, len + 1, "%s", (const char *)path); +#else + strcpy(state->path, path); +#endif + + /* compute the flags for open() */ + oflag = +#ifdef O_LARGEFILE + O_LARGEFILE | +#endif +#ifdef O_BINARY + O_BINARY | +#endif +#ifdef O_CLOEXEC + (cloexec ? O_CLOEXEC : 0) | +#endif + (state->mode == GZ_READ ? + O_RDONLY : + (O_WRONLY | O_CREAT | +#ifdef O_EXCL + (exclusive ? O_EXCL : 0) | +#endif + (state->mode == GZ_WRITE ? + O_TRUNC : + O_APPEND))); + + /* open the file with the appropriate flags (or just use fd) */ + state->fd = fd > -1 ? fd : ( +#ifdef WIDECHAR + fd == -2 ? _wopen(path, oflag, 0666) : +#endif + open((const char *)path, oflag, 0666)); + if (state->fd == -1) { + free(state->path); + free(state); + return NULL; + } + if (state->mode == GZ_APPEND) { + LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */ + state->mode = GZ_WRITE; /* simplify later checks */ + } + + /* save the current position for rewinding (only if reading) */ + if (state->mode == GZ_READ) { + state->start = LSEEK(state->fd, 0, SEEK_CUR); + if (state->start == -1) state->start = 0; + } + + /* initialize stream */ + gz_reset(state); + + /* return stream */ + return (gzFile)state; +} + +/* -- see zlib.h -- */ +gzFile ZEXPORT gzopen(path, mode) + const char *path; + const char *mode; +{ + return gz_open(path, -1, mode); +} + +/* -- see zlib.h -- */ +gzFile ZEXPORT gzopen64(path, mode) + const char *path; + const char *mode; +{ + return gz_open(path, -1, mode); +} + +/* -- see zlib.h -- */ +gzFile ZEXPORT gzdopen(fd, mode) + int fd; + const char *mode; +{ + char *path; /* identifier for error messages */ + gzFile gz; + + if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) + return NULL; +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + (void)snprintf(path, 7 + 3 * sizeof(int), "", fd); +#else + sprintf(path, "", fd); /* for debugging */ +#endif + gz = gz_open(path, fd, mode); + free(path); + return gz; +} + +/* -- see zlib.h -- */ +#ifdef WIDECHAR +gzFile ZEXPORT gzopen_w(path, mode) + const wchar_t *path; + const char *mode; +{ + return gz_open(path, -2, mode); +} +#endif + +/* -- see zlib.h -- */ +int ZEXPORT gzbuffer(file, size) + gzFile file; + unsigned size; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return -1; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return -1; + + /* make sure we haven't already allocated memory */ + if (state->size != 0) + return -1; + + /* check and set requested size */ + if ((size << 1) < size) + return -1; /* need to be able to double it */ + if (size < 2) + size = 2; /* need two bytes to check magic header */ + state->want = size; + return 0; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzrewind(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return -1; + + /* back up and start over */ + if (LSEEK(state->fd, state->start, SEEK_SET) == -1) + return -1; + gz_reset(state); + return 0; +} + +/* -- see zlib.h -- */ +z_off64_t ZEXPORT gzseek64(file, offset, whence) + gzFile file; + z_off64_t offset; + int whence; +{ + unsigned n; + z_off64_t ret; + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return -1; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return -1; + + /* check that there's no error */ + if (state->err != Z_OK && state->err != Z_BUF_ERROR) + return -1; + + /* can only seek from start or relative to current position */ + if (whence != SEEK_SET && whence != SEEK_CUR) + return -1; + + /* normalize offset to a SEEK_CUR specification */ + if (whence == SEEK_SET) + offset -= state->x.pos; + else if (state->seek) + offset += state->skip; + state->seek = 0; + + /* if within raw area while reading, just go there */ + if (state->mode == GZ_READ && state->how == COPY && + state->x.pos + offset >= 0) { + ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR); + if (ret == -1) + return -1; + state->x.have = 0; + state->eof = 0; + state->past = 0; + state->seek = 0; + gz_error(state, Z_OK, NULL); + state->strm.avail_in = 0; + state->x.pos += offset; + return state->x.pos; + } + + /* calculate skip amount, rewinding if needed for back seek when reading */ + if (offset < 0) { + if (state->mode != GZ_READ) /* writing -- can't go backwards */ + return -1; + offset += state->x.pos; + if (offset < 0) /* before start of file! */ + return -1; + if (gzrewind(file) == -1) /* rewind, then skip to offset */ + return -1; + } + + /* if reading, skip what's in output buffer (one less gzgetc() check) */ + if (state->mode == GZ_READ) { + n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? + (unsigned)offset : state->x.have; + state->x.have -= n; + state->x.next += n; + state->x.pos += n; + offset -= n; + } + + /* request skip (if not zero) */ + if (offset) { + state->seek = 1; + state->skip = offset; + } + return state->x.pos + offset; +} + +/* -- see zlib.h -- */ +z_off_t ZEXPORT gzseek(file, offset, whence) + gzFile file; + z_off_t offset; + int whence; +{ + z_off64_t ret; + + ret = gzseek64(file, (z_off64_t)offset, whence); + return ret == (z_off_t)ret ? (z_off_t)ret : -1; +} + +/* -- see zlib.h -- */ +z_off64_t ZEXPORT gztell64(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return -1; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return -1; + + /* return position */ + return state->x.pos + (state->seek ? state->skip : 0); +} + +/* -- see zlib.h -- */ +z_off_t ZEXPORT gztell(file) + gzFile file; +{ + z_off64_t ret; + + ret = gztell64(file); + return ret == (z_off_t)ret ? (z_off_t)ret : -1; +} + +/* -- see zlib.h -- */ +z_off64_t ZEXPORT gzoffset64(file) + gzFile file; +{ + z_off64_t offset; + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return -1; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return -1; + + /* compute and return effective offset in file */ + offset = LSEEK(state->fd, 0, SEEK_CUR); + if (offset == -1) + return -1; + if (state->mode == GZ_READ) /* reading */ + offset -= state->strm.avail_in; /* don't count buffered input */ + return offset; +} + +/* -- see zlib.h -- */ +z_off_t ZEXPORT gzoffset(file) + gzFile file; +{ + z_off64_t ret; + + ret = gzoffset64(file); + return ret == (z_off_t)ret ? (z_off_t)ret : -1; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzeof(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return 0; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return 0; + + /* return end-of-file state */ + return state->mode == GZ_READ ? state->past : 0; +} + +/* -- see zlib.h -- */ +const char * ZEXPORT gzerror(file, errnum) + gzFile file; + int *errnum; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return NULL; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return NULL; + + /* return error information */ + if (errnum != NULL) + *errnum = state->err; + return state->err == Z_MEM_ERROR ? "out of memory" : + (state->msg == NULL ? "" : state->msg); +} + +/* -- see zlib.h -- */ +void ZEXPORT gzclearerr(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return; + + /* clear error and end-of-file */ + if (state->mode == GZ_READ) { + state->eof = 0; + state->past = 0; + } + gz_error(state, Z_OK, NULL); +} + +/* Create an error message in allocated memory and set state->err and + state->msg accordingly. Free any previous error message already there. Do + not try to free or allocate space if the error is Z_MEM_ERROR (out of + memory). Simply save the error message as a static string. If there is an + allocation failure constructing the error message, then convert the error to + out of memory. */ +void ZLIB_INTERNAL gz_error(state, err, msg) + gz_statep state; + int err; + const char *msg; +{ + /* free previously allocated message and clear */ + if (state->msg != NULL) { + if (state->err != Z_MEM_ERROR) + free(state->msg); + state->msg = NULL; + } + + /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */ + if (err != Z_OK && err != Z_BUF_ERROR) + state->x.have = 0; + + /* set error code, and if no message, then done */ + state->err = err; + if (msg == NULL) + return; + + /* for an out of memory error, return literal string when requested */ + if (err == Z_MEM_ERROR) + return; + + /* construct error message with path */ + if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == + NULL) { + state->err = Z_MEM_ERROR; + return; + } +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, + "%s%s%s", state->path, ": ", msg); +#else + strcpy(state->msg, state->path); + strcat(state->msg, ": "); + strcat(state->msg, msg); +#endif +} + +#ifndef INT_MAX +/* portably return maximum value for an int (when limits.h presumed not + available) -- we need to do this to cover cases where 2's complement not + used, since C standard permits 1's complement and sign-bit representations, + otherwise we could just use ((unsigned)-1) >> 1 */ +unsigned ZLIB_INTERNAL gz_intmax() +{ + unsigned p, q; + + p = 1; + do { + q = p; + p <<= 1; + p++; + } while (p > q); + return q >> 1; +} +#endif diff --git a/xs/src/png/zlib/gzread.c b/xs/src/png/zlib/gzread.c new file mode 100644 index 0000000000..956b91ea7d --- /dev/null +++ b/xs/src/png/zlib/gzread.c @@ -0,0 +1,654 @@ +/* gzread.c -- zlib functions for reading gzip files + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "gzguts.h" + +/* Local functions */ +local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); +local int gz_avail OF((gz_statep)); +local int gz_look OF((gz_statep)); +local int gz_decomp OF((gz_statep)); +local int gz_fetch OF((gz_statep)); +local int gz_skip OF((gz_statep, z_off64_t)); +local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); + +/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from + state->fd, and update state->eof, state->err, and state->msg as appropriate. + This function needs to loop on read(), since read() is not guaranteed to + read the number of bytes requested, depending on the type of descriptor. */ +local int gz_load(state, buf, len, have) + gz_statep state; + unsigned char *buf; + unsigned len; + unsigned *have; +{ + int ret; + unsigned get, max = ((unsigned)-1 >> 2) + 1; + + *have = 0; + do { + get = len - *have; + if (get > max) + get = max; + ret = read(state->fd, buf + *have, get); + if (ret <= 0) + break; + *have += (unsigned)ret; + } while (*have < len); + if (ret < 0) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + if (ret == 0) + state->eof = 1; + return 0; +} + +/* Load up input buffer and set eof flag if last data loaded -- return -1 on + error, 0 otherwise. Note that the eof flag is set when the end of the input + file is reached, even though there may be unused data in the buffer. Once + that data has been used, no more attempts will be made to read the file. + If strm->avail_in != 0, then the current data is moved to the beginning of + the input buffer, and then the remainder of the buffer is loaded with the + available data from the input file. */ +local int gz_avail(state) + gz_statep state; +{ + unsigned got; + z_streamp strm = &(state->strm); + + if (state->err != Z_OK && state->err != Z_BUF_ERROR) + return -1; + if (state->eof == 0) { + if (strm->avail_in) { /* copy what's there to the start */ + unsigned char *p = state->in; + unsigned const char *q = strm->next_in; + unsigned n = strm->avail_in; + do { + *p++ = *q++; + } while (--n); + } + if (gz_load(state, state->in + strm->avail_in, + state->size - strm->avail_in, &got) == -1) + return -1; + strm->avail_in += got; + strm->next_in = state->in; + } + return 0; +} + +/* Look for gzip header, set up for inflate or copy. state->x.have must be 0. + If this is the first time in, allocate required memory. state->how will be + left unchanged if there is no more input data available, will be set to COPY + if there is no gzip header and direct copying will be performed, or it will + be set to GZIP for decompression. If direct copying, then leftover input + data from the input buffer will be copied to the output buffer. In that + case, all further file reads will be directly to either the output buffer or + a user buffer. If decompressing, the inflate state will be initialized. + gz_look() will return 0 on success or -1 on failure. */ +local int gz_look(state) + gz_statep state; +{ + z_streamp strm = &(state->strm); + + /* allocate read buffers and inflate memory */ + if (state->size == 0) { + /* allocate buffers */ + state->in = (unsigned char *)malloc(state->want); + state->out = (unsigned char *)malloc(state->want << 1); + if (state->in == NULL || state->out == NULL) { + free(state->out); + free(state->in); + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + state->size = state->want; + + /* allocate inflate memory */ + state->strm.zalloc = Z_NULL; + state->strm.zfree = Z_NULL; + state->strm.opaque = Z_NULL; + state->strm.avail_in = 0; + state->strm.next_in = Z_NULL; + if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ + free(state->out); + free(state->in); + state->size = 0; + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + } + + /* get at least the magic bytes in the input buffer */ + if (strm->avail_in < 2) { + if (gz_avail(state) == -1) + return -1; + if (strm->avail_in == 0) + return 0; + } + + /* look for gzip magic bytes -- if there, do gzip decoding (note: there is + a logical dilemma here when considering the case of a partially written + gzip file, to wit, if a single 31 byte is written, then we cannot tell + whether this is a single-byte file, or just a partially written gzip + file -- for here we assume that if a gzip file is being written, then + the header will be written in a single operation, so that reading a + single byte is sufficient indication that it is not a gzip file) */ + if (strm->avail_in > 1 && + strm->next_in[0] == 31 && strm->next_in[1] == 139) { + inflateReset(strm); + state->how = GZIP; + state->direct = 0; + return 0; + } + + /* no gzip header -- if we were decoding gzip before, then this is trailing + garbage. Ignore the trailing garbage and finish. */ + if (state->direct == 0) { + strm->avail_in = 0; + state->eof = 1; + state->x.have = 0; + return 0; + } + + /* doing raw i/o, copy any leftover input to output -- this assumes that + the output buffer is larger than the input buffer, which also assures + space for gzungetc() */ + state->x.next = state->out; + if (strm->avail_in) { + memcpy(state->x.next, strm->next_in, strm->avail_in); + state->x.have = strm->avail_in; + strm->avail_in = 0; + } + state->how = COPY; + state->direct = 1; + return 0; +} + +/* Decompress from input to the provided next_out and avail_out in the state. + On return, state->x.have and state->x.next point to the just decompressed + data. If the gzip stream completes, state->how is reset to LOOK to look for + the next gzip stream or raw data, once state->x.have is depleted. Returns 0 + on success, -1 on failure. */ +local int gz_decomp(state) + gz_statep state; +{ + int ret = Z_OK; + unsigned had; + z_streamp strm = &(state->strm); + + /* fill output buffer up to end of deflate stream */ + had = strm->avail_out; + do { + /* get more input for inflate() */ + if (strm->avail_in == 0 && gz_avail(state) == -1) + return -1; + if (strm->avail_in == 0) { + gz_error(state, Z_BUF_ERROR, "unexpected end of file"); + break; + } + + /* decompress and handle errors */ + ret = inflate(strm, Z_NO_FLUSH); + if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { + gz_error(state, Z_STREAM_ERROR, + "internal error: inflate stream corrupt"); + return -1; + } + if (ret == Z_MEM_ERROR) { + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ + gz_error(state, Z_DATA_ERROR, + strm->msg == NULL ? "compressed data error" : strm->msg); + return -1; + } + } while (strm->avail_out && ret != Z_STREAM_END); + + /* update available output */ + state->x.have = had - strm->avail_out; + state->x.next = strm->next_out - state->x.have; + + /* if the gzip stream completed successfully, look for another */ + if (ret == Z_STREAM_END) + state->how = LOOK; + + /* good decompression */ + return 0; +} + +/* Fetch data and put it in the output buffer. Assumes state->x.have is 0. + Data is either copied from the input file or decompressed from the input + file depending on state->how. If state->how is LOOK, then a gzip header is + looked for to determine whether to copy or decompress. Returns -1 on error, + otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the + end of the input file has been reached and all data has been processed. */ +local int gz_fetch(state) + gz_statep state; +{ + z_streamp strm = &(state->strm); + + do { + switch(state->how) { + case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ + if (gz_look(state) == -1) + return -1; + if (state->how == LOOK) + return 0; + break; + case COPY: /* -> COPY */ + if (gz_load(state, state->out, state->size << 1, &(state->x.have)) + == -1) + return -1; + state->x.next = state->out; + return 0; + case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ + strm->avail_out = state->size << 1; + strm->next_out = state->out; + if (gz_decomp(state) == -1) + return -1; + } + } while (state->x.have == 0 && (!state->eof || strm->avail_in)); + return 0; +} + +/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ +local int gz_skip(state, len) + gz_statep state; + z_off64_t len; +{ + unsigned n; + + /* skip over len bytes or reach end-of-file, whichever comes first */ + while (len) + /* skip over whatever is in output buffer */ + if (state->x.have) { + n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ? + (unsigned)len : state->x.have; + state->x.have -= n; + state->x.next += n; + state->x.pos += n; + len -= n; + } + + /* output buffer empty -- return if we're at the end of the input */ + else if (state->eof && state->strm.avail_in == 0) + break; + + /* need more data to skip -- load up output buffer */ + else { + /* get more output, looking for header if required */ + if (gz_fetch(state) == -1) + return -1; + } + return 0; +} + +/* Read len bytes into buf from file, or less than len up to the end of the + input. Return the number of bytes read. If zero is returned, either the + end of file was reached, or there was an error. state->err must be + consulted in that case to determine which. */ +local z_size_t gz_read(state, buf, len) + gz_statep state; + voidp buf; + z_size_t len; +{ + z_size_t got; + unsigned n; + + /* if len is zero, avoid unnecessary operations */ + if (len == 0) + return 0; + + /* process a skip request */ + if (state->seek) { + state->seek = 0; + if (gz_skip(state, state->skip) == -1) + return 0; + } + + /* get len bytes to buf, or less than len if at the end */ + got = 0; + do { + /* set n to the maximum amount of len that fits in an unsigned int */ + n = -1; + if (n > len) + n = len; + + /* first just try copying data from the output buffer */ + if (state->x.have) { + if (state->x.have < n) + n = state->x.have; + memcpy(buf, state->x.next, n); + state->x.next += n; + state->x.have -= n; + } + + /* output buffer empty -- return if we're at the end of the input */ + else if (state->eof && state->strm.avail_in == 0) { + state->past = 1; /* tried to read past end */ + break; + } + + /* need output data -- for small len or new stream load up our output + buffer */ + else if (state->how == LOOK || n < (state->size << 1)) { + /* get more output, looking for header if required */ + if (gz_fetch(state) == -1) + return 0; + continue; /* no progress yet -- go back to copy above */ + /* the copy above assures that we will leave with space in the + output buffer, allowing at least one gzungetc() to succeed */ + } + + /* large len -- read directly into user buffer */ + else if (state->how == COPY) { /* read directly */ + if (gz_load(state, (unsigned char *)buf, n, &n) == -1) + return 0; + } + + /* large len -- decompress directly into user buffer */ + else { /* state->how == GZIP */ + state->strm.avail_out = n; + state->strm.next_out = (unsigned char *)buf; + if (gz_decomp(state) == -1) + return 0; + n = state->x.have; + state->x.have = 0; + } + + /* update progress */ + len -= n; + buf = (char *)buf + n; + got += n; + state->x.pos += n; + } while (len); + + /* return number of bytes read into user buffer */ + return got; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzread(file, buf, len) + gzFile file; + voidp buf; + unsigned len; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return -1; + + /* since an int is returned, make sure len fits in one, otherwise return + with an error (this avoids a flaw in the interface) */ + if ((int)len < 0) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in an int"); + return -1; + } + + /* read len or fewer bytes to buf */ + len = gz_read(state, buf, len); + + /* check for an error */ + if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR) + return -1; + + /* return the number of bytes read (this is assured to fit in an int) */ + return (int)len; +} + +/* -- see zlib.h -- */ +z_size_t ZEXPORT gzfread(buf, size, nitems, file) + voidp buf; + z_size_t size; + z_size_t nitems; + gzFile file; +{ + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return 0; + + /* compute bytes to read -- error on overflow */ + len = nitems * size; + if (size && len / size != nitems) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); + return 0; + } + + /* read len or fewer bytes to buf, return the number of full items read */ + return len ? gz_read(state, buf, len) / size : 0; +} + +/* -- see zlib.h -- */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +#else +# undef gzgetc +#endif +int ZEXPORT gzgetc(file) + gzFile file; +{ + int ret; + unsigned char buf[1]; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return -1; + + /* try output buffer (no need to check for skip request) */ + if (state->x.have) { + state->x.have--; + state->x.pos++; + return *(state->x.next)++; + } + + /* nothing there -- try gz_read() */ + ret = gz_read(state, buf, 1); + return ret < 1 ? -1 : buf[0]; +} + +int ZEXPORT gzgetc_(file) +gzFile file; +{ + return gzgetc(file); +} + +/* -- see zlib.h -- */ +int ZEXPORT gzungetc(c, file) + int c; + gzFile file; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return -1; + + /* process a skip request */ + if (state->seek) { + state->seek = 0; + if (gz_skip(state, state->skip) == -1) + return -1; + } + + /* can't push EOF */ + if (c < 0) + return -1; + + /* if output buffer empty, put byte at end (allows more pushing) */ + if (state->x.have == 0) { + state->x.have = 1; + state->x.next = state->out + (state->size << 1) - 1; + state->x.next[0] = (unsigned char)c; + state->x.pos--; + state->past = 0; + return c; + } + + /* if no room, give up (must have already done a gzungetc()) */ + if (state->x.have == (state->size << 1)) { + gz_error(state, Z_DATA_ERROR, "out of room to push characters"); + return -1; + } + + /* slide output data if needed and insert byte before existing data */ + if (state->x.next == state->out) { + unsigned char *src = state->out + state->x.have; + unsigned char *dest = state->out + (state->size << 1); + while (src > state->out) + *--dest = *--src; + state->x.next = dest; + } + state->x.have++; + state->x.next--; + state->x.next[0] = (unsigned char)c; + state->x.pos--; + state->past = 0; + return c; +} + +/* -- see zlib.h -- */ +char * ZEXPORT gzgets(file, buf, len) + gzFile file; + char *buf; + int len; +{ + unsigned left, n; + char *str; + unsigned char *eol; + gz_statep state; + + /* check parameters and get internal structure */ + if (file == NULL || buf == NULL || len < 1) + return NULL; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return NULL; + + /* process a skip request */ + if (state->seek) { + state->seek = 0; + if (gz_skip(state, state->skip) == -1) + return NULL; + } + + /* copy output bytes up to new line or len - 1, whichever comes first -- + append a terminating zero to the string (we don't check for a zero in + the contents, let the user worry about that) */ + str = buf; + left = (unsigned)len - 1; + if (left) do { + /* assure that something is in the output buffer */ + if (state->x.have == 0 && gz_fetch(state) == -1) + return NULL; /* error */ + if (state->x.have == 0) { /* end of file */ + state->past = 1; /* read past end */ + break; /* return what we have */ + } + + /* look for end-of-line in current output buffer */ + n = state->x.have > left ? left : state->x.have; + eol = (unsigned char *)memchr(state->x.next, '\n', n); + if (eol != NULL) + n = (unsigned)(eol - state->x.next) + 1; + + /* copy through end-of-line, or remainder if not found */ + memcpy(buf, state->x.next, n); + state->x.have -= n; + state->x.next += n; + state->x.pos += n; + left -= n; + buf += n; + } while (left && eol == NULL); + + /* return terminated string, or if nothing, end of file */ + if (buf == str) + return NULL; + buf[0] = 0; + return str; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzdirect(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* if the state is not known, but we can find out, then do so (this is + mainly for right after a gzopen() or gzdopen()) */ + if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) + (void)gz_look(state); + + /* return 1 if transparent, 0 if processing a gzip stream */ + return state->direct; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzclose_r(file) + gzFile file; +{ + int ret, err; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + + /* check that we're reading */ + if (state->mode != GZ_READ) + return Z_STREAM_ERROR; + + /* free memory and close file */ + if (state->size) { + inflateEnd(&(state->strm)); + free(state->out); + free(state->in); + } + err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; + gz_error(state, Z_OK, NULL); + free(state->path); + ret = close(state->fd); + free(state); + return ret ? Z_ERRNO : err; +} diff --git a/xs/src/png/zlib/gzwrite.c b/xs/src/png/zlib/gzwrite.c new file mode 100644 index 0000000000..c7b5651d70 --- /dev/null +++ b/xs/src/png/zlib/gzwrite.c @@ -0,0 +1,665 @@ +/* gzwrite.c -- zlib functions for writing gzip files + * Copyright (C) 2004-2017 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "gzguts.h" + +/* Local functions */ +local int gz_init OF((gz_statep)); +local int gz_comp OF((gz_statep, int)); +local int gz_zero OF((gz_statep, z_off64_t)); +local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); + +/* Initialize state for writing a gzip file. Mark initialization by setting + state->size to non-zero. Return -1 on a memory allocation failure, or 0 on + success. */ +local int gz_init(state) + gz_statep state; +{ + int ret; + z_streamp strm = &(state->strm); + + /* allocate input buffer (double size for gzprintf) */ + state->in = (unsigned char *)malloc(state->want << 1); + if (state->in == NULL) { + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + + /* only need output buffer and deflate state if compressing */ + if (!state->direct) { + /* allocate output buffer */ + state->out = (unsigned char *)malloc(state->want); + if (state->out == NULL) { + free(state->in); + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + + /* allocate deflate memory, set up for gzip compression */ + strm->zalloc = Z_NULL; + strm->zfree = Z_NULL; + strm->opaque = Z_NULL; + ret = deflateInit2(strm, state->level, Z_DEFLATED, + MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); + if (ret != Z_OK) { + free(state->out); + free(state->in); + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + strm->next_in = NULL; + } + + /* mark state as initialized */ + state->size = state->want; + + /* initialize write buffer if compressing */ + if (!state->direct) { + strm->avail_out = state->size; + strm->next_out = state->out; + state->x.next = strm->next_out; + } + return 0; +} + +/* Compress whatever is at avail_in and next_in and write to the output file. + Return -1 if there is an error writing to the output file or if gz_init() + fails to allocate memory, otherwise 0. flush is assumed to be a valid + deflate() flush value. If flush is Z_FINISH, then the deflate() state is + reset to start a new gzip stream. If gz->direct is true, then simply write + to the output file without compressing, and ignore flush. */ +local int gz_comp(state, flush) + gz_statep state; + int flush; +{ + int ret, writ; + unsigned have, put, max = ((unsigned)-1 >> 2) + 1; + z_streamp strm = &(state->strm); + + /* allocate memory if this is the first time through */ + if (state->size == 0 && gz_init(state) == -1) + return -1; + + /* write directly if requested */ + if (state->direct) { + while (strm->avail_in) { + put = strm->avail_in > max ? max : strm->avail_in; + writ = write(state->fd, strm->next_in, put); + if (writ < 0) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + strm->avail_in -= (unsigned)writ; + strm->next_in += writ; + } + return 0; + } + + /* run deflate() on provided input until it produces no more output */ + ret = Z_OK; + do { + /* write out current buffer contents if full, or if flushing, but if + doing Z_FINISH then don't write until we get to Z_STREAM_END */ + if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && + (flush != Z_FINISH || ret == Z_STREAM_END))) { + while (strm->next_out > state->x.next) { + put = strm->next_out - state->x.next > (int)max ? max : + (unsigned)(strm->next_out - state->x.next); + writ = write(state->fd, state->x.next, put); + if (writ < 0) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + state->x.next += writ; + } + if (strm->avail_out == 0) { + strm->avail_out = state->size; + strm->next_out = state->out; + state->x.next = state->out; + } + } + + /* compress */ + have = strm->avail_out; + ret = deflate(strm, flush); + if (ret == Z_STREAM_ERROR) { + gz_error(state, Z_STREAM_ERROR, + "internal error: deflate stream corrupt"); + return -1; + } + have -= strm->avail_out; + } while (have); + + /* if that completed a deflate stream, allow another to start */ + if (flush == Z_FINISH) + deflateReset(strm); + + /* all done, no errors */ + return 0; +} + +/* Compress len zeros to output. Return -1 on a write error or memory + allocation failure by gz_comp(), or 0 on success. */ +local int gz_zero(state, len) + gz_statep state; + z_off64_t len; +{ + int first; + unsigned n; + z_streamp strm = &(state->strm); + + /* consume whatever's left in the input buffer */ + if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) + return -1; + + /* compress len zeros (len guaranteed > 0) */ + first = 1; + while (len) { + n = GT_OFF(state->size) || (z_off64_t)state->size > len ? + (unsigned)len : state->size; + if (first) { + memset(state->in, 0, n); + first = 0; + } + strm->avail_in = n; + strm->next_in = state->in; + state->x.pos += n; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return -1; + len -= n; + } + return 0; +} + +/* Write len bytes from buf to file. Return the number of bytes written. If + the returned value is less than len, then there was an error. */ +local z_size_t gz_write(state, buf, len) + gz_statep state; + voidpc buf; + z_size_t len; +{ + z_size_t put = len; + + /* if len is zero, avoid unnecessary operations */ + if (len == 0) + return 0; + + /* allocate memory if this is the first time through */ + if (state->size == 0 && gz_init(state) == -1) + return 0; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return 0; + } + + /* for small len, copy to input buffer, otherwise compress directly */ + if (len < state->size) { + /* copy to input buffer, compress when full */ + do { + unsigned have, copy; + + if (state->strm.avail_in == 0) + state->strm.next_in = state->in; + have = (unsigned)((state->strm.next_in + state->strm.avail_in) - + state->in); + copy = state->size - have; + if (copy > len) + copy = len; + memcpy(state->in + have, buf, copy); + state->strm.avail_in += copy; + state->x.pos += copy; + buf = (const char *)buf + copy; + len -= copy; + if (len && gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + } while (len); + } + else { + /* consume whatever's left in the input buffer */ + if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + + /* directly compress user buffer to file */ + state->strm.next_in = (z_const Bytef *)buf; + do { + unsigned n = (unsigned)-1; + if (n > len) + n = len; + state->strm.avail_in = n; + state->x.pos += n; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + len -= n; + } while (len); + } + + /* input was all buffered or compressed */ + return put; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzwrite(file, buf, len) + gzFile file; + voidpc buf; + unsigned len; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* since an int is returned, make sure len fits in one, otherwise return + with an error (this avoids a flaw in the interface) */ + if ((int)len < 0) { + gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); + return 0; + } + + /* write len bytes from buf (the return value will fit in an int) */ + return (int)gz_write(state, buf, len); +} + +/* -- see zlib.h -- */ +z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) + voidpc buf; + z_size_t size; + z_size_t nitems; + gzFile file; +{ + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* compute bytes to read -- error on overflow */ + len = nitems * size; + if (size && len / size != nitems) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); + return 0; + } + + /* write len bytes to buf, return the number of full items written */ + return len ? gz_write(state, buf, len) / size : 0; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzputc(file, c) + gzFile file; + int c; +{ + unsigned have; + unsigned char buf[1]; + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return -1; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return -1; + } + + /* try writing to input buffer for speed (state->size == 0 if buffer not + initialized) */ + if (state->size) { + if (strm->avail_in == 0) + strm->next_in = state->in; + have = (unsigned)((strm->next_in + strm->avail_in) - state->in); + if (have < state->size) { + state->in[have] = (unsigned char)c; + strm->avail_in++; + state->x.pos++; + return c & 0xff; + } + } + + /* no room in buffer or not initialized, use gz_write() */ + buf[0] = (unsigned char)c; + if (gz_write(state, buf, 1) != 1) + return -1; + return c & 0xff; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzputs(file, str) + gzFile file; + const char *str; +{ + int ret; + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return -1; + + /* write string */ + len = strlen(str); + ret = gz_write(state, str, len); + return ret == 0 && len != 0 ? -1 : ret; +} + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +#include + +/* -- see zlib.h -- */ +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) +{ + int len; + unsigned left; + char *next; + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return Z_STREAM_ERROR; + + /* make sure we have some buffer space */ + if (state->size == 0 && gz_init(state) == -1) + return state->err; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return state->err; + } + + /* do the printf() into the input buffer, put length in len -- the input + buffer is double-sized just for this function, so there is guaranteed to + be state->size bytes available after the current contents */ + if (strm->avail_in == 0) + strm->next_in = state->in; + next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in); + next[state->size - 1] = 0; +#ifdef NO_vsnprintf +# ifdef HAS_vsprintf_void + (void)vsprintf(next, format, va); + for (len = 0; len < state->size; len++) + if (next[len] == 0) break; +# else + len = vsprintf(next, format, va); +# endif +#else +# ifdef HAS_vsnprintf_void + (void)vsnprintf(next, state->size, format, va); + len = strlen(next); +# else + len = vsnprintf(next, state->size, format, va); +# endif +#endif + + /* check that printf() results fit in buffer */ + if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0) + return 0; + + /* update buffer and position, compress first half if past that */ + strm->avail_in += (unsigned)len; + state->x.pos += len; + if (strm->avail_in >= state->size) { + left = strm->avail_in - state->size; + strm->avail_in = state->size; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return state->err; + memcpy(state->in, state->in + state->size, left); + strm->next_in = state->in; + strm->avail_in = left; + } + return len; +} + +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) +{ + va_list va; + int ret; + + va_start(va, format); + ret = gzvprintf(file, format, va); + va_end(va); + return ret; +} + +#else /* !STDC && !Z_HAVE_STDARG_H */ + +/* -- see zlib.h -- */ +int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) + gzFile file; + const char *format; + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; +{ + unsigned len, left; + char *next; + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that can really pass pointer in ints */ + if (sizeof(int) != sizeof(void *)) + return Z_STREAM_ERROR; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return Z_STREAM_ERROR; + + /* make sure we have some buffer space */ + if (state->size == 0 && gz_init(state) == -1) + return state->error; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return state->error; + } + + /* do the printf() into the input buffer, put length in len -- the input + buffer is double-sized just for this function, so there is guaranteed to + be state->size bytes available after the current contents */ + if (strm->avail_in == 0) + strm->next_in = state->in; + next = (char *)(strm->next_in + strm->avail_in); + next[state->size - 1] = 0; +#ifdef NO_snprintf +# ifdef HAS_sprintf_void + sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, + a13, a14, a15, a16, a17, a18, a19, a20); + for (len = 0; len < size; len++) + if (next[len] == 0) + break; +# else + len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, + a12, a13, a14, a15, a16, a17, a18, a19, a20); +# endif +#else +# ifdef HAS_snprintf_void + snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, + a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = strlen(next); +# else + len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); +# endif +#endif + + /* check that printf() results fit in buffer */ + if (len == 0 || len >= state->size || next[state->size - 1] != 0) + return 0; + + /* update buffer and position, compress first half if past that */ + strm->avail_in += len; + state->x.pos += len; + if (strm->avail_in >= state->size) { + left = strm->avail_in - state->size; + strm->avail_in = state->size; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return state->err; + memcpy(state->in, state->in + state->size, left); + strm->next_in = state->in; + strm->avail_in = left; + } + return (int)len; +} + +#endif + +/* -- see zlib.h -- */ +int ZEXPORT gzflush(file, flush) + gzFile file; + int flush; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return Z_STREAM_ERROR; + + /* check flush parameter */ + if (flush < 0 || flush > Z_FINISH) + return Z_STREAM_ERROR; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return state->err; + } + + /* compress remaining data with requested flush */ + (void)gz_comp(state, flush); + return state->err; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzsetparams(file, level, strategy) + gzFile file; + int level; + int strategy; +{ + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return Z_STREAM_ERROR; + + /* if no change is requested, then do nothing */ + if (level == state->level && strategy == state->strategy) + return Z_OK; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return state->err; + } + + /* change compression parameters for subsequent input */ + if (state->size) { + /* flush previous input with previous parameters before changing */ + if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1) + return state->err; + deflateParams(strm, level, strategy); + } + state->level = level; + state->strategy = strategy; + return Z_OK; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzclose_w(file) + gzFile file; +{ + int ret = Z_OK; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + + /* check that we're writing */ + if (state->mode != GZ_WRITE) + return Z_STREAM_ERROR; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + ret = state->err; + } + + /* flush, free memory, and close file */ + if (gz_comp(state, Z_FINISH) == -1) + ret = state->err; + if (state->size) { + if (!state->direct) { + (void)deflateEnd(&(state->strm)); + free(state->out); + } + free(state->in); + } + gz_error(state, Z_OK, NULL); + free(state->path); + if (close(state->fd) == -1) + ret = Z_ERRNO; + free(state); + return ret; +} diff --git a/xs/src/png/zlib/infback.c b/xs/src/png/zlib/infback.c new file mode 100644 index 0000000000..59679ecbfc --- /dev/null +++ b/xs/src/png/zlib/infback.c @@ -0,0 +1,640 @@ +/* infback.c -- inflate using a call-back interface + * Copyright (C) 1995-2016 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + This code is largely copied from inflate.c. Normally either infback.o or + inflate.o would be linked into an application--not both. The interface + with inffast.c is retained so that optimized assembler-coded versions of + inflate_fast() can be used with either inflate.c or infback.c. + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +/* function prototypes */ +local void fixedtables OF((struct inflate_state FAR *state)); + +/* + strm provides memory allocation functions in zalloc and zfree, or + Z_NULL to use the library memory allocation functions. + + windowBits is in the range 8..15, and window is a user-supplied + window and output buffer that is 2**windowBits bytes. + */ +int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) +z_streamp strm; +int windowBits; +unsigned char FAR *window; +const char *version; +int stream_size; +{ + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL || window == Z_NULL || + windowBits < 8 || windowBits > 15) + return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; +#endif + } + if (strm->zfree == (free_func)0) +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zfree = zcfree; +#endif + state = (struct inflate_state FAR *)ZALLOC(strm, 1, + sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (struct internal_state FAR *)state; + state->dmax = 32768U; + state->wbits = (uInt)windowBits; + state->wsize = 1U << windowBits; + state->window = window; + state->wnext = 0; + state->whave = 0; + return Z_OK; +} + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +local void fixedtables(state) +struct inflate_state FAR *state; +{ +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +/* Macros for inflateBack(): */ + +/* Load returned state from inflate_fast() */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Set state from registers for inflate_fast() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Assure that some input is available. If input is requested, but denied, + then return a Z_BUF_ERROR from inflateBack(). */ +#define PULL() \ + do { \ + if (have == 0) { \ + have = in(in_desc, &next); \ + if (have == 0) { \ + next = Z_NULL; \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflateBack() + with an error if there is no input available. */ +#define PULLBYTE() \ + do { \ + PULL(); \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflateBack() with + an error. */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* Assure that some output space is available, by writing out the window + if it's full. If the write fails, return from inflateBack() with a + Z_BUF_ERROR. */ +#define ROOM() \ + do { \ + if (left == 0) { \ + put = state->window; \ + left = state->wsize; \ + state->whave = left; \ + if (out(out_desc, put, left)) { \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + +/* + strm provides the memory allocation functions and window buffer on input, + and provides information on the unused input on return. For Z_DATA_ERROR + returns, strm will also provide an error message. + + in() and out() are the call-back input and output functions. When + inflateBack() needs more input, it calls in(). When inflateBack() has + filled the window with output, or when it completes with data in the + window, it calls out() to write out the data. The application must not + change the provided input until in() is called again or inflateBack() + returns. The application must not change the window/output buffer until + inflateBack() returns. + + in() and out() are called with a descriptor parameter provided in the + inflateBack() call. This parameter can be a structure that provides the + information required to do the read or write, as well as accumulated + information on the input and output such as totals and check values. + + in() should return zero on failure. out() should return non-zero on + failure. If either in() or out() fails, than inflateBack() returns a + Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it + was in() or out() that caused in the error. Otherwise, inflateBack() + returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format + error, or Z_MEM_ERROR if it could not allocate memory for the state. + inflateBack() can also return Z_STREAM_ERROR if the input parameters + are not correct, i.e. strm is Z_NULL or the state was not initialized. + */ +int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) +z_streamp strm; +in_func in; +void FAR *in_desc; +out_func out; +void FAR *out_desc; +{ + struct inflate_state FAR *state; + z_const unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code here; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + /* Check that the strm exists and that the state was initialized */ + if (strm == Z_NULL || strm->state == Z_NULL) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* Reset the state */ + strm->msg = Z_NULL; + state->mode = TYPE; + state->last = 0; + state->whave = 0; + next = strm->next_in; + have = next != Z_NULL ? strm->avail_in : 0; + hold = 0; + bits = 0; + put = state->window; + left = state->wsize; + + /* Inflate until end of block marked as last */ + for (;;) + switch (state->mode) { + case TYPE: + /* determine and dispatch block type */ + if (state->last) { + BYTEBITS(); + state->mode = DONE; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + state->last ? " (last)" : "")); + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + Tracev((stderr, "inflate: fixed codes block%s\n", + state->last ? " (last)" : "")); + state->mode = LEN; /* decode codes */ + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + state->last ? " (last)" : "")); + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + + case STORED: + /* get and verify stored block length */ + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %u\n", + state->length)); + INITBITS(); + + /* copy stored block from input to output */ + while (state->length != 0) { + copy = state->length; + PULL(); + ROOM(); + if (copy > have) copy = have; + if (copy > left) copy = left; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + } + Tracev((stderr, "inflate: stored end\n")); + state->mode = TYPE; + break; + + case TABLE: + /* get dynamic table entries descriptor */ + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); +#ifndef PKZIP_BUG_WORKAROUND + if (state->nlen > 286 || state->ndist > 30) { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } +#endif + Tracev((stderr, "inflate: table sizes ok\n")); + + /* get code length code lengths (not a typo) */ + state->have = 0; + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + + /* get length and distance code code lengths */ + state->have = 0; + while (state->have < state->nlen + state->ndist) { + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.val < 16) { + DROPBITS(here.bits); + state->lens[state->have++] = here.val; + } + else { + if (here.val == 16) { + NEEDBITS(here.bits + 2); + DROPBITS(here.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = (unsigned)(state->lens[state->have - 1]); + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (here.val == 17) { + NEEDBITS(here.bits + 3); + DROPBITS(here.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(here.bits + 7); + DROPBITS(here.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (state->mode == BAD) break; + + /* check for end-of-block code (better have one) */ + if (state->lens[256] == 0) { + strm->msg = (char *)"invalid code -- missing end-of-block"; + state->mode = BAD; + break; + } + + /* build code tables -- note: do not change the lenbits or distbits + values here (9 and 6) without reading the comments in inftrees.h + concerning the ENOUGH constants, which depend on those values */ + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (code const FAR *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + &(state->next), &(state->distbits), state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + state->mode = LEN; + + case LEN: + /* use inflate_fast() if we have enough input and output */ + if (have >= 6 && left >= 258) { + RESTORE(); + if (state->whave < state->wsize) + state->whave = state->wsize - left; + inflate_fast(strm, state->wsize); + LOAD(); + break; + } + + /* get a literal, length, or end-of-block code */ + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.op && (here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(here.bits); + state->length = (unsigned)here.val; + + /* process literal */ + if (here.op == 0) { + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + ROOM(); + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + } + + /* process end of block */ + if (here.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + + /* invalid code */ + if (here.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + + /* length code -- get extra bits, if any */ + state->extra = (unsigned)(here.op) & 15; + if (state->extra != 0) { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + } + Tracevv((stderr, "inflate: length %u\n", state->length)); + + /* get distance code */ + for (;;) { + here = state->distcode[BITS(state->distbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if ((here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(here.bits); + if (here.op & 64) { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)here.val; + + /* get distance extra bits, if any */ + state->extra = (unsigned)(here.op) & 15; + if (state->extra != 0) { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + } + if (state->offset > state->wsize - (state->whave < state->wsize ? + left : 0)) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + Tracevv((stderr, "inflate: distance %u\n", state->offset)); + + /* copy match from window to output */ + do { + ROOM(); + copy = state->wsize - state->offset; + if (copy < left) { + from = put + copy; + copy = left - copy; + } + else { + from = put - state->offset; + copy = left; + } + if (copy > state->length) copy = state->length; + state->length -= copy; + left -= copy; + do { + *put++ = *from++; + } while (--copy); + } while (state->length != 0); + break; + + case DONE: + /* inflate stream terminated properly -- write leftover output */ + ret = Z_STREAM_END; + if (left < state->wsize) { + if (out(out_desc, state->window, state->wsize - left)) + ret = Z_BUF_ERROR; + } + goto inf_leave; + + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + + default: /* can't happen, but makes compilers happy */ + ret = Z_STREAM_ERROR; + goto inf_leave; + } + + /* Return unused input */ + inf_leave: + strm->next_in = next; + strm->avail_in = have; + return ret; +} + +int ZEXPORT inflateBackEnd(strm) +z_streamp strm; +{ + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} diff --git a/xs/src/png/zlib/inffast.c b/xs/src/png/zlib/inffast.c new file mode 100644 index 0000000000..0dbd1dbc09 --- /dev/null +++ b/xs/src/png/zlib/inffast.c @@ -0,0 +1,323 @@ +/* inffast.c -- fast decoding + * Copyright (C) 1995-2017 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifdef ASMINF +# pragma message("Assembler code may have bugs -- use at your own risk") +#else + +/* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state->mode == LEN + strm->avail_in >= 6 + strm->avail_out >= 258 + start >= strm->avail_out + state->bits < 8 + + On return, state->mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm->avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm->avail_out >= 258 for each loop to avoid checking for + output space. + */ +void ZLIB_INTERNAL inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + z_const unsigned char FAR *in; /* local strm->next_in */ + z_const unsigned char FAR *last; /* have enough input while in < last */ + unsigned char FAR *out; /* local strm->next_out */ + unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ + unsigned char FAR *end; /* while out < end, enough space available */ +#ifdef INFLATE_STRICT + unsigned dmax; /* maximum distance from zlib header */ +#endif + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const FAR *lcode; /* local strm->lencode */ + code const FAR *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + code here; /* retrieved table entry */ + unsigned op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned char FAR *from; /* where to copy match from */ + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + in = strm->next_in; + last = in + (strm->avail_in - 5); + out = strm->next_out; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); +#ifdef INFLATE_STRICT + dmax = state->dmax; +#endif + wsize = state->wsize; + whave = state->whave; + wnext = state->wnext; + window = state->window; + hold = state->hold; + bits = state->bits; + lcode = state->lencode; + dcode = state->distcode; + lmask = (1U << state->lenbits) - 1; + dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + do { + if (bits < 15) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + hold += (unsigned long)(*in++) << bits; + bits += 8; + } + here = lcode[hold & lmask]; + dolen: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op == 0) { /* literal */ + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + *out++ = (unsigned char)(here.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + } + Tracevv((stderr, "inflate: length %u\n", len)); + if (bits < 15) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + hold += (unsigned long)(*in++) << bits; + bits += 8; + } + here = dcode[hold & dmask]; + dodist: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op & 16) { /* distance base */ + dist = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (bits < op) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + if (bits < op) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + } + } + dist += (unsigned)hold & ((1U << op) - 1); +#ifdef INFLATE_STRICT + if (dist > dmax) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#endif + hold >>= op; + bits -= op; + Tracevv((stderr, "inflate: distance %u\n", dist)); + op = (unsigned)(out - beg); /* max distance in output */ + if (dist > op) { /* see if copy from window */ + op = dist - op; /* distance back in window */ + if (op > whave) { + if (state->sane) { + strm->msg = + (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + if (len <= op - whave) { + do { + *out++ = 0; + } while (--len); + continue; + } + len -= op - whave; + do { + *out++ = 0; + } while (--op > whave); + if (op == 0) { + from = out - dist; + do { + *out++ = *from++; + } while (--len); + continue; + } +#endif + } + from = window; + if (wnext == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + else if (wnext < op) { /* wrap around window */ + from += wsize + wnext - op; + op -= wnext; + if (op < len) { /* some from end of window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = window; + if (wnext < len) { /* some from start of window */ + op = wnext; + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + } + else { /* contiguous in window */ + from += wnext - op; + if (op < len) { /* some from window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; + len -= 3; + } + if (len) { + *out++ = *from++; + if (len > 1) + *out++ = *from++; + } + } + else { + from = out - dist; /* copy direct from output */ + do { /* minimum length is three */ + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; + len -= 3; + } while (len > 2); + if (len) { + *out++ = *from++; + if (len > 1) + *out++ = *from++; + } + } + } + else if ((op & 64) == 0) { /* 2nd level distance code */ + here = dcode[here.val + (hold & ((1U << op) - 1))]; + goto dodist; + } + else { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + } + else if ((op & 64) == 0) { /* 2nd level length code */ + here = lcode[here.val + (hold & ((1U << op) - 1))]; + goto dolen; + } + else if (op & 32) { /* end-of-block */ + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + else { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + } while (in < last && out < end); + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + len = bits >> 3; + in -= len; + bits -= len << 3; + hold &= (1U << bits) - 1; + + /* update state and return */ + strm->next_in = in; + strm->next_out = out; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end)); + state->hold = hold; + state->bits = bits; + return; +} + +/* + inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): + - Using bit fields for code structure + - Different op definition to avoid & for extra bits (do & for table bits) + - Three separate decoding do-loops for direct, window, and wnext == 0 + - Special case for distance > 1 copies to do overlapped load and store copy + - Explicit branch predictions (based on measured branch probabilities) + - Deferring match copy and interspersed it with decoding subsequent codes + - Swapping literal/length else + - Swapping window/direct else + - Larger unrolled copy loops (three is about right) + - Moving len -= 3 statement into middle of loop + */ + +#endif /* !ASMINF */ diff --git a/xs/src/png/zlib/inffast.h b/xs/src/png/zlib/inffast.h new file mode 100644 index 0000000000..e5c1aa4ca8 --- /dev/null +++ b/xs/src/png/zlib/inffast.h @@ -0,0 +1,11 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-2003, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/xs/src/png/zlib/inffixed.h b/xs/src/png/zlib/inffixed.h new file mode 100644 index 0000000000..d628327769 --- /dev/null +++ b/xs/src/png/zlib/inffixed.h @@ -0,0 +1,94 @@ + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by makefixed(). + */ + + /* WARNING: this file should *not* be used by applications. + It is part of the implementation of this library and is + subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} + }; + + static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} + }; diff --git a/xs/src/png/zlib/inflate.c b/xs/src/png/zlib/inflate.c new file mode 100644 index 0000000000..ac333e8c2e --- /dev/null +++ b/xs/src/png/zlib/inflate.c @@ -0,0 +1,1561 @@ +/* inflate.c -- zlib decompression + * Copyright (C) 1995-2016 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * Change history: + * + * 1.2.beta0 24 Nov 2002 + * - First version -- complete rewrite of inflate to simplify code, avoid + * creation of window when not needed, minimize use of window when it is + * needed, make inffast.c even faster, implement gzip decoding, and to + * improve code readability and style over the previous zlib inflate code + * + * 1.2.beta1 25 Nov 2002 + * - Use pointers for available input and output checking in inffast.c + * - Remove input and output counters in inffast.c + * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 + * - Remove unnecessary second byte pull from length extra in inffast.c + * - Unroll direct copy to three copies per loop in inffast.c + * + * 1.2.beta2 4 Dec 2002 + * - Change external routine names to reduce potential conflicts + * - Correct filename to inffixed.h for fixed tables in inflate.c + * - Make hbuf[] unsigned char to match parameter type in inflate.c + * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) + * to avoid negation problem on Alphas (64 bit) in inflate.c + * + * 1.2.beta3 22 Dec 2002 + * - Add comments on state->bits assertion in inffast.c + * - Add comments on op field in inftrees.h + * - Fix bug in reuse of allocated window after inflateReset() + * - Remove bit fields--back to byte structure for speed + * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths + * - Change post-increments to pre-increments in inflate_fast(), PPC biased? + * - Add compile time option, POSTINC, to use post-increments instead (Intel?) + * - Make MATCH copy in inflate() much faster for when inflate_fast() not used + * - Use local copies of stream next and avail values, as well as local bit + * buffer and bit count in inflate()--for speed when inflate_fast() not used + * + * 1.2.beta4 1 Jan 2003 + * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings + * - Move a comment on output buffer sizes from inffast.c to inflate.c + * - Add comments in inffast.c to introduce the inflate_fast() routine + * - Rearrange window copies in inflate_fast() for speed and simplification + * - Unroll last copy for window match in inflate_fast() + * - Use local copies of window variables in inflate_fast() for speed + * - Pull out common wnext == 0 case for speed in inflate_fast() + * - Make op and len in inflate_fast() unsigned for consistency + * - Add FAR to lcode and dcode declarations in inflate_fast() + * - Simplified bad distance check in inflate_fast() + * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new + * source file infback.c to provide a call-back interface to inflate for + * programs like gzip and unzip -- uses window as output buffer to avoid + * window copying + * + * 1.2.beta5 1 Jan 2003 + * - Improved inflateBack() interface to allow the caller to provide initial + * input in strm. + * - Fixed stored blocks bug in inflateBack() + * + * 1.2.beta6 4 Jan 2003 + * - Added comments in inffast.c on effectiveness of POSTINC + * - Typecasting all around to reduce compiler warnings + * - Changed loops from while (1) or do {} while (1) to for (;;), again to + * make compilers happy + * - Changed type of window in inflateBackInit() to unsigned char * + * + * 1.2.beta7 27 Jan 2003 + * - Changed many types to unsigned or unsigned short to avoid warnings + * - Added inflateCopy() function + * + * 1.2.0 9 Mar 2003 + * - Changed inflateBack() interface to provide separate opaque descriptors + * for the in() and out() functions + * - Changed inflateBack() argument and in_func typedef to swap the length + * and buffer address return values for the input function + * - Check next_in and next_out for Z_NULL on entry to inflate() + * + * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifdef MAKEFIXED +# ifndef BUILDFIXED +# define BUILDFIXED +# endif +#endif + +/* function prototypes */ +local int inflateStateCheck OF((z_streamp strm)); +local void fixedtables OF((struct inflate_state FAR *state)); +local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, + unsigned copy)); +#ifdef BUILDFIXED + void makefixed OF((void)); +#endif +local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, + unsigned len)); + +local int inflateStateCheck(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (strm == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) + return 1; + state = (struct inflate_state FAR *)strm->state; + if (state == Z_NULL || state->strm != strm || + state->mode < HEAD || state->mode > SYNC) + return 1; + return 0; +} + +int ZEXPORT inflateResetKeep(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + strm->total_in = strm->total_out = state->total = 0; + strm->msg = Z_NULL; + if (state->wrap) /* to support ill-conceived Java test suite */ + strm->adler = state->wrap & 1; + state->mode = HEAD; + state->last = 0; + state->havedict = 0; + state->dmax = 32768U; + state->head = Z_NULL; + state->hold = 0; + state->bits = 0; + state->lencode = state->distcode = state->next = state->codes; + state->sane = 1; + state->back = -1; + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + +int ZEXPORT inflateReset(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + state->wsize = 0; + state->whave = 0; + state->wnext = 0; + return inflateResetKeep(strm); +} + +int ZEXPORT inflateReset2(strm, windowBits) +z_streamp strm; +int windowBits; +{ + int wrap; + struct inflate_state FAR *state; + + /* get the state */ + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* extract wrap request from windowBits parameter */ + if (windowBits < 0) { + wrap = 0; + windowBits = -windowBits; + } + else { + wrap = (windowBits >> 4) + 5; +#ifdef GUNZIP + if (windowBits < 48) + windowBits &= 15; +#endif + } + + /* set number of window bits, free window if different */ + if (windowBits && (windowBits < 8 || windowBits > 15)) + return Z_STREAM_ERROR; + if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { + ZFREE(strm, state->window); + state->window = Z_NULL; + } + + /* update state and reset the rest of it */ + state->wrap = wrap; + state->wbits = (unsigned)windowBits; + return inflateReset(strm); +} + +int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) +z_streamp strm; +int windowBits; +const char *version; +int stream_size; +{ + int ret; + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL) return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; +#endif + } + if (strm->zfree == (free_func)0) +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zfree = zcfree; +#endif + state = (struct inflate_state FAR *) + ZALLOC(strm, 1, sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (struct internal_state FAR *)state; + state->strm = strm; + state->window = Z_NULL; + state->mode = HEAD; /* to pass state test in inflateReset2() */ + ret = inflateReset2(strm, windowBits); + if (ret != Z_OK) { + ZFREE(strm, state); + strm->state = Z_NULL; + } + return ret; +} + +int ZEXPORT inflateInit_(strm, version, stream_size) +z_streamp strm; +const char *version; +int stream_size; +{ + return inflateInit2_(strm, DEF_WBITS, version, stream_size); +} + +int ZEXPORT inflatePrime(strm, bits, value) +z_streamp strm; +int bits; +int value; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (bits < 0) { + state->hold = 0; + state->bits = 0; + return Z_OK; + } + if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR; + value &= (1L << bits) - 1; + state->hold += (unsigned)value << state->bits; + state->bits += (uInt)bits; + return Z_OK; +} + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +local void fixedtables(state) +struct inflate_state FAR *state; +{ +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +#ifdef MAKEFIXED +#include + +/* + Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also + defines BUILDFIXED, so the tables are built on the fly. makefixed() writes + those tables to stdout, which would be piped to inffixed.h. A small program + can simply call makefixed to do this: + + void makefixed(void); + + int main(void) + { + makefixed(); + return 0; + } + + Then that can be linked with zlib built with MAKEFIXED defined and run: + + a.out > inffixed.h + */ +void makefixed() +{ + unsigned low, size; + struct inflate_state state; + + fixedtables(&state); + puts(" /* inffixed.h -- table for decoding fixed codes"); + puts(" * Generated automatically by makefixed()."); + puts(" */"); + puts(""); + puts(" /* WARNING: this file should *not* be used by applications."); + puts(" It is part of the implementation of this library and is"); + puts(" subject to change. Applications should only use zlib.h."); + puts(" */"); + puts(""); + size = 1U << 9; + printf(" static const code lenfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 7) == 0) printf("\n "); + printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, + state.lencode[low].bits, state.lencode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); + size = 1U << 5; + printf("\n static const code distfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 6) == 0) printf("\n "); + printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, + state.distcode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); +} +#endif /* MAKEFIXED */ + +/* + Update the window with the last wsize (normally 32K) bytes written before + returning. If window does not exist yet, create it. This is only called + when a window is already in use, or when output has been written during this + inflate call, but the end of the deflate stream has not been reached yet. + It is also called to create a window for dictionary data when a dictionary + is loaded. + + Providing output buffers larger than 32K to inflate() should provide a speed + advantage, since only the last 32K of output is copied to the sliding window + upon return from inflate(), and since all distances after the first 32K of + output will fall in the output data, making match copies simpler and faster. + The advantage may be dependent on the size of the processor's data caches. + */ +local int updatewindow(strm, end, copy) +z_streamp strm; +const Bytef *end; +unsigned copy; +{ + struct inflate_state FAR *state; + unsigned dist; + + state = (struct inflate_state FAR *)strm->state; + + /* if it hasn't been done already, allocate space for the window */ + if (state->window == Z_NULL) { + state->window = (unsigned char FAR *) + ZALLOC(strm, 1U << state->wbits, + sizeof(unsigned char)); + if (state->window == Z_NULL) return 1; + } + + /* if window not in use yet, initialize */ + if (state->wsize == 0) { + state->wsize = 1U << state->wbits; + state->wnext = 0; + state->whave = 0; + } + + /* copy state->wsize or less output bytes into the circular window */ + if (copy >= state->wsize) { + zmemcpy(state->window, end - state->wsize, state->wsize); + state->wnext = 0; + state->whave = state->wsize; + } + else { + dist = state->wsize - state->wnext; + if (dist > copy) dist = copy; + zmemcpy(state->window + state->wnext, end - copy, dist); + copy -= dist; + if (copy) { + zmemcpy(state->window, end - copy, copy); + state->wnext = copy; + state->whave = state->wsize; + } + else { + state->wnext += dist; + if (state->wnext == state->wsize) state->wnext = 0; + if (state->whave < state->wsize) state->whave += dist; + } + } + return 0; +} + +/* Macros for inflate(): */ + +/* check function to use adler32() for zlib or crc32() for gzip */ +#ifdef GUNZIP +# define UPDATE(check, buf, len) \ + (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) +#else +# define UPDATE(check, buf, len) adler32(check, buf, len) +#endif + +/* check macros for header crc */ +#ifdef GUNZIP +# define CRC2(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + check = crc32(check, hbuf, 2); \ + } while (0) + +# define CRC4(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + hbuf[2] = (unsigned char)((word) >> 16); \ + hbuf[3] = (unsigned char)((word) >> 24); \ + check = crc32(check, hbuf, 4); \ + } while (0) +#endif + +/* Load registers with state in inflate() for speed */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Restore state from registers in inflate() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflate() + if there is no input available. */ +#define PULLBYTE() \ + do { \ + if (have == 0) goto inf_leave; \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflate(). */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* + inflate() uses a state machine to process as much input data and generate as + much output data as possible before returning. The state machine is + structured roughly as follows: + + for (;;) switch (state) { + ... + case STATEn: + if (not enough input data or output space to make progress) + return; + ... make progress ... + state = STATEm; + break; + ... + } + + so when inflate() is called again, the same case is attempted again, and + if the appropriate resources are provided, the machine proceeds to the + next state. The NEEDBITS() macro is usually the way the state evaluates + whether it can proceed or should return. NEEDBITS() does the return if + the requested bits are not available. The typical use of the BITS macros + is: + + NEEDBITS(n); + ... do something with BITS(n) ... + DROPBITS(n); + + where NEEDBITS(n) either returns from inflate() if there isn't enough + input left to load n bits into the accumulator, or it continues. BITS(n) + gives the low n bits in the accumulator. When done, DROPBITS(n) drops + the low n bits off the accumulator. INITBITS() clears the accumulator + and sets the number of available bits to zero. BYTEBITS() discards just + enough bits to put the accumulator on a byte boundary. After BYTEBITS() + and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. + + NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return + if there is no input available. The decoding of variable length codes uses + PULLBYTE() directly in order to pull just enough bytes to decode the next + code, and no more. + + Some states loop until they get enough input, making sure that enough + state information is maintained to continue the loop where it left off + if NEEDBITS() returns in the loop. For example, want, need, and keep + would all have to actually be part of the saved state in case NEEDBITS() + returns: + + case STATEw: + while (want < need) { + NEEDBITS(n); + keep[want++] = BITS(n); + DROPBITS(n); + } + state = STATEx; + case STATEx: + + As shown above, if the next state is also the next case, then the break + is omitted. + + A state may also return if there is not enough output space available to + complete that state. Those states are copying stored data, writing a + literal byte, and copying a matching string. + + When returning, a "goto inf_leave" is used to update the total counters, + update the check value, and determine whether any progress has been made + during that inflate() call in order to return the proper return code. + Progress is defined as a change in either strm->avail_in or strm->avail_out. + When there is a window, goto inf_leave will update the window with the last + output written. If a goto inf_leave occurs in the middle of decompression + and there is no window currently, goto inf_leave will create one and copy + output to the window for the next call of inflate(). + + In this implementation, the flush parameter of inflate() only affects the + return code (per zlib.h). inflate() always writes as much as possible to + strm->next_out, given the space available and the provided input--the effect + documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers + the allocation of and copying into a sliding window until necessary, which + provides the effect documented in zlib.h for Z_FINISH when the entire input + stream available. So the only thing the flush parameter actually does is: + when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it + will return Z_BUF_ERROR if it has not reached the end of the stream. + */ + +int ZEXPORT inflate(strm, flush) +z_streamp strm; +int flush; +{ + struct inflate_state FAR *state; + z_const unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned in, out; /* save starting available input and output */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code here; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ +#ifdef GUNZIP + unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ +#endif + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + if (inflateStateCheck(strm) || strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0)) + return Z_STREAM_ERROR; + + state = (struct inflate_state FAR *)strm->state; + if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ + LOAD(); + in = have; + out = left; + ret = Z_OK; + for (;;) + switch (state->mode) { + case HEAD: + if (state->wrap == 0) { + state->mode = TYPEDO; + break; + } + NEEDBITS(16); +#ifdef GUNZIP + if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ + if (state->wbits == 0) + state->wbits = 15; + state->check = crc32(0L, Z_NULL, 0); + CRC2(state->check, hold); + INITBITS(); + state->mode = FLAGS; + break; + } + state->flags = 0; /* expect zlib header */ + if (state->head != Z_NULL) + state->head->done = -1; + if (!(state->wrap & 1) || /* check if zlib header allowed */ +#else + if ( +#endif + ((BITS(8) << 8) + (hold >> 8)) % 31) { + strm->msg = (char *)"incorrect header check"; + state->mode = BAD; + break; + } + if (BITS(4) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + DROPBITS(4); + len = BITS(4) + 8; + if (state->wbits == 0) + state->wbits = len; + if (len > 15 || len > state->wbits) { + strm->msg = (char *)"invalid window size"; + state->mode = BAD; + break; + } + state->dmax = 1U << len; + Tracev((stderr, "inflate: zlib header ok\n")); + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = hold & 0x200 ? DICTID : TYPE; + INITBITS(); + break; +#ifdef GUNZIP + case FLAGS: + NEEDBITS(16); + state->flags = (int)(hold); + if ((state->flags & 0xff) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + if (state->flags & 0xe000) { + strm->msg = (char *)"unknown header flags set"; + state->mode = BAD; + break; + } + if (state->head != Z_NULL) + state->head->text = (int)((hold >> 8) & 1); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); + INITBITS(); + state->mode = TIME; + case TIME: + NEEDBITS(32); + if (state->head != Z_NULL) + state->head->time = hold; + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC4(state->check, hold); + INITBITS(); + state->mode = OS; + case OS: + NEEDBITS(16); + if (state->head != Z_NULL) { + state->head->xflags = (int)(hold & 0xff); + state->head->os = (int)(hold >> 8); + } + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); + INITBITS(); + state->mode = EXLEN; + case EXLEN: + if (state->flags & 0x0400) { + NEEDBITS(16); + state->length = (unsigned)(hold); + if (state->head != Z_NULL) + state->head->extra_len = (unsigned)hold; + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); + INITBITS(); + } + else if (state->head != Z_NULL) + state->head->extra = Z_NULL; + state->mode = EXTRA; + case EXTRA: + if (state->flags & 0x0400) { + copy = state->length; + if (copy > have) copy = have; + if (copy) { + if (state->head != Z_NULL && + state->head->extra != Z_NULL) { + len = state->head->extra_len - state->length; + zmemcpy(state->head->extra + len, next, + len + copy > state->head->extra_max ? + state->head->extra_max - len : copy); + } + if ((state->flags & 0x0200) && (state->wrap & 4)) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + state->length -= copy; + } + if (state->length) goto inf_leave; + } + state->length = 0; + state->mode = NAME; + case NAME: + if (state->flags & 0x0800) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + if (state->head != Z_NULL && + state->head->name != Z_NULL && + state->length < state->head->name_max) + state->head->name[state->length++] = (Bytef)len; + } while (len && copy < have); + if ((state->flags & 0x0200) && (state->wrap & 4)) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + else if (state->head != Z_NULL) + state->head->name = Z_NULL; + state->length = 0; + state->mode = COMMENT; + case COMMENT: + if (state->flags & 0x1000) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + if (state->head != Z_NULL && + state->head->comment != Z_NULL && + state->length < state->head->comm_max) + state->head->comment[state->length++] = (Bytef)len; + } while (len && copy < have); + if ((state->flags & 0x0200) && (state->wrap & 4)) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + else if (state->head != Z_NULL) + state->head->comment = Z_NULL; + state->mode = HCRC; + case HCRC: + if (state->flags & 0x0200) { + NEEDBITS(16); + if ((state->wrap & 4) && hold != (state->check & 0xffff)) { + strm->msg = (char *)"header crc mismatch"; + state->mode = BAD; + break; + } + INITBITS(); + } + if (state->head != Z_NULL) { + state->head->hcrc = (int)((state->flags >> 9) & 1); + state->head->done = 1; + } + strm->adler = state->check = crc32(0L, Z_NULL, 0); + state->mode = TYPE; + break; +#endif + case DICTID: + NEEDBITS(32); + strm->adler = state->check = ZSWAP32(hold); + INITBITS(); + state->mode = DICT; + case DICT: + if (state->havedict == 0) { + RESTORE(); + return Z_NEED_DICT; + } + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = TYPE; + case TYPE: + if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; + case TYPEDO: + if (state->last) { + BYTEBITS(); + state->mode = CHECK; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + state->last ? " (last)" : "")); + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + Tracev((stderr, "inflate: fixed codes block%s\n", + state->last ? " (last)" : "")); + state->mode = LEN_; /* decode codes */ + if (flush == Z_TREES) { + DROPBITS(2); + goto inf_leave; + } + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + state->last ? " (last)" : "")); + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + case STORED: + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %u\n", + state->length)); + INITBITS(); + state->mode = COPY_; + if (flush == Z_TREES) goto inf_leave; + case COPY_: + state->mode = COPY; + case COPY: + copy = state->length; + if (copy) { + if (copy > have) copy = have; + if (copy > left) copy = left; + if (copy == 0) goto inf_leave; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + break; + } + Tracev((stderr, "inflate: stored end\n")); + state->mode = TYPE; + break; + case TABLE: + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); +#ifndef PKZIP_BUG_WORKAROUND + if (state->nlen > 286 || state->ndist > 30) { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } +#endif + Tracev((stderr, "inflate: table sizes ok\n")); + state->have = 0; + state->mode = LENLENS; + case LENLENS: + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (const code FAR *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + state->have = 0; + state->mode = CODELENS; + case CODELENS: + while (state->have < state->nlen + state->ndist) { + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.val < 16) { + DROPBITS(here.bits); + state->lens[state->have++] = here.val; + } + else { + if (here.val == 16) { + NEEDBITS(here.bits + 2); + DROPBITS(here.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = state->lens[state->have - 1]; + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (here.val == 17) { + NEEDBITS(here.bits + 3); + DROPBITS(here.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(here.bits + 7); + DROPBITS(here.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (state->mode == BAD) break; + + /* check for end-of-block code (better have one) */ + if (state->lens[256] == 0) { + strm->msg = (char *)"invalid code -- missing end-of-block"; + state->mode = BAD; + break; + } + + /* build code tables -- note: do not change the lenbits or distbits + values here (9 and 6) without reading the comments in inftrees.h + concerning the ENOUGH constants, which depend on those values */ + state->next = state->codes; + state->lencode = (const code FAR *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (const code FAR *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + &(state->next), &(state->distbits), state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + state->mode = LEN_; + if (flush == Z_TREES) goto inf_leave; + case LEN_: + state->mode = LEN; + case LEN: + if (have >= 6 && left >= 258) { + RESTORE(); + inflate_fast(strm, out); + LOAD(); + if (state->mode == TYPE) + state->back = -1; + break; + } + state->back = 0; + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.op && (here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + state->back += last.bits; + } + DROPBITS(here.bits); + state->back += here.bits; + state->length = (unsigned)here.val; + if ((int)(here.op) == 0) { + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + state->mode = LIT; + break; + } + if (here.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + state->back = -1; + state->mode = TYPE; + break; + } + if (here.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + state->extra = (unsigned)(here.op) & 15; + state->mode = LENEXT; + case LENEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + state->back += state->extra; + } + Tracevv((stderr, "inflate: length %u\n", state->length)); + state->was = state->length; + state->mode = DIST; + case DIST: + for (;;) { + here = state->distcode[BITS(state->distbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if ((here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + state->back += last.bits; + } + DROPBITS(here.bits); + state->back += here.bits; + if (here.op & 64) { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)here.val; + state->extra = (unsigned)(here.op) & 15; + state->mode = DISTEXT; + case DISTEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + state->back += state->extra; + } +#ifdef INFLATE_STRICT + if (state->offset > state->dmax) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#endif + Tracevv((stderr, "inflate: distance %u\n", state->offset)); + state->mode = MATCH; + case MATCH: + if (left == 0) goto inf_leave; + copy = out - left; + if (state->offset > copy) { /* copy from window */ + copy = state->offset - copy; + if (copy > state->whave) { + if (state->sane) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + Trace((stderr, "inflate.c too far\n")); + copy -= state->whave; + if (copy > state->length) copy = state->length; + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do { + *put++ = 0; + } while (--copy); + if (state->length == 0) state->mode = LEN; + break; +#endif + } + if (copy > state->wnext) { + copy -= state->wnext; + from = state->window + (state->wsize - copy); + } + else + from = state->window + (state->wnext - copy); + if (copy > state->length) copy = state->length; + } + else { /* copy from output */ + from = put - state->offset; + copy = state->length; + } + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do { + *put++ = *from++; + } while (--copy); + if (state->length == 0) state->mode = LEN; + break; + case LIT: + if (left == 0) goto inf_leave; + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + case CHECK: + if (state->wrap) { + NEEDBITS(32); + out -= left; + strm->total_out += out; + state->total += out; + if ((state->wrap & 4) && out) + strm->adler = state->check = + UPDATE(state->check, put - out, out); + out = left; + if ((state->wrap & 4) && ( +#ifdef GUNZIP + state->flags ? hold : +#endif + ZSWAP32(hold)) != state->check) { + strm->msg = (char *)"incorrect data check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: check matches trailer\n")); + } +#ifdef GUNZIP + state->mode = LENGTH; + case LENGTH: + if (state->wrap && state->flags) { + NEEDBITS(32); + if (hold != (state->total & 0xffffffffUL)) { + strm->msg = (char *)"incorrect length check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: length matches trailer\n")); + } +#endif + state->mode = DONE; + case DONE: + ret = Z_STREAM_END; + goto inf_leave; + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + default: + return Z_STREAM_ERROR; + } + + /* + Return from inflate(), updating the total counts and the check value. + If there was no progress during the inflate() call, return a buffer + error. Call updatewindow() to create and/or update the window state. + Note: a memory error from inflate() is non-recoverable. + */ + inf_leave: + RESTORE(); + if (state->wsize || (out != strm->avail_out && state->mode < BAD && + (state->mode < CHECK || flush != Z_FINISH))) + if (updatewindow(strm, strm->next_out, out - strm->avail_out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + in -= strm->avail_in; + out -= strm->avail_out; + strm->total_in += in; + strm->total_out += out; + state->total += out; + if ((state->wrap & 4) && out) + strm->adler = state->check = + UPDATE(state->check, strm->next_out - out, out); + strm->data_type = (int)state->bits + (state->last ? 64 : 0) + + (state->mode == TYPE ? 128 : 0) + + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); + if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) + ret = Z_BUF_ERROR; + return ret; +} + +int ZEXPORT inflateEnd(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (inflateStateCheck(strm)) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->window != Z_NULL) ZFREE(strm, state->window); + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + +int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) +z_streamp strm; +Bytef *dictionary; +uInt *dictLength; +{ + struct inflate_state FAR *state; + + /* check state */ + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* copy dictionary */ + if (state->whave && dictionary != Z_NULL) { + zmemcpy(dictionary, state->window + state->wnext, + state->whave - state->wnext); + zmemcpy(dictionary + state->whave - state->wnext, + state->window, state->wnext); + } + if (dictLength != Z_NULL) + *dictLength = state->whave; + return Z_OK; +} + +int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) +z_streamp strm; +const Bytef *dictionary; +uInt dictLength; +{ + struct inflate_state FAR *state; + unsigned long dictid; + int ret; + + /* check state */ + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->wrap != 0 && state->mode != DICT) + return Z_STREAM_ERROR; + + /* check for correct dictionary identifier */ + if (state->mode == DICT) { + dictid = adler32(0L, Z_NULL, 0); + dictid = adler32(dictid, dictionary, dictLength); + if (dictid != state->check) + return Z_DATA_ERROR; + } + + /* copy dictionary to window using updatewindow(), which will amend the + existing dictionary if appropriate */ + ret = updatewindow(strm, dictionary + dictLength, dictLength); + if (ret) { + state->mode = MEM; + return Z_MEM_ERROR; + } + state->havedict = 1; + Tracev((stderr, "inflate: dictionary set\n")); + return Z_OK; +} + +int ZEXPORT inflateGetHeader(strm, head) +z_streamp strm; +gz_headerp head; +{ + struct inflate_state FAR *state; + + /* check state */ + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; + + /* save header structure */ + state->head = head; + head->done = 0; + return Z_OK; +} + +/* + Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found + or when out of input. When called, *have is the number of pattern bytes + found in order so far, in 0..3. On return *have is updated to the new + state. If on return *have equals four, then the pattern was found and the + return value is how many bytes were read including the last byte of the + pattern. If *have is less than four, then the pattern has not been found + yet and the return value is len. In the latter case, syncsearch() can be + called again with more data and the *have state. *have is initialized to + zero for the first call. + */ +local unsigned syncsearch(have, buf, len) +unsigned FAR *have; +const unsigned char FAR *buf; +unsigned len; +{ + unsigned got; + unsigned next; + + got = *have; + next = 0; + while (next < len && got < 4) { + if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) + got++; + else if (buf[next]) + got = 0; + else + got = 4 - got; + next++; + } + *have = got; + return next; +} + +int ZEXPORT inflateSync(strm) +z_streamp strm; +{ + unsigned len; /* number of bytes to look at or looked at */ + unsigned long in, out; /* temporary to save total_in and total_out */ + unsigned char buf[4]; /* to restore bit buffer to byte string */ + struct inflate_state FAR *state; + + /* check parameters */ + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; + + /* if first time, start search in bit buffer */ + if (state->mode != SYNC) { + state->mode = SYNC; + state->hold <<= state->bits & 7; + state->bits -= state->bits & 7; + len = 0; + while (state->bits >= 8) { + buf[len++] = (unsigned char)(state->hold); + state->hold >>= 8; + state->bits -= 8; + } + state->have = 0; + syncsearch(&(state->have), buf, len); + } + + /* search available input */ + len = syncsearch(&(state->have), strm->next_in, strm->avail_in); + strm->avail_in -= len; + strm->next_in += len; + strm->total_in += len; + + /* return no joy or set up to restart inflate() on a new block */ + if (state->have != 4) return Z_DATA_ERROR; + in = strm->total_in; out = strm->total_out; + inflateReset(strm); + strm->total_in = in; strm->total_out = out; + state->mode = TYPE; + return Z_OK; +} + +/* + Returns true if inflate is currently at the end of a block generated by + Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + implementation to provide an additional safety check. PPP uses + Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored + block. When decompressing, PPP checks that at the end of input packet, + inflate is waiting for these length bytes. + */ +int ZEXPORT inflateSyncPoint(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + return state->mode == STORED && state->bits == 0; +} + +int ZEXPORT inflateCopy(dest, source) +z_streamp dest; +z_streamp source; +{ + struct inflate_state FAR *state; + struct inflate_state FAR *copy; + unsigned char FAR *window; + unsigned wsize; + + /* check input */ + if (inflateStateCheck(source) || dest == Z_NULL) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)source->state; + + /* allocate space */ + copy = (struct inflate_state FAR *) + ZALLOC(source, 1, sizeof(struct inflate_state)); + if (copy == Z_NULL) return Z_MEM_ERROR; + window = Z_NULL; + if (state->window != Z_NULL) { + window = (unsigned char FAR *) + ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); + if (window == Z_NULL) { + ZFREE(source, copy); + return Z_MEM_ERROR; + } + } + + /* copy state */ + zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); + zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); + copy->strm = dest; + if (state->lencode >= state->codes && + state->lencode <= state->codes + ENOUGH - 1) { + copy->lencode = copy->codes + (state->lencode - state->codes); + copy->distcode = copy->codes + (state->distcode - state->codes); + } + copy->next = copy->codes + (state->next - state->codes); + if (window != Z_NULL) { + wsize = 1U << state->wbits; + zmemcpy(window, state->window, wsize); + } + copy->window = window; + dest->state = (struct internal_state FAR *)copy; + return Z_OK; +} + +int ZEXPORT inflateUndermine(strm, subvert) +z_streamp strm; +int subvert; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + state->sane = !subvert; + return Z_OK; +#else + (void)subvert; + state->sane = 1; + return Z_DATA_ERROR; +#endif +} + +int ZEXPORT inflateValidate(strm, check) +z_streamp strm; +int check; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (check) + state->wrap |= 4; + else + state->wrap &= ~4; + return Z_OK; +} + +long ZEXPORT inflateMark(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) + return -(1L << 16); + state = (struct inflate_state FAR *)strm->state; + return (long)(((unsigned long)((long)state->back)) << 16) + + (state->mode == COPY ? state->length : + (state->mode == MATCH ? state->was - state->length : 0)); +} + +unsigned long ZEXPORT inflateCodesUsed(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (inflateStateCheck(strm)) return (unsigned long)-1; + state = (struct inflate_state FAR *)strm->state; + return (unsigned long)(state->next - state->codes); +} diff --git a/xs/src/png/zlib/inflate.h b/xs/src/png/zlib/inflate.h new file mode 100644 index 0000000000..a46cce6b6d --- /dev/null +++ b/xs/src/png/zlib/inflate.h @@ -0,0 +1,125 @@ +/* inflate.h -- internal inflate state definition + * Copyright (C) 1995-2016 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer decoding by inflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip decoding + should be left enabled. */ +#ifndef NO_GZIP +# define GUNZIP +#endif + +/* Possible inflate modes between inflate() calls */ +typedef enum { + HEAD = 16180, /* i: waiting for magic header */ + FLAGS, /* i: waiting for method and flags (gzip) */ + TIME, /* i: waiting for modification time (gzip) */ + OS, /* i: waiting for extra flags and operating system (gzip) */ + EXLEN, /* i: waiting for extra length (gzip) */ + EXTRA, /* i: waiting for extra bytes (gzip) */ + NAME, /* i: waiting for end of file name (gzip) */ + COMMENT, /* i: waiting for end of comment (gzip) */ + HCRC, /* i: waiting for header crc (gzip) */ + DICTID, /* i: waiting for dictionary check value */ + DICT, /* waiting for inflateSetDictionary() call */ + TYPE, /* i: waiting for type bits, including last-flag bit */ + TYPEDO, /* i: same, but skip check to exit inflate on new block */ + STORED, /* i: waiting for stored size (length and complement) */ + COPY_, /* i/o: same as COPY below, but only first time in */ + COPY, /* i/o: waiting for input or output to copy stored block */ + TABLE, /* i: waiting for dynamic block table lengths */ + LENLENS, /* i: waiting for code length code lengths */ + CODELENS, /* i: waiting for length/lit and distance code lengths */ + LEN_, /* i: same as LEN below, but only first time in */ + LEN, /* i: waiting for length/lit/eob code */ + LENEXT, /* i: waiting for length extra bits */ + DIST, /* i: waiting for distance code */ + DISTEXT, /* i: waiting for distance extra bits */ + MATCH, /* o: waiting for output space to copy string */ + LIT, /* o: waiting for output space to write literal */ + CHECK, /* i: waiting for 32-bit check value */ + LENGTH, /* i: waiting for 32-bit length (gzip) */ + DONE, /* finished check, done -- remain here until reset */ + BAD, /* got a data error -- remain here until reset */ + MEM, /* got an inflate() memory error -- remain here until reset */ + SYNC /* looking for synchronization bytes to restart inflate() */ +} inflate_mode; + +/* + State transitions between above modes - + + (most modes can go to BAD or MEM on error -- not shown for clarity) + + Process header: + HEAD -> (gzip) or (zlib) or (raw) + (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> + HCRC -> TYPE + (zlib) -> DICTID or TYPE + DICTID -> DICT -> TYPE + (raw) -> TYPEDO + Read deflate blocks: + TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK + STORED -> COPY_ -> COPY -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN_ + LEN_ -> LEN + Read deflate codes in fixed or dynamic block: + LEN -> LENEXT or LIT or TYPE + LENEXT -> DIST -> DISTEXT -> MATCH -> LEN + LIT -> LEN + Process trailer: + CHECK -> LENGTH -> DONE + */ + +/* State maintained between inflate() calls -- approximately 7K bytes, not + including the allocated sliding window, which is up to 32K bytes. */ +struct inflate_state { + z_streamp strm; /* pointer back to this zlib stream */ + inflate_mode mode; /* current inflate mode */ + int last; /* true if processing last block */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip, + bit 2 true to validate check value */ + int havedict; /* true if dictionary provided */ + int flags; /* gzip header method and flags (0 if zlib) */ + unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ + unsigned long check; /* protected copy of check value */ + unsigned long total; /* protected copy of output count */ + gz_headerp head; /* where to save gzip header information */ + /* sliding window */ + unsigned wbits; /* log base 2 of requested window size */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* bit accumulator */ + unsigned long hold; /* input bit accumulator */ + unsigned bits; /* number of bits in "in" */ + /* for string and stored block copying */ + unsigned length; /* literal or length of data to copy */ + unsigned offset; /* distance back to copy string from */ + /* for table and code decoding */ + unsigned extra; /* extra bits needed */ + /* fixed and dynamic code tables */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ + int sane; /* if false, allow invalid distance too far */ + int back; /* bits back of last unprocessed length/lit */ + unsigned was; /* initial length of match */ +}; diff --git a/xs/src/png/zlib/inftrees.c b/xs/src/png/zlib/inftrees.c new file mode 100644 index 0000000000..2ea08fc13e --- /dev/null +++ b/xs/src/png/zlib/inftrees.c @@ -0,0 +1,304 @@ +/* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2017 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" + +#define MAXBITS 15 + +const char inflate_copyright[] = + " inflate 1.2.11 Copyright 1995-2017 Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* + Build a set of tables to decode the provided canonical Huffman code. + The code lengths are lens[0..codes-1]. The result starts at *table, + whose indices are 0..2^bits-1. work is a writable array of at least + lens shorts, which is used as a work area. type is the type of code + to be generated, CODES, LENS, or DISTS. On return, zero is success, + -1 is an invalid code, and +1 means that ENOUGH isn't enough. table + on return points to the next available entry's address. bits is the + requested root table index bits, and on return it is the actual root + table index bits. It will differ if the request is greater than the + longest code or if it is less than the shortest code. + */ +int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) +codetype type; +unsigned short FAR *lens; +unsigned codes; +code FAR * FAR *table; +unsigned FAR *bits; +unsigned short FAR *work; +{ + unsigned len; /* a code's length in bits */ + unsigned sym; /* index of code symbols */ + unsigned min, max; /* minimum and maximum code lengths */ + unsigned root; /* number of index bits for root table */ + unsigned curr; /* number of index bits for current table */ + unsigned drop; /* code bits to drop for sub-table */ + int left; /* number of prefix codes available */ + unsigned used; /* code entries in table used */ + unsigned huff; /* Huffman code */ + unsigned incr; /* for incrementing code, index */ + unsigned fill; /* index for replicating entries */ + unsigned low; /* low bits for current root entry */ + unsigned mask; /* mask for low root bits */ + code here; /* table entry for duplication */ + code FAR *next; /* next available space in table */ + const unsigned short FAR *base; /* base value table to use */ + const unsigned short FAR *extra; /* extra bits table to use */ + unsigned match; /* use base and extra for symbol >= match */ + unsigned short count[MAXBITS+1]; /* number of codes of each length */ + unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ + static const unsigned short lbase[31] = { /* Length codes 257..285 base */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + static const unsigned short lext[31] = { /* Length codes 257..285 extra */ + 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202}; + static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577, 0, 0}; + static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ + 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, + 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 28, 28, 29, 29, 64, 64}; + + /* + Process a set of code lengths to create a canonical Huffman code. The + code lengths are lens[0..codes-1]. Each length corresponds to the + symbols 0..codes-1. The Huffman code is generated by first sorting the + symbols by length from short to long, and retaining the symbol order + for codes with equal lengths. Then the code starts with all zero bits + for the first code of the shortest length, and the codes are integer + increments for the same length, and zeros are appended as the length + increases. For the deflate format, these bits are stored backwards + from their more natural integer increment ordering, and so when the + decoding tables are built in the large loop below, the integer codes + are incremented backwards. + + This routine assumes, but does not check, that all of the entries in + lens[] are in the range 0..MAXBITS. The caller must assure this. + 1..MAXBITS is interpreted as that code length. zero means that that + symbol does not occur in this code. + + The codes are sorted by computing a count of codes for each length, + creating from that a table of starting indices for each length in the + sorted table, and then entering the symbols in order in the sorted + table. The sorted table is work[], with that space being provided by + the caller. + + The length counts are used for other purposes as well, i.e. finding + the minimum and maximum length codes, determining if there are any + codes at all, checking for a valid set of lengths, and looking ahead + at length counts to determine sub-table sizes when building the + decoding tables. + */ + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAXBITS; len++) + count[len] = 0; + for (sym = 0; sym < codes; sym++) + count[lens[sym]]++; + + /* bound code lengths, force root to be within code lengths */ + root = *bits; + for (max = MAXBITS; max >= 1; max--) + if (count[max] != 0) break; + if (root > max) root = max; + if (max == 0) { /* no symbols to code at all */ + here.op = (unsigned char)64; /* invalid code marker */ + here.bits = (unsigned char)1; + here.val = (unsigned short)0; + *(*table)++ = here; /* make a table to force an error */ + *(*table)++ = here; + *bits = 1; + return 0; /* no symbols, but wait for decoding to report error */ + } + for (min = 1; min < max; min++) + if (count[min] != 0) break; + if (root < min) root = min; + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) return -1; /* over-subscribed */ + } + if (left > 0 && (type == CODES || max != 1)) + return -1; /* incomplete set */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + count[len]; + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) + if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; + + /* + Create and fill in decoding tables. In this loop, the table being + filled is at next and has curr index bits. The code being used is huff + with length len. That code is converted to an index by dropping drop + bits off of the bottom. For codes where len is less than drop + curr, + those top drop + curr - len bits are incremented through all values to + fill the table with replicated entries. + + root is the number of index bits for the root table. When len exceeds + root, sub-tables are created pointed to by the root entry with an index + of the low root bits of huff. This is saved in low to check for when a + new sub-table should be started. drop is zero when the root table is + being filled, and drop is root when sub-tables are being filled. + + When a new sub-table is needed, it is necessary to look ahead in the + code lengths to determine what size sub-table is needed. The length + counts are used for this, and so count[] is decremented as codes are + entered in the tables. + + used keeps track of how many table entries have been allocated from the + provided *table space. It is checked for LENS and DIST tables against + the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in + the initial root table size constants. See the comments in inftrees.h + for more information. + + sym increments through all symbols, and the loop terminates when + all codes of length max, i.e. all codes, have been processed. This + routine permits incomplete codes, so another loop after this one fills + in the rest of the decoding tables with invalid code markers. + */ + + /* set up for code type */ + switch (type) { + case CODES: + base = extra = work; /* dummy value--not used */ + match = 20; + break; + case LENS: + base = lbase; + extra = lext; + match = 257; + break; + default: /* DISTS */ + base = dbase; + extra = dext; + match = 0; + } + + /* initialize state for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = *table; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = (unsigned)(-1); /* trigger new sub-table when len > root */ + used = 1U << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if ((type == LENS && used > ENOUGH_LENS) || + (type == DISTS && used > ENOUGH_DISTS)) + return 1; + + /* process all codes and make table entries */ + for (;;) { + /* create table entry */ + here.bits = (unsigned char)(len - drop); + if (work[sym] + 1U < match) { + here.op = (unsigned char)0; + here.val = work[sym]; + } + else if (work[sym] >= match) { + here.op = (unsigned char)(extra[work[sym] - match]); + here.val = base[work[sym] - match]; + } + else { + here.op = (unsigned char)(32 + 64); /* end of block */ + here.val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1U << (len - drop); + fill = 1U << curr; + min = fill; /* save offset to next table */ + do { + fill -= incr; + next[(huff >> drop) + fill] = here; + } while (fill != 0); + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + + /* go to next symbol, update count, len */ + sym++; + if (--(count[len]) == 0) { + if (len == max) break; + len = lens[work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) != low) { + /* if first time, transition to sub-tables */ + if (drop == 0) + drop = root; + + /* increment past last table */ + next += min; /* here min is 1 << curr */ + + /* determine length of next table */ + curr = len - drop; + left = (int)(1 << curr); + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) break; + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1U << curr; + if ((type == LENS && used > ENOUGH_LENS) || + (type == DISTS && used > ENOUGH_DISTS)) + return 1; + + /* point entry in root table to sub-table */ + low = huff & mask; + (*table)[low].op = (unsigned char)curr; + (*table)[low].bits = (unsigned char)root; + (*table)[low].val = (unsigned short)(next - *table); + } + } + + /* fill in remaining table entry if code is incomplete (guaranteed to have + at most one remaining entry, since if the code is incomplete, the + maximum code length that was allowed to get this far is one bit) */ + if (huff != 0) { + here.op = (unsigned char)64; /* invalid code marker */ + here.bits = (unsigned char)(len - drop); + here.val = (unsigned short)0; + next[huff] = here; + } + + /* set return parameters */ + *table += used; + *bits = root; + return 0; +} diff --git a/xs/src/png/zlib/inftrees.h b/xs/src/png/zlib/inftrees.h new file mode 100644 index 0000000000..baa53a0b1a --- /dev/null +++ b/xs/src/png/zlib/inftrees.h @@ -0,0 +1,62 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2005, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + +/* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 0001eeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + +/* Maximum size of the dynamic table. The maximum number of code structures is + 1444, which is the sum of 852 for literal/length codes and 592 for distance + codes. These values were found by exhaustive searches using the program + examples/enough.c found in the zlib distribtution. The arguments to that + program are the number of symbols, the initial root table size, and the + maximum bit length of a code. "enough 286 9 15" for literal/length codes + returns returns 852, and "enough 30 6 15" for distance codes returns 592. + The initial root table size (9 or 6) is found in the fifth argument of the + inflate_table() calls in inflate.c and infback.c. If the root table size is + changed, then these maximum sizes would be need to be recalculated and + updated. */ +#define ENOUGH_LENS 852 +#define ENOUGH_DISTS 592 +#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) + +/* Type of code to build for inflate_table() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; + +int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work)); diff --git a/xs/src/png/zlib/make_vms.com b/xs/src/png/zlib/make_vms.com new file mode 100644 index 0000000000..65e9d0cbc8 --- /dev/null +++ b/xs/src/png/zlib/make_vms.com @@ -0,0 +1,867 @@ +$! make libz under VMS written by +$! Martin P.J. Zinser +$! +$! In case of problems with the install you might contact me at +$! zinser@zinser.no-ip.info(preferred) or +$! martin.zinser@eurexchange.com (work) +$! +$! Make procedure history for Zlib +$! +$!------------------------------------------------------------------------------ +$! Version history +$! 0.01 20060120 First version to receive a number +$! 0.02 20061008 Adapt to new Makefile.in +$! 0.03 20091224 Add support for large file check +$! 0.04 20100110 Add new gzclose, gzlib, gzread, gzwrite +$! 0.05 20100221 Exchange zlibdefs.h by zconf.h.in +$! 0.06 20120111 Fix missing amiss_err, update zconf_h.in, fix new exmples +$! subdir path, update module search in makefile.in +$! 0.07 20120115 Triggered by work done by Alexey Chupahin completly redesigned +$! shared image creation +$! 0.08 20120219 Make it work on VAX again, pre-load missing symbols to shared +$! image +$! 0.09 20120305 SMS. P1 sets builder ("MMK", "MMS", " " (built-in)). +$! "" -> automatic, preference: MMK, MMS, built-in. +$! +$ on error then goto err_exit +$! +$ true = 1 +$ false = 0 +$ tmpnam = "temp_" + f$getjpi("","pid") +$ tt = tmpnam + ".txt" +$ tc = tmpnam + ".c" +$ th = tmpnam + ".h" +$ define/nolog tconfig 'th' +$ its_decc = false +$ its_vaxc = false +$ its_gnuc = false +$ s_case = False +$! +$! Setup variables holding "config" information +$! +$ Make = "''p1'" +$ name = "Zlib" +$ version = "?.?.?" +$ v_string = "ZLIB_VERSION" +$ v_file = "zlib.h" +$ ccopt = "/include = []" +$ lopts = "" +$ dnsrl = "" +$ aconf_in_file = "zconf.h.in#zconf.h_in#zconf_h.in" +$ conf_check_string = "" +$ linkonly = false +$ optfile = name + ".opt" +$ mapfile = name + ".map" +$ libdefs = "" +$ vax = f$getsyi("HW_MODEL").lt.1024 +$ axp = f$getsyi("HW_MODEL").ge.1024 .and. f$getsyi("HW_MODEL").lt.4096 +$ ia64 = f$getsyi("HW_MODEL").ge.4096 +$! +$! 2012-03-05 SMS. +$! Why is this needed? And if it is needed, why not simply ".not. vax"? +$! +$!!! if axp .or. ia64 then set proc/parse=extended +$! +$ whoami = f$parse(f$environment("Procedure"),,,,"NO_CONCEAL") +$ mydef = F$parse(whoami,,,"DEVICE") +$ mydir = f$parse(whoami,,,"DIRECTORY") - "][" +$ myproc = f$parse(whoami,,,"Name") + f$parse(whoami,,,"type") +$! +$! Check for MMK/MMS +$! +$ if (Make .eqs. "") +$ then +$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" +$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" +$ else +$ Make = f$edit( Make, "trim") +$ endif +$! +$ gosub find_version +$! +$ open/write topt tmp.opt +$ open/write optf 'optfile' +$! +$ gosub check_opts +$! +$! Look for the compiler used +$! +$ gosub check_compiler +$ close topt +$ close optf +$! +$ if its_decc +$ then +$ ccopt = "/prefix=all" + ccopt +$ if f$trnlnm("SYS") .eqs. "" +$ then +$ if axp +$ then +$ define sys sys$library: +$ else +$ ccopt = "/decc" + ccopt +$ define sys decc$library_include: +$ endif +$ endif +$! +$! 2012-03-05 SMS. +$! Why /NAMES = AS_IS? Why not simply ".not. vax"? And why not on VAX? +$! +$ if axp .or. ia64 +$ then +$ ccopt = ccopt + "/name=as_is/opt=(inline=speed)" +$ s_case = true +$ endif +$ endif +$ if its_vaxc .or. its_gnuc +$ then +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ endif +$! +$! Build a fake configure input header +$! +$ open/write conf_hin config.hin +$ write conf_hin "#undef _LARGEFILE64_SOURCE" +$ close conf_hin +$! +$! +$ i = 0 +$FIND_ACONF: +$ fname = f$element(i,"#",aconf_in_file) +$ if fname .eqs. "#" then goto AMISS_ERR +$ if f$search(fname) .eqs. "" +$ then +$ i = i + 1 +$ goto find_aconf +$ endif +$ open/read/err=aconf_err aconf_in 'fname' +$ open/write aconf zconf.h +$ACONF_LOOP: +$ read/end_of_file=aconf_exit aconf_in line +$ work = f$edit(line, "compress,trim") +$ if f$extract(0,6,work) .nes. "#undef" +$ then +$ if f$extract(0,12,work) .nes. "#cmakedefine" +$ then +$ write aconf line +$ endif +$ else +$ cdef = f$element(1," ",work) +$ gosub check_config +$ endif +$ goto aconf_loop +$ACONF_EXIT: +$ write aconf "" +$ write aconf "/* VMS specifics added by make_vms.com: */" +$ write aconf "#define VMS 1" +$ write aconf "#include " +$ write aconf "#include " +$ write aconf "#ifdef _LARGEFILE" +$ write aconf "# define off64_t __off64_t" +$ write aconf "# define fopen64 fopen" +$ write aconf "# define fseeko64 fseeko" +$ write aconf "# define lseek64 lseek" +$ write aconf "# define ftello64 ftell" +$ write aconf "#endif" +$ write aconf "#if !defined( __VAX) && (__CRTL_VER >= 70312000)" +$ write aconf "# define HAVE_VSNPRINTF" +$ write aconf "#endif" +$ close aconf_in +$ close aconf +$ if f$search("''th'") .nes. "" then delete 'th';* +$! Build the thing plain or with mms +$! +$ write sys$output "Compiling Zlib sources ..." +$ if make.eqs."" +$ then +$ if (f$search( "example.obj;*") .nes. "") then delete example.obj;* +$ if (f$search( "minigzip.obj;*") .nes. "") then delete minigzip.obj;* +$ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - + adler32.c zlib.h zconf.h +$ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - + compress.c zlib.h zconf.h +$ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" - + crc32.c zlib.h zconf.h +$ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" - + deflate.c deflate.h zutil.h zlib.h zconf.h +$ CALL MAKE gzclose.OBJ "CC ''CCOPT' gzclose" - + gzclose.c zutil.h zlib.h zconf.h +$ CALL MAKE gzlib.OBJ "CC ''CCOPT' gzlib" - + gzlib.c zutil.h zlib.h zconf.h +$ CALL MAKE gzread.OBJ "CC ''CCOPT' gzread" - + gzread.c zutil.h zlib.h zconf.h +$ CALL MAKE gzwrite.OBJ "CC ''CCOPT' gzwrite" - + gzwrite.c zutil.h zlib.h zconf.h +$ CALL MAKE infback.OBJ "CC ''CCOPT' infback" - + infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h +$ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" - + inffast.c zutil.h zlib.h zconf.h inffast.h +$ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" - + inflate.c zutil.h zlib.h zconf.h infblock.h +$ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" - + inftrees.c zutil.h zlib.h zconf.h inftrees.h +$ CALL MAKE trees.OBJ "CC ''CCOPT' trees" - + trees.c deflate.h zutil.h zlib.h zconf.h +$ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" - + uncompr.c zlib.h zconf.h +$ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" - + zutil.c zutil.h zlib.h zconf.h +$ write sys$output "Building Zlib ..." +$ CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ +$ write sys$output "Building example..." +$ CALL MAKE example.OBJ "CC ''CCOPT' [.test]example" - + [.test]example.c zlib.h zconf.h +$ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb +$ write sys$output "Building minigzip..." +$ CALL MAKE minigzip.OBJ "CC ''CCOPT' [.test]minigzip" - + [.test]minigzip.c zlib.h zconf.h +$ call make minigzip.exe - + "LINK minigzip,libz.olb/lib" - + minigzip.obj libz.olb +$ else +$ gosub crea_mms +$ write sys$output "Make ''name' ''version' with ''Make' " +$ 'make' +$ endif +$! +$! Create shareable image +$! +$ gosub crea_olist +$ write sys$output "Creating libzshr.exe" +$ call map_2_shopt 'mapfile' 'optfile' +$ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,'optfile'/opt +$ write sys$output "Zlib build completed" +$ delete/nolog tmp.opt;* +$ exit +$AMISS_ERR: +$ write sys$output "No source for config.hin found." +$ write sys$output "Tried any of ''aconf_in_file'" +$ goto err_exit +$CC_ERR: +$ write sys$output "C compiler required to build ''name'" +$ goto err_exit +$ERR_EXIT: +$ set message/facil/ident/sever/text +$ close/nolog optf +$ close/nolog topt +$ close/nolog aconf_in +$ close/nolog aconf +$ close/nolog out +$ close/nolog min +$ close/nolog mod +$ close/nolog h_in +$ write sys$output "Exiting..." +$ exit 2 +$! +$! +$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES +$ V = 'F$Verify(0) +$! P1 = What we are trying to make +$! P2 = Command to make it +$! P3 - P8 What it depends on +$ +$ If F$Search(P1) .Eqs. "" Then Goto Makeit +$ Time = F$CvTime(F$File(P1,"RDT")) +$arg=3 +$Loop: +$ Argument = P'arg +$ If Argument .Eqs. "" Then Goto Exit +$ El=0 +$Loop2: +$ File = F$Element(El," ",Argument) +$ If File .Eqs. " " Then Goto Endl +$ AFile = "" +$Loop3: +$ OFile = AFile +$ AFile = F$Search(File) +$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl +$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit +$ Goto Loop3 +$NextEL: +$ El = El + 1 +$ Goto Loop2 +$EndL: +$ arg=arg+1 +$ If arg .Le. 8 Then Goto Loop +$ Goto Exit +$ +$Makeit: +$ VV=F$VERIFY(0) +$ write sys$output P2 +$ 'P2 +$ VV='F$Verify(VV) +$Exit: +$ If V Then Set Verify +$ENDSUBROUTINE +$!------------------------------------------------------------------------------ +$! +$! Check command line options and set symbols accordingly +$! +$!------------------------------------------------------------------------------ +$! Version history +$! 0.01 20041206 First version to receive a number +$! 0.02 20060126 Add new "HELP" target +$ CHECK_OPTS: +$ i = 1 +$ OPT_LOOP: +$ if i .lt. 9 +$ then +$ cparm = f$edit(p'i',"upcase") +$! +$! Check if parameter actually contains something +$! +$ if f$edit(cparm,"trim") .nes. "" +$ then +$ if cparm .eqs. "DEBUG" +$ then +$ ccopt = ccopt + "/noopt/deb" +$ lopts = lopts + "/deb" +$ endif +$ if f$locate("CCOPT=",cparm) .lt. f$length(cparm) +$ then +$ start = f$locate("=",cparm) + 1 +$ len = f$length(cparm) - start +$ ccopt = ccopt + f$extract(start,len,cparm) +$ if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) - + then s_case = true +$ endif +$ if cparm .eqs. "LINK" then linkonly = true +$ if f$locate("LOPTS=",cparm) .lt. f$length(cparm) +$ then +$ start = f$locate("=",cparm) + 1 +$ len = f$length(cparm) - start +$ lopts = lopts + f$extract(start,len,cparm) +$ endif +$ if f$locate("CC=",cparm) .lt. f$length(cparm) +$ then +$ start = f$locate("=",cparm) + 1 +$ len = f$length(cparm) - start +$ cc_com = f$extract(start,len,cparm) + if (cc_com .nes. "DECC") .and. - + (cc_com .nes. "VAXC") .and. - + (cc_com .nes. "GNUC") +$ then +$ write sys$output "Unsupported compiler choice ''cc_com' ignored" +$ write sys$output "Use DECC, VAXC, or GNUC instead" +$ else +$ if cc_com .eqs. "DECC" then its_decc = true +$ if cc_com .eqs. "VAXC" then its_vaxc = true +$ if cc_com .eqs. "GNUC" then its_gnuc = true +$ endif +$ endif +$ if f$locate("MAKE=",cparm) .lt. f$length(cparm) +$ then +$ start = f$locate("=",cparm) + 1 +$ len = f$length(cparm) - start +$ mmks = f$extract(start,len,cparm) +$ if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS") +$ then +$ make = mmks +$ else +$ write sys$output "Unsupported make choice ''mmks' ignored" +$ write sys$output "Use MMK or MMS instead" +$ endif +$ endif +$ if cparm .eqs. "HELP" then gosub bhelp +$ endif +$ i = i + 1 +$ goto opt_loop +$ endif +$ return +$!------------------------------------------------------------------------------ +$! +$! Look for the compiler used +$! +$! Version history +$! 0.01 20040223 First version to receive a number +$! 0.02 20040229 Save/set value of decc$no_rooted_search_lists +$! 0.03 20060202 Extend handling of GNU C +$! 0.04 20090402 Compaq -> hp +$CHECK_COMPILER: +$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) +$ then +$ its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "") +$ its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "") +$ its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "") +$ endif +$! +$! Exit if no compiler available +$! +$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) +$ then goto CC_ERR +$ else +$ if its_decc +$ then +$ write sys$output "CC compiler check ... hp C" +$ if f$trnlnm("decc$no_rooted_search_lists") .nes. "" +$ then +$ dnrsl = f$trnlnm("decc$no_rooted_search_lists") +$ endif +$ define/nolog decc$no_rooted_search_lists 1 +$ else +$ if its_vaxc then write sys$output "CC compiler check ... VAX C" +$ if its_gnuc +$ then +$ write sys$output "CC compiler check ... GNU C" +$ if f$trnlnm(topt) then write topt "gnu_cc:[000000]gcclib.olb/lib" +$ if f$trnlnm(optf) then write optf "gnu_cc:[000000]gcclib.olb/lib" +$ cc = "gcc" +$ endif +$ if f$trnlnm(topt) then write topt "sys$share:vaxcrtl.exe/share" +$ if f$trnlnm(optf) then write optf "sys$share:vaxcrtl.exe/share" +$ endif +$ endif +$ return +$!------------------------------------------------------------------------------ +$! +$! If MMS/MMK are available dump out the descrip.mms if required +$! +$CREA_MMS: +$ write sys$output "Creating descrip.mms..." +$ create descrip.mms +$ open/append out descrip.mms +$ copy sys$input: out +$ deck +# descrip.mms: MMS description file for building zlib on VMS +# written by Martin P.J. Zinser +# + +OBJS = adler32.obj, compress.obj, crc32.obj, gzclose.obj, gzlib.obj\ + gzread.obj, gzwrite.obj, uncompr.obj, infback.obj\ + deflate.obj, trees.obj, zutil.obj, inflate.obj, \ + inftrees.obj, inffast.obj + +$ eod +$ write out "CFLAGS=", ccopt +$ write out "LOPTS=", lopts +$ write out "all : example.exe minigzip.exe libz.olb" +$ copy sys$input: out +$ deck + @ write sys$output " Example applications available" + +libz.olb : libz.olb($(OBJS)) + @ write sys$output " libz available" + +example.exe : example.obj libz.olb + link $(LOPTS) example,libz.olb/lib + +minigzip.exe : minigzip.obj libz.olb + link $(LOPTS) minigzip,libz.olb/lib + +clean : + delete *.obj;*,libz.olb;*,*.opt;*,*.exe;* + + +# Other dependencies. +adler32.obj : adler32.c zutil.h zlib.h zconf.h +compress.obj : compress.c zlib.h zconf.h +crc32.obj : crc32.c zutil.h zlib.h zconf.h +deflate.obj : deflate.c deflate.h zutil.h zlib.h zconf.h +example.obj : [.test]example.c zlib.h zconf.h +gzclose.obj : gzclose.c zutil.h zlib.h zconf.h +gzlib.obj : gzlib.c zutil.h zlib.h zconf.h +gzread.obj : gzread.c zutil.h zlib.h zconf.h +gzwrite.obj : gzwrite.c zutil.h zlib.h zconf.h +inffast.obj : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h +inflate.obj : inflate.c zutil.h zlib.h zconf.h +inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h +minigzip.obj : [.test]minigzip.c zlib.h zconf.h +trees.obj : trees.c deflate.h zutil.h zlib.h zconf.h +uncompr.obj : uncompr.c zlib.h zconf.h +zutil.obj : zutil.c zutil.h zlib.h zconf.h +infback.obj : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h +$ eod +$ close out +$ return +$!------------------------------------------------------------------------------ +$! +$! Read list of core library sources from makefile.in and create options +$! needed to build shareable image +$! +$CREA_OLIST: +$ open/read min makefile.in +$ open/write mod modules.opt +$ src_check_list = "OBJZ =#OBJG =" +$MRLOOP: +$ read/end=mrdone min rec +$ i = 0 +$SRC_CHECK_LOOP: +$ src_check = f$element(i, "#", src_check_list) +$ i = i+1 +$ if src_check .eqs. "#" then goto mrloop +$ if (f$extract(0,6,rec) .nes. src_check) then goto src_check_loop +$ rec = rec - src_check +$ gosub extra_filnam +$ if (f$element(1,"\",rec) .eqs. "\") then goto mrloop +$MRSLOOP: +$ read/end=mrdone min rec +$ gosub extra_filnam +$ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop +$MRDONE: +$ close min +$ close mod +$ return +$!------------------------------------------------------------------------------ +$! +$! Take record extracted in crea_olist and split it into single filenames +$! +$EXTRA_FILNAM: +$ myrec = f$edit(rec - "\", "trim,compress") +$ i = 0 +$FELOOP: +$ srcfil = f$element(i," ", myrec) +$ if (srcfil .nes. " ") +$ then +$ write mod f$parse(srcfil,,,"NAME"), ".obj" +$ i = i + 1 +$ goto feloop +$ endif +$ return +$!------------------------------------------------------------------------------ +$! +$! Find current Zlib version number +$! +$FIND_VERSION: +$ open/read h_in 'v_file' +$hloop: +$ read/end=hdone h_in rec +$ rec = f$edit(rec,"TRIM") +$ if (f$extract(0,1,rec) .nes. "#") then goto hloop +$ rec = f$edit(rec - "#", "TRIM") +$ if f$element(0," ",rec) .nes. "define" then goto hloop +$ if f$element(1," ",rec) .eqs. v_string +$ then +$ version = 'f$element(2," ",rec)' +$ goto hdone +$ endif +$ goto hloop +$hdone: +$ close h_in +$ return +$!------------------------------------------------------------------------------ +$! +$CHECK_CONFIG: +$! +$ in_ldef = f$locate(cdef,libdefs) +$ if (in_ldef .lt. f$length(libdefs)) +$ then +$ write aconf "#define ''cdef' 1" +$ libdefs = f$extract(0,in_ldef,libdefs) + - + f$extract(in_ldef + f$length(cdef) + 1, - + f$length(libdefs) - in_ldef - f$length(cdef) - 1, - + libdefs) +$ else +$ if (f$type('cdef') .eqs. "INTEGER") +$ then +$ write aconf "#define ''cdef' ", 'cdef' +$ else +$ if (f$type('cdef') .eqs. "STRING") +$ then +$ write aconf "#define ''cdef' ", """", '''cdef'', """" +$ else +$ gosub check_cc_def +$ endif +$ endif +$ endif +$ return +$!------------------------------------------------------------------------------ +$! +$! Check if this is a define relating to the properties of the C/C++ +$! compiler +$! +$ CHECK_CC_DEF: +$ if (cdef .eqs. "_LARGEFILE64_SOURCE") +$ then +$ copy sys$input: 'tc' +$ deck +#include "tconfig" +#define _LARGEFILE +#include + +int main(){ +FILE *fp; + fp = fopen("temp.txt","r"); + fseeko(fp,1,SEEK_SET); + fclose(fp); +} + +$ eod +$ test_inv = false +$ comm_h = false +$ gosub cc_prop_check +$ return +$ endif +$ write aconf "/* ", line, " */" +$ return +$!------------------------------------------------------------------------------ +$! +$! Check for properties of C/C++ compiler +$! +$! Version history +$! 0.01 20031020 First version to receive a number +$! 0.02 20031022 Added logic for defines with value +$! 0.03 20040309 Make sure local config file gets not deleted +$! 0.04 20041230 Also write include for configure run +$! 0.05 20050103 Add processing of "comment defines" +$CC_PROP_CHECK: +$ cc_prop = true +$ is_need = false +$ is_need = (f$extract(0,4,cdef) .eqs. "NEED") .or. (test_inv .eq. true) +$ if f$search(th) .eqs. "" then create 'th' +$ set message/nofac/noident/nosever/notext +$ on error then continue +$ cc 'tmpnam' +$ if .not. ($status) then cc_prop = false +$ on error then continue +$! The headers might lie about the capabilities of the RTL +$ link 'tmpnam',tmp.opt/opt +$ if .not. ($status) then cc_prop = false +$ set message/fac/ident/sever/text +$ on error then goto err_exit +$ delete/nolog 'tmpnam'.*;*/exclude='th' +$ if (cc_prop .and. .not. is_need) .or. - + (.not. cc_prop .and. is_need) +$ then +$ write sys$output "Checking for ''cdef'... yes" +$ if f$type('cdef_val'_yes) .nes. "" +$ then +$ if f$type('cdef_val'_yes) .eqs. "INTEGER" - + then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_yes) +$ if f$type('cdef_val'_yes) .eqs. "STRING" - + then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_yes) +$ else +$ call write_config f$fao("#define !AS 1",cdef) +$ endif +$ if (cdef .eqs. "HAVE_FSEEKO") .or. (cdef .eqs. "_LARGE_FILES") .or. - + (cdef .eqs. "_LARGEFILE64_SOURCE") then - + call write_config f$string("#define _LARGEFILE 1") +$ else +$ write sys$output "Checking for ''cdef'... no" +$ if (comm_h) +$ then + call write_config f$fao("/* !AS */",line) +$ else +$ if f$type('cdef_val'_no) .nes. "" +$ then +$ if f$type('cdef_val'_no) .eqs. "INTEGER" - + then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_no) +$ if f$type('cdef_val'_no) .eqs. "STRING" - + then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_no) +$ else +$ call write_config f$fao("#undef !AS",cdef) +$ endif +$ endif +$ endif +$ return +$!------------------------------------------------------------------------------ +$! +$! Check for properties of C/C++ compiler with multiple result values +$! +$! Version history +$! 0.01 20040127 First version +$! 0.02 20050103 Reconcile changes from cc_prop up to version 0.05 +$CC_MPROP_CHECK: +$ cc_prop = true +$ i = 1 +$ idel = 1 +$ MT_LOOP: +$ if f$type(result_'i') .eqs. "STRING" +$ then +$ set message/nofac/noident/nosever/notext +$ on error then continue +$ cc 'tmpnam'_'i' +$ if .not. ($status) then cc_prop = false +$ on error then continue +$! The headers might lie about the capabilities of the RTL +$ link 'tmpnam'_'i',tmp.opt/opt +$ if .not. ($status) then cc_prop = false +$ set message/fac/ident/sever/text +$ on error then goto err_exit +$ delete/nolog 'tmpnam'_'i'.*;* +$ if (cc_prop) +$ then +$ write sys$output "Checking for ''cdef'... ", mdef_'i' +$ if f$type(mdef_'i') .eqs. "INTEGER" - + then call write_config f$fao("#define !AS !UL",cdef,mdef_'i') +$ if f$type('cdef_val'_yes) .eqs. "STRING" - + then call write_config f$fao("#define !AS !AS",cdef,mdef_'i') +$ goto msym_clean +$ else +$ i = i + 1 +$ goto mt_loop +$ endif +$ endif +$ write sys$output "Checking for ''cdef'... no" +$ call write_config f$fao("#undef !AS",cdef) +$ MSYM_CLEAN: +$ if (idel .le. msym_max) +$ then +$ delete/sym mdef_'idel' +$ idel = idel + 1 +$ goto msym_clean +$ endif +$ return +$!------------------------------------------------------------------------------ +$! +$! Write configuration to both permanent and temporary config file +$! +$! Version history +$! 0.01 20031029 First version to receive a number +$! +$WRITE_CONFIG: SUBROUTINE +$ write aconf 'p1' +$ open/append confh 'th' +$ write confh 'p1' +$ close confh +$ENDSUBROUTINE +$!------------------------------------------------------------------------------ +$! +$! Analyze the project map file and create the symbol vector for a shareable +$! image from it +$! +$! Version history +$! 0.01 20120128 First version +$! 0.02 20120226 Add pre-load logic +$! +$ MAP_2_SHOPT: Subroutine +$! +$ SAY := "WRITE_ SYS$OUTPUT" +$! +$ IF F$SEARCH("''P1'") .EQS. "" +$ THEN +$ SAY "MAP_2_SHOPT-E-NOSUCHFILE: Error, inputfile ''p1' not available" +$ goto exit_m2s +$ ENDIF +$ IF "''P2'" .EQS. "" +$ THEN +$ SAY "MAP_2_SHOPT: Error, no output file provided" +$ goto exit_m2s +$ ENDIF +$! +$ module1 = "deflate#deflateEnd#deflateInit_#deflateParams#deflateSetDictionary" +$ module2 = "gzclose#gzerror#gzgetc#gzgets#gzopen#gzprintf#gzputc#gzputs#gzread" +$ module3 = "gzseek#gztell#inflate#inflateEnd#inflateInit_#inflateSetDictionary" +$ module4 = "inflateSync#uncompress#zlibVersion#compress" +$ open/read map 'p1 +$ if axp .or. ia64 +$ then +$ open/write aopt a.opt +$ open/write bopt b.opt +$ write aopt " CASE_SENSITIVE=YES" +$ write bopt "SYMBOL_VECTOR= (-" +$ mod_sym_num = 1 +$ MOD_SYM_LOOP: +$ if f$type(module'mod_sym_num') .nes. "" +$ then +$ mod_in = 0 +$ MOD_SYM_IN: +$ shared_proc = f$element(mod_in, "#", module'mod_sym_num') +$ if shared_proc .nes. "#" +$ then +$ write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",- + f$edit(shared_proc,"upcase"),shared_proc) +$ write bopt f$fao("!AS=PROCEDURE,-",shared_proc) +$ mod_in = mod_in + 1 +$ goto mod_sym_in +$ endif +$ mod_sym_num = mod_sym_num + 1 +$ goto mod_sym_loop +$ endif +$MAP_LOOP: +$ read/end=map_end map line +$ if (f$locate("{",line).lt. f$length(line)) .or. - + (f$locate("global:", line) .lt. f$length(line)) +$ then +$ proc = true +$ goto map_loop +$ endif +$ if f$locate("}",line).lt. f$length(line) then proc = false +$ if f$locate("local:", line) .lt. f$length(line) then proc = false +$ if proc +$ then +$ shared_proc = f$edit(line,"collapse") +$ chop_semi = f$locate(";", shared_proc) +$ if chop_semi .lt. f$length(shared_proc) then - + shared_proc = f$extract(0, chop_semi, shared_proc) +$ write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",- + f$edit(shared_proc,"upcase"),shared_proc) +$ write bopt f$fao("!AS=PROCEDURE,-",shared_proc) +$ endif +$ goto map_loop +$MAP_END: +$ close/nolog aopt +$ close/nolog bopt +$ open/append libopt 'p2' +$ open/read aopt a.opt +$ open/read bopt b.opt +$ALOOP: +$ read/end=aloop_end aopt line +$ write libopt line +$ goto aloop +$ALOOP_END: +$ close/nolog aopt +$ sv = "" +$BLOOP: +$ read/end=bloop_end bopt svn +$ if (svn.nes."") +$ then +$ if (sv.nes."") then write libopt sv +$ sv = svn +$ endif +$ goto bloop +$BLOOP_END: +$ write libopt f$extract(0,f$length(sv)-2,sv), "-" +$ write libopt ")" +$ close/nolog bopt +$ delete/nolog/noconf a.opt;*,b.opt;* +$ else +$ if vax +$ then +$ open/append libopt 'p2' +$ mod_sym_num = 1 +$ VMOD_SYM_LOOP: +$ if f$type(module'mod_sym_num') .nes. "" +$ then +$ mod_in = 0 +$ VMOD_SYM_IN: +$ shared_proc = f$element(mod_in, "#", module'mod_sym_num') +$ if shared_proc .nes. "#" +$ then +$ write libopt f$fao("UNIVERSAL=!AS",- + f$edit(shared_proc,"upcase")) +$ mod_in = mod_in + 1 +$ goto vmod_sym_in +$ endif +$ mod_sym_num = mod_sym_num + 1 +$ goto vmod_sym_loop +$ endif +$VMAP_LOOP: +$ read/end=vmap_end map line +$ if (f$locate("{",line).lt. f$length(line)) .or. - + (f$locate("global:", line) .lt. f$length(line)) +$ then +$ proc = true +$ goto vmap_loop +$ endif +$ if f$locate("}",line).lt. f$length(line) then proc = false +$ if f$locate("local:", line) .lt. f$length(line) then proc = false +$ if proc +$ then +$ shared_proc = f$edit(line,"collapse") +$ chop_semi = f$locate(";", shared_proc) +$ if chop_semi .lt. f$length(shared_proc) then - + shared_proc = f$extract(0, chop_semi, shared_proc) +$ write libopt f$fao("UNIVERSAL=!AS",- + f$edit(shared_proc,"upcase")) +$ endif +$ goto vmap_loop +$VMAP_END: +$ else +$ write sys$output "Unknown Architecture (Not VAX, AXP, or IA64)" +$ write sys$output "No options file created" +$ endif +$ endif +$ EXIT_M2S: +$ close/nolog map +$ close/nolog libopt +$ endsubroutine diff --git a/xs/src/png/zlib/msdos/Makefile.bor b/xs/src/png/zlib/msdos/Makefile.bor new file mode 100644 index 0000000000..3d12a2c252 --- /dev/null +++ b/xs/src/png/zlib/msdos/Makefile.bor @@ -0,0 +1,115 @@ +# Makefile for zlib +# Borland C++ +# Last updated: 15-Mar-2003 + +# To use, do "make -fmakefile.bor" +# To compile in small model, set below: MODEL=s + +# WARNING: the small model is supported but only for small values of +# MAX_WBITS and MAX_MEM_LEVEL. For example: +# -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3 +# If you wish to reduce the memory requirements (default 256K for big +# objects plus a few K), you can add to the LOC macro below: +# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 +# See zconf.h for details about the memory requirements. + +# ------------ Turbo C++, Borland C++ ------------ + +# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) +# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added +# to the declaration of LOC here: +LOC = $(LOCAL_ZLIB) + +# type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. +CPU_TYP = 0 + +# memory model: one of s, m, c, l (small, medium, compact, large) +MODEL=l + +# replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version +CC=bcc +LD=bcc +AR=tlib + +# compiler flags +# replace "-O2" by "-O -G -a -d" for Turbo C++ 1.0 +CFLAGS=-O2 -Z -m$(MODEL) $(LOC) + +LDFLAGS=-m$(MODEL) -f- + + +# variables +ZLIB_LIB = zlib_$(MODEL).lib + +OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj +OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj +OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj +OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj + + +# targets +all: $(ZLIB_LIB) example.exe minigzip.exe + +.c.obj: + $(CC) -c $(CFLAGS) $*.c + +adler32.obj: adler32.c zlib.h zconf.h + +compress.obj: compress.c zlib.h zconf.h + +crc32.obj: crc32.c zlib.h zconf.h crc32.h + +deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + +gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h + +gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h + +gzread.obj: gzread.c zlib.h zconf.h gzguts.h + +gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h + +infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + +inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + +trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + +uncompr.obj: uncompr.c zlib.h zconf.h + +zutil.obj: zutil.c zutil.h zlib.h zconf.h + +example.obj: test/example.c zlib.h zconf.h + +minigzip.obj: test/minigzip.c zlib.h zconf.h + + +# the command line is cut to fit in the MS-DOS 128 byte limit: +$(ZLIB_LIB): $(OBJ1) $(OBJ2) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + +example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + +minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + +test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + +clean: + -del *.obj + -del *.lib + -del *.exe + -del zlib_*.bak + -del foo.gz diff --git a/xs/src/png/zlib/msdos/Makefile.dj2 b/xs/src/png/zlib/msdos/Makefile.dj2 new file mode 100644 index 0000000000..59d2037d69 --- /dev/null +++ b/xs/src/png/zlib/msdos/Makefile.dj2 @@ -0,0 +1,104 @@ +# Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. +# Copyright (C) 1995-1998 Jean-loup Gailly. +# For conditions of distribution and use, see copyright notice in zlib.h + +# To compile, or to compile and test, type: +# +# make -fmakefile.dj2; make test -fmakefile.dj2 +# +# To install libz.a, zconf.h and zlib.h in the djgpp directories, type: +# +# make install -fmakefile.dj2 +# +# after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as +# in the sample below if the pattern of the DJGPP distribution is to +# be followed. Remember that, while 'es around <=> are ignored in +# makefiles, they are *not* in batch files or in djgpp.env. +# - - - - - +# [make] +# INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include +# LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib +# BUTT=-m486 +# - - - - - +# Alternately, these variables may be defined below, overriding the values +# in djgpp.env, as +# INCLUDE_PATH=c:\usr\include +# LIBRARY_PATH=c:\usr\lib + +CC=gcc + +#CFLAGS=-MMD -O +#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 +#CFLAGS=-MMD -g -DZLIB_DEBUG +CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ + -Wstrict-prototypes -Wmissing-prototypes + +# If cp.exe is available, replace "copy /Y" with "cp -fp" . +CP=copy /Y +# If gnu install.exe is available, replace $(CP) with ginstall. +INSTALL=$(CP) +# The default value of RM is "rm -f." If "rm.exe" is found, comment out: +RM=del +LDLIBS=-L. -lz +LD=$(CC) -s -o +LDSHARED=$(CC) + +INCL=zlib.h zconf.h +LIBS=libz.a + +AR=ar rcs + +prefix=/usr/local +exec_prefix = $(prefix) + +OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ + uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o + +OBJA = +# to use the asm code: make OBJA=match.o + +TEST_OBJS = example.o minigzip.o + +all: example.exe minigzip.exe + +check: test +test: all + ./example + echo hello world | .\minigzip | .\minigzip -d + +%.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + +libz.a: $(OBJS) $(OBJA) + $(AR) $@ $(OBJS) $(OBJA) + +%.exe : %.o $(LIBS) + $(LD) $@ $< $(LDLIBS) + +# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . + +.PHONY : uninstall clean + +install: $(INCL) $(LIBS) + -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) + -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) + $(INSTALL) zlib.h $(INCLUDE_PATH) + $(INSTALL) zconf.h $(INCLUDE_PATH) + $(INSTALL) libz.a $(LIBRARY_PATH) + +uninstall: + $(RM) $(INCLUDE_PATH)\zlib.h + $(RM) $(INCLUDE_PATH)\zconf.h + $(RM) $(LIBRARY_PATH)\libz.a + +clean: + $(RM) *.d + $(RM) *.o + $(RM) *.exe + $(RM) libz.a + $(RM) foo.gz + +DEPS := $(wildcard *.d) +ifneq ($(DEPS),) +include $(DEPS) +endif diff --git a/xs/src/png/zlib/msdos/Makefile.emx b/xs/src/png/zlib/msdos/Makefile.emx new file mode 100644 index 0000000000..e30f67bed6 --- /dev/null +++ b/xs/src/png/zlib/msdos/Makefile.emx @@ -0,0 +1,69 @@ +# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. +# Copyright (C) 1995-1998 Jean-loup Gailly. +# For conditions of distribution and use, see copyright notice in zlib.h + +# To compile, or to compile and test, type: +# +# make -fmakefile.emx; make test -fmakefile.emx +# + +CC=gcc + +#CFLAGS=-MMD -O +#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 +#CFLAGS=-MMD -g -DZLIB_DEBUG +CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ + -Wstrict-prototypes -Wmissing-prototypes + +# If cp.exe is available, replace "copy /Y" with "cp -fp" . +CP=copy /Y +# If gnu install.exe is available, replace $(CP) with ginstall. +INSTALL=$(CP) +# The default value of RM is "rm -f." If "rm.exe" is found, comment out: +RM=del +LDLIBS=-L. -lzlib +LD=$(CC) -s -o +LDSHARED=$(CC) + +INCL=zlib.h zconf.h +LIBS=zlib.a + +AR=ar rcs + +prefix=/usr/local +exec_prefix = $(prefix) + +OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ + uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o + +TEST_OBJS = example.o minigzip.o + +all: example.exe minigzip.exe + +test: all + ./example + echo hello world | .\minigzip | .\minigzip -d + +%.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + +zlib.a: $(OBJS) + $(AR) $@ $(OBJS) + +%.exe : %.o $(LIBS) + $(LD) $@ $< $(LDLIBS) + + +.PHONY : clean + +clean: + $(RM) *.d + $(RM) *.o + $(RM) *.exe + $(RM) zlib.a + $(RM) foo.gz + +DEPS := $(wildcard *.d) +ifneq ($(DEPS),) +include $(DEPS) +endif diff --git a/xs/src/png/zlib/msdos/Makefile.msc b/xs/src/png/zlib/msdos/Makefile.msc new file mode 100644 index 0000000000..ae8378615e --- /dev/null +++ b/xs/src/png/zlib/msdos/Makefile.msc @@ -0,0 +1,112 @@ +# Makefile for zlib +# Microsoft C 5.1 or later +# Last updated: 19-Mar-2003 + +# To use, do "make makefile.msc" +# To compile in small model, set below: MODEL=S + +# If you wish to reduce the memory requirements (default 256K for big +# objects plus a few K), you can add to the LOC macro below: +# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 +# See zconf.h for details about the memory requirements. + +# ------------- Microsoft C 5.1 and later ------------- + +# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) +# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added +# to the declaration of LOC here: +LOC = $(LOCAL_ZLIB) + +# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. +CPU_TYP = 0 + +# Memory model: one of S, M, C, L (small, medium, compact, large) +MODEL=L + +CC=cl +CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) +#-Ox generates bad code with MSC 5.1 +LIB_CFLAGS=-Zl $(CFLAGS) + +LD=link +LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode +# "/farcall/packcode" are only useful for `large code' memory models +# but should be a "no-op" for small code models. + + +# variables +ZLIB_LIB = zlib_$(MODEL).lib + +OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj +OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj + + +# targets +all: $(ZLIB_LIB) example.exe minigzip.exe + +.c.obj: + $(CC) -c $(LIB_CFLAGS) $*.c + +adler32.obj: adler32.c zlib.h zconf.h + +compress.obj: compress.c zlib.h zconf.h + +crc32.obj: crc32.c zlib.h zconf.h crc32.h + +deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + +gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h + +gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h + +gzread.obj: gzread.c zlib.h zconf.h gzguts.h + +gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h + +infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + +inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + +trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + +uncompr.obj: uncompr.c zlib.h zconf.h + +zutil.obj: zutil.c zutil.h zlib.h zconf.h + +example.obj: test/example.c zlib.h zconf.h + $(CC) -c $(CFLAGS) $*.c + +minigzip.obj: test/minigzip.c zlib.h zconf.h + $(CC) -c $(CFLAGS) $*.c + + +# the command line is cut to fit in the MS-DOS 128 byte limit: +$(ZLIB_LIB): $(OBJ1) $(OBJ2) + if exist $(ZLIB_LIB) del $(ZLIB_LIB) + lib $(ZLIB_LIB) $(OBJ1); + lib $(ZLIB_LIB) $(OBJ2); + +example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); + +minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); + +test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + +clean: + -del *.obj + -del *.lib + -del *.exe + -del *.map + -del zlib_*.bak + -del foo.gz diff --git a/xs/src/png/zlib/msdos/Makefile.tc b/xs/src/png/zlib/msdos/Makefile.tc new file mode 100644 index 0000000000..5aec82a9d5 --- /dev/null +++ b/xs/src/png/zlib/msdos/Makefile.tc @@ -0,0 +1,100 @@ +# Makefile for zlib +# Turbo C 2.01, Turbo C++ 1.01 +# Last updated: 15-Mar-2003 + +# To use, do "make -fmakefile.tc" +# To compile in small model, set below: MODEL=s + +# WARNING: the small model is supported but only for small values of +# MAX_WBITS and MAX_MEM_LEVEL. For example: +# -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 +# If you wish to reduce the memory requirements (default 256K for big +# objects plus a few K), you can add to CFLAGS below: +# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 +# See zconf.h for details about the memory requirements. + +# ------------ Turbo C 2.01, Turbo C++ 1.01 ------------ +MODEL=l +CC=tcc +LD=tcc +AR=tlib +# CFLAGS=-O2 -G -Z -m$(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 +CFLAGS=-O2 -G -Z -m$(MODEL) +LDFLAGS=-m$(MODEL) -f- + + +# variables +ZLIB_LIB = zlib_$(MODEL).lib + +OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj +OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj +OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj +OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj + + +# targets +all: $(ZLIB_LIB) example.exe minigzip.exe + +.c.obj: + $(CC) -c $(CFLAGS) $*.c + +adler32.obj: adler32.c zlib.h zconf.h + +compress.obj: compress.c zlib.h zconf.h + +crc32.obj: crc32.c zlib.h zconf.h crc32.h + +deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + +gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h + +gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h + +gzread.obj: gzread.c zlib.h zconf.h gzguts.h + +gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h + +infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + +inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + +trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + +uncompr.obj: uncompr.c zlib.h zconf.h + +zutil.obj: zutil.c zutil.h zlib.h zconf.h + +example.obj: test/example.c zlib.h zconf.h + +minigzip.obj: test/minigzip.c zlib.h zconf.h + + +# the command line is cut to fit in the MS-DOS 128 byte limit: +$(ZLIB_LIB): $(OBJ1) $(OBJ2) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + +example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + +minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + +test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + +clean: + -del *.obj + -del *.lib + -del *.exe + -del zlib_*.bak + -del foo.gz diff --git a/xs/src/png/zlib/nintendods/Makefile b/xs/src/png/zlib/nintendods/Makefile new file mode 100644 index 0000000000..21337d01ab --- /dev/null +++ b/xs/src/png/zlib/nintendods/Makefile @@ -0,0 +1,126 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +include $(DEVKITARM)/ds_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#--------------------------------------------------------------------------------- +TARGET := $(shell basename $(CURDIR)) +BUILD := build +SOURCES := ../../ +DATA := data +INCLUDES := include + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb -mthumb-interwork + +CFLAGS := -Wall -O2\ + -march=armv5te -mtune=arm946e-s \ + -fomit-frame-pointer -ffast-math \ + $(ARCH) + +CFLAGS += $(INCLUDE) -DARM9 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := $(ARCH) -march=armv5te -mtune=arm946e-s +LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/lib/libz.a + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES := $(addsuffix .o,$(BINFILES)) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +.PHONY: $(BUILD) clean all + +#--------------------------------------------------------------------------------- +all: $(BUILD) + @[ -d $@ ] || mkdir -p include + @cp ../../*.h include + +lib: + @[ -d $@ ] || mkdir -p $@ + +$(BUILD): lib + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) lib + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT) : $(OFILES) + +#--------------------------------------------------------------------------------- +%.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/xs/src/png/zlib/nintendods/README b/xs/src/png/zlib/nintendods/README new file mode 100644 index 0000000000..ba7a37dbe8 --- /dev/null +++ b/xs/src/png/zlib/nintendods/README @@ -0,0 +1,5 @@ +This Makefile requires devkitARM (http://www.devkitpro.org/category/devkitarm/) and works inside "contrib/nds". It is based on a devkitARM template. + +Eduardo Costa +January 3, 2009 + diff --git a/xs/src/png/zlib/old/Makefile.emx b/xs/src/png/zlib/old/Makefile.emx new file mode 100644 index 0000000000..612b037915 --- /dev/null +++ b/xs/src/png/zlib/old/Makefile.emx @@ -0,0 +1,69 @@ +# Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. +# Copyright (C) 1995-1998 Jean-loup Gailly. +# For conditions of distribution and use, see copyright notice in zlib.h + +# To compile, or to compile and test, type: +# +# make -fmakefile.emx; make test -fmakefile.emx +# + +CC=gcc -Zwin32 + +#CFLAGS=-MMD -O +#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 +#CFLAGS=-MMD -g -DZLIB_DEBUG +CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ + -Wstrict-prototypes -Wmissing-prototypes + +# If cp.exe is available, replace "copy /Y" with "cp -fp" . +CP=copy /Y +# If gnu install.exe is available, replace $(CP) with ginstall. +INSTALL=$(CP) +# The default value of RM is "rm -f." If "rm.exe" is found, comment out: +RM=del +LDLIBS=-L. -lzlib +LD=$(CC) -s -o +LDSHARED=$(CC) + +INCL=zlib.h zconf.h +LIBS=zlib.a + +AR=ar rcs + +prefix=/usr/local +exec_prefix = $(prefix) + +OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ + gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o + +TEST_OBJS = example.o minigzip.o + +all: example.exe minigzip.exe + +test: all + ./example + echo hello world | .\minigzip | .\minigzip -d + +%.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + +zlib.a: $(OBJS) + $(AR) $@ $(OBJS) + +%.exe : %.o $(LIBS) + $(LD) $@ $< $(LDLIBS) + + +.PHONY : clean + +clean: + $(RM) *.d + $(RM) *.o + $(RM) *.exe + $(RM) zlib.a + $(RM) foo.gz + +DEPS := $(wildcard *.d) +ifneq ($(DEPS),) +include $(DEPS) +endif diff --git a/xs/src/png/zlib/old/Makefile.riscos b/xs/src/png/zlib/old/Makefile.riscos new file mode 100644 index 0000000000..57e29d3fba --- /dev/null +++ b/xs/src/png/zlib/old/Makefile.riscos @@ -0,0 +1,151 @@ +# Project: zlib_1_03 +# Patched for zlib 1.1.2 rw@shadow.org.uk 19980430 +# test works out-of-the-box, installs `somewhere' on demand + +# Toolflags: +CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah +C++flags = -c -depend !Depend -IC: -throwback +Linkflags = -aif -c++ -o $@ +ObjAsmflags = -throwback -NoCache -depend !Depend +CMHGflags = +LibFileflags = -c -l -o $@ +Squeezeflags = -o $@ + +# change the line below to where _you_ want the library installed. +libdest = lib:zlib + +# Final targets: +@.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \ + @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \ + @.o.uncompr @.o.zutil + LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \ + @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \ + @.o.trees @.o.uncompr @.o.zutil +test: @.minigzip @.example @.lib + @copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV + @echo running tests: hang on. + @/@.minigzip -f -9 libc + @/@.minigzip -d libc-gz + @/@.minigzip -f -1 libc + @/@.minigzip -d libc-gz + @/@.minigzip -h -9 libc + @/@.minigzip -d libc-gz + @/@.minigzip -h -1 libc + @/@.minigzip -d libc-gz + @/@.minigzip -9 libc + @/@.minigzip -d libc-gz + @/@.minigzip -1 libc + @/@.minigzip -d libc-gz + @diff @.lib @.libc + @echo that should have reported '@.lib and @.libc identical' if you have diff. + @/@.example @.fred @.fred + @echo that will have given lots of hello!'s. + +@.minigzip: @.o.minigzip @.lib C:o.Stubs + Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs +@.example: @.o.example @.lib C:o.Stubs + Link $(Linkflags) @.o.example @.lib C:o.Stubs + +install: @.lib + cdir $(libdest) + cdir $(libdest).h + @copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV + @copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV + @copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV + @echo okay, installed zlib in $(libdest) + +clean:; remove @.minigzip + remove @.example + remove @.libc + -wipe @.o.* F~r~cV + remove @.fred + +# User-editable dependencies: +.c.o: + cc $(ccflags) -o $@ $< + +# Static dependencies: + +# Dynamic dependencies: +o.example: c.example +o.example: h.zlib +o.example: h.zconf +o.minigzip: c.minigzip +o.minigzip: h.zlib +o.minigzip: h.zconf +o.adler32: c.adler32 +o.adler32: h.zlib +o.adler32: h.zconf +o.compress: c.compress +o.compress: h.zlib +o.compress: h.zconf +o.crc32: c.crc32 +o.crc32: h.zlib +o.crc32: h.zconf +o.deflate: c.deflate +o.deflate: h.deflate +o.deflate: h.zutil +o.deflate: h.zlib +o.deflate: h.zconf +o.gzio: c.gzio +o.gzio: h.zutil +o.gzio: h.zlib +o.gzio: h.zconf +o.infblock: c.infblock +o.infblock: h.zutil +o.infblock: h.zlib +o.infblock: h.zconf +o.infblock: h.infblock +o.infblock: h.inftrees +o.infblock: h.infcodes +o.infblock: h.infutil +o.infcodes: c.infcodes +o.infcodes: h.zutil +o.infcodes: h.zlib +o.infcodes: h.zconf +o.infcodes: h.inftrees +o.infcodes: h.infblock +o.infcodes: h.infcodes +o.infcodes: h.infutil +o.infcodes: h.inffast +o.inffast: c.inffast +o.inffast: h.zutil +o.inffast: h.zlib +o.inffast: h.zconf +o.inffast: h.inftrees +o.inffast: h.infblock +o.inffast: h.infcodes +o.inffast: h.infutil +o.inffast: h.inffast +o.inflate: c.inflate +o.inflate: h.zutil +o.inflate: h.zlib +o.inflate: h.zconf +o.inflate: h.infblock +o.inftrees: c.inftrees +o.inftrees: h.zutil +o.inftrees: h.zlib +o.inftrees: h.zconf +o.inftrees: h.inftrees +o.inftrees: h.inffixed +o.infutil: c.infutil +o.infutil: h.zutil +o.infutil: h.zlib +o.infutil: h.zconf +o.infutil: h.infblock +o.infutil: h.inftrees +o.infutil: h.infcodes +o.infutil: h.infutil +o.trees: c.trees +o.trees: h.deflate +o.trees: h.zutil +o.trees: h.zlib +o.trees: h.zconf +o.trees: h.trees +o.uncompr: c.uncompr +o.uncompr: h.zlib +o.uncompr: h.zconf +o.zutil: c.zutil +o.zutil: h.zutil +o.zutil: h.zlib +o.zutil: h.zconf diff --git a/xs/src/png/zlib/old/README b/xs/src/png/zlib/old/README new file mode 100644 index 0000000000..800bf07982 --- /dev/null +++ b/xs/src/png/zlib/old/README @@ -0,0 +1,3 @@ +This directory contains files that have not been updated for zlib 1.2.x + +(Volunteers are encouraged to help clean this up. Thanks.) diff --git a/xs/src/png/zlib/old/descrip.mms b/xs/src/png/zlib/old/descrip.mms new file mode 100644 index 0000000000..7066da5b55 --- /dev/null +++ b/xs/src/png/zlib/old/descrip.mms @@ -0,0 +1,48 @@ +# descrip.mms: MMS description file for building zlib on VMS +# written by Martin P.J. Zinser + +cc_defs = +c_deb = + +.ifdef __DECC__ +pref = /prefix=all +.endif + +OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\ + deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\ + inftrees.obj, infcodes.obj, infutil.obj, inffast.obj + +CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) + +all : example.exe minigzip.exe + @ write sys$output " Example applications available" +libz.olb : libz.olb($(OBJS)) + @ write sys$output " libz available" + +example.exe : example.obj libz.olb + link example,libz.olb/lib + +minigzip.exe : minigzip.obj libz.olb + link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib + +clean : + delete *.obj;*,libz.olb;* + + +# Other dependencies. +adler32.obj : zutil.h zlib.h zconf.h +compress.obj : zlib.h zconf.h +crc32.obj : zutil.h zlib.h zconf.h +deflate.obj : deflate.h zutil.h zlib.h zconf.h +example.obj : zlib.h zconf.h +gzio.obj : zutil.h zlib.h zconf.h +infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h +infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h +inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h +inflate.obj : zutil.h zlib.h zconf.h infblock.h +inftrees.obj : zutil.h zlib.h zconf.h inftrees.h +infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h +minigzip.obj : zlib.h zconf.h +trees.obj : deflate.h zutil.h zlib.h zconf.h +uncompr.obj : zlib.h zconf.h +zutil.obj : zutil.h zlib.h zconf.h diff --git a/xs/src/png/zlib/old/os2/Makefile.os2 b/xs/src/png/zlib/old/os2/Makefile.os2 new file mode 100644 index 0000000000..bb426c0d8e --- /dev/null +++ b/xs/src/png/zlib/old/os2/Makefile.os2 @@ -0,0 +1,136 @@ +# Makefile for zlib under OS/2 using GCC (PGCC) +# For conditions of distribution and use, see copyright notice in zlib.h + +# To compile and test, type: +# cp Makefile.os2 .. +# cd .. +# make -f Makefile.os2 test + +# This makefile will build a static library z.lib, a shared library +# z.dll and a import library zdll.lib. You can use either z.lib or +# zdll.lib by specifying either -lz or -lzdll on gcc's command line + +CC=gcc -Zomf -s + +CFLAGS=-O6 -Wall +#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 +#CFLAGS=-g -DZLIB_DEBUG +#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ +# -Wstrict-prototypes -Wmissing-prototypes + +#################### BUG WARNING: ##################### +## infcodes.c hits a bug in pgcc-1.0, so you have to use either +## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem) +## This bug is reportedly fixed in pgcc >1.0, but this was not tested +CFLAGS+=-fno-force-mem + +LDFLAGS=-s -L. -lzdll -Zcrtdll +LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll + +VER=1.1.0 +ZLIB=z.lib +SHAREDLIB=z.dll +SHAREDLIBIMP=zdll.lib +LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP) + +AR=emxomfar cr +IMPLIB=emximp +RANLIB=echo +TAR=tar +SHELL=bash + +prefix=/usr/local +exec_prefix = $(prefix) + +OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ + zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o + +TEST_OBJS = example.o minigzip.o + +DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ + algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ + nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \ + contrib/asm386/*.asm contrib/asm386/*.c \ + contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ + contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ + contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 + +all: example.exe minigzip.exe + +test: all + @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ + echo hello world | ./minigzip | ./minigzip -d || \ + echo ' *** minigzip test FAILED ***' ; \ + if ./example; then \ + echo ' *** zlib test OK ***'; \ + else \ + echo ' *** zlib test FAILED ***'; \ + fi + +$(ZLIB): $(OBJS) + $(AR) $@ $(OBJS) + -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 + +$(SHAREDLIB): $(OBJS) os2/z.def + $(LDSHARED) -o $@ $^ + +$(SHAREDLIBIMP): os2/z.def + $(IMPLIB) -o $@ $^ + +example.exe: example.o $(LIBS) + $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) + +minigzip.exe: minigzip.o $(LIBS) + $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) + +clean: + rm -f *.o *~ example minigzip libz.a libz.so* foo.gz + +distclean: clean + +zip: + mv Makefile Makefile~; cp -p Makefile.in Makefile + rm -f test.c ztest*.c + v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ + zip -ul9 zlib$$v $(DISTFILES) + mv Makefile~ Makefile + +dist: + mv Makefile Makefile~; cp -p Makefile.in Makefile + rm -f test.c ztest*.c + d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ + rm -f $$d.tar.gz; \ + if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ + files=""; \ + for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ + cd ..; \ + GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ + if test ! -d $$d; then rm -f $$d; fi + mv Makefile~ Makefile + +tags: + etags *.[ch] + +depend: + makedepend -- $(CFLAGS) -- *.[ch] + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +adler32.o: zlib.h zconf.h +compress.o: zlib.h zconf.h +crc32.o: zlib.h zconf.h +deflate.o: deflate.h zutil.h zlib.h zconf.h +example.o: zlib.h zconf.h +gzio.o: zutil.h zlib.h zconf.h +infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h +infcodes.o: zutil.h zlib.h zconf.h +infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h +inffast.o: zutil.h zlib.h zconf.h inftrees.h +inffast.o: infblock.h infcodes.h infutil.h inffast.h +inflate.o: zutil.h zlib.h zconf.h infblock.h +inftrees.o: zutil.h zlib.h zconf.h inftrees.h +infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h +minigzip.o: zlib.h zconf.h +trees.o: deflate.h zutil.h zlib.h zconf.h trees.h +uncompr.o: zlib.h zconf.h +zutil.o: zutil.h zlib.h zconf.h diff --git a/xs/src/png/zlib/old/os2/zlib.def b/xs/src/png/zlib/old/os2/zlib.def new file mode 100644 index 0000000000..4c753f1a3b --- /dev/null +++ b/xs/src/png/zlib/old/os2/zlib.def @@ -0,0 +1,51 @@ +; +; Slightly modified version of ../nt/zlib.dnt :-) +; + +LIBRARY Z +DESCRIPTION "Zlib compression library for OS/2" +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE + +EXPORTS + adler32 + compress + crc32 + deflate + deflateCopy + deflateEnd + deflateInit2_ + deflateInit_ + deflateParams + deflateReset + deflateSetDictionary + gzclose + gzdopen + gzerror + gzflush + gzopen + gzread + gzwrite + inflate + inflateEnd + inflateInit2_ + inflateInit_ + inflateReset + inflateSetDictionary + inflateSync + uncompress + zlibVersion + gzprintf + gzputc + gzgetc + gzseek + gzrewind + gztell + gzeof + gzsetparams + zError + inflateSyncPoint + get_crc_table + compress2 + gzputs + gzgets diff --git a/xs/src/png/zlib/old/visual-basic.txt b/xs/src/png/zlib/old/visual-basic.txt new file mode 100644 index 0000000000..57efe58124 --- /dev/null +++ b/xs/src/png/zlib/old/visual-basic.txt @@ -0,0 +1,160 @@ +See below some functions declarations for Visual Basic. + +Frequently Asked Question: + +Q: Each time I use the compress function I get the -5 error (not enough + room in the output buffer). + +A: Make sure that the length of the compressed buffer is passed by + reference ("as any"), not by value ("as long"). Also check that + before the call of compress this length is equal to the total size of + the compressed buffer and not zero. + + +From: "Jon Caruana" +Subject: Re: How to port zlib declares to vb? +Date: Mon, 28 Oct 1996 18:33:03 -0600 + +Got the answer! (I haven't had time to check this but it's what I got, and +looks correct): + +He has the following routines working: + compress + uncompress + gzopen + gzwrite + gzread + gzclose + +Declares follow: (Quoted from Carlos Rios , in Vb4 form) + +#If Win16 Then 'Use Win16 calls. +Declare Function compress Lib "ZLIB.DLL" (ByVal compr As + String, comprLen As Any, ByVal buf As String, ByVal buflen + As Long) As Integer +Declare Function uncompress Lib "ZLIB.DLL" (ByVal uncompr + As String, uncomprLen As Any, ByVal compr As String, ByVal + lcompr As Long) As Integer +Declare Function gzopen Lib "ZLIB.DLL" (ByVal filePath As + String, ByVal mode As String) As Long +Declare Function gzread Lib "ZLIB.DLL" (ByVal file As + Long, ByVal uncompr As String, ByVal uncomprLen As Integer) + As Integer +Declare Function gzwrite Lib "ZLIB.DLL" (ByVal file As + Long, ByVal uncompr As String, ByVal uncomprLen As Integer) + As Integer +Declare Function gzclose Lib "ZLIB.DLL" (ByVal file As + Long) As Integer +#Else +Declare Function compress Lib "ZLIB32.DLL" + (ByVal compr As String, comprLen As Any, ByVal buf As + String, ByVal buflen As Long) As Integer +Declare Function uncompress Lib "ZLIB32.DLL" + (ByVal uncompr As String, uncomprLen As Any, ByVal compr As + String, ByVal lcompr As Long) As Long +Declare Function gzopen Lib "ZLIB32.DLL" + (ByVal file As String, ByVal mode As String) As Long +Declare Function gzread Lib "ZLIB32.DLL" + (ByVal file As Long, ByVal uncompr As String, ByVal + uncomprLen As Long) As Long +Declare Function gzwrite Lib "ZLIB32.DLL" + (ByVal file As Long, ByVal uncompr As String, ByVal + uncomprLen As Long) As Long +Declare Function gzclose Lib "ZLIB32.DLL" + (ByVal file As Long) As Long +#End If + +-Jon Caruana +jon-net@usa.net +Microsoft Sitebuilder Network Level 1 Member - HTML Writer's Guild Member + + +Here is another example from Michael that he +says conforms to the VB guidelines, and that solves the problem of not +knowing the uncompressed size by storing it at the end of the file: + +'Calling the functions: +'bracket meaning: [optional] {Range of possible values} +'Call subCompressFile( [, , [level of compression {1..9}]]) +'Call subUncompressFile() + +Option Explicit +Private lngpvtPcnSml As Long 'Stores value for 'lngPercentSmaller' +Private Const SUCCESS As Long = 0 +Private Const strFilExt As String = ".cpr" +Private Declare Function lngfncCpr Lib "zlib.dll" Alias "compress2" (ByRef +dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long, +ByVal level As Integer) As Long +Private Declare Function lngfncUcp Lib "zlib.dll" Alias "uncompress" (ByRef +dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long) +As Long + +Public Sub subCompressFile(ByVal strargOriFilPth As String, Optional ByVal +strargCprFilPth As String, Optional ByVal intLvl As Integer = 9) + Dim strCprPth As String + Dim lngOriSiz As Long + Dim lngCprSiz As Long + Dim bytaryOri() As Byte + Dim bytaryCpr() As Byte + lngOriSiz = FileLen(strargOriFilPth) + ReDim bytaryOri(lngOriSiz - 1) + Open strargOriFilPth For Binary Access Read As #1 + Get #1, , bytaryOri() + Close #1 + strCprPth = IIf(strargCprFilPth = "", strargOriFilPth, strargCprFilPth) +'Select file path and name + strCprPth = strCprPth & IIf(Right(strCprPth, Len(strFilExt)) = +strFilExt, "", strFilExt) 'Add file extension if not exists + lngCprSiz = (lngOriSiz * 1.01) + 12 'Compression needs temporary a bit +more space then original file size + ReDim bytaryCpr(lngCprSiz - 1) + If lngfncCpr(bytaryCpr(0), lngCprSiz, bytaryOri(0), lngOriSiz, intLvl) = +SUCCESS Then + lngpvtPcnSml = (1# - (lngCprSiz / lngOriSiz)) * 100 + ReDim Preserve bytaryCpr(lngCprSiz - 1) + Open strCprPth For Binary Access Write As #1 + Put #1, , bytaryCpr() + Put #1, , lngOriSiz 'Add the the original size value to the end +(last 4 bytes) + Close #1 + Else + MsgBox "Compression error" + End If + Erase bytaryCpr + Erase bytaryOri +End Sub + +Public Sub subUncompressFile(ByVal strargFilPth As String) + Dim bytaryCpr() As Byte + Dim bytaryOri() As Byte + Dim lngOriSiz As Long + Dim lngCprSiz As Long + Dim strOriPth As String + lngCprSiz = FileLen(strargFilPth) + ReDim bytaryCpr(lngCprSiz - 1) + Open strargFilPth For Binary Access Read As #1 + Get #1, , bytaryCpr() + Close #1 + 'Read the original file size value: + lngOriSiz = bytaryCpr(lngCprSiz - 1) * (2 ^ 24) _ + + bytaryCpr(lngCprSiz - 2) * (2 ^ 16) _ + + bytaryCpr(lngCprSiz - 3) * (2 ^ 8) _ + + bytaryCpr(lngCprSiz - 4) + ReDim Preserve bytaryCpr(lngCprSiz - 5) 'Cut of the original size value + ReDim bytaryOri(lngOriSiz - 1) + If lngfncUcp(bytaryOri(0), lngOriSiz, bytaryCpr(0), lngCprSiz) = SUCCESS +Then + strOriPth = Left(strargFilPth, Len(strargFilPth) - Len(strFilExt)) + Open strOriPth For Binary Access Write As #1 + Put #1, , bytaryOri() + Close #1 + Else + MsgBox "Uncompression error" + End If + Erase bytaryCpr + Erase bytaryOri +End Sub +Public Property Get lngPercentSmaller() As Long + lngPercentSmaller = lngpvtPcnSml +End Property diff --git a/xs/src/png/zlib/os400/README400 b/xs/src/png/zlib/os400/README400 new file mode 100644 index 0000000000..4f98334f5a --- /dev/null +++ b/xs/src/png/zlib/os400/README400 @@ -0,0 +1,48 @@ + ZLIB version 1.2.11 for OS/400 installation instructions + +1) Download and unpack the zlib tarball to some IFS directory. + (i.e.: /path/to/the/zlib/ifs/source/directory) + + If the installed IFS command suppors gzip format, this is straightforward, +else you have to unpack first to some directory on a system supporting it, +then move the whole directory to the IFS via the network (via SMB or FTP). + +2) Edit the configuration parameters in the compilation script. + + EDTF STMF('/path/to/the/zlib/ifs/source/directory/os400/make.sh') + +Tune the parameters according to your needs if not matching the defaults. +Save the file and exit after edition. + +3) Enter qshell, then work in the zlib OS/400 specific directory. + + QSH + cd /path/to/the/zlib/ifs/source/directory/os400 + +4) Compile and install + + sh make.sh + +The script will: +- create the libraries, objects and IFS directories for the zlib environment, +- compile all modules, +- create a service program, +- create a static and a dynamic binding directory, +- install header files for C/C++ and for ILE/RPG, both for compilation in + DB2 and IFS environments. + +That's all. + + +Notes: For OS/400 ILE RPG programmers, a /copy member defining the ZLIB + API prototypes for ILE RPG can be found in ZLIB/H(ZLIB.INC). + In the ILE environment, the same definitions are available from + file zlib.inc located in the same IFS include directory as the + C/C++ header files. + Please read comments in this member for more information. + + Remember that most foreign textual data are ASCII coded: this + implementation does not handle conversion from/to ASCII, so + text data code conversions must be done explicitely. + + Mainly for the reason above, always open zipped files in binary mode. diff --git a/xs/src/png/zlib/os400/bndsrc b/xs/src/png/zlib/os400/bndsrc new file mode 100644 index 0000000000..5e6e0a2f0a --- /dev/null +++ b/xs/src/png/zlib/os400/bndsrc @@ -0,0 +1,119 @@ +STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB') + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.1.3 entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("adler32") + EXPORT SYMBOL("compress") + EXPORT SYMBOL("compress2") + EXPORT SYMBOL("crc32") + EXPORT SYMBOL("get_crc_table") + EXPORT SYMBOL("deflate") + EXPORT SYMBOL("deflateEnd") + EXPORT SYMBOL("deflateSetDictionary") + EXPORT SYMBOL("deflateCopy") + EXPORT SYMBOL("deflateReset") + EXPORT SYMBOL("deflateParams") + EXPORT SYMBOL("deflatePrime") + EXPORT SYMBOL("deflateInit_") + EXPORT SYMBOL("deflateInit2_") + EXPORT SYMBOL("gzopen") + EXPORT SYMBOL("gzdopen") + EXPORT SYMBOL("gzsetparams") + EXPORT SYMBOL("gzread") + EXPORT SYMBOL("gzwrite") + EXPORT SYMBOL("gzprintf") + EXPORT SYMBOL("gzputs") + EXPORT SYMBOL("gzgets") + EXPORT SYMBOL("gzputc") + EXPORT SYMBOL("gzgetc") + EXPORT SYMBOL("gzflush") + EXPORT SYMBOL("gzseek") + EXPORT SYMBOL("gzrewind") + EXPORT SYMBOL("gztell") + EXPORT SYMBOL("gzeof") + EXPORT SYMBOL("gzclose") + EXPORT SYMBOL("gzerror") + EXPORT SYMBOL("inflate") + EXPORT SYMBOL("inflateEnd") + EXPORT SYMBOL("inflateSetDictionary") + EXPORT SYMBOL("inflateSync") + EXPORT SYMBOL("inflateReset") + EXPORT SYMBOL("inflateInit_") + EXPORT SYMBOL("inflateInit2_") + EXPORT SYMBOL("inflateSyncPoint") + EXPORT SYMBOL("uncompress") + EXPORT SYMBOL("zlibVersion") + EXPORT SYMBOL("zError") + EXPORT SYMBOL("z_errmsg") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.1 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("compressBound") + EXPORT SYMBOL("deflateBound") + EXPORT SYMBOL("deflatePending") + EXPORT SYMBOL("gzungetc") + EXPORT SYMBOL("gzclearerr") + EXPORT SYMBOL("inflateBack") + EXPORT SYMBOL("inflateBackEnd") + EXPORT SYMBOL("inflateBackInit_") + EXPORT SYMBOL("inflateCopy") + EXPORT SYMBOL("zlibCompileFlags") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.4 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("adler32_combine") + EXPORT SYMBOL("adler32_combine64") + EXPORT SYMBOL("crc32_combine") + EXPORT SYMBOL("crc32_combine64") + EXPORT SYMBOL("deflateSetHeader") + EXPORT SYMBOL("deflateTune") + EXPORT SYMBOL("gzbuffer") + EXPORT SYMBOL("gzclose_r") + EXPORT SYMBOL("gzclose_w") + EXPORT SYMBOL("gzdirect") + EXPORT SYMBOL("gzoffset") + EXPORT SYMBOL("gzoffset64") + EXPORT SYMBOL("gzopen64") + EXPORT SYMBOL("gzseek64") + EXPORT SYMBOL("gztell64") + EXPORT SYMBOL("inflateGetHeader") + EXPORT SYMBOL("inflateMark") + EXPORT SYMBOL("inflatePrime") + EXPORT SYMBOL("inflateReset2") + EXPORT SYMBOL("inflateUndermine") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.6 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("deflateResetKeep") + EXPORT SYMBOL("gzgetc_") + EXPORT SYMBOL("inflateResetKeep") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.8 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("gzvprintf") + EXPORT SYMBOL("inflateGetDictionary") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.9 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("adler32_z") + EXPORT SYMBOL("crc32_z") + EXPORT SYMBOL("deflateGetDictionary") + EXPORT SYMBOL("gzfread") + EXPORT SYMBOL("gzfwrite") + EXPORT SYMBOL("inflateCodesUsed") + EXPORT SYMBOL("inflateValidate") + EXPORT SYMBOL("uncompress2") + +ENDPGMEXP diff --git a/xs/src/png/zlib/os400/make.sh b/xs/src/png/zlib/os400/make.sh new file mode 100644 index 0000000000..19eec117a6 --- /dev/null +++ b/xs/src/png/zlib/os400/make.sh @@ -0,0 +1,366 @@ +#!/bin/sh +# +# ZLIB compilation script for the OS/400. +# +# +# This is a shell script since make is not a standard component of OS/400. + + +################################################################################ +# +# Tunable configuration parameters. +# +################################################################################ + +TARGETLIB='ZLIB' # Target OS/400 program library +STATBNDDIR='ZLIB_A' # Static binding directory. +DYNBNDDIR='ZLIB' # Dynamic binding directory. +SRVPGM="ZLIB" # Service program. +IFSDIR='/zlib' # IFS support base directory. +TGTCCSID='500' # Target CCSID of objects +DEBUG='*NONE' # Debug level +OPTIMIZE='40' # Optimisation level +OUTPUT='*NONE' # Compilation output option. +TGTRLS='V6R1M0' # Target OS release + +export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM IFSDIR +export TGTCCSID DEBUG OPTIMIZE OUTPUT TGTRLS + + +################################################################################ +# +# OS/400 specific definitions. +# +################################################################################ + +LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB" + + +################################################################################ +# +# Procedures. +# +################################################################################ + +# action_needed dest [src] +# +# dest is an object to build +# if specified, src is an object on which dest depends. +# +# exit 0 (succeeds) if some action has to be taken, else 1. + +action_needed() + +{ + [ ! -e "${1}" ] && return 0 + [ "${2}" ] || return 1 + [ "${1}" -ot "${2}" ] && return 0 + return 1 +} + + +# make_module module_name source_name [additional_definitions] +# +# Compile source name into module if needed. +# As side effect, append the module name to variable MODULES. +# Set LINK to "YES" if the module has been compiled. + +make_module() + +{ + MODULES="${MODULES} ${1}" + MODIFSNAME="${LIBIFSNAME}/${1}.MODULE" + CSRC="`basename \"${2}\"`" + + if action_needed "${MODIFSNAME}" "${2}" + then : + elif [ ! "`sed -e \"//,/<\\\\/source>/!d\" \ + -e '/ tmphdrfile + + # Need to translate to target CCSID. + + CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')" + CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" + system "${CMD}" + # touch -r "${HFILE}" "${DEST}" + rm -f tmphdrfile + fi + + IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`" + + if action_needed "${IFSFILE}" "${DEST}" + then rm -f "${IFSFILE}" + ln -s "${DEST}" "${IFSFILE}" + fi +done + + +# Install the ILE/RPG header file. + + +HFILE="${SCRIPTDIR}/zlib.inc" +DEST="${SRCPF}/ZLIB.INC.MBR" + +if action_needed "${DEST}" "${HFILE}" +then CMD="CPY OBJ('${HFILE}') TOOBJ('${DEST}')" + CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" + system "${CMD}" + # touch -r "${HFILE}" "${DEST}" +fi + +IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`" + +if action_needed "${IFSFILE}" "${DEST}" +then rm -f "${IFSFILE}" + ln -s "${DEST}" "${IFSFILE}" +fi + + +# Create and compile the identification source file. + +echo '#pragma comment(user, "ZLIB version '"${VERSION}"'")' > os400.c +echo '#pragma comment(user, __DATE__)' >> os400.c +echo '#pragma comment(user, __TIME__)' >> os400.c +echo '#pragma comment(copyright, "Copyright (C) 1995-2017 Jean-Loup Gailly, Mark Adler. OS/400 version by P. Monnerat.")' >> os400.c +make_module OS400 os400.c +LINK= # No need to rebuild service program yet. +MODULES= + + +# Get source list. + +CSOURCES=`sed -e '/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Library + + Medium + + 2.0 + + + + zlib + zlib + alain.bonnefoy@icbt.com + Public + public + www.gzip.org/zlib + + + Jean-Loup Gailly,Mark Adler + www.gzip.org/zlib + + zlib@gzip.org + + + A massively spiffy yet delicately unobtrusive compression library. + zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system. + http://www.gzip.org/zlib + + + + + 1.2.11 + Medium + Stable + + + + + + + No License + + + + Software Development/Libraries and Extensions/C Libraries + zlib,compression + qnx6 + qnx6 + None + Developer + + + + + + + + + + + + + + Install + Post + No + Ignore + + No + Optional + + + + + + + + + + + + + InstallOver + zlib + + + + + + + + + + + + + InstallOver + zlib-dev + + + + + + + + + diff --git a/xs/src/png/zlib/treebuild.xml b/xs/src/png/zlib/treebuild.xml new file mode 100644 index 0000000000..fd75525f99 --- /dev/null +++ b/xs/src/png/zlib/treebuild.xml @@ -0,0 +1,116 @@ + + + + zip compression library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/png/zlib/trees.c b/xs/src/png/zlib/trees.c new file mode 100644 index 0000000000..50cf4b4571 --- /dev/null +++ b/xs/src/png/zlib/trees.c @@ -0,0 +1,1203 @@ +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1995-2017 Jean-loup Gailly + * detect_data_type() function provided freely by Cosmin Truta, 2006 + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in a compressed form which is itself + * a Huffman encoding of the lengths of all the code strings (in + * ascending order by source values). The actual code strings are + * reconstructed from the lengths in the inflate process, as described + * in the deflate specification. + * + * REFERENCES + * + * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". + * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + */ + +/* @(#) $Id$ */ + +/* #define GEN_TREES_H */ + +#include "deflate.h" + +#ifdef ZLIB_DEBUG +# include +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +local const int extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +local const uch bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +/* =========================================================================== + * Local data. These are initialized only once. + */ + +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) || !defined(STDC) +/* non ANSI compilers may not accept trees.h */ + +local ct_data static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +local ct_data static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +uch _dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +uch _length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +local int base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +local int base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + +struct static_tree_desc_s { + const ct_data *static_tree; /* static tree or NULL */ + const intf *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ +}; + +local const static_tree_desc static_l_desc = +{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; + +local const static_tree_desc static_d_desc = +{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; + +local const static_tree_desc static_bl_desc = +{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; + +/* =========================================================================== + * Local (static) routines in this file. + */ + +local void tr_static_init OF((void)); +local void init_block OF((deflate_state *s)); +local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); +local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); +local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); +local void build_tree OF((deflate_state *s, tree_desc *desc)); +local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local int build_bl_tree OF((deflate_state *s)); +local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, + int blcodes)); +local void compress_block OF((deflate_state *s, const ct_data *ltree, + const ct_data *dtree)); +local int detect_data_type OF((deflate_state *s)); +local unsigned bi_reverse OF((unsigned value, int length)); +local void bi_windup OF((deflate_state *s)); +local void bi_flush OF((deflate_state *s)); + +#ifdef GEN_TREES_H +local void gen_trees_header OF((void)); +#endif + +#ifndef ZLIB_DEBUG +# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) + /* Send a code of the given tree. c and tree must not have side effects */ + +#else /* !ZLIB_DEBUG */ +# define send_code(s, c, tree) \ + { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ + send_bits(s, tree[c].Code, tree[c].Len); } +#endif + +/* =========================================================================== + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +#ifdef ZLIB_DEBUG +local void send_bits OF((deflate_state *s, int value, int length)); + +local void send_bits(s, value, length) + deflate_state *s; + int value; /* value to send */ + int length; /* number of bits */ +{ + Tracevv((stderr," l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + s->bits_sent += (ulg)length; + + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (s->bi_valid > (int)Buf_size - length) { + s->bi_buf |= (ush)value << s->bi_valid; + put_short(s, s->bi_buf); + s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); + s->bi_valid += length - Buf_size; + } else { + s->bi_buf |= (ush)value << s->bi_valid; + s->bi_valid += length; + } +} +#else /* !ZLIB_DEBUG */ + +#define send_bits(s, value, length) \ +{ int len = length;\ + if (s->bi_valid > (int)Buf_size - len) {\ + int val = (int)value;\ + s->bi_buf |= (ush)val << s->bi_valid;\ + put_short(s, s->bi_buf);\ + s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ + s->bi_valid += len - Buf_size;\ + } else {\ + s->bi_buf |= (ush)(value) << s->bi_valid;\ + s->bi_valid += len;\ + }\ +} +#endif /* ZLIB_DEBUG */ + + +/* the arguments must not have side effects */ + +/* =========================================================================== + * Initialize the various 'constant' tables. + */ +local void tr_static_init() +{ +#if defined(GEN_TREES_H) || !defined(STDC) + static int static_init_done = 0; + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + if (static_init_done) return; + + /* For some embedded targets, global variables are not initialized: */ +#ifdef NO_INIT_GLOBAL_POINTERS + static_l_desc.static_tree = static_ltree; + static_l_desc.extra_bits = extra_lbits; + static_d_desc.static_tree = static_dtree; + static_d_desc.extra_bits = extra_dbits; + static_bl_desc.extra_bits = extra_blbits; +#endif + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1< dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + _dist_code[256 + dist++] = (uch)code; + } + } + Assert (dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse((unsigned)n, 5); + } + static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) || !defined(STDC) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef ZLIB_DEBUG +# include +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() +{ + FILE *header = fopen("trees.h", "w"); + int i; + + Assert (header != NULL, "Can't open trees.h"); + fprintf(header, + "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", _dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, + "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", _length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "local const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); + } + + fclose(header); +} +#endif /* GEN_TREES_H */ + +/* =========================================================================== + * Initialize the tree data structures for a new zlib stream. + */ +void ZLIB_INTERNAL _tr_init(s) + deflate_state *s; +{ + tr_static_init(); + + s->l_desc.dyn_tree = s->dyn_ltree; + s->l_desc.stat_desc = &static_l_desc; + + s->d_desc.dyn_tree = s->dyn_dtree; + s->d_desc.stat_desc = &static_d_desc; + + s->bl_desc.dyn_tree = s->bl_tree; + s->bl_desc.stat_desc = &static_bl_desc; + + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef ZLIB_DEBUG + s->compressed_len = 0L; + s->bits_sent = 0L; +#endif + + /* Initialize the first block of the first file: */ + init_block(s); +} + +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(s) + deflate_state *s; +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->last_lit = s->matches = 0; +} + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + + +/* =========================================================================== + * Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. + */ +#define pqremove(s, tree, top) \ +{\ + top = s->heap[SMALLEST]; \ + s->heap[SMALLEST] = s->heap[s->heap_len--]; \ + pqdownheap(s, tree, SMALLEST); \ +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +#define smaller(tree, n, m, depth) \ + (tree[n].Freq < tree[m].Freq || \ + (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +local void pqdownheap(s, tree, k) + deflate_state *s; + ct_data *tree; /* the tree to restore */ + int k; /* node to move down */ +{ + int v = s->heap[k]; + int j = k << 1; /* left son of k */ + while (j <= s->heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < s->heap_len && + smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { + j++; + } + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, s->heap[j], s->depth)) break; + + /* Exchange v with the smallest son */ + s->heap[k] = s->heap[j]; k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + s->heap[k] = v; +} + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +local void gen_bitlen(s, desc) + deflate_state *s; + tree_desc *desc; /* the tree descriptor */ +{ + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const intf *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ + + for (h = s->heap_max+1; h < HEAP_SIZE; h++) { + n = s->heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (ush)bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) continue; /* not a leaf node */ + + s->bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + s->opt_len += (ulg)f * (unsigned)(bits + xbits); + if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits); + } + if (overflow == 0) return; + + Tracev((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length-1; + while (s->bl_count[bits] == 0) bits--; + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s->bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = s->bl_count[bits]; + while (n != 0) { + m = s->heap[--h]; + if (m > max_code) continue; + if ((unsigned) tree[m].Len != (unsigned) bits) { + Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq; + tree[m].Len = (ush)bits; + } + n--; + } + } +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes (tree, max_code, bl_count) + ct_data *tree; /* the tree to decorate */ + int max_code; /* largest code with non zero frequency */ + ushf *bl_count; /* number of codes at each bit length */ +{ + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + unsigned code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + code = (code + bl_count[bits-1]) << 1; + next_code[bits] = (ush)code; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node; /* new node being created */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + s->heap_len = 0, s->heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + s->heap[++(s->heap_len)] = max_code = n; + s->depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (s->heap_len < 2) { + node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); + tree[node].Freq = 1; + s->depth[node] = 0; + s->opt_len--; if (stree) s->static_len -= stree[node].Len; + /* node is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + node = elems; /* next internal node of the tree */ + do { + pqremove(s, tree, n); /* n = node of least frequency */ + m = s->heap[SMALLEST]; /* m = node of next least frequency */ + + s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ + s->heap[--(s->heap_max)] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? + s->depth[n] : s->depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (ush)node; +#ifdef DUMP_BL_TREE + if (tree == s->bl_tree) { + fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + s->heap[SMALLEST] = node++; + pqdownheap(s, tree, SMALLEST); + + } while (s->heap_len >= 2); + + s->heap[--(s->heap_max)] = s->heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen(s, (tree_desc *)desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes ((ct_data *)tree, max_code, s->bl_count); +} + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. + */ +local void scan_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (ush)0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + s->bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) s->bl_tree[curlen].Freq++; + s->bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + s->bl_tree[REPZ_3_10].Freq++; + } else { + s->bl_tree[REPZ_11_138].Freq++; + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +local void send_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { send_code(s, curlen, s->bl_tree); } while (--count != 0); + + } else if (curlen != 0) { + if (curlen != prevlen) { + send_code(s, curlen, s->bl_tree); count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); + + } else if (count <= 10) { + send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); + + } else { + send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +local int build_bl_tree(s) + deflate_state *s; +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); + scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(s, (tree_desc *)(&(s->bl_desc))); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { + if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; + } + /* Update opt_len to include the bit length tree and counts */ + s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", + s->opt_len, s->static_len)); + + return max_blindex; +} + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +local void send_all_trees(s, lcodes, dcodes, blcodes) + deflate_state *s; + int lcodes, dcodes, blcodes; /* number of codes for each tree */ +{ + int rank; /* index in bl_order */ + + Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); +} + +/* =========================================================================== + * Send a stored block + */ +void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) + deflate_state *s; + charf *buf; /* input block */ + ulg stored_len; /* length of input block */ + int last; /* one if this is the last block for a file */ +{ + send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ + bi_windup(s); /* align on byte boundary */ + put_short(s, (ush)stored_len); + put_short(s, (ush)~stored_len); + zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); + s->pending += stored_len; +#ifdef ZLIB_DEBUG + s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; + s->compressed_len += (stored_len + 4) << 3; + s->bits_sent += 2*16; + s->bits_sent += stored_len<<3; +#endif +} + +/* =========================================================================== + * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) + */ +void ZLIB_INTERNAL _tr_flush_bits(s) + deflate_state *s; +{ + bi_flush(s); +} + +/* =========================================================================== + * Send one empty static block to give enough lookahead for inflate. + * This takes 10 bits, of which 7 may remain in the bit buffer. + */ +void ZLIB_INTERNAL _tr_align(s) + deflate_state *s; +{ + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef ZLIB_DEBUG + s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif + bi_flush(s); +} + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and write out the encoded block. + */ +void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) + deflate_state *s; + charf *buf; /* input block, or NULL if too old */ + ulg stored_len; /* length of input block */ + int last; /* one if this is the last block for a file */ +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex = 0; /* index of last bit length code of non zero freq */ + + /* Build the Huffman trees unless a stored block is forced */ + if (s->level > 0) { + + /* Check if the file is binary or text */ + if (s->strm->data_type == Z_UNKNOWN) + s->strm->data_type = detect_data_type(s); + + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); + + /* Determine the best encoding. Compute the block lengths in bytes. */ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; + + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + + } else { + Assert(buf != (char*)0, "lost buf"); + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + +#ifdef FORCE_STORED + if (buf != (char*)0) { /* force stored block */ +#else + if (stored_len+4 <= opt_lenb && buf != (char*)0) { + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + _tr_stored_block(s, buf, stored_len, last); + +#ifdef FORCE_STATIC + } else if (static_lenb >= 0) { /* force static trees */ +#else + } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { +#endif + send_bits(s, (STATIC_TREES<<1)+last, 3); + compress_block(s, (const ct_data *)static_ltree, + (const ct_data *)static_dtree); +#ifdef ZLIB_DEBUG + s->compressed_len += 3 + s->static_len; +#endif + } else { + send_bits(s, (DYN_TREES<<1)+last, 3); + send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, + max_blindex+1); + compress_block(s, (const ct_data *)s->dyn_ltree, + (const ct_data *)s->dyn_dtree); +#ifdef ZLIB_DEBUG + s->compressed_len += 3 + s->opt_len; +#endif + } + Assert (s->compressed_len == s->bits_sent, "bad compressed size"); + /* The above check is made mod 2^32, for files larger than 512 MB + * and uLong implemented on 32 bits. + */ + init_block(s); + + if (last) { + bi_windup(s); +#ifdef ZLIB_DEBUG + s->compressed_len += 7; /* align on byte boundary */ +#endif + } + Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, + s->compressed_len-7*last)); +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int ZLIB_INTERNAL _tr_tally (s, dist, lc) + deflate_state *s; + unsigned dist; /* distance of matched string */ + unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + s->d_buf[s->last_lit] = (ush)dist; + s->l_buf[s->last_lit++] = (uch)lc; + if (dist == 0) { + /* lc is the unmatched char */ + s->dyn_ltree[lc].Freq++; + } else { + s->matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush)dist < (ush)MAX_DIST(s) && + (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); + + s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_dtree[d_code(dist)].Freq++; + } + +#ifdef TRUNCATE_BLOCK + /* Try to guess if it is profitable to stop the current block here */ + if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { + /* Compute an upper bound for the compressed length */ + ulg out_length = (ulg)s->last_lit*8L; + ulg in_length = (ulg)((long)s->strstart - s->block_start); + int dcode; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += (ulg)s->dyn_dtree[dcode].Freq * + (5L+extra_dbits[dcode]); + } + out_length >>= 3; + Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", + s->last_lit, in_length, out_length, + 100L - out_length*100L/in_length)); + if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; + } +#endif + return (s->last_lit == s->lit_bufsize-1); + /* We avoid equality with lit_bufsize because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(s, ltree, dtree) + deflate_state *s; + const ct_data *ltree; /* literal tree */ + const ct_data *dtree; /* distance tree */ +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->last_lit != 0) do { + dist = s->d_buf[lx]; + lc = s->l_buf[lx++]; + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= (unsigned)base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ + Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, + "pendingBuf overflow"); + + } while (lx < s->last_lit); + + send_code(s, END_BLOCK, ltree); +} + +/* =========================================================================== + * Check if the data type is TEXT or BINARY, using the following algorithm: + * - TEXT if the two conditions below are satisfied: + * a) There are no non-portable control characters belonging to the + * "black list" (0..6, 14..25, 28..31). + * b) There is at least one printable character belonging to the + * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). + * - BINARY otherwise. + * - The following partially-portable control characters form a + * "gray list" that is ignored in this detection algorithm: + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). + * IN assertion: the fields Freq of dyn_ltree are set. + */ +local int detect_data_type(s) + deflate_state *s; +{ + /* black_mask is the bit mask of black-listed bytes + * set bits 0..6, 14..25, and 28..31 + * 0xf3ffc07f = binary 11110011111111111100000001111111 + */ + unsigned long black_mask = 0xf3ffc07fUL; + int n; + + /* Check for non-textual ("black-listed") bytes. */ + for (n = 0; n <= 31; n++, black_mask >>= 1) + if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0)) + return Z_BINARY; + + /* Check for textual ("white-listed") bytes. */ + if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 + || s->dyn_ltree[13].Freq != 0) + return Z_TEXT; + for (n = 32; n < LITERALS; n++) + if (s->dyn_ltree[n].Freq != 0) + return Z_TEXT; + + /* There are no "black-listed" or "white-listed" bytes: + * this stream either is empty or has tolerated ("gray-listed") bytes only. + */ + return Z_BINARY; +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +local unsigned bi_reverse(code, len) + unsigned code; /* the value to invert */ + int len; /* its bit length */ +{ + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(s) + deflate_state *s; +{ + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(s) + deflate_state *s; +{ + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef ZLIB_DEBUG + s->bits_sent = (s->bits_sent+7) & ~7; +#endif +} diff --git a/xs/src/png/zlib/trees.h b/xs/src/png/zlib/trees.h new file mode 100644 index 0000000000..d35639d82a --- /dev/null +++ b/xs/src/png/zlib/trees.h @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/xs/src/png/zlib/uncompr.c b/xs/src/png/zlib/uncompr.c new file mode 100644 index 0000000000..f03a1a865e --- /dev/null +++ b/xs/src/png/zlib/uncompr.c @@ -0,0 +1,93 @@ +/* uncompr.c -- decompress a memory buffer + * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +/* =========================================================================== + Decompresses the source buffer into the destination buffer. *sourceLen is + the byte length of the source buffer. Upon entry, *destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, + *destLen is the size of the decompressed data and *sourceLen is the number + of source bytes consumed. Upon return, source + *sourceLen points to the + first unused input byte. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, or + Z_DATA_ERROR if the input data was corrupted, including if the input data is + an incomplete zlib stream. +*/ +int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong *sourceLen; +{ + z_stream stream; + int err; + const uInt max = (uInt)-1; + uLong len, left; + Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ + + len = *sourceLen; + if (*destLen) { + left = *destLen; + *destLen = 0; + } + else { + left = 1; + dest = buf; + } + + stream.next_in = (z_const Bytef *)source; + stream.avail_in = 0; + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; + + err = inflateInit(&stream); + if (err != Z_OK) return err; + + stream.next_out = dest; + stream.avail_out = 0; + + do { + if (stream.avail_out == 0) { + stream.avail_out = left > (uLong)max ? max : (uInt)left; + left -= stream.avail_out; + } + if (stream.avail_in == 0) { + stream.avail_in = len > (uLong)max ? max : (uInt)len; + len -= stream.avail_in; + } + err = inflate(&stream, Z_NO_FLUSH); + } while (err == Z_OK); + + *sourceLen -= len + stream.avail_in; + if (dest != buf) + *destLen = stream.total_out; + else if (stream.total_out && err == Z_BUF_ERROR) + left = 1; + + inflateEnd(&stream); + return err == Z_STREAM_END ? Z_OK : + err == Z_NEED_DICT ? Z_DATA_ERROR : + err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : + err; +} + +int ZEXPORT uncompress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return uncompress2(dest, destLen, source, &sourceLen); +} diff --git a/xs/src/png/zlib/watcom/watcom_f.mak b/xs/src/png/zlib/watcom/watcom_f.mak new file mode 100644 index 0000000000..37f4d74c19 --- /dev/null +++ b/xs/src/png/zlib/watcom/watcom_f.mak @@ -0,0 +1,43 @@ +# Makefile for zlib +# OpenWatcom flat model +# Last updated: 28-Dec-2005 + +# To use, do "wmake -f watcom_f.mak" + +C_SOURCE = adler32.c compress.c crc32.c deflate.c & + gzclose.c gzlib.c gzread.c gzwrite.c & + infback.c inffast.c inflate.c inftrees.c & + trees.c uncompr.c zutil.c + +OBJS = adler32.obj compress.obj crc32.obj deflate.obj & + gzclose.obj gzlib.obj gzread.obj gzwrite.obj & + infback.obj inffast.obj inflate.obj inftrees.obj & + trees.obj uncompr.obj zutil.obj + +CC = wcc386 +LINKER = wcl386 +CFLAGS = -zq -mf -3r -fp3 -s -bt=dos -oilrtfm -fr=nul -wx +ZLIB_LIB = zlib_f.lib + +.C.OBJ: + $(CC) $(CFLAGS) $[@ + +all: $(ZLIB_LIB) example.exe minigzip.exe + +$(ZLIB_LIB): $(OBJS) + wlib -b -c $(ZLIB_LIB) -+adler32.obj -+compress.obj -+crc32.obj + wlib -b -c $(ZLIB_LIB) -+gzclose.obj -+gzlib.obj -+gzread.obj -+gzwrite.obj + wlib -b -c $(ZLIB_LIB) -+deflate.obj -+infback.obj + wlib -b -c $(ZLIB_LIB) -+inffast.obj -+inflate.obj -+inftrees.obj + wlib -b -c $(ZLIB_LIB) -+trees.obj -+uncompr.obj -+zutil.obj + +example.exe: $(ZLIB_LIB) example.obj + $(LINKER) -ldos32a -fe=example.exe example.obj $(ZLIB_LIB) + +minigzip.exe: $(ZLIB_LIB) minigzip.obj + $(LINKER) -ldos32a -fe=minigzip.exe minigzip.obj $(ZLIB_LIB) + +clean: .SYMBOLIC + del *.obj + del $(ZLIB_LIB) + @echo Cleaning done diff --git a/xs/src/png/zlib/watcom/watcom_l.mak b/xs/src/png/zlib/watcom/watcom_l.mak new file mode 100644 index 0000000000..193eed7b31 --- /dev/null +++ b/xs/src/png/zlib/watcom/watcom_l.mak @@ -0,0 +1,43 @@ +# Makefile for zlib +# OpenWatcom large model +# Last updated: 28-Dec-2005 + +# To use, do "wmake -f watcom_l.mak" + +C_SOURCE = adler32.c compress.c crc32.c deflate.c & + gzclose.c gzlib.c gzread.c gzwrite.c & + infback.c inffast.c inflate.c inftrees.c & + trees.c uncompr.c zutil.c + +OBJS = adler32.obj compress.obj crc32.obj deflate.obj & + gzclose.obj gzlib.obj gzread.obj gzwrite.obj & + infback.obj inffast.obj inflate.obj inftrees.obj & + trees.obj uncompr.obj zutil.obj + +CC = wcc +LINKER = wcl +CFLAGS = -zq -ml -s -bt=dos -oilrtfm -fr=nul -wx +ZLIB_LIB = zlib_l.lib + +.C.OBJ: + $(CC) $(CFLAGS) $[@ + +all: $(ZLIB_LIB) example.exe minigzip.exe + +$(ZLIB_LIB): $(OBJS) + wlib -b -c $(ZLIB_LIB) -+adler32.obj -+compress.obj -+crc32.obj + wlib -b -c $(ZLIB_LIB) -+gzclose.obj -+gzlib.obj -+gzread.obj -+gzwrite.obj + wlib -b -c $(ZLIB_LIB) -+deflate.obj -+infback.obj + wlib -b -c $(ZLIB_LIB) -+inffast.obj -+inflate.obj -+inftrees.obj + wlib -b -c $(ZLIB_LIB) -+trees.obj -+uncompr.obj -+zutil.obj + +example.exe: $(ZLIB_LIB) example.obj + $(LINKER) -fe=example.exe example.obj $(ZLIB_LIB) + +minigzip.exe: $(ZLIB_LIB) minigzip.obj + $(LINKER) -fe=minigzip.exe minigzip.obj $(ZLIB_LIB) + +clean: .SYMBOLIC + del *.obj + del $(ZLIB_LIB) + @echo Cleaning done diff --git a/xs/src/png/zlib/win32/DLL_FAQ.txt b/xs/src/png/zlib/win32/DLL_FAQ.txt new file mode 100644 index 0000000000..12c009018c --- /dev/null +++ b/xs/src/png/zlib/win32/DLL_FAQ.txt @@ -0,0 +1,397 @@ + + Frequently Asked Questions about ZLIB1.DLL + + +This document describes the design, the rationale, and the usage +of the official DLL build of zlib, named ZLIB1.DLL. If you have +general questions about zlib, you should see the file "FAQ" found +in the zlib distribution, or at the following location: + http://www.gzip.org/zlib/zlib_faq.html + + + 1. What is ZLIB1.DLL, and how can I get it? + + - ZLIB1.DLL is the official build of zlib as a DLL. + (Please remark the character '1' in the name.) + + Pointers to a precompiled ZLIB1.DLL can be found in the zlib + web site at: + http://www.zlib.net/ + + Applications that link to ZLIB1.DLL can rely on the following + specification: + + * The exported symbols are exclusively defined in the source + files "zlib.h" and "zlib.def", found in an official zlib + source distribution. + * The symbols are exported by name, not by ordinal. + * The exported names are undecorated. + * The calling convention of functions is "C" (CDECL). + * The ZLIB1.DLL binary is linked to MSVCRT.DLL. + + The archive in which ZLIB1.DLL is bundled contains compiled + test programs that must run with a valid build of ZLIB1.DLL. + It is recommended to download the prebuilt DLL from the zlib + web site, instead of building it yourself, to avoid potential + incompatibilities that could be introduced by your compiler + and build settings. If you do build the DLL yourself, please + make sure that it complies with all the above requirements, + and it runs with the precompiled test programs, bundled with + the original ZLIB1.DLL distribution. + + If, for any reason, you need to build an incompatible DLL, + please use a different file name. + + + 2. Why did you change the name of the DLL to ZLIB1.DLL? + What happened to the old ZLIB.DLL? + + - The old ZLIB.DLL, built from zlib-1.1.4 or earlier, required + compilation settings that were incompatible to those used by + a static build. The DLL settings were supposed to be enabled + by defining the macro ZLIB_DLL, before including "zlib.h". + Incorrect handling of this macro was silently accepted at + build time, resulting in two major problems: + + * ZLIB_DLL was missing from the old makefile. When building + the DLL, not all people added it to the build options. In + consequence, incompatible incarnations of ZLIB.DLL started + to circulate around the net. + + * When switching from using the static library to using the + DLL, applications had to define the ZLIB_DLL macro and + to recompile all the sources that contained calls to zlib + functions. Failure to do so resulted in creating binaries + that were unable to run with the official ZLIB.DLL build. + + The only possible solution that we could foresee was to make + a binary-incompatible change in the DLL interface, in order to + remove the dependency on the ZLIB_DLL macro, and to release + the new DLL under a different name. + + We chose the name ZLIB1.DLL, where '1' indicates the major + zlib version number. We hope that we will not have to break + the binary compatibility again, at least not as long as the + zlib-1.x series will last. + + There is still a ZLIB_DLL macro, that can trigger a more + efficient build and use of the DLL, but compatibility no + longer dependents on it. + + + 3. Can I build ZLIB.DLL from the new zlib sources, and replace + an old ZLIB.DLL, that was built from zlib-1.1.4 or earlier? + + - In principle, you can do it by assigning calling convention + keywords to the macros ZEXPORT and ZEXPORTVA. In practice, + it depends on what you mean by "an old ZLIB.DLL", because the + old DLL exists in several mutually-incompatible versions. + You have to find out first what kind of calling convention is + being used in your particular ZLIB.DLL build, and to use the + same one in the new build. If you don't know what this is all + about, you might be better off if you would just leave the old + DLL intact. + + + 4. Can I compile my application using the new zlib interface, and + link it to an old ZLIB.DLL, that was built from zlib-1.1.4 or + earlier? + + - The official answer is "no"; the real answer depends again on + what kind of ZLIB.DLL you have. Even if you are lucky, this + course of action is unreliable. + + If you rebuild your application and you intend to use a newer + version of zlib (post- 1.1.4), it is strongly recommended to + link it to the new ZLIB1.DLL. + + + 5. Why are the zlib symbols exported by name, and not by ordinal? + + - Although exporting symbols by ordinal is a little faster, it + is risky. Any single glitch in the maintenance or use of the + DEF file that contains the ordinals can result in incompatible + builds and frustrating crashes. Simply put, the benefits of + exporting symbols by ordinal do not justify the risks. + + Technically, it should be possible to maintain ordinals in + the DEF file, and still export the symbols by name. Ordinals + exist in every DLL, and even if the dynamic linking performed + at the DLL startup is searching for names, ordinals serve as + hints, for a faster name lookup. However, if the DEF file + contains ordinals, the Microsoft linker automatically builds + an implib that will cause the executables linked to it to use + those ordinals, and not the names. It is interesting to + notice that the GNU linker for Win32 does not suffer from this + problem. + + It is possible to avoid the DEF file if the exported symbols + are accompanied by a "__declspec(dllexport)" attribute in the + source files. You can do this in zlib by predefining the + ZLIB_DLL macro. + + + 6. I see that the ZLIB1.DLL functions use the "C" (CDECL) calling + convention. Why not use the STDCALL convention? + STDCALL is the standard convention in Win32, and I need it in + my Visual Basic project! + + (For readability, we use CDECL to refer to the convention + triggered by the "__cdecl" keyword, STDCALL to refer to + the convention triggered by "__stdcall", and FASTCALL to + refer to the convention triggered by "__fastcall".) + + - Most of the native Windows API functions (without varargs) use + indeed the WINAPI convention (which translates to STDCALL in + Win32), but the standard C functions use CDECL. If a user + application is intrinsically tied to the Windows API (e.g. + it calls native Windows API functions such as CreateFile()), + sometimes it makes sense to decorate its own functions with + WINAPI. But if ANSI C or POSIX portability is a goal (e.g. + it calls standard C functions such as fopen()), it is not a + sound decision to request the inclusion of , or to + use non-ANSI constructs, for the sole purpose to make the user + functions STDCALL-able. + + The functionality offered by zlib is not in the category of + "Windows functionality", but is more like "C functionality". + + Technically, STDCALL is not bad; in fact, it is slightly + faster than CDECL, and it works with variable-argument + functions, just like CDECL. It is unfortunate that, in spite + of using STDCALL in the Windows API, it is not the default + convention used by the C compilers that run under Windows. + The roots of the problem reside deep inside the unsafety of + the K&R-style function prototypes, where the argument types + are not specified; but that is another story for another day. + + The remaining fact is that CDECL is the default convention. + Even if an explicit convention is hard-coded into the function + prototypes inside C headers, problems may appear. The + necessity to expose the convention in users' callbacks is one + of these problems. + + The calling convention issues are also important when using + zlib in other programming languages. Some of them, like Ada + (GNAT) and Fortran (GNU G77), have C bindings implemented + initially on Unix, and relying on the C calling convention. + On the other hand, the pre- .NET versions of Microsoft Visual + Basic require STDCALL, while Borland Delphi prefers, although + it does not require, FASTCALL. + + In fairness to all possible uses of zlib outside the C + programming language, we choose the default "C" convention. + Anyone interested in different bindings or conventions is + encouraged to maintain specialized projects. The "contrib/" + directory from the zlib distribution already holds a couple + of foreign bindings, such as Ada, C++, and Delphi. + + + 7. I need a DLL for my Visual Basic project. What can I do? + + - Define the ZLIB_WINAPI macro before including "zlib.h", when + building both the DLL and the user application (except that + you don't need to define anything when using the DLL in Visual + Basic). The ZLIB_WINAPI macro will switch on the WINAPI + (STDCALL) convention. The name of this DLL must be different + than the official ZLIB1.DLL. + + Gilles Vollant has contributed a build named ZLIBWAPI.DLL, + with the ZLIB_WINAPI macro turned on, and with the minizip + functionality built in. For more information, please read + the notes inside "contrib/vstudio/readme.txt", found in the + zlib distribution. + + + 8. I need to use zlib in my Microsoft .NET project. What can I + do? + + - Henrik Ravn has contributed a .NET wrapper around zlib. Look + into contrib/dotzlib/, inside the zlib distribution. + + + 9. If my application uses ZLIB1.DLL, should I link it to + MSVCRT.DLL? Why? + + - It is not required, but it is recommended to link your + application to MSVCRT.DLL, if it uses ZLIB1.DLL. + + The executables (.EXE, .DLL, etc.) that are involved in the + same process and are using the C run-time library (i.e. they + are calling standard C functions), must link to the same + library. There are several libraries in the Win32 system: + CRTDLL.DLL, MSVCRT.DLL, the static C libraries, etc. + Since ZLIB1.DLL is linked to MSVCRT.DLL, the executables that + depend on it should also be linked to MSVCRT.DLL. + + +10. Why are you saying that ZLIB1.DLL and my application should + be linked to the same C run-time (CRT) library? I linked my + application and my DLLs to different C libraries (e.g. my + application to a static library, and my DLLs to MSVCRT.DLL), + and everything works fine. + + - If a user library invokes only pure Win32 API (accessible via + and the related headers), its DLL build will work + in any context. But if this library invokes standard C API, + things get more complicated. + + There is a single Win32 library in a Win32 system. Every + function in this library resides in a single DLL module, that + is safe to call from anywhere. On the other hand, there are + multiple versions of the C library, and each of them has its + own separate internal state. Standalone executables and user + DLLs that call standard C functions must link to a C run-time + (CRT) library, be it static or shared (DLL). Intermixing + occurs when an executable (not necessarily standalone) and a + DLL are linked to different CRTs, and both are running in the + same process. + + Intermixing multiple CRTs is possible, as long as their + internal states are kept intact. The Microsoft Knowledge Base + articles KB94248 "HOWTO: Use the C Run-Time" and KB140584 + "HOWTO: Link with the Correct C Run-Time (CRT) Library" + mention the potential problems raised by intermixing. + + If intermixing works for you, it's because your application + and DLLs are avoiding the corruption of each of the CRTs' + internal states, maybe by careful design, or maybe by fortune. + + Also note that linking ZLIB1.DLL to non-Microsoft CRTs, such + as those provided by Borland, raises similar problems. + + +11. Why are you linking ZLIB1.DLL to MSVCRT.DLL? + + - MSVCRT.DLL exists on every Windows 95 with a new service pack + installed, or with Microsoft Internet Explorer 4 or later, and + on all other Windows 4.x or later (Windows 98, Windows NT 4, + or later). It is freely distributable; if not present in the + system, it can be downloaded from Microsoft or from other + software provider for free. + + The fact that MSVCRT.DLL does not exist on a virgin Windows 95 + is not so problematic. Windows 95 is scarcely found nowadays, + Microsoft ended its support a long time ago, and many recent + applications from various vendors, including Microsoft, do not + even run on it. Furthermore, no serious user should run + Windows 95 without a proper update installed. + + +12. Why are you not linking ZLIB1.DLL to + <> ? + + - We considered and abandoned the following alternatives: + + * Linking ZLIB1.DLL to a static C library (LIBC.LIB, or + LIBCMT.LIB) is not a good option. People are using the DLL + mainly to save disk space. If you are linking your program + to a static C library, you may as well consider linking zlib + in statically, too. + + * Linking ZLIB1.DLL to CRTDLL.DLL looks appealing, because + CRTDLL.DLL is present on every Win32 installation. + Unfortunately, it has a series of problems: it does not + work properly with Microsoft's C++ libraries, it does not + provide support for 64-bit file offsets, (and so on...), + and Microsoft discontinued its support a long time ago. + + * Linking ZLIB1.DLL to MSVCR70.DLL or MSVCR71.DLL, supplied + with the Microsoft .NET platform, and Visual C++ 7.0/7.1, + raises problems related to the status of ZLIB1.DLL as a + system component. According to the Microsoft Knowledge Base + article KB326922 "INFO: Redistribution of the Shared C + Runtime Component in Visual C++ .NET", MSVCR70.DLL and + MSVCR71.DLL are not supposed to function as system DLLs, + because they may clash with MSVCRT.DLL. Instead, the + application's installer is supposed to put these DLLs + (if needed) in the application's private directory. + If ZLIB1.DLL depends on a non-system runtime, it cannot + function as a redistributable system component. + + * Linking ZLIB1.DLL to non-Microsoft runtimes, such as + Borland's, or Cygwin's, raises problems related to the + reliable presence of these runtimes on Win32 systems. + It's easier to let the DLL build of zlib up to the people + who distribute these runtimes, and who may proceed as + explained in the answer to Question 14. + + +13. If ZLIB1.DLL cannot be linked to MSVCR70.DLL or MSVCR71.DLL, + how can I build/use ZLIB1.DLL in Microsoft Visual C++ 7.0 + (Visual Studio .NET) or newer? + + - Due to the problems explained in the Microsoft Knowledge Base + article KB326922 (see the previous answer), the C runtime that + comes with the VC7 environment is no longer considered a + system component. That is, it should not be assumed that this + runtime exists, or may be installed in a system directory. + Since ZLIB1.DLL is supposed to be a system component, it may + not depend on a non-system component. + + In order to link ZLIB1.DLL and your application to MSVCRT.DLL + in VC7, you need the library of Visual C++ 6.0 or older. If + you don't have this library at hand, it's probably best not to + use ZLIB1.DLL. + + We are hoping that, in the future, Microsoft will provide a + way to build applications linked to a proper system runtime, + from the Visual C++ environment. Until then, you have a + couple of alternatives, such as linking zlib in statically. + If your application requires dynamic linking, you may proceed + as explained in the answer to Question 14. + + +14. I need to link my own DLL build to a CRT different than + MSVCRT.DLL. What can I do? + + - Feel free to rebuild the DLL from the zlib sources, and link + it the way you want. You should, however, clearly state that + your build is unofficial. You should give it a different file + name, and/or install it in a private directory that can be + accessed by your application only, and is not visible to the + others (i.e. it's neither in the PATH, nor in the SYSTEM or + SYSTEM32 directories). Otherwise, your build may clash with + applications that link to the official build. + + For example, in Cygwin, zlib is linked to the Cygwin runtime + CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL. + + +15. May I include additional pieces of code that I find useful, + link them in ZLIB1.DLL, and export them? + + - No. A legitimate build of ZLIB1.DLL must not include code + that does not originate from the official zlib source code. + But you can make your own private DLL build, under a different + file name, as suggested in the previous answer. + + For example, zlib is a part of the VCL library, distributed + with Borland Delphi and C++ Builder. The DLL build of VCL + is a redistributable file, named VCLxx.DLL. + + +16. May I remove some functionality out of ZLIB1.DLL, by enabling + macros like NO_GZCOMPRESS or NO_GZIP at compile time? + + - No. A legitimate build of ZLIB1.DLL must provide the complete + zlib functionality, as implemented in the official zlib source + code. But you can make your own private DLL build, under a + different file name, as suggested in the previous answer. + + +17. I made my own ZLIB1.DLL build. Can I test it for compliance? + + - We prefer that you download the official DLL from the zlib + web site. If you need something peculiar from this DLL, you + can send your suggestion to the zlib mailing list. + + However, in case you do rebuild the DLL yourself, you can run + it with the test programs found in the DLL distribution. + Running these test programs is not a guarantee of compliance, + but a failure can imply a detected problem. + +** + +This document is written and maintained by +Cosmin Truta diff --git a/xs/src/png/zlib/win32/Makefile.bor b/xs/src/png/zlib/win32/Makefile.bor new file mode 100644 index 0000000000..d152bbb7ff --- /dev/null +++ b/xs/src/png/zlib/win32/Makefile.bor @@ -0,0 +1,110 @@ +# Makefile for zlib +# Borland C++ for Win32 +# +# Usage: +# make -f win32/Makefile.bor +# make -f win32/Makefile.bor LOCAL_ZLIB=-DASMV OBJA=match.obj OBJPA=+match.obj + +# ------------ Borland C++ ------------ + +# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) +# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or +# added to the declaration of LOC here: +LOC = $(LOCAL_ZLIB) + +CC = bcc32 +AS = bcc32 +LD = bcc32 +AR = tlib +CFLAGS = -a -d -k- -O2 $(LOC) +ASFLAGS = $(LOC) +LDFLAGS = $(LOC) + + +# variables +ZLIB_LIB = zlib.lib + +OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj +OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj +#OBJA = +OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj +OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj +#OBJPA= + + +# targets +all: $(ZLIB_LIB) example.exe minigzip.exe + +.c.obj: + $(CC) -c $(CFLAGS) $< + +.asm.obj: + $(AS) -c $(ASFLAGS) $< + +adler32.obj: adler32.c zlib.h zconf.h + +compress.obj: compress.c zlib.h zconf.h + +crc32.obj: crc32.c zlib.h zconf.h crc32.h + +deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + +gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h + +gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h + +gzread.obj: gzread.c zlib.h zconf.h gzguts.h + +gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h + +infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + +inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + +inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + +trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + +uncompr.obj: uncompr.c zlib.h zconf.h + +zutil.obj: zutil.c zutil.h zlib.h zconf.h + +example.obj: test/example.c zlib.h zconf.h + +minigzip.obj: test/minigzip.c zlib.h zconf.h + + +# For the sake of the old Borland make, +# the command line is cut to fit in the MS-DOS 128 byte limit: +$(ZLIB_LIB): $(OBJ1) $(OBJ2) $(OBJA) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + $(AR) $(ZLIB_LIB) $(OBJPA) + + +# testing +test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + +example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + +minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + + +# cleanup +clean: + -del $(ZLIB_LIB) + -del *.obj + -del *.exe + -del *.tds + -del zlib.bak + -del foo.gz diff --git a/xs/src/png/zlib/win32/Makefile.gcc b/xs/src/png/zlib/win32/Makefile.gcc new file mode 100644 index 0000000000..305be50afe --- /dev/null +++ b/xs/src/png/zlib/win32/Makefile.gcc @@ -0,0 +1,182 @@ +# Makefile for zlib, derived from Makefile.dj2. +# Modified for mingw32 by C. Spieler, 6/16/98. +# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. +# Last updated: Mar 2012. +# Tested under Cygwin and MinGW. + +# Copyright (C) 1995-2003 Jean-loup Gailly. +# For conditions of distribution and use, see copyright notice in zlib.h + +# To compile, or to compile and test, type from the top level zlib directory: +# +# make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc +# +# To use the asm code, type: +# cp contrib/asm?86/match.S ./match.S +# make LOC=-DASMV OBJA=match.o -fwin32/Makefile.gcc +# +# To install libz.a, zconf.h and zlib.h in the system directories, type: +# +# make install -fwin32/Makefile.gcc +# +# BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set. +# +# To install the shared lib, append SHARED_MODE=1 to the make command : +# +# make install -fwin32/Makefile.gcc SHARED_MODE=1 + +# Note: +# If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), +# the DLL name should be changed from "zlib1.dll". + +STATICLIB = libz.a +SHAREDLIB = zlib1.dll +IMPLIB = libz.dll.a + +# +# Set to 1 if shared object needs to be installed +# +SHARED_MODE=0 + +#LOC = -DASMV +#LOC = -DZLIB_DEBUG -g + +PREFIX = +CC = $(PREFIX)gcc +CFLAGS = $(LOC) -O3 -Wall + +AS = $(CC) +ASFLAGS = $(LOC) -Wall + +LD = $(CC) +LDFLAGS = $(LOC) + +AR = $(PREFIX)ar +ARFLAGS = rcs + +RC = $(PREFIX)windres +RCFLAGS = --define GCC_WINDRES + +STRIP = $(PREFIX)strip + +CP = cp -fp +# If GNU install is available, replace $(CP) with install. +INSTALL = $(CP) +RM = rm -f + +prefix ?= /usr/local +exec_prefix = $(prefix) + +OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ + gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o +OBJA = + +all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe + +test: example.exe minigzip.exe + ./example + echo hello world | ./minigzip | ./minigzip -d + +testdll: example_d.exe minigzip_d.exe + ./example_d + echo hello world | ./minigzip_d | ./minigzip_d -d + +.c.o: + $(CC) $(CFLAGS) -c -o $@ $< + +.S.o: + $(AS) $(ASFLAGS) -c -o $@ $< + +$(STATICLIB): $(OBJS) $(OBJA) + $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) + +$(IMPLIB): $(SHAREDLIB) + +$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o + $(CC) -shared -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \ + -o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o + $(STRIP) $@ + +example.exe: example.o $(STATICLIB) + $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) + $(STRIP) $@ + +minigzip.exe: minigzip.o $(STATICLIB) + $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) + $(STRIP) $@ + +example_d.exe: example.o $(IMPLIB) + $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) + $(STRIP) $@ + +minigzip_d.exe: minigzip.o $(IMPLIB) + $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) + $(STRIP) $@ + +example.o: test/example.c zlib.h zconf.h + $(CC) $(CFLAGS) -I. -c -o $@ test/example.c + +minigzip.o: test/minigzip.c zlib.h zconf.h + $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c + +zlibrc.o: win32/zlib1.rc + $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc + +.PHONY: install uninstall clean + +install: zlib.h zconf.h $(STATICLIB) $(IMPLIB) + @if test -z "$(DESTDIR)$(INCLUDE_PATH)" -o -z "$(DESTDIR)$(LIBRARY_PATH)" -o -z "$(DESTDIR)$(BINARY_PATH)"; then \ + echo INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH must be specified; \ + exit 1; \ + fi + -@mkdir -p '$(DESTDIR)$(INCLUDE_PATH)' + -@mkdir -p '$(DESTDIR)$(LIBRARY_PATH)' '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig + -if [ "$(SHARED_MODE)" = "1" ]; then \ + mkdir -p '$(DESTDIR)$(BINARY_PATH)'; \ + $(INSTALL) $(SHAREDLIB) '$(DESTDIR)$(BINARY_PATH)'; \ + $(INSTALL) $(IMPLIB) '$(DESTDIR)$(LIBRARY_PATH)'; \ + fi + -$(INSTALL) zlib.h '$(DESTDIR)$(INCLUDE_PATH)' + -$(INSTALL) zconf.h '$(DESTDIR)$(INCLUDE_PATH)' + -$(INSTALL) $(STATICLIB) '$(DESTDIR)$(LIBRARY_PATH)' + sed \ + -e 's|@prefix@|${prefix}|g' \ + -e 's|@exec_prefix@|${exec_prefix}|g' \ + -e 's|@libdir@|$(LIBRARY_PATH)|g' \ + -e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \ + -e 's|@includedir@|$(INCLUDE_PATH)|g' \ + -e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \ + zlib.pc.in > '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig/zlib.pc + +uninstall: + -if [ "$(SHARED_MODE)" = "1" ]; then \ + $(RM) '$(DESTDIR)$(BINARY_PATH)'/$(SHAREDLIB); \ + $(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(IMPLIB); \ + fi + -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zlib.h + -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zconf.h + -$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(STATICLIB) + +clean: + -$(RM) $(STATICLIB) + -$(RM) $(SHAREDLIB) + -$(RM) $(IMPLIB) + -$(RM) *.o + -$(RM) *.exe + -$(RM) foo.gz + +adler32.o: zlib.h zconf.h +compress.o: zlib.h zconf.h +crc32.o: crc32.h zlib.h zconf.h +deflate.o: deflate.h zutil.h zlib.h zconf.h +gzclose.o: zlib.h zconf.h gzguts.h +gzlib.o: zlib.h zconf.h gzguts.h +gzread.o: zlib.h zconf.h gzguts.h +gzwrite.o: zlib.h zconf.h gzguts.h +inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h +inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h +infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h +inftrees.o: zutil.h zlib.h zconf.h inftrees.h +trees.o: deflate.h zutil.h zlib.h zconf.h trees.h +uncompr.o: zlib.h zconf.h +zutil.o: zutil.h zlib.h zconf.h diff --git a/xs/src/png/zlib/win32/Makefile.msc b/xs/src/png/zlib/win32/Makefile.msc new file mode 100644 index 0000000000..6831882de4 --- /dev/null +++ b/xs/src/png/zlib/win32/Makefile.msc @@ -0,0 +1,163 @@ +# Makefile for zlib using Microsoft (Visual) C +# zlib is copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler +# +# Usage: +# nmake -f win32/Makefile.msc (standard build) +# nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build) +# nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" \ +# OBJA="inffas32.obj match686.obj" (use ASM code, x86) +# nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." \ +# OBJA="inffasx64.obj gvmat64.obj inffas8664.obj" (use ASM code, x64) + +# The toplevel directory of the source tree. +# +TOP = . + +# optional build flags +LOC = + +# variables +STATICLIB = zlib.lib +SHAREDLIB = zlib1.dll +IMPLIB = zdll.lib + +CC = cl +AS = ml +LD = link +AR = lib +RC = rc +CFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) +WFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE +ASFLAGS = -coff -Zi $(LOC) +LDFLAGS = -nologo -debug -incremental:no -opt:ref +ARFLAGS = -nologo +RCFLAGS = /dWIN32 /r + +OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \ + gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj +OBJA = + + +# targets +all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ + example.exe minigzip.exe example_d.exe minigzip_d.exe + +$(STATICLIB): $(OBJS) $(OBJA) + $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA) + +$(IMPLIB): $(SHAREDLIB) + +$(SHAREDLIB): $(TOP)/win32/zlib.def $(OBJS) $(OBJA) zlib1.res + $(LD) $(LDFLAGS) -def:$(TOP)/win32/zlib.def -dll -implib:$(IMPLIB) \ + -out:$@ -base:0x5A4C0000 $(OBJS) $(OBJA) zlib1.res + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;2 + +example.exe: example.obj $(STATICLIB) + $(LD) $(LDFLAGS) example.obj $(STATICLIB) + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;1 + +minigzip.exe: minigzip.obj $(STATICLIB) + $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;1 + +example_d.exe: example.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;1 + +minigzip_d.exe: minigzip.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;1 + +{$(TOP)}.c.obj: + $(CC) -c $(WFLAGS) $(CFLAGS) $< + +{$(TOP)/test}.c.obj: + $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< + +{$(TOP)/contrib/masmx64}.c.obj: + $(CC) -c $(WFLAGS) $(CFLAGS) $< + +{$(TOP)/contrib/masmx64}.asm.obj: + $(AS) -c $(ASFLAGS) $< + +{$(TOP)/contrib/masmx86}.asm.obj: + $(AS) -c $(ASFLAGS) $< + +adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h + +compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h + +crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h + +deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h + +gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h + +gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h + +gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h + +gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h + +infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ + $(TOP)/inffast.h $(TOP)/inffixed.h + +inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ + $(TOP)/inffast.h + +inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ + $(TOP)/inffast.h $(TOP)/inffixed.h + +inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h + +trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h + +uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h + +zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h + +gvmat64.obj: $(TOP)/contrib\masmx64\gvmat64.asm + +inffasx64.obj: $(TOP)/contrib\masmx64\inffasx64.asm + +inffas8664.obj: $(TOP)/contrib\masmx64\inffas8664.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h \ + $(TOP)/inftrees.h $(TOP)/inflate.h $(TOP)/inffast.h + +inffas32.obj: $(TOP)/contrib\masmx86\inffas32.asm + +match686.obj: $(TOP)/contrib\masmx86\match686.asm + +example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h + +minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h + +zlib1.res: $(TOP)/win32/zlib1.rc + $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc + +# testing +test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + +testdll: example_d.exe minigzip_d.exe + example_d + echo hello world | minigzip_d | minigzip_d -d + + +# cleanup +clean: + -del $(STATICLIB) + -del $(SHAREDLIB) + -del $(IMPLIB) + -del *.obj + -del *.res + -del *.exp + -del *.exe + -del *.pdb + -del *.manifest + -del foo.gz diff --git a/xs/src/png/zlib/win32/README-WIN32.txt b/xs/src/png/zlib/win32/README-WIN32.txt new file mode 100644 index 0000000000..df7ab7f4b3 --- /dev/null +++ b/xs/src/png/zlib/win32/README-WIN32.txt @@ -0,0 +1,103 @@ +ZLIB DATA COMPRESSION LIBRARY + +zlib 1.2.11 is a general purpose data compression library. All the code is +thread safe. The data format used by the zlib library is described by RFCs +(Request for Comments) 1950 to 1952 in the files +http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) +and rfc1952.txt (gzip format). + +All functions of the compression library are documented in the file zlib.h +(volunteer to write man pages welcome, contact zlib@gzip.org). Two compiled +examples are distributed in this package, example and minigzip. The example_d +and minigzip_d flavors validate that the zlib1.dll file is working correctly. + +Questions about zlib should be sent to . The zlib home page +is http://zlib.net/ . Before reporting a problem, please check this site to +verify that you have the latest version of zlib; otherwise get the latest +version and check whether the problem still exists or not. + +PLEASE read DLL_FAQ.txt, and the the zlib FAQ http://zlib.net/zlib_faq.html +before asking for help. + + +Manifest: + +The package zlib-1.2.11-win32-x86.zip will contain the following files: + + README-WIN32.txt This document + ChangeLog Changes since previous zlib packages + DLL_FAQ.txt Frequently asked questions about zlib1.dll + zlib.3.pdf Documentation of this library in Adobe Acrobat format + + example.exe A statically-bound example (using zlib.lib, not the dll) + example.pdb Symbolic information for debugging example.exe + + example_d.exe A zlib1.dll bound example (using zdll.lib) + example_d.pdb Symbolic information for debugging example_d.exe + + minigzip.exe A statically-bound test program (using zlib.lib, not the dll) + minigzip.pdb Symbolic information for debugging minigzip.exe + + minigzip_d.exe A zlib1.dll bound test program (using zdll.lib) + minigzip_d.pdb Symbolic information for debugging minigzip_d.exe + + zlib.h Install these files into the compilers' INCLUDE path to + zconf.h compile programs which use zlib.lib or zdll.lib + + zdll.lib Install these files into the compilers' LIB path if linking + zdll.exp a compiled program to the zlib1.dll binary + + zlib.lib Install these files into the compilers' LIB path to link zlib + zlib.pdb into compiled programs, without zlib1.dll runtime dependency + (zlib.pdb provides debugging info to the compile time linker) + + zlib1.dll Install this binary shared library into the system PATH, or + the program's runtime directory (where the .exe resides) + zlib1.pdb Install in the same directory as zlib1.dll, in order to debug + an application crash using WinDbg or similar tools. + +All .pdb files above are entirely optional, but are very useful to a developer +attempting to diagnose program misbehavior or a crash. Many additional +important files for developers can be found in the zlib127.zip source package +available from http://zlib.net/ - review that package's README file for details. + + +Acknowledgments: + +The deflate format used by zlib was defined by Phil Katz. The deflate and +zlib specifications were written by L. Peter Deutsch. Thanks to all the +people who reported problems and suggested various improvements in zlib; they +are too numerous to cite here. + + +Copyright notice: + + (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* receiving +lengthy legal documents to sign. The sources are provided for free but without +warranty of any kind. The library has been entirely written by Jean-loup +Gailly and Mark Adler; it does not include third-party code. + +If you redistribute modified sources, we would appreciate that you include in +the file ChangeLog history information documenting your changes. Please read +the FAQ for more information on the distribution of modified source versions. diff --git a/xs/src/png/zlib/win32/VisualC.txt b/xs/src/png/zlib/win32/VisualC.txt new file mode 100644 index 0000000000..1005b21941 --- /dev/null +++ b/xs/src/png/zlib/win32/VisualC.txt @@ -0,0 +1,3 @@ + +To build zlib using the Microsoft Visual C++ environment, +use the appropriate project from the contrib/vstudio/ directory. diff --git a/xs/src/png/zlib/win32/zlib.def b/xs/src/png/zlib/win32/zlib.def new file mode 100644 index 0000000000..a2188b0006 --- /dev/null +++ b/xs/src/png/zlib/win32/zlib.def @@ -0,0 +1,94 @@ +; zlib data compression library +EXPORTS +; basic functions + zlibVersion + deflate + deflateEnd + inflate + inflateEnd +; advanced functions + deflateSetDictionary + deflateGetDictionary + deflateCopy + deflateReset + deflateParams + deflateTune + deflateBound + deflatePending + deflatePrime + deflateSetHeader + inflateSetDictionary + inflateGetDictionary + inflateSync + inflateCopy + inflateReset + inflateReset2 + inflatePrime + inflateMark + inflateGetHeader + inflateBack + inflateBackEnd + zlibCompileFlags +; utility functions + compress + compress2 + compressBound + uncompress + uncompress2 + gzopen + gzdopen + gzbuffer + gzsetparams + gzread + gzfread + gzwrite + gzfwrite + gzprintf + gzvprintf + gzputs + gzgets + gzputc + gzgetc + gzungetc + gzflush + gzseek + gzrewind + gztell + gzoffset + gzeof + gzdirect + gzclose + gzclose_r + gzclose_w + gzerror + gzclearerr +; large file functions + gzopen64 + gzseek64 + gztell64 + gzoffset64 + adler32_combine64 + crc32_combine64 +; checksum functions + adler32 + adler32_z + crc32 + crc32_z + adler32_combine + crc32_combine +; various hacks, don't look :) + deflateInit_ + deflateInit2_ + inflateInit_ + inflateInit2_ + inflateBackInit_ + gzgetc_ + zError + inflateSyncPoint + get_crc_table + inflateUndermine + inflateValidate + inflateCodesUsed + inflateResetKeep + deflateResetKeep + gzopen_w diff --git a/xs/src/png/zlib/win32/zlib1.rc b/xs/src/png/zlib/win32/zlib1.rc new file mode 100644 index 0000000000..234e641c32 --- /dev/null +++ b/xs/src/png/zlib/win32/zlib1.rc @@ -0,0 +1,40 @@ +#include +#include "../zlib.h" + +#ifdef GCC_WINDRES +VS_VERSION_INFO VERSIONINFO +#else +VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE +#endif + FILEVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 + PRODUCTVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS 1 +#else + FILEFLAGS 0 +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + BEGIN + VALUE "FileDescription", "zlib data compression library\0" + VALUE "FileVersion", ZLIB_VERSION "\0" + VALUE "InternalName", "zlib1.dll\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + VALUE "OriginalFilename", "zlib1.dll\0" + VALUE "ProductName", "zlib\0" + VALUE "ProductVersion", ZLIB_VERSION "\0" + VALUE "Comments", "For more information visit http://www.zlib.net/\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/xs/src/png/zlib/zconf.h.cmakein b/xs/src/png/zlib/zconf.h.cmakein new file mode 100644 index 0000000000..a7f24cce60 --- /dev/null +++ b/xs/src/png/zlib/zconf.h.cmakein @@ -0,0 +1,536 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H +#cmakedefine Z_PREFIX +#cmakedefine Z_HAVE_UNISTD_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols and init macros */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define crc32_z z_crc32_z +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary +# define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateValidate z_inflateValidate +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# define uncompress2 z_uncompress2 +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +#ifdef Z_SOLO + typedef unsigned long z_size_t; +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + +#ifdef _WIN32 +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) +# define Z_HAVE_UNISTD_H +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/xs/src/png/zlib/zconf.h.in b/xs/src/png/zlib/zconf.h.in new file mode 100644 index 0000000000..5e1d68a004 --- /dev/null +++ b/xs/src/png/zlib/zconf.h.in @@ -0,0 +1,534 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols and init macros */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define crc32_z z_crc32_z +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary +# define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateValidate z_inflateValidate +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# define uncompress2 z_uncompress2 +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +#ifdef Z_SOLO + typedef unsigned long z_size_t; +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + +#ifdef _WIN32 +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) +# define Z_HAVE_UNISTD_H +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/xs/src/png/zlib/zconf.h.included b/xs/src/png/zlib/zconf.h.included new file mode 100644 index 0000000000..5e1d68a004 --- /dev/null +++ b/xs/src/png/zlib/zconf.h.included @@ -0,0 +1,534 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols and init macros */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define crc32_z z_crc32_z +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary +# define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateValidate z_inflateValidate +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# define uncompress2 z_uncompress2 +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +#ifdef Z_SOLO + typedef unsigned long z_size_t; +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + +#ifdef _WIN32 +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) +# define Z_HAVE_UNISTD_H +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/xs/src/png/zlib/zlib.3 b/xs/src/png/zlib/zlib.3 new file mode 100644 index 0000000000..bda4eb0737 --- /dev/null +++ b/xs/src/png/zlib/zlib.3 @@ -0,0 +1,149 @@ +.TH ZLIB 3 "15 Jan 2017" +.SH NAME +zlib \- compression/decompression library +.SH SYNOPSIS +[see +.I zlib.h +for full description] +.SH DESCRIPTION +The +.I zlib +library is a general purpose data compression library. +The code is thread safe, assuming that the standard library functions +used are thread safe, such as memory allocation routines. +It provides in-memory compression and decompression functions, +including integrity checks of the uncompressed data. +This version of the library supports only one compression method (deflation) +but other algorithms may be added later +with the same stream interface. +.LP +Compression can be done in a single step if the buffers are large enough +or can be done by repeated calls of the compression function. +In the latter case, +the application must provide more input and/or consume the output +(providing more output space) before each call. +.LP +The library also supports reading and writing files in +.IR gzip (1) +(.gz) format +with an interface similar to that of stdio. +.LP +The library does not install any signal handler. +The decoder checks the consistency of the compressed data, +so the library should never crash even in the case of corrupted input. +.LP +All functions of the compression library are documented in the file +.IR zlib.h . +The distribution source includes examples of use of the library +in the files +.I test/example.c +and +.IR test/minigzip.c, +as well as other examples in the +.IR examples/ +directory. +.LP +Changes to this version are documented in the file +.I ChangeLog +that accompanies the source. +.LP +.I zlib +is built in to many languages and operating systems, including but not limited to +Java, Python, .NET, PHP, Perl, Ruby, Swift, and Go. +.LP +An experimental package to read and write files in the .zip format, +written on top of +.I zlib +by Gilles Vollant (info@winimage.com), +is available at: +.IP +http://www.winimage.com/zLibDll/minizip.html +and also in the +.I contrib/minizip +directory of the main +.I zlib +source distribution. +.SH "SEE ALSO" +The +.I zlib +web site can be found at: +.IP +http://zlib.net/ +.LP +The data format used by the +.I zlib +library is described by RFC +(Request for Comments) 1950 to 1952 in the files: +.IP +http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format) +.br +http://tools.ietf.org/html/rfc1951 (for the deflate compressed data format) +.br +http://tools.ietf.org/html/rfc1952 (for the gzip header and trailer format) +.LP +Mark Nelson wrote an article about +.I zlib +for the Jan. 1997 issue of Dr. Dobb's Journal; +a copy of the article is available at: +.IP +http://marknelson.us/1997/01/01/zlib-engine/ +.SH "REPORTING PROBLEMS" +Before reporting a problem, +please check the +.I zlib +web site to verify that you have the latest version of +.IR zlib ; +otherwise, +obtain the latest version and see if the problem still exists. +Please read the +.I zlib +FAQ at: +.IP +http://zlib.net/zlib_faq.html +.LP +before asking for help. +Send questions and/or comments to zlib@gzip.org, +or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). +.SH AUTHORS AND LICENSE +Version 1.2.11 +.LP +Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler +.LP +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. +.LP +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: +.LP +.nr step 1 1 +.IP \n[step]. 3 +The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software +in a product, an acknowledgment in the product documentation would be +appreciated but is not required. +.IP \n+[step]. +Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. +.IP \n+[step]. +This notice may not be removed or altered from any source distribution. +.LP +Jean-loup Gailly Mark Adler +.br +jloup@gzip.org madler@alumni.caltech.edu +.LP +The deflate format used by +.I zlib +was defined by Phil Katz. +The deflate and +.I zlib +specifications were written by L. Peter Deutsch. +Thanks to all the people who reported problems and suggested various +improvements in +.IR zlib ; +who are too numerous to cite here. +.LP +UNIX manual page by R. P. C. Rodgers, +U.S. National Library of Medicine (rodgers@nlm.nih.gov). +.\" end of man page diff --git a/xs/src/png/zlib/zlib.3.pdf b/xs/src/png/zlib/zlib.3.pdf new file mode 100644 index 0000000000000000000000000000000000000000..6fa519c5bdf5df33b2f17549e1df142c619c916c GIT binary patch literal 19318 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 to the Adler-32 checksum of all input read + so far (that is, total_in bytes). If a gzip stream is being generated, then + strm->adler will be the CRC-32 checksum of the input read so far. (See + deflateInit2 below.) + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is + considered binary. This field is only for information purposes and does not + affect the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL or the state was inadvertently written over + by the application), or Z_BUF_ERROR if no progress is possible (for example + avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and + deflate() can be called again with more input and more output space to + continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. In the current version of inflate, the provided input is not + read or consumed. The allocation of a sliding window will be deferred to + the first call of inflate (if the decompression does not complete on the + first call). If zalloc and zfree are set to Z_NULL, inflateInit updates + them to use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression. + Actual decompression will be done by inflate(). So next_in, and avail_in, + next_out, and avail_out are unused and unchanged. The current + implementation of inflateInit() does not process any header information -- + that is deferred until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), then next_in and avail_in are updated + accordingly, and processing will resume at this point for the next call of + inflate(). + + - Generate more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. If the + caller of inflate() does not provide both available input and available + output space, it is possible that there will be no progress made. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + To assist in this, on return inflate() always sets strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all of the uncompressed data for the + operation to complete. (The size of the uncompressed data may have been + saved by the compressor for this purpose.) The use of Z_FINISH is not + required to perform an inflation in one step. However it may be used to + inform inflate that a faster approach can be used for the single inflate() + call. Z_FINISH also informs inflate to not maintain a sliding window if the + stream completes, which reduces inflate's memory footprint. If the stream + does not complete, either because not all of the stream is provided or not + enough output space is provided, then a sliding window will be allocated and + inflate() can be called again to continue the operation as if Z_NO_FLUSH had + been used. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the effects of the flush parameter in this implementation are + on the return value of inflate() as noted below, when inflate() returns early + when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of + memory for a sliding window when Z_FINISH is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the Adler-32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the Adler-32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed Adler-32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained unless inflateGetHeader() is used. When processing + gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output + produced so far. The CRC-32 is checked against the gzip trailer, as is the + uncompressed length, modulo 2^32. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value, in which case strm->msg points to a string with a more specific + error), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL, or the state was inadvertently written over + by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR + if no progress was possible or if there was not enough room in the output + buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is to be attempted. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state + was inconsistent. +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by the + caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + For the current implementation of deflate(), a windowBits value of 8 (a + window size of 256 bytes) is not supported. As a result, a request for 8 + will result in 9 (a 512-byte window). In that case, providing 8 to + inflateInit2() will result in an error when the zlib header with 9 is + checked against the initialization of inflate(). The remedy is to not use 8 + with deflateInit2() with this initialization, or at least in that case use 9 + with inflateInit2(). + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute a check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to the appropriate value, + if the operating system was determined at compile time. If a gzip stream is + being written, strm->adler is a CRC-32 instead of an Adler-32. + + For raw deflate or gzip encoding, a request for a 256-byte window is + rejected as invalid, since only the zlib header provides a means of + transmitting the window size to the decompressor. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. When using the zlib format, this + function must be called immediately after deflateInit, deflateInit2 or + deflateReset, and before any call of deflate. When doing raw deflate, this + function must be called either before any call of deflate, or immediately + after the completion of a deflate block, i.e. after all input has been + consumed and all output has been delivered when using any of the flush + options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The + compressor and decompressor must use exactly the same dictionary (see + inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the Adler-32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler-32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + Adler-32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if not at a block boundary for raw deflate). deflateSetDictionary does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, + Bytef *dictionary, + uInt *dictLength)); +/* + Returns the sliding dictionary being maintained by deflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If deflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similary, if dictLength is Z_NULL, then it is not set. + + deflateGetDictionary() may return a length less than the window size, even + when more than the window size in input has been provided. It may return up + to 258 bytes less in that case, due to how zlib's implementation of deflate + manages the sliding window and lookahead for matches, where matches can be + up to 258 bytes long. If the application needs the last window-size bytes of + input, then that would need to be saved by the application outside of zlib. + + deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, but + does not free and reallocate the internal compression state. The stream + will leave the compression level and any other attributes that may have been + set unchanged. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2(). This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression approach (which is a function of the level) or the + strategy is changed, and if any input has been consumed in a previous + deflate() call, then the input available so far is compressed with the old + level and strategy using deflate(strm, Z_BLOCK). There are three approaches + for the compression levels 0, 1..3, and 4..9 respectively. The new level + and strategy will take effect at the next call of deflate(). + + If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does + not have enough output space to complete, then the parameter change will not + take effect. In this case, deflateParams() can be called again with the + same parameters and more output space to try again. + + In order to assure a change in the parameters on the first try, the + deflate stream should be flushed using deflate() with Z_BLOCK or other flush + request until strm.avail_out is not zero, before calling deflateParams(). + Then no more input data should be provided before the deflateParams() call. + If this is done, the old level and strategy will be applied to the data + compressed before deflateParams(), and the new level and strategy will be + applied to the the data compressed after deflateParams(). + + deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream + state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if + there was not enough output space to complete the compression of the + available input data before a change in the strategy or approach. Note that + in the case of a Z_BUF_ERROR, the parameters are not changed. A return + value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be + retried with more output space. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). If that first deflate() call is provided the + sourceLen input bytes, an output buffer allocated to the size returned by + deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed + to return Z_STREAM_END. Note that it is possible for the compressed size to + be larger than the value returned by deflateBound() if flush options other + than Z_FINISH or Z_NO_FLUSH are used. +*/ + +ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, + unsigned *pending, + int *bits)); +/* + deflatePending() returns the number of bytes and bits of output that have + been generated, but not yet provided in the available output. The bytes not + provided would be due to the available output space having being consumed. + The number of bits of output not provided are between 0 and 7, where they + await more bits to join them in order to fill out a full byte. If pending + or bits are Z_NULL, then those values are not set. + + deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. + */ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough + room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an Adler-32 or a CRC-32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see + below), inflate() will not automatically decode concatenated gzip streams. + inflate() will return Z_STREAM_END at the end of the gzip stream. The state + would need to be reset to continue decoding a subsequent gzip stream. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler-32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called at any + time to set the dictionary. If the provided dictionary is smaller than the + window and there is already data in the window, then the provided dictionary + will amend what's there. The application must insure that the dictionary + that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler-32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, + Bytef *dictionary, + uInt *dictLength)); +/* + Returns the sliding dictionary being maintained by inflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If inflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similary, if dictLength is Z_NULL, then it is not set. + + inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a possible full flush point (see above + for the description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync searches for a 00 00 FF FF pattern in the compressed data. + All full flush points have this pattern, but not all occurrences of this + pattern are full flush points. + + inflateSync returns Z_OK if a possible full flush point has been found, + Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point + has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. + In the success case, the application may save the current current value of + total_in which indicates where valid compressed data was found. In the + error case, the application may repeatedly call inflateSync, providing more + input each time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. If the window size is changed, then the + memory allocated for the window is freed, and the window will be reallocated + by inflate() if needed. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above, or -65536 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the parameters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, + z_const unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is potentially more efficient than + inflate() for file i/o applications, in that it avoids copying between the + output and the sliding window by simply making the window itself the output + buffer. inflate() can be faster on modern CPUs when used with large + buffers. inflateBack() trusts the application to not change the output + buffer passed by the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the default + behavior of inflate(), which expects a zlib header and trailer around the + deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero -- buf is ignored in that + case -- and inflateBack() will return a buffer error. inflateBack() will + call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. + out() should return zero on success, or non-zero on failure. If out() + returns non-zero, inflateBack() will return with an error. Neither in() nor + out() are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: ZLIB_DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + +#ifndef Z_SOLO + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed data. compress() is equivalent to compress2() with a level + parameter of Z_DEFAULT_COMPRESSION. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed data. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed data. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In + the case where there is not enough room, uncompress() will fill the output + buffer with the uncompressed data up to that point. +*/ + +ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen)); +/* + Same as uncompress, except that sourceLen is a pointer, where the + length of the source is *sourceLen. On return, *sourceLen is the number of + source bytes consumed. +*/ + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Opens a gzip (.gz) file for reading or writing. The mode parameter is as + in fopen ("rb" or "wb") but can also include a compression level ("wb9") or + a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only + compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' + for fixed code compression as in "wb9F". (See the description of + deflateInit2 for more information about the strategy parameter.) 'T' will + request transparent writing or appending with no compression and not using + the gzip format. + + "a" can be used instead of "w" to request that the gzip stream that will + be written be appended to the file. "+" will result in an error, since + reading and writing to the same gzip file is not supported. The addition of + "x" when writing will create the file exclusively, which fails if the file + already exists. On systems that support it, the addition of "e" when + reading or writing will set the flag to close the file on an execve() call. + + These functions, as well as gzip, will read and decode a sequence of gzip + streams in a file. The append function of gzopen() can be used to create + such a file. (Also see gzflush() for another way to do this.) When + appending, gzopen does not test whether the file begins with a gzip stream, + nor does it look for the end of the gzip streams to begin appending. gzopen + will simply append a gzip stream to the existing file. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. When + reading, this will be detected automatically by looking for the magic two- + byte gzip header. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen associates a gzFile with the file descriptor fd. File descriptors + are obtained from calls like open, dup, creat, pipe or fileno (if the file + has been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. If you are using fileno() to get the + file descriptor from a FILE *, then you will have to use dup() to avoid + double-close()ing the file descriptor. Both gzclose() and fclose() will + close the associated file descriptor, so they need to have different file + descriptors. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions. The + default buffer size is 8192 bytes. This function must be called after + gzopen() or gzdopen(), and before any other calls that read or write the + file. The buffer memory allocation is always deferred to the first read or + write. Three times that size in buffer space is allocated. A larger buffer + size of, for example, 64K or 128K bytes will noticeably increase the speed + of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. Previously provided + data is flushed before the parameter change. + + gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not + opened for writing, Z_ERRNO if there is an error writing the flushed data, + or Z_MEM_ERROR if there is a memory allocation error. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. If + the input file is not in gzip format, gzread copies the given number of + bytes into the buffer directly from the file. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream. Any number of gzip streams may be + concatenated in the input file, and will all be decompressed by gzread(). + If something other than a gzip stream is encountered after a gzip stream, + that remaining trailing garbage is ignored (and no error is returned). + + gzread can be used to read a gzip file that is being concurrently written. + Upon reaching the end of the input, gzread will return with the available + data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then + gzclearerr can be used to clear the end of file indicator in order to permit + gzread to be tried again. Z_OK indicates that a gzip stream was completed + on the last gzread. Z_BUF_ERROR indicates that the input file ended in the + middle of a gzip stream. Note that gzread does not return -1 in the event + of an incomplete gzip stream. This error is deferred until gzclose(), which + will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip + stream. Alternatively, gzerror can be used before gzclose to detect this + case. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. If len is too large to fit in an int, + then nothing is read, -1 is returned, and the error state is set to + Z_STREAM_ERROR. +*/ + +ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, + gzFile file)); +/* + Read up to nitems items of size size from file to buf, otherwise operating + as gzread() does. This duplicates the interface of stdio's fread(), with + size_t request and return types. If the library defines size_t, then + z_size_t is identical to size_t. If not, then z_size_t is an unsigned + integer type that can contain a pointer. + + gzfread() returns the number of full items read of size size, or zero if + the end of the file was reached and a full item could not be read, or if + there was an error. gzerror() must be consulted if zero is returned in + order to determine if there was an error. If the multiplication of size and + nitems overflows, i.e. the product does not fit in a z_size_t, then nothing + is read, zero is returned, and the error state is set to Z_STREAM_ERROR. + + In the event that the end of file is reached and only a partial item is + available at the end, i.e. the remaining uncompressed data length is not a + multiple of size, then the final partial item is nevetheless read into buf + and the end-of-file flag is set. The length of the partial item read is not + provided, but could be inferred from the result of gztell(). This behavior + is the same as the behavior of fread() implementations in common libraries, + but it prevents the direct use of gzfread() to read a concurrently written + file, reseting and retrying on end-of-file, when size is not 1. +*/ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes written or 0 in case of + error. +*/ + +ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, + z_size_t nitems, gzFile file)); +/* + gzfwrite() writes nitems items of size size from buf to file, duplicating + the interface of stdio's fwrite(), with size_t request and return types. If + the library defines size_t, then z_size_t is identical to size_t. If not, + then z_size_t is an unsigned integer type that can contain a pointer. + + gzfwrite() returns the number of full items written of size size, or zero + if there was an error. If the multiplication of size and nitems overflows, + i.e. the product does not fit in a z_size_t, then nothing is written, zero + is returned, and the error state is set to Z_STREAM_ERROR. +*/ + +ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the arguments to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or a negative zlib error code in case + of error. The number of uncompressed bytes written is limited to 8191, or + one less than the buffer size given to gzbuffer(). The caller should assure + that this limit is not exceeded. If it is exceeded, then gzprintf() will + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. + This can be determined using zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or a + newline character is read and transferred to buf, or an end-of-file + condition is encountered. If any characters are read or if len == 1, the + string is terminated with a null character. If no characters are read due + to an end-of-file or len < 1, then the buffer is left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte or -1 + in case of end of file or error. This is implemented as a macro for speed. + As such, it does not do all of the checking the other functions do. I.e. + it does not check to see if file is NULL, nor whether the structure file + points to has been clobbered or not. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read as the first character + on the next read. At least one character of push-back is allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter flush + is as in the deflate() function. The return value is the zlib error number + (see function gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatenated gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Returns the starting position for the next gzread or gzwrite on the given + compressed file. This position represents a number of bytes in the + uncompressed data stream, and is zero when starting, even if appending or + reading a gzip stream from the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); + + Returns the current offset in the file being read or written. This offset + includes the count of bytes that precede the gzip stream, for example when + appending or when using gzdopen() for reading. When reading, the offset + does not include as yet unused buffered input. This information can be used + for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns true (1) if the end-of-file indicator has been set while reading, + false (0) otherwise. Note that the end-of-file indicator is set only if the + read tried to go past the end of the input, but came up short. Therefore, + just like feof(), gzeof() may return false even if there is no more data to + read, in the event that the last read request was for the exact number of + bytes remaining in the input file. This will happen if the input file size + is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). + + When writing, gzdirect() returns true (1) if transparent writing was + requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: + gzdirect() is not needed when writing. Transparent writing must be + explicitly requested, so the application already knows the answer. When + linking statically, using gzdirect() will include all of the zlib code for + gzip file reading and decompression, which may not be desired.) +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file and + deallocates the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the + last read ended in the middle of a gzip stream, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the given + compressed file. errnum is set to zlib error number. If an error occurred + in the file system and not in the compression library, errnum is set to + Z_ERRNO and the application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + +#endif /* !Z_SOLO */ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is Z_NULL, this function returns the + required initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, + z_size_t len)); +/* + Same as adler32(), but with a size_t length. +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note + that the z_off_t type (like off_t) is a signed integer. If len2 is + negative, the result has no meaning or utility. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is Z_NULL, this function returns the required + initial value for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf, + z_size_t len)); +/* + Same as crc32(), but with a size_t length. +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#ifdef Z_PREFIX_SET +# define z_deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define z_inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#else +# define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#endif + +#ifndef Z_SOLO + +/* gzgetc() macro and its supporting function and exposed data structure. Note + * that the real internal state is much larger than the exposed structure. + * This abbreviated structure exposes just enough for the gzgetc() macro. The + * user should not mess with these exposed elements, since their names or + * behavior could change in the future, perhaps even capriciously. They can + * only be used by the gzgetc() macro. You have been warned. + */ +struct gzFile_s { + unsigned have; + unsigned char *next; + z_off64_t pos; +}; +ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +# define z_gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) +#else +# define gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) +#endif + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#ifdef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# ifdef Z_PREFIX_SET +# define z_gzopen z_gzopen64 +# define z_gzseek z_gzseek64 +# define z_gztell z_gztell64 +# define z_gzoffset z_gzoffset64 +# define z_adler32_combine z_adler32_combine64 +# define z_crc32_combine z_crc32_combine64 +# else +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# endif +# ifndef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); +#endif + +#else /* Z_SOLO */ + + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); + +#endif /* !Z_SOLO */ + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); +ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); +ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); +ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, + const char *mode)); +#endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, + const char *format, + va_list va)); +# endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/xs/src/png/zlib/zlib.map b/xs/src/png/zlib/zlib.map new file mode 100644 index 0000000000..82ce98cf7d --- /dev/null +++ b/xs/src/png/zlib/zlib.map @@ -0,0 +1,94 @@ +ZLIB_1.2.0 { + global: + compressBound; + deflateBound; + inflateBack; + inflateBackEnd; + inflateBackInit_; + inflateCopy; + local: + deflate_copyright; + inflate_copyright; + inflate_fast; + inflate_table; + zcalloc; + zcfree; + z_errmsg; + gz_error; + gz_intmax; + _*; +}; + +ZLIB_1.2.0.2 { + gzclearerr; + gzungetc; + zlibCompileFlags; +} ZLIB_1.2.0; + +ZLIB_1.2.0.8 { + deflatePrime; +} ZLIB_1.2.0.2; + +ZLIB_1.2.2 { + adler32_combine; + crc32_combine; + deflateSetHeader; + inflateGetHeader; +} ZLIB_1.2.0.8; + +ZLIB_1.2.2.3 { + deflateTune; + gzdirect; +} ZLIB_1.2.2; + +ZLIB_1.2.2.4 { + inflatePrime; +} ZLIB_1.2.2.3; + +ZLIB_1.2.3.3 { + adler32_combine64; + crc32_combine64; + gzopen64; + gzseek64; + gztell64; + inflateUndermine; +} ZLIB_1.2.2.4; + +ZLIB_1.2.3.4 { + inflateReset2; + inflateMark; +} ZLIB_1.2.3.3; + +ZLIB_1.2.3.5 { + gzbuffer; + gzoffset; + gzoffset64; + gzclose_r; + gzclose_w; +} ZLIB_1.2.3.4; + +ZLIB_1.2.5.1 { + deflatePending; +} ZLIB_1.2.3.5; + +ZLIB_1.2.5.2 { + deflateResetKeep; + gzgetc_; + inflateResetKeep; +} ZLIB_1.2.5.1; + +ZLIB_1.2.7.1 { + inflateGetDictionary; + gzvprintf; +} ZLIB_1.2.5.2; + +ZLIB_1.2.9 { + inflateCodesUsed; + inflateValidate; + uncompress2; + gzfread; + gzfwrite; + deflateGetDictionary; + adler32_z; + crc32_z; +} ZLIB_1.2.7.1; diff --git a/xs/src/png/zlib/zlib.pc.cmakein b/xs/src/png/zlib/zlib.pc.cmakein new file mode 100644 index 0000000000..a5e642938c --- /dev/null +++ b/xs/src/png/zlib/zlib.pc.cmakein @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@INSTALL_LIB_DIR@ +sharedlibdir=@INSTALL_LIB_DIR@ +includedir=@INSTALL_INC_DIR@ + +Name: zlib +Description: zlib compression library +Version: @VERSION@ + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -lz +Cflags: -I${includedir} diff --git a/xs/src/png/zlib/zlib.pc.in b/xs/src/png/zlib/zlib.pc.in new file mode 100644 index 0000000000..7e5acf9c77 --- /dev/null +++ b/xs/src/png/zlib/zlib.pc.in @@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +sharedlibdir=@sharedlibdir@ +includedir=@includedir@ + +Name: zlib +Description: zlib compression library +Version: @VERSION@ + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -lz +Cflags: -I${includedir} diff --git a/xs/src/png/zlib/zlib2ansi b/xs/src/png/zlib/zlib2ansi new file mode 100644 index 0000000000..15e3e165f3 --- /dev/null +++ b/xs/src/png/zlib/zlib2ansi @@ -0,0 +1,152 @@ +#!/usr/bin/perl + +# Transform K&R C function definitions into ANSI equivalent. +# +# Author: Paul Marquess +# Version: 1.0 +# Date: 3 October 2006 + +# TODO +# +# Asumes no function pointer parameters. unless they are typedefed. +# Assumes no literal strings that look like function definitions +# Assumes functions start at the beginning of a line + +use strict; +use warnings; + +local $/; +$_ = <>; + +my $sp = qr{ \s* (?: /\* .*? \*/ )? \s* }x; # assume no nested comments + +my $d1 = qr{ $sp (?: [\w\*\s]+ $sp)* $sp \w+ $sp [\[\]\s]* $sp }x ; +my $decl = qr{ $sp (?: \w+ $sp )+ $d1 }xo ; +my $dList = qr{ $sp $decl (?: $sp , $d1 )* $sp ; $sp }xo ; + + +while (s/^ + ( # Start $1 + ( # Start $2 + .*? # Minimal eat content + ( ^ \w [\w\s\*]+ ) # $3 -- function name + \s* # optional whitespace + ) # $2 - Matched up to before parameter list + + \( \s* # Literal "(" + optional whitespace + ( [^\)]+ ) # $4 - one or more anythings except ")" + \s* \) # optional whitespace surrounding a Literal ")" + + ( (?: $dList )+ ) # $5 + + $sp ^ { # literal "{" at start of line + ) # Remember to $1 + //xsom + ) +{ + my $all = $1 ; + my $prefix = $2; + my $param_list = $4 ; + my $params = $5; + + StripComments($params); + StripComments($param_list); + $param_list =~ s/^\s+//; + $param_list =~ s/\s+$//; + + my $i = 0 ; + my %pList = map { $_ => $i++ } + split /\s*,\s*/, $param_list; + my $pMatch = '(\b' . join('|', keys %pList) . '\b)\W*$' ; + + my @params = split /\s*;\s*/, $params; + my @outParams = (); + foreach my $p (@params) + { + if ($p =~ /,/) + { + my @bits = split /\s*,\s*/, $p; + my $first = shift @bits; + $first =~ s/^\s*//; + push @outParams, $first; + $first =~ /^(\w+\s*)/; + my $type = $1 ; + push @outParams, map { $type . $_ } @bits; + } + else + { + $p =~ s/^\s+//; + push @outParams, $p; + } + } + + + my %tmp = map { /$pMatch/; $_ => $pList{$1} } + @outParams ; + + @outParams = map { " $_" } + sort { $tmp{$a} <=> $tmp{$b} } + @outParams ; + + print $prefix ; + print "(\n" . join(",\n", @outParams) . ")\n"; + print "{" ; + +} + +# Output any trailing code. +print ; +exit 0; + + +sub StripComments +{ + + no warnings; + + # Strip C & C++ coments + # From the perlfaq + $_[0] =~ + + s{ + /\* ## Start of /* ... */ comment + [^*]*\*+ ## Non-* followed by 1-or-more *'s + ( + [^/*][^*]*\*+ + )* ## 0-or-more things which don't start with / + ## but do end with '*' + / ## End of /* ... */ comment + + | ## OR C++ Comment + // ## Start of C++ comment // + [^\n]* ## followed by 0-or-more non end of line characters + + | ## OR various things which aren't comments: + + ( + " ## Start of " ... " string + ( + \\. ## Escaped char + | ## OR + [^"\\] ## Non "\ + )* + " ## End of " ... " string + + | ## OR + + ' ## Start of ' ... ' string + ( + \\. ## Escaped char + | ## OR + [^'\\] ## Non '\ + )* + ' ## End of ' ... ' string + + | ## OR + + . ## Anything other char + [^/"'\\]* ## Chars which doesn't start a comment, string or escape + ) + }{$2}gxs; + +} diff --git a/xs/src/png/zlib/zutil.c b/xs/src/png/zlib/zutil.c new file mode 100644 index 0000000000..a76c6b0c7e --- /dev/null +++ b/xs/src/png/zlib/zutil.c @@ -0,0 +1,325 @@ +/* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-2017 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" +#ifndef Z_SOLO +# include "gzguts.h" +#endif + +z_const char * const z_errmsg[10] = { + (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ + (z_const char *)"stream end", /* Z_STREAM_END 1 */ + (z_const char *)"", /* Z_OK 0 */ + (z_const char *)"file error", /* Z_ERRNO (-1) */ + (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ + (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ + (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ + (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ + (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ + (z_const char *)"" +}; + + +const char * ZEXPORT zlibVersion() +{ + return ZLIB_VERSION; +} + +uLong ZEXPORT zlibCompileFlags() +{ + uLong flags; + + flags = 0; + switch ((int)(sizeof(uInt))) { + case 2: break; + case 4: flags += 1; break; + case 8: flags += 2; break; + default: flags += 3; + } + switch ((int)(sizeof(uLong))) { + case 2: break; + case 4: flags += 1 << 2; break; + case 8: flags += 2 << 2; break; + default: flags += 3 << 2; + } + switch ((int)(sizeof(voidpf))) { + case 2: break; + case 4: flags += 1 << 4; break; + case 8: flags += 2 << 4; break; + default: flags += 3 << 4; + } + switch ((int)(sizeof(z_off_t))) { + case 2: break; + case 4: flags += 1 << 6; break; + case 8: flags += 2 << 6; break; + default: flags += 3 << 6; + } +#ifdef ZLIB_DEBUG + flags += 1 << 8; +#endif +#if defined(ASMV) || defined(ASMINF) + flags += 1 << 9; +#endif +#ifdef ZLIB_WINAPI + flags += 1 << 10; +#endif +#ifdef BUILDFIXED + flags += 1 << 12; +#endif +#ifdef DYNAMIC_CRC_TABLE + flags += 1 << 13; +#endif +#ifdef NO_GZCOMPRESS + flags += 1L << 16; +#endif +#ifdef NO_GZIP + flags += 1L << 17; +#endif +#ifdef PKZIP_BUG_WORKAROUND + flags += 1L << 20; +#endif +#ifdef FASTEST + flags += 1L << 21; +#endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifdef NO_vsnprintf + flags += 1L << 25; +# ifdef HAS_vsprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_vsnprintf_void + flags += 1L << 26; +# endif +# endif +#else + flags += 1L << 24; +# ifdef NO_snprintf + flags += 1L << 25; +# ifdef HAS_sprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_snprintf_void + flags += 1L << 26; +# endif +# endif +#endif + return flags; +} + +#ifdef ZLIB_DEBUG +#include +# ifndef verbose +# define verbose 0 +# endif +int ZLIB_INTERNAL z_verbose = verbose; + +void ZLIB_INTERNAL z_error (m) + char *m; +{ + fprintf(stderr, "%s\n", m); + exit(1); +} +#endif + +/* exported to allow conversion of error code to string for compress() and + * uncompress() + */ +const char * ZEXPORT zError(err) + int err; +{ + return ERR_MSG(err); +} + +#if defined(_WIN32_WCE) + /* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. + */ + int errno = 0; +#endif + +#ifndef HAVE_MEMCPY + +void ZLIB_INTERNAL zmemcpy(dest, source, len) + Bytef* dest; + const Bytef* source; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); +} + +int ZLIB_INTERNAL zmemcmp(s1, s2, len) + const Bytef* s1; + const Bytef* s2; + uInt len; +{ + uInt j; + + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; +} + +void ZLIB_INTERNAL zmemzero(dest, len) + Bytef* dest; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); +} +#endif + +#ifndef Z_SOLO + +#ifdef SYS16BIT + +#ifdef __TURBOC__ +/* Turbo C in 16-bit mode */ + +# define MY_ZCALLOC + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use zcfree(). + */ + +#define MAX_PTR 10 +/* 10*64K = 640K */ + +local int next_ptr = 0; + +typedef struct ptr_table_s { + voidpf org_ptr; + voidpf new_ptr; +} ptr_table; + +local ptr_table table[MAX_PTR]; +/* This table is used to remember the original form of pointers + * to large buffers (64K). Such pointers are normalized with a zero offset. + * Since MSDOS is not a preemptive multitasking OS, this table is not + * protected from concurrent access. This hack doesn't work anyway on + * a protected system like OS/2. Use Microsoft C instead. + */ + +voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + voidpf buf; + ulg bsize = (ulg)items*size; + + (void)opaque; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; +} + +void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) +{ + int n; + + (void)opaque; + + if (*(ush*)&ptr != 0) { /* object < 64K */ + farfree(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + farfree(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + Assert(0, "zcfree: ptr not found"); +} + +#endif /* __TURBOC__ */ + + +#ifdef M_I86 +/* Microsoft C in 16-bit mode */ + +# define MY_ZCALLOC + +#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +# define _halloc halloc +# define _hfree hfree +#endif + +voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) +{ + (void)opaque; + return _halloc((long)items, size); +} + +void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) +{ + (void)opaque; + _hfree(ptr); +} + +#endif /* M_I86 */ + +#endif /* SYS16BIT */ + + +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +#ifndef STDC +extern voidp malloc OF((uInt size)); +extern voidp calloc OF((uInt items, uInt size)); +extern void free OF((voidpf ptr)); +#endif + +voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) + voidpf opaque; + unsigned items; + unsigned size; +{ + (void)opaque; + return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : + (voidpf)calloc(items, size); +} + +void ZLIB_INTERNAL zcfree (opaque, ptr) + voidpf opaque; + voidpf ptr; +{ + (void)opaque; + free(ptr); +} + +#endif /* MY_ZCALLOC */ + +#endif /* !Z_SOLO */ diff --git a/xs/src/png/zlib/zutil.h b/xs/src/png/zlib/zutil.h new file mode 100644 index 0000000000..b079ea6a80 --- /dev/null +++ b/xs/src/png/zlib/zutil.h @@ -0,0 +1,271 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#ifdef HAVE_HIDDEN +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +#else +# define ZLIB_INTERNAL +#endif + +#include "zlib.h" + +#if defined(STDC) && !defined(Z_SOLO) +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) +# include +# endif +# include +# include +#endif + +#ifdef Z_SOLO + typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ +#endif + +#ifndef local +# define local static +#endif +/* since "static" is used to mean two completely different things in C, we + define "local" for the non-static meaning of "static", for readability + (compile with -Dlocal if your debugger can't find static symbols) */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# ifndef Z_SOLO +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 1 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 2 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#ifdef __370__ +# if __TARGET_LIB__ < 0x20000000 +# define OS_CODE 4 +# elif __TARGET_LIB__ < 0x40000000 +# define OS_CODE 11 +# else +# define OS_CODE 8 +# endif +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 5 +#endif + +#ifdef OS2 +# define OS_CODE 6 +# if defined(M_I86) && !defined(Z_SOLO) +# include +# endif +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 7 +# ifndef Z_SOLO +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +# endif +#endif + +#ifdef __acorn +# define OS_CODE 13 +#endif + +#if defined(WIN32) && !defined(__CYGWIN__) +# define OS_CODE 10 +#endif + +#ifdef _BEOS_ +# define OS_CODE 16 +#endif + +#ifdef __TOS_OS400__ +# define OS_CODE 18 +#endif + +#ifdef __APPLE__ +# define OS_CODE 19 +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif +#endif + +#if defined(__BORLANDC__) && !defined(MSDOS) + #pragma warn -8004 + #pragma warn -8008 + #pragma warn -8066 +#endif + +/* provide prototypes for these when building zlib without LFS */ +#if !defined(_WIN32) && \ + (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 3 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(pyr) || defined(Z_SOLO) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef ZLIB_DEBUG +# include + extern int ZLIB_INTERNAL z_verbose; + extern void ZLIB_INTERNAL z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + +#ifndef Z_SOLO + voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, + unsigned size)); + void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); +#endif + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +/* Reverse the bytes in a 32-bit value */ +#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + +#endif /* ZUTIL_H */ From 6cc4e9963244d1166b55c6946af9fff071fcb135 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 21 May 2018 16:28:00 +0200 Subject: [PATCH 0397/1150] Logging file system error and formatting png output filename for equal leading zeros. --- xs/src/agg/VERSION | 2 ++ xs/src/libslic3r/Print.cpp | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 xs/src/agg/VERSION diff --git a/xs/src/agg/VERSION b/xs/src/agg/VERSION new file mode 100644 index 0000000000..c5de3e3b0c --- /dev/null +++ b/xs/src/agg/VERSION @@ -0,0 +1,2 @@ +2.4 +svn revision 128 \ No newline at end of file diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 1da3d9ce23..8416dd979e 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -10,6 +10,7 @@ #include #include #include +#include // For png export of the sliced model @@ -1352,13 +1353,22 @@ public: } inline void save(const std::string& path) { + for(unsigned i = 0; i < layers_rst_.size(); i++) { if(layers_rst_[i].second.rdbuf()->in_avail() > 0) { - std::string loc = path + "layer" + std::to_string(i) + ".png"; + + char lyrnum[6]; + std::sprintf(lyrnum, "%.5d", i); + std::string loc = path + "layer" + lyrnum + ".png"; + std::fstream out(loc, std::fstream::out | std::fstream::binary); if(out.good()) { out << layers_rst_[i].second.rdbuf(); + } else { + BOOST_LOG_TRIVIAL(error) << "Can't create file for layer " + << i; } + out.close(); layers_rst_[i].second.str(""); } @@ -1368,13 +1378,18 @@ public: void saveLayer(unsigned lyr, const std::string& path) { unsigned i = lyr; assert(i < layers_rst_.size()); - std::string loc = path + "layer" + std::to_string(i) + ".png"; + + char lyrnum[6]; + std::sprintf(lyrnum, "%.5d", lyr); + std::string loc = path + "layer" + lyrnum + ".png"; + std::fstream out(loc, std::fstream::out | std::fstream::binary); if(out.good()) { layers_rst_[i].first.save(out, Raster::Compression::PNG); - } /*else { - some logging should be done here... - }*/ + } else { + BOOST_LOG_TRIVIAL(error) << "Can't create file for layer"; + } + out.close(); layers_rst_[i].first.reset(); } From b3c49cbbe6ecad3dee5ce5f9eb11887b456b28d8 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 21 May 2018 17:42:46 +0200 Subject: [PATCH 0398/1150] Fixing zlib and libpng build on Linux --- xs/CMakeLists.txt | 9 +- xs/src/png/libpng/arm/arm_init.c | 135 +++ xs/src/png/libpng/arm/filter_neon.S | 253 +++++ .../png/libpng/arm/filter_neon_intrinsics.c | 387 ++++++++ .../png/libpng/intel/filter_sse2_intrinsics.c | 406 ++++++++ xs/src/png/libpng/intel/intel_init.c | 53 + .../png/libpng/mips/filter_msa_intrinsics.c | 807 +++++++++++++++ xs/src/png/libpng/mips/mips_init.c | 129 +++ xs/src/png/libpng/pngusr.dfa | 14 + .../libpng/powerpc/filter_vsx_intrinsics.c | 767 +++++++++++++++ xs/src/png/libpng/powerpc/powerpc_init.c | 125 +++ xs/src/png/libpng/scripts/checksym.awk | 173 ++++ xs/src/png/libpng/scripts/def.c | 29 + xs/src/png/libpng/scripts/dfn.awk | 203 ++++ xs/src/png/libpng/scripts/intprefix.c | 22 + xs/src/png/libpng/scripts/options.awk | 898 +++++++++++++++++ xs/src/png/libpng/scripts/pnglibconf.dfa | 919 ++++++++++++++++++ xs/src/png/libpng/scripts/prefix.c | 24 + xs/src/png/libpng/scripts/sym.c | 15 + xs/src/png/libpng/scripts/symbols.c | 58 ++ xs/src/png/libpng/scripts/symbols.def | 256 +++++ xs/src/png/libpng/scripts/vers.c | 19 + xs/src/png/zlib/CMakeLists.txt | 8 +- 23 files changed, 5704 insertions(+), 5 deletions(-) create mode 100644 xs/src/png/libpng/arm/arm_init.c create mode 100644 xs/src/png/libpng/arm/filter_neon.S create mode 100644 xs/src/png/libpng/arm/filter_neon_intrinsics.c create mode 100644 xs/src/png/libpng/intel/filter_sse2_intrinsics.c create mode 100644 xs/src/png/libpng/intel/intel_init.c create mode 100644 xs/src/png/libpng/mips/filter_msa_intrinsics.c create mode 100644 xs/src/png/libpng/mips/mips_init.c create mode 100644 xs/src/png/libpng/pngusr.dfa create mode 100644 xs/src/png/libpng/powerpc/filter_vsx_intrinsics.c create mode 100644 xs/src/png/libpng/powerpc/powerpc_init.c create mode 100755 xs/src/png/libpng/scripts/checksym.awk create mode 100644 xs/src/png/libpng/scripts/def.c create mode 100755 xs/src/png/libpng/scripts/dfn.awk create mode 100644 xs/src/png/libpng/scripts/intprefix.c create mode 100755 xs/src/png/libpng/scripts/options.awk create mode 100644 xs/src/png/libpng/scripts/pnglibconf.dfa create mode 100644 xs/src/png/libpng/scripts/prefix.c create mode 100644 xs/src/png/libpng/scripts/sym.c create mode 100644 xs/src/png/libpng/scripts/symbols.c create mode 100644 xs/src/png/libpng/scripts/symbols.def create mode 100644 xs/src/png/libpng/scripts/vers.c diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 73b7cae37a..9de06a6628 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -351,13 +351,18 @@ if(RASTERIZER_USE_SYSTEM_LIBPNG) target_compile_definitions(rasterizer PRIVATE ${PNG_DEFINITIONS}) else() add_subdirectory( ${LIBDIR}/png/zlib) - add_subdirectory( ${LIBDIR}/png/libpng ) - target_include_directories( png_static PRIVATE + set(ZLIB_INCLUDE_DIR ${LIBDIR}/png/zlib ${CMAKE_CURRENT_BINARY_DIR}/src/png/zlib ) + add_subdirectory( ${LIBDIR}/png/libpng ) + + target_include_directories(rasterizer PRIVATE + ${LIBDIR}/png/libpng + ${CMAKE_CURRENT_BINARY_DIR}/src/png/libpng + ) target_link_libraries(rasterizer PRIVATE png_static zlibstatic) endif() diff --git a/xs/src/png/libpng/arm/arm_init.c b/xs/src/png/libpng/arm/arm_init.c new file mode 100644 index 0000000000..02df812e77 --- /dev/null +++ b/xs/src/png/libpng/arm/arm_init.c @@ -0,0 +1,135 @@ + +/* arm_init.c - NEON optimised filter functions + * + * Copyright (c) 2014,2016 Glenn Randers-Pehrson + * Written by Mans Rullgard, 2011. + * Last changed in libpng 1.6.22 [May 26, 2016] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ +/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are + * called. + */ +#define _POSIX_SOURCE 1 + +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +#if PNG_ARM_NEON_OPT > 0 +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */ +/* WARNING: it is strongly recommended that you do not build libpng with + * run-time checks for CPU features if at all possible. In the case of the ARM + * NEON instructions there is no processor-specific way of detecting the + * presence of the required support, therefore run-time detection is extremely + * OS specific. + * + * You may set the macro PNG_ARM_NEON_FILE to the file name of file containing + * a fragment of C source code which defines the png_have_neon function. There + * are a number of implementations in contrib/arm-neon, but the only one that + * has partial support is contrib/arm-neon/linux.c - a generic Linux + * implementation which reads /proc/cpufino. + */ +#ifndef PNG_ARM_NEON_FILE +# ifdef __linux__ +# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c" +# endif +#endif + +#ifdef PNG_ARM_NEON_FILE + +#include /* for sig_atomic_t */ +static int png_have_neon(png_structp png_ptr); +#include PNG_ARM_NEON_FILE + +#else /* PNG_ARM_NEON_FILE */ +# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks" +#endif /* PNG_ARM_NEON_FILE */ +#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ + +#ifndef PNG_ALIGNED_MEMORY_SUPPORTED +# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED" +#endif + +void +png_init_filter_functions_neon(png_structp pp, unsigned int bpp) +{ + /* The switch statement is compiled in for ARM_NEON_API, the call to + * png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined + * the check is only performed if the API has not set the NEON option on + * or off explicitly. In this case the check controls what happens. + * + * If the CHECK is not compiled in and the option is UNSET the behavior prior + * to 1.6.7 was to use the NEON code - this was a bug caused by having the + * wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF, + * as documented in png.h + */ + png_debug(1, "in png_init_filter_functions_neon"); +#ifdef PNG_ARM_NEON_API_SUPPORTED + switch ((pp->options >> PNG_ARM_NEON) & 3) + { + case PNG_OPTION_UNSET: + /* Allow the run-time check to execute if it has been enabled - + * thus both API and CHECK can be turned on. If it isn't supported + * this case will fall through to the 'default' below, which just + * returns. + */ +#endif /* PNG_ARM_NEON_API_SUPPORTED */ +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED + { + static volatile sig_atomic_t no_neon = -1; /* not checked */ + + if (no_neon < 0) + no_neon = !png_have_neon(pp); + + if (no_neon) + return; + } +#ifdef PNG_ARM_NEON_API_SUPPORTED + break; +#endif +#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ + +#ifdef PNG_ARM_NEON_API_SUPPORTED + default: /* OFF or INVALID */ + return; + + case PNG_OPTION_ON: + /* Option turned on */ + break; + } +#endif + + /* IMPORTANT: any new external functions used here must be declared using + * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the + * 'prefix' option to configure works: + * + * ./configure --with-libpng-prefix=foobar_ + * + * Verify you have got this right by running the above command, doing a build + * and examining pngprefix.h; it must contain a #define for every external + * function you add. (Notice that this happens automatically for the + * initialization function.) + */ + pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon; + + if (bpp == 3) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth3_neon; + } + + else if (bpp == 4) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth4_neon; + } +} +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* READ */ diff --git a/xs/src/png/libpng/arm/filter_neon.S b/xs/src/png/libpng/arm/filter_neon.S new file mode 100644 index 0000000000..000764cd21 --- /dev/null +++ b/xs/src/png/libpng/arm/filter_neon.S @@ -0,0 +1,253 @@ + +/* filter_neon.S - NEON optimised filter functions + * + * Copyright (c) 2014,2017 Glenn Randers-Pehrson + * Written by Mans Rullgard, 2011. + * Last changed in libpng 1.6.31 [July 27, 2017] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* This is required to get the symbol renames, which are #defines, and the + * definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION. + */ +#define PNG_VERSION_INFO_ONLY +#include "../pngpriv.h" + +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ +#endif + +#ifdef PNG_READ_SUPPORTED + +/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for + * ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it + * only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h + * for the logic which sets PNG_USE_ARM_NEON_ASM: + */ +#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */ + +#if PNG_ARM_NEON_OPT > 0 + +#ifdef __ELF__ +# define ELF +#else +# define ELF @ +#endif + + .arch armv7-a + .fpu neon + +.macro func name, export=0 + .macro endfunc +ELF .size \name, . - \name + .endfunc + .purgem endfunc + .endm + .text + + /* Explicitly specifying alignment here because some versions of + * GAS don't align code correctly. This is harmless in correctly + * written versions of GAS. + */ + .align 2 + + .if \export + .global \name + .endif +ELF .type \name, STT_FUNC + .func \name +\name: +.endm + +func png_read_filter_row_sub4_neon, export=1 + ldr r3, [r0, #4] @ rowbytes + vmov.i8 d3, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vadd.u8 d0, d3, d4 + vadd.u8 d1, d0, d5 + vadd.u8 d2, d1, d6 + vadd.u8 d3, d2, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r3, r3, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_sub3_neon, export=1 + ldr r3, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + mov r0, r1 + mov r2, #3 + mov r12, #12 + vld1.8 {q11}, [r0], r12 +1: + vext.8 d5, d22, d23, #3 + vadd.u8 d0, d3, d22 + vext.8 d6, d22, d23, #6 + vadd.u8 d1, d0, d5 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], r12 + vst1.32 {d0[0]}, [r1,:32], r2 + vadd.u8 d2, d1, d6 + vst1.32 {d1[0]}, [r1], r2 + vadd.u8 d3, d2, d7 + vst1.32 {d2[0]}, [r1], r2 + vst1.32 {d3[0]}, [r1], r2 + subs r3, r3, #12 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_up_neon, export=1 + ldr r3, [r0, #4] @ rowbytes +1: + vld1.8 {q0}, [r1,:128] + vld1.8 {q1}, [r2,:128]! + vadd.u8 q0, q0, q1 + vst1.8 {q0}, [r1,:128]! + subs r3, r3, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_avg4_neon, export=1 + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]! + vhadd.u8 d0, d3, d16 + vadd.u8 d0, d0, d4 + vhadd.u8 d1, d0, d17 + vadd.u8 d1, d1, d5 + vhadd.u8 d2, d1, d18 + vadd.u8 d2, d2, d6 + vhadd.u8 d3, d2, d19 + vadd.u8 d3, d3, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r12, r12, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_avg3_neon, export=1 + push {r4,lr} + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + mov r0, r1 + mov r4, #3 + mov lr, #12 + vld1.8 {q11}, [r0], lr +1: + vld1.8 {q10}, [r2], lr + vext.8 d5, d22, d23, #3 + vhadd.u8 d0, d3, d20 + vext.8 d17, d20, d21, #3 + vadd.u8 d0, d0, d22 + vext.8 d6, d22, d23, #6 + vhadd.u8 d1, d0, d17 + vext.8 d18, d20, d21, #6 + vadd.u8 d1, d1, d5 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], lr + vst1.32 {d0[0]}, [r1,:32], r4 + vhadd.u8 d2, d1, d18 + vst1.32 {d1[0]}, [r1], r4 + vext.8 d19, d21, d21, #1 + vadd.u8 d2, d2, d6 + vhadd.u8 d3, d2, d19 + vst1.32 {d2[0]}, [r1], r4 + vadd.u8 d3, d3, d7 + vst1.32 {d3[0]}, [r1], r4 + subs r12, r12, #12 + bgt 1b + + pop {r4,pc} +endfunc + +.macro paeth rx, ra, rb, rc + vaddl.u8 q12, \ra, \rb @ a + b + vaddl.u8 q15, \rc, \rc @ 2*c + vabdl.u8 q13, \rb, \rc @ pa + vabdl.u8 q14, \ra, \rc @ pb + vabd.u16 q15, q12, q15 @ pc + vcle.u16 q12, q13, q14 @ pa <= pb + vcle.u16 q13, q13, q15 @ pa <= pc + vcle.u16 q14, q14, q15 @ pb <= pc + vand q12, q12, q13 @ pa <= pb && pa <= pc + vmovn.u16 d28, q14 + vmovn.u16 \rx, q12 + vbsl d28, \rb, \rc + vbsl \rx, \ra, d28 +.endm + +func png_read_filter_row_paeth4_neon, export=1 + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + vmov.i8 d20, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]! + paeth d0, d3, d16, d20 + vadd.u8 d0, d0, d4 + paeth d1, d0, d17, d16 + vadd.u8 d1, d1, d5 + paeth d2, d1, d18, d17 + vadd.u8 d2, d2, d6 + paeth d3, d2, d19, d18 + vmov d20, d19 + vadd.u8 d3, d3, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r12, r12, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_paeth3_neon, export=1 + push {r4,lr} + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + vmov.i8 d4, #0 + mov r0, r1 + mov r4, #3 + mov lr, #12 + vld1.8 {q11}, [r0], lr +1: + vld1.8 {q10}, [r2], lr + paeth d0, d3, d20, d4 + vext.8 d5, d22, d23, #3 + vadd.u8 d0, d0, d22 + vext.8 d17, d20, d21, #3 + paeth d1, d0, d17, d20 + vst1.32 {d0[0]}, [r1,:32], r4 + vext.8 d6, d22, d23, #6 + vadd.u8 d1, d1, d5 + vext.8 d18, d20, d21, #6 + paeth d2, d1, d18, d17 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], lr + vst1.32 {d1[0]}, [r1], r4 + vadd.u8 d2, d2, d6 + vext.8 d19, d21, d21, #1 + paeth d3, d2, d19, d18 + vst1.32 {d2[0]}, [r1], r4 + vmov d4, d19 + vadd.u8 d3, d3, d7 + vst1.32 {d3[0]}, [r1], r4 + subs r12, r12, #12 + bgt 1b + + pop {r4,pc} +endfunc +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */ +#endif /* READ */ diff --git a/xs/src/png/libpng/arm/filter_neon_intrinsics.c b/xs/src/png/libpng/arm/filter_neon_intrinsics.c new file mode 100644 index 0000000000..ea7e356bcc --- /dev/null +++ b/xs/src/png/libpng/arm/filter_neon_intrinsics.c @@ -0,0 +1,387 @@ + +/* filter_neon_intrinsics.c - NEON optimised filter functions + * + * Copyright (c) 2014,2016 Glenn Randers-Pehrson + * Written by James Yu , October 2013. + * Based on filter_neon.S, written by Mans Rullgard, 2011. + * + * Last changed in libpng 1.6.22 [May 26, 2016] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +/* This code requires -mfpu=neon on the command line: */ +#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */ + +#include + +/* libpng row pointers are not necessarily aligned to any particular boundary, + * however this code will only work with appropriate alignment. arm/arm_init.c + * checks for this (and will not compile unless it is done). This code uses + * variants of png_aligncast to avoid compiler warnings. + */ +#define png_ptr(type,pointer) png_aligncast(type *,pointer) +#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer) + +/* The following relies on a variable 'temp_pointer' being declared with type + * 'type'. This is written this way just to hide the GCC strict aliasing + * warning; note that the code is safe because there never is an alias between + * the input and output pointers. + */ +#define png_ldr(type,pointer)\ + (temp_pointer = png_ptr(type,pointer), *temp_pointer) + +#if PNG_ARM_NEON_OPT > 0 + +void +png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + png_debug(1, "in png_read_filter_row_up_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint8x16_t qrp, qpp; + + qrp = vld1q_u8(rp); + qpp = vld1q_u8(pp); + qrp = vaddq_u8(qrp, qpp); + vst1q_u8(rp, qrp); + } +} + +void +png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp = vld1q_u8(rp); + uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp); + uint8x8x2_t vrp = *vrpt; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_sub3_neon"); + + for (; rp < rp_stop;) + { + uint8x8_t vtmp1, vtmp2; + uint32x2_t *temp_pointer; + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]); + vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6); + vdest.val[1] = vadd_u8(vdest.val[0], vtmp1); + + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + vdest.val[2] = vadd_u8(vdest.val[1], vtmp2); + vdest.val[3] = vadd_u8(vdest.val[2], vtmp1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t, &vtmp); + vrp = *vrpt; + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } + + PNG_UNUSED(prev_row) +} + +void +png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_sub4_neon"); + + for (; rp < rp_stop; rp += 16) + { + uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp)); + uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp); + uint8x8x4_t vrp = *vrpt; + uint32x2x4_t *temp_pointer; + + vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]); + vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]); + vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]); + vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0); + } + + PNG_UNUSED(prev_row) +} + +void +png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_const_bytep pp = prev_row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp; + uint8x8x2_t *vrpt; + uint8x8x2_t vrp; + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + vtmp = vld1q_u8(rp); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + png_debug(1, "in png_read_filter_row_avg3_neon"); + + for (; rp < rp_stop; pp += 12) + { + uint8x8_t vtmp1, vtmp2, vtmp3; + + uint8x8x2_t *vppt; + uint8x8x2_t vpp; + + uint32x2_t *temp_pointer; + + vtmp = vld1q_u8(pp); + vppt = png_ptr(uint8x8x2_t,&vtmp); + vpp = *vppt; + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3); + vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6); + vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2); + vdest.val[1] = vadd_u8(vdest.val[1], vtmp1); + + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6); + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2); + vdest.val[2] = vadd_u8(vdest.val[2], vtmp3); + + vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1); + + vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2); + vdest.val[3] = vadd_u8(vdest.val[3], vtmp1); + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } +} + +void +png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_avg4_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint32x2x4_t vtmp; + uint8x8x4_t *vrpt, *vppt; + uint8x8x4_t vrp, vpp; + uint32x2x4_t *temp_pointer; + + vtmp = vld4_u32(png_ptr(uint32_t,rp)); + vrpt = png_ptr(uint8x8x4_t,&vtmp); + vrp = *vrpt; + vtmp = vld4_u32(png_ptrc(uint32_t,pp)); + vppt = png_ptr(uint8x8x4_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]); + vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]); + vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]); + vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]); + vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]); + vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]); + + vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0); + } +} + +static uint8x8_t +paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c) +{ + uint8x8_t d, e; + uint16x8_t p1, pa, pb, pc; + + p1 = vaddl_u8(a, b); /* a + b */ + pc = vaddl_u8(c, c); /* c * 2 */ + pa = vabdl_u8(b, c); /* pa */ + pb = vabdl_u8(a, c); /* pb */ + pc = vabdq_u16(p1, pc); /* pc */ + + p1 = vcleq_u16(pa, pb); /* pa <= pb */ + pa = vcleq_u16(pa, pc); /* pa <= pc */ + pb = vcleq_u16(pb, pc); /* pb <= pc */ + + p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */ + + d = vmovn_u16(pb); + e = vmovn_u16(p1); + + d = vbsl_u8(d, b, c); + e = vbsl_u8(e, a, d); + + return e; +} + +void +png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_const_bytep pp = prev_row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp; + uint8x8x2_t *vrpt; + uint8x8x2_t vrp; + uint8x8_t vlast = vdup_n_u8(0); + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + vtmp = vld1q_u8(rp); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + png_debug(1, "in png_read_filter_row_paeth3_neon"); + + for (; rp < rp_stop; pp += 12) + { + uint8x8x2_t *vppt; + uint8x8x2_t vpp; + uint8x8_t vtmp1, vtmp2, vtmp3; + uint32x2_t *temp_pointer; + + vtmp = vld1q_u8(pp); + vppt = png_ptr(uint8x8x2_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3); + vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[1], vtmp1); + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6); + vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6); + vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2); + vdest.val[2] = vadd_u8(vdest.val[2], vtmp1); + + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3); + vdest.val[3] = vadd_u8(vdest.val[3], vtmp1); + + vlast = vtmp2; + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } +} + +void +png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + uint8x8_t vlast = vdup_n_u8(0); + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_paeth4_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint32x2x4_t vtmp; + uint8x8x4_t *vrpt, *vppt; + uint8x8x4_t vrp, vpp; + uint32x2x4_t *temp_pointer; + + vtmp = vld4_u32(png_ptr(uint32_t,rp)); + vrpt = png_ptr(uint8x8x4_t,&vtmp); + vrp = *vrpt; + vtmp = vld4_u32(png_ptrc(uint32_t,pp)); + vppt = png_ptr(uint8x8x4_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]); + vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]); + vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]); + vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]); + vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]); + + vlast = vpp.val[3]; + + vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0); + } +} + +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */ +#endif /* READ */ diff --git a/xs/src/png/libpng/intel/filter_sse2_intrinsics.c b/xs/src/png/libpng/intel/filter_sse2_intrinsics.c new file mode 100644 index 0000000000..5e8553fbb9 --- /dev/null +++ b/xs/src/png/libpng/intel/filter_sse2_intrinsics.c @@ -0,0 +1,406 @@ + +/* filter_sse2_intrinsics.c - SSE2 optimized filter functions + * + * Copyright (c) 2016-2017 Glenn Randers-Pehrson + * Written by Mike Klein and Matt Sarett + * Derived from arm/filter_neon_intrinsics.c + * + * Last changed in libpng 1.6.31 [July 27, 2017] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +#if PNG_INTEL_SSE_IMPLEMENTATION > 0 + +#include + +/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d). + * They're positioned like this: + * prev: c b + * row: a d + * The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be + * whichever of a, b, or c is closest to p=a+b-c. + */ + +static __m128i load4(const void* p) { + return _mm_cvtsi32_si128(*(const int*)p); +} + +static void store4(void* p, __m128i v) { + *(int*)p = _mm_cvtsi128_si32(v); +} + +static __m128i load3(const void* p) { + /* We'll load 2 bytes, then 1 byte, + * then mask them together, and finally load into SSE. + */ + const png_uint_16* p01 = (png_const_uint_16p)p; + const png_byte* p2 = (const png_byte*)(p01+1); + + png_uint_32 v012 = (png_uint_32)(*p01) + | (png_uint_32)(*p2) << 16; + return load4(&v012); +} + +static void store3(void* p, __m128i v) { + /* We'll pull from SSE as a 32-bit int, then write + * its bottom two bytes, then its third byte. + */ + png_uint_32 v012; + png_uint_16* p01; + png_byte* p2; + + store4(&v012, v); + + p01 = (png_uint_16p)p; + p2 = (png_byte*)(p01+1); + *p01 = (png_uint_16)v012; + *p2 = (png_byte)(v012 >> 16); +} + +void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row, + png_const_bytep prev) +{ + /* The Sub filter predicts each pixel as the previous pixel, a. + * There is no pixel to the left of the first pixel. It's encoded directly. + * That works with our main loop if we just say that left pixel was zero. + */ + png_size_t rb; + + __m128i a, d = _mm_setzero_si128(); + + png_debug(1, "in png_read_filter_row_sub3_sse2"); + + rb = row_info->rowbytes; + while (rb >= 4) { + a = d; d = load4(row); + d = _mm_add_epi8(d, a); + store3(row, d); + + row += 3; + rb -= 3; + } + if (rb > 0) { + a = d; d = load3(row); + d = _mm_add_epi8(d, a); + store3(row, d); + + row += 3; + rb -= 3; + } + PNG_UNUSED(prev) +} + +void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row, + png_const_bytep prev) +{ + /* The Sub filter predicts each pixel as the previous pixel, a. + * There is no pixel to the left of the first pixel. It's encoded directly. + * That works with our main loop if we just say that left pixel was zero. + */ + png_size_t rb; + + __m128i a, d = _mm_setzero_si128(); + + png_debug(1, "in png_read_filter_row_sub4_sse2"); + + rb = row_info->rowbytes+4; + while (rb > 4) { + a = d; d = load4(row); + d = _mm_add_epi8(d, a); + store4(row, d); + + row += 4; + rb -= 4; + } + PNG_UNUSED(prev) +} + +void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row, + png_const_bytep prev) +{ + /* The Avg filter predicts each pixel as the (truncated) average of a and b. + * There's no pixel to the left of the first pixel. Luckily, it's + * predicted to be half of the pixel above it. So again, this works + * perfectly with our loop if we make sure a starts at zero. + */ + + png_size_t rb; + + const __m128i zero = _mm_setzero_si128(); + + __m128i b; + __m128i a, d = zero; + + png_debug(1, "in png_read_filter_row_avg3_sse2"); + rb = row_info->rowbytes; + while (rb >= 4) { + __m128i avg; + b = load4(prev); + a = d; d = load4(row ); + + /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */ + avg = _mm_avg_epu8(a,b); + /* ...but we can fix it up by subtracting off 1 if it rounded up. */ + avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b), + _mm_set1_epi8(1))); + d = _mm_add_epi8(d, avg); + store3(row, d); + + prev += 3; + row += 3; + rb -= 3; + } + if (rb > 0) { + __m128i avg; + b = load3(prev); + a = d; d = load3(row ); + + /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */ + avg = _mm_avg_epu8(a,b); + /* ...but we can fix it up by subtracting off 1 if it rounded up. */ + avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b), + _mm_set1_epi8(1))); + + d = _mm_add_epi8(d, avg); + store3(row, d); + + prev += 3; + row += 3; + rb -= 3; + } +} + +void png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row, + png_const_bytep prev) +{ + /* The Avg filter predicts each pixel as the (truncated) average of a and b. + * There's no pixel to the left of the first pixel. Luckily, it's + * predicted to be half of the pixel above it. So again, this works + * perfectly with our loop if we make sure a starts at zero. + */ + png_size_t rb; + const __m128i zero = _mm_setzero_si128(); + __m128i b; + __m128i a, d = zero; + + png_debug(1, "in png_read_filter_row_avg4_sse2"); + + rb = row_info->rowbytes+4; + while (rb > 4) { + __m128i avg; + b = load4(prev); + a = d; d = load4(row ); + + /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */ + avg = _mm_avg_epu8(a,b); + /* ...but we can fix it up by subtracting off 1 if it rounded up. */ + avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b), + _mm_set1_epi8(1))); + + d = _mm_add_epi8(d, avg); + store4(row, d); + + prev += 4; + row += 4; + rb -= 4; + } +} + +/* Returns |x| for 16-bit lanes. */ +static __m128i abs_i16(__m128i x) { +#if PNG_INTEL_SSE_IMPLEMENTATION >= 2 + return _mm_abs_epi16(x); +#else + /* Read this all as, return x<0 ? -x : x. + * To negate two's complement, you flip all the bits then add 1. + */ + __m128i is_negative = _mm_cmplt_epi16(x, _mm_setzero_si128()); + + /* Flip negative lanes. */ + x = _mm_xor_si128(x, is_negative); + + /* +1 to negative lanes, else +0. */ + x = _mm_sub_epi16(x, is_negative); + return x; +#endif +} + +/* Bytewise c ? t : e. */ +static __m128i if_then_else(__m128i c, __m128i t, __m128i e) { +#if PNG_INTEL_SSE_IMPLEMENTATION >= 3 + return _mm_blendv_epi8(e,t,c); +#else + return _mm_or_si128(_mm_and_si128(c, t), _mm_andnot_si128(c, e)); +#endif +} + +void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row, + png_const_bytep prev) +{ + /* Paeth tries to predict pixel d using the pixel to the left of it, a, + * and two pixels from the previous row, b and c: + * prev: c b + * row: a d + * The Paeth function predicts d to be whichever of a, b, or c is nearest to + * p=a+b-c. + * + * The first pixel has no left context, and so uses an Up filter, p = b. + * This works naturally with our main loop's p = a+b-c if we force a and c + * to zero. + * Here we zero b and d, which become c and a respectively at the start of + * the loop. + */ + png_size_t rb; + const __m128i zero = _mm_setzero_si128(); + __m128i c, b = zero, + a, d = zero; + + png_debug(1, "in png_read_filter_row_paeth3_sse2"); + + rb = row_info->rowbytes; + while (rb >= 4) { + /* It's easiest to do this math (particularly, deal with pc) with 16-bit + * intermediates. + */ + __m128i pa,pb,pc,smallest,nearest; + c = b; b = _mm_unpacklo_epi8(load4(prev), zero); + a = d; d = _mm_unpacklo_epi8(load4(row ), zero); + + /* (p-a) == (a+b-c - a) == (b-c) */ + + pa = _mm_sub_epi16(b,c); + + /* (p-b) == (a+b-c - b) == (a-c) */ + pb = _mm_sub_epi16(a,c); + + /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */ + pc = _mm_add_epi16(pa,pb); + + pa = abs_i16(pa); /* |p-a| */ + pb = abs_i16(pb); /* |p-b| */ + pc = abs_i16(pc); /* |p-c| */ + + smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb)); + + /* Paeth breaks ties favoring a over b over c. */ + nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a, + if_then_else(_mm_cmpeq_epi16(smallest, pb), b, + c)); + + /* Note `_epi8`: we need addition to wrap modulo 255. */ + d = _mm_add_epi8(d, nearest); + store3(row, _mm_packus_epi16(d,d)); + + prev += 3; + row += 3; + rb -= 3; + } + if (rb > 0) { + /* It's easiest to do this math (particularly, deal with pc) with 16-bit + * intermediates. + */ + __m128i pa,pb,pc,smallest,nearest; + c = b; b = _mm_unpacklo_epi8(load3(prev), zero); + a = d; d = _mm_unpacklo_epi8(load3(row ), zero); + + /* (p-a) == (a+b-c - a) == (b-c) */ + pa = _mm_sub_epi16(b,c); + + /* (p-b) == (a+b-c - b) == (a-c) */ + pb = _mm_sub_epi16(a,c); + + /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */ + pc = _mm_add_epi16(pa,pb); + + pa = abs_i16(pa); /* |p-a| */ + pb = abs_i16(pb); /* |p-b| */ + pc = abs_i16(pc); /* |p-c| */ + + smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb)); + + /* Paeth breaks ties favoring a over b over c. */ + nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a, + if_then_else(_mm_cmpeq_epi16(smallest, pb), b, + c)); + + /* Note `_epi8`: we need addition to wrap modulo 255. */ + d = _mm_add_epi8(d, nearest); + store3(row, _mm_packus_epi16(d,d)); + + prev += 3; + row += 3; + rb -= 3; + } +} + +void png_read_filter_row_paeth4_sse2(png_row_infop row_info, png_bytep row, + png_const_bytep prev) +{ + /* Paeth tries to predict pixel d using the pixel to the left of it, a, + * and two pixels from the previous row, b and c: + * prev: c b + * row: a d + * The Paeth function predicts d to be whichever of a, b, or c is nearest to + * p=a+b-c. + * + * The first pixel has no left context, and so uses an Up filter, p = b. + * This works naturally with our main loop's p = a+b-c if we force a and c + * to zero. + * Here we zero b and d, which become c and a respectively at the start of + * the loop. + */ + png_size_t rb; + const __m128i zero = _mm_setzero_si128(); + __m128i pa,pb,pc,smallest,nearest; + __m128i c, b = zero, + a, d = zero; + + png_debug(1, "in png_read_filter_row_paeth4_sse2"); + + rb = row_info->rowbytes+4; + while (rb > 4) { + /* It's easiest to do this math (particularly, deal with pc) with 16-bit + * intermediates. + */ + c = b; b = _mm_unpacklo_epi8(load4(prev), zero); + a = d; d = _mm_unpacklo_epi8(load4(row ), zero); + + /* (p-a) == (a+b-c - a) == (b-c) */ + pa = _mm_sub_epi16(b,c); + + /* (p-b) == (a+b-c - b) == (a-c) */ + pb = _mm_sub_epi16(a,c); + + /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */ + pc = _mm_add_epi16(pa,pb); + + pa = abs_i16(pa); /* |p-a| */ + pb = abs_i16(pb); /* |p-b| */ + pc = abs_i16(pc); /* |p-c| */ + + smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb)); + + /* Paeth breaks ties favoring a over b over c. */ + nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a, + if_then_else(_mm_cmpeq_epi16(smallest, pb), b, + c)); + + /* Note `_epi8`: we need addition to wrap modulo 255. */ + d = _mm_add_epi8(d, nearest); + store4(row, _mm_packus_epi16(d,d)); + + prev += 4; + row += 4; + rb -= 4; + } +} + +#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */ +#endif /* READ */ diff --git a/xs/src/png/libpng/intel/intel_init.c b/xs/src/png/libpng/intel/intel_init.c new file mode 100644 index 0000000000..8f08baf8c5 --- /dev/null +++ b/xs/src/png/libpng/intel/intel_init.c @@ -0,0 +1,53 @@ + +/* intel_init.c - SSE2 optimized filter functions + * + * Copyright (c) 2016-2017 Glenn Randers-Pehrson + * Written by Mike Klein and Matt Sarett, Google, Inc. + * Derived from arm/arm_init.c + * + * Last changed in libpng 1.6.29 [March 16, 2017] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED +#if PNG_INTEL_SSE_IMPLEMENTATION > 0 + +void +png_init_filter_functions_sse2(png_structp pp, unsigned int bpp) +{ + /* The techniques used to implement each of these filters in SSE operate on + * one pixel at a time. + * So they generally speed up 3bpp images about 3x, 4bpp images about 4x. + * They can scale up to 6 and 8 bpp images and down to 2 bpp images, + * but they'd not likely have any benefit for 1bpp images. + * Most of these can be implemented using only MMX and 64-bit registers, + * but they end up a bit slower than using the equally-ubiquitous SSE2. + */ + png_debug(1, "in png_init_filter_functions_sse2"); + if (bpp == 3) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_sse2; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_sse2; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth3_sse2; + } + else if (bpp == 4) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_sse2; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_sse2; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth4_sse2; + } + + /* No need optimize PNG_FILTER_VALUE_UP. The compiler should + * autovectorize. + */ +} + +#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */ +#endif /* PNG_READ_SUPPORTED */ diff --git a/xs/src/png/libpng/mips/filter_msa_intrinsics.c b/xs/src/png/libpng/mips/filter_msa_intrinsics.c new file mode 100644 index 0000000000..943bb3d052 --- /dev/null +++ b/xs/src/png/libpng/mips/filter_msa_intrinsics.c @@ -0,0 +1,807 @@ + +/* filter_msa_intrinsics.c - MSA optimised filter functions + * + * Copyright (c) 2016 Glenn Randers-Pehrson + * Written by Mandar Sahastrabuddhe, August 2016. + * Last changed in libpng 1.6.25 [September 1, 2016] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ +#include +#include +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +/* This code requires -mfpu=msa on the command line: */ +#if PNG_MIPS_MSA_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */ + +#include + +/* libpng row pointers are not necessarily aligned to any particular boundary, + * however this code will only work with appropriate alignment. mips/mips_init.c + * checks for this (and will not compile unless it is done). This code uses + * variants of png_aligncast to avoid compiler warnings. + */ +#define png_ptr(type,pointer) png_aligncast(type *,pointer) +#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer) + +/* The following relies on a variable 'temp_pointer' being declared with type + * 'type'. This is written this way just to hide the GCC strict aliasing + * warning; note that the code is safe because there never is an alias between + * the input and output pointers. + */ +#define png_ldr(type,pointer)\ + (temp_pointer = png_ptr(type,pointer), *temp_pointer) + +#if PNG_MIPS_MSA_OPT > 0 + +#ifdef CLANG_BUILD + #define MSA_SRLI_B(a, b) __msa_srli_b((v16i8) a, b) + + #define LW(psrc) \ + ( { \ + uint8_t *psrc_lw_m = (uint8_t *) (psrc); \ + uint32_t val_m; \ + \ + asm volatile ( \ + "lw %[val_m], %[psrc_lw_m] \n\t" \ + \ + : [val_m] "=r" (val_m) \ + : [psrc_lw_m] "m" (*psrc_lw_m) \ + ); \ + \ + val_m; \ + } ) + + #define SH(val, pdst) \ + { \ + uint8_t *pdst_sh_m = (uint8_t *) (pdst); \ + uint16_t val_m = (val); \ + \ + asm volatile ( \ + "sh %[val_m], %[pdst_sh_m] \n\t" \ + \ + : [pdst_sh_m] "=m" (*pdst_sh_m) \ + : [val_m] "r" (val_m) \ + ); \ + } + + #define SW(val, pdst) \ + { \ + uint8_t *pdst_sw_m = (uint8_t *) (pdst); \ + uint32_t val_m = (val); \ + \ + asm volatile ( \ + "sw %[val_m], %[pdst_sw_m] \n\t" \ + \ + : [pdst_sw_m] "=m" (*pdst_sw_m) \ + : [val_m] "r" (val_m) \ + ); \ + } + + #if (__mips == 64) + #define SD(val, pdst) \ + { \ + uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ + uint64_t val_m = (val); \ + \ + asm volatile ( \ + "sd %[val_m], %[pdst_sd_m] \n\t" \ + \ + : [pdst_sd_m] "=m" (*pdst_sd_m) \ + : [val_m] "r" (val_m) \ + ); \ + } + #else + #define SD(val, pdst) \ + { \ + uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ + uint32_t val0_m, val1_m; \ + \ + val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \ + val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \ + \ + SW(val0_m, pdst_sd_m); \ + SW(val1_m, pdst_sd_m + 4); \ + } + #endif +#else + #define MSA_SRLI_B(a, b) (a >> b) + +#if (__mips_isa_rev >= 6) + #define LW(psrc) \ + ( { \ + uint8_t *psrc_lw_m = (uint8_t *) (psrc); \ + uint32_t val_m; \ + \ + asm volatile ( \ + "lw %[val_m], %[psrc_lw_m] \n\t" \ + \ + : [val_m] "=r" (val_m) \ + : [psrc_lw_m] "m" (*psrc_lw_m) \ + ); \ + \ + val_m; \ + } ) + + #define SH(val, pdst) \ + { \ + uint8_t *pdst_sh_m = (uint8_t *) (pdst); \ + uint16_t val_m = (val); \ + \ + asm volatile ( \ + "sh %[val_m], %[pdst_sh_m] \n\t" \ + \ + : [pdst_sh_m] "=m" (*pdst_sh_m) \ + : [val_m] "r" (val_m) \ + ); \ + } + + #define SW(val, pdst) \ + { \ + uint8_t *pdst_sw_m = (uint8_t *) (pdst); \ + uint32_t val_m = (val); \ + \ + asm volatile ( \ + "sw %[val_m], %[pdst_sw_m] \n\t" \ + \ + : [pdst_sw_m] "=m" (*pdst_sw_m) \ + : [val_m] "r" (val_m) \ + ); \ + } + + #if (__mips == 64) + #define SD(val, pdst) \ + { \ + uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ + uint64_t val_m = (val); \ + \ + asm volatile ( \ + "sd %[val_m], %[pdst_sd_m] \n\t" \ + \ + : [pdst_sd_m] "=m" (*pdst_sd_m) \ + : [val_m] "r" (val_m) \ + ); \ + } + #else + #define SD(val, pdst) \ + { \ + uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ + uint32_t val0_m, val1_m; \ + \ + val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \ + val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \ + \ + SW(val0_m, pdst_sd_m); \ + SW(val1_m, pdst_sd_m + 4); \ + } + #endif +#else // !(__mips_isa_rev >= 6) + #define LW(psrc) \ + ( { \ + uint8_t *psrc_lw_m = (uint8_t *) (psrc); \ + uint32_t val_m; \ + \ + asm volatile ( \ + "ulw %[val_m], %[psrc_lw_m] \n\t" \ + \ + : [val_m] "=r" (val_m) \ + : [psrc_lw_m] "m" (*psrc_lw_m) \ + ); \ + \ + val_m; \ + } ) + + #define SH(val, pdst) \ + { \ + uint8_t *pdst_sh_m = (uint8_t *) (pdst); \ + uint16_t val_m = (val); \ + \ + asm volatile ( \ + "ush %[val_m], %[pdst_sh_m] \n\t" \ + \ + : [pdst_sh_m] "=m" (*pdst_sh_m) \ + : [val_m] "r" (val_m) \ + ); \ + } + + #define SW(val, pdst) \ + { \ + uint8_t *pdst_sw_m = (uint8_t *) (pdst); \ + uint32_t val_m = (val); \ + \ + asm volatile ( \ + "usw %[val_m], %[pdst_sw_m] \n\t" \ + \ + : [pdst_sw_m] "=m" (*pdst_sw_m) \ + : [val_m] "r" (val_m) \ + ); \ + } + + #define SD(val, pdst) \ + { \ + uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ + uint32_t val0_m, val1_m; \ + \ + val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \ + val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \ + \ + SW(val0_m, pdst_sd_m); \ + SW(val1_m, pdst_sd_m + 4); \ + } + + #define SW_ZERO(pdst) \ + { \ + uint8_t *pdst_m = (uint8_t *) (pdst); \ + \ + asm volatile ( \ + "usw $0, %[pdst_m] \n\t" \ + \ + : [pdst_m] "=m" (*pdst_m) \ + : \ + ); \ + } +#endif // (__mips_isa_rev >= 6) +#endif + +#define LD_B(RTYPE, psrc) *((RTYPE *) (psrc)) +#define LD_UB(...) LD_B(v16u8, __VA_ARGS__) +#define LD_B2(RTYPE, psrc, stride, out0, out1) \ +{ \ + out0 = LD_B(RTYPE, (psrc)); \ + out1 = LD_B(RTYPE, (psrc) + stride); \ +} +#define LD_UB2(...) LD_B2(v16u8, __VA_ARGS__) +#define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) \ +{ \ + LD_B2(RTYPE, (psrc), stride, out0, out1); \ + LD_B2(RTYPE, (psrc) + 2 * stride , stride, out2, out3); \ +} +#define LD_UB4(...) LD_B4(v16u8, __VA_ARGS__) + +#define ST_B(RTYPE, in, pdst) *((RTYPE *) (pdst)) = (in) +#define ST_UB(...) ST_B(v16u8, __VA_ARGS__) +#define ST_B2(RTYPE, in0, in1, pdst, stride) \ +{ \ + ST_B(RTYPE, in0, (pdst)); \ + ST_B(RTYPE, in1, (pdst) + stride); \ +} +#define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__) +#define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) \ +{ \ + ST_B2(RTYPE, in0, in1, (pdst), stride); \ + ST_B2(RTYPE, in2, in3, (pdst) + 2 * stride, stride); \ +} +#define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__) + +#define ADD2(in0, in1, in2, in3, out0, out1) \ +{ \ + out0 = in0 + in1; \ + out1 = in2 + in3; \ +} +#define ADD3(in0, in1, in2, in3, in4, in5, \ + out0, out1, out2) \ +{ \ + ADD2(in0, in1, in2, in3, out0, out1); \ + out2 = in4 + in5; \ +} +#define ADD4(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3) \ +{ \ + ADD2(in0, in1, in2, in3, out0, out1); \ + ADD2(in4, in5, in6, in7, out2, out3); \ +} + +#define ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_ilvr_b((v16i8) in0, (v16i8) in1); \ + out1 = (RTYPE) __msa_ilvr_b((v16i8) in2, (v16i8) in3); \ +} +#define ILVR_B2_SH(...) ILVR_B2(v8i16, __VA_ARGS__) + +#define HSUB_UB2(RTYPE, in0, in1, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_hsub_u_h((v16u8) in0, (v16u8) in0); \ + out1 = (RTYPE) __msa_hsub_u_h((v16u8) in1, (v16u8) in1); \ +} +#define HSUB_UB2_SH(...) HSUB_UB2(v8i16, __VA_ARGS__) + +#define SLDI_B2_0(RTYPE, in0, in1, out0, out1, slide_val) \ +{ \ + v16i8 zero_m = { 0 }; \ + out0 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in0, slide_val); \ + out1 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in1, slide_val); \ +} +#define SLDI_B2_0_UB(...) SLDI_B2_0(v16u8, __VA_ARGS__) + +#define SLDI_B3_0(RTYPE, in0, in1, in2, out0, out1, out2, slide_val) \ +{ \ + v16i8 zero_m = { 0 }; \ + SLDI_B2_0(RTYPE, in0, in1, out0, out1, slide_val); \ + out2 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in2, slide_val); \ +} +#define SLDI_B3_0_UB(...) SLDI_B3_0(v16u8, __VA_ARGS__) + +#define ILVEV_W2(RTYPE, in0, in1, in2, in3, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_ilvev_w((v4i32) in1, (v4i32) in0); \ + out1 = (RTYPE) __msa_ilvev_w((v4i32) in3, (v4i32) in2); \ +} +#define ILVEV_W2_UB(...) ILVEV_W2(v16u8, __VA_ARGS__) + +#define ADD_ABS_H3(RTYPE, in0, in1, in2, out0, out1, out2) \ +{ \ + RTYPE zero = {0}; \ + \ + out0 = __msa_add_a_h((v8i16) zero, in0); \ + out1 = __msa_add_a_h((v8i16) zero, in1); \ + out2 = __msa_add_a_h((v8i16) zero, in2); \ +} +#define ADD_ABS_H3_SH(...) ADD_ABS_H3(v8i16, __VA_ARGS__) + +#define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_vshf_b((v16i8) mask0, (v16i8) in1, (v16i8) in0); \ + out1 = (RTYPE) __msa_vshf_b((v16i8) mask1, (v16i8) in3, (v16i8) in2); \ +} +#define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__) + +#define CMP_AND_SELECT(inp0, inp1, inp2, inp3, inp4, inp5, out0) \ +{ \ + v8i16 _sel_h0, _sel_h1; \ + v16u8 _sel_b0, _sel_b1; \ + _sel_h0 = (v8i16) __msa_clt_u_h((v8u16) inp1, (v8u16) inp0); \ + _sel_b0 = (v16u8) __msa_pckev_b((v16i8) _sel_h0, (v16i8) _sel_h0); \ + inp0 = (v8i16) __msa_bmnz_v((v16u8) inp0, (v16u8) inp1, (v16u8) _sel_h0); \ + inp4 = (v16u8) __msa_bmnz_v(inp3, inp4, _sel_b0); \ + _sel_h1 = (v8i16) __msa_clt_u_h((v8u16) inp2, (v8u16) inp0); \ + _sel_b1 = (v16u8) __msa_pckev_b((v16i8) _sel_h1, (v16i8) _sel_h1); \ + inp4 = (v16u8) __msa_bmnz_v(inp4, inp5, _sel_b1); \ + out0 += inp4; \ +} + +void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i, cnt, cnt16, cnt32; + png_size_t istop = row_info->rowbytes; + png_bytep rp = row; + png_const_bytep pp = prev_row; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + for (i = 0; i < (istop >> 6); i++) + { + LD_UB4(rp, 16, src0, src1, src2, src3); + LD_UB4(pp, 16, src4, src5, src6, src7); + pp += 64; + + ADD4(src0, src4, src1, src5, src2, src6, src3, src7, + src0, src1, src2, src3); + + ST_UB4(src0, src1, src2, src3, rp, 16); + rp += 64; + } + + if (istop & 0x3F) + { + cnt32 = istop & 0x20; + cnt16 = istop & 0x10; + cnt = istop & 0xF; + + if(cnt32) + { + if (cnt16 && cnt) + { + LD_UB4(rp, 16, src0, src1, src2, src3); + LD_UB4(pp, 16, src4, src5, src6, src7); + + ADD4(src0, src4, src1, src5, src2, src6, src3, src7, + src0, src1, src2, src3); + + ST_UB4(src0, src1, src2, src3, rp, 16); + rp += 64; + } + else if (cnt16 || cnt) + { + LD_UB2(rp, 16, src0, src1); + LD_UB2(pp, 16, src4, src5); + pp += 32; + src2 = LD_UB(rp + 32); + src6 = LD_UB(pp); + + ADD3(src0, src4, src1, src5, src2, src6, src0, src1, src2); + + ST_UB2(src0, src1, rp, 16); + rp += 32; + ST_UB(src2, rp); + rp += 16; + } + else + { + LD_UB2(rp, 16, src0, src1); + LD_UB2(pp, 16, src4, src5); + + ADD2(src0, src4, src1, src5, src0, src1); + + ST_UB2(src0, src1, rp, 16); + rp += 32; + } + } + else if (cnt16 && cnt) + { + LD_UB2(rp, 16, src0, src1); + LD_UB2(pp, 16, src4, src5); + + ADD2(src0, src4, src1, src5, src0, src1); + + ST_UB2(src0, src1, rp, 16); + rp += 32; + } + else if (cnt16 || cnt) + { + src0 = LD_UB(rp); + src4 = LD_UB(pp); + pp += 16; + + src0 += src4; + + ST_UB(src0, rp); + rp += 16; + } + } +} + +void png_read_filter_row_sub4_msa(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t count; + png_size_t istop = row_info->rowbytes; + png_bytep src = row; + png_bytep nxt = row + 4; + int32_t inp0; + v16u8 src0, src1, src2, src3, src4; + v16u8 dst0, dst1; + v16u8 zero = { 0 }; + + istop -= 4; + + inp0 = LW(src); + src += 4; + src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0); + + for (count = 0; count < istop; count += 16) + { + src1 = LD_UB(src); + src += 16; + + src2 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 4); + src3 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 8); + src4 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 12); + src1 += src0; + src2 += src1; + src3 += src2; + src4 += src3; + src0 = src4; + ILVEV_W2_UB(src1, src2, src3, src4, dst0, dst1); + dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0); + + ST_UB(dst0, nxt); + nxt += 16; + } +} + +void png_read_filter_row_sub3_msa(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t count; + png_size_t istop = row_info->rowbytes; + png_bytep src = row; + png_bytep nxt = row + 3; + int64_t out0; + int32_t inp0, out1; + v16u8 src0, src1, src2, src3, src4, dst0, dst1; + v16u8 zero = { 0 }; + v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 }; + + istop -= 3; + + inp0 = LW(src); + src += 3; + src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0); + + for (count = 0; count < istop; count += 12) + { + src1 = LD_UB(src); + src += 12; + + src2 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 3); + src3 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 6); + src4 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 9); + src1 += src0; + src2 += src1; + src3 += src2; + src4 += src3; + src0 = src4; + VSHF_B2_UB(src1, src2, src3, src4, mask0, mask0, dst0, dst1); + dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0); + out0 = __msa_copy_s_d((v2i64) dst0, 0); + out1 = __msa_copy_s_w((v4i32) dst0, 2); + + SD(out0, nxt); + nxt += 8; + SW(out1, nxt); + nxt += 4; + } +} + +void png_read_filter_row_avg4_msa(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i; + png_bytep src = row; + png_bytep nxt = row; + png_const_bytep pp = prev_row; + png_size_t istop = row_info->rowbytes - 4; + int32_t inp0, inp1, out0; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1; + v16u8 zero = { 0 }; + + inp0 = LW(pp); + pp += 4; + inp1 = LW(src); + src += 4; + src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0); + src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1); + src0 = (v16u8) MSA_SRLI_B(src0, 1); + src1 += src0; + out0 = __msa_copy_s_w((v4i32) src1, 0); + SW(out0, nxt); + nxt += 4; + + for (i = 0; i < istop; i += 16) + { + src2 = LD_UB(pp); + pp += 16; + src6 = LD_UB(src); + src += 16; + + SLDI_B2_0_UB(src2, src6, src3, src7, 4); + SLDI_B2_0_UB(src2, src6, src4, src8, 8); + SLDI_B2_0_UB(src2, src6, src5, src9, 12); + src2 = __msa_ave_u_b(src2, src1); + src6 += src2; + src3 = __msa_ave_u_b(src3, src6); + src7 += src3; + src4 = __msa_ave_u_b(src4, src7); + src8 += src4; + src5 = __msa_ave_u_b(src5, src8); + src9 += src5; + src1 = src9; + ILVEV_W2_UB(src6, src7, src8, src9, dst0, dst1); + dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0); + + ST_UB(dst0, nxt); + nxt += 16; + } +} + +void png_read_filter_row_avg3_msa(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i; + png_bytep src = row; + png_bytep nxt = row; + png_const_bytep pp = prev_row; + png_size_t istop = row_info->rowbytes - 3; + int64_t out0; + int32_t inp0, inp1, out1; + int16_t out2; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1; + v16u8 zero = { 0 }; + v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 }; + + inp0 = LW(pp); + pp += 3; + inp1 = LW(src); + src += 3; + src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0); + src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1); + src0 = (v16u8) MSA_SRLI_B(src0, 1); + src1 += src0; + out2 = __msa_copy_s_h((v8i16) src1, 0); + SH(out2, nxt); + nxt += 2; + nxt[0] = src1[2]; + nxt++; + + for (i = 0; i < istop; i += 12) + { + src2 = LD_UB(pp); + pp += 12; + src6 = LD_UB(src); + src += 12; + + SLDI_B2_0_UB(src2, src6, src3, src7, 3); + SLDI_B2_0_UB(src2, src6, src4, src8, 6); + SLDI_B2_0_UB(src2, src6, src5, src9, 9); + src2 = __msa_ave_u_b(src2, src1); + src6 += src2; + src3 = __msa_ave_u_b(src3, src6); + src7 += src3; + src4 = __msa_ave_u_b(src4, src7); + src8 += src4; + src5 = __msa_ave_u_b(src5, src8); + src9 += src5; + src1 = src9; + VSHF_B2_UB(src6, src7, src8, src9, mask0, mask0, dst0, dst1); + dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0); + out0 = __msa_copy_s_d((v2i64) dst0, 0); + out1 = __msa_copy_s_w((v4i32) dst0, 2); + + SD(out0, nxt); + nxt += 8; + SW(out1, nxt); + nxt += 4; + } +} + +void png_read_filter_row_paeth4_msa(png_row_infop row_info, + png_bytep row, + png_const_bytep prev_row) +{ + int32_t count, rp_end; + png_bytep nxt; + png_const_bytep prev_nxt; + int32_t inp0, inp1, res0; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9; + v16u8 src10, src11, src12, src13, dst0, dst1; + v8i16 vec0, vec1, vec2; + v16u8 zero = { 0 }; + + nxt = row; + prev_nxt = prev_row; + + inp0 = LW(nxt); + inp1 = LW(prev_nxt); + prev_nxt += 4; + src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0); + src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1); + + src1 += src0; + res0 = __msa_copy_s_w((v4i32) src1, 0); + + SW(res0, nxt); + nxt += 4; + + /* Remainder */ + rp_end = row_info->rowbytes - 4; + + for (count = 0; count < rp_end; count += 16) + { + src2 = LD_UB(prev_nxt); + prev_nxt += 16; + src6 = LD_UB(prev_row); + prev_row += 16; + src10 = LD_UB(nxt); + + SLDI_B3_0_UB(src2, src6, src10, src3, src7, src11, 4); + SLDI_B3_0_UB(src2, src6, src10, src4, src8, src12, 8); + SLDI_B3_0_UB(src2, src6, src10, src5, src9, src13, 12); + ILVR_B2_SH(src2, src6, src1, src6, vec0, vec1); + HSUB_UB2_SH(vec0, vec1, vec0, vec1); + vec2 = vec0 + vec1; + ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2); + CMP_AND_SELECT(vec0, vec1, vec2, src1, src2, src6, src10); + ILVR_B2_SH(src3, src7, src10, src7, vec0, vec1); + HSUB_UB2_SH(vec0, vec1, vec0, vec1); + vec2 = vec0 + vec1; + ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2); + CMP_AND_SELECT(vec0, vec1, vec2, src10, src3, src7, src11); + ILVR_B2_SH(src4, src8, src11, src8, vec0, vec1); + HSUB_UB2_SH(vec0, vec1, vec0, vec1); + vec2 = vec0 + vec1; + ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2); + CMP_AND_SELECT(vec0, vec1, vec2, src11, src4, src8, src12); + ILVR_B2_SH(src5, src9, src12, src9, vec0, vec1); + HSUB_UB2_SH(vec0, vec1, vec0, vec1); + vec2 = vec0 + vec1; + ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2); + CMP_AND_SELECT(vec0, vec1, vec2, src12, src5, src9, src13); + src1 = src13; + ILVEV_W2_UB(src10, src11, src12, src1, dst0, dst1); + dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0); + + ST_UB(dst0, nxt); + nxt += 16; + } +} + +void png_read_filter_row_paeth3_msa(png_row_infop row_info, + png_bytep row, + png_const_bytep prev_row) +{ + int32_t count, rp_end; + png_bytep nxt; + png_const_bytep prev_nxt; + int64_t out0; + int32_t inp0, inp1, out1; + int16_t out2; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1; + v16u8 src10, src11, src12, src13; + v8i16 vec0, vec1, vec2; + v16u8 zero = { 0 }; + v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 }; + + nxt = row; + prev_nxt = prev_row; + + inp0 = LW(nxt); + inp1 = LW(prev_nxt); + prev_nxt += 3; + src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0); + src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1); + + src1 += src0; + out2 = __msa_copy_s_h((v8i16) src1, 0); + + SH(out2, nxt); + nxt += 2; + nxt[0] = src1[2]; + nxt++; + + /* Remainder */ + rp_end = row_info->rowbytes - 3; + + for (count = 0; count < rp_end; count += 12) + { + src2 = LD_UB(prev_nxt); + prev_nxt += 12; + src6 = LD_UB(prev_row); + prev_row += 12; + src10 = LD_UB(nxt); + + SLDI_B3_0_UB(src2, src6, src10, src3, src7, src11, 3); + SLDI_B3_0_UB(src2, src6, src10, src4, src8, src12, 6); + SLDI_B3_0_UB(src2, src6, src10, src5, src9, src13, 9); + ILVR_B2_SH(src2, src6, src1, src6, vec0, vec1); + HSUB_UB2_SH(vec0, vec1, vec0, vec1); + vec2 = vec0 + vec1; + ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2); + CMP_AND_SELECT(vec0, vec1, vec2, src1, src2, src6, src10); + ILVR_B2_SH(src3, src7, src10, src7, vec0, vec1); + HSUB_UB2_SH(vec0, vec1, vec0, vec1); + vec2 = vec0 + vec1; + ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2); + CMP_AND_SELECT(vec0, vec1, vec2, src10, src3, src7, src11); + ILVR_B2_SH(src4, src8, src11, src8, vec0, vec1); + HSUB_UB2_SH(vec0, vec1, vec0, vec1); + vec2 = vec0 + vec1; + ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2); + CMP_AND_SELECT(vec0, vec1, vec2, src11, src4, src8, src12); + ILVR_B2_SH(src5, src9, src12, src9, vec0, vec1); + HSUB_UB2_SH(vec0, vec1, vec0, vec1); + vec2 = vec0 + vec1; + ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2); + CMP_AND_SELECT(vec0, vec1, vec2, src12, src5, src9, src13); + src1 = src13; + VSHF_B2_UB(src10, src11, src12, src13, mask0, mask0, dst0, dst1); + dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0); + out0 = __msa_copy_s_d((v2i64) dst0, 0); + out1 = __msa_copy_s_w((v4i32) dst0, 2); + + SD(out0, nxt); + nxt += 8; + SW(out1, nxt); + nxt += 4; + } +} + +#endif /* PNG_MIPS_MSA_OPT > 0 */ +#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 (intrinsics) */ +#endif /* READ */ diff --git a/xs/src/png/libpng/mips/mips_init.c b/xs/src/png/libpng/mips/mips_init.c new file mode 100644 index 0000000000..0bfb7a32e9 --- /dev/null +++ b/xs/src/png/libpng/mips/mips_init.c @@ -0,0 +1,129 @@ + +/* mips_init.c - MSA optimised filter functions + * + * Copyright (c) 2016 Glenn Randers-Pehrson + * Written by Mandar Sahastrabuddhe, 2016. + * Last changed in libpng 1.6.25 [September 1, 2016] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ +/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are + * called. + */ +#define _POSIX_SOURCE 1 + +#include +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +#if PNG_MIPS_MSA_OPT > 0 +#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED /* Do run-time checks */ +/* WARNING: it is strongly recommended that you do not build libpng with + * run-time checks for CPU features if at all possible. In the case of the MIPS + * MSA instructions there is no processor-specific way of detecting the + * presence of the required support, therefore run-time detection is extremely + * OS specific. + * + * You may set the macro PNG_MIPS_MSA_FILE to the file name of file containing + * a fragment of C source code which defines the png_have_msa function. There + * are a number of implementations in contrib/mips-msa, but the only one that + * has partial support is contrib/mips-msa/linux.c - a generic Linux + * implementation which reads /proc/cpufino. + */ +#ifndef PNG_MIPS_MSA_FILE +# ifdef __linux__ +# define PNG_MIPS_MSA_FILE "contrib/mips-msa/linux.c" +# endif +#endif + +#ifdef PNG_MIPS_MSA_FILE + +#include /* for sig_atomic_t */ +static int png_have_msa(png_structp png_ptr); +#include PNG_MIPS_MSA_FILE + +#else /* PNG_MIPS_MSA_FILE */ +# error "PNG_MIPS_MSA_FILE undefined: no support for run-time MIPS MSA checks" +#endif /* PNG_MIPS_MSA_FILE */ +#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */ + +#ifndef PNG_ALIGNED_MEMORY_SUPPORTED +# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED" +#endif + +void +png_init_filter_functions_msa(png_structp pp, unsigned int bpp) +{ + /* The switch statement is compiled in for MIPS_MSA_API, the call to + * png_have_msa is compiled in for MIPS_MSA_CHECK. If both are defined + * the check is only performed if the API has not set the MSA option on + * or off explicitly. In this case the check controls what happens. + */ + +#ifdef PNG_MIPS_MSA_API_SUPPORTED + switch ((pp->options >> PNG_MIPS_MSA) & 3) + { + case PNG_OPTION_UNSET: + /* Allow the run-time check to execute if it has been enabled - + * thus both API and CHECK can be turned on. If it isn't supported + * this case will fall through to the 'default' below, which just + * returns. + */ +#endif /* PNG_MIPS_MSA_API_SUPPORTED */ +#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED + { + static volatile sig_atomic_t no_msa = -1; /* not checked */ + + if (no_msa < 0) + no_msa = !png_have_msa(pp); + + if (no_msa) + return; + } +#ifdef PNG_MIPS_MSA_API_SUPPORTED + break; +#endif +#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */ + +#ifdef PNG_MIPS_MSA_API_SUPPORTED + default: /* OFF or INVALID */ + return; + + case PNG_OPTION_ON: + /* Option turned on */ + break; + } +#endif + + /* IMPORTANT: any new external functions used here must be declared using + * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the + * 'prefix' option to configure works: + * + * ./configure --with-libpng-prefix=foobar_ + * + * Verify you have got this right by running the above command, doing a build + * and examining pngprefix.h; it must contain a #define for every external + * function you add. (Notice that this happens automatically for the + * initialization function.) + */ + pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_msa; + + if (bpp == 3) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_msa; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_msa; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_msa; + } + + else if (bpp == 4) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_msa; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_msa; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_msa; + } +} +#endif /* PNG_MIPS_MSA_OPT > 0 */ +#endif /* READ */ diff --git a/xs/src/png/libpng/pngusr.dfa b/xs/src/png/libpng/pngusr.dfa new file mode 100644 index 0000000000..83067c38c0 --- /dev/null +++ b/xs/src/png/libpng/pngusr.dfa @@ -0,0 +1,14 @@ +# pngusr.dfa +# +# Build time configuration of libpng +# +# Enter build configuration options in this file +# +# Security settings: by default these limits are unset, you can change them +# here by entering the appropriate values as #defines preceded by '@' (to cause, +# them to be passed through to the build of pnglibconf.h), for example: +# +# @# define PNG_USER_WIDTH_MAX 65535 +# @# define PNG_USER_HEIGHT_MAX 65535 +# @# define PNG_USER_CHUNK_CACHE_MAX 256 +# @# define PNG_USER_CHUNK_MALLOC_MAX 640000 diff --git a/xs/src/png/libpng/powerpc/filter_vsx_intrinsics.c b/xs/src/png/libpng/powerpc/filter_vsx_intrinsics.c new file mode 100644 index 0000000000..e3de496bdc --- /dev/null +++ b/xs/src/png/libpng/powerpc/filter_vsx_intrinsics.c @@ -0,0 +1,767 @@ +/* filter_vsx_intrinsics.c - PowerPC optimised filter functions + * + * Copyright (c) 2017 Glenn Randers-Pehrson + * Written by Vadim Barkov, 2017. + * Last changed in libpng 1.6.29 [March 16, 2017] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ +#include +#include +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +/* This code requires -maltivec and -mvsx on the command line: */ +#if PNG_POWERPC_VSX_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */ + +#include + +#if PNG_POWERPC_VSX_OPT > 0 + +#ifndef __VSX__ +# error "This code requires VSX support (POWER7 and later). Please provide -mvsx compiler flag." +#endif + +#define vec_ld_unaligned(vec,data) vec = vec_vsx_ld(0,data) +#define vec_st_unaligned(vec,data) vec_vsx_st(vec,0,data) + + +/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d). + * They're positioned like this: + * prev: c b + * row: a d + * The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be + * whichever of a, b, or c is closest to p=a+b-c. + * ( this is taken from ../intel/filter_sse2_intrinsics.c ) + */ + +#define vsx_declare_common_vars(row_info,row,prev_row,offset) \ + png_byte i;\ + png_bytep rp = row + offset;\ + png_const_bytep pp = prev_row;\ + png_size_t unaligned_top = 16 - (((png_size_t)rp % 16));\ + png_size_t istop;\ + if(unaligned_top == 16)\ + unaligned_top = 0;\ + istop = row_info->rowbytes;\ + if((unaligned_top < istop))\ + istop -= unaligned_top;\ + else{\ + unaligned_top = istop;\ + istop = 0;\ + } + +void png_read_filter_row_up_vsx(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + vector unsigned char rp_vec; + vector unsigned char pp_vec; + vsx_declare_common_vars(row_info,row,prev_row,0) + + /* Altivec operations require 16-byte aligned data + * but input can be unaligned. So we calculate + * unaligned part as usual. + */ + for (i = 0; i < unaligned_top; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + /* Using SIMD while we can */ + while( istop >= 16 ) + { + rp_vec = vec_ld(0,rp); + vec_ld_unaligned(pp_vec,pp); + + rp_vec = vec_add(rp_vec,pp_vec); + + vec_st(rp_vec,0,rp); + + pp += 16; + rp += 16; + istop -= 16; + } + + if(istop > 0) + { + /* If byte count of row is not divisible by 16 + * we will process remaining part as usual + */ + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } +} + +} + +static const vector unsigned char VSX_LEFTSHIFTED1_4 = {16,16,16,16, 0, 1, 2, 3,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_LEFTSHIFTED2_4 = {16,16,16,16,16,16,16,16, 4, 5, 6, 7,16,16,16,16}; +static const vector unsigned char VSX_LEFTSHIFTED3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 8, 9,10,11}; + +static const vector unsigned char VSX_LEFTSHIFTED1_3 = {16,16,16, 0, 1, 2,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_LEFTSHIFTED2_3 = {16,16,16,16,16,16, 3, 4, 5,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_LEFTSHIFTED3_3 = {16,16,16,16,16,16,16,16,16, 6, 7, 8,16,16,16,16}; +static const vector unsigned char VSX_LEFTSHIFTED4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 9,10,11,16}; + +static const vector unsigned char VSX_NOT_SHIFTED1_4 = {16,16,16,16, 4, 5, 6, 7,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_NOT_SHIFTED2_4 = {16,16,16,16,16,16,16,16, 8, 9,10,11,16,16,16,16}; +static const vector unsigned char VSX_NOT_SHIFTED3_4 = {16,16,16,16,16,16,16,16,16,16,16,16,12,13,14,15}; + +static const vector unsigned char VSX_NOT_SHIFTED1_3 = {16,16,16, 3, 4, 5,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_NOT_SHIFTED2_3 = {16,16,16,16,16,16, 6, 7, 8,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_NOT_SHIFTED3_3 = {16,16,16,16,16,16,16,16,16, 9,10,11,16,16,16,16}; +static const vector unsigned char VSX_NOT_SHIFTED4_3 = {16,16,16,16,16,16,16,16,16,16,16,16,12,13,14,16}; + +static const vector unsigned char VSX_CHAR_ZERO = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +#ifdef __LITTLE_ENDIAN__ + +static const vector unsigned char VSX_CHAR_TO_SHORT1_4 = { 4,16, 5,16, 6,16, 7,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT2_4 = { 8,16, 9,16,10,16,11,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT3_4 = {12,16,13,16,14,16,15,16,16,16,16,16,16,16,16,16}; + +static const vector unsigned char VSX_SHORT_TO_CHAR1_4 = {16,16,16,16, 0, 2, 4, 6,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR2_4 = {16,16,16,16,16,16,16,16, 0, 2, 4, 6,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 0, 2, 4, 6}; + +static const vector unsigned char VSX_CHAR_TO_SHORT1_3 = { 3,16, 4,16, 5,16,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT2_3 = { 6,16, 7,16, 8,16,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT3_3 = { 9,16,10,16,11,16,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT4_3 = {12,16,13,16,14,16,16,16,16,16,16,16,16,16,16,16}; + +static const vector unsigned char VSX_SHORT_TO_CHAR1_3 = {16,16,16, 0, 2, 4,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR2_3 = {16,16,16,16,16,16, 0, 2, 4,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR3_3 = {16,16,16,16,16,16,16,16,16, 0, 2, 4,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 0, 2, 4,16}; + +#elif defined(__BIG_ENDIAN__) + +static const vector unsigned char VSX_CHAR_TO_SHORT1_4 = {16, 4,16, 5,16, 6,16, 7,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT2_4 = {16, 8,16, 9,16,10,16,11,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT3_4 = {16,12,16,13,16,14,16,15,16,16,16,16,16,16,16,16}; + +static const vector unsigned char VSX_SHORT_TO_CHAR1_4 = {16,16,16,16, 1, 3, 5, 7,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR2_4 = {16,16,16,16,16,16,16,16, 1, 3, 5, 7,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 1, 3, 5, 7}; + +static const vector unsigned char VSX_CHAR_TO_SHORT1_3 = {16, 3,16, 4,16, 5,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT2_3 = {16, 6,16, 7,16, 8,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT3_3 = {16, 9,16,10,16,11,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_CHAR_TO_SHORT4_3 = {16,12,16,13,16,14,16,16,16,16,16,16,16,16,16,16}; + +static const vector unsigned char VSX_SHORT_TO_CHAR1_3 = {16,16,16, 1, 3, 5,16,16,16,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR2_3 = {16,16,16,16,16,16, 1, 3, 5,16,16,16,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR3_3 = {16,16,16,16,16,16,16,16,16, 1, 3, 5,16,16,16,16}; +static const vector unsigned char VSX_SHORT_TO_CHAR4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 1, 3, 5,16}; + +#endif + +#define vsx_char_to_short(vec,offset,bpp) (vector unsigned short)vec_perm((vec),VSX_CHAR_ZERO,VSX_CHAR_TO_SHORT##offset##_##bpp) +#define vsx_short_to_char(vec,offset,bpp) vec_perm(((vector unsigned char)(vec)),VSX_CHAR_ZERO,VSX_SHORT_TO_CHAR##offset##_##bpp) + +#ifdef PNG_USE_ABS +# define vsx_abs(number) abs(number) +#else +# define vsx_abs(number) (number > 0) ? (number) : -(number) +#endif + +void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + const png_byte bpp = 4; + + vector unsigned char rp_vec; + vector unsigned char part_vec; + + vsx_declare_common_vars(row_info,row,prev_row,bpp) + + PNG_UNUSED(pp) + + /* Altivec operations require 16-byte aligned data + * but input can be unaligned. So we calculate + * unaligned part as usual. + */ + for (i = 0; i < unaligned_top; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); + rp++; + } + + /* Using SIMD while we can */ + while( istop >= 16 ) + { + for(i=0;i < bpp ; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); + rp++; + } + rp -= bpp; + + rp_vec = vec_ld(0,rp); + part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_4); + rp_vec = vec_add(rp_vec,part_vec); + + part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_4); + rp_vec = vec_add(rp_vec,part_vec); + + part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_4); + rp_vec = vec_add(rp_vec,part_vec); + + vec_st(rp_vec,0,rp); + + rp += 16; + istop -= 16; + } + + if(istop > 0) + for (i = 0; i < istop % 16; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*(rp - bpp))) & 0xff); + rp++; + } + +} + +void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + const png_byte bpp = 3; + + vector unsigned char rp_vec; + vector unsigned char part_vec; + + vsx_declare_common_vars(row_info,row,prev_row,bpp) + + PNG_UNUSED(pp) + + /* Altivec operations require 16-byte aligned data + * but input can be unaligned. So we calculate + * unaligned part as usual. + */ + for (i = 0; i < unaligned_top; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); + rp++; + } + + /* Using SIMD while we can */ + while( istop >= 16 ) + { + for(i=0;i < bpp ; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); + rp++; + } + rp -= bpp; + + rp_vec = vec_ld(0,rp); + part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_3); + rp_vec = vec_add(rp_vec,part_vec); + + part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_3); + rp_vec = vec_add(rp_vec,part_vec); + + part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_3); + rp_vec = vec_add(rp_vec,part_vec); + + part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED4_3); + rp_vec = vec_add(rp_vec,part_vec); + + vec_st(rp_vec,0,rp); + rp += 15; + istop -= 16; + + /* Since 16 % bpp = 16 % 3 = 1, last element of array must + * be proceeded manually + */ + *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); + rp++; + } + + if(istop > 0) + for (i = 0; i < istop % 16; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); + rp++; + } +} + +void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + const png_byte bpp = 4; + + vector unsigned char rp_vec; + vector unsigned char pp_vec; + vector unsigned char pp_part_vec; + vector unsigned char rp_part_vec; + vector unsigned char avg_vec; + + vsx_declare_common_vars(row_info,row,prev_row,bpp) + rp -= bpp; + if(istop >= bpp) + istop -= bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + + rp++; + } + + /* Altivec operations require 16-byte aligned data + * but input can be unaligned. So we calculate + * unaligned part as usual. + */ + for (i = 0; i < unaligned_top; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + + rp++; + } + + /* Using SIMD while we can */ + while( istop >= 16 ) + { + for(i=0;i < bpp ; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + + rp++; + } + rp -= bpp; + pp -= bpp; + + vec_ld_unaligned(pp_vec,pp); + rp_vec = vec_ld(0,rp); + + rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_4); + pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED1_4); + avg_vec = vec_avg(rp_part_vec,pp_part_vec); + avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1))); + rp_vec = vec_add(rp_vec,avg_vec); + + rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_4); + pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED2_4); + avg_vec = vec_avg(rp_part_vec,pp_part_vec); + avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1))); + rp_vec = vec_add(rp_vec,avg_vec); + + rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_4); + pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED3_4); + avg_vec = vec_avg(rp_part_vec,pp_part_vec); + avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1))); + rp_vec = vec_add(rp_vec,avg_vec); + + vec_st(rp_vec,0,rp); + + rp += 16; + pp += 16; + istop -= 16; + } + + if(istop > 0) + for (i = 0; i < istop % 16; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + + rp++; + } +} + +void png_read_filter_row_avg3_vsx(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + const png_byte bpp = 3; + + vector unsigned char rp_vec; + vector unsigned char pp_vec; + vector unsigned char pp_part_vec; + vector unsigned char rp_part_vec; + vector unsigned char avg_vec; + + vsx_declare_common_vars(row_info,row,prev_row,bpp) + rp -= bpp; + if(istop >= bpp) + istop -= bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + + rp++; + } + + /* Altivec operations require 16-byte aligned data + * but input can be unaligned. So we calculate + * unaligned part as usual. + */ + for (i = 0; i < unaligned_top; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + + rp++; + } + + /* Using SIMD while we can */ + while( istop >= 16 ) + { + for(i=0;i < bpp ; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + + rp++; + } + rp -= bpp; + pp -= bpp; + + vec_ld_unaligned(pp_vec,pp); + rp_vec = vec_ld(0,rp); + + rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_3); + pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED1_3); + avg_vec = vec_avg(rp_part_vec,pp_part_vec); + avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1))); + rp_vec = vec_add(rp_vec,avg_vec); + + rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_3); + pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED2_3); + avg_vec = vec_avg(rp_part_vec,pp_part_vec); + avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1))); + rp_vec = vec_add(rp_vec,avg_vec); + + rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_3); + pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED3_3); + avg_vec = vec_avg(rp_part_vec,pp_part_vec); + avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1))); + rp_vec = vec_add(rp_vec,avg_vec); + + rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED4_3); + pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED4_3); + avg_vec = vec_avg(rp_part_vec,pp_part_vec); + avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1))); + rp_vec = vec_add(rp_vec,avg_vec); + + vec_st(rp_vec,0,rp); + + rp += 15; + pp += 15; + istop -= 16; + + /* Since 16 % bpp = 16 % 3 = 1, last element of array must + * be proceeded manually + */ + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + rp++; + } + + if(istop > 0) + for (i = 0; i < istop % 16; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + + rp++; + } +} + +/* Bytewise c ? t : e. */ +#define if_then_else(c,t,e) vec_sel(e,t,c) + +#define vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) {\ + c = *(pp - bpp);\ + a = *(rp - bpp);\ + b = *pp++;\ + p = b - c;\ + pc = a - c;\ + pa = vsx_abs(p);\ + pb = vsx_abs(pc);\ + pc = vsx_abs(p + pc);\ + if (pb < pa) pa = pb, a = b;\ + if (pc < pa) a = c;\ + a += *rp;\ + *rp++ = (png_byte)a;\ + } + +void png_read_filter_row_paeth4_vsx(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + const png_byte bpp = 4; + + int a, b, c, pa, pb, pc, p; + vector unsigned char rp_vec; + vector unsigned char pp_vec; + vector unsigned short a_vec,b_vec,c_vec,nearest_vec; + vector signed short pa_vec,pb_vec,pc_vec,smallest_vec; + + vsx_declare_common_vars(row_info,row,prev_row,bpp) + rp -= bpp; + if(istop >= bpp) + istop -= bpp; + + /* Process the first pixel in the row completely (this is the same as 'up' + * because there is only one candidate predictor for the first row). + */ + for(i = 0; i < bpp ; i++) + { + *rp = (png_byte)( *rp + *pp); + rp++; + pp++; + } + + for(i = 0; i < unaligned_top ; i++) + { + vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) + } + + while( istop >= 16) + { + for(i = 0; i < bpp ; i++) + { + vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) + } + + rp -= bpp; + pp -= bpp; + rp_vec = vec_ld(0,rp); + vec_ld_unaligned(pp_vec,pp); + + a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_4),1,4); + b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED1_4),1,4); + c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_4),1,4); + pa_vec = (vector signed short) vec_sub(b_vec,c_vec); + pb_vec = (vector signed short) vec_sub(a_vec , c_vec); + pc_vec = vec_add(pa_vec,pb_vec); + pa_vec = vec_abs(pa_vec); + pb_vec = vec_abs(pb_vec); + pc_vec = vec_abs(pc_vec); + smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec)); + nearest_vec = if_then_else( + vec_cmpeq(pa_vec,smallest_vec), + a_vec, + if_then_else( + vec_cmpeq(pb_vec,smallest_vec), + b_vec, + c_vec + ) + ); + rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,1,4))); + + a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_4),2,4); + b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED2_4),2,4); + c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_4),2,4); + pa_vec = (vector signed short) vec_sub(b_vec,c_vec); + pb_vec = (vector signed short) vec_sub(a_vec , c_vec); + pc_vec = vec_add(pa_vec,pb_vec); + pa_vec = vec_abs(pa_vec); + pb_vec = vec_abs(pb_vec); + pc_vec = vec_abs(pc_vec); + smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec)); + nearest_vec = if_then_else( + vec_cmpeq(pa_vec,smallest_vec), + a_vec, + if_then_else( + vec_cmpeq(pb_vec,smallest_vec), + b_vec, + c_vec + ) + ); + rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,2,4))); + + a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_4),3,4); + b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED3_4),3,4); + c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_4),3,4); + pa_vec = (vector signed short) vec_sub(b_vec,c_vec); + pb_vec = (vector signed short) vec_sub(a_vec , c_vec); + pc_vec = vec_add(pa_vec,pb_vec); + pa_vec = vec_abs(pa_vec); + pb_vec = vec_abs(pb_vec); + pc_vec = vec_abs(pc_vec); + smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec)); + nearest_vec = if_then_else( + vec_cmpeq(pa_vec,smallest_vec), + a_vec, + if_then_else( + vec_cmpeq(pb_vec,smallest_vec), + b_vec, + c_vec + ) + ); + rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,3,4))); + + vec_st(rp_vec,0,rp); + + rp += 16; + pp += 16; + istop -= 16; + } + + if(istop > 0) + for (i = 0; i < istop % 16; i++) + { + vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) + } +} + +void png_read_filter_row_paeth3_vsx(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + const png_byte bpp = 3; + + int a, b, c, pa, pb, pc, p; + vector unsigned char rp_vec; + vector unsigned char pp_vec; + vector unsigned short a_vec,b_vec,c_vec,nearest_vec; + vector signed short pa_vec,pb_vec,pc_vec,smallest_vec; + + vsx_declare_common_vars(row_info,row,prev_row,bpp) + rp -= bpp; + if(istop >= bpp) + istop -= bpp; + + /* Process the first pixel in the row completely (this is the same as 'up' + * because there is only one candidate predictor for the first row). + */ + for(i = 0; i < bpp ; i++) + { + *rp = (png_byte)( *rp + *pp); + rp++; + pp++; + } + + for(i = 0; i < unaligned_top ; i++) + { + vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) + } + + while( istop >= 16) + { + for(i = 0; i < bpp ; i++) + { + vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) + } + + rp -= bpp; + pp -= bpp; + rp_vec = vec_ld(0,rp); + vec_ld_unaligned(pp_vec,pp); + + a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_3),1,3); + b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED1_3),1,3); + c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_3),1,3); + pa_vec = (vector signed short) vec_sub(b_vec,c_vec); + pb_vec = (vector signed short) vec_sub(a_vec , c_vec); + pc_vec = vec_add(pa_vec,pb_vec); + pa_vec = vec_abs(pa_vec); + pb_vec = vec_abs(pb_vec); + pc_vec = vec_abs(pc_vec); + smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec)); + nearest_vec = if_then_else( + vec_cmpeq(pa_vec,smallest_vec), + a_vec, + if_then_else( + vec_cmpeq(pb_vec,smallest_vec), + b_vec, + c_vec + ) + ); + rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,1,3))); + + a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_3),2,3); + b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED2_3),2,3); + c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_3),2,3); + pa_vec = (vector signed short) vec_sub(b_vec,c_vec); + pb_vec = (vector signed short) vec_sub(a_vec , c_vec); + pc_vec = vec_add(pa_vec,pb_vec); + pa_vec = vec_abs(pa_vec); + pb_vec = vec_abs(pb_vec); + pc_vec = vec_abs(pc_vec); + smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec)); + nearest_vec = if_then_else( + vec_cmpeq(pa_vec,smallest_vec), + a_vec, + if_then_else( + vec_cmpeq(pb_vec,smallest_vec), + b_vec, + c_vec + ) + ); + rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,2,3))); + + a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_3),3,3); + b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED3_3),3,3); + c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_3),3,3); + pa_vec = (vector signed short) vec_sub(b_vec,c_vec); + pb_vec = (vector signed short) vec_sub(a_vec , c_vec); + pc_vec = vec_add(pa_vec,pb_vec); + pa_vec = vec_abs(pa_vec); + pb_vec = vec_abs(pb_vec); + pc_vec = vec_abs(pc_vec); + smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec)); + nearest_vec = if_then_else( + vec_cmpeq(pa_vec,smallest_vec), + a_vec, + if_then_else( + vec_cmpeq(pb_vec,smallest_vec), + b_vec, + c_vec + ) + ); + rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,3,3))); + + a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED4_3),4,3); + b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED4_3),4,3); + c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED4_3),4,3); + pa_vec = (vector signed short) vec_sub(b_vec,c_vec); + pb_vec = (vector signed short) vec_sub(a_vec , c_vec); + pc_vec = vec_add(pa_vec,pb_vec); + pa_vec = vec_abs(pa_vec); + pb_vec = vec_abs(pb_vec); + pc_vec = vec_abs(pc_vec); + smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec)); + nearest_vec = if_then_else( + vec_cmpeq(pa_vec,smallest_vec), + a_vec, + if_then_else( + vec_cmpeq(pb_vec,smallest_vec), + b_vec, + c_vec + ) + ); + rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,4,3))); + + vec_st(rp_vec,0,rp); + + rp += 15; + pp += 15; + istop -= 16; + + /* Since 16 % bpp = 16 % 3 = 1, last element of array must + * be proceeded manually + */ + vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) + } + + if(istop > 0) + for (i = 0; i < istop % 16; i++) + { + vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) + } +} + +#endif /* PNG_POWERPC_VSX_OPT > 0 */ +#endif /* PNG_POWERPC_VSX_IMPLEMENTATION == 1 (intrinsics) */ +#endif /* READ */ diff --git a/xs/src/png/libpng/powerpc/powerpc_init.c b/xs/src/png/libpng/powerpc/powerpc_init.c new file mode 100644 index 0000000000..07016177c5 --- /dev/null +++ b/xs/src/png/libpng/powerpc/powerpc_init.c @@ -0,0 +1,125 @@ + +/* powerpc_init.c - POWERPC optimised filter functions + * + * Copyright (c) 2017 Glenn Randers-Pehrson + * Written by Vadim Barkov, 2017. + * Last changed in libpng 1.6.29 [March 16, 2017] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ +/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are + * called. + */ +#define _POSIX_SOURCE 1 + +#include +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +#if PNG_POWERPC_VSX_OPT > 0 +#ifdef PNG_POWERPC_VSX_CHECK_SUPPORTED /* Do run-time checks */ +/* WARNING: it is strongly recommended that you do not build libpng with + * run-time checks for CPU features if at all possible. In the case of the PowerPC + * VSX instructions there is no processor-specific way of detecting the + * presence of the required support, therefore run-time detection is extremely + * OS specific. + * + * You may set the macro PNG_POWERPC_VSX_FILE to the file name of file containing + * a fragment of C source code which defines the png_have_vsx function. There + * are a number of implementations in contrib/powerpc-vsx, but the only one that + * has partial support is contrib/powerpc-vsx/linux.c - a generic Linux + * implementation which reads /proc/cpufino. + */ +#ifndef PNG_POWERPC_VSX_FILE +# ifdef __linux__ +# define PNG_POWERPC_VSX_FILE "contrib/powerpc-vsx/linux_aux.c" +# endif +#endif + +#ifdef PNG_POWERPC_VSX_FILE + +#include /* for sig_atomic_t */ +static int png_have_vsx(png_structp png_ptr); +#include PNG_POWERPC_VSX_FILE + +#else /* PNG_POWERPC_VSX_FILE */ +# error "PNG_POWERPC_VSX_FILE undefined: no support for run-time POWERPC VSX checks" +#endif /* PNG_POWERPC_VSX_FILE */ +#endif /* PNG_POWERPC_VSX_CHECK_SUPPORTED */ + +void +png_init_filter_functions_vsx(png_structp pp, unsigned int bpp) +{ + /* The switch statement is compiled in for POWERPC_VSX_API, the call to + * png_have_vsx is compiled in for POWERPC_VSX_CHECK. If both are defined + * the check is only performed if the API has not set the PowerPC option on + * or off explicitly. In this case the check controls what happens. + */ + +#ifdef PNG_POWERPC_VSX_API_SUPPORTED + switch ((pp->options >> PNG_POWERPC_VSX) & 3) + { + case PNG_OPTION_UNSET: + /* Allow the run-time check to execute if it has been enabled - + * thus both API and CHECK can be turned on. If it isn't supported + * this case will fall through to the 'default' below, which just + * returns. + */ +#endif /* PNG_POWERPC_VSX_API_SUPPORTED */ +#ifdef PNG_POWERPC_VSX_CHECK_SUPPORTED + { + static volatile sig_atomic_t no_vsx = -1; /* not checked */ + + if (no_vsx < 0) + no_vsx = !png_have_vsx(pp); + + if (no_vsx) + return; + } +#ifdef PNG_POWERPC_VSX_API_SUPPORTED + break; +#endif +#endif /* PNG_POWERPC_VSX_CHECK_SUPPORTED */ + +#ifdef PNG_POWERPC_VSX_API_SUPPORTED + default: /* OFF or INVALID */ + return; + + case PNG_OPTION_ON: + /* Option turned on */ + break; + } +#endif + + /* IMPORTANT: any new internal functions used here must be declared using + * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the + * 'prefix' option to configure works: + * + * ./configure --with-libpng-prefix=foobar_ + * + * Verify you have got this right by running the above command, doing a build + * and examining pngprefix.h; it must contain a #define for every external + * function you add. (Notice that this happens automatically for the + * initialization function.) + */ + pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_vsx; + + if (bpp == 3) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_vsx; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_vsx; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_vsx; + } + + else if (bpp == 4) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_vsx; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_vsx; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_vsx; + } +} +#endif /* PNG_POWERPC_VSX_OPT > 0 */ +#endif /* READ */ diff --git a/xs/src/png/libpng/scripts/checksym.awk b/xs/src/png/libpng/scripts/checksym.awk new file mode 100755 index 0000000000..fe3af55e05 --- /dev/null +++ b/xs/src/png/libpng/scripts/checksym.awk @@ -0,0 +1,173 @@ +#!/bin/awk -f +# Check a list of symbols against the master definition +# (official) list. Arguments: +# +# awk -f checksym.awk official-def list-to-check +# +# Output is a file in the current directory called 'symbols.new', +# the value of the awk variable "of" (which can be changed on the +# command line if required.) stdout holds error messages. Error +# code indicates success or failure. +# +# NOTE: this is a pure, old fashioned, awk script. It will +# work with any awk + +BEGIN{ + err=0 + master="" # master file + official[1] = "" # defined symbols from master file + symbol[1] = "" # defined symbols from png.h + removed[1] = "" # removed symbols from png.h + lasto = 0 # last ordinal value from png.h + mastero = 0 # highest ordinal in master file + symbolo = 0 # highest ordinal in png.h + missing = "error"# log an error on missing symbols + of="symbols.new" # default to a fixed name +} + +# Read existing definitions from the master file (the first +# file on the command line.) This must be a def file and it +# has definition lines (others are ignored) of the form: +# +# symbol @ordinal +# +master == "" { + master = FILENAME +} +FILENAME==master && NF==2 && $2~/^@/ && $1!~/^;/ { + o=0+substr($2,2) + if (o > 0) { + if (official[o] == "") { + official[o] = $1 + if (o > mastero) mastero = o + next + } else + print master ": duplicated symbol:", official[o] ":", $0 + } else + print master ": bad export line format:", $0 + err = 1 +} +FILENAME==master && $1==";missing" && NF==2{ + # This allows the master file to control how missing symbols + # are handled; symbols that aren't in either the master or + # the new file. Valid values are 'ignore', 'warning' and + # 'error' + missing = $2 +} +FILENAME==master { + next +} + +# Read new definitions, these are free form but the lines must +# just be symbol definitions. Lines will be commented out for +# 'removed' symbols, introduced in png.h using PNG_REMOVED rather +# than PNG_EXPORT. Use symbols.dfn or pngwin.dfn to generate the +# input file. +# +# symbol @ordinal # two fields, exported symbol +# ; symbol @ordinal # three fields, removed symbol +# ; @ordinal # two fields, the last ordinal +NF==2 && $1 == ";" && $2 ~ /^@[1-9][0-9]*$/ { # last ordinal + o=0+substr($2,2) + if (lasto == 0 || lasto == o) + lasto=o + else { + print "png.h: duplicated last ordinal:", lasto, o + err = 1 + } + next +} +NF==3 && $1 == ";" && $3 ~ /^@[1-9][0-9]*$/ { # removed symbol + o=0+substr($3,2) + if (removed[o] == "" || removed[o] == $2) { + removed[o] = $2 + if (o > symbolo) symbolo = o + } else { + print "png.h: duplicated removed symbol", o ": '" removed[o] "' != '" $2 "'" + err = 1 + } + next +} +NF==2 && $2 ~ /^@[1-9][0-9]*$/ { # exported symbol + o=0+substr($2,2) + if (symbol[o] == "" || symbol[o] == $1) { + symbol[o] = $1 + if (o > symbolo) symbolo = o + } else { + print "png.h: duplicated symbol", o ": '" symbol[o] "' != '" $1 "'" + err = 1 + } +} +{ + next # skip all other lines +} + +# At the end check for symbols marked as both duplicated and removed +END{ + if (symbolo > lasto) { + print "highest symbol ordinal in png.h,", symbolo ", exceeds last ordinal from png.h", lasto + err = 1 + } + if (mastero > lasto) { + print "highest symbol ordinal in", master ",", mastero ", exceeds last ordinal from png.h", lasto + err = 1 + } + unexported=0 + # Add a standard header to symbols.new: + print ";Version INSERT-VERSION-HERE" >of + print ";--------------------------------------------------------------" >of + print "; LIBPNG symbol list as a Win32 DEF file" >of + print "; Contains all the symbols that can be exported from libpng" >of + print ";--------------------------------------------------------------" >of + print "LIBRARY" >of + print "" >of + print "EXPORTS" >of + + for (o=1; o<=lasto; ++o) { + if (symbol[o] == "" && removed[o] == "") { + if (unexported == 0) unexported = o + if (official[o] == "") { + # missing in export list too, so ok + if (o < lasto) continue + } + } + if (unexported != 0) { + # Symbols in the .def but not in the new file are errors, but + # the 'unexported' symbols aren't in either. By default this + # is an error too (see the setting of 'missing' at the start), + # but this can be reset on the command line or by stuff in the + # file - see the comments above. + if (missing != "ignore") { + if (o-1 > unexported) + print "png.h:", missing ": missing symbols:", unexported "-" o-1 + else + print "png.h:", missing ": missing symbol:", unexported + if (missing != "warning") + err = 1 + } + unexported = 0 + } + if (symbol[o] != "" && removed[o] != "") { + print "png.h: symbol", o, "both exported as '" symbol[o] "' and removed as '" removed[o] "'" + err = 1 + } else if (symbol[o] != official[o]) { + # either the symbol is missing somewhere or it changed + err = 1 + if (symbol[o] == "") + print "png.h: symbol", o, "is exported as '" official[o] "' in", master + else if (official[o] == "") + print "png.h: exported symbol", o, "'" symbol[o] "' not present in", master + else + print "png.h: exported symbol", o, "'" symbol[o] "' exists as '" official[o] "' in", master + } + + # Finally generate symbols.new + if (symbol[o] != "") + print " " symbol[o], "@" o > of + } + + if (err != 0) { + print "*** A new list is in", of, "***" + exit 1 + } +} diff --git a/xs/src/png/libpng/scripts/def.c b/xs/src/png/libpng/scripts/def.c new file mode 100644 index 0000000000..0ffcbeb0c2 --- /dev/null +++ b/xs/src/png/libpng/scripts/def.c @@ -0,0 +1,29 @@ +/* def.c - define format of libpng.def + * + * Last changed in libpng version 1.6.16 [December 22, 2014] + * Copyright (c) 2011-2014 Glenn Randers-Pehrson + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* Write the export file header: */ +PNG_DFN ";--------------------------------------------------------------" +PNG_DFN "; LIBPNG module definition file for OS/2" +PNG_DFN ";--------------------------------------------------------------" +PNG_DFN "" +PNG_DFN "; If you give the library an explicit name one or other files" +PNG_DFN "; may need modifying to support the new name on one or more" +PNG_DFN "; systems." +PNG_DFN "LIBRARY" +PNG_DFN "OS2 DESCRIPTION "PNG image compression library"" +PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE" +PNG_DFN "" +PNG_DFN "EXPORTS" +PNG_DFN ";Version 1.6.35beta02" + +#define PNG_EXPORTA(ordinal, type, name, args, attributes)\ + PNG_DFN "@" SYMBOL_PREFIX "@@" name "@" + +#include "../png.h" diff --git a/xs/src/png/libpng/scripts/dfn.awk b/xs/src/png/libpng/scripts/dfn.awk new file mode 100755 index 0000000000..346b9db7d5 --- /dev/null +++ b/xs/src/png/libpng/scripts/dfn.awk @@ -0,0 +1,203 @@ +#!/bin/awk -f +# scripts/dfn.awk - process a .dfn file +# +# last changed in libpng version 1.5.19 - August 21, 2014 +# +# Copyright (c) 2013-2014 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# The output of this script is written to the file given by +# the variable 'out', which should be set on the command line. +# Error messages are printed to stdout and if any are printed +# the script will exit with error code 1. + +BEGIN{ + out="/dev/null" # as a flag + out_count=0 # count of output lines + err=0 # set if an error occurred + sort=0 # sort the output + array[""]="" +} + +# The output file must be specified before any input: +NR==1 && out == "/dev/null" { + print "out=output.file must be given on the command line" + # but continue without setting the error code; this allows the + # script to be checked easily +} + +# Output can be sorted; two lines are recognized +$1 == "PNG_DFN_START_SORT"{ + sort=0+$2 + next +} + +$1 ~ /^PNG_DFN_END_SORT/{ + # Do a very simple, slow, sort; notice that blank lines won't be + # output by this + for (entry in array) { + while (array[entry] != "") { + key = entry + value = array[key] + array[key] = "" + + for (alt in array) { + if (array[alt] != "" && alt < key) { + array[key] = value + value = array[alt] + key = alt + array[alt] = "" + } + } + + print value >out + } + } + sort=0 + next +} + +/^[^"]*PNG_DFN *".*"[^"]*$/{ + # A definition line, apparently correctly formatted; extract the + # definition then replace any doubled "" that remain with a single + # double quote. Notice that the original doubled double quotes + # may have been split by tokenization + # + # Sometimes GCC splits the PNG_DFN lines; we know this has happened + # if the quotes aren't closed and must read another line. In this + # case it is essential to reject lines that start with '#' because those + # are introduced #line directives. + orig=$0 + line=$0 + lineno=FNR + if (lineno == "") lineno=NR + + if (sub(/^[^"]*PNG_DFN *"/,"",line) != 1) { + print "line", lineno ": processing failed:" + print orig + err=1 + next + } else { + ++out_count + } + + # Now examine quotes within the value: + # + # @" - delete this and any following spaces + # "@ - delete this and any preceding spaces + # @' - replace this by a double quote + # + # This allows macro substitution by the C compiler thus: + # + # #define first_name John + # #define last_name Smith + # + # PNG_DFN"#define name @'@" first_name "@ @" last_name "@@'" + # + # Might get C preprocessed to: + # + # PNG_DFN "#define foo @'@" John "@ @" Smith "@@'" + # + # Which this script reduces to: + # + # #define name "John Smith" + # + while (1) { + # While there is an @" remove it and the next "@ + if (line ~ /@"/) { + if (line ~ /@".*"@/) { + # Do this special case first to avoid swallowing extra spaces + # before or after the @ stuff: + if (!sub(/@" *"@/, "", line)) { + # Ok, do it in pieces - there has to be a non-space between the + # two. NOTE: really weird things happen if a leading @" is + # lost - the code will error out below (I believe). + if (!sub(/@" */, "", line) || !sub(/ *"@/, "", line)) { + print "line", lineno, ": internal error:", orig + exit 1 + } + } + } + + # There is no matching "@. Assume a split line + else while (1) { + if (getline nextline) { + # If the line starts with '#' it is a preprocesor line directive + # from cc -E; skip it: + if (nextline !~ /^#/) { + line = line " " nextline + break + } + } else { + # This is end-of-input - probably a missing "@ on the first line: + print "line", lineno ": unbalanced @\" ... \"@ pair" + err=1 + next + } + } + + # Keep going until all the @" have gone + continue + } + + # Attempt to remove a trailing " (not preceded by '@') - if this can + # be done, stop now; if not assume a split line again + if (sub(/"[^"]*$/, "", line)) + break + + # Read another line + while (1) { + if (getline nextline) { + if (nextline !~ /^#/) { + line = line " " nextline + # Go back to stripping @" "@ pairs + break + } + } else { + print "line", lineno ": unterminated PNG_DFN string" + err=1 + next + } + } + } + + # Put any needed double quotes in (at the end, because these would otherwise + # interfere with the processing above.) + gsub(/@'/,"\"", line) + + # Remove any trailing spaces (not really required, but for + # editorial consistency + sub(/ *$/, "", line) + + # Remove trailing CR + sub(/ $/, "", line) + + if (sort) { + if (split(line, parts) < sort) { + print "line", lineno ": missing sort field:", line + err=1 + } else + array[parts[sort]] = line + } + + else + print line >out + next +} + +/PNG_DFN/{ + print "line", NR, "incorrectly formatted PNG_DFN line:" + print $0 + err = 1 +} + +END{ + if (out_count > 0 || err > 0) + exit err + + print "no definition lines found" + exit 1 +} diff --git a/xs/src/png/libpng/scripts/intprefix.c b/xs/src/png/libpng/scripts/intprefix.c new file mode 100644 index 0000000000..254f8e94b4 --- /dev/null +++ b/xs/src/png/libpng/scripts/intprefix.c @@ -0,0 +1,22 @@ + +/* intprefix.c - generate an unprefixed internal symbol list + * + * Last changed in libpng version 1.6.16 [December 22, 2014] + * Copyright (c) 2013-2014 Glenn Randers-Pehrson + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#define PNG_INTERNAL_DATA(type, name, array)\ + PNG_DFN "@" name "@" + +#define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\ + PNG_DFN "@" name "@" + +#define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\ + PNG_DFN "@" name "@" + +#define PNGPREFIX_H /* self generation */ +#include "../pngpriv.h" diff --git a/xs/src/png/libpng/scripts/options.awk b/xs/src/png/libpng/scripts/options.awk new file mode 100755 index 0000000000..fef5dfd78b --- /dev/null +++ b/xs/src/png/libpng/scripts/options.awk @@ -0,0 +1,898 @@ +#!/bin/awk -f +# scripts/options.awk - library build configuration control +# +# last changed in libpng version 1.6.11 - June 5, 2014 +# +# Copyright (c) 1998-2014 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# The output of this script is written to the file given by +# the variable 'out'. The script is run twice, once with +# an intermediate output file, 'options.tmp' then again on +# that file to produce the final output: +# +# awk -f scripts/options.awk out=options.tmp scripts/options.dfa 1>&2 +# awk -f scripts/options.awk out=options.dfn options.tmp 1>&2 +# +# Some options may be specified on the command line: +# +# deb=1 Causes debugging to be output +# logunsupported=1 Causes all options to be recorded in the output +# everything=off Causes all options to be disabled by default +# everything=on Causes all options to be enabled by default +# +# If awk fails on your platform, try nawk instead. +# +# These options may also be specified in the original input file (and +# are copied to the preprocessed file). + +BEGIN{ + out="" # intermediate, preprocessed, file + pre=-1 # preprocess (first line) + version="libpng version unknown" # version information + version_file="" # where to find the version + err=0 # in-line exit sets this + # The following definitions prevent the C preprocessor noticing the lines + # that will be in the final output file. Some C preprocessors tokenise + # the lines, for example by inserting spaces around operators, and all + # C preprocessors notice lines that start with '#', most remove comments. + # The technique adopted here is to make the final output lines into + # C strings (enclosed in double quotes), preceded by PNG_DFN. As a + # consequence the output cannot contain a 'raw' double quote - instead put + # @' in, this will be replaced by a single " afterward. See the parser + # script dfn.awk for more capabilities (not required here). Note that if + # you need a " in a 'setting' in pnglibconf.dfa it must also be @'! + dq="@'" # For a single double quote + start=" PNG_DFN \"" # Start stuff to output (can't contain a "!) + end="\" " # End stuff to output + subs="@\" " # Substitute start (substitute a C macro) + sube=" \"@" # Substitute end + comment=start "/*" # Comment start + cend="*/" end # Comment end + def=start "#define PNG_" # Arbitrary define + sup="_SUPPORTED" end # end supported option + und=comment "#undef PNG_" # Unsupported option + une="_SUPPORTED" cend # end unsupported option + error=start "ERROR:" # error message, terminate with 'end' + + # Variables + deb=0 # debug - set on command line + everything="" # do not override defaults + logunsupported=0 # write unsupported options too + + # Precreate arrays + # for each option: + option[""] = "" # list of all options: default enabled/disabled + done[""] = 1 # marks option as having been output + requires[""] = "" # requires by option + iffs[""] = "" # if by option + enabledby[""] = "" # options that enable it by option + sets[""] = "" # settings set by each option + setval[""] = "" # value to set (indexed: 'option sets[option]') + # for each setting: + setting[""] = "" # requires by setting + defaults[""] = "" # used for a defaulted value + doneset[""] = 1 # marks setting as having been output + r[""] = "" # Temporary array + + # For decorating the output file + protect = "" +} + +# The output file must be specified before any input: +out == "" { + print "out=output.file must be given on the command line" + err = 1 + exit 1 +} + +# The very first line indicates whether we are reading pre-processed +# input or not, this must come *first* because 'PREPROCESSED' needs +# to be the very first line in the temporary file. +pre == -1{ + if ($0 == "PREPROCESSED") { + pre = 0 + next + } else { + pre = 1 + print "PREPROCESSED" >out + # And fall through to continue processing + } +} + +# While pre-processing if version is set to "search" look for a version string +# in the following file. +pre && version == "search" && version_file == ""{ + version_file = FILENAME +} + +pre && version == "search" && version_file != FILENAME{ + print "version string not found in", version_file + err = 1 + exit 1 +} + +pre && version == "search" && $0 ~ /^ \* libpng version/{ + version = substr($0, 4) + print "version =", version >out + next +} + +pre && FILENAME == version_file{ + next +} + +# variable=value +# Sets the given variable to the given value (the syntax is fairly +# free form, except for deb (you are expected to understand how to +# set the debug variable...) +# +# This happens before the check on 'pre' below skips most of the +# rest of the actions, so the variable settings happen during +# preprocessing but are recorded in the END action too. This +# allows them to be set on the command line too. +$0 ~ /^[ ]*version[ ]*=/{ + sub(/^[ ]*version[ ]*=[ ]*/, "") + version = $0 + next +} +$0 ~ /^[ ]*everything[ =]*off[ ]*$/{ + everything = "off" + next +} +$0 ~ /^[ ]*everything[ =]*on[ ]*$/{ + everything = "on" + next +} +$0 ~ /^[ ]*logunsupported[ =]*0[ ]*$/{ + logunsupported = 0 + next +} +$0 ~ /^[ ]*logunsupported[ =]*1[ ]*$/{ + logunsupported = 1 + next +} +$1 == "deb" && $2 == "=" && NF == 3{ + deb = $3 + next +} + +# Preprocessing - this just copies the input file with lines +# that need preprocessing (just chunk at present) expanded +# The bare "pre" instead of "pre != 0" crashes under Sunos awk +pre && $1 != "chunk"{ + print >out + next +} + +# The first characters of the line determine how it is processed, +# leading spaces are ignored. In general tokens that are not +# keywords are the names of options. An option 'name' is +# controlled by the definition of the corresponding macros: +# +# PNG_name_SUPPORTED The option is turned on +# PNG_NO_name +# PNG_NO_name_SUPPORTED If the first macro is not defined +# either of these will turn the option off +# +# If none of these macros are defined the option is turned on, unless +# the keyword 'off' is given in a line relating to the option. The +# keyword 'on' can also be given, but it will be ignored (since it is +# the default.) +# +# In the syntax below a 'name' is indicated by "NAME", other macro +# values are indicated by "MACRO", as with "NAME" the leading "PNG_" +# is omitted, but in this case the "NO_" prefix and the "_SUPPORTED" +# suffix are never used. +# +# Each line is introduced by a keyword - the first non-space characters +# on the line. A line starting with a '#' is a comment - it is totally +# ignored. Keywords are as follows, a NAME, is simply a macro name +# without the leading PNG_, PNG_NO_ or the trailing _SUPPORTED. + +$1 ~ /^#/ || $0 ~ /^[ ]*$/{ + next +} + +# com +# The whole line is placed in the output file as a comment with +# the preceding 'com' removed +$1 == "com"{ + if (NF > 1) { + # sub(/^[ ]*com[ ]*/, "") + $1 = "" + print comment $0, cend >out + } else + print start end >out + next +} + +# version +# Inserts a version comment +$1 == "version" && NF == 1{ + if (version == "") { + print "ERROR: no version string set" + err = 1 # prevent END{} running + exit 1 + } + + print comment, version, cend >out + next +} + +# file output input protect +# Informational: the official name of the input file (without +# make generated local directories), the official name of the +# output file and, if required, a name to use in a protection +# macro for the contents. +$1 == "file" && NF >= 2{ + print comment, $2, cend >out + print comment, "Machine generated file: DO NOT EDIT", cend >out + if (NF >= 3) + print comment, "Derived from:", $3, cend >out + protect = $4 + if (protect != "") { + print start "#ifndef", protect end >out + print start "#define", protect end >out + } + next +} + +# option NAME ( (requires|enables|if) NAME* | on | off | disabled | +# sets SETTING VALUE+ )* +# +# Declares an option 'NAME' and describes its default setting (disabled) +# and its relationship to other options. The option is disabled +# unless *all* the options listed after 'requires' are set and at +# least one of the options listed after 'if' is set. If the +# option is set then it turns on all the options listed after 'enables'. +# +# Note that "enables" takes priority over the required/if/disabled/off +# setting of the target option. +# +# The definition file may list an option as 'disabled': off by default, +# otherwise the option is enabled: on by default. A later (and it must +# be later) entry may turn an option on or off explicitly. + +$1 == "option" && NF >= 2{ + opt = $2 + sub(/,$/,"",opt) + onoff = option[opt] # records current (and the default is "", enabled) + key = "" + istart = 3 + do { + if (istart == 1) { # continuation line + val = getline + + if (val != 1) { # error reading it + if (val == 0) + print "option", opt ": ERROR: missing continuation line" + else + print "option", opt ": ERROR: error reading continuation line" + + # This is a hard error + err = 1 # prevent END{} running + exit 1 + } + } + + for (i=istart; i<=NF; ++i) { + val=$(i) + sub(/,$/,"",val) + if (val == "on" || val == "off" || val == "disabled" || val =="enabled") { + key = "" + if (onoff != val) { + # on or off can zap disabled or enabled: + if (onoff == "" || (onoff == "disabled" || onoff == "enabled") && + (val == "on" || val == "off")) { + # It's easy to mis-spell the option when turning it + # on or off, so warn about it here: + if (onoff == "" && (val == "on" || val == "off")) { + print "option", opt ": ERROR: turning unrecognized option", val + # For the moment error out - it is safer + err = 1 # prevent END{} running + exit 1 + } + onoff = val + } else { + # Print a message, otherwise the error + # below is incomprehensible + print "option", opt ": currently", onoff ": attempt to turn", val + break + } + } + } else if (val == "requires" || val == "if" || val == "enables" || val =="sets") { + key = val + } else if (key == "requires") { + requires[opt] = requires[opt] " " val + } else if (key == "if") { + iffs[opt] = iffs[opt] " " val + } else if (key == "enables") { + enabledby[val] = enabledby[val] " " opt + } else if (key == "sets") { + sets[opt] = sets[opt] " " val + key = "setval" + set = val + } else if (key == "setval") { + setval[opt " " set] = setval[opt " " set] " " val + } else + break # bad line format + } + + istart = 1 + } while (i > NF && $0 ~ /,$/) + + if (i > NF) { + # Set the option, defaulting to 'enabled' + if (onoff == "") onoff = "enabled" + option[opt] = onoff + next + } + # Else fall through to the error handler +} + +# chunk NAME [requires OPT] [enables LIST] [on|off|disabled] +# Expands to the 'option' settings appropriate to the reading and +# writing of an ancillary PNG chunk 'NAME': +# +# option READ_NAME requires READ_ANCILLARY_CHUNKS [READ_OPT] +# option READ_NAME enables NAME LIST +# [option READ_NAME off] +# option WRITE_NAME requires WRITE_ANCILLARY_CHUNKS [WRITE_OPT] +# option WRITE_NAME enables NAME LIST +# [option WRITE_NAME off] + +pre != 0 && $1 == "chunk" && NF >= 2{ + # 'chunk' is handled on the first pass by writing appropriate + # 'option' lines into the intermediate file. + opt = $2 + sub(/,$/,"",opt) + onoff = "" + reqread = "" + reqwrite = "" + enables = "" + req = 0 + istart = 3 + do { + if (istart == 1) { # continuation line + val = getline + + if (val != 1) { # error reading it + if (val == 0) + print "chunk", opt ": ERROR: missing continuation line" + else + print "chunk", opt ": ERROR: error reading continuation line" + + # This is a hard error + err = 1 # prevent END{} running + exit 1 + } + } + + # read the keywords/additional OPTS + for (i=istart; i<=NF; ++i) { + val = $(i) + sub(/,$/,"",val) + if (val == "on" || val == "off" || val == "disabled") { + if (onoff != val) { + if (onoff == "") + onoff = val + else + break # on/off conflict + } + req = 0 + } else if (val == "requires") + req = 1 + else if (val == "enables") + req = 2 + else if (req == 1){ + reqread = reqread " READ_" val + reqwrite = reqwrite " WRITE_" val + } else if (req == 2) + enables = enables " " val + else + break # bad line: handled below + } + + istart = 1 + } while (i > NF && $0 ~ /,$/) + + if (i > NF) { + # Output new 'option' lines to the intermediate file (out) + print "option READ_" opt, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", opt enables , onoff >out + print "option WRITE_" opt, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", opt enables, onoff >out + next + } + # Else hit the error handler below - bad line format! +} + +# setting MACRO ( requires MACRO* )* [ default VALUE ] +# Behaves in a similar way to 'option' without looking for NO_ or +# _SUPPORTED; the macro is enabled if it is defined so long as all +# the 'requires' macros are also defined. The definitions may be +# empty, an error will be issued if the 'requires' macros are +# *not* defined. If given the 'default' value is used if the +# macro is not defined. The default value will be re-tokenised. +# (BTW: this is somewhat restrictive, it mainly exists for the +# support of non-standard configurations and numeric parameters, +# see the uses in scripts/options.dat + +$1 == "setting" && (NF == 2 || NF >= 3 && ($3 == "requires" || $3 == "default")){ + reqs = "" + deflt = "" + isdef = 0 + key = "" + for (i=3; i<=NF; ++i) + if ($(i) == "requires" || $(i) == "default") { + key = $(i) + if (key == "default") isdef = 1 + } else if (key == "requires") + reqs = reqs " " $(i) + else if (key == "default") + deflt = deflt " " $(i) + else + break # Format error, handled below + + setting[$2] = reqs + # NOTE: this overwrites a previous value silently + if (isdef && deflt == "") + deflt = " " # as a flag to force output + defaults[$2] = deflt + next +} + +# The order of the dependency lines (option, chunk, setting) is irrelevant +# - the 'enables', 'requires' and 'if' settings will be used to determine +# the correct order in the output and the final values in pnglibconf.h are +# not order dependent. 'requires' and 'if' entries take precedence over +# 'enables' from other options; if an option requires another option it +# won't be set regardless of any options that enable it unless the other +# option is also enabled. +# +# Similarly 'enables' trumps a NO_ definition in CFLAGS or pngusr.h +# +# For simplicity cycles in the definitions are regarded as errors, +# even if they are not ambiguous. +# A given NAME can be specified in as many 'option' lines as required, the +# definitions are additive. + +# For backwards compatibility equivalent macros may be listed thus: +# +# = [NO_]NAME MACRO +# Makes -DMACRO equivalent to -DPNG_NO_NAME or -DPNG_NAME_SUPPORTED +# as appropriate. +# +# The definition is injected into the C compiler input when encountered +# in the second pass (so all these definitions appear *after* the @ +# lines!) +# +# 'NAME' is as above, but 'MACRO' is the full text of the equivalent +# old, deprecated, macro. + +$1 == "=" && NF == 3{ + print "#ifdef PNG_" $3 >out + if ($2 ~ /^NO_/) + print "# define PNG_" $2 >out + else + print "# define PNG_" $2 "_SUPPORTED" >out + print "#endif" >out + next +} + +# Lines may be injected into the C compiler input by preceding them +# with an "@" character. The line is copied with just the leading +# @ removed. + +$1 ~ /^@/{ + # sub(/^[ ]*@/, "") + $1 = substr($1, 2) + print >out + next +} + +# Check for unrecognized lines, because of the preprocessing chunk +# format errors will be detected on the first pass independent of +# any other format errors. +{ + print "options.awk: bad line (" NR "):", $0 + err = 1 # prevent END{} running + exit 1 +} + +# For checking purposes names that start with "ok_" or "fail_" are +# not output to pnglibconf.h and must be either enabled or disabled +# respectively for the build to succeed. This allows interdependencies +# between options of the form "at least one of" or "at most one of" +# to be checked. For example: +# +# option FLOATING_POINT enables ok_math +# option FIXED_POINT enables ok_math +# This ensures that at least one of FLOATING_POINT and FIXED_POINT +# must be set for the build to succeed. +# +# option fail_math requires FLOATING_POINT FIXED_POINT +# This means the build will fail if *both* FLOATING_POINT and +# FIXED_POINT are set (this is an example; in fact both are allowed.) +# +# If all these options were given the build would require exactly one +# of the names to be enabled. + +END{ + # END{} gets run on an exit (a traditional awk feature) + if (err) exit 1 + + if (pre) { + # Record the final value of the variables + print "deb =", deb >out + if (everything != "") { + print "everything =", everything >out + } + print "logunsupported =", logunsupported >out + exit 0 + } + + # Do the options first (allowing options to set settings). The dependency + # tree is thus: + # + # name > name + # name requires name + # name if name + # name enabledby name + # + # First build a list 'tree' by option of all the things on which + # it depends. + print "" >out + print "/* OPTIONS */" >out + print comment, "options", cend >out + for (opt in enabledby) tree[opt] = 1 # may not be explicit options + for (opt in option) if (opt != "") { + o = option[opt] + # option should always be one of the following values + if (o != "on" && o != "off" && o != "disabled" && o != "enabled") { + print "internal option error (" o ")" + exit 1 + } + tree[opt] = "" # so unlisted options marked + } + for (opt in tree) if (opt != "") { + if (tree[opt] == 1) { + tree[opt] = "" + if (option[opt] != "") { + print "internal error (1)" + exit 1 + } + # Macros only listed in 'enables' remain off unless + # one of the enabling macros is on. + option[opt] = "disabled" + } + + split("", list) # clear 'list' + # Now add every requires, iffs or enabledby entry to 'list' + # so that we can add a unique list of requirements to tree[i] + split(requires[opt] iffs[opt] enabledby[opt], r) + for (i in r) list[r[i]] = 1 + for (i in list) tree[opt] = tree[opt] " " i + } + + # print the tree for extreme debugging + if (deb > 2) for (i in tree) if (i != "") print i, "depends-on" tree[i] + + # Ok, now check all options marked explicitly 'on' or 'off': + # + # If an option[opt] is 'on' then turn on all requires[opt] + # If an option[opt] is 'off' then turn off all enabledby[opt] + # + # Error out if we have to turn 'on' to an 'off' option or vice versa. + npending = 0 + for (opt in option) if (opt != "") { + if (option[opt] == "on" || option[opt] == "off") { + pending[++npending] = opt + } + } + + err = 0 # set on error + while (npending > 0) { + opt = pending[npending--] + if (option[opt] == "on") { + nreqs = split(requires[opt], r) + for (j=1; j<=nreqs; ++j) { + if (option[r[j]] == "off") { + print "option", opt, "turned on, but requirement", r[j], "is turned off" + err = 1 + } else if (option[r[j]] != "on") { + option[r[j]] = "on" + pending[++npending] = r[j] + } + } + } else { + if (option[opt] != "off") { + print "internal error (2)" + exit 1 + } + nreqs = split(enabledby[opt], r) + for (j=1; j<=nreqs; ++j) { + if (option[r[j]] == "on") { + print "option", opt, "turned off, but enabled by", r[j], "which is turned on" + err = 1 + } else if (option[r[j]] != "off") { + option[r[j]] = "off" + pending[++npending] = r[j] + } + } + } + } + if (err) exit 1 + + # Sort options: + print "PNG_DFN_START_SORT 2" >out + + # option[i] is now the complete list of all the tokens we may + # need to output, go through it as above, depth first. + finished = 0 + while (!finished) { + finished = 1 + movement = 0 # done nothing + for (i in option) if (!done[i]) { + nreqs = split(tree[i], r) + if (nreqs > 0) { + for (j=1; j<=nreqs; ++j) if (!done[r[j]]) { + break + } + if (j<=nreqs) { + finished = 0 + continue # next option + } + } + + # All the requirements have been processed, output + # this option. An option is _SUPPORTED if: + # + # all 'requires' are _SUPPORTED AND + # at least one of the 'if' options are _SUPPORTED AND + # EITHER: + # The name is _SUPPORTED (on the command line) + # OR: + # an 'enabledby' is _SUPPORTED + # OR: + # NO_name is not defined AND + # the option is not disabled; an option is disabled if: + # option == off + # option == disabled && everything != on + # option == "" && everything == off + if (deb) print "option", i + print "" >out + print "/* option:", i, option[i] >out + print " * requires: " requires[i] >out + print " * if: " iffs[i] >out + print " * enabled-by:" enabledby[i] >out + print " * sets: " sets[i], "*/" >out + print "#undef PNG_on" >out + print "#define PNG_on 1" >out + + # requires + nreqs = split(requires[i], r) + for (j=1; j<=nreqs; ++j) { + print "#ifndef PNG_" r[j] "_SUPPORTED" >out + print "# undef PNG_on /*!" r[j] "*/" >out + # This error appears in the final output if something + # was switched 'on' but the processing above to force + # the requires did not work + if (option[i] == "on") { + print error, i, "requires", r[j] end >out + } + print "#endif" >out + } + + # if + have_ifs = 0 + nreqs = split(iffs[i], r) + print "#undef PNG_no_if" >out + if (nreqs > 0) { + have_ifs = 1 + print "/* if" iffs[i], "*/" >out + print "#define PNG_no_if 1" >out + for (j=1; j<=nreqs; ++j) { + print "#ifdef PNG_" r[j] "_SUPPORTED" >out + print "# undef PNG_no_if /*" r[j] "*/" >out + print "#endif" >out + } + print "#ifdef PNG_no_if /*missing if*/" >out + print "# undef PNG_on" >out + # There is no checking above for this, because we + # don't know which 'if' to choose, so whine about + # it here: + if (option[i] == "on") { + print error, i, "needs one of:", iffs[i] end >out + } + print "#endif" >out + } + + print "#ifdef PNG_on /*requires, if*/" >out + # enables + print "# undef PNG_not_enabled" >out + print "# define PNG_not_enabled 1" >out + print " /* enabled by" enabledby[i], "*/" >out + nreqs = split(enabledby[i], r) + for (j=1; j<=nreqs; ++j) { + print "#ifdef PNG_" r[j] "_SUPPORTED" >out + print "# undef PNG_not_enabled /*" r[j] "*/" >out + # Oops, probably not intended (should be factored + # out by the checks above). + if (option[i] == "off") { + print error, i, "enabled by:", r[j] end >out + } + print "#endif" >out + } + + print "# ifndef PNG_" i "_SUPPORTED /*!command line*/" >out + print "# ifdef PNG_not_enabled /*!enabled*/" >out + # 'have_ifs' here means that everything = "off" still allows an 'if' on + # an otherwise enabled option to turn it on; otherwise the 'if' + # handling is effectively disabled by 'everything = off' + if (option[i] == "off" || option[i] == "disabled" && everything != "on" || option[i] == "enabled" && everything == "off" && !have_ifs) { + print "# undef PNG_on /*default off*/" >out + } else { + print "# ifdef PNG_NO_" i >out + print "# undef PNG_on /*turned off*/" >out + print "# endif" >out + print "# ifdef PNG_NO_" i "_SUPPORTED" >out + print "# undef PNG_on /*turned off*/" >out + print "# endif" >out + } + print "# endif /*!enabled*/" >out + print "# ifdef PNG_on" >out + # The _SUPPORTED macro must be defined so that dependent + # options output later work. + print "# define PNG_" i "_SUPPORTED" >out + print "# endif" >out + print "# endif /*!command line*/" >out + # If PNG_on is still set the option should be defined in + # pnglibconf.h + print "# ifdef PNG_on" >out + if (i ~ /^fail_/) { + print error, i, "is on: enabled by:" iffs[i] enabledby[i] ", requires" requires[i] end >out + } else if (i !~ /^ok_/) { + print def i sup >out + # Supported option, set required settings + nreqs = split(sets[i], r) + for (j=1; j<=nreqs; ++j) { + print "# ifdef PNG_set_" r[j] >out + # Some other option has already set a value: + print error, i, "sets", r[j] ": duplicate setting" end >out + print error, " previous value: " end "PNG_set_" r[j] >out + print "# else" >out + # Else set the default: note that this won't accept arbitrary + # values, the setval string must be acceptable to all the C + # compilers we use. That means it must be VERY simple; a number, + # a name or a string. + print "# define PNG_set_" r[j], setval[i " " r[j]] >out + print "# endif" >out + } + } + print "# endif /* definition */" >out + print "#endif /*requires, if*/" >out + if (logunsupported || i ~ /^ok_/) { + print "#ifndef PNG_on" >out + if (logunsupported) { + print und i une >out + } + if (i ~ /^ok_/) { + print error, i, "not enabled: requires:" requires[i] ", enabled by:" iffs[i] enabledby[i] end >out + } + print "#endif" >out + } + + done[i] = 1 + ++movement + } + + if (!finished && !movement) { + print "option: loop or missing option in dependency tree, cannot process:" + for (i in option) if (!done[i]) { + print " option", i, "depends on" tree[i], "needs:" + nreqs = split(tree[i], r) + if (nreqs > 0) for (j=1; j<=nreqs; ++j) if (!done[r[j]]) { + print " " r[j] + } + } + exit 1 + } + } + print "PNG_DFN_END_SORT" >out + print comment, "end of options", cend >out + + # Do the 'setting' values second, the algorithm the standard + # tree walk (O(1)) done in an O(2) while/for loop; iterations + # settings x depth, outputting the deepest required macros + # first. + print "" >out + print "/* SETTINGS */" >out + print comment, "settings", cend >out + # Sort (in dfn.awk) on field 2, the setting name + print "PNG_DFN_START_SORT 2" >out + finished = 0 + while (!finished) { + finished = 1 + movement = 0 # done nothing + for (i in setting) if (!doneset[i]) { + nreqs = split(setting[i], r) + if (nreqs > 0) { + # By default assume the requires values are options, but if there + # is no option with that name check for a setting + for (j=1; j<=nreqs; ++j) if (option[r[j]] == "" && !doneset[r[j]]) { + break + } + if (j<=nreqs) { + finished = 0 + continue # try a different setting + } + } + + # All the requirements have been processed, output + # this setting. + if (deb) print "setting", i + deflt = defaults[i] + # Remove any spurious trailing spaces + sub(/ *$/,"",deflt) + # A leading @ means leave it unquoted so the preprocessor + # can substitute the build time value + if (deflt ~ /^ @/) + deflt = " " subs substr(deflt, 3) sube + print "" >out + print "/* setting: ", i >out + print " * requires:" setting[i] >out + print " * default: ", defaults[i] deflt, "*/" >out + for (j=1; j<=nreqs; ++j) { + if (option[r[j]] != "") + print "#ifndef PNG_" r[j] "_SUPPORTED" >out + else + print "#ifndef PNG_" r[j] >out + print error, i, "requires", r[j] end >out + print "# endif" >out + } + # The precedence is: + # + # 1) External definition; trumps: + # 2) Option 'sets' value; trumps: + # 3) Setting 'default' + # + print "#ifdef PNG_" i >out + # PNG_ is defined, so substitute the value: + print def i, subs "PNG_" i sube end >out + print "#else /* use default */" >out + print "# ifdef PNG_set_" i >out + # Value from an option 'sets' argument + print def i, subs "PNG_set_" i sube end >out + # This is so that subsequent tests on the setting work: + print "# define PNG_" i, "1" >out + if (defaults[i] != "") { + print "# else /*default*/" >out + print def i deflt end >out + print "# define PNG_" i, "1" >out + } + print "# endif /* defaults */" >out + print "#endif /* setting", i, "*/" >out + + doneset[i] = 1 + ++movement + } + + if (!finished && !movement) { + print "setting: loop or missing setting in 'requires', cannot process:" + for (i in setting) if (!doneset[i]) { + print " setting", i, "requires" setting[i] + } + exit 1 + } + } + print "PNG_DFN_END_SORT" >out + print comment, "end of settings", cend >out + + # Regular end - everything looks ok + if (protect != "") { + print start "#endif", "/*", protect, "*/" end >out + } +} diff --git a/xs/src/png/libpng/scripts/pnglibconf.dfa b/xs/src/png/libpng/scripts/pnglibconf.dfa new file mode 100644 index 0000000000..b298a72f3b --- /dev/null +++ b/xs/src/png/libpng/scripts/pnglibconf.dfa @@ -0,0 +1,919 @@ +# scripts/pnglibconf.dfa - library build configuration control +# +@/*- pnglibconf.dfn intermediate file +@ * generated from scripts/pnglibconf.dfa +@ */ +# +com pnglibconf.h - library build configuration +com +version +com +com Copyright (c) 1998-2017 Glenn Randers-Pehrson +com +com This code is released under the libpng license. +com For conditions of distribution and use, see the disclaimer +com and license in png.h +com + +file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H + +# This file is preprocessed by scripts/options.awk and the +# C compiler to generate 'pnglibconf.h' - a list of all the +# configuration options. The file lists the various options +# that can *only* be specified during the libpng build; +# pnglibconf.h freezes the definitions selected for the specific +# build. +# +# The syntax is detailed in scripts/options.awk; this is a summary +# only: +# +# setting [requires ...] [default] +# #define PNG_ /* value comes from current setting */ +# option [requires ...] [if ...] [enables ...] [disabled] +# #define PNG__SUPPORTED if the requirements are met and +# enable the other options listed +# chunk [requires ...] [enables ...] [disabled] +# Enable chunk processing for the given ancillary chunk; any +# 'requires something' expands to READ_something for read and +# WRITE_something for write, but the enables list members are +# used as given (e.g. enables GAMMA just expands to that on the +# correspond READ_name and WRITE_name lines.) +# +# "," may be used to separate options on an 'option' line and is ignored; it +# doesn't change the meaning of the line. (NOT setting, where "," becomes +# part of the setting!) A comma at the end of an option line causes a +# continuation (the next line is included in the option too.) +# +# Note that the 'on' and 'off' keywords, while valid on both option +# and chunk, should not be used in this file because they force the +# relevant options on or off. + +#---------------------------------------------------------------------- + +# The following setting, option and chunk values can all be changed +# while building libpng: +# +# setting: change 'setting' lines to fine tune library performance; +# changes to the settings don't affect the libpng API functionally +# +# option: change 'option' lines to remove or add capabilities from +# or to the library; options change the library API +# +# chunk: change 'chunk' lines to remove capabilities to process +# optional ('ancillary') chunks. This does not prevent PNG +# decoding but does change the libpng API because some chunks +# will be ignored. +# +# There are three ways of disabling features, in no particular order: +# +# 1) Create 'pngusr.h', enter the required private build information +# detailed below and #define PNG_NO_